UNPKG

p5

Version:

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

2 lines 1.1 MB
const t=Math.PI,r="2.3.2",n="p2d",i="webgl",s="webgl2",o="webgpu",a="default",u="simple",l="full",h="crosshair",c="pointer",d="move",p="text",f="wait",m=t/2,g=t,y=t/4,v=2*t,b=2*t,x=t/180,_=180/t,w="corner",C="corners",E="radius",S="right",A="left",D="center",T="top",F="bottom",I="alphabetic",k=0,N=1,M=4,O=6,B=5,L="quads",P="quad_strip",R=7,V=8,U="close",z="open",j="chord",G="pie",$="square",H="butt",q="round",W="bevel",X="miter",Z="auto",Y="source-over",K="destination-out",J="lighter",Q="darken",ee="lighten",te="difference",re="subtract",ne="exclusion",ie="multiply",se="screen",oe="copy",ae="overlay",ue="hard-light",le="soft-light",he="color-dodge",ce="color-burn",de="threshold",pe="gray",fe="opaque",me="invert",ge="posterize",ye="dilate",ve="erode",be="blur",xe="normal",_e="WORD",we="linear",Ce="fill",Ee="texture",Se="image",Ae="linear_mipmap",De="nearest",Te="repeat",Fe="clamp",Ie="mirror",ke="flat",Ne="smooth",Me="#000000",Oe="#FFFFFF",Be="grid",Le="axes",Pe="contain",Re="cover",Ve="unsigned-byte",Ue="unsigned-int",ze="float",je="half-float",Ge=Symbol("include"),$e=Symbol("exclude"),He=Symbol("join");var qe=Object.freeze({__proto__:null,ADD:J,ALT:"Alt",ARROW:a,AUTO:Z,AXES:Le,BACKSPACE:"Backspace",BASELINE:I,BEVEL:W,BEZIER:"bezier",BLEND:Y,BLUR:be,BOLD:"bold",BOLDITALIC:"bold italic",BOTTOM:F,BURN:ce,CENTER:D,CHAR:"CHAR",CHORD:j,CLAMP:Fe,CLOSE:U,CONTAIN:Pe,CONTROL:"Control",CORNER:w,CORNERS:C,COVER:Re,CROSS:h,CURVE:"curve",DARKEST:Q,DEG_TO_RAD:x,DELETE:"Delete",DIFFERENCE:te,DILATE:ye,DODGE:he,DOWN_ARROW:"ArrowDown",EMPTY_PATH:7,ENTER:"Enter",ERODE:ve,ESCAPE:"Escape",EXCLUDE:$e,EXCLUSION:ne,FALLBACK:"fallback",FILL:Ce,FLAT:ke,FLOAT:ze,FULL:l,GRAY:pe,GRID:Be,HALF_FLOAT:je,HALF_PI:m,HAND:c,HARD_LIGHT:ue,IMAGE:Se,IMMEDIATE:"immediate",INCLUDE:Ge,INVERT:me,ITALIC:"italic",JOIN:He,LABEL:"label",LANDSCAPE:"landscape",LEFT:A,LEFT_ARROW:"ArrowLeft",LIGHTEST:ee,LINEAR:we,LINEAR_MIPMAP:Ae,LINES:N,LINE_LOOP:2,LINE_STRIP:3,MIRROR:Ie,MITER:X,MOVE:d,MULTIPLY:ie,NEAREST:De,NORMAL:xe,OPAQUE:fe,OPEN:z,OPTION:"Alt",OVERLAY:ae,P2D:n,P2DP3:"p2d-p3",PATH:8,PI:g,PIE:G,POINTS:k,PORTRAIT:"portrait",POSTERIZE:ge,PROJECT:$,QUADRATIC:"quadratic",QUADS:L,QUAD_STRIP:P,QUARTER_PI:y,RADIUS:E,RAD_TO_DEG:_,REMOVE:K,REPEAT:Te,REPLACE:oe,RETURN:"Enter",RIGHT:S,RIGHT_ARROW:"ArrowRight",ROUND:q,SCREEN:se,SHIFT:"Shift",SIMPLE:u,SMOOTH:Ne,SOFT_LIGHT:le,SQUARE:H,STROKE:"stroke",SUBTRACT:re,TAB:"Tab",TAU:v,TESS:"tess",TEXT:p,TEXTURE:Ee,THRESHOLD:de,TOP:T,TRIANGLES:4,TRIANGLE_FAN:6,TRIANGLE_STRIP:5,TWO_PI:b,UNSIGNED_BYTE:Ve,UNSIGNED_INT:Ue,UP_ARROW:"ArrowUp",VERSION:r,WAIT:f,WEBGL:i,WEBGL2:s,WEBGPU:o,WORD:_e,_CTX_MIDDLE:"middle",_DEFAULT_FILL:Oe,_DEFAULT_LEADMULT:1.25,_DEFAULT_STROKE:Me,_DEFAULT_TEXT_FILL:"#000000"});function We(e,t){t.applyMatrix=function(...e){let t=e[0]instanceof Object.getPrototypeOf(Uint8Array);return Array.isArray(e[0])||t?this._renderer.applyMatrix(...e[0]):this._renderer.applyMatrix(...e),this},t.resetMatrix=function(){return this._renderer.resetMatrix(),this},t.rotate=function(e,t){return this._renderer.rotate(this._toRadians(e),t)},t.rotateX=function(e){return this._assert3d("rotateX"),this._renderer.rotateX(this._toRadians(e))},t.rotateY=function(e){return this._assert3d("rotateY"),this._renderer.rotateY(this._toRadians(e))},t.rotateZ=function(e){return this._assert3d("rotateZ"),this._renderer.rotateZ(this._toRadians(e))},t.scale=function(t,r,n){if(t instanceof e.Vector){const e=t;t=e.x,r=e.y,n=e.z}else if(Array.isArray(t)){const e=t;t=e[0],r=e[1],n=e[2]||1}return isNaN(r)?r=n=t:isNaN(n)&&(n=1),this._renderer.scale(t,r,n)},t.shearX=function(e){const t=this._toRadians(e);return this._renderer.applyMatrix(1,0,Math.tan(t),1,0,0),this},t.shearY=function(e){const t=this._toRadians(e);return this._renderer.applyMatrix(1,Math.tan(t),0,1,0,0),this},t.translate=function(e,t,r){return this._renderer.isP3D?this._renderer.translate(e,t,r):this._renderer.translate(e,t)},t.push=function(){this._renderer.push()},t.pop=function(){this._renderer.pop()}}function Xe(e,t){t.noLoop=function(){this._loop=!1},t.loop=function(){this._loop||(this._loop=!0,this._setupDone&&this._draw())},t.isLooping=function(){return this._loop},t.redraw=async function(e){if(this._inUserDraw||!this._setupDone)return;let t=parseInt(e);(isNaN(t)||t<1)&&(t=1);const r=this._isGlobal?window:this;if("function"==typeof r.draw){void 0===r.setup&&r.scale(r._pixelDensity,r._pixelDensity);for(let e=0;e<t;e++){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?.())}}}function Ze(e,t,r){const i=[a,h,c,d,p,f],s="undefined"!=typeof window&&"undefined"!=typeof document;t._frameRate=0,t._lastFrameTime=globalThis.performance.now(),t._targetFrameRate=60;const o=s?window.print:null;let u=!1;function l(){return s?document.documentElement.clientWidth:0}function m(){return s?document.documentElement.clientHeight:0}r.presetup=function(){const e=["resize"];if(s)for(const t of e)window.addEventListener(t,this[`_on${t}`].bind(this),{passive:!1,signal:this._removeSignal})},t.print=function(...e){e.length||null===o?console.log(...e):u||(o(),window.confirm("You just tried to print the webpage. Do you want to prevent this from running again?")&&(u=!0))},t.frameCount=0,t.deltaTime=0,t.focused=!s||document.hasFocus(),t.cursor=function(e,t,r){let n="auto";const s=this._curElement.elt;if(void 0===e){let e=s.style.cursor;return e.length?e:"default"}if(i.includes(e))n=e;else if("string"==typeof e){let i="";"number"==typeof t&&(r="number"==typeof r?r:0,i=`${Math.max(t,0)} ${Math.max(r,0)}`),n="http://"===e.substring(0,7)||"https://"===e.substring(0,8)||/\.(cur|jpg|jpeg|gif|png|CUR|JPG|JPEG|GIF|PNG)$/.test(e)?`url(${e}) ${i}, auto`:e}s.style.cursor=n},t.frameRate=function(e){return"number"!=typeof e||e<0?this._frameRate:(this._targetFrameRate=e,0===e&&(this._frameRate=e),this)},t.getFrameRate=function(){return this.frameRate()},t.setFrameRate=function(e){return this.frameRate(e)},t.getTargetFrameRate=function(){return this._targetFrameRate},t.noCursor=function(){this._curElement.elt.style.cursor="none"},t.webglVersion=n,t.displayWidth=s?window.screen.width:0,t.displayHeight=s?window.screen.height:0,t.windowWidth=0,t.windowHeight=0,t._onresize=function(e){let t;this.windowWidth=l(),this.windowHeight=m(),"function"==typeof this._customActions.windowResized&&(t=this._customActions.windowResized(e),void 0===t||t||e.preventDefault())},t._updateWindowSize=function(){this.windowWidth=l(),this.windowHeight=m()},Object.defineProperty(t,"width",{configurable:!0,enumerable:!0,get(){return this._renderer?.width}}),Object.defineProperty(t,"height",{configurable:!0,enumerable:!0,get(){return this._renderer?.height}}),t.fullscreen=function(e){if(void 0===e)return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement;e?function(e){if(!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled))throw new Error("Fullscreen not enabled in this browser.");e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen&&e.msRequestFullscreen()}(document.documentElement):document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen&&document.msExitFullscreen()},t.pixelDensity=function(e){let t;return"number"==typeof e?(e!==this._renderer._pixelDensity&&(this._renderer._pixelDensity=e),t=this,this.resizeCanvas(this.width,this.height,!0)):t=this._renderer._pixelDensity,t},t.displayDensity=()=>window.devicePixelRatio,t.getURL=()=>location.href,t.getURLPath=()=>location.pathname.split("/").filter((e=>""!==e)),t.getURLParams=function(){const e=/[?&]([^&=]+)(?:[&=])([^&=]+)/gim;let t;const r={};for(;null!=(t=e.exec(location.search));)t.index===e.lastIndex&&e.lastIndex++,r[t[1]]=t[2];return r},t.worldToScreen=function(e){"number"==typeof e&&(e=this.createVector(...arguments));return this._renderer.getWorldToScreenMatrix().multiplyAndNormalizePoint(e)},t.screenToWorld=function(e){"number"==typeof e&&(e=this.createVector(...arguments));const t=this._renderer.getWorldToScreenMatrix();if(2===e.dimensions){let r=t.mat4[14]/t.mat4[15];e=this.createVector(e.x,e.y,r)}return t.invert(t).multiplyAndNormalizePoint(e)}}function Ye(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Ke(e,t,r=[0,0,0]){const n=Ye(e,t[0]),i=Ye(e,t[1]),s=Ye(e,t[2]);return r[0]=n,r[1]=i,r[2]=s,r}function Je(e){return"string"===Qe(e)}function Qe(e){return(Object.prototype.toString.call(e).match(/^\[object\s+(.*?)\]$/)[1]||"").toLowerCase()}function et(e,{precision:t=16,unit:r}){return tt(e)?"none":(e=+rt(e,t))+(r??"")}function tt(e){return null===e}function rt(e,t){if(0===e)return 0;let r=~~e,n=0;r&&t&&(n=1+~~Math.log10(Math.abs(r)));const i=10**(t-n);return Math.floor(e*i+.5)/i}function nt(e,t,r){return isNaN(e)?t:isNaN(t)?e:e+(t-e)*r}function it(e,t,r){return!e||!t||e===t||e[0]===t[0]&&e[1]===t[1]||isNaN(r)||null===r?r:nt(t[0],t[1],function(e,t,r){return(r-e)/(t-e)}(e[0],e[1],r))}function st(e,t,r){return Math.max(Math.min(r,t),e)}function ot(e,t){return Math.sign(e)===Math.sign(t)?e:-e}function at(e,t){return ot(Math.abs(e)**t,e)}function ut(e,t){return 0===t?0:e/t}function lt(e,t){if(e instanceof t)return!0;const r=t.name;for(;e;){const t=Object.getPrototypeOf(e),n=t?.constructor?.name;if(n===r)return!0;if(!n||"Object"===n)return!1;e=t}return!1}"undefined"!=typeof p5&&We(p5,p5.prototype),"undefined"!=typeof p5&&Xe(p5,p5.prototype),"undefined"!=typeof p5&&Ze(p5,p5.prototype);class ht{type;coordMeta;coordRange;range;constructor(e,t){if("object"==typeof e&&(this.coordMeta=e),t&&(this.coordMeta=t,this.coordRange=t.range??t.refRange),"string"==typeof e){let t=e.trim().match(/^(?<type><[a-z]+>)(\[(?<min>-?[.\d]+),\s*(?<max>-?[.\d]+)\])?$/);if(!t)throw new TypeError(`Cannot parse ${e} as a type definition.`);this.type=t.groups.type;let{min:r,max:n}=t.groups;(r||n)&&(this.range=[+r,+n])}}get computedRange(){return this.range?this.range:"<percentage>"===this.type?this.percentageRange():"<angle>"===this.type?[0,360]:null}get unit(){return"<percentage>"===this.type?"%":"<angle>"===this.type?"deg":""}resolve(e){if("<angle>"===this.type)return e;let t=this.computedRange,r=this.coordRange;return"<percentage>"===this.type&&(r??=this.percentageRange()),it(t,r,e)}serialize(e,t){let r="<percentage>"===this.type?this.percentageRange(100):this.computedRange,n=this.unit;return et(e=it(this.coordRange,r,e),{unit:n,precision:t})}toString(){let e=this.type;if(this.range){let[t="",r=""]=this.range;e+=`[${t},${r}]`}return e}percentageRange(e=1){let t;return t=this.coordMeta&&this.coordMeta.range||this.coordRange&&this.coordRange[0]>=0?[0,1]:[-1,1],[t[0]*e,t[1]*e]}static get(e,t){return lt(e,this)?e:new this(e,t)}}const ct=Symbol("instance");class dt{type;name;spaceCoords;coords;id;alpha;constructor(e,t=e.space){e[ct]=this,this.type="function",this.name="color",Object.assign(this,e),this.space=t,"custom"!==this.type&&(this.spaceCoords=Object.values(t.coords),this.coords||(this.coords=this.spaceCoords.map((e=>{let t=["<number>","<percentage>"];return"angle"===e.type&&t.push("<angle>"),t}))),this.coords=this.coords.map(((e,t)=>{let r=this.spaceCoords[t];return"string"==typeof e&&(e=e.trim().split(/\s*\|\s*/)),e.map((e=>ht.get(e,r)))})))}serializeCoords(e,t,r){return r=e.map(((e,t)=>ht.get(r?.[t]??this.coords[t][0],this.spaceCoords[t]))),e.map(((e,n)=>r[n].serialize(e,t)))}coerceCoords(e,t){return Object.entries(this.space.coords).map((([r,n],i)=>{let s=e[i];if(tt(s)||isNaN(s))return s;let o=t[i],a=this.coords[i].find((e=>e.type==o));if(!a){let e=n.name||r;throw new TypeError(`${o??s?.raw??s} not allowed for ${e} in ${this.name}()`)}return s=a.resolve(s),a.range&&(t[i]=a.toString()),s}))}canSerialize(){return"function"===this.type||this.serialize}parse(e){return null}static get(e,...t){return!e||lt(e,this)?e:e[ct]?e[ct]:new dt(e,...t)}}const pt=new class{add(e,t,r){if("string"==typeof arguments[0])(Array.isArray(e)?e:[e]).forEach((function(e){this[e]=this[e]||[],t&&this[e][r?"unshift":"push"](t)}),this);else for(var e in arguments[0])this.add(e,arguments[0][e],arguments[1])}run(e,t){this[e]=this[e]||[],this[e].forEach((function(e){e.call(t&&t.context?t.context:t,t)}))}},ft={D50:[.3457/.3585,1,.2958/.3585],D65:[.3127/.329,1,.3583/.329]};function mt(e){return Array.isArray(e)?e:ft[e]}function gt(e,t,r,n={}){if(e=mt(e),t=mt(t),!e||!t)throw new TypeError(`Missing white point to convert ${e?"":"from"}${e||t?"":"/"}${t?"":"to"}`);if(e===t)return r;let i={W1:e,W2:t,XYZ:r,options:n};if(pt.run("chromatic-adaptation-start",i),i.M||(i.W1===ft.D65&&i.W2===ft.D50?i.M=[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]]:i.W1===ft.D50&&i.W2===ft.D65&&(i.M=[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]])),pt.run("chromatic-adaptation-end",i),i.M)return Ke(i.XYZ,i.M);throw new TypeError("Only Bradford CAT with white points D50 and D65 supported for now.")}var yt={gamut_mapping:"css",precision:5,deltaE:"76",verbose:"test"!==globalThis?.process?.env?.NODE_ENV?.toLowerCase(),warn:function(e){this.verbose&&globalThis?.console?.warn?.(e)}};function vt(e,t){let r,n={str:String(e)?.trim(),options:t};if(pt.run("parse-start",n),n.color)return n.color;n.parsed=function(e){if(!e)return;e=e.trim();let t=e.match(xt.function);if(t){let e=[],r=[],n=!1,i=t[1].toLowerCase(),s=t[2].replace(xt.singleArgument,((t,s)=>{let{value:o,meta:a}=function(e){let t={},r=e.match(xt.unitValue)?.[0],n=t.raw=e;r?(t.type="%"===r?"<percentage>":"<angle>",t.unit=r,t.unitless=Number(n.slice(0,-r.length)),n=t.unitless*bt[r]):xt.number.test(n)?(n=Number(n),t.type="<number>"):"none"===n?n=null:"NaN"===n||"calc(NaN)"===n?(n=NaN,t.type="<number>"):t.type="<ident>";return{value:n,meta:t}}(s);return(t.startsWith("/")||"color"!==i&&3===e.length)&&(n=!0),e.push(o),r.push(a),""}));return{name:i,args:e,argMeta:r,lastAlpha:n,commas:s.includes(","),rawName:t[1],rawArgs:t[2]}}}(n.str);let i=n.options?n.options.parseMeta??n.options.meta:null;if(n.parsed){let t,s,o=n.parsed.name,a=n.parsed.args,u=a.map(((e,t)=>n.parsed.argMeta[t]?.type));if("color"===o){let r=a.shift();u.shift();let i=r.startsWith("--")?r.substring(2):`--${r}`,l=[r,i];if(t=wt.findFormat({name:o,id:l,type:"function"}),!t){let t,s=r in wt.registry?r:i;if(s in wt.registry){let n=wt.registry[s].formats?.color?.id;if(n){t=`Did you mean ${e.replace("color("+r,"color("+n)}?`}}throw new TypeError(`Cannot parse ${n.str}. `+(t??"Missing a plugin?"))}s=t.space,t.id.startsWith("--")&&!r.startsWith("--")&&yt.warn(`${s.name} is a non-standard space and not currently supported in the CSS spec. Use prefixed color(${t.id}) instead of color(${r}).`),r.startsWith("--")&&!t.id.startsWith("--")&&yt.warn(`${s.name} is a standard space and supported in the CSS spec. Use color(${t.id}) instead of prefixed color(${r}).`)}else t=wt.findFormat({name:o,type:"function"}),s=t.space;i&&Object.assign(i,{format:t,formatId:t.name,types:u,commas:n.parsed.commas});let l=1;n.parsed.lastAlpha&&(l=n.parsed.args.pop(),i&&(i.alphaType=u.pop()));let h=t.coords.length;if(a.length!==h)throw new TypeError(`Expected ${h} coordinates for ${s.id} in ${n.str}), got ${a.length}`);a=t.coerceCoords(a,u),r={spaceId:s.id,coords:a,alpha:l}}else e:for(let e of wt.all)for(let t in e.formats){let s=e.formats[t];if("custom"!==s.type)continue;if(s.test&&!s.test(n.str))continue;let o=e.getFormat(s),a=o.parse(n.str);if(a){i&&Object.assign(i,{format:o,formatId:t}),r=a;break e}}if(!r)throw new TypeError(`Could not parse ${e} as a color. Missing a plugin?`);return r.alpha=tt(r.alpha)?r.alpha:void 0===r.alpha?1:st(0,r.alpha,1),r}const bt={"%":.01,deg:1,grad:.9,rad:180/Math.PI,turn:360},xt={function:/^([a-z]+)\(((?:calc\(NaN\)|.)+?)\)$/i,number:/^([-+]?(?:[0-9]*\.)?[0-9]+(e[-+]?[0-9]+)?)$/i,unitValue:RegExp(`(${Object.keys(bt).join("|")})$`),singleArgument:/\/?\s*(none|NaN|calc\(NaN\)|[-+\w.]+(?:%|deg|g?rad|turn)?)/g};function _t(e,t){if(Array.isArray(e))return e.map((e=>_t(e,t)));if(!e)throw new TypeError("Empty color reference");Je(e)&&(e=vt(e,t));let r=e.space||e.spaceId;return"string"==typeof r&&(e.space=wt.get(r)),void 0===e.alpha&&(e.alpha=1),e}class wt{constructor(e){this.id=e.id,this.name=e.name,this.base=e.base?wt.get(e.base):null,this.aliases=e.aliases,this.base&&(this.fromBase=e.fromBase,this.toBase=e.toBase);let t=e.coords??this.base.coords;for(let e in t)"name"in t[e]||(t[e].name=e);this.coords=t;let r=e.white??this.base.white??"D65";this.white=mt(r),this.formats=e.formats??{};for(let e in this.formats){let t=this.formats[e];t.type||="function",t.name||=e}this.formats.color?.id||(this.formats.color={...this.formats.color??{},id:e.cssId||this.id}),e.gamutSpace?this.gamutSpace="self"===e.gamutSpace?this:wt.get(e.gamutSpace):this.isPolar?this.gamutSpace=this.base:this.gamutSpace=this,this.gamutSpace.isUnbounded&&(this.inGamut=(e,t)=>!0),this.referred=e.referred,Object.defineProperty(this,"path",{value:Ct(this).reverse(),writable:!1,enumerable:!0,configurable:!0}),pt.run("colorspace-init-end",this)}inGamut(e,{epsilon:t=75e-6}={}){if(!this.equals(this.gamutSpace))return e=this.to(this.gamutSpace,e),this.gamutSpace.inGamut(e,{epsilon:t});let r=Object.values(this.coords);return e.every(((e,n)=>{let i=r[n];if("angle"!==i.type&&i.range){if(tt(e))return!0;let[r,n]=i.range;return(void 0===r||e>=r-t)&&(void 0===n||e<=n+t)}return!0}))}get isUnbounded(){return Object.values(this.coords).every((e=>!("range"in e)))}get cssId(){return this.formats?.color?.id||this.id}get isPolar(){for(let e in this.coords)if("angle"===this.coords[e].type)return!0;return!1}getFormat(e){if(!e)return null;"default"===e?e=Object.values(this.formats)[0]:"string"==typeof e&&(e=this.formats[e]);let t=dt.get(e,this);return t!==e&&e.name in this.formats&&(this.formats[e.name]=t),t}equals(e){return!!e&&(this===e||this.id===e||this.id===e.id)}to(e,t){if(1===arguments.length){const r=_t(e);[e,t]=[r.space,r.coords]}if(e=wt.get(e),this.equals(e))return t;t=t.map((e=>tt(e)?0:e));let r,n,i=this.path,s=e.path;for(let e=0;e<i.length&&i[e].equals(s[e]);e++)r=i[e],n=e;if(!r)throw new Error(`Cannot convert between color spaces ${this} and ${e}: no connection space was found`);for(let e=i.length-1;e>n;e--)t=i[e].toBase(t);for(let e=n+1;e<s.length;e++)t=s[e].fromBase(t);return t}from(e,t){if(1===arguments.length){const r=_t(e);[e,t]=[r.space,r.coords]}return(e=wt.get(e)).to(this,t)}toString(){return`${this.name} (${this.id})`}getMinCoords(){let e=[];for(let t in this.coords){let r=this.coords[t],n=r.range||r.refRange;e.push(n?.min??0)}return e}static registry={};static get all(){return[...new Set(Object.values(wt.registry))]}static register(e,t){if(1===arguments.length&&(e=(t=arguments[0]).id),t=this.get(t),this.registry[e]&&this.registry[e]!==t)throw new Error(`Duplicate color space registration: '${e}'`);if(this.registry[e]=t,1===arguments.length&&t.aliases)for(let e of t.aliases)this.register(e,t);return t}static get(e,...t){if(!e||lt(e,this))return e;if("string"===Qe(e)){let t=wt.registry[e.toLowerCase()];if(!t)throw new TypeError(`No color space found with id = "${e}"`);return t}if(t.length)return wt.get(...t);throw new TypeError(`${e} is not a valid color space`)}static findFormat(e,t=wt.all){if(!e)return null;"string"==typeof e&&(e={name:e});for(let r of t)for(let[t,n]of Object.entries(r.formats)){n.name??=t,n.type??="function";let i=!(e.name&&n.name!==e.name||e.type&&n.type!==e.type);if(e.id){let t=n.ids||[n.id],r=Array.isArray(e.id)?e.id:[e.id];i&&=r.some((e=>t.includes(e)))}if(i){let e=dt.get(n,r);return e!==n&&(r.formats[n.name]=e),e}}return null}static resolveCoord(e,t){let r,n,i=Qe(e);if("string"===i?e.includes(".")?[r,n]=e.split("."):[r,n]=[,e]:Array.isArray(e)?[r,n]=e:(r=e.space,n=e.coordId),r=wt.get(r),r||(r=t),!r)throw new TypeError(`Cannot resolve coordinate reference ${e}: No color space specified and relative references are not allowed here`);if(i=Qe(n),"number"===i||"string"===i&&n>=0){let e=Object.entries(r.coords)[n];if(e)return{space:r,id:e[0],index:n,...e[1]}}r=wt.get(r);let s=n.toLowerCase(),o=0;for(let e in r.coords){let t=r.coords[e];if(e.toLowerCase()===s||t.name?.toLowerCase()===s)return{space:r,id:e,index:o,...t};o++}throw new TypeError(`No "${n}" coordinate found in ${r.name}. Its coordinates are: ${Object.keys(r.coords).join(", ")}`)}static DEFAULT_FORMAT={type:"functions",name:"color"}}function Ct(e){let t=[e];for(let r=e;r=r.base;)t.push(r);return t}var Et=new wt({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"]});class St extends wt{constructor(e){e.coords||(e.coords={r:{range:[0,1],name:"Red"},g:{range:[0,1],name:"Green"},b:{range:[0,1],name:"Blue"}}),e.base||(e.base=Et),e.toXYZ_M&&e.fromXYZ_M&&(e.toBase??=t=>{let r=Ke(t,e.toXYZ_M);return this.white!==this.base.white&&(r=gt(this.white,this.base.white,r)),r},e.fromBase??=t=>Ke(t=gt(this.base.white,this.white,t),e.fromXYZ_M)),e.referred??="display",super(e)}}function At(e,t){e=_t(e);let r,n=wt.get(t,t?.space),i=t?.precision;return r=!n||e.space.equals(n)?e.coords.slice():n.from(e),void 0===i?r:r.map((e=>rt(e,i)))}function Dt(e,t){if(e=_t(e),"alpha"===t)return e.alpha??1;let{space:r,index:n}=wt.resolveCoord(t,e.space);return At(e,r)[n]}function Tt(e,t,r,n){return e=_t(e),Array.isArray(t)&&([t,r,n]=[e.space,t,r]),t=wt.get(t),e.coords=t===e.space?r.slice():t.to(e.space,r),void 0!==n&&(e.alpha=n),e}function Ft(e,t,r){if(e=_t(e),2===arguments.length&&"object"===Qe(arguments[1])){let t=arguments[1];for(let r in t)Ft(e,r,t[r])}else if("function"==typeof r&&(r=r(Dt(e,t))),"alpha"===t)e.alpha=r;else{let{space:n,index:i}=wt.resolveCoord(t,e.space),s=At(e,n);s[i]=r,Tt(e,n,s)}return e}Tt.returns="color",Ft.returns="color";var It=new wt({id:"xyz-d50",name:"XYZ D50",white:"D50",base:Et,fromBase:e=>gt(Et.white,"D50",e),toBase:e=>gt("D50",Et.white,e)});const kt=216/24389,Nt=24/116,Mt=24389/27;let Ot=ft.D50;var Bt=new wt({id:"lab",name:"Lab",coords:{l:{refRange:[0,100],name:"Lightness"},a:{refRange:[-125,125]},b:{refRange:[-125,125]}},white:Ot,base:It,fromBase(e){let t=e.map(((e,t)=>e/Ot[t])),r=t.map((e=>e>kt?Math.cbrt(e):(Mt*e+16)/116));return[116*r[1]-16,500*(r[0]-r[1]),200*(r[1]-r[2])]},toBase(e){let[t,r,n]=e,i=[];return i[1]=(t+16)/116,i[0]=r/500+i[1],i[2]=i[1]-n/200,[i[0]>Nt?Math.pow(i[0],3):(116*i[0]-16)/Mt,e[0]>8?Math.pow((e[0]+16)/116,3):e[0]/Mt,i[2]>Nt?Math.pow(i[2],3):(116*i[2]-16)/Mt].map(((e,t)=>e*Ot[t]))},formats:{lab:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <percentage>"]}}});function Lt(e){return"number"!=typeof e?e:(e%360+360)%360}var Pt=new wt({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:Bt,fromBase(e){if(void 0===this.ε){let e=Object.values(this.base.coords)[1].refRange,t=e[1]-e[0];this.ε=t/1e5}let[t,r,n]=e,i=Math.abs(r)<this.ε&&Math.abs(n)<this.ε,s=i?null:Lt(180*Math.atan2(n,r)/Math.PI);return[t,i?0:Math.sqrt(r**2+n**2),s]},toBase(e){let[t,r,n]=e,i=null,s=null;return tt(n)||(r=r<0?0:r,i=r*Math.cos(n*Math.PI/180),s=r*Math.sin(n*Math.PI/180)),[t,i,s]},formats:{lch:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <angle>"]}}});const Rt=25**7,Vt=Math.PI,Ut=180/Vt,zt=Vt/180;function jt(e){const t=e*e;return t*t*t*e}function Gt(e,t,{kL:r=1,kC:n=1,kH:i=1}={}){[e,t]=_t([e,t]);let[s,o,a]=Bt.from(e),u=Pt.from(Bt,[s,o,a])[1],[l,h,c]=Bt.from(t),d=Pt.from(Bt,[l,h,c])[1];u<0&&(u=0),d<0&&(d=0);let p=jt((u+d)/2),f=.5*(1-Math.sqrt(p/(p+Rt))),m=(1+f)*o,g=(1+f)*h,y=Math.sqrt(m**2+a**2),v=Math.sqrt(g**2+c**2),b=0===m&&0===a?0:Math.atan2(a,m),x=0===g&&0===c?0:Math.atan2(c,g);b<0&&(b+=2*Vt),x<0&&(x+=2*Vt),b*=Ut,x*=Ut;let _,w=l-s,C=v-y,E=x-b,S=b+x,A=Math.abs(E);y*v==0?_=0:A<=180?_=E:E>180?_=E-360:E<-180?_=E+360:yt.warn("the unthinkable has happened");let D,T=2*Math.sqrt(v*y)*Math.sin(_*zt/2),F=(s+l)/2,I=(y+v)/2,k=jt(I);D=y*v==0?S:A<=180?S/2:S<360?(S+360)/2:(S-360)/2;let N=(F-50)**2,M=1+.015*N/Math.sqrt(20+N),O=1+.045*I,B=1;B-=.17*Math.cos((D-30)*zt),B+=.24*Math.cos(2*D*zt),B+=.32*Math.cos((3*D+6)*zt),B-=.2*Math.cos((4*D-63)*zt);let L=1+.015*I*B,P=30*Math.exp(-1*((D-275)/25)**2),R=2*Math.sqrt(k/(k+Rt)),V=(w/(r*M))**2;return V+=(C/(n*O))**2,V+=(T/(i*L))**2,V+=-1*Math.sin(2*P*zt)*R*(C/(n*O))*(T/(i*L)),Math.sqrt(V)}const $t=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],Ht=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],qt=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],Wt=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]];var Xt=new wt({id:"oklab",name:"Oklab",coords:{l:{refRange:[0,1],name:"Lightness"},a:{refRange:[-.4,.4]},b:{refRange:[-.4,.4]}},white:"D65",base:Et,fromBase(e){let t=Ke(e,$t);return t[0]=Math.cbrt(t[0]),t[1]=Math.cbrt(t[1]),t[2]=Math.cbrt(t[2]),Ke(t,qt,t)},toBase(e){let t=Ke(e,Wt);return t[0]=t[0]**3,t[1]=t[1]**3,t[2]=t[2]**3,Ke(t,Ht,t)},formats:{oklab:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <percentage>"]}}});function Zt(e,t){[e,t]=_t([e,t]);let[r,n,i]=Xt.from(e),[s,o,a]=Xt.from(t),u=r-s,l=n-o,h=i-a;return Math.sqrt(u**2+l**2+h**2)}function Yt(e,t,{epsilon:r=75e-6}={}){e=_t(e),t||(t=e.space),t=wt.get(t);let n=e.coords;return t!==e.space&&(n=t.from(e)),t.inGamut(n,{epsilon:r})}function Kt(e){return{space:e.space,coords:e.coords.slice(),alpha:e.alpha}}const Jt=Math.PI/180;var Qt=new wt({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:Et,fromBase:e=>e.map((e=>203*e)),toBase:e=>e.map((e=>e/203))});const er=1.15,tr=.66,rr=2610/16384,nr=16384/2610,ir=.8359375,sr=2413/128,or=18.6875,ar=1.7*2523/32,ur=32/(1.7*2523),lr=-.56,hr=16295499532821565e-27,cr=[[.41478972,.579999,.014648],[-.20151,1.120649,.0531008],[-.0166008,.2648,.6684799]],dr=[[1.9242264357876067,-1.0047923125953657,.037651404030618],[.35031676209499907,.7264811939316552,-.06538442294808501],[-.09098281098284752,-.3127282905230739,1.5227665613052603]],pr=[[.5,.5,0],[3.524,-4.066708,.542708],[.199076,1.096799,-1.295875]],fr=[[1,.13860504327153927,.05804731615611883],[1,-.1386050432715393,-.058047316156118904],[1,-.09601924202631895,-.811891896056039]];var mr=new wt({id:"jzazbz",name:"Jzazbz",coords:{jz:{refRange:[0,1],name:"Jz"},az:{refRange:[-.21,.21]},bz:{refRange:[-.21,.21]}},base:Qt,fromBase(e){let[t,r,n]=e,i=Ke([er*t-(er-1)*n,tr*r-(tr-1)*t,n],cr).map((function(e){let t=ir+sr*at(e/1e4,rr),r=1+or*at(e/1e4,rr);return at(t/r,ar)})),[s,o,a]=Ke(i,pr);return[(1+lr)*s/(1+lr*s)-hr,o,a]},toBase(e){let[t,r,n]=e,i=Ke([(t+hr)/(1+lr-lr*(t+hr)),r,n],fr).map((function(e){let t=ir-at(e,ur),r=or*at(e,ur)-sr;return 1e4*at(t/r,nr)})),[s,o,a]=Ke(i,dr),u=(s+(er-1)*a)/er;return[u,(o+(tr-1)*u)/tr,a]},formats:{jzazbz:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <percentage>"]}}}),gr=new wt({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:mr,fromBase:Pt.fromBase,toBase:Pt.toBase,formats:{jzczhz:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <angle>"]}}});const yr=.8359375,vr=2413/128,br=18.6875,xr=2610/16384,_r=2523/32,wr=16384/2610,Cr=32/2523,Er=[[.3592832590121217,.6976051147779502,-.035891593232029],[-.1920808463704993,1.100476797037432,.0753748658519118],[.0070797844607479,.0748396662186362,.8433265453898765]],Sr=[[.5,.5,0],[6610/4096,-13613/4096,7003/4096],[17933/4096,-17390/4096,-543/4096]],Ar=[[.9999999999999998,.0086090370379328,.111029625003026],[.9999999999999998,-.0086090370379328,-.1110296250030259],[.9999999999999998,.5600313357106791,-.3206271749873188]],Dr=[[2.0701522183894223,-1.3263473389671563,.2066510476294053],[.3647385209748072,.6805660249472273,-.0453045459220347],[-.0497472075358123,-.0492609666966131,1.1880659249923042]];var Tr=new wt({id:"ictcp",name:"ICTCP",coords:{i:{refRange:[0,1],name:"I"},ct:{refRange:[-.5,.5],name:"CT"},cp:{refRange:[-.5,.5],name:"CP"}},base:Qt,fromBase:e=>function(e){let t=e.map((function(e){return((yr+vr*(e/1e4)**xr)/(1+br*(e/1e4)**xr))**_r}));return Ke(t,Sr)}(Ke(e,Er)),toBase(e){let t=function(e){let t=Ke(e,Ar),r=t.map((function(e){return 1e4*(Math.max(e**Cr-yr,0)/(vr-br*e**Cr))**wr}));return r}(e);return Ke(t,Dr)},formats:{ictcp:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <percentage>"]}}});const Fr=ft.D65,Ir=1/.42,kr=2*Math.PI,Nr=[[.401288,.650173,-.051461],[-.250268,1.204414,.045854],[-.002079,.048952,.953127]],Mr=[[1.8620678550872327,-1.0112546305316843,.14918677544445175],[.38752654323613717,.6214474419314753,-.008973985167612518],[-.015841498849333856,-.03412293802851557,1.0499644368778496]],Or=[[460,451,288],[460,-891,-261],[460,-220,-6300]],Br={dark:[.8,.525,.8],dim:[.9,.59,.9],average:[1,.69,1]},Lr={h:[20.14,90,164.25,237.53,380.14],e:[.8,.7,1,1.2,.8],H:[0,100,200,300,400]},Pr=180/Math.PI,Rr=Math.PI/180;function Vr(e,t){return e.map((e=>{const r=at(t*Math.abs(e)*.01,.42);return 400*ot(r,e)/(r+27.13)}))}function Ur(e,t,r,n,i){const s={};s.discounting=i,s.refWhite=e,s.surround=n;const o=e.map((e=>100*e));s.la=t,s.yb=r;const a=o[1],u=Ke(o,Nr);let l=Br[s.surround];const h=l[0];s.c=l[1],s.nc=l[2];const c=(1/(5*s.la+1))**4;s.fl=c*s.la+.1*(1-c)*(1-c)*Math.cbrt(5*s.la),s.flRoot=s.fl**.25,s.n=s.yb/a,s.z=1.48+Math.sqrt(s.n),s.nbb=.725*s.n**-.2,s.ncb=s.nbb;const d=Math.max(Math.min(h*(1-1/3.6*Math.exp((-s.la-42)/92)),1),0);s.dRgb=u.map((e=>nt(1,a/e,d))),s.dRgbInv=s.dRgb.map((e=>1/e));const p=u.map(((e,t)=>e*s.dRgb[t])),f=Vr(p,s.fl);return s.aW=s.nbb*(2*f[0]+f[1]+.05*f[2]),s}const zr=Ur(Fr,64/Math.PI*.2,20,"average",!1);function jr(e,t){if(!(void 0!==e.J^void 0!==e.Q))throw new Error("Conversion requires one and only one: 'J' or 'Q'");if(!(void 0!==e.C^void 0!==e.M^void 0!==e.s))throw new Error("Conversion requires one and only one: 'C', 'M' or 's'");if(!(void 0!==e.h^void 0!==e.H))throw new Error("Conversion requires one and only one: 'h' or 'H'");if(0===e.J||0===e.Q)return[0,0,0];let r=0;r=void 0!==e.h?Lt(e.h)*Rr:function(e){let t=(e%400+400)%400;const r=Math.floor(.01*t);t%=100;const[n,i]=Lr.h.slice(r,r+2),[s,o]=Lr.e.slice(r,r+2);return Lt((t*(o*n-s*i)-100*n*o)/(t*(o-s)-100*o))}(e.H)*Rr;const n=Math.cos(r),i=Math.sin(r);let s=0;void 0!==e.J?s=.1*at(e.J,.5):void 0!==e.Q&&(s=.25*t.c*e.Q/((t.aW+4)*t.flRoot));let o=0;void 0!==e.C?o=e.C/s:void 0!==e.M?o=e.M/t.flRoot/s:void 0!==e.s&&(o=4e-4*e.s**2*(t.aW+4)/t.c);const a=at(o*Math.pow(1.64-Math.pow(.29,t.n),-.73),10/9),u=.25*(Math.cos(r+2)+3.8),l=t.aW*at(s,2/t.c/t.z),h=5e4/13*t.nc*t.ncb*u,c=l/t.nbb,d=23*(c+.305)*ut(a,23*h+a*(11*n+108*i)),p=function(e,t){const r=100/t*2588.068098016295;return e.map((e=>{const t=Math.abs(e);return ot(r*at(t/(400-t),Ir),e)}))}(Ke([c,d*n,d*i],Or).map((e=>1*e/1403)),t.fl);return Ke(p.map(((e,r)=>e*t.dRgbInv[r])),Mr).map((e=>e/100))}function Gr(e,t){const r=Vr(Ke(e.map((e=>100*e)),Nr).map(((e,r)=>e*t.dRgb[r])),t.fl),n=r[0]+(-12*r[1]+r[2])/11,i=(r[0]+r[1]-2*r[2])/9,s=(Math.atan2(i,n)%kr+kr)%kr,o=.25*(Math.cos(s+2)+3.8),a=at(5e4/13*t.nc*t.ncb*ut(o*Math.sqrt(n**2+i**2),r[0]+r[1]+1.05*r[2]+.305),.9)*Math.pow(1.64-Math.pow(.29,t.n),.73),u=at(t.nbb*(2*r[0]+r[1]+.05*r[2])/t.aW,.5*t.c*t.z),l=100*at(u,2),h=4/t.c*u*(t.aW+4)*t.flRoot,c=a*u,d=c*t.flRoot,p=Lt(s*Pr),f=function(e){let t=Lt(e);t<=Lr.h[0]&&(t+=360);const r=function(e,t,r=0,n=e.length){for(;r<n;){const i=r+n>>1;e[i]<t?r=i+1:n=i}return r}(Lr.h,t)-1,[n,i]=Lr.h.slice(r,r+2),[s,o]=Lr.e.slice(r,r+2),a=(t-n)/s;return Lr.H[r]+100*a/(a+(i-t)/o)}(p);return{J:l,C:c,h:p,s:50*at(t.c*a/(t.aW+4),.5),Q:h,M:d,H:f}}new wt({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:Et,fromBase(e){void 0===this.ε&&(this.ε=Object.values(this.coords)[1].refRange[1]/1e5);const t=Gr(e,zr),r=Math.abs(t.M)<this.ε;return[t.J,r?0:t.M,r?null:t.h]},toBase:e=>jr({J:e[0],M:e[1],h:e[2]},zr)});const $r=216/24389,Hr=24389/27;function qr(e){return e>8?Math.pow((e+16)/116,3):e/Hr}function Wr(e,t){const r=116*((n=e[1])>$r?Math.cbrt(n):(Hr*n+16)/116)-16;var n;if(0===r)return[0,0,0];const i=Gr(e,Xr);return[Lt(i.h),i.C,r]}const Xr=Ur(ft.D65,200/Math.PI*qr(50),100*qr(50),"average",!1);var Zr=new wt({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:Et,fromBase(e){void 0===this.ε&&(this.ε=Object.values(this.coords)[1].refRange[1]/1e5);let t=Wr(e);return t[1]<this.ε&&(t[1]=0,t[0]=null),t},toBase:e=>function(e,t){let[r,n,i]=e,s=[],o=0;if(0===i)return[0,0,0];let a=qr(i);o=i>0?.00379058511492914*i**2+.608983189401032*i+.9155088574762233:9514440756550361e-21*i**2+.08693057439788597*i-21.928975842194614;let u=0,l=1/0;for(;u<=15;){s=jr({J:o,C:n,h:r},t);const e=Math.abs(s[1]-a);if(e<l){if(e<=2e-12)return s;l=e}o-=(s[1]-a)*o/(2*s[1]),u+=1}return jr({J:o,C:n,h:r},t)}(e,Xr),formats:{color:{id:"--hct",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}});const Yr=Math.PI/180,Kr=[1,.007,.0228];function Jr(e){e[1]<0&&(e=Zr.fromBase(Zr.toBase(e)));const t=Math.log(Math.max(1+Kr[2]*e[1]*Xr.flRoot,1))/Kr[2],r=e[0]*Yr,n=t*Math.cos(r),i=t*Math.sin(r);return[e[2],n,i]}var Qr={deltaE76:function(e,t){return function(e,t,r="lab"){let n=(r=wt.get(r)).from(e),i=r.from(t);return Math.sqrt(n.reduce(((e,t,r)=>{let n=i[r];return tt(t)||tt(n)?e:e+(n-t)**2}),0))}(e,t,"lab")},deltaECMC:function(e,t,{l:r=2,c:n=1}={}){[e,t]=_t([e,t]);let[i,s,o]=Bt.from(e),[,a,u]=Pt.from(Bt,[i,s,o]),[l,h,c]=Bt.from(t),d=Pt.from(Bt,[l,h,c])[1];a<0&&(a=0),d<0&&(d=0);let p=i-l,f=a-d,m=(s-h)**2+(o-c)**2-f**2,g=.511;i>=16&&(g=.040975*i/(1+.01765*i));let y,v=.0638*a/(1+.0131*a)+.638;tt(u)&&(u=0),y=u>=164&&u<=345?.56+Math.abs(.2*Math.cos((u+168)*Jt)):.36+Math.abs(.4*Math.cos((u+35)*Jt));let b=Math.pow(a,4),x=Math.sqrt(b/(b+1900)),_=(p/(r*g))**2;return _+=(f/(n*v))**2,_+=m/(v*(x*y+1-x))**2,Math.sqrt(_)},deltaE2000:Gt,deltaEJz:function(e,t){[e,t]=_t([e,t]);let[r,n,i]=gr.from(e),[s,o,a]=gr.from(t),u=r-s,l=n-o;tt(i)&&tt(a)?(i=0,a=0):tt(i)?i=a:tt(a)&&(a=i);let h=i-a,c=2*Math.sqrt(n*o)*Math.sin(h/2*(Math.PI/180));return Math.sqrt(u**2+l**2+c**2)},deltaEITP:function(e,t){[e,t]=_t([e,t]);let[r,n,i]=Tr.from(e),[s,o,a]=Tr.from(t);return 720*Math.sqrt((r-s)**2+.25*(n-o)**2+(i-a)**2)},deltaEOK:Zt,deltaEOK2:function(e,t){[e,t]=_t([e,t]);let[r,n,i]=Xt.from(e),[s,o,a]=Xt.from(t),u=r-s,l=2*(n-o),h=2*(i-a);return Math.sqrt(u**2+l**2+h**2)},deltaEHCT:function(e,t){[e,t]=_t([e,t]);let[r,n,i]=Jr(Zr.from(e)),[s,o,a]=Jr(Zr.from(t));return Math.sqrt((r-s)**2+(n-o)**2+(i-a)**2)}};const en={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 tn(e,{method:t=yt.gamut_mapping,space:r,deltaEMethod:n="",jnd:i=2,blackWhiteClamp:s}={}){if(e=_t(e),Je(arguments[1])?r=arguments[1]:r||(r=e.space),Yt(e,r=wt.get(r),{epsilon:0}))return e;let o;if("css"===t)o=function(e,{space:t}={}){const r=.02,n=1e-4;e=_t(e),t||(t=e.space);t=wt.get(t);const i=wt.get("oklch");if(t.isUnbounded)return nn(e,t);const s=nn(e,i);let o=s.coords[0];if(o>=1){const r=nn(rn.WHITE,t);return r.alpha=e.alpha,nn(r,t)}if(o<=0){const r=nn(rn.BLACK,t);return r.alpha=e.alpha,nn(r,t)}if(Yt(s,t,{epsilon:0}))return nn(s,t);function a(e){const r=nn(e,t),n=Object.values(t.coords);return r.coords=r.coords.map(((e,t)=>{if("range"in n[t]){const[r,i]=n[t].range;return st(r,e,i)}return e})),r}let u=0,l=s.coords[1],h=!0,c=Kt(s),d=a(c),p=Zt(d,c);if(p<r)return d;for(;l-u>n;){const e=(u+l)/2;if(c.coords[1]=e,h&&Yt(c,t,{epsilon:0}))u=e;else if(d=a(c),p=Zt(d,c),p<r){if(r-p<n)break;h=!1,u=e}else l=e}return d}(e,{space:r});else{if("clip"===t||Yt(e,r))o=nn(e,r);else{Object.prototype.hasOwnProperty.call(en,t)&&({method:t,jnd:i,deltaEMethod:n,blackWhiteClamp:s}=en[t]);let a=Gt;if(""!==n)for(let e in Qr)if("deltae"+n.toLowerCase()===e.toLowerCase()){a=Qr[e];break}0===i&&(i=1e-16);let u=tn(nn(e,r),{method:"clip",space:r});if(a(e,u)>i){if(s&&3===Object.keys(s).length){let t=wt.resolveCoord(s.channel),r=Dt(nn(e,t.space),t.id);if(tt(r)&&(r=0),r>=s.max)return nn({space:"xyz-d65",coords:ft.D65},e.space);if(r<=s.min)return nn({space:"xyz-d65",coords:[0,0,0]},e.space)}let n=wt.resolveCoord(t),u=n.space,l=n.id,h=nn(e,u);h.coords.forEach(((e,t)=>{tt(e)&&(h.coords[t]=0)}));let c=(n.range||n.refRange)[0],d=function(e){const t=e?Math.floor(Math.log10(Math.abs(e))):0;return Math.max(parseFloat("1e"+(t-2)),1e-6)}(i),p=c,f=Dt(h,l);for(;f-p>d;){let e=Kt(h);e=tn(e,{space:r,method:"clip"}),a(h,e)-i<d?p=Dt(h,l):f=Dt(h,l),Ft(h,l,(p+f)/2)}o=nn(h,r)}else o=u}if("clip"===t||!Yt(o,r,{epsilon:0})){let e=Object.values(r.coords).map((e=>e.range||[]));o.coords=o.coords.map(((t,r)=>{let[n,i]=e[r];return void 0!==n&&(t=Math.max(n,t)),void 0!==i&&(t=Math.min(t,i)),t}))}}return r!==e.space&&(o=nn(o,e.space)),e.coords=o.coords,e}tn.returns="color";const rn={WHITE:{space:Xt,coords:[1,0,0],alpha:1},BLACK:{space:Xt,coords:[0,0,0],alpha:1}};function nn(e,t,{inGamut:r}={}){e=_t(e);let n=(t=wt.get(t)).from(e),i={space:t,coords:n,alpha:e.alpha};return r&&(i=tn(i,!0===r?void 0:r)),i}nn.returns="color";var sn=new St({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]]});var on=new St({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]]}),an={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:[.6,50/255,.8],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,.6],lightslategrey:[119/255,136/255,.6],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:[.4,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,.8],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:[.4,.2,.6],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 un=Array(3).fill("<percentage> | <number>[0, 255]"),ln=Array(3).fill("<number>[0, 255]");var hn=new St({id:"srgb",name:"sRGB",base:on,fromBase:e=>e.map((e=>{let t=e<0?-1:1,r=e*t;return r>.0031308?t*(1.055*r**(1/2.4)-.055):12.92*e})),toBase:e=>e.map((e=>{let t=e<0?-1:1,r=e*t;return r<=.04045?e/12.92:t*((r+.055)/1.055)**2.4})),formats:{rgb:{coords:un},rgb_number:{name:"rgb",commas:!0,coords:ln,alpha:!1},color:{},rgba:{coords:un,commas:!0,alpha:!0},rgba_number:{name:"rgba",commas:!0,coords:ln},hex:{type:"custom",toGamut:!0,test:e=>/^#(([a-f0-9]{2}){3,4}|[a-f0-9]{3,4})$/i.test(e),parse(e){e.length<=5&&(e=e.replace(/[a-f0-9]/gi,"$&$&"));let t=[];return e.replace(/[a-f0-9]{2}/gi,(e=>{t.push(parseInt(e,16)/255)})),{spaceId:"srgb",coords:t.slice(0,3),alpha:t.slice(3)[0]}},serialize:(e,t,{collapse:r=!0,alpha:n}={})=>{(!1!==n&&t<1||!0===n)&&e.push(t),e=e.map((e=>Math.round(255*e)));let i=r&&e.every((e=>e%17==0));return"#"+e.map((e=>i?(e/17).toString(16):e.toString(16).padStart(2,"0"))).join("")}},keyword:{type:"custom",test:e=>/^[a-z]+$/i.test(e),parse(e){let t={spaceId:"srgb",coords:null,alpha:1};if("transparent"===(e=e.toLowerCase())?(t.coords=an.black,t.alpha=0):t.coords=an[e],t.coords)return t}}}}),cn=new St({id:"p3",cssId:"display-p3",name:"P3",base:sn,fromBase:hn.fromBase,toBase:hn.toBase});function dn(e){return Dt(e,[Et,"y"])}function pn(e,t){e=_t(e),t=_t(t);let r=Math.max(dn(e),0),n=Math.max(dn(t),0);return n>r&&([r,n]=[n,r]),(r+.05)/(n+.05)}function mn(e){return e>=.022?e:e+(.022-e)**1.414}function gn(e){let t=e<0?-1:1,r=Math.abs(e);return t*Math.pow(r,2.4)}function yn(e,t){let r,n,i,s,o,a;t=_t(t),e=_t(e),t=nn(t,"srgb"),[s,o,a]=t.coords.map((e=>tt(e)?0:e));let u=.2126729*gn(s)+.7151522*gn(o)+.072175*gn(a);e=nn(e,"srgb"),[s,o,a]=e.coords.map((e=>tt(e)?0:e));let l=.2126729*gn(s)+.7151522*gn(o)+.072175*gn(a),h=mn(u),c=mn(l),d=c>h;return Math.abs(c-h)<5e-4?n=0:d?(r=c**.56-h**.57,n=1.14*r):(r=c**.65-h**.62,n=1.14*r),i=Math.abs(n)<.1?0:n>0?n-.027:n+.027,100*i}function vn(e,t,r={}){if("function"===Qe(n=e)&&n.rangeArgs){let[r,n]=[e,t];return vn(...r.rangeArgs.colors,{...r.rangeArgs.options,...n})}var n;let{space:i,outputSpace:s,progression:o,premultiplied:a}=r;e=_t(e),t=_t(t),e=Kt(e),t=Kt(t);let u={colors:[e,t],options:r};if(i=i?wt.get(i):wt.registry[yt.interpolationSpace]||e.space,s=s?wt.get(s):i,e=nn(e,i),t=nn(t,i),e=tn(e),t=tn(t),i.coords.h&&"angle"===i.coords.h.type){let n=r.hue=r.hue||"shorter",s=[i,"h"],[o,a]=[Dt(e,s),Dt(t,s)];tt(o)&&!tt(a)?o=a:tt(a)&&!tt(o)&&(a=o),[o,a]=function(e,t){let[r,n]=t,i=tt(r),s=tt(n);if(i&&s)return[r,n];if(i?r=n:s&&(n=r),"raw"===e)return t;r=Lt(r),n=Lt(n);let o=n-r;return"increasing"===e?o<0&&(n+=360):"decreasing"===e?o>0&&(r+=360):"longer"===e?-180<o&&o<180&&(o>0?r+=360:n+=360):"shorter"===e&&(o>180?r+=360:o<-180&&(n+=360)),[r,n]}(n,[o,a]),Ft(e,s,o),Ft(t,s,a)}return a&&(e.coords=e.coords.map((t=>t*e.alpha)),t.coords=t.coords.map((e=>e*t.alpha))),Object.assign((r=>{r=o?o(r):r;let n=e.coords.map(((e,n)=>nt(e,t.coords[n],r))),u=nt(e.alpha,t.alpha,r),l={space:i,coords:n,alpha:u};return a&&(l.coords=l.coords.map((e=>e/u))),s!==i&&(l=nn(l,s)),l}),{rangeArgs:u})}yt.interpolationSpace="lab";var bn=new wt({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:hn,fromBase:e=>{let t=Math.max(...e),r=Math.min(...e),[n,i,s]=e,[o,a,u]=[null,0,(r+t)/2],l=t-r;if(0!==l){switch(a=0===u||1===u?0:(t-u)/Math.min(u,1-u),t){case n:o=(i-s)/l+(i<s?6:0);break;case i:o=(s-n)/l+2;break;case s:o=(n-i)/l+4}o*=60}return a<0&&(o+=180,a=Math.abs(a)),o>=360&&(o-=360),[o,100*a,100*u]},toBase:e=>{let[t,r,n]=e;function i(e){let i=(e+t/30)%12,s=r*Math.min(n,1-n);return n-s*Math.max(-1,Math.min(i-3,9-i,1))}return t%=360,t<0&&(t+=360),r/=100,n/=100,[i(0),i(8),i(4)]},formats:{hsl:{coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]},hsla:{coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"],commas:!0,alpha:!0}}}),xn=new wt({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:hn,fromBase(e){let t=Math.max(...e),r=Math.min(...e),[n,i,s]=e,[o,a,u]=[null,0,t],l=t-r;if(0!==l){switch(t){case n:o=(i-s)/l+(i<s?6:0);break;case i:o=(s-n)/l+2;break;case s:o=(n-i)/l+4}o*=60}return u&&(a=l/u),o>=360&&(o-=360),[o,100*a,100*u]},toBase(e){let[t,r,n]=e;function i(e){let i=(e+t/60)%6;return n-n*r*Math.max(0,Math.min(i,4-i,1))}return t%=360,t<0&&(t+=360),r/=100,n/=100,[i(5),i(3),i(1)]},formats:{color:{id:"--hsv",coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}}),_n=new wt({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:xn,fromBase(e){let[t,r,n]=e;return[t,n*(100-r)/100,100-n]},toBase(e){let[t,r,n]=e;r/=100,n/=100;let i=r+n;if(i>=1){return[t,0,100*(r/i)]}let s=1-n;return[t,100*(0===s?0:1-r/s),100*s]},formats:{hwb:{coords:["<number> | <angle>","<percentage> | <number>","<percentage> | <number>"]}}}),wn=new wt({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:Xt,fromBase:Pt.fromBase,toBase:Pt.toBase,formats:{oklch:{coords:["<percentage> | <number>","<number> | <percentage>","<number> | <angle>"]}}}),Cn=new wt({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:hn,fromBase:e=>{const t=Math.max(...e),r=t-Math.min(...e);let n,i,[s,o,a]=e;return 0===r?(n=0,i=0):(i=r/t,s===t?n=(o-a)/r:o===t?n=2+(a-s)/r:a===t&&(n=4+(s-o)/r),n<0?n+=6:n>=6&&(n-=6)),[n/6*360,100*i,100*t]},toBase:En,formats:{default:{type:"custom",serialize:(e,t)=>{const r=En(e);let n=`rgb(${Math.round(100*r[0]*100)/100}% ${Math.round(100*r[1]*100)/100}% ${Math.round(100*r[2]*100)/100}%`;return t<1&&(n+=` / ${t}`),n+=")",n}},hsb:{coords:["<number> | <angle>","<percentage>","<percentage>"]},hsba:{coords:["<number> | <angle>","<percentage>","<percentage>"],commans:!0,lastAlpha:!0}}});function En(e){const t=e[0]/360*6,r=e[1]/100,n=e[2]/100;let i=[];if(0===r)i=[n,n,n];else{const e=Math.floor(t),s=n*(1-r),o=n*(1-r*(t-e)),a=n*(1-r*(1+e-t));let u,l,h;1===e?(u=o,l=n,h=s):2===e?(u=s,l=n,h=a):3===e?(u=s,l=o,h=n):4===e?(u=a,l=s,h=n):5===e?(u=n,l=s,h=o):(u=n,l=a,h=s),i=[u,l,h]}return i}const Sn=(e,t,r,n,i,s)=>{let o=(e-t)/(r-t)*(i-n)+n;return s&&(o=Math.max(o,Math.min(n,i)),o=Math.min(o,Math.max(n,i))),o},An=e=>{const t=(~~(255*e)).toString(16);return t.length<2?"0"+t:t},Dn=new Map;class Tn{static colorMap={};static#e={};static#t={};isColor=!0;static addColorMode(e,t){wt.register(t),Tn.colorMap[e]=t.id,Tn.#e[e]=Object.values(t.coords).reduce(((e,t)=>(e.push(t.refRange||t.range),e)),[]),Tn.#e[e].push([0,1]),Tn.#t[e]=t.fromGray}constructor(e,t,r,{clamp:n=!1}={}){if(this._cachedMode=t||In,e instanceof Tn){const r=t?Tn.colorMap[t]:Tn.colorMap[e.mode];this._initialize=()=>{this._cachedColor=nn(e._color,r),this._cachedMode=r}}else if("object"!=typeof e||Array.isArray(e)||null===e)if("string"==typeof e[0])this._defaultStringValue=e[0],this._initialize=()=>{try{this._cachedColor=vt(e[0]);const[t]=Object.entries(Tn.colorMap).find((([e,t])=>t===this._cachedColor.spaceId));this._cachedMode=t,this._cachedColor=nn(this._cachedColor,this._cachedColor.spaceId)}catch(e){throw new Error("Invalid color string")}};else{let t;if(r)if(4===e.length)t=Tn.mapColorRange(e,this._cachedMode,r,n);else if(3===e.length)t=Tn.mapColorRange([e[0],e[1],e[2]],this._cachedMode,r,n),t.push(1);else if(2===e.length){t=Tn.#t[this._cachedMode]?Tn.#t[this._cachedMode](e[0],r,n):Tn.mapColorRange([e[0],e[0],e[0]],this._cachedMode,r,n);const i=Array.isArray(r[r.length-1])?r[r.length-1]:[0,r[r.length-1]];t.push(Sn(e[1],i[0],i[1],0,1,n))}else{if(1!==e.length)throw new Error("Invalid color");t=Tn.#t[this._cachedMode]?Tn.#t[this._cachedMode](e[0],r,n):Tn.mapColorRange([e[0],e[0],e[0]],this._cachedMode,r,n),t.push(1)}else t=e;this._cachedMode===In&&(1===t[3]?this._defaultStringValue="#"+An(t[0])+An(t[1])+An(t[2]):this._defaultStringValue="#"+An(t[0])+An(t[1])+An(t[2])+An(t[3])),this._initialize=()=>{const e=Tn.colorMap[this._cachedMode]||console.error("Invalid color mode"),r={space:e,coords:t.slice(0,3),alpha:t[3]};this._cachedColor=nn(r,e)}}else{const r=t?Tn.colorMap[t]:e.spaceId;this._initialize=()=>{this._cachedColor=nn(e,r),this._cachedMode=t||Object.entries(Tn.colorMap).find((([e,t])=>t===this._cachedColor.spaceId))}}}get mode(){return this._initialize&&(this._initialize(),this._initialize=void 0),this._cachedMode}get _color(){return this._initialize&&(this._initialize(),this._initialize=void 0),this._cachedColor}set _color(e){this._initialize&&(this._initialize(),this._initialize=void 0),this._cachedColor=e}static mapColorRange(e,t,r,n){const i=r.map((e=>Array.isArray(e)?e:[0,e])),s=Tn.#e[t];return e.map(((e,t)=>Sn(e,i[t][0],i[t][1],s[t][0],s[t][1],n)))}static unmapColorRange(e,t,r){const n=r.map((e=>Array.isArray(e)?e:[0,e])),i=Tn.#e[t];return e.map(((e,t)=>Sn(e,i[t][0],i[t][1],n[t][0],n[t][1])))}#r(e){return new Tn(this._color,e)}get _array(){return this._getRGBA()}array(){return this._array}lerp(e,t,r){let n=-1;for(;(n+1<this._color.space.path.length||n+1<e._color.space.path.length)&&this._color.space.path[n+1]===e._color.space.path[n+1];)n+=1;if(-1===n)throw new Error("Cannot lerp colors. No common color space found");const i=vn(this._color,e._color,{space:this._color.space.path[n].id})(t);return new Tn(i,r||this.mode)}toString(e){if(void 0===e&&void 0!==this._defaultStringValue)return this._defaultStringValue;let t=e;"#rrggbb"===e&&(t="hex");const r=`${this._color.space.id}-${this._color.coords.join(",")}-${this._color.alpha}-${e}`;let n=Dn.get(r);if(!n){if(n=function(e,t={}){let r,{precision:n=yt.precision,format:i,inGamut:s=!0,coords:o,alpha:a,commas:u}=t,l=_t(e),h=i,c=l.parseMeta;c&&!i&&(c.format.canSerialize()&&(i=c.format,h=c.formatId),o??=c.types,a??=c.alphaType,u??=c.commas),h&&(i=l.space.getFormat(i)??wt.findFormat(h)),i||(i=l.space.getFormat("default")??wt.DEFAULT_FORMAT,h=i.name),i&&i.space&&i.space!==l.space&&(l=nn(l,i.space));let d=l.coords.slice();if(s||=i.toGamut,s&&!Yt(l)&&(d=tn(Kt(l),!0===s?void 0:s).coords),"custom"===i.type){if(!i.serialize)throw new TypeError(`format ${h} can only be used to parse colors, not for serialization`);r=i.serialize(d,l.alpha,t)}else{let e=i.name||"color",t=i.serializeCoords(d,n,o);if("color"===e){let e=i.id||i.ids?.[0]||l.space.cssId||l.space.id;t.unshift(e)}let s=l.alpha;void 0!==a&&"object"!=typeof a&&(a="string"==typeof a?{type:a}:{include:a});let h=a?.type??"<number>",c=!0===a?.include||!0===i.alpha||!1!==a?.include&&!1!==i.alpha&&s<1,p="";if(u??=i.commas,c){if(null!==n){let e;"<percentage>"===h&&(e="%",s*=100),s=et(s,{precision:n,unit:e})}p=`${u?",":" /"} ${s}`}r=`${e}(${t.join(u?", ":" ")}${p})`}return r}(this._color,{format:t}),"#rrggbb"===e){if(n=String(n),4===n.length){const e=n[1],t=n[2],r=n[3];n=`#${e}${e}${t}${t}${r}${r}`}n.length>7&&(n=n.slice(0,7)),n=n.toLowerCase()}Dn.size>1e3&&Dn.delete(Dn.keys().next().value),Dn.set(r,n)}return n}contrast(e,t="WCAG21"){if("all"!==t){let r,n;switch(t){case"WCAG21":r=pn(this._color,e._color),n=4.5;break;case"APCA":r=Math.abs(yn(this._color,e._color)),n=75;break;default:return null}return r>=n}{const t=pn(this._color,e._color),r=yn(this._color,e._color);return{WCAG21:{value:t,passedMinimum:t>=4.5,passedAAA:t>=7},APCA:{value:r,passedMinimum:Math.abs(r)>=75}}}}setRed(e,t=[0,1]){this._defaultStringValue=void 0,Array.isArray(t)||(t=[0,t]);const r=Tn.#e[In][0],n=Sn(e,t[0],t[1],r[0],r[1]);if(this.mode===In||this.mode===kn)this._color.coords[0]=n;else{const e=this._color.space.id,t=nn(this._color,"srgb");t.coords[0]=n,this._color=nn(t,e)}}setGreen(e,t=[0,1]){this._defaultStringValue=void 0,Array.isArray(t)||(t=[0,t]);const r=Tn.#e[In][1],n=Sn(e,t[0],t[1],r[0],r[1]);if(this.mode===In||this.mode===kn)this._color.coords[1]=n;else{const e=this._color.space.id,t=nn(this._color,"srgb");t.coords[1]=n,this._color=nn(t,e)}}setBlue(e,t=[0,1]){this._defaultStringValue=void 0,Array.isArray(t)||(t=[0,t]);const r=Tn.#e[In][2],n=Sn(e,t[0],t[1],r[0],r[1]);if(this.mode===In||this.mode===kn)this._color.coords[2]=n;else{const e=this._color.space.id,t=nn(this._color,"srgb");t.coords[2]=n,this._color=nn(t,e)}}setAlpha(e,t=[0,1]){this._defaultStringValue=void 0,Array.isArray(t)||(t=[0,t]);const r=Tn.#e[this.mode][3],n=Sn(e,t[0],t[1],r[0],r[1]);this._color.alpha=n}_getRGBA(e=[1,1,1,1]){const t=Tn.#e[In];let r=structuredClone(nn(this._color,"srgb").coords);r.push(this._color.alpha);const n=e.map((e=>Array.isArray(e)?e:[0,e]));return r=r.map(((e,r)=>Sn(e,t[r][0],t[r][1],n[r][0],n[r][1]))),r}_getMode(){return this.mode}_getRed(e=[0,1]){if(Array.isArray(e)||(e=[0,e]),this.mode===In||this.mode===kn){const t=Tn.#e[this.mode][0];return Sn(this._color.coords[0],t[0],t[1],e[0],e[1])}{const t=Tn.#e[In][0];return Sn(nn(this._color,"srgb").coords[0],t[0],t[1],e[0],e[1])}}_getGreen(e=[0,1]){if(Array.isArray(e)||(e=[0,e]),this.mode===In||this.mode===kn){const t=Tn.#e[this.mode][1];return Sn(this._color.coords[1],t[0],t[1],e[0],e[1])}{const t=Tn.#e[In][1];return Sn(nn(this._color,"srgb").coords[1],t[0],t[1],e[0],e[1])}}_getBlue(e=[0,1]){if(Array.isArray(e)||(e=[0,e]),this.mode===In||this.mode===kn){const t=Tn.#e[this.mode][2];return Sn(this._color.coords[2],t[0],t[1],e[0],e[1])}{const t=Tn.#e[In][2];return Sn(nn(this._color,"srgb").coords[2],t[0],t[1],e[0],e[1])}}_getAlpha(e=[0,1]){Array.isArray(e)||(e=[0,e]);const t=Tn.#e[this.mode][3];return Sn(this._color.alpha,t[0],t[1],e[0],e[1])}_getHue(e=[0,360]){if(Array.isArray(e)||(e=[0,e]),this.mode===Nn||this.mode===Mn){const t=Tn.#e[this.mode][0];return Sn(this._color.coords[0],t[0],t[1],e[0],e[1])}{const t=Tn.#e[Mn][0];return Sn(nn(this._color,"hsl").coords[0],t[0],t[1],e[0],e[1])}}_getSaturation(e=[0,100]){if(Array.isArray(e)||(e=[0,e]),this.mode===Nn||this.mode===Mn){const t=Tn.#e[this.mode][1];return Sn(this._color.coords[1],t[0],t[1],e[0],e[1])}{const t=Tn.#e[Mn][1];return Sn(nn(this._color,"hsl").coords[1],t[0],t[1],e[0],e[1])}}_getBrightness(e=[0,100]){if(Array.isArray(e)||(e=[0,e]),this.mode===Nn){const t=Tn.#e[this.mode][2];return Sn(this._color.coords[2],t[0],t[1],e[0],e[1])}{const t=Tn.#e[Nn][2];return Sn(nn(this._color,"hsb").coords[2],t[0],t[1],e[0],e[1])}}_getLightness(e=[0,100]){if(Array.isArray(e)||(e=[0,e]),this.mode===Mn){const t=Tn.#e[this.mode][2];return Sn(this._color.coords[2],t[0],t[1],e[0],e[1])}{const t=Tn.#e[Mn][2];return Sn(nn(this._color,"hsl").coords[2],t[0],t[1],e[0],e[1])}}}function Fn(e,t,r){e.Color=Tn,hn.fromGray=cn.fromGray=function(e,t,r){const n=t.map((e=>Array.isArray(e)?e:[0,e])),i=Sn(e,n[2][0],n[2][1],0,1,r);return[i,i,i]},Cn.fromGray=bn.fromGray=function(e,t,r){const n=t.map((e=>Array.isArray(e)?e:[0,e]));return[0,0,Sn(e,n[2][0],n[2][1],0,100,r)]},_n.fromGray=function(e,t,r){const n=t.map((e=>Array.isArray(e)?e:[0,e])),i=Math.abs(n[1][0]-n[1][1])/2+Math.abs(n[2][0]-n[2][1])/2,s=Sn(e,0,i,0,100);let o,a;return s<50?(a=s,o=100-s):s>=50&&(o=s,a=100-s),[0,o,a]},Bt.fromGray=Pt.fromGray=Xt.fromGray=wn.fromGray=function(e,t,r){const n=t.map((e=>Array.isArray(e)?e:[0,e]));return[Sn(e,n[0][0],n[0][1],0,100,r),0,0]},e.Color.addColorMode(In,hn),e.Color.addColorMode(kn,cn),e.Color.addColorMode(Nn,Cn),e.Color.addColorMode(Mn,bn),e.Color.addColorMode(On,_n),e.Color.addColorMode(Bn,Bt),e.Color.addColorMode(Ln,Pt),e.Color.addColorMode(Pn,Xt),e.Color.addColorMode(Rn,wn),r.presetup=function(){const t=this,r=["Red","Green","Blue","Alpha"];for(let n in r){const i=r[n],s=e.Color.prototype["set"+i];e.Color.prototype["set"+i]=function(e,r){return r=r||t?._renderer?.states?.colorMaxes?.[In][n],s.call(this,e,r)}}function n(r,n){const i=e.Color.prototype["_get"+r];e.Color.prototype["_get"+r]=function(e){if(Object.keys(n).includes(this.mode))e=e||t?._renderer?.states?.colorMaxes?.[this.mode][n[this.mode]];else{const r=Object.keys(n)[0];e=e||t?._renderer?.states?.colorMaxes?.[r][n[r]]}return i.call(this,e)}}n("Red",{[In]:0,[kn]:0}),n("Green",{[In]:1,[kn]:1}),n("Blue",{[In]:2,[kn]:2}),n("Alpha",{[In]:3,[kn]:3,[Nn]:3,[Mn]:3,[On]:3,[Bn]:3,[Ln]:3,[Pn]:3,[Rn]:3}),n("Hue",{[Mn]:0,[Nn]:0,[On]:0,[Ln]:2,[Rn]:2}),n("Saturation",{[Mn]:1,[Nn]:1}),n("Brightness",{[Nn]:2}),n("Lightness",{[Mn]:2})}}"undefined"!=typeof p5&&Fn(p5);const In="rgb",kn="rgbp3",Nn="hsb",Mn="hsl",On="hwb",Bn="lab",Ln="lch",Pn="oklab",Rn="oklch",Vn="rgba";function Un(e,t){t.RGB=In,t.RGBP3=kn,t.HSB=Nn,t.HSL=Mn,t.HWB=On,t.LAB=Bn,t.LCH=Ln,t.OKLAB=Pn,t.OKLCH=Rn,t.RGBA=Vn,e.Renderer.states.colorMode=In,e.Renderer.states.colorMaxes={[In]:[255,255,255,255],[kn]:[255,255,255,255],[Nn]:[360,100,100,1],[Mn]:[360,100,100,1],[On]:[360,100,100,1],[Bn]:[100,[-125,125],[-125,125],1],[Ln]:[100,150,360,1],[Pn]:[100,[-125,125],[-125,125],1],[Rn]:[100,150,360,1],clone:function(){const e={...this};for(const t in e)e[t]instanceof Array&&(e[t]=[...e[t]]);return e}},t.color=function(...e){if(e[0]instanceof Tn)return e[0];const t=Array.isArray(e[0])?e[0]:e;return new Tn(t,this._renderer.states.colorMode,this._renderer.states.colorMaxes[this._renderer.states.colorMode],{clamp:!0})},t.red=function(e){return this.color(e)._getRed()},t.green=function(e){return this.color(e)._getGreen()},t.blue=function(e){return this.color(e)._getBlue()},t.alpha=function(e){return this.color(e)._getAlpha()},t.hue=function(e){let t=Mn,r=0;return this._renderer.states.colorMode===Nn||this._renderer.states.colorMode===Mn?t=this._renderer.states.colorMode:this._renderer.states.colorMode!==Ln&&this._renderer.states.colorMode!==Rn||(t=this._renderer.states.colorMode,r=2),this.color(e)._getHue(this._renderer.states.colorMaxes[t][r])},t.saturation=function(e){const t=this._renderer.states.colorMode===Nn?Nn:Mn;return this.color(e)._getSaturation(this._renderer.states.colorMaxes[t][1])},t.brightness=function(e){return this.color(e)._getBrightness(this._renderer.states.colorMaxes.hsb[2])},t.lightness=function(e){return this.color(e)._getLightness(this._renderer.states.colorMaxes.hsl[2])},t.lerpColor=function(e,t,r){return e.lerp(t,r,this._renderer.states.colorMode)},t.paletteLerp=function(e,t){const r=e[0];if(t<r[1])return this.color(r[0]);for(let r=1;r<e.length;r++){const n=e[r];if(t<n[1]){const i=e[r-1];return this.lerpColor(this.color(i[0]),this.color(n[0]),(t-i[1])/(n[1]-i[1]))}}return this.color(e[e.length-1][0])}}"undefined"!=typeof p5&&Un(p5,p5.prototype);const zn={OPERATION:"operation",LITERAL:"literal",VARIABLE:"variable",CONSTANT:"constant",STRUCT:"struct",PHI:"phi",STATEMENT:"statement",ASSIGNMENT:"assignment"},jn="_p5_instanceID",Gn="_p5_param_",$n=Object.fromEntries(Object.entries(zn).map((([e,t])=>[t,e]))),Hn={[zn.OPERATION]:["opCode","dependsOn","dimension","baseType"],[zn.LITERAL]:["value","dimension","baseType"],[zn.VARIABLE]:["identifier","dimension","baseType"],[zn.CONSTANT]:["value","dimension","baseType"],[zn.STRUCT]:[""],[zn.PHI]:["dependsOn","phiBlocks","dimension","baseType"],[zn.STATEMENT]:["statementType"],[zn.ASSIGNMENT]:["dependsOn"]},qn="discard",Wn="break",Xn="early_return",Zn="expression",Yn="empty",Kn="float",Jn="int",Qn="bool",ei="mat",ti="defer",ri="assign_on_use",ni="sampler2D",ii="sampler",si={[Kn]:3,[Jn]:2,[Qn]:1,[ei]:0,[ti]:-1,[ri]:-2,[ni]:-10,[ii]:-11},oi={float1:{fnName:"float",baseType:Kn,dimension:1,priority:3},float2:{fnName:"vec2",baseType:Kn,dimension:2,priority:3},float3:{fnName:"vec3",baseType:Kn,dimension:3,priority:3},float4:{fnName:"vec4",baseType:Kn,dimension:4,priority:3},int1:{fnName:"int",baseType:Jn,dimension:1,priority:2},int2:{fnName:"ivec2",baseType:Jn,dimension:2,priority:2},int3:{fnName:"ivec3",baseType:Jn,dimension:3,priority:2},int4:{fnName:"ivec4",baseType:Jn,dimension:4,priority:2},bool1:{fnName:"bool",baseType:Qn,dimension:1,priority:1},bool2:{fnName:"bvec2",baseType:Qn,dimension:2,priority:1},bool3:{fnName:"bvec3",baseType:Qn,dimension:3,priority:1},bool4:{fnName:"bvec4",baseType:Qn,dimension:4,priority:1},mat2:{fnName:"mat2x2",baseType:ei,dimension:2,priority:0},mat3:{fnName:"mat3x3",baseType:ei,dimension:3,priority:0},mat4:{fnName:"mat4x4",baseType:ei,dimension:4,priority:0},defer:{fnName:null,baseType:ti,dimension:null,priority:-1},assign_on_use:{fnName:null,baseType:ri,dimension:null,priority:-2},sampler2D:{fnName:"sampler2D",baseType:ni,dimension:1,priority:-10},sampler:{fnName:"sampler",baseType:ii,dimension:1,priority:-11}},ai=function(e){let t=void 0===e.type?e:e.type;const r={name:e.name,properties:[],typeName:t.typeName};for(const e of t.properties){const t=e.type.dataType;r.properties.push({name:e.name,dataType:t})}return r};function ui(e){return!(!e||!e.properties)}const li={FLOAT:{baseType:Kn,dimension:null,priority:3},INT:{baseType:Jn,dimension:null,priority:2},BOOL:{baseType:Qn,dimension:null,priority:1}};const hi=Object.fromEntries(Object.values(oi).filter((e=>null!==e.fnName)).map((e=>[e.fnName,e]))),ci={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},di={LOGICAL_NOT:100,NEGATE:101,PLUS:102,SWIZZLE:103},pi={FUNCTION_CALL:200,CONSTRUCTOR:201,TERNARY:202},fi=[{arity:"unary",boolean:!0,name:"not",symbol:"!",opCode:di.LOGICAL_NOT},{arity:"unary",name:"neg",symbol:"-",opCode:di.NEGATE},{arity:"unary",name:"plus",symbol:"+",opCode:di.PLUS},{arity:"binary",name:"add",symbol:"+",opCode:ci.ADD},{arity:"binary",name:"sub",symbol:"-",opCode:ci.SUBTRACT},{arity:"binary",name:"mult",symbol:"*",opCode:ci.MULTIPLY},{arity:"binary",name:"div",symbol:"/",opCode:ci.DIVIDE},{arity:"binary",name:"mod",symbol:"%",opCode:ci.MODULO},{arity:"binary",boolean:!0,name:"equalTo",symbol:"==",opCode:ci.EQUAL},{arity:"binary",boolean:!0,name:"notEqual",symbol:"!=",opCode:ci.NOT_EQUAL},{arity:"binary",boolean:!0,name:"greaterThan",symbol:">",opCode:ci.GREATER_THAN},{arity:"binary",boolean:!0,name:"greaterEqual",symbol:">=",opCode:ci.GREATER_EQUAL},{arity:"binary",boolean:!0,name:"lessThan",symbol:"<",opCode:ci.LESS_THAN},{arity:"binary",boolean:!0,name:"lessEqual",symbol:"<=",opCode:ci.LESS_EQUAL},{arity:"binary",boolean:!0,name:"and",symbol:"&&",opCode:ci.LOGICAL_AND},{arity:"binary",boolean:!0,name:"or",symbol:"||",opCode:ci.LOGICAL_OR}],mi={},gi={},yi={};for(const{symbol:e,opCode:t,name:r,arity:n,boolean:i}of fi)mi[t]=e,"unary"===n&&(gi[e]=r),i&&(yi[t]=!0);const vi={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(vi).map((([e,t])=>[t,e])));class bi{constructor(e){if(e)this.DOM=e;else{const e=document.implementation.createDocument(null,"doc");this.DOM=e.createElement("root")}}getParent(){return new bi(this.DOM.parentElement)}getName(){return this.DOM.tagName}setName(e){const t=this.DOM.innerHTML,r=this.DOM.attributes,n=document.implementation.createDocument(null,"default").createElement(e);n.innerHTML=t;for(let e=0;e<r.length;e++)n.setAttribute(r[e].nodeName,r[e].nodeValue);this.DOM=n}hasChildren(){return this.DOM.children.length>0}listChildren(){const e=[];for(let t=0;t<this.DOM.childNodes.length;t++)e.push(this.DOM.childNodes[t].nodeName);return e}getChildren(e){return xi(e?this.DOM.getElementsByTagName(e):this.DOM.children)}getChild(e){if("string"!=typeof e)return new bi(this.DOM.children[e]);for(const t of this.DOM.children)if(t.tagName===e)return new bi(t)}addChild(e){e instanceof bi&&this.DOM.appendChild(e.DOM)}removeChild(e){let t=-1;if("string"==typeof e){for(let r=0;r<this.DOM.children.length;r++)if(this.DOM.children[r].tagName===e){t=r;break}}else t=e;-1!==t&&this.DOM.removeChild(this.DOM.children[t])}getAttributeCount(){return this.DOM.attributes.length}listAttributes(){const e=[];for(const t of this.DOM.attributes)e.push(t.nodeName);return e}hasAttribute(e){const t={};for(const e of this.DOM.attributes)t[e.nodeName]=e.nodeValue;return!!t[e]}getNum(e,t){const r={};for(const e of this.DOM.attributes)r[e.nodeName]=e.nodeValue;return Number(r[e])||t||0}getString(e,t){const r={};for(const e of this.DOM.attributes)r[e.nodeName]=e.nodeValue;return r[e]?String(r[e]):t||null}setAttribute(e,t){this.DOM.setAttribute(e,t)}getContent(e){let t;return t=this.DOM.textContent,t=t.replace(/\s\s+/g,","),t||e||null}setContent(e){this.DOM.children.length||(this.DOM.textContent=e)}serialize(){return(new XMLSerializer).serializeToString(this.DOM)}}function xi(e){const t=[];for(let r=0;r<e.length;r++)t.push(new bi(e[r]));return t}function _i(e,t){e.XML=bi}"undefined"!=typeof p5&&_i(p5);class wi{constructor(e,t){this.file=e,this._pInst=t;const r=e.type.split("/");this.type=r[0],this.subtype=r[1],this.name=e.name,this.size=e.size,this.data=void 0}static _createLoader(e,t){const r=new FileReader;return r.onload=function(r){const n=new wi(e);if("application/json"===n.file.type)n.data=JSON.parse(r.target.result);else if("text/xml"===n.file.type){const e=(new DOMParser).parseFromString(r.target.result,"text/xml");n.data=new bi(e.documentElement)}else n.data=r.target.result;t(n)},r}static _load(e,t){if(/^text\//.test(e.type)||"application/json"===e.type)wi._createLoader(e,t).readAsText(e);else if(/^(video|audio)\//.test(e.type)){const r=new wi(e);r.data=URL.createObjectURL(e),t(r)}else wi._createLoader(e,t).readAsDataURL(e)}}function Ci(e,t){e.File=wi}"undefined"!=typeof p5&&Ci(p5);class Ei{width;height;elt;constructor(e,t){this.elt=e,this._pInst=this._pixelsState=t,this._events={},this.width=this.elt.offsetWidth,this.height=this.elt.offsetHeight}remove(){if(this.stop){this.stop();const e=this.elt.srcObject;if(null!==e){e.getTracks().forEach((e=>{e.stop()}))}}let e=this._pInst;if(e&&!e._elements&&e._pInst&&(e=e._pInst),e&&e._elements){const t=e._elements.indexOf(this);-1!==t&&e._elements.splice(t,1)}for(let e in this._events)this.elt.removeEventListener(e,this._events[e]);this.elt&&this.elt.parentNode&&this.elt.parentNode.removeChild(this.elt)}parent(e){return void 0===e?this.elt.parentNode:("string"==typeof e?("#"===e[0]&&(e=e.substring(1)),e=document.getElementById(e)):e instanceof Ei&&(e=e.elt),e.appendChild(this.elt),this)}child(e){return void 0===e?this.elt.childNodes:("string"==typeof e?("#"===e[0]&&(e=e.substring(1)),e=document.getElementById(e)):e instanceof Ei&&(e=e.elt),e instanceof HTMLElement&&this.elt.appendChild(e),this)}html(...e){return 0===e.length?this.elt.innerHTML:e[1]?(this.elt.insertAdjacentHTML("beforeend",e[0]),this):(this.elt.innerHTML=e[0],this)}id(e){return void 0===e?this.elt.id:(this.elt.id=e,this.width=this.elt.offsetWidth,this.height=this.elt.offsetHeight,this)}class(e){return void 0===e?this.elt.className:(this.elt.className=e,this)}addClass(e){return this.elt.className?this.hasClass(e)||(this.elt.className=this.elt.className+" "+e):this.elt.className=e,this}removeClass(e){return this.elt.classList.remove(e),this}hasClass(e){return this.elt.classList.contains(e)}toggleClass(e){return this.elt.classList.contains(e)?this.elt.classList.remove(e):this.elt.classList.add(e),this}center(e){const t=this.elt.style.display,r="none"===this.elt.style.display,n="none"===this.parent().style.display,i={x:this.elt.offsetLeft,y:this.elt.offsetTop};r&&this.show(),n&&this.parent().show(),this.elt.style.display="block",this.position(0,0);const s=Math.abs(this.parent().offsetWidth-this.elt.offsetWidth),o=Math.abs(this.parent().offsetHeight-this.elt.offsetHeight);return"both"===e||void 0===e?this.position(s/2+this.parent().offsetLeft,o/2+this.parent().offsetTop):"horizontal"===e?this.position(s/2+this.parent().offsetLeft,i.y):"vertical"===e&&this.position(i.x,o/2+this.parent().offsetTop),this.style("display",t),r&&this.hide(),n&&this.parent().hide(),this}position(...e){if(0===e.length)return{x:this.elt.offsetLeft,y:this.elt.offsetTop};{let t="absolute";return"static"!==e[2]&&"fixed"!==e[2]&&"relative"!==e[2]&&"sticky"!==e[2]&&"initial"!==e[2]&&"inherit"!==e[2]||(t=e[2]),this.elt.style.position=t,this.elt.style.left=e[0]+"px",this.elt.style.top=e[1]+"px",this.x=e[0],this.y=e[1],this}}show(){return this.elt.style.display="block",this}hide(){return this.elt.style.display="none",this}size(e,t){if(0===arguments.length)return{width:this.elt.offsetWidth,height:this.elt.offsetHeight};{let r=e,n=t;const i=Z;if(r!==i||n!==i){if(r===i?r=t*this.width/this.height:n===i&&(n=e*this.height/this.width),this.elt instanceof HTMLCanvasElement){const e={},t=this.elt.getContext("2d");let i;for(i in t)e[i]=t[i];for(i in this.elt.setAttribute("width",r*this._pInst._pixelDensity),this.elt.setAttribute("height",n*this._pInst._pixelDensity),this.elt.style.width=r+"px",this.elt.style.height=n+"px",this._pInst.scale(this._pInst._pixelDensity,this._pInst._pixelDensity),e)this.elt.getContext("2d")[i]=e[i]}else this.elt.style.width=r+"px",this.elt.style.height=n+"px",this.elt.width=r,this.elt.height=n;this.width=r,this.height=n,this._pInst&&this._pInst._curElement&&this._pInst._curElement.elt===this.elt&&(this._pInst.width=r,this._pInst.height=n)}return this}}style(e,t){const r=this;if(t instanceof Tn&&(t=t.toString()),void 0===t){if(-1===e.indexOf(":")){return window.getComputedStyle(r.elt).getPropertyValue(e)}{const t=e.split(";");for(let e=0;e<t.length;e++){const r=t[e].split(":");r[0]&&r[1]&&(this.elt.style[r[0].trim()]=r[1].trim())}}}else if(this.elt.style[e]=t,"width"===e||"height"===e||"left"===e||"top"===e){let t=window.getComputedStyle(r.elt).getPropertyValue(e).replace(/[^\d.]/g,"");this[e]=Math.round(parseFloat(t,10))}return this}_translate(...e){this.elt.style.position="absolute";let t="";return this.elt.style.transform&&(t=this.elt.style.transform.replace(/translate3d\(.*\)/g,""),t=t.replace(/translate[X-Z]?\(.*\)/g,"")),2===e.length?this.elt.style.transform="translate("+e[0]+"px, "+e[1]+"px)":e.length>2&&(this.elt.style.transform="translate3d("+e[0]+"px,"+e[1]+"px,"+e[2]+"px)",3===e.length?this.elt.parentElement.style.perspective="1000px":this.elt.parentElement.style.perspective=e[3]+"px"),this.elt.style.transform+=t,this}_rotate(...e){let t="";return this.elt.style.transform&&(t=this.elt.style.transform.replace(/rotate3d\(.*\)/g,""),t=t.replace(/rotate[X-Z]?\(.*\)/g,"")),1===e.length?this.elt.style.transform="rotate("+e[0]+"deg)":2===e.length?this.elt.style.transform="rotate("+e[0]+"deg, "+e[1]+"deg)":3===e.length&&(this.elt.style.transform="rotateX("+e[0]+"deg)",this.elt.style.transform+="rotateY("+e[1]+"deg)",this.elt.style.transform+="rotateZ("+e[2]+"deg)"),this.elt.style.transform+=t,this}attribute(e,t){if(null==this.elt.firstChild||"checkbox"!==this.elt.firstChild.type&&"radio"!==this.elt.firstChild.type)return void 0===t?this.elt.getAttribute(e):(this.elt.setAttribute(e,t),this);if(void 0===t)return this.elt.firstChild.getAttribute(e);for(let r=0;r<this.elt.childNodes.length;r++)this.elt.childNodes[r].setAttribute(e,t)}removeAttribute(e){if(null!=this.elt.firstChild&&("checkbox"===this.elt.firstChild.type||"radio"===this.elt.firstChild.type))for(let t=0;t<this.elt.childNodes.length;t++)this.elt.childNodes[t].removeAttribute(e);return this.elt.removeAttribute(e),this}value(...e){return e.length>0?(this.elt.value=e[0],this):"range"===this.elt.type?parseFloat(this.elt.value):this.elt.value}mousePressed(e){return Ei._adjustListener("pointerdown",(function(t){return this._pInst.mouseIsPressed=!0,this._pInst._activePointers.set(t.pointerId,t),this._pInst._setMouseButton(t),this._pInst._updatePointerCoords(t),e.call(this,t)}),this),this}doubleClicked(e){return Ei._adjustListener("dblclick",e,this),this}mouseWheel(e){return Ei._adjustListener("wheel",e,this),this}mouseReleased(e){return Ei._adjustListener("pointerup",e,this),this}mouseClicked(e){return Ei._adjustListener("click",e,this),this}mouseMoved(e){return Ei._adjustListener("pointermove",e,this),this}mouseOver(e){return Ei._adjustListener("pointerover",e,this),this}mouseOut(e){return Ei._adjustListener("pointerout",e,this),this}dragOver(e){return Ei._adjustListener("dragover",e,this),this}dragLeave(e){return Ei._adjustListener("dragleave",e,this),this}changed(e){return Ei._adjustListener("change",e,this),this}input(e){return Ei._adjustListener("input",e,this),this}drop(e,t){if(window.File&&window.FileReader&&window.FileList&&window.Blob){if(!this._dragDisabled){this._dragDisabled=!0;const e=function(e){e.preventDefault()};this.elt.addEventListener("dragover",e),this.elt.addEventListener("dragleave",e)}Ei._attachListener("drop",(function(r){r.preventDefault(),"function"==typeof t&&t.call(this,r);const n=r.dataTransfer.files;for(const t of n)wi._load(t,e)}),this)}else console.log("The File APIs are not fully supported in this browser.");return this}draggable(e){let t,r="ontouchstart"in window,n=0,i=0,s=0,o=0,a=r?"touchstart":"mousedown",u=r?"touchend":"mouseup",l=r?"touchmove":"mousemove";function h(t){if(t=t||window.event,r){const e=t.changedTouches;n=s-parseInt(e[0].clientX),i=o-parseInt(e[0].clientY),s=parseInt(e[0].clientX),o=parseInt(e[0].clientY)}else n=s-parseInt(t.clientX),i=o-parseInt(t.clientY),s=parseInt(t.clientX),o=parseInt(t.clientY);e.style.left=e.offsetLeft-n+"px",e.style.top=e.offsetTop-i+"px"}function c(){document.removeEventListener(u,c,!1),document.removeEventListener(l,h,!1)}return void 0===e?t=e=this.elt:e!==this.elt&&e.elt!==this.elt&&(e=e.elt,t=this.elt),t.addEventListener(a,(function(e){if(e=e||window.event,r){const t=e.changedTouches;s=parseInt(t[0].clientX),o=parseInt(t[0].clientY)}else s=parseInt(e.clientX),o=parseInt(e.clientY);return document.addEventListener(u,c,!1),document.addEventListener(l,h,!1),!1}),!1),t.style.cursor="move",this}static _adjustListener(e,t,r){return!1===t?Ei._detachListener(e,r):Ei._attachListener(e,t,r),this}static _attachListener(e,t,r){r._events[e]&&Ei._detachListener(e,r);const n=t.bind(r);r.elt.addEventListener(e,n,{capture:!1,signal:r._pInst._removeSignal}),r._events[e]=n}static _detachListener(e,t){const r=t._events[e];t.elt.removeEventListener(e,r,!1),t._events[e]=null}}function Si(e,t){e.Element=Ei}"undefined"!=typeof p5&&Si(p5);const Ai={_toPixels(e){if(e instanceof ImageData)return e.data;if(e.getContext("2d"))return e.getContext("2d").getImageData(0,0,e.width,e.height).data;if(e.getContext("webgl")){const t=e.getContext("webgl"),r=t.drawingBufferWidth*t.drawingBufferHeight*4,n=new Uint8Array(r);return t.readPixels(0,0,e.width,e.height,t.RGBA,t.UNSIGNED_BYTE,n),n}},_getARGB(e,t){const r=4*t;return e[r+3]<<24&4278190080|e[r]<<16&16711680|e[r+1]<<8&65280|255&e[r+2]},_setPixels(e,t){let r=0;for(let n=0,i=e.length;n<i;n++)r=4*n,e[r+0]=(16711680&t[n])>>>16,e[r+1]=(65280&t[n])>>>8,e[r+2]=255&t[n],e[r+3]=(4278190080&t[n])>>>24},_toImageData:e=>e instanceof ImageData?e:e.getContext("2d").getImageData(0,0,e.width,e.height),_createImageData(e,t){return Ai._tmpCanvas=document.createElement("canvas"),Ai._tmpCtx=Ai._tmpCanvas.getContext("2d"),this._tmpCtx.createImageData(e,t)},apply(e,t,r){const n=e.getContext("2d"),i=n.getImageData(0,0,e.width,e.height),s=t(i,r);s instanceof ImageData?n.putImageData(s,0,0,0,0,e.width,e.height):n.putImageData(i,0,0,0,0,e.width,e.height)},threshold(e,t=.5){const r=Ai._toPixels(e),n=Math.floor(255*t);for(let e=0;e<r.length;e+=4){let t;t=.2126*r[e]+.7152*r[e+1]+.0722*r[e+2]>=n?255:0,r[e]=r[e+1]=r[e+2]=t}},gray(e){const t=Ai._toPixels(e);for(let e=0;e<t.length;e+=4){const r=.2126*t[e]+.7152*t[e+1]+.0722*t[e+2];t[e]=t[e+1]=t[e+2]=r}},opaque(e){const t=Ai._toPixels(e);for(let e=0;e<t.length;e+=4)t[e+3]=255;return t},invert(e){const t=Ai._toPixels(e);for(let e=0;e<t.length;e+=4)t[e]=255-t[e],t[e+1]=255-t[e+1],t[e+2]=255-t[e+2]},posterize(e,t=4){const r=Ai._toPixels(e);if(t<2||t>255)throw new Error("Level must be greater than 2 and less than 255 for posterize");const n=t-1;for(let e=0;e<r.length;e+=4){const i=r[e],s=r[e+1],o=r[e+2];r[e]=255*(i*t>>8)/n,r[e+1]=255*(s*t>>8)/n,r[e+2]=255*(o*t>>8)/n}},dilate(e){const t=Ai._toPixels(e);let r=0;const n=t.length?t.length/4:0,i=new Int32Array(n);let s,o,a,u,l,h,c,d,p,f,m,g,y,v,b,x,_;for(;r<n;)for(s=r,o=r+e.width;r<o;)a=u=Ai._getARGB(t,r),c=r-1,h=r+1,d=r-e.width,p=r+e.width,c<s&&(c=r),h>=o&&(h=r),d<0&&(d=0),p>=n&&(p=r),g=Ai._getARGB(t,d),m=Ai._getARGB(t,c),y=Ai._getARGB(t,p),f=Ai._getARGB(t,h),l=77*(a>>16&255)+151*(a>>8&255)+28*(255&a),b=77*(m>>16&255)+151*(m>>8&255)+28*(255&m),v=77*(f>>16&255)+151*(f>>8&255)+28*(255&f),x=77*(g>>16&255)+151*(g>>8&255)+28*(255&g),_=77*(y>>16&255)+151*(y>>8&255)+28*(255&y),b>l&&(u=m,l=b),v>l&&(u=f,l=v),x>l&&(u=g,l=x),_>l&&(u=y,l=_),i[r++]=u;Ai._setPixels(t,i)},erode(e){const t=Ai._toPixels(e);let r=0;const n=t.length?t.length/4:0,i=new Int32Array(n);let s,o,a,u,l,h,c,d,p,f,m,g,y,v,b,x,_;for(;r<n;)for(s=r,o=r+e.width;r<o;)a=u=Ai._getARGB(t,r),c=r-1,h=r+1,d=r-e.width,p=r+e.width,c<s&&(c=r),h>=o&&(h=r),d<0&&(d=0),p>=n&&(p=r),g=Ai._getARGB(t,d),m=Ai._getARGB(t,c),y=Ai._getARGB(t,p),f=Ai._getARGB(t,h),l=77*(a>>16&255)+151*(a>>8&255)+28*(255&a),b=77*(m>>16&255)+151*(m>>8&255)+28*(255&m),v=77*(f>>16&255)+151*(f>>8&255)+28*(255&f),x=77*(g>>16&255)+151*(g>>8&255)+28*(255&g),_=77*(y>>16&255)+151*(y>>8&255)+28*(255&y),b<l&&(u=m,l=b),v<l&&(u=f,l=v),x<l&&(u=g,l=x),_<l&&(u=y,l=_),i[r++]=u;Ai._setPixels(t,i)},blur(e,t){!function(e,t){const r=Ai._toPixels(e),n=e.width,i=e.height,s=n*i,o=new Int32Array(s);for(let e=0;e<s;e++)o[e]=Ai._getARGB(r,e);let a,u,l,h,c,d,p,f,m,g;const y=new Int32Array(s),v=new Int32Array(s),b=new Int32Array(s),x=new Int32Array(s);let _,w,C,E,S=0;for(function(e){let t=3.5*e|0;if(t=t<1?1:t<248?t:248,Di!==t){Di=t,Ti=1+Di<<1,Fi=new Int32Array(Ti),Ii=new Array(Ti);for(let e=0;e<Ti;e++)Ii[e]=new Int32Array(256);let e,r,n,i;for(let e=1,s=t-1;e<t;e++){Fi[t+e]=Fi[s]=r=s*s,n=Ii[t+e],i=Ii[s--];for(let e=0;e<256;e++)n[e]=i[e]=r*e}e=Fi[t]=t*t,n=Ii[t];for(let t=0;t<256;t++)n[t]=e*t}}(t),w=0;w<i;w++){for(_=0;_<n;_++){if(h=l=u=c=a=0,d=_-Di,d<0)g=-d,d=0;else{if(d>=n)break;g=0}for(C=g;C<Ti&&!(d>=n);C++){const e=o[d+S];E=Ii[C],c+=E[(-16777216&e)>>>24],u+=E[(16711680&e)>>16],l+=E[(65280&e)>>8],h+=E[255&e],a+=Fi[C],d++}p=S+_,y[p]=c/a,v[p]=u/a,b[p]=l/a,x[p]=h/a}S+=n}for(S=0,f=-Di,m=f*n,w=0;w<i;w++){for(_=0;_<n;_++){if(h=l=u=c=a=0,f<0)g=p=-f,d=_;else{if(f>=i)break;g=0,p=f,d=_+m}for(C=g;C<Ti&&!(p>=i);C++)E=Ii[C],c+=E[y[d]],u+=E[v[d]],l+=E[b[d]],h+=E[x[d]],a+=Fi[C],p++,d+=n;o[_+S]=c/a<<24|u/a<<16|l/a<<8|h/a}S+=n,m+=n,f++}Ai._setPixels(r,o)}(e,t)}};let Di,Ti,Fi,Ii;function ki(e,t,r){const n=Ni(t,r)[0];let i=e;if(i instanceof Blob||(i=new Blob([e])),document){const e=URL.createObjectURL(i),t=document.createElement("a");t.href=e,t.download=n,t.click(),URL.revokeObjectURL(e)}}function Ni(e,t){t&&!0!==t&&"true"!==t||(t=""),e||(e="untitled");let r="";return e&&e.includes(".")&&(r=e.split(".").pop()),t&&r!==t&&(r=t,e=`${e}.${r}`),[e,r]}let Mi=class e{constructor(e,t){this.width=e,this.height=t,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(e){}pixelDensity(e){return void 0!==e?(e<=0&&(e=1),this._pixelDensity=e,this.width/=e,this.height/=e,this):this._pixelDensity}_animateGif(e){const t=this.gifProperties,r=e._lastRealFrameTime||window.performance.now();if(0===t.lastChangeTime&&(t.lastChangeTime=r),t.playing){t.timeDisplayed=r-t.lastChangeTime;const e=t.frames[t.displayIndex].delay;if(t.timeDisplayed>=e){const n=Math.floor(t.timeDisplayed/e);if(t.timeDisplayed=0,t.lastChangeTime=r,t.displayIndex+=n,t.loopCount=Math.floor(t.displayIndex/t.numFrames),null!==t.loopLimit&&t.loopCount>=t.loopLimit)t.playing=!1;else{const e=t.displayIndex%t.numFrames;this.drawingContext.putImageData(t.frames[e].image,0,0),t.displayIndex=e,this.setModified(!0)}}}}loadPixels(){const e=this._pixelsState,t=this._pixelDensity,r=this.width*t,n=this.height*t,i=this.drawingContext.getImageData(0,0,r,n);e.imageData=i,this.pixels=e.pixels=i.data,this.setModified(!0)}updatePixels(e,t,r,n){const i=this._pixelsState,s=this._pixelDensity;void 0===e&&void 0===t&&void 0===r&&void 0===n&&(e=0,t=0,r=this.width,n=this.height),e*=s,t*=s,r*=s,n*=s,this.gifProperties&&(this.gifProperties.frames[this.gifProperties.displayIndex].image=i.imageData),this.drawingContext.putImageData(i.imageData,e,t,0,0,r,n),this.setModified(!0)}get(t,r,n,i){const s=this._pixelsState,o=this._pixelDensity,a=this.canvas;if(void 0===t&&void 0===r)t=r=0,n=s.width,i=s.height;else if(t*=o,r*=o,void 0===n&&void 0===i)return t<0||r<0||t>=a.width||r>=a.height?[0,0,0,0]:this._getPixel(t,r);const u=new e(n*o,i*o);return u.pixelDensity(o),u.canvas.getContext("2d").drawImage(a,t,r,n*o,i*o,0,0,n*o,i*o),u}_getPixel(e,t){let r,n;return r=this.drawingContext.getImageData(e,t,1,1).data,n=0,[r[0],r[1],r[2],r[3]]}set(t,r,n){t=Math.floor(t),r=Math.floor(r);const i=this._pixelsState;if(n instanceof e)this.drawingContext.save(),this.drawingContext.setTransform(1,0,0,1,0,0),this.drawingContext.scale(this._pixelDensity,this._pixelDensity),this.drawingContext.clearRect(t,r,n.width,n.height),this.drawingContext.drawImage(n.canvas,t,r),this.drawingContext.restore();else{let e=0,s=0,o=0,a=0,u=4*(r*this._pixelDensity*(this.width*this._pixelDensity)+t*this._pixelDensity);if(i.imageData||i.loadPixels(),"number"==typeof n)u<i.pixels.length&&(e=n,s=n,o=n,a=255);else if(Array.isArray(n)){if(n.length<4)throw new Error("pixel array must be of the form [R, G, B, A]");u<i.pixels.length&&(e=n[0],s=n[1],o=n[2],a=n[3])}else n instanceof p5.Color&&u<i.pixels.length&&([e,s,o,a]=n._getRGBA([255,255,255,255]));for(let n=0;n<this._pixelDensity;n++)for(let l=0;l<this._pixelDensity;l++)u=4*((r*this._pixelDensity+l)*this.width*this._pixelDensity+(t*this._pixelDensity+n)),i.pixels[u]=e,i.pixels[u+1]=s,i.pixels[u+2]=o,i.pixels[u+3]=a}this.setModified(!0)}resize(e,t){0===e&&0===t?(e=this.canvas.width,t=this.canvas.height):0===e?e=this.canvas.width*t/this.canvas.height:0===t&&(t=this.canvas.height*e/this.canvas.width),e=Math.floor(e),t=Math.floor(t);const r=document.createElement("canvas");if(r.width=e,r.height=t,this.gifProperties){const r=this.gifProperties,n=(e,t)=>{let r=0;for(let n=0;n<t.height;n++)for(let i=0;i<t.width;i++){const s=Math.floor(i*e.width/t.width);let o=4*(Math.floor(n*e.height/t.height)*e.width+s);t.data[r++]=e.data[o++],t.data[r++]=e.data[o++],t.data[r++]=e.data[o++],t.data[r++]=e.data[o++]}};for(let i=0;i<r.numFrames;i++){const s=this.drawingContext.createImageData(e,t);n(r.frames[i].image,s),r.frames[i].image=s}}r.getContext("2d").drawImage(this.canvas,0,0,this.canvas.width,this.canvas.height,0,0,r.width,r.height),this.canvas.width=this.width=e,this.canvas.height=this.height=t,this.drawingContext.drawImage(r,0,0,e,t,0,0,e,t),this.pixels.length>0&&this.loadPixels(),this.setModified(!0)}copy(...e){let t,r,n,i,s,o,a,u,l;if(9===e.length)t=e[0],r=e[1],n=e[2],i=e[3],s=e[4],o=e[5],a=e[6],u=e[7],l=e[8];else{if(8!==e.length)throw new Error("Signature not supported");t=this,r=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],u=e[6],l=e[7]}this._copyHelper(this,t,r,n,i,s,o,a,u,l)}_copyHelper(e,t,r,n,i,s,o,a,u,l){const h=t.canvas.width/t.width;let c=0,d=0;t._renderer&&t._renderer.isP3D&&(c=t.width/2,d=t.height/2),e._renderer&&e._renderer.isP3D?(e.push(),e.resetMatrix(),e.noLights(),e.blendMode(e.BLEND),e.imageMode(e.CORNER),e._renderer.image(t,r+c,n+d,i,s,o,a,u,l),e.pop()):e.drawingContext.drawImage(t.canvas,h*(r+c),h*(n+d),h*i,h*s,o,a,u,l)}mask(e){void 0===e&&(e=this);const t=this.drawingContext.globalCompositeOperation;let r=this._pixelDensity,n=1;e instanceof ps&&(n=e._pInst._renderer._pixelDensity);const i=[e,0,0,n*e.width,n*e.height,0,0,r*this.width,r*this.height];if(this.drawingContext.globalCompositeOperation="destination-in",this.gifProperties){for(let e=0;e<this.gifProperties.frames.length;e++)this.drawingContext.putImageData(this.gifProperties.frames[e].image,0,0),this.copy(...i),this.gifProperties.frames[e].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(...i);this.drawingContext.globalCompositeOperation=t,this.setModified(!0)}filter(e,t){Ai.apply(this.canvas,Ai[e],t),this.setModified(!0)}blend(...e){const t=this.drawingContext.globalCompositeOperation,r=e[e.length-1],n=Array.prototype.slice.call(e,0,e.length-1);this.drawingContext.globalCompositeOperation=r,this.copy(...n),this.drawingContext.globalCompositeOperation=t,this.setModified(!0)}setModified(e){this._modified=e}isModified(){return this._modified}save(e,t){if(this.gifProperties)!function(e,t){const r=e.gifProperties;let n=r.loopLimit;1===n?n=null:null===n&&(n=0);const i=new Uint8Array(e.width*e.height*r.numFrames),s=[],o={};for(let t=0;t<r.numFrames;t++){const n=new Set,i=r.frames[t].image.data,a=i.length,u=new Uint32Array(e.width*e.height);for(let e=0,t=0;e<a;e+=4,t++){const r=i[e+0]<<16|i[e+1]<<8|i[e+2];n.add(r),u[t]=r}const l=[...n].sort().toString();void 0===o[l]?o[l]={freq:1,frames:[t]}:(o[l].freq+=1,o[l].frames.push(t)),s.push(u)}let a=[];const u=Object.keys(o).sort((function(e,t){return o[t].freq-o[e].freq})),l=u[0].split(",").map((e=>parseInt(e)));a=a.concat(o[l].frames);const h=new Set(l);for(let e=1;e<u.length;e++){const t=u[e].split(",").map((e=>parseInt(e))).filter((e=>!h.has(e)));if(l.length+t.length<=256){for(let e=0;e<t.length;e++)l.push(t[e]),h.add(t[e]);a=a.concat(o[u[e]].frames)}}a=new Set(a);const c={};for(let e=0;e<l.length;e++)c[l[e]]||(c[l[e]]=e);let d=1;for(;d<l.length;)d<<=1;l.length=d;const p={loop:n,palette:new Uint32Array(l)},f=new omggif.GifWriter(i,e.width,e.height,p);let m={};for(let t=0;t<r.numFrames;t++){const n=!a.has(t),i=n?[]:l,o=new Uint8Array(e.width*e.height),u={},h=new Set;s[t].forEach(((e,r)=>{n?(void 0===u[e]&&(u[e]=i.length,i.push(e)),o[r]=u[e]):o[r]=c[e],t>0&&s[t-1][r]!==e&&h.add(e)}));const d={},p=i.filter((e=>!h.has(e)));if(p.length>0){const e=p[0],r=n?u[e]:c[e];if(t>0){for(let e=0;e<s[t].length;e++)s[t-1][e]===s[t][e]&&(o[e]=r);d.transparent=r,m.frameOpts.disposal=1}}if(d.delay=r.frames[t].delay/10,n){let e=1;for(;e<i.length;)e<<=1;i.length=e,d.palette=new Uint32Array(i)}t>0&&f.addFrame(0,0,e.width,e.height,m.pixelPaletteIndex,m.frameOpts),m={pixelPaletteIndex:o,frameOpts:d}}m.frameOpts.disposal=1,f.addFrame(0,0,e.width,e.height,m.pixelPaletteIndex,m.frameOpts);const g="gif";ki(new Blob([i.slice(0,f.end())],{type:"image/gif"}),t,g)}(this,e);else{let r,n=this.canvas;switch(t=t||Ni(e,t)[1]||"png"){default:r="image/png";break;case"webp":r="image/webp";break;case"jpeg":case"jpg":r="image/jpeg"}n.toBlob((r=>{ki(r,e,t)}),r)}}async toBlob(){return new Promise((e=>{this.canvas.toBlob(e)}))}reset(){if(this.gifProperties){const e=this.gifProperties;e.playing=!0,e.timeSinceStart=0,e.timeDisplayed=0,e.lastChangeTime=0,e.loopCount=0,e.displayIndex=0,this.drawingContext.putImageData(e.frames[0].image,0,0)}}getCurrentFrame(){if(this.gifProperties){const e=this.gifProperties;return e.displayIndex%e.numFrames}}setFrame(e){if(this.gifProperties){const t=this.gifProperties;e<t.numFrames&&e>=0?(t.timeDisplayed=0,t.lastChangeTime=0,t.displayIndex=e,this.drawingContext.putImageData(t.frames[e].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(e,t){if(this.gifProperties){const r=this.gifProperties;if(t<r.numFrames&&t>=0)r.frames[t].delay=e;else for(const t of r.frames)t.delay=e}}};function Oi(e,t){e.Image=Mi,Mi.prototype._friendlyError=e._friendlyError}"undefined"!=typeof p5&&Oi(p5);const Bi=function(e,t){const r=Math.min(e,t.length);return Array.isArray(t)&&e!==t.length&&console.warn("When working with two vectors of different sizes, the smaller dimension is used. In this operation, both vector will be treated as "+r+"D vectors, and any additional values of the linger vector will be ignored."),r},Li=function(e,t){for(;e.length>t;)e.pop()};class Pi{values=[];static friendlyErrorsDisabled(){return!0}constructor(...e){if(0===e.length&&this._friendlyError("Requires valid arguments.","p5.Vector"),"function"==typeof e[0]&&(this.isPInst=!0,this._fromRadians=e.shift(),this._toRadians=e.shift()),this.values=e,Array.isArray(e))for(let t=0;t<e.length;t++){const r=e[t];if("number"!=typeof r||!Number.isFinite(r)){Pi.friendlyErrorsDisabled()||this._friendlyError("Arguments contain non-finite numbers","p5.Vector"),this.values=[];break}}else this.values=[];this.isVector=!0}_friendlyError(e){}get dimensions(){return this.values.length}get x(){return this.values[0]||0}getValue(e){if(e<this.values.length)return this.values[e];this._friendlyError("The index parameter is trying to set a value outside the bounds of the vector","p5.Vector.setValue")}setValue(e,t){e<this.values.length?this.values[e]=t: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(e){this.values.length>1&&(this.values[0]=e)}set y(e){this.values.length>1&&(this.values[1]=e)}set z(e){this.values.length>2&&(this.values[2]=e)}set w(e){this.values.length>3&&(this.values[3]=e)}toString(){return`vector[${this.values.join(", ")}]`}set(...e){return e[0]instanceof Pi?this.values=e[0].values.slice():Array.isArray(e[0])?this.values=e[0].map((e=>e||0)):this.values=e.map((e=>e||0)),this}copy(){return this.isPInst?new Pi(this._fromRadians,this._toRadians,...this.values):new Pi(...this.values)}add(e){const t=Bi(this.dimensions,e);Li(this.values,t);for(let t=0;t<this.values.length;t++)this.values[t]+=e[t];return this}rem(e){const t=Bi(this.dimensions,e);if(Li(this.values,t),Array.isArray(e))for(let t=0;t<this.values.length;t++)e[t]>0&&(this.values[t]=this.values[t]%e[t]);else if(e>0)for(let t=0;t<this.values.length;t++)this.values[t]=this.values[t]%e;return this}sub(e){const t=Bi(this.dimensions,e);Li(this.values,t);for(let t=0;t<this.values.length;t++)this.values[t]-=e[t];return this}mult(e){const t=Bi(this.dimensions,e);if(Li(this.values,t),Array.isArray(e))for(let t=0;t<this.values.length;t++)this.values[t]*=e[t];else for(let t=0;t<this.values.length;t++)this.values[t]*=e;return this}div(e){const t=Bi(this.dimensions,e);if(Array.isArray(e)){for(let r=0;r<t;r++)if("number"!=typeof e[r]||0===e[r])return this.friendlyErrorsDisabled()||console.warn("p5.Vector.prototype.div","Arguments contain components that are 0"),this}else if("number"!=typeof e||0===e)return this.friendlyErrorsDisabled()||console.warn("p5.Vector.prototype.div","Arguments contain components that are 0"),this;if(Li(this.values,t),Array.isArray(e))for(let t=0;t<this.values.length;t++)this.values[t]/=e[t];else for(let t=0;t<this.values.length;t++)this.values[t]/=e;return this}mag(){let e=0;for(let t=0;t<this.values.length;t++){const r=this.values[t];e+=r*r}return Math.sqrt(e)}magSq(){let e=0;for(let t=0;t<this.values.length;t++){const r=this.values[t];e+=r*r}return e}dot(...e){let t=e;e[0]instanceof Pi&&(t=e[0].values);const r=Bi(this.dimensions,t);let n=0;for(let e=0;e<r;e++)n+=this.values[e]*t[e];return n}cross(e){const t=this.y*e.z-this.z*e.y,r=this.z*e.x-this.x*e.z,n=this.x*e.y-this.y*e.x;return this.isPInst?new Pi(this._fromRadians,this._toRadians,t,r,n):new Pi(t,r,n)}dist(e){const t=Bi(this.dimensions,e.values);let r=0;for(let n=0;n<t;n++){const t=this.values[n]-e.values[n];r+=t*t}return Math.sqrt(r)}normalize(){const e=this.mag();return 0!==e&&this.mult(1/e),this}limit(e){const t=this.magSq();return t>e*e&&this.div(Math.sqrt(t)).mult(e),this}setMag(e){return this.normalize().mult(e)}heading(){const e=Math.atan2(this.y,this.x);return this.isPInst?this._fromRadians(e):e}setHeading(e){if(this.dimensions<2||this._values instanceof Array&&this._values.slice(2).some((e=>0!==e)))return p5._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;const t=this.mag();return this.x=t*Math.cos(e),this.y=t*Math.sin(e),this}rotate(e){let t=this.heading()+e;this.isPInst&&(t=this._toRadians(t));const r=this.mag();return this.x=Math.cos(t)*r,this.y=Math.sin(t)*r,this}angleBetween(e){if(0===this.magSq()*e.magSq())return NaN;const t=this.cross(e);let r=Math.atan2(t.mag(),this.dot(e))*Math.sign(t.z||1);return this.isPInst&&(r=this._fromRadians(r)),r}lerp(e,t,r,n){return e instanceof Pi?this.lerp(e.x,e.y,e.z,t):(this.x+=(e-this.x)*n||0,this.y+=(t-this.y)*n||0,this.z+=(r-this.z)*n||0,this)}slerp(e,t){if(0===t)return this;if(1===t)return this.set(e);const r=this.mag(),n=e.mag();if(0===r*n)return this.mult(1-t).add(e.x*t,e.y*t,e.z*t),this;const i=this.cross(e),s=i.mag(),o=Math.atan2(s,this.dot(e));if(s>0)i.x/=s,i.y/=s,i.z/=s;else{if(o<.5*Math.PI)return this.mult(1-t).add(e.x*t,e.y*t,e.z*t),this;0===this.z&&0===e.z?i.set(0,0,1):0!==this.x?i.set(this.y,-this.x,0).normalize():i.set(1,0,0)}const a=i.cross(this),u=1-t+t*n/r,l=u*Math.cos(t*o),h=u*Math.sin(t*o);return this.x=this.x*l+a.x*h,this.y=this.y*l+a.y*h,this.z=this.z*l+a.z*h,this}reflect(e){const t=Pi.normalize(e);return this.sub(t.mult(2*this.dot(t)))}array(){return[this.x||0,this.y||0,this.z||0]}equals(...e){let t;t=e[0]instanceof Pi?e[0].values:Array.isArray(e[0])?e[0]:e;for(let e=0;e<this.values.length;e++)if(this.values[e]!==(t[e]||0))return!1;return!0}clampToZero(){for(let e=0;e<this.values.length;e++)this.values[e]=this._clampToZero(this.values[e]);return this}_clampToZero(e){return Math.abs((e||0)-0)<=Number.EPSILON?0:e}static fromAngle(e,t){return void 0===t&&(t=1),new Pi(t*Math.cos(e),t*Math.sin(e))}static fromAngles(e,t,r){void 0===r&&(r=1);const n=Math.cos(t),i=Math.sin(t),s=Math.cos(e),o=Math.sin(e);return new Pi(r*o*i,-r*s,r*o*n)}static random2D(){return this.fromAngle(Math.random()*b)}static random3D(){const e=Math.random()*b,t=2*Math.random()-1,r=Math.sqrt(1-t*t),n=r*Math.cos(e),i=r*Math.sin(e);return new Pi(n,i,t)}static copy(e){return e.copy(e)}static add(e,t,r){return r?r.set(e):(r=e.copy(),3===arguments.length&&this._friendlyError("The target parameter is undefined, it should be of type p5.Vector","p5.Vector.add")),r.add(t),r}static rem(e,t){if(e instanceof Pi&&t instanceof Pi){let r=e.copy();return r.rem(t),r}}static sub(e,t,r){return r?r.set(e):(r=e.copy(),3===arguments.length&&this._friendlyError("The target parameter is undefined, it should be of type p5.Vector","p5.Vector.sub")),r.sub(t),r}static mult(e,t,r){return r?r.set(e):(r=e.copy(),3===arguments.length&&this._friendlyError("The target parameter is undefined, it should be of type p5.Vector","p5.Vector.mult")),r.mult(t),r}static rotate(e,t,r){return 2===arguments.length?r=e.copy():(r instanceof Pi||this._friendlyError("The target parameter should be of type p5.Vector","p5.Vector.rotate"),r.set(e)),r.rotate(t),r}static div(e,t,r){return r?r.set(e):(r=e.copy(),3===arguments.length&&this._friendlyError("The target parameter is undefined, it should be of type p5.Vector","p5.Vector.div")),r.div(t),r}static dot(e,t){return e.dot(t)}static cross(e,t){return e.cross(t)}static dist(e,t){return e.dist(t)}static lerp(e,t,r,n){return n?n.set(e):(n=e.copy(),4===arguments.length&&this._friendlyError("The target parameter is undefined, it should be of type p5.Vector","p5.Vector.lerp")),n.lerp(t,r),n}static slerp(e,t,r,n){return n?n.set(e):(n=e.copy(),4===arguments.length&&this._friendlyError("The target parameter is undefined, it should be of type p5.Vector","p5.Vector.slerp")),n.slerp(t,r),n}static mag(e){return e.mag()}static magSq(e){return e.magSq()}static normalize(e,t){return arguments.length<2?t=e.copy():(t instanceof Pi||this._friendlyError("The target parameter should be of type p5.Vector","p5.Vector.normalize"),t.set(e)),t.normalize()}static limit(e,t,r){return arguments.length<3?r=e.copy():(r instanceof Pi||this._friendlyError("The target parameter should be of type p5.Vector","p5.Vector.limit"),r.set(e)),r.limit(t)}static setMag(e,t,r){return arguments.length<3?r=e.copy():(r instanceof Pi||this._friendlyError("The target parameter should be of type p5.Vector","p5.Vector.setMag"),r.set(e)),r.setMag(t)}static heading(e){return e.heading()}static angleBetween(e,t){return e.angleBetween(t)}static reflect(e,t,r){return arguments.length<3?r=e.copy():(r instanceof Pi||this._friendlyError("The target parameter should be of type p5.Vector","p5.Vector.reflect"),r.set(e)),r.reflect(t)}static array(e){return e.array()}static equals(e,t){let r;return e instanceof Pi?r=e:e instanceof Array?r=(new Pi).set(e):this._friendlyError("The v1 parameter should be of type Array or p5.Vector","p5.Vector.equals"),r.equals(t)}}function Ri(e,t){e.Vector=Pi,Pi.prototype._friendlyError=e._friendlyError,Pi.prototype.friendlyErrorsDisabled=function(){return e.disableFriendlyErrors}}function Vi(e){let t=0;for(let r=1;r<e.length;r++)t+=e[r-1].position.dist(e[r].position);return t}"undefined"!=typeof p5&&Ri(p5);class Ui{constructor(e){Object.assign(this,e)}}class zi{vertices;_shape=null;_primitivesIndex=null;_contoursIndex=null;isClosing=!1;constructor(...e){if(new.target===zi)throw new Error("ShapePrimitive is an abstract class: it cannot be instantiated.");if(!(e.length>0))throw new Error("At least one vertex must be passed to the constructor.");this.vertices=e}get vertexCount(){return this.vertices.length}get vertexCapacity(){throw new Error("Getter vertexCapacity must be implemented.")}get _firstInterpolatedVertex(){return this.startVertex()}get canOverrideAnchor(){return!1}accept(e){throw new Error("Method accept() must be implemented.")}addToShape(e){let t=e.at(-1);if(0===t.primitives.length)t.primitives.push(this);else{let r,n,i=e.at(-1,-1),s=i instanceof this.constructor,o=i.vertexCapacity-i.vertexCount;s&&o>0?(r=this.vertices.splice(0,o),n=this.vertices,i.vertices.push(...r),n.length>0&&t.primitives.push(this)):t.primitives.push(this)}if(this.vertices.length>0){let t=e.at(-1);this._primitivesIndex=t.primitives.length-1,this._contoursIndex=e.contours.length-1,this._shape=e}return e.at(-1,-1)}get _nextPrimitive(){return this._belongsToShape?this._shape.at(this._contoursIndex,this._primitivesIndex+1):null}get _belongsToShape(){return null!==this._shape}handlesClose(){return!1}close(e){throw new Error("Unimplemented!")}}class ji{#n;primitives;constructor(e=8){this.#n=e,this.primitives=[]}get kind(){const e=0===this.primitives.length,t=8===this.#n;return e&&t?7:this.#n}accept(e){for(const t of this.primitives)t.accept(e)}}class Gi extends zi{get vertexCapacity(){return 1}accept(e){e.visitAnchor(this)}getEndVertex(){return this.vertices[0]}}class $i extends zi{constructor(...e){if(super(...e),new.target===$i)throw new 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]}}class Hi extends $i{get vertexCapacity(){return 1}accept(e){e.visitLineSegment(this)}}let qi=class extends $i{#i;#s;constructor(e,...t){super(...t);let r=Array.isArray(e)?e[0]:e;this.#i=r,this.#s=r}get order(){return this.#i}get vertexCapacity(){return this.#s}#o;hullLength(){return void 0===this.#o&&(this.#o=Vi([this.getStartVertex(),...this.vertices])),this.#o}accept(e){e.visitBezierSegment(this)}};class Wi extends $i{#s=1/0;_splineProperties={ends:Ge,tightness:0};get vertexCapacity(){return this.#s}accept(e){e.visitSplineSegment(this)}get _comesAfterSegment(){return this._previousPrimitive instanceof $i}get canOverrideAnchor(){return this._splineProperties.ends===$e}get _firstInterpolatedVertex(){return this._splineProperties.ends===$e?this._comesAfterSegment?this.vertices[1]:this.vertices[0]:this.getStartVertex()}get _chainedToSegment(){if(this._belongsToShape&&this._comesAfterSegment){let e=this._firstInterpolatedVertex.position;return this.getStartVertex().position.equals(e)}return!1}addToShape(e){const t=super.addToShape(e);if(this._splineProperties.ends=e._splineProperties.ends,this._splineProperties.tightness=e._splineProperties.tightness,this._splineProperties.ends!==$e)return t;let r=!this._belongsToShape,n=e.at(-1,-1);if(r&&2===n.vertices.length&&n._comesAfterSegment&&!n._chainedToSegment){let e=n._firstInterpolatedVertex.position,t=n.getStartVertex().position;console.warn((i=e.array(),s=t.array(),`Spline does not start where previous path segment ends:\n      second spline vertex at (${i})\n      expected to be at (${s}).`))}var i,s;return t}getEndVertex(){return this._splineProperties.ends===Ge?super.getEndVertex():this._splineProperties.ends===$e?this.vertices.at(-2):this.getStartVertex()}getControlPoints(){let e=[];this._comesAfterSegment&&e.push(this.getStartVertex()),e.push(this.getStartVertex());for(const t of this.vertices)e.push(t);const t=this.getStartVertex();return this._splineProperties.ends===Ge?(e.unshift(t),e.push(this.vertices.at(-1))):this._splineProperties.ends===He&&(e.unshift(this.vertices.at(-1)),e.push(t,this.vertices.at(0))),e}handlesClose(){if(!this._belongsToShape)return!1;return 2===this._shape.at(this._contoursIndex).primitives.length&&1===this._primitivesIndex}close(){this._splineProperties.ends=He}}class Xi extends zi{get vertexCapacity(){return 1}accept(e){e.visitPoint(this)}}class Zi extends zi{get vertexCapacity(){return 2}accept(e){e.visitLine(this)}}class Yi extends zi{get vertexCapacity(){return 3}accept(e){e.visitTriangle(this)}}class Ki extends zi{get vertexCapacity(){return 4}accept(e){e.visitQuad(this)}}class Ji extends zi{#a;#u;#l;#h;#c;#d;#p;#s=2;constructor(e,t,r,n,i,s,o,a,u){super(e,t),this.#a=r,this.#u=n,this.#l=i,this.#h=s,this.#c=o,this.#d=a,this.#p=u}get x(){return this.#a}get y(){return this.#u}get w(){return this.#l}get h(){return this.#h}get start(){return this.#c}get stop(){return this.#d}get mode(){return this.#p}get startVertex(){return this.vertices[0]}get endVertex(){return this.vertices[1]}get vertexCapacity(){return this.#s}accept(e){e.visitArcPrimitive(this)}}class Qi extends zi{#a;#u;#l;#h;#s=1;constructor(e,t,r,n,i){super(e),this.#a=t,this.#u=r,this.#l=n,this.#h=i}get x(){return this.#a}get y(){return this.#u}get w(){return this.#l}get h(){return this.#h}get vertexCapacity(){return this.#s}accept(e){e.visitEllipsePrimitive(this)}}class es extends zi{#a;#u;#l;#h;#f;#m;#g;#y;#s=1;constructor(e,t,r,n,i,s,o,a,u){super(e),this.#a=t,this.#u=r,this.#l=n,this.#h=i,this.#f=s,this.#m=o,this.#g=a,this.#y=u}get x(){return this.#a}get y(){return this.#u}get w(){return this.#l}get h(){return this.#h}get tl(){return this.#f}get tr(){return this.#m}get br(){return this.#g}get bl(){return this.#y}get vertexCapacity(){return this.#s}accept(e){e.visitRectPrimitive(this)}}class ts extends zi{get vertexCapacity(){return 1/0}accept(e){e.visitTriangleFan(this)}}class rs extends zi{get vertexCapacity(){return 1/0}accept(e){e.visitTriangleStrip(this)}}class ns extends zi{get vertexCapacity(){return 1/0}accept(e){e.visitQuadStrip(this)}}const is={vertex:{[R]:(...e)=>new Gi(...e),[V]:(...e)=>new Hi(...e),[k]:(...e)=>new Xi(...e),[N]:(...e)=>new Zi(...e),[M]:(...e)=>new Yi(...e),[L]:(...e)=>new Ki(...e),[O]:(...e)=>new ts(...e),[B]:(...e)=>new rs(...e),[P]:(...e)=>new ns(...e)},bezierVertex:{[R]:(e,...t)=>new Gi(...t),[V]:(e,...t)=>new qi(e,...t)},splineVertex:{[R]:(...e)=>new Gi(...e),[V]:(...e)=>new Wi(...e)}};class ss{#v;#b;#x;#_=3;kind=null;contours=[];_splineProperties={tightness:0,ends:Ge};userVertexProperties=null;constructor(e,t=is){this.#b=e,this.#v=e,this.#x=t;for(const e in this.#v)"position"!==e&&"textureCoordinates"!==e&&(this[e]=function(t){this.#v[e]=t})}serializeToArray(e){if(null==e)return[];if(e instanceof Number)return[e];if(e instanceof Array)return e;if(e.array instanceof Function)return e.array();throw new Error(`Can't convert ${e} to array!`)}vertexToArray(e){const t=[];for(const r in this.#v){if(this.userVertexProperties&&r in this.userVertexProperties)continue;const n=e[r];t.push(...this.serializeToArray(n))}for(const r in this.userVertexProperties)r in e?t.push(...this.serializeToArray(e[r])):t.push(...new Array(this.userVertexProperties[r]).fill(0));return t}hydrateValue(e,t){if(null===t)return null;if(t instanceof Number)return e.shift();if(t instanceof Array){const r=[];for(let n=0;n<t.length;n++)r.push(e.shift());return r}if(t instanceof Pi)return new Pi(e.shift(),e.shift(),e.shift());if(t instanceof Tn){const t=[e.shift(),e.shift(),e.shift(),e.shift()];return new Tn(t)}}arrayToVertex(e){const t={},r=[...e];for(const e in this.#v){if(this.userVertexProperties&&e in this.userVertexProperties)continue;const n=this.#v[e];t[e]=this.hydrateValue(r,n)}for(const e in this.userVertexProperties){const n=this.#v[e];t[e]=this.hydrateValue(r,n)}return t}arrayScale(e,t){return e.map((e=>e*t))}arraySum(e,...t){return e.map(((e,r)=>{let n=e;for(let e=0;e<t.length;e++)n+=t[e][r];return n}))}arrayMinus(e,t){return e.map(((e,r)=>e-t[r]))}evaluateCubicBezier([e,t,r,n],i){return this.arraySum(this.arrayScale(e,Math.pow(1-i,3)),this.arrayScale(t,3*Math.pow(1-i,2)*i),this.arrayScale(r,3*(1-i)*Math.pow(i,2)),this.arrayScale(n,Math.pow(i,3)))}evaluateQuadraticBezier([e,t,r],n){return this.arraySum(this.arrayScale(e,Math.pow(1-n,2)),this.arrayScale(t,2*(1-n)*n),this.arrayScale(r,n*n))}catmullRomToBezier(e,t){let r=1-t,n=[];for(let t=0;t+3<e.length;t++){const[i,s,o,a]=e.slice(t,t+4),u=this.arraySum(s,this.arrayScale(this.arrayMinus(o,i),r/6)),l=this.arraySum(o,this.arrayScale(this.arrayMinus(s,a),r/6)),h=o;n.push([u,l,h])}return n}at(e,t,r){let n,i;switch(n=this.contours.at(e),arguments.length){case 1:return n;case 2:return n.primitives.at(t);case 3:return i=n.primitives.at(t),i.vertices.at(r)}}reset(){this.#v={...this.#b},this.kind=null,this.contours=[],this.userVertexProperties=null}vertexProperty(e,t){this.userVertexProperties=this.userVertexProperties||{};const r=this.vertexPropertyKey(e),n=Array.isArray(t)?t:[t];this.userVertexProperties[r]||(this.userVertexProperties[r]=n.length),this.#v[r]=n}vertexPropertyName(e){return e.replace(/Src$/,"")}vertexPropertyKey(e){return e+"Src"}bezierOrder(...e){this.#_=e}splineProperty(e,t){this._splineProperties[e]=t}splineProperties(e){if(!e)return this._splineProperties;for(const t in e)this.splineProperty(t,e[t])}#w(e,t){return this.#v.position=e,void 0!==t&&(this.#v.textureCoordinates=t),new Ui(this.#v)}#C(e,t,...r){let n=this.#x[e][t];return"bezierVertex"===e?n(this.#_,...r):n(...r)}#E(e,t,r){let n=e,i=this.at(-1).kind,s=this.#w(t,r);return this.#C(n,i,s).addToShape(this)}vertex(e,t,{isClosing:r=!1}={}){const n=this.contours,i=n[n.length-1];if(void 0!==i&&i.primitives.length>0&&8===i.kind){const s=this.#w(e,t),o=i.primitives,a=o[o.length-1];if(!r&&a instanceof Hi&&!a.isClosing)return void a.vertices.push(s);const u=new Hi(s);return u.isClosing=r,u._primitivesIndex=o.length,u._contoursIndex=n.length-1,u._shape=this,void o.push(u)}this.#E("vertex",e,t).isClosing=r}bezierVertex(e,t){this.#E("bezierVertex",e,t)}splineVertex(e,t){this.#E("splineVertex",e,t)}arcVertex(e,t){this.#E("arcVertex",e,t)}arcPrimitive(e,t,r,n,i,s,o){this.beginShape();const a=e+r/2,u=t+n/2,l=r/2,h=n/2,c=this.#w(new Pi(a+l*Math.cos(i),u+h*Math.sin(i))),d=this.#w(new Pi(a+l*Math.cos(s),u+h*Math.sin(s)));return new Ji(c,d,e,t,r,n,i,s,o).addToShape(this),this.endShape(),this}ellipsePrimitive(e,t,r,n){const i=this.#w(new Pi(e+r/2,t+n/2));return new Qi(i,e,t,r,n).addToShape(this)}rectPrimitive(e,t,r,n,i,s,o,a){const u=this.#w(new Pi(e,t));return new es(u,e,t,r,n,i,s,o,a).addToShape(this)}point(e,t){const r=this.#w(new Pi(e,t));return new Xi(r).addToShape(this)}line(e,t,r,n){const i=this.#w(new Pi(e,t)),s=this.#w(new Pi(r,n));return new Zi(i,s).addToShape(this)}triangle(e,t,r,n,i,s){const o=this.#w(new Pi(e,t)),a=this.#w(new Pi(r,n)),u=this.#w(new Pi(i,s));return new Yi(o,a,u).addToShape(this)}quad(e,t,r,n,i,s,o,a){const u=this.#w(new Pi(e,t)),l=this.#w(new Pi(r,n)),h=this.#w(new Pi(i,s)),c=this.#w(new Pi(o,a));return new Ki(u,l,h,c).addToShape(this)}beginContour(e=8){7===this.at(-1)?.kind&&this.contours.pop(),this.contours.push(new ji(e))}endContour(e=z,t=this.contours.length-1){const r=this.at(t);if(e===U){const e=8===r.kind,n=this.at(t,0,0),i=Object.hasOwn(n,"position"),s=this.at(t,-1);if(e&&i)if(s.handlesClose())s.close(n);else{const e=this.contours.splice(t+1,this.contours.length-t-1),r=this.#v;this.#v={...r};for(const e in n)"position"!==e&&"textureCoordinates"!==e&&(this.#v[e]=n[e]);this.vertex(n.position,n.textureCoordinates,{isClosing:!0}),this.#v=r,this.contours.push(...e)}}}beginShape(e=8){this.kind=e,this.beginContour(e)}endShape(e=z){e===U&&this.endContour(e,0)}accept(e){for(const t of this.contours)t.accept(e)}}class os{constructor(){if(new.target===os)throw new Error("PrimitiveVisitor is an abstract class: it cannot be instantiated.")}visitAnchor(e){throw new Error("Method visitAnchor() has not been implemented.")}visitLineSegment(e){throw new Error("Method visitLineSegment() has not been implemented.")}visitBezierSegment(e){throw new Error("Method visitBezierSegment() has not been implemented.")}visitSplineSegment(e){throw new Error("Method visitSplineSegment() has not been implemented.")}visitArcSegment(e){throw new Error("Method visitArcSegment() has not been implemented.")}visitArcPrimitive(e){throw new Error("Method visitArcPrimitive() has not been implemented.")}visitEllipsePrimitive(e){throw new Error("Method visitEllipsePrimitive() has not been implemented.")}visitRectPrimitive(e){throw new Error("Method visitRectPrimitive() has not been implemented.")}visitPoint(e){throw new Error("Method visitPoint() has not been implemented.")}visitLine(e){throw new Error("Method visitLine() has not been implemented.")}visitTriangle(e){throw new Error("Method visitTriangle() has not been implemented.")}visitQuad(e){throw new Error("Method visitQuad() has not been implemented.")}visitTriangleFan(e){throw new Error("Method visitTriangleFan() has not been implemented.")}visitTriangleStrip(e){throw new Error("Method visitTriangleStrip() has not been implemented.")}visitQuadStrip(e){throw new Error("Method visitQuadStrip() has not been implemented.")}}class as extends os{path=new Path2D;strokePath=null;fillPath=null;strokeWeight;hasFill;hasStroke;constructor({strokeWeight:e,hasFill:t=!0,hasStroke:r=!0}){super(),this.strokeWeight=e,this.hasFill=t,this.hasStroke=r}visitAnchor(e){let t=e.getEndVertex();this.path.moveTo(t.position.x,t.position.y)}visitLineSegment(e){if(e.isClosing)this.path.closePath();else{const t=e.vertices;for(let e=0;e<t.length;e++){const r=t[e].position;this.path.lineTo(r.x,r.y)}}}visitBezierSegment(e){let[t,r,n]=e.vertices;switch(e.order){case 2:this.path.quadraticCurveTo(t.position.x,t.position.y,r.position.x,r.position.y);break;case 3:this.path.bezierCurveTo(t.position.x,t.position.y,r.position.x,r.position.y,n.position.x,n.position.y)}}visitSplineSegment(e){const t=e._shape;if(e._splineProperties.ends===$e&&!e._comesAfterSegment){let t=e._firstInterpolatedVertex;this.path.moveTo(t.position.x,t.position.y)}const r=e.getControlPoints().map((e=>t.vertexToArray(e)));let n=t.catmullRomToBezier(r,e._splineProperties.tightness).map((e=>e.map((e=>t.arrayToVertex(e)))));for(const e of n){const t=e.flatMap((e=>[e.position.x,e.position.y]));this.path.bezierCurveTo(...t)}}visitPoint(e){const{x:t,y:r}=e.vertices[0].position;this.path.moveTo(t,r),this.path.lineTo(t+1e-5,r)}visitLine(e){const{x:t,y:r}=e.vertices[0].position,{x:n,y:i}=e.vertices[1].position;this.path.moveTo(t,r),this.path.lineTo(n,i)}visitTriangle(e){const[t,r,n]=e.vertices;this.path.moveTo(t.position.x,t.position.y),this.path.lineTo(r.position.x,r.position.y),this.path.lineTo(n.position.x,n.position.y),this.path.closePath()}visitQuad(e){const[t,r,n,i]=e.vertices;this.path.moveTo(t.position.x,t.position.y),this.path.lineTo(r.position.x,r.position.y),this.path.lineTo(n.position.x,n.position.y),this.path.lineTo(i.position.x,i.position.y),this.path.closePath()}visitTriangleFan(e){const[t,...r]=e.vertices;for(let e=0;e<r.length-1;e++){const n=r[e],i=r[e+1];this.path.moveTo(t.position.x,t.position.y),this.path.lineTo(n.position.x,n.position.y),this.path.lineTo(i.position.x,i.position.y),this.path.closePath()}}visitTriangleStrip(e){for(let t=0;t<e.vertices.length-2;t++){const r=e.vertices[t],n=e.vertices[t+1],i=e.vertices[t+2];this.path.moveTo(r.position.x,r.position.y),this.path.lineTo(n.position.x,n.position.y),this.path.lineTo(i.position.x,i.position.y),this.path.closePath()}}visitArcPrimitive(e){const t=e.x+e.w/2,r=e.y+e.h/2,n=e.w/2,i=e.h/2,s=t+n*Math.cos(e.start),o=r+i*Math.sin(e.start),a=e.stop-e.start,u=Math.abs(a%(2*Math.PI))<1e-5&&Math.abs(a)>1e-5,l=!(e.mode===j||e.mode===z||u);this.hasFill&&(this.fillPath||(this.fillPath=new Path2D(this.path)),this.fillPath.moveTo(s,o),this.fillPath.ellipse(t,r,n,i,0,e.start,e.stop),l&&this.fillPath.lineTo(t,r),this.fillPath.closePath()),this.hasStroke&&(this.strokePath||(this.strokePath=new Path2D(this.path)),this.strokePath.moveTo(s,o),this.strokePath.ellipse(t,r,n,i,0,e.start,e.stop),e.mode===G&&l&&this.strokePath.lineTo(t,r),e.mode!==G&&e.mode!==j||this.strokePath.closePath()),this.path.moveTo(s,o),this.path.ellipse(t,r,n,i,0,e.start,e.stop)}visitEllipsePrimitive(e){const t=e.x+e.w/2,r=e.y+e.h/2,n=e.w/2,i=e.h/2;this.path.moveTo(t+n,r),this.path.ellipse(t,r,n,i,0,0,2*Math.PI)}visitRectPrimitive(e){const t=e.x,r=e.y,n=e.w,i=e.h;let s=e.tl,o=e.tr,a=e.br,u=e.bl;if(void 0===s)this.path.rect(t,r,n,i);else{void 0===o&&(o=s),void 0===a&&(a=o),void 0===u&&(u=a);const e=Math.abs(n),l=Math.abs(i),h=e/2,c=l/2;e<2*s&&(s=h),l<2*s&&(s=c),e<2*o&&(o=h),l<2*o&&(o=c),e<2*a&&(a=h),l<2*a&&(a=c),e<2*u&&(u=h),l<2*u&&(u=c),this.path.roundRect(t,r,n,i,[s,o,a,u])}}visitQuadStrip(e){for(let t=0;t<e.vertices.length-3;t+=2){const r=e.vertices[t],n=e.vertices[t+1],i=e.vertices[t+2],s=e.vertices[t+3];this.path.moveTo(r.position.x,r.position.y),this.path.lineTo(n.position.x,n.position.y),this.path.lineTo(s.position.x,s.position.y),this.path.lineTo(i.position.x,i.position.y),this.path.closePath()}}}class us extends os{contours=[];curveDetail;pointsToLines;constructor({curveDetail:e=1,pointsToLines:t=!0}={}){super(),this.curveDetail=e,this.pointsToLines=t}lastContour(){return this.contours[this.contours.length-1]}visitAnchor(e){this.contours.push([]);const t=e._nextPrimitive;t?.canOverrideAnchor?this.lastContour().push(t._firstInterpolatedVertex):this.lastContour().push(e.getEndVertex())}visitLineSegment(e){const t=this.lastContour(),r=e.vertices;for(let e=0;e<r.length;e++)t.push(r[e])}visitBezierSegment(e){const t=this.lastContour(),r=Math.max(1,Math.ceil(e.hullLength()*this.curveDetail)),n=[e.getStartVertex(),...e.vertices].map((t=>e._shape.vertexToArray(t)));for(let i=0;i<r;i++){const s=(i+1)/r;t.push(e._shape.arrayToVertex(3===e.order?e._shape.evaluateCubicBezier(n,s):e._shape.evaluateQuadraticBezier(n,s)))}}visitSplineSegment(e){const t=e._shape,r=this.lastContour(),n=e.getControlPoints().map((e=>t.vertexToArray(e)));let i=t.catmullRomToBezier(n,e._splineProperties.tightness),s=t.vertexToArray(e._firstInterpolatedVertex);for(const e of i){const n=[s,...e],i=Math.max(1,Math.ceil(Vi(n.map((e=>t.arrayToVertex(e))))*this.curveDetail));for(let e=0;e<i;e++){const s=(e+1)/i;r.push(t.arrayToVertex(t.evaluateCubicBezier(n,s)))}s=e[2]}}visitPoint(e){this.pointsToLines?this.contours.push(...e.vertices.map((e=>[e,e]))):this.contours.push(e.vertices.slice())}visitLine(e){this.contours.push(e.vertices.slice())}visitTriangle(e){this.contours.push(e.vertices.slice())}visitQuad(e){this.contours.push(e.vertices.slice())}visitTriangleFan(e){this.contours.push(e.vertices.slice())}visitTriangleStrip(e){this.contours.push(e.vertices.slice())}visitQuadStrip(e){this.contours.push(e.vertices.slice())}visitArcPrimitive(e){const t=e.startVertex,r=e.endVertex,n=e.x+e.w/2,i=e.y+e.h/2,s=e.w/2,o=e.h/2,a=(s+o)/2*Math.abs(e.stop-e.start),u=Math.max(3,Math.ceil(this.curveDetail*a)),l=[],h=(e,t,r)=>{const n={};for(const[i,s]of Object.entries(e))"position"!==i&&("number"==typeof s&&"number"==typeof t[i]?n[i]=s*(1-r)+t[i]*r:n[i]=s);return n};if(e.mode===G){const e=h(t,r,.5);e.position=new Pi(n,i),l.push(new Ui(e))}for(let a=0;a<=u;a++){const c=a/u,d=e.start+(e.stop-e.start)*c,p=h(t,r,c);p.position=new Pi(n+s*Math.cos(d),i+o*Math.sin(d)),l.push(new Ui(p))}this.contours.push(l)}visitEllipsePrimitive(e){const t=e.x+e.w/2,r=e.y+e.h/2,n=e.w/2,i=e.h/2,s=(n+i)/2,o=2*Math.PI*s,a=Math.max(3,Math.ceil(this.curveDetail*o)),u=[],l=e.vertices[0];for(let e=0;e<=a;e++){const s=2*Math.PI*e/a,o={};for(const[e,t]of Object.entries(l))"position"!==e&&(o[e]=t);o.position=new Pi(t+n*Math.cos(s),r+i*Math.sin(s)),u.push(new Ui(o))}this.contours.push(u)}visitRectPrimitive(e){const t=e.x,r=e.y,n=e.w,i=e.h;let s=e.tl,o=e.tr,a=e.br,u=e.bl;const l=e.vertices[0],h=(e,t)=>{const r={};for(const[e,t]of Object.entries(l))"position"!==e&&(r[e]=t);return r.position=new Pi(e,t),new Ui(r)},c=[];if(void 0===s)c.push(h(t,r)),c.push(h(t+n,r)),c.push(h(t+n,r+i)),c.push(h(t,r+i)),c.push(h(t,r));else{void 0===o&&(o=s),void 0===a&&(a=o),void 0===u&&(u=a);const e=Math.abs(n),l=Math.abs(i),d=e/2,p=l/2;e<2*s&&(s=d),l<2*s&&(s=p),e<2*o&&(o=d),l<2*o&&(o=p),e<2*a&&(a=d),l<2*a&&(a=p),e<2*u&&(u=d),l<2*u&&(u=p);const f=(e,t,r,n,i,s)=>{const o=Math.PI/2*(r+n)/2,a=Math.max(1,Math.ceil(this.curveDetail*o));for(let o=0;o<=a;o++){const u=i+o/a*(s-i);c.push(h(e+r*Math.cos(u),t+n*Math.sin(u)))}};f(t+s,r+s,s,s,Math.PI,1.5*Math.PI),f(t+n-o,r+o,o,o,1.5*Math.PI,2*Math.PI),f(t+n-a,r+i-a,a,a,0,.5*Math.PI),f(t+u,r+i-u,u,u,.5*Math.PI,Math.PI),c.push(c[0])}this.contours.push(c)}}class ls extends os{constructor(){super()}}function hs(e,t){e.Shape=ss,e.Contour=ji,e.ShapePrimitive=zi,e.Vertex=Ui,e.Anchor=Gi,e.Segment=$i,e.LineSegment=Hi,e.BezierSegment=qi,e.SplineSegment=Wi,e.Point=Xi,e.Line=Zi,e.Triangle=Yi,e.Quad=Ki,e.TriangleFan=ts,e.TriangleStrip=rs,e.QuadStrip=ns,e.PrimitiveVisitor=os,e.PrimitiveToPath2DConverter=as,e.PrimitiveToVerticesConverter=us,e.PointAtLengthGetter=ls,t.bezierOrder=function(e){return this._renderer.bezierOrder(e)},t.splineVertex=function(...e){let t=0,r=0,n=0,i=0,s=0;2===e.length?[t,r]=e:4===e.length?[t,r,i,s]=e:3===e.length?[t,r,n]=e:5===e.length&&([t,r,n,i,s]=e),this._renderer.splineVertex(t,r,n,i,s)},t.splineProperty=function(e,t){return this._renderer.splineProperty(e,t)},t.splineProperties=function(e){return this._renderer.splineProperties(e)},t.vertex=function(e,t){let r,n,i;r=n=i=0,3===arguments.length?r=arguments[2]:4===arguments.length?(n=arguments[2],i=arguments[3]):5===arguments.length&&(r=arguments[2],n=arguments[3],i=arguments[4]),this._renderer.vertex(e,t,r,n,i)},t.beginContour=function(e){this._renderer.beginContour(e)},t.endContour=function(e=z){this._renderer.endContour(e)}}"undefined"!=typeof p5&&hs(p5,p5.prototype);class cs{#S={};constructor(e){for(const t in e)this[t]=e[t]}setValue(e,t){e in this.#S||(this.#S[e]=this[e]),this[e]=t}takeDiff(){const e=this.#S;return this.#S={},e}getModified(){return this.#S}applyDiff(e){for(const e in this.#S)this[e]=this.#S[e];this.#S=e}}class ds{constructor(e={}){for(const t in e)this[t]=e[t]}clone(){return new ds(this)}}class ps{static states={strokeColor:null,strokeSet:!1,fillColor:null,fillSet:!1,tint:null,imageMode:w,rectMode:w,ellipseMode:D,strokeWeight:1,bezierOrder:3,splineProperties:new ds({ends:Ge,tightness:0}),textFont:{family:"sans-serif"},textLeading:15,leadingSet:!1,textSize:12,textAlign:A,textBaseline:I,textWrap:_e,fontStyle:xe,fontStretch:xe,fontWeight:xe,lineHeight:xe,fontVariant:xe,direction:"inherit"};constructor(e,t,r,n){this._pInst=e,this._isMainCanvas=n,this.pixels=[];const i="undefined"!=typeof window?Math.ceil(window.devicePixelRatio):1;if(n)this._pixelDensity=i;else{const t=e._pInst?._renderer?._pixelDensity;this._pixelDensity=t||i}this.width=t,this.height=r,this._events={},n&&(this._isMainCanvas=!0),this.states=new cs(ps.states),this.states.strokeColor=new Tn([0,0,0]),this.states.fillColor=new Tn([1,1,1]),this._pushPopStack=[],this._pushPopDepth=0,this._clipping=!1,this._clipInvert=!1,this._currentShape=void 0,this._supportsIndividualTextureCoordinates=void 0}get currentShape(){return this._currentShape||(this._currentShape=new ss(this.getCommonVertexProperties())),this._currentShape}remove(){}pixelDensity(e){let t;return"number"==typeof e?(e!==this._pixelDensity&&(this._pixelDensity=e),t=this,this.resize(this.width,this.height)):t=this._pixelDensity,t}push(){this._pushPopDepth++,this._pushPopStack.push(this.states.takeDiff())}pop(){this._pushPopDepth--;const e=this._pushPopStack.pop()||{},t=this.states.getModified();this.states.applyDiff(e),this.updateShapeVertexProperties(t),this.updateShapeProperties(t)}bezierOrder(e){if(void 0===e)return this.states.bezierOrder;this.states.setValue("bezierOrder",e),this.updateShapeProperties()}_individualTextureCoordinates(e,t){return void 0===this._supportsIndividualTextureCoordinates&&(this._supportsIndividualTextureCoordinates=this.getSupportedIndividualVertexProperties().textureCoordinates),this._supportsIndividualTextureCoordinates?new Pi(e,t):void 0}bezierVertex(e,t,r=0,n=0,i=0){const s=new Pi(e,t,r),o=this._individualTextureCoordinates(n,i);this.currentShape.bezierVertex(s,o)}splineProperty(e,t){if(void 0===t)return this.states.splineProperties[e];this.states.setValue("splineProperties",this.states.splineProperties.clone()),this.states.splineProperties[e]=t,this.updateShapeProperties()}splineProperties(e){if(!e)return{...this.states.splineProperties};for(const t in e)this.splineProperty(t,e[t])}splineVertex(e,t,r=0,n=0,i=0){const s=new Pi(e,t,r),o=this._individualTextureCoordinates(n,i);this.currentShape.splineVertex(s,o)}curveDetail(e){if(void 0===e)return this.states.curveDetail;this.states.setValue("curveDetail",e)}beginShape(...e){this.currentShape.reset(),this.updateShapeVertexProperties(),this.currentShape.beginShape(...e)}endShape(...e){this.currentShape.endShape(...e),this.drawShape(this.currentShape)}beginContour(e){this.currentShape.beginContour(e)}endContour(e){this.currentShape.endContour(e)}drawShape(e,t){throw new Error("Unimplemented")}vertex(e,t,r=0,n=0,i=0){const s=new Pi(e,t,r),o=this._individualTextureCoordinates(n,i);this.currentShape.vertex(s,o)}bezier(e,t,r,n,i,s,o,a){const u=this._pInst.bezierOrder();return this._pInst.bezierOrder(u),this._pInst.beginShape(),this._pInst.bezierVertex(e,t),this._pInst.bezierVertex(r,n),this._pInst.bezierVertex(i,s),this._pInst.bezierVertex(o,a),this._pInst.endShape(),this}spline(...e){if(8===e.length){const[t,r,n,i,s,o,a,u]=e;this._pInst.beginShape(),this._pInst.splineVertex(t,r),this._pInst.splineVertex(n,i),this._pInst.splineVertex(s,o),this._pInst.splineVertex(a,u),this._pInst.endShape()}else if(12===e.length){const[t,r,n,i,s,o,a,u,l,h,c,d]=e;this._pInst.beginShape(),this._pInst.splineVertex(t,r,n),this._pInst.splineVertex(i,s,o),this._pInst.splineVertex(a,u,l),this._pInst.splineVertex(h,c,d),this._pInst.endShape()}return this}beginClip(e={}){if(this._clipping)throw new 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=e.invert}endClip(){if(!this._clipping)throw new Error("It looks like you've called endClip() without beginClip(). Did you forget to call beginClip() first?");this._clipping=!1}resize(e,t){this.width=e,this.height=t}get(e,t,r,n){const i=this._pixelDensity,s=this.canvas;if(void 0===e&&void 0===t)e=t=0,r=this.width,n=this.height;else if(e*=i,t*=i,void 0===r&&void 0===n)return e<0||t<0||e>=s.width||t>=s.height?[0,0,0,0]:this._getPixel(e,t);const o=new Mi(r*i,n*i);return o.pixelDensity(i),o.canvas.getContext("2d").drawImage(s,e,t,r*i,n*i,0,0,r*i,n*i),o}scale(e,t){}fill(...e){return e.length>0&&(this.states.setValue("fillSet",!0),this.states.setValue("fillColor",this._pInst.color(...e)),this.updateShapeVertexProperties()),this.states.fillColor}noFill(){this.states.setValue("fillColor",null)}strokeWeight(e){if(void 0===e)return this.states.strokeWeight;this.states.setValue("strokeWeight",e)}stroke(...e){if(0===e.length)return this.states.strokeColor;this.states.setValue("strokeSet",!0),this.states.setValue("strokeColor",this._pInst.color(...e)),this.updateShapeVertexProperties()}noStroke(){this.states.setValue("strokeColor",null)}getCommonVertexProperties(){return{}}getSupportedIndividualVertexProperties(){return{textureCoordinates:!1}}updateShapeProperties(e){if(!e||e.bezierOrder||e.splineProperties){const e=this.currentShape;e.bezierOrder(this.states.bezierOrder),e.splineProperty("ends",this.states.splineProperties.ends),e.splineProperty("tightness",this.states.splineProperties.tightness)}}updateShapeVertexProperties(e){const t=this.getCommonVertexProperties();if(!e||Object.keys(e).some((e=>e in t))){const e=this.currentShape;for(const r in t)e[r](t[r])}}_applyDefaults(){return this}finishDraw(){}_middleAlignOffset=function(){const{textFont:e,textSize:t}=this.states,r=e?.font,n=this.textDrawingContext().measureText("X");let i=(r?.data||{})["OS/2"]?.sCapHeight;if(i){i*=t/r.data.head.unitsPerEm}else i=n.fontBoundingBoxAscent;return n.alphabeticBaseline+i/2}}const fs="video",ms="audio";class gs{constructor(e,t,r,n){this.callback=e,this.time=t,this.id=r,this.val=n}}class ys extends Ei{constructor(e,t){super(e,t);const 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(){const e=r.elt.children[0].src,t=r.elt.src===window.location.href?"":r.elt.src;return e===window.location.href?t:e},set(t){for(let e=0;e<r.elt.children.length;e++)r.elt.removeChild(r.elt.children[e]);const n=document.createElement("source");n.src=t,e.appendChild(n),r.elt.src=t,r._modified=!0}}),r._onended=function(){},r.elt.onended=function(){r._onended(r)}}play(){let e;return this.elt.currentTime===this.elt.duration&&(this.elt.currentTime=0),this.elt.readyState>1||this.elt.load(),e=this.elt.play(),e&&e.catch&&e.catch((e=>{"NotAllowedError"===e.name?console.error(e):console.error("Media play method encountered an unexpected error",e)})),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(){const t=setTimeout((()=>{console.error(e)}),500);this.elt.addEventListener("play",(()=>clearTimeout(t)),{passive:!0,once:!0})}autoplay(e){const t=this.elt.getAttribute("autoplay");if(this.elt.setAttribute("autoplay",e),e&&!t){const e=()=>this._setupAutoplayFailDetection();4===this.elt.readyState?e():this.elt.addEventListener("canplay",e,{passive:!0,once:!0})}return this}volume(e){if(void 0===e)return this.elt.volume;this.elt.volume=e}speed(e){if(void 0===e)return this.presetPlaybackRate||this.elt.playbackRate;this.loadedmetadata?this.elt.playbackRate=e:this.presetPlaybackRate=e}time(e){return void 0!==e&&(this.elt.currentTime=e),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));const e=this._frameOnCanvas!==this._pInst.frameCount;this.loadedmetadata&&e&&(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),!0===this.flipped&&(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),!0===this.flipped&&this.drawingContext.restore(),this.setModified(!0),this._frameOnCanvas=this._pInst.frameCount)}loadPixels(...e){return this._ensureCanvas(),p5.Renderer2D.prototype.loadPixels.apply(this,e)}updatePixels(e,t,r,n){return this.loadedmetadata&&(this._ensureCanvas(),p5.Renderer2D.prototype.updatePixels.call(this,e,t,r,n)),this.setModified(!0),this}get(...e){return this._ensureCanvas(),p5.Renderer2D.prototype.get.apply(this,e)}_getPixel(...e){return this.loadPixels(),p5.Renderer2D.prototype._getPixel.apply(this,e)}set(e,t,r){this.loadedmetadata&&(this._ensureCanvas(),p5.Renderer2D.prototype.set.call(this,e,t,r),this.setModified(!0))}copy(...e){this._ensureCanvas(),p5.prototype.copy.apply(this,e)}mask(...e){this.loadPixels(),this.setModified(!0),p5.Image.prototype.mask.apply(this,e)}isModified(){return this._modified}setModified(e){this._modified=e}onended(e){return this._onended=e,this}_getAudioContext(){}_getSoundOut(){}connect(e){let t,r;if(this._getAudioContext()&&this._getSoundOut())t=this._getAudioContext(),r=this._getSoundOut().input;else try{t=e.context,r=t.destination}catch(e){throw"connect() is meant to be used with Web Audio API or p5.sound.js"}this.audioSourceNode||(this.audioSourceNode=t.createMediaElementSource(this.elt),this.audioSourceNode.connect(r)),e?e.input?this.audioSourceNode.connect(e.input):this.audioSourceNode.connect(e):this.audioSourceNode.connect(r)}disconnect(){if(!this.audioSourceNode)throw"nothing to disconnect";this.audioSourceNode.disconnect()}showControls(){this.elt.style["text-align"]="inherit",this.elt.controls=!0}hideControls(){this.elt.controls=!1}addCue(e,t,r){const n=this._cueIDCounter++,i=new gs(t,e,n,r);return this._cues.push(i),this.elt.ontimeupdate||(this.elt.ontimeupdate=this._onTimeUpdate.bind(this)),n}removeCue(e){for(let t=0;t<this._cues.length;t++)this._cues[t].id===e&&this._cues.splice(t,1);0===this._cues.length&&(this.elt.ontimeupdate=null)}clearCues(){this._cues=[],this.elt.ontimeupdate=null}_onTimeUpdate(){const e=this.time();for(let t=0;t<this._cues.length;t++){const r=this._cues[t].time,n=this._cues[t].val;this._prevTime<r&&r<=e&&this._cues[t].callback(n)}this._prevTime=e}}function vs(e,t){function r(e,t,r){(t._userNode?t._userNode:document.body).appendChild(e);const n=r?new ys(e,t):new Ei(e,t);return t._elements.push(n),n}function n(e,t,n,i){const s=document.createElement(t);"string"==typeof(n=n||"")&&(n=[n]);for(const e of n){const t=document.createElement("source");t.setAttribute("src",e),s.appendChild(t)}const o=r(s,e,!0);if(o.loadedmetadata=!1,s.addEventListener("loadedmetadata",(()=>{o.width=s.videoWidth,o.height=s.videoHeight,0===o.elt.width&&(o.elt.width=s.videoWidth),0===o.elt.height&&(o.elt.height=s.videoHeight),o.presetPlaybackRate&&(o.elt.playbackRate=o.presetPlaybackRate,delete o.presetPlaybackRate),o.loadedmetadata=!0})),"function"==typeof i){const e=()=>{i(o),s.removeEventListener("canplaythrough",e)};s.addEventListener("canplaythrough",e)}return o}t.createVideo=function(e,t){return n(this,fs,e,t)},t.createAudio=function(e,t){return n(this,ms,e,t)},t.VIDEO=fs,t.AUDIO=ms,void 0===navigator.mediaDevices&&(navigator.mediaDevices={}),void 0===navigator.mediaDevices.getUserMedia&&(navigator.mediaDevices.getUserMedia=function(e){const t=navigator.webkitGetUserMedia||navigator.mozGetUserMedia;return t?new Promise((function(r,n){t.call(navigator,e,r,n)})):Promise.reject(new Error("getUserMedia is not implemented in this browser"))}),t.createCapture=function(...n){if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new DOMException("getUserMedia not supported in this browser");let i,s,o=!0,a=!0,u=!1;for(const e of n)e===t.VIDEO?a=!1:e===t.AUDIO?o=!1:"object"==typeof e?(void 0!==e.flipped&&(u=e.flipped,delete e.flipped),i=Object.assign({},i,e)):"function"==typeof e&&(s=e);const l={video:o,audio:a};i=Object.assign({},l,i);const h=document.createElement(fs);h.setAttribute("playsinline",""),navigator.mediaDevices.getUserMedia(i).then((function(e){try{"srcObject"in h?h.srcObject=e:h.src=window.URL.createObjectURL(e)}catch(t){h.src=e}})).catch((t=>{"NotFoundError"===t.name&&e._friendlyError("No webcam found on this device","createCapture"),"NotAllowedError"===t.name&&e._friendlyError("Access to the camera was denied","createCapture"),console.error(t)}));const c=r(h,this,!0);return c.loadedmetadata=!1,h.addEventListener("loadedmetadata",(function(){h.play(),h.width?(c.width=h.width,c.height=h.height):(c.width=c.elt.width=h.videoWidth,c.height=c.elt.height=h.videoHeight),u&&(c.elt.style.transform="scaleX(-1)"),c.loadedmetadata=!0,s&&s(h.srcObject)})),c.flipped=u,c},e.MediaElement=ys,ys.prototype._getSoundOut=function(){return e.soundOut},ys.prototype._getAudioContext=function(){return"function"==typeof t.getAudioContext?t.getAudioContext():void 0}}"undefined"!=typeof p5&&vs(p5,p5.prototype);var bs={modeAdjust:function(e,t,r,n,i){let s;return i===w?s={x:e,y:t,w:Math.abs(r),h:Math.abs(n)}:i===C?s={x:Math.min(e,r),y:Math.min(t,n),w:Math.abs(r-e),h:Math.abs(n-t)}:i===E?s={x:e-(r=Math.abs(r)),y:t-(n=Math.abs(n)),w:2*r,h:2*n}:i===D&&(s={x:e-.5*(r=Math.abs(r)),y:t-.5*(n=Math.abs(n)),w:r,h:n}),s}};function xs(e,t){t._normalizeArcAngles=(e,t,r,n,i)=>{let s;return e-=b*Math.floor(e/b),t-=b*Math.floor(t/b),s=Math.min(Math.abs(e-t),b-Math.abs(e-t)),i&&(e=e<=m?Math.atan(r/n*Math.tan(e)):e>m&&e<=3*m?Math.atan(r/n*Math.tan(e))+g:Math.atan(r/n*Math.tan(e))+b,t=t<=m?Math.atan(r/n*Math.tan(t)):t>m&&t<=3*m?Math.atan(r/n*Math.tan(t))+g:Math.atan(r/n*Math.tan(t))+b),e>t&&(t+=b),{start:e,stop:t,correspondToSamePoint:s<1e-5}},t.arc=function(e,t,r,n,i,s,o,a){if(!this._renderer.states.strokeColor&&!this._renderer.states.fillColor)return this;if(i===s)return this;i=this._toRadians(i),s=this._toRadians(s);const u=bs.modeAdjust(e,t,r,n,this._renderer.states.ellipseMode),l=this._normalizeArcAngles(i,s,u.w,u.h,!0);return l.correspondToSamePoint?this._renderer.ellipse([u.x,u.y,u.w,u.h,a]):(this._renderer.arc(u.x,u.y,u.w,u.h,l.start,l.stop,o,a),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._accsOutput("arc",[u.x,u.y,u.w,u.h,l.start,l.stop,o])),this},t.ellipse=function(e,t,r,n,i){return this._renderEllipse(...arguments)},t.circle=function(...e){const t=e.slice(0,2);return t.push(e[2],e[2]),this._renderEllipse(...t)},t._renderEllipse=function(e,t,r,n,i){if(!this._renderer.states.strokeColor&&!this._renderer.states.fillColor)return this;void 0===n&&(n=r);const s=bs.modeAdjust(e,t,r,n,this._renderer.states.ellipseMode);return this._renderer.ellipse([s.x,s.y,s.w,s.h,i]),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._accsOutput("ellipse",[s.x,s.y,s.w,s.h]),this},t.line=function(...e){return this._renderer.states.strokeColor&&this._renderer.line(...e),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._accsOutput("line",e),this},t.point=function(...t){return this._renderer.states.strokeColor&&(1===t.length&&t[0]instanceof e.Vector?this._renderer.point.call(this._renderer,t[0].x,t[0].y,t[0].z):(this._renderer.point(...t),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._accsOutput("point",t))),this},t.quad=function(...e){return(this._renderer.states.strokeColor||this._renderer.states.fillColor)&&(this._renderer.isP3D&&e.length<12?this._renderer.quad.call(this._renderer,e[0],e[1],0,e[2],e[3],0,e[4],e[5],0,e[6],e[7],0,e[8],e[9]):(this._renderer.quad(...e),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._accsOutput("quadrilateral",e))),this},t.rect=function(...e){return this._renderRect(...e)},t.square=function(e,t,r,n,i,s,o){return this._renderRect.call(this,e,t,r,r,n,i,s,o)},t._renderRect=function(){if(this._renderer.states.strokeColor||this._renderer.states.fillColor){3===arguments.length&&(arguments[3]=arguments[2]);const e=bs.modeAdjust(arguments[0],arguments[1],arguments[2],arguments[3],this._renderer.states.rectMode);this._renderer.states.rectMode===w&&(e.w=arguments[2],e.h=arguments[3]);const t=[e.x,e.y,e.w,e.h];for(let e=4;e<arguments.length;e++)t[e]=arguments[e];this._renderer.rect(t),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._accsOutput("rectangle",[e.x,e.y,e.w,e.h])}return this},t.triangle=function(...e){return(this._renderer.states.strokeColor||this._renderer.states.fillColor)&&this._renderer.triangle(e),(this._accessibleOutputs.grid||this._accessibleOutputs.text)&&this._accsOutput("triangle",e),this}}function _s(e,t){t.ellipseMode=function(e){return void 0===e?this._renderer?.states.ellipseMode:(e!==w&&e!==C&&e!==E&&e!==D||this._renderer.states.setValue("ellipseMode",e),this)},t.noSmooth=function(){return this._renderer.isP3D?this.setAttributes("antialias",!1):("imageSmoothingEnabled"in this.drawingContext&&(this.drawingContext.imageSmoothingEnabled=!1),this)},t.rectMode=function(e){return void 0===e?this._renderer?.states.rectMode:(e!==w&&e!==C&&e!==E&&e!==D||this._renderer.states.setValue("rectMode",e),this)},t.smooth=function(){return this._renderer.isP3D?this.setAttributes("antialias",!0):"imageSmoothingEnabled"in this.drawingContext&&(this.drawingContext.imageSmoothingEnabled=!0),this},t.strokeCap=function(e){return void 0===e?this._renderer.strokeCap():(e!==q&&e!==H&&e!==$||this._renderer.strokeCap(e),this)},t.strokeJoin=function(e){return void 0===e?this._renderer.strokeJoin():(e!==q&&e!==W&&e!==X||this._renderer.strokeJoin(e),this)},t.strokeWeight=function(e){return this._renderer.strokeWeight(e)}}function ws(e,t){t.bezier=function(...e){return this._renderer.states.strokeColor||this._renderer.states.fillColor?(this._renderer.bezier(...e),this):this},t.bezierPoint=function(e,t,r,n,i){const s=1-i;return Math.pow(s,3)*e+3*Math.pow(s,2)*i*t+3*s*Math.pow(i,2)*r+Math.pow(i,3)*n},t.bezierTangent=function(e,t,r,n,i){const s=1-i;return 3*n*Math.pow(i,2)-3*r*Math.pow(i,2)+6*r*s*i-6*t*s*i+3*t*Math.pow(s,2)-3*e*Math.pow(s,2)},t.spline=function(...e){return this._renderer.states.strokeColor||this._renderer.states.fillColor?(this._renderer.spline(...e),this):this},t.splinePoint=function(e,t,r,n,i){const s=this._renderer.states.splineProperties.tightness,o=i*i*i,a=i*i;return e*((s-1)/2*o+(1-s)*a+(s-1)/2*i)+t*((s+3)/2*o+(-5-s)/2*a+1)+r*((-3-s)/2*o+(s+2)*a+(1-s)/2*i)+n*((1-s)/2*o+(s-1)/2*a)},t.splineTangent=function(e,t,r,n,i){const s=this._renderer.states.splineProperties.tightness,o=i*i*3,a=2*i;return e*((s-1)/2*o+(1-s)*a+(s-1)/2)+t*((s+3)/2*o+(-5-s)/2*a)+r*((-3-s)/2*o+(s+2)*a+(1-s)/2)+n*((1-s)/2*o+(s-1)/2*a)}}function Cs(e,t){t.beginShape=function(e){this._renderer.beginShape(...arguments)},t.bezierVertex=function(...e){this._renderer.bezierVertex(...e)},t.endShape=function(e,t=1){t<1&&(console.log("🌸 p5.js says: You can not have less than one instance"),t=1),this._renderer.endShape(e,t)},t.normal=function(e,t,r){return this._assert3d("normal"),this._renderer.normal(...arguments),this},t.vertexProperty=function(e,t){this._renderer.vertexProperty(e,t)}}function Es(e,t){t.beginClip=function(e={}){this._renderer.beginClip(e)},t.endClip=function(){this._renderer.endClip()},t.clip=function(e,t){this._renderer.beginClip(t),e(),this._renderer.endClip(t)},t.background=function(...e){return this._renderer.background(...e)},t.clear=function(...e){const t=e[0]||0,r=e[1]||0,n=e[2]||0,i=e[3]||0;return this._renderer.clear(t,r,n,i),this},t.colorMode=function(e,t,r,n,i){if([In,kn,Nn,Mn,On,Bn,Ln,Pn,Rn].includes(e)){this._renderer.states.setValue("colorMode",e),this._renderer.states.setValue("colorMaxes",this._renderer.states.colorMaxes.clone());const s=this._renderer.states.colorMaxes[e];2===arguments.length?(s[0]=t,s[1]=t,s[2]=t,s[3]=t):4===arguments.length?(s[0]=t,s[1]=r,s[2]=n):5===arguments.length&&(s[0]=t,s[1]=r,s[2]=n,s[3]=i)}return this._renderer.states.colorMode},t.fill=function(...e){return this._renderer.fill(...e)},t.noFill=function(){return this._renderer.noFill(),this},t.noStroke=function(){return this._renderer.states.setValue("strokeColor",null),this},t.stroke=function(...e){return this._renderer.stroke(...e)},t.erase=function(e=255,t=255){return this._renderer.erase(e,t),this},t.noErase=function(){return this._renderer.noErase(),this},t.blendMode=function(e){return e===xe&&(console.warn("NORMAL has been deprecated for use in blendMode. defaulting to BLEND instead."),e=Y),this._renderer.blendMode(e)}}"undefined"!=typeof p5&&xs(p5,p5.prototype),"undefined"!=typeof p5&&_s(p5,p5.prototype),"undefined"!=typeof p5&&ws(p5,p5.prototype),"undefined"!=typeof p5&&Cs(p5,p5.prototype),"undefined"!=typeof p5&&Es(p5,p5.prototype);var Ss,As,Ds="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ts(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Fs(e,t,r,n){for(var i=e[t++],s=1<<i,o=s+1,a=o+1,u=i+1,l=(1<<u)-1,h=0,c=0,d=0,p=e[t++],f=new Int32Array(4096),m=null;;){for(;h<16&&0!==p;)c|=e[t++]<<h,h+=8,1===p?p=e[t++]:--p;if(h<u)break;var g=c&l;if(c>>=u,h-=u,g!==s){if(g===o)break;for(var y=g<a?g:m,v=0,b=y;b>s;)b=f[b]>>8,++v;var x=b;if(d+v+(y!==g?1:0)>n)return void console.log("Warning, gif stream longer than expected.");r[d++]=x;var _=d+=v;for(y!==g&&(r[d++]=x),b=y;v--;)b=f[b],r[--_]=255&b,b>>=8;null!==m&&a<4096&&(f[a++]=m<<8|x,a>=l+1&&u<12&&(++u,l=l<<1|1)),m=g}else a=o+1,l=(1<<(u=i+1))-1,m=null}return d!==n&&console.log("Warning, gif stream shorter than expected."),r}try{As=function(e,t,r,n){var i=0,s=void 0===(n=void 0===n?{}:n).loop?null:n.loop,o=void 0===n.palette?null:n.palette;if(t<=0||r<=0||t>65535||r>65535)throw new Error("Width/Height invalid.");function a(e){var t=e.length;if(t<2||t>256||t&t-1)throw new Error("Invalid code/color length, must be power of 2 and 2 .. 256.");return t}e[i++]=71,e[i++]=73,e[i++]=70,e[i++]=56,e[i++]=57,e[i++]=97;var u=0,l=0;if(null!==o){for(var h=a(o);h>>=1;)++u;if(h=1<<u,--u,void 0!==n.background){if((l=n.background)>=h)throw new Error("Background index out of range.");if(0===l)throw new Error("Background index explicitly passed as 0.")}}if(e[i++]=255&t,e[i++]=t>>8&255,e[i++]=255&r,e[i++]=r>>8&255,e[i++]=(null!==o?128:0)|u,e[i++]=l,e[i++]=0,null!==o)for(var c=0,d=o.length;c<d;++c){var p=o[c];e[i++]=p>>16&255,e[i++]=p>>8&255,e[i++]=255&p}if(null!==s){if(s<0||s>65535)throw new Error("Loop count invalid.");e[i++]=33,e[i++]=255,e[i++]=11,e[i++]=78,e[i++]=69,e[i++]=84,e[i++]=83,e[i++]=67,e[i++]=65,e[i++]=80,e[i++]=69,e[i++]=50,e[i++]=46,e[i++]=48,e[i++]=3,e[i++]=1,e[i++]=255&s,e[i++]=s>>8&255,e[i++]=0}var f=!1;this.addFrame=function(t,r,n,s,u,l){if(!0===f&&(--i,f=!1),l=void 0===l?{}:l,t<0||r<0||t>65535||r>65535)throw new Error("x/y invalid.");if(n<=0||s<=0||n>65535||s>65535)throw new Error("Width/Height invalid.");if(u.length<n*s)throw new Error("Not enough pixels for the frame size.");var h=!0,c=l.palette;if(null==c&&(h=!1,c=o),null==c)throw new Error("Must supply either a local or global palette.");for(var d=a(c),p=0;d>>=1;)++p;d=1<<p;var m=void 0===l.delay?0:l.delay,g=void 0===l.disposal?0:l.disposal;if(g<0||g>3)throw new Error("Disposal out of range.");var y=!1,v=0;if(void 0!==l.transparent&&null!==l.transparent&&(y=!0,(v=l.transparent)<0||v>=d))throw new Error("Transparent color index.");if((0!==g||y||0!==m)&&(e[i++]=33,e[i++]=249,e[i++]=4,e[i++]=g<<2|(!0===y?1:0),e[i++]=255&m,e[i++]=m>>8&255,e[i++]=v,e[i++]=0),e[i++]=44,e[i++]=255&t,e[i++]=t>>8&255,e[i++]=255&r,e[i++]=r>>8&255,e[i++]=255&n,e[i++]=n>>8&255,e[i++]=255&s,e[i++]=s>>8&255,e[i++]=!0===h?128|p-1:0,!0===h)for(var b=0,x=c.length;b<x;++b){var _=c[b];e[i++]=_>>16&255,e[i++]=_>>8&255,e[i++]=255&_}return i=function(e,t,r,n){e[t++]=r;var i=t++,s=1<<r,o=s-1,a=s+1,u=a+1,l=r+1,h=0,c=0;function d(r){for(;h>=r;)e[t++]=255&c,c>>=8,h-=8,t===i+256&&(e[i]=255,i=t++)}function p(e){c|=e<<h,h+=l,d(8)}var f=n[0]&o,m={};p(s);for(var g=1,y=n.length;g<y;++g){var v=n[g]&o,b=f<<8|v,x=m[b];if(void 0===x){for(c|=f<<h,h+=l;h>=8;)e[t++]=255&c,c>>=8,h-=8,t===i+256&&(e[i]=255,i=t++);4096===u?(p(s),u=a+1,l=r+1,m={}):(u>=1<<l&&++l,m[b]=u++),f=v}else f=x}return p(f),p(a),d(1),i+1===t?e[i]=0:(e[i]=t-i-1,e[t++]=0),t}(e,i,p<2?2:p,u),i},this.end=function(){return!1===f&&(e[i++]=59,f=!0),i},this.getOutputBuffer=function(){return e},this.setOutputBuffer=function(t){e=t},this.getOutputBufferPosition=function(){return i},this.setOutputBufferPosition=function(e){i=e}},Ss=function(e){var t=0;if(71!==e[t++]||73!==e[t++]||70!==e[t++]||56!==e[t++]||56!=(e[t++]+1&253)||97!==e[t++])throw new Error("Invalid GIF 87a/89a header.");var r=e[t++]|e[t++]<<8,n=e[t++]|e[t++]<<8,i=e[t++],s=i>>7,o=1<<1+(7&i);e[t++],e[t++];var a=null,u=null;s&&(a=t,u=o,t+=3*o);var l=!0,h=[],c=0,d=null,p=0,f=null;for(this.width=r,this.height=n;l&&t<e.length;)switch(e[t++]){case 33:switch(e[t++]){case 255:if(11!==e[t]||78==e[t+1]&&69==e[t+2]&&84==e[t+3]&&83==e[t+4]&&67==e[t+5]&&65==e[t+6]&&80==e[t+7]&&69==e[t+8]&&50==e[t+9]&&46==e[t+10]&&48==e[t+11]&&3==e[t+12]&&1==e[t+13]&&0==e[t+16])t+=14,f=e[t++]|e[t++]<<8,t++;else for(t+=12;;){if(!((D=e[t++])>=0))throw Error("Invalid block size");if(0===D)break;t+=D}break;case 249:if(4!==e[t++]||0!==e[t+4])throw new Error("Invalid graphics extension block.");var m=e[t++];c=e[t++]|e[t++]<<8,d=e[t++],1&m||(d=null),p=m>>2&7,t++;break;case 254:for(;;){if(!((D=e[t++])>=0))throw Error("Invalid block size");if(0===D)break;t+=D}break;default:throw new Error("Unknown graphic control label: 0x"+e[t-1].toString(16))}break;case 44:var g=e[t++]|e[t++]<<8,y=e[t++]|e[t++]<<8,v=e[t++]|e[t++]<<8,b=e[t++]|e[t++]<<8,x=e[t++],_=x>>6&1,w=1<<1+(7&x),C=a,E=u,S=!1;x>>7&&(S=!0,C=t,E=w,t+=3*w);var A=t;for(t++;;){var D;if(!((D=e[t++])>=0))throw Error("Invalid block size");if(0===D)break;t+=D}h.push({x:g,y:y,width:v,height:b,has_local_palette:S,palette_offset:C,palette_size:E,data_offset:A,data_length:t-A,transparent_index:d,interlaced:!!_,delay:c,disposal:p});break;case 59:l=!1;break;default:throw new Error("Unknown gif block: 0x"+e[t-1].toString(16))}this.numFrames=function(){return h.length},this.loopCount=function(){return f},this.frameInfo=function(e){if(e<0||e>=h.length)throw new Error("Frame index out of range.");return h[e]},this.decodeAndBlitFrameBGRA=function(t,n){var i=this.frameInfo(t),s=i.width*i.height,o=new Uint8Array(s);Fs(e,i.data_offset,o,s);var a=i.palette_offset,u=i.transparent_index;null===u&&(u=256);var l=i.width,h=r-l,c=l,d=4*(i.y*r+i.x),p=4*((i.y+i.height)*r+i.x),f=d,m=4*h;!0===i.interlaced&&(m+=4*r*7);for(var g=8,y=0,v=o.length;y<v;++y){var b=o[y];if(0===c&&(c=l,(f+=m)>=p&&(m=4*h+4*r*(g-1),f=d+(l+h)*(g<<1),g>>=1)),b===u)f+=4;else{var x=e[a+3*b],_=e[a+3*b+1],w=e[a+3*b+2];n[f++]=w,n[f++]=_,n[f++]=x,n[f++]=255}--c}},this.decodeAndBlitFrameRGBA=function(t,n){var i=this.frameInfo(t),s=i.width*i.height,o=new Uint8Array(s);Fs(e,i.data_offset,o,s);var a=i.palette_offset,u=i.transparent_index;null===u&&(u=256);var l=i.width,h=r-l,c=l,d=4*(i.y*r+i.x),p=4*((i.y+i.height)*r+i.x),f=d,m=4*h;!0===i.interlaced&&(m+=4*r*7);for(var g=8,y=0,v=o.length;y<v;++y){var b=o[y];if(0===c&&(c=l,(f+=m)>=p&&(m=4*h+4*r*(g-1),f=d+(l+h)*(g<<1),g>>=1)),b===u)f+=4;else{var x=e[a+3*b],_=e[a+3*b+1],w=e[a+3*b+2];n[f++]=x,n[f++]=_,n[f++]=w,n[f++]=255}--c}}}}catch(e){}function Is(e,t){t.createImage=function(t,r){return new e.Image(t,r)},t.saveCanvas=function(...e){let r,n,i,s,o;if(e[0]instanceof HTMLCanvasElement)r=e[0],e.shift();else if(e[0]instanceof Ei)r=e[0].elt,e.shift();else if(e[0]instanceof ma){const t=e[0];s=this.createGraphics(t.width,t.height),s.pixelDensity(t.pixelDensity()),t.loadPixels(),s.loadPixels(),s.pixels.set(t.pixels),s.updatePixels(),r=s._renderer.canvas,e.shift()}else r=this._curElement&&this._curElement.elt;switch(e.length>=1&&(n=e[0]),e.length>=2&&(i=e[1]),i=i||t._checkFileExtension(n,i)[1]||"png",i){default:o="image/png";break;case"webp":o="image/webp";break;case"jpeg":case"jpg":o="image/jpeg"}r.toBlob((e=>{t.downloadFile(e,n,i),s&&s.remove()}),o)},t.encodeAndDownloadGif=function(e,r){const n=e.gifProperties;let i=n.loopLimit;1===i?i=null:null===i&&(i=0);const s=new Uint8Array(e.width*e.height*n.numFrames),o=[],a={};for(let t=0;t<n.numFrames;t++){const r=new Set,i=n.frames[t].image.data,s=i.length,u=new Uint32Array(e.width*e.height);for(let e=0,t=0;e<s;e+=4,t++){const n=i[e+0]<<16|i[e+1]<<8|i[e+2];r.add(n),u[t]=n}const l=[...r].sort().toString();void 0===a[l]?a[l]={freq:1,frames:[t]}:(a[l].freq+=1,a[l].frames.push(t)),o.push(u)}let u=[];const l=Object.keys(a).sort((function(e,t){return a[t].freq-a[e].freq})),h=l[0].split(",").map((e=>parseInt(e)));u=u.concat(a[h].frames);const c=new Set(h);for(let e=1;e<l.length;e++){const t=l[e].split(",").map((e=>parseInt(e))).filter((e=>!c.has(e)));if(h.length+t.length<=256){for(let e=0;e<t.length;e++)h.push(t[e]),c.add(t[e]);u=u.concat(a[l[e]].frames)}}u=new Set(u);const d={};for(let e=0;e<h.length;e++)d[h[e]]||(d[h[e]]=e);let p=1;for(;p<h.length;)p<<=1;h.length=p;const f={loop:i,palette:new Uint32Array(h)},m=new As(s,e.width,e.height,f);let g={};for(let t=0;t<n.numFrames;t++){const r=!u.has(t),i=r?[]:h,s=new Uint8Array(e.width*e.height),a={},l=new Set;o[t].forEach(((e,n)=>{r?(void 0===a[e]&&(a[e]=i.length,i.push(e)),s[n]=a[e]):s[n]=d[e],t>0&&o[t-1][n]!==e&&l.add(e)}));const c={},p=i.filter((e=>!l.has(e)));if(p.length>0){const e=p[0],n=r?a[e]:d[e];if(t>0){for(let e=0;e<o[t].length;e++)o[t-1][e]===o[t][e]&&(s[e]=n);c.transparent=n,g.frameOpts.disposal=1}}if(c.delay=n.frames[t].delay/10,r){let e=1;for(;e<i.length;)e<<=1;i.length=e,c.palette=new Uint32Array(i)}t>0&&m.addFrame(0,0,e.width,e.height,g.pixelPaletteIndex,g.frameOpts),g={pixelPaletteIndex:s,frameOpts:c}}g.frameOpts.disposal=1,m.addFrame(0,0,e.width,e.height,g.pixelPaletteIndex,g.frameOpts);const y=new Blob([s.slice(0,m.end())],{type:"image/gif"});t.downloadFile(y,r,"gif")},t.saveFrames=function(e,r,n,i,s){let o=n||3;o=Math.max(Math.min(o,15),0),o*=1e3;let a=i||15;a=Math.max(Math.min(a,22),0);let u=0;const l=t._makeFrame,h=this._curElement.elt;let c=[];const d=setInterval((()=>{c.push(l(e+u,r,h)),u++}),1e3/a);setTimeout((()=>{if(clearInterval(d),s)s(c);else for(const e of c)t.downloadFile(e.imageData,e.filename,e.ext);c=[]}),o+.01)},t._makeFrame=function(e,t,r){let n,i;if(n=this?this._curElement.elt:r,t)switch(t.toLowerCase()){case"png":default:i="image/png";break;case"jpeg":case"jpg":i="image/jpeg"}else t="png",i="image/png";let s=n.toDataURL(i);s=s.replace(i,"image/octet-stream");const o={};return o.imageData=s,o.filename=e,o.ext=t,o}}function ks(e){const t=e.options.typed?function(e){switch(!0){case"true"===e:case"false"===e:return"true"===e;case/.\./.test(e):return parseFloat(e);case isFinite(e):return parseInt(e);default:return e}}(e.value):e.value;e.entry.push(e.reviver(t,e.row,e.col)),e.value="",e.col++}function Ns(e){e.output.push(e.entry),e.entry=[],e.row++,e.col=1}function Ms(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}"undefined"!=typeof p5&&Is(p5,p5.prototype);class Os extends Error{status;response;ok}async function Bs(e,t){try{const r=await fetch(e);if(r.ok){let e;switch(t){case"json":e=await r.json();break;case"text":e=await r.text();break;case"arrayBuffer":e=await r.arrayBuffer();break;case"blob":e=await r.blob();break;case"bytes":if(r.bytes)e=await r.bytes();else{const t=await r.arrayBuffer();e=new Uint8Array(t)}break;default:throw new Error("Unsupported response type")}return{data:e,headers:r.headers}}{const e=new Os(r.statusText);throw e.status=r.status,e.response=r,e.ok=!1,e}}catch(e){throw e instanceof TypeError?console.log("You may have encountered a CORS error"):e instanceof Os?console.log("You have encountered a HTTP error"):e instanceof SyntaxError&&console.log("There is an error parsing the response to requested data structure"),e}}function Ls(e,t){function r(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}t.loadJSON=async function(t,r,n){try{const{data:e}=await Bs(t,"json"),n=()=>r?r(e):e;return this._internal?this._internal(n):n()}catch(r){if(e._friendlyFileLoadError(5,t),n)return n(r);throw r}},t.loadStrings=async function(t,r,n){try{let{data:e}=await Bs(t,"text");const n=()=>(e=e.split(/\r?\n/),r?r(e):e);return this._internal?this._internal(n):n()}catch(r){if(e._friendlyFileLoadError(3,t),n)return n(r);throw r}},t.loadTable=async function(t,r,n,i,s){"function"==typeof arguments[arguments.length-1]&&("function"==typeof arguments[arguments.length-2]?(i=arguments[arguments.length-2],s=arguments[arguments.length-1]):i=arguments[arguments.length-1]),"string"!=typeof r&&(r=","),"function"==typeof n&&(n=!1);try{let{data:s}=await Bs(t,"text");const o=()=>{let t=new e.Table;return s=function(e,t,r=e=>e){const n=Object.create(null);if(n.options=t||{},n.reviver=r,n.value="",n.entry=[],n.output=[],n.col=1,n.row=1,n.options.delimiter=void 0===n.options.delimiter?'"':t.delimiter,n.options.delimiter.length>1||0===n.options.delimiter.length)throw Error(`CSVError: delimiter must be one character [${n.options.separator}]`);if(n.options.separator=void 0===n.options.separator?",":t.separator,n.options.separator.length>1||0===n.options.separator.length)throw Error(`CSVError: separator must be one character [${n.options.separator}]`);const i=new RegExp(`${Ms(n.options.delimiter)}|${Ms(n.options.separator)}|\r\n|\n|\r|[^${Ms(n.options.delimiter)}${Ms(n.options.separator)}\r\n]+`,"y"),s=/^(\r\n|\n|\r)$/;let o=[],a="",u=0;for(;null!==(o=i.exec(e));)switch(a=o[0],u){case 0:switch(!0){case a===n.options.delimiter:u=3;break;case a===n.options.separator:u=0,ks(n);break;case s.test(a):u=0,ks(n),Ns(n);break;default:n.value+=a,u=2}break;case 2:switch(!0){case a===n.options.separator:u=0,ks(n);break;case s.test(a):u=0,ks(n),Ns(n);break;default:throw u=4,Error(`CSVError: Illegal state [row:${n.row}, col:${n.col}]`)}break;case 3:1==(a===n.options.delimiter)?u=4:(u=3,n.value+=a);break;case 4:switch(!0){case a===n.options.delimiter:u=3,n.value+=a;break;case a===n.options.separator:u=0,ks(n);break;case s.test(a):u=0,ks(n),Ns(n);break;default:throw Error(`CSVError: Illegal state [row:${n.row}, col:${n.col}]`)}}return 0!==n.entry.length&&(ks(n),Ns(n)),n.output}(s,{separator:r}),t.columns=n?s.shift():Array(s[0].length).fill(null),s.forEach((r=>{const n=new e.TableRow(r);t.addRow(n)})),i?i(t):t};return this._internal?this._internal(o):o()}catch(r){if(e._friendlyFileLoadError(2,t),s)return s(r);throw r}},t.loadXML=async function(t,r,n){try{const n=new DOMParser;let{data:i}=await Bs(t,"text");const s=()=>{const t=n.parseFromString(i,"application/xml");return i=new e.XML(t),r?r(i):i};return this._internal?this._internal(s):s()}catch(r){if(e._friendlyFileLoadError(1,t),n)return n(r);throw r}},t.loadBytes=async function(t,r,n){try{let{data:e}=await Bs(t,"arrayBuffer");const n=()=>(e=new Uint8Array(e),r?r(e):e);return this._internal?this._internal(n):n()}catch(r){if(e._friendlyFileLoadError(6,t),n)return n(r);throw r}},t.loadBlob=async function(e,t,r){try{const{data:r}=await Bs(e,"blob"),n=()=>t?t(r):r;return this._internal?this._internal(n):n()}catch(e){if(r)return r(e);throw e}},t.httpGet=async function(e,t="text",r,n){return"function"==typeof t&&(n=r,r=t,t="text"),this.httpDo(e,"GET",t,r,n)},t.httpPost=async function(t,r,n="text",i,s){"function"==typeof r?(i=r,s=n,r=void 0,n="text"):"function"==typeof n&&(s=i,i=n,n="text");let o=r,a="text/plain";r instanceof e.XML?(o=r.serialize(),a="application/xml"):r instanceof e.Image?(o=await r.toBlob(),a="image/png"):"object"==typeof r&&(o=JSON.stringify(r),a="application/json");const u={method:"POST",body:o,headers:{"Content-Type":a}};o&&(u.body=o);const l=new Request(t,u);return this.httpDo(l,"POST",n,i,s)},t.httpDo=async function(e,t,r,n,i){if("function"==typeof r&&(i=n,n=r,r=void 0),!r){switch("string"==typeof e?e.split(".").pop():e.url.split(".").pop()){case"json":r="json";break;case"jpg":case"jpeg":case"png":case"webp":case"gif":r="blob";break;default:r="text"}}const s=new Request(e,{method:t});try{const{data:e}=await Bs(s,r);return n?n(e):e}catch(e){if(i)return i(e);throw e}},t._pWriters=[],t.createWriter=function(r,n){let i;for(const s in t._pWriters)if(t._pWriters[s].name===r)return i=new e.PrintWriter(r+this.millis(),n),t._pWriters.push(i),i;return i=new e.PrintWriter(r,n),t._pWriters.push(i),i},e.PrintWriter=function(e,r){let n=this;this.name=e,this.content="",this.write=function(e){this.content+=e},this.print=function(e){this.content+=`${e}\n`},this.clear=function(){this.content=""},this.close=function(){const i=[];i.push(this.content),t.writeFile(i,e,r);for(const e in t._pWriters)t._pWriters[e].name===this.name&&t._pWriters.splice(e,1);n.clear(),n={}}},t.save=function(r,n,i){const s=arguments,o=this._curElement?this._curElement.elt:this.elt;if(0!==s.length)if(s[0]instanceof ps||s[0]instanceof Qo)t.saveCanvas(s[0].canvas,s[1],s[2]);else if(1===s.length&&"string"==typeof s[0])t.saveCanvas(o,s[0]);else{switch(Ni(s[1],s[2])[1]){case"json":return void t.saveJSON(s[0],s[1],s[2]);case"txt":return void t.saveStrings(s[0],s[1],s[2]);default:s[0]instanceof Array?t.saveStrings(s[0],s[1],s[2]):s[0]instanceof e.Table?t.saveTable(s[0],s[1],s[2]):s[0]instanceof e.Image?t.saveCanvas(s[0].canvas,s[1]):s[0]instanceof e.SoundFile&&t.saveSound(s[0],s[1],s[2],s[3])}}else t.saveCanvas(o)},t.saveJSON=function(e,t,r){let n;n=r?JSON.stringify(e):JSON.stringify(e,void 0,2),this.saveStrings(n.split("\n"),t,"json")},t.saveStrings=function(t,r,n,i){const s=n||"txt",o=new e.PrintWriter(r,s);for(let e of t)i?o.write(e+"\r\n"):o.write(e+"\n");o.close(),o.clear()},t.saveTable=function(e,t,n){let i;void 0===n?(i=t.substring(t.lastIndexOf(".")+1,t.length),i===t&&(i="csv")):i=n;const s=this.createWriter(t,i),o=e.columns;let a=",";if("tsv"===i&&(a="\t"),"html"!==i){const t=e.toString(a);s.write(t)}else{s.print("<html>"),s.print("<head>");let t='  <meta http-equiv="content-type" content';if(t+='="text/html;charset=utf-8" />',s.print(t),s.print("</head>"),s.print("<body>"),s.print("  <table>"),"0"!==o[0]){s.print("    <tr>");for(let e=0;e<o.length;e++){const t=r(o[e]);s.print(`      <td>${t}`),s.print("      </td>")}s.print("    </tr>")}for(let t=0;t<e.rows.length;t++){s.print("    <tr>");for(let n=0;n<e.columns.length;n++){const i=r(e.rows[t].getString(n));s.print(`      <td>${i}`),s.print("      </td>")}s.print("    </tr>")}s.print("  </table>"),s.print("</body>"),s.print("</html>")}s.close(),s.clear()},t.writeFile=function(e,r,n){let i="application/octet-stream";t._isSafari()&&(i="text/plain");const s=new Blob(e,{type:i});t.downloadFile(s,r,n)},t.downloadFile=ki,t._checkFileExtension=Ni,t._isSafari=function(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}}"undefined"!=typeof p5&&Ls(p5,p5.prototype);var Ps=59;function Rs(e=256){let t=0,r=new Uint8Array(e);return{get buffer(){return r.buffer},reset(){t=0},bytesView:()=>r.subarray(0,t),bytes:()=>r.slice(0,t),writeByte(e){n(t+1),r[t]=e,t++},writeBytes(e,i=0,s=e.length){n(t+s);for(let n=0;n<s;n++)r[t++]=e[n+i]},writeBytesView(e,i=0,s=e.byteLength){n(t+s),r.set(e.subarray(i,i+s),t),t+=s}};function n(e){var n=r.length;if(n>=e)return;e=Math.max(e,n*(n<1048576?2:1.125)>>>0),0!=n&&(e=Math.max(e,256));let i=r;r=new Uint8Array(e),t>0&&r.set(i.subarray(0,t),0)}}var Vs=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];var Us=function(e,t,r,n,i=Rs(512),s=new Uint8Array(256),o=new Int32Array(5003),a=new Int32Array(5003)){let u=o.length,l=Math.max(2,n);s.fill(0),a.fill(0),o.fill(-1);let h=0,c=0,d=l+1,p=d,f=!1,m=p,g=(1<<m)-1,y=1<<d-1,v=y+1,b=y+2,x=0,_=r[0],w=0;for(let e=u;e<65536;e*=2)++w;w=8-w,i.writeByte(l),E(y);let C=r.length;for(let e=1;e<C;e++)e:{let t=r[e],n=(t<<12)+_,i=t<<w^_;if(o[i]===n){_=a[i];break e}let s=0===i?1:u-i;for(;o[i]>=0;)if(i-=s,i<0&&(i+=u),o[i]===n){_=a[i];break e}E(_),_=t,b<4096?(a[i]=b++,o[i]=n):(o.fill(-1),b=y+2,f=!0,E(y))}return E(_),E(v),i.writeByte(0),i.bytesView();function E(e){for(h&=Vs[c],c>0?h|=e<<c:h=e,c+=m;c>=8;)s[x++]=255&h,x>=254&&(i.writeByte(x),i.writeBytesView(s,0,x),x=0),h>>=8,c-=8;if((b>g||f)&&(f?(m=p,g=(1<<m)-1,f=!1):(++m,g=12===m?1<<m:(1<<m)-1)),e==v){for(;c>0;)s[x++]=255&h,x>=254&&(i.writeByte(x),i.writeBytesView(s,0,x),x=0),h>>=8,c-=8;x>0&&(i.writeByte(x),i.writeBytesView(s,0,x),x=0)}}};function zs(e,t,r){return e<<8&63488|t<<2&992|r>>3}function js(e,t,r,n){return e>>4|240&t|(240&r)<<4|(240&n)<<8}function Gs(e,t,r){return e>>4<<8|240&t|r>>4}function $s(e,t,r){return e<t?t:e>r?r:e}function Hs(e){return e*e}function qs(e,t,r){var n=0,i=1e100;let s=e[t],o=s.cnt,a=s.rc,u=s.gc,l=s.bc;for(var h=s.fw;0!=h;h=e[h].fw){let t=e[h],r=t.cnt,s=o*r/(o+r);if(!(s>=i)){var c=0;!((c+=s*Hs(t.rc-a))>=i)&&(!((c+=s*Hs(t.gc-u))>=i)&&(!((c+=s*Hs(t.bc-l))>=i)&&(i=c,n=h)))}}s.err=i,s.nn=n}function Ws(e,t,r={}){let{format:n="rgb565",clearAlpha:i=!0,clearAlphaColor:s=0,clearAlphaThreshold:o=0,oneBitAlpha:a=!1}=r;if(!e||!e.buffer)throw new Error("quantize() expected RGBA Uint8Array data");if(!(e instanceof Uint8Array||e instanceof Uint8ClampedArray))throw new Error("quantize() expected RGBA Uint8Array data");let u=new Uint32Array(e.buffer),l=!1!==r.useSqrt,h="rgba4444"===n,c=function(e,t){let r=new Array("rgb444"===t?4096:65536),n=e.length;if("rgba4444"===t)for(let t=0;t<n;++t){let n=e[t],i=n>>24&255,s=n>>16&255,o=n>>8&255,a=255&n,u=js(a,o,s,i),l=u in r?r[u]:r[u]={ac:0,rc:0,gc:0,bc:0,cnt:0,nn:0,fw:0,bk:0,tm:0,mtm:0,err:0};l.rc+=a,l.gc+=o,l.bc+=s,l.ac+=i,l.cnt++}else if("rgb444"===t)for(let t=0;t<n;++t){let n=e[t],i=n>>16&255,s=n>>8&255,o=255&n,a=Gs(o,s,i),u=a in r?r[a]:r[a]={ac:0,rc:0,gc:0,bc:0,cnt:0,nn:0,fw:0,bk:0,tm:0,mtm:0,err:0};u.rc+=o,u.gc+=s,u.bc+=i,u.cnt++}else for(let t=0;t<n;++t){let n=e[t],i=n>>16&255,s=n>>8&255,o=255&n,a=zs(o,s,i),u=a in r?r[a]:r[a]={ac:0,rc:0,gc:0,bc:0,cnt:0,nn:0,fw:0,bk:0,tm:0,mtm:0,err:0};u.rc+=o,u.gc+=s,u.bc+=i,u.cnt++}return r}(u,n),d=c.length,p=d-1,f=new Uint32Array(d+1);for(var m=0,g=0;g<d;++g){let e=c[g];if(null!=e){var y=1/e.cnt;h&&(e.ac*=y),e.rc*=y,e.gc*=y,e.bc*=y,c[m++]=e}}Hs(t)/m<.022&&(l=!1);for(g=0;g<m-1;++g)c[g].fw=g+1,c[g+1].bk=g,l&&(c[g].cnt=Math.sqrt(c[g].cnt));var v,b,x;for(l&&(c[g].cnt=Math.sqrt(c[g].cnt)),g=0;g<m;++g){qs(c,g);var _=c[g].err;for(b=++f[0];b>1&&!(c[v=f[x=b>>1]].err<=_);b=x)f[b]=v;f[b]=g}var w=m-t;for(g=0;g<w;){for(var C;;){var E=f[1];if((C=c[E]).tm>=C.mtm&&c[C.nn].mtm<=C.tm)break;C.mtm==p?E=f[1]=f[f[0]--]:(qs(c,E),C.tm=g);_=c[E].err;for(b=1;(x=b+b)<=f[0]&&(x<f[0]&&c[f[x]].err>c[f[x+1]].err&&x++,!(_<=c[v=f[x]].err));b=x)f[b]=v;f[b]=E}var S=c[C.nn],A=C.cnt,D=S.cnt;y=1/(A+D);h&&(C.ac=y*(A*C.ac+D*S.ac)),C.rc=y*(A*C.rc+D*S.rc),C.gc=y*(A*C.gc+D*S.gc),C.bc=y*(A*C.bc+D*S.bc),C.cnt+=S.cnt,C.mtm=++g,c[S.bk].fw=S.fw,c[S.fw].bk=S.bk,S.mtm=p}let T=[];var F=0;for(g=0;;++F){let e=$s(Math.round(c[g].rc),0,255),t=$s(Math.round(c[g].gc),0,255),r=$s(Math.round(c[g].bc),0,255),n=255;if(h){if(n=$s(Math.round(c[g].ac),0,255),a){n=n<=("number"==typeof a?a:127)?0:255}i&&n<=o&&(e=t=r=s,n=0)}let u=h?[e,t,r,n]:[e,t,r];if(Xs(T,u)||T.push(u),0==(g=c[g].fw))break}return T}function Xs(e,t){for(let r=0;r<e.length;r++){let n=e[r],i=n[0]===t[0]&&n[1]===t[1]&&n[2]===t[2],s=!(n.length>=4&&t.length>=4)||n[3]===t[3];if(i&&s)return!0}return!1}function Zs(e,t){var r,n=0;for(r=0;r<e.length;r++){let i=e[r]-t[r];n+=i*i}return n}function Ys(e,t,r=Zs){let n=1/0,i=-1;for(let s=0;s<e.length;s++){let o=r(t,e[s]);o<n&&(n=o,i=s)}return i}function Ks(e={}){let{initialCapacity:t=4096,auto:r=!0}=e,n=Rs(t),i=new Uint8Array(256),s=new Int32Array(5003),o=new Int32Array(5003),a=!1;return{reset(){n.reset(),a=!1},finish(){n.writeByte(Ps)},bytes:()=>n.bytes(),bytesView:()=>n.bytesView(),get buffer(){return n.buffer},get stream(){return n},writeHeader:u,writeFrame(e,t,l,h={}){let{transparent:c=!1,transparentIndex:d=0,delay:p=0,palette:f=null,repeat:m=0,colorDepth:g=8,dispose:y=-1}=h,v=!1;if(r?a||(v=!0,u(),a=!0):v=Boolean(h.first),t=Math.max(0,Math.floor(t)),l=Math.max(0,Math.floor(l)),v){if(!f)throw new Error("First frame must include a { palette } option");(function(e,t,r,n,i=8){let s=1,o=0,a=to(n.length)-1,u=s<<7|i-1<<4|o<<3|a,l=0,h=0;Qs(e,t),Qs(e,r),e.writeBytes([u,l,h])})(n,t,l,f,g),Js(n,f),m>=0&&function(e,t){e.writeByte(33),e.writeByte(255),e.writeByte(11),eo(e,"NETSCAPE2.0"),e.writeByte(3),e.writeByte(1),Qs(e,t),e.writeByte(0)}(n,m)}let b=Math.round(p/10);!function(e,t,r,n,i){var s,o;e.writeByte(33),e.writeByte(249),e.writeByte(4),i<0&&(i=0,n=!1),n?(s=1,o=2):(s=0,o=0),t>=0&&(o=7&t),o<<=2;let a=0;e.writeByte(o|a|s),Qs(e,r),e.writeByte(i||0),e.writeByte(0)}(n,y,b,c,d);let x=Boolean(f)&&!v;(function(e,t,r,n){if(e.writeByte(44),Qs(e,0),Qs(e,0),Qs(e,t),Qs(e,r),n){let t=0,r=0,i=to(n.length)-1;e.writeByte(128|t|r|i)}else e.writeByte(0)})(n,t,l,x?f:null),x&&Js(n,f),function(e,t,r,n,i=8,s,o,a){Us(r,n,t,i,e,s,o,a)}(n,e,t,l,g,i,s,o)}};function u(){eo(n,"GIF89a")}}function Js(e,t){let r=1<<to(t.length);for(let n=0;n<r;n++){let r=[0,0,0];n<t.length&&(r=t[n]),e.writeByte(r[0]),e.writeByte(r[1]),e.writeByte(r[2])}}function Qs(e,t){e.writeByte(255&t),e.writeByte(t>>8&255)}function eo(e,t){for(var r=0;r<t.length;r++)e.writeByte(t.charCodeAt(r))}function to(e){return Math.max(Math.ceil(Math.log2(e)),1)}function ro(e,t){function r(e,t,r){const n=parseInt(r/2),i=4*t,s=new Uint8Array(4*t);for(let t=0;t<n;++t){const n=t*i,o=(r-t-1)*i;s.set(e.subarray(n,n+i)),e.copyWithin(n,o,o+i),e.set(s,o)}return e}function n(e,t,r,n,i,s,o,a,u,l,h){if(e===Re){const{x:e,y:n,w:i,h:c}=function(e,t,r,n,i,s,o,a){const u=Math.max(r/o,n/a),[l,h]=[r/u,n/u];let c=i,d=s;return e===D?c+=(o-l)/2:e===S&&(c+=o-l),t===D?d+=(a-h)/2:t===F&&(d+=a-h),{x:c,y:d,w:l,h:h}}(t,r,s,o,a,u,l,h);a=e,u=n,l=i,h=c}if(e===Pe){const{x:e,y:a,w:u,h:c}=function(e,t,r,n,i,s,o,a){const u=Math.max(o/i,a/s),[l,h]=[o/u,a/u];let c=r,d=n;return e===D?c+=(i-l)/2:e===S&&(c+=i-l),t===D?d+=(s-h)/2:t===F&&(d+=s-h),{x:c,y:d,w:l,h:h}}(t,r,n,i,s,o,l,h);n=e,i=a,s=u,o=c}return{sx:a,sy:u,sw:l,sh:h,dx:n,dy:i,dw:s,dh:o}}function i(e,t){return e>0&&e<t?e:t}t.loadImage=async function(t,r,n){try{let n=new e.Image(1,1,this);const i=new Request(t,{method:"GET",mode:"cors"}),{data:s,headers:o}=await Bs(i,"bytes"),a=o.get("content-type");if(null===a&&console.warn("The image you loaded does not have a Content-Type header. If you are using the online editor consider reuploading the asset."),a&&a.includes("image/gif"))await async function(t,r){const n=new Ss(t);r.width=r.canvas.width=n.width,r.height=r.canvas.height=n.height;const i=[],s=n.numFrames();let o=new Uint8ClampedArray(r.width*r.height*4);const a=(t,n)=>{try{n.decodeAndBlitFrameRGBA(t,o)}catch(t){throw e._friendlyFileLoadError(8,r.src),t}};for(let e=0;e<s;e++){const t=n.frameInfo(e),s=r.drawingContext.getImageData(0,0,r.width,r.height);o=s.data.slice(),a(e,n);const u=new ImageData(o,r.width,r.height);r.drawingContext.putImageData(u,0,0);let l=t.delay;0===l&&(l=10),i.push({image:r.drawingContext.getImageData(0,0,r.width,r.height),delay:10*l}),2===t.disposal?r.drawingContext.clearRect(t.x,t.y,t.width,t.height):3===t.disposal&&r.drawingContext.putImageData(s,0,0,t.x,t.y,t.width,t.height)}let u=n.loopCount();null===u?u=1:0===u&&(u=null);r.drawingContext.putImageData(i[0].image,0,0),i.length>1&&(r.gifProperties={displayIndex:0,loopLimit:u,loopCount:0,frames:i,numFrames:s,playing:!0,timeDisplayed:0,lastChangeTime:0});return r}(s,n);else{const e=await new Promise(((e,t)=>{const r=new Image,n=new Blob([s],{type:a}),i=URL.createObjectURL(n);r.onerror=e=>{URL.revokeObjectURL(i),t(e)},r.onload=()=>{URL.revokeObjectURL(i),e(r)},r.src=i}));n.width=n.canvas.width=e.width,n.height=n.canvas.height=e.height,n.drawingContext.drawImage(e,0,0)}const u=()=>(n.modified=!0,r?r(n):n);return this._internal?this._internal(u):u()}catch(r){if(e._friendlyFileLoadError(0,t),"function"==typeof n)return n(r);throw r}},t.saveGif=async function(n,i,s={delay:0,units:"seconds",silent:!1,notificationDuration:0,notificationID:"progressBar",reset:!0}){if("string"!=typeof n)throw TypeError("fileName parameter must be a string");if("number"!=typeof i)throw TypeError("Duration parameter must be a number");const o=s&&s.delay||0,a=s&&s.units||"seconds",u=s&&s.silent||!1,l=s&&s.notificationDuration||0,h=s&&s.notificationID||"progressBar",c=!s||void 0===s.reset||s.reset;if("number"!=typeof o)throw TypeError("Delay parameter must be a number");if("seconds"!==a&&"frames"!==a)throw TypeError('Units parameter must be either "frames" or "seconds"');if("boolean"!=typeof u)throw TypeError("Silent parameter must be a boolean");if("number"!=typeof l)throw TypeError("Notification duration parameter must be a number");if("string"!=typeof h)throw TypeError("Notification ID parameter must be a string");this._recording=!0;let d=this._targetFrameRate;d!==1/0&&void 0!==d&&0!==d||(d=60);let p=1/d*1e3;p=p<20?20:p;const f="seconds"===a?i*d:i,m="seconds"===a?o*d:o;let g,y;c?(g=m,this.frameCount=g,y=f+m):(g=this.frameCount+m,y=g+f);const v=this._renderer._pixelDensity;this.pixelDensity(1);let b,x,_,w=[];for(null!==document.getElementById(h)&&document.getElementById(h).remove(),u||(b=this.createP(""),b.id(h),b.style("font-size","16px"),b.style("font-family","Montserrat"),b.style("background-color","#ffffffa0"),b.style("padding","8px"),b.style("border-radius","10px"),b.position(0,0)),this._renderer instanceof e.RendererGL&&(_=this.drawingContext,x=new Uint8Array(_.drawingBufferWidth*_.drawingBufferHeight*4)),this.noLoop(),await new Promise(requestAnimationFrame);g<y;){let t;this.redraw(),await new Promise(requestAnimationFrame),this._renderer instanceof e.RendererGL?(x=new Uint8Array(_.drawingBufferWidth*_.drawingBufferHeight*4),_.readPixels(0,0,_.drawingBufferWidth,_.drawingBufferHeight,_.RGBA,_.UNSIGNED_BYTE,x),t=r(x,this.width,this.height)):t=this.drawingContext.getImageData(0,0,this.width,this.height).data,w.push(t),g++,u||b.html("Saved frame <b>"+w.length.toString()+"</b> out of "+f.toString()),await new Promise((e=>setTimeout(e,0)))}u||b.html("Frames processed, generating color palette..."),this.loop(),this.pixelDensity(v);const C=Ks(),E=function(e){let t=new Uint8Array(e.length*e[0].length);for(let r=0;r<e.length;r++)t.set(e[r],r*e[0].length);let r=Ws(t,256,{format:"rgba4444",oneBitAlpha:!0});256===r.length?r[r.length-1]=[255*Math.random(),255*Math.random(),255*Math.random(),0]:r.push([255*Math.random(),255*Math.random(),255*Math.random(),0]);return r}(w),S={},A=e=>{const t=e.length/4,r=new Uint8Array(t);for(let n=0;n<t;n++){const t=e[4*n]<<24|e[4*n+1]<<16|e[4*n+2]<<8|e[4*n+3];void 0===S[t]&&(S[t]=Ys(E,e.slice(4*n,4*(n+1)))),r[n]=S[t]}return r},D=E.length-1;let T=[];for(let e=0;e<w.length;e++){const t=A(w[e]),r=t.slice();if(0===e)C.writeFrame(t,this.width,this.height,{palette:E,delay:p,dispose:1});else{for(let e=0;e<t.length;e++)t[e]===T[e]&&(t[e]=D);C.writeFrame(t,this.width,this.height,{delay:p,transparent:!0,transparentIndex:D,dispose:1})}T=r,u||b.html("Rendered frame <b>"+e.toString()+"</b> out of "+f.toString()),await new Promise((e=>setTimeout(e,0)))}C.finish();const F=C.bytesView(),I=new Blob([F],{type:"image/gif"});w=[],this._recording=!1,this.loop(),u||(b.html("Done. Downloading your gif!🌸"),l>0&&setTimeout((()=>b.remove()),1e3*l)),t.downloadFile(I,n,"gif")},t.image=function(e,t,r,s,o,a,u,l,h,c,d,p){let f=e.width,m=e.height;p=p||D,d=d||D,e.elt&&(f=void 0!==f?f:e.elt.width,m=void 0!==m?m:e.elt.height),e.elt&&e.elt.videoWidth&&!e.canvas&&(f=void 0!==f?f:e.elt.videoWidth,m=void 0!==m?m:e.elt.videoHeight);let g=t,y=r,v=s||f,b=o||m,x=a||0,_=u||0,w=void 0!==l?l:f,C=void 0!==h?h:m;w=i(w,f),C=i(C,m);let E=1;e.elt&&!e.canvas&&e.elt.style.width&&(E=e.elt.videoWidth&&!s?e.elt.videoWidth:e.elt.width,E/=parseInt(e.elt.style.width,10)),x*=E,_*=E,C*=E,w*=E;let S=bs.modeAdjust(g,y,v,b,this._renderer.states.imageMode);S=n(c,d,p,S.x,S.y,S.w,S.h,x,_,w,C),this._renderer.image(e,S.sx,S.sy,S.sw,S.sh,S.dx,S.dy,S.dw,S.dh)},t.tint=function(...e){return 0===e.length?this._renderer.states.tint:(this._renderer.states.setValue("tint",this.color(...e)),this)},t.noTint=function(){return this._renderer.states.setValue("tint",null),this},t.imageMode=function(e){if(void 0===e)return this._renderer.states.imageMode;e!==w&&e!==C&&e!==D||this._renderer.states.setValue("imageMode",e)}}function no(e,t){t.blend=function(...t){this._renderer?this._renderer.blend(...t):e.Renderer2D.prototype.blend.apply(this,t)},t.copy=function(...e){let r,n,i,s,o,a,u,l,h;if(9===e.length)r=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],u=e[6],l=e[7],h=e[8];else{if(8!==e.length)throw new Error("Signature not supported");r=this,n=e[0],i=e[1],s=e[2],o=e[3],a=e[4],u=e[5],l=e[6],h=e[7]}t._copyHelper(this,r,n,i,s,o,a,u,l,h)},t._copyHelper=(e,t,r,n,i,s,o,a,u,l)=>{const h=t.canvas.width/t.width;let c=0,d=0;t._renderer&&t._renderer.isP3D&&(c=t.width/2,d=t.height/2),e._renderer&&e._renderer.isP3D?(e.push(),e.resetMatrix(),e.noLights(),e.blendMode(e.BLEND),e.imageMode(e.CORNER),e._renderer.image(t,r+c,n+d,i,s,o,a,u,l),e.pop()):e.drawingContext.drawImage(t.canvas,h*(r+c),h*(n+d),h*i,h*s,o,a,u,l)},t.getFilterGraphicsLayer=function(){return this._renderer.getFilterGraphicsLayer()},t.filter=function(...t){let{shader:r,operation:n,value:i,useWebGL:s}=function(...t){let r={shader:void 0,operation:void 0,value:void 0,useWebGL:!0};if(t[0]instanceof e.Shader)return r.shader=t[0],r;r.operation=t[0];t.length>1&&"number"==typeof t[1]&&(r.value=t[1]);!1===t[t.length-1]&&(r.useWebGL=!1);return r}(...t);this._renderer.isP3D&&r?this._renderer.filter(r):s||this._renderer.isP3D?(!s&&this._renderer.isP3D&&console.warn("filter() with useWebGL=false is not supported in WEBGL"),this._renderer.isP3D?this._renderer.filter(n,i):(r?this._renderer.filterRenderer.setOperation(n,i,r):this._renderer.filterRenderer.setOperation(n,i),this._renderer.filterRenderer.applyFilter())):void 0!==this.canvas?Ai.apply(this.canvas,Ai[n],i):Ai.apply(this.elt,Ai[n],i)},t.get=function(e,t,r,n){return this._renderer.get(...arguments)},t.loadPixels=function(...e){return this._renderer.loadPixels()},t.set=function(e,t,r){this._renderer.set(e,t,r)},t.updatePixels=function(e,t,r,n){0!==this.pixels.length&&this._renderer.updatePixels(e,t,r,n)}}"undefined"!=typeof p5&&ro(p5,p5.prototype),"undefined"!=typeof p5&&no(p5,p5.prototype);class io{#A=null;constructor(...e){if(this.constructor===io)throw new Error("Class is of abstract type and can't be instantiated")}}const so=e=>{if(Math.sqrt(e.length)%1!=0)throw new Error("Array length must be a perfect square.");return!0};let oo=Array,ao=e=>Array.isArray(e);"undefined"!=typeof Float32Array&&(oo=Float32Array,ao=e=>Array.isArray(e)||e instanceof Float32Array);class uo extends io{matrix;#D;constructor(...e){if(super(...e),ao(e[0])&&so(e[0])){const t=Math.sqrt(e[0].length);this.#D=t,this.matrix=oo.from(e[0])}else"number"==typeof e[0]&&(this.#D=Number(e[0]),this.matrix=this.#T(e[0]));return this}get mat3(){return 3===this.#D?this.matrix:void 0}get mat4(){return 4===this.#D?this.matrix:void 0}add(e){if(this.matrix.length!==e.matrix.length)throw new Error("Matrices must be of the same dimension to add.");for(let t=0;t<this.matrix.length;t++)this.matrix[t]+=e.matrix[t];return this}setElement(e,t){return e>=0&&e<this.matrix.length&&(this.matrix[e]=t),this}reset(){return this.matrix=this.#T(this.#D),this}set(e){let t=oo.from([...arguments]);return e instanceof uo?t=oo.from(e.matrix):ao(e)&&(t=oo.from(e)),t.length!==this.matrix.length?(p5._friendlyError(`Expected same dimensions values but received different ${t.length}.`,"p5.Matrix.set"),this):(this.matrix=t,this)}get(){return new uo(this.matrix)}copy(){return new uo(this.matrix)}clone(){return this.copy()}diagonal(){const e=[];for(let t=0;t<this.#D;t++)e.push(this.matrix[t*(this.#D+1)]);return e}row(e){const t=[];for(let r=0;r<this.#D;r++)t.push(this.matrix[r*this.#D+e]);return new Pi(...t)}column(e){const t=[];for(let r=0;r<this.#D;r++)t.push(this.matrix[e*this.#D+r]);return new Pi(...t)}transpose(e){return 4===this.#D?this.#F(e):3===this.#D?this.#I(e):this.#k(e)}mult(e){let t;return e===this||e===this.matrix?t=this.copy().matrix:e instanceof uo?t=e.matrix:ao(e)&&so(e)?t=e:so(Array.from(arguments))&&(t=Array.from(arguments)),4===this.#D&&16===t.length?this.#N(t):3===this.#D&&9===t.length?this.#M(t):this.#O(t)}multiplyVec(e,t){void 0===t&&(t=e.copy());for(let r=0;r<this.#D;r++)t.values[r]=this.row(r).dot(e);return t}invert(e){if(4===this.#D)return this.#B(e);if(3===this.#D)return this.#L(e);throw new Error("Invert is not implemented for N>4 at the moment, we are working on it")}createSubMatrix3x3(){if(4===this.#D){const e=new uo(3);return e.mat3[0]=this.matrix[0],e.mat3[1]=this.matrix[1],e.mat3[2]=this.matrix[2],e.mat3[3]=this.matrix[4],e.mat3[4]=this.matrix[5],e.mat3[5]=this.matrix[6],e.mat3[6]=this.matrix[8],e.mat3[7]=this.matrix[9],e.mat3[8]=this.matrix[10],e}throw new Error("Matrix dimension must be 4 to create a 3x3 submatrix.")}inverseTranspose4x4({mat4:e}){if(3!==this.#D)throw new Error("This function only works with 3×3 matrices.");this.matrix[0]=e[0],this.matrix[1]=e[1],this.matrix[2]=e[2],this.matrix[3]=e[4],this.matrix[4]=e[5],this.matrix[5]=e[6],this.matrix[6]=e[8],this.matrix[7]=e[9],this.matrix[8]=e[10];const t=this.invert();if(t)t.transpose(this.matrix);else for(let e=0;e<9;e++)this.matrix[e]=0;return this}apply(e){let t;if(e===this||e===this.matrix)t=this.copy().matrix;else if(e instanceof uo)t=e.matrix;else if(ao(e))t=e;else{if(16!==arguments.length)return;t=arguments}const r=this.matrix,n=r[0],i=r[4],s=r[8],o=r[12];r[0]=t[0]*n+t[1]*i+t[2]*s+t[3]*o,r[4]=t[4]*n+t[5]*i+t[6]*s+t[7]*o,r[8]=t[8]*n+t[9]*i+t[10]*s+t[11]*o,r[12]=t[12]*n+t[13]*i+t[14]*s+t[15]*o;const a=r[1],u=r[5],l=r[9],h=r[13];r[1]=t[0]*a+t[1]*u+t[2]*l+t[3]*h,r[5]=t[4]*a+t[5]*u+t[6]*l+t[7]*h,r[9]=t[8]*a+t[9]*u+t[10]*l+t[11]*h,r[13]=t[12]*a+t[13]*u+t[14]*l+t[15]*h;const c=r[2],d=r[6],p=r[10],f=r[14];r[2]=t[0]*c+t[1]*d+t[2]*p+t[3]*f,r[6]=t[4]*c+t[5]*d+t[6]*p+t[7]*f,r[10]=t[8]*c+t[9]*d+t[10]*p+t[11]*f,r[14]=t[12]*c+t[13]*d+t[14]*p+t[15]*f;const m=r[3],g=r[7],y=r[11],v=r[15];return r[3]=t[0]*m+t[1]*g+t[2]*y+t[3]*v,r[7]=t[4]*m+t[5]*g+t[6]*y+t[7]*v,r[11]=t[8]*m+t[9]*g+t[10]*y+t[11]*v,r[15]=t[12]*m+t[13]*g+t[14]*y+t[15]*v,this}scale(e,t,r){return e instanceof Pi?(t=e.y,r=e.z,e=e.x):e instanceof Array&&(t=e[1],r=e[2],e=e[0]),this.matrix[0]*=e,this.matrix[1]*=e,this.matrix[2]*=e,this.matrix[3]*=e,this.matrix[4]*=t,this.matrix[5]*=t,this.matrix[6]*=t,this.matrix[7]*=t,this.matrix[8]*=r,this.matrix[9]*=r,this.matrix[10]*=r,this.matrix[11]*=r,this}rotate4x4(e,t,r,n){t instanceof Pi?(r=t.y,n=t.z,t=t.x):t instanceof Array&&(r=t[1],n=t[2],t=t[0]);const i=Math.sqrt(t*t+r*r+n*n);t*=1/i,r*=1/i,n*=1/i;const s=this.matrix[0],o=this.matrix[1],a=this.matrix[2],u=this.matrix[3],l=this.matrix[4],h=this.matrix[5],c=this.matrix[6],d=this.matrix[7],p=this.matrix[8],f=this.matrix[9],m=this.matrix[10],g=this.matrix[11],y=Math.sin(e),v=Math.cos(e),b=1-v,x=t*t*b+v,_=r*t*b+n*y,w=n*t*b-r*y,C=t*r*b-n*y,E=r*r*b+v,S=n*r*b+t*y,A=t*n*b+r*y,D=r*n*b-t*y,T=n*n*b+v;return this.matrix[0]=s*x+l*_+p*w,this.matrix[1]=o*x+h*_+f*w,this.matrix[2]=a*x+c*_+m*w,this.matrix[3]=u*x+d*_+g*w,this.matrix[4]=s*C+l*E+p*S,this.matrix[5]=o*C+h*E+f*S,this.matrix[6]=a*C+c*E+m*S,this.matrix[7]=u*C+d*E+g*S,this.matrix[8]=s*A+l*D+p*T,this.matrix[9]=o*A+h*D+f*T,this.matrix[10]=a*A+c*D+m*T,this.matrix[11]=u*A+d*D+g*T,this}translate(e){const t=e[0],r=e[1],n=e[2]||0;return this.matrix[12]+=this.matrix[0]*t+this.matrix[4]*r+this.matrix[8]*n,this.matrix[13]+=this.matrix[1]*t+this.matrix[5]*r+this.matrix[9]*n,this.matrix[14]+=this.matrix[2]*t+this.matrix[6]*r+this.matrix[10]*n,this.matrix[15]+=this.matrix[3]*t+this.matrix[7]*r+this.matrix[11]*n,this}rotateX(e){this.rotate4x4(e,1,0,0)}rotateY(e){this.rotate4x4(e,0,1,0)}rotateZ(e){this.rotate4x4(e,0,0,1)}perspective(e,t,r,n){const i=1/Math.tan(e/2),s=1/(r-n);return this.matrix[0]=i/t,this.matrix[1]=0,this.matrix[2]=0,this.matrix[3]=0,this.matrix[4]=0,this.matrix[5]=i,this.matrix[6]=0,this.matrix[7]=0,this.matrix[8]=0,this.matrix[9]=0,this.matrix[10]=(n+r)*s,this.matrix[11]=-1,this.matrix[12]=0,this.matrix[13]=0,this.matrix[14]=2*n*r*s,this.matrix[15]=0,this}ortho(e,t,r,n,i,s){const o=1/(e-t),a=1/(r-n),u=1/(i-s);return this.matrix[0]=-2*o,this.matrix[1]=0,this.matrix[2]=0,this.matrix[3]=0,this.matrix[4]=0,this.matrix[5]=-2*a,this.matrix[6]=0,this.matrix[7]=0,this.matrix[8]=0,this.matrix[9]=0,this.matrix[10]=2*u,this.matrix[11]=0,this.matrix[12]=(e+t)*o,this.matrix[13]=(n+r)*a,this.matrix[14]=(s+i)*u,this.matrix[15]=1,this}multiplyVec4(e,t,r,n){const i=new Array(4),s=this.matrix;return i[0]=s[0]*e+s[4]*t+s[8]*r+s[12]*n,i[1]=s[1]*e+s[5]*t+s[9]*r+s[13]*n,i[2]=s[2]*e+s[6]*t+s[10]*r+s[14]*n,i[3]=s[3]*e+s[7]*t+s[11]*r+s[15]*n,i}multiplyPoint({x:e,y:t,z:r}){const n=this.multiplyVec4(e,t,r,1);return new Pi(n[0],n[1],n[2])}multiplyAndNormalizePoint({x:e,y:t,z:r}){const n=this.multiplyVec4(e,t,r,1);return n[0]/=n[3],n[1]/=n[3],n[2]/=n[3],new Pi(n[0],n[1],n[2])}multiplyDirection({x:e,y:t,z:r}){const n=this.multiplyVec4(e,t,r,0);return new Pi(n[0],n[1],n[2])}multiplyVec3(e,t){return void 0===t&&(t=e.copy()),t.x=this.row(0).dot(e),t.y=this.row(1).dot(e),t.z=this.row(2).dot(e),t}#T(e){if(3===e)return new oo([1,0,0,0,1,0,0,0,1]);if(4===e)return new oo([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);const t=new oo(e*e).fill(0);for(let r=0;r<e;r++)t[r*e+r]=1;return t}#N(e){let t=this.matrix[0],r=this.matrix[1],n=this.matrix[2],i=this.matrix[3];return this.matrix[0]=t*e[0]+r*e[4]+n*e[8]+i*e[12],this.matrix[1]=t*e[1]+r*e[5]+n*e[9]+i*e[13],this.matrix[2]=t*e[2]+r*e[6]+n*e[10]+i*e[14],this.matrix[3]=t*e[3]+r*e[7]+n*e[11]+i*e[15],t=this.matrix[4],r=this.matrix[5],n=this.matrix[6],i=this.matrix[7],this.matrix[4]=t*e[0]+r*e[4]+n*e[8]+i*e[12],this.matrix[5]=t*e[1]+r*e[5]+n*e[9]+i*e[13],this.matrix[6]=t*e[2]+r*e[6]+n*e[10]+i*e[14],this.matrix[7]=t*e[3]+r*e[7]+n*e[11]+i*e[15],t=this.matrix[8],r=this.matrix[9],n=this.matrix[10],i=this.matrix[11],this.matrix[8]=t*e[0]+r*e[4]+n*e[8]+i*e[12],this.matrix[9]=t*e[1]+r*e[5]+n*e[9]+i*e[13],this.matrix[10]=t*e[2]+r*e[6]+n*e[10]+i*e[14],this.matrix[11]=t*e[3]+r*e[7]+n*e[11]+i*e[15],t=this.matrix[12],r=this.matrix[13],n=this.matrix[14],i=this.matrix[15],this.matrix[12]=t*e[0]+r*e[4]+n*e[8]+i*e[12],this.matrix[13]=t*e[1]+r*e[5]+n*e[9]+i*e[13],this.matrix[14]=t*e[2]+r*e[6]+n*e[10]+i*e[14],this.matrix[15]=t*e[3]+r*e[7]+n*e[11]+i*e[15],this}#O(e){if(e.length!==this.matrix.length)throw new Error("Matrices must be of the same dimension to multiply.");const t=new oo(this.matrix.length).fill(0);for(let r=0;r<this.#D;r++)for(let n=0;n<this.#D;n++)for(let i=0;i<this.#D;i++)t[r*this.#D+n]+=this.matrix[r*this.#D+i]*e[i*this.#D+n];return this.matrix=t,this}#M(e){let t=this.mat3[0],r=this.mat3[1],n=this.mat3[2];return this.mat3[0]=t*e[0]+r*e[3]+n*e[6],this.mat3[1]=t*e[1]+r*e[4]+n*e[7],this.mat3[2]=t*e[2]+r*e[5]+n*e[8],t=this.mat3[3],r=this.mat3[4],n=this.mat3[5],this.mat3[3]=t*e[0]+r*e[3]+n*e[6],this.mat3[4]=t*e[1]+r*e[4]+n*e[7],this.mat3[5]=t*e[2]+r*e[5]+n*e[8],t=this.mat3[6],r=this.mat3[7],n=this.mat3[8],this.mat3[6]=t*e[0]+r*e[3]+n*e[6],this.mat3[7]=t*e[1]+r*e[4]+n*e[7],this.mat3[8]=t*e[2]+r*e[5]+n*e[8],this}#k(){const e=this.#D;for(let t=0;t<e;t++)for(let r=0;r<e;r++)this.matrix[t*e+r]=this.matrix[r*e+t];return this}#F(e){let t,r,n,i,s,o;return console.log("====> 4x4"),e instanceof uo?(t=e.matrix[1],r=e.matrix[2],n=e.matrix[3],i=e.matrix[6],s=e.matrix[7],o=e.matrix[11],this.matrix[0]=e.matrix[0],this.matrix[1]=e.matrix[4],this.matrix[2]=e.matrix[8],this.matrix[3]=e.matrix[12],this.matrix[4]=t,this.matrix[5]=e.matrix[5],this.matrix[6]=e.matrix[9],this.matrix[7]=e.matrix[13],this.matrix[8]=r,this.matrix[9]=i,this.matrix[10]=e.matrix[10],this.matrix[11]=e.matrix[14],this.matrix[12]=n,this.matrix[13]=s,this.matrix[14]=o,this.matrix[15]=e.matrix[15]):ao(e)&&(t=e[1],r=e[2],n=e[3],i=e[6],s=e[7],o=e[11],this.matrix[0]=e[0],this.matrix[1]=e[4],this.matrix[2]=e[8],this.matrix[3]=e[12],this.matrix[4]=t,this.matrix[5]=e[5],this.matrix[6]=e[9],this.matrix[7]=e[13],this.matrix[8]=r,this.matrix[9]=i,this.matrix[10]=e[10],this.matrix[11]=e[14],this.matrix[12]=n,this.matrix[13]=s,this.matrix[14]=o,this.matrix[15]=e[15]),this}#I(e){void 0===e&&(e=this.mat3);const t=e[1],r=e[2],n=e[5];return this.mat3[0]=e[0],this.mat3[1]=e[3],this.mat3[2]=e[6],this.mat3[3]=t,this.mat3[4]=e[4],this.mat3[5]=e[7],this.mat3[6]=r,this.mat3[7]=n,this.mat3[8]=e[8],this}#B(e){let t,r,n,i,s,o,a,u,l,h,c,d,p,f,m,g;e instanceof uo?(t=e.matrix[0],r=e.matrix[1],n=e.matrix[2],i=e.matrix[3],s=e.matrix[4],o=e.matrix[5],a=e.matrix[6],u=e.matrix[7],l=e.matrix[8],h=e.matrix[9],c=e.matrix[10],d=e.matrix[11],p=e.matrix[12],f=e.matrix[13],m=e.matrix[14],g=e.matrix[15]):ao(e)&&(t=e[0],r=e[1],n=e[2],i=e[3],s=e[4],o=e[5],a=e[6],u=e[7],l=e[8],h=e[9],c=e[10],d=e[11],p=e[12],f=e[13],m=e[14],g=e[15]);const y=t*o-r*s,v=t*a-n*s,b=t*u-i*s,x=r*a-n*o,_=r*u-i*o,w=n*u-i*a,C=l*f-h*p,E=l*m-c*p,S=l*g-d*p,A=h*m-c*f,D=h*g-d*f,T=c*g-d*m;let F=y*T-v*D+b*A+x*S-_*E+w*C;return F?(F=1/F,this.matrix[0]=(o*T-a*D+u*A)*F,this.matrix[1]=(n*D-r*T-i*A)*F,this.matrix[2]=(f*w-m*_+g*x)*F,this.matrix[3]=(c*_-h*w-d*x)*F,this.matrix[4]=(a*S-s*T-u*E)*F,this.matrix[5]=(t*T-n*S+i*E)*F,this.matrix[6]=(m*b-p*w-g*v)*F,this.matrix[7]=(l*w-c*b+d*v)*F,this.matrix[8]=(s*D-o*S+u*C)*F,this.matrix[9]=(r*S-t*D-i*C)*F,this.matrix[10]=(p*_-f*b+g*y)*F,this.matrix[11]=(h*b-l*_-d*y)*F,this.matrix[12]=(o*E-s*A-a*C)*F,this.matrix[13]=(t*A-r*E+n*C)*F,this.matrix[14]=(f*v-p*x-m*y)*F,this.matrix[15]=(l*x-h*v+c*y)*F,this):null}#L(){const e=this.mat3[0],t=this.mat3[1],r=this.mat3[2],n=this.mat3[3],i=this.mat3[4],s=this.mat3[5],o=this.mat3[6],a=this.mat3[7],u=this.mat3[8],l=u*i-s*a,h=-u*n+s*o,c=a*n-i*o;let d=e*l+t*h+r*c;return d?(d=1/d,this.mat3[0]=l*d,this.mat3[1]=(-u*t+r*a)*d,this.mat3[2]=(s*t-r*i)*d,this.mat3[3]=h*d,this.mat3[4]=(u*e-r*o)*d,this.mat3[5]=(-s*e+r*n)*d,this.mat3[6]=c*d,this.mat3[7]=(-a*e+t*o)*d,this.mat3[8]=(i*e-t*n)*d,this):null}#P(){if(4!==this.#D)throw new Error("Determinant is only implemented for 4x4 matrices. We are working on it.");const e=this.matrix[0]*this.matrix[5]-this.matrix[1]*this.matrix[4],t=this.matrix[0]*this.matrix[6]-this.matrix[2]*this.matrix[4],r=this.matrix[0]*this.matrix[7]-this.matrix[3]*this.matrix[4],n=this.matrix[1]*this.matrix[6]-this.matrix[2]*this.matrix[5],i=this.matrix[1]*this.matrix[7]-this.matrix[3]*this.matrix[5],s=this.matrix[2]*this.matrix[7]-this.matrix[3]*this.matrix[6],o=this.matrix[8]*this.matrix[13]-this.matrix[9]*this.matrix[12],a=this.matrix[8]*this.matrix[14]-this.matrix[10]*this.matrix[12],u=this.matrix[8]*this.matrix[15]-this.matrix[11]*this.matrix[12],l=this.matrix[9]*this.matrix[14]-this.matrix[10]*this.matrix[13],h=this.matrix[9]*this.matrix[15]-this.matrix[11]*this.matrix[13];return e*(this.matrix[10]*this.matrix[15]-this.matrix[11]*this.matrix[14])-t*h+r*l+n*u-i*a+s*o}}function lo(e,t){e.Matrix=uo}"undefined"!=typeof p5&&lo(p5);class ho{constructor(e=128){this.length=0,this.data=new Float32Array(e),this.initialLength=e}dataArray(){return this.subArray(0,this.length)}clear(){this.length=0}rescale(){if(this.length<this.data.length/2){const e=1<<Math.ceil(Math.log2(this.length)),t=new Float32Array(e);t.set(this.data.subarray(0,this.length),0),this.data=t}}reset(){this.clear(),this.data=new Float32Array(this.initialLength)}push(...e){this.ensureLength(this.length+e.length),this.data.set(e,this.length),this.length+=e.length}slice(e,t){return this.data.slice(e,Math.min(t,this.length))}subArray(e,t){return this.data.subarray(e,Math.min(t,this.length))}ensureLength(e){for(;this.data.length<e;){const e=new Float32Array(2*this.data.length);e.set(this.data,0),this.data=e}}}function co(e,t){e.DataArray=ho}"undefined"!=typeof p5&&co(p5);class po{constructor(e,t,r,n){this.renderer=n,this.vertices=[],this.boundingBoxCache=null,this.lineVertices=new ho,this.lineTangentsIn=new ho,this.lineTangentsOut=new ho,this.lineSides=new ho,this.vertexNormals=[],this.faces=[],this.uvs=[],this.edges=[],this.vertexColors=[],this.vertexStrokeColors=[],this.userVertexProperties={},this.lineVertexColors=new ho,this.detailX=void 0!==e?e:1,this.detailY=void 0!==t?t:1,this.dirtyFlags={},this._hasFillTransparency=void 0,this._hasStrokeTransparency=void 0,this.gid=`_p5_Geometry_${po.nextId}`,po.nextId++,r instanceof Function&&r.call(this)}calculateBoundingBox(){if(this.boundingBoxCache)return this.boundingBoxCache;let e=new Pi(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),t=new Pi(Number.MIN_VALUE,Number.MIN_VALUE,Number.MIN_VALUE);for(let r=0;r<this.vertices.length;r++){let n=this.vertices[r];e.x=Math.min(e.x,n.x),e.y=Math.min(e.y,n.y),e.z=Math.min(e.z,n.z),t.x=Math.max(t.x,n.x),t.y=Math.max(t.y,n.y),t.z=Math.max(t.z,n.z)}let r=new Pi(t.x-e.x,t.y-e.y,t.z-e.z),n=new Pi((e.x+t.x)/2,(e.y+t.y)/2,(e.z+t.z)/2);return this.boundingBoxCache={min:e,max:t,size:r,offset:n},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.uvs.length=0;for(const e in this.userVertexProperties)this.userVertexProperties[e].delete();this.userVertexProperties={},this.dirtyFlags={}}hasFillTransparency(){if(void 0===this._hasFillTransparency){this._hasFillTransparency=!1;for(let e=0;e<this.vertexColors.length;e+=4)if(this.vertexColors[e+3]<1){this._hasFillTransparency=!0;break}}return this._hasFillTransparency}hasStrokeTransparency(){if(void 0===this._hasStrokeTransparency){this._hasStrokeTransparency=!1;for(let e=0;e<this.lineVertexColors.length;e+=4)if(this.lineVertexColors[e+3]<1){this._hasStrokeTransparency=!0;break}}return this._hasStrokeTransparency}clearColors(){return this.vertexColors=[],this}saveObj(e="model.obj"){let t="";if(this.vertices.forEach((e=>{t+=`v ${e.x} ${e.y} ${e.z}\n`})),this.uvs&&this.uvs.length>0)for(let e=0;e<this.uvs.length;e+=2)t+=`vt ${this.uvs[e]} ${this.uvs[e+1]}\n`;this.vertexNormals&&this.vertexNormals.length>0&&this.vertexNormals.forEach((e=>{t+=`vn ${e.x} ${e.y} ${e.z}\n`})),this.faces.forEach((e=>{let r="f";e.forEach((e=>{r+=" ",r+=e+1,(this.vertexNormals.length>0||this.uvs.length>0)&&(r+="/",this.uvs.length>0&&(r+=e+1),r+="/",this.vertexNormals.length>0&&(r+=e+1))})),t+=r+"\n"}));ki(new Blob([t],{type:"text/plain"}),e,"obj")}saveStl(e="model.stl",{binary:t=!1}={}){let r,n=e.substring(0,e.lastIndexOf(".")),i=[];for(let e of this.faces){const t=Pi.sub(this.vertices[e[1]],this.vertices[e[0]]),r=Pi.sub(this.vertices[e[2]],this.vertices[e[0]]),n=t.y*r.z-t.z*r.y,s=t.z*r.x-t.x*r.z,o=t.x*r.y-t.y*r.x;i.push(new Pi(n,s,o).normalize())}if(t){let e=80;const t=2*this.faces.length+3*this.faces.length*4*4+80+4,n=new ArrayBuffer(t);r=new DataView(n),r.setUint32(e,this.faces.length,!0),e+=4;for(const[t,n]of Object.entries(this.faces)){const s=i[t];r.setFloat32(e,s.x,!0),e+=4,r.setFloat32(e,s.y,!0),e+=4,r.setFloat32(e,s.z,!0),e+=4;for(let t of n){const n=this.vertices[t];r.setFloat32(e,n.x,!0),e+=4,r.setFloat32(e,n.y,!0),e+=4,r.setFloat32(e,n.z,!0),e+=4}r.setUint16(e,0,!0),e+=2}}else{r="solid "+n+"\n";for(const[e,t]of Object.entries(this.faces)){const n=i[e];r+=" facet norm "+n.x+" "+n.y+" "+n.z+"\n",r+="  outer loop\n";for(let e of t){const t=this.vertices[e];r+="   vertex "+t.x+" "+t.y+" "+t.z+"\n"}r+="  endloop\n",r+=" endfacet\n"}r+="endsolid "+n+"\n"}ki(new Blob([r],{type:"text/plain"}),e,"stl")}flipU(){this.uvs=this.uvs.flat().map(((e,t)=>t%2==0?1-e:e))}flipV(){this.uvs=this.uvs.flat().map(((e,t)=>t%2==0?e:1-e))}computeFaces(){this.faces.length=0;const e=this.detailX+1;let t,r,n,i;for(let s=0;s<this.detailY;s++)for(let o=0;o<this.detailX;o++)t=s*e+o,r=s*e+o+1,n=(s+1)*e+o+1,i=(s+1)*e+o,this.faces.push([t,r,i]),this.faces.push([i,r,n]);return this}_getFaceNormal(e){const t=this.faces[e],r=this.vertices[t[0]],n=this.vertices[t[1]],i=this.vertices[t[2]],s=Pi.sub(n,r),o=Pi.sub(i,r),a=Pi.cross(s,o),u=Pi.mag(a);let l=u/(Pi.mag(s)*Pi.mag(o));return 0===l||isNaN(l)?(console.warn("p5.Geometry.prototype._getFaceNormal:","face has colinear sides or a repeated vertex"),a):(l>1&&(l=1),a.mult(Math.asin(l)/u))}computeNormals(e=ke,{roundToPrecision:t=3}={}){const r=this.vertexNormals;let n=this.vertices;const i=this.faces;let s;if(e===Ne){const e={},r=[],s=Math.pow(10,t),o=e=>Math.round(e*s)/s,a=e=>`${o(e.x)},${o(e.y)},${o(e.z)}`;for(let t=0;t<n.length;t++){const i=n[t],s=a(i);void 0===e[s]&&(e[s]=r.length,r.push(i))}i.forEach((t=>{for(let r=0;r<3;++r){const i=t[r],s=n[i],o=a(s);t[r]=e[o]}})),this.edges.forEach((t=>{for(let r=0;r<2;++r){const i=t[r],s=n[i],o=a(s);t[r]=e[o]}})),this.vertices=n=r}for(r.length=0,s=0;s<n.length;++s)r.push(new Pi(0,0,0));for(i.forEach(((e,t)=>{const n=this._getFaceNormal(t);for(let t=0;t<3;++t){const i=e[t];r[i].add(n)}})),s=0;s<n.length;++s)r[s].normalize();return this}averageNormals(){for(let e=0;e<=this.detailY;e++){const t=this.detailX+1;let r=Pi.add(this.vertexNormals[e*t],this.vertexNormals[e*t+this.detailX]);r=Pi.div(r,2),this.vertexNormals[e*t]=r,this.vertexNormals[e*t+this.detailX]=r}return this}averagePoleNormals(){let e=new Pi(0,0,0);for(let t=0;t<this.detailX;t++)e.add(this.vertexNormals[t]);e=Pi.div(e,this.detailX);for(let t=0;t<this.detailX;t++)this.vertexNormals[t]=e;e=new Pi(0,0,0);for(let t=this.vertices.length-1;t>this.vertices.length-1-this.detailX;t--)e.add(this.vertexNormals[t]);e=Pi.div(e,this.detailX);for(let t=this.vertices.length-1;t>this.vertices.length-1-this.detailX;t--)this.vertexNormals[t]=e;return this}_makeTriangleEdges(){this.edges.length=0;for(let e=0;e<this.faces.length;e++)this.edges.push([this.faces[e][0],this.faces[e][1]]),this.edges.push([this.faces[e][1],this.faces[e][2]]),this.edges.push([this.faces[e][2],this.faces[e][0]]);return this}makeEdgesFromFaces(){this._makeTriangleEdges()}_edgesToVertices(){this.lineVertices.clear(),this.lineTangentsIn.clear(),this.lineTangentsOut.clear(),this.lineSides.clear();const e=new Map,t=new Set;let r;for(let n=0;n<this.edges.length;n++){const i=this.edges[n-1],s=this.edges[n],o=s[0]===s[1],a=this.vertices[s[0]],u=this.vertices[s[1]],l=this.vertexStrokeColors.length>0&&i?this.vertexStrokeColors.slice(4*i[1],4*(i[1]+1)):[0,0,0,0],h=this.vertexStrokeColors.length>0?this.vertexStrokeColors.slice(4*s[0],4*(s[0]+1)):[0,0,0,0],c=this.vertexStrokeColors.length>0?this.vertexStrokeColors.slice(4*s[1],4*(s[1]+1)):[0,0,0,0],d=o?new Pi(0,1,0):u.copy().sub(a).normalize(),p=d.magSq()>0;if(p&&this._addSegment(a,u,h,c,d),!this.renderer?._simpleLines){if(n>0&&i[1]===s[0])t.has(s[0])||(t.add(s[0]),e.delete(s[0]),r&&p&&d.dot(r)<1-1e-8&&this._addJoin(a,r,d,h));else if(o)this._addCap(a,d.copy().mult(-1),h),this._addCap(a,d,h);else{if(p&&!t.has(s[0])){const r=e.get(s[0]);r?(this._addJoin(a,r.dir,d,h),e.delete(s[0]),t.add(s[0])):e.set(s[0],{point:a,dir:d.copy().mult(-1),color:h})}if(!o&&r&&!t.has(i[1])){const n=e.get(i[1]);n?(this._addJoin(this.vertices[i[1]],r,n.dir.copy().mult(-1),l),e.delete(i[1]),t.add(i[1])):e.set(i[1],{point:this.vertices[i[1]],dir:r,color:l}),r=void 0}}if(n===this.edges.length-1&&!t.has(s[1])){const r=e.get(s[1]);r?(this._addJoin(u,d,r.dir.copy().mult(-1),c),e.delete(s[1]),t.add(s[1])):e.set(s[1],{point:u,dir:d,color:c})}p&&(r=d)}}for(const{point:t,dir:r,color:n}of e.values())this._addCap(t,r,n);return this}_addSegment(e,t,r,n,i){const s=e.array(),o=t.array(),a=i.array();this.lineSides.push(1,1,-1,1,-1,-1);for(const e of[this.lineTangentsIn,this.lineTangentsOut])for(let t=0;t<6;t++)e.push(...a);return this.lineVertices.push(...s,...o,...s,...o,...o,...s),this.renderer?._simpleLines||this.lineVertexColors.push(...r,...n,...r,...n,...n,...r),this}_addCap(e,t,r){const n=e.array(),i=t.array(),s=[0,0,0];for(let e=0;e<6;e++)this.lineVertices.push(...n),this.lineTangentsIn.push(...i),this.lineTangentsOut.push(...s),this.lineVertexColors.push(...r);return this.lineSides.push(-1,2,-2,1,2,-1),this}_addJoin(e,t,r,n){const i=e.array(),s=t.array(),o=r.array();for(let e=0;e<12;e++)this.lineVertices.push(...i),this.lineTangentsIn.push(...s),this.lineTangentsOut.push(...o),this.lineVertexColors.push(...n);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){const e=this.vertices[0].copy(),t=this.vertices[0].copy();for(let r=0;r<this.vertices.length;r++)e.x=Math.max(e.x,this.vertices[r].x),t.x=Math.min(t.x,this.vertices[r].x),e.y=Math.max(e.y,this.vertices[r].y),t.y=Math.min(t.y,this.vertices[r].y),e.z=Math.max(e.z,this.vertices[r].z),t.z=Math.min(t.z,this.vertices[r].z);const r=Pi.lerp(e,t,.5),n=Pi.sub(e,t),i=200/Math.max(Math.max(n.x,n.y),n.z);for(let e=0;e<this.vertices.length;e++)this.vertices[e].sub(r),this.vertices[e].mult(i)}return this}vertexProperty(e,t,r){let n;this.userVertexProperties[e]||(n=this.userVertexProperties[e]=this._userVertexPropertyHelper(e,t,r)),n=this.userVertexProperties[e],r?n.pushDirect(t):(n.setCurrentData(t),n.pushCurrentData())}_userVertexPropertyHelper(e,t,r){const n=this.userVertexProperties[e]={name:e,dataSize:r||(t.length?t.length:1),geometry:this,getName(){return this.name},getCurrentData(){return void 0===this.currentData&&(this.currentData=new Array(this.getDataSize()).fill(0)),this.currentData},getDataSize(){return this.dataSize},getSrcName(){return this.name.concat("Src")},getDstName(){return this.name.concat("Buffer")},getSrcArray(){const e=this.getSrcName();return this.geometry[e]},setCurrentData(e){this.currentData=e},pushCurrentData(){const e=this.getCurrentData();this.pushDirect(e)},pushDirect(e){e.length?this.getSrcArray().push(...e):this.getSrcArray().push(e)},resetSrcArray(){this.geometry[this.getSrcName()]=[]},delete(){const e=this.getSrcName();delete this.geometry[e]}};return this[n.getSrcName()]=[],this.userVertexProperties[e]}}function fo(e,t){e.Geometry=po}po.nextId=0,"undefined"!=typeof p5&&fo(p5);class mo{constructor(e){this.renderer=e,e._pInst.push(),this.identityMatrix=new uo(4),e.states.setValue("uModelMatrix",new uo(4)),this.geometry=new po(void 0,void 0,void 0,this.renderer),this.geometry.gid=`_p5_GeometryBuilder_${mo.nextGeometryId}`,mo.nextGeometryId++,this.hasTransform=!1}transformVertices(e){return this.hasTransform?e.map((e=>this.renderer.states.uModelMatrix.multiplyPoint(e))):e}transformNormals(e){return this.hasTransform?e.map((e=>this.renderer.scratchMat3.multiplyVec(e))):e}addGeometry(e){this.hasTransform=!this.renderer.states.uModelMatrix.mat4.every(((e,t)=>e===this.identityMatrix.mat4[t])),this.hasTransform&&this.renderer.scratchMat3.inverseTranspose4x4(this.renderer.states.uModelMatrix);let t=this.geometry.vertices.length;for(const t of this.transformVertices(e.vertices))this.geometry.vertices.push(t);for(const t of this.transformNormals(e.vertexNormals))this.geometry.vertexNormals.push(t);for(const t of e.uvs)this.geometry.uvs.push(t);const r=e.userVertexProperties,n=this.geometry.userVertexProperties,i=this.geometry.vertices.length-e.vertices.length;for(const t in n){if(t in r)continue;const i=n[t],s=i.getDataSize()*e.vertices.length,o=Array(s).fill(0);i.pushDirect(o)}for(const e in r){const t=r[e],s=t.getSrcArray(),o=t.getDataSize();if(i>0&&!(e in n)){const t=Array(o*i).fill(0);this.geometry.vertexProperty(e,t,o)}this.geometry.vertexProperty(e,s,o)}if(this.renderer.states.fillColor&&this.geometry.faces.push(...e.faces.map((e=>e.map((e=>e+t))))),this.renderer.states.strokeColor)for(const r of e.edges.map((e=>e.map((e=>e+t)))))this.geometry.edges.push(r);const s=[...e.vertexColors];for(;s.length<4*e.vertices.length;)s.push(...this.renderer.states.curFillColor);for(const e of s)this.geometry.vertexColors.push(e)}addImmediate(e,t,{validateFaces:r=!1}={}){const n=[];if(this.renderer.states.fillColor)if(5===t||t===P)for(let t=2;t<e.vertices.length;t++)t%2==0?n.push([t,t-1,t-2]):n.push([t,t-2,t-1]);else if(6===t)for(let t=2;t<e.vertices.length;t++)n.push([0,t-1,t]);else if(4===t)for(let t=0;t<e.vertices.length;t+=3)(!r||e.vertices[t].copy().sub(e.vertices[t+1]).cross(e.vertices[t].copy().sub(e.vertices[t+2])).magSq()>0)&&n.push([t,t+1,t+2]);this.addGeometry(Object.assign({},e,{faces:n}))}addRetained(e){this.addGeometry(e)}finish(){return this.renderer._pInst.pop(),this.geometry}}mo.nextGeometryId=0;class go{constructor(e,t,r,n){this.w=e,this.vec=new Pi(t,r,n)}static fromAxisAngle(e,t,r,n){const i=Math.cos(e/2),s=new Pi(t,r,n).normalize().mult(Math.sin(e/2));return new go(i,s.x,s.y,s.z)}conjugate(){return new go(this.w,-this.vec.x,-this.vec.y,-this.vec.z)}multiply(e){return new go(this.w*e.w-this.vec.x*e.vec.x-this.vec.y*e.vec.y-this.vec.z-e.vec.z,this.w*e.vec.x+this.vec.x*e.w+this.vec.y*e.vec.z-this.vec.z*e.vec.y,this.w*e.vec.y-this.vec.x*e.vec.z+this.vec.y*e.w+this.vec.z*e.vec.x,this.w*e.vec.z+this.vec.x*e.vec.y-this.vec.y*e.vec.x+this.vec.z*e.w)}rotateVector(e){return Pi.mult(e,this.w*this.w-this.vec.dot(this.vec)).add(Pi.mult(this.vec,2*e.dot(this.vec))).add(Pi.mult(this.vec,2*this.w).cross(e)).clampToZero()}rotateBy(e){return e.multiply(this).multiply(e.conjugate()).vec.clampToZero()}}function yo(e,t){e.Quat=go}"undefined"!=typeof p5&&yo(p5);class vo{constructor(e){this._renderer=e,this.cameraType="default",this.useLinePerspective=!0,this.cameraMatrix=new uo(4),this.projMatrix=new uo(4),this.yScale=1}perspective(e,t,r,n){const i=this._renderer.zClipRange();this.cameraType=arguments.length>0?"custom":"default",void 0===e?(e=this.defaultCameraFOV,this.cameraFOV=e):this.cameraFOV=this._renderer._pInst._toRadians(e),void 0===t&&(t=this.defaultAspectRatio),void 0===r&&(r=this.defaultCameraNear),void 0===n&&(n=this.defaultCameraFar),r<=1e-4&&(r=.01,console.log("Avoid perspective near plane values close to or below 0. Setting value to 0.01.")),n<r&&console.log("Perspective far plane value is less than near plane value. Nothing will be shown."),this.aspectRatio=t,this.cameraNear=r,this.cameraFar=n,this.projMatrix=new uo(4);const s=1/Math.tan(this.cameraFOV/2),o=1/(this.cameraNear-this.cameraFar);let a,u;0===i[0]?(a=n/(r-n),u=n*r/(r-n)):(a=(n+r)*o,u=2*n*r*o),this.projMatrix.set(s/t,0,0,0,0,-s*this.yScale,0,0,0,0,a,-1,0,0,u,0),this._isActive()&&(this._renderer.states.setValue("uPMatrix",this._renderer.states.uPMatrix.clone()),this._renderer.states.uPMatrix.set(this.projMatrix))}ortho(e,t,r,n,i,s){const o=this.fbo||this._renderer;void 0===e&&(e=-o.width/2),void 0===t&&(t=+o.width/2),void 0===r&&(r=-o.height/2),void 0===n&&(n=+o.height/2),void 0===i&&(i=0),void 0===s&&(s=Math.max(o.width,o.height)+800),this.cameraNear=i,this.cameraFar=s;const a=t-e,u=n-r,l=s-i,h=2/a,c=2/u*this.yScale,d=-2/l,p=-(t+e)/a,f=-(n+r)/u,m=-(s+i)/l;this.projMatrix=new uo(4),this.projMatrix.set(h,0,0,0,0,-c,0,0,0,0,d,0,p,f,m,1),this._isActive()&&(this._renderer.states.setValue("uPMatrix",this._renderer.states.uPMatrix.clone()),this._renderer.states.uPMatrix.set(this.projMatrix)),this.cameraType="custom"}frustum(e,t,r,n,i,s){void 0===e&&(e=.05*-this._renderer.width),void 0===t&&(t=.05*+this._renderer.width),void 0===r&&(r=.05*+this._renderer.height),void 0===n&&(n=.05*-this._renderer.height),void 0===i&&(i=this.defaultCameraNear),void 0===s&&(s=this.defaultCameraFar),this.cameraNear=i,this.cameraFar=s;const o=t-e,a=n-r,u=s-i,l=2*i/o,h=2*i/a*this.yScale,c=-2*s*i/u,d=(t+e)/o,p=(n+r)/a,f=-(s+i)/u;this.projMatrix=new uo(4),this.projMatrix.set(l,0,0,0,0,-h,0,0,d,p,f,-1,0,0,c,0),this._isActive()&&(this._renderer.states.setValue("uPMatrix",this._renderer.states.uPMatrix.clone()),this._renderer.states.uPMatrix.set(this.projMatrix)),this.cameraType="custom"}_rotateView(e,t,r,n){let i=this.centerX,s=this.centerY,o=this.centerZ;i-=this.eyeX,s-=this.eyeY,o-=this.eyeZ;const a=new uo(4);a.rotate4x4(this._renderer._pInst._toRadians(e),t,r,n);const u=[i*a.mat4[0]+s*a.mat4[4]+o*a.mat4[8],i*a.mat4[1]+s*a.mat4[5]+o*a.mat4[9],i*a.mat4[2]+s*a.mat4[6]+o*a.mat4[10]];u[0]+=this.eyeX,u[1]+=this.eyeY,u[2]+=this.eyeZ,this.camera(this.eyeX,this.eyeY,this.eyeZ,u[0],u[1],u[2],this.upX,this.upY,this.upZ)}roll(e){const t=this._getLocalAxes(),r=go.fromAxisAngle(this._renderer._pInst._toRadians(e),t.z[0],t.z[1],t.z[2]).rotateVector(new Pi(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(e){const t=this._getLocalAxes();this._rotateView(e,t.y[0],t.y[1],t.y[2])}tilt(e){const t=this._getLocalAxes();this._rotateView(e,t.x[0],t.x[1],t.x[2])}lookAt(e,t,r){this.camera(this.eyeX,this.eyeY,this.eyeZ,e,t,r,this.upX,this.upY,this.upZ)}camera(e,t,r,n,i,s,o,a,u){void 0===e&&(e=this.defaultEyeX,t=this.defaultEyeY,r=this.defaultEyeZ,n=e,i=t,s=0,o=0,a=1,u=0),this.eyeX=e,this.eyeY=t,this.eyeZ=r,void 0!==n&&(this.centerX=n,this.centerY=i,this.centerZ=s),void 0!==o&&(this.upX=o,this.upY=a,this.upZ=u);const l=this._getLocalAxes();this.cameraMatrix.set(l.x[0],l.y[0],l.z[0],0,l.x[1],l.y[1],l.z[1],0,l.x[2],l.y[2],l.z[2],0,0,0,0,1);const h=-e,c=-t,d=-r;return this.cameraMatrix.translate([h,c,d]),this._isActive()&&(this._renderer.states.setValue("uViewMatrix",this._renderer.states.uViewMatrix.clone()),this._renderer.states.uViewMatrix.set(this.cameraMatrix)),this}move(e,t,r){const n=this._getLocalAxes(),i=[n.x[0]*e,n.x[1]*e,n.x[2]*e],s=[n.y[0]*t,n.y[1]*t,n.y[2]*t],o=[n.z[0]*r,n.z[1]*r,n.z[2]*r];this.camera(this.eyeX+i[0]+s[0]+o[0],this.eyeY+i[1]+s[1]+o[1],this.eyeZ+i[2]+s[2]+o[2],this.centerX+i[0]+s[0]+o[0],this.centerY+i[1]+s[1]+o[1],this.centerZ+i[2]+s[2]+o[2],this.upX,this.upY,this.upZ)}setPosition(e,t,r){const n=e-this.eyeX,i=t-this.eyeY,s=r-this.eyeZ;this.camera(e,t,r,this.centerX+n,this.centerY+i,this.centerZ+s,this.upX,this.upY,this.upZ)}set(e){const t=["eyeX","eyeY","eyeZ","centerX","centerY","centerZ","upX","upY","upZ","cameraFOV","aspectRatio","cameraNear","cameraFar","cameraType","yScale","useLinePerspective"];for(const r of t)this[r]=e[r];this.cameraMatrix=e.cameraMatrix.copy(),this.projMatrix=e.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(e,t,r){if(0===r)return void this.set(e);if(1===r)return void this.set(t);0!==this.projMatrix.mat4[15]&&(this.projMatrix.setElement(0,e.projMatrix.mat4[0]*Math.pow(t.projMatrix.mat4[0]/e.projMatrix.mat4[0],r)),this.projMatrix.setElement(5,e.projMatrix.mat4[5]*Math.pow(t.projMatrix.mat4[5]/e.projMatrix.mat4[5],r)),this._isActive()&&this._renderer.states.setValue("uPMatrix",this.projMatrix.clone()));const n=new Pi(e.eyeX,e.eyeY,e.eyeZ),i=new Pi(t.eyeX,t.eyeY,t.eyeZ),s=new Pi(e.centerX,e.centerY,e.centerZ),o=new Pi(t.centerX,t.centerY,t.centerZ),a=Pi.dist(n,s),u=Pi.dist(i,o),l=a*Math.pow(u/a,r),h=Pi.sub(n,i),c=n.copy().sub(i).sub(s).add(o),d=c.magSq();let p=1;d>1e-6&&(p=Pi.dot(h,c)/d,p=Math.max(0,Math.min(p,1)));const f=Pi.lerp(Pi.lerp(n,s,p),Pi.lerp(i,o,p),r),m=e.cameraMatrix.createSubMatrix3x3(),g=t.cameraMatrix.createSubMatrix3x3(),y=m.row(2),v=g.row(2),b=m.row(1),x=g.row(1),_=new Pi(0,0,0),w=new Pi(0,0,0),C=new Pi(0,0,0),E=new Pi(0,0,0),S=g.mult(m.copy().transpose()),A=S.diagonal();let D,T,F,I,k=.5*(A[0]+A[1]+A[2]-1);if(1-k<1e-7)return _.set(Pi.lerp(y,v,r)).normalize(),C.set(_).mult(p*l).add(f),E.set(_).mult((p-1)*l).add(f),w.set(Pi.lerp(b,x,r)).normalize(),void this.camera(C.x,C.y,C.z,E.x,E.y,E.z,w.x,w.y,w.z);let N=1/(1-k);const M=Math.max(A[0],A[1],A[2]),O=S.mat3[1]+S.mat3[3],B=S.mat3[2]+S.mat3[6],L=S.mat3[5]+S.mat3[7];M===A[0]?(D=Math.sqrt((A[0]-k)*N),N/=D,T=.5*O*N,F=.5*B*N,I=.5*(S.mat3[7]-S.mat3[5])/D):M===A[1]?(T=Math.sqrt((A[1]-k)*N),N/=T,F=.5*L*N,D=.5*O*N,I=.5*(S.mat3[2]-S.mat3[6])/T):(F=Math.sqrt((A[2]-k)*N),N/=F,D=.5*B*N,T=.5*L*N,I=.5*(S.mat3[3]-S.mat3[1])/F);const P=r*Math.atan2(I,k),R=Math.cos(P),V=Math.sin(P),U=1-R,z=D*T,j=T*F,G=F*D,$=new uo([R+U*D*D,U*z+V*F,U*G-V*T,U*z-V*F,R+U*T*T,U*j+V*D,U*G+V*T,U*j-V*D,R+U*F*F]);$.multiplyVec(y,_),C.set(_).mult(p*l).add(f),E.set(_).mult((p-1)*l).add(f),$.multiplyVec(b,w),this.camera(C.x,C.y,C.z,E.x,E.y,E.z,w.x,w.y,w.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(){"default"===this.cameraType&&(this._computeCameraDefaultSettings(),this.cameraFOV=this.defaultCameraFOV,this.aspectRatio=this.defaultAspectRatio,this.perspective())}copy(){const e=new vo(this._renderer);return e.cameraFOV=this.cameraFOV,e.aspectRatio=this.aspectRatio,e.eyeX=this.eyeX,e.eyeY=this.eyeY,e.eyeZ=this.eyeZ,e.centerX=this.centerX,e.centerY=this.centerY,e.centerZ=this.centerZ,e.upX=this.upX,e.upY=this.upY,e.upZ=this.upZ,e.cameraNear=this.cameraNear,e.cameraFar=this.cameraFar,e.cameraType=this.cameraType,e.useLinePerspective=this.useLinePerspective,e.cameraMatrix=this.cameraMatrix.copy(),e.projMatrix=this.projMatrix.copy(),e.yScale=this.yScale,e.cameraType=this.cameraType,e.defaultAspectRatio=this.defaultAspectRatio,e.defaultEyeX=this.defaultEyeX,e.defaultEyeY=this.defaultEyeY,e.defaultEyeZ=this.defaultEyeZ,e.defaultCameraFOV=this.defaultCameraFOV,e.defaultCenterX=this.defaultCenterX,e.defaultCenterY=this.defaultCenterY,e.defaultCenterZ=this.defaultCenterZ,e.defaultCameraNear=this.defaultCameraNear,e.defaultCameraFar=this.defaultCameraFar,e}clone(){return this.copy()}_getLocalAxes(){let e=this.eyeX-this.centerX,t=this.eyeY-this.centerY,r=this.eyeZ-this.centerZ;const n=Math.sqrt(e*e+t*t+r*r);0!==n&&(e/=n,t/=n,r/=n);let i=this.upX,s=this.upY,o=this.upZ,a=s*r-o*t,u=-i*r+o*e,l=i*t-s*e;i=t*l-r*u,s=-e*l+r*a,o=e*u-t*a;const h=Math.sqrt(a*a+u*u+l*l);0!==h&&(a/=h,u/=h,l/=h);const c=Math.sqrt(i*i+s*s+o*o);return 0!==c&&(i/=c,s/=c,o/=c),{x:[a,u,l],y:[i,s,o],z:[e,t,r]}}_orbit(e,t,r){const n=this.eyeX-this.centerX,i=this.eyeY-this.centerY,s=this.eyeZ-this.centerZ;let o=Math.hypot(n,i,s);const a=new Pi(n,i,s).normalize(),u=new Pi(this.upX,this.upY,this.upZ).normalize(),l=Pi.cross(u,a).normalize(),h=Pi.cross(l,u);o*=Math.pow(10,r),o<this.cameraNear&&(o=this.cameraNear),o>this.cameraFar&&(o=this.cameraFar);const c=Math.acos(Math.max(-1,Math.min(1,Pi.dot(a,u))))+t,d=e;(c<=0||c>=Math.PI)&&(this.upX*=-1,this.upY*=-1,this.upZ*=-1),u.mult(Math.cos(c)),h.mult(Math.cos(d)*Math.sin(c)),l.mult(Math.sin(d)*Math.sin(c)),a.set(u).add(h).add(l),this.eyeX=o*a.x+this.centerX,this.eyeY=o*a.y+this.centerY,this.eyeZ=o*a.z+this.centerZ,this.camera(this.eyeX,this.eyeY,this.eyeZ,this.centerX,this.centerY,this.centerZ,this.upX,this.upY,this.upZ)}_orbitFree(e,t,r){const n=this.eyeX-this.centerX,i=this.eyeY-this.centerY,s=this.eyeZ-this.centerZ;let o=Math.hypot(n,i,s);const a=new Pi(n,i,s).normalize(),u=new Pi(this.upX,this.upY,this.upZ),l=Pi.cross(u,a).normalize(),h=Pi.cross(a,l),c=Math.atan2(t,e);h.mult(Math.sin(c)),l.mult(Math.cos(c)).add(h);const d=Math.sqrt(e*e+t*t),p=Pi.cross(a,l);o*=Math.pow(10,r),o<this.cameraNear&&(o=this.cameraNear),o>this.cameraFar&&(o=this.cameraFar);const f=Math.cos(d),m=Math.sin(d),g=u.dot(a),y=u.dot(l),v=g*f+y*m,b=-g*m+y*f,x=u.dot(p);u.x=v*a.x+b*l.x+x*p.x,u.y=v*a.y+b*l.y+x*p.y,u.z=v*a.z+b*l.z+x*p.z,l.mult(-m),a.mult(f).add(l).mult(o),this.camera(a.x+this.centerX,a.y+this.centerY,a.z+this.centerZ,this.centerX,this.centerY,this.centerZ,u.x,u.y,u.z)}_isActive(){return this===this._renderer.states.curCamera}}function bo(e,t){t.camera=function(...e){return this._assert3d("camera"),this._renderer.camera(...e),this},t.perspective=function(...e){return this._assert3d("perspective"),this._renderer.perspective(...e),this},t.linePerspective=function(e){if(!(this._renderer instanceof zo))throw new Error("linePerspective() must be called in WebGL mode.");return this._renderer.linePerspective(e)},t.ortho=function(...e){return this._assert3d("ortho"),this._renderer.ortho(...e),this},t.frustum=function(...e){return this._assert3d("frustum"),this._renderer.frustum(...e),this},t.createCamera=function(){return this._assert3d("createCamera"),this._renderer.createCamera()},t.setCamera=function(e){this._renderer.setCamera(e)},e.Camera=vo,zo.prototype.camera=function(...e){this.states.setValue("curCamera",this.states.curCamera.clone()),this.states.curCamera.camera(...e)},zo.prototype.perspective=function(...e){this.states.setValue("curCamera",this.states.curCamera.clone()),this.states.curCamera.perspective(...e)},zo.prototype.linePerspective=function(e){if(void 0===e)return this.states.curCamera.useLinePerspective;this.states.setValue("curCamera",this.states.curCamera.clone()),this.states.curCamera.useLinePerspective=e},zo.prototype.ortho=function(...e){this.states.setValue("curCamera",this.states.curCamera.clone()),this.states.curCamera.ortho(...e)},zo.prototype.frustum=function(...e){this.states.setValue("curCamera",this.states.curCamera.clone()),this.states.curCamera.frustum(...e)},zo.prototype.createCamera=function(){const e=new vo(this);return e._computeCameraDefaultSettings(),e._setDefaultCamera(),e},zo.prototype.setCamera=function(e){this.states.setValue("curCamera",e),this.states.setValue("uPMatrix",this.states.uPMatrix.clone()),this.states.uPMatrix.set(e.projMatrix),this.states.setValue("uViewMatrix",this.states.uViewMatrix.clone()),this.states.uViewMatrix.set(e.cameraMatrix)}}"undefined"!=typeof p5&&bo(p5,p5.prototype);var xo={exports:{}};!function(e){var t;function r(e,t){return e.b===t.b&&e.a===t.a}function n(e,t){return e.b<t.b||e.b===t.b&&e.a<=t.a}function i(e,t,r){var n=t.b-e.b,i=r.b-t.b;return 0<n+i?n<i?t.a-e.a+n/(n+i)*(e.a-r.a):t.a-r.a+i/(n+i)*(r.a-e.a):0}function s(e,t,r){var n=t.b-e.b,i=r.b-t.b;return 0<n+i?(t.a-r.a)*n+(t.a-e.a)*i:0}function o(e,t){return e.a<t.a||e.a===t.a&&e.b<=t.b}function a(e,t,r){var n=t.a-e.a,i=r.a-t.a;return 0<n+i?n<i?t.b-e.b+n/(n+i)*(e.b-r.b):t.b-r.b+i/(n+i)*(r.b-e.b):0}function u(e,t,r){var n=t.a-e.a,i=r.a-t.a;return 0<n+i?(t.b-r.b)*n+(t.b-e.b)*i:0}function l(e){return n(e.b.a,e.a)}function h(e){return n(e.a,e.b.a)}function c(e,t,r,n){return(e=0>e?0:e)<=(r=0>r?0:r)?0===r?(t+n)/2:t+e/(e+r)*(n-t):n+r/(e+r)*(t-n)}function d(e){var t=y(e.b);return b(t,e.c),b(t.b,e.c),x(t,e.a),t}function p(e,t){var r=!1,n=!1;e!==t&&(t.a!==e.a&&(n=!0,w(t.a,e.a)),t.d!==e.d&&(r=!0,C(t.d,e.d)),v(t,e),n||(b(t,e.a),e.a.c=e),r||(x(t,e.d),e.d.a=e))}function f(e){var t=e.b,r=!1;e.d!==e.b.d&&(r=!0,C(e.d,e.b.d)),e.c===e?w(e.a,null):(e.b.d.a=Q(e),e.a.c=e.c,v(e,Q(e)),r||x(e,e.d)),t.c===t?(w(t.a,null),C(t.d,null)):(e.d.a=Q(t),t.a.c=t.c,v(t,Q(t))),_(e)}function m(e){var t=y(e),r=t.b;return v(t,e.e),t.a=e.b.a,b(r,t.a),t.d=r.d=e.d,t=t.b,v(e.b,Q(e.b)),v(e.b,t),e.b.a=t.a,t.b.a.c=t.b,t.b.d=e.b.d,t.f=e.f,t.b.f=e.b.f,t}function g(e,t){var r=!1,n=y(e),i=n.b;return t.d!==e.d&&(r=!0,C(t.d,e.d)),v(n,e.e),v(i,t),n.a=e.b.a,i.a=t.a,n.d=i.d=e.d,e.d.a=i,r||x(n,e.d),n}function y(e){var t=new J,r=new J,n=e.b.h;return r.h=n,n.b.h=t,t.h=e,e.b.h=r,t.b=r,t.c=t,t.e=r,r.b=t,r.c=r,r.e=t}function v(e,t){var r=e.c,n=t.c;r.b.e=t,n.b.e=e,e.c=n,t.c=r}function b(e,t){var r=t.f,n=new te(t,r);r.e=n,t.f=n,r=n.c=e;do{r.a=n,r=r.c}while(r!==e)}function x(e,t){var r=t.d,n=new K(t,r);r.b=n,t.d=n,n.a=e,n.c=t.c,r=e;do{r.d=n,r=r.e}while(r!==e)}function _(e){var t=e.h;e=e.b.h,t.b.h=e,e.b.h=t}function w(e,t){var r=e.c,n=r;do{n.a=t,n=n.c}while(n!==r);r=e.f,(n=e.e).f=r,r.e=n}function C(e,t){var r=e.a,n=r;do{n.d=t,n=n.e}while(n!==r);r=e.d,(n=e.b).d=r,r.b=n}function E(e){var t=0;return Math.abs(e[1])>Math.abs(e[0])&&(t=1),Math.abs(e[2])>Math.abs(e[t])&&(t=2),t}var S=4e150;function A(e,t){e.f+=t.f,e.b.f+=t.b.f}function D(e,t,r){return e=e.a,t=t.a,r=r.a,t.b.a===e?r.b.a===e?n(t.a,r.a)?0>=s(r.b.a,t.a,r.a):0<=s(t.b.a,r.a,t.a):0>=s(r.b.a,e,r.a):r.b.a===e?0<=s(t.b.a,e,t.a):(t=i(t.b.a,e,t.a))>=(e=i(r.b.a,e,r.a))}function T(e){e.a.i=null;var t=e.e;t.a.c=t.c,t.c.a=t.a,e.e=null}function F(e,t){f(e.a),e.c=!1,e.a=t,t.i=e}function I(e){var t=e.a.a;do{e=pe(e)}while(e.a.a===t);return e.c&&(F(e,t=g(de(e).a.b,e.a.e)),e=pe(e)),e}function k(e,t,r){var n=new ce;return n.a=r,n.e=H(e.f,t.e,n),r.i=n}function N(e,t){switch(e.s){case 100130:return!!(1&t);case 100131:return 0!==t;case 100132:return 0<t;case 100133:return 0>t;case 100134:return 2<=t||-2>=t}return!1}function M(e){var t=e.a,r=t.d;r.c=e.d,r.a=t,T(e)}function O(e,t,r){for(e=t,t=t.a;e!==r;){e.c=!1;var n=de(e),i=n.a;if(i.a!==t.a){if(!n.c){M(e);break}F(n,i=g(t.c.b,i.b))}t.c!==i&&(p(Q(i),i),p(t,i)),M(e),t=n.a,e=n}return t}function B(e,t,r,n,i,s){var o=!0;do{k(e,t,r.b),r=r.c}while(r!==n);for(null===i&&(i=de(t).a.b.c);(r=(n=de(t)).a.b).a===i.a;)r.c!==i&&(p(Q(r),r),p(Q(i),r)),n.f=t.f-r.f,n.d=N(e,n.f),t.b=!0,!o&&V(e,t)&&(A(r,i),T(t),f(i)),o=!1,t=n,i=r;t.b=!0,s&&z(e,t)}function L(e,t,r,n,i){var s=[t.g[0],t.g[1],t.g[2]];t.d=null,t.d=e.o&&e.o(s,r,n,e.c)||null,null===t.d&&(i?e.n||(Y(e,100156),e.n=!0):t.d=r[0])}function P(e,t,r){var n=[null,null,null,null];n[0]=t.a.d,n[1]=r.a.d,L(e,t.a,n,[.5,.5,0,0],!1),p(t,r)}function R(e,t,r,n,i){var s=Math.abs(t.b-e.b)+Math.abs(t.a-e.a),o=Math.abs(r.b-e.b)+Math.abs(r.a-e.a),a=i+1;n[i]=.5*o/(s+o),n[a]=.5*s/(s+o),e.g[0]+=n[i]*t.g[0]+n[a]*r.g[0],e.g[1]+=n[i]*t.g[1]+n[a]*r.g[1],e.g[2]+=n[i]*t.g[2]+n[a]*r.g[2]}function V(e,t){var i=de(t),o=t.a,a=i.a;if(n(o.a,a.a)){if(0<s(a.b.a,o.a,a.a))return!1;if(r(o.a,a.a)){if(o.a!==a.a){i=e.e;var u=o.a.h;if(0<=u){var l=(i=i.b).d,h=i.e,c=i.c,d=c[u];l[d]=l[i.a],c[l[d]]=d,d<=--i.a&&(1>=d||n(h[l[d>>1]],h[l[d]])?le(i,d):he(i,d)),h[u]=null,c[u]=i.b,i.b=u}else for(i.c[-(u+1)]=null;0<i.a&&null===i.c[i.d[i.a-1]];)--i.a;P(e,Q(a),o)}}else m(a.b),p(o,Q(a)),t.b=i.b=!0}else{if(0>s(o.b.a,a.a,o.a))return!1;pe(t).b=t.b=!0,m(o.b),p(Q(a),o)}return!0}function U(e,t){var l=de(t),h=t.a,d=l.a,f=h.a,g=d.a,y=h.b.a,v=d.b.a,b=new te;if(f===g||Math.min(f.a,y.a)>Math.max(g.a,v.a))return!1;if(n(f,g)){if(0<s(v,f,g))return!1}else if(0>s(y,g,f))return!1;var x,_,w=y,C=f,E=v,S=g;if(n(w,C)||(x=w,w=C,C=x),n(E,S)||(x=E,E=S,S=x),n(w,E)||(x=w,w=E,E=x,x=C,C=S,S=x),n(E,C)?n(C,S)?(0>(x=i(w,E,C))+(_=i(E,C,S))&&(x=-x,_=-_),b.b=c(x,E.b,_,C.b)):(0>(x=s(w,E,C))+(_=-s(w,S,C))&&(x=-x,_=-_),b.b=c(x,E.b,_,S.b)):b.b=(E.b+C.b)/2,o(w,C)||(x=w,w=C,C=x),o(E,S)||(x=E,E=S,S=x),o(w,E)||(x=w,w=E,E=x,x=C,C=S,S=x),o(E,C)?o(C,S)?(0>(x=a(w,E,C))+(_=a(E,C,S))&&(x=-x,_=-_),b.a=c(x,E.a,_,C.a)):(0>(x=u(w,E,C))+(_=-u(w,S,C))&&(x=-x,_=-_),b.a=c(x,E.a,_,S.a)):b.a=(E.a+C.a)/2,n(b,e.a)&&(b.b=e.a.b,b.a=e.a.a),w=n(f,g)?f:g,n(w,b)&&(b.b=w.b,b.a=w.a),r(b,f)||r(b,g))return V(e,t),!1;if(!r(y,e.a)&&0<=s(y,e.a,b)||!r(v,e.a)&&0>=s(v,e.a,b)){if(v===e.a)return m(h.b),p(d.b,h),h=de(t=I(t)).a,O(e,de(t),l),B(e,t,Q(h),h,h,!0),!0;if(y===e.a){m(d.b),p(h.e,Q(d)),g=(f=l=t).a.b.a;do{f=pe(f)}while(f.a.b.a===g);return f=de(t=f).a.b.c,l.a=Q(d),B(e,t,(d=O(e,l,null)).c,h.b.c,f,!0),!0}return 0<=s(y,e.a,b)&&(pe(t).b=t.b=!0,m(h.b),h.a.b=e.a.b,h.a.a=e.a.a),0>=s(v,e.a,b)&&(t.b=l.b=!0,m(d.b),d.a.b=e.a.b,d.a.a=e.a.a),!1}return m(h.b),m(d.b),p(Q(d),h),h.a.b=b.b,h.a.a=b.a,h.a.h=ne(e.e,h.a),h=h.a,d=[0,0,0,0],b=[f.d,y.d,g.d,v.d],h.g[0]=h.g[1]=h.g[2]=0,R(h,f,y,d,0),R(h,g,v,d,2),L(e,h,b,d,!0),pe(t).b=t.b=l.b=!0,!1}function z(e,t){for(var r=de(t);;){for(;r.b;)t=r,r=de(r);if(!t.b&&(r=t,null===(t=pe(t))||!t.b))break;t.b=!1;var i,o=t.a,a=r.a;if(i=o.b.a!==a.b.a)e:{var u=de(i=t),l=i.a,h=u.a,c=void 0;if(n(l.b.a,h.b.a)){if(0>s(l.b.a,h.b.a,l.a)){i=!1;break e}pe(i).b=i.b=!0,c=m(l),p(h.b,c),c.d.c=i.d}else{if(0<s(h.b.a,l.b.a,h.a)){i=!1;break e}i.b=u.b=!0,c=m(h),p(l.e,h.b),c.b.d.c=i.d}i=!0}if(i&&(r.c?(T(r),f(a),a=(r=de(t)).a):t.c&&(T(t),f(o),o=(t=pe(r)).a)),o.a!==a.a)if(o.b.a===a.b.a||t.c||r.c||o.b.a!==e.a&&a.b.a!==e.a)V(e,t);else if(U(e,t))break;o.a===a.a&&o.b.a===a.b.a&&(A(a,o),T(t),f(o),t=pe(r))}}function j(e,t){e.a=t;for(var i=t.c;null===i.i;)if((i=i.c)===t.c){i=e;var o=t;(l=new ce).a=o.c.b;var a=(c=i.f).a;do{a=a.a}while(null!==a.b&&!c.c(c.b,l,a.b));var u=de(c=a.b),l=c.a;a=u.a;if(0===s(l.b.a,o,l.a))r((l=c.a).a,o)||r(l.b.a,o)||(m(l.b),c.c&&(f(l.c),c.c=!1),p(o.c,l),j(i,o));else{var h=n(a.b.a,l.b.a)?c:u;u=void 0;c.d||h.c?(u=h===c?g(o.c.b,l.e):g(a.b.c.b,o.c).b,h.c?F(h,u):(l=i,(c=k(i,c,u)).f=pe(c).f+c.a.f,c.d=N(l,c.f)),j(i,o)):B(i,c,o.c,o.c,null,!0)}return}if(c=(l=de(i=I(i.i))).a,(l=O(e,l,null)).c===c){l=(c=l).c,a=de(i),u=i.a,h=a.a;var c,d=!1;u.b.a!==h.b.a&&U(e,i),r(u.a,e.a)&&(p(Q(l),u),l=de(i=I(i)).a,O(e,de(i),a),d=!0),r(h.a,e.a)&&(p(c,Q(h)),c=O(e,a,null),d=!0),d?B(e,i,c.c,l,l,!0):(o=n(h.a,u.a)?Q(h):u,B(e,i,o=g(c.c.b,o),o.c,o.c,!1),o.b.i.c=!0,z(e,i))}else B(e,i,l.c,c,c,!0)}function G(e,t){var r=new ce,n=d(e.b);n.a.b=S,n.a.a=t,n.b.a.b=-S,n.b.a.a=t,e.a=n.b.a,r.a=n,r.f=0,r.d=!1,r.c=!1,r.h=!0,r.b=!1,n=H(n=e.f,n.a,r),r.e=n}function $(e){this.a=new q,this.b=e,this.c=D}function H(e,t,r){do{t=t.c}while(null!==t.b&&!e.c(e.b,t.b,r));return e=new q(r,t.a,t),t.a.c=e,t.a=e}function q(e,t,r){this.b=e||null,this.a=t||this,this.c=r||this}function W(){this.d=X,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 X=0;function Z(e,t){if(e.d!==t)for(;e.d!==t;)if(e.d<t)switch(e.d){case X:Y(e,100151),e.u(null);break;case 1:Y(e,100152),e.t()}else switch(e.d){case 2:Y(e,100154),e.v();break;case 1:Y(e,100153),e.w()}}function Y(e,t){e.p&&e.p(t,e.c)}function K(e,t){this.b=e||this,this.d=t||this,this.a=null,this.c=!1}function J(){this.h=this,this.i=this.d=this.a=this.e=this.c=this.b=null,this.f=0}function Q(e){return e.b.e}function ee(){this.c=new te,this.a=new K,this.b=new J,this.d=new J,this.b.b=this.d,this.d.b=this.b}function te(e,t){this.e=e||this,this.f=t||this,this.d=this.c=null,this.g=[0,0,0],this.h=this.a=this.b=0}function re(){this.c=[],this.d=null,this.a=0,this.e=!1,this.b=new se}function ne(e,t){if(e.e){var r,n=e.b,i=++n.a;return 2*i>n.f&&(n.f*=2,n.c=oe(n.c,n.f+1)),0===n.b?r=i:(r=n.b,n.b=n.c[n.b]),n.e[r]=t,n.c[r]=i,n.d[i]=r,n.h&&he(n,i),r}return n=e.a++,e.c[n]=t,-(n+1)}function ie(e){if(0===e.a)return ue(e.b);var t=e.c[e.d[e.a-1]];if(0!==e.b.a&&n(ae(e.b),t))return ue(e.b);do{--e.a}while(0<e.a&&null===e.c[e.d[e.a-1]]);return t}function se(){this.d=oe([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 oe(e,t){for(var r=Array(t),n=0;n<e.length;n++)r[n]=e[n];for(;n<t;n++)r[n]=0;return r}function ae(e){return e.e[e.d[1]]}function ue(e){var t=e.d,r=e.e,n=e.c,i=t[1],s=r[i];return 0<e.a&&(t[1]=t[e.a],n[t[1]]=1,r[i]=null,n[i]=e.b,e.b=i,0<--e.a&&le(e,1)),s}function le(e,t){for(var r=e.d,i=e.e,s=e.c,o=t,a=r[o];;){var u=o<<1;u<e.a&&n(i[r[u+1]],i[r[u]])&&(u+=1);var l=r[u];if(u>e.a||n(i[a],i[l])){r[o]=a,s[a]=o;break}r[o]=l,s[l]=o,o=u}}function he(e,t){for(var r=e.d,i=e.e,s=e.c,o=t,a=r[o];;){var u=o>>1,l=r[u];if(0===u||n(i[l],i[a])){r[o]=a,s[a]=o;break}r[o]=l,s[l]=o,o=u}}function ce(){this.e=this.a=null,this.f=0,this.c=this.b=this.h=this.d=!1}function de(e){return e.e.c.b}function pe(e){return e.e.a.b}(t=W.prototype).x=function(){Z(this,X)},t.B=function(e,t){switch(e){case 100142:return;case 100140:switch(t){case 100130:case 100131:case 100132:case 100133:case 100134:return void(this.s=t)}break;case 100141:return void(this.m=!!t);default:return void Y(this,100900)}Y(this,100901)},t.y=function(e){switch(e){case 100142:return 0;case 100140:return this.s;case 100141:return this.m;default:Y(this,100900)}return!1},t.A=function(e,t,r){this.j[0]=e,this.j[1]=t,this.j[2]=r},t.z=function(e,t){var r=t||null;switch(e){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:Y(this,100900)}},t.C=function(e,t){var r=!1,n=[0,0,0];Z(this,2);for(var i=0;3>i;++i){var s=e[i];-1e150>s&&(s=-1e150,r=!0),1e150<s&&(s=1e150,r=!0),n[i]=s}r&&Y(this,100155),null===(r=this.q)?p(r=d(this.b),r.b):(m(r),r=r.e),r.a.d=t,r.a.g[0]=n[0],r.a.g[1]=n[1],r.a.g[2]=n[2],r.f=1,r.b.f=-1,this.q=r},t.u=function(e){Z(this,X),this.d=1,this.b=new ee,this.c=e},t.t=function(){Z(this,1),this.d=2,this.q=null},t.v=function(){Z(this,2),this.d=1},t.w=function(){Z(this,1),this.d=X;var e=!1,t=[c=this.j[0],i=this.j[1],a=this.j[2]];if(0===c&&0===i&&0===a){for(var i=[-2e150,-2e150,-2e150],o=[2e150,2e150,2e150],a=[],u=[],c=(e=this.b.c).e;c!==e;c=c.e)for(var d=0;3>d;++d){var p=c.g[d];p<o[d]&&(o[d]=p,u[d]=c),p>i[d]&&(i[d]=p,a[d]=c)}if(c=0,i[1]-o[1]>i[0]-o[0]&&(c=1),i[2]-o[2]>i[c]-o[c]&&(c=2),o[c]>=i[c])t[0]=0,t[1]=0,t[2]=1;else{for(i=0,o=u[c],a=a[c],u=[0,0,0],o=[o.g[0]-a.g[0],o.g[1]-a.g[1],o.g[2]-a.g[2]],d=[0,0,0],c=e.e;c!==e;c=c.e)d[0]=c.g[0]-a.g[0],d[1]=c.g[1]-a.g[1],d[2]=c.g[2]-a.g[2],u[0]=o[1]*d[2]-o[2]*d[1],u[1]=o[2]*d[0]-o[0]*d[2],u[2]=o[0]*d[1]-o[1]*d[0],(p=u[0]*u[0]+u[1]*u[1]+u[2]*u[2])>i&&(i=p,t[0]=u[0],t[1]=u[1],t[2]=u[2]);0>=i&&(t[0]=t[1]=t[2]=0,t[E(o)]=1)}e=!0}for(u=E(t),c=this.b.c,i=(u+1)%3,a=(u+2)%3,u=0<t[u]?1:-1,t=c.e;t!==c;t=t.e)t.b=t.g[i],t.a=u*t.g[a];if(e){for(t=0,c=(e=this.b.a).b;c!==e;c=c.b)if(!(0>=(i=c.a).f))do{t+=(i.a.b-i.b.a.b)*(i.a.a+i.b.a.a),i=i.e}while(i!==c.a);if(0>t)for(e=(t=this.b.c).e;e!==t;e=e.e)e.a=-e.a}for(this.n=!1,c=(t=this.b.b).h;c!==t;c=e)e=c.h,i=c.e,r(c.a,c.b.a)&&c.e.e!==c&&(P(this,i,c),f(c),i=(c=i).e),i.e===c&&(i!==c&&(i!==e&&i!==e.b||(e=e.h),f(i)),c!==e&&c!==e.b||(e=e.h),f(c));for(this.e=t=new re,c=(e=this.b.c).e;c!==e;c=c.e)c.h=ne(t,c);for(function(e){e.d=[];for(var t=0;t<e.a;t++)e.d[t]=t;e.d.sort(function(e){return function(t,r){return n(e[t],e[r])?1:-1}}(e.c)),e.e=!0,function(e){for(var t=e.a;1<=t;--t)le(e,t);e.h=!0}(e.b)}(t),this.f=new $(this),G(this,-S),G(this,S);null!==(t=ie(this.e));){for(;;){e:if(c=this.e,0===c.a)e=ae(c.b);else if(e=c.c[c.d[c.a-1]],0!==c.b.a&&(c=ae(c.b),n(c,e))){e=c;break e}if(null===e||!r(e,t))break;e=ie(this.e),P(this,t.c,e.c)}j(this,t)}for(this.a=this.f.a.a.b.a.a,t=0;null!==(e=this.f.a.a.b);)e.h||++t,T(e);for(this.f=null,(t=this.e).b=null,t.d=null,this.e=t.c=null,c=(t=this.b).a.b;c!==t.a;c=e)e=c.b,(c=c.a).e.e===c&&(A(c.c,c),f(c));if(!this.n){if(t=this.b,this.m)for(c=t.b.h;c!==t.b;c=e)e=c.h,c.b.d.c!==c.d.c?c.f=c.d.c?1:-1:f(c);else for(c=t.a.b;c!==t.a;c=e)if(e=c.b,c.c){for(c=c.a;n(c.b.a,c.a);c=c.c.b);for(;n(c.a,c.b.a);c=c.e);for(i=c.c.b,a=void 0;c.e!==i;)if(n(c.b.a,i.a)){for(;i.e!==c&&(l(i.e)||0>=s(i.a,i.b.a,i.e.b.a));)i=(a=g(i.e,i)).b;i=i.c.b}else{for(;i.e!==c&&(h(c.c.b)||0<=s(c.b.a,c.a,c.c.b.a));)c=(a=g(c,c.c.b)).b;c=c.e}for(;i.e.e!==c;)i=(a=g(i.e,i)).b}if(this.h||this.i||this.k||this.l)if(this.m){for(e=(t=this.b).a.b;e!==t.a;e=e.b)if(e.c){this.h&&this.h(2,this.c),c=e.a;do{this.k&&this.k(c.a.d,this.c),c=c.e}while(c!==e.a);this.i&&this.i(this.c)}}else{for(t=this.b,e=!!this.l,c=!1,i=-1,a=t.a.d;a!==t.a;a=a.d)if(a.c){c||(this.h&&this.h(4,this.c),c=!0),u=a.a;do{e&&(i!==(o=u.b.d.c?0:1)&&(i=o,this.l&&this.l(!!i,this.c))),this.k&&this.k(u.a.d,this.c),u=u.e}while(u!==a.a)}c&&this.i&&this.i(this.c)}if(this.r){for(c=(t=this.b).a.b;c!==t.a;c=e)if(e=c.b,!c.c){a=(i=c.a).e,u=void 0;do{a=(u=a).e,u.d=null,null===u.b.d&&(u.c===u?w(u.a,null):(u.a.c=u.c,v(u,Q(u))),(o=u.b).c===o?w(o.a,null):(o.a.c=o.c,v(o,Q(o))),_(u))}while(u!==i);i=c.d,(c=c.b).d=i,i.b=c}return this.r(this.b),void(this.c=this.b=null)}}this.b=this.c=null},Ds.libtess={GluTesselator:W,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}},W.prototype.gluDeleteTess=W.prototype.x,W.prototype.gluTessProperty=W.prototype.B,W.prototype.gluGetTessProperty=W.prototype.y,W.prototype.gluTessNormal=W.prototype.A,W.prototype.gluTessCallback=W.prototype.z,W.prototype.gluTessVertex=W.prototype.C,W.prototype.gluTessBeginPolygon=W.prototype.u,W.prototype.gluTessBeginContour=W.prototype.t,W.prototype.gluTessEndContour=W.prototype.v,W.prototype.gluTessEndPolygon=W.prototype.w,e.exports=Ds.libtess}(xo);var _o=Ts(xo.exports);class wo{constructor(e,t,r,n,i,s){this.size=e,this.src=t,this.dst=r,this.attr=n,this._renderer=i,this.map=s}default(e){return this.default=e,this}_prepareBuffer(e,t){this._renderer._prepareBuffer(this,e,t)}}function Co(e,t){e.RenderBuffer=wo}"undefined"!=typeof p5&&Co(p5);const Eo={vertices:1,vertexNormals:1,vertexColors:4,vertexStrokeColors:4,uvs:2},So=Object.values(Eo).reduce(((e,t)=>e+t));class Ao{constructor(e){this.renderer=e,this.shapeMode=8,this.geometry=new po(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=So,this.bufferStrides={...Eo}}friendlyErrorsDisabled(){return!1}constructFromContours(e,t){this._useUserVertexProperties&&this._resetUserVertexProperties(),this.geometry.reset(),this.contourIndices=[],this.shapeMode=e.contours[0].kind;const r=!!this.renderer.states.strokeColor,n={};if(e.userVertexProperties){this._useUserVertexProperties=!0;for(const t in e.userVertexProperties){const r=e.vertexPropertyName(t),i=this.geometry._userVertexPropertyHelper(r,[],e.userVertexProperties[t]);n[t]=i,this.tessyVertexSize+=i.getDataSize(),this.bufferStrides[i.getSrcName()]=i.getDataSize(),this.renderer.buffers.user.push(new wo(i.getDataSize(),i.getSrcName(),i.getDstName(),r,this.renderer))}}else this._useUserVertexProperties=!1;for(const e of t){this.contourIndices.push(this.geometry.vertices.length);for(const t of e){if(this.shapeMode===L&&this.geometry.vertices.length%6==3)for(const e in this.bufferStrides){const t=this.bufferStrides[e],r=this.geometry[e];r.push(...r.slice(r.length-3*t,r.length-2*t),...r.slice(r.length-t,r.length))}this.geometry.vertices.push(t.position),this.geometry.vertexNormals.push(t.normal||new Pi(0,0,0)),this.geometry.uvs.push(t.textureCoordinates.x,t.textureCoordinates.y),this.renderer.states.fillColor?this.geometry.vertexColors.push(...t.fill.array()):this.geometry.vertexColors.push(0,0,0,0),this.renderer.states.strokeColor?this.geometry.vertexStrokeColors.push(...t.stroke.array()):this.geometry.vertexStrokeColors.push(0,0,0,0);for(const e in n){const r=n[e];e in t&&r.setCurrentData(t[e]),r.pushCurrentData()}}}if(r&&(this.geometry.edges=this._calculateEdges(this.shapeMode,this.geometry.vertices)),r&&!this.renderer.geometryBuilder&&this.geometry._edgesToVertices(),8===this.shapeMode){const e=this.geometry.vertices.length;if(e>5e4&&!this.friendlyErrorsDisabled()&&!this.renderer._largeTessellationAcknowledged){if(!window.confirm(`🌸 p5.js says:\n\nThis shape has ${e} vertices. Tessellating shapes with this many vertices can be very slow and may cause your browser to become unresponsive.\n\nDo you want to continue tessellating this shape?`))return;this.renderer._largeTessellationAcknowledged=!0}this.isProcessingVertices=!0,this._tesselateShape(),this.isProcessingVertices=!1}else this.shapeMode===P?this.shapeMode=5:this.shapeMode===L&&(this.shapeMode=4);this.renderer.geometryBuilder||6!==this.shapeMode||this.renderer.supportsTriangleFan()||(this._convertFanToTriangles(),this.shapeMode=4),this.renderer.states.textureMode===Se&&null!==this.renderer.states._tex&&this.renderer.states._tex.width>0&&this.renderer.states._tex.height>0&&(this.geometry.uvs=this.geometry.uvs.map(((e,t)=>t%2==0?e/this.renderer.states._tex.width:e/this.renderer.states._tex.height)))}_remapVertices(e){this.geometry.vertices=e.map((e=>this.geometry.vertices[e])),this.geometry.vertexNormals=e.map((e=>this.geometry.vertexNormals[e]));const t=(t,r)=>{const n=[];for(const i of e)for(let e=0;e<r;e++)n.push(t[i*r+e]);return n};this.geometry.uvs=t(this.geometry.uvs,2),this.geometry.vertexColors=t(this.geometry.vertexColors,4),this.geometry.vertexStrokeColors=t(this.geometry.vertexStrokeColors,4);for(const t in this.geometry.userVertexProperties){const r=this.geometry.userVertexProperties[t],n=r.getDataSize(),i=r.getSrcArray();r.resetSrcArray();for(const t of e)r.setCurrentData(i.slice(t*n,t*n+n)),r.pushCurrentData()}}_convertFanToTriangles(){const e=this.geometry.vertices.length;if(e<3)return;const t=[];for(let r=2;r<e;r++)t.push(0,r-1,r);this._remapVertices(t)}_resetUserVertexProperties(){const e=this.geometry.userVertexProperties;for(const t in e){const r=e[t];delete this.bufferStrides[t],r.delete()}this._useUserVertexProperties=!1,this.tessyVertexSize=So,this.geometry.userVertexProperties={}}_calculateEdges(e,t){const r=[];let n=0;const i=this.contourIndices.slice();let s=-1;switch(e){case 5:for(n=0;n<t.length-2;n++)r.push([n,n+1]),r.push([n,n+2]);r.push([n,n+1]);break;case 6:for(n=1;n<t.length-1;n++)r.push([0,n]),r.push([n,n+1]);r.push([0,t.length-1]);break;case 4:for(n=0;n<t.length-2;n+=3)r.push([n,n+1]),r.push([n+1,n+2]),r.push([n+2,n]);break;case N:for(n=0;n<t.length-1;n+=2)r.push([n,n+1]);break;case L:for(n=0;n<t.length-5;n+=6)r.push([n,n+1]),r.push([n+1,n+2]),r.push([n+2,n+5]),r.push([n+5,n]);break;case P:for(n=0;n<t.length-2;n+=2)r.push([n,n+1]),r.push([n+1,n+3]),r.push([n,n+2]);r.push([n,n+1]);break;default:for(n=0;n<t.length;n++)n===i[0]?s=i.shift():t[s]&&t[n].equals(t[s])?r.push([n-1,s]):r.push([n-1,n])}return r}_tesselateShape(){const e=[];for(let t=0;t<this.geometry.vertices.length;t++){this.contourIndices.length>0&&this.contourIndices[0]===t&&(this.contourIndices.shift(),e.push([])),e[e.length-1].push(this.geometry.vertices[t].x,this.geometry.vertices[t].y,this.geometry.vertices[t].z,this.geometry.uvs[2*t],this.geometry.uvs[2*t+1],this.geometry.vertexColors[4*t],this.geometry.vertexColors[4*t+1],this.geometry.vertexColors[4*t+2],this.geometry.vertexColors[4*t+3],this.geometry.vertexNormals[t].x,this.geometry.vertexNormals[t].y,this.geometry.vertexNormals[t].z);for(const r in this.geometry.userVertexProperties){const n=this.geometry.userVertexProperties[r],i=t*n.getDataSize(),s=i+n.getDataSize(),o=n.getSrcArray().slice(i,s);e[e.length-1].push(...o)}}const t=1e-6;for(const r of e){const e=this.tessyVertexSize;for(let n=e;n<r.length;n+=e){const i=r[n-e],s=r[n-e+1],o=r[n],a=r[n+1];Math.abs(o-i)<t&&(r[n]=i),Math.abs(a-s)<t&&(r[n+1]=s)}}const r=this._triangulate(e);if(0===r.length)return;this.shapeMode=4;const n=this.geometry.vertices;this.geometry.vertices=[],this.geometry.vertexNormals=[],this.geometry.uvs=[];for(const e in this.geometry.userVertexProperties){this.geometry.userVertexProperties[e].resetSrcArray()}const i=[];for(let e=0,t=r.length;e<t;e+=this.tessyVertexSize){i.push(...r.slice(e+5,e+9)),this.geometry.vertexNormals.push(new Pi(...r.slice(e+9,e+12)));{let t=12;for(const n in this.geometry.userVertexProperties){const i=this.geometry.userVertexProperties[n],s=i.getDataSize(),o=e+t,a=o+s;i.setCurrentData(r.slice(o,a)),i.pushCurrentData(),t+=s}}this.geometry.vertices.push(new Pi(...r.slice(e,e+3))),this.geometry.uvs.push(...r.slice(e+3,e+5))}if(this.renderer.geometryBuilder){const e=new Map;this.geometry.edges=this.geometry.edges.map((t=>t.map((t=>{if(!e.has(t)){const r=n[t];let i=this.geometry.vertices.findIndex((e=>r.x===e.x&&r.y===e.y&&r.z===e.z));if(-1===i){let e=1/0,t=0;for(let n=0;n<this.geometry.vertices.length;n++){const i=this.geometry.vertices[n],s=r.x-i.x,o=r.y-i.y,a=r.z-i.z,u=s*s+o*o+a*a;u<e&&(e=u,t=n)}i=t}e.set(t,i)}return e.get(t)}))))}this.geometry.vertexColors=i}_initTessy(){const e=new _o.GluTesselator;return e.gluTessCallback(_o.gluEnum.GLU_TESS_VERTEX_DATA,(function(e,t){for(const r of e)t.push(r)})),e.gluTessCallback(_o.gluEnum.GLU_TESS_BEGIN,(function(e){e!==_o.primitiveType.GL_TRIANGLES&&console.log(`expected TRIANGLES but got type: ${e}`)})),e.gluTessCallback(_o.gluEnum.GLU_TESS_ERROR,(function(e){console.log("error callback"),console.log(`error number: ${e}`)})),e.gluTessCallback(_o.gluEnum.GLU_TESS_COMBINE,((e,t,r)=>{const n=new Array(this.tessyVertexSize).fill(0);for(let e=0;e<r.length;e++)for(let i=0;i<n.length;i++)0!==r[e]&&t[e]&&(n[i]+=t[e][i]*r[e]);return n})),e.gluTessCallback(_o.gluEnum.GLU_TESS_EDGE_FLAG,(function(e){})),e.gluTessProperty(_o.gluEnum.GLU_TESS_WINDING_RULE,_o.windingRule.GLU_TESS_WINDING_NONZERO),e}_triangulate(e){const t=e[0]?e[0][2]:void 0;let r=!0;for(const n of e)for(let e=0;e<n.length;e+=this.tessyVertexSize)if(n[e+2]!==t){r=!1;break}r?this._tessy.gluTessNormal(0,0,1):this._tessy.gluTessNormal(0,0,0);const n=[];this._tessy.gluTessBeginPolygon(n);for(const t of e){this._tessy.gluTessBeginContour();for(let e=0;e<t.length;e+=this.tessyVertexSize){const r=t.slice(e,e+this.tessyVertexSize);this._tessy.gluTessVertex(r,r)}this._tessy.gluTessEndContour()}return this._tessy.gluTessEndPolygon(),n}}class Do{constructor(e){this.renderer=e,this.cache={}}numCached(){return Object.keys(this.cache).length}isCached(e){return void 0!==this.cache[e]}getGeometryByID(e){return this.cache[e]?.geometry}getCached(e){return this.getCachedID(e.gid)}getCachedID(e){return this.cache[e]}ensureCached(e){const t=e.gid;if(!t)throw new Error("The p5.Geometry you passed in has no gid property!");if(this.isCached(t))return this.getCached(e);if(this.freeBuffers(t),Object.keys(this.cache).length>1e3){const e=Object.keys(this.cache)[0];this.freeBuffers(e)}const r={geometry:e};this.cache[t]=r;const n=e.faces.length?e.faces.flat():null;let i=null;if(n){const e=n.some((e=>e>65535));i=e?Uint32Array:Uint16Array}return this.renderer._ensureGeometryBuffers(r,n,i),r}freeBuffers(e){const t=this.cache[e];t&&(delete this.cache[e],this.renderer._freeBuffers(t))}}const To={[be]:3,[ge]:4,[de]:.5},Fo="ideographic",Io="middle",ko="_textBoundsSingle",No="_fontBoundsSingle",Mo="hanging",Oo="start",Bo="end";function Lo(e,t){const r=/\r?\n/g,n=/,\s+/,i=/^".*"$/,s=/[^\x00-\x7F]/,o=/\t/g,a=new 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=>{t[r]=function(...e){if(!(r in ps.prototype))throw Error(`Renderer2D.prototype.${r} is not defined.`);return this._renderer[r](...e)},e.Graphics.prototype[r]=function(...e){return this._renderer[r](...e)}}));const u={textAlign:{default:t.LEFT,type:"Context2d"},textBaseline:{default:t.BASELINE,type:"Context2d"},textFont:{default:{family:"sans-serif"}},textLeading:{default:15},textSize:{default:12},textWrap:{default:t.WORD},fontStretch:{default:t.NORMAL,isShorthand:!0},fontWeight:{default:t.NORMAL,isShorthand:!0},lineHeight:{default:t.NORMAL,isShorthand:!0},fontVariant:{default:t.NORMAL,isShorthand:!0},fontStyle:{default:t.NORMAL,isShorthand:!0},direction:{default:"inherit"}},l=["font","direction","fontKerning","fontStretch","fontVariantCaps","letterSpacing","textAlign","textBaseline","textRendering","wordSpacing"],h=Object.keys(u).filter((e=>u[e].isShorthand)),c=["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded"];let d,p;ps.prototype.text=function(e,t,r,n,i){let s=this.textDrawingContext().textBaseline;({x:t,y:r,width:n,height:i}=this._handleRectMode(t,r,n,i));let o=this._processLines(e,n,i);o=this._positionLines(t,r,n,i,o),o.forEach((e=>this._renderText(e.text,e.x,e.y))),this.textDrawingContext().textBaseline=s},ps.prototype.textBounds=function(e,t,r,n,i){return this._computeBounds(ko,e,t,r,n,i).bounds},ps.prototype.fontBounds=function(e,t,r,n,i){return this._computeBounds(No,e,t,r,n,i).bounds},ps.prototype.textWidth=function(e){let t=this._processLines(e);return Math.max(...t.map((e=>this._textWidthSingle(e))))},ps.prototype.fontWidth=function(e){let t=this._processLines(e);return Math.max(...t.map((e=>this._fontWidthSingle(e))))},ps.prototype.textAscent=function(e=""){return e.length?this.textDrawingContext().measureText(e).actualBoundingBoxAscent:this.fontAscent()},ps.prototype.fontAscent=function(){return this.textDrawingContext().measureText("_").fontBoundingBoxAscent},ps.prototype.textDescent=function(e=""){return e.length?this.textDrawingContext().measureText(e).actualBoundingBoxDescent:this.fontDescent()},ps.prototype.fontDescent=function(){return this.textDrawingContext().measureText("_").fontBoundingBoxDescent},ps.prototype.textAlign=function(e,r){return 0===arguments.length?{horizontal:this.states.textAlign,vertical:this.states.textBaseline}:("object"==typeof e&&null!==e&&(e.hasOwnProperty("vertical")&&(r=e.vertical),e.hasOwnProperty("horizontal")&&(e=e.horizontal)),("string"==typeof e||e instanceof String)&&this.states.setValue("textAlign",e),("string"==typeof r||r instanceof String)&&(r===t.CENTER&&(r=Io),this.states.setValue("textBaseline",r)),this._applyTextProperties())},ps.prototype._currentTextFont=function(){return this.states.textFont.font||this.states.textFont.family},ps.prototype.textFont=function(t,r,n){if(0===arguments.length)return this._currentTextFont();let i=t;if(t instanceof e.Font?i=t.face.family:t.data instanceof Uint8Array?(i=t.name.fontFamily,t.name?.fontSubfamily&&(i+="-"+t.name.fontSubfamily)):"string"==typeof t&&void 0===r&&/[.0-9]+(%|em|p[xt])/.test(i)&&({family:i,size:r}=this._directSetFontString(i)),"string"!=typeof i)throw Error("null font in textFont()");return 2===arguments.length&&"object"==typeof r&&(n=r,r=void 0),this.states.setValue("textFont",{font:t,family:i,size:r}),void 0!==r&&this._setTextSize(r),"object"==typeof n&&this.textProperties(n),this._applyTextProperties()},ps.prototype._directSetFontString=function(e,t=0){t&&console.log('_directSetFontString"'+e+'"');let r=h.reduce(((e,t)=>(e[t]=u[t].default,e)),{}),n=this._cachedDiv(r);n.style.font=e;let i=getComputedStyle(n);return h.forEach((e=>{this.states[e]=i[e],t&&console.log("  this.states."+e+'="'+i[e]+'"')})),{family:i.fontFamily,size:i.fontSize}},ps.prototype.textLeading=function(e){return"number"==typeof e?(this.states.setValue("leadingSet",!0),this.states.setValue("textLeading",e),this._applyTextProperties()):this.states.textLeading},ps.prototype.textWeight=function(e){return"number"==typeof e?(this.states.setValue("fontWeight",e),void this._applyTextProperties()):this.states.fontWeight},ps.prototype.textSize=function(e){return void 0!==e?(this._setTextSize(e),this._applyTextProperties()):this.states.textSize},ps.prototype.textStyle=function(e){return void 0!==e?(this.states.setValue("fontStyle",e),this._applyTextProperties()):this.states.fontStyle},ps.prototype.textWrap=function(e){return e===t.WORD||e===t.CHAR?(this.states.setValue("textWrap",e),this._pInst):this.states.textWrap},ps.prototype.textDirection=function(e){return void 0!==e?(this.states.setValue("direction",e),this._applyTextProperties()):this.states.direction},ps.prototype.textProperty=function(e,t,r){let n=!1,i=r?.debug||!1;if(void 0===t){let t=this.textProperties();if(e in t)return t[e];throw Error('Unknown text option "'+e+'"')}return e in this.states&&this.states[e]!==t?(this.states[e]=t,n=!0,i&&console.log("this.states."+e+'="'+options[e]+'"')):e in this.textDrawingContext()?(this._setContextProperty(e,t,i),n=!0):e in this.textCanvas().style?(this._setCanvasStyleProperty(e,t,i),n=!0):console.warn('Ignoring unknown text option: "'+e+'"\n'),n?this._applyTextProperties():this._pInst},ps.prototype.textProperties=function(e){if(void 0!==e)return Object.keys(e).forEach((t=>{this.textProperty(t,e[t])})),this._pInst;let t=this.textDrawingContext();return e=l.reduce(((e,r)=>(e[r]=t[r],e)),{}),Object.keys(u).forEach((r=>{if("Context2d"===u[r]?.type)e[r]=t[r];else if("textFont"===r){let t=this._currentTextFont();"object"==typeof t&&"_pInst"in t&&(t=Object.assign({},t),delete t._pInst),e[r]=t}else e[r]=this.states[r]})),e},ps.prototype.textMode=function(){},ps.prototype._currentTextFont=function(){return this.states.textFont.font||this.states.textFont.family},ps.prototype._computeBounds=function(t,r,n,i,s,o,a){let u=this.textDrawingContext(),l=u.textBaseline,{textLeading:h,textAlign:c}=this.states;({width:s,height:o}=this._rectModeAdjust(n,i,s,o));let d=this._processLines(r,s,o),p=d.map(((e,r)=>this[t].bind(this)(e,n,i+r*h)));d.length>1&&void 0!==s&&p.forEach((t=>t.x+=e.Renderer2D.prototype._xAlignOffset.call(this,c,s))),e.Renderer2D.prototype._yAlignOffset.call(this,p,o||0);let f=p[0];return d.length>1&&(f=this._aggregateBounds(p),a?.ignoreRectMode||this._rectModeAlign(f,s||0,o||0)),u.textBaseline=l,{bounds:f,lines:d}},ps.prototype._rectModeAdjust=function(e,r,n,i){if(void 0!==n)switch(this.states.rectMode){case t.CENTER:break;case t.CORNERS:n-=e,i-=r;break;case t.RADIUS:n*=2,i*=2}return{x:e,y:r,width:n,height:i}},ps.prototype._setCanvasStyleProperty=function(e,t,r){let n=t.toString();r&&console.log("canvas.style."+e+'="'+n+'"'),"fontVariationSettings"===e&&this._handleFontVariationSettings(n),this.textCanvas().style[e]=n,this.textCanvas().style[e]},ps.prototype._handleFontVariationSettings=function(e,t=!1){"object"==typeof e&&(e=Object.keys(e).map((t=>t+" "+e[t])).join(", ")),e.split(n).forEach((e=>{e=e.replace(/["']/g,"");let r=a.exec(e);if(r&&r.length){let n=r[0],i=parseFloat(parseFloat(e.replace(n,"").trim()).toFixed(3));switch(n){case"wght":return t&&console.log("setting font-weight="+i),this.states.fontWeight!==i&&this.textWeight(i),i;case"wdth":break;case"ital":t&&console.log("setting font-style="+(i?"italic":"normal"));break;case"slnt":t&&console.log("setting font-style="+(i?"oblique":"normal"));break;case"opsz":t&&console.log("setting font-optical-size="+i)}}}))},ps.prototype._setContextProperty=function(e,t,r=!1){if(this.textDrawingContext()[e]===t)return this._pInst;(d??=[]).push([e,t]),r&&console.log("queued context2d."+e+'="'+t+'"')},ps.prototype._handleRectMode=function(e,r,n,i){let s=this.states.rectMode;if(void 0!==n)switch(s){case t.RADIUS:e-=(n*=2)/2,void 0!==i&&(r-=(i*=2)/2);break;case t.CENTER:e-=n/2,void 0!==i&&(r-=i/2);break;case t.CORNERS:n-=e,void 0!==i&&(i-=r)}return{x:e,y:r,width:n,height:i}},ps.prototype._fontSizePx=function(e,{family:t}=this.states.textFont){if(r=e,!isNaN(r)&&""!==r.trim())return parseFloat(e);var r;let n=this._cachedDiv({fontSize:e});n.style.fontSize=e,n.style.fontFamily=t;let i=getComputedStyle(n).fontSize,s=parseFloat(i);if("number"!=typeof s)throw Error("textSize: invalid font-size");return s},ps.prototype._cachedDiv=function(e){if(void 0===p){let t=document.createElement("div");t.ariaHidden="true",t.style.display="none",Object.entries(e).forEach((([e,r])=>{t.style[e]=r})),this.textCanvas().appendChild(t),p=t}return p},ps.prototype._aggregateBounds=function(e){let t=Math.min(...e.map((e=>e.x))),r=Math.min(...e.map((e=>e.y))),n=Math.max(...e.map((e=>e.y+e.h))),i=Math.max(...e.map((e=>e.x+e.w)));return{x:t,y:r,w:i-t,h:n-r}},ps.prototype._processLines=function(e,r,n){if(void 0!==r){this.textDrawingContext().textBaseline===t.BASELINE&&(this.drawingContext.textBaseline=t.TOP)}let i=this._splitOnBreaks(e.toString()),s=i.length>1,o=void 0!==r,a=o&&i.some((e=>this._textWidthSingle(e)>r)),{textLeading:u,textWrap:l}=this.states;if((s||a)&&o&&(i=this._lineate(l,i,r)),o&&void 0!==n){if(void 0===u)throw Error("leading is required if height is specified");for(let e=0;e<i.length;e++){if(u*(e+1)>n){i=i.slice(0,e);break}}}return i},ps.prototype._xAlignOffset=function(e,r){switch(e){case t.LEFT:return 0;case t.CENTER:return r/2;case t.RIGHT:return r;case Oo:return 0;case Bo:throw new Error("textBounds: END not yet supported for textAlign");default:return 0}},ps.prototype._rectModeAlign=function(e,r,n){if(void 0!==r){switch(this.states.rectMode){case t.CENTER:e.x-=(r-e.w)/2,e.y-=(n-e.h)/2;break;case t.CORNERS:e.w+=e.x,e.h+=e.y;break;case t.RADIUS:e.x-=(r-e.w)/2,e.y-=(n-e.h)/2,e.w/=2,e.h/=2}return e}},ps.prototype._rectModeAlignRevert=function(e,r,n){if(void 0!==r){switch(this.states.rectMode){case t.CENTER:e.x+=(r-e.w)/2,e.y+=(n-e.h)/2;break;case t.CORNERS:e.w-=e.x,e.h-=e.y;break;case t.RADIUS:e.x+=(r-e.w)/2,e.y+=(n-e.h)/2,e.w*=2,e.h*=2}return e}},ps.prototype._textWidthSingle=function(e){let t=this.textDrawingContext().measureText(e),r=t.actualBoundingBoxLeft;return t.actualBoundingBoxRight+r},ps.prototype._fontWidthSingle=function(e){return this.textDrawingContext().measureText(e).width},ps.prototype._textBoundsSingle=function(e,t=0,r=0){let n=this.textDrawingContext().measureText(e),i=n.actualBoundingBoxAscent,s=n.actualBoundingBoxDescent,o=n.actualBoundingBoxLeft;return{x:t-o,y:r-i,w:n.actualBoundingBoxRight+o,h:i+s}},ps.prototype._fontBoundsSingle=function(e,t=0,r=0){let n=this.textDrawingContext().measureText(e),i=n.fontBoundingBoxAscent,s=n.fontBoundingBoxDescent;return{x:t-=this._xAlignOffset(this.states.textAlign,n.width),y:r-i,w:n.width,h:i+s}},ps.prototype._setTextSize=function(e){if("string"==typeof e&&(e=this._fontSizePx(e)),"number"==typeof e){if(this.states.textSize!==e)return this.states.setValue("textSize",e),this.states.leadingSet||this.states.setValue("textLeading",1.275*this.states.textSize),!0}else console.warn("textSize: invalid size: "+e);return!1},ps.prototype._lineate=function(e,r,n=1/0,i={}){let s,o,a,u,l=i.splitChar??(e===t.WORD?" ":""),h=[];for(let e=0;e<r.length;e++){s="",u=r[e].split(l);for(let e=0;e<u.length;e++)o=`${s+u[e]}`+l,a=this._textWidthSingle(o),s.length>0&&a>n?(h.push(s.trim()),s=`${u[e]}`+l):s=o;h.push(s.trim())}return h},ps.prototype._splitOnBreaks=function(e){return e&&0!==e.length?e.replace(o,"  ").split(r):[""]},ps.prototype._parseFontFamily=function(e){return e.split(n).map((e=>(((e=e.trim()).indexOf(" ")>-1||s.test(e))&&!i.test(e)&&(e=`"${e}"`),e))).join(", ")},ps.prototype._applyFontString=function(){let{textFont:e,textSize:r,lineHeight:n,fontStyle:i,fontWeight:s,fontVariant:o}=this.states,a=this.textDrawingContext(),u=this._parseFontFamily(e.family),l=i!==t.NORMAL?`${i} `:"",h=s!==t.NORMAL?`${s} `:"",c=`${l}${o!==t.NORMAL?`${o} `:""}${h}${`${r}px`+(n!==t.NORMAL?`/${n} `:" ")}${u}`.trim();if(a.font=c,a.font!==c){if(c!==a.font)return!1}return!0},ps.prototype._applyTextProperties=function(e=!1){this._applyFontString();let t=this.textDrawingContext();t.direction=this.states.direction,t.textAlign=this.states.textAlign,t.textBaseline=this.states.textBaseline;let r=this.states.fontStretch;for(c.includes(r)&&t.fontStretch!==r&&(t.fontStretch=r);d?.length;){let[r,n]=d.shift();e&&console.log('apply context property "'+r+'" = "'+n+'"'),t[r]=n,t[r]!==n&&(console.warn(`Unable to set '${r}' property on context2d. It may not be supported.`),console.log('Expected "'+n+'" but got: "'+t[r]+'"'))}return this._pInst}}function Po(e,t,r){switch(t){case pe:return e.baseFilterShader().modify((({p5:e})=>{e.getColor(((t,r)=>{const n=e.getTexture(r,t.texCoord),i=e.dot(n.rgb,e.vec3(.2126,.7152,.0722));return e.vec4(i,i,i,n.a)}))}),{p5:r});case me:return e.baseFilterShader().modify((({p5:e})=>{e.getColor(((t,r)=>{const n=e.getTexture(r,t.texCoord),i=e.vec3(1)-n.rgb;return e.vec4(i,n.a)}))}),{p5:r});case de:return e.baseFilterShader().modify((({p5:e})=>{const t=e.uniformFloat("filterParameter");e.getColor(((r,n)=>{const i=e.getTexture(n,r.texCoord),s=e.dot(i.rgb,e.vec3(.2126,.7152,.0722)),o=e.floor(255*t)/255,a=e.step(o,s);return e.vec4(e.vec3(a),i.a)}))}),{p5:r});case ge:return e.baseFilterShader().modify((({p5:e})=>{const t=e.uniformFloat("filterParameter");e.getColor(((r,n)=>{const i=e.getTexture(n,r.texCoord),s=((t,r)=>(t*=r,t=e.floor(t),t/(r-1)))(i.rgb,t);return e.vec4(s,i.a)}))}),{p5:r});case be:return e.baseFilterShader().modify((({p5:e})=>{const t=e.uniformFloat("radius"),r=e.uniformVec2("direction"),n=(t,r)=>e.pow(r-e.abs(t),2);e.getColor(((i,s)=>{const o=i.texCoord;let a=e.floor(7*t);0==e.mod(a,2)&&a++;let u=e.vec4(0),l=0,h=1;a>64&&(h=a/64,a=64);const c=(h-1)*e.mix(-.5,.5,(t=>{let r=e.fract(.1031*t.xyx);return r+=e.dot(r,r.yzx+33.33),e.fract((r.x+r.y)*r.z)})(o*i.canvasSize));for(let t=0;t<a;t++){const d=t*h-.5*(a-1)*h+c,p=o+e.vec2(d,d)/i.canvasSize*r,f=n(d,.5*(a-1)*h),m=e.getTexture(s,p);u+=f*m*e.vec4(m.a,m.a,m.a,1),l+=f}const d=u/l;return e.vec4(d.r/d.a,d.g/d.a,d.b/d.a,d.a)}))}),{p5:r});case ve:return e.baseFilterShader().modify((({p5:e})=>{const t=t=>e.dot(t.rgb,e.vec3(.2126,.7152,.0722));e.getColor(((r,n)=>{const i=r.texCoord;let s=e.getTexture(n,i),o=t(s);for(let a=-1;a<=1;a++)for(let u=-1;u<=1;u++)if(0!=a||0!=u){const l=e.vec2(a,u)*r.texelSize,h=e.getTexture(n,i+l),c=t(h);c<o&&(o=c,s=h)}return s}))}),{p5:r});case ye:return e.baseFilterShader().modify((({p5:e})=>{const t=t=>e.dot(t.rgb,e.vec3(.2126,.7152,.0722));e.getColor(((r,n)=>{const i=r.texCoord;let s=e.getTexture(n,i),o=t(s);for(let a=-1;a<=1;a++)for(let u=-1;u<=1;u++)if(0!=a||0!=u){const l=e.vec2(a,u)*r.texelSize,h=e.getTexture(n,i+l),c=t(h);c>o&&(o=c,s=h)}return s}))}),{p5:r});case fe:return e.baseFilterShader().modify((({p5:e})=>{e.getColor(((t,r)=>{const n=e.getTexture(r,t.texCoord);return e.vec4(n.rgb,1)}))}),{p5:r});default:throw new Error(`Unknown filter: ${t}`)}}function Ro(e){const t={},r={};let n="";const i=function(r,i){n+=e(`STROKE_CAP_${r}`,`${i}`,"u32"),t[qe[r]]=i},s=function(t,i){n+=e(`STROKE_JOIN_${t}`,`${i}`,"u32"),r[qe[t]]=i};return i("ROUND",0),i("PROJECT",1),i("SQUARE",2),s("ROUND",0),s("MITER",1),s("BEVEL",2),{STROKE_CAP_ENUM:t,STROKE_JOIN_ENUM:r,lineDefs:n}}"undefined"!=typeof p5&&Lo(p5,p5.prototype);const{STROKE_CAP_ENUM:Vo,STROKE_JOIN_ENUM:Uo}=Ro((()=>""));class zo extends ps{constructor(e,t,r,n,i){super(e,t,r,n),this.canvas=this.elt=i||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 Ei(this.elt,this._pInst);for(const e of Object.getOwnPropertyNames(Ei.prototype))"constructor"!==e&&"_"!==e[0]&&Object.defineProperty(this,e,{get(){return this.wrappedElt[e]}});const s=this._adjustDimensions(t,r);if(t=s.adjustedWidth,r=s.adjustedHeight,this.width=t,this.height=r,this.elt.width=t*this._pixelDensity,this.elt.height=r*this._pixelDensity,this.elt.style.width=`${t}px`,this.elt.style.height=`${r}px`,this._updateViewport(),this._pInst._userNode)this._pInst._userNode.appendChild(this.elt);else{if(0===document.getElementsByTagName("main").length){let e=document.createElement("main");document.body.appendChild(e)}document.getElementsByTagName("main")[0].appendChild(this.elt)}this.isP3D=!0,this.geometryBuilder=void 0,this.states.uModelMatrix=new uo(4),this.states.uViewMatrix=new uo(4),this.states.uPMatrix=new uo(4),this.mainCamera=new vo(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=Y,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 Pi(0,0,1),this.states.drawMode=Ce,this.states._tex=null,this.states.textureMode=Se,this.states.textureWrapX=Fe,this.states.textureWrapY=Fe,this._isErasing=!1,this._simpleLines=!1,this._clipDepths=[],this._textContextSavedStack=[],this._isClipApplied=!1,this._stencilTestOn=!1,this.mixedAmbientLight=[],this.mixedSpecularColor=[],this.diffusedTextures=new Map,this.specularTextures=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=new Set,this.mainCamera._computeCameraDefaultSettings(),this.mainCamera._setDefaultCamera(),this.filterCamera=new vo(this),this.filterCamera._computeCameraDefaultSettings(),this.filterCamera._setDefaultCamera(),this.prevTouches=[],this.zoomVelocity=0,this.rotateVelocity=new Pi(0,0),this.moveVelocity=new Pi(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 Ao(this),this._largeTessellationAcknowledged=!1,this.geometryBufferCache=new Do(this),this.curStrokeCap=q,this.curStrokeJoin=q,this.textures=new Map,this.framebuffers=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.scratchMat3=new uo(3),this._validateFaces=!1,this.buffers={fill:[new wo(3,"vertices","vertexBuffer","aPosition",this,this._vToNArray),new wo(3,"vertexNormals","normalBuffer","aNormal",this,this._vToNArray),new wo(4,"vertexColors","colorBuffer","aVertexColor",this).default((e=>e.vertices.flatMap((()=>[-1,-1,-1,-1])))),new wo(3,"vertexAmbients","ambientBuffer","aAmbientColor",this),new wo(2,"uvs","uvBuffer","aTexCoord",this,(e=>e.flat()))],stroke:[new wo(4,"lineVertexColors","lineColorBuffer","aVertexColor",this).default((e=>e.lineVertices.flatMap((()=>[-1,-1,-1,-1])))),new wo(3,"lineVertices","lineVerticesBuffer","aPosition",this),new wo(3,"lineTangentsIn","lineTangentsInBuffer","aTangentIn",this),new wo(3,"lineTangentsOut","lineTangentsOutBuffer","aTangentOut",this),new wo(1,"lineSides","lineSidesBuffer","aSide",this)],text:[new wo(3,"vertices","vertexBuffer","aPosition",this,this._vToNArray),new wo(2,"uvs","uvBuffer","aTexCoord",this,(e=>e.flat()))],user:[]}}async _resetContext(e,t,r=zo){const n=this.width,i=this.height,s=this.canvas.id,o=this._pInst instanceof Qo,a={position:this.canvas.style.position,top:this.canvas.style.top,left:this.canvas.style.left};if(o){const e=this._pInst;e.canvas.parentNode.removeChild(e.canvas),e.canvas=document.createElement("canvas");(e._pInst._userNode||document.body).appendChild(e.canvas),Ei.call(e,e.canvas,e._pInst),e.width=n,e.height=i}else{let e=this.canvas;e&&e.parentNode.removeChild(e),e=document.createElement("canvas"),e.id=s,this._pInst._userNode?this._pInst._userNode.appendChild(e):document.body.appendChild(e),this._pInst.canvas=e,this.canvas=e,this.canvas.style.position=a.position,this.canvas.style.top=a.top,this.canvas.style.left=a.left}const u=new r(this._pInst,n,i,!o,this._pInst.canvas);this._pInst._renderer=u,u._applyDefaults(),u.contextReady&&await u.contextReady,"function"==typeof t&&setTimeout((()=>{t.apply(window._renderer,e)}),0)}remove(){this.wrappedElt.remove(),this.wrappedElt=null,this.canvas=null,this.elt=null}beginGeometry(){if(this.geometryBuilder)throw new Error("It looks like `beginGeometry()` is being called while another p5.Geometry is already being build.");this.geometryBuilder=new mo(this),this.geometryBuilder.prevFillColor=this.states.fillColor,this.fill(new Tn([-1,-1,-1,-1]))}endGeometry(){if(!this.geometryBuilder)throw new Error("Make sure you call beginGeometry() before endGeometry()!");const e=this.geometryBuilder.finish();return this.geometryBuilder.prevFillColor?this.fill(this.geometryBuilder.prevFillColor):this.noFill(),this.geometryBuilder=void 0,e}buildGeometry(e){return this.beginGeometry(),e(),this.endGeometry()}beginShape(...e){super.beginShape(...e)}curveDetail(e){if(void 0===e)return this.states.curveDetail;this.states.setValue("curveDetail",e)}drawShape(e){const t=new us({curveDetail:this.states.curveDetail});e.accept(t),this.shapeBuilder.constructFromContours(e,t.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(e,t){this.drawShapeCount=t,super.endShape(e,t)}vertexProperty(...e){this.currentShape.vertexProperty(...e)}normal(e,t,r){e instanceof Pi?this.states.setValue("_currentNormal",e):this.states.setValue("_currentNormal",new Pi(e,t,r)),this.updateShapeVertexProperties()}model(e,t=1){e.vertices.length>0&&(this.geometryBuilder?this.geometryBuilder.addRetained(e):(this.geometryInHash(e.gid)||(e._edgesToVertices(),this._getOrMakeCachedBuffers(e)),this._drawGeometry(e,{count:t})))}_getOrMakeCachedBuffers(e){return this.geometryBufferCache.ensureCached(e)}_drawGeometry(e,{mode:t=4,count:r=1}={}){for(const t in e.userVertexProperties){const r=e.userVertexProperties[t];this.buffers.user.push(new wo(r.getDataSize(),r.getSrcName(),r.getDstName(),r.getName(),this))}this.states.fillColor&&e.vertices.length>=3&&![N,k].includes(t)&&this._drawFills(e,{mode:t,count:r}),this.states.strokeColor&&e.lineVertices.length>=1&&this._drawStrokes(e,{count:r}),this.buffers.user=[]}_drawFills(e,{count:t,mode:r}={}){this._useVertexColor=e.vertexColors.length>0&&!e.vertexColors.isDefault;const n=!this._drawingFilter&&this.states.userFillShader?this.states.userFillShader:this._getFillShader();n.bindShader("fill"),this._setGlobalUniforms(n),this._setFillUniforms(n),n.bindTextures();for(const t of this.buffers.fill)t._prepareBuffer(e,n);this._prepareUserAttributes(e,n),this._disableRemainingAttributes(n),this._applyColorBlend(this.states.curFillColor,e.hasFillTransparency()),this._drawBuffers(e,{mode:r,count:t}),n.unbindShader()}_drawStrokes(e,{count:t}={}){this._useLineColor=e.vertexStrokeColors.length>0;const r=this._getStrokeShader();r.bindShader("stroke"),this._setGlobalUniforms(r),this._setStrokeUniforms(r),r.bindTextures();for(const t of this.buffers.stroke)t._prepareBuffer(e,r);this._prepareUserAttributes(e,r),this._disableRemainingAttributes(r),this._applyColorBlend(this.states.curStrokeColor,e.hasStrokeTransparency()),this._drawBuffers(e,{count:t}),r.unbindShader()}_prepareUserAttributes(e,t){for(const r of this.buffers.user){if(!this._pInst.constructor.disableFriendleErrors){const t=e.userVertexProperties[r.attr];if(t){const r=t.getSrcArray().length/t.getDataSize();r>e.vertices.length?this._pInst.constructor._friendlyError(`One of the geometries has a custom vertex property '${t.getName()}' with more values than vertices. This is probably caused by directly using the Geometry.vertexProperty() method.`,"vertexProperty()"):r<e.vertices.length&&this._pInst.constructor._friendlyError(`One of the geometries has a custom vertex property '${t.getName()}' with fewer values than vertices. This is probably caused by directly using the Geometry.vertexProperty() method.`,"vertexProperty()")}}r._prepareBuffer(e,t)}}_drawGeometryScaled(e,t,r,n){let i=this.states.uModelMatrix;this.states.setValue("uModelMatrix",this.states.uModelMatrix.clone());try{this.states.uModelMatrix.scale(t,r,n),this.geometryBuilder?this.geometryBuilder.addRetained(e):this._drawGeometry(e)}finally{this.states.setValue("uModelMatrix",i)}}_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 Tn([1,1,1,1])),this._resetBuffersBeforeDraw()}background(...e){const t=e[0];if(null!=t&&"object"==typeof t&&"number"==typeof t.width&&"number"==typeof t.height&&(null!=t.canvas||null!=t.elt))return this._pInst.clear(),this._pInst.push(),this._pInst.resetMatrix(),this._pInst.imageMode(D),this._pInst.image(t,0,0,this._pInst.width,this._pInst.height),void this._pInst.pop();const r=this._pInst.color(...e);this.clear(...r._getRGBA())}get uModelMatrix(){return this.states.uModelMatrix}get uViewMatrix(){return this.states.uViewMatrix}get uPMatrix(){return this.states.uPMatrix}get uMVMatrix(){const e=this.uModelMatrix.copy();return e.mult(this.uViewMatrix),e}getWorldToScreenMatrix(){const e=this.states.uModelMatrix,t=this.states.uViewMatrix,r=this.states.uPMatrix,n=new uo(4);n.scale(this.width,this.height,1),n.translate([.5,.5,.5]),n.scale(.5,-.5,.5);return e.copy().mult(t).mult(r).mult(n)}fill(...e){super.fill(...e);const t=this.states.fillColor;this.states.setValue("curFillColor",t._array),this.states.setValue("drawMode",Ce),this.states.setValue("_useNormalMaterial",!1),this.states.setValue("_tex",null)}stroke(...e){super.stroke(...e),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(e){this.curStrokeCap=e}strokeJoin(e){this.curStrokeJoin=e}getFilterLayer(){return this.filterLayer||(this.filterLayer=new ma(this)),this.filterLayer}getFilterLayerTemp(){return this.filterLayerTemp||(this.filterLayerTemp=new ma(this)),this.filterLayerTemp}matchSize(e,t){e.width===t.width&&e.height===t.height||e.resize(t.width,t.height),e.pixelDensity()!==t.pixelDensity()&&e.pixelDensity(t.pixelDensity())}filter(...e){let t,r,n=this.getFilterLayer();if("string"==typeof e[0]){r=e[0];let i=r in To&&void 0===e[1];t=i?To[r]:e[1],r in this.defaultFilterShaders||(this.defaultFilterShaders[r]=this._makeFilterShader(n.renderer,r)),this.states.setValue("filterShader",this.defaultFilterShaders[r])}else this.states.setValue("filterShader",e[0]);const i=this.activeFramebuffer()||this;this.matchSize(n,i),n.draw((()=>this.clear()));let s=[1/(i.width*i.pixelDensity()),1/(i.height*i.pixelDensity())];if(r===be){const e=this.getFilterLayerTemp();this.matchSize(e,i),this.push(),this.states.setValue("strokeColor",null),this.blendMode(Y),this.shader(this.states.filterShader),this.states.filterShader.setUniform("texelSize",s),this.states.filterShader.setUniform("canvasSize",[i.width,i.height]),this.states.filterShader.setUniform("radius",Math.max(1,t)),e.draw((()=>{this.states.filterShader.setUniform("direction",[1,0]),this.states.filterShader.setUniform("tex0",i),this.clear(),this.shader(this.states.filterShader),this.noLights(),this.plane(i.width,i.height)})),n.draw((()=>{this.states.filterShader.setUniform("direction",[0,1]),this.states.filterShader.setUniform("tex0",e),this.clear(),this.shader(this.states.filterShader),this.noLights(),this.plane(i.width,i.height)})),this.pop()}else n.draw((()=>{this.states.setValue("strokeColor",null),this.blendMode(Y),this.shader(this.states.filterShader),this.states.filterShader.setUniform("tex0",i),this.states.filterShader.setUniform("texelSize",s),this.states.filterShader.setUniform("canvasSize",[i.width,i.height]),this.states.filterShader.setUniform("filterParameter",t),this.noLights(),this.plane(i.width,i.height)}));this.push(),this.states.setValue("strokeColor",null),this.clear(),this.push(),this.states.setValue("imageMode",w),this.blendMode(Y),i.filterCamera._resize(),this.setCamera(i.filterCamera),this.resetMatrix(),this._drawingFilter=!0,this.image(n,0,0,n.width,n.height,-i.width/2,-i.height/2,i.width,i.height),this._drawingFilter=!1,this.clearDepth(),this.pop(),this.pop()}pixelDensity(e){return e?this._pInst.pixelDensity(e):this._pInst.pixelDensity()}blendMode(e){e===Q||e===ee||e===J||e===Y||e===re||e===se||e===ne||e===oe||e===ie||e===K?this.states.setValue("curBlendMode",e):e!==ce&&e!==ae&&e!==ue&&e!==le&&e!==he||console.warn("BURN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, and DODGE only work for blendMode in 2D mode.")}erase(e,t){this._isErasing||(this.preEraseBlend=this.states.curBlendMode,this._isErasing=!0,this.blendMode(K),this._cachedFillStyle=this.states.curFillColor.slice(),this.states.setValue("curFillColor",[1,1,1,e/255]),this._cachedStrokeStyle=this.states.curStrokeColor.slice(),this.states.setValue("curStrokeColor",[1,1,1,t/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(e={}){super.beginClip(e),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||(this._tempFramebuffer=new ma(this,{format:Ve,useDepth:this._pInst._glAttributes.depth,depthFormat:Ue,antialias:this._pInst._glAttributes.antialias})),this._tempFramebuffer}geometryInHash(e){return this.geometryBufferCache.isCached(e)}resize(e,t){super.resize(e,t);const r={};for(const e in this.drawingContext){const t=this.drawingContext[e];"object"!=typeof t&&"function"!=typeof t&&(r[e]=t)}const n=this._adjustDimensions(e,t);e=n.adjustedWidth,t=n.adjustedHeight,this.width=e,this.height=t,this.canvas.width=e*this._pixelDensity,this.canvas.height=t*this._pixelDensity,this.canvas.style.width=`${e}px`,this.canvas.style.height=`${t}px`,this._updateViewport(),this._updateSize(),this.mainCamera._resize(),this.states.curCamera!==this.mainCamera&&this.states.curCamera._resize(),void 0!==this.pixels&&this._createPixelsArray();for(const e of this.framebuffers)this.flushDraw?.(),e._canvasSizeChanged();this.flushDraw?.();for(const e in r)try{this.drawingContext[e]=r[e]}catch(e){}}applyMatrix(e,t,r,n,i,s){this.states.setValue("uModelMatrix",this.states.uModelMatrix.clone()),16===arguments.length?uo.prototype.apply.apply(this.states.uModelMatrix,arguments):this.states.uModelMatrix.apply([e,t,0,0,r,n,0,0,0,0,1,0,i,s,0,1])}translate(e,t,r){return e instanceof Pi&&(r=e.z,t=e.y,e=e.x),this.states.setValue("uModelMatrix",this.states.uModelMatrix.clone()),this.states.uModelMatrix.translate([e,t,r]),this}scale(e,t,r){return this.states.setValue("uModelMatrix",this.states.uModelMatrix.clone()),this.states.uModelMatrix.scale(e,t,r),this}rotate(e,t){return void 0===t?this.rotateZ(e):(this.states.setValue("uModelMatrix",this.states.uModelMatrix.clone()),uo.prototype.rotate4x4.apply(this.states.uModelMatrix,arguments),this)}rotateX(e){return this.rotate(e,1,0,0),this}rotateY(e){return this.rotate(e,0,1,0),this}rotateZ(e){return this.rotate(e,0,0,1),this}push(){super.push();const e=!!this.states.textFont?.font;e&&this.textDrawingContext().save(),this._textContextSavedStack.push(e)}pop(...e){this._clipDepths.length>0&&this._pushPopDepth===this._clipDepths[this._clipDepths.length-1]&&this._clearClip(),this._textContextSavedStack.pop()&&this.textDrawingContext().restore(),super.pop(...e),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(){const e=this.states.userStrokeShader;return e||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._getColorShader()}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(e){return new ma(this,e)}_setGlobalUniforms(e){const t=this.states.uModelMatrix,r=this.states.uViewMatrix,n=this.states.uPMatrix,i=t.copy().mult(r);if(e.setUniform("uPerspective",this.states.curCamera.useLinePerspective?1:0),e.setUniform("uViewMatrix",r.mat4),e.setUniform("uProjectionMatrix",n.mat4),e.setUniform("uModelMatrix",t.mat4),e.setUniform("uModelViewMatrix",i.mat4),e.uniforms.uModelViewProjectionMatrix){const t=i.copy();t.mult(n),e.setUniform("uModelViewProjectionMatrix",t.mat4)}e.uniforms.uNormalMatrix&&(this.scratchMat3.inverseTranspose4x4(i),e.setUniform("uNormalMatrix",this.scratchMat3.mat3)),e.uniforms.uModelNormalMatrix&&(this.scratchMat3.inverseTranspose4x4(this.states.uModelMatrix),e.setUniform("uModelNormalMatrix",this.scratchMat3.mat3)),e.uniforms.uCameraNormalMatrix&&(this.scratchMat3.inverseTranspose4x4(this.states.uViewMatrix),e.setUniform("uCameraNormalMatrix",this.scratchMat3.mat3)),e.setUniform("uViewport",this._viewport)}_setStrokeUniforms(e){e.setUniform("uSimpleLines",this._simpleLines),e.setUniform("uUseLineColor",this._useLineColor),e.setUniform("uMaterialColor",this.states.curStrokeColor),e.setUniform("uStrokeWeight",this.states.strokeWeight),e.setUniform("uStrokeCap",Vo[this.curStrokeCap]),e.setUniform("uStrokeJoin",Uo[this.curStrokeJoin])}_setFillUniforms(e){this.mixedSpecularColor=[...this.states.curSpecularColor];const t=this._getEmptyTexture();this.states._useMetalness>0&&(this.mixedSpecularColor=this.mixedSpecularColor.map(((e,t)=>this.states.curFillColor[t]*this.states._useMetalness+e*(1-this.states._useMetalness)))),e.setUniform("uUseVertexColor",this._useVertexColor),e.setUniform("uMaterialColor",this.states.curFillColor),e.setUniform("isTexture",!!this.states._tex),this._settingFillUniforms=!0,!this.states._tex&&e._userSetSampler||e.setUniform("uSampler",this.states._tex||t),this._settingFillUniforms=!1,e.setUniform("uTint",this.states.tint?._getRGBA([255,255,255,255])??[255,255,255,255]),e.setUniform("uHasSetAmbient",this.states._hasSetAmbient),e.setUniform("uAmbientMatColor",this.states.curAmbientColor),e.setUniform("uSpecularMatColor",this.mixedSpecularColor),e.setUniform("uEmissiveMatColor",this.states.curEmissiveColor),e.setUniform("uSpecular",this.states._useSpecularMaterial),e.setUniform("uEmissive",this.states._useEmissiveMaterial),e.setUniform("uShininess",this.states._useShininess),e.setUniform("uMetallic",this.states._useMetalness),this._setImageLightUniforms(e),e.setUniform("uUseLighting",this.states.enableLighting);const r=this.states.pointLightDiffuseColors.length/3;e.setUniform("uPointLightCount",r),e.setUniform("uPointLightLocation",this.states.pointLightPositions),e.setUniform("uPointLightDiffuseColors",this.states.pointLightDiffuseColors),e.setUniform("uPointLightSpecularColors",this.states.pointLightSpecularColors);const n=this.states.directionalLightDiffuseColors.length/3;e.setUniform("uDirectionalLightCount",n),e.setUniform("uLightingDirection",this.states.directionalLightDirections),e.setUniform("uDirectionalDiffuseColors",this.states.directionalLightDiffuseColors),e.setUniform("uDirectionalSpecularColors",this.states.directionalLightSpecularColors);let i=[0,0,0];for(let e=0;e<this.states.ambientLightColors.length;e+=3)for(let t=0;t<3;t++)this.states._useMetalness>0?i[t]+=Math.max(0,this.states.ambientLightColors[e+t]-this.states._useMetalness):i[t]+=this.states.ambientLightColors[e+t];e.setUniform("uAmbientColor",i);const s=this.states.spotLightDiffuseColors.length/3;e.setUniform("uSpotLightCount",s),e.setUniform("uSpotLightAngle",this.states.spotLightAngle),e.setUniform("uSpotLightConc",this.states.spotLightConc),e.setUniform("uSpotLightDiffuseColors",this.states.spotLightDiffuseColors),e.setUniform("uSpotLightSpecularColors",this.states.spotLightSpecularColors),e.setUniform("uSpotLightLocation",this.states.spotLightPositions),e.setUniform("uSpotLightDirection",this.states.spotLightDirections),e.setUniform("uConstantAttenuation",this.states.constantAttenuation),e.setUniform("uLinearAttenuation",this.states.linearAttenuation),e.setUniform("uQuadraticAttenuation",this.states.quadraticAttenuation)}_setImageLightUniforms(e){if(e.setUniform("uUseImageLight",null!=this.states.activeImageLight),this.states.activeImageLight){let t=this.getDiffusedTexture(this.states.activeImageLight);e.setUniform("environmentMapDiffused",t);let r=this.getSpecularTexture(this.states.activeImageLight);e.setUniform("environmentMapSpecular",r)}else e.setUniform("environmentMapDiffused",this._getEmptyTexture()),e.setUniform("environmentMapSpecular",this._getEmptyTexture())}_getEmptyTexture(){if(!this._emptyTexture){const e=new Mi(1,1);e.set(0,0,255),this._emptyTexture=new ea(this,e)}return this._emptyTexture}getTexture(e){let t=e;t instanceof ma&&(t=t.color);const r=this.textures.get(t);if(r)return r;const n=new ea(this,t);return this.textures.set(t,n),n}_normalizeBufferData(e,t=Float32Array){return e?e instanceof ho?e.dataArray():e instanceof t?e:new t(e):null}_arraysEqual(e,t){return e.length===t.length&&e.every(((e,r)=>e===t[r]))}_isTypedArray(e){return[Float32Array,Float64Array,Int16Array,Uint16Array,Uint32Array].some((t=>e instanceof t))}_vToNArray(e){return e.flatMap((e=>[e.x,e.y,e.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){const e=this.textCanvas();this._textDrawingContext=e.getContext("2d")}return this._textDrawingContext}_positionLines(e,t,r,n,i){let{textLeading:s,textAlign:o}=this.states;const a=i.map((e=>this._fontWidthSingle(e)));let u,l=new Array(i.length),h=void 0===r?Math.max(0,...a):r,c=void 0===n?0:n;for(let n=0;n<i.length;n++){switch(o){case Oo:throw new Error("textBounds: START not yet supported for textAlign");case A:u=e;break;case D:u=e+(h-a[n])/2-h/2+(r||0)/2;break;case S:u=e+h-a[n]-h+(r||0);break;case Bo:throw new Error("textBounds: END not yet supported for textAlign");default:u=e}l[n]={text:i[n],x:u,y:t+n*s}}return this._yAlignOffset(l,c)}_verticalAlignFont=function(){const e=this.textDrawingContext().measureText("X");return-e.alphabeticBaseline||-e.fontBoundingBoxAscent+e.fontBoundingBoxDescent};_yAlignOffset(e,t){if(void 0===t)throw Error("_yAlignOffset: height is required");let{textLeading:r,textBaseline:n,textSize:i}=this.states,s=0,o=e.length,a=i*o+(r-i)*(o-1);switch(n){case T:s=this._verticalAlignFont();break;case I:break;case Io:s=(-a+i+(t||0))/2+this._verticalAlignFont()+this._middleAlignOffset();break;case F:s=-(a-i)+(t||0);break;default:console.warn(`${n} is not supported in WebGL mode.`)}return e.forEach((e=>e.y+=s)),e}_makeFilterShader(e,t){return Po(this,t,this._pInst)}makeDiffusedTexture(e){if(null!=this.diffusedTextures.get(e))return this.diffusedTextures.get(e);let t,r=Math.floor(e.height/e.width*200);return t=new ma(this,{width:200,height:r,density:1}),this.diffusedShader||(this.diffusedShader=this._createImageLightShader("diffused")),t.draw((()=>{this.shader(this.diffusedShader),this._setImageLightShaderUniforms(this.diffusedShader,e),this.states.setValue("strokeColor",null),this.noLights(),this.plane(200,r)})),this.diffusedTextures.set(e,t),t}getDiffusedTexture(e){return this.diffusedTextures.get(e)}makeSpecularTexture(e){if(null!=this.specularTextures.get(e))return this.specularTextures.get(e);const t=512;let r,n=Math.floor(Math.log2(t))+1;this.specularShader||(this.specularShader=this._createImageLightShader("specular"));const i=this._prepareMipmapData(t,n),s=new ma(this,{width:t,height:t,density:1});let o=0;for(let r=t;r>=1;r/=2){s.resize(r,r);let t=1-Math.log(r)/Math.log(2)/n;s.draw((()=>{this.shader(this.specularShader),this.clear(),this._setImageLightShaderUniforms(this.specularShader,e,t),this.states.setValue("strokeColor",null),this.noLights(),this.plane(r,r)})),this._accumulateMipLevel(s,i,o,r,r),o++}return s.remove(),r=this._finalizeMipmapTexture(i),this.specularTextures.set(e,r),r}getSpecularTexture(e){return this.specularTextures.get(e)}_getSphereMapping(e){if(!this.sphereMapping){const e=this._pInst;this.sphereMapping=this.baseFilterShader().modify((({p5:e})=>{const t=e.uniformTexture("uEnvMap"),r=e.uniformFloat("uFovY"),n=e.uniformFloat("uAspect"),i=e.uniformVec3("uN1"),s=e.uniformVec3("uN2"),o=e.uniformVec3("uN3");e.getColor((a=>{const u=r*n,l=e.mix(r/2,-r/2,a.texCoord.y),h=e.mix(u/2,-u/2,a.texCoord.x);let c=e.normalize([h,l,1]);c=[e.dot(c,i),e.dot(c,s),e.dot(c,o)];const d=c.z;c.z=c.x,c.x=-d;const p=[e.atan(c.z,c.x)/(2*e.PI)+.5,.5+.5*-c.y];return e.getTexture(t,p)}))}),{p5:e})}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);const t=this.scratchMat3.mat3;return this.sphereMapping.setUniform("uN1",[t[0],t[3],t[6]]),this.sphereMapping.setUniform("uN2",[t[1],t[4],t[7]]),this.sphereMapping.setUniform("uN3",[t[2],t[5],t[8]]),this.sphereMapping.setUniform("uEnvMap",e),this.sphereMapping}_createImageLightShader(e){throw new Error("_createImageLightShader must be implemented by the renderer")}_setImageLightShaderUniforms(e,t,r){e.setUniform("environmentMap",t),void 0!==r&&e.setUniform("roughness",r)}_createMipmapTexture(e){throw new Error("_createMipmapTexture must be implemented by the renderer")}_prepareMipmapData(e,t){throw new Error("_prepareMipmapData must be implemented by the renderer")}_accumulateMipLevel(e,t,r,n,i){throw new Error("_accumulateMipLevel must be implemented by the renderer")}_finalizeMipmapTexture(e){throw new Error("_finalizeMipmapTexture must be implemented by the renderer")}remove(){this._textCanvas&&this._textCanvas.parentElement.removeChild(this._textCanvas),super.remove()}}const jo="Add the WebGPU add-on to your project and pass WEBGPU as the last argument to createCanvas.";function Go(e,t){e.Renderer3D=zo,Ao.prototype.friendlyErrorsDisabled=function(){return Boolean(e.disableFriendlyErrors)},t.createStorage=function(t){if(this._renderer.createStorage)return this._renderer.createStorage(t);e._friendlyError(`createStorage() is only available with the WebGPU renderer. ${jo}`,"createStorage")},t.baseComputeShader=function(){if(this._renderer.baseComputeShader)return this._renderer.baseComputeShader();e._friendlyError(`baseComputeShader() is only available with the WebGPU renderer. ${jo}`,"baseComputeShader")},t.buildComputeShader=function(t,r){if(this._renderer.baseComputeShader)return this.baseComputeShader().modify(t,r,{hook:"iteration"});e._friendlyError(`buildComputeShader() is only available with the WebGPU renderer. ${jo}`,"buildComputeShader")},t.compute=function(t,r,n,i){this._renderer.compute?this._renderer.compute(t,r,n,i):e._friendlyError(`compute() is only available with the WebGPU renderer. ${jo}`,"compute")}}function $o(e,t){t.strokeMode=function(e){if(void 0===e)return this._renderer._simpleLines?u:l;if(e===u)this._renderer._simpleLines=!0;else{if(e!==l)throw Error("no such parameter");this._renderer._simpleLines=!1}},t.buildGeometry=function(e){return this._renderer.buildGeometry(e)},t.freeGeometry=function(e){this._renderer.geometryBufferCache.freeBuffers(e.gid)},t.plane=function(e=50,t=e,r=1,n=1){return this._assert3d("plane"),this._renderer.plane(e,t,r,n),this},t.box=function(e,t,r,n,i){return this._assert3d("box"),this._renderer.box(e,t,r,n,i),this},t.sphere=function(e=50,t=24,r=16){return this._assert3d("sphere"),this._renderer.sphere(e,t,r),this},t.cylinder=function(e=50,t=e,r=24,n=1,i=!0,s=!0){return this._assert3d("cylinder"),this._renderer.cylinder(e,t,r,n,i,s),this},t.cone=function(e=50,t=e,r=24,n=1,i=!0){return this._assert3d("cone"),this._renderer.cone(e,t,r,n,i),this},t.ellipsoid=function(e=50,t=e,r=e,n=24,i=16){return this._assert3d("ellipsoid"),this._renderer.ellipsoid(e,t,r,n,i),this},t.torus=function(e,t,r,n){return this._assert3d("torus"),this._renderer.torus(e,t,r,n),this},zo.prototype.point=function(e,t,r=0){return this.beginShape(k),this.vertex(e,t,r),this.endShape(),this},zo.prototype.triangle=function(e){const t=e[0],r=e[1],n=e[2],i=e[3],s=e[4],o=e[5],a="tri";if(!this.geometryInHash(a)){const e=new po(1,1,(function(){const e=[];e.push(new Pi(0,0,0)),e.push(new Pi(1,0,0)),e.push(new Pi(0,1,0)),this.edges=[[0,1],[1,2],[2,0]],this.vertices=e,this.faces=[[0,1,2]],this.uvs=[0,0,1,0,1,1]}),this);e._edgesToVertices(),e.computeNormals(),e.gid=a,this.geometryBufferCache.ensureCached(e)}const u=this.states.uModelMatrix.copy();try{const e=Math.sign(t*i-n*r+n*o-s*i+s*r-t*o),u=new uo([n-t,i-r,0,0,s-t,o-r,0,0,0,0,e,0,t,r,0,1]).mult(this.states.uModelMatrix);this.states.setValue("uModelMatrix",u),this.model(this.geometryBufferCache.getGeometryByID(a))}finally{this.states.setValue("uModelMatrix",u)}return this},zo.prototype.ellipse=function(e){this.arc(e[0],e[1],e[2],e[3],0,b,z,e[4])},zo.prototype.arc=function(...e){const t=e[0],r=e[1],n=e[2],i=e[3],s=e[4],o=e[5],a=e[6],u=e[7]||25;let l,h;if(Math.abs(o-s)>=b?(l="ellipse",h=`${l}|${u}|`):(l="arc",h=`${l}|${s}|${o}|${a}|${u}|`),!this.geometryInHash(h)){const e=function(){if(s.toFixed(10)!==o.toFixed(10)){a!==G&&void 0!==a||(this.vertices.push(new Pi(.5,.5,0)),this.uvs.push([.5,.5]));for(let e=0;e<=u;e++){const t=(o-s)*(e/u)+s,r=.5+Math.cos(t)/2,n=.5+Math.sin(t)/2;this.vertices.push(new Pi(r,n,0)),this.uvs.push([r,n]),e<u-1&&(this.faces.push([0,e+1,e+2]),this.edges.push([e+1,e+2]))}switch(a){case G: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 j:this.edges.push([0,1]),this.edges.push([0,this.vertices.length-1]);break;case z: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])}}},t=new po(u,1,e,this);t.computeNormals(),u<=50?t._edgesToVertices(t):this.states.strokeColor&&console.log(`Cannot apply a stroke to an ${l} with more than 50 detail`),t.gid=h,this.geometryBufferCache.ensureCached(t)}const c=this.states.uModelMatrix;this.states.setValue("uModelMatrix",this.states.uModelMatrix.clone());try{this.states.uModelMatrix.translate([t,r,0]),this.states.uModelMatrix.scale(n,i,1),this.model(this.geometryBufferCache.getGeometryByID(h))}finally{this.states.setValue("uModelMatrix",c)}return this},zo.prototype.rect=function(e){const t=e[0],r=e[1],n=e[2],i=e[3];if(void 0===e[4]){const s=this._pInst._glAttributes?.perPixelLighting??!0,o=e[4]||(s?1:24),a=e[5]||(s?1:16),u=`rect|${o}|${a}`;if(!this.geometryInHash(u)){const e=function(){for(let e=0;e<=this.detailY;e++){const t=e/this.detailY;for(let e=0;e<=this.detailX;e++){const r=e/this.detailX,n=new Pi(r,t,0);this.vertices.push(n),this.uvs.push(r,t)}}o>0&&a>0&&(this.edges=[[0,o],[o,(o+1)*(a+1)-1],[(o+1)*(a+1)-1,(o+1)*a],[(o+1)*a,0]])},t=new po(o,a,e,this);t.computeFaces().computeNormals()._edgesToVertices(),t.gid=u,this.geometryBufferCache.ensureCached(t)}const l=this.states.uModelMatrix;this.states.setValue("uModelMatrix",this.states.uModelMatrix.copy());try{this.states.uModelMatrix.translate([t,r,0]),this.states.uModelMatrix.scale(n,i,1),this.model(this.geometryBufferCache.getGeometryByID(u))}finally{this.states.setValue("uModelMatrix",l)}}else{let s=e[4],o=void 0===e[5]?s:e[5],a=void 0===e[6]?o:e[6],u=void 0===e[7]?a:e[7],l=t,h=r,c=n,d=i;if(c+=l,d+=h,l>c){const e=l;l=c,c=e}if(h>d){const e=h;h=d,d=e}const p=Math.min((c-l)/2,(d-h)/2);s>p&&(s=p),o>p&&(o=p),a>p&&(a=p),u>p&&(u=p);let f=l,m=h,g=c,y=d;const v=this.states.textureMode;this.states.setValue("textureMode",xe);const b=this.bezierOrder();this.bezierOrder(3),this.beginShape();const x=(e,t)=>[e,t,0,(e-f)/n,(t-m)/i],_=.5523;0!==o?(this.vertex(...x(g-o,m)),this.bezierVertex(...x(g-o+o*_,m)),this.bezierVertex(...x(g,m+o-o*_)),this.bezierVertex(...x(g,m+o))):this.vertex(...x(g,m)),0!==a?(this.vertex(...x(g,y-a)),this.bezierVertex(...x(g,y-a+a*_)),this.bezierVertex(...x(g-a+_*a,y)),this.bezierVertex(...x(g-a,y))):this.vertex(...x(g,y)),0!==u?(this.vertex(...x(f+u,y)),this.bezierVertex(...x(f+u-u*_,y)),this.bezierVertex(...x(f,y-u+u*_)),this.bezierVertex(...x(f,y-u))):this.vertex(...x(f,y)),0!==s?(this.vertex(...x(f,m+s)),this.bezierVertex(...x(f,m+s-s*_)),this.bezierVertex(...x(f+s-s*_,m)),this.bezierVertex(...x(f+s,m))):this.vertex(...x(f,m)),this.endShape(U),this.states.setValue("textureMode",v),this.bezierOrder(b)}return this},zo.prototype.quad=function(e,t,r,n,i,s,o,a,u,l,h,c,d=2,p=2){const f=`quad|${e}|${t}|${r}|${n}|${i}|${s}|${o}|${a}|${u}|${l}|${h}|${c}|${d}|${p}`;if(!this.geometryInHash(f)){const m=new po(d,p,(function(){let d=1/(this.detailX-1),p=1/(this.detailY-1);for(let f=0;f<this.detailY;f++)for(let m=0;m<this.detailX;m++){let g=m*d,y=f*p,v=(1-g)*((1-y)*e+y*l)+g*((1-y)*n+y*o),b=(1-g)*((1-y)*t+y*h)+g*((1-y)*i+y*a),x=(1-g)*((1-y)*r+y*c)+g*((1-y)*s+y*u);this.vertices.push(new Pi(v,b,x)),this.uvs.push([g,y])}}),this);m.faces=[];for(let e=0;e<p-1;e++)for(let t=0;t<d-1;t++){let r=t+e*d,n=t+1+e*d,i=t+1+(e+1)*d,s=t+(e+1)*d;m.faces.push([r,n,i]),m.faces.push([r,i,s])}m.computeNormals(),m.edges.length=0;const g=[0,2,3,1];for(let e=0;e<g.length;e++){const t=g[e],r=g[(e+1)%g.length];m.edges.push([t,r])}m._edgesToVertices(),m.gid=f,this.geometryBufferCache.ensureCached(m)}return this.model(this.geometryBufferCache.getGeometryByID(f)),this},zo.prototype.bezier=function(e,t,r,n,i,s,o,a,u,l,h,c){8===arguments.length&&(h=a,l=o,a=s,o=i,i=n,n=r,r=s=u=c=0),this.bezierOrder(),this.bezierOrder(3),this.beginShape(),this.vertex(e,t,r),this.bezierVertex(n,i,s),this.bezierVertex(o,a,u),this.bezierVertex(l,h,c),this.endShape()},zo.prototype.curve=function(e,t,r,n,i,s,o,a,u,l,h,c){8===arguments.length&&(l=o,h=a,o=i,a=n,i=n=r,r=s=u=c=0),this.beginShape(),this.splineVertex(e,t,r),this.splineVertex(n,i,s),this.splineVertex(o,a,u),this.splineVertex(l,h,c),this.endShape()},zo.prototype.line=function(...e){return 6===e.length?(this.beginShape(N),this.vertex(e[0],e[1],e[2]),this.vertex(e[3],e[4],e[5]),this.endShape()):4===e.length&&(this.beginShape(N),this.vertex(e[0],e[1],0),this.vertex(e[2],e[3],0),this.endShape()),this},zo.prototype.image=function(e,t,r,n,i,s,o,a,u){this._isErasing&&this.blendMode(this._cachedBlendMode),this.push(),this.noLights(),this.states.setValue("strokeColor",null),this.texture(e),this.states.setValue("textureMode",xe);let l=0;t<=e.width&&(l=t/e.width);let h=1;t+n<=e.width&&(h=(t+n)/e.width);let c=0;r<=e.height&&(c=r/e.height);let d=1;r+i<=e.height&&(d=(r+i)/e.height),this._drawingImage=!0,this.beginShape(),this.vertex(s,o,0,l,c),this.vertex(s+a,o,0,h,c),this.vertex(s+a,o+u,0,h,d),this.vertex(s,o+u,0,l,d),this.endShape(U),this._drawingImage=!1,this.pop(),this._isErasing&&this.blendMode(K)};const r=function(e,t,r,n,i,s,o){e=e<=0?1:e,t=t<0?0:t,r=r<=0?e:r,n=n<3?3:n;const a=(s=void 0===s||s)?-2:0,u=(i=i<1?1:i)+((o=void 0===o?0!==t:o)?2:0),l=Math.atan2(e-t,r),h=Math.sin(l),c=Math.cos(l);let d,p,f;for(d=a;d<=u;++d){let s,o=d/i,a=r*o;for(d<0?(a=0,o=0,s=e):d>i?(a=r,o=1,s=t):s=e+(t-e)*o,-2!==d&&d!==i+2||(s=0),a-=r/2,p=0;p<n;++p){const e=p/(n-1),r=2*Math.PI*e,u=Math.sin(r),l=Math.cos(r);let f;this.vertices.push(new Pi(u*s,a,l*s)),f=d<0?new Pi(0,-1,0):d>i&&t?new Pi(0,1,0):new Pi(u*c,h,l*c),this.vertexNormals.push(f),this.uvs.push(e,o)}}let m=0;if(s){for(f=0;f<n;++f){const e=(f+1)%n;this.faces.push([m+f,m+n+e,m+n+f])}m+=2*n}for(d=0;d<i;++d){for(p=0;p<n;++p){const e=(p+1)%n;this.faces.push([m+p,m+e,m+n+e]),this.faces.push([m+p,m+n+e,m+n+p])}m+=n}if(o)for(m+=n,p=0;p<n;++p)this.faces.push([m+p,m+(p+1)%n,m+n])};zo.prototype.plane=function(e=50,t=e,r=1,n=1){const i=`plane|${r}|${n}`;if(!this.geometryInHash(i)){const e=function(){let e,t,r;for(let n=0;n<=this.detailY;n++){t=n/this.detailY;for(let n=0;n<=this.detailX;n++)e=n/this.detailX,r=new Pi(e-.5,t-.5,0),this.vertices.push(r),this.uvs.push(e,t)}},t=new po(r,n,e,this);t.computeFaces().computeNormals(),r<=1&&n<=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=i,this.geometryBufferCache.ensureCached(t)}this._drawGeometryScaled(this.geometryBufferCache.getGeometryByID(i),e,t,1)},zo.prototype.box=function(e=50,t=e,r=t,n,i){const s=this.attributes&&this.attributes.perPixelLighting;void 0===n&&(n=s?1:4),void 0===i&&(i=s?1:4);const o=`box|${n}|${i}`;if(!this.geometryInHash(o)){const e=function(){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]],[[0,4,2,6],[1,3,5,7],[0,1,4,5],[2,6,3,7],[0,2,1,3],[4,5,6,7]].forEach(((e,t)=>{const r=4*t;for(let t=0;t<4;t++){const r=e[t],n=new Pi((2*(1&r)-1)/2,((2&r)-1)/2,((4&r)/2-1)/2);this.vertices.push(n),this.uvs.push(1&t,(2&t)/2)}this.faces.push([r,r+1,r+2]),this.faces.push([r+2,r+1,r+3])}))},t=new po(n,i,e,this);t.computeNormals(),n<=4&&i<=4?t._edgesToVertices():this.states.strokeColor&&console.log("Cannot draw stroke on box objects with more than 4 detailX or 4 detailY"),t.gid=o,this.geometryBufferCache.ensureCached(t)}this._drawGeometryScaled(this.geometryBufferCache.getGeometryByID(o),e,t,r)},zo.prototype.sphere=function(e=50,t=24,r=16){this.ellipsoid(e,e,e,t,r)},zo.prototype.ellipsoid=function(t=50,r=t,n=t,i=24,s=16){const o=`ellipsoid|${i}|${s}`;if(!this.geometryInHash(o)){const t=function(){for(let t=0;t<=this.detailY;t++){const r=t/this.detailY,n=Math.PI*r-Math.PI/2,i=Math.cos(n),s=Math.sin(n);for(let t=0;t<=this.detailX;t++){const n=t/this.detailX,o=2*Math.PI*n,a=Math.cos(o),u=Math.sin(o),l=new e.Vector(i*u,s,i*a);this.vertices.push(l),this.vertexNormals.push(l),this.uvs.push(n,r)}}},r=new po(i,s,t,this);r.computeFaces(),i<=24&&s<=24?r._makeTriangleEdges()._edgesToVertices():this.states.strokeColor&&console.log("Cannot draw stroke on ellipsoids with more than 24 detailX or 24 detailY"),r.gid=o,this.geometryBufferCache.ensureCached(r)}this._drawGeometryScaled(this.geometryBufferCache.getGeometryByID(o),t,r,n)},zo.prototype.cylinder=function(t=50,n=t,i=24,s=1,o=!0,a=!0){const u=`cylinder|${i}|${s}|${o}|${a}`;if(!this.geometryInHash(u)){const t=new e.Geometry(i,s,(function(){r.call(this,1,1,1,i,s,o,a)}),this);i<=24&&s<=16?t._makeTriangleEdges()._edgesToVertices():this.states.strokeColor&&console.log("Cannot draw stroke on cylinder objects with more than 24 detailX or 16 detailY"),t.gid=u,this.geometryBufferCache.ensureCached(t)}this._drawGeometryScaled(this.geometryBufferCache.getGeometryByID(u),t,n,t)},zo.prototype.cone=function(e=50,t=e,n=24,i=1,s=!0){const o=`cone|${n}|${i}|${s}`;if(!this.geometryInHash(o)){const e=new po(n,i,(function(){r.call(this,1,0,1,n,i,s,!1)}),this);n<=24&&i<=16?e._makeTriangleEdges()._edgesToVertices():this.states.strokeColor&&console.log("Cannot draw stroke on cone objects with more than 24 detailX or 16 detailY"),e.gid=o,this.geometryBufferCache.ensureCached(e)}this._drawGeometryScaled(this.geometryBufferCache.getGeometryByID(o),e,t,e)},zo.prototype.torus=function(e=50,t=10,r=24,n=16){if(0===e)return;if(0===t)return;const i=(t/e).toPrecision(4),s=`torus|${i}|${r}|${n}`;if(!this.geometryInHash(s)){const e=function(){for(let e=0;e<=this.detailY;e++){const t=e/this.detailY,r=2*Math.PI*t,n=Math.cos(r),s=Math.sin(r),o=1+i*n;for(let e=0;e<=this.detailX;e++){const r=e/this.detailX,a=2*Math.PI*r,u=Math.cos(a),l=Math.sin(a),h=new Pi(o*u,o*l,i*s),c=new Pi(n*u,n*l,s);this.vertices.push(h),this.vertexNormals.push(c),this.uvs.push(r,t)}}},t=new po(r,n,e,this);t.computeFaces(),r<=24&&n<=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=s,this.geometryBufferCache.ensureCached(t)}this._drawGeometryScaled(this.geometryBufferCache.getGeometryByID(s),e,e,e)},t.curveDetail=function(e){if(!(this._renderer instanceof zo))throw new Error("curveDetail() only works in WebGL mode. Did you mean to call createCanvas(width, height, WEBGL)?");return this._renderer.curveDetail(e)}}function Ho(e,t){t.ambientLight=function(e,t,r,n){return this._assert3d("ambientLight"),this._renderer.ambientLight(...arguments),this},t.specularColor=function(e,t,r){return this._assert3d("specularColor"),this._renderer.specularColor(...arguments),this},t.directionalLight=function(e,t,r,n,i,s){return this._assert3d("directionalLight"),this._renderer.directionalLight(...arguments),this},t.pointLight=function(e,t,r,n,i,s){return this._assert3d("pointLight"),this._renderer.pointLight(...arguments),this},t.imageLight=function(e){this._renderer.imageLight(e)},t.panorama=function(e){this.filter(this._renderer._getSphereMapping(e))},t.lights=function(){return this._assert3d("lights"),this._renderer.lights(),this},t.lightFalloff=function(e,t,r){return this._assert3d("lightFalloff"),this._renderer.lightFalloff(e,t,r),this},t.spotLight=function(e,t,r,n,i,s,o,a,u,l,h){return this._assert3d("spotLight"),this._renderer.spotLight(...arguments),this},t.noLights=function(...e){return this._assert3d("noLights"),this._renderer.noLights(),this},zo.prototype.ambientLight=function(e,t,r,n){const i=this._pInst.color(...arguments);this.states.setValue("ambientLightColors",[...this.states.ambientLightColors]),this.states.ambientLightColors.push(i._array[0],i._array[1],i._array[2]),this.states.setValue("enableLighting",!0)},zo.prototype.specularColor=function(e,t,r){const n=this._pInst.color(...arguments);this.states.setValue("specularColors",[n._array[0],n._array[1],n._array[2]])},zo.prototype.directionalLight=function(e,t,r,n,i,s){let o,a,u,l;o=e instanceof Tn?e:this._pInst.color(e,t,r);const h=arguments[arguments.length-1];"number"==typeof h?(a=arguments[arguments.length-3],u=arguments[arguments.length-2],l=arguments[arguments.length-1]):(a=h.x,u=h.y,l=h.z);const c=Math.sqrt(a*a+u*u+l*l);this.states.setValue("directionalLightDirections",[...this.states.directionalLightDirections]),this.states.directionalLightDirections.push(a/c,u/c,l/c),this.states.setValue("directionalLightDiffuseColors",[...this.states.directionalLightDiffuseColors]),this.states.directionalLightDiffuseColors.push(o._array[0],o._array[1],o._array[2]),this.states.setValue("directionalLightSpecularColors",[...this.states.directionalLightSpecularColors]),Array.prototype.push.apply(this.states.directionalLightSpecularColors,this.states.specularColors),this.states.setValue("enableLighting",!0)},zo.prototype.pointLight=function(e,t,r,n,i,s){let o,a,u,l;o=e instanceof Tn?e:this._pInst.color(e,t,r);const h=arguments[arguments.length-1];"number"==typeof h?(a=arguments[arguments.length-3],u=arguments[arguments.length-2],l=arguments[arguments.length-1]):(a=h.x,u=h.y,l=h.z),this.states.setValue("pointLightPositions",[...this.states.pointLightPositions]),this.states.pointLightPositions.push(a,u,l),this.states.setValue("pointLightDiffuseColors",[...this.states.pointLightDiffuseColors]),this.states.pointLightDiffuseColors.push(o._array[0],o._array[1],o._array[2]),this.states.setValue("pointLightSpecularColors",[...this.states.pointLightSpecularColors]),Array.prototype.push.apply(this.states.pointLightSpecularColors,this.states.specularColors),this.states.setValue("enableLighting",!0)},zo.prototype.imageLight=function(e){this.states.setValue("activeImageLight",e),this.states.setValue("enableLighting",!0),this.makeDiffusedTexture(e),this.makeSpecularTexture(e)},zo.prototype.lights=function(){const e=this._pInst.color("rgb(128,128,128)");this.ambientLight(e),this.directionalLight(e,0,0,-1)},zo.prototype.lightFalloff=function(e,t,r){e<0&&(e=0,console.warn("Value of constant argument in lightFalloff() should be never be negative. Set to 0.")),t<0&&(t=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.")),0===e&&0===t&&0===r&&(e=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",e),this.states.setValue("linearAttenuation",t),this.states.setValue("quadraticAttenuation",r)},zo.prototype.spotLight=function(e,t,r,n,i,s,o,a,u,l,h){if(this.states.spotLightDiffuseColors.length/3>=4)return;let c,d,p;const f=arguments.length;switch(f){case 11:case 10:c=this._pInst.color(e,t,r),d=new Pi(n,i,s),p=new Pi(o,a,u);break;case 9:e instanceof Tn?(c=e,d=new Pi(t,r,n),p=new Pi(i,s,o),l=a,h=u):n instanceof Pi?(c=this._pInst.color(e,t,r),d=n,p=new Pi(i,s,o),l=a,h=u):o instanceof Pi?(c=this._pInst.color(e,t,r),d=new Pi(n,i,s),p=o,l=a,h=u):(c=this._pInst.color(e,t,r),d=new Pi(n,i,s),p=new Pi(o,a,u));break;case 8:e instanceof Tn?(c=e,d=new Pi(t,r,n),p=new Pi(i,s,o),l=a):n instanceof Pi?(c=this._pInst.color(e,t,r),d=n,p=new Pi(i,s,o),l=a):(c=this._pInst.color(e,t,r),d=new Pi(n,i,s),p=o,l=a);break;case 7:e instanceof Tn&&t instanceof Pi?(c=e,d=t,p=new Pi(r,n,i),l=s,h=o):e instanceof Tn&&i instanceof Pi?(c=e,d=new Pi(t,r,n),p=i,l=s,h=o):n instanceof Pi&&i instanceof Pi?(c=this._pInst.color(e,t,r),d=n,p=i,l=s,h=o):e instanceof Tn?(c=e,d=new Pi(t,r,n),p=new Pi(i,s,o)):n instanceof Pi?(c=this._pInst.color(e,t,r),d=n,p=new Pi(i,s,o)):(c=this._pInst.color(e,t,r),d=new Pi(n,i,s),p=o);break;case 6:n instanceof Pi&&i instanceof Pi?(c=this._pInst.color(e,t,r),d=n,p=i,l=s):e instanceof Tn&&i instanceof Pi?(c=e,d=new Pi(t,r,n),p=i,l=s):e instanceof Tn&&t instanceof Pi&&(c=e,d=t,p=new Pi(r,n,i),l=s);break;case 5:e instanceof Tn&&t instanceof Pi&&r instanceof Pi?(c=e,d=t,p=r,l=n,h=i):n instanceof Pi&&i instanceof Pi?(c=this._pInst.color(e,t,r),d=n,p=i):e instanceof Tn&&i instanceof Pi?(c=e,d=new Pi(t,r,n),p=i):e instanceof Tn&&t instanceof Pi&&(c=e,d=t,p=new Pi(r,n,i));break;case 4:c=e,d=t,p=r,l=n;break;case 3:c=e,d=t,p=r;break;default:return void console.warn(`Sorry, input for spotlight() is not in prescribed format. Too ${f<3?"few":"many"} arguments were provided`)}this.states.setValue("spotLightDiffuseColors",[...this.states.spotLightDiffuseColors,c._array[0],c._array[1],c._array[2]]),this.states.setValue("spotLightSpecularColors",[...this.states.spotLightSpecularColors,...this.states.specularColors]),this.states.setValue("spotLightPositions",[...this.states.spotLightPositions,d.x,d.y,d.z]),p.normalize(),this.states.setValue("spotLightDirections",[...this.states.spotLightDirections,p.x,p.y,p.z]),void 0===l&&(l=Math.PI/3),void 0!==h&&h<1?(h=1,console.warn("Value of concentration needs to be greater than 1. Setting it to 1")):void 0===h&&(h=100),l=this._pInst._toRadians(l),this.states.setValue("spotLightAngle",[...this.states.spotLightAngle,Math.cos(l)]),this.states.setValue("spotLightConc",[...this.states.spotLightConc,h]),this.states.setValue("enableLighting",!0)},zo.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)}}"undefined"!=typeof p5&&Go(p5,p5.prototype),"undefined"!=typeof p5&&$o(p5,p5.prototype),"undefined"!=typeof p5&&Ho(p5,p5.prototype);const qo=Object.getPrototypeOf(Uint8Array);class Wo{constructor(e,t,r,n={}){this._renderer=e,"string"!=typeof t||void 0!==r&&("object"!=typeof r||Array.isArray(r))?(this._vertSrc=t,this._fragSrc=r,this._computeSrc=null):(this.shaderType="compute",this._computeSrc=t,this._vertSrc=null,this._fragSrc=null,"object"==typeof r&&(n=r)),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:n.uniforms||{},storageUniforms:n.storageUniforms||{},declarations:n.declarations,varyingVariables:n.varyingVariables||[],instanceIDVarying:n.instanceIDVarying||null,helpers:n.helpers||{},vertex:n.vertex||{},fragment:n.fragment||{},compute:n.compute||{},hookAliases:n.hookAliases||{},modified:{vertex:n.modified&&n.modified.vertex||{},fragment:n.modified&&n.modified.fragment||{},compute:n.modified&&n.modified.compute||{}}}}hookTypes(e){return this._renderer.getShaderHookTypes(this,e)}shaderSrc(e,t){return this._renderer.populateHooks(this,e,t)}version(){const e=/#version (.+)$/m.exec(this.vertSrc());return e?e[1]:"100 es"}vertSrc(){return"compute"===this.shaderType?null:this.shaderSrc(this._vertSrc,"vertex")}fragSrc(){return"compute"===this.shaderType?null:this.shaderSrc(this._fragSrc,"fragment")}computeSrc(){return"compute"!==this.shaderType?null:this.shaderSrc(this._computeSrc,"compute")}inspectHooks(){if("compute"===this.shaderType){console.log("==== Compute shader hooks: ====");for(const e in this.hooks.compute)console.log((this.hooks.modified.compute[e]?"[MODIFIED] ":"")+e+this.hooks.compute[e])}else{console.log("==== Vertex shader hooks: ====");for(const e in this.hooks.vertex)console.log((this.hooks.modified.vertex[e]?"[MODIFIED] ":"")+e+this.hooks.vertex[e]);console.log(""),console.log("==== Fragment shader hooks: ====");for(const e in this.hooks.fragment)console.log((this.hooks.modified.fragment[e]?"[MODIFIED] ":"")+e+this.hooks.fragment[e])}console.log(""),console.log("==== Helper functions: ====");for(const e in this.hooks.helpers)console.log(e+this.hooks.helpers[e])}modify(e){const t={vertex:{},fragment:{},compute:{},helpers:{}};for(const r in e)"declarations"!==r&&"uniforms"!==r&&"storageUniforms"!==r&&"varyingVariables"!==r&&"instanceIDVarying"!==r&&("vertexDeclarations"===r?t.vertex.declarations=(t.vertex.declarations||"")+"\n"+e[r]:"fragmentDeclarations"===r?t.fragment.declarations=(t.fragment.declarations||"")+"\n"+e[r]:"computeDeclarations"===r?t.compute.declarations=(t.compute.declarations||"")+"\n"+e[r]:this.hooks.vertex[r]?t.vertex[r]=e[r]:this.hooks.fragment[r]?t.fragment[r]=e[r]:this.hooks.compute[r]?t.compute[r]=e[r]:t.helpers[r]=e[r]);const r=Object.assign({},this.hooks.modified.vertex),n=Object.assign({},this.hooks.modified.fragment),i=Object.assign({},this.hooks.modified.compute);for(const e in t.vertex||{})"declarations"!==e&&(r[e]=!0);for(const e in t.fragment||{})"declarations"!==e&&(n[e]=!0);for(const e in t.compute||{})"declarations"!==e&&(i[e]=!0);const s=[this._renderer];return"compute"===this.shaderType?s.push(this._computeSrc):s.push(this._vertSrc,this._fragSrc),s.push({declarations:(this.hooks.declarations||"")+"\n"+(e.declarations||""),uniforms:Object.assign({},this.hooks.uniforms,e.uniforms||{}),storageUniforms:Object.assign({},this.hooks.storageUniforms,e.storageUniforms||{}),varyingVariables:(e.varyingVariables||[]).concat(this.hooks.varyingVariables||[]),instanceIDVarying:e.instanceIDVarying||this.hooks.instanceIDVarying||null,fragment:Object.assign({},this.hooks.fragment,t.fragment||{}),vertex:Object.assign({},this.hooks.vertex,t.vertex||{}),compute:Object.assign({},this.hooks.compute,t.compute||{}),helpers:Object.assign({},this.hooks.helpers,t.helpers||{}),hookAliases:Object.assign({},this.hooks.hookAliases,t.hookAliases||{}),modified:{vertex:r,fragment:n,compute:i}}),new Wo(...s)}init(){if(!this._initialized){try{this._renderer._initShader(this)}catch(e){throw new Error(`Whoops! Something went wrong initializing the shader:\n${e.message||e}`)}"compute"!==this.shaderType&&this._loadAttributes(),this._loadUniforms(),this._renderer._finalizeShader(this),this._initialized=!0}return this}setDefaultUniforms(){for(const e in this.hooks.uniforms){const t=this._renderer.uniformNameFromHookKey(e),r=this.hooks.uniforms[e];let n;n=r instanceof Function?r():r,null!=n&&this.setUniform(t,n)}for(const e in this.hooks.storageUniforms){const t=this.hooks.storageUniforms[e],r=t instanceof Function?t():t;null!=r&&this.setUniform(e,r)}}copyToContext(e){const t=[e._renderer];"compute"===this.shaderType?t.push(this._computeSrc):t.push(this._vertSrc,this._fragSrc),t.push(this.hooks);const r=new Wo(...t);return r.ensureCompiledOnContext(e._renderer),r}ensureCompiledOnContext(e){if(this._compiled&&this._renderer!==e)throw new 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=e?._renderer?.filterRenderer?._renderer||e,this.init())}_loadAttributes(){this._loadedAttributes||(this.attributes=this._renderer._getShaderAttributes(this),this._loadedAttributes=!0)}_loadUniforms(){if(this._loadedUniforms)return;this.uniforms={},this.samplers=[];const e=this._renderer.getUniformMetadata(this);for(const t of e){const e={...t,_cachedData:void 0};e.isSampler&&this.samplers.push(e),this.uniforms[e.name]=e}this._loadedUniforms=!0}bindShader(e,t){if(this.shaderType&&this.shaderType!==e)throw new Error(`You've already used this shader as a ${this.shaderType} shader, but are now using it as a ${e}.`);this.shaderType=e,this.init(),this._bound||(this.useProgram(t),this._bound=!0)}unbindShader(){return this._bound&&(this.unbindTextures(),this._bound=!1),this}bindTextures(){const e=this._renderer._getEmptyTexture();for(const t of this.samplers){if(t.noData)continue;let r=t.texture;(void 0===r||r.isFramebufferTexture&&!r.src.framebuffer.antialias&&r.src.framebuffer===this._renderer.activeFramebuffer())&&(t.texture=r=e),this._renderer._updateTexture(t,r)}}unbindTextures(){for(const e of this.samplers)e.texture?.isFramebufferTexture&&this._renderer._unbindFramebufferTexture(e)}useProgram(e){return this._renderer._curShader!==this&&(this._renderer._useShader(this),this._renderer._curShader=this),this}setUniform(e,t){this.init();const r=this.uniforms[e];if(r){if("uSampler"!==e||this._renderer._settingFillUniforms||(this._userSetSampler=!0),t?.isVector?t=t.values.length!==t.dimensions?t.values.slice(0,t.dimensions):t.values:t?.isColor&&(t=t._getRGBA([1,1,1,1])),r.isArray){if(r._cachedData&&this._renderer._arraysEqual(r._cachedData,t))return;r._cachedData=t.slice(0)}else{if(r._cachedData&&r._cachedData===t)return;if(Array.isArray(t)||t instanceof qo){if(r._cachedData&&this._renderer._arraysEqual(r._cachedData,t))return;r._cachedData=t.slice(0)}else{if(r._cachedData===t)return;r._cachedData=t}}this._renderer.updateUniformValue(this,r,t)}}enableAttrib(e,t,r,n,i,s){return e&&-1!==e.location&&this._renderer._enableAttrib(this,e,t,r,n,i,s),this}}function Xo(e,t){e.Shader=Wo}async function Zo(e){const t=await fetch(e).then((e=>e.text()));return new Function(t)}function Yo(e,t){const r=e._runStrandsInGlobalMode;e._runStrandsInGlobalMode=!0;try{return t()}finally{e._runStrandsInGlobalMode=r}}function Ko(e,t){t.loadShader=async function(e,t,r,n){const i=new Wo;try{return i._vertSrc=(await Bs(e,"text")).data,i._fragSrc=(await Bs(t,"text")).data,r&&r(i)||i}catch(e){if(n)return n(e);throw e}},t.createShader=function(e,t,r){return new Wo(this._renderer,e,t,r)},t.loadFilterShader=async function(e,t,r){try{const r=await this.loadStrings(e),n=await r.join("\n");let i;return i=/void\s+main/.exec(n)?this._internal((()=>this.createFilterShader(n,!0))):this._internal((()=>Yo(this,(()=>this.baseFilterShader().modify(new Function(n)))))),t&&(i=t(i)||i),i}catch(e){r?r(e):console.error(e)}},t.buildFilterShader=function(e,t){return this.baseFilterShader().modify(e,t)},t.createFilterShader=function(e,t=!1){let r=e.includes("#version 300 es")?"#version 300 es\n      uniform mat4 uModelViewMatrix;\n      uniform mat4 uProjectionMatrix;\n\n      in vec3 aPosition;\n      in vec2 aTexCoord;\n      out vec2 vTexCoord;\n\n      void main() {\n        // transferring texcoords for the frag shader\n        vTexCoord = aTexCoord;\n\n        // copy position with a fourth coordinate for projection (1.0 is normal)\n        vec4 positionVec4 = vec4(aPosition, 1.0);\n\n        // project to 3D space\n        gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n      }\n    ":"\n      uniform mat4 uModelViewMatrix;\n      uniform mat4 uProjectionMatrix;\n\n      attribute vec3 aPosition;\n      // texcoords only come from p5 to vertex shader\n      // so pass texcoords on to the fragment shader in a varying variable\n      attribute vec2 aTexCoord;\n      varying vec2 vTexCoord;\n\n      void main() {\n        // transferring texcoords for the frag shader\n        vTexCoord = aTexCoord;\n\n        // copy position with a fourth coordinate for projection (1.0 is normal)\n        vec4 positionVec4 = vec4(aPosition, 1.0);\n\n        // project to 3D space\n        gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n      }\n    ";const n=new Wo(this._renderer,r,e);return t||(this._renderer.GL?n.ensureCompiledOnContext(this._renderer):n.ensureCompiledOnContext(this)),n},t.shader=function(e){return this._assert3d("shader"),this._renderer.shader(e),this},t.strokeShader=function(e){return this._assert3d("strokeShader"),this._renderer.strokeShader(e),this},t.imageShader=function(e){return this._assert3d("imageShader"),this._renderer.imageShader(e),this},t.buildMaterialShader=function(e,t){return this.baseMaterialShader().modify(e,t)},t.loadMaterialShader=async function(e,t,r){try{const r=await Zo(e);let n=this._internal((()=>Yo(this,(()=>this.buildMaterialShader(r)))));return t&&(n=t(n)||n),n}catch(e){console.error(e),r&&r(e)}},t.baseMaterialShader=function(){return this._assert3d("baseMaterialShader"),this._renderer.baseMaterialShader()},t.baseFilterShader=function(){return(this._renderer.filterRenderer||this._renderer).baseFilterShader()},t.buildNormalShader=function(e,t){return this.baseNormalShader().modify(e,t)},t.loadNormalShader=async function(e,t,r){try{const r=await Zo(e);let n=this._internal((()=>this.withGlobalStrands(this,(()=>this.buildNormalShader(r)))));return t&&(n=t(n)||n),n}catch(e){console.error(e),r&&r(e)}},t.baseNormalShader=function(){return this._assert3d("baseNormalShader"),this._renderer.baseNormalShader()},t.buildColorShader=function(e,t){return this.baseColorShader().modify(e,t)},t.loadColorShader=async function(e,t,r){try{const r=await Zo(e);let n=this._internal((()=>Yo(this,(()=>this.buildColorShader(r)))));return t&&(n=t(n)||n),n}catch(e){console.error(e),r&&r(e)}},t.baseColorShader=function(){return this._assert3d("baseColorShader"),this._renderer.baseColorShader()},t.buildStrokeShader=function(e,t){return this.baseStrokeShader().modify(e,t)},t.loadStrokeShader=async function(e,t,r){try{const r=await Zo(e);let n=this._internal((()=>Yo(this,(()=>this.buildStrokeShader(r)))));return t&&(n=t(n)||n),n}catch(e){console.error(e),r&&r(e)}},t.baseStrokeShader=function(){return this._assert3d("baseStrokeShader"),this._renderer.baseStrokeShader()},t.resetShader=function(){return this._renderer.resetShader(),this},t.texture=function(e){return this._assert3d("texture"),e.gifProperties&&e._animateGif(this),this._renderer.texture(e),this},t.textureMode=function(e){if(void 0===e)return this._renderer.states.textureMode;e!==Se&&e!==xe?console.warn(`You tried to set ${e} textureMode only supports IMAGE & NORMAL `):this._renderer.states.setValue("textureMode",e)},t.textureWrap=function(e,t=e){if(void 0===e)return{x:this._renderer.states.textureWrapX,y:this._renderer.states.textureWrapY};if(e.hasOwnProperty("x")&&e.hasOwnProperty("y")&&(t=(e=e.x).y),this._renderer.states.setValue("textureWrapX",e),this._renderer.states.setValue("textureWrapY",t),this._renderer.textures)for(const r of this._renderer.textures.values())r.setWrapMode(e,t);return this},t.normalMaterial=function(...e){return this._assert3d("normalMaterial"),this._renderer.normalMaterial(...e),this},t.ambientMaterial=function(e,r,n){this._assert3d("ambientMaterial");const i=t.color.apply(this,arguments);return this._renderer.states.setValue("_hasSetAmbient",!0),this._renderer.states.setValue("curAmbientColor",i._array),this._renderer.states.setValue("_useNormalMaterial",!1),this._renderer.states.setValue("enableLighting",!0),this._renderer.states.fillColor||this._renderer.states.setValue("fillColor",new Tn([1,1,1])),this},t.emissiveMaterial=function(e,r,n,i){this._assert3d("emissiveMaterial");const s=t.color.apply(this,arguments);return this._renderer.states.setValue("curEmissiveColor",s._array),this._renderer.states.setValue("_useEmissiveMaterial",!0),this._renderer.states.setValue("_useNormalMaterial",!1),this._renderer.states.setValue("enableLighting",!0),this},t.specularMaterial=function(e,r,n,i){this._assert3d("specularMaterial");const s=t.color.apply(this,arguments);return this._renderer.states.setValue("curSpecularColor",s._array),this._renderer.states.setValue("_useSpecularMaterial",!0),this._renderer.states.setValue("_useNormalMaterial",!1),this._renderer.states.setValue("enableLighting",!0),this},t.shininess=function(e){return this._assert3d("shininess"),this._renderer.shininess(e),this},t.metalness=function(e){return this._assert3d("metalness"),this._renderer.metalness(e),this},zo.prototype.shader=function(e){this.states.setValue("userFillShader",e),this.states.setValue("_useNormalMaterial",!1),e.ensureCompiledOnContext(this),e.setDefaultUniforms()},zo.prototype.strokeShader=function(e){this.states.setValue("userStrokeShader",e),e.ensureCompiledOnContext(this),e.setDefaultUniforms()},zo.prototype.imageShader=function(e){this.states.setValue("userImageShader",e),e.ensureCompiledOnContext(this),e.setDefaultUniforms()},zo.prototype.resetShader=function(){this.states.setValue("userFillShader",null),this.states.setValue("userStrokeShader",null),this.states.setValue("userImageShader",null)},zo.prototype.texture=function(e){this.states.setValue("drawMode",Ee),this.states.setValue("_useNormalMaterial",!1),this.states.setValue("_tex",e),this.states.setValue("fillColor",new Tn([1,1,1]))},zo.prototype.normalMaterial=function(...e){this.states.setValue("drawMode",Ce),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 Tn([1,1,1])),this.states.setValue("strokeColor",null)},zo.prototype.shininess=function(e){e<1&&(e=1),this.states.setValue("_useShininess",e)},zo.prototype.metalness=function(e){const t=1-Math.exp(-e/100);this.states.setValue("_useMetalness",t)}}function Jo(e,t){const r=t.DEGREES="degrees",n=t.RADIANS="radians";t._angleMode=n,t.acos=function(e){return this._fromRadians(Math.acos(e))},t.asin=function(e){return this._fromRadians(Math.asin(e))},t.atan=function(e){return this._fromRadians(Math.atan(e))},t.atan2=function(e,t){return this._fromRadians(Math.atan2(e,t))},t.cos=function(e){return Math.cos(this._toRadians(e))},t.sin=function(e){return Math.sin(this._toRadians(e))},t.tan=function(e){return Math.tan(this._toRadians(e))},t.degrees=e=>e*_,t.radians=e=>e*x,t.angleMode=function(e){if(void 0===e)return this._angleMode;if(e===r||e===n){if(e===this._angleMode)return;e===n?(this.pRotationX=this.pRotationX*x,this.pRotationY=this.pRotationY*x,this.pRotationZ=this.pRotationZ*x):(this.pRotationX=this.pRotationX*_,this.pRotationY=this.pRotationY*_,this.pRotationZ=this.pRotationZ*_),this._angleMode=e}},t._toRadians=function(e){return void 0!==e&&this._angleMode===r?e*x:e},t._toDegrees=function(e){return this._angleMode===n?e*_:e},t._fromRadians=function(e){return this._angleMode===r?e*_:e},t._fromDegrees=function(e){return this._angleMode===n?e*x:e}}"undefined"!=typeof p5&&Xo(p5),"undefined"!=typeof p5&&loading(p5,p5.prototype),"undefined"!=typeof p5&&Jo(p5,p5.prototype);class Qo{constructor(e,t,r,i,s){const o=r||n;return this._pInst=i,this._renderer=new fa[o](this,e,t,!1,s),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(e){let t;return"number"==typeof e?(e!==this._renderer._pixelDensity&&(this._renderer._pixelDensity=e),t=this,this.resizeCanvas(this.width,this.height,!0)):t=this._renderer._pixelDensity,t}resizeCanvas(e,t){this._renderer.resize(e,t)}reset(){this._renderer.resetMatrix(),this._renderer.isP3D&&this._renderer._update()}remove(){this._renderer.remove(),this._renderer=void 0}createFramebuffer(e){return new ma(this._renderer,e)}_assert3d(e){if(!this._renderer.isP3D)throw new Error(`${e}() 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={}}}class ea{constructor(e,t,r={}){this._renderer=e,this.src=t,this.format=r.format||"rgba8unorm",this.minFilter=r.minFilter||we,this.magFilter=r.magFilter||we,this.wrapS=r.wrapS||e.states.textureWrapX,this.wrapT=r.wrapT||e.states.textureWrapY,this.dataType=r.dataType||"uint8",this.textureHandle=null,this._detectSourceType();const n=this._getTextureDataFromSource();this.width=n.width,this.height=n.height,this.init(n)}_detectSourceType(){const e=this.src;this.isFramebufferTexture=e instanceof pa,this.isSrcP5Image=e instanceof Mi,this.isSrcP5Graphics=e instanceof Qo,this.isSrcP5Renderer=e instanceof ps,this.isImageData="undefined"!=typeof ImageData&&e instanceof ImageData,this.isSrcMediaElement=void 0!==ys&&e instanceof ys,this.isSrcHTMLElement=void 0!==Ei&&e instanceof Ei&&!this.isSrcMediaElement&&!this.isSrcP5Graphics&&!this.isSrcP5Renderer}remove(){this.textureHandle&&(this._renderer.deleteTexture(this.textureHandle),this.textureHandle=null)}_getTextureDataFromSource(){let e;return this.isFramebufferTexture?e=this.src.rawTexture():this.isSrcP5Image?e=this.src.canvas:this.isSrcMediaElement||this.isSrcHTMLElement?this.isSrcMediaElement&&this.src.flipped?(this.src._ensureCanvas(),e=this.src.canvas):(this.src._checkIfTextureNeedsUpdate&&this.src._checkIfTextureNeedsUpdate(),e=this.src.elt):this.isSrcP5Graphics||this.isSrcP5Renderer?e=this.src.canvas:this.isImageData&&(e=this.src),e}init(e){this.isFramebufferTexture?this.textureHandle=this._renderer.createFramebufferTextureHandle(this.src):this.textureHandle=this._renderer.createTexture({format:this.format,dataType:this.dataType,width:e.width,height:e.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,new Uint8Array(1,1,1,1),1,1):this.isFramebufferTexture||this._renderer.uploadTextureFromSource(this.textureHandle,e),this.unbindTexture()}_shouldDeferUpload(){return 0===this.width||0===this.height||this.isSrcMediaElement&&!this.src.loadedmetadata}update(){const e=this._getTextureDataFromSource();if(!e)return!1;let t=!1;return this._shouldUpdate(e)&&(this.bindTexture(),this._renderer.uploadTextureFromSource(this.textureHandle,e),t=!0),t}_shouldUpdate(e){const t=this.src;if(0===t.width||0===t.height)return!1;if(this.isFramebufferTexture)return this.src.update(),!1;let r=!1;return e.width!==this.width||e.height!==this.height?(r=!0,this.width=e.width||t.width,this.height=e.height||t.height,this.isSrcP5Image?t.setModified(!1):(this.isSrcMediaElement||this.isSrcHTMLElement)&&t.setModified&&t.setModified(!0)):this.isSrcP5Image?(t.gifProperties&&t._animateGif(this._renderer._pInst),t.isModified()&&(r=!0,t.setModified(!1))):this.isSrcMediaElement?t.isModified()?(r=!0,t.setModified(!1)):t.loadedmetadata&&this._videoPrevUpdateTime!==t.time()&&(this._videoPrevUpdateTime=t.time(),r=!0):this.isImageData?t._dirty&&(t._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(e,t){this.minFilter=e,this.magFilter=t,this._renderer.setTextureParams(this)}setWrapMode(e,t){this.wrapS=e,this.wrapT=t,this._renderer.setTextureParams(this)}}class ta extends ea{constructor(e,t,r={}){super(e,t,{minFilter:we,magFilter:we,...r}),this.levels=t}_getTextureDataFromSource(){return this.src}init(e){if(Array.isArray(e)){const t=e[0];this.width=t.width,this.height=t.height,this.textureHandle=this._renderer.createMipmapTextureHandle({levels:e,format:this.format,dataType:this.dataType,width:this.width,height:this.height})}else this.width=e.size,this.height=e.size,this.textureHandle=this._renderer.createMipmapTextureHandle({gpuTexture:e.gpuTexture,format:e.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 ra(e,t){e.Texture=ea,e.MipmapTexture=ta}function na(e,t,r,n,i,s,o,a,u,l){const h=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,r);const c=a===t.RGBA?4:3,d=s*o*c,p=u===t.UNSIGNED_BYTE?Uint8Array:Float32Array;if(e instanceof p&&e.length===d||(e=new p(d)),t.readPixels(n,l?l-i-o:i,s,o,a,u,e),t.bindFramebuffer(t.FRAMEBUFFER,h),l){const t=Math.floor(o/2),r=new p(s*c);for(let n=0;n<t;n++){const t=n*s*4,i=(o-n-1)*s*4;r.set(e.subarray(t,t+4*s)),e.copyWithin(t,i,i+4*s),e.set(r,i)}}return e}function ia(e,t,r,n,i,s,o){const a=e.getParameter(e.FRAMEBUFFER_BINDING);e.bindFramebuffer(e.FRAMEBUFFER,t);const u=i===e.RGBA?4:3,l=new(s===e.UNSIGNED_BYTE?Uint8Array:Float32Array)(u);return e.readPixels(r,o?o-n-1:n,1,1,i,s,l),e.bindFramebuffer(e.FRAMEBUFFER,a),Array.from(l)}function sa(e,t,r){e.bindTexture();const n=e.minFilter===De?t.NEAREST:e.minFilter===Ae?t.LINEAR_MIPMAP_LINEAR:t.LINEAR,i=e.magFilter===De?t.NEAREST:t.LINEAR,o=e=>!(e&e-1),a=e._getTextureDataFromSource();let u,l;a.naturalWidth&&a.naturalHeight?(u=a.naturalWidth,l=a.naturalHeight):(u=e.width,l=e.height);const h=o(u),c=o(l);let d,p;e.wrapS===Te?r===s||h&&c?d=t.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"),d=t.CLAMP_TO_EDGE):e.wrapS===Ie?r===s||h&&c?d=t.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"),d=t.CLAMP_TO_EDGE):d=t.CLAMP_TO_EDGE,e.wrapT===Te?r===s||h&&c?p=t.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=t.CLAMP_TO_EDGE):e.wrapT===Ie?r===s||h&&c?p=t.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=t.CLAMP_TO_EDGE):p=t.CLAMP_TO_EDGE,t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,n),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,d),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,p),e.unbindTexture()}function oa(e,t,r,n,i){const s=t.location;switch(e.useProgram(),t.type){case i.BOOL:!0===r?i.uniform1i(s,1):i.uniform1i(s,0);break;case i.INT:t.size>1?r.length&&i.uniform1iv(s,r):i.uniform1i(s,r);break;case i.FLOAT:t.size>1?r.length&&i.uniform1fv(s,r):i.uniform1f(s,r);break;case i.FLOAT_MAT2:i.uniformMatrix2fv(s,!1,r);break;case i.FLOAT_MAT3:i.uniformMatrix3fv(s,!1,r);break;case i.FLOAT_MAT4:i.uniformMatrix4fv(s,!1,r);break;case i.FLOAT_VEC2:t.size>1?r.length&&i.uniform2fv(s,r):i.uniform2f(s,r[0],r[1]);break;case i.FLOAT_VEC3:t.size>1?r.length&&i.uniform3fv(s,r):i.uniform3f(s,r[0],r[1],r[2]);break;case i.FLOAT_VEC4:t.size>1?r.length&&i.uniform4fv(s,r):i.uniform4f(s,r[0],r[1],r[2],r[3]);break;case i.INT_VEC2:t.size>1?r.length&&i.uniform2iv(s,r):i.uniform2i(s,r[0],r[1]);break;case i.INT_VEC3:t.size>1?r.length&&i.uniform3iv(s,r):i.uniform3i(s,r[0],r[1],r[2]);break;case i.INT_VEC4:t.size>1?r.length&&i.uniform4iv(s,r):i.uniform4i(s,r[0],r[1],r[2],r[3]);break;case i.SAMPLER_2D:if("number"==typeof r){if(r<i.TEXTURE0||r>i.TEXTURE31||r!==Math.ceil(r))return void console.log("🌸 p5.js says: You're trying to use a number as the data for a texture.Please use a texture.");i.activeTexture(r),i.uniform1i(s,r)}else i.activeTexture(i.TEXTURE0+t.samplerIndex),t.texture=r instanceof ea?r:n(r),i.uniform1i(s,t.samplerIndex);break;case i.SAMPLER_CUBE:case i.SAMPLER_3D:case i.SAMPLER_2D_SHADOW:case i.SAMPLER_2D_ARRAY:case i.SAMPLER_2D_ARRAY_SHADOW:case i.SAMPLER_CUBE_SHADOW:case i.INT_SAMPLER_2D:case i.INT_SAMPLER_3D:case i.INT_SAMPLER_CUBE:case i.INT_SAMPLER_2D_ARRAY:case i.UNSIGNED_INT_SAMPLER_2D:case i.UNSIGNED_INT_SAMPLER_3D:case i.UNSIGNED_INT_SAMPLER_CUBE:case i.UNSIGNED_INT_SAMPLER_2D_ARRAY:if("number"!=typeof r)break;if(r<i.TEXTURE0||r>i.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}i.activeTexture(r),i.uniform1i(s,r)}}function aa(e,t){const r=e._glProgram,n=t.getProgramParameter(r,t.ACTIVE_UNIFORMS),i=[];let s=0;for(let e=0;e<n;++e){const n=t.getActiveUniform(r,e),o={};o.location=t.getUniformLocation(r,n.name),o.size=n.size;let a=n.name;n.size>1&&(a=a.substring(0,a.indexOf("[0]"))),o.name=a,o.type=n.type,o._cachedData=void 0,o.type===t.SAMPLER_2D&&(o.isSampler=!0,o.samplerIndex=s,s++),o.isArray=n.size>1||o.type===t.FLOAT_MAT2||o.type===t.FLOAT_MAT3||o.type===t.FLOAT_MAT4||o.type===t.FLOAT_VEC2||o.type===t.FLOAT_VEC3||o.type===t.FLOAT_VEC4||o.type===t.INT_VEC2||o.type===t.INT_VEC4||o.type===t.INT_VEC3,i.push(o)}return i}function ua(e,t){const r={},n=t.getProgramParameter(e._glProgram,t.ACTIVE_ATTRIBUTES);for(let i=0;i<n;++i){const n=t.getActiveAttrib(e._glProgram,i),s=n.name,o=t.getAttribLocation(e._glProgram,s),a={};a.name=s,a.location=o,a.index=i,a.type=n.type,a.size=n.size,r[s]=a}return r}function la(e,t,r){const n="void main";if(!t.includes(n))return t;let[i,s]=t.split(n),o="",a="";for(const t in e.hooks.uniforms)o+=`uniform ${t};\n`;if(e.hooks.declarations&&(o+=e.hooks.declarations+"\n"),e.hooks[r].declarations&&(o+=e.hooks[r].declarations+"\n"),e.hooks.varyingVariables&&e.hooks.varyingVariables.length>0)for(const t of e.hooks.varyingVariables)"vertex"===r?o+=`OUT ${t};\n`:"fragment"===r&&(o+=`IN ${t};\n`);if(e.hooks.instanceIDVarying){const{declaration:t,source:n,interpolation:i}=e.hooks.instanceIDVarying,a=i?`${i} `:"";"vertex"===r?(o+=`${a}OUT ${t};\n`,s=s.replace(/\{/,`{\n  ${t.split(" ").pop()} = ${n};`)):"fragment"===r&&(o+=`${a}IN ${t};\n`)}for(const t in e.hooks.helpers)o+=`${t}${e.hooks.helpers[t]}\n`;for(const t in e.hooks[r]){if("declarations"===t)continue;const[n,i]=t.split(" ");(e.hooks.modified.vertex[t]||e.hooks.modified.fragment[t])&&(a+="#define AUGMENTED_HOOK_"+i+"\n"),o+=n+" HOOK_"+i+e.hooks[r][t]+"\n"}return-1!==i.indexOf("#define HOOK_DEFINES")&&(i=i.replace("#define HOOK_DEFINES","\n"+a+"\n"),a=""),i+"\n"+a+o+n+s}function ha({GL:e,webglVersion:t}){const r=e,n=t===s?r.getExtension("EXT_color_buffer_float")&&r.getExtension("EXT_float_blend"):r.getExtension("OES_texture_float"),i=n&&r.getExtension("OES_texture_float_linear"),o=t===s?r.getExtension("EXT_color_buffer_float"):r.getExtension("OES_texture_half_float");return{float:n,floatLinear:i,halfFloat:o,halfFloatLinear:o&&r.getExtension("OES_texture_half_float_linear")}}"undefined"!=typeof p5&&ra(p5);const ca=(e,t,r)=>Math.max(Math.min(e,r),t);class da extends vo{constructor(e){super(e.renderer),this.fbo=e,this.yScale=e.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(){const e=super.copy();return e.fbo=this.fbo,e}}class pa{constructor(e,t){this.framebuffer=e,this.property=t}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]}}}let fa,ma=class{constructor(e,t={}){if(this.renderer=e,this.renderer.framebuffers.add(this),this._isClipApplied=!1,this._useCanvasFormat=t._useCanvasFormat||!1,this.dirty={colorTexture:!1,depthTexture:!1},this.pixels=[],this.format=t.format||Ve,this.channels=t.channels||(this.renderer.defaultFramebufferAlpha()?Vn:In),this.useDepth=void 0===t.depth||t.depth,this.depthFormat=t.depthFormat||ze,this.textureFiltering=t.textureFiltering||we,void 0===t.antialias?this.antialiasSamples=this.renderer.defaultFramebufferAntialias()?2:0:"number"==typeof t.antialias?this.antialiasSamples=t.antialias:this.antialiasSamples=t.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=t.density||this.renderer._pixelDensity,t.width&&t.height){const e=this.renderer._adjustDimensions(t.width,t.height,this.density);this.width=e.adjustedWidth,this.height=e.adjustedHeight,this._autoSized=!1}else void 0===t.width!=(void 0===t.height)&&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),t.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&&(void 0===t.stencil||t.stencil),this.renderer.createFramebufferResources(this),this._recreateTextures(),this.defaultCamera=this.createCamera(),this.filterCamera=this.createCamera(),this.draw((()=>this.renderer.clear()))}resize(e,t){this._autoSized=!1;const r=this.renderer._adjustDimensions(e,t,this.density);e=r.adjustedWidth,t=r.adjustedHeight,this.width=e,this.height=t,this._handleResize()}pixelDensity(e){if(!e)return this.density;this._autoSized=!1,this.density=e,this._handleResize()}autoSized(e){if(void 0===e)return this._autoSized;this._autoSized=e,this._handleResize()}_checkIfFormatsAvailable(){const e=this.gl;this.useDepth&&this.renderer.webglVersion===i&&!e.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===i&&this.depthFormat===ze&&(console.warn("FLOAT depth format is unavailable in WebGL 1. Defaulting to UNSIGNED_INT."),this.depthFormat=Ue),[Ve,ze,je].includes(this.format)||(console.warn("Unknown Framebuffer format. Please use UNSIGNED_BYTE, FLOAT, or HALF_FLOAT. Defaulting to UNSIGNED_BYTE."),this.format=Ve),this.useDepth&&![Ue,ze].includes(this.depthFormat)&&(console.warn("Unknown Framebuffer depth format. Please use UNSIGNED_INT or FLOAT. Defaulting to FLOAT."),this.depthFormat=ze);const t=ha(this.renderer);t.float||this.format!==ze||(console.warn("This environment does not support FLOAT textures. Falling back to UNSIGNED_BYTE."),this.format=Ve),this.useDepth&&!t.float&&this.depthFormat===ze&&(console.warn("This environment does not support FLOAT depth textures. Falling back to UNSIGNED_INT."),this.depthFormat=Ue),t.halfFloat||this.format!==je||(console.warn("This environment does not support HALF_FLOAT textures. Falling back to UNSIGNED_BYTE."),this.format=Ve),this.channels===In&&[ze,je].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=Vn)}_deleteTextures(){this.renderer.deleteFramebufferTextures(this)}_recreateTextures(){if(this._updateSize(),this.renderer.recreateFramebufferTextures(this),this.useDepth){this.depth=new pa(this,"depthTexture");const e=De;this.depthP5Texture=new ea(this.renderer,this.depth,{minFilter:e,magFilter:e}),this.renderer.textures.set(this.depth,this.depthP5Texture)}this.color=new pa(this,"colorTexture");const e=this.textureFiltering===we?we:De;this.colorP5Texture=new ea(this.renderer,this.color,{minFilter:e,magFilter:e}),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(){const e=new da(this);return e._computeCameraDefaultSettings(),e._setDefaultCamera(),e}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(e){this.dirty[e]&&(this.renderer.updateFramebufferTexture(this,e),this.dirty[e]=!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(){this.renderer.pop();if(this.renderer.activeFramebuffers.pop()!==this)throw new 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(e){this.begin(),e(),this.end()}loadPixels(){this._update("colorTexture");const e=this.renderer.readFramebufferPixels(this);return e&&"function"==typeof e.then?e.then((e=>(this.pixels=e,e))):(this.pixels=e,e)}get(e,t,r,n){if(this._update("colorTexture"),void 0===e&&void 0===t)e=0,t=0,r=this.width,n=this.height;else if(void 0===r&&void 0===n)return(e<0||t<0||e>=this.width||t>=this.height)&&(console.warn("The x and y values passed to p5.Framebuffer.get are outside of its range and will be clamped."),e=ca(e,0,this.width-1),t=ca(t,0,this.height-1)),this.renderer.readFramebufferPixel(this,e*this.density,t*this.density);return e=ca(e,0,this.width-1),t=ca(t,0,this.height-1),r=ca(r,1,this.width-e),n=ca(n,1,this.height-t),this.renderer.readFramebufferRegion(this,e,t,r,n)}updatePixels(){this.renderer.updateFramebufferPixels(this)}};function ga(e,t){e.FramebufferCamera=da,e.FramebufferTexture=pa,e.Framebuffer=ma}function ya(e,t){e.renderers||(e.renderers={}),fa=e.renderers,t.createCanvas=function(t,r,i,...s){let a=n;return Reflect.ownKeys(fa).includes(i)?a=i:s.unshift(i),fa[a]||(a===o?e._friendlyError("To create a WEBGPU canvas, remember to add the WebGPU add-on to your project."):e._friendlyError(`We weren't able to find a renderer called ${a}.`)),this._renderer&&this._renderer.remove(),this._renderer=new fa[a](this,t,r,!0,...s),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)):this._renderer},t.resizeCanvas=function(e,t,r){this._renderer&&(this._renderer.resize(e,t),r||this.redraw()),this._addAccsOutput()&&this._updateAccsOutput()},t.noCanvas=function(){this.canvas&&this.canvas.parentNode.removeChild(this.canvas)},t.createGraphics=function(t,r,...i){return i[0]instanceof HTMLCanvasElement&&(i[1]=i[0],i[0]=n),new e.Graphics(t,r,i[0],this,i[1])},t.createFramebuffer=function(e){return new ma(this._renderer,e)},t.clearDepth=function(e){this._assert3d("clearDepth"),this._renderer.clearDepth(e)}}"undefined"!=typeof p5&&ga(p5),"undefined"!=typeof p5&&ya(p5,p5.prototype);var va="precision highp float;\n\nuniform sampler2D tex0;\nuniform vec2 canvasSize;\nuniform vec2 texelSize;\n\nIN vec2 vTexCoord;\n\nstruct FilterInputs {\n  vec2 texCoord;\n  vec2 canvasSize;\n  vec2 texelSize;\n};\n\nvoid main(void) {\n  FilterInputs inputs;\n  inputs.texCoord = vTexCoord;\n  inputs.canvasSize = canvasSize;\n  inputs.texelSize = texelSize;\n  OUT_COLOR = HOOK_getColor(inputs, tex0);\n  OUT_COLOR.rgb *= outColor.a;\n}\n",ba="precision highp int;\n\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nIN vec3 aPosition;\nIN vec2 aTexCoord;\nOUT vec2 vTexCoord;\n\nvoid main() {\n  // transferring texcoords for the frag shader\n  vTexCoord = aTexCoord;\n\n  // copy position with a fourth coordinate for projection (1.0 is normal)\n  vec4 positionVec4 = vec4(aPosition, 1.0);\n\n  // project to 3D space\n  gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n}\n",xa="#ifdef WEBGL2\n\n#define IN in\n#define OUT out\n\n#ifdef FRAGMENT_SHADER\nout vec4 outColor;\n#define OUT_COLOR outColor\n#endif\n#define TEXTURE texture\n\n#else\n\n#ifdef FRAGMENT_SHADER\n#define IN varying\n#else\n#define IN attribute\n#endif\n#define OUT varying\n#define TEXTURE texture2D\n\n#ifdef FRAGMENT_SHADER\n#define OUT_COLOR gl_FragColor\n#endif\n\n#endif\n\nvec4 getTexture(in sampler2D content, vec2 coord) {\n  vec4 color = TEXTURE(content, coord);\n  if (color.a > 0.) color.rgb /= color.a;\n  return color;\n}\n",_a='// _p5_hash: "Hash without Sine" by Dave Hoskins (https://www.shadertoy.com/view/4djSRW)\n// Mixing constants: R₂ sequence by Martin Roberts (https://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/)\n//   α₁ = 1/φ₂ = 0.7548776662 (plastic constant reciprocal)\n//   α₂ = 1/φ₂² = 0.5698402910\n//   1/φ = 0.6180339887 (golden ratio conjugate)\n\nint _p5_randomCallIndex = 0;\n\nfloat _p5_hash(vec3 p) {\n  p = fract(p * vec3(0.1031, 0.1030, 0.0973));\n  p += dot(p, p.yxz + 33.33);\n  return fract((p.x + p.y) * p.z);\n}\n\nfloat random(float seed) {\n  vec2 pixelCoord = gl_FragCoord.xy;\n  float callIndex = float(_p5_randomCallIndex);\n  _p5_randomCallIndex += 1;\n  // fract(seed * α₁) normalizes large seeds (e.g. performance.now()) into [0,1)\n  // and spreads them optimally via the R₂ sequence\'s plastic constant\n  float s = fract(seed * 0.7548776662);\n  return _p5_hash(vec3(\n    pixelCoord.x + s,\n    pixelCoord.y + callIndex * 0.5698402910,\n    s + callIndex * 0.6180339887\n  ));\n}\n',wa='// _p5_hash: "Hash without Sine" by Dave Hoskins (https://www.shadertoy.com/view/4djSRW)\n// Mixing constants: R₂ sequence by Martin Roberts (https://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/)\n//   α₁ = 1/φ₂ = 0.7548776662 (plastic constant reciprocal)\n//   α₂ = 1/φ₂² = 0.5698402910\n//   1/φ = 0.6180339887 (golden ratio conjugate)\n\nint _p5_randomCallIndex = 0;\n\nfloat _p5_hash(vec3 p) {\n  p = fract(p * vec3(0.1031, 0.1030, 0.0973));\n  p += dot(p, p.yxz + 33.33);\n  return fract((p.x + p.y) * p.z);\n}\n\nfloat random(float seed) {\n  float vid = float(gl_VertexID);\n  float callIndex = float(_p5_randomCallIndex);\n  _p5_randomCallIndex += 1;\n  float s = fract(seed * 0.7548776662);\n  return _p5_hash(vec3(\n    vid + s,\n    vid * 0.5698402910 + callIndex * 0.6180339887,\n    s + callIndex * 0.7548776662\n  ));\n}\n';function Ca(e){throw new Error(`[p5.strands internal error]: ${e}`)}function Ea(e,t){throw new Error(`[p5.strands ${e}]: ${t}`)}function Sa(e,t,r){Ea("dimension mismatch",`Cannot assign a value of dimension ${t} to \`${r}\`, which expects dimension ${e}.`)}function Aa(){return{nextID:0,cache:new Map,nodeTypes:[],baseTypes:[],dimensions:[],opCodes:[],values:[],identifiers:[],phiBlocks:[],dependsOn:[],usedBy:[],statementTypes:[],swizzles:[]}}function Da(e,t){const r=function(e,t){const r=e.nextID++;e.nodeTypes[r]=t.nodeType,e.opCodes[r]=t.opCode,e.values[r]=t.value,e.identifiers[r]=t.identifier,e.dependsOn[r]=t.dependsOn.slice(),e.usedBy[r]=t.usedBy,e.phiBlocks[r]=t.phiBlocks.slice(),e.baseTypes[r]=t.baseType,e.dimensions[r]=t.dimension,e.statementTypes[r]=t.statementType,e.swizzles[r]=t.swizzle;for(const n of t.dependsOn)Array.isArray(e.usedBy[n])||(e.usedBy[n]=[]),e.usedBy[n].push(r);return r}(e,t);return r}function Ta(e={}){const t={nodeType:e.nodeType??null,baseType:e.baseType??null,dimension:e.dimension??null,opCode:e.opCode??null,value:e.value??null,identifier:e.identifier??null,statementType:e.statementType??null,swizzle:e.swizzle??null,dependsOn:Array.isArray(e.dependsOn)?e.dependsOn:[],usedBy:Array.isArray(e.usedBy)?e.usedBy:[],phiBlocks:Array.isArray(e.phiBlocks)?e.phiBlocks:[]};return function(e){const t=e.nodeType,r=Hn[t];2===r.length&&Ca(`Required fields for node type '${$n[t]}' not defined. Please add them to the utils.js file in p5.strands!`);const n=[];for(const t of r)null===e[t]&&n.push(t);if(e.dependsOn?.some((e=>void 0===e)))throw new Error("Undefined dependency!");n.length>0&&Ca(`Missing fields ${n.join(", ")} for a node type '${$n[t]}'.`)}(t),t}function Fa(e,t){return{id:t,nodeType:e.nodeTypes[t],opCode:e.opCodes[t],value:e.values[t],identifier:e.identifiers[t],dependsOn:e.dependsOn[t],usedBy:e.usedBy[t],phiBlocks:e.phiBlocks[t],dimension:e.dimensions[t],baseType:e.baseTypes[t],statementType:e.statementTypes[t],swizzle:e.swizzles[t]}}function Ia(e,t){return{baseType:e.baseTypes[t],dimension:e.dimensions[t],priority:si[e.baseTypes[t]]}}function ka(e,t,r,n,i=new Set){if(i.has(t))return;i.add(t);const s=Fa(e,t);if(s.baseType===ri&&(e.baseTypes[t]=r,e.dimensions[t]=n,s.dependsOn&&s.dependsOn.length>0))for(const t of s.dependsOn){Fa(e,t).baseType===ri&&ka(e,t,r,n,i)}}function Na(e,t){e.blockStack.push(t),e.blockOrder.push(t),e.currentBlock=t}function Ma(e){e.blockStack.pop();const t=e.blockStack.length;e.currentBlock=e.blockStack[t-1]}function Oa(e,t){e.blockStack.push(t),e.currentBlock=t}function Ba(e,t){const r=e.nextID++;return e.blockTypes[r]=t,e.incomingEdges[r]=[],e.outgoingEdges[r]=[],e.blockInstructions[r]=[],r}function La(e,t,r){e.outgoingEdges[t].push(r),e.incomingEdges[r].push(t)}function Pa(e,t,r){void 0===r&&Ca("undefined nodeID in `recordInBasicBlock()`"),void 0===t&&Ca("undefined blockID in `recordInBasicBlock()"),e.blockInstructions[t]=e.blockInstructions[t]||[],e.blockInstructions[t].push(r)}function Ra(e,t){const r=new Set,n=[];return function t(i){if(!r.has(i)){r.add(i);for(let r of e[i].sort(((e,t)=>t-e))||[])t(r);n.push(i)}}(t),n.reverse()}class Va{constructor(e,t,r){this.id=e,this.strandsContext=r,this.dimension=t,this.structProperties=null,this._schema=null,this.isStrandsNode=!0;const n=Fa(this.strandsContext.dag,this.id);n&&n.identifier&&(this._originalIdentifier=n.identifier),n&&(this._originalBaseType=n.baseType,this._originalDimension=n.dimension)}withStructProperties(e){return this.structProperties=e,this}copy(){return Ua(this.id,this.dimension,this.strandsContext)}typeInfo(){return{baseType:this._originalBaseType||Kn,dimension:this.dimension}}bridge(e){const{dag:t,cfg:r}=this.strandsContext,n=Fa(t,this.id),i=n?.baseType??Kn;let s;if(e?.isStrandsNode)s=e.id;else{s=Za(this.strandsContext,{baseType:i,dimension:this.dimension},e).id}if(this._originalIdentifier){const n=e?.isStrandsNode?e.dimension:Array.isArray(e)?e.length:1;n!==this._originalDimension&&1!==n&&Sa(this._originalDimension,n,this._originalIdentifier);const{id:i}=Ga(this.strandsContext,{baseType:this._originalBaseType,dimension:this._originalDimension},this._originalIdentifier),o=Da(t,Ta({nodeType:zn.ASSIGNMENT,dependsOn:[i,s],phiBlocks:[]}));Pa(r,r.currentBlock,o);const a=Da(t,Ta({nodeType:zn.VARIABLE,baseType:this._originalBaseType,dimension:this._originalDimension,identifier:this._originalIdentifier}));this.id=a}else this.id=s;return this}bridgeSwizzle(e,t){const{dag:r,cfg:n}=this.strandsContext,i=Fa(r,this.id),s=i?.baseType??Kn;let o;if(t?.isStrandsNode)o=t.id;else{o=Za(this.strandsContext,{baseType:s,dimension:this.dimension},t).id}if(this._originalIdentifier){const i=t?.isStrandsNode?t.dimension:Array.isArray(t)?t.length:1;i!==e.length&&1!==i&&Sa(e.length,i,`${this._originalIdentifier}.${e}`);const{id:s}=Ga(this.strandsContext,{baseType:this._originalBaseType,dimension:this._originalDimension},this._originalIdentifier),a=Da(r,Ta({nodeType:zn.OPERATION,opCode:di.SWIZZLE,baseType:this._originalBaseType,dimension:e.length,swizzle:e,dependsOn:[s]})),u=Da(r,Ta({nodeType:zn.ASSIGNMENT,dependsOn:[a,o],phiBlocks:[]}));Pa(n,n.currentBlock,u);const l=Da(r,Ta({nodeType:zn.VARIABLE,baseType:this._originalBaseType,dimension:this._originalDimension,identifier:this._originalIdentifier}));this.id=l}else this.id=o;return this}getValue(){if(this._originalIdentifier){const{id:e,dimension:t}=Ga(this.strandsContext,{baseType:this._originalBaseType,dimension:this._originalDimension},this._originalIdentifier);return Ua(e,t,this.strandsContext)}return this}get(e){if("storage"===Fa(this.strandsContext.dag,this.id).baseType&&this._schema)return eu(this.strandsContext,this,e,this._schema);const{id:t,dimension:r}=function(e,t,r){const{dag:n,cfg:i}=e;let s;if(r instanceof Va)s=r;else{const{id:t,dimension:n}=Za(e,{baseType:Jn,dimension:1},r);s=Ua(t,n,e)}const o=Ta({nodeType:zn.OPERATION,opCode:ci.ARRAY_ACCESS,dependsOn:[t.id,s.id],dimension:1,baseType:Kn}),a=Da(n,o);return Pa(i,i.currentBlock,a),{id:a,dimension:1}}(this.strandsContext,this,e);return Ua(t,r,this.strandsContext)}set(e,t){if("storage"!==Fa(this.strandsContext.dag,this.id).baseType)throw new Error("set() can only be used on storage buffers");if(!this._originalIdentifier)throw new Error("set() can only be used on storage buffers with an identifier");if(null!==t&&"object"==typeof t&&!t.isStrandsNode&&this._schema){const r=eu(this.strandsContext,this,e,this._schema);for(const[e,n]of Object.entries(t))r[e]=n;return this}return function(e,t,r,n){const{dag:i,cfg:s}=e;let o,a;if(r instanceof Va)o=r;else{const{id:t,dimension:n}=Za(e,{baseType:Jn,dimension:1},r);o=Ua(t,n,e)}if(n instanceof Va)a=n;else{const{id:t,dimension:r}=Za(e,{baseType:Kn,dimension:1},n);a=Ua(t,r,e)}const u=Ta({nodeType:zn.OPERATION,opCode:ci.ARRAY_ACCESS,dependsOn:[t.id,o.id],dimension:1,baseType:Kn}),l=Da(i,u),h=Ta({nodeType:zn.ASSIGNMENT,dependsOn:[l,a.id],phiBlocks:[]}),c=Da(i,h);Pa(s,s.currentBlock,c)}(this.strandsContext,this,e,t),this}}function Ua(e,t,r,n){return new Proxy(new Va(e,t,r),function(e,t,r,n){const i=[["x","y","z","w"],["r","g","b","a"],["s","t","p","q"]].map((e=>e.slice(0,t))),s={get(e,t,n){if(t in e)return Reflect.get(...arguments);for(const n of i)if([...t.toString()].every((e=>n.includes(e)))){const s=[...t].map((e=>{const t=n.indexOf(e);return i[0][t]})).join(""),o=Qa(r,e,s);return Ua(o.id,o.dimension,r)}},set(e,t,s,o){for(const o of i){const i=[...t];if(!(i.every((e=>o.includes(e)))&&new Set(i).size===i.length&&e.dimension>=i.length))continue;const a=e.dimension,u=new Array(a);for(let t=0;t<a;t++){const{id:n,dimension:i}=Qa(r,e,"xyzw"[t]);u[t]=Ua(n,i,r)}let l=[];if(s?.isStrandsNode)if(1===s.dimension)l=Array(i.length).fill(s);else if(s.dimension===i.length)for(let e=0;e<i.length;e++){const{id:t,dimension:n}=Qa(r,s,"xyzw"[e]);l.push(Ua(t,n,r))}else Sa(i.length,s.dimension,`${e._originalIdentifier||"value"}.${t}`);else if(Array.isArray(s)){const e=s.flat(1/0);1===e.length?l=Array(i.length).fill(e[0]):e.length===i.length?l=e:Ea("type error",`Swizzle assignment: RHS length ${e.length} does not match ${i.length}.`)}else"number"==typeof s?l=Array(i.length).fill(s):Ea("type error",`Unsupported RHS for swizzle assignment: ${s}`);for(let e=0;e<i.length;e++){u[o.indexOf(i[e])]=l[e]}const h=Fa(r.dag,e.id),c=h?.baseType??Kn,{id:d}=Za(r,{baseType:c,dimension:a},u);return e.id=d,"function"==typeof n&&n(d),!0}return Reflect.set(...arguments)}};return s}(0,t,r,n))}const za={...{acos:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!0}],acosh:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!1}],asin:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!0}],asinh:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!1}],atan:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!0},{params:[li.FLOAT,li.FLOAT],returnType:li.FLOAT,isp5Function:!0}],atanh:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!1}],cos:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!0}],cosh:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!1}],degrees:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!0}],radians:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!0}],sin:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!0}],sinh:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!1}],tan:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!0}],tanh:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!1}],abs:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!0},{params:[li.FLOAT],returnType:li.INT,isp5Function:!0}],ceil:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!0}],clamp:[{params:[li.FLOAT,li.FLOAT,li.FLOAT],returnType:li.FLOAT,isp5Function:!1},{params:[li.FLOAT,oi.float1,oi.float1],returnType:li.FLOAT,isp5Function:!1},{params:[li.INT,li.INT,li.INT],returnType:li.INT,isp5Function:!1},{params:[li.INT,oi.int1,oi.int1],returnType:li.INT,isp5Function:!1}],dFdx:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!1}],dFdy:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!1}],exp:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!0}],exp2:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!1}],floor:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!0}],fma:[{params:[li.FLOAT,li.FLOAT,li.FLOAT],returnType:li.FLOAT,isp5Function:!1}],fract:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!0}],fwidth:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!1}],inversesqrt:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!0}],log:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!0}],log2:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!1}],max:[{params:[li.FLOAT,li.FLOAT],returnType:li.FLOAT,isp5Function:!0},{params:[li.FLOAT,oi.float1],returnType:li.FLOAT,isp5Function:!0},{params:[li.INT,li.INT],returnType:li.INT,isp5Function:!0},{params:[li.INT,oi.int1],returnType:li.INT,isp5Function:!0}],min:[{params:[li.FLOAT,li.FLOAT],returnType:li.FLOAT,isp5Function:!0},{params:[li.FLOAT,oi.float1],returnType:li.FLOAT,isp5Function:!0},{params:[li.INT,li.INT],returnType:li.INT,isp5Function:!0},{params:[li.INT,oi.int1],returnType:li.INT,isp5Function:!0}],mix:[{params:[li.FLOAT,li.FLOAT,li.FLOAT],returnType:li.FLOAT,isp5Function:!1},{params:[li.FLOAT,li.FLOAT,oi.float1],returnType:li.FLOAT,isp5Function:!1},{params:[li.FLOAT,li.FLOAT,li.BOOL],returnType:li.FLOAT,isp5Function:!1}],mod:[{params:[li.FLOAT,li.FLOAT],returnType:li.FLOAT,isp5Function:!0},{params:[li.FLOAT,oi.float1],returnType:li.FLOAT,isp5Function:!0}],pow:[{params:[li.FLOAT,li.FLOAT],returnType:li.FLOAT,isp5Function:!0}],round:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!0}],roundEven:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!1}],sign:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!1},{params:[li.INT],returnType:li.INT,isp5Function:!1}],smoothstep:[{params:[li.FLOAT,li.FLOAT,li.FLOAT],returnType:li.FLOAT,isp5Function:!1},{params:[oi.float1,oi.float1,li.FLOAT],returnType:li.FLOAT,isp5Function:!1}],sqrt:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!0}],step:[{params:[li.FLOAT,li.FLOAT],returnType:li.FLOAT,isp5Function:!1}],trunc:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!1}],cross:[{params:[oi.float3,oi.float3],returnType:oi.float3,isp5Function:!0}],distance:[{params:[li.FLOAT,li.FLOAT],returnType:oi.float1,isp5Function:!0}],dot:[{params:[li.FLOAT,li.FLOAT],returnType:oi.float1,isp5Function:!0}],equal:[{params:[li.FLOAT,li.FLOAT],returnType:li.BOOL,isp5Function:!1},{params:[li.INT,li.INT],returnType:li.BOOL,isp5Function:!1},{params:[li.BOOL,li.BOOL],returnType:li.BOOL,isp5Function:!1}],faceforward:[{params:[li.FLOAT,li.FLOAT,li.FLOAT],returnType:li.FLOAT,isp5Function:!1}],length:[{params:[li.FLOAT],returnType:oi.float1,isp5Function:!1}],normalize:[{params:[li.FLOAT],returnType:li.FLOAT,isp5Function:!0}],notEqual:[{params:[li.FLOAT,li.FLOAT],returnType:li.BOOL,isp5Function:!1},{params:[li.INT,li.INT],returnType:li.BOOL,isp5Function:!1},{params:[li.BOOL,li.BOOL],returnType:li.BOOL,isp5Function:!1}],reflect:[{params:[li.FLOAT,li.FLOAT],returnType:li.FLOAT,isp5Function:!1}],refract:[{params:[li.FLOAT,li.FLOAT,oi.float1],returnType:li.FLOAT,isp5Function:!1}]}};function ja(e,t,r){const{cfg:n,dag:i}=e;let{dimension:s,baseType:o}=t;1!==s&&Ca("Created a scalar literal node with dimension > 1.");const a=Da(i,Ta({nodeType:zn.LITERAL,dimension:s,baseType:o,value:r}));return Pa(n,n.currentBlock,a),{id:a,dimension:s}}function Ga(e,t,r){const{cfg:n,dag:i}=e,{dimension:s,baseType:o}=t,a=Da(i,Ta({nodeType:zn.VARIABLE,dimension:s,baseType:o,identifier:r}));return Pa(n,n.currentBlock,a),{id:a,dimension:s}}function $a(e,t,r){const{dag:n,cfg:i}=e;let s,o;if(t?.isStrandsNode)o=t;else{const{id:r,dimension:n}=Za(e,{baseType:Kn,dimension:null},t);o=Ua(r,n,e)}s=[o.id];const a={baseType:n.baseTypes[o.id],dimension:o.dimension};yi[r]&&(a.baseType=Qn,a.dimension=1);const u=Da(n,Ta({nodeType:zn.OPERATION,opCode:r,dependsOn:s,baseType:a.baseType,dimension:a.dimension}));return Pa(i,i.currentBlock,u),{id:u,dimension:o.dimension}}function Ha(e,t,r,n){const{dag:i,cfg:s}=e;let o;if(r[0]instanceof Va&&1===r.length)o=r[0];else{const{id:t,dimension:n}=Za(e,{baseType:Kn,dimension:null},r);o=Ua(t,n,e)}let a=t.id,u=o.id,l=Ia(i,t.id),h=Ia(i,o.id);l.baseType===ri&&h.baseType!==ri?(ka(i,t.id,h.baseType,h.dimension),l=Ia(i,t.id)):h.baseType===ri&&l.baseType!==ri&&(ka(i,o.id,l.baseType,l.dimension),h=Ia(i,o.id));const c={node:null,toType:l};if(l.baseType===h.baseType&&l.baseType===ti){c.toType.baseType=Kn,l.dimension===h.dimension?c.toType.dimension=l.dimension:1===l.dimension&&h.dimension>1?c.toType.dimension=h.dimension:1===h.dimension&&l.dimension>1?c.toType.dimension=l.dimension:Ea("type error",`You have tried to perform a binary operation:\n${l.baseType+l.dimension} ${mi[n]} ${h.baseType+h.dimension}\nIt's only possible to operate on two nodes with the same dimension, or a scalar value and a vector.`);const r=Za(e,c.toType,t),i=Za(e,c.toType,o);a=r.id,u=i.id}else if(l.baseType!==h.baseType||l.dimension!==h.dimension){1===l.dimension&&h.dimension>1?(c.node=t,c.toType=h):1===h.dimension&&l.dimension>1||l.priority>h.priority?(c.node=o,c.toType=l):h.priority>l.priority?(c.node=t,c.toType=h):Ea("type error",`A vector of length ${l.dimension} operated with a vector of length ${h.dimension} is not allowed.`);const r=Za(e,c.toType,c.node);c.node===t?a=(t=Ua(r.id,r.dimension,e)).id:(o=Ua(r.id,r.dimension,e),u=o.id)}yi[n]&&(c.toType.baseType=Qn,c.toType.dimension=1);const d=Ta({nodeType:zn.OPERATION,opCode:n,dependsOn:[a,u],baseType:c.toType.baseType,dimension:c.toType.dimension}),p=Da(i,d);return Pa(s,s.currentBlock,p),{id:p,dimension:d.dimension}}function qa(e,t,r,n){const{cfg:i,dag:s}=e;if(0===n.length)for(const e of t.properties){const t=e.dataType,o=Da(s,Ta({nodeType:zn.VARIABLE,baseType:t.baseType,dimension:t.dimension,identifier:`${r}.${e.name}`}));Pa(i,i.currentBlock,o),n.push(o)}const o=Da(s,Ta({nodeType:zn.VARIABLE,dimension:t.properties.length,baseType:t.typeName,identifier:r,dependsOn:n}));return Pa(i,i.currentBlock,o),{id:o,dimension:0,components:n}}function Wa(e,t,r){const n=Array.isArray(r)?r:[r],i=[];let{dimension:s,baseType:o}=t;const a=e.dag;let u=0,l=null;for(const t of n.flat(1/0))if(t&&t.isStrandsNode){const e=Fa(a,t.id);if(l=t.id,o=e.baseType,e.opCode===pi.CONSTRUCTOR)for(const t of e.dependsOn)i.push(t);else i.push(t.id);u+=e.dimension}else if("number"!=typeof t)if("boolean"!=typeof t)Ea("type error",`You've tried to construct a scalar or vector type with a non-numeric value: ${t}`);else{const{id:r,dimension:n}=ja(e,{dimension:1,baseType:Qn},t);i.push(r),u+=n,o!==Qn&&(o=Qn)}else{const{id:r,dimension:n}=ja(e,{dimension:1,baseType:o},t);i.push(r),u+=n}null===s?s=u:s>u&&1===u?u=s:1!==u&&u!==s&&Ea("type error",`You've tried to construct a ${o+s} with ${u} components`);return{originalNodeID:l,mappedDependencies:i,inferredTypeInfo:{dimension:s,baseType:o,priority:si[o]}}}function Xa(e,t,r){const n=Ta({nodeType:zn.OPERATION,opCode:pi.CONSTRUCTOR,dimension:t.dimension,baseType:t.baseType,dependsOn:r});return Da(e.dag,n)}function Za(e,t,r){const n=e.cfg;r=(Array.isArray(r)?r:[r]).flat(1/0).map((t=>t.isStrandsNode&&t.typeInfo().baseType===Jn&&1===t.typeInfo().dimension?function(e,t){const{id:r,dimension:n}=Ka(e,e.backend.getTypeName("float",t.typeInfo().dimension),[t],{overloads:[{params:[t.typeInfo()],returnType:{...t.typeInfo(),baseType:Kn}}]});return Ua(r,n,e)}(e,t):t));const{mappedDependencies:i,inferredTypeInfo:s}=Wa(e,t,r),o={baseType:s.baseType===Qn?Qn:t.baseType,dimension:s.dimension},a=Xa(e,o,i);return t.baseType!==ti&&Pa(n,n.currentBlock,a),{id:a,dimension:o.dimension,components:i}}function Ya(e,t,r){const{cfg:n,dag:i}=e,{properties:s}=t;r.length!==s.length&&Ea("type error",`You've tried to construct a ${t.typeName} struct with ${r.length} properties, but it expects ${s.length} properties.\nThe properties it expects are:\n${s.map((e=>`${e.name}: ${e.dataType.baseType}${e.dataType.dimension}`)).join(", ")}`);const o=Da(i,Ta({nodeType:zn.OPERATION,opCode:pi.CONSTRUCTOR,dimension:s.length,baseType:t.typeName,dependsOn:r}));return Pa(n,n.currentBlock,o),{id:o,dimension:s.length,components:t.components}}function Ka(e,t,r,{overloads:n}={}){const{cfg:i,dag:s}=e,o=n||za[t],a=r.map((t=>Wa(e,oi.defer,t))),u=o.filter((e=>e.params.length===a.length));if(0===u.length){const e=new Set,r=[];o.forEach((t=>e.add(t.params.length))),e.forEach((e=>r.push(`${e}`)));const n=r.join(", or ");Ea("parameter validation error",`Function '${t}' has ${o.length} variants which expect ${n} arguments, but ${a.length} arguments were provided.`)}const l=e=>null===e.dimension;let h=null,c=0,d=null,p=null;for(const e of u){let t=!0,r=0;for(let n=0;n<a.length;n++){const i=a[n].inferredTypeInfo,s=e.params[n];let o=s.dimension;l(s)?(null!==p&&1!==p||(p=i.dimension),p===i.dimension||1===i.dimension&&p>=1||(t=!1),o=p):i.dimension>o&&(t=!1),i.baseType===s.baseType?r+=2:s.priority>i.priority&&(r+=1)}t&&(!h||r>c)&&(h=e,c=r,d={...e.returnType},l(d)&&(d.dimension=p))}null===h&&Ea("parameter validation",`No matching overload for ${t} was found!`);let f=[];for(let t=0;t<h.params.length;t++){const r=a[t],n={...h.params[t]};if(l(n)&&(n.dimension=p),r.originalNodeID&&(m=r.inferredTypeInfo,g=n,m.dimension===g.dimension&&m.baseType===g.baseType))f.push(r.originalNodeID);else{const t=Xa(e,n,r.mappedDependencies);Pa(i,i.currentBlock,t),f.push(t)}}var m,g;const y=Da(s,Ta({nodeType:zn.OPERATION,opCode:pi.FUNCTION_CALL,identifier:t,dependsOn:f,baseType:d.baseType,dimension:d.dimension}));return Pa(i,i.currentBlock,y),{id:y,dimension:d.dimension}}function Ja(e,t){const{dag:r,cfg:n}=e,i=Da(r,Ta({nodeType:zn.STATEMENT,statementType:t}));return Pa(n,n.currentBlock,i),i}function Qa(e,t,r){const{dag:n,cfg:i}=e,s=n.baseTypes[t.id],o=Da(n,Ta({nodeType:zn.OPERATION,baseType:s,dimension:r.length,opCode:di.SWIZZLE,dependsOn:[t.id],swizzle:r}));return Pa(i,i.currentBlock,o),{id:o,dimension:r.length}}function eu(e,t,r,n){const{dag:i,cfg:s}=e;let o;if(r instanceof Va)o=r;else{const{id:t,dimension:n}=Za(e,{baseType:Jn,dimension:1},r);o=Ua(t,n,e)}const a={};for(const r of n.fields)Object.defineProperty(a,r.name,{get(){const n=Ta({nodeType:zn.OPERATION,opCode:ci.ARRAY_ACCESS,dependsOn:[t.id,o.id],dimension:r.dim,baseType:Kn,identifier:r.name}),a=Da(i,n);Pa(s,s.currentBlock,a);return Ua(a,r.dim,e,(e=>{const n=Ta({nodeType:zn.OPERATION,opCode:ci.ARRAY_ACCESS,dependsOn:[t.id,o.id],dimension:r.dim,baseType:Kn,identifier:r.name}),a=Da(i,n),u=Ta({nodeType:zn.ASSIGNMENT,dependsOn:[a,e],phiBlocks:[]}),l=Da(i,u);Pa(s,s.currentBlock,l)}))},set(n){const a=Ta({nodeType:zn.OPERATION,opCode:ci.ARRAY_ACCESS,dependsOn:[t.id,o.id],dimension:r.dim,baseType:Kn,identifier:r.name}),u=Da(i,a);let l;if(n?.isStrandsNode)l=n.id;else{const{id:t}=Za(e,{baseType:Kn,dimension:r.dim},n);l=t}const h=Ta({nodeType:zn.ASSIGNMENT,dependsOn:[u,l],phiBlocks:[]}),c=Da(i,h);Pa(s,s.currentBlock,c)},configurable:!0});return a}function tu(e,t){if(e.nodeTypes[t]!==zn.OPERATION)return!1;if(e.baseTypes[t]===ni)return!1;return(e.usedBy[t]||[]).length>1}const ru={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"},nu={[vi.DEFAULT]:(e,t,r)=>{const{dag:n,cfg:i}=t,s=i.blockInstructions[e]||[];for(const e of s){const t=n.nodeTypes[e];if(tu(n,e)){const t=iu.generateDeclaration(r,n,e);r.write(t)}t===zn.STATEMENT&&iu.generateStatement(r,n,e),t===zn.ASSIGNMENT&&(iu.generateAssignment(r,n,e),r.visitedNodes.add(e))}},[vi.BRANCH](e,t,r){const{dag:n,cfg:i}=t,s=i.blockInstructions[e]||[];for(const e of s){const t=Fa(n,e);if(t.nodeType===zn.PHI){const i=t.dependsOn||[];if(i.length>0){const t=i[0],n=r.tempNames[t];if(n){r.tempNames[e]=n;continue}}const s="T"+r.nextTempID++;r.tempNames[e]=s;const o=Ia(n,e),a=iu.getTypeName(o.baseType,o.dimension);r.write(`${a} ${s};`)}}this[vi.DEFAULT](e,t,r)},[vi.IF_COND](e,t,r){const{dag:n,cfg:i}=t,s=i.blockConditions[e],o=iu.generateExpression(r,n,s);r.write(`if (${o})`),this[vi.DEFAULT](e,t,r)},[vi.ELSE_COND](e,t,r){r.write("else"),this[vi.DEFAULT](e,t,r)},[vi.IF_BODY](e,t,r){this[vi.DEFAULT](e,t,r),this.assignPhiNodeValues(e,t,r)},[vi.SCOPE_START](e,t,r){r.write("{"),r.indent++},[vi.SCOPE_END](e,t,r){r.indent--,r.write("}")},[vi.MERGE](e,t,r){this[vi.DEFAULT](e,t,r)},[vi.FUNCTION](e,t,r){this[vi.DEFAULT](e,t,r)},[vi.FOR](e,t,r){const{dag:n,cfg:i}=t,s=i.blockInstructions[e]||[];r.write("for (");const o=r.suppressSemicolon;for(let e=0;e<s.length;e++){const t=s[e],i=Fa(n,t),o=e===s.length-1;if(r.suppressSemicolon=o,tu(n,t)){const e=iu.generateDeclaration(r,n,t);r.write(e)}i.nodeType===zn.STATEMENT&&iu.generateStatement(r,n,t),i.nodeType===zn.ASSIGNMENT&&(iu.generateAssignment(r,n,t),r.visitedNodes.add(t))}r.suppressSemicolon=o,r.write(")")},assignPhiNodeValues(e,t,r){const{dag:n,cfg:i}=t,s=i.outgoingEdges[e]||[];for(const t of s){const s=i.blockInstructions[t]||[];for(const t of s){const i=Fa(n,t);if(i.nodeType===zn.PHI){const s=i.phiBlocks?.indexOf(e);if(-1!==s&&s<i.dependsOn.length){const e=i.dependsOn[s],o=r.tempNames[t];if(o&&null!==e){const t=iu.generateExpression(r,n,e);r.write(`${o} = ${t};`)}}}}}}},iu={hookEntry:e=>`(${e.parameters.flatMap((e=>`${e.qualifiers?.length?e.qualifiers.join(" "):""}${e.type.typeName} ${Gn}${e.name}`)).join(", ")}) {`,getNoiseShaderSnippet:()=>"// Based on https://github.com/stegu/webgl-noise/blob/22434e04d7753f7e949e8d724ab3da2864c17a0f/src/noise3D.glsl\n// MIT licensed, adapted for p5.strands\n\nvec3 mod289(vec3 x) {\n  return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 mod289(vec4 x) {\n  return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 permute(vec4 x) {\n  return mod289(((x*34.0)+10.0)*x);\n}\n\nvec4 taylorInvSqrt(vec4 r)\n{\n  return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nfloat baseNoise(vec3 v)\n{\n  const vec2  C = vec2(1.0/6.0, 1.0/3.0) ;\n  const vec4  D = vec4(0.0, 0.5, 1.0, 2.0);\n\n  // First corner\n  vec3 i  = floor(v + dot(v, C.yyy) );\n  vec3 x0 =   v - i + dot(i, C.xxx) ;\n\n  // Other corners\n  vec3 g = step(x0.yzx, x0.xyz);\n  vec3 l = 1.0 - g;\n  vec3 i1 = min( g.xyz, l.zxy );\n  vec3 i2 = max( g.xyz, l.zxy );\n\n  //   x0 = x0 - 0.0 + 0.0 * C.xxx;\n  //   x1 = x0 - i1  + 1.0 * C.xxx;\n  //   x2 = x0 - i2  + 2.0 * C.xxx;\n  //   x3 = x0 - 1.0 + 3.0 * C.xxx;\n  vec3 x1 = x0 - i1 + C.xxx;\n  vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y\n  vec3 x3 = x0 - D.yyy;      // -1.0+3.0*C.x = -0.5 = -D.y\n\n  // Permutations\n  i = mod289(i);\n  vec4 p = permute( permute( permute(\n          i.z + vec4(0.0, i1.z, i2.z, 1.0 ))\n        + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))\n      + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));\n\n  // Gradients: 7x7 points over a square, mapped onto an octahedron.\n  // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)\n  float n_ = 0.142857142857; // 1.0/7.0\n  vec3  ns = n_ * D.wyz - D.xzx;\n\n  vec4 j = p - 49.0 * floor(p * ns.z * ns.z);  //  mod(p,7*7)\n\n  vec4 x_ = floor(j * ns.z);\n  vec4 y_ = floor(j - 7.0 * x_ );    // mod(j,N)\n\n  vec4 x = x_ *ns.x + ns.yyyy;\n  vec4 y = y_ *ns.x + ns.yyyy;\n  vec4 h = 1.0 - abs(x) - abs(y);\n\n  vec4 b0 = vec4( x.xy, y.xy );\n  vec4 b1 = vec4( x.zw, y.zw );\n\n  //vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;\n  //vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;\n  vec4 s0 = floor(b0)*2.0 + 1.0;\n  vec4 s1 = floor(b1)*2.0 + 1.0;\n  vec4 sh = -step(h, vec4(0.0));\n\n  vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;\n  vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;\n\n  vec3 p0 = vec3(a0.xy,h.x);\n  vec3 p1 = vec3(a0.zw,h.y);\n  vec3 p2 = vec3(a1.xy,h.z);\n  vec3 p3 = vec3(a1.zw,h.w);\n\n  //Normalise gradients\n  vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));\n  p0 *= norm.x;\n  p1 *= norm.y;\n  p2 *= norm.z;\n  p3 *= norm.w;\n\n  // Mix final noise value\n  vec4 m = max(0.5 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);\n  m = m * m;\n  return 105.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),\n        dot(p2,x2), dot(p3,x3) ) );\n}\n\nfloat noise(vec3 st, int octaves, float ampFalloff) {\n  float result = 0.0;\n  float amplitude = 1.0;\n  float frequency = 1.0;\n\n  for (int i = 0; i < 8; i++) {\n    if (i >= octaves) break;\n    result += amplitude * baseNoise(st * frequency);\n    frequency *= 2.0;\n    amplitude *= ampFalloff;\n  }\n  return (result + 1.0) * 0.5;\n}\n",getRandomFragmentShaderSnippet:()=>_a,getRandomVertexShaderSnippet:()=>wa,getTypeName(e,t){const r=ru[e+t];return r||e},generateHookUniformKey(e,t){return`${this.getTypeName(t.baseType,t.dimension)} ${e}`},generateVaryingVariable:(e,t)=>`${t.fnName} ${e}`,generateLocalDeclaration:(e,t)=>`${t.fnName} ${e};`,generateStatement(e,t,r){const n=Fa(t,r),i=e.suppressSemicolon?"":";";if(n.statementType===qn)e.write(`discard${i}`);else if(n.statementType===Wn)e.write(`break${i}`);else if(n.statementType===Zn){const r=n.dependsOn[0],s=this.generateExpression(e,t,r);e.write(`${s}${i}`)}else if(n.statementType===Yn)e.write(i);else if(n.statementType===Xn){const r=n.dependsOn[0],s=this.generateExpression(e,t,r);e.write(`return ${s}${i}`)}},generateAssignment(e,t,r){const n=Fa(t,r),i=n.dependsOn[0],s=n.dependsOn[1],o=this.generateExpression(e,t,i),a=this.generateExpression(e,t,s),u=e.suppressSemicolon?"":";";o&&a&&o!==a&&e.write(`${o} = ${a}${u}`)},generateDeclaration(e,t,r){const n=this.generateExpression(e,t,r),i="T"+e.nextTempID++;e.tempNames[r]=i;const s=Ia(t,r);return`${this.getTypeName(s.baseType,s.dimension)} ${i} = ${n};`},generateReturnStatement(e,t,r,n){if(!n)return void t.write("return;");const i=e.dag,s=Fa(i,r);if(ui(n)&&s.identifier){const e=n;for(let r=0;r<e.properties.length;r++){const n=e.properties[r],o=this.generateExpression(t,i,s.dependsOn[r]);n.name!==o&&t.write(`${s.identifier}.${n.name} = ${o};`)}}t.write(`return ${this.generateExpression(t,i,r)};`)},generateExpression(e,t,r){const n=Fa(t,r);if(e.tempNames?.[r])return e.tempNames[r];switch(n.nodeType){case zn.LITERAL:return n.baseType===Kn?n.value.toFixed(4):n.value;case zn.VARIABLE:if(e.shaderContext&&e.strandsContext?.sharedVariables?.has(n.identifier)){const t=e.strandsContext.sharedVariables.get(n.identifier);"vertex"===e.shaderContext?t.usedInVertex=!0:"fragment"===e.shaderContext&&(t.usedInFragment=!0)}return n.identifier===this.instanceIdReference()&&"fragment"===e.shaderContext?(e.strandsContext._instanceIDUsedInFragment=!0,jn):n.identifier;case zn.OPERATION:const i=n.usedBy.length>0;if(n.opCode===pi.CONSTRUCTOR){if(n.baseType===ni)return this.generateExpression(e,t,n.dependsOn[0]);return`${this.getTypeName(n.baseType,n.dimension)}(${n.dependsOn.map((r=>this.generateExpression(e,t,r))).join(", ")})`}if(n.opCode===pi.FUNCTION_CALL){const r=n.dependsOn.map((r=>this.generateExpression(e,t,r)));return`${n.identifier}(${r.join(", ")})`}if(n.opCode===pi.TERNARY){const[r,i,s]=n.dependsOn;return`(${this.generateExpression(e,t,r)} ? ${this.generateExpression(e,t,i)} : ${this.generateExpression(e,t,s)})`}if(n.opCode===ci.MEMBER_ACCESS){const[r,i]=n.dependsOn;return`${this.generateExpression(e,t,r)}.${this.generateExpression(e,t,i)}`}if(n.opCode===di.SWIZZLE){const r=n.dependsOn[0];return`${this.generateExpression(e,t,r)}.${n.swizzle}`}if(n.opCode===ci.ARRAY_ACCESS){const[r,i]=n.dependsOn;return`${this.generateExpression(e,t,r)}[${this.generateExpression(e,t,i)}]`}if(2===n.dependsOn.length){const[r,s]=n.dependsOn,o=this.generateExpression(e,t,r),a=this.generateExpression(e,t,s);if(n.opCode===ci.MODULO){const e=Fa(t,r),n=Fa(t,s);return e.baseType===Kn||n.baseType===Kn?`mod(${o}, ${a})`:`(${o} % ${a})`}const u=mi[n.opCode];return i?`(${o} ${u} ${a})`:`${o} ${u} ${a}`}if(n.opCode===di.LOGICAL_NOT||n.opCode===di.NEGATE||n.opCode===di.PLUS){const[r]=n.dependsOn,i=this.generateExpression(e,t,r);return`${mi[n.opCode]}${i}`}case zn.PHI:if(n.identifier)return n.identifier;if(e.tempNames?.[r])return e.tempNames[r];{const r=n.dependsOn.filter((e=>null!==e));if(r.length>0)return this.generateExpression(e,t,r[0]);throw new Error("No valid inputs for node")}case zn.ASSIGNMENT:Ca("ASSIGNMENT nodes should not be used as expressions");default:Ca(`${$n[n.nodeType]} code generation not implemented yet`)}},generateBlock(e,t,r){const n=t.cfg.blockTypes[e];(nu[n]||nu[vi.DEFAULT]).call(nu,e,t,r)},createGetTextureCall(e,t){const{id:r,dimension:n}=Ka(e,"getTexture",t,{overloads:[{params:[oi.sampler2D,oi.float2],returnType:oi.float4}]});return{id:r,dimension:n}},instanceIdReference:()=>"gl_InstanceID",generateInstanceIDVarying:()=>({name:jn,declaration:`int ${jn}`,source:"gl_InstanceID",interpolation:"flat"})};function su(e,t){let r=e._vertSrc,n=e.hooks.vertex[t];if(n||(n=e.hooks.fragment[t],r=e._fragSrc),!n)throw new Error(`Can't find hook ${t}!`);const i=t.split(/\s+/g),s=i.pop(),o=i.pop(),a=[...i],u=/\(([^\)]*)\)/.exec(n);if(!u)throw new Error(`Couldn't find function parameters in hook body:\n${n}`);const l=e=>{const t=new RegExp(`struct\\s+${e}\\s*{([^}]*)}`).exec(r);if(!t)return;const n=[];for(const e of t[1].split(";")){const t=e.trim().split(/\s+|,/g),r=t.shift(),i=[...t],s=l(r);for(const e of i){const t=hi[r]||null;n.push({name:e,type:{typeName:r,qualifiers:[],properties:s,dataType:t}})}}return n},h=u[1].split(",").map((e=>{const t=e.trim().split(/\s+/g),r=t.pop(),n=t.pop();return{name:r,type:{typeName:n,qualifiers:[...t],properties:l(n),dataType:hi[n]||null}}})),c=hi[o]||null;return{name:s,returnType:{typeName:o,qualifiers:a,properties:l(o),dataType:c},parameters:h}}class ou{constructor(e){this.parentRenderer=e,this.canvas=document.createElement("canvas"),this.canvas.width=e.width,this.canvas.height=e.height;let t=s;this.gl=this.canvas.getContext("webgl2"),this.gl||(t=i,this.gl=this.canvas.getContext("webgl")),this.gl?(this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this.textures=new Map,this._renderer={GL:this.gl,registerEnabled:new Set,_curShader:null,_emptyTexture:null,webglVersion:t,states:{textureWrapX:Fe,textureWrapY:Fe},_arraysEqual:(e,t)=>JSON.stringify(e)===JSON.stringify(t),_getEmptyTexture:()=>{if(!this._emptyTexture){const e=new Mi(1,1);e.set(0,0,255),this._emptyTexture=new ea(this._renderer,e)}return this._emptyTexture},_initShader:e=>{const t=this.gl,r=t.createShader(t.VERTEX_SHADER);if(t.shaderSource(r,e.vertSrc()),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new Error(`Yikes! An error occurred compiling the vertex shader: ${t.getShaderInfoLog(r)}`);const n=t.createShader(t.FRAGMENT_SHADER);if(t.shaderSource(n,e.fragSrc()),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new Error(`Darn! An error occurred compiling the fragment shader: ${t.getShaderInfoLog(n)}`);const i=t.createProgram();if(t.attachShader(i,r),t.attachShader(i,n),t.linkProgram(i),!t.getProgramParameter(i,t.LINK_STATUS))throw new Error(`Snap! Error linking shader program: ${t.getProgramInfoLog(i)}`);e._glProgram=i,e._vertShader=r,e._fragShader=n},getTexture:e=>{let t=e;t instanceof Framebuffer&&(t=t.color);const r=this.textures.get(t);if(r)return r;const n=new ea(this._renderer,t);return this.textures.set(t,n),n},populateHooks:(e,t,r)=>la(e,t,r),_getShaderAttributes:e=>ua(e,this.gl),getUniformMetadata:e=>aa(e,this.gl),_finalizeShader:()=>{},_useShader:e=>{this.gl.useProgram(e._glProgram)},bindTexture:e=>{this.gl.bindTexture(this.gl.TEXTURE_2D,e.getTexture().texture)},unbindTexture:()=>{this.gl.bindTexture(this.gl.TEXTURE_2D,null)},_unbindFramebufferTexture:e=>{const t=this.gl,r=this._getEmptyTexture();t.activeTexture(t.TEXTURE0+e.samplerIndex),r.bindTexture(),t.uniform1i(e.location,e.samplerIndex)},createTexture:({width:e,height:t,format:r,dataType:n})=>{const i=this.gl,s=i.createTexture();return i.bindTexture(i.TEXTURE_2D,s),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,e,t,0,i.RGBA,i.UNSIGNED_BYTE,null),{texture:s,glFormat:i.RGBA,glDataType:i.UNSIGNED_BYTE}},uploadTextureFromSource:({texture:e,glFormat:t,glDataType:r},n)=>{const i=this.gl;i.bindTexture(i.TEXTURE_2D,e),i.texImage2D(i.TEXTURE_2D,0,t,t,r,n)},uploadTextureFromData:({texture:e,glFormat:t,glDataType:r},n,i,s)=>{const o=this.gl;o.bindTexture(o.TEXTURE_2D,e),o.texImage2D(o.TEXTURE_2D,0,t,i,s,0,t,r,n)},setTextureParams:e=>sa(e,this.gl,this._renderer.webglVersion),updateUniformValue:(e,t,r)=>oa(e,t,r,(e=>this._renderer.getTexture(e)),this.gl),_enableAttrib:(e,t,r,n,i,s,o)=>{const a=t.location,u=this.gl;this._renderer.registerEnabled.has(a)||(u.enableVertexAttribArray(a),this._renderer.registerEnabled.add(a)),u.vertexAttribPointer(a,r,n||u.FLOAT,i||!1,s||0,o||0)},_disableRemainingAttributes:e=>{for(const t of this._renderer.registerEnabled.values())Object.keys(e.attributes).some((r=>e.attributes[r].location===t))||(this.gl.disableVertexAttribArray(t),this._renderer.registerEnabled.delete(t))},_updateTexture:(e,t)=>{const r=this.gl;r.activeTexture(r.TEXTURE0+e.samplerIndex),t.bindTexture(),t.update(),r.uniform1i(e.location,e.samplerIndex)},baseFilterShader:()=>this.baseFilterShader(),strandsBackend:iu,getShaderHookTypes:(e,t)=>su(e,t),uniformNameFromHookKey:e=>e.slice(e.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(e,t){let r="";return this._renderer.webglVersion===s&&(r+="#version 300 es\n#define WEBGL2\n"),"vert"===e?r+="#define VERTEX_SHADER\n":"frag"===e&&(r+="#define FRAGMENT_SHADER\n"),t&&(r+=`precision ${t} float;\n`),r}baseFilterShader(){return this._baseFilterShader||(this._baseFilterShader=new Wo(this._renderer,this._webGL2CompatibilityPrefix("vert","highp")+xa+ba,this._webGL2CompatibilityPrefix("frag","highp")+xa+va,{vertex:{},fragment:{"vec4 getColor":"(FilterInputs inputs, in sampler2D canvasContent) {\n              return getTexture(canvasContent, inputs.texCoord);\n            }"},hookAliases:{getColor:["filterColor"]}})),this._baseFilterShader}getRandomFragmentShaderSnippet(){return _a}getRandomVertexShaderSnippet(){return wa}setOperation(e,t,r=null){this.operation=e,this.filterParameter=t,e in To&&void 0===t&&(this.filterParameter=To[e]),this.customShader=r,this._initializeShader()}_initializeShader(){if(this.customShader)return void(this._shader=this.customShader);if(!this.operation)return void console.error("No operation set for FilterRenderer2D, cannot initialize shader.");if(this.filterShaders[this.operation])return void(this._shader=this.filterShaders[this.operation]);const e=Po(this._renderer,this.operation,this.parentRenderer._pInst);this.filterShaders[this.operation]=e,this._shader=e}_bindBufferData(e,t,r){const n=this.gl;n.bindBuffer(t,e),n.bufferData(t,r,n.STATIC_DRAW)}get canvasTexture(){return this._canvasTexture||(this._canvasTexture=new ea(this._renderer,this.parentRenderer)),this._canvasTexture}_renderPass(){const e=this.gl;this._shader.bindShader("fill");const t=this.parentRenderer.pixelDensity?this.parentRenderer.pixelDensity():1,r=[1/(this.parentRenderer.width*t),1/(this.parentRenderer.height*t)],n=this.canvasTexture;this._shader.setUniform("tex0",n),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",w),this.parentRenderer.states.setValue("imageMode",w),this.parentRenderer.blendMode(Y),this.parentRenderer.resetMatrix();const i=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];this._shader.setUniform("uModelViewMatrix",i),this._shader.setUniform("uProjectionMatrix",i),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),this._shader.enableAttrib(this._shader.attributes.aPosition,2),e.bindBuffer(e.ARRAY_BUFFER,this.texcoordBuffer),this._shader.enableAttrib(this._shader.attributes.aTexCoord,2),this._shader.bindTextures(),this._renderer._disableRemainingAttributes(this._shader),e.drawArrays(e.TRIANGLE_STRIP,0,4),this._shader.unbindShader()}applyFilter(){this._shader?(this.parentRenderer.push(),this.parentRenderer.resetMatrix(),this.operation!==be||this.customShader?(this._renderPass(),this.parentRenderer.clear(),this.parentRenderer.blendMode(Y),this.parentRenderer.drawingContext.drawImage(this.canvas,0,0,this.parentRenderer.width,this.parentRenderer.height)):(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.parentRenderer.pop()):console.error("Cannot apply filter: shader not initialized.")}}class au extends ps{constructor(e,t,r,n,i,s={}){super(e,t,r,n),this.canvas=this.elt=i||document.createElement("canvas"),n?(this._pInst._curElement=this,this._pInst.canvas=this.canvas):this.canvas.style.display="none",this.elt.id||(this.elt.id="defaultCanvas"+uu.sketchCount++),this.elt.classList.add("p5Canvas");for(const e of Object.getOwnPropertyNames(Ei.prototype))"constructor"!==e&&"_"!==e[0]&&Object.defineProperty(this,e,{get(){return this.wrappedElt[e]}});if(this.elt.width=t*this._pixelDensity,this.elt.height=r*this._pixelDensity,this.elt.style.width=`${t}px`,this.elt.style.height=`${r}px`,this._pInst._userNode)this._pInst._userNode.appendChild(this.elt);else{if(0===document.getElementsByTagName("main").length){let e=document.createElement("main");document.body.appendChild(e)}document.getElementsByTagName("main")[0].appendChild(this.elt)}this.drawingContext=this.canvas.getContext("2d",s),"display-p3"===s.colorSpace&&(this.states.colorMode=kn),this.scale(this._pixelDensity,this._pixelDensity),this.wrappedElt=new Ei(this.elt,this._pInst),this.clipPath=null}get filterRenderer(){return this._filterRenderer||(this._filterRenderer=new ou(this)),this._filterRenderer}remove(){this.wrappedElt.remove(),this.wrappedElt=null,this.canvas=null,this.elt=null}getFilterGraphicsLayer(){if(!this.filterGraphicsLayer){const e=this._pInst;this.filterGraphicsLayer=new Qo(this.width,this.height,i,e)}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=Y,this._setFill(Oe),this._setStroke(Me),this.drawingContext.lineCap=q,this.drawingContext.font="normal 12px sans-serif"}resize(e,t){super.resize(e,t);const r={};for(const e in this.drawingContext){const t=this.drawingContext[e];"object"!=typeof t&&"function"!=typeof t&&(r[e]=t)}this.canvas.width=e*this._pixelDensity,this.canvas.height=t*this._pixelDensity,this.canvas.style.width=`${e}px`,this.canvas.style.height=`${t}px`,this.drawingContext.scale(this._pixelDensity,this._pixelDensity);for(const e in r)try{this.drawingContext[e]=r[e]}catch(e){}}background(...e){if(0===e.length)return this;if(this.push(),this.resetMatrix(),e[0]instanceof Mi){const t=e[0];e[1]>=0&&(this.drawingContext.globalAlpha=e[1]/255),this._pInst.image(t,0,0,this.width,this.height)}else{const t=this._pInst.color(...e);this._pInst._addAccsOutput?.()&&this._pInst._accsBackground?.(t._getRGBA([255,255,255,255]));const r=t.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(...e){super.fill(...e);const t=this.states.fillColor;if(0===e.length)return t;this._setFill(t.toString()),this._pInst._addAccsOutput?.()&&this._pInst._accsCanvasColors?.("fill",t._getRGBA([255,255,255,255]))}stroke(...e){super.stroke(...e);const t=this.states.strokeColor;if(0===e.length)return t;this._setStroke(t.toString()),this._pInst._addAccsOutput?.()&&this._pInst._accsCanvasColors?.("stroke",t._getRGBA([255,255,255,255]))}erase(e,t){if(!this._isErasing){this.states.setValue("_cachedFillStyle",this.drawingContext.fillStyle);const r=this._pInst.color(255,e).toString();this.drawingContext.fillStyle=r,this.states.setValue("_cachedStrokeStyle",this.drawingContext.strokeStyle);const n=this._pInst.color(255,t).toString();this.drawingContext.strokeStyle=n;const i=this._cachedBlendMode;this.blendMode(K),this._cachedBlendMode=i,this._isErasing=!0}}noErase(){this._isErasing&&(this.drawingContext.fillStyle=this.states._cachedFillStyle,this.drawingContext.strokeStyle=this.states._cachedStrokeStyle,this.blendMode(this._cachedBlendMode),this._isErasing=!1)}drawShape(e){const t=new as({strokeWeight:this.states.strokeWeight,hasFill:!this._clipping&&!!this.states.fillColor,hasStroke:!this._clipping&&!!this.states.strokeColor});if(e.accept(t),this._clipping){const e=this.drawingContext.getTransform(),r=this._clipBaseTransform.inverse().multiply(e);this.clipPath.addPath(t.path,r),this.clipPath.closePath()}else this.states.fillColor&&this.drawingContext.fill(t.fillPath||t.path),this.states.strokeColor&&this.drawingContext.stroke(t.strokePath||t.path)}beginClip(e={}){super.beginClip(e),this._clipBaseTransform=this.drawingContext.getTransform(),this.states.setValue("_cachedFillStyle",this.drawingContext.fillStyle);const t=this._pInst.color(255,0).toString();this.drawingContext.fillStyle=t,this.states.setValue("_cachedStrokeStyle",this.drawingContext.strokeStyle);const r=this._pInst.color(255,0).toString();this.drawingContext.strokeStyle=r;const n=this._cachedBlendMode;this.blendMode(Y),this._cachedBlendMode=n,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(){const e=this.drawingContext.getTransform();this.drawingContext.setTransform(this._clipBaseTransform),this.drawingContext.clip(this.clipPath),this.drawingContext.setTransform(e),this.clipPath=null,super.endClip(),this.drawingContext.fillStyle=this.states._cachedFillStyle,this.drawingContext.strokeStyle=this.states._cachedStrokeStyle,this.blendMode(this._cachedBlendMode)}image(e,t,r,n,i,s,o,a,u){let l;e.gifProperties&&e._animateGif(this._pInst);try{e instanceof ys&&e._ensureCanvas(),this.states.tint&&e.canvas&&(l=this._getTintedImageCanvas(e)),l||(l=e.canvas||e.elt);let h=1;e.width&&e.width>0&&(h=l.width/e.width),this._isErasing&&this.blendMode(this._cachedBlendMode),this.drawingContext.drawImage(l,h*t,h*r,h*n,h*i,s,o,a,u),this._isErasing&&this._pInst.erase()}catch(e){if("NS_ERROR_NOT_AVAILABLE"!==e.name)throw e}}_getTintedImageCanvas(e){if(!e.canvas)return e;e.tintCanvas||(e.tintCanvas=document.createElement("canvas")),e.tintCanvas.width!==e.canvas.width&&(e.tintCanvas.width=e.canvas.width),e.tintCanvas.height!==e.canvas.height&&(e.tintCanvas.height=e.canvas.height);const t=e.tintCanvas.getContext("2d");t.save(),t.clearRect(0,0,e.canvas.width,e.canvas.height);const r=this.states.tint._getRGBA([255,255,255,255]);return r[0]<255||r[1]<255||r[2]<255?(t.drawImage(e.canvas,0,0),t.globalCompositeOperation="luminosity",t.drawImage(e.canvas,0,0),t.globalCompositeOperation="color",t.drawImage(e.canvas,0,0),t.globalCompositeOperation="multiply",t.fillStyle=`rgb(${r.slice(0,3).join(", ")})`,t.fillRect(0,0,e.canvas.width,e.canvas.height),t.globalCompositeOperation="destination-in",t.globalAlpha=r[3]/255,t.drawImage(e.canvas,0,0)):(t.globalAlpha=r[3]/255,t.drawImage(e.canvas,0,0)),t.restore(),e.tintCanvas}blendMode(e){if(void 0===e)return this._cachedBlendMode;if(e===re)console.warn("blendMode(SUBTRACT) only works in WEBGL mode.");else{if(e!==Y&&e!==K&&e!==Q&&e!==ee&&e!==te&&e!==ie&&e!==ne&&e!==se&&e!==oe&&e!==ae&&e!==ue&&e!==le&&e!==he&&e!==ce&&e!==J)throw new Error(`Mode ${e} not recognized.`);this._cachedBlendMode=e,this.drawingContext.globalCompositeOperation=e}}blend(...e){const t=this.drawingContext.globalCompositeOperation,r=e[e.length-1],n=Array.prototype.slice.call(e,0,e.length-1);this.drawingContext.globalCompositeOperation=r,uu.prototype.copy.apply(this,n),this.drawingContext.globalCompositeOperation=t}_getPixel(e,t){let r,n;return r=this.drawingContext.getImageData(e,t,1,1).data,n=0,[r[0],r[1],r[2],r[3]]}loadPixels(){const e=this._pixelDensity,t=this.width*e,r=this.height*e,n=this.drawingContext.getImageData(0,0,t,r);this.imageData=n,this.pixels=n.data}set(e,t,r){if(e=Math.floor(e),t=Math.floor(t),r instanceof Qo||r instanceof Mi){this.drawingContext.save(),this.drawingContext.setTransform(1,0,0,1,0,0),this.drawingContext.scale(this._pixelDensity,this._pixelDensity);const n=r.width,i=r.height;this.drawingContext.clearRect(e,t,n,i),this.drawingContext.drawImage(r.canvas,e,t,n,i)}else{let n=0,i=0,s=0,o=0,a=4*(t*this._pixelDensity*(this.width*this._pixelDensity)+e*this._pixelDensity);if(this.imageData||this.loadPixels(),"number"==typeof r)a<this.pixels.length&&(n=r,i=r,s=r,o=255);else if(Array.isArray(r)){if(r.length<4)throw new Error("pixel array must be of the form [R, G, B, A]");a<this.pixels.length&&(n=r[0],i=r[1],s=r[2],o=r[3])}else r instanceof uu.Color&&a<this.pixels.length&&([n,i,s,o]=r._getRGBA([255,255,255,255]));for(let r=0;r<this._pixelDensity;r++)for(let u=0;u<this._pixelDensity;u++)a=4*((t*this._pixelDensity+u)*this.width*this._pixelDensity+(e*this._pixelDensity+r)),this.pixels[a]=n,this.pixels[a+1]=i,this.pixels[a+2]=s,this.pixels[a+3]=o}}updatePixels(e,t,r,n){const i=this._pixelDensity;void 0===e&&void 0===t&&void 0===r&&void 0===n&&(e=0,t=0,r=this.width,n=this.height),e*=i,t*=i,r*=i,n*=i,this.gifProperties&&(this.gifProperties.frames[this.gifProperties.displayIndex].image=this.imageData),this.drawingContext.putImageData(this.imageData,0,0,e,t,r,n)}arc(e,t,r,n,i,s,o){const a=new uu.Shape({position:new uu.Vector(0,0)});return a.beginShape(),a.arcPrimitive(e,t,r,n,i,s,o),a.endShape(),this.drawShape(a),this}ellipse(e){const t=parseFloat(e[0]),r=parseFloat(e[1]),n=parseFloat(e[2]),i=parseFloat(e[3]),s=new uu.Shape({position:new uu.Vector(0,0)});return s.beginShape(),s.ellipsePrimitive(t,r,n,i),s.endShape(),this.drawShape(s),this}line(e,t,r,n){const i=new uu.Shape({position:new uu.Vector(0,0)});return i.beginShape(),i.line(e,t,r,n),i.endShape(),this.drawShape(i),this}point(e,t){const r=new uu.Shape({position:new uu.Vector(0,0)});return r.beginShape(),r.point(e,t),r.endShape(),this.drawShape(r),this}quad(e,t,r,n,i,s,o,a){const u=new uu.Shape({position:new uu.Vector(0,0)});return u.beginShape(),u.quad(e,t,r,n,i,s,o,a),u.endShape(),this.drawShape(u),this}rect(e){const t=e[0],r=e[1],n=e[2],i=e[3];let s=e[4],o=e[5],a=e[6],u=e[7];const l=new uu.Shape({position:new uu.Vector(0,0)});return l.beginShape(),l.rectPrimitive(t,r,n,i,s,o,a,u),l.endShape(),this.drawShape(l),this}triangle(e){const t=e[0],r=e[1],n=e[2],i=e[3],s=e[4],o=e[5],a=new uu.Shape({position:new uu.Vector(0,0)});return a.beginShape(),a.triangle(t,r,n,i,s,o),a.endShape(),this.drawShape(a),this}strokeCap(e){return void 0===e?this.drawingContext.lineCap:(e!==q&&e!==H&&e!==$||(this.drawingContext.lineCap=e),this)}strokeJoin(e){return void 0===e?this.drawingContext.lineJoin:(e!==q&&e!==W&&e!==X||(this.drawingContext.lineJoin=e),this)}strokeWeight(e){return super.strokeWeight(e),void 0===e?this.states.strokeWeight:(this.drawingContext.lineWidth=0===e?1e-4:e,this)}_getFill(){return this.states._cachedFillStyle||this.states.setValue("_cachedFillStyle",this.drawingContext.fillStyle),this.states._cachedFillStyle}_setFill(e){e!==this.states._cachedFillStyle&&(this.drawingContext.fillStyle=e,this.states.setValue("_cachedFillStyle",e))}_getStroke(){return this.states._cachedStrokeStyle||this.states.setValue("_cachedStrokeStyle",this.drawingContext.strokeStyle),this.states._cachedStrokeStyle}_setStroke(e){e!==this.states._cachedStrokeStyle&&(this.drawingContext.strokeStyle=e,this.states.setValue("_cachedStrokeStyle",e))}applyMatrix(e,t,r,n,i,s){this.drawingContext.transform(e,t,r,n,i,s)}getWorldToScreenMatrix(){let e=(new DOMMatrix).scale(1/this._pixelDensity).multiply(this.drawingContext.getTransform());return new uo(e.toFloat32Array())}resetMatrix(){return this.drawingContext.setTransform(1,0,0,1,0,0),this.drawingContext.scale(this._pixelDensity,this._pixelDensity),this}rotate(e){return this.drawingContext.rotate(e),this}scale(e,t){return"object"==typeof e&&"x"in e&&"y"in e&&(t=e.y,e=e.x),this.drawingContext.scale(e,t),this}translate(e,t){return"object"==typeof e&&"x"in e&&"y"in e&&(t=e.y,e=e.x),this.drawingContext.translate(e,t),this}push(){return this.drawingContext.save(),super.push()}pop(e){this.drawingContext.restore(),super.pop(e)}textCanvas(){return this.canvas}textDrawingContext(){return this.drawingContext}_renderText(e,t,r,n,i){let s=this.states,o=this.textDrawingContext();r<i||r>=n||(this.push(),s.strokeColor&&s.strokeSet&&o.strokeText(e,t,r),!this._clipping&&s.fillColor&&(s.fillSet||this._setFill("#000000"),o.fillText(e,t,r)),this.pop())}_positionLines(e,t,r,n,i){let s,{textLeading:o,textAlign:a}=this.states,u=new Array(i.length),l=void 0===r?0:r,h=void 0===n?0:n;for(let r=0;r<i.length;r++){switch(a){case Oo:throw new Error("textBounds: START not yet supported for textAlign");case A:s=e;break;case D:s=e+l/2;break;case S:s=e+l;break;case Bo:throw new Error("textBounds: END not yet supported for textAlign")}u[r]={text:i[r],x:s,y:t+r*o}}return this._yAlignOffset(u,h)}_yAlignOffset(e,t){if(void 0===t)throw Error("_yAlignOffset: height is required");let{textLeading:r,textBaseline:n}=this.states,i=0,s=t-r*(e.length-1);switch(n){case T:case I:break;case Io:i=s/2+this._middleAlignOffset();break;case F:i=s;break;case Fo:console.warn("textBounds: IDEOGRAPHIC not yet supported for textBaseline");break;case Mo:console.warn("textBounds: HANGING not yet supported for textBaseline")}return e.forEach((e=>e.y+=i)),e}}let uu=class e{static VERSION=r;static instance=null;static sketchCount=0;static lifecycleHooks={presetup:[],postsetup:[],predraw:[],postdraw:[],remove:[]};static _checkForUserDefinedFunctions=()=>{};static _friendlyFileLoadError=()=>{};constructor(t,r){e.decorations.size>0&&(lu(e,e.decorations,"p5"),e.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();const n=function(e){return function(t){if("constructor"===t)return;const r=Object.getOwnPropertyDescriptor(e,t),n=Object.getOwnPropertyDescriptor(uu.prototype,t),i=r&&r.get||n&&n.get;let s,o=!1,a=!1;if(!i){const e=uu.prototype[t];o="function"==typeof e,o||void 0===qe[t]||(a=!0,s=e)}if(o){const r=uu.prototype[t].bind(e);Object.defineProperty(window,t,{configurable:!0,enumerable:!0,value:r})}else if(a)Object.defineProperty(window,t,{configurable:!0,enumerable:!0,value:s});else if(i||!o){let r=null,n=null,i=null;Object.defineProperty(window,t,{configurable:!0,enumerable:!0,get:()=>{const s=e[t];return null===i?(i="function"==typeof s,i?(r=s,n=s.bind(e),n):s):i?(s!==r&&(r=s,n=s.bind(e)),n):s}})}}}(this);if(t)t(this),e._checkForUserDefinedFunctions(this);else{if(this._isGlobal=!0,window.hitCriticalError)return;e.instance=this;for(const t of Object.getOwnPropertyNames(e.prototype))"_"!==t[0]&&n(t);const t=["constructor","length"];for(const e in this)if(this.hasOwnProperty(e)){if("_"===e[0]||t.includes(e))continue;n(e)}}const i=()=>{this.focused=!0},s=()=>{this.focused=!1};"undefined"!=typeof window?(window.addEventListener("focus",i),window.addEventListener("blur",s),e.lifecycleHooks.remove.push((function(){window.removeEventListener("focus",i),window.removeEventListener("blur",s)})),"complete"===document.readyState?this.#R():(this._startListener=this.#R.bind(this),window.addEventListener("load",this._startListener,!1))):this.#R()}get pixels(){return this._renderer?.pixels}get drawingContext(){return this._renderer?.drawingContext}static _registeredAddons=new Set;static registerAddon(t){const r={};if(e._registeredAddons.has(t))return;e._registeredAddons.add(t),t(e,e.prototype,r);const n=Object.keys(e.lifecycleHooks);for(const t of n)"function"==typeof r[t]&&e.lifecycleHooks[t].push(r[t])}static decorations=new Map;static registerDecorator(t,r){if("string"==typeof t){const e=t;t=({path:t})=>e===t}else if(Array.isArray(t)&&t.every((e=>"string"==typeof e))){const e=t;t=({path:t})=>e.includes(t)}else if("function"!=typeof t)throw new Error("Decorator matching pattern must be a function, a string, or an array of strings");e.decorations.set(t,r)}#V={};_customActions=new Proxy({},{get:(e,t)=>{if(!this.#V[t]){const e=this._isGlobal?window:this;"function"==typeof e[t]&&(this.#V[t]=e[t].bind(this))}return this.#V[t]}});async#R(){this.hitCriticalError||(this._userNode&&"string"==typeof this._userNode&&(this._userNode=document.getElementById(this._userNode)),await this.#U(),this.hitCriticalError||this._recording||this._draw())}async#U(){if(await this._runLifecycleHook("presetup"),this.hitCriticalError)return;"undefined"!=typeof window&&this.createCanvas(100,100,n),this._millisStart=globalThis.performance.now();const e=this._isGlobal?window:this;if("function"==typeof e.setup&&await e.setup(),!this.hitCriticalError){if("undefined"!=typeof document){const e=document.getElementsByTagName("canvas");for(const t of e)t.style.touchAction="none","true"===t.dataset.hidden&&(t.style.visibility="",delete t.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(e){if(this.hitCriticalError)return;const t=e||globalThis.performance.now(),r=t-this._lastTargetFrameTime,n=1e3/this._targetFrameRate;if((!this._loop||r>=n-5)&&(this.deltaTime=t-this._lastRealFrameTime,this._frameRate=1e3/this.deltaTime,await this.redraw(),this._lastTargetFrameTime=Math.max(this._lastTargetFrameTime+n,t),this._lastRealFrameTime=t,void 0!==this._updateMouseCoords&&(this._updateMouseCoords(),this.movedX=0,this.movedY=0)),this._loop){const e=this._draw.bind(this);this._requestAnimId="undefined"!=typeof window?window.requestAnimationFrame(e):setImmediate(e)}}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();for(const e of this._elements)e.elt&&e.elt.parentNode&&e.elt.parentNode.removeChild(e.elt);await this._runLifecycleHook("remove")}if(this._isGlobal){for(const t in e.prototype)try{delete window[t]}catch(e){window[t]=void 0}for(const e in this)if(this.hasOwnProperty(e))try{delete window[e]}catch(t){window[e]=void 0}e.instance=null}}async _runLifecycleHook(t){await Promise.all(e.lifecycleHooks[t].map((e=>e.call(this))))}_initializeInstanceVariables(){this._accessibleOutputs={text:!1,grid:!1,textLabel:!1,gridLabel:!1},this._styles=[],this._downKeys={},this._downKeyCodes={}}};for(const e in qe)uu.prototype[e]=qe[e];function lu(e,t,r){for(const n in e)if(!n.startsWith("_")){for(const[i,s]of t)if(i({path:`${r}.${n}`}))if("function"==typeof e[n]){const t=s(e[n],{kind:"method",name:n,static:!0});t&&Object.defineProperty(e,n,{enumerable:!0,writable:!0,value:t})}else{const t=s(void 0,{kind:"field",name:n,static:!0});t&&"function"==typeof t&&(e[n]=t(e[n]))}"function"==typeof e[n]&&e[n].prototype&&lu(e[n],t,`${r}.${n}`)}for(const n of Object.getOwnPropertyNames(e.prototype))if("constructor"!==n&&!n.startsWith("_"))for(const[i,s]of t)if(i({path:`${r}.prototype.${n}`}))if("function"==typeof e.prototype[n]){const t=s(e.prototype[n],{kind:"method",name:n,static:!1});t&&Object.defineProperty(e.prototype,n,{enumerable:!0,writable:!0,value:t})}else{const t=Object.getOwnPropertyDescriptor(e.prototype,n);if(t.hasOwnProperty("value")){const t=s(void 0,{kind:"field",name:n,static:!1});Object.defineProperty(e.prototype,n,{enumerable:!0,writable:!0,value:t&&"function"==typeof t?t(e.prototype[n]):e.prototype[n]})}else{const{get:r,set:i}=t,o=s(r,{kind:"getter",name:n,static:!1}),a=s(i,{kind:"setter",name:n,static:!1});Object.defineProperty(e.prototype,n,{enumerable:!0,get:o??r,set:a??i})}}}function hu(e,t){const r="_Description",n="_fallbackDesc",i="_fallbackTable",s="_fte_",o="_Label",a="_labelDesc",u="_labelTable",l="_lte_";function h(e){if("label"===e||"fallback"===e)throw new Error("description should not be LABEL or FALLBACK");return e.endsWith(".")||e.endsWith(";")||e.endsWith(",")||e.endsWith("?")||e.endsWith("!")||(e+="."),e}t.describe=function(e,t){if("string"!=typeof e)return;const r=this.canvas.id;e=h(e),this.dummyDOM||(this.dummyDOM=document.getElementById(r).parentNode),this.descriptions||(this.descriptions={}),this.descriptions.fallback?this.descriptions.fallback.innerHTML!==e&&(this.descriptions.fallback.innerHTML=e):this._describeHTML("fallback",e),t===this.LABEL&&(this.descriptions.label?this.descriptions.label.innerHTML!==e&&(this.descriptions.label.innerHTML=e):this._describeHTML("label",e))},t.describeElement=function(e,t,r){if("string"!=typeof t||"string"!=typeof e)return;const n=this.canvas.id;t=h(t);let i=function(e){if("label"===e||"fallback"===e)throw new Error("element name should not be LABEL or FALLBACK");e.endsWith(".")||e.endsWith(";")||e.endsWith(",")?e=e.replace(/.$/,":"):e.endsWith(":")||(e+=":");return e}(e);e=e.replace(/[^a-zA-Z0-9]/g,"");let s=`<th scope="row">${i}</th><td>${t}</td>`;this.dummyDOM||(this.dummyDOM=document.getElementById(n).parentNode),this.descriptions?this.descriptions.fallbackElements||(this.descriptions.fallbackElements={}):this.descriptions={fallbackElements:{}},this.descriptions.fallbackElements[e]?this.descriptions.fallbackElements[e].innerHTML!==s&&(this.descriptions.fallbackElements[e].innerHTML=s):this._describeElementHTML("fallback",e,s),r===this.LABEL&&(this.descriptions.labelElements||(this.descriptions.labelElements={}),this.descriptions.labelElements[e]?this.descriptions.labelElements[e].innerHTML!==s&&(this.descriptions.labelElements[e].innerHTML=s):this._describeElementHTML("label",e,s))},t._describeHTML=function(e,t){const s=this.canvas.id;if("fallback"===e){if(this.dummyDOM.querySelector(`#${s+r}`))this.dummyDOM.querySelector("#"+s+i).insertAdjacentHTML("beforebegin",`<p id="${s+n}"></p>`);else{let e=`<div id="${s}${r}" role="region" aria-label="Canvas Description"><p id="${s}${n}"></p></div>`;this.dummyDOM.querySelector(`#${s}accessibleOutput`)?this.dummyDOM.querySelector(`#${s}accessibleOutput`).insertAdjacentHTML("beforebegin",e):this.dummyDOM.querySelector(`#${s}`).innerHTML=e}return this.descriptions.fallback=this.dummyDOM.querySelector(`#${s}${n}`),void(this.descriptions.fallback.innerHTML=t)}if("label"===e){if(this.dummyDOM.querySelector(`#${s+o}`))this.dummyDOM.querySelector(`#${s+u}`)&&this.dummyDOM.querySelector(`#${s+u}`).insertAdjacentHTML("beforebegin",`<p id="${s}${a}"></p>`);else{let e=`<div id="${s}${o}" class="p5Label"><p id="${s}${a}"></p></div>`;this.dummyDOM.querySelector(`#${s}accessibleOutputLabel`)?this.dummyDOM.querySelector(`#${s}accessibleOutputLabel`).insertAdjacentHTML("beforebegin",e):this.dummyDOM.querySelector("#"+s).insertAdjacentHTML("afterend",e)}return this.descriptions.label=this.dummyDOM.querySelector("#"+s+a),void(this.descriptions.label.innerHTML=t)}},t._describeElementHTML=function(e,t,h){const c=this.canvas.id;if("fallback"===e){if(this.dummyDOM.querySelector(`#${c+r}`))this.dummyDOM.querySelector("#"+c+i)||this.dummyDOM.querySelector("#"+c+n).insertAdjacentHTML("afterend",`<table id="${c}${i}"><caption>Canvas elements and their descriptions</caption></table>`);else{let e=`<div id="${c}${r}" role="region" aria-label="Canvas Description"><table id="${c}${i}"><caption>Canvas elements and their descriptions</caption></table></div>`;this.dummyDOM.querySelector(`#${c}accessibleOutput`)?this.dummyDOM.querySelector(`#${c}accessibleOutput`).insertAdjacentHTML("beforebegin",e):this.dummyDOM.querySelector("#"+c).innerHTML=e}let e=document.createElement("tr");return e.id=c+s+t,this.dummyDOM.querySelector("#"+c+i).appendChild(e),this.descriptions.fallbackElements[t]=this.dummyDOM.querySelector(`#${c}${s}${t}`),void(this.descriptions.fallbackElements[t].innerHTML=h)}if("label"===e){if(this.dummyDOM.querySelector(`#${c+o}`))this.dummyDOM.querySelector(`#${c+u}`)||this.dummyDOM.querySelector("#"+c+a).insertAdjacentHTML("afterend",`<table id="${c+u}"></table>`);else{let e=`<div id="${c}${o}" class="p5Label"><table id="${c}${u}"></table></div>`;this.dummyDOM.querySelector(`#${c}accessibleOutputLabel`)?this.dummyDOM.querySelector(`#${c}accessibleOutputLabel`).insertAdjacentHTML("beforebegin",e):this.dummyDOM.querySelector("#"+c).insertAdjacentHTML("afterend",e)}let e=document.createElement("tr");e.id=c+l+t,this.dummyDOM.querySelector("#"+c+u).appendChild(e),this.descriptions.labelElements[t]=this.dummyDOM.querySelector(`#${c}${l}${t}`),this.descriptions.labelElements[t].innerHTML=h}}}function cu(e,t){t._updateGridOutput=function(e){if(this._renderer&&this._renderer.isP3D)return void(this._didOutputGridWebGLMessage||(this._didOutputGridWebGLMessage=!0,console.error("gridOutput() does not yet work in WebGL mode.")));if(!this.dummyDOM.querySelector(`#${e}_summary`))return;let t=this._accessibleOutputs[e],r=function(e,t){let r="",n="",i=0;for(let s in t){let o=0;for(let n in t[s]){let a=`<li id="${e}shape${i}">${t[s][n].color} ${s},`;"line"===s?a+=` location = ${t[s][n].pos}, length = ${t[s][n].length} pixels`:(a+=` location = ${t[s][n].pos}`,"point"!==s&&(a+=`, area = ${t[s][n].area} %`),a+="</li>"),r+=a,o++,i++}n=o>1?`${n} ${o} ${s}s`:`${n} ${o} ${s}`}return{numShapes:[i,n],details:r}}(e,this.ingredients.shapes),n=function(e,t,r,n){let i=`${t} canvas, ${r} by ${n} pixels, contains ${e[0]}`;i=1===e[0]?`${i} shape: ${e[1]}`:`${i} shapes: ${e[1]}`;return i}(r.numShapes,this.ingredients.colors.background,this.width,this.height),i=function(e,t){let r=0,n="",i=Array.from(Array(10),(()=>Array(10)));for(let n in t)for(let s in t[n]){let o;o="line"!==n?`<a href="#${e}shape${r}">${t[n][s].color} ${n}</a>`:`<a href="#${e}shape${r}">${t[n][s].color} ${n} midpoint</a>`,t[n][s].loc.locY<i.length&&t[n][s].loc.locX<i[t[n][s].loc.locY].length&&(i[t[n][s].loc.locY][t[n][s].loc.locX]?i[t[n][s].loc.locY][t[n][s].loc.locX]=i[t[n][s].loc.locY][t[n][s].loc.locX]+"  "+o:i[t[n][s].loc.locY][t[n][s].loc.locX]=o,r++)}for(let e in i){let t="<tr>";for(let r in i[e])t+="<td>",void 0!==i[e][r]&&(t+=i[e][r]),t+="</td>";n=n+t+"</tr>"}return n}(e,this.ingredients.shapes);n!==t.summary.innerHTML&&(t.summary.innerHTML=n),i!==t.map.innerHTML&&(t.map.innerHTML=i),r.details!==t.shapeDetails.innerHTML&&(t.shapeDetails.innerHTML=r.details),this._accessibleOutputs[e]=t}}function du(e,t){t._updateTextOutput=function(e){if(this._renderer&&this._renderer.isP3D)return void(this._didOutputTextWebGLMessage||(this._didOutputTextWebGLMessage=!0,console.error("textOutput() does not yet work in WebGL mode.")));if(!this.dummyDOM.querySelector(`#${e}_summary`))return;let t=this._accessibleOutputs[e],r=function(e,t){let r="",n=0;for(let i in t)for(let s in t[i]){let o=`<li><a href="#${e}shape${n}">${t[i][s].color} ${i}</a>`;"line"===i?o+=`, ${t[i][s].pos}, ${t[i][s].length} pixels long.</li>`:(o+=`, at ${t[i][s].pos}`,"point"!==i&&(o+=`, covering ${t[i][s].area}% of the canvas`),o+=".</li>"),r+=o,n++}return{numShapes:n,listShapes:r}}(e,this.ingredients.shapes),n=function(e,t,r,n){let i=`Your output is a, ${r} by ${n} pixels, ${t} canvas containing the following`;i=1===e?`${i} shape:`:`${i} ${e} shapes:`;return i}(r.numShapes,this.ingredients.colors.background,this.width,this.height),i=function(e,t){let r="",n=0;for(let i in t)for(let s in t[i]){let o=`<tr id="${e}shape${n}"><th>${t[i][s].color} ${i}</th>`;"line"===i?o+=`<td>location = ${t[i][s].pos}</td><td>length = ${t[i][s].length} pixels</td></tr>`:(o+=`<td>location = ${t[i][s].pos}</td>`,"point"!==i&&(o+=`<td> area = ${t[i][s].area}%</td>`),o+="</tr>"),r+=o,n++}return r}(e,this.ingredients.shapes);n!==t.summary.innerHTML&&(t.summary.innerHTML=n),r.listShapes!==t.list.innerHTML&&(t.list.innerHTML=r.listShapes),i!==t.shapeDetails.innerHTML&&(t.shapeDetails.innerHTML=i),this._accessibleOutputs[e]=t}}function pu(e,t){function r(e,t,r){let n=Math.floor(e[0]/t*10),i=Math.floor(e[1]/r*10);return 10===n&&(n-=1),10===i&&(i-=1),{locX:n,locY:i}}t.textOutput=function(e){this._accessibleOutputs.text||(this._accessibleOutputs.text=!0,this._createOutput("textOutput","Fallback"),e===this.LABEL&&(this._accessibleOutputs.textLabel=!0,this._createOutput("textOutput","Label")))},t.gridOutput=function(e){this._accessibleOutputs.grid||(this._accessibleOutputs.grid=!0,this._createOutput("gridOutput","Fallback"),e===this.LABEL&&(this._accessibleOutputs.gridLabel=!0,this._createOutput("gridOutput","Label")))},t._addAccsOutput=function(){return this._accessibleOutputs||(this._accessibleOutputs={text:!1,grid:!1,textLabel:!1,gridLabel:!1}),this._accessibleOutputs.grid||this._accessibleOutputs.text},t._createOutput=function(e,t){let r,n,i,s=this.canvas.id;this.ingredients||(this.ingredients={shapes:{},colors:{background:"white",fill:"white",stroke:"black"},pShapes:"",pBackground:""}),this.dummyDOM||(this.dummyDOM=document.getElementById(s).parentNode);let o="";"Fallback"===t?(r=s+e,n=s+"accessibleOutput",this.dummyDOM.querySelector(`#${n}`)||(this.dummyDOM.querySelector(`#${s}_Description`)?this.dummyDOM.querySelector(`#${s}_Description`).insertAdjacentHTML("afterend",`<div id="${n}" role="region" aria-label="Canvas Outputs"></div>`):this.dummyDOM.querySelector(`#${s}`).innerHTML=`<div id="${n}" role="region" aria-label="Canvas Outputs"></div>`)):"Label"===t&&(o=t,r=s+e+t,n=s+"accessibleOutput"+t,this.dummyDOM.querySelector(`#${n}`)||(this.dummyDOM.querySelector(`#${s}_Label`)?this.dummyDOM.querySelector(`#${s}_Label`).insertAdjacentHTML("afterend",`<div id="${n}"></div>`):this.dummyDOM.querySelector(`#${s}`).insertAdjacentHTML("afterend",`<div id="${n}"></div>`))),this._accessibleOutputs[r]={},"textOutput"===e?(o=`#${s}gridOutput${o}`,i=`<div id="${r}">Text Output<div id="${r}Summary" aria-label="text output summary"><p id="${r}_summary"></p><ul id="${r}_list"></ul></div><table id="${r}_shapeDetails" summary="text output shape details"></table></div>`,this.dummyDOM.querySelector(o)?this.dummyDOM.querySelector(o).insertAdjacentHTML("beforebegin",i):this.dummyDOM.querySelector(`#${n}`).innerHTML=i,this._accessibleOutputs[r].list=this.dummyDOM.querySelector(`#${r}_list`)):"gridOutput"===e&&(o=`#${s}textOutput${o}`,i=`<div id="${r}">Grid Output<p id="${r}_summary" aria-label="grid output summary"><table id="${r}_map" summary="grid output content"></table><ul id="${r}_shapeDetails" aria-label="grid output shape details"></ul></div>`,this.dummyDOM.querySelector(o)?this.dummyDOM.querySelector(o).insertAdjacentHTML("afterend",i):this.dummyDOM.querySelector(`#${n}`).innerHTML=i,this._accessibleOutputs[r].map=this.dummyDOM.querySelector(`#${r}_map`)),this._accessibleOutputs[r].shapeDetails=this.dummyDOM.querySelector(`#${r}_shapeDetails`),this._accessibleOutputs[r].summary=this.dummyDOM.querySelector(`#${r}_summary`)},t._updateAccsOutput=function(){let e=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(e+"textOutput"),this._accessibleOutputs.grid&&this._updateGridOutput(e+"gridOutput"),this._accessibleOutputs.textLabel&&this._updateTextOutput(e+"textOutputLabel"),this._accessibleOutputs.gridLabel&&this._updateGridOutput(e+"gridOutputLabel"))},t._accsBackground=function(e){this.ingredients.pShapes=JSON.stringify(this.ingredients.shapes),this.ingredients.pBackground=this.ingredients.colors.background,this.ingredients.shapes={},this.ingredients.colors.backgroundRGBA!==e&&(this.ingredients.colors.backgroundRGBA=e,this.ingredients.colors.background=this._rgbColorName(e))},t._accsCanvasColors=function(e,t){"fill"===e?this.ingredients.colors.fillRGBA!==t&&(this.ingredients.colors.fillRGBA=t,this.ingredients.colors.fill=this._rgbColorName(t)):"stroke"===e&&this.ingredients.colors.strokeRGBA!==t&&(this.ingredients.colors.strokeRGBA=t,this.ingredients.colors.stroke=this._rgbColorName(t))},t._accsOutput=function(e,t){"ellipse"===e&&t[2]===t[3]?e="circle":"rectangle"===e&&t[2]===t[3]&&(e="square");let n={},i=!0,s=function(e,t){let r,n;"rectangle"===e||"ellipse"===e||"arc"===e||"circle"===e||"square"===e?(r=Math.round(t[0]+t[2]/2),n=Math.round(t[1]+t[3]/2)):"triangle"===e?(r=(t[0]+t[2]+t[4])/3,n=(t[1]+t[3]+t[5])/3):"quadrilateral"===e?(r=(t[0]+t[2]+t[4]+t[6])/4,n=(t[1]+t[3]+t[5]+t[7])/4):"line"===e?(r=(t[0]+t[2])/2,n=(t[1]+t[3])/2):(r=t[0],n=t[1]);return[r,n]}(e,t);if("line"===e){n.color=this.ingredients.colors.stroke,n.length=Math.round(Math.hypot(t[2]-t[0],t[3]-t[1]));let e=this._getPos(t[0],[1]),i=this._getPos(t[2],[3]);n.loc=r(s,this.width,this.height),n.pos=e===i?`at ${e}`:`from ${e} to ${i}`}else"point"===e?n.color=this.ingredients.colors.stroke:(n.color=this.ingredients.colors.fill,n.area=this._getArea(e,t)),n.pos=this._getPos(...s),n.loc=r(s,this.width,this.height);if(this.ingredients.shapes[e]){for(let t in this.ingredients.shapes[e])JSON.stringify(this.ingredients.shapes[e][t])===JSON.stringify(n)&&(i=!1);!0===i&&this.ingredients.shapes[e].push(n)}else this.ingredients.shapes[e]=[n]},t._getPos=function(t,r){const{x:n,y:i}=this.worldToScreen(new e.Vector(t,r)),s=this.width,o=this.height;return n<.4*s?i<.4*o?"top left":i>.6*o?"bottom left":"mid left":n>.6*s?i<.4*o?"top right":i>.6*o?"bottom right":"mid right":i<.4*o?"top middle":i>.6*o?"bottom middle":"middle"},t._getArea=function(e,t){let r=0;if("arc"===e){const e=((t[5]-t[4])%(2*Math.PI)+2*Math.PI)%(2*Math.PI);if(r=e*t[2]*t[3]/8,"open"===t[6]||"chord"===t[6]){const n=t[0],i=t[1],s=t[0]+t[2]/2*Math.cos(t[4]).toFixed(2),o=t[1]+t[3]/2*Math.sin(t[4]).toFixed(2),a=t[0]+t[2]/2*Math.cos(t[5]).toFixed(2),u=t[1]+t[3]/2*Math.sin(t[5]).toFixed(2),l=Math.abs(n*(o-u)+s*(u-i)+a*(i-o))/2;e>Math.PI?r+=l:r-=l}}else"ellipse"===e||"circle"===e?r=3.14*t[2]/2*t[3]/2:"line"===e||"point"===e?r=0:"quadrilateral"===e?r=Math.abs((t[6]+t[0])*(t[7]-t[1])+(t[0]+t[2])*(t[1]-t[3])+(t[2]+t[4])*(t[3]-t[5])+(t[4]+t[6])*(t[5]-t[7]))/2:"rectangle"===e||"square"===e?r=t[2]*t[3]:"triangle"===e&&(r=Math.abs(t[0]*(t[3]-t[5])+t[2]*(t[5]-t[1])+t[4]*(t[1]-t[3]))/2);const n=this.width*this._renderer._pixelDensity,i=this.height*this._renderer._pixelDensity,s=[new DOMPoint(0,0),new DOMPoint(n,0),new DOMPoint(n,i),new DOMPoint(0,i)],o=(this._renderer.isP3D?new DOMMatrix(this._renderer.uMVMatrix.mat4):this.drawingContext.getTransform()).inverse(),a=s.map((e=>e.matrixTransform(o))),u=Math.abs((a[3].x+a[0].x)*(a[3].y-a[0].y)+(a[0].x+a[1].x)*(a[0].y-a[1].y)+(a[1].x+a[2].x)*(a[1].y-a[2].y)+(a[2].x+a[3].x)*(a[2].y-a[3].y))/2;return Math.round(100*r/u)}}uu.registerAddon(We),uu.registerAddon(Xe),uu.registerAddon(Ze),uu.registerAddon(ya),uu.registerAddon((function(e,t){e.Renderer=ps})),uu.registerAddon((function(e,t){e.Renderer2D=au,e.renderers[n]=au,e.renderers["p2d-p3"]=new Proxy(au,{construct:(e,[t,r,n,i,s])=>new e(t,r,n,i,s,{colorSpace:"display-p3"})})})),uu.registerAddon((function(e,t){e.Graphics=Qo,xs(e,e.Graphics.prototype),_s(0,e.Graphics.prototype),ws(0,e.Graphics.prototype),Cs(0,e.Graphics.prototype),hs(e,e.Graphics.prototype),Es(0,e.Graphics.prototype),ro(e,e.Graphics.prototype),Is(e,e.Graphics.prototype),no(e,e.Graphics.prototype),We(e,e.Graphics.prototype),$o(e,e.Graphics.prototype),Ho(0,e.Graphics.prototype),Ko(0,e.Graphics.prototype),Un(e,e.Graphics.prototype),Jo(0,e.Graphics.prototype)})),uu.registerAddon((function(e,t,r){r.presetup=function(){if("undefined"==typeof window||this._loadingIndicator)return;const e=this.canvas?.parentElement;let t=this._userNode||e||document.body;"string"==typeof t&&(t=document.getElementById(t)||document.body),this._loadingIndicator=function(e){if(!document.getElementById("p5-loading-style")){const e=document.createElement("style");e.id="p5-loading-style",e.textContent="@keyframes p5-loading-spin { to { transform: rotate(360deg); } }",document.head.appendChild(e)}const t=document.createElement("div");return t.className="loading-indicator",t.style.cssText="\n    position: fixed;\n    inset: 0;\n    margin: auto;\n    width: 30px;\n    height: 30px;\n    border-radius: 50%;\n\n    border: 3px solid rgba(0, 0, 0, 0.1);\n    border-top-color: rgba(0, 0, 0, 0.8);\n    animation: p5-loading-spin 1s linear infinite;\n    z-index: 9999;\n  ",e.appendChild(t),t}(t)},r.postsetup=function(){this._loadingIndicator&&(this._loadingIndicator.remove(),this._loadingIndicator=null)}})),"undefined"!=typeof p5&&hu(p5,p5.prototype),"undefined"!=typeof p5&&cu(p5,p5.prototype),"undefined"!=typeof p5&&du(p5,p5.prototype),"undefined"!=typeof p5&&pu(p5,p5.prototype),uu.ColorConversion={_hsbaToHSLA(e){const t=e[0];let r=e[1];const n=e[2],i=(2-r)*n/2;return 0!==i&&(1===i?r=0:i<.5?r/=2-r:r=r*n/(2-2*i)),[t,r,i,e[3]]},_hsbaToRGBA(e){const t=6*e[0],r=e[1],n=e[2];let i=[];if(0===r)i=[n,n,n,e[3]];else{const s=Math.floor(t),o=n*(1-r),a=n*(1-r*(t-s)),u=n*(1-r*(1+s-t));let l,h,c;1===s?(l=a,h=n,c=o):2===s?(l=o,h=n,c=u):3===s?(l=o,h=a,c=n):4===s?(l=u,h=o,c=n):5===s?(l=n,h=o,c=a):(l=n,h=u,c=o),i=[l,h,c,e[3]]}return i},_hslaToHSBA(e){const t=e[0];let r=e[1];const n=e[2];let i;return i=n<.5?(1+r)*n:n+r-n*r,r=2*(i-n)/i,[t,r,i,e[3]]},_hslaToRGBA(e){const t=6*e[0],r=e[1],n=e[2];let i=[];if(0===r)i=[n,n,n,e[3]];else{let s;s=n<.5?(1+r)*n:n+r-n*r;const o=2*n-s,a=(e,t,r)=>(e<0?e+=6:e>=6&&(e-=6),e<1?t+(r-t)*e:e<3?r:e<4?t+(r-t)*(4-e):t);i=[a(t+2,o,s),a(t,o,s),a(t-2,o,s),e[3]]}return i},_rgbaToHSBA(e){const t=e[0],r=e[1],n=e[2],i=Math.max(t,r,n),s=i-Math.min(t,r,n);let o,a;return 0===s?(o=0,a=0):(a=s/i,t===i?o=(r-n)/s:r===i?o=2+(n-t)/s:n===i&&(o=4+(t-r)/s),o<0?o+=6:o>=6&&(o-=6)),[o/6,a,i,e[3]]},_rgbaToHSLA(e){const t=e[0],r=e[1],n=e[2],i=Math.max(t,r,n),s=Math.min(t,r,n),o=i+s,a=i-s;let u,l;return 0===a?(u=0,l=0):(l=o<1?a/o:a/(2-o),t===i?u=(r-n)/a:r===i?u=2+(n-t)/a:n===i&&(u=4+(t-r)/a),u<0?u+=6:u>=6&&(u-=6)),[u/6,l,o/2,e[3]]}};var fu=uu.ColorConversion;function mu(e,t){let r;const n=[{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"}],i=[{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"}];t._rgbColorName=function(e){let t=fu._rgbaToHSBA(e);return r=t,function(e){let t;if(0!==e[0]){e[0]=Math.round(100*e[0]);let t=e[0].toString().split("");const r=t.length-1;t[r]=parseInt(t[r]),t[r]<2.5?t[r]=0:t[r]>=2.5&&t[r]<7.5&&(t[r]=5),2===t.length?(t[0]=parseInt(t[0]),t[r]>=7.5&&(t[r]=0,t[0]=t[0]+1),e[0]=10*t[0]+t[1]):t[r]>=7.5?e[0]=10:e[0]=t[r]}e[2]=e[2]/255;for(let t=e.length-1;t>=1;t--)e[t]<=.25?e[t]=0:e[t]>.25&&e[t]<.75?e[t]=.5:e[t]=1;if(0===e[0]&&0===e[1]&&1===e[2]){for(let e=2;e>=0;e--)r[e]=Math.round(1e4*r[e])/1e4;for(let e=0;e<n.length;e++){if(n[e].h===r[0]&&n[e].s===r[1]&&n[e].b===r[2]){t=n[e].name;break}t="white"}}else for(let r=0;r<i.length;r++)if(i[r].h===e[0]&&i[r].s===e[1]&&i[r].b===e[2]){t=i[r].name;break}return t}([t[0],t[1],t[2]])}}function gu(e){return gu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},gu(e)}function yu(e){var t=function(e,t){if("object"!=gu(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!=gu(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==gu(t)?t:t+""}function vu(e,t,r){return(t=yu(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function bu(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?Object(arguments[t]):{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&n.push.apply(n,Object.getOwnPropertySymbols(r).filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach((function(t){vu(e,t,r[t])}))}return e}function xu(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _u(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,yu(n.key),n)}}function wu(e,t,r){return t&&_u(e.prototype,t),r&&_u(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Cu(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Eu(e,t){if(t&&("object"==gu(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Cu(e)}function Su(e){return Su=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Su(e)}function Au(e,t){return Au=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Au(e,t)}function Du(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Au(e,t)}"undefined"!=typeof p5&&mu(p5,p5.prototype);var Tu={type:"logger",log:function(e){this.output("log",e)},warn:function(e){this.output("warn",e)},error:function(e){this.output("error",e)},output:function(e,t){console&&console[e]&&console[e].apply(console,t)}},Fu=new(function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};xu(this,e),this.init(t,r)}return wu(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||Tu,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"log","",!0)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"warn","",!0)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"error","")}},{key:"deprecate",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(e,t,r,n){return n&&!this.debug?null:("string"==typeof e[0]&&(e[0]="".concat(r).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(t){return new e(this.logger,bu({},{prefix:"".concat(this.prefix,":").concat(t,":")},this.options))}}]),e}()),Iu=function(){function e(){xu(this,e),this.observers={}}return wu(e,[{key:"on",value:function(e,t){var r=this;return e.split(" ").forEach((function(e){r.observers[e]=r.observers[e]||[],r.observers[e].push(t)})),this}},{key:"off",value:function(e,t){this.observers[e]&&(t?this.observers[e]=this.observers[e].filter((function(e){return e!==t})):delete this.observers[e])}},{key:"emit",value:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this.observers[e]&&[].concat(this.observers[e]).forEach((function(e){e.apply(void 0,r)}));this.observers["*"]&&[].concat(this.observers["*"]).forEach((function(t){t.apply(t,[e].concat(r))}))}}]),e}();function ku(){var e,t,r=new Promise((function(r,n){e=r,t=n}));return r.resolve=e,r.reject=t,r}function Nu(e){return null==e?"":""+e}function Mu(e,t,r){function n(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function i(){return!e||"string"==typeof e}for(var s="string"!=typeof t?[].concat(t):t.split(".");s.length>1;){if(i())return{};var o=n(s.shift());!e[o]&&r&&(e[o]=new r),e=Object.prototype.hasOwnProperty.call(e,o)?e[o]:{}}return i()?{}:{obj:e,k:n(s.shift())}}function Ou(e,t,r){var n=Mu(e,t,Object);n.obj[n.k]=r}function Bu(e,t){var r=Mu(e,t),n=r.obj,i=r.k;if(n)return n[i]}function Lu(e,t,r){var n=Bu(e,r);return void 0!==n?n:Bu(t,r)}function Pu(e,t,r){for(var n in t)"__proto__"!==n&&"constructor"!==n&&(n in e?"string"==typeof e[n]||e[n]instanceof String||"string"==typeof t[n]||t[n]instanceof String?r&&(e[n]=t[n]):Pu(e[n],t[n],r):e[n]=t[n]);return e}function Ru(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var Vu={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function Uu(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(function(e){return Vu[e]})):e}var zu="undefined"!=typeof window&&window.navigator&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,ju=function(){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return xu(this,e),r=Eu(this,Su(e).call(this)),zu&&Iu.call(Cu(r)),r.data=t||{},r.options=n,void 0===r.options.keySeparator&&(r.options.keySeparator="."),r}return Du(e,Iu),wu(e,[{key:"addNamespaces",value:function(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,s=[e,t];return r&&"string"!=typeof r&&(s=s.concat(r)),r&&"string"==typeof r&&(s=s.concat(i?r.split(i):r)),e.indexOf(".")>-1&&(s=e.split(".")),Bu(this.data,s)}},{key:"addResource",value:function(e,t,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},s=this.options.keySeparator;void 0===s&&(s=".");var o=[e,t];r&&(o=o.concat(s?r.split(s):r)),e.indexOf(".")>-1&&(n=t,t=(o=e.split("."))[1]),this.addNamespaces(t),Ou(this.data,o,n),i.silent||this.emit("added",e,t,r,n)}},{key:"addResources",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var i in r)"string"!=typeof r[i]&&"[object Array]"!==Object.prototype.toString.apply(r[i])||this.addResource(e,t,i,r[i],{silent:!0});n.silent||this.emit("added",e,t,r)}},{key:"addResourceBundle",value:function(e,t,r,n,i){var s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},o=[e,t];e.indexOf(".")>-1&&(n=r,r=t,t=(o=e.split("."))[1]),this.addNamespaces(t);var a=Bu(this.data,o)||{};n?Pu(a,r,i):a=bu({},a,r),Ou(this.data,o,a),s.silent||this.emit("added",e,t,r)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI?bu({},{},this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"toJSON",value:function(){return this.data}}]),e}(),Gu={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,r,n,i){var s=this;return e.forEach((function(e){s.processors[e]&&(t=s.processors[e].process(t,r,n,i))})),t}},$u={},Hu=function(){function e(t){var r,n,i,s,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return xu(this,e),r=Eu(this,Su(e).call(this)),zu&&Iu.call(Cu(r)),n=["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],i=t,s=Cu(r),n.forEach((function(e){i[e]&&(s[e]=i[e])})),r.options=o,void 0===r.options.keySeparator&&(r.options.keySeparator="."),r.logger=Fu.create("translator"),r}return Du(e,Iu),wu(e,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}},r=this.resolve(e,t);return r&&void 0!==r.res}},{key:"extractFromKey",value:function(e,t){var r=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===r&&(r=":");var n=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,i=t.ns||this.options.defaultNS;if(r&&e.indexOf(r)>-1){var s=e.match(this.interpolator.nestingRegexp);if(s&&s.length>0)return{key:e,namespaces:i};var o=e.split(r);(r!==n||r===n&&this.options.ns.indexOf(o[0])>-1)&&(i=o.shift()),e=o.join(n)}return"string"==typeof i&&(i=[i]),{key:e,namespaces:i}}},{key:"translate",value:function(t,r,n){var i=this;if("object"!==gu(r)&&this.options.overloadTranslationOptionHandler&&(r=this.options.overloadTranslationOptionHandler(arguments)),r||(r={}),null==t)return"";Array.isArray(t)||(t=[String(t)]);var s=void 0!==r.keySeparator?r.keySeparator:this.options.keySeparator,o=this.extractFromKey(t[t.length-1],r),a=o.key,u=o.namespaces,l=u[u.length-1],h=r.lng||this.language,c=r.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(h&&"cimode"===h.toLowerCase()){if(c){var d=r.nsSeparator||this.options.nsSeparator;return l+d+a}return a}var p=this.resolve(t,r),f=p&&p.res,m=p&&p.usedKey||a,g=p&&p.exactUsedKey||a,y=Object.prototype.toString.apply(f),v=void 0!==r.joinArrays?r.joinArrays:this.options.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject;if(b&&f&&("string"!=typeof f&&"boolean"!=typeof f&&"number"!=typeof f)&&["[object Number]","[object Function]","[object RegExp]"].indexOf(y)<0&&("string"!=typeof v||"[object Array]"!==y)){if(!r.returnObjects&&!this.options.returnObjects)return this.logger.warn("accessing an object - but returnObjects options is not enabled!"),this.options.returnedObjectHandler?this.options.returnedObjectHandler(m,f,r):"key '".concat(a," (").concat(this.language,")' returned an object instead of string.");if(s){var x="[object Array]"===y,_=x?[]:{},w=x?g:m;for(var C in f)if(Object.prototype.hasOwnProperty.call(f,C)){var E="".concat(w).concat(s).concat(C);_[C]=this.translate(E,bu({},r,{joinArrays:!1,ns:u})),_[C]===E&&(_[C]=f[C])}f=_}}else if(b&&"string"==typeof v&&"[object Array]"===y)(f=f.join(v))&&(f=this.extendTranslation(f,t,r,n));else{var S=!1,A=!1,D=void 0!==r.count&&"string"!=typeof r.count,T=e.hasDefaultValue(r),F=D?this.pluralResolver.getSuffix(h,r.count):"",I=r["defaultValue".concat(F)]||r.defaultValue;!this.isValidLookup(f)&&T&&(S=!0,f=I),this.isValidLookup(f)||(A=!0,f=a);var k=T&&I!==f&&this.options.updateMissing;if(A||S||k){if(this.logger.log(k?"updateKey":"missingKey",h,l,a,k?I:f),s){var N=this.resolve(a,bu({},r,{keySeparator:!1}));N&&N.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var M=[],O=this.languageUtils.getFallbackCodes(this.options.fallbackLng,r.lng||this.language);if("fallback"===this.options.saveMissingTo&&O&&O[0])for(var B=0;B<O.length;B++)M.push(O[B]);else"all"===this.options.saveMissingTo?M=this.languageUtils.toResolveHierarchy(r.lng||this.language):M.push(r.lng||this.language);var L=function(e,t,n){i.options.missingKeyHandler?i.options.missingKeyHandler(e,l,t,k?n:f,k,r):i.backendConnector&&i.backendConnector.saveMissing&&i.backendConnector.saveMissing(e,l,t,k?n:f,k,r),i.emit("missingKey",e,l,t,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&D?M.forEach((function(e){i.pluralResolver.getSuffixes(e).forEach((function(t){L([e],a+t,r["defaultValue".concat(t)]||I)}))})):L(M,a,I))}f=this.extendTranslation(f,t,r,p,n),A&&f===a&&this.options.appendNamespaceToMissingKey&&(f="".concat(l,":").concat(a)),A&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(f))}return f}},{key:"extendTranslation",value:function(e,t,r,n,i){var s=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,r,n.usedLng,n.usedNS,n.usedKey,{resolved:n});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init(bu({},r,{interpolation:bu({},this.options.interpolation,r.interpolation)}));var o,a=r.interpolation&&r.interpolation.skipOnVariables||this.options.interpolation.skipOnVariables;if(a){var u=e.match(this.interpolator.nestingRegexp);o=u&&u.length}var l=r.replace&&"string"!=typeof r.replace?r.replace:r;if(this.options.interpolation.defaultVariables&&(l=bu({},this.options.interpolation.defaultVariables,l)),e=this.interpolator.interpolate(e,l,r.lng||this.language,r),a){var h=e.match(this.interpolator.nestingRegexp);o<(h&&h.length)&&(r.nest=!1)}!1!==r.nest&&(e=this.interpolator.nest(e,(function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];return i&&i[0]===n[0]&&!r.context?(s.logger.warn("It seems you are nesting recursively key: ".concat(n[0]," in key: ").concat(t[0])),null):s.translate.apply(s,n.concat([t]))}),r)),r.interpolation&&this.interpolator.reset()}var c=r.postProcess||this.options.postProcess,d="string"==typeof c?[c]:c;return null!=e&&d&&d.length&&!1!==r.applyPostProcessor&&(e=Gu.handle(d,e,t,this.options&&this.options.postProcessPassResolved?bu({i18nResolved:n},r):r,this)),e}},{key:"resolve",value:function(e){var t,r,n,i,s,o=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach((function(e){if(!o.isValidLookup(t)){var u=o.extractFromKey(e,a),l=u.key;r=l;var h=u.namespaces;o.options.fallbackNS&&(h=h.concat(o.options.fallbackNS));var c=void 0!==a.count&&"string"!=typeof a.count,d=void 0!==a.context&&"string"==typeof a.context&&""!==a.context,p=a.lngs?a.lngs:o.languageUtils.toResolveHierarchy(a.lng||o.language,a.fallbackLng);h.forEach((function(e){o.isValidLookup(t)||(s=e,!$u["".concat(p[0],"-").concat(e)]&&o.utils&&o.utils.hasLoadedNamespace&&!o.utils.hasLoadedNamespace(s)&&($u["".concat(p[0],"-").concat(e)]=!0,o.logger.warn('key "'.concat(r,'" for languages "').concat(p.join(", "),'" won\'t get resolved as namespace "').concat(s,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),p.forEach((function(r){if(!o.isValidLookup(t)){i=r;var s,u,h=l,p=[h];if(o.i18nFormat&&o.i18nFormat.addLookupKeys)o.i18nFormat.addLookupKeys(p,l,r,e,a);else c&&(s=o.pluralResolver.getSuffix(r,a.count)),c&&d&&p.push(h+s),d&&p.push(h+="".concat(o.options.contextSeparator).concat(a.context)),c&&p.push(h+=s);for(;u=p.pop();)o.isValidLookup(t)||(n=u,t=o.getResource(r,e,u,a))}})))}))}})),{res:t,usedKey:r,exactUsedKey:n,usedLng:i,usedNS:s}}},{key:"isValidLookup",value:function(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,r,n):this.resourceStore.getResource(e,t,r,n)}}],[{key:"hasDefaultValue",value:function(e){var t="defaultValue";for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t===r.substring(0,12)&&void 0!==e[r])return!0;return!1}}]),e}();function qu(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Wu=function(){function e(t){xu(this,e),this.options=t,this.whitelist=this.options.supportedLngs||!1,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Fu.create("languageUtils")}return wu(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return null;var t=e.split("-");return 2===t.length?null:(t.pop(),"x"===t[t.length-1].toLowerCase()?null:this.formatLanguageCode(t.join("-")))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],r=e.split("-");return this.options.lowerCaseLng?r=r.map((function(e){return e.toLowerCase()})):2===r.length?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),t.indexOf(r[1].toLowerCase())>-1&&(r[1]=qu(r[1].toLowerCase()))):3===r.length&&(r[0]=r[0].toLowerCase(),2===r[1].length&&(r[1]=r[1].toUpperCase()),"sgn"!==r[0]&&2===r[2].length&&(r[2]=r[2].toUpperCase()),t.indexOf(r[1].toLowerCase())>-1&&(r[1]=qu(r[1].toLowerCase())),t.indexOf(r[2].toLowerCase())>-1&&(r[2]=qu(r[2].toLowerCase()))),r.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isWhitelisted",value:function(e){return this.logger.deprecate("languageUtils.isWhitelisted",'function "isWhitelisted" will be renamed to "isSupportedCode" in the next major - please make sure to rename it\'s usage asap.'),this.isSupportedCode(e)}},{key:"isSupportedCode",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}},{key:"getBestMatchFromCodes",value:function(e){var t,r=this;return e?(e.forEach((function(e){if(!t){var n=r.formatLanguageCode(e);r.options.supportedLngs&&!r.isSupportedCode(n)||(t=n)}})),!t&&this.options.supportedLngs&&e.forEach((function(e){if(!t){var n=r.getLanguagePartFromCode(e);if(r.isSupportedCode(n))return t=n;t=r.options.supportedLngs.find((function(e){if(0===e.indexOf(n))return e}))}})),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var r=e[t];return r||(r=e[this.getScriptPartFromCode(t)]),r||(r=e[this.formatLanguageCode(t)]),r||(r=e[this.getLanguagePartFromCode(t)]),r||(r=e.default),r||[]}},{key:"toResolveHierarchy",value:function(e,t){var r=this,n=this.getFallbackCodes(t||this.options.fallbackLng||[],e),i=[],s=function(e){e&&(r.isSupportedCode(e)?i.push(e):r.logger.warn("rejecting language code not found in supportedLngs: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&s(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&s(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&s(this.getLanguagePartFromCode(e))):"string"==typeof e&&s(this.formatLanguageCode(e)),n.forEach((function(e){i.indexOf(e)<0&&s(r.formatLanguageCode(e))})),i}}]),e}(),Xu=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","kk","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],Zu={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(1==e||e%10==1&&e%100!=11?0:1)},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}};var Yu=function(){function e(t){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};xu(this,e),this.languageUtils=t,this.options=n,this.logger=Fu.create("pluralResolver"),this.rules=(r={},Xu.forEach((function(e){e.lngs.forEach((function(t){r[t]={numbers:e.nr,plurals:Zu[e.fc]}}))})),r)}return wu(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=this.getRule(e);return t&&t.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){return this.getSuffixes(e).map((function(e){return t+e}))}},{key:"getSuffixes",value:function(e){var t=this,r=this.getRule(e);return r?r.numbers.map((function(r){return t.getSuffix(e,r)})):[]}},{key:"getSuffix",value:function(e,t){var r=this,n=this.getRule(e);if(n){var i=n.noAbs?n.plurals(t):n.plurals(Math.abs(t)),s=n.numbers[i];this.options.simplifyPluralSuffix&&2===n.numbers.length&&1===n.numbers[0]&&(2===s?s="plural":1===s&&(s=""));var o=function(){return r.options.prepend&&s.toString()?r.options.prepend+s.toString():s.toString()};return"v1"===this.options.compatibilityJSON?1===s?"":"number"==typeof s?"_plural_".concat(s.toString()):o():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===n.numbers.length&&1===n.numbers[0]?o():this.options.prepend&&i.toString()?this.options.prepend+i.toString():i.toString()}return this.logger.warn("no plural rule found for: ".concat(e)),""}}]),e}(),Ku=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};xu(this,e),this.logger=Fu.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return wu(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:Uu,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?Ru(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?Ru(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?Ru(t.nestingPrefix):t.nestingPrefixEscaped||Ru("$t("),this.nestingSuffix=t.nestingSuffix?Ru(t.nestingSuffix):t.nestingSuffixEscaped||Ru(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(t,"g");var r="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(r,"g")}},{key:"interpolate",value:function(e,t,r,n){var i,s,o,a=this,u=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function l(e){return e.replace(/\$/g,"$$$$")}var h=function(e){if(e.indexOf(a.formatSeparator)<0){var i=Lu(t,u,e);return a.alwaysFormat?a.format(i,void 0,r):i}var s=e.split(a.formatSeparator),o=s.shift().trim(),l=s.join(a.formatSeparator).trim();return a.format(Lu(t,u,o),l,r,n)};this.resetRegExp();var c=n&&n.missingInterpolationHandler||this.options.missingInterpolationHandler,d=n&&n.interpolation&&n.interpolation.skipOnVariables||this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(e){return l(e)}},{regex:this.regexp,safeValue:function(e){return a.escapeValue?l(a.escape(e)):l(e)}}].forEach((function(t){for(o=0;i=t.regex.exec(e);){if(void 0===(s=h(i[1].trim())))if("function"==typeof c){var r=c(e,i,n);s="string"==typeof r?r:""}else{if(d){s=i[0];continue}a.logger.warn("missed to pass in variable ".concat(i[1]," for interpolating ").concat(e)),s=""}else"string"==typeof s||a.useRawValueToEscape||(s=Nu(s));if(e=e.replace(i[0],t.safeValue(s)),t.regex.lastIndex=0,++o>=a.maxReplaces)break}})),e}},{key:"nest",value:function(e,t){var r,n,i=this,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=bu({},s);function a(e,t){var r=this.nestingOptionsSeparator;if(e.indexOf(r)<0)return e;var n=e.split(new RegExp("".concat(r,"[ ]*{"))),i="{".concat(n[1]);e=n[0],i=(i=this.interpolate(i,o)).replace(/'/g,'"');try{o=JSON.parse(i),t&&(o=bu({},t,o))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(r).concat(i)}return delete o.defaultValue,e}for(o.applyPostProcessor=!1,delete o.defaultValue;r=this.nestingRegexp.exec(e);){var u=[],l=!1;if(r[0].includes(this.formatSeparator)&&!/{.*}/.test(r[1])){var h=r[1].split(this.formatSeparator).map((function(e){return e.trim()}));r[1]=h.shift(),u=h,l=!0}if((n=t(a.call(this,r[1].trim(),o),o))&&r[0]===e&&"string"!=typeof n)return n;"string"!=typeof n&&(n=Nu(n)),n||(this.logger.warn("missed to resolve ".concat(r[1]," for nesting ").concat(e)),n=""),l&&(n=u.reduce((function(e,t){return i.format(e,t,s.lng,s)}),n.trim())),e=e.replace(r[0],n),this.regexp.lastIndex=0}return e}}]),e}();var Ju=function(){function e(t,r,n){var i,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return xu(this,e),i=Eu(this,Su(e).call(this)),zu&&Iu.call(Cu(i)),i.backend=t,i.store=r,i.services=n,i.languageUtils=n.languageUtils,i.options=s,i.logger=Fu.create("backendConnector"),i.state={},i.queue=[],i.backend&&i.backend.init&&i.backend.init(n,s.backend,s),i}return Du(e,Iu),wu(e,[{key:"queueLoad",value:function(e,t,r,n){var i=this,s=[],o=[],a=[],u=[];return e.forEach((function(e){var n=!0;t.forEach((function(t){var a="".concat(e,"|").concat(t);!r.reload&&i.store.hasResourceBundle(e,t)?i.state[a]=2:i.state[a]<0||(1===i.state[a]?o.indexOf(a)<0&&o.push(a):(i.state[a]=1,n=!1,o.indexOf(a)<0&&o.push(a),s.indexOf(a)<0&&s.push(a),u.indexOf(t)<0&&u.push(t)))})),n||a.push(e)})),(s.length||o.length)&&this.queue.push({pending:o,loaded:{},errors:[],callback:n}),{toLoad:s,pending:o,toLoadLanguages:a,toLoadNamespaces:u}}},{key:"loaded",value:function(e,t,r){var n=e.split("|"),i=n[0],s=n[1];t&&this.emit("failedLoading",i,s,t),r&&this.store.addResourceBundle(i,s,r),this.state[e]=t?-1:2;var o={};this.queue.forEach((function(r){!function(e,t,r){var n=Mu(e,t,Object),i=n.obj,s=n.k;i[s]=i[s]||[],i[s].push(r)}(r.loaded,[i],s),function(e,t){for(var r=e.indexOf(t);-1!==r;)e.splice(r,1),r=e.indexOf(t)}(r.pending,e),t&&r.errors.push(t),0!==r.pending.length||r.done||(Object.keys(r.loaded).forEach((function(e){o[e]||(o[e]=[]),r.loaded[e].length&&r.loaded[e].forEach((function(t){o[e].indexOf(t)<0&&o[e].push(t)}))})),r.done=!0,r.errors.length?r.callback(r.errors):r.callback())})),this.emit("loaded",o),this.queue=this.queue.filter((function(e){return!e.done}))}},{key:"read",value:function(e,t,r){var n=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:350,o=arguments.length>5?arguments[5]:void 0;return e.length?this.backend[r](e,t,(function(a,u){a&&u&&i<5?setTimeout((function(){n.read.call(n,e,t,r,i+1,2*s,o)}),s):o(a,u)})):o(null,{})}},{key:"prepareLoading",value:function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),i&&i();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var s=this.queueLoad(e,t,n,i);if(!s.toLoad.length)return s.pending.length||i(),null;s.toLoad.forEach((function(e){r.loadOne(e)}))}},{key:"load",value:function(e,t,r){this.prepareLoading(e,t,{},r)}},{key:"reload",value:function(e,t,r){this.prepareLoading(e,t,{reload:!0},r)}},{key:"loadOne",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=e.split("|"),i=n[0],s=n[1];this.read(i,s,"read",void 0,void 0,(function(n,o){n&&t.logger.warn("".concat(r,"loading namespace ").concat(s," for language ").concat(i," failed"),n),!n&&o&&t.logger.log("".concat(r,"loaded namespace ").concat(s," for language ").concat(i),o),t.loaded(e,n,o)}))}},{key:"saveMissing",value:function(e,t,r,n,i){var s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t)?this.logger.warn('did not save key "'.concat(r,'" as the namespace "').concat(t,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!"):null!=r&&""!==r&&(this.backend&&this.backend.create&&this.backend.create(e,t,r,n,null,bu({},s,{isUpdate:i})),e&&e[0]&&this.store.addResource(e[0],t,r,n))}}]),e}();function Qu(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.whitelist&&(e.whitelist&&e.whitelist.indexOf("cimode")<0&&(e.whitelist=e.whitelist.concat(["cimode"])),e.supportedLngs=e.whitelist),e.nonExplicitWhitelist&&(e.nonExplicitSupportedLngs=e.nonExplicitWhitelist),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function el(){}var tl=function(){function e(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(xu(this,e),t=Eu(this,Su(e).call(this)),zu&&Iu.call(Cu(t)),t.options=Qu(r),t.services={},t.logger=Fu,t.modules={external:[]},n&&!t.isInitialized&&!r.isClone){if(!t.options.initImmediate)return t.init(r,n),Eu(t,Cu(t));setTimeout((function(){t.init(r,n)}),0)}return t}return Du(e,Iu),wu(e,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;function n(e){return e?"function"==typeof e?new e:e:null}if("function"==typeof t&&(r=t,t={}),t.whitelist&&!t.supportedLngs&&this.logger.deprecate("whitelist",'option "whitelist" will be renamed to "supportedLngs" in the next major - please make sure to rename this option asap.'),t.nonExplicitWhitelist&&!t.nonExplicitSupportedLngs&&this.logger.deprecate("whitelist",'options "nonExplicitWhitelist" will be renamed to "nonExplicitSupportedLngs" in the next major - please make sure to rename this option asap.'),this.options=bu({},{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,whitelist:!1,nonExplicitWhitelist:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===gu(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===gu(e[2])||"object"===gu(e[3])){var r=e[3]||e[2];Object.keys(r).forEach((function(e){t[e]=r[e]}))}return t},interpolation:{escapeValue:!0,format:function(e,t,r,n){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!1}},this.options,Qu(t)),this.format=this.options.interpolation.format,r||(r=el),!this.options.isClone){this.modules.logger?Fu.init(n(this.modules.logger),this.options):Fu.init(null,this.options);var i=new Wu(this.options);this.store=new ju(this.options.resources,this.options);var s=this.services;s.logger=Fu,s.resourceStore=this.store,s.languageUtils=i,s.pluralResolver=new Yu(i,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),s.interpolator=new Ku(this.options),s.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},s.backendConnector=new Ju(n(this.modules.backend),s.resourceStore,s,this.options),s.backendConnector.on("*",(function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];e.emit.apply(e,[t].concat(n))})),this.modules.languageDetector&&(s.languageDetector=n(this.modules.languageDetector),s.languageDetector.init(s,this.options.detection,this.options)),this.modules.i18nFormat&&(s.i18nFormat=n(this.modules.i18nFormat),s.i18nFormat.init&&s.i18nFormat.init(this)),this.translator=new Hu(this.services,this.options),this.translator.on("*",(function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];e.emit.apply(e,[t].concat(n))})),this.modules.external.forEach((function(t){t.init&&t.init(e)}))}if(this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){var o=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);o.length>0&&"dev"!==o[0]&&(this.options.lng=o[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined");["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach((function(t){e[t]=function(){var r;return(r=e.store)[t].apply(r,arguments)}}));["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((function(t){e[t]=function(){var r;return(r=e.store)[t].apply(r,arguments),e}}));var a=ku(),u=function(){var t=function(t,n){e.isInitialized&&e.logger.warn("init: i18next is already initialized. You should call init just once!"),e.isInitialized=!0,e.options.isClone||e.logger.log("initialized",e.options),e.emit("initialized",e.options),a.resolve(n),r(t,n)};if(e.languages&&"v1"!==e.options.compatibilityAPI&&!e.isInitialized)return t(null,e.t.bind(e));e.changeLanguage(e.options.lng,t)};return this.options.resources||!this.options.initImmediate?u():setTimeout(u,0),a}},{key:"loadResources",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:el,n="string"==typeof e?e:this.language;if("function"==typeof e&&(r=e),!this.options.resources||this.options.partialBundledLanguages){if(n&&"cimode"===n.toLowerCase())return r();var i=[],s=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach((function(e){i.indexOf(e)<0&&i.push(e)}))};if(n)s(n);else this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((function(e){return s(e)}));this.options.preload&&this.options.preload.forEach((function(e){return s(e)})),this.services.backendConnector.load(i,this.options.ns,r)}else r(null)}},{key:"reloadResources",value:function(e,t,r){var n=ku();return e||(e=this.languages),t||(t=this.options.ns),r||(r=el),this.services.backendConnector.reload(e,t,(function(e){n.resolve(),r(e)})),n}},{key:"use",value:function(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&Gu.addPostProcessor(e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"changeLanguage",value:function(e,t){var r=this;this.isLanguageChangingTo=e;var n=ku();this.emit("languageChanging",e);var i=function(e){var i="string"==typeof e?e:r.services.languageUtils.getBestMatchFromCodes(e);i&&(r.language||(r.language=i,r.languages=r.services.languageUtils.toResolveHierarchy(i)),r.translator.language||r.translator.changeLanguage(i),r.services.languageDetector&&r.services.languageDetector.cacheUserLanguage(i)),r.loadResources(i,(function(e){!function(e,i){i?(r.language=i,r.languages=r.services.languageUtils.toResolveHierarchy(i),r.translator.changeLanguage(i),r.isLanguageChangingTo=void 0,r.emit("languageChanged",i),r.logger.log("languageChanged",i)):r.isLanguageChangingTo=void 0,n.resolve((function(){return r.t.apply(r,arguments)})),t&&t(e,(function(){return r.t.apply(r,arguments)}))}(e,i)}))};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(i):i(e):i(this.services.languageDetector.detect()),n}},{key:"getFixedT",value:function(e,t){var r=this,n=function e(t,n){var i;if("object"!==gu(n)){for(var s=arguments.length,o=new Array(s>2?s-2:0),a=2;a<s;a++)o[a-2]=arguments[a];i=r.options.overloadTranslationOptionHandler([t,n].concat(o))}else i=bu({},n);return i.lng=i.lng||e.lng,i.lngs=i.lngs||e.lngs,i.ns=i.ns||e.ns,r.t(t,i)};return"string"==typeof e?n.lng=e:n.lngs=e,n.ns=t,n}},{key:"t",value:function(){var e;return this.translator&&(e=this.translator).translate.apply(e,arguments)}},{key:"exists",value:function(){var e;return this.translator&&(e=this.translator).exists.apply(e,arguments)}},{key:"setDefaultNamespace",value:function(e){this.options.defaultNS=e}},{key:"hasLoadedNamespace",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var n=this.languages[0],i=!!this.options&&this.options.fallbackLng,s=this.languages[this.languages.length-1];if("cimode"===n.toLowerCase())return!0;var o=function(e,r){var n=t.services.backendConnector.state["".concat(e,"|").concat(r)];return-1===n||2===n};if(r.precheck){var a=r.precheck(this,o);if(void 0!==a)return a}return!!this.hasResourceBundle(n,e)||(!this.services.backendConnector.backend||!(!o(n,e)||i&&!o(s,e)))}},{key:"loadNamespaces",value:function(e,t){var r=this,n=ku();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach((function(e){r.options.ns.indexOf(e)<0&&r.options.ns.push(e)})),this.loadResources((function(e){n.resolve(),t&&t(e)})),n):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var r=ku();"string"==typeof e&&(e=[e]);var n=this.options.preload||[],i=e.filter((function(e){return n.indexOf(e)<0}));return i.length?(this.options.preload=n.concat(i),this.loadResources((function(e){r.resolve(),t&&t(e)})),r):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){if(e||(e=this.languages&&this.languages.length>0?this.languages[0]:this.language),!e)return"rtl";return["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam"].indexOf(this.services.languageUtils.getLanguagePartFromCode(e))>=0?"rtl":"ltr"}},{key:"createInstance",value:function(){return new e(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}},{key:"cloneInstance",value:function(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:el,i=bu({},this.options,r,{isClone:!0}),s=new e(i);return["store","services","language"].forEach((function(e){s[e]=t[e]})),s.services=bu({},this.services),s.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s.translator=new Hu(s.services,s.options),s.translator.on("*",(function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];s.emit.apply(s,[e].concat(r))})),s.init(i,n),s.translator.options=s.options,s.translator.backendConnector.services.utils={hasLoadedNamespace:s.hasLoadedNamespace.bind(s)},s}}]),e}(),rl=new tl,nl=[],il=nl.forEach,sl=nl.slice;var ol,al=function(e,t,r,n){var i,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{path:"/"};if(r){var o=new Date;o.setTime(o.getTime()+60*r*1e3),i="; expires="+o.toUTCString()}else i="";n=n?"domain="+n+";":"",s=Object.keys(s).reduce((function(e,t){return e+";"+t.replace(/([A-Z])/g,(function(e){return"-"+e.toLowerCase()}))+"="+s[t]}),""),document.cookie=e+"="+encodeURIComponent(t)+i+";"+n+s},ul=function(e){for(var t=e+"=",r=document.cookie.split(";"),n=0;n<r.length;n++){for(var i=r[n];" "===i.charAt(0);)i=i.substring(1,i.length);if(0===i.indexOf(t))return i.substring(t.length,i.length)}return null},ll={name:"cookie",lookup:function(e){var t;if(e.lookupCookie&&"undefined"!=typeof document){var r=ul(e.lookupCookie);r&&(t=r)}return t},cacheUserLanguage:function(e,t){t.lookupCookie&&"undefined"!=typeof document&&al(t.lookupCookie,e,t.cookieMinutes,t.cookieDomain,t.cookieOptions)}},hl={name:"querystring",lookup:function(e){var t;if("undefined"!=typeof window)for(var r=window.location.search.substring(1).split("&"),n=0;n<r.length;n++){var i=r[n].indexOf("=");if(i>0)r[n].substring(0,i)===e.lookupQuerystring&&(t=r[n].substring(i+1))}return t}};try{ol="undefined"!==window&&null!==window.localStorage;var cl="i18next.translate.boo";window.localStorage.setItem(cl,"foo"),window.localStorage.removeItem(cl)}catch(e){ol=!1}var dl,pl={name:"localStorage",lookup:function(e){var t;if(e.lookupLocalStorage&&ol){var r=window.localStorage.getItem(e.lookupLocalStorage);r&&(t=r)}return t},cacheUserLanguage:function(e,t){t.lookupLocalStorage&&ol&&window.localStorage.setItem(t.lookupLocalStorage,e)}};try{dl="undefined"!==window&&null!==window.sessionStorage;var fl="i18next.translate.boo";window.sessionStorage.setItem(fl,"foo"),window.sessionStorage.removeItem(fl)}catch(e){dl=!1}var ml={name:"sessionStorage",lookup:function(e){var t;if(e.lookupsessionStorage&&dl){var r=window.sessionStorage.getItem(e.lookupsessionStorage);r&&(t=r)}return t},cacheUserLanguage:function(e,t){t.lookupsessionStorage&&dl&&window.sessionStorage.setItem(t.lookupsessionStorage,e)}},gl={name:"navigator",lookup:function(e){var t=[];if("undefined"!=typeof navigator){if(navigator.languages)for(var r=0;r<navigator.languages.length;r++)t.push(navigator.languages[r]);navigator.userLanguage&&t.push(navigator.userLanguage),navigator.language&&t.push(navigator.language)}return t.length>0?t:void 0}},yl={name:"htmlTag",lookup:function(e){var t,r=e.htmlTag||("undefined"!=typeof document?document.documentElement:null);return r&&"function"==typeof r.getAttribute&&(t=r.getAttribute("lang")),t}},vl={name:"path",lookup:function(e){var t;if("undefined"!=typeof window){var r=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(r instanceof Array)if("number"==typeof e.lookupFromPathIndex){if("string"!=typeof r[e.lookupFromPathIndex])return;t=r[e.lookupFromPathIndex].replace("/","")}else t=r[0].replace("/","")}return t}},bl={name:"subdomain",lookup:function(e){var t;if("undefined"!=typeof window){var r=window.location.href.match(/(?:http[s]*\:\/\/)*(.*?)\.(?=[^\/]*\..{2,5})/gi);r instanceof Array&&(t="number"==typeof e.lookupFromSubdomainIndex?r[e.lookupFromSubdomainIndex].replace("http://","").replace("https://","").replace(".",""):r[0].replace("http://","").replace("https://","").replace(".",""))}return t}};var xl=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};xu(this,e),this.type="languageDetector",this.detectors={},this.init(t,r)}return wu(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.services=e,this.options=function(e){return il.call(sl.call(arguments,1),(function(t){if(t)for(var r in t)void 0===e[r]&&(e[r]=t[r])})),e}(t,this.options||{},{order:["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"],lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],checkWhitelist:!0,checkForSimilarInWhitelist:!1}),this.options.checkForSimilarInWhitelist&&(this.options.checkWhitelist=!0),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=r,this.addDetector(ll),this.addDetector(hl),this.addDetector(pl),this.addDetector(ml),this.addDetector(gl),this.addDetector(yl),this.addDetector(vl),this.addDetector(bl)}},{key:"addDetector",value:function(e){this.detectors[e.name]=e}},{key:"detect",value:function(e){var t=this;e||(e=this.options.order);var r,n=[];if(e.forEach((function(e){if(t.detectors[e]){var r=t.detectors[e].lookup(t.options);r&&"string"==typeof r&&(r=[r]),r&&(n=n.concat(r))}})),n.forEach((function(e){if(!r){var n=t.services.languageUtils.formatLanguageCode(e);t.options.checkWhitelist&&!t.services.languageUtils.isWhitelisted(n)||(r=n),!r&&t.options.checkForSimilarInWhitelist&&(r=t.getSimilarInWhitelist(n))}})),!r){var i=this.i18nOptions.fallbackLng;"string"==typeof i&&(i=[i]),i||(i=[]),r="[object Array]"===Object.prototype.toString.apply(i)?i[0]:i[0]||i.default&&i.default[0]}return r}},{key:"cacheUserLanguage",value:function(e,t){var r=this;t||(t=this.options.caches),t&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(e)>-1||t.forEach((function(t){r.detectors[t]&&r.detectors[t].cacheUserLanguage(e,r.options)})))}},{key:"getSimilarInWhitelist",value:function(e){var t=this;if(this.i18nOptions.whitelist){if(e.includes("-")){var r=e.split("-")[0],n=this.services.languageUtils.formatLanguageCode(r);if(this.services.languageUtils.isWhitelisted(n))return n;e=n}var i=this.i18nOptions.whitelist.find((function(r){var n=t.services.languageUtils.formatLanguageCode(r);if(n.startsWith(e))return n}));return i||void 0}}}]),e}();xl.type="languageDetector";var _l={en:{translation:{fes:{autoplay:"The media that tried to play (with '{{src}}') wasn't allowed to by this browser, most likely due to the browser's autoplay policy.\n\n+ More info: {{url}}",checkUserDefinedFns:"It seems that you may have accidentally written {{name}} instead of {{actualName}}. Please correct it if it's not intentional.",fileLoadError:{bytes:"It looks like there was a problem loading your file. {{suggestion}}",font:"It looks like there was a problem loading your font. {{suggestion}}",gif:"There was some trouble loading your GIF. Make sure that your GIF is using 87a or 89a encoding.",image:"It looks like there was a problem loading your image. {{suggestion}}",json:"It looks like there was a problem loading your JSON file. {{suggestion}}",large:"If your large file isn't fetched successfully, we recommend splitting the file into smaller segments and fetching those.",strings:"It looks like there was a problem loading your text file. {{suggestion}}",suggestion:"Try checking if the file path ({{filePath}}) is correct, hosting the file online, or running a local server.\n\n+ More info: {{url}}",table:"It looks like there was a problem loading your table file. {{suggestion}}",xml:"It looks like there was a problem loading your XML file. {{suggestion}}"},friendlyParamError:{type_EMPTY_VAR:"{{location}} {{func}}() was expecting {{formatType}} for the {{position}} parameter, received an empty variable instead. If not intentional, this is often a problem with scope.\n\n+ More info: {{url}}",type_TOO_FEW_ARGUMENTS:"{{location}} {{func}}() was expecting at least {{minParams}} arguments, but received only {{argCount}}.",type_TOO_MANY_ARGUMENTS:"{{location}} {{func}}() was expecting no more than {{maxParams}} arguments, but received {{argCount}}.",type_WRONG_TYPE:"{{location}} {{func}}() was expecting {{formatType}} for the {{position}} parameter, received {{argType}} instead."},globalErrors:{reference:{cannotAccess:'\n{{location}} "{{symbol}}" is used before declaration. Make sure you have declared the variable before using it.\n\n+ More info: {{url}}',notDefined:'\n{{location}} "{{symbol}}" 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: {{url}}'},stackSubseq:"└[{{location}}] \n\t Called from line {{line}} in {{func}}()\n",stackTop:"┌[{{location}}] \n\t Error at line {{line}} in {{func}}()\n",syntax:{badReturnOrYield:"\nSyntax 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}}",invalidToken:"\nSyntax Error - Found a symbol that JavaScript doesn't recognize or didn't expect at it's place.\n\n+ More info: {{url}}",missingInitializer:"\nSyntax 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}}",redeclaredVariable:'\nSyntax Error - "{{symbol}}" 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}}',unexpectedToken:"\nSyntax 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}}"},type:{constAssign:"\n{{location}} 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: {{url}}",notfunc:'\n{{location}} "{{symbol}}" could not be called as a function.\nCheck the spelling, letter-casing (JavaScript is case-sensitive) and its type.\n\n+ More info: {{url}}',notfuncObj:'\n{{location}} "{{symbol}}" could not be called as a function.\nVerify whether "{{obj}}" has "{{symbol}}" in it and check the spelling, letter-casing (JavaScript is case-sensitive) and its type.\n\n+ More info: {{url}}',readFromNull:"\n{{location}} The property of null can't be read. In javascript the value null indicates that an object has no value.\n\n+ More info: {{url}}",readFromUndefined:"\n{{location}} 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: {{url}}"}},libraryError:'{{location}} An error with message "{{error}}" occurred inside the p5js library when {{func}} was called. If not stated otherwise, it might be an issue with the arguments passed to {{func}}.',location:"[{{file}}, line {{line}}]",misspelling:'{{location}} It seems that you may have accidentally written "{{name}}" instead of "{{actualName}}". Please correct it to {{actualName}} if you wish to use the {{type}} from p5.js.',misspelling_plural:'{{location}} It seems that you may have accidentally written "{{name}}".\nYou may have meant one of the following: \n{{suggestions}}',misusedTopLevel:"Did you just try to use p5.js's {{symbolName}} {{symbolType}}? If so, you may want to move it into your sketch's setup() function.\n\n+ More info: {{url}}",preloadDisabled:"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.",positions:{p_1:"first",p_10:"tenth",p_11:"eleventh",p_12:"twelfth",p_2:"second",p_3:"third",p_4:"fourth",p_5:"fifth",p_6:"sixth",p_7:"seventh",p_8:"eighth",p_9:"ninth"},pre:"\n🌸 p5.js says: {{message}}",sketchReaderErrors:{reservedConst:'you have used a p5.js reserved variable "{{symbol}}" make sure you change the variable name to something else.\n\n+ More info: {{url}}',reservedFunc:'you have used a p5.js reserved function "{{symbol}}" make sure you change the function name to something else.\n\n+ More info: {{url}}'},welcome:"Welcome! This is your friendly debugger. To turn me off, switch to using p5.min.js.",wrongPreload:'{{location}} An error with message "{{error}}" occurred inside the p5js library when "{{func}}" was called. If not stated otherwise, it might be due to "{{func}}" being called from preload. Nothing besides load calls (loadImage, loadJSON, loadFont, loadStrings, etc.) should be inside the preload function.'}}}};const wl=["en","es","ko","zh","hi","ja"];class Cl{constructor(e,t){this.init(e,t)}fetchWithTimeout(e,t,r=2e3){return Promise.race([fetch(e,t),new Promise(((e,t)=>setTimeout((()=>t(new Error("timeout"))),r)))])}init(e,t={}){this.services=e,this.options=t}read(e,t,r){const n=this.options.loadPath;if(e===this.options.fallback)r(null,_l[e][t]);else if(wl.includes(e)){const i=this.services.interpolator.interpolate(n,{lng:e,ns:t});this.loadUrl(i,r)}else r("Not found",!1)}loadUrl(e,t){this.fetchWithTimeout(e).then((t=>{if(!t.ok)throw new Error(`failed loading ${e}`);return t.json()}),(()=>{throw new Error(`failed loading ${e}`)})).then((e=>t(null,e))).catch(t)}}Cl.type="backend";let El=(e,t)=>{console.debug("p5.js translator called before translations were loaded"),rl.t(e,t)};function Sl(e,t,r){let n=null,i=null;Error;e._friendlyError=e._checkForUserDefinedFunctions=e._fesErrorMonitor=()=>{},n=null;const s="https://github.com/processing/p5.js/wiki/p5.js-overview#why-cant-i-assign-variables-using-p5-functions-and-variables-before-setup";i=()=>{const e={},r=t=>Object.getOwnPropertyNames(t).filter((t=>"_"!==t[0]&&(!(t in e)&&(e[t]=!0,!0)))).map((e=>{let r;return r="function"==typeof t[e]?"function":e===e.toUpperCase()?"constant":"variable",{name:e,type:r}}));n=[].concat(r(t),r(qe)),n.sort(((e,t)=>t.name.length-e.name.length))};const o=(e,t)=>{t||(t=console.log.bind(console)),n||i(),n.some((r=>{if(e.message&&null!==e.message.match(`\\W?${r.name}\\W`)){const e="function"===r.type?`${r.name}()`:r.name;return t(`Did you just try to use p5.js's ${e} ${r.type}? If so, you may want to move it into your sketch's setup() function.\n\nFor more details, see: ${s}`),!0}}))};t._helpForMisusedAtTopLevelCode=o,"undefined"!=typeof document&&"complete"!==document.readyState&&(window.addEventListener("error",o,!1),window.addEventListener("load",(()=>{window.removeEventListener("error",o,!1)})))}function Al(){let e=/(^|@)\S+:\d+/,t=/^\s*at .*(\S+:\d+|\(native\))/m,r=/^(eval@)?(\[native code])?$/;return{parse:function(e){return void 0!==e.stacktrace||void 0!==e["opera#sourceloc"]?this.parseOpera(e):e.stack&&e.stack.match(t)?this.parseV8OrIE(e):e.stack?this.parseFFOrSafari(e):void 0},extractLocation:function(e){if(-1===e.indexOf(":"))return[e];let t=/(.+?)(?::(\d+))?(?::(\d+))?$/.exec(e.replace(/[()]/g,""));return[t[1],t[2]||void 0,t[3]||void 0]},parseV8OrIE:function(e){return e.stack.split("\n").filter((function(e){return!!e.match(t)}),this).map((function(e){e.indexOf("(eval ")>-1&&(e=e.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(\),.*$)/g,""));let t=e.replace(/^\s+/,"").replace(/\(eval code/g,"("),r=t.match(/ (\((.+):(\d+):(\d+)\)$)/);t=r?t.replace(r[0],""):t;let n=t.split(/\s+/).slice(1),i=this.extractLocation(r?r[1]:n.pop());return{functionName:n.join(" ")||void 0,fileName:["eval","<anonymous>"].indexOf(i[0])>-1?void 0:i[0],lineNumber:i[1],columnNumber:i[2],source:e}}),this)},parseFFOrSafari:function(e){return e.stack.split("\n").filter((function(e){return!e.match(r)}),this).map((function(e){if(e.indexOf(" > eval")>-1&&(e=e.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),-1===e.indexOf("@")&&-1===e.indexOf(":"))return{functionName:e};{let t=/((.*".+"[^@]*)?[^@]*)(?:@)/,r=e.match(t),n=r&&r[1]?r[1]:void 0,i=this.extractLocation(e.replace(t,""));return{functionName:n,fileName:i[0],lineNumber:i[1],columnNumber:i[2],source:e}}}),this)},parseOpera:function(e){return!e.stacktrace||e.message.indexOf("\n")>-1&&e.message.split("\n").length>e.stacktrace.split("\n").length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9:function(e){let t=/Line (\d+).*script (?:in )?(\S+)/i,r=e.message.split("\n"),n=[];for(let e=2,i=r.length;e<i;e+=2){let i=t.exec(r[e]);i&&n.push({fileName:i[2],lineNumber:i[1],source:r[e]})}return n},parseOpera10:function(e){let t=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,r=e.stacktrace.split("\n"),n=[];for(let e=0,i=r.length;e<i;e+=2){let i=t.exec(r[e]);i&&n.push({functionName:i[3]||void 0,fileName:i[2],lineNumber:i[1],source:r[e]})}return n},parseOpera11:function(t){return t.stack.split("\n").filter((function(t){return!!t.match(e)&&!t.match(/^Error created at/)}),this).map((function(e){let t,r=e.split("@"),n=this.extractLocation(r.pop()),i=r.shift()||"",s=i.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0;return i.match(/\(([^)]*)\)/)&&(t=i.replace(/^[^(]+\(([^)]*)\)$/,"$1")),{functionName:s,args:void 0===t||"[arguments not available]"===t?void 0:t.split(","),fileName:n[0],lineNumber:n[1],columnNumber:n[2],source:e}}),this)}}}function Dl(e,t){e._getErrorStackParser=function(){return new Al}}function Tl(e,t,r){function n(r,n){if(r._zod||Object.defineProperty(r,"_zod",{value:{def:n,constr:o,traits:new Set},enumerable:!1}),r._zod.traits.has(e))return;r._zod.traits.add(e),t(r,n);const i=o.prototype,s=Object.keys(i);for(let e=0;e<s.length;e++){const t=s[e];t in r||(r[t]=i[t].bind(r))}}const i=r?.Parent??Object;class s extends i{}function o(e){var t;const i=r?.Parent?new s:this;n(i,e),(t=i._zod).deferred??(t.deferred=[]);for(const e of i._zod.deferred)e();return i}return Object.defineProperty(s,"name",{value:e}),Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>!!(r?.Parent&&t instanceof r.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}"undefined"!=typeof p5&&p5.registerAddon(Sl),"undefined"!=typeof p5&&Dl(p5);class Fl extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Il extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const kl={};function Nl(e){return kl}function Ml(e){const t=Object.values(e).filter((e=>"number"==typeof e));return Object.entries(e).filter((([e,r])=>-1===t.indexOf(+e))).map((([e,t])=>t))}function Ol(e,t){return"bigint"==typeof t?t.toString():t}function Bl(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ll(e){return null==e}function Pl(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}const Rl=Symbol("evaluating");function Vl(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Rl)return void 0===n&&(n=Rl,n=r()),n},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function Ul(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function zl(...e){const t={};for(const r of e){const e=Object.getOwnPropertyDescriptors(r);Object.assign(t,e)}return Object.defineProperties({},t)}function jl(e){return JSON.stringify(e)}const Gl="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function $l(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const Hl=Bl((()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}}));function ql(e){if(!1===$l(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const r=t.prototype;return!1!==$l(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}function Wl(e){return ql(e)?{...e}:Array.isArray(e)?[...e]:e}const Xl=new Set(["string","number","symbol"]);function Zl(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Yl(e,t,r){const n=new e._zod.constr(t??e._zod.def);return t&&!r?.parent||(n._zod.parent=e),n}function Kl(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}const Jl={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Ql(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(!0!==e.issues[r]?.continue)return!0;return!1}function eh(e,t){return t.map((t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(e),t}))}function th(e){return"string"==typeof e?e:e?.message}function rh(e,t,r){const n={...e,path:e.path??[]};if(!e.message){const i=th(e.inst?._zod.def?.error?.(e))??th(t?.error?.(e))??th(r.customError?.(e))??th(r.localeError?.(e))??"Invalid input";n.message=i}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function nh(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function ih(...e){const[t,r,n]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:n}:{...t}}const sh=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ol,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},oh=Tl("$ZodError",sh),ah=Tl("$ZodError",sh,{Parent:Error});const uh=e=>(t,r,n,i)=>{const s=n?Object.assign(n,{async:!1}):{async:!1},o=t._zod.run({value:r,issues:[]},s);if(o instanceof Promise)throw new Fl;if(o.issues.length){const t=new(i?.Err??e)(o.issues.map((e=>rh(e,s,Nl()))));throw Gl(t,i?.callee),t}return o.value},lh=uh(ah),hh=e=>async(t,r,n,i)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let o=t._zod.run({value:r,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const t=new(i?.Err??e)(o.issues.map((e=>rh(e,s,Nl()))));throw Gl(t,i?.callee),t}return o.value},ch=hh(ah),dh=e=>(t,r,n)=>{const i=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)throw new Fl;return s.issues.length?{success:!1,error:new(e??oh)(s.issues.map((e=>rh(e,i,Nl()))))}:{success:!0,data:s.value}},ph=dh(ah),fh=e=>async(t,r,n)=>{const i=n?Object.assign(n,{async:!0}):{async:!0};let s=t._zod.run({value:r,issues:[]},i);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map((e=>rh(e,i,Nl()))))}:{success:!0,data:s.value}},mh=fh(ah),gh=e=>(t,r,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return uh(e)(t,r,i)},yh=e=>(t,r,n)=>uh(e)(t,r,n),vh=e=>async(t,r,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return hh(e)(t,r,i)},bh=e=>async(t,r,n)=>hh(e)(t,r,n),xh=e=>(t,r,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return dh(e)(t,r,i)},_h=e=>(t,r,n)=>dh(e)(t,r,n),wh=e=>async(t,r,n)=>{const i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return fh(e)(t,r,i)},Ch=e=>async(t,r,n)=>fh(e)(t,r,n),Eh=/^[cC][^\s-]{8,}$/,Sh=/^[0-9a-z]+$/,Ah=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Dh=/^[0-9a-vA-V]{20}$/,Th=/^[A-Za-z0-9]{27}$/,Fh=/^[a-zA-Z0-9_-]{21}$/,Ih=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,kh=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Nh=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Mh=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const Oh=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Bh=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Lh=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ph=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Rh=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Vh=/^[A-Za-z0-9_-]*$/,Uh=/^\+(?:[0-9]){6,14}[0-9]$/,zh="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",jh=new RegExp(`^${zh}$`);function Gh(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const $h=/^-?\d+$/,Hh=/^-?\d+(?:\.\d+)?/,qh=/^(?:true|false)$/i,Wh=/^[^A-Z]*$/,Xh=/^[^a-z]*$/,Zh=Tl("$ZodCheck",((e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])})),Yh={number:"number",bigint:"bigint",object:"date"},Kh=Tl("$ZodCheckLessThan",((e,t)=>{Zh.init(e,t);const r=Yh[typeof t.value];e._zod.onattach.push((e=>{const r=e._zod.bag,n=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<n&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)})),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}})),Jh=Tl("$ZodCheckGreaterThan",((e,t)=>{Zh.init(e,t);const r=Yh[typeof t.value];e._zod.onattach.push((e=>{const r=e._zod.bag,n=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>n&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)})),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}})),Qh=Tl("$ZodCheckMultipleOf",((e,t)=>{Zh.init(e,t),e._zod.onattach.push((e=>{var r;(r=e._zod.bag).multipleOf??(r.multipleOf=t.value)})),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof r.value?r.value%t.value===BigInt(0):0===function(e,t){const r=(e.toString().split(".")[1]||"").length,n=t.toString();let i=(n.split(".")[1]||"").length;if(0===i&&/\d?e-\d?/.test(n)){const e=n.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}const s=r>i?r:i;return Number.parseInt(e.toFixed(s).replace(".",""))%Number.parseInt(t.toFixed(s).replace(".",""))/10**s}(r.value,t.value))||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}})),ec=Tl("$ZodCheckNumberFormat",((e,t)=>{Zh.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[i,s]=Jl[t.format];e._zod.onattach.push((e=>{const n=e._zod.bag;n.format=t.format,n.minimum=i,n.maximum=s,r&&(n.pattern=$h)})),e._zod.check=o=>{const a=o.value;if(r){if(!Number.isInteger(a))return void o.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});if(!Number.isSafeInteger(a))return void(a>0?o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}):o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}))}a<i&&o.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),a>s&&o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inst:e})}})),tc=Tl("$ZodCheckMaxLength",((e,t)=>{var r;Zh.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!Ll(t)&&void 0!==t.length}),e._zod.onattach.push((e=>{const r=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(e._zod.bag.maximum=t.maximum)})),e._zod.check=r=>{const n=r.value;if(n.length<=t.maximum)return;const i=nh(n);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}})),rc=Tl("$ZodCheckMinLength",((e,t)=>{var r;Zh.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!Ll(t)&&void 0!==t.length}),e._zod.onattach.push((e=>{const r=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(e._zod.bag.minimum=t.minimum)})),e._zod.check=r=>{const n=r.value;if(n.length>=t.minimum)return;const i=nh(n);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}})),nc=Tl("$ZodCheckLengthEquals",((e,t)=>{var r;Zh.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!Ll(t)&&void 0!==t.length}),e._zod.onattach.push((e=>{const r=e._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length})),e._zod.check=r=>{const n=r.value,i=n.length;if(i===t.length)return;const s=nh(n),o=i>t.length;r.issues.push({origin:s,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}})),ic=Tl("$ZodCheckStringFormat",((e,t)=>{var r,n;Zh.init(e,t),e._zod.onattach.push((e=>{const r=e._zod.bag;r.format=t.format,t.pattern&&(r.patterns??(r.patterns=new Set),r.patterns.add(t.pattern))})),t.pattern?(r=e._zod).check??(r.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})})),sc=Tl("$ZodCheckRegex",((e,t)=>{ic.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}})),oc=Tl("$ZodCheckLowerCase",((e,t)=>{t.pattern??(t.pattern=Wh),ic.init(e,t)})),ac=Tl("$ZodCheckUpperCase",((e,t)=>{t.pattern??(t.pattern=Xh),ic.init(e,t)})),uc=Tl("$ZodCheckIncludes",((e,t)=>{Zh.init(e,t);const r=Zl(t.includes),n=new RegExp("number"==typeof t.position?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push((e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)})),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}})),lc=Tl("$ZodCheckStartsWith",((e,t)=>{Zh.init(e,t);const r=new RegExp(`^${Zl(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push((e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)})),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}})),hc=Tl("$ZodCheckEndsWith",((e,t)=>{Zh.init(e,t);const r=new RegExp(`.*${Zl(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push((e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)})),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}})),cc=Tl("$ZodCheckOverwrite",((e,t)=>{Zh.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}));class dc{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter((e=>e)),r=Math.min(...t.map((e=>e.length-e.trimStart().length))),n=t.map((e=>e.slice(r))).map((e=>" ".repeat(2*this.indent)+e));for(const e of n)this.content.push(e)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map((e=>`  ${e}`))].join("\n"))}}const pc={major:4,minor:2,patch:1},fc=Tl("$ZodType",((e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=pc;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const t of n)for(const r of t._zod.onattach)r(e);if(0===n.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push((()=>{e._zod.run=e._zod.parse}));else{const t=(e,t,r)=>{let n,i=Ql(e);for(const s of t){if(s._zod.def.when){if(!s._zod.def.when(e))continue}else if(i)continue;const t=e.issues.length,o=s._zod.check(e);if(o instanceof Promise&&!1===r?.async)throw new Fl;if(n||o instanceof Promise)n=(n??Promise.resolve()).then((async()=>{await o;e.issues.length!==t&&(i||(i=Ql(e,t)))}));else{if(e.issues.length===t)continue;i||(i=Ql(e,t))}}return n?n.then((()=>e)):e},r=(r,i,s)=>{if(Ql(r))return r.aborted=!0,r;const o=t(i,n,s);if(o instanceof Promise){if(!1===s.async)throw new Fl;return o.then((t=>e._zod.parse(t,s)))}return e._zod.parse(o,s)};e._zod.run=(i,s)=>{if(s.skipChecks)return e._zod.parse(i,s);if("backward"===s.direction){const t=e._zod.parse({value:i.value,issues:[]},{...s,skipChecks:!0});return t instanceof Promise?t.then((e=>r(e,i,s))):r(t,i,s)}const o=e._zod.parse(i,s);if(o instanceof Promise){if(!1===s.async)throw new Fl;return o.then((e=>t(e,n,s)))}return t(o,n,s)}}e["~standard"]={validate:t=>{try{const r=ph(e,t);return r.success?{value:r.data}:{issues:r.error?.issues}}catch(r){return mh(e,t).then((e=>e.success?{value:e.data}:{issues:e.error?.issues}))}},vendor:"zod",version:1}})),mc=Tl("$ZodString",((e,t)=>{var r;fc.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(r=e._zod.bag,new RegExp(`^${r?`[\\s\\S]{${r?.minimum??0},${r?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(n){}return"string"==typeof r.value||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}})),gc=Tl("$ZodStringFormat",((e,t)=>{ic.init(e,t),mc.init(e,t)})),yc=Tl("$ZodGUID",((e,t)=>{t.pattern??(t.pattern=kh),gc.init(e,t)})),vc=Tl("$ZodUUID",((e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Nh(e))}else t.pattern??(t.pattern=Nh());gc.init(e,t)})),bc=Tl("$ZodEmail",((e,t)=>{t.pattern??(t.pattern=Mh),gc.init(e,t)})),xc=Tl("$ZodURL",((e,t)=>{gc.init(e,t),e._zod.check=r=>{try{const n=r.value.trim(),i=new URL(n);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),void(t.normalize?r.value=i.href:r.value=n)}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}})),_c=Tl("$ZodEmoji",((e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),gc.init(e,t)})),wc=Tl("$ZodNanoID",((e,t)=>{t.pattern??(t.pattern=Fh),gc.init(e,t)})),Cc=Tl("$ZodCUID",((e,t)=>{t.pattern??(t.pattern=Eh),gc.init(e,t)})),Ec=Tl("$ZodCUID2",((e,t)=>{t.pattern??(t.pattern=Sh),gc.init(e,t)})),Sc=Tl("$ZodULID",((e,t)=>{t.pattern??(t.pattern=Ah),gc.init(e,t)})),Ac=Tl("$ZodXID",((e,t)=>{t.pattern??(t.pattern=Dh),gc.init(e,t)})),Dc=Tl("$ZodKSUID",((e,t)=>{t.pattern??(t.pattern=Th),gc.init(e,t)})),Tc=Tl("$ZodISODateTime",((e,t)=>{t.pattern??(t.pattern=function(e){const t=Gh({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${zh}T(?:${n})$`)}(t)),gc.init(e,t)})),Fc=Tl("$ZodISODate",((e,t)=>{t.pattern??(t.pattern=jh),gc.init(e,t)})),Ic=Tl("$ZodISOTime",((e,t)=>{t.pattern??(t.pattern=new RegExp(`^${Gh(t)}$`)),gc.init(e,t)})),kc=Tl("$ZodISODuration",((e,t)=>{t.pattern??(t.pattern=Ih),gc.init(e,t)})),Nc=Tl("$ZodIPv4",((e,t)=>{t.pattern??(t.pattern=Oh),gc.init(e,t),e._zod.bag.format="ipv4"})),Mc=Tl("$ZodIPv6",((e,t)=>{t.pattern??(t.pattern=Bh),gc.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}})),Oc=Tl("$ZodCIDRv4",((e,t)=>{t.pattern??(t.pattern=Lh),gc.init(e,t)})),Bc=Tl("$ZodCIDRv6",((e,t)=>{t.pattern??(t.pattern=Ph),gc.init(e,t),e._zod.check=r=>{const n=r.value.split("/");try{if(2!==n.length)throw new Error;const[e,t]=n;if(!t)throw new Error;const r=Number(t);if(`${r}`!==t)throw new Error;if(r<0||r>128)throw new Error;new URL(`http://[${e}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}}));function Lc(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Pc=Tl("$ZodBase64",((e,t)=>{t.pattern??(t.pattern=Rh),gc.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{Lc(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}));const Rc=Tl("$ZodBase64URL",((e,t)=>{t.pattern??(t.pattern=Vh),gc.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{(function(e){if(!Vh.test(e))return!1;const t=e.replace(/[-_]/g,(e=>"-"===e?"+":"/"));return Lc(t.padEnd(4*Math.ceil(t.length/4),"="))})(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}})),Vc=Tl("$ZodE164",((e,t)=>{t.pattern??(t.pattern=Uh),gc.init(e,t)}));const Uc=Tl("$ZodJWT",((e,t)=>{gc.init(e,t),e._zod.check=r=>{(function(e,t=null){try{const r=e.split(".");if(3!==r.length)return!1;const[n]=r;if(!n)return!1;const i=JSON.parse(atob(n));return!("typ"in i&&"JWT"!==i?.typ||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}})(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}})),zc=Tl("$ZodNumber",((e,t)=>{fc.init(e,t),e._zod.pattern=e._zod.bag.pattern??Hh,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(e){}const i=r.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return r;const s="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...s?{received:s}:{}}),r}})),jc=Tl("$ZodNumberFormat",((e,t)=>{ec.init(e,t),zc.init(e,t)})),Gc=Tl("$ZodBoolean",((e,t)=>{fc.init(e,t),e._zod.pattern=qh,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(e){}const i=r.value;return"boolean"==typeof i||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),r}})),$c=Tl("$ZodAny",((e,t)=>{fc.init(e,t),e._zod.parse=e=>e})),Hc=Tl("$ZodUnknown",((e,t)=>{fc.init(e,t),e._zod.parse=e=>e})),qc=Tl("$ZodNever",((e,t)=>{fc.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}));function Wc(e,t,r){e.issues.length&&t.issues.push(...eh(r,e.issues)),t.value[r]=e.value}const Xc=Tl("$ZodArray",((e,t)=>{fc.init(e,t),e._zod.parse=(r,n)=>{const i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=Array(i.length);const s=[];for(let e=0;e<i.length;e++){const o=i[e],a=t.element._zod.run({value:o,issues:[]},n);a instanceof Promise?s.push(a.then((t=>Wc(t,r,e)))):Wc(a,r,e)}return s.length?Promise.all(s).then((()=>r)):r}}));function Zc(e,t,r,n){e.issues.length&&t.issues.push(...eh(r,e.issues)),void 0===e.value?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function Yc(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const r=function(e){return Object.keys(e).filter((t=>"optional"===e[t]._zod.optin&&"optional"===e[t]._zod.optout))}(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Kc(e,t,r,n,i,s){const o=[],a=i.keySet,u=i.catchall._zod,l=u.def.type;for(const i in t){if(a.has(i))continue;if("never"===l){o.push(i);continue}const s=u.run({value:t[i],issues:[]},n);s instanceof Promise?e.push(s.then((e=>Zc(e,r,i,t)))):Zc(s,r,i,t)}return o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:s}),e.length?Promise.all(e).then((()=>r)):r}const Jc=Tl("$ZodObject",((e,t)=>{fc.init(e,t);const r=Object.getOwnPropertyDescriptor(t,"shape");if(!r?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const r={...e};return Object.defineProperty(t,"shape",{value:r}),r}})}const n=Bl((()=>Yc(t)));Vl(e._zod,"propValues",(()=>{const e=t.shape,r={};for(const t in e){const n=e[t]._zod;if(n.values){r[t]??(r[t]=new Set);for(const e of n.values)r[t].add(e)}}return r}));const i=$l,s=t.catchall;let o;e._zod.parse=(t,r)=>{o??(o=n.value);const a=t.value;if(!i(a))return t.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),t;t.value={};const u=[],l=o.shape;for(const e of o.keys){const n=l[e]._zod.run({value:a[e],issues:[]},r);n instanceof Promise?u.push(n.then((r=>Zc(r,t,e,a)))):Zc(n,t,e,a)}return s?Kc(u,a,t,r,n.value,e):u.length?Promise.all(u).then((()=>t)):t}})),Qc=Tl("$ZodObjectJIT",((e,t)=>{Jc.init(e,t);const r=e._zod.parse,n=Bl((()=>Yc(t)));let i;const s=$l,o=!kl.jitless,a=o&&Hl.value,u=t.catchall;let l;e._zod.parse=(h,c)=>{l??(l=n.value);const d=h.value;return s(d)?o&&a&&!1===c?.async&&!0!==c.jitless?(i||(i=(e=>{const t=new dc(["shape","payload","ctx"]),r=n.value,i=e=>{const t=jl(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const s=Object.create(null);let o=0;for(const e of r.keys)s[e]="key_"+o++;t.write("const newResult = {};");for(const e of r.keys){const r=s[e],n=jl(e);t.write(`const ${r} = ${i(e)};`),t.write(`\n        if (${r}.issues.length) {\n          payload.issues = payload.issues.concat(${r}.issues.map(iss => ({\n            ...iss,\n            path: iss.path ? [${n}, ...iss.path] : [${n}]\n          })));\n        }\n        \n        \n        if (${r}.value === undefined) {\n          if (${n} in input) {\n            newResult[${n}] = undefined;\n          }\n        } else {\n          newResult[${n}] = ${r}.value;\n        }\n        \n      `)}t.write("payload.value = newResult;"),t.write("return payload;");const a=t.compile();return(t,r)=>a(e,t,r)})(t.shape)),h=i(h,c),u?Kc([],d,h,c,l,e):h):r(h,c):(h.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),h)}}));function ed(e,t,r,n){for(const r of e)if(0===r.issues.length)return t.value=r.value,t;const i=e.filter((e=>!Ql(e)));return 1===i.length?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((e=>e.issues.map((e=>rh(e,n,Nl())))))}),t)}const td=Tl("$ZodUnion",((e,t)=>{fc.init(e,t),Vl(e._zod,"optin",(()=>t.options.some((e=>"optional"===e._zod.optin))?"optional":void 0)),Vl(e._zod,"optout",(()=>t.options.some((e=>"optional"===e._zod.optout))?"optional":void 0)),Vl(e._zod,"values",(()=>{if(t.options.every((e=>e._zod.values)))return new Set(t.options.flatMap((e=>Array.from(e._zod.values))))})),Vl(e._zod,"pattern",(()=>{if(t.options.every((e=>e._zod.pattern))){const e=t.options.map((e=>e._zod.pattern));return new RegExp(`^(${e.map((e=>Pl(e.source))).join("|")})$`)}}));const r=1===t.options.length,n=t.options[0]._zod.run;e._zod.parse=(i,s)=>{if(r)return n(i,s);let o=!1;const a=[];for(const e of t.options){const t=e._zod.run({value:i.value,issues:[]},s);if(t instanceof Promise)a.push(t),o=!0;else{if(0===t.issues.length)return t;a.push(t)}}return o?Promise.all(a).then((t=>ed(t,i,e,s))):ed(a,i,e,s)}})),rd=Tl("$ZodIntersection",((e,t)=>{fc.init(e,t),e._zod.parse=(e,r)=>{const n=e.value,i=t.left._zod.run({value:n,issues:[]},r),s=t.right._zod.run({value:n,issues:[]},r);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then((([t,r])=>id(e,t,r))):id(e,i,s)}}));function nd(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ql(e)&&ql(t)){const r=Object.keys(t),n=Object.keys(e).filter((e=>-1!==r.indexOf(e))),i={...e,...t};for(const r of n){const n=nd(e[r],t[r]);if(!n.valid)return{valid:!1,mergeErrorPath:[r,...n.mergeErrorPath]};i[r]=n.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const i=nd(e[n],t[n]);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function id(e,t,r){if(t.issues.length&&e.issues.push(...t.issues),r.issues.length&&e.issues.push(...r.issues),Ql(e))return e;const n=nd(t.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}const sd=Tl("$ZodTuple",((e,t)=>{fc.init(e,t);const r=t.items;e._zod.parse=(n,i)=>{const s=n.value;if(!Array.isArray(s))return n.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),n;n.value=[];const o=[],a=[...r].reverse().findIndex((e=>"optional"!==e._zod.optin)),u=-1===a?0:r.length-a;if(!t.rest){const t=s.length>r.length,i=s.length<u-1;if(t||i)return n.issues.push({...t?{code:"too_big",maximum:r.length}:{code:"too_small",minimum:r.length},input:s,inst:e,origin:"array"}),n}let l=-1;for(const e of r){if(l++,l>=s.length&&l>=u)continue;const t=e._zod.run({value:s[l],issues:[]},i);t instanceof Promise?o.push(t.then((e=>od(e,n,l)))):od(t,n,l)}if(t.rest){const e=s.slice(r.length);for(const r of e){l++;const e=t.rest._zod.run({value:r,issues:[]},i);e instanceof Promise?o.push(e.then((e=>od(e,n,l)))):od(e,n,l)}}return o.length?Promise.all(o).then((()=>n)):n}}));function od(e,t,r){e.issues.length&&t.issues.push(...eh(r,e.issues)),t.value[r]=e.value}const ad=Tl("$ZodEnum",((e,t)=>{fc.init(e,t);const r=Ml(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter((e=>Xl.has(typeof e))).map((e=>"string"==typeof e?Zl(e):e.toString())).join("|")})$`),e._zod.parse=(t,i)=>{const s=t.value;return n.has(s)||t.issues.push({code:"invalid_value",values:r,input:s,inst:e}),t}})),ud=Tl("$ZodLiteral",((e,t)=>{if(fc.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");const r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map((e=>"string"==typeof e?Zl(e):e?Zl(e.toString()):String(e))).join("|")})$`),e._zod.parse=(n,i)=>{const s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}})),ld=Tl("$ZodTransform",((e,t)=>{fc.init(e,t),e._zod.parse=(r,n)=>{if("backward"===n.direction)throw new Il(e.constructor.name);const i=t.transform(r.value,r);if(n.async){return(i instanceof Promise?i:Promise.resolve(i)).then((e=>(r.value=e,r)))}if(i instanceof Promise)throw new Fl;return r.value=i,r}}));function hd(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}const cd=Tl("$ZodOptional",((e,t)=>{fc.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Vl(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0)),Vl(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Pl(e.source)})?$`):void 0})),e._zod.parse=(e,r)=>{if("optional"===t.innerType._zod.optin){const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then((t=>hd(t,e.value))):hd(n,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,r)}})),dd=Tl("$ZodNullable",((e,t)=>{fc.init(e,t),Vl(e._zod,"optin",(()=>t.innerType._zod.optin)),Vl(e._zod,"optout",(()=>t.innerType._zod.optout)),Vl(e._zod,"pattern",(()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Pl(e.source)}|null)$`):void 0})),Vl(e._zod,"values",(()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0)),e._zod.parse=(e,r)=>null===e.value?e:t.innerType._zod.run(e,r)})),pd=Tl("$ZodDefault",((e,t)=>{fc.init(e,t),e._zod.optin="optional",Vl(e._zod,"values",(()=>t.innerType._zod.values)),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);if(void 0===e.value)return e.value=t.defaultValue,e;const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then((e=>fd(e,t))):fd(n,t)}}));function fd(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const md=Tl("$ZodPrefault",((e,t)=>{fc.init(e,t),e._zod.optin="optional",Vl(e._zod,"values",(()=>t.innerType._zod.values)),e._zod.parse=(e,r)=>("backward"===r.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))})),gd=Tl("$ZodNonOptional",((e,t)=>{fc.init(e,t),Vl(e._zod,"values",(()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter((e=>void 0!==e))):void 0})),e._zod.parse=(r,n)=>{const i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then((t=>yd(t,e))):yd(i,e)}}));function yd(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const vd=Tl("$ZodCatch",((e,t)=>{fc.init(e,t),Vl(e._zod,"optin",(()=>t.innerType._zod.optin)),Vl(e._zod,"optout",(()=>t.innerType._zod.optout)),Vl(e._zod,"values",(()=>t.innerType._zod.values)),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then((n=>(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map((e=>rh(e,r,Nl())))},input:e.value}),e.issues=[]),e))):(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map((e=>rh(e,r,Nl())))},input:e.value}),e.issues=[]),e)}})),bd=Tl("$ZodPipe",((e,t)=>{fc.init(e,t),Vl(e._zod,"values",(()=>t.in._zod.values)),Vl(e._zod,"optin",(()=>t.in._zod.optin)),Vl(e._zod,"optout",(()=>t.out._zod.optout)),Vl(e._zod,"propValues",(()=>t.in._zod.propValues)),e._zod.parse=(e,r)=>{if("backward"===r.direction){const n=t.out._zod.run(e,r);return n instanceof Promise?n.then((e=>xd(e,t.in,r))):xd(n,t.in,r)}const n=t.in._zod.run(e,r);return n instanceof Promise?n.then((e=>xd(e,t.out,r))):xd(n,t.out,r)}}));function xd(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}const _d=Tl("$ZodReadonly",((e,t)=>{fc.init(e,t),Vl(e._zod,"propValues",(()=>t.innerType._zod.propValues)),Vl(e._zod,"values",(()=>t.innerType._zod.values)),Vl(e._zod,"optin",(()=>t.innerType?._zod?.optin)),Vl(e._zod,"optout",(()=>t.innerType?._zod?.optout)),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(wd):wd(n)}}));function wd(e){return e.value=Object.freeze(e.value),e}const Cd=Tl("$ZodFunction",((e,t)=>(fc.init(e,t),e._def=t,e._zod.def=t,e.implement=t=>{if("function"!=typeof t)throw new Error("implement() must be called with a function");return function(...r){const n=e._def.input?lh(e._def.input,r):r,i=Reflect.apply(t,this,n);return e._def.output?lh(e._def.output,i):i}},e.implementAsync=t=>{if("function"!=typeof t)throw new Error("implementAsync() must be called with a function");return async function(...r){const n=e._def.input?await ch(e._def.input,r):r,i=await Reflect.apply(t,this,n);return e._def.output?await ch(e._def.output,i):i}},e._zod.parse=(t,r)=>{if("function"!=typeof t.value)return t.issues.push({code:"invalid_type",expected:"function",input:t.value,inst:e}),t;const n=e._def.output&&"promise"===e._def.output._zod.def.type;return t.value=n?e.implementAsync(t.value):e.implement(t.value),t},e.input=(...t)=>{const r=e.constructor;return Array.isArray(t[0])?new r({type:"function",input:new sd({type:"tuple",items:t[0],rest:t[1]}),output:e._def.output}):new r({type:"function",input:t[0],output:e._def.output})},e.output=t=>new(0,e.constructor)({type:"function",input:e._def.input,output:t}),e))),Ed=Tl("$ZodCustom",((e,t)=>{Zh.init(e,t),fc.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=r=>{const n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then((t=>Sd(t,r,n,e)));Sd(i,r,n,e)}}));function Sd(e,t,r,n){if(!e){const e={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(e.params=n._zod.def.params),t.issues.push(ih(e))}}var Ad;class Dd{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const r=t[0];if(this._map.set(e,r),r&&"object"==typeof r&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};delete r.id;const n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}(Ad=globalThis).__zod_globalRegistry??(Ad.__zod_globalRegistry=new Dd);const Td=globalThis.__zod_globalRegistry;function Fd(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Kl(t)})}function Id(e,t){return new Kh({check:"less_than",...Kl(t),value:e,inclusive:!1})}function kd(e,t){return new Kh({check:"less_than",...Kl(t),value:e,inclusive:!0})}function Nd(e,t){return new Jh({check:"greater_than",...Kl(t),value:e,inclusive:!1})}function Md(e,t){return new Jh({check:"greater_than",...Kl(t),value:e,inclusive:!0})}function Od(e,t){return new Qh({check:"multiple_of",...Kl(t),value:e})}function Bd(e,t){return new tc({check:"max_length",...Kl(t),maximum:e})}function Ld(e,t){return new rc({check:"min_length",...Kl(t),minimum:e})}function Pd(e,t){return new nc({check:"length_equals",...Kl(t),length:e})}function Rd(e){return new cc({check:"overwrite",tx:e})}function Vd(e){const t=function(e,t){const r=new Zh({check:"custom",...Kl(t)});return r._zod.check=e,r}((r=>(r.addIssue=e=>{if("string"==typeof e)r.issues.push(ih(e,r.value,t._zod.def));else{const n=e;n.fatal&&(n.continue=!1),n.code??(n.code="custom"),n.input??(n.input=r.value),n.inst??(n.inst=t),n.continue??(n.continue=!t._zod.def.abort),r.issues.push(ih(n))}},e(r.value,r))));return t}function Ud(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Td,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function zd(e,t,r={path:[],schemaPath:[]}){var n;const i=e._zod.def,s=t.seen.get(e);if(s){s.count++;return r.schemaPath.includes(e)&&(s.cycle=r.path),s.schema}const o={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,o);const a=e._zod.toJSONSchema?.();if(a)o.schema=a;else{const n={...r,schemaPath:[...r.schemaPath,e],path:r.path},s=e._zod.parent;if(s)o.ref=s,zd(s,t,n),t.seen.get(s).isParent=!0;else if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,n);else{const r=o.schema,s=t.processors[i.type];if(!s)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);s(e,t,r,n)}}const u=t.metadataRegistry.get(e);u&&Object.assign(o.schema,u),"input"===t.io&&$d(e)&&(delete o.schema.examples,delete o.schema.default),"input"===t.io&&o.schema._prefault&&((n=o.schema).default??(n.default=o.schema._prefault)),delete o.schema._prefault;return t.seen.get(e).schema}function jd(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=t=>{if(t[1].schema.$ref)return;const n=t[1],{ref:i,defId:s}=(t=>{const n="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const r=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(r)return{ref:i(r)};const s=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=s,{defId:s,ref:`${i("__shared")}#/${n}/${s}`}}if(t[1]===r)return{ref:"#"};const i=`#/${n}/`,s=t[1].schema.id??"__schema"+e.counter++;return{defId:s,ref:i+s}})(t);n.def={...n.schema},s&&(n.defId=s);const o=n.schema;for(const e in o)delete o[e];o.$ref=i};if("throw"===e.cycles)for(const t of e.seen.entries()){const e=t[1];if(e.cycle)throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const r of e.seen.entries()){const i=r[1];if(t===r[0]){n(r);continue}if(e.external){const i=e.external.registry.get(r[0])?.id;if(t!==r[0]&&i){n(r);continue}}const s=e.metadataRegistry.get(r[0])?.id;s?n(r):(i.cycle||i.count>1&&"ref"===e.reused)&&n(r)}}function Gd(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=t=>{const r=e.seen.get(t),i=r.def??r.schema,s={...i};if(null===r.ref)return;const o=r.ref;if(r.ref=null,o){n(o);const t=e.seen.get(o).schema;!t.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?(Object.assign(i,t),Object.assign(i,s)):(i.allOf=i.allOf??[],i.allOf.push(t))}r.isParent||e.override({zodSchema:t,jsonSchema:i,path:r.path??[]})};for(const t of[...e.seen.entries()].reverse())n(t[0]);const i={};if("draft-2020-12"===e.target?i.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?i.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target&&(i.$schema="http://json-schema.org/draft-04/schema#"),e.external?.uri){const r=e.external.registry.get(t)?.id;if(!r)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(r)}Object.assign(i,r.def??r.schema);const s=e.external?.defs??{};for(const t of e.seen.entries()){const e=t[1];e.def&&e.defId&&(s[e.defId]=e.def)}e.external||Object.keys(s).length>0&&("draft-2020-12"===e.target?i.$defs=s:i.definitions=s);try{const e=JSON.parse(JSON.stringify(i));return Object.defineProperty(e,"~standard",{value:{...t["~standard"],jsonSchema:{input:Hd(t,"input"),output:Hd(t,"output")}},enumerable:!1,writable:!1}),e}catch(e){throw new Error("Error converting schema to JSON.")}}function $d(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if("transform"===n.type)return!0;if("array"===n.type)return $d(n.element,r);if("set"===n.type)return $d(n.valueType,r);if("lazy"===n.type)return $d(n.getter(),r);if("promise"===n.type||"optional"===n.type||"nonoptional"===n.type||"nullable"===n.type||"readonly"===n.type||"default"===n.type||"prefault"===n.type)return $d(n.innerType,r);if("intersection"===n.type)return $d(n.left,r)||$d(n.right,r);if("record"===n.type||"map"===n.type)return $d(n.keyType,r)||$d(n.valueType,r);if("pipe"===n.type)return $d(n.in,r)||$d(n.out,r);if("object"===n.type){for(const e in n.shape)if($d(n.shape[e],r))return!0;return!1}if("union"===n.type){for(const e of n.options)if($d(e,r))return!0;return!1}if("tuple"===n.type){for(const e of n.items)if($d(e,r))return!0;return!(!n.rest||!$d(n.rest,r))}return!1}const Hd=(e,t)=>r=>{const{libraryOptions:n,target:i}=r??{},s=Ud({...n??{},target:i,io:t,processors:{}});return zd(e,s),jd(s,e),Gd(s,e)},qd={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Wd=Tl("ZodISODateTime",((e,t)=>{Tc.init(e,t),vp.init(e,t)}));function Xd(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Kl(t)})}(Wd,e)}const Zd=Tl("ZodISODate",((e,t)=>{Fc.init(e,t),vp.init(e,t)}));function Yd(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...Kl(t)})}(Zd,e)}const Kd=Tl("ZodISOTime",((e,t)=>{Ic.init(e,t),vp.init(e,t)}));function Jd(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Kl(t)})}(Kd,e)}const Qd=Tl("ZodISODuration",((e,t)=>{kc.init(e,t),vp.init(e,t)}));function ep(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...Kl(t)})}(Qd,e)}const tp=Tl("ZodError",((e,t)=>{oh.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const r={_errors:[]},n=e=>{for(const i of e.issues)if("invalid_union"===i.code&&i.errors.length)i.errors.map((e=>n({issues:e})));else if("invalid_key"===i.code)n({issues:i.issues});else if("invalid_element"===i.code)n({issues:i.issues});else if(0===i.path.length)r._errors.push(t(i));else{let e=r,n=0;for(;n<i.path.length;){const r=i.path[n];n===i.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(t(i))):e[r]=e[r]||{_errors:[]},e=e[r],n++}}};return n(e),r}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const r={},n=[];for(const i of e.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:r}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ol,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ol,2)}},isEmpty:{get:()=>0===e.issues.length}})}),{Parent:Error}),rp=uh(tp),np=hh(tp),ip=dh(tp),sp=fh(tp),op=gh(tp),ap=yh(tp),up=vh(tp),lp=bh(tp),hp=xh(tp),cp=_h(tp),dp=wh(tp),pp=Ch(tp),fp=Tl("ZodType",((e,t)=>(fc.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Hd(e,"input"),output:Hd(e,"output")}}),e.toJSONSchema=((e,t={})=>r=>{const n=Ud({...r,processors:t});return zd(e,n),jd(n,e),Gd(n,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(zl(t,{checks:[...t.checks??[],...r.map((e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e))]})),e.clone=(t,r)=>Yl(e,t,r),e.brand=()=>e,e.register=(t,r)=>(t.add(e,r),e),e.parse=(t,r)=>rp(e,t,r,{callee:e.parse}),e.safeParse=(t,r)=>ip(e,t,r),e.parseAsync=async(t,r)=>np(e,t,r,{callee:e.parseAsync}),e.safeParseAsync=async(t,r)=>sp(e,t,r),e.spa=e.safeParseAsync,e.encode=(t,r)=>op(e,t,r),e.decode=(t,r)=>ap(e,t,r),e.encodeAsync=async(t,r)=>up(e,t,r),e.decodeAsync=async(t,r)=>lp(e,t,r),e.safeEncode=(t,r)=>hp(e,t,r),e.safeDecode=(t,r)=>cp(e,t,r),e.safeEncodeAsync=async(t,r)=>dp(e,t,r),e.safeDecodeAsync=async(t,r)=>pp(e,t,r),e.refine=(t,r)=>e.check(function(e,t={}){return function(e,t,r){return new e({type:"custom",check:"custom",fn:t,...Kl(r)})}(Cf,e,t)}(t,r)),e.superRefine=t=>e.check(function(e){return Vd(e)}(t)),e.overwrite=t=>e.check(Rd(t)),e.optional=()=>cf(e),e.nullable=()=>pf(e),e.nullish=()=>cf(pf(e)),e.nonoptional=t=>function(e,t){return new gf({type:"nonoptional",innerType:e,...Kl(t)})}(e,t),e.array=()=>Kp(e),e.or=t=>tf([e,t]),e.and=t=>new rf({type:"intersection",left:e,right:t}),e.transform=t=>bf(e,function(e){return new lf({type:"transform",transform:e})}(t)),e.default=t=>{return r=t,new ff({type:"default",innerType:e,get defaultValue(){return"function"==typeof r?r():Wl(r)}});var r},e.prefault=t=>{return r=t,new mf({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof r?r():Wl(r)}});var r},e.catch=t=>{return new yf({type:"catch",innerType:e,catchValue:"function"==typeof(r=t)?r:()=>r});var r},e.pipe=t=>bf(e,t),e.readonly=()=>new xf({type:"readonly",innerType:e}),e.describe=t=>{const r=e.clone();return Td.add(r,{description:t}),r},Object.defineProperty(e,"description",{get:()=>Td.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return Td.get(e);const r=e.clone();return Td.add(r,t[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e))),mp=Tl("_ZodString",((e,t)=>{mc.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r)=>{const n=r;n.type="string";const{minimum:i,maximum:s,format:o,patterns:a,contentEncoding:u}=e._zod.bag;if("number"==typeof i&&(n.minLength=i),"number"==typeof s&&(n.maxLength=s),o&&(n.format=qd[o]??o,""===n.format&&delete n.format),u&&(n.contentEncoding=u),a&&a.size>0){const e=[...a];1===e.length?n.pattern=e[0].source:e.length>1&&(n.allOf=[...e.map((e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source})))])}})(e,t,r);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...t)=>e.check(function(e,t){return new sc({check:"string_format",format:"regex",...Kl(t),pattern:e})}(...t)),e.includes=(...t)=>e.check(function(e,t){return new uc({check:"string_format",format:"includes",...Kl(t),includes:e})}(...t)),e.startsWith=(...t)=>e.check(function(e,t){return new lc({check:"string_format",format:"starts_with",...Kl(t),prefix:e})}(...t)),e.endsWith=(...t)=>e.check(function(e,t){return new hc({check:"string_format",format:"ends_with",...Kl(t),suffix:e})}(...t)),e.min=(...t)=>e.check(Ld(...t)),e.max=(...t)=>e.check(Bd(...t)),e.length=(...t)=>e.check(Pd(...t)),e.nonempty=(...t)=>e.check(Ld(1,...t)),e.lowercase=t=>e.check(function(e){return new oc({check:"string_format",format:"lowercase",...Kl(e)})}(t)),e.uppercase=t=>e.check(function(e){return new ac({check:"string_format",format:"uppercase",...Kl(e)})}(t)),e.trim=()=>e.check(Rd((e=>e.trim()))),e.normalize=(...t)=>e.check(function(e){return Rd((t=>t.normalize(e)))}(...t)),e.toLowerCase=()=>e.check(Rd((e=>e.toLowerCase()))),e.toUpperCase=()=>e.check(Rd((e=>e.toUpperCase()))),e.slugify=()=>e.check(Rd((e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e))))})),gp=Tl("ZodString",((e,t)=>{mc.init(e,t),mp.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Kl(t)})}(bp,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Kl(t)})}(wp,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Kl(t)})}(Pp,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Kl(t)})}(Cp,t)),e.guid=t=>e.check(Fd(xp,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Kl(t)})}(_p,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Kl(t)})}(_p,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Kl(t)})}(_p,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Kl(t)})}(_p,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Kl(t)})}(Ep,t)),e.guid=t=>e.check(Fd(xp,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Kl(t)})}(Sp,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Kl(t)})}(Ap,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Kl(t)})}(Dp,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Kl(t)})}(Op,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Kl(t)})}(Bp,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Kl(t)})}(Tp,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Kl(t)})}(Fp,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Kl(t)})}(Ip,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Kl(t)})}(kp,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Kl(t)})}(Np,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Kl(t)})}(Mp,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Kl(t)})}(Lp,t)),e.datetime=t=>e.check(Xd(t)),e.date=t=>e.check(Yd(t)),e.time=t=>e.check(Jd(t)),e.duration=t=>e.check(ep(t))}));function yp(e){return function(e,t){return new e({type:"string",...Kl(t)})}(gp,e)}const vp=Tl("ZodStringFormat",((e,t)=>{gc.init(e,t),mp.init(e,t)})),bp=Tl("ZodEmail",((e,t)=>{bc.init(e,t),vp.init(e,t)})),xp=Tl("ZodGUID",((e,t)=>{yc.init(e,t),vp.init(e,t)})),_p=Tl("ZodUUID",((e,t)=>{vc.init(e,t),vp.init(e,t)})),wp=Tl("ZodURL",((e,t)=>{xc.init(e,t),vp.init(e,t)})),Cp=Tl("ZodEmoji",((e,t)=>{_c.init(e,t),vp.init(e,t)})),Ep=Tl("ZodNanoID",((e,t)=>{wc.init(e,t),vp.init(e,t)})),Sp=Tl("ZodCUID",((e,t)=>{Cc.init(e,t),vp.init(e,t)})),Ap=Tl("ZodCUID2",((e,t)=>{Ec.init(e,t),vp.init(e,t)})),Dp=Tl("ZodULID",((e,t)=>{Sc.init(e,t),vp.init(e,t)})),Tp=Tl("ZodXID",((e,t)=>{Ac.init(e,t),vp.init(e,t)})),Fp=Tl("ZodKSUID",((e,t)=>{Dc.init(e,t),vp.init(e,t)})),Ip=Tl("ZodIPv4",((e,t)=>{Nc.init(e,t),vp.init(e,t)})),kp=Tl("ZodIPv6",((e,t)=>{Mc.init(e,t),vp.init(e,t)})),Np=Tl("ZodCIDRv4",((e,t)=>{Oc.init(e,t),vp.init(e,t)})),Mp=Tl("ZodCIDRv6",((e,t)=>{Bc.init(e,t),vp.init(e,t)})),Op=Tl("ZodBase64",((e,t)=>{Pc.init(e,t),vp.init(e,t)})),Bp=Tl("ZodBase64URL",((e,t)=>{Rc.init(e,t),vp.init(e,t)})),Lp=Tl("ZodE164",((e,t)=>{Vc.init(e,t),vp.init(e,t)})),Pp=Tl("ZodJWT",((e,t)=>{Uc.init(e,t),vp.init(e,t)})),Rp=Tl("ZodNumber",((e,t)=>{zc.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r)=>{const n=r,{minimum:i,maximum:s,format:o,multipleOf:a,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;"string"==typeof o&&o.includes("int")?n.type="integer":n.type="number","number"==typeof l&&("draft-04"===t.target||"openapi-3.0"===t.target?(n.minimum=l,n.exclusiveMinimum=!0):n.exclusiveMinimum=l),"number"==typeof i&&(n.minimum=i,"number"==typeof l&&"draft-04"!==t.target&&(l>=i?delete n.minimum:delete n.exclusiveMinimum)),"number"==typeof u&&("draft-04"===t.target||"openapi-3.0"===t.target?(n.maximum=u,n.exclusiveMaximum=!0):n.exclusiveMaximum=u),"number"==typeof s&&(n.maximum=s,"number"==typeof u&&"draft-04"!==t.target&&(u<=s?delete n.maximum:delete n.exclusiveMaximum)),"number"==typeof a&&(n.multipleOf=a)})(e,t,r),e.gt=(t,r)=>e.check(Nd(t,r)),e.gte=(t,r)=>e.check(Md(t,r)),e.min=(t,r)=>e.check(Md(t,r)),e.lt=(t,r)=>e.check(Id(t,r)),e.lte=(t,r)=>e.check(kd(t,r)),e.max=(t,r)=>e.check(kd(t,r)),e.int=t=>e.check(zp(t)),e.safe=t=>e.check(zp(t)),e.positive=t=>e.check(Nd(0,t)),e.nonnegative=t=>e.check(Md(0,t)),e.negative=t=>e.check(Id(0,t)),e.nonpositive=t=>e.check(kd(0,t)),e.multipleOf=(t,r)=>e.check(Od(t,r)),e.step=(t,r)=>e.check(Od(t,r)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null}));function Vp(e){return function(e,t){return new e({type:"number",checks:[],...Kl(t)})}(Rp,e)}const Up=Tl("ZodNumberFormat",((e,t)=>{jc.init(e,t),Rp.init(e,t)}));function zp(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Kl(t)})}(Up,e)}const jp=Tl("ZodBoolean",((e,t)=>{Gc.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(e,t,r)=>((e,t,r)=>{r.type="boolean"})(0,0,t)}));function Gp(e){return function(e,t){return new e({type:"boolean",...Kl(t)})}(jp,e)}const $p=Tl("ZodAny",((e,t)=>{$c.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(e,t,r)=>{}}));function Hp(){return new $p({type:"any"})}const qp=Tl("ZodUnknown",((e,t)=>{Hc.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(e,t,r)=>{}}));function Wp(){return new qp({type:"unknown"})}const Xp=Tl("ZodNever",((e,t)=>{qc.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(e,t,r)=>((e,t,r)=>{r.not={}})(0,0,t)}));function Zp(e){return function(e,t){return new e({type:"never",...Kl(t)})}(Xp,e)}const Yp=Tl("ZodArray",((e,t)=>{Xc.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=r,s=e._zod.def,{minimum:o,maximum:a}=e._zod.bag;"number"==typeof o&&(i.minItems=o),"number"==typeof a&&(i.maxItems=a),i.type="array",i.items=zd(s.element,t,{...n,path:[...n.path,"items"]})})(e,t,r,n),e.element=t.element,e.min=(t,r)=>e.check(Ld(t,r)),e.nonempty=t=>e.check(Ld(1,t)),e.max=(t,r)=>e.check(Bd(t,r)),e.length=(t,r)=>e.check(Pd(t,r)),e.unwrap=()=>e.element}));function Kp(e,t){return function(e,t,r){return new e({type:"array",element:t,...Kl(r)})}(Yp,e,t)}const Jp=Tl("ZodObject",((e,t)=>{Qc.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=r,s=e._zod.def;i.type="object",i.properties={};const o=s.shape;for(const e in o)i.properties[e]=zd(o[e],t,{...n,path:[...n.path,"properties",e]});const a=new Set(Object.keys(o)),u=new Set([...a].filter((e=>{const r=s.shape[e]._zod;return"input"===t.io?void 0===r.optin:void 0===r.optout})));u.size>0&&(i.required=Array.from(u)),"never"===s.catchall?._zod.def.type?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=zd(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):"output"===t.io&&(i.additionalProperties=!1)})(e,t,r,n),Vl(e,"shape",(()=>t.shape)),e.keyof=()=>function(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map((e=>[e,e]))):e;return new of({type:"enum",entries:r,...Kl(t)})}(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Wp()}),e.loose=()=>e.clone({...e._zod.def,catchall:Wp()}),e.strict=()=>e.clone({...e._zod.def,catchall:Zp()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){if(!ql(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const n=zl(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Ul(this,"shape",r),r},checks:[]});return Yl(e,n)}(e,t),e.safeExtend=t=>function(e,t){if(!ql(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return Ul(this,"shape",r),r},checks:e._zod.def.checks};return Yl(e,r)}(e,t),e.merge=t=>function(e,t){const r=zl(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Ul(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return Yl(e,r)}(e,t),e.pick=t=>function(e,t){const r=e._zod.def;return Yl(e,zl(e._zod.def,{get shape(){const e={};for(const n in t){if(!(n in r.shape))throw new Error(`Unrecognized key: "${n}"`);t[n]&&(e[n]=r.shape[n])}return Ul(this,"shape",e),e},checks:[]}))}(e,t),e.omit=t=>function(e,t){const r=e._zod.def,n=zl(e._zod.def,{get shape(){const n={...e._zod.def.shape};for(const e in t){if(!(e in r.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete n[e]}return Ul(this,"shape",n),n},checks:[]});return Yl(e,n)}(e,t),e.partial=(...t)=>function(e,t,r){const n=zl(t._zod.def,{get shape(){const n=t._zod.def.shape,i={...n};if(r)for(const t in r){if(!(t in n))throw new Error(`Unrecognized key: "${t}"`);r[t]&&(i[t]=e?new e({type:"optional",innerType:n[t]}):n[t])}else for(const t in n)i[t]=e?new e({type:"optional",innerType:n[t]}):n[t];return Ul(this,"shape",i),i},checks:[]});return Yl(t,n)}(hf,e,t[0]),e.required=(...t)=>function(e,t,r){const n=zl(t._zod.def,{get shape(){const n=t._zod.def.shape,i={...n};if(r)for(const t in r){if(!(t in i))throw new Error(`Unrecognized key: "${t}"`);r[t]&&(i[t]=new e({type:"nonoptional",innerType:n[t]}))}else for(const t in n)i[t]=new e({type:"nonoptional",innerType:n[t]});return Ul(this,"shape",i),i},checks:[]});return Yl(t,n)}(gf,e,t[0])}));function Qp(e,t){const r={type:"object",shape:e??{},...Kl(t)};return new Jp(r)}const ef=Tl("ZodUnion",((e,t)=>{td.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=e._zod.def,s=!1===i.inclusive,o=i.options.map(((e,r)=>zd(e,t,{...n,path:[...n.path,s?"oneOf":"anyOf",r]})));s?r.oneOf=o:r.anyOf=o})(e,t,r,n),e.options=t.options}));function tf(e,t){return new ef({type:"union",options:e,...Kl(t)})}const rf=Tl("ZodIntersection",((e,t)=>{rd.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=e._zod.def,s=zd(i.left,t,{...n,path:[...n.path,"allOf",0]}),o=zd(i.right,t,{...n,path:[...n.path,"allOf",1]}),a=e=>"allOf"in e&&1===Object.keys(e).length,u=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];r.allOf=u})(e,t,r,n)}));const nf=Tl("ZodTuple",((e,t)=>{sd.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=r,s=e._zod.def;i.type="array";const o="draft-2020-12"===t.target?"prefixItems":"items",a="draft-2020-12"===t.target||"openapi-3.0"===t.target?"items":"additionalItems",u=s.items.map(((e,r)=>zd(e,t,{...n,path:[...n.path,o,r]}))),l=s.rest?zd(s.rest,t,{...n,path:[...n.path,a,..."openapi-3.0"===t.target?[s.items.length]:[]]}):null;"draft-2020-12"===t.target?(i.prefixItems=u,l&&(i.items=l)):"openapi-3.0"===t.target?(i.items={anyOf:u},l&&i.items.anyOf.push(l),i.minItems=u.length,l||(i.maxItems=u.length)):(i.items=u,l&&(i.additionalItems=l));const{minimum:h,maximum:c}=e._zod.bag;"number"==typeof h&&(i.minItems=h),"number"==typeof c&&(i.maxItems=c)})(e,t,r,n),e.rest=t=>e.clone({...e._zod.def,rest:t})}));function sf(e,t,r){const n=t instanceof fc;return new nf({type:"tuple",items:e,rest:n?t:null,...Kl(n?r:t)})}const of=Tl("ZodEnum",((e,t)=>{ad.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r)=>{const n=Ml(e._zod.def.entries);n.every((e=>"number"==typeof e))&&(r.type="number"),n.every((e=>"string"==typeof e))&&(r.type="string"),r.enum=n})(e,0,r),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(e,n)=>{const i={};for(const n of e){if(!r.has(n))throw new Error(`Key ${n} not found in enum`);i[n]=t.entries[n]}return new of({...t,checks:[],...Kl(n),entries:i})},e.exclude=(e,n)=>{const i={...t.entries};for(const t of e){if(!r.has(t))throw new Error(`Key ${t} not found in enum`);delete i[t]}return new of({...t,checks:[],...Kl(n),entries:i})}}));const af=Tl("ZodLiteral",((e,t)=>{ud.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r)=>{const n=e._zod.def,i=[];for(const e of n.values)if(void 0===e){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof e){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(e))}else i.push(e);if(0===i.length);else if(1===i.length){const e=i[0];r.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?r.enum=[e]:r.const=e}else i.every((e=>"number"==typeof e))&&(r.type="number"),i.every((e=>"string"==typeof e))&&(r.type="string"),i.every((e=>"boolean"==typeof e))&&(r.type="boolean"),i.every((e=>null===e))&&(r.type="null"),r.enum=i})(e,t,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})}));function uf(e,t){return new af({type:"literal",values:Array.isArray(e)?e:[e],...Kl(t)})}const lf=Tl("ZodTransform",((e,t)=>{ld.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(e,t,r)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")})(0,e),e._zod.parse=(r,n)=>{if("backward"===n.direction)throw new Il(e.constructor.name);r.addIssue=n=>{if("string"==typeof n)r.issues.push(ih(n,r.value,t));else{const t=n;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=r.value),t.inst??(t.inst=e),r.issues.push(ih(t))}};const i=t.transform(r.value,r);return i instanceof Promise?i.then((e=>(r.value=e,r))):(r.value=i,r)}}));const hf=Tl("ZodOptional",((e,t)=>{cd.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=e._zod.def;zd(i.innerType,t,n),t.seen.get(e).ref=i.innerType})(e,t,0,n),e.unwrap=()=>e._zod.def.innerType}));function cf(e){return new hf({type:"optional",innerType:e})}const df=Tl("ZodNullable",((e,t)=>{dd.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=e._zod.def,s=zd(i.innerType,t,n),o=t.seen.get(e);"openapi-3.0"===t.target?(o.ref=i.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]})(e,t,r,n),e.unwrap=()=>e._zod.def.innerType}));function pf(e){return new df({type:"nullable",innerType:e})}const ff=Tl("ZodDefault",((e,t)=>{pd.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=e._zod.def;zd(i.innerType,t,n),t.seen.get(e).ref=i.innerType,r.default=JSON.parse(JSON.stringify(i.defaultValue))})(e,t,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}));const mf=Tl("ZodPrefault",((e,t)=>{md.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=e._zod.def;zd(i.innerType,t,n),t.seen.get(e).ref=i.innerType,"input"===t.io&&(r._prefault=JSON.parse(JSON.stringify(i.defaultValue)))})(e,t,r,n),e.unwrap=()=>e._zod.def.innerType}));const gf=Tl("ZodNonOptional",((e,t)=>{gd.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=e._zod.def;zd(i.innerType,t,n),t.seen.get(e).ref=i.innerType})(e,t,0,n),e.unwrap=()=>e._zod.def.innerType}));const yf=Tl("ZodCatch",((e,t)=>{vd.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=e._zod.def;let s;zd(i.innerType,t,n),t.seen.get(e).ref=i.innerType;try{s=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=s})(e,t,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}));const vf=Tl("ZodPipe",((e,t)=>{bd.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=e._zod.def,s="input"===t.io?"transform"===i.in._zod.def.type?i.out:i.in:i.out;zd(s,t,n),t.seen.get(e).ref=s})(e,t,0,n),e.in=t.in,e.out=t.out}));function bf(e,t){return new vf({type:"pipe",in:e,out:t})}const xf=Tl("ZodReadonly",((e,t)=>{_d.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{const i=e._zod.def;zd(i.innerType,t,n),t.seen.get(e).ref=i.innerType,r.readOnly=!0})(e,t,r,n),e.unwrap=()=>e._zod.def.innerType}));const _f=Tl("ZodFunction",((e,t)=>{Cd.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(e,t,r)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Function types cannot be represented in JSON Schema")})(0,e)}));function wf(e){return new _f({type:"function",input:Array.isArray(e?.input)?sf(e?.input):Kp(Wp()),output:Wp()})}const Cf=Tl("ZodCustom",((e,t)=>{Ed.init(e,t),fp.init(e,t),e._zod.processJSONSchema=(e,t,r)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")})(0,e)}));function Ef(e,t){return function(e,t,r){const n=Kl(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}(Cf,e??(()=>!0),t)}function Sf(e,t={error:`Input not instance of ${e.name}`}){const r=new Cf({type:"custom",check:"custom",fn:t=>t instanceof e,abort:!0,...Kl(t)});return r._zod.bag.Class=e,r}var Af={"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"]]},fromAxisAngle:{overloads:[["Number?","Number?","Number?","Number?"]]},day:{overloads:[[]]},mult:{overloads:[["p5.Quat?"]]},print:{overloads:[["Any"],["String|Number|Array"]]},hour:{overloads:[[]]},randomSeed:{overloads:[["Number"]]},float:{overloads:[["String"],["String[]"]]},rotateBy:{overloads:[["p5.Quat?"]]},ellipseMode:{overloads:[["CENTER|RADIUS|CORNER|CORNERS"],[]]},abs:{overloads:[["Number"]]},nf:{overloads:[["Number|String","Integer|String?","Integer|String?"],["Number[]","Integer|String?","Integer|String?"]]},strokeMode:{overloads:[["String"]]},select:{overloads:[["String","String|p5.Element|HTMLElement?"]]},loadImage:{overloads:[["String|Request","function(p5.Image)?","function(Event)?"]]},createVector:{overloads:[["...Number[]"]]},minute:{overloads:[[]]},noLoop:{overloads:[[]]},describe:{overloads:[["String","FALLBACK|LABEL?"]]},storeItem:{overloads:[["String","String|Number|Boolean|Object|Array"]]},textOutput:{overloads:[["FALLBACK|LABEL?"]]},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?"]]},loadShader:{overloads:[["String|Request","String|Request","Function?","Function?"]]},createImage:{overloads:[["Integer","Integer"]]},orbitControl:{overloads:[["Number?","Number?","Number?","Object?"]]},noSmooth:{overloads:[[]]},beginClip:{overloads:[["Object?"]]},ceil:{overloads:[["Number"]]},ambientLight:{overloads:[["Number","Number","Number","Number?"],["Number","Number?"],["String"],["Number[]"],["p5.Color"]]},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"]]},endClip:{overloads:[[]]},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:[[]]},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"]]},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:[[]]},describeElement:{overloads:[["String","String","FALLBACK|LABEL?"]]},millis:{overloads:[[]]},isLooping:{overloads:[[]]},gridOutput:{overloads:[["FALLBACK|LABEL?"]]},resizeCanvas:{overloads:[["Number","Number","Boolean?"]]},saveGif:{overloads:[["String","Number","Object?"]]},saveCanvas:{overloads:[["p5.Framebuffer|p5.Element|HTMLCanvasElement","String?","String?"],["String?","String?"]]},resetMatrix:{overloads:[[]]},getItem:{overloads:[["String"]]},noise:{overloads:[["Number","Number?","Number?"]]},rectMode:{overloads:[["CENTER|RADIUS|CORNER|CORNERS"],[]]},month:{overloads:[[]]},random:{overloads:[["Number?","Number?"],["Array"]]},loadJSON:{overloads:[["String|Request","Function?","Function?"]]},arc:{overloads:[["Number","Number","Number","Number","Number","Number","CHORD|PIE|OPEN?","Integer?"]]},noCanvas:{overloads:[[]]},createElement:{overloads:[["String","String?"]]},asin:{overloads:[["Number"]]},dist:{overloads:[["Number","Number","Number","Number"],["Number","Number","Number","Number","Number","Number"]]},cursor:{overloads:[["ARROW|CROSS|HAND|MOVE|TEXT|WAIT|String","Number?","Number?"],[]]},str:{overloads:[["String|Boolean|Number"]]},second:{overloads:[[]]},buildGeometry:{overloads:[["Function"]]},byte:{overloads:[["String|Boolean|Number"],["Array"]]},bezierPoint:{overloads:[["Number","Number","Number","Number","Number"]]},set:{overloads:[["Number","Number","Number|Number[]|Object"]]},loadModel:{overloads:[["String|Request","String?","Boolean?","function(p5.Geometry)?","function(Event)?"],["String|Request","String?","function(p5.Geometry)?","function(Event)?"],["String|Request","Object?"]]},redraw:{overloads:[["Integer?"]]},year:{overloads:[[]]},nfp:{overloads:[["Number","Integer?","Integer?"],["Number[]","Integer?","Integer?"]]},smooth:{overloads:[[]]},clearStorage:{overloads:[[]]},removeElements:{overloads:[[]]},beginShape:{overloads:[["POINTS|LINES|TRIANGLES|TRIANGLE_FAN|TRIANGLE_STRIP|QUADS|QUAD_STRIP|PATH?"]]},saveObj:{overloads:[["String?"]]},randomGaussian:{overloads:[["Number?","Number?"]]},addElement:{overloads:[[]]},clip:{overloads:[["Function","Object?"]]},color:{overloads:[["Number","Number?"],["Number","Number","Number","Number?"],["String"],["Number[]"],["p5.Color"]]},atan:{overloads:[["Number"]]},createGraphics:{overloads:[["Number","Number","P2D|WEBGL?","HTMLCanvasElement?"],["Number","Number","HTMLCanvasElement?"]]},freeGeometry:{overloads:[["p5.Geometry"]]},frameRate:{overloads:[["Number"],[]]},strokeCap:{overloads:[["ROUND|SQUARE|PROJECT"]]},exp:{overloads:[["Number"]]},noiseDetail:{overloads:[["Number","Number?"]]},specularColor:{overloads:[["Number","Number","Number"],["Number"],["String"],["Number[]"],["p5.Color"]]},createDiv:{overloads:[["String?"]]},loadStrings:{overloads:[["String|Request","Function?","Function?"]]},boolean:{overloads:[["String|Boolean|Number"],["Array"]]},rotate:{overloads:[["Number","p5.Vector|Number[]?"]]},removeItem:{overloads:[["String"]]},bezierTangent:{overloads:[["Number","Number","Number","Number","Number"]]},setMoveThreshold:{overloads:[["Number"]]},ellipse:{overloads:[["Number","Number","Number","Number?"],["Number","Number","Number","Number","Integer?"]]},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"]]},saveStl:{overloads:[["String?","Object?"]]},circle:{overloads:[["Number","Number","Number"]]},floor:{overloads:[["Number"]]},noCursor:{overloads:[[]]},loadTable:{overloads:[["String|Request","String?","String?","Function?","Function?"]]},plane:{overloads:[["Number?","Number?","Integer?","Integer?"]]},strokeJoin:{overloads:[["MITER|BEVEL|ROUND"],[]]},filter:{overloads:[["THRESHOLD|GRAY|OPAQUE|INVERT|POSTERIZE|BLUR|ERODE|DILATE|BLUR","Number?","Boolean?"],["p5.Shader"]]},red:{overloads:[["p5.Color|Number[]|String"]]},createSpan:{overloads:[["String?"]]},loadFilterShader:{overloads:[["String","Function?","Function?"]]},rotateX:{overloads:[["Number"]]},createFramebuffer:{overloads:[["Object?"]]},createImg:{overloads:[["String","String"],["String","String","String?","Function?"]]},strokeWeight:{overloads:[["Number"],[]]},cos:{overloads:[["Number"]]},deviceMoved:{overloads:[[]]},deviceTurned:{overloads:[[]]},deviceShaken:{overloads:[[]]},background:{overloads:[["p5.Color"],["String","Number?"],["Number","Number?"],["Number","Number","Number","Number?"],["Number[]"],["p5.Image","Number?"]]},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"]]},splitTokens:{overloads:[["String","String?"]]},lerp:{overloads:[["Number","Number","Number"]]},keyPressed:{overloads:[["KeyboardEvent?"]]},box:{overloads:[["Number?","Number?","Number?","Integer?","Integer?"]]},clearDepth:{overloads:[["Number?"]]},green:{overloads:[["p5.Color|Number[]|String"]]},bezierVertex:{overloads:[["Number","Number","Number?","Number?"],["Number","Number","Number","Number?","Number?"]]},createA:{overloads:[["String","String","String?"]]},saveFrames:{overloads:[["String","String","Number","Number","function(Array)?"]]},line:{overloads:[["Number","Number","Number","Number"],["Number","Number","Number","Number","Number","Number"]]},clear:{overloads:[["Number?","Number?","Number?","Number?"],[]]},setup:{overloads:[[]]},draw:{overloads:[[]]},registerAddon:{overloads:[["Function"]]},char:{overloads:[["String|Number"],["Array"]]},rotateY:{overloads:[["Number"]]},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?"]]},roll:{overloads:[["Number"]]},spline:{overloads:[["Number","Number","Number","Number","Number","Number","Number","Number"],["Number","Number","Number","Number","Number","Number","Number","Number","Number","Number","Number","Number"]]},sin:{overloads:[["Number"]]},loadXML:{overloads:[["String|Request","Function?","Function?"]]},get:{overloads:[["Number","Number","Number","Number"],[],["Number","Number"]]},log:{overloads:[["Number"]]},shuffle:{overloads:[["Array","Boolean?"]]},windowResized:{overloads:[["Event?"]]},unchar:{overloads:[["String"],["String[]"]]},noDebugMode:{overloads:[[]]},sphere:{overloads:[["Number?","Integer?","Integer?"]]},loadPixels:{overloads:[[]]},loadBytes:{overloads:[["String|Request","Function?","Function?"]]},buildFilterShader:{overloads:[["Function","Object?"],["Object","Object?"]]},blue:{overloads:[["p5.Color|Number[]|String"]]},createSlider:{overloads:[["Number","Number","Number?","Number?"]]},mag:{overloads:[["Number","Number"]]},tan:{overloads:[["Number"]]},keyReleased:{overloads:[["KeyboardEvent?"]]},rotateZ:{overloads:[["Number"]]},loadBlob:{overloads:[["String|Request","Function?","Function?"]]},fullscreen:{overloads:[["Boolean?"]]},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"]]},createButton:{overloads:[["String","String?"]]},createFilterShader:{overloads:[["String"]]},alpha:{overloads:[["p5.Color|Number[]|String"]]},endShape:{overloads:[["CLOSE?","Integer?"]]},degrees:{overloads:[["Number"]]},hex:{overloads:[["Number","Number?"],["Number[]","Number?"]]},splinePoint:{overloads:[["Number","Number","Number","Number","Number"]]},map:{overloads:[["Number","Number","Number","Number","Number","Boolean?"]]},pixelDensity:{overloads:[["Number?"],[]]},httpGet:{overloads:[["String|Request","String?","Function?","Function?"],["String|Request","Function","Function?"]]},imageLight:{overloads:[["p5.Image"]]},updatePixels:{overloads:[["Number?","Number?","Number?","Number?"],[]]},displayDensity:{overloads:[[]]},radians:{overloads:[["Number"]]},panorama:{overloads:[["p5.Image"]]},createCheckbox:{overloads:[["String?","Boolean?"]]},keyTyped:{overloads:[["KeyboardEvent?"]]},cylinder:{overloads:[["Number?","Number?","Integer?","Integer?","Boolean?","Boolean?"]]},scale:{overloads:[["Number|p5.Vector|Number[]","Number?","Number?"],["p5.Vector|Number[]"]]},hue:{overloads:[["p5.Color|Number[]|String"]]},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?"]]},getURL:{overloads:[[]]},max:{overloads:[["Number","Number"],["Number[]"]]},lights:{overloads:[[]]},getURLPath:{overloads:[[]]},splineTangent:{overloads:[["Number","Number","Number","Number","Number"]]},normal:{overloads:[["p5.Vector"],["Number","Number","Number"]]},shearX:{overloads:[["Number"]]},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?"],[]]},getURLParams:{overloads:[[]]},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?"]]},lightFalloff:{overloads:[["Number","Number","Number"]]},shader:{overloads:[["p5.Shader"]]},mouseMoved:{overloads:[["MouseEvent?"]]},mouseDragged:{overloads:[["MouseEvent?"]]},keyIsDown:{overloads:[["Number|String"]]},setContent:{overloads:[["String"]]},angleMode:{overloads:[["RADIANS|DEGREES"],[]]},rect:{overloads:[["Number","Number","Number","Number?","Number?","Number?","Number?","Number?"],["Number","Number","Number","Number","Integer?","Integer?"]]},shearY:{overloads:[["Number"]]},min:{overloads:[["Number","Number"],["Number[]"]]},httpDo:{overloads:[["String|Request","String?","String?","Object?","Function?","Function?"],["String|Request","Function?","Function?"]]},saturation:{overloads:[["p5.Color|Number[]|String"]]},model:{overloads:[["p5.Geometry","Number?"]]},createSelect:{overloads:[["Boolean?"],["Object"]]},cone:{overloads:[["Number?","Number?","Integer?","Integer?","Boolean?"]]},norm:{overloads:[["Number","Number","Number"]]},worldToScreen:{overloads:[["Number|p5.Vector","Number","Number?"]]},vertexProperty:{overloads:[["String","Number|Number[]"]]},square:{overloads:[["Number","Number","Number","Number?","Number?","Number?","Number?"]]},screenToWorld:{overloads:[["Number|p5.Vector","Number","Number?"]]},createModel:{overloads:[["String","String?","Boolean?","function(p5.Geometry)?","function(Event)?"],["String","String?","function(p5.Geometry)?","function(Event)?"],["String","String?","Object?"]]},strokeShader:{overloads:[["p5.Shader"]]},mousePressed:{overloads:[["MouseEvent?"]]},pow:{overloads:[["Number","Number"]]},brightness:{overloads:[["p5.Color|Number[]|String"]]},translate:{overloads:[["Number","Number","Number?"],["p5.Vector"]]},tint:{overloads:[["Number","Number","Number","Number?"],["String"],["Number","Number?"],["Number[]"],["p5.Color"],[]]},createWriter:{overloads:[["String","String?"]]},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?"]]},fill:{overloads:[["Number","Number","Number","Number?"],["String"],["Number","Number?"],["Number[]"],["p5.Color"],[]]},triangle:{overloads:[["Number","Number","Number","Number","Number","Number"]]},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"],[]]},noTint:{overloads:[[]]},ellipsoid:{overloads:[["Number?","Number?","Number?","Integer?","Integer?"]]},round:{overloads:[["Number","Number?"]]},noFill:{overloads:[[]]},noLights:{overloads:[[]]},imageShader:{overloads:[["p5.Shader"]]},lightness:{overloads:[["p5.Color|Number[]|String"]]},mouseReleased:{overloads:[["MouseEvent?"]]},write:{overloads:[["String|Number|Array"]]},noStroke:{overloads:[[]]},createRadio:{overloads:[["Object?"],["String?"],[]]},sq:{overloads:[["Number"]]},createVideo:{overloads:[["String|String[]?","Function?"]]},imageMode:{overloads:[["CORNER|CORNERS|CENTER"],[]]},loadFont:{overloads:[["String","String?","Object?","Function?","Function?"],["String","Function?","Function?"]]},lerpColor:{overloads:[["p5.Color","p5.Color","Number"]]},createAudio:{overloads:[["String|String[]?","Function?"]]},torus:{overloads:[["Number?","Number?","Integer?","Integer?"]]},paletteLerp:{overloads:[["[p5.Color|String|Number|Number[], Number][]","Number"]]},sqrt:{overloads:[["Number"]]},close:{overloads:[[]]},mouseClicked:{overloads:[["MouseEvent?"]]},buildMaterialShader:{overloads:[["Function","Object?"],["Object","Object?"]]},fract:{overloads:[["Number"]]},createCapture:{overloads:[["AUDIO|VIDEO|Object?","Object?","Function?"]]},stroke:{overloads:[["Number","Number","Number","Number?"],["String"],["Number","Number?"],["Number[]"],["p5.Color"],[]]},createColorPicker:{overloads:[["String|p5.Color?"]]},loadMaterialShader:{overloads:[["String","Function?","Function?"]]},save:{overloads:[["Object|String?","String?","Boolean|String?"]]},baseMaterialShader:{overloads:[[]]},doubleClicked:{overloads:[["MouseEvent?"]]},baseFilterShader:{overloads:[[]]},erase:{overloads:[["Number?","Number?"]]},createInput:{overloads:[["String?","String?"],["String?"]]},noErase:{overloads:[[]]},buildNormalShader:{overloads:[["Function","Object?"],["Object","Object?"]]},saveJSON:{overloads:[["Array|Object","String","Boolean?"]]},pop:{overloads:[[]]},mouseWheel:{overloads:[["WheelEvent?"]]},createFileInput:{overloads:[["Function","Boolean?"]]},loadNormalShader:{overloads:[["String","Function?","Function?"]]},requestPointerLock:{overloads:[[]]},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:[[]]},setAttributes:{overloads:[["String","Boolean"],["Object"]]},bezierOrder:{overloads:[["Number"],[]]},blendMode:{overloads:[["BLEND|DARKEST|LIGHTEST|DIFFERENCE|MULTIPLY|EXCLUSION|SCREEN|REPLACE|OVERLAY|HARD_LIGHT|SOFT_LIGHT|DODGE|BURN|ADD|REMOVE|SUBTRACT"],[]]},camera:{overloads:[["Number?","Number?","Number?","Number?","Number?","Number?","Number?","Number?","Number?"]]},createStorage:{overloads:[["Number|Array|Float32Array|Object[]"]]},buildStrokeShader:{overloads:[["Function","Object?"],["Object","Object?"]]},baseComputeShader:{overloads:[[]]},loadStrokeShader:{overloads:[["String","Function?","Function?"]]},perspective:{overloads:[["Number?","Number?","Number?","Number?"]]},baseStrokeShader:{overloads:[[]]},resetShader:{overloads:[[]]},buildComputeShader:{overloads:[["Function"]]},linePerspective:{overloads:[["Boolean"],[]]},splineVertex:{overloads:[["Number","Number"],["Number","Number","Number?"],["Number","Number","Number?","Number?"],["Number","Number","Number","Number?","Number?"]]},ortho:{overloads:[["Number?","Number?","Number?","Number?","Number?","Number?"]]},texture:{overloads:[["p5.Image|p5.MediaElement|p5.Graphics|p5.Texture|p5.Framebuffer|p5.FramebufferTexture"]]},compute:{overloads:[["p5.Shader","Number","Number?","Number?"]]},curveDetail:{overloads:[["Number"]]},frustum:{overloads:[["Number?","Number?","Number?","Number?","Number?","Number?"]]},createCamera:{overloads:[[]]},splineProperty:{overloads:[["String",null],["String"]]},textureMode:{overloads:[["IMAGE|NORMAL"],[]]},setCamera:{overloads:[["p5.Camera"]]},splineProperties:{overloads:[["Object"]]},textureWrap:{overloads:[["CLAMP|REPEAT|MIRROR","CLAMP|REPEAT|MIRROR?"],[]]},vertex:{overloads:[["Number","Number"],["Number","Number","Number?","Number?"],["Number","Number","Number","Number?","Number?"]]},normalMaterial:{overloads:[[]]},beginContour:{overloads:[[]]},endContour:{overloads:[["OPEN|CLOSE?"]]},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.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","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.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|Object[]"]]},read:{overloads:[[]]},set:{overloads:[["Number","Number|Object"]]}},"p5.Geometry":{calculateBoundingBox:{overloads:[[]]},clearColors:{overloads:[[]]},flipU:{overloads:[[]]},computeFaces:{overloads:[[]]},computeNormals:{overloads:[["FLAT|SMOOTH?","Object?"]]},makeEdgesFromFaces:{overloads:[[]]},normalize:{overloads:[[]]},vertexProperty:{overloads:[["String","Number|Number[]","Number?"]]},flipV:{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.Graphics":{reset:{overloads:[[]]},remove:{overloads:[[]]},createFramebuffer:{overloads:[["Object?"]]}}};function Df(e,t,r){let n=new Map;const i=Object.keys(e).reduce(((t,r)=>(r.match(/^[A-Z]/)&&!r.match(/^[A-Z][A-Z0-9]*$/)&&e[r]instanceof Function&&(t[r]=e[r]),t)),{});const s={};for(const[e,t]of Object.entries(qe))s[e]=t;const o={Any:Hp(),Array:Kp(Hp()),Boolean:Gp(),Function:wf(),Integer:Vp().int(),Number:tf([Vp(),uf(1/0),uf(-1/0)]),Object:Qp({}),String:yp()};const a=["AudioNode","HTMLCanvasElement","HTMLElement","KeyboardEvent","MouseEvent","RegExp","TouchEvent","UIEvent","WheelEvent"].reduce(((e,t)=>(e[t]=Ef((e=>e instanceof globalThis[t]),{message:`Expected a ${t}`}),e)),{});Object.assign(o,a);const u=["first","second","third","fourth","fifth","sixth","seventh","eighth","ninth","tenth"];function l(e){const t=e.lastIndexOf(".");return{funcName:e.slice(t+1),funcClass:e.slice(0,-1!==t?t:0)||"p5"}}function h(e){let t=0;for(let r=0;r<e.length;r++)if("["===e[r])t++;else if("]"===e[r]&&(t--,t<0))return!1;return 0===t}const c=function(e){const{funcName:r,funcClass:n}=l(e);let a=Af[n][r];if(!a)return;let u=[];a.hasOwnProperty("overloads")&&(u=a.overloads);const c=e=>{if(!e)return Hp();let r;if(e in s)r=uf(s[e]);else if(e.match(/^[A-Z][A-Z0-9]*$/)&&e in t)r=uf(t[e]);else if(e.startsWith("function"))r=wf();else if(/^p5\.[a-zA-Z0-9]+$/.exec(e)||"p5"===e){const t=e.substring(e.indexOf(".")+1);r=Sf(i[t])}else if(o[e])r=o[e];else if(e.startsWith("[")&&e.endsWith("]")&&h(e.slice(1,-1)))r=sf(e.slice(1,-1).split(/, */g).map((e=>c(e))));else if(e.match(/^[A-Z]/)&&e in window)r=Sf(window[e]);else if(e.includes("|")&&e.split("|").every((e=>h(e)))){r=tf(e.split("|").map((e=>c(e))).filter((e=>void 0!==e)))}else{if(!e.endsWith("[]"))throw new Error(`Unsupported type '${e}' in parameter validation. Please report this issue.`);r=Kp(c(e.slice(0,-2)))}return r},d=u.flatMap((e=>{const t=(e=>{if(!e.some((e=>e?.endsWith("?"))))return[e];const t=e.filter((e=>null===e||!e.endsWith("?"))).length,r=[];for(let n=t;n<=e.length;n++)r.push(e.slice(0,n));return r})(e);return t.map((e=>{const t=e.map((e=>(e=>{const t=e?.endsWith("?");e=e?.replace(/\?$/,"");const r=e?.startsWith("...")&&e?.endsWith("[]");e=e?.replace(/^\.\.\.(.+)\[\]$/,"$1");let n=c(e);return"function"===n.def.type&&(n=Ef((e=>e instanceof Function))),t&&(n=n.optional()),{schema:n,rest:r}})(e))).filter((e=>void 0!==e.schema));let r;t.at(-1)?.rest&&(r=t.pop());let n=sf(t.map((e=>e.schema)));return r&&(n=n.rest(r.schema)),n}))}));return 1===d.length?d[0]:tf(d)},d=function(e,t){if(!(e instanceof ef))return e;let r=e.def.options[0],n=1/0;return e.def.options.forEach((e=>{const i=(e=>{let r=1/0;if(!(e instanceof nf))return console.warn("Schema below is not a tuple: "),printZodSchema(e),r;const n=t.length,i=e.def.items,s=i.length,o=i.filter((e=>!e.isOptional())).length;r=n>=o&&n<=s?0:4*Math.abs(n<o?o-n:n-s);for(let e=0;e<Math.min(i.length,t.length);e++){const n=i[e],s=t[e];n.safeParse(s).success||r++}return r})(e);i<n&&(r=e,n=i)})),r},p=function(t,r,n){let i="🌸 p5.js says: ",s=!1,o=t.issues[0];const a=(e,t,r)=>`Expected ${t} ${r?`at the ${u[r]} parameter`:""}${e?`, but received ${e}`:""}`;switch(o.code){case"invalid_union":(e=>{const t=new Set;let r;const o=i=>{if(i)if(r||(r=i.message),"invalid_type"===i.code)r=i.message.split(", received ")[1],t.add(i.expected);else if("invalid_value"===i.code)Array.isArray(i.values)&&i.values.every((e=>e===1/0||e===-1/0))?t.add("number"):(t.add("constant (please refer to documentation for allowed values)"),r=n[e.path[0]]);else if("custom"===i.code){const e=i.message.match(/Input not instance of (\w+)/);e&&t.add(e[1]),r=void 0}else"invalid_union"===i.code&&i.errors.forEach((e=>{e.forEach((e=>o(e)))}))};if(e.errors.forEach((e=>{e.forEach((e=>o(e)))})),t.size>0){e.path?.length>0&&n[e.path[0]]instanceof Promise&&(i+="Did you mean to put `await` before a loading function? An unexpected Promise was found. ",s=!0);const o=Array.from(t).join(" or "),u=e.path.join(".");i+=a(r,o,u)}})(o);break;case"too_small":{const e=o.minimum;i+=`Expected at least ${e} argument${e>1?"s":""}, but received fewer`;break}case"invalid_type":i+=a(o.message.split(", received ")[1],o.expected,o.path.join("."));break;case"too_big":{const e=o.maximum;i+=`Expected at most ${e} argument${e>1?"s":""}, but received more`;break}default:console.log("Zod error object",o)}i+=` in ${r}().`;if("too_big"===o.code||"too_small"===o.code){const e=(e=>{const{funcName:t,funcClass:r}=l(e);return`https://p5js.org/reference/${r}/${t}`})(r);i+=` For more information, see ${e}.`}return s?e._error(this,i):console.log(i),i},f=function(t,r){if(e.disableFriendlyErrors)return;if(Array.isArray(r)||(r=Array.from(r)),Array.isArray(r)&&r.length>0&&r.every((e=>void 0===e))){return{success:!1,error:`🌸 p5.js says: All arguments for ${t}() are undefined. There is likely an error in the code.`}}let i=n.get(t);if(!i){if(i=c(t),!i)return;n.set(t,i)}try{return{success:!0,data:i.parse(r)}}catch(e){const n=d(i,r).safeParse(r).error;return{success:!1,error:p(n,t,r)}}};t._validate=f,t._internal=function(e){const t=this._isUserCall;this._isUserCall=!0;try{return e()}finally{this._isUserCall=t}},e.registerDecorator((({path:e})=>e.startsWith("p5.prototype")),(function(t,{kind:r,name:n}){if("method"===r)return function(...r){if(e.disableFriendlyErrors)return t.apply(this,r);const i=this._isUserCall;this._isUserCall=!0;try{return i||e.disableFriendlyErrors||e.disableParameterValidator||f(n,r),t.apply(this,r)}finally{this._isUserCall=i}}})),r.presetup=function(){!function(){for(let t of Object.keys(e))"function"==typeof e[t]&&t[0]!==t[0].toLowerCase()&&(i[t]=e[t])}()}}"undefined"!=typeof p5&&p5.registerAddon(Df);var Tf=[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,80,3,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,343,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,330,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,726,6,110,6,6,9,4759,9,787719,239],Ff=[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,71,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,2,60,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,328,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,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,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,496,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,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],If="ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢎࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೝೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-ᲊᲐ-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ-ꟍꟐꟑꟓꟕ-Ƛꟲ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ",kf={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"},Nf="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",Mf={5:Nf,"5module":Nf+" export import",6:Nf+" const class extends export import super"},Of=/^in(stanceof)?$/,Bf=new RegExp("["+If+"]"),Lf=new RegExp("["+If+"‌‍·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࢗ-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ-ᫎᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‌‍‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・]");function Pf(e,t){for(var r=65536,n=0;n<t.length;n+=2){if((r+=t[n])>e)return!1;if((r+=t[n+1])>=e)return!0}return!1}function Rf(e,t){return e<65?36===e:e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&Bf.test(String.fromCharCode(e)):!1!==t&&Pf(e,Ff)))}function Vf(e,t){return e<48?36===e:e<58||!(e<65)&&(e<91||(e<97?95===e:e<123||(e<=65535?e>=170&&Lf.test(String.fromCharCode(e)):!1!==t&&(Pf(e,Ff)||Pf(e,Tf)))))}var Uf=function(e,t){void 0===t&&(t={}),this.label=e,this.keyword=t.keyword,this.beforeExpr=!!t.beforeExpr,this.startsExpr=!!t.startsExpr,this.isLoop=!!t.isLoop,this.isAssign=!!t.isAssign,this.prefix=!!t.prefix,this.postfix=!!t.postfix,this.binop=t.binop||null,this.updateContext=null};function zf(e,t){return new Uf(e,{beforeExpr:!0,binop:t})}var jf={beforeExpr:!0},Gf={startsExpr:!0},$f={};function Hf(e,t){return void 0===t&&(t={}),t.keyword=e,$f[e]=new Uf(e,t)}var qf={num:new Uf("num",Gf),regexp:new Uf("regexp",Gf),string:new Uf("string",Gf),name:new Uf("name",Gf),privateId:new Uf("privateId",Gf),eof:new Uf("eof"),bracketL:new Uf("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new Uf("]"),braceL:new Uf("{",{beforeExpr:!0,startsExpr:!0}),braceR:new Uf("}"),parenL:new Uf("(",{beforeExpr:!0,startsExpr:!0}),parenR:new Uf(")"),comma:new Uf(",",jf),semi:new Uf(";",jf),colon:new Uf(":",jf),dot:new Uf("."),question:new Uf("?",jf),questionDot:new Uf("?."),arrow:new Uf("=>",jf),template:new Uf("template"),invalidTemplate:new Uf("invalidTemplate"),ellipsis:new Uf("...",jf),backQuote:new Uf("`",Gf),dollarBraceL:new Uf("${",{beforeExpr:!0,startsExpr:!0}),eq:new Uf("=",{beforeExpr:!0,isAssign:!0}),assign:new Uf("_=",{beforeExpr:!0,isAssign:!0}),incDec:new Uf("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new Uf("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:zf("||",1),logicalAND:zf("&&",2),bitwiseOR:zf("|",3),bitwiseXOR:zf("^",4),bitwiseAND:zf("&",5),equality:zf("==/!=/===/!==",6),relational:zf("</>/<=/>=",7),bitShift:zf("<</>>/>>>",8),plusMin:new Uf("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:zf("%",10),star:zf("*",10),slash:zf("/",10),starstar:new Uf("**",{beforeExpr:!0}),coalesce:zf("??",1),_break:Hf("break"),_case:Hf("case",jf),_catch:Hf("catch"),_continue:Hf("continue"),_debugger:Hf("debugger"),_default:Hf("default",jf),_do:Hf("do",{isLoop:!0,beforeExpr:!0}),_else:Hf("else",jf),_finally:Hf("finally"),_for:Hf("for",{isLoop:!0}),_function:Hf("function",Gf),_if:Hf("if"),_return:Hf("return",jf),_switch:Hf("switch"),_throw:Hf("throw",jf),_try:Hf("try"),_var:Hf("var"),_const:Hf("const"),_while:Hf("while",{isLoop:!0}),_with:Hf("with"),_new:Hf("new",{beforeExpr:!0,startsExpr:!0}),_this:Hf("this",Gf),_super:Hf("super",Gf),_class:Hf("class",Gf),_extends:Hf("extends",jf),_export:Hf("export"),_import:Hf("import",Gf),_null:Hf("null",Gf),_true:Hf("true",Gf),_false:Hf("false",Gf),_in:Hf("in",{beforeExpr:!0,binop:7}),_instanceof:Hf("instanceof",{beforeExpr:!0,binop:7}),_typeof:Hf("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:Hf("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:Hf("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},Wf=/\r\n?|\n|\u2028|\u2029/,Xf=new RegExp(Wf.source,"g");function Zf(e){return 10===e||13===e||8232===e||8233===e}function Yf(e,t,r){void 0===r&&(r=e.length);for(var n=t;n<r;n++){var i=e.charCodeAt(n);if(Zf(i))return n<r-1&&13===i&&10===e.charCodeAt(n+1)?n+2:n+1}return-1}var Kf=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,Jf=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,Qf=Object.prototype,em=Qf.hasOwnProperty,tm=Qf.toString,rm=Object.hasOwn||function(e,t){return em.call(e,t)},nm=Array.isArray||function(e){return"[object Array]"===tm.call(e)},im=Object.create(null);function sm(e){return im[e]||(im[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}function om(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}var am=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,um=function(e,t){this.line=e,this.column=t};um.prototype.offset=function(e){return new um(this.line,this.column+e)};var lm=function(e,t,r){this.start=t,this.end=r,null!==e.sourceFile&&(this.source=e.sourceFile)};function hm(e,t){for(var r=1,n=0;;){var i=Yf(e,n,t);if(i<0)return new um(r,t-n);++r,n=i}}var cm={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},dm=!1;function pm(e){var t={};for(var r in cm)t[r]=e&&rm(e,r)?e[r]:cm[r];if("latest"===t.ecmaVersion?t.ecmaVersion=1e8:null==t.ecmaVersion?(!dm&&"object"==typeof console&&console.warn&&(dm=!0,console.warn("Since Acorn 8.0.0, options.ecmaVersion is required.\nDefaulting to 2020, but this will stop working in the future.")),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),null==t.allowReserved&&(t.allowReserved=t.ecmaVersion<5),e&&null!=e.allowHashBang||(t.allowHashBang=t.ecmaVersion>=14),nm(t.onToken)){var n=t.onToken;t.onToken=function(e){return n.push(e)}}return nm(t.onComment)&&(t.onComment=function(e,t){return function(r,n,i,s,o,a){var u={type:r?"Block":"Line",value:n,start:i,end:s};e.locations&&(u.loc=new lm(this,o,a)),e.ranges&&(u.range=[i,s]),t.push(u)}}(t,t.onComment)),t}var fm=256,mm=259;function gm(e,t){return 2|(e?4:0)|(t?8:0)}var ym=function(e,t,r){this.options=e=pm(e),this.sourceFile=e.sourceFile,this.keywords=sm(Mf[e.ecmaVersion>=6?6:"module"===e.sourceType?"5module":5]);var n="";!0!==e.allowReserved&&(n=kf[e.ecmaVersion>=6?6:5===e.ecmaVersion?5:3],"module"===e.sourceType&&(n+=" await")),this.reservedWords=sm(n);var i=(n?n+" ":"")+kf.strict;this.reservedWordsStrict=sm(i),this.reservedWordsStrictBind=sm(i+" "+kf.strictBind),this.input=String(t),this.containsEsc=!1,r?(this.pos=r,this.lineStart=this.input.lastIndexOf("\n",r-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(Wf).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=qf.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="module"===e.sourceType,this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),0===this.pos&&e.allowHashBang&&"#!"===this.input.slice(0,2)&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(1),this.regexpState=null,this.privateNameStack=[]},vm={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};ym.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)},vm.inFunction.get=function(){return(2&this.currentVarScope().flags)>0},vm.inGenerator.get=function(){return(8&this.currentVarScope().flags)>0},vm.inAsync.get=function(){return(4&this.currentVarScope().flags)>0},vm.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(768&t)return!1;if(2&t)return(4&t)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},vm.allowSuper.get=function(){return(64&this.currentThisScope().flags)>0||this.options.allowSuperOutsideMethod},vm.allowDirectSuper.get=function(){return(128&this.currentThisScope().flags)>0},vm.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},vm.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e].flags;if(768&t||2&t&&!(16&t))return!0}return!1},vm.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&fm)>0},ym.extend=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var r=this,n=0;n<e.length;n++)r=e[n](r);return r},ym.parse=function(e,t){return new this(t,e).parse()},ym.parseExpressionAt=function(e,t,r){var n=new this(r,e,t);return n.nextToken(),n.parseExpression()},ym.tokenizer=function(e,t){return new this(t,e)},Object.defineProperties(ym.prototype,vm);var bm=ym.prototype,xm=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;bm.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){Jf.lastIndex=e,e+=Jf.exec(this.input)[0].length;var t=xm.exec(this.input.slice(e));if(!t)return!1;if("use strict"===(t[1]||t[2])){Jf.lastIndex=e+t[0].length;var r=Jf.exec(this.input),n=r.index+r[0].length,i=this.input.charAt(n);return";"===i||"}"===i||Wf.test(r[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(i)||"!"===i&&"="===this.input.charAt(n+1))}e+=t[0].length,Jf.lastIndex=e,e+=Jf.exec(this.input)[0].length,";"===this.input[e]&&e++}},bm.eat=function(e){return this.type===e&&(this.next(),!0)},bm.isContextual=function(e){return this.type===qf.name&&this.value===e&&!this.containsEsc},bm.eatContextual=function(e){return!!this.isContextual(e)&&(this.next(),!0)},bm.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},bm.canInsertSemicolon=function(){return this.type===qf.eof||this.type===qf.braceR||Wf.test(this.input.slice(this.lastTokEnd,this.start))},bm.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},bm.semicolon=function(){this.eat(qf.semi)||this.insertSemicolon()||this.unexpected()},bm.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},bm.expect=function(e){this.eat(e)||this.unexpected()},bm.unexpected=function(e){this.raise(null!=e?e:this.start,"Unexpected token")};var _m=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};bm.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var r=t?e.parenthesizedAssign:e.parenthesizedBind;r>-1&&this.raiseRecoverable(r,t?"Assigning to rvalue":"Parenthesized pattern")}},bm.checkExpressionErrors=function(e,t){if(!e)return!1;var r=e.shorthandAssign,n=e.doubleProto;if(!t)return r>=0||n>=0;r>=0&&this.raise(r,"Shorthand property assignments are valid only in destructuring patterns"),n>=0&&this.raiseRecoverable(n,"Redefinition of __proto__ property")},bm.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")},bm.isSimpleAssignTarget=function(e){return"ParenthesizedExpression"===e.type?this.isSimpleAssignTarget(e.expression):"Identifier"===e.type||"MemberExpression"===e.type};var wm=ym.prototype;wm.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==qf.eof;){var r=this.parseStatement(null,!0,t);e.body.push(r)}if(this.inModule)for(var n=0,i=Object.keys(this.undefinedExports);n<i.length;n+=1){var s=i[n];this.raiseRecoverable(this.undefinedExports[s].start,"Export '"+s+"' is not defined")}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType,this.finishNode(e,"Program")};var Cm={kind:"loop"},Em={kind:"switch"};wm.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;Jf.lastIndex=this.pos;var t=Jf.exec(this.input),r=this.pos+t[0].length,n=this.input.charCodeAt(r);if(91===n||92===n)return!0;if(e)return!1;if(123===n||n>55295&&n<56320)return!0;if(Rf(n,!0)){for(var i=r+1;Vf(n=this.input.charCodeAt(i),!0);)++i;if(92===n||n>55295&&n<56320)return!0;var s=this.input.slice(r,i);if(!Of.test(s))return!0}return!1},wm.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;Jf.lastIndex=this.pos;var e,t=Jf.exec(this.input),r=this.pos+t[0].length;return!(Wf.test(this.input.slice(this.pos,r))||"function"!==this.input.slice(r,r+8)||r+8!==this.input.length&&(Vf(e=this.input.charCodeAt(r+8))||e>55295&&e<56320))},wm.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;Jf.lastIndex=this.pos;var r=Jf.exec(this.input),n=this.pos+r[0].length;if(Wf.test(this.input.slice(this.pos,n)))return!1;if(e){var i,s=n+5;if("using"!==this.input.slice(n,s)||s===this.input.length||Vf(i=this.input.charCodeAt(s))||i>55295&&i<56320)return!1;Jf.lastIndex=s;var o=Jf.exec(this.input);if(o&&Wf.test(this.input.slice(s,s+o[0].length)))return!1}if(t){var a,u=n+2;if(!("of"!==this.input.slice(n,u)||u!==this.input.length&&(Vf(a=this.input.charCodeAt(u))||a>55295&&a<56320)))return!1}var l=this.input.charCodeAt(n);return Rf(l,!0)||92===l},wm.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},wm.isUsing=function(e){return this.isUsingKeyword(!1,e)},wm.parseStatement=function(e,t,r){var n,i=this.type,s=this.startNode();switch(this.isLet(e)&&(i=qf._var,n="let"),i){case qf._break:case qf._continue:return this.parseBreakContinueStatement(s,i.keyword);case qf._debugger:return this.parseDebuggerStatement(s);case qf._do:return this.parseDoStatement(s);case qf._for:return this.parseForStatement(s);case qf._function:return e&&(this.strict||"if"!==e&&"label"!==e)&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(s,!1,!e);case qf._class:return e&&this.unexpected(),this.parseClass(s,!0);case qf._if:return this.parseIfStatement(s);case qf._return:return this.parseReturnStatement(s);case qf._switch:return this.parseSwitchStatement(s);case qf._throw:return this.parseThrowStatement(s);case qf._try:return this.parseTryStatement(s);case qf._const:case qf._var:return n=n||this.value,e&&"var"!==n&&this.unexpected(),this.parseVarStatement(s,n);case qf._while:return this.parseWhileStatement(s);case qf._with:return this.parseWithStatement(s);case qf.braceL:return this.parseBlock(!0,s);case qf.semi:return this.parseEmptyStatement(s);case qf._export:case qf._import:if(this.options.ecmaVersion>10&&i===qf._import){Jf.lastIndex=this.pos;var o=Jf.exec(this.input),a=this.pos+o[0].length,u=this.input.charCodeAt(a);if(40===u||46===u)return this.parseExpressionStatement(s,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||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===qf._import?this.parseImport(s):this.parseExport(s,r);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(s,!0,!e);var l=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(l)return t&&"script"===this.options.sourceType&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),"await using"===l&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(s,!1,l),this.semicolon(),this.finishNode(s,"VariableDeclaration");var h=this.value,c=this.parseExpression();return i===qf.name&&"Identifier"===c.type&&this.eat(qf.colon)?this.parseLabeledStatement(s,h,c,e):this.parseExpressionStatement(s,c)}},wm.parseBreakContinueStatement=function(e,t){var r="break"===t;this.next(),this.eat(qf.semi)||this.insertSemicolon()?e.label=null:this.type!==qf.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var n=0;n<this.labels.length;++n){var i=this.labels[n];if(null==e.label||i.name===e.label.name){if(null!=i.kind&&(r||"loop"===i.kind))break;if(e.label&&r)break}}return n===this.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,r?"BreakStatement":"ContinueStatement")},wm.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")},wm.parseDoStatement=function(e){return this.next(),this.labels.push(Cm),e.body=this.parseStatement("do"),this.labels.pop(),this.expect(qf._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(qf.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")},wm.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(Cm),this.enterScope(0),this.expect(qf.parenL),this.type===qf.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var r=this.isLet();if(this.type===qf._var||this.type===qf._const||r){var n=this.startNode(),i=r?"let":this.value;return this.next(),this.parseVar(n,!0,i),this.finishNode(n,"VariableDeclaration"),this.parseForAfterInit(e,n,t)}var s=this.isContextual("let"),o=!1,a=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(a){var u=this.startNode();return this.next(),"await using"===a&&this.next(),this.parseVar(u,!0,a),this.finishNode(u,"VariableDeclaration"),this.parseForAfterInit(e,u,t)}var l=this.containsEsc,h=new _m,c=this.start,d=t>-1?this.parseExprSubscripts(h,"await"):this.parseExpression(!0,h);return this.type===qf._in||(o=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===qf._in&&this.unexpected(t),e.await=!0):o&&this.options.ecmaVersion>=8&&(d.start!==c||l||"Identifier"!==d.type||"async"!==d.name?this.options.ecmaVersion>=9&&(e.await=!1):this.unexpected()),s&&o&&this.raise(d.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(d,!1,h),this.checkLValPattern(d),this.parseForIn(e,d)):(this.checkExpressionErrors(h,!0),t>-1&&this.unexpected(t),this.parseFor(e,d))},wm.parseForAfterInit=function(e,t,r){return(this.type===qf._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&1===t.declarations.length?(this.options.ecmaVersion>=9&&(this.type===qf._in?r>-1&&this.unexpected(r):e.await=r>-1),this.parseForIn(e,t)):(r>-1&&this.unexpected(r),this.parseFor(e,t))},wm.parseFunctionStatement=function(e,t,r){return this.next(),this.parseFunction(e,Am|(r?0:Dm),!1,t)},wm.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement("if"),e.alternate=this.eat(qf._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")},wm.parseReturnStatement=function(e){return this.inFunction||this.options.allowReturnOutsideFunction||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(qf.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")},wm.parseSwitchStatement=function(e){var t;this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(qf.braceL),this.labels.push(Em),this.enterScope(0);for(var r=!1;this.type!==qf.braceR;)if(this.type===qf._case||this.type===qf._default){var n=this.type===qf._case;t&&this.finishNode(t,"SwitchCase"),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),n?t.test=this.parseExpression():(r&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),r=!0,t.test=null),this.expect(qf.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")},wm.parseThrowStatement=function(e){return this.next(),Wf.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var Sm=[];wm.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t="Identifier"===e.type;return this.enterScope(t?32:0),this.checkLValPattern(e,t?4:2),this.expect(qf.parenR),e},wm.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===qf._catch){var t=this.startNode();this.next(),this.eat(qf.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,"CatchClause")}return e.finalizer=this.eat(qf._finally)?this.parseBlock():null,e.handler||e.finalizer||this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")},wm.parseVarStatement=function(e,t,r){return this.next(),this.parseVar(e,!1,t,r),this.semicolon(),this.finishNode(e,"VariableDeclaration")},wm.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(Cm),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")},wm.parseWithStatement=function(e){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement("with"),this.finishNode(e,"WithStatement")},wm.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")},wm.parseLabeledStatement=function(e,t,r,n){for(var i=0,s=this.labels;i<s.length;i+=1){s[i].name===t&&this.raise(r.start,"Label '"+t+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===qf._switch?"switch":null,a=this.labels.length-1;a>=0;a--){var u=this.labels[a];if(u.statementStart!==e.start)break;u.statementStart=this.start,u.kind=o}return this.labels.push({name:t,kind:o,statementStart:this.start}),e.body=this.parseStatement(n?-1===n.indexOf("label")?n+"label":n:"label"),this.labels.pop(),e.label=r,this.finishNode(e,"LabeledStatement")},wm.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")},wm.parseBlock=function(e,t,r){for(void 0===e&&(e=!0),void 0===t&&(t=this.startNode()),t.body=[],this.expect(qf.braceL),e&&this.enterScope(0);this.type!==qf.braceR;){var n=this.parseStatement(null);t.body.push(n)}return r&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,"BlockStatement")},wm.parseFor=function(e,t){return e.init=t,this.expect(qf.semi),e.test=this.type===qf.semi?null:this.parseExpression(),this.expect(qf.semi),e.update=this.type===qf.parenR?null:this.parseExpression(),this.expect(qf.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")},wm.parseForIn=function(e,t){var r=this.type===qf._in;return this.next(),"VariableDeclaration"===t.type&&null!=t.declarations[0].init&&(!r||this.options.ecmaVersion<8||this.strict||"var"!==t.kind||"Identifier"!==t.declarations[0].id.type)&&this.raise(t.start,(r?"for-in":"for-of")+" loop variable declaration may not have an initializer"),e.left=t,e.right=r?this.parseExpression():this.parseMaybeAssign(),this.expect(qf.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,r?"ForInStatement":"ForOfStatement")},wm.parseVar=function(e,t,r,n){for(e.declarations=[],e.kind=r;;){var i=this.startNode();if(this.parseVarId(i,r),this.eat(qf.eq)?i.init=this.parseMaybeAssign(t):n||"const"!==r||this.type===qf._in||this.options.ecmaVersion>=6&&this.isContextual("of")?n||"using"!==r&&"await using"!==r||!(this.options.ecmaVersion>=17)||this.type===qf._in||this.isContextual("of")?n||"Identifier"===i.id.type||t&&(this.type===qf._in||this.isContextual("of"))?i.init=null:this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):this.raise(this.lastTokEnd,"Missing initializer in "+r+" declaration"):this.unexpected(),e.declarations.push(this.finishNode(i,"VariableDeclarator")),!this.eat(qf.comma))break}return e},wm.parseVarId=function(e,t){e.id="using"===t||"await using"===t?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,"var"===t?1:2,!1)};var Am=1,Dm=2;function Tm(e,t){var r=t.key.name,n=e[r],i="true";return"MethodDefinition"!==t.type||"get"!==t.kind&&"set"!==t.kind||(i=(t.static?"s":"i")+t.kind),"iget"===n&&"iset"===i||"iset"===n&&"iget"===i||"sget"===n&&"sset"===i||"sset"===n&&"sget"===i?(e[r]="true",!1):!!n||(e[r]=i,!1)}function Fm(e,t){var r=e.computed,n=e.key;return!r&&("Identifier"===n.type&&n.name===t||"Literal"===n.type&&n.value===t)}wm.parseFunction=function(e,t,r,n,i){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!n)&&(this.type===qf.star&&t&Dm&&this.unexpected(),e.generator=this.eat(qf.star)),this.options.ecmaVersion>=8&&(e.async=!!n),t&Am&&(e.id=4&t&&this.type!==qf.name?null:this.parseIdent(),!e.id||t&Dm||this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?1:2:3));var s=this.yieldPos,o=this.awaitPos,a=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(gm(e.async,e.generator)),t&Am||(e.id=this.type===qf.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,r,!1,i),this.yieldPos=s,this.awaitPos=o,this.awaitIdentPos=a,this.finishNode(e,t&Am?"FunctionDeclaration":"FunctionExpression")},wm.parseFunctionParams=function(e){this.expect(qf.parenL),e.params=this.parseBindingList(qf.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},wm.parseClass=function(e,t){this.next();var r=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var n=this.enterClassBody(),i=this.startNode(),s=!1;for(i.body=[],this.expect(qf.braceL);this.type!==qf.braceR;){var o=this.parseClassElement(null!==e.superClass);o&&(i.body.push(o),"MethodDefinition"===o.type&&"constructor"===o.kind?(s&&this.raiseRecoverable(o.start,"Duplicate constructor in the same class"),s=!0):o.key&&"PrivateIdentifier"===o.key.type&&Tm(n,o)&&this.raiseRecoverable(o.key.start,"Identifier '#"+o.key.name+"' has already been declared"))}return this.strict=r,this.next(),e.body=this.finishNode(i,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")},wm.parseClassElement=function(e){if(this.eat(qf.semi))return null;var t=this.options.ecmaVersion,r=this.startNode(),n="",i=!1,s=!1,o="method",a=!1;if(this.eatContextual("static")){if(t>=13&&this.eat(qf.braceL))return this.parseClassStaticBlock(r),r;this.isClassElementNameStart()||this.type===qf.star?a=!0:n="static"}if(r.static=a,!n&&t>=8&&this.eatContextual("async")&&(!this.isClassElementNameStart()&&this.type!==qf.star||this.canInsertSemicolon()?n="async":s=!0),!n&&(t>=9||!s)&&this.eat(qf.star)&&(i=!0),!n&&!s&&!i){var u=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?o=u:n=u)}if(n?(r.computed=!1,r.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),r.key.name=n,this.finishNode(r.key,"Identifier")):this.parseClassElementName(r),t<13||this.type===qf.parenL||"method"!==o||i||s){var l=!r.static&&Fm(r,"constructor"),h=l&&e;l&&"method"!==o&&this.raise(r.key.start,"Constructor can't have get/set modifier"),r.kind=l?"constructor":o,this.parseClassMethod(r,i,s,h)}else this.parseClassField(r);return r},wm.isClassElementNameStart=function(){return this.type===qf.name||this.type===qf.privateId||this.type===qf.num||this.type===qf.string||this.type===qf.bracketL||this.type.keyword},wm.parseClassElementName=function(e){this.type===qf.privateId?("constructor"===this.value&&this.raise(this.start,"Classes can't have an element named '#constructor'"),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)},wm.parseClassMethod=function(e,t,r,n){var i=e.key;"constructor"===e.kind?(t&&this.raise(i.start,"Constructor can't be a generator"),r&&this.raise(i.start,"Constructor can't be an async method")):e.static&&Fm(e,"prototype")&&this.raise(i.start,"Classes may not have a static property named prototype");var s=e.value=this.parseMethod(t,r,n);return"get"===e.kind&&0!==s.params.length&&this.raiseRecoverable(s.start,"getter should have no params"),"set"===e.kind&&1!==s.params.length&&this.raiseRecoverable(s.start,"setter should have exactly one param"),"set"===e.kind&&"RestElement"===s.params[0].type&&this.raiseRecoverable(s.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")},wm.parseClassField=function(e){return Fm(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&Fm(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(qf.eq)?(this.enterScope(576),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")},wm.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(320);this.type!==qf.braceR;){var r=this.parseStatement(null);e.body.push(r)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")},wm.parseClassId=function(e,t){this.type===qf.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,2,!1)):(!0===t&&this.unexpected(),e.id=null)},wm.parseClassSuper=function(e){e.superClass=this.eat(qf._extends)?this.parseExprSubscripts(null,!1):null},wm.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},wm.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,r=e.used;if(this.options.checkPrivateFields)for(var n=this.privateNameStack.length,i=0===n?null:this.privateNameStack[n-1],s=0;s<r.length;++s){var o=r[s];rm(t,o.name)||(i?i.used.push(o):this.raiseRecoverable(o.start,"Private field '#"+o.name+"' must be declared in an enclosing class"))}},wm.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual("from"),this.type!==qf.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")},wm.parseExport=function(e,t){if(this.next(),this.eat(qf.star))return this.parseExportAllDeclaration(e,t);if(this.eat(qf._default))return this.checkExport(t,"default",this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),"VariableDeclaration"===e.declaration.type?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual("from"))this.type!==qf.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var r=0,n=e.specifiers;r<n.length;r+=1){var i=n[r];this.checkUnreserved(i.local),this.checkLocalExport(i.local),"Literal"===i.local.type&&this.raise(i.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,"ExportNamedDeclaration")},wm.parseExportDeclaration=function(e){return this.parseStatement(null)},wm.parseExportDefaultDeclaration=function(){var e;if(this.type===qf._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,4|Am,!1,e)}if(this.type===qf._class){var r=this.startNode();return this.parseClass(r,"nullableID")}var n=this.parseMaybeAssign();return this.semicolon(),n},wm.checkExport=function(e,t,r){e&&("string"!=typeof t&&(t="Identifier"===t.type?t.name:t.value),rm(e,t)&&this.raiseRecoverable(r,"Duplicate export '"+t+"'"),e[t]=!0)},wm.checkPatternExport=function(e,t){var r=t.type;if("Identifier"===r)this.checkExport(e,t,t.start);else if("ObjectPattern"===r)for(var n=0,i=t.properties;n<i.length;n+=1){var s=i[n];this.checkPatternExport(e,s)}else if("ArrayPattern"===r)for(var o=0,a=t.elements;o<a.length;o+=1){var u=a[o];u&&this.checkPatternExport(e,u)}else"Property"===r?this.checkPatternExport(e,t.value):"AssignmentPattern"===r?this.checkPatternExport(e,t.left):"RestElement"===r&&this.checkPatternExport(e,t.argument)},wm.checkVariableExport=function(e,t){if(e)for(var r=0,n=t;r<n.length;r+=1){var i=n[r];this.checkPatternExport(e,i.id)}},wm.shouldParseExportStatement=function(){return"var"===this.type.keyword||"const"===this.type.keyword||"class"===this.type.keyword||"function"===this.type.keyword||this.isLet()||this.isAsyncFunction()},wm.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual("as")?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,"ExportSpecifier")},wm.parseExportSpecifiers=function(e){var t=[],r=!0;for(this.expect(qf.braceL);!this.eat(qf.braceR);){if(r)r=!1;else if(this.expect(qf.comma),this.afterTrailingComma(qf.braceR))break;t.push(this.parseExportSpecifier(e))}return t},wm.parseImport=function(e){return this.next(),this.type===qf.string?(e.specifiers=Sm,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===qf.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")},wm.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual("as")?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,2),this.finishNode(e,"ImportSpecifier")},wm.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,2),this.finishNode(e,"ImportDefaultSpecifier")},wm.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual("as"),e.local=this.parseIdent(),this.checkLValSimple(e.local,2),this.finishNode(e,"ImportNamespaceSpecifier")},wm.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===qf.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(qf.comma)))return e;if(this.type===qf.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(qf.braceL);!this.eat(qf.braceR);){if(t)t=!1;else if(this.expect(qf.comma),this.afterTrailingComma(qf.braceR))break;e.push(this.parseImportSpecifier())}return e},wm.parseWithClause=function(){var e=[];if(!this.eat(qf._with))return e;this.expect(qf.braceL);for(var t={},r=!0;!this.eat(qf.braceR);){if(r)r=!1;else if(this.expect(qf.comma),this.afterTrailingComma(qf.braceR))break;var n=this.parseImportAttribute(),i="Identifier"===n.key.type?n.key.name:n.key.value;rm(t,i)&&this.raiseRecoverable(n.key.start,"Duplicate attribute key '"+i+"'"),t[i]=!0,e.push(n)}return e},wm.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===qf.string?this.parseExprAtom():this.parseIdent("never"!==this.options.allowReserved),this.expect(qf.colon),this.type!==qf.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")},wm.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===qf.string){var e=this.parseLiteral(this.value);return am.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)},wm.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)},wm.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&"ExpressionStatement"===e.type&&"Literal"===e.expression.type&&"string"==typeof e.expression.value&&('"'===this.input[e.start]||"'"===this.input[e.start])};var Im=ym.prototype;Im.toAssignable=function(e,t,r){if(this.options.ecmaVersion>=6&&e)switch(e.type){case"Identifier":this.inAsync&&"await"===e.name&&this.raise(e.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",r&&this.checkPatternErrors(r,!0);for(var n=0,i=e.properties;n<i.length;n+=1){var s=i[n];this.toAssignable(s,t),"RestElement"!==s.type||"ArrayPattern"!==s.argument.type&&"ObjectPattern"!==s.argument.type||this.raise(s.argument.start,"Unexpected token")}break;case"Property":"init"!==e.kind&&this.raise(e.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(e.value,t);break;case"ArrayExpression":e.type="ArrayPattern",r&&this.checkPatternErrors(r,!0),this.toAssignableList(e.elements,t);break;case"SpreadElement":e.type="RestElement",this.toAssignable(e.argument,t),"AssignmentPattern"===e.argument.type&&this.raise(e.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":"="!==e.operator&&this.raise(e.left.end,"Only '=' operator can be used for specifying default value."),e.type="AssignmentPattern",delete e.operator,this.toAssignable(e.left,t);break;case"ParenthesizedExpression":this.toAssignable(e.expression,t,r);break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!t)break;default:this.raise(e.start,"Assigning to rvalue")}else r&&this.checkPatternErrors(r,!0);return e},Im.toAssignableList=function(e,t){for(var r=e.length,n=0;n<r;n++){var i=e[n];i&&this.toAssignable(i,t)}if(r){var s=e[r-1];6===this.options.ecmaVersion&&t&&s&&"RestElement"===s.type&&"Identifier"!==s.argument.type&&this.unexpected(s.argument.start)}return e},Im.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")},Im.parseRestBinding=function(){var e=this.startNode();return this.next(),6===this.options.ecmaVersion&&this.type!==qf.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")},Im.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case qf.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(qf.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case qf.braceL:return this.parseObj(!0)}return this.parseIdent()},Im.parseBindingList=function(e,t,r,n){for(var i=[],s=!0;!this.eat(e);)if(s?s=!1:this.expect(qf.comma),t&&this.type===qf.comma)i.push(null);else{if(r&&this.afterTrailingComma(e))break;if(this.type===qf.ellipsis){var o=this.parseRestBinding();this.parseBindingListItem(o),i.push(o),this.type===qf.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}i.push(this.parseAssignableListItem(n))}return i},Im.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},Im.parseBindingListItem=function(e){return e},Im.parseMaybeDefault=function(e,t,r){if(r=r||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(qf.eq))return r;var n=this.startNodeAt(e,t);return n.left=r,n.right=this.parseMaybeAssign(),this.finishNode(n,"AssignmentPattern")},Im.checkLValSimple=function(e,t,r){void 0===t&&(t=0);var n=0!==t;switch(e.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(n?"Binding ":"Assigning to ")+e.name+" in strict mode"),n&&(2===t&&"let"===e.name&&this.raiseRecoverable(e.start,"let is disallowed as a lexically bound name"),r&&(rm(r,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),r[e.name]=!0),5!==t&&this.declareName(e.name,t,e.start));break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":n&&this.raiseRecoverable(e.start,"Binding member expression");break;case"ParenthesizedExpression":return n&&this.raiseRecoverable(e.start,"Binding parenthesized expression"),this.checkLValSimple(e.expression,t,r);default:this.raise(e.start,(n?"Binding":"Assigning to")+" rvalue")}},Im.checkLValPattern=function(e,t,r){switch(void 0===t&&(t=0),e.type){case"ObjectPattern":for(var n=0,i=e.properties;n<i.length;n+=1){var s=i[n];this.checkLValInnerPattern(s,t,r)}break;case"ArrayPattern":for(var o=0,a=e.elements;o<a.length;o+=1){var u=a[o];u&&this.checkLValInnerPattern(u,t,r)}break;default:this.checkLValSimple(e,t,r)}},Im.checkLValInnerPattern=function(e,t,r){switch(void 0===t&&(t=0),e.type){case"Property":this.checkLValInnerPattern(e.value,t,r);break;case"AssignmentPattern":this.checkLValPattern(e.left,t,r);break;case"RestElement":this.checkLValPattern(e.argument,t,r);break;default:this.checkLValPattern(e,t,r)}};var km=function(e,t,r,n,i){this.token=e,this.isExpr=!!t,this.preserveSpace=!!r,this.override=n,this.generator=!!i},Nm={b_stat:new km("{",!1),b_expr:new km("{",!0),b_tmpl:new km("${",!1),p_stat:new km("(",!1),p_expr:new km("(",!0),q_tmpl:new km("`",!0,!0,(function(e){return e.tryReadTemplateToken()})),f_stat:new km("function",!1),f_expr:new km("function",!0),f_expr_gen:new km("function",!0,!1,null,!0),f_gen:new km("function",!1,!1,null,!0)},Mm=ym.prototype;Mm.initialContext=function(){return[Nm.b_stat]},Mm.curContext=function(){return this.context[this.context.length-1]},Mm.braceIsBlock=function(e){var t=this.curContext();return t===Nm.f_expr||t===Nm.f_stat||(e!==qf.colon||t!==Nm.b_stat&&t!==Nm.b_expr?e===qf._return||e===qf.name&&this.exprAllowed?Wf.test(this.input.slice(this.lastTokEnd,this.start)):e===qf._else||e===qf.semi||e===qf.eof||e===qf.parenR||e===qf.arrow||(e===qf.braceL?t===Nm.b_stat:e!==qf._var&&e!==qf._const&&e!==qf.name&&!this.exprAllowed):!t.isExpr)},Mm.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if("function"===t.token)return t.generator}return!1},Mm.updateContext=function(e){var t,r=this.type;r.keyword&&e===qf.dot?this.exprAllowed=!1:(t=r.updateContext)?t.call(this,e):this.exprAllowed=r.beforeExpr},Mm.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},qf.parenR.updateContext=qf.braceR.updateContext=function(){if(1!==this.context.length){var e=this.context.pop();e===Nm.b_stat&&"function"===this.curContext().token&&(e=this.context.pop()),this.exprAllowed=!e.isExpr}else this.exprAllowed=!0},qf.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?Nm.b_stat:Nm.b_expr),this.exprAllowed=!0},qf.dollarBraceL.updateContext=function(){this.context.push(Nm.b_tmpl),this.exprAllowed=!0},qf.parenL.updateContext=function(e){var t=e===qf._if||e===qf._for||e===qf._with||e===qf._while;this.context.push(t?Nm.p_stat:Nm.p_expr),this.exprAllowed=!0},qf.incDec.updateContext=function(){},qf._function.updateContext=qf._class.updateContext=function(e){!e.beforeExpr||e===qf._else||e===qf.semi&&this.curContext()!==Nm.p_stat||e===qf._return&&Wf.test(this.input.slice(this.lastTokEnd,this.start))||(e===qf.colon||e===qf.braceL)&&this.curContext()===Nm.b_stat?this.context.push(Nm.f_stat):this.context.push(Nm.f_expr),this.exprAllowed=!1},qf.colon.updateContext=function(){"function"===this.curContext().token&&this.context.pop(),this.exprAllowed=!0},qf.backQuote.updateContext=function(){this.curContext()===Nm.q_tmpl?this.context.pop():this.context.push(Nm.q_tmpl),this.exprAllowed=!1},qf.star.updateContext=function(e){if(e===qf._function){var t=this.context.length-1;this.context[t]===Nm.f_expr?this.context[t]=Nm.f_expr_gen:this.context[t]=Nm.f_gen}this.exprAllowed=!0},qf.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==qf.dot&&("of"===this.value&&!this.exprAllowed||"yield"===this.value&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var Om=ym.prototype;function Bm(e){return"Identifier"===e.type||"ParenthesizedExpression"===e.type&&Bm(e.expression)}function Lm(e){return"MemberExpression"===e.type&&"PrivateIdentifier"===e.property.type||"ChainExpression"===e.type&&Lm(e.expression)||"ParenthesizedExpression"===e.type&&Lm(e.expression)}Om.checkPropClash=function(e,t,r){if(!(this.options.ecmaVersion>=9&&"SpreadElement"===e.type||this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var n,i=e.key;switch(i.type){case"Identifier":n=i.name;break;case"Literal":n=String(i.value);break;default:return}var s=e.kind;if(this.options.ecmaVersion>=6)"__proto__"===n&&"init"===s&&(t.proto&&(r?r.doubleProto<0&&(r.doubleProto=i.start):this.raiseRecoverable(i.start,"Redefinition of __proto__ property")),t.proto=!0);else{var o=t[n="$"+n];if(o)("init"===s?this.strict&&o.init||o.get||o.set:o.init||o[s])&&this.raiseRecoverable(i.start,"Redefinition of property");else o=t[n]={init:!1,get:!1,set:!1};o[s]=!0}}},Om.parseExpression=function(e,t){var r=this.start,n=this.startLoc,i=this.parseMaybeAssign(e,t);if(this.type===qf.comma){var s=this.startNodeAt(r,n);for(s.expressions=[i];this.eat(qf.comma);)s.expressions.push(this.parseMaybeAssign(e,t));return this.finishNode(s,"SequenceExpression")}return i},Om.parseMaybeAssign=function(e,t,r){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var n=!1,i=-1,s=-1,o=-1;t?(i=t.parenthesizedAssign,s=t.trailingComma,o=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new _m,n=!0);var a=this.start,u=this.startLoc;this.type!==qf.parenL&&this.type!==qf.name||(this.potentialArrowAt=this.start,this.potentialArrowInForAwait="await"===e);var l=this.parseMaybeConditional(e,t);if(r&&(l=r.call(this,l,a,u)),this.type.isAssign){var h=this.startNodeAt(a,u);return h.operator=this.value,this.type===qf.eq&&(l=this.toAssignable(l,!1,t)),n||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=l.start&&(t.shorthandAssign=-1),this.type===qf.eq?this.checkLValPattern(l):this.checkLValSimple(l),h.left=l,this.next(),h.right=this.parseMaybeAssign(e),o>-1&&(t.doubleProto=o),this.finishNode(h,"AssignmentExpression")}return n&&this.checkExpressionErrors(t,!0),i>-1&&(t.parenthesizedAssign=i),s>-1&&(t.trailingComma=s),l},Om.parseMaybeConditional=function(e,t){var r=this.start,n=this.startLoc,i=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return i;if(this.eat(qf.question)){var s=this.startNodeAt(r,n);return s.test=i,s.consequent=this.parseMaybeAssign(),this.expect(qf.colon),s.alternate=this.parseMaybeAssign(e),this.finishNode(s,"ConditionalExpression")}return i},Om.parseExprOps=function(e,t){var r=this.start,n=this.startLoc,i=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||i.start===r&&"ArrowFunctionExpression"===i.type?i:this.parseExprOp(i,r,n,-1,e)},Om.parseExprOp=function(e,t,r,n,i){var s=this.type.binop;if(null!=s&&(!i||this.type!==qf._in)&&s>n){var o=this.type===qf.logicalOR||this.type===qf.logicalAND,a=this.type===qf.coalesce;a&&(s=qf.logicalAND.binop);var u=this.value;this.next();var l=this.start,h=this.startLoc,c=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,i),l,h,s,i),d=this.buildBinary(t,r,e,c,u,o||a);return(o&&this.type===qf.coalesce||a&&(this.type===qf.logicalOR||this.type===qf.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(d,t,r,n,i)}return e},Om.buildBinary=function(e,t,r,n,i,s){"PrivateIdentifier"===n.type&&this.raise(n.start,"Private identifier can only be left side of binary expression");var o=this.startNodeAt(e,t);return o.left=r,o.operator=i,o.right=n,this.finishNode(o,s?"LogicalExpression":"BinaryExpression")},Om.parseMaybeUnary=function(e,t,r,n){var i,s=this.start,o=this.startLoc;if(this.isContextual("await")&&this.canAwait)i=this.parseAwait(n),t=!0;else if(this.type.prefix){var a=this.startNode(),u=this.type===qf.incDec;a.operator=this.value,a.prefix=!0,this.next(),a.argument=this.parseMaybeUnary(null,!0,u,n),this.checkExpressionErrors(e,!0),u?this.checkLValSimple(a.argument):this.strict&&"delete"===a.operator&&Bm(a.argument)?this.raiseRecoverable(a.start,"Deleting local variable in strict mode"):"delete"===a.operator&&Lm(a.argument)?this.raiseRecoverable(a.start,"Private fields can not be deleted"):t=!0,i=this.finishNode(a,u?"UpdateExpression":"UnaryExpression")}else if(t||this.type!==qf.privateId){if(i=this.parseExprSubscripts(e,n),this.checkExpressionErrors(e))return i;for(;this.type.postfix&&!this.canInsertSemicolon();){var l=this.startNodeAt(s,o);l.operator=this.value,l.prefix=!1,l.argument=i,this.checkLValSimple(i),this.next(),i=this.finishNode(l,"UpdateExpression")}}else(n||0===this.privateNameStack.length)&&this.options.checkPrivateFields&&this.unexpected(),i=this.parsePrivateIdent(),this.type!==qf._in&&this.unexpected();return r||!this.eat(qf.starstar)?i:t?void this.unexpected(this.lastTokStart):this.buildBinary(s,o,i,this.parseMaybeUnary(null,!1,!1,n),"**",!1)},Om.parseExprSubscripts=function(e,t){var r=this.start,n=this.startLoc,i=this.parseExprAtom(e,t);if("ArrowFunctionExpression"===i.type&&")"!==this.input.slice(this.lastTokStart,this.lastTokEnd))return i;var s=this.parseSubscripts(i,r,n,!1,t);return e&&"MemberExpression"===s.type&&(e.parenthesizedAssign>=s.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=s.start&&(e.parenthesizedBind=-1),e.trailingComma>=s.start&&(e.trailingComma=-1)),s},Om.parseSubscripts=function(e,t,r,n,i){for(var s=this.options.ecmaVersion>=8&&"Identifier"===e.type&&"async"===e.name&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start==5&&this.potentialArrowAt===e.start,o=!1;;){var a=this.parseSubscript(e,t,r,n,s,o,i);if(a.optional&&(o=!0),a===e||"ArrowFunctionExpression"===a.type){if(o){var u=this.startNodeAt(t,r);u.expression=a,a=this.finishNode(u,"ChainExpression")}return a}e=a}},Om.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(qf.arrow)},Om.parseSubscriptAsyncArrow=function(e,t,r,n){return this.parseArrowExpression(this.startNodeAt(e,t),r,!0,n)},Om.parseSubscript=function(e,t,r,n,i,s,o){var a=this.options.ecmaVersion>=11,u=a&&this.eat(qf.questionDot);n&&u&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var l=this.eat(qf.bracketL);if(l||u&&this.type!==qf.parenL&&this.type!==qf.backQuote||this.eat(qf.dot)){var h=this.startNodeAt(t,r);h.object=e,l?(h.property=this.parseExpression(),this.expect(qf.bracketR)):this.type===qf.privateId&&"Super"!==e.type?h.property=this.parsePrivateIdent():h.property=this.parseIdent("never"!==this.options.allowReserved),h.computed=!!l,a&&(h.optional=u),e=this.finishNode(h,"MemberExpression")}else if(!n&&this.eat(qf.parenL)){var c=new _m,d=this.yieldPos,p=this.awaitPos,f=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var m=this.parseExprList(qf.parenR,this.options.ecmaVersion>=8,!1,c);if(i&&!u&&this.shouldParseAsyncArrow())return this.checkPatternErrors(c,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=d,this.awaitPos=p,this.awaitIdentPos=f,this.parseSubscriptAsyncArrow(t,r,m,o);this.checkExpressionErrors(c,!0),this.yieldPos=d||this.yieldPos,this.awaitPos=p||this.awaitPos,this.awaitIdentPos=f||this.awaitIdentPos;var g=this.startNodeAt(t,r);g.callee=e,g.arguments=m,a&&(g.optional=u),e=this.finishNode(g,"CallExpression")}else if(this.type===qf.backQuote){(u||s)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var y=this.startNodeAt(t,r);y.tag=e,y.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(y,"TaggedTemplateExpression")}return e},Om.parseExprAtom=function(e,t,r){this.type===qf.slash&&this.readRegexp();var n,i=this.potentialArrowAt===this.start;switch(this.type){case qf._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),n=this.startNode(),this.next(),this.type!==qf.parenL||this.allowDirectSuper||this.raise(n.start,"super() call outside constructor of a subclass"),this.type!==qf.dot&&this.type!==qf.bracketL&&this.type!==qf.parenL&&this.unexpected(),this.finishNode(n,"Super");case qf._this:return n=this.startNode(),this.next(),this.finishNode(n,"ThisExpression");case qf.name:var s=this.start,o=this.startLoc,a=this.containsEsc,u=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!a&&"async"===u.name&&!this.canInsertSemicolon()&&this.eat(qf._function))return this.overrideContext(Nm.f_expr),this.parseFunction(this.startNodeAt(s,o),0,!1,!0,t);if(i&&!this.canInsertSemicolon()){if(this.eat(qf.arrow))return this.parseArrowExpression(this.startNodeAt(s,o),[u],!1,t);if(this.options.ecmaVersion>=8&&"async"===u.name&&this.type===qf.name&&!a&&(!this.potentialArrowInForAwait||"of"!==this.value||this.containsEsc))return u=this.parseIdent(!1),!this.canInsertSemicolon()&&this.eat(qf.arrow)||this.unexpected(),this.parseArrowExpression(this.startNodeAt(s,o),[u],!0,t)}return u;case qf.regexp:var l=this.value;return(n=this.parseLiteral(l.value)).regex={pattern:l.pattern,flags:l.flags},n;case qf.num:case qf.string:return this.parseLiteral(this.value);case qf._null:case qf._true:case qf._false:return(n=this.startNode()).value=this.type===qf._null?null:this.type===qf._true,n.raw=this.type.keyword,this.next(),this.finishNode(n,"Literal");case qf.parenL:var h=this.start,c=this.parseParenAndDistinguishExpression(i,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(c)&&(e.parenthesizedAssign=h),e.parenthesizedBind<0&&(e.parenthesizedBind=h)),c;case qf.bracketL:return n=this.startNode(),this.next(),n.elements=this.parseExprList(qf.bracketR,!0,!0,e),this.finishNode(n,"ArrayExpression");case qf.braceL:return this.overrideContext(Nm.b_expr),this.parseObj(!1,e);case qf._function:return n=this.startNode(),this.next(),this.parseFunction(n,0);case qf._class:return this.parseClass(this.startNode(),!1);case qf._new:return this.parseNew();case qf.backQuote:return this.parseTemplate();case qf._import:return this.options.ecmaVersion>=11?this.parseExprImport(r):this.unexpected();default:return this.parseExprAtomDefault()}},Om.parseExprAtomDefault=function(){this.unexpected()},Om.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===qf.parenL&&!e)return this.parseDynamicImport(t);if(this.type===qf.dot){var r=this.startNodeAt(t.start,t.loc&&t.loc.start);return r.name="import",t.meta=this.finishNode(r,"Identifier"),this.parseImportMeta(t)}this.unexpected()},Om.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(qf.parenR)?e.options=null:(this.expect(qf.comma),this.afterTrailingComma(qf.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(qf.parenR)||(this.expect(qf.comma),this.afterTrailingComma(qf.parenR)||this.unexpected())));else if(!this.eat(qf.parenR)){var t=this.start;this.eat(qf.comma)&&this.eat(qf.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")},Om.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),"meta"!==e.property.name&&this.raiseRecoverable(e.property.start,"The only valid meta property for import is 'import.meta'"),t&&this.raiseRecoverable(e.start,"'import.meta' must not contain escaped characters"),"module"===this.options.sourceType||this.options.allowImportExportEverywhere||this.raiseRecoverable(e.start,"Cannot use 'import.meta' outside a module"),this.finishNode(e,"MetaProperty")},Om.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),110===t.raw.charCodeAt(t.raw.length-1)&&(t.bigint=null!=t.value?t.value.toString():t.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(t,"Literal")},Om.parseParenExpression=function(){this.expect(qf.parenL);var e=this.parseExpression();return this.expect(qf.parenR),e},Om.shouldParseArrow=function(e){return!this.canInsertSemicolon()},Om.parseParenAndDistinguishExpression=function(e,t){var r,n=this.start,i=this.startLoc,s=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var o,a=this.start,u=this.startLoc,l=[],h=!0,c=!1,d=new _m,p=this.yieldPos,f=this.awaitPos;for(this.yieldPos=0,this.awaitPos=0;this.type!==qf.parenR;){if(h?h=!1:this.expect(qf.comma),s&&this.afterTrailingComma(qf.parenR,!0)){c=!0;break}if(this.type===qf.ellipsis){o=this.start,l.push(this.parseParenItem(this.parseRestBinding())),this.type===qf.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}l.push(this.parseMaybeAssign(!1,d,this.parseParenItem))}var m=this.lastTokEnd,g=this.lastTokEndLoc;if(this.expect(qf.parenR),e&&this.shouldParseArrow(l)&&this.eat(qf.arrow))return this.checkPatternErrors(d,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=p,this.awaitPos=f,this.parseParenArrowList(n,i,l,t);l.length&&!c||this.unexpected(this.lastTokStart),o&&this.unexpected(o),this.checkExpressionErrors(d,!0),this.yieldPos=p||this.yieldPos,this.awaitPos=f||this.awaitPos,l.length>1?((r=this.startNodeAt(a,u)).expressions=l,this.finishNodeAt(r,"SequenceExpression",m,g)):r=l[0]}else r=this.parseParenExpression();if(this.options.preserveParens){var y=this.startNodeAt(n,i);return y.expression=r,this.finishNode(y,"ParenthesizedExpression")}return r},Om.parseParenItem=function(e){return e},Om.parseParenArrowList=function(e,t,r,n){return this.parseArrowExpression(this.startNodeAt(e,t),r,!1,n)};var Pm=[];Om.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===qf.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name="new",e.meta=this.finishNode(t,"Identifier"),this.next();var r=this.containsEsc;return e.property=this.parseIdent(!0),"target"!==e.property.name&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is 'new.target'"),r&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var n=this.start,i=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),n,i,!0,!1),this.eat(qf.parenL)?e.arguments=this.parseExprList(qf.parenR,this.options.ecmaVersion>=8,!1):e.arguments=Pm,this.finishNode(e,"NewExpression")},Om.parseTemplateElement=function(e){var t=e.isTagged,r=this.startNode();return this.type===qf.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),r.value={raw:this.value.replace(/\r\n?/g,"\n"),cooked:null}):r.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,"\n"),cooked:this.value},this.next(),r.tail=this.type===qf.backQuote,this.finishNode(r,"TemplateElement")},Om.parseTemplate=function(e){void 0===e&&(e={});var t=e.isTagged;void 0===t&&(t=!1);var r=this.startNode();this.next(),r.expressions=[];var n=this.parseTemplateElement({isTagged:t});for(r.quasis=[n];!n.tail;)this.type===qf.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(qf.dollarBraceL),r.expressions.push(this.parseExpression()),this.expect(qf.braceR),r.quasis.push(n=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(r,"TemplateLiteral")},Om.isAsyncProp=function(e){return!e.computed&&"Identifier"===e.key.type&&"async"===e.key.name&&(this.type===qf.name||this.type===qf.num||this.type===qf.string||this.type===qf.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===qf.star)&&!Wf.test(this.input.slice(this.lastTokEnd,this.start))},Om.parseObj=function(e,t){var r=this.startNode(),n=!0,i={};for(r.properties=[],this.next();!this.eat(qf.braceR);){if(n)n=!1;else if(this.expect(qf.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(qf.braceR))break;var s=this.parseProperty(e,t);e||this.checkPropClash(s,i,t),r.properties.push(s)}return this.finishNode(r,e?"ObjectPattern":"ObjectExpression")},Om.parseProperty=function(e,t){var r,n,i,s,o=this.startNode();if(this.options.ecmaVersion>=9&&this.eat(qf.ellipsis))return e?(o.argument=this.parseIdent(!1),this.type===qf.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(o,"RestElement")):(o.argument=this.parseMaybeAssign(!1,t),this.type===qf.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(o,"SpreadElement"));this.options.ecmaVersion>=6&&(o.method=!1,o.shorthand=!1,(e||t)&&(i=this.start,s=this.startLoc),e||(r=this.eat(qf.star)));var a=this.containsEsc;return this.parsePropertyName(o),!e&&!a&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(o)?(n=!0,r=this.options.ecmaVersion>=9&&this.eat(qf.star),this.parsePropertyName(o)):n=!1,this.parsePropertyValue(o,e,r,n,i,s,t,a),this.finishNode(o,"Property")},Om.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var r="get"===e.kind?0:1;if(e.value.params.length!==r){var n=e.value.start;"get"===e.kind?this.raiseRecoverable(n,"getter should have no params"):this.raiseRecoverable(n,"setter should have exactly one param")}else"set"===e.kind&&"RestElement"===e.value.params[0].type&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")},Om.parsePropertyValue=function(e,t,r,n,i,s,o,a){(r||n)&&this.type===qf.colon&&this.unexpected(),this.eat(qf.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,o),e.kind="init"):this.options.ecmaVersion>=6&&this.type===qf.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(r,n),e.kind="init"):t||a||!(this.options.ecmaVersion>=5)||e.computed||"Identifier"!==e.key.type||"get"!==e.key.name&&"set"!==e.key.name||this.type===qf.comma||this.type===qf.braceR||this.type===qf.eq?this.options.ecmaVersion>=6&&!e.computed&&"Identifier"===e.key.type?((r||n)&&this.unexpected(),this.checkUnreserved(e.key),"await"!==e.key.name||this.awaitIdentPos||(this.awaitIdentPos=i),t?e.value=this.parseMaybeDefault(i,s,this.copyNode(e.key)):this.type===qf.eq&&o?(o.shorthandAssign<0&&(o.shorthandAssign=this.start),e.value=this.parseMaybeDefault(i,s,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind="init",e.shorthand=!0):this.unexpected():((r||n)&&this.unexpected(),this.parseGetterSetter(e))},Om.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(qf.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(qf.bracketR),e.key;e.computed=!1}return e.key=this.type===qf.num||this.type===qf.string?this.parseExprAtom():this.parseIdent("never"!==this.options.allowReserved)},Om.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},Om.parseMethod=function(e,t,r){var n=this.startNode(),i=this.yieldPos,s=this.awaitPos,o=this.awaitIdentPos;return this.initFunction(n),this.options.ecmaVersion>=6&&(n.generator=e),this.options.ecmaVersion>=8&&(n.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(64|gm(t,n.generator)|(r?128:0)),this.expect(qf.parenL),n.params=this.parseBindingList(qf.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(n,!1,!0,!1),this.yieldPos=i,this.awaitPos=s,this.awaitIdentPos=o,this.finishNode(n,"FunctionExpression")},Om.parseArrowExpression=function(e,t,r,n){var i=this.yieldPos,s=this.awaitPos,o=this.awaitIdentPos;return this.enterScope(16|gm(r,!1)),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!r),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,n),this.yieldPos=i,this.awaitPos=s,this.awaitIdentPos=o,this.finishNode(e,"ArrowFunctionExpression")},Om.parseFunctionBody=function(e,t,r,n){var i=t&&this.type!==qf.braceL,s=this.strict,o=!1;if(i)e.body=this.parseMaybeAssign(n),e.expression=!0,this.checkParams(e,!1);else{var a=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);s&&!a||(o=this.strictDirective(this.end))&&a&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list");var u=this.labels;this.labels=[],o&&(this.strict=!0),this.checkParams(e,!s&&!o&&!t&&!r&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,5),e.body=this.parseBlock(!1,void 0,o&&!s),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=u}this.exitScope()},Om.isSimpleParamList=function(e){for(var t=0,r=e;t<r.length;t+=1){if("Identifier"!==r[t].type)return!1}return!0},Om.checkParams=function(e,t){for(var r=Object.create(null),n=0,i=e.params;n<i.length;n+=1){var s=i[n];this.checkLValInnerPattern(s,1,t?null:r)}},Om.parseExprList=function(e,t,r,n){for(var i=[],s=!0;!this.eat(e);){if(s)s=!1;else if(this.expect(qf.comma),t&&this.afterTrailingComma(e))break;var o=void 0;r&&this.type===qf.comma?o=null:this.type===qf.ellipsis?(o=this.parseSpread(n),n&&this.type===qf.comma&&n.trailingComma<0&&(n.trailingComma=this.start)):o=this.parseMaybeAssign(!1,n),i.push(o)}return i},Om.checkUnreserved=function(e){var t=e.start,r=e.end,n=e.name;(this.inGenerator&&"yield"===n&&this.raiseRecoverable(t,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&"await"===n&&this.raiseRecoverable(t,"Cannot use 'await' as identifier inside an async function"),this.currentThisScope().flags&mm||"arguments"!==n||this.raiseRecoverable(t,"Cannot use 'arguments' in class field initializer"),!this.inClassStaticBlock||"arguments"!==n&&"await"!==n||this.raise(t,"Cannot use "+n+" in class static initialization block"),this.keywords.test(n)&&this.raise(t,"Unexpected keyword '"+n+"'"),this.options.ecmaVersion<6&&-1!==this.input.slice(t,r).indexOf("\\"))||(this.strict?this.reservedWordsStrict:this.reservedWords).test(n)&&(this.inAsync||"await"!==n||this.raiseRecoverable(t,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(t,"The keyword '"+n+"' is reserved"))},Om.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,"Identifier"),e||(this.checkUnreserved(t),"await"!==t.name||this.awaitIdentPos||(this.awaitIdentPos=t.start)),t},Om.parseIdentNode=function(){var e=this.startNode();return this.type===qf.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,"class"!==e.name&&"function"!==e.name||this.lastTokEnd===this.lastTokStart+1&&46===this.input.charCodeAt(this.lastTokStart)||this.context.pop(),this.type=qf.name):this.unexpected(),e},Om.parsePrivateIdent=function(){var e=this.startNode();return this.type===qf.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,"PrivateIdentifier"),this.options.checkPrivateFields&&(0===this.privateNameStack.length?this.raise(e.start,"Private field '#"+e.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e},Om.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===qf.semi||this.canInsertSemicolon()||this.type!==qf.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(qf.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")},Om.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,"AwaitExpression")};var Rm=ym.prototype;Rm.raise=function(e,t){var r=hm(this.input,e);t+=" ("+r.line+":"+r.column+")",this.sourceFile&&(t+=" in "+this.sourceFile);var n=new SyntaxError(t);throw n.pos=e,n.loc=r,n.raisedAt=this.pos,n},Rm.raiseRecoverable=Rm.raise,Rm.curPosition=function(){if(this.options.locations)return new um(this.curLine,this.pos-this.lineStart)};var Vm=ym.prototype,Um=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};Vm.enterScope=function(e){this.scopeStack.push(new Um(e))},Vm.exitScope=function(){this.scopeStack.pop()},Vm.treatFunctionsAsVarInScope=function(e){return 2&e.flags||!this.inModule&&1&e.flags},Vm.declareName=function(e,t,r){var n=!1;if(2===t){var i=this.currentScope();n=i.lexical.indexOf(e)>-1||i.functions.indexOf(e)>-1||i.var.indexOf(e)>-1,i.lexical.push(e),this.inModule&&1&i.flags&&delete this.undefinedExports[e]}else if(4===t){this.currentScope().lexical.push(e)}else if(3===t){var s=this.currentScope();n=this.treatFunctionsAsVar?s.lexical.indexOf(e)>-1:s.lexical.indexOf(e)>-1||s.var.indexOf(e)>-1,s.functions.push(e)}else for(var o=this.scopeStack.length-1;o>=0;--o){var a=this.scopeStack[o];if(a.lexical.indexOf(e)>-1&&!(32&a.flags&&a.lexical[0]===e)||!this.treatFunctionsAsVarInScope(a)&&a.functions.indexOf(e)>-1){n=!0;break}if(a.var.push(e),this.inModule&&1&a.flags&&delete this.undefinedExports[e],a.flags&mm)break}n&&this.raiseRecoverable(r,"Identifier '"+e+"' has already been declared")},Vm.checkLocalExport=function(e){-1===this.scopeStack[0].lexical.indexOf(e.name)&&-1===this.scopeStack[0].var.indexOf(e.name)&&(this.undefinedExports[e.name]=e)},Vm.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},Vm.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(771&t.flags)return t}},Vm.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(771&t.flags&&!(16&t.flags))return t}};var zm=function(e,t,r){this.type="",this.start=t,this.end=0,e.options.locations&&(this.loc=new lm(e,r)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[t,0])},jm=ym.prototype;function Gm(e,t,r,n){return e.type=t,e.end=r,this.options.locations&&(e.loc.end=n),this.options.ranges&&(e.range[1]=r),e}jm.startNode=function(){return new zm(this,this.start,this.startLoc)},jm.startNodeAt=function(e,t){return new zm(this,e,t)},jm.finishNode=function(e,t){return Gm.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},jm.finishNodeAt=function(e,t,r,n){return Gm.call(this,e,t,r,n)},jm.copyNode=function(e){var t=new zm(this,e.start,this.startLoc);for(var r in e)t[r]=e[r];return t};var $m="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",Hm=$m+" Extended_Pictographic",qm=Hm+" EBase EComp EMod EPres ExtPict",Wm={9:$m,10:Hm,11:Hm,12:qm,13:qm,14:qm},Xm={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"},Zm="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",Ym="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",Km=Ym+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",Jm=Km+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Qm=Jm+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",eg=Qm+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",tg={9:Ym,10:Km,11:Jm,12:Qm,13:eg,14:eg+" Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz"},rg={};function ng(e){var t=rg[e]={binary:sm(Wm[e]+" "+Zm),binaryOfStrings:sm(Xm[e]),nonBinary:{General_Category:sm(Zm),Script:sm(tg[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(var ig=0,sg=[9,10,11,12,13,14];ig<sg.length;ig+=1){ng(sg[ig])}var og=ym.prototype,ag=function(e,t){this.parent=e,this.base=t||this};ag.prototype.separatedFrom=function(e){for(var t=this;t;t=t.parent)for(var r=e;r;r=r.parent)if(t.base===r.base&&t!==r)return!0;return!1},ag.prototype.sibling=function(){return new ag(this.parent,this.base)};var ug=function(e){this.parser=e,this.validFlags="gim"+(e.options.ecmaVersion>=6?"uy":"")+(e.options.ecmaVersion>=9?"s":"")+(e.options.ecmaVersion>=13?"d":"")+(e.options.ecmaVersion>=15?"v":""),this.unicodeProperties=rg[e.options.ecmaVersion>=14?14:e.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};function lg(e){return 105===e||109===e||115===e}function hg(e){return 36===e||e>=40&&e<=43||46===e||63===e||e>=91&&e<=94||e>=123&&e<=125}function cg(e){return e>=65&&e<=90||e>=97&&e<=122}ug.prototype.reset=function(e,t,r){var n=-1!==r.indexOf("v"),i=-1!==r.indexOf("u");this.start=0|e,this.source=t+"",this.flags=r,n&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=i&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=i&&this.parser.options.ecmaVersion>=9)},ug.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)},ug.prototype.at=function(e,t){void 0===t&&(t=!1);var r=this.source,n=r.length;if(e>=n)return-1;var i=r.charCodeAt(e);if(!t&&!this.switchU||i<=55295||i>=57344||e+1>=n)return i;var s=r.charCodeAt(e+1);return s>=56320&&s<=57343?(i<<10)+s-56613888:i},ug.prototype.nextIndex=function(e,t){void 0===t&&(t=!1);var r=this.source,n=r.length;if(e>=n)return n;var i,s=r.charCodeAt(e);return!t&&!this.switchU||s<=55295||s>=57344||e+1>=n||(i=r.charCodeAt(e+1))<56320||i>57343?e+1:e+2},ug.prototype.current=function(e){return void 0===e&&(e=!1),this.at(this.pos,e)},ug.prototype.lookahead=function(e){return void 0===e&&(e=!1),this.at(this.nextIndex(this.pos,e),e)},ug.prototype.advance=function(e){void 0===e&&(e=!1),this.pos=this.nextIndex(this.pos,e)},ug.prototype.eat=function(e,t){return void 0===t&&(t=!1),this.current(t)===e&&(this.advance(t),!0)},ug.prototype.eatChars=function(e,t){void 0===t&&(t=!1);for(var r=this.pos,n=0,i=e;n<i.length;n+=1){var s=i[n],o=this.at(r,t);if(-1===o||o!==s)return!1;r=this.nextIndex(r,t)}return this.pos=r,!0},og.validateRegExpFlags=function(e){for(var t=e.validFlags,r=e.flags,n=!1,i=!1,s=0;s<r.length;s++){var o=r.charAt(s);-1===t.indexOf(o)&&this.raise(e.start,"Invalid regular expression flag"),r.indexOf(o,s+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),"u"===o&&(n=!0),"v"===o&&(i=!0)}this.options.ecmaVersion>=15&&n&&i&&this.raise(e.start,"Invalid regular expression flag")},og.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&function(e){for(var t in e)return!0;return!1}(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))},og.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue="",e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise("Unmatched ')'"),(e.eat(93)||e.eat(125))&&e.raise("Lone quantifier brackets")),e.maxBackReference>e.numCapturingParens&&e.raise("Invalid escape");for(var t=0,r=e.backReferenceNames;t<r.length;t+=1){var n=r[t];e.groupNames[n]||e.raise("Invalid named capture referenced")}},og.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new ag(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise("Nothing to repeat"),e.eat(123)&&e.raise("Lone quantifier brackets")},og.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},og.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise("Invalid quantifier"),!0):!!(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))&&(this.regexp_eatQuantifier(e),!0)},og.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var r=!1;if(this.options.ecmaVersion>=9&&(r=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!r,!0}return e.pos=t,!1},og.regexp_eatQuantifier=function(e,t){return void 0===t&&(t=!1),!!this.regexp_eatQuantifierPrefix(e,t)&&(e.eat(63),!0)},og.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},og.regexp_eatBracedQuantifier=function(e,t){var r=e.pos;if(e.eat(123)){var n=0,i=-1;if(this.regexp_eatDecimalDigits(e)&&(n=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(i=e.lastIntValue),e.eat(125)))return-1!==i&&i<n&&!t&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!t&&e.raise("Incomplete quantifier"),e.pos=r}return!1},og.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)},og.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1},og.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var r=this.regexp_eatModifiers(e),n=e.eat(45);if(r||n){for(var i=0;i<r.length;i++){var s=r.charAt(i);r.indexOf(s,i+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(n){var o=this.regexp_eatModifiers(e);r||o||58!==e.current()||e.raise("Invalid regular expression modifiers");for(var a=0;a<o.length;a++){var u=o.charAt(a);(o.indexOf(u,a+1)>-1||r.indexOf(u)>-1)&&e.raise("Duplicate regular expression modifiers")}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise("Unterminated group")}}e.pos=t}return!1},og.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):63===e.current()&&e.raise("Invalid group"),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise("Unterminated group")}return!1},og.regexp_eatModifiers=function(e){for(var t="",r=0;-1!==(r=e.current())&&lg(r);)t+=om(r),e.advance();return t},og.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)},og.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1},og.regexp_eatSyntaxCharacter=function(e){var t=e.current();return!!hg(t)&&(e.lastIntValue=t,e.advance(),!0)},og.regexp_eatPatternCharacters=function(e){for(var t=e.pos,r=0;-1!==(r=e.current())&&!hg(r);)e.advance();return e.pos!==t},og.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return!(-1===t||36===t||t>=40&&t<=43||46===t||63===t||91===t||94===t||124===t)&&(e.advance(),!0)},og.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise("Invalid group");var t=this.options.ecmaVersion>=16,r=e.groupNames[e.lastStringValue];if(r)if(t)for(var n=0,i=r;n<i.length;n+=1){i[n].separatedFrom(e.branchID)||e.raise("Duplicate capture group name")}else e.raise("Duplicate capture group name");t?(r||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}},og.regexp_eatGroupName=function(e){if(e.lastStringValue="",e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise("Invalid capture group name")}return!1},og.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue="",this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=om(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=om(e.lastIntValue);return!0}return!1},og.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,r=this.options.ecmaVersion>=11,n=e.current(r);return e.advance(r),92===n&&this.regexp_eatRegExpUnicodeEscapeSequence(e,r)&&(n=e.lastIntValue),function(e){return Rf(e,!0)||36===e||95===e}(n)?(e.lastIntValue=n,!0):(e.pos=t,!1)},og.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,r=this.options.ecmaVersion>=11,n=e.current(r);return e.advance(r),92===n&&this.regexp_eatRegExpUnicodeEscapeSequence(e,r)&&(n=e.lastIntValue),function(e){return Vf(e,!0)||36===e||95===e||8204===e||8205===e}(n)?(e.lastIntValue=n,!0):(e.pos=t,!1)},og.regexp_eatAtomEscape=function(e){return!!(this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e))||(e.switchU&&(99===e.current()&&e.raise("Invalid unicode escape"),e.raise("Invalid escape")),!1)},og.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var r=e.lastIntValue;if(e.switchU)return r>e.maxBackReference&&(e.maxBackReference=r),!0;if(r<=e.numCapturingParens)return!0;e.pos=t}return!1},og.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise("Invalid named reference")}return!1},og.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)},og.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},og.regexp_eatZero=function(e){return 48===e.current()&&!fg(e.lookahead())&&(e.lastIntValue=0,e.advance(),!0)},og.regexp_eatControlEscape=function(e){var t=e.current();return 116===t?(e.lastIntValue=9,e.advance(),!0):110===t?(e.lastIntValue=10,e.advance(),!0):118===t?(e.lastIntValue=11,e.advance(),!0):102===t?(e.lastIntValue=12,e.advance(),!0):114===t&&(e.lastIntValue=13,e.advance(),!0)},og.regexp_eatControlLetter=function(e){var t=e.current();return!!cg(t)&&(e.lastIntValue=t%32,e.advance(),!0)},og.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){void 0===t&&(t=!1);var r,n=e.pos,i=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var s=e.lastIntValue;if(i&&s>=55296&&s<=56319){var o=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var a=e.lastIntValue;if(a>=56320&&a<=57343)return e.lastIntValue=1024*(s-55296)+(a-56320)+65536,!0}e.pos=o,e.lastIntValue=s}return!0}if(i&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&((r=e.lastIntValue)>=0&&r<=1114111))return!0;i&&e.raise("Invalid unicode escape"),e.pos=n}return!1},og.regexp_eatIdentityEscape=function(e){if(e.switchU)return!!this.regexp_eatSyntaxCharacter(e)||!!e.eat(47)&&(e.lastIntValue=47,!0);var t=e.current();return!(99===t||e.switchN&&107===t)&&(e.lastIntValue=t,e.advance(),!0)},og.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do{e.lastIntValue=10*e.lastIntValue+(t-48),e.advance()}while((t=e.current())>=48&&t<=57);return!0}return!1};function dg(e){return cg(e)||95===e}function pg(e){return dg(e)||fg(e)}function fg(e){return e>=48&&e<=57}function mg(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function gg(e){return e>=65&&e<=70?e-65+10:e>=97&&e<=102?e-97+10:e-48}function yg(e){return e>=48&&e<=55}og.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(function(e){return 100===e||68===e||115===e||83===e||119===e||87===e}(t))return e.lastIntValue=-1,e.advance(),1;var r=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((r=80===t)||112===t)){var n;if(e.lastIntValue=-1,e.advance(),e.eat(123)&&(n=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return r&&2===n&&e.raise("Invalid property name"),n;e.raise("Invalid property name")}return 0},og.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var r=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var n=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,r,n),1}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var i=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,i)}return 0},og.regexp_validateUnicodePropertyNameAndValue=function(e,t,r){rm(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(r)||e.raise("Invalid property value")},og.regexp_validateUnicodePropertyNameOrValue=function(e,t){return e.unicodeProperties.binary.test(t)?1:e.switchV&&e.unicodeProperties.binaryOfStrings.test(t)?2:void e.raise("Invalid property name")},og.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";dg(t=e.current());)e.lastStringValue+=om(t),e.advance();return""!==e.lastStringValue},og.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";pg(t=e.current());)e.lastStringValue+=om(t),e.advance();return""!==e.lastStringValue},og.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},og.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),r=this.regexp_classContents(e);return e.eat(93)||e.raise("Unterminated character class"),t&&2===r&&e.raise("Negated character class may contain strings"),!0}return!1},og.regexp_classContents=function(e){return 93===e.current()?1:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),1)},og.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var r=e.lastIntValue;!e.switchU||-1!==t&&-1!==r||e.raise("Invalid character class"),-1!==t&&-1!==r&&t>r&&e.raise("Range out of order in character class")}}},og.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var r=e.current();(99===r||yg(r))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var n=e.current();return 93!==n&&(e.lastIntValue=n,e.advance(),!0)},og.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)},og.regexp_classSetExpression=function(e){var t,r=1;if(this.regexp_eatClassSetRange(e));else if(t=this.regexp_eatClassSetOperand(e)){2===t&&(r=2);for(var n=e.pos;e.eatChars([38,38]);)38!==e.current()&&(t=this.regexp_eatClassSetOperand(e))?2!==t&&(r=1):e.raise("Invalid character in character class");if(n!==e.pos)return r;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise("Invalid character in character class");if(n!==e.pos)return r}else e.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(e)){if(!(t=this.regexp_eatClassSetOperand(e)))return r;2===t&&(r=2)}},og.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var r=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var n=e.lastIntValue;return-1!==r&&-1!==n&&r>n&&e.raise("Range out of order in character class"),!0}e.pos=t}return!1},og.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?1:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},og.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var r=e.eat(94),n=this.regexp_classContents(e);if(e.eat(93))return r&&2===n&&e.raise("Negated character class may contain strings"),n;e.pos=t}if(e.eat(92)){var i=this.regexp_eatCharacterClassEscape(e);if(i)return i;e.pos=t}return null},og.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var r=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return r}else e.raise("Invalid escape");e.pos=t}return null},og.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)2===this.regexp_classString(e)&&(t=2);return t},og.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return 1===t?1:2},og.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return!(!this.regexp_eatCharacterEscape(e)&&!this.regexp_eatClassSetReservedPunctuator(e))||(e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1));var r=e.current();return!(r<0||r===e.lookahead()&&function(e){return 33===e||e>=35&&e<=38||e>=42&&e<=44||46===e||e>=58&&e<=64||94===e||96===e||126===e}(r))&&(!function(e){return 40===e||41===e||45===e||47===e||e>=91&&e<=93||e>=123&&e<=125}(r)&&(e.advance(),e.lastIntValue=r,!0))},og.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return!!function(e){return 33===e||35===e||37===e||38===e||44===e||45===e||e>=58&&e<=62||64===e||96===e||126===e}(t)&&(e.lastIntValue=t,e.advance(),!0)},og.regexp_eatClassControlLetter=function(e){var t=e.current();return!(!fg(t)&&95!==t)&&(e.lastIntValue=t%32,e.advance(),!0)},og.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise("Invalid escape"),e.pos=t}return!1},og.regexp_eatDecimalDigits=function(e){var t=e.pos,r=0;for(e.lastIntValue=0;fg(r=e.current());)e.lastIntValue=10*e.lastIntValue+(r-48),e.advance();return e.pos!==t},og.regexp_eatHexDigits=function(e){var t=e.pos,r=0;for(e.lastIntValue=0;mg(r=e.current());)e.lastIntValue=16*e.lastIntValue+gg(r),e.advance();return e.pos!==t},og.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var r=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=64*t+8*r+e.lastIntValue:e.lastIntValue=8*t+r}else e.lastIntValue=t;return!0}return!1},og.regexp_eatOctalDigit=function(e){var t=e.current();return yg(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)},og.regexp_eatFixedHexDigits=function(e,t){var r=e.pos;e.lastIntValue=0;for(var n=0;n<t;++n){var i=e.current();if(!mg(i))return e.pos=r,!1;e.lastIntValue=16*e.lastIntValue+gg(i),e.advance()}return!0};var vg=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new lm(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},bg=ym.prototype;function xg(e){return"function"!=typeof BigInt?null:BigInt(e.replace(/_/g,""))}bg.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new vg(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},bg.getToken=function(){return this.next(),new vg(this)},"undefined"!=typeof Symbol&&(bg[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===qf.eof,value:t}}}}),bg.nextToken=function(){var e=this.curContext();return e&&e.preserveSpace||this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length?this.finishToken(qf.eof):e.override?e.override(this):void this.readToken(this.fullCharCodeAtPos())},bg.readToken=function(e){return Rf(e,this.options.ecmaVersion>=6)||92===e?this.readWord():this.getTokenFromCode(e)},bg.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=56320)return e;var t=this.input.charCodeAt(this.pos+1);return t<=56319||t>=57344?e:(e<<10)+t-56613888},bg.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,r=this.input.indexOf("*/",this.pos+=2);if(-1===r&&this.raise(this.pos-2,"Unterminated comment"),this.pos=r+2,this.options.locations)for(var n=void 0,i=t;(n=Yf(this.input,i,this.pos))>-1;)++this.curLine,i=this.lineStart=n;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,r),t,this.pos,e,this.curPosition())},bg.skipLineComment=function(e){for(var t=this.pos,r=this.options.onComment&&this.curPosition(),n=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!Zf(n);)n=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,r,this.curPosition())},bg.skipSpace=function(){e:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:10===this.input.charCodeAt(this.pos+1)&&++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 e}break;default:if(!(e>8&&e<14||e>=5760&&Kf.test(String.fromCharCode(e))))break e;++this.pos}}},bg.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var r=this.type;this.type=e,this.value=t,this.updateContext(r)},bg.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&46===e&&46===t?(this.pos+=3,this.finishToken(qf.ellipsis)):(++this.pos,this.finishToken(qf.dot))},bg.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):61===e?this.finishOp(qf.assign,2):this.finishOp(qf.slash,1)},bg.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),r=1,n=42===e?qf.star:qf.modulo;return this.options.ecmaVersion>=7&&42===e&&42===t&&(++r,n=qf.starstar,t=this.input.charCodeAt(this.pos+2)),61===t?this.finishOp(qf.assign,r+1):this.finishOp(n,r)},bg.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);if(t===e){if(this.options.ecmaVersion>=12)if(61===this.input.charCodeAt(this.pos+2))return this.finishOp(qf.assign,3);return this.finishOp(124===e?qf.logicalOR:qf.logicalAND,2)}return 61===t?this.finishOp(qf.assign,2):this.finishOp(124===e?qf.bitwiseOR:qf.bitwiseAND,1)},bg.readToken_caret=function(){return 61===this.input.charCodeAt(this.pos+1)?this.finishOp(qf.assign,2):this.finishOp(qf.bitwiseXOR,1)},bg.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?45!==t||this.inModule||62!==this.input.charCodeAt(this.pos+2)||0!==this.lastTokEnd&&!Wf.test(this.input.slice(this.lastTokEnd,this.pos))?this.finishOp(qf.incDec,2):(this.skipLineComment(3),this.skipSpace(),this.nextToken()):61===t?this.finishOp(qf.assign,2):this.finishOp(qf.plusMin,1)},bg.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),r=1;return t===e?(r=62===e&&62===this.input.charCodeAt(this.pos+2)?3:2,61===this.input.charCodeAt(this.pos+r)?this.finishOp(qf.assign,r+1):this.finishOp(qf.bitShift,r)):33!==t||60!==e||this.inModule||45!==this.input.charCodeAt(this.pos+2)||45!==this.input.charCodeAt(this.pos+3)?(61===t&&(r=2),this.finishOp(qf.relational,r)):(this.skipLineComment(4),this.skipSpace(),this.nextToken())},bg.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return 61===t?this.finishOp(qf.equality,61===this.input.charCodeAt(this.pos+2)?3:2):61===e&&62===t&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(qf.arrow)):this.finishOp(61===e?qf.eq:qf.prefix,1)},bg.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(46===t){var r=this.input.charCodeAt(this.pos+2);if(r<48||r>57)return this.finishOp(qf.questionDot,2)}if(63===t){if(e>=12)if(61===this.input.charCodeAt(this.pos+2))return this.finishOp(qf.assign,3);return this.finishOp(qf.coalesce,2)}}return this.finishOp(qf.question,1)},bg.readToken_numberSign=function(){var e=35;if(this.options.ecmaVersion>=13&&(++this.pos,Rf(e=this.fullCharCodeAtPos(),!0)||92===e))return this.finishToken(qf.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+om(e)+"'")},bg.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(qf.parenL);case 41:return++this.pos,this.finishToken(qf.parenR);case 59:return++this.pos,this.finishToken(qf.semi);case 44:return++this.pos,this.finishToken(qf.comma);case 91:return++this.pos,this.finishToken(qf.bracketL);case 93:return++this.pos,this.finishToken(qf.bracketR);case 123:return++this.pos,this.finishToken(qf.braceL);case 125:return++this.pos,this.finishToken(qf.braceR);case 58:return++this.pos,this.finishToken(qf.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(qf.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(120===t||88===t)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(111===t||79===t)return this.readRadixNumber(8);if(98===t||66===t)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(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(qf.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+om(e)+"'")},bg.finishOp=function(e,t){var r=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,r)},bg.readRegexp=function(){for(var e,t,r=this.pos;;){this.pos>=this.input.length&&this.raise(r,"Unterminated regular expression");var n=this.input.charAt(this.pos);if(Wf.test(n)&&this.raise(r,"Unterminated regular expression"),e)e=!1;else{if("["===n)t=!0;else if("]"===n&&t)t=!1;else if("/"===n&&!t)break;e="\\"===n}++this.pos}var i=this.input.slice(r,this.pos);++this.pos;var s=this.pos,o=this.readWord1();this.containsEsc&&this.unexpected(s);var a=this.regexpState||(this.regexpState=new ug(this));a.reset(r,i,o),this.validateRegExpFlags(a),this.validateRegExpPattern(a);var u=null;try{u=new RegExp(i,o)}catch(e){}return this.finishToken(qf.regexp,{pattern:i,flags:o,value:u})},bg.readInt=function(e,t,r){for(var n=this.options.ecmaVersion>=12&&void 0===t,i=r&&48===this.input.charCodeAt(this.pos),s=this.pos,o=0,a=0,u=0,l=null==t?1/0:t;u<l;++u,++this.pos){var h=this.input.charCodeAt(this.pos),c=void 0;if(n&&95===h)i&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),95===a&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),0===u&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),a=h;else{if((c=h>=97?h-97+10:h>=65?h-65+10:h>=48&&h<=57?h-48:1/0)>=e)break;a=h,o=o*e+c}}return n&&95===a&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===s||null!=t&&this.pos-s!==t?null:o},bg.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var r=this.readInt(e);return null==r&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&110===this.input.charCodeAt(this.pos)?(r=xg(this.input.slice(t,this.pos)),++this.pos):Rf(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(qf.num,r)},bg.readNumber=function(e){var t=this.pos;e||null!==this.readInt(10,void 0,!0)||this.raise(t,"Invalid number");var r=this.pos-t>=2&&48===this.input.charCodeAt(t);r&&this.strict&&this.raise(t,"Invalid number");var n=this.input.charCodeAt(this.pos);if(!r&&!e&&this.options.ecmaVersion>=11&&110===n){var i=xg(this.input.slice(t,this.pos));return++this.pos,Rf(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(qf.num,i)}r&&/[89]/.test(this.input.slice(t,this.pos))&&(r=!1),46!==n||r||(++this.pos,this.readInt(10),n=this.input.charCodeAt(this.pos)),69!==n&&101!==n||r||(43!==(n=this.input.charCodeAt(++this.pos))&&45!==n||++this.pos,null===this.readInt(10)&&this.raise(t,"Invalid number")),Rf(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var s,o=(s=this.input.slice(t,this.pos),r?parseInt(s,8):parseFloat(s.replace(/_/g,"")));return this.finishToken(qf.num,o)},bg.readCodePoint=function(){var e;if(123===this.input.charCodeAt(this.pos)){this.options.ecmaVersion<6&&this.unexpected();var t=++this.pos;e=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,e>1114111&&this.invalidStringToken(t,"Code point out of bounds")}else e=this.readHexChar(4);return e},bg.readString=function(e){for(var t="",r=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var n=this.input.charCodeAt(this.pos);if(n===e)break;92===n?(t+=this.input.slice(r,this.pos),t+=this.readEscapedChar(!1),r=this.pos):8232===n||8233===n?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(Zf(n)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(r,this.pos++),this.finishToken(qf.string,t)};var _g={};bg.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e!==_g)throw e;this.readInvalidTemplateToken()}this.inTemplateElement=!1},bg.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw _g;this.raise(e,t)},bg.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var r=this.input.charCodeAt(this.pos);if(96===r||36===r&&123===this.input.charCodeAt(this.pos+1))return this.pos!==this.start||this.type!==qf.template&&this.type!==qf.invalidTemplate?(e+=this.input.slice(t,this.pos),this.finishToken(qf.template,e)):36===r?(this.pos+=2,this.finishToken(qf.dollarBraceL)):(++this.pos,this.finishToken(qf.backQuote));if(92===r)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(Zf(r)){switch(e+=this.input.slice(t,this.pos),++this.pos,r){case 13:10===this.input.charCodeAt(this.pos)&&++this.pos;case 10:e+="\n";break;default:e+=String.fromCharCode(r)}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}},bg.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(qf.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":"\n"===this.input[this.pos+1]&&++this.pos;case"\n":case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1}this.raise(this.start,"Unterminated template")},bg.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return"\n";case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return om(this.readCodePoint());case 116:return"\t";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:10===this.input.charCodeAt(this.pos)&&++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"),e){var r=this.pos-1;this.invalidStringToken(r,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var n=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],i=parseInt(n,8);return i>255&&(n=n.slice(0,-1),i=parseInt(n,8)),this.pos+=n.length-1,t=this.input.charCodeAt(this.pos),"0"===n&&56!==t&&57!==t||!this.strict&&!e||this.invalidStringToken(this.pos-1-n.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(i)}return Zf(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},bg.readHexChar=function(e){var t=this.pos,r=this.readInt(16,e);return null===r&&this.invalidStringToken(t,"Bad character escape sequence"),r},bg.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,r=this.pos,n=this.options.ecmaVersion>=6;this.pos<this.input.length;){var i=this.fullCharCodeAtPos();if(Vf(i,n))this.pos+=i<=65535?1:2;else{if(92!==i)break;this.containsEsc=!0,e+=this.input.slice(r,this.pos);var s=this.pos;117!==this.input.charCodeAt(++this.pos)&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var o=this.readCodePoint();(t?Rf:Vf)(o,n)||this.invalidStringToken(s,"Invalid Unicode escape"),e+=om(o),r=this.pos}t=!1}return e+this.input.slice(r,this.pos)},bg.readWord=function(){var e=this.readWord1(),t=qf.name;return this.keywords.test(e)&&(t=$f[e]),this.finishToken(t,e)};function wg(e,t){return ym.parse(e,t)}function Cg(e,t,r,n,i){var s=[];r||(r=Dg),function e(n,i,o){var a=o||n.type,u=n!==s[s.length-1];u&&s.push(n),r[a](n,i,e),t[a]&&t[a](n,i||s,s),u&&s.pop()}(e,n,i)}function Eg(e,t,r,n,i){var s=r?function(e){var t=Object.create(Dg);for(var r in e)t[r]=e[r];return t}(r):n;!function e(t,r,n){s[n||t.type](t,r,e)}(e,t,i)}function Sg(e,t,r){r(e,t)}function Ag(e,t,r){}ym.acorn={Parser:ym,version:"8.15.0",defaultOptions:cm,Position:um,SourceLocation:lm,getLineInfo:hm,Node:zm,TokenType:Uf,tokTypes:qf,keywordTypes:$f,TokContext:km,tokContexts:Nm,isIdentifierChar:Vf,isIdentifierStart:Rf,Token:vg,isNewLine:Zf,lineBreak:Wf,lineBreakG:Xf,nonASCIIwhitespace:Kf};var Dg={};Dg.Program=Dg.BlockStatement=Dg.StaticBlock=function(e,t,r){for(var n=0,i=e.body;n<i.length;n+=1){r(i[n],t,"Statement")}},Dg.Statement=Sg,Dg.EmptyStatement=Ag,Dg.ExpressionStatement=Dg.ParenthesizedExpression=Dg.ChainExpression=function(e,t,r){return r(e.expression,t,"Expression")},Dg.IfStatement=function(e,t,r){r(e.test,t,"Expression"),r(e.consequent,t,"Statement"),e.alternate&&r(e.alternate,t,"Statement")},Dg.LabeledStatement=function(e,t,r){return r(e.body,t,"Statement")},Dg.BreakStatement=Dg.ContinueStatement=Ag,Dg.WithStatement=function(e,t,r){r(e.object,t,"Expression"),r(e.body,t,"Statement")},Dg.SwitchStatement=function(e,t,r){r(e.discriminant,t,"Expression");for(var n=0,i=e.cases;n<i.length;n+=1){r(i[n],t)}},Dg.SwitchCase=function(e,t,r){e.test&&r(e.test,t,"Expression");for(var n=0,i=e.consequent;n<i.length;n+=1){r(i[n],t,"Statement")}},Dg.ReturnStatement=Dg.YieldExpression=Dg.AwaitExpression=function(e,t,r){e.argument&&r(e.argument,t,"Expression")},Dg.ThrowStatement=Dg.SpreadElement=function(e,t,r){return r(e.argument,t,"Expression")},Dg.TryStatement=function(e,t,r){r(e.block,t,"Statement"),e.handler&&r(e.handler,t),e.finalizer&&r(e.finalizer,t,"Statement")},Dg.CatchClause=function(e,t,r){e.param&&r(e.param,t,"Pattern"),r(e.body,t,"Statement")},Dg.WhileStatement=Dg.DoWhileStatement=function(e,t,r){r(e.test,t,"Expression"),r(e.body,t,"Statement")},Dg.ForStatement=function(e,t,r){e.init&&r(e.init,t,"ForInit"),e.test&&r(e.test,t,"Expression"),e.update&&r(e.update,t,"Expression"),r(e.body,t,"Statement")},Dg.ForInStatement=Dg.ForOfStatement=function(e,t,r){r(e.left,t,"ForInit"),r(e.right,t,"Expression"),r(e.body,t,"Statement")},Dg.ForInit=function(e,t,r){"VariableDeclaration"===e.type?r(e,t):r(e,t,"Expression")},Dg.DebuggerStatement=Ag,Dg.FunctionDeclaration=function(e,t,r){return r(e,t,"Function")},Dg.VariableDeclaration=function(e,t,r){for(var n=0,i=e.declarations;n<i.length;n+=1){r(i[n],t)}},Dg.VariableDeclarator=function(e,t,r){r(e.id,t,"Pattern"),e.init&&r(e.init,t,"Expression")},Dg.Function=function(e,t,r){e.id&&r(e.id,t,"Pattern");for(var n=0,i=e.params;n<i.length;n+=1){r(i[n],t,"Pattern")}r(e.body,t,e.expression?"Expression":"Statement")},Dg.Pattern=function(e,t,r){"Identifier"===e.type?r(e,t,"VariablePattern"):"MemberExpression"===e.type?r(e,t,"MemberPattern"):r(e,t)},Dg.VariablePattern=Ag,Dg.MemberPattern=Sg,Dg.RestElement=function(e,t,r){return r(e.argument,t,"Pattern")},Dg.ArrayPattern=function(e,t,r){for(var n=0,i=e.elements;n<i.length;n+=1){var s=i[n];s&&r(s,t,"Pattern")}},Dg.ObjectPattern=function(e,t,r){for(var n=0,i=e.properties;n<i.length;n+=1){var s=i[n];"Property"===s.type?(s.computed&&r(s.key,t,"Expression"),r(s.value,t,"Pattern")):"RestElement"===s.type&&r(s.argument,t,"Pattern")}},Dg.Expression=Sg,Dg.ThisExpression=Dg.Super=Dg.MetaProperty=Ag,Dg.ArrayExpression=function(e,t,r){for(var n=0,i=e.elements;n<i.length;n+=1){var s=i[n];s&&r(s,t,"Expression")}},Dg.ObjectExpression=function(e,t,r){for(var n=0,i=e.properties;n<i.length;n+=1){r(i[n],t)}},Dg.FunctionExpression=Dg.ArrowFunctionExpression=Dg.FunctionDeclaration,Dg.SequenceExpression=function(e,t,r){for(var n=0,i=e.expressions;n<i.length;n+=1){r(i[n],t,"Expression")}},Dg.TemplateLiteral=function(e,t,r){for(var n=0,i=e.quasis;n<i.length;n+=1){r(i[n],t)}for(var s=0,o=e.expressions;s<o.length;s+=1){r(o[s],t,"Expression")}},Dg.TemplateElement=Ag,Dg.UnaryExpression=Dg.UpdateExpression=function(e,t,r){r(e.argument,t,"Expression")},Dg.BinaryExpression=Dg.LogicalExpression=function(e,t,r){r(e.left,t,"Expression"),r(e.right,t,"Expression")},Dg.AssignmentExpression=Dg.AssignmentPattern=function(e,t,r){r(e.left,t,"Pattern"),r(e.right,t,"Expression")},Dg.ConditionalExpression=function(e,t,r){r(e.test,t,"Expression"),r(e.consequent,t,"Expression"),r(e.alternate,t,"Expression")},Dg.NewExpression=Dg.CallExpression=function(e,t,r){if(r(e.callee,t,"Expression"),e.arguments)for(var n=0,i=e.arguments;n<i.length;n+=1){r(i[n],t,"Expression")}},Dg.MemberExpression=function(e,t,r){r(e.object,t,"Expression"),e.computed&&r(e.property,t,"Expression")},Dg.ExportNamedDeclaration=Dg.ExportDefaultDeclaration=function(e,t,r){e.declaration&&r(e.declaration,t,"ExportNamedDeclaration"===e.type||e.declaration.id?"Statement":"Expression"),e.source&&r(e.source,t,"Expression")},Dg.ExportAllDeclaration=function(e,t,r){e.exported&&r(e.exported,t),r(e.source,t,"Expression")},Dg.ImportDeclaration=function(e,t,r){for(var n=0,i=e.specifiers;n<i.length;n+=1){r(i[n],t)}r(e.source,t,"Expression")},Dg.ImportExpression=function(e,t,r){r(e.source,t,"Expression")},Dg.ImportSpecifier=Dg.ImportDefaultSpecifier=Dg.ImportNamespaceSpecifier=Dg.Identifier=Dg.PrivateIdentifier=Dg.Literal=Ag,Dg.TaggedTemplateExpression=function(e,t,r){r(e.tag,t,"Expression"),r(e.quasi,t,"Expression")},Dg.ClassDeclaration=Dg.ClassExpression=function(e,t,r){return r(e,t,"Class")},Dg.Class=function(e,t,r){e.id&&r(e.id,t,"Pattern"),e.superClass&&r(e.superClass,t,"Expression"),r(e.body,t)},Dg.ClassBody=function(e,t,r){for(var n=0,i=e.body;n<i.length;n+=1){r(i[n],t)}},Dg.MethodDefinition=Dg.PropertyDefinition=Dg.Property=function(e,t,r){e.computed&&r(e.key,t,"Expression"),e.value&&r(e.value,t,"Expression")};const Tg=["setup","draw","preload","deviceMoved","deviceTurned","deviceShaken","doubleClicked","mousePressed","mouseReleased","mouseMoved","mouseDragged","mouseClicked","mouseWheel","touchStarted","touchMoved","touchEnded","keyPressed","keyReleased","keyTyped","windowResized"],Fg={fetchScript:async function(e){if(!e.src)return e.textContent;try{return await fetch(e.src).then((e=>e.text()))}catch(e){return console.error("Error fetching script:",e),""}},extractUserDefinedVariablesAndFuncs:function(e){const t={variables:[],functions:[]};try{const a=wg(e,{ecmaVersion:"latest",sourceType:"module",locations:!0});r=a,n={VariableDeclarator(e){if("Identifier"===e.id.type){const r=e.init&&["ArrowFunctionExpression","FunctionExpression"].includes(e.init.type)?"functions":"variables";t[r].push({name:e.id.name,line:e.loc.start.line+-1})}},FunctionDeclaration(e){e.id&&"Identifier"===e.id.type&&t.functions.push({name:e.id.name,line:e.loc.start.line+-1})},ClassDeclaration(e){e.id&&"Identifier"===e.id.type&&t.variables.push({name:e.id.name,line:e.loc.start.line+-1})}},i||(i=Dg),function e(t,r,s){var o=s||t.type;i[o](t,r,e),n[o]&&n[o](t,r)}(r,s,o)}catch(e){console.error("Error parsing code:",e)}var r,n,i,s,o;return t},checkForConstsAndFuncs:function(e,t){const r=[...e.variables,...e.functions];function n(e,t,r){const n=`https://p5js.org/reference/p5/${t}`;return`${e} "${t}" on line ${r} is being redeclared and conflicts with a p5.js ${e.toLowerCase()}. p5.js reference: ${n}`}for(let{name:e,line:t}of r){if(void 0!==qe[e]){const r=n("Constant",e,t);return console.log(r),!0}}const i=new Set(Object.getOwnPropertyNames(t.prototype).filter((e=>!e.startsWith("_")&&"constructor"!==e)));for(let{name:e,line:t}of r)if(!Tg.includes(e)&&i.has(e)){const r=n("Function",e,t);return console.log(r),!0}return!1},getUserCode:async function(){const e=document.querySelectorAll("script"),t=e[e.length-1];return await Fg.fetchScript(t)},runFES:async function(e){const t=await Fg.getUserCode(),r=Fg.extractUserDefinedVariablesAndFuncs(t);Fg.checkForConstsAndFuncs(r,e)}};function Ig(e,t,r){r.presetup=async function(){e.disableFriendlyErrors||e.disableSketchChecker||Fg.runFES(e)}}function kg(e,t){e._friendlyFileLoadError=function(t,r){const{message:n,method:i}=((e,t)=>{const r=El("fes.fileLoadError.suggestion",{filePath:t,url:"https://github.com/processing/p5.js/wiki/Local-server"});switch(e){case 0:return{message:El("fes.fileLoadError.image",{suggestion:r}),method:"loadImage"};case 1:return{message:El("fes.fileLoadError.xml",{suggestion:r}),method:"loadXML"};case 2:return{message:El("fes.fileLoadError.table",{suggestion:r}),method:"loadTable"};case 3:return{message:El("fes.fileLoadError.strings",{suggestion:r}),method:"loadStrings"};case 4:return{message:El("fes.fileLoadError.font",{suggestion:r}),method:"loadFont"};case 5:return{message:El("fes.fileLoadError.json",{suggestion:r}),method:"loadJSON"};case 6:return{message:El("fes.fileLoadError.bytes",{suggestion:r}),method:"loadBytes"};case 7:return{message:El("fes.fileLoadError.large"),method:"loadX"};case 8:return{message:El("fes.fileLoadError.gif"),method:"loadImage"}}})(t,r);e._friendlyError(n,i,3)}}function Ng(e,t){t.storeItem=function(t,r){"string"!=typeof t&&e._friendlyError(`The argument that you passed to storeItem() - ${t} is not a string.`,"storeItem"),t.endsWith("p5TypeID")&&e._friendlyError(`The argument that you passed to storeItem() - ${t} must not end with 'p5TypeID'.`,"storeItem"),void 0===r&&e._friendlyError("You cannot store undefined variables using storeItem().","storeItem");let n=typeof r;switch(n){case"number":case"boolean":r=r.toString();break;case"object":if(r instanceof e.Color)n="p5.Color",r=r.toString();else if(r instanceof e.Vector){n="p5.Vector";r=r.values}r=JSON.stringify(r)}localStorage.setItem(t,r);const i=`${t}p5TypeID`;localStorage.setItem(i,n)},t.getItem=function(t){let r=localStorage.getItem(t);const n=localStorage.getItem(`${t}p5TypeID`);if(void 0===n)e._friendlyError(`Unable to determine type of item stored under ${t}in local storage. Did you save the item with something other than setItem()?`,"getItem");else if(null!==r)switch(n){case"number":r=parseFloat(r);break;case"boolean":r="true"===r;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},t.clearStorage=function(){Object.keys(localStorage).forEach((e=>{e.endsWith("p5TypeID")&&this.removeItem(e.replace("p5TypeID",""))}))},t.removeItem=function(t){"string"!=typeof t&&e._friendlyError(`The argument that you passed to removeItem() - ${t} is not a string.`,"removeItem"),localStorage.removeItem(t),localStorage.removeItem(`${t}p5TypeID`)}}function Mg(e,t){function r(e,t,r){(t._userNode?t._userNode:document.body).appendChild(e);const n=r?new ys(e,t):new Ei(e,t);return t._elements.push(n),n}t.select=function(e,t){const r=this._getContainer(t).querySelector(e);return r?this._wrapElement(r):null},t.selectAll=function(e,t){const r=[],n=this._getContainer(t).querySelectorAll(e);if(n)for(let e=0;e<n.length;e++){const t=this._wrapElement(n[e]);r.push(t)}return r},t._getContainer=function(e){let t=document;return"string"==typeof e?t=document.querySelector(e)||document:e instanceof Ei?t=e.elt:e instanceof HTMLElement&&(t=e),t},t._wrapElement=function(e){const t=Array.prototype.slice.call(e.children);if("INPUT"===e.tagName&&"checkbox"===e.type){let t=new Ei(e,this);return t.checked=function(...e){return 0===e.length?this.elt.checked:(e[0]?this.elt.checked=!0:this.elt.checked=!1,this)},t}return"VIDEO"===e.tagName||"AUDIO"===e.tagName?new ys(e,this):"SELECT"===e.tagName?this.createSelect(new Ei(e,this)):t.length>0&&t.every((function(e){return"INPUT"===e.tagName||"LABEL"===e.tagName}))&&("DIV"===e.tagName||"SPAN"===e.tagName)?this.createRadio(new Ei(e,this)):new Ei(e,this)},t.createElement=function(e,t){const n=document.createElement(e);return void 0!==t&&(n.innerHTML=t),r(n,this)},t.removeElements=function(e){this._elements.filter((e=>!(e.elt instanceof HTMLCanvasElement))).map((e=>e.remove()))},t.createDiv=function(e=""){let t=document.createElement("div");return t.innerHTML=e,r(t,this)},t.createP=function(e=""){let t=document.createElement("p");return t.innerHTML=e,r(t,this)},t.createSpan=function(e=""){let t=document.createElement("span");return t.innerHTML=e,r(t,this)},t.createImg=function(){const e=document.createElement("img"),t=arguments;let n;return t.length>1&&"string"==typeof t[1]&&(e.alt=t[1]),t.length>2&&"string"==typeof t[2]&&(e.crossOrigin=t[2]),e.src=t[0],n=r(e,this),e.addEventListener("load",(function(){n.width=e.offsetWidth||e.width,n.height=e.offsetHeight||e.height;const r=t[t.length-1];"function"==typeof r&&r(n)})),n},t.createA=function(e,t,n){const i=document.createElement("a");return i.href=e,i.innerHTML=t,n&&(i.target=n),r(i,this)},t.createSlider=function(e,t,n,i){const s=document.createElement("input");return s.type="range",s.min=e,s.max=t,0===i?s.step=1e-18:i&&(s.step=i),"number"==typeof n&&(s.value=n),r(s,this)},t.createButton=function(e,t){const n=document.createElement("button");return n.innerHTML=e,t&&(n.value=t),r(n,this)},t.createCheckbox=function(...e){const t=document.createElement("div"),n=document.createElement("input");n.type="checkbox";const i=document.createElement("label");i.appendChild(n),t.appendChild(i);const s=r(t,this);if(s.checked=function(...e){const t=s.elt.firstElementChild.getElementsByTagName("input")[0];if(t){if(0===e.length)return t.checked;e[0]?t.checked=!0:t.checked=!1}return s},this.value=function(e){return s.value=e,this},e[0]){s.value(e[0]);const t=document.createElement("span");t.innerHTML=e[0],i.appendChild(t)}return e[1]&&(n.checked=!0),s},t.createSelect=function(...e){let t,n=e[0];if(n instanceof Ei&&n.elt instanceof HTMLSelectElement)t=n,this.elt=n.elt;else if(n instanceof HTMLSelectElement)t=r(n,this),this.elt=n;else{const e=document.createElement("select");n&&"boolean"==typeof n&&e.setAttribute("multiple","true"),t=r(e,this),this.elt=e}return t.option=function(e,t){let r;if(void 0!==e){for(let t=0;t<this.elt.length;t+=1)if(this.elt[t].textContent===e){r=t;break}if(void 0!==r)!1===t?this.elt.remove(r):this.elt[r].value=t;else{const r=document.createElement("option");r.textContent=e,r.value=void 0===t?e:t,this.elt.appendChild(r),this._pInst._elements.push(r)}}},t.selected=function(e){if(void 0!==e){for(let t=0;t<this.elt.length;t+=1)this.elt[t].value.toString()===e.toString()&&(this.elt.selectedIndex=t);return this}if(this.elt.getAttribute("multiple")){let e=[];for(const t of this.elt.selectedOptions)e.push(t.value);return e}return this.elt.value},t.disable=function(e){if("string"==typeof e)for(let t=0;t<this.elt.length;t++)this.elt[t].value.toString()===e&&(this.elt[t].disabled=!0,this.elt[t].selected=!1);else this.elt.disabled=!0;return this},t.enable=function(e){if("string"==typeof e)for(let t=0;t<this.elt.length;t++)this.elt[t].value.toString()===e&&(this.elt[t].disabled=!1,this.elt[t].selected=!1);else{this.elt.disabled=!1;for(let e=0;e<this.elt.length;e++)this.elt[e].disabled=!1,this.elt[e].selected=!1}return this},t};let n=0;t.createRadio=function(...e){let t,i,s;const o=e[0];o instanceof Ei&&(o.elt instanceof HTMLDivElement||o.elt instanceof HTMLSpanElement)?(t=o,this.elt=o.elt):o instanceof HTMLDivElement||o instanceof HTMLSpanElement?(t=r(o,this),this.elt=o,i=o,"string"==typeof e[1]&&(s=e[1])):("string"==typeof o&&(s=o),i=document.createElement("div"),t=r(i,this),this.elt=i),t._name=s||"radioOption_"+n++;const a=e=>e instanceof HTMLInputElement&&"radio"===e.type,u=e=>e instanceof HTMLLabelElement;return t._getOptionsArray=function(){return Array.from(this.elt.children).filter((e=>a(e)||u(e)&&a(e.firstElementChild))).map((e=>a(e)?e:e.firstElementChild))},t.option=function(e,r){let n,i,s;for(const r of t._getOptionsArray())if(r.value===e){n=r;break}return void 0===n&&(n=document.createElement("input"),n.setAttribute("type","radio"),n.setAttribute("value",e)),n.setAttribute("name",t._name),u(n.parentElement)?i=n.parentElement:(i=document.createElement("label"),i.insertAdjacentElement("afterbegin",n)),i.lastElementChild instanceof HTMLSpanElement?s=i.lastElementChild:(s=document.createElement("span"),n.insertAdjacentElement("afterend",s)),s.innerHTML=void 0===r?e:r,this.elt.appendChild(i),n},t.remove=function(e){for(const r of t._getOptionsArray())if(r.value===e)return void(u(r.parentElement)?r.parentElement.remove():r.remove())},t.value=function(){let e="";for(const r of t._getOptionsArray())if(r.checked){e=r.value;break}return e},t.selected=function(e){let r=null;if(void 0===e){for(const e of t._getOptionsArray())if(e.checked){r=e;break}}else{t._getOptionsArray().forEach((e=>{e.checked=!1,e.removeAttribute("checked")}));for(const n of t._getOptionsArray())n.value===e&&(n.setAttribute("checked",!0),n.checked=!0,r=n)}return r},t.disable=function(e=!0){for(const r of t._getOptionsArray())r.setAttribute("disabled",e)},t},t.createColorPicker=function(t){const n=document.createElement("input");let i;n.type="color",t?t instanceof e.Color?n.value=t.toString("#rrggbb"):(this.push(),this.colorMode("rgb"),n.value=this.color(t).toString("#rrggbb"),this.pop()):n.value="#000000",i=r(n,this);const s=this;return i.color=function(){s.push(),t&&t.mode&&s.colorMode(t.mode,...t?.maxes&&t.maxes[t.mode]||[]);const e=s.color(this.elt.value);return s.pop(),e},i},t.createInput=function(e="",t="text"){let n=document.createElement("input");return n.setAttribute("value",e),n.setAttribute("type",t),r(n,this)},t.createFileInput=function(t,n=!1){if(!(window.File&&window.FileReader&&window.FileList&&window.Blob))return void e._friendlyError("The File APIs are not fully supported in this browser. Cannot create element.","createFileInput");const i=document.createElement("input");return i.setAttribute("type","file"),n&&i.setAttribute("multiple",!0),i.addEventListener("change",(function(e){for(const r of e.target.files)wi._load(r,t)}),!1),r(i,this)}}function Og(e,t,r){r.presetup=function(){const e=["deviceorientation","devicemotion"];for(const t of e)window.addEventListener(t,this[`_on${t}`].bind(this),{passive:!1,signal:this._removeSignal});this.deviceOrientation="undefined"!=typeof window&&window.innerWidth/window.innerHeight>1?"landscape":"portrait"},t.deviceOrientation="landscape",t.accelerationX=0,t.accelerationY=0,t.accelerationZ=0,t.pAccelerationX=0,t.pAccelerationY=0,t.pAccelerationZ=0,t._updatePAccelerations=function(){this.pAccelerationX=this.accelerationX,this.pAccelerationY=this.accelerationY,this.pAccelerationZ=this.accelerationZ},t.rotationX=0,t.rotationY=0,t.rotationZ=0,t.pRotationX=0,t.pRotationY=0,t.pRotationZ=0;let n=0,i=0,s=0,o="clockwise",a="clockwise",u="clockwise";t.pRotateDirectionX=void 0,t.pRotateDirectionY=void 0,t.pRotateDirectionZ=void 0,t._updatePRotations=function(){this.pRotationX=this.rotationX,this.pRotationY=this.rotationY,this.pRotationZ=this.rotationZ},t.turnAxis=void 0;let l=.5,h=30;t.setMoveThreshold=function(e){l=e},t.setShakeThreshold=function(e){h=e},t._ondeviceorientation=function(e){this._updatePRotations(),this.rotationX=this._fromDegrees(e.beta),this.rotationY=this._fromDegrees(e.gamma),this.rotationZ=this._fromDegrees(e.alpha),this._handleMotion()},t._ondevicemotion=function(e){this._updatePAccelerations(),this.accelerationX=2*e.acceleration.x,this.accelerationY=2*e.acceleration.y,this.accelerationZ=2*e.acceleration.z,this._handleMotion()},t._handleMotion=function(){if("landscape-primary"===screen.orientation.type||"landscape-secondary"===screen.orientation.type?this.deviceOrientation="landscape":"portrait-primary"===screen.orientation.type||"portrait-secondary"===screen.orientation.type?this.deviceOrientation="portrait":this.deviceOrientation="undefined","function"==typeof this._customActions.deviceMoved&&(Math.abs(this.accelerationX-this.pAccelerationX)>l||Math.abs(this.accelerationY-this.pAccelerationY)>l||Math.abs(this.accelerationZ-this.pAccelerationZ)>l)&&this._customActions.deviceMoved(),"function"==typeof this._customActions.deviceTurned){const e=this._toDegrees(this.rotationX)+180,t=this._toDegrees(this.pRotationX)+180;let r=n+180;e-t>0&&e-t<270||e-t<-270?o="clockwise":(e-t<0||e-t>270)&&(o="counter-clockwise"),o!==this.pRotateDirectionX&&(r=e),Math.abs(e-r)>90&&Math.abs(e-r)<270&&(r=e,this.turnAxis="X",this._customActions.deviceTurned()),this.pRotateDirectionX=o,n=r-180;const l=this._toDegrees(this.rotationY)+180,h=this._toDegrees(this.pRotationY)+180;let c=i+180;l-h>0&&l-h<270||l-h<-270?a="clockwise":(l-h<0||l-this.pRotationY>270)&&(a="counter-clockwise"),a!==this.pRotateDirectionY&&(c=l),Math.abs(l-c)>90&&Math.abs(l-c)<270&&(c=l,this.turnAxis="Y",this._customActions.deviceTurned()),this.pRotateDirectionY=a,i=c-180;const d=this._toDegrees(this.rotationZ),p=this._toDegrees(this.pRotationZ);d-p>0&&d-p<270||d-p<-270?u="clockwise":(d-p<0||d-p>270)&&(u="counter-clockwise"),u!==this.pRotateDirectionZ&&(s=d),Math.abs(d-s)>90&&Math.abs(d-s)<270&&(s=d,this.turnAxis="Z",this._customActions.deviceTurned()),this.pRotateDirectionZ=u,this.turnAxis=void 0}if("function"==typeof this._customActions.deviceShaken){let e,t;null!==this.pAccelerationX&&(e=Math.abs(this.accelerationX-this.pAccelerationX),t=Math.abs(this.accelerationY-this.pAccelerationY)),e+t>h&&this._customActions.deviceShaken()}}}function Bg(e,t,r){r.presetup=function(){const e=["keydown","keyup","keypress","blur"];for(const t of e)window.addEventListener(t,this[`_on${t}`].bind(this),{passive:!1,signal:this._removeSignal})},t.keyIsPressed=!1,t.key="",t.code="",t.keyCode=0,t._onkeydown=function(e){if(!this._downKeys[e.code]&&(this.keyIsPressed=!0,this.keyCode=e.which,this.key=e.key,this.code=e.code,this._downKeyCodes[e.code]=!0,this._downKeys[e.key]=!0,"function"==typeof this._customActions.keyPressed&&!e.charCode)){!1===this._customActions.keyPressed(e)&&e.preventDefault()}},t._onkeyup=function(e){if("function"==typeof this._customActions.keyReleased){!1===this._customActions.keyReleased(e)&&e.preventDefault()}if(delete this._downKeyCodes[e.code],delete this._downKeys[e.key],this._areDownKeys()){const e=Object.keys(this._downKeyCodes).pop();this.code=e;const t=Object.keys(this._downKeys).pop();this.key=t}else this.keyIsPressed=!1,this.key="",this.code=""},t._onkeypress=function(e){if((e.which!==this._lastKeyCodeTyped||!e.repeat)&&(this._lastKeyCodeTyped=e.which,this.key=e.key||String.fromCharCode(e.which)||e.which,"function"==typeof this._customActions.keyTyped)){!1===this._customActions.keyTyped(e)&&e.preventDefault()}},t._onblur=function(e){this._downKeys={}},t.keyIsDown=function(e){return function(e){return!["Alt","Shift","Control","Meta"].includes(e)&&"string"==typeof e&&e.length>1}(e)?this._downKeyCodes[e]||this._downKeys[e]||!1:this._downKeys[e]||this._downKeyCodes[e]||!1},t._areDownKeys=function(){for(const e in this._downKeys)if(this._downKeys.hasOwnProperty(e)&&!0===this._downKeys[e])return!0;return!1}}function Lg(e,t,r){function n(e,t,r,n){const i=e.getBoundingClientRect();return{x:(n.clientX-i.left)/t,y:(n.clientY-i.top)/r,winX:n.clientX,winY:n.clientY,id:n.pointerId}}r.presetup=function(){const e=["pointerdown","pointerup","pointercancel","pointermove","dragend","dragover","click","dblclick","wheel"];for(const t of e)window.addEventListener(t,this[`_on${t}`].bind(this),{passive:!1,signal:this._removeSignal});window.addEventListener("blur",(()=>{this.mouseIsPressed=!1}),{signal:this._removeSignal})},t.movedX=0,t.movedY=0,t._hasMouseInteracted=!1,t.mouseX=0,t.mouseY=0,t.pmouseX=0,t.pmouseY=0,t.winMouseX=0,t.winMouseY=0,t.pwinMouseX=0,t.pwinMouseY=0,t.mouseButton={left:!1,right:!1,center:!1},t.touches=[],t._activePointers=new Map,t.mouseIsPressed=!1,t._updatePointerCoords=function(e){if(null!==this._curElement){const t=this._curElement.elt,r=t.scrollWidth/this.width||1,i=t.scrollHeight/this.height||1;if("touch"===e.pointerType){const e=[];for(const s of this._activePointers.values())e.push(n(t,r,i,s));this.touches=e}const s=function(e,t,r,n){const i=e.getBoundingClientRect();return{x:(n.clientX-i.left)/t,y:(n.clientY-i.top)/r,winX:n.clientX,winY:n.clientY}}(t,r,i,e);this.movedX=e.movementX||0,this.movedY=e.movementY||0,this.mouseX=s.x,this.mouseY=s.y,this.winMouseX=s.winX,this.winMouseY=s.winY,this._hasMouseInteracted||(this._updateMouseCoords(),this._hasMouseInteracted=!0)}},t._updateMouseCoords=function(){this.pmouseX=this.mouseX,this.pmouseY=this.mouseY,this.pwinMouseX=this.winMouseX,this.pwinMouseY=this.winMouseY,this._pmouseWheelDeltaY=this._mouseWheelDeltaY},t._setMouseButton=function(e){this.mouseButton.left=Array.from(this._activePointers.values()).some((e=>!!(1&e.buttons))),this.mouseButton.center=Array.from(this._activePointers.values()).some((e=>!!(4&e.buttons))),this.mouseButton.right=Array.from(this._activePointers.values()).some((e=>!!(2&e.buttons)))},t._onpointermove=function(e){let t;this._updatePointerCoords(e),this._activePointers.set(e.pointerId,e),this._setMouseButton(e),this.mouseIsPressed&&0===e.buttons&&this._onpointerup(e),this.mouseIsPressed||"function"!=typeof this._customActions.mouseMoved?this.mouseIsPressed&&"function"==typeof this._customActions.mouseDragged&&(t=this._customActions.mouseDragged(e),!1===t&&e.preventDefault()):(t=this._customActions.mouseMoved(e),!1===t&&e.preventDefault())},t._onpointerdown=function(e){let t;this.mouseIsPressed=!0,this._activePointers.set(e.pointerId,e),this._setMouseButton(e),this._updatePointerCoords(e),"function"==typeof this._customActions.mousePressed&&(t=this._customActions.mousePressed(e),!1===t&&e.preventDefault())},t._onpointerup=function(e){let t;this.mouseIsPressed=!1,this._activePointers.delete(e.pointerId),this._setMouseButton(e),this._updatePointerCoords(e),"function"==typeof this._customActions.mouseReleased&&(t=this._customActions.mouseReleased(e),!1===t&&e.preventDefault())},t._ondragend=t._onpointerup,t._ondragover=t._onpointermove,t._onpointercancel=function(e){this._activePointers.delete(e.pointerId),this._setMouseButton(e),this._updatePointerCoords(e),0===this._activePointers.size&&(this.mouseIsPressed=!1)},t._onclick=function(e){if("function"==typeof this._customActions.mouseClicked){!1===this._customActions.mouseClicked(e)&&e.preventDefault()}},t._ondblclick=function(e){if("function"==typeof this._customActions.doubleClicked){!1===this._customActions.doubleClicked(e)&&e.preventDefault()}},t._mouseWheelDeltaY=0,t._pmouseWheelDeltaY=0,t._onwheel=function(e){if(this._mouseWheelDeltaY=e.deltaY,"function"==typeof this._customActions.mouseWheel){e.delta=e.deltaY;!1===this._customActions.mouseWheel(e)&&e.preventDefault()}},t.requestPointerLock=function(){const t=this._curElement.elt;return t.requestPointerLock=t.requestPointerLock||t.mozRequestPointerLock,t.requestPointerLock?(t.requestPointerLock(),!0):(e._friendlyError("requestPointerLock is not implemented in this browser","requestPointerLock"),!1)},t.exitPointerLock=function(){document.exitPointerLock()}}"undefined"!=typeof p5&&Ig(p5),"undefined"!=typeof p5&&kg(p5),"undefined"!=typeof p5&&Ng(p5,p5.prototype),"undefined"!=typeof p5&&Mg(p5,p5.prototype),"undefined"!=typeof p5&&Og(p5,p5.prototype),"undefined"!=typeof p5&&Bg(p5,p5.prototype),"undefined"!=typeof p5&&Lg(p5,p5.prototype);class Pg{constructor(e){this.columns=[],this.rows=[]}toString(e=","){let t=this.rows.map((e=>e.arr));return this.columns.some((e=>null===e))||(t=[this.columns,...t]),function(e,t={},r=e=>e){const n=Object.create(null);if(n.options=t,n.options.eof=void 0===n.options.eof||n.options.eof,n.row=1,n.col=1,n.output="",n.options.delimiter=void 0===n.options.delimiter?'"':t.delimiter,n.options.delimiter.length>1||0===n.options.delimiter.length)throw Error(`CSVError: delimiter must be one character [${n.options.separator}]`);if(n.options.separator=void 0===n.options.separator?",":t.separator,n.options.separator.length>1||0===n.options.separator.length)throw Error(`CSVError: separator must be one character [${n.options.separator}]`);const i=new RegExp(`${Ms(n.options.delimiter)}|${Ms(n.options.separator)}|\r\n|\n|\r`);return e.forEach(((t,s)=>{let o="";switch(n.col=1,t.forEach(((e,s)=>{"string"==typeof e&&(e=e.replace(new RegExp(n.options.delimiter,"g"),`${n.options.delimiter}${n.options.delimiter}`),e=i.test(e)?`${n.options.delimiter}${e}${n.options.delimiter}`:e),o+=r(e,n.row,n.col),s!==t.length-1&&(o+=n.options.separator),n.col++})),!0){case n.options.eof:case!n.options.eof&&s!==e.length-1:n.output+=`${o}\n`;break;default:n.output+=`${o}`}n.row++})),n.output}(t,{separator:e})}addRow(e){const t=e||new p5.TableRow;if(void 0===t.arr||void 0===t.obj)throw new Error(`invalid TableRow: ${t}`);return t.table=this,this.rows.push(t),t}removeRow(e){this.rows[e].table=null;const t=this.rows.splice(e+1,this.rows.length);this.rows.pop(),this.rows=this.rows.concat(t)}getRow(e){return this.rows[e]}getRows(){return this.rows}findRow(e,t){if("string"==typeof t){for(let r=0;r<this.rows.length;r++)if(this.rows[r].obj[this.columns.indexOf(t)]===e)return this.rows[r]}else for(let r=0;r<this.rows.length;r++)if(this.rows[r].arr[t]===e)return this.rows[r];return null}findRows(e,t){const r=[];if("string"==typeof t)for(let n=0;n<this.rows.length;n++)this.rows[n].obj[this.columns.indexOf(t)]===e&&r.push(this.rows[n]);else for(let n=0;n<this.rows.length;n++)this.rows[n].arr[t]===e&&r.push(this.rows[n]);return r}matchRow(e,t){if("number"==typeof t){for(let r=0;r<this.rows.length;r++)if(this.rows[r].arr[t].match(e))return this.rows[r]}else for(let r=0;r<this.rows.length;r++)if(this.rows[r].obj[this.columns.indexOf(t)].match(e))return this.rows[r];return null}matchRows(e,t){const r=[];if("number"==typeof t)for(let n=0;n<this.rows.length;n++)this.rows[n].arr[t].match(e)&&r.push(this.rows[n]);else for(let n=0;n<this.rows.length;n++)this.rows[n].obj[this.columns.indexOf(t)].match(e)&&r.push(this.rows[n]);return r}getColumn(e){const t=[];if("string"==typeof e)for(let r=0;r<this.rows.length;r++)t.push(this.rows[r].obj[this.columns.indexOf(e)]);else for(let r=0;r<this.rows.length;r++)t.push(this.rows[r].arr[e]);return t}clearRows(){delete this.rows,this.rows=[]}addColumn(e){const t=e||null;this.columns.push(t)}getColumnCount(){return this.columns.length}getRowCount(){return this.rows.length}removeTokens(e,t){const r=[];for(let t=0;t<e.length;t++)r.push(e.charAt(t).replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"));const n=new RegExp(r.join("|"),"g");if(void 0===t)for(let e=0;e<this.columns.length;e++)for(let t=0;t<this.rows.length;t++){let r=this.rows[t].arr[e];r=r.replace(n,""),this.rows[t].arr[e]=r,this.rows[t].obj[this.columns[e]]=r}else if("string"==typeof t)for(let e=0;e<this.rows.length;e++){let r=this.rows[e].obj[t];r=r.replace(n,""),this.rows[e].obj[t]=r;const i=this.columns.indexOf(t);this.rows[e].arr[i]=r}else for(let e=0;e<this.rows.length;e++){let r=this.rows[e].arr[t];r=r.replace(n,""),this.rows[e].arr[t]=r,this.rows[e].obj[this.columns[t]]=r}}trim(e){const t=new RegExp(" ","g");if(void 0===e)for(let e=0;e<this.columns.length;e++)for(let r=0;r<this.rows.length;r++){let n=this.rows[r].arr[e];n=n.replace(t,""),this.rows[r].arr[e]=n,this.rows[r].obj[this.columns[e]]=n}else if("string"==typeof e)for(let r=0;r<this.rows.length;r++){let n=this.rows[r].obj[e];n=n.replace(t,""),this.rows[r].obj[e]=n;const i=this.columns.indexOf(e);this.rows[r].arr[i]=n}else for(let r=0;r<this.rows.length;r++){let n=this.rows[r].arr[e];n=n.replace(t,""),this.rows[r].arr[e]=n,this.rows[r].obj[this.columns[e]]=n}}removeColumn(e){let t,r;"string"==typeof e?(t=e,r=this.columns.indexOf(e)):(r=e,t=this.columns[e]);const n=this.columns.splice(r+1,this.columns.length);this.columns.pop(),this.columns=this.columns.concat(n);for(let e=0;e<this.rows.length;e++){const n=this.rows[e].arr,i=n.splice(r+1,n.length);n.pop(),this.rows[e].arr=n.concat(i),delete this.rows[e].obj[t]}}set(e,t,r){this.rows[e].set(t,r)}setNum(e,t,r){this.rows[e].setNum(t,r)}setString(e,t,r){this.rows[e].setString(t,r)}get(e,t){return"string"==typeof t?this.rows[e].get(this.columns.indexOf(t)):this.rows[e].get(t)}getNum(e,t){return this.rows[e].getNum(t)}getString(e,t){return this.rows[e].getString(t)}getObject(e){const t={};let r,n,i;for(let s=0;s<this.rows.length;s++)if(r=this.rows[s].obj,"string"==typeof e){if(n=this.columns.indexOf(e),!(n>=0))throw new Error(`This table has no column named "${e}"`);i=r[e],t[i]=r}else t[s]=this.rows[s].obj;return t}getArray(){const e=[];for(let t=0;t<this.rows.length;t++)e.push(this.rows[t].arr);return e}}function Rg(e,t){e.Table=Pg}"undefined"!=typeof p5&&Rg(p5);class Vg{constructor(e=[]){let t=e;this.arr=t,this.obj=Object.fromEntries(t.entries()),this.table=null}set(e,t){if("string"==typeof e){const r=this.table.columns.indexOf(e);if(!(r>=0))throw new Error(`This table has no column named "${e}"`);this.obj[e]=t,this.arr[r]=t}else{if(!(e<this.table.columns.length))throw new Error(`Column #${e} is out of the range of this table`);{this.arr[e]=t;const r=this.table.columns[e];this.obj[r]=t}}}setNum(e,t){const r=parseFloat(t);this.set(e,r)}setString(e,t){const r=t.toString();this.set(e,r)}get(e){return"string"==typeof e?this.obj[this.table.columns.indexOf(e)]:this.arr[e]}getNum(e){let t;if(t="string"==typeof e?parseFloat(this.obj[this.table.columns.indexOf(e)]):parseFloat(this.arr[e]),"NaN"===t.toString())throw`Error: ${this.obj[e]} is NaN (Not a Number)`;return t}getString(e){return"string"==typeof e?this.obj[this.table.columns.indexOf(e)].toString():this.arr[e].toString()}}function Ug(e,t){e.TableRow=Vg}function zg(e,t){t.abs=Math.abs,t.ceil=Math.ceil,t.constrain=function(e,t,r){return Math.max(Math.min(e,r),t)},t.dist=function(...e){return 4===e.length?Math.hypot(e[2]-e[0],e[3]-e[1]):6===e.length?Math.hypot(e[3]-e[0],e[4]-e[1],e[5]-e[2]):void 0},t.exp=Math.exp,t.floor=Math.floor,t.lerp=function(e,t,r){return r*(t-e)+e},t.log=Math.log,t.mag=function(e,t){return Math.hypot(e,t)},t.map=function(e,t,r,n,i,s){const o=(e-t)/(r-t)*(i-n)+n;return s?n<i?this.constrain(o,n,i):this.constrain(o,i,n):o},t.max=function(...e){const t=e=>{let t=-1/0;for(let r of e)t=Math.max(t,r);return t};return e[0]instanceof Array?t(e[0]):t(e)},t.min=function(...e){const t=e=>{let t=1/0;for(let r of e)t=Math.min(t,r);return t};return e[0]instanceof Array?t(e[0]):t(e)},t.norm=function(e,t,r){return this.map(e,t,r,0,1)},t.pow=Math.pow,t.round=function(e,t){if(!t)return Math.round(e);const r=Math.pow(10,t);return Math.round(e*r)/r},t.sq=e=>e*e,t.sqrt=Math.sqrt,t.fract=function(e){let t=0,r=Number(e);if(isNaN(r)||Math.abs(r)===1/0)return r;if(r<0&&(r=-r,t=1),String(r).includes(".")&&!String(r).includes("e")){let e=String(r);return e=Number("0"+e.slice(e.indexOf("."))),Math.abs(t-e)}return r<1?Math.abs(t-r):0}}function jg(e,t){const r=4095;let n=4,i=.5;const s=e=>.5*(1-Math.cos(e*Math.PI));let o;t.noise=function(e,t=0,a=0){if(null==o){o=new Array(4096);for(let e=0;e<4096;e++)o[e]=Math.random()}e<0&&(e=-e),t<0&&(t=-t),a<0&&(a=-a);let u,l,h,c,d,p=Math.floor(e),f=Math.floor(t),m=Math.floor(a),g=e-p,y=t-f,v=a-m,b=0,x=.5;for(let e=0;e<n;e++){let e=p+(f<<4)+(m<<8);u=s(g),l=s(y),h=o[e&r],h+=u*(o[e+1&r]-h),c=o[e+16&r],c+=u*(o[e+16+1&r]-c),h+=l*(c-h),e+=256,c=o[e&r],c+=u*(o[e+1&r]-c),d=o[e+16&r],d+=u*(o[e+16+1&r]-d),c+=l*(d-c),h+=s(v)*(c-h),b+=h*x,x*=i,p<<=1,g*=2,f<<=1,y*=2,m<<=1,v*=2,g>=1&&(p++,g--),y>=1&&(f++,y--),v>=1&&(m++,v--)}return b},t.noiseDetail=function(e,t=.5){e>0&&(n=e),t>0&&(i=t)},t._getNoiseOctaves=function(){return n},t._getNoiseAmpFalloff=function(){return i},t.noiseSeed=function(e){const t=(()=>{const e=4294967296;let t,r;return{setSeed(n){r=t=(null==n?Math.random()*e:n)>>>0},getSeed:()=>t,rand:()=>(r=(1664525*r+1013904223)%e,r/e)}})();t.setSeed(e),o=new Array(4096);for(let e=0;e<4096;e++)o[e]=t.rand()}}function Gg(e,t){const r="_lcg_random_state",n=4294967296;let i=0;t._lcg=function(e){return this[e]=(1664525*this[e]+1013904223)%n,this[e]/n},t._lcgSetSeed=function(e,t){this[e]=(null==t?Math.random()*n:t)>>>0},t.randomSeed=function(e){this._lcgSetSeed(r,e),this._gaussian_previous=!1},t.random=function(e,t){let n;if(n=null!=this[r]?this._lcg(r):Math.random(),void 0===e)return n;if(void 0===t)return e instanceof Array?e[Math.floor(n*e.length)]:n*e;if(e>t){const r=e;e=t,t=r}return n*(t-e)+e},t.randomGaussian=function(e,t=1){let r,n,s,o;if(this._gaussian_previous)r=i,this._gaussian_previous=!1;else{do{n=this.random(2)-1,s=this.random(2)-1,o=n*n+s*s}while(o>=1);o=Math.sqrt(-2*Math.log(o)/o),r=n*o,i=s*o,this._gaussian_previous=!0}return r*t+(e||0)}}function $g(e,t){t.createVector=function(...t){return this instanceof e?(this._boundFromRadians||(this._boundFromRadians=this._fromRadians.bind(this),this._boundToRadians=this._toRadians.bind(this)),new e.Vector(this._boundFromRadians,this._boundToRadians,...t)):new e.Vector(...t)},t.createMatrix=function(...t){return new e.Matrix(...t)}}function Hg(e){return function(...t){return 0===t.length?(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"),e.call(this,0,0,0)):(Array.isArray(t[0])&&(t=t[0]),e.call(this,...t))}}function qg(e){return function(t){return function(...r){if(0===r.length)return this;if(r[0]instanceof Pi?r=r[0].values:(Array.isArray(r[0])||1===r.length&&e)&&(r=r[0]),Array.isArray(r))for(let e=0;e<r.length;e++){const t=r[e];if("number"!=typeof t||!Number.isFinite(t))return this.friendlyErrorsDisabled()||this._friendlyError("Arguments contain non-finite numbers","p5.Vector"),this}else if("number"!=typeof r||!Number.isFinite(r))return this.friendlyErrorsDisabled()||this._friendlyError("Arguments contain non-finite numbers","p5.Vector"),this;return t.call(this,r)}}}function Wg(e,t,r){e.registerDecorator("p5.prototype.createVector",Hg),e.registerDecorator("p5.Vector.prototype.mult",qg(!0)),e.registerDecorator("p5.Vector.prototype.rem",qg(!0)),e.registerDecorator("p5.Vector.prototype.div",qg(!0)),e.registerDecorator("p5.Vector.prototype.add",qg(!1)),e.registerDecorator("p5.Vector.prototype.sub",qg(!1))}function Xg(e,t){t.float=function(e){return e instanceof Array?e.map(parseFloat):parseFloat(e)},t.int=function(e,r=10){return e===1/0||"Infinity"===e?1/0:e===-1/0||"-Infinity"===e?-1/0:"string"==typeof e?parseInt(e,r):"number"==typeof e?0|e:"boolean"==typeof e?e?1:0:e instanceof Array?e.map((e=>t.int(e,r))):void 0},t.str=function(e){return e instanceof Array?e.map(t.str):String(e)},t.boolean=function(e){return"number"==typeof e?0!==e:"string"==typeof e?"true"===e.toLowerCase():"boolean"==typeof e?e:e instanceof Array?e.map(t.boolean):void 0},t.byte=function(e){const r=t.int(e,10);return"number"==typeof r?(r+128)%256-128:r instanceof Array?r.map(t.byte):void 0},t.char=function(e){return"number"!=typeof e||isNaN(e)?e instanceof Array?e.map(t.char):"string"==typeof e?t.char(parseInt(e,10)):void 0:String.fromCharCode(e)},t.unchar=function(e){return"string"==typeof e&&1===e.length?e.charCodeAt(0):e instanceof Array?e.map(t.unchar):void 0},t.hex=function(e,r){if(r=null==r?r=8:r,e instanceof Array)return e.map((e=>t.hex(e,r)));if(e===1/0||e===-1/0){return(e===1/0?"F":"0").repeat(r)}if("number"==typeof e){e<0&&(e=4294967295+e+1);let t=Number(e).toString(16).toUpperCase();for(;t.length<r;)t=`0${t}`;return t.length>=r&&(t=t.substring(t.length-r,t.length)),t}},t.unhex=function(e){return e instanceof Array?e.map(t.unhex):parseInt(`0x${e}`,16)}}function Zg(e,t){function r(e,t,r){let n=e<0;e=Math.abs(e);let[i,s]=e.toString().split(".");if(void 0===r){i=i.padStart(t,"0");let e=s?i+"."+s:i;return n?"-"+e:e}{let o=e.toFixed(r);[i,s]=o.toString().split("."),i=i.padStart(t,"0");let a=void 0===s?i:i+"."+s;return n?"-"+a:a}}function n(e,t){const r=(e=e.toString()).indexOf(".");let n=-1!==r?e.substring(r):"",i=-1!==r?e.substring(0,r):e;if(i=i.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","),0===t)n="";else if(void 0!==t)if(t>n.length){n+=-1===r?".":"";const e=t-n.length+1;for(let t=0;t<e;t++)n+="0"}else n=n.substring(0,t+1);return i+n}function i(e){return parseFloat(e)>0?`+${e.toString()}`:e.toString()}function s(e){return parseFloat(e)>=0?` ${e.toString()}`:e.toString()}t.nf=function(e,t,n){if(e instanceof Array)return e.map((e=>r(e,t,n)));return"[object Arguments]"===Object.prototype.toString.call(e)?3===e.length?this.nf(e[0],e[1],e[2]):2===e.length?this.nf(e[0],e[1]):this.nf(e[0]):r(e,t,n)},t.nfc=function(e,t){return e instanceof Array?e.map((e=>n(e,t))):n(e,t)},t.nfp=function(...e){const r=t.nf.apply(this,e);return r instanceof Array?r.map(i):i(r)},t.nfs=function(...e){const r=t.nf.apply(this,e);return r instanceof Array?r.map(s):s(r)},t.splitTokens=function(e,t){let r;if(void 0!==t){let e=t;const n=/\]/g.exec(e);let i=/\[/g.exec(e);i&&n?(e=e.slice(0,n.index)+e.slice(n.index+1),i=/\[/g.exec(e),e=e.slice(0,i.index)+e.slice(i.index+1),r=new RegExp(`[\\[${e}\\]]`,"g")):n?(e=e.slice(0,n.index)+e.slice(n.index+1),r=new RegExp(`[${e}\\]]`,"g")):i?(e=e.slice(0,i.index)+e.slice(i.index+1),r=new RegExp(`[${e}\\[]`,"g")):r=new RegExp(`[${e}]`,"g")}else r=/\s/g;return e.split(r).filter((e=>e))},t.shuffle=function(e,t){const r=ArrayBuffer&&ArrayBuffer.isView&&ArrayBuffer.isView(e);let n,i,s=(e=t||r?e:e.slice()).length;for(;s>1;)n=this.random(0,1)*s|0,i=e[--s],e[s]=e[n],e[n]=i;return e}}function Yg(e,t){t.day=function(){return(new Date).getDate()},t.hour=function(){return(new Date).getHours()},t.minute=function(){return(new Date).getMinutes()},t.millis=function(){return-1===this._millisStart?0:window.performance.now()-this._millisStart},t.month=function(){return(new Date).getMonth()+1},t.second=function(){return(new Date).getSeconds()},t.year=function(){return(new Date).getFullYear()}}function Kg(e,t){t.orbitControl=function(e,t,r,n){this._assert3d("orbitControl");const i=this._renderer.states.curCamera;void 0===e&&(e=1),void 0===t&&(t=e),void 0===r&&(r=1),"object"!=typeof n&&(n={}),!0!==this.contextMenuDisabled&&(this.canvas.oncontextmenu=()=>!1,this.contextMenuDisabled=!0),!0!==this.wheelDefaultDisabled&&(this.canvas.onwheel=()=>!1,this.wheelDefaultDisabled=!0);const{disableTouchActions:s=!0}=n;!0!==this.touchActionsDisabled&&s&&(this.canvas.style["touch-action"]="none",this.touchActionsDisabled=!0);const{freeRotation:o=!1}=n,a=[];this.touches.forEach((e=>{this._renderer.prevTouches.forEach((t=>{if(e.id===t.id){const r={x:e.x,y:e.y,px:t.x,py:t.y};a.push(r)}}))})),this._renderer.prevTouches=this.touches;let u=0,l=0,h=0,c=0,d=0;const p=.85,f=this.height<this.width?this.height:this.width;let m=!1;if(a.length>0){if(m=a[0].x>0&&a[0].x<this.width&&a[0].y>0&&a[0].y<this.height,1===a.length){const r=a[0];l=-e*(r.x-r.px)/f,h=t*(r.y-r.py)/f}else{const e=a[0],t=a[1];u=-(Math.hypot(e.x-t.x,e.y-t.y)-Math.hypot(e.px-t.px,e.py-t.py))*r*4e-4,c=.5*(e.x+t.x)-.5*(e.px+t.px),d=.5*(e.y+t.y)-.5*(e.py+t.py)}this.touches.length>0?m&&(this._renderer.executeRotateAndMove=!0,this._renderer.executeZoom=!0):(this._renderer.executeRotateAndMove=!1,this._renderer.executeZoom=!1)}else m=this.mouseX>0&&this.mouseX<this.width&&this.mouseY>0&&this.mouseY<this.height,0!==this._mouseWheelDeltaY?(u=Math.sign(this._mouseWheelDeltaY)*r,u*=.01,this._mouseWheelDeltaY=0,m&&(this._renderer.executeZoom=!0)):this._renderer.executeZoom=!1,this.mouseIsPressed?(this.mouseButton.left?(l=-e*this.movedX/f,h=t*this.movedY/f):this.mouseButton.right&&(c=this.movedX,d=this.movedY*i.yScale),m&&(this._renderer.executeRotateAndMove=!0)):this._renderer.executeRotateAndMove=!1;if(0!==u&&this._renderer.executeZoom&&(this._renderer.zoomVelocity+=u),Math.abs(this._renderer.zoomVelocity)>.001?(o?i._orbitFree(0,0,this._renderer.zoomVelocity):i._orbit(0,0,this._renderer.zoomVelocity),0!==i.projMatrix.mat4[15]&&(i.projMatrix.mat4[0]*=Math.pow(10,-this._renderer.zoomVelocity),i.projMatrix.mat4[5]*=Math.pow(10,-this._renderer.zoomVelocity),this._renderer.states.setValue("uPMatrix",this._renderer.states.uPMatrix.clone()),this._renderer.states.uPMatrix.mat4[0]=i.projMatrix.mat4[0],this._renderer.states.uPMatrix.mat4[5]=i.projMatrix.mat4[5]),this._renderer.zoomVelocity*=p):this._renderer.zoomVelocity=0,0===l&&0===h||!this._renderer.executeRotateAndMove||this._renderer.rotateVelocity.add(.6*l,.6*h,0),this._renderer.rotateVelocity.magSq()>1e-6?(o?i._orbitFree(-this._renderer.rotateVelocity.x,this._renderer.rotateVelocity.y,0):i._orbit(this._renderer.rotateVelocity.x,this._renderer.rotateVelocity.y,0),this._renderer.rotateVelocity.mult(p)):this._renderer.rotateVelocity.set(0,0,0),(0!==c||0!==d)&&this._renderer.executeRotateAndMove){const e=2*c/this.width,t=2*-d/this.height;this._renderer.moveVelocity.add(.15*e,.15*t)}if(this._renderer.moveVelocity.magSq()>1e-6){const e=i._getLocalAxes(),t=i.eyeX-i.centerX,r=i.eyeY-i.centerY,n=i.eyeZ-i.centerZ,s=Math.sqrt(t*t+r*r+n*n);let o,a,u=new Pi(i.centerX,i.centerY,i.centerZ);u=i.cameraMatrix.multiplyPoint(u),u=this._renderer.states.uPMatrix.multiplyAndNormalizePoint(u),u.x-=this._renderer.moveVelocity.x,u.y-=this._renderer.moveVelocity.y;const l=this._renderer.states.uPMatrix.mat4;0===l[15]?(o=(l[8]+u.x)/l[0]*s,a=(l[9]+u.y)/l[5]*s):(o=(u.x-l[12])/l[0],a=(u.y-l[13])/l[5]),i.setPosition(i.eyeX+o*e.x[0]+a*e.y[0],i.eyeY+o*e.x[1]+a*e.y[1],i.eyeZ+o*e.x[2]+a*e.y[2]),this._renderer.moveVelocity.mult(p)}else this._renderer.moveVelocity.set(0,0);return this},t.debugMode=function(...t){this._assert3d("debugMode");for(let t=e.lifecycleHooks.postdraw.length-1;t>=0;t--)e.lifecycleHooks.postdraw[t].toString()!==this._grid().toString()&&e.lifecycleHooks.postdraw[t].toString()!==this._axesIcon().toString()||e.lifecycleHooks.postdraw.splice(t,1);t[0]===Be?e.lifecycleHooks.postdraw.push(this._grid(t[1],t[2],t[3],t[4],t[5])):t[0]===Le?e.lifecycleHooks.postdraw.push(this._axesIcon(t[1],t[2],t[3],t[4])):(e.lifecycleHooks.postdraw.push(this._grid(t[0],t[1],t[2],t[3],t[4])),e.lifecycleHooks.postdraw.push(this._axesIcon(t[5],t[6],t[7],t[8])))},t.noDebugMode=function(){this._assert3d("noDebugMode");for(let t=e.lifecycleHooks.postdraw.length-1;t>=0;t--)e.lifecycleHooks.postdraw[t].toString()!==this._grid().toString()&&e.lifecycleHooks.postdraw[t].toString()!==this._axesIcon().toString()||e.lifecycleHooks.postdraw.splice(t,1)},t._grid=function(e,t,r,n,i){void 0===e&&(e=this.width/2),void 0===t&&(t=Math.round(e/30)<4?4:Math.round(e/30)),void 0===r&&(r=0),void 0===n&&(n=0),void 0===i&&(i=0);const s=e/t,o=e/2;return function(){this.push(),this.stroke(255*this._renderer.states.curStrokeColor[0],255*this._renderer.states.curStrokeColor[1],255*this._renderer.states.curStrokeColor[2]),this._renderer.states.setValue("uModelMatrix",this._renderer.states.uModelMatrix.clone()),this._renderer.states.uModelMatrix.reset();for(let e=0;e<=t;e++)this.beginShape(this.LINES),this.vertex(-o+r,n,e*s-o+i),this.vertex(+o+r,n,e*s-o+i),this.endShape();for(let e=0;e<=t;e++)this.beginShape(this.LINES),this.vertex(e*s-o+r,n,-o+i),this.vertex(e*s-o+r,n,+o+i),this.endShape();this.pop()}},t._axesIcon=function(e,t,r,n){return void 0===e&&(e=this.width/20>40?this.width/20:40),void 0===t&&(t=-this.width/4),void 0===r&&(r=t),void 0===n&&(n=t),()=>{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(t,r,n),this.vertex(t+e,r,n),this.endShape(),this.stroke(0,255,0),this.beginShape(this.LINES),this.vertex(t,r,n),this.vertex(t,r+e,n),this.endShape(),this.stroke(0,0,255),this.beginShape(this.LINES),this.vertex(t,r,n),this.vertex(t,r,n+e),this.endShape(),this.pop()}}}async function Jg(e){try{return(await fetch(e,{method:"HEAD"})).ok}catch(e){return!1}}function Qg(e,t){async function r(e){let t=null,r={};const{data:n}=await Bs(e,"text"),i=n.split("\n");for(let e=0;e<i.length;++e){const n=i[e].trim().split(/\s+/);if("newmtl"===n[0]){t=n[1],r[t]={}}else"Kd"===n[0]?r[t].diffuseColor=[parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3])]:"Ka"===n[0]?r[t].ambientColor=[parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3])]:"Ks"===n[0]?r[t].specularColor=[parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3])]:"map_Kd"===n[0]&&(r[t].texturePath=n[1])}return r}function n(e,t,r={}){const n={v:[],vt:[],vn:[]},i={};let s=null,o=!1;for(let a=0;a<t.length;++a){const u=t[a].trim().split(/\b\s+/);if(u.length>0)if("usemtl"===u[0])s=u[1];else if("v"===u[0]||"vn"===u[0]){const e=new Pi(parseFloat(u[1]),parseFloat(u[2]),parseFloat(u[3]));n[u[0]].push(e)}else if("vt"===u[0]){const e=[parseFloat(u[1]),1-parseFloat(u[2])];n[u[0]].push(e)}else if("f"===u[0])for(let t=3;t<u.length;++t){const a=[],l=[1,t-1,t];for(let t=0;t<l.length;++t){const h=u[l[t]];let c=h.split("/");for(let e=0;e<c.length;e++){let t=parseInt(c[e]);t>0&&(t-=1),c[e]=t}if(i[h]||(i[h]={}),void 0===i[h][s]){const t=e.vertices.length;if(e.vertices.push(n.v.at(c[0]).copy()),e.uvs.push(n.vt.at(c[1])?n.vt.at(c[1]).slice():[0,0]),e.vertexNormals.push(n.vn.at(c[2])?n.vn.at(c[2]).copy():new Pi(0,0,0)),i[h][s]=t,a.push(t),s&&r[s]&&r[s].diffuseColor){o=!0;const t=r[s].diffuseColor;e.vertexColors.push(t[0]),e.vertexColors.push(t[1]),e.vertexColors.push(t[2]),e.vertexColors.push(1)}else e.vertexColors.push(-1,-1,-1,-1)}else a.push(i[h][s])}a[0]!==a[1]&&a[0]!==a[2]&&a[1]!==a[2]&&e.faces.push(a)}}return 0===e.vertexNormals.length&&e.computeNormals(),o||(e.vertexColors=[]),e}function i(e,t){if(function(e){const t=new DataView(e),r=[115,111,108,105,100];for(let e=0;e<5;e++)if(s(r,t,e))return!1;return!0}(t))!function(e,t){const r=new DataView(t),n=r.getUint32(80,!0);let i,s,o,a,u,l,h,c=!1;for(let e=0;e<70;e++)1129270351===r.getUint32(e,!1)&&82===r.getUint8(e+4)&&61===r.getUint8(e+5)&&(c=!0,a=[],u=r.getUint8(e+6)/255,l=r.getUint8(e+7)/255,h=r.getUint8(e+8)/255);const d=84,p=50;for(let t=0;t<n;t++){const n=d+t*p,f=r.getFloat32(n,!0),m=r.getFloat32(n+4,!0),g=r.getFloat32(n+8,!0);if(c){const e=r.getUint16(n+48,!0);32768&e?(i=u,s=l,o=h):(i=(31&e)/31,s=(e>>5&31)/31,o=(e>>10&31)/31)}const y=new Pi(f,m,g);for(let t=1;t<=3;t++){const u=n+12*t,l=new Pi(r.getFloat32(u,!0),r.getFloat32(u+4,!0),r.getFloat32(u+8,!0));e.vertices.push(l),e.vertexNormals.push(y),c&&a.push(i,s,o)}e.faces.push([3*t,3*t+1,3*t+2]),e.uvs.push([0,0],[0,0],[0,0])}}(e,t);else{const r=new DataView(t);if(!("TextDecoder"in window))return console.warn("Sorry, ASCII STL loading only works in browsers that support TextDecoder (https://caniuse.com/#feat=textencoder)"),e;!function(e,t){let r,n,i="",s=[];for(let o=0;o<t.length;++o){const a=t[o].trim(),u=a.split(" ");for(let e=0;e<u.length;++e)""===u[e]&&u.splice(e,1);if(0!==u.length)switch(i){case"":if("solid"!==u[0])return console.error(a),void console.error(`Invalid state "${u[0]}", should be "solid"`);i="solid";break;case"solid":if("facet"!==u[0]||"normal"!==u[1])return console.error(a),void console.error(`Invalid state "${u[0]}", should be "facet normal"`);r=new Pi(parseFloat(u[2]),parseFloat(u[3]),parseFloat(u[4])),e.vertexNormals.push(r,r,r),i="facet normal";break;case"facet normal":if("outer"!==u[0]||"loop"!==u[1])return console.error(a),void console.error(`Invalid state "${u[0]}", should be "outer loop"`);i="vertex";break;case"vertex":if("vertex"===u[0])n=new Pi(parseFloat(u[1]),parseFloat(u[2]),parseFloat(u[3])),e.vertices.push(n),e.uvs.push([0,0]),s.push(e.vertices.indexOf(n));else{if("endloop"!==u[0])return console.error(a),void console.error(`Invalid state "${u[0]}", should be "vertex" or "endloop"`);e.faces.push(s),s=[],i="endloop"}break;case"endloop":if("endfacet"!==u[0])return console.error(a),void console.error(`Invalid state "${u[0]}", should be "endfacet"`);i="endfacet";break;case"endfacet":if("endsolid"===u[0]);else{if("facet"!==u[0]||"normal"!==u[1])return console.error(a),void console.error(`Invalid state "${u[0]}", should be "endsolid" or "facet normal"`);r=new Pi(parseFloat(u[2]),parseFloat(u[3]),parseFloat(u[4])),e.vertexNormals.push(r,r,r),i="facet normal"}break;default:console.error(`Invalid state "${i}"`)}}}(e,new TextDecoder("utf-8").decode(r).split("\n"))}return e}function s(e,t,r){for(let n=0,i=e.length;n<i;n++)if(e[n]!==t.getUint8(r+n,!1))return!1;return!0}t.loadModel=async function(t,s,o,a,u){let l=!1,h=!1;"object"==typeof s?(o=s.normalize||!1,a=s.successCallback,u=s.failureCallback,s=s.fileType||s,l=s.flipU||!1,h=s.flipV||!1):("function"==typeof arguments[arguments.length-1]&&("function"==typeof arguments[arguments.length-2]?(a=arguments[arguments.length-2],u=arguments[arguments.length-1]):a=arguments[arguments.length-1]),"string"==typeof s?"boolean"!=typeof o&&(o=!1):"boolean"==typeof s?(o=s,s=t.slice(-4)):(s=t.slice(-4),o=!1)),".obj"!==s.toLowerCase()&&".stl"!==s.toLowerCase()&&(s=".obj");const c=new po(void 0,void 0,void 0,this._renderer);c.gid=`${t}|${o}`;try{if(s.match(/\.stl$/i)){const{data:e}=await Bs(t,"arrayBuffer"),r=()=>(i(c,e),o&&c.normalize(),l&&c.flipU(),h&&c.flipV(),c._makeTriangleEdges(),a?a(c):c);return this._internal?this._internal(r):r()}if(s.match(/\.obj$/i)){const{data:e}=await Bs(t,"text"),i=e.split("\n"),s=await async function(e){const n=[];for(let i of e){const e=i.match(/^mtllib (.+)/);if(e){let i="";const s=e[1],o=t.split("/");if(o.length>1){o.pop();const e=o.join("/");i=e+"/"+s}else i=s;n.push(Jg(i).then((e=>e?r(i):(console.warn(`MTL file not found or error in parsing; proceeding without materials: ${i}`),{}))).catch((e=>(console.warn(`Error loading MTL file: ${i}`,e),{}))))}}try{const e=await Promise.all(n);return Object.assign({},...e)}catch(e){return{}}}(i),u=()=>(n(c,i,s),o&&c.normalize(),l&&c.flipU(),h&&c.flipV(),c._makeTriangleEdges(),a?a(c):c);return this._internal?this._internal(u):u()}}catch(r){if(e._friendlyFileLoadError(3,t),u)return u(r);throw r}},t.model=function(e,t=1){this._assert3d("model"),this._renderer.model(e,t)};let o=0;t.createModel=function(t,r=" ",s){let a,u,l=!1,h=!1,c=!1;s&&"object"==typeof s?(l=s.normalize||!1,a=s.successCallback,u=s.failureCallback,h=s.flipU||!1,c=s.flipV||!1):"boolean"==typeof s?(l=s,a=arguments[3],u=arguments[4]):(a="function"==typeof arguments[2]?arguments[2]:void 0,u=arguments[3]);const d=new e.Geometry;if(d.gid=`${r}|${l}|${o++}`,r.match(/\.stl$/i))try{i(d,(new TextEncoder).encode(t).buffer)}catch(t){return void(u?u(t):e._friendlyError("Error during parsing: "+t.message))}else if(r.match(/\.obj$/i))try{n(d,t.split("\n"))}catch(t){return void(u?u(t):e._friendlyError("Error during parsing: "+t.message))}else e._friendlyFileLoadError(3,t),u?u():e._friendlyError("Sorry, the file type is invalid. Only OBJ and STL files are supported.");return l&&d.normalize(),h&&d.flipU(),c&&d.flipV(),d._makeTriangleEdges(),"function"==typeof a&&a(d),d}}"undefined"!=typeof p5&&Ug(p5),"undefined"!=typeof p5&&zg(p5,p5.prototype),"undefined"!=typeof p5&&jg(p5,p5.prototype),"undefined"!=typeof p5&&Gg(p5,p5.prototype),"undefined"!=typeof p5&&$g(p5,p5.prototype),"undefined"!=typeof p5&&Xg(p5,p5.prototype),"undefined"!=typeof p5&&Zg(p5,p5.prototype),"undefined"!=typeof p5&&Yg(p5,p5.prototype),"undefined"!=typeof p5&&Kg(p5,p5.prototype),"undefined"!=typeof p5&&Qg(p5,p5.prototype);var ey={};Object.defineProperty(ey,"__esModule",{value:!0});var ty=function(){function e(){}return e.parse=function(t){for(var r=new Set,n=0,i=t;n<i.length;n++){var s=i[n];if(!e.REGEXP.test(s))throw new TypeError('"'+s+'" is invalid unicode-range.');var o=s.match(e.REGEXP),a=o[1],u=o[2],l=o[3];if(a){if(/\?[^?]+$/.test(a))throw new TypeError('"'+s+'" is invalid unicode-range.');if(a.includes("?"))for(var h=a.replace(/\?/g,"0"),c=a.replace(/\?/g,"F"),d=0,p=e.parse(["U+"+h+"-"+c]);d<p.length;d++){var f=p[d];r.add(f)}else r.add(parseInt(a,16))}if(u&&l){var m=parseInt(u,16),g=parseInt(l,16);for(f=m;f<=g;f++)r.add(f)}}return Array.from(r).sort((function(e,t){return e-t}))},e.stringify=function(t){for(var r,n=Array.from(new Set(t)).sort((function(e,t){return e-t})),i=[],s=0;s<n.length;s++){var o=n[s],a=n[s-1];r&&o-a!=1&&(i.push(e.rangeString(r,a)),r=o),r||(r=o),s===n.length-1&&(r===o?i.push(e.rangeString(o)):i.push(e.rangeString(r,o)))}return i},e.rangeString=function(e,t){return t&&e!==t?"U+"+e.toString(16)+"-"+t.toString(16):"U+"+e.toString(16)},e.REGEXP=/^u\+(?:([0-9a-f]?[0-9a-f?]{1,5})|([0-9a-f]{1,6})-([0-9a-f]{1,6}))?$/i,e}(),ry=ey.UnicodeRange=ty;const ny=[{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"]}];function iy(e){let t=e.length;for(;--t>=0;)e[t]=0}iy(new Array(576));iy(new Array(60));iy(new Array(512));iy(new Array(256));iy(new Array(29));iy(new Array(30));var sy=(e,t,r,n)=>{let i=65535&e,s=e>>>16&65535,o=0;for(;0!==r;){o=r>2e3?2e3:r,r-=o;do{i=i+t[n++]|0,s=s+i|0}while(--o);i%=65521,s%=65521}return i|s<<16};const oy=new Uint32Array((()=>{let e,t=[];for(var r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t})());var ay=(e,t,r,n)=>{const i=oy,s=n+r;e^=-1;for(let r=n;r<s;r++)e=e>>>8^i[255&(e^t[r])];return~e},uy={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"},ly={Z_NO_FLUSH:0,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_DEFLATED:8};const hy=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var cy=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const t in r)hy(r,t)&&(e[t]=r[t])}}return e},dy=e=>{let t=0;for(let r=0,n=e.length;r<n;r++)t+=e[r].length;const r=new Uint8Array(t);for(let t=0,n=0,i=e.length;t<i;t++){let i=e[t];r.set(i,n),n+=i.length}return r};let py=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){py=!1}const fy=new Uint8Array(256);for(let e=0;e<256;e++)fy[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;fy[254]=fy[254]=1;var my=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,r,n,i,s,o=e.length,a=0;for(i=0;i<o;i++)r=e.charCodeAt(i),55296==(64512&r)&&i+1<o&&(n=e.charCodeAt(i+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),i++)),a+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Uint8Array(a),s=0,i=0;s<a;i++)r=e.charCodeAt(i),55296==(64512&r)&&i+1<o&&(n=e.charCodeAt(i+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),i++)),r<128?t[s++]=r:r<2048?(t[s++]=192|r>>>6,t[s++]=128|63&r):r<65536?(t[s++]=224|r>>>12,t[s++]=128|r>>>6&63,t[s++]=128|63&r):(t[s++]=240|r>>>18,t[s++]=128|r>>>12&63,t[s++]=128|r>>>6&63,t[s++]=128|63&r);return t},gy=(e,t)=>{const r=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let n,i;const s=new Array(2*r);for(i=0,n=0;n<r;){let t=e[n++];if(t<128){s[i++]=t;continue}let o=fy[t];if(o>4)s[i++]=65533,n+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&n<r;)t=t<<6|63&e[n++],o--;o>1?s[i++]=65533:t<65536?s[i++]=t:(t-=65536,s[i++]=55296|t>>10&1023,s[i++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&py)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let r="";for(let n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r})(s,i)},yy=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let r=t-1;for(;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+fy[e[r]]>t?r:t};var vy=function(){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};const by=16209;var xy=function(e,t){let r,n,i,s,o,a,u,l,h,c,d,p,f,m,g,y,v,b,x,_,w,C,E,S;const A=e.state;r=e.next_in,E=e.input,n=r+(e.avail_in-5),i=e.next_out,S=e.output,s=i-(t-e.avail_out),o=i+(e.avail_out-257),a=A.dmax,u=A.wsize,l=A.whave,h=A.wnext,c=A.window,d=A.hold,p=A.bits,f=A.lencode,m=A.distcode,g=(1<<A.lenbits)-1,y=(1<<A.distbits)-1;e:do{p<15&&(d+=E[r++]<<p,p+=8,d+=E[r++]<<p,p+=8),v=f[d&g];t:for(;;){if(b=v>>>24,d>>>=b,p-=b,b=v>>>16&255,0===b)S[i++]=65535&v;else{if(!(16&b)){if(64&b){if(32&b){A.mode=16191;break e}e.msg="invalid literal/length code",A.mode=by;break e}v=f[(65535&v)+(d&(1<<b)-1)];continue t}for(x=65535&v,b&=15,b&&(p<b&&(d+=E[r++]<<p,p+=8),x+=d&(1<<b)-1,d>>>=b,p-=b),p<15&&(d+=E[r++]<<p,p+=8,d+=E[r++]<<p,p+=8),v=m[d&y];;){if(b=v>>>24,d>>>=b,p-=b,b=v>>>16&255,16&b){if(_=65535&v,b&=15,p<b&&(d+=E[r++]<<p,p+=8,p<b&&(d+=E[r++]<<p,p+=8)),_+=d&(1<<b)-1,_>a){e.msg="invalid distance too far back",A.mode=by;break e}if(d>>>=b,p-=b,b=i-s,_>b){if(b=_-b,b>l&&A.sane){e.msg="invalid distance too far back",A.mode=by;break e}if(w=0,C=c,0===h){if(w+=u-b,b<x){x-=b;do{S[i++]=c[w++]}while(--b);w=i-_,C=S}}else if(h<b){if(w+=u+h-b,b-=h,b<x){x-=b;do{S[i++]=c[w++]}while(--b);if(w=0,h<x){b=h,x-=b;do{S[i++]=c[w++]}while(--b);w=i-_,C=S}}}else if(w+=h-b,b<x){x-=b;do{S[i++]=c[w++]}while(--b);w=i-_,C=S}for(;x>2;)S[i++]=C[w++],S[i++]=C[w++],S[i++]=C[w++],x-=3;x&&(S[i++]=C[w++],x>1&&(S[i++]=C[w++]))}else{w=i-_;do{S[i++]=S[w++],S[i++]=S[w++],S[i++]=S[w++],x-=3}while(x>2);x&&(S[i++]=S[w++],x>1&&(S[i++]=S[w++]))}break}if(64&b){e.msg="invalid distance code",A.mode=by;break e}v=m[(65535&v)+(d&(1<<b)-1)]}}break}}while(r<n&&i<o);x=p>>3,r-=x,p-=x<<3,d&=(1<<p)-1,e.next_in=r,e.next_out=i,e.avail_in=r<n?n-r+5:5-(r-n),e.avail_out=i<o?o-i+257:257-(i-o),A.hold=d,A.bits=p};const _y=15,wy=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]),Cy=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,72,78]),Ey=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]),Sy=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 Ay=(e,t,r,n,i,s,o,a)=>{const u=a.bits;let l,h,c,d,p,f,m=0,g=0,y=0,v=0,b=0,x=0,_=0,w=0,C=0,E=0,S=null;const A=new Uint16Array(16),D=new Uint16Array(16);let T,F,I,k=null;for(m=0;m<=_y;m++)A[m]=0;for(g=0;g<n;g++)A[t[r+g]]++;for(b=u,v=_y;v>=1&&0===A[v];v--);if(b>v&&(b=v),0===v)return i[s++]=20971520,i[s++]=20971520,a.bits=1,0;for(y=1;y<v&&0===A[y];y++);for(b<y&&(b=y),w=1,m=1;m<=_y;m++)if(w<<=1,w-=A[m],w<0)return-1;if(w>0&&(0===e||1!==v))return-1;for(D[1]=0,m=1;m<_y;m++)D[m+1]=D[m]+A[m];for(g=0;g<n;g++)0!==t[r+g]&&(o[D[t[r+g]]++]=g);if(0===e?(S=k=o,f=20):1===e?(S=wy,k=Cy,f=257):(S=Ey,k=Sy,f=0),E=0,g=0,m=y,p=s,x=b,_=0,c=-1,C=1<<b,d=C-1,1===e&&C>852||2===e&&C>592)return 1;for(;;){T=m-_,o[g]+1<f?(F=0,I=o[g]):o[g]>=f?(F=k[o[g]-f],I=S[o[g]-f]):(F=96,I=0),l=1<<m-_,h=1<<x,y=h;do{h-=l,i[p+(E>>_)+h]=T<<24|F<<16|I}while(0!==h);for(l=1<<m-1;E&l;)l>>=1;if(0!==l?(E&=l-1,E+=l):E=0,g++,0==--A[m]){if(m===v)break;m=t[r+o[g]]}if(m>b&&(E&d)!==c){for(0===_&&(_=b),p+=y,x=m-_,w=1<<x;x+_<v&&(w-=A[x+_],!(w<=0));)x++,w<<=1;if(C+=1<<x,1===e&&C>852||2===e&&C>592)return 1;c=E&d,i[c]=b<<24|x<<16|p-s}}return 0!==E&&(i[p+E]=m-_<<24|64<<16),a.bits=b,0};const{Z_FINISH:Dy,Z_BLOCK:Ty,Z_TREES:Fy,Z_OK:Iy,Z_STREAM_END:ky,Z_NEED_DICT:Ny,Z_STREAM_ERROR:My,Z_DATA_ERROR:Oy,Z_MEM_ERROR:By,Z_BUF_ERROR:Ly,Z_DEFLATED:Py}=ly,Ry=16180,Vy=16190,Uy=16191,zy=16192,jy=16194,Gy=16199,$y=16200,Hy=16206,qy=16209,Wy=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function Xy(){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=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Zy=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<Ry||t.mode>16211?1:0},Yy=e=>{if(Zy(e))return My;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Ry,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Iy},Ky=e=>{if(Zy(e))return My;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Yy(e)},Jy=(e,t)=>{let r;if(Zy(e))return My;const n=e.state;return t<0?(r=0,t=-t):(r=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?My:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,Ky(e))},Qy=(e,t)=>{if(!e)return My;const r=new Xy;e.state=r,r.strm=e,r.window=null,r.mode=Ry;const n=Jy(e,t);return n!==Iy&&(e.state=null),n};let ev,tv,rv=!0;const nv=e=>{if(rv){ev=new Int32Array(512),tv=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Ay(1,e.lens,0,288,ev,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Ay(2,e.lens,0,32,tv,0,e.work,{bits:5}),rv=!1}e.lencode=ev,e.lenbits=9,e.distcode=tv,e.distbits=5},iv=(e,t,r,n)=>{let i;const s=e.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),n>=s.wsize?(s.window.set(t.subarray(r-s.wsize,r),0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>n&&(i=n),s.window.set(t.subarray(r-n,r-n+i),s.wnext),(n-=i)?(s.window.set(t.subarray(r-n,r),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=i))),0};var sv=(e,t)=>{let r,n,i,s,o,a,u,l,h,c,d,p,f,m,g,y,v,b,x,_,w,C,E=0;const S=new Uint8Array(4);let A,D;const T=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Zy(e)||!e.output||!e.input&&0!==e.avail_in)return My;r=e.state,r.mode===Uy&&(r.mode=zy),o=e.next_out,i=e.output,u=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,l=r.hold,h=r.bits,c=a,d=u,C=Iy;e:for(;;)switch(r.mode){case Ry:if(0===r.wrap){r.mode=zy;break}for(;h<16;){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}if(2&r.wrap&&35615===l){0===r.wbits&&(r.wbits=15),r.check=0,S[0]=255&l,S[1]=l>>>8&255,r.check=ay(r.check,S,2,0),l=0,h=0,r.mode=16181;break}if(r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",r.mode=qy;break}if((15&l)!==Py){e.msg="unknown compression method",r.mode=qy;break}if(l>>>=4,h-=4,w=8+(15&l),0===r.wbits&&(r.wbits=w),w>15||w>r.wbits){e.msg="invalid window size",r.mode=qy;break}r.dmax=1<<r.wbits,r.flags=0,e.adler=r.check=1,r.mode=512&l?16189:Uy,l=0,h=0;break;case 16181:for(;h<16;){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}if(r.flags=l,(255&r.flags)!==Py){e.msg="unknown compression method",r.mode=qy;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=qy;break}r.head&&(r.head.text=l>>8&1),512&r.flags&&4&r.wrap&&(S[0]=255&l,S[1]=l>>>8&255,r.check=ay(r.check,S,2,0)),l=0,h=0,r.mode=16182;case 16182:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}r.head&&(r.head.time=l),512&r.flags&&4&r.wrap&&(S[0]=255&l,S[1]=l>>>8&255,S[2]=l>>>16&255,S[3]=l>>>24&255,r.check=ay(r.check,S,4,0)),l=0,h=0,r.mode=16183;case 16183:for(;h<16;){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}r.head&&(r.head.xflags=255&l,r.head.os=l>>8),512&r.flags&&4&r.wrap&&(S[0]=255&l,S[1]=l>>>8&255,r.check=ay(r.check,S,2,0)),l=0,h=0,r.mode=16184;case 16184:if(1024&r.flags){for(;h<16;){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}r.length=l,r.head&&(r.head.extra_len=l),512&r.flags&&4&r.wrap&&(S[0]=255&l,S[1]=l>>>8&255,r.check=ay(r.check,S,2,0)),l=0,h=0}else r.head&&(r.head.extra=null);r.mode=16185;case 16185:if(1024&r.flags&&(p=r.length,p>a&&(p=a),p&&(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(n.subarray(s,s+p),w)),512&r.flags&&4&r.wrap&&(r.check=ay(r.check,n,p,s)),a-=p,s+=p,r.length-=p),r.length))break e;r.length=0,r.mode=16186;case 16186:if(2048&r.flags){if(0===a)break e;p=0;do{w=n[s+p++],r.head&&w&&r.length<65536&&(r.head.name+=String.fromCharCode(w))}while(w&&p<a);if(512&r.flags&&4&r.wrap&&(r.check=ay(r.check,n,p,s)),a-=p,s+=p,w)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=16187;case 16187:if(4096&r.flags){if(0===a)break e;p=0;do{w=n[s+p++],r.head&&w&&r.length<65536&&(r.head.comment+=String.fromCharCode(w))}while(w&&p<a);if(512&r.flags&&4&r.wrap&&(r.check=ay(r.check,n,p,s)),a-=p,s+=p,w)break e}else r.head&&(r.head.comment=null);r.mode=16188;case 16188:if(512&r.flags){for(;h<16;){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}if(4&r.wrap&&l!==(65535&r.check)){e.msg="header crc mismatch",r.mode=qy;break}l=0,h=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=Uy;break;case 16189:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}e.adler=r.check=Wy(l),l=0,h=0,r.mode=Vy;case Vy:if(0===r.havedict)return e.next_out=o,e.avail_out=u,e.next_in=s,e.avail_in=a,r.hold=l,r.bits=h,Ny;e.adler=r.check=1,r.mode=Uy;case Uy:if(t===Ty||t===Fy)break e;case zy:if(r.last){l>>>=7&h,h-=7&h,r.mode=Hy;break}for(;h<3;){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}switch(r.last=1&l,l>>>=1,h-=1,3&l){case 0:r.mode=16193;break;case 1:if(nv(r),r.mode=Gy,t===Fy){l>>>=2,h-=2;break e}break;case 2:r.mode=16196;break;case 3:e.msg="invalid block type",r.mode=qy}l>>>=2,h-=2;break;case 16193:for(l>>>=7&h,h-=7&h;h<32;){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}if((65535&l)!=(l>>>16^65535)){e.msg="invalid stored block lengths",r.mode=qy;break}if(r.length=65535&l,l=0,h=0,r.mode=jy,t===Fy)break e;case jy:r.mode=16195;case 16195:if(p=r.length,p){if(p>a&&(p=a),p>u&&(p=u),0===p)break e;i.set(n.subarray(s,s+p),o),a-=p,s+=p,u-=p,o+=p,r.length-=p;break}r.mode=Uy;break;case 16196:for(;h<14;){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}if(r.nlen=257+(31&l),l>>>=5,h-=5,r.ndist=1+(31&l),l>>>=5,h-=5,r.ncode=4+(15&l),l>>>=4,h-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=qy;break}r.have=0,r.mode=16197;case 16197:for(;r.have<r.ncode;){for(;h<3;){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}r.lens[T[r.have++]]=7&l,l>>>=3,h-=3}for(;r.have<19;)r.lens[T[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,A={bits:r.lenbits},C=Ay(0,r.lens,0,19,r.lencode,0,r.work,A),r.lenbits=A.bits,C){e.msg="invalid code lengths set",r.mode=qy;break}r.have=0,r.mode=16198;case 16198:for(;r.have<r.nlen+r.ndist;){for(;E=r.lencode[l&(1<<r.lenbits)-1],g=E>>>24,y=E>>>16&255,v=65535&E,!(g<=h);){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}if(v<16)l>>>=g,h-=g,r.lens[r.have++]=v;else{if(16===v){for(D=g+2;h<D;){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}if(l>>>=g,h-=g,0===r.have){e.msg="invalid bit length repeat",r.mode=qy;break}w=r.lens[r.have-1],p=3+(3&l),l>>>=2,h-=2}else if(17===v){for(D=g+3;h<D;){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}l>>>=g,h-=g,w=0,p=3+(7&l),l>>>=3,h-=3}else{for(D=g+7;h<D;){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}l>>>=g,h-=g,w=0,p=11+(127&l),l>>>=7,h-=7}if(r.have+p>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=qy;break}for(;p--;)r.lens[r.have++]=w}}if(r.mode===qy)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=qy;break}if(r.lenbits=9,A={bits:r.lenbits},C=Ay(1,r.lens,0,r.nlen,r.lencode,0,r.work,A),r.lenbits=A.bits,C){e.msg="invalid literal/lengths set",r.mode=qy;break}if(r.distbits=6,r.distcode=r.distdyn,A={bits:r.distbits},C=Ay(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,A),r.distbits=A.bits,C){e.msg="invalid distances set",r.mode=qy;break}if(r.mode=Gy,t===Fy)break e;case Gy:r.mode=$y;case $y:if(a>=6&&u>=258){e.next_out=o,e.avail_out=u,e.next_in=s,e.avail_in=a,r.hold=l,r.bits=h,xy(e,d),o=e.next_out,i=e.output,u=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,l=r.hold,h=r.bits,r.mode===Uy&&(r.back=-1);break}for(r.back=0;E=r.lencode[l&(1<<r.lenbits)-1],g=E>>>24,y=E>>>16&255,v=65535&E,!(g<=h);){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}if(y&&!(240&y)){for(b=g,x=y,_=v;E=r.lencode[_+((l&(1<<b+x)-1)>>b)],g=E>>>24,y=E>>>16&255,v=65535&E,!(b+g<=h);){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}l>>>=b,h-=b,r.back+=b}if(l>>>=g,h-=g,r.back+=g,r.length=v,0===y){r.mode=16205;break}if(32&y){r.back=-1,r.mode=Uy;break}if(64&y){e.msg="invalid literal/length code",r.mode=qy;break}r.extra=15&y,r.mode=16201;case 16201:if(r.extra){for(D=r.extra;h<D;){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}r.length+=l&(1<<r.extra)-1,l>>>=r.extra,h-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=16202;case 16202:for(;E=r.distcode[l&(1<<r.distbits)-1],g=E>>>24,y=E>>>16&255,v=65535&E,!(g<=h);){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}if(!(240&y)){for(b=g,x=y,_=v;E=r.distcode[_+((l&(1<<b+x)-1)>>b)],g=E>>>24,y=E>>>16&255,v=65535&E,!(b+g<=h);){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}l>>>=b,h-=b,r.back+=b}if(l>>>=g,h-=g,r.back+=g,64&y){e.msg="invalid distance code",r.mode=qy;break}r.offset=v,r.extra=15&y,r.mode=16203;case 16203:if(r.extra){for(D=r.extra;h<D;){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}r.offset+=l&(1<<r.extra)-1,l>>>=r.extra,h-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=qy;break}r.mode=16204;case 16204:if(0===u)break e;if(p=d-u,r.offset>p){if(p=r.offset-p,p>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=qy;break}p>r.wnext?(p-=r.wnext,f=r.wsize-p):f=r.wnext-p,p>r.length&&(p=r.length),m=r.window}else m=i,f=o-r.offset,p=r.length;p>u&&(p=u),u-=p,r.length-=p;do{i[o++]=m[f++]}while(--p);0===r.length&&(r.mode=$y);break;case 16205:if(0===u)break e;i[o++]=r.length,u--,r.mode=$y;break;case Hy:if(r.wrap){for(;h<32;){if(0===a)break e;a--,l|=n[s++]<<h,h+=8}if(d-=u,e.total_out+=d,r.total+=d,4&r.wrap&&d&&(e.adler=r.check=r.flags?ay(r.check,i,d,o-d):sy(r.check,i,d,o-d)),d=u,4&r.wrap&&(r.flags?l:Wy(l))!==r.check){e.msg="incorrect data check",r.mode=qy;break}l=0,h=0}r.mode=16207;case 16207:if(r.wrap&&r.flags){for(;h<32;){if(0===a)break e;a--,l+=n[s++]<<h,h+=8}if(4&r.wrap&&l!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=qy;break}l=0,h=0}r.mode=16208;case 16208:C=ky;break e;case qy:C=Oy;break e;case 16210:return By;default:return My}return e.next_out=o,e.avail_out=u,e.next_in=s,e.avail_in=a,r.hold=l,r.bits=h,(r.wsize||d!==e.avail_out&&r.mode<qy&&(r.mode<Hy||t!==Dy))&&iv(e,e.output,e.next_out,d-e.avail_out),c-=e.avail_in,d-=e.avail_out,e.total_in+=c,e.total_out+=d,r.total+=d,4&r.wrap&&d&&(e.adler=r.check=r.flags?ay(r.check,i,d,e.next_out-d):sy(r.check,i,d,e.next_out-d)),e.data_type=r.bits+(r.last?64:0)+(r.mode===Uy?128:0)+(r.mode===Gy||r.mode===jy?256:0),(0===c&&0===d||t===Dy)&&C===Iy&&(C=Ly),C},ov={inflateReset:Ky,inflateReset2:Jy,inflateResetKeep:Yy,inflateInit:e=>Qy(e,15),inflateInit2:Qy,inflate:sv,inflateEnd:e=>{if(Zy(e))return My;let t=e.state;return t.window&&(t.window=null),e.state=null,Iy},inflateGetHeader:(e,t)=>{if(Zy(e))return My;const r=e.state;return 2&r.wrap?(r.head=t,t.done=!1,Iy):My},inflateSetDictionary:(e,t)=>{const r=t.length;let n,i,s;return Zy(e)?My:(n=e.state,0!==n.wrap&&n.mode!==Vy?My:n.mode===Vy&&(i=1,i=sy(i,t,r,0),i!==n.check)?Oy:(s=iv(e,t,r,r),s?(n.mode=16210,By):(n.havedict=1,Iy)))},inflateInfo:"pako inflate (from Nodeca project)"};var av=function(){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};const uv=Object.prototype.toString,{Z_NO_FLUSH:lv,Z_FINISH:hv,Z_OK:cv,Z_STREAM_END:dv,Z_NEED_DICT:pv,Z_STREAM_ERROR:fv,Z_DATA_ERROR:mv,Z_MEM_ERROR:gv}=ly;function yv(e){this.options=cy({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(15&t.windowBits||(t.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new vy,this.strm.avail_out=0;let r=ov.inflateInit2(this.strm,t.windowBits);if(r!==cv)throw new Error(uy[r]);if(this.header=new av,ov.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=my(t.dictionary):"[object ArrayBuffer]"===uv.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=ov.inflateSetDictionary(this.strm,t.dictionary),r!==cv)))throw new Error(uy[r])}yv.prototype.push=function(e,t){const r=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=t===~~t?t:!0===t?hv:lv,"[object ArrayBuffer]"===uv.call(e)?r.input=new Uint8Array(e):r.input=e,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),s=ov.inflate(r,o),s===pv&&i&&(s=ov.inflateSetDictionary(r,i),s===cv?s=ov.inflate(r,o):s===mv&&(s=pv));r.avail_in>0&&s===dv&&r.state.wrap>0&&0!==e[r.next_in];)ov.inflateReset(r),s=ov.inflate(r,o);switch(s){case fv:case mv:case pv:case gv:return this.onEnd(s),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(0===r.avail_out||s===dv))if("string"===this.options.to){let e=yy(r.output,r.next_out),t=r.next_out-e,i=gy(r.output,e);r.next_out=t,r.avail_out=n-t,t&&r.output.set(r.output.subarray(e,e+t),0),this.onData(i)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(s!==cv||0!==a){if(s===dv)return s=ov.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},yv.prototype.onData=function(e){this.chunks.push(e)},yv.prototype.onEnd=function(e){e===cv&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=dy(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var vv={inflate:function(e,t){const r=new yv(t);if(r.push(e),r.err)throw r.msg||uy[r.err];return r.result}};const{inflate:bv}=vv;const xv={inflate:bv};var _v,wv={};function Cv(e){const t=[];for(let r=0;r<e;r++)t.push(r);return t}wv.parse=function(e){var t=wv.B,r=function(e,t,r,n){var i=wv.T,s={cmap:i.cmap,head:i.head,hhea:i.hhea,maxp:i.maxp,hmtx:i.hmtx,name:i.name,"OS/2":i.OS2,post:i.post,loca:i.loca,kern:i.kern,glyf:i.glyf,"CFF ":i.CFF,GSUB:i.GSUB,CBLC:i.CBLC,CBDT:i.CBDT,"SVG ":i.SVG,COLR:i.colr,CPAL:i.cpal,sbix:i.sbix,fvar:i.fvar,gvar:i.gvar,avar:i.avar,HVAR:i.HVAR},o={_data:e,_index:t,_offset:r};for(var a in s){var u=wv.findTable(e,a,r);if(u){var l=u[0],h=n[l];null==h&&(h=s[a].parseTab(e,l,u[1],o)),o[a]=n[l]=h}}return o};var n=new Uint8Array(e);let i;119==n[0]&&(i=n,n=function(e){var r=t.readUshort(e,12),n=t.readUint(e,16),i=new Uint8Array(n),s=12+16*r;t.writeASCII(i,0,"OTTO"),t.writeUshort(i,4,r);for(var o=44,a=0;a<r;a++){var u=t.readASCII(e,o,4),l=t.readUint(e,o+4),h=t.readUint(e,o+8),c=t.readUint(e,o+12);o+=20;var d=e.slice(l,l+h);h!=c&&(d=xv.inflate(d));var p=12+16*a;t.writeASCII(i,p,u),t.writeUint(i,p+8,s),t.writeUint(i,p+12,c),i.set(d,s),s+=c}return i}(n));var s={};if("ttcf"==t.readASCII(n,0,4)){var o=4;t.readUshort(n,o),o+=2,t.readUshort(n,o),o+=2;var a=t.readUint(n,o);o+=4;for(var u=[],l=0;l<a;l++){var h=t.readUint(n,o);o+=4,u.push(r(n,l,h,s))}return u}var c=r(n,0,0,s);c._compressedData=i;var d=c.fvar;if(d){var p=[c];for(l=0;l<d[1].length;l++){var f=d[1][l],m={};for(var g in p.push(m),c)m[g]=c[g];m._index=l;var y=m.name=JSON.parse(JSON.stringify(m.name));y.fontSubfamily=f[0],null==f[3]&&(f[3]=(y.fontFamily+"-"+y.fontSubfamily).replaceAll(" ","")),y.postScriptName=f[3]}return p}return[c]},wv.findTable=function(e,t,r){for(var n=wv.B,i=n.readUshort(e,r+4),s=r+12,o=0;o<i;o++){var a=n.readASCII(e,s,4);n.readUint(e,s+4);var u=n.readUint(e,s+8),l=n.readUint(e,s+12);if(a==t)return[u,l];s+=16}return null},wv.T={},wv.B={readFixed:function(e,t){return(e[t]<<8|e[t+1])+(e[t+2]<<8|e[t+3])/65540},readF2dot14:function(e,t){return wv.B.readShort(e,t)/16384},readInt:function(e,t){var r=wv.B.t.uint8;return r[0]=e[t+3],r[1]=e[t+2],r[2]=e[t+1],r[3]=e[t],wv.B.t.int32[0]},readInt8:function(e,t){return wv.B.t.uint8[0]=e[t],wv.B.t.int8[0]},readShort:function(e,t){return wv.B.t.uint16[0]=e[t]<<8|e[t+1],wv.B.t.int16[0]},readUshort:function(e,t){return e[t]<<8|e[t+1]},writeUshort:function(e,t,r){e[t]=r>>8&255,e[t+1]=255&r},readUshorts:function(e,t,r){for(var n=[],i=0;i<r;i++){var s=wv.B.readUshort(e,t+2*i);n.push(s)}return n},readUint:function(e,t){var r=wv.B.t.uint8;return r[3]=e[t],r[2]=e[t+1],r[1]=e[t+2],r[0]=e[t+3],wv.B.t.uint32[0]},writeUint:function(e,t,r){e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r},readUint64:function(e,t){return 4294967296*wv.B.readUint(e,t)+wv.B.readUint(e,t+4)},readASCII:function(e,t,r){for(var n="",i=0;i<r;i++)n+=String.fromCharCode(e[t+i]);return n},writeASCII:function(e,t,r){for(var n=0;n<r.length;n++)e[t+n]=r.charCodeAt(n)},readUnicode:function(e,t,r){for(var n="",i=0;i<r;i++){var s=e[t++]<<8|e[t++];n+=String.fromCharCode(s)}return n},_tdec:globalThis.TextDecoder?new globalThis.TextDecoder:null,readUTF8:function(e,t,r){var n=wv.B._tdec;return n&&0==t&&r==e.length?n.decode(e):wv.B.readASCII(e,t,r)},readBytes:function(e,t,r){for(var n=[],i=0;i<r;i++)n.push(e[t+i]);return n},readASCIIArray:function(e,t,r){for(var n=[],i=0;i<r;i++)n.push(String.fromCharCode(e[t+i]));return n},t:(_v=new ArrayBuffer(8),{buff:_v,int8:new Int8Array(_v),uint8:new Uint8Array(_v),int16:new Int16Array(_v),uint16:new Uint16Array(_v),int32:new Int32Array(_v),uint32:new Uint32Array(_v)})},wv.T.CFF={parseTab:function(e,t,r){var n=wv.B,i=wv.T.CFF;e=new Uint8Array(e.buffer,t,r),t=0,t++,t++,t++,t++;var s=[];t=i.readIndex(e,t,s);for(var o=[],a=0;a<s.length-1;a++)o.push(n.readASCII(e,t+s[a],s[a+1]-s[a]));t+=s[s.length-1];var u=[];t=i.readIndex(e,t,u);var l=[];for(a=0;a<u.length-1;a++)l.push(i.readDict(e,t+u[a],t+u[a+1]));t+=u[u.length-1];var h=l[0],c=[];t=i.readIndex(e,t,c);var d=[];for(a=0;a<c.length-1;a++)d.push(n.readASCII(e,t+c[a],c[a+1]-c[a]));if(t+=c[c.length-1],i.readSubrs(e,t,h),h.CharStrings&&(h.CharStrings=i.readBytes(e,h.CharStrings)),h.ROS){t=h.FDArray;var p=[];t=i.readIndex(e,t,p),h.FDArray=[];for(a=0;a<p.length-1;a++){var f=i.readDict(e,t+p[a],t+p[a+1]);i._readFDict(e,f,d),h.FDArray.push(f)}t+=p[p.length-1],t=h.FDSelect,h.FDSelect=[];var m=e[t];if(t++,3!=m)throw m;var g=n.readUshort(e,t);t+=2;for(a=0;a<g+1;a++)h.FDSelect.push(n.readUshort(e,t),e[t+2]),t+=3}return h.charset&&(h.charset=i.readCharset(e,h.charset,h.CharStrings.length)),i._readFDict(e,h,d),h},_readFDict:function(e,t,r){var n,i=wv.T.CFF;for(var s in t.Private&&(n=t.Private[1],t.Private=i.readDict(e,n,n+t.Private[0]),t.Private.Subrs&&i.readSubrs(e,n+t.Private.Subrs,t.Private)),t)-1!=["FamilyName","FontName","FullName","Notice","version","Copyright"].indexOf(s)&&(t[s]=r[t[s]-426+35])},readSubrs:function(e,t,r){r.Subrs=wv.T.CFF.readBytes(e,t);var n,i=r.Subrs.length+1;n=i<1240?107:i<33900?1131:32768,r.Bias=n},readBytes:function(e,t){var r=[];t=wv.T.CFF.readIndex(e,t,r);for(var n=[],i=r.length-1,s=e.byteOffset+t,o=0;o<i;o++){var a=r[o];n.push(new Uint8Array(e.buffer,s+a,r[o+1]-a))}return n},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(e,t){for(var r=0;r<e.charset.length;r++)if(e.charset[r]==t)return r;return-1},glyphBySE:function(e,t){return t<0||t>255?-1:wv.T.CFF.glyphByUnicode(e,wv.T.CFF.tableSE[t])},readCharset:function(e,t,r){var n=wv.B,i=[".notdef"],s=e[t];if(t++,0==s)for(var o=0;o<r;o++){var a=n.readUshort(e,t);t+=2,i.push(a)}else{if(1!=s&&2!=s)throw"error: format: "+s;for(;i.length<r;){a=n.readUshort(e,t);t+=2;var u=0;1==s?(u=e[t],t++):(u=n.readUshort(e,t),t+=2);for(o=0;o<=u;o++)i.push(a),a++}}return i},readIndex:function(e,t,r){var n=wv.B,i=n.readUshort(e,t)+1,s=e[t+=2];if(t++,1==s)for(var o=0;o<i;o++)r.push(e[t+o]);else if(2==s)for(o=0;o<i;o++)r.push(n.readUshort(e,t+2*o));else if(3==s)for(o=0;o<i;o++)r.push(16777215&n.readUint(e,t+3*o-1));else if(4==s)for(o=0;o<i;o++)r.push(n.readUint(e,t+4*o));else if(1!=i)throw"unsupported offset size: "+s+", count: "+i;return(t+=i*s)-1},getCharString:function(e,t,r){var n=wv.B,i=e[t],s=e[t+1],o=1,a=null,u=null;i<=20&&(a=i,o=1),12==i&&(a=100*i+s,o=2),21<=i&&i<=27&&(a=i,o=1),28==i&&(u=n.readShort(e,t+1),o=3),29<=i&&i<=31&&(a=i,o=1),32<=i&&i<=246&&(u=i-139,o=1),247<=i&&i<=250&&(u=256*(i-247)+s+108,o=2),251<=i&&i<=254&&(u=256*-(i-251)-s-108,o=2),255==i&&(u=n.readInt(e,t+1)/65535,o=5),r.val=null!=u?u:"o"+a,r.size=o},readCharString:function(e,t,r){for(var n=t+r,i=wv.B,s=[];t<n;){var o=e[t],a=e[t+1],u=1,l=null,h=null;o<=20&&(l=o,u=1),12==o&&(l=100*o+a,u=2),19!=o&&20!=o||(l=o,u=2),21<=o&&o<=27&&(l=o,u=1),28==o&&(h=i.readShort(e,t+1),u=3),29<=o&&o<=31&&(l=o,u=1),32<=o&&o<=246&&(h=o-139,u=1),247<=o&&o<=250&&(h=256*(o-247)+a+108,u=2),251<=o&&o<=254&&(h=256*-(o-251)-a-108,u=2),255==o&&(h=i.readInt(e,t+1)/65535,u=5),s.push(null!=h?h:"o"+l),t+=u}return s},readDict:function(e,t,r){for(var n=wv.B,i={},s=[];t<r;){var o=e[t],a=e[t+1],u=1,l=null,h=null;if(28==o&&(h=n.readShort(e,t+1),u=3),29==o&&(h=n.readInt(e,t+1),u=5),32<=o&&o<=246&&(h=o-139,u=1),247<=o&&o<=250&&(h=256*(o-247)+a+108,u=2),251<=o&&o<=254&&(h=256*-(o-251)-a-108,u=2),255==o)throw h=n.readInt(e,t+1)/65535,u=5,"unknown number";if(30==o){var c=[];for(u=1;;){var d=e[t+u];u++;var p=d>>4,f=15&d;if(15!=p&&c.push(p),15!=f&&c.push(f),15==f)break}for(var m="",g=[0,1,2,3,4,5,6,7,8,9,".","e","e-","reserved","-","endOfNumber"],y=0;y<c.length;y++)m+=g[c[y]];h=parseFloat(m)}if(o<=21)if(l=["version","Notice","FullName","FamilyName","Weight","FontBBox","BlueValues","OtherBlues","FamilyBlues","FamilyOtherBlues","StdHW","StdVW","escape","UniqueID","XUID","charset","Encoding","CharStrings","Private","Subrs","defaultWidthX","nominalWidthX"][o],u=1,12==o)l=["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"][a],u=2;null!=l?(i[l]=1==s.length?s[0]:s,s=[]):s.push(h),t+=u}return i}},wv.T.cmap={parseTab:function(e,t,r){var n={tables:[],ids:{},off:t};e=new Uint8Array(e.buffer,t,r),t=0;var i=wv.B,s=i.readUshort,o=wv.T.cmap;s(e,t);var a=s(e,t+=2);t+=2;for(var u=[],l=0;l<a;l++){var h=s(e,t),c=s(e,t+=2);t+=2;var d=i.readUint(e,t);t+=4;var p="p"+h+"e"+c,f=u.indexOf(d);if(-1==f){f=n.tables.length;var m={};u.push(d);var g=m.format=s(e,d);0==g?m=o.parse0(e,d,m):4==g?m=o.parse4(e,d,m):6==g?m=o.parse6(e,d,m):12==g&&(m=o.parse12(e,d,m)),n.tables.push(m)}null!=n.ids[p]&&console.log("multiple tables for one platform+encoding: "+p),n.ids[p]=f}return n},parse0:function(e,t,r){var n=wv.B;t+=2;var i=n.readUshort(e,t);t+=2,n.readUshort(e,t),t+=2,r.map=[];for(var s=0;s<i-6;s++)r.map.push(e[t+s]);return r},parse4:function(e,t,r){var n=wv.B,i=n.readUshort,s=n.readUshorts,o=t,a=i(e,t+=2);i(e,t+=2);var u=i(e,t+=2);t+=2;var l=u>>>1;r.searchRange=i(e,t),t+=2,r.entrySelector=i(e,t),t+=2,r.rangeShift=i(e,t),t+=2,r.endCount=s(e,t,l),t+=2*l,t+=2,r.startCount=s(e,t,l),t+=2*l,r.idDelta=[];for(var h=0;h<l;h++)r.idDelta.push(n.readShort(e,t)),t+=2;return r.idRangeOffset=s(e,t,l),t+=2*l,r.glyphIdArray=s(e,t,o+a-t>>1),r},parse6:function(e,t,r){var n=wv.B;t+=2,n.readUshort(e,t),t+=2,n.readUshort(e,t),t+=2,r.firstCode=n.readUshort(e,t),t+=2;var i=n.readUshort(e,t);t+=2,r.glyphIdArray=[];for(var s=0;s<i;s++)r.glyphIdArray.push(n.readUshort(e,t)),t+=2;return r},parse12:function(e,t,r){var n=wv.B.readUint;n(e,t+=4),n(e,t+=4);var i=3*n(e,t+=4);t+=4;for(var s=r.groups=new Uint32Array(i),o=0;o<i;o+=3)s[o]=n(e,t+(o<<2)),s[o+1]=n(e,t+(o<<2)+4),s[o+2]=n(e,t+(o<<2)+8);return r}},wv.T.CBLC={parseTab:function(e,t,r){var n=wv.B,i=t;n.readUshort(e,t),t+=2,n.readUshort(e,t),t+=2;var s=n.readUint(e,t);t+=4;for(var o=[],a=0;a<s;a++){var u=n.readUint(e,t);t+=4,n.readUint(e,t),t+=4,n.readUint(e,t),t+=4,t+=4,t+=24,n.readUshort(e,t),t+=2,n.readUshort(e,t),t+=2,t+=4;for(var l=i+u,h=0;h<3;h++){var c=n.readUshort(e,l);l+=2;var d=n.readUshort(e,l);l+=2;var p=n.readUint(e,l);l+=4;var f=d-c+1,m=i+u+p,g=n.readUshort(e,m);if(m+=2,1!=g)throw g;var y=n.readUshort(e,m);m+=2;var v=n.readUint(e,m);m+=4;for(var b=[],x=0;x<f;x++){var _=n.readUint(e,m+4*x);b.push(v+_)}o.push([c,d,y,b])}}return o}},wv.T.CBDT={parseTab:function(e,t,r){return new Uint8Array(e.buffer,e.byteOffset+t,r)}},wv.T.glyf={parseTab:function(e,t,r,n){for(var i=[],s=n.maxp.numGlyphs,o=0;o<s;o++)i.push(null);return i},_parseGlyf:function(e,t){var r=wv.B,n=e._data,i=e.loca;if(i[t]==i[t+1])return null;var s=wv.findTable(n,"glyf",e._offset)[0]+i[t],o={};if(o.noc=r.readShort(n,s),s+=2,o.xMin=r.readShort(n,s),s+=2,o.yMin=r.readShort(n,s),s+=2,o.xMax=r.readShort(n,s),s+=2,o.yMax=r.readShort(n,s),s+=2,o.xMin>=o.xMax||o.yMin>=o.yMax)return null;if(o.noc>0){o.endPts=[];for(var a=0;a<o.noc;a++)o.endPts.push(r.readUshort(n,s)),s+=2;var u=r.readUshort(n,s);if(s+=2,n.length-s<u)return null;o.instructions=r.readBytes(n,s,u),s+=u;var l=o.endPts[o.noc-1]+1;o.flags=[];for(a=0;a<l;a++){var h=n[s];if(s++,o.flags.push(h),8&h){var c=n[s];s++;for(var d=0;d<c;d++)o.flags.push(h),a++}}o.xs=[];for(a=0;a<l;a++){var p=!!(2&o.flags[a]),f=!!(16&o.flags[a]);p?(o.xs.push(f?n[s]:-n[s]),s++):f?o.xs.push(0):(o.xs.push(r.readShort(n,s)),s+=2)}o.ys=[];for(a=0;a<l;a++){p=!!(4&o.flags[a]),f=!!(32&o.flags[a]);p?(o.ys.push(f?n[s]:-n[s]),s++):f?o.ys.push(0):(o.ys.push(r.readShort(n,s)),s+=2)}var m=0,g=0;for(a=0;a<l;a++)m+=o.xs[a],g+=o.ys[a],o.xs[a]=m,o.ys[a]=g}else{var y;o.parts=[];do{y=r.readUshort(n,s),s+=2;var v={m:{a:1,b:0,c:0,d:1,tx:0,ty:0},p1:-1,p2:-1};if(o.parts.push(v),v.glyphIndex=r.readUshort(n,s),s+=2,1&y){var b=r.readShort(n,s);s+=2;var x=r.readShort(n,s);s+=2}else{b=r.readInt8(n,s);s++;x=r.readInt8(n,s);s++}2&y?(v.m.tx=b,v.m.ty=x):(v.p1=b,v.p2=x),8&y?(v.m.a=v.m.d=r.readF2dot14(n,s),s+=2):64&y?(v.m.a=r.readF2dot14(n,s),s+=2,v.m.d=r.readF2dot14(n,s),s+=2):128&y&&(v.m.a=r.readF2dot14(n,s),s+=2,v.m.b=r.readF2dot14(n,s),s+=2,v.m.c=r.readF2dot14(n,s),s+=2,v.m.d=r.readF2dot14(n,s),s+=2)}while(32&y);if(256&y){var _=r.readUshort(n,s);s+=2,o.instr=[];for(a=0;a<_;a++)o.instr.push(n[s]),s++}}return o}},wv.T.head={parseTab:function(e,t,r){var n=wv.B,i={};return n.readFixed(e,t),t+=4,i.fontRevision=n.readFixed(e,t),t+=4,n.readUint(e,t),t+=4,n.readUint(e,t),t+=4,i.flags=n.readUshort(e,t),t+=2,i.unitsPerEm=n.readUshort(e,t),t+=2,i.created=n.readUint64(e,t),t+=8,i.modified=n.readUint64(e,t),t+=8,i.xMin=n.readShort(e,t),t+=2,i.yMin=n.readShort(e,t),t+=2,i.xMax=n.readShort(e,t),t+=2,i.yMax=n.readShort(e,t),t+=2,i.macStyle=n.readUshort(e,t),t+=2,i.lowestRecPPEM=n.readUshort(e,t),t+=2,i.fontDirectionHint=n.readShort(e,t),t+=2,i.indexToLocFormat=n.readShort(e,t),t+=2,i.glyphDataFormat=n.readShort(e,t),t+=2,i}},wv.T.hhea={parseTab:function(e,t,r){var n=wv.B,i={};n.readFixed(e,t),t+=4;for(var s=["ascender","descender","lineGap","advanceWidthMax","minLeftSideBearing","minRightSideBearing","xMaxExtent","caretSlopeRise","caretSlopeRun","caretOffset","res0","res1","res2","res3","metricDataFormat","numberOfHMetrics"],o=0;o<s.length;o++){var a=s[o],u="advanceWidthMax"==a||"numberOfHMetrics"==a?n.readUshort:n.readShort;i[a]=u(e,t+2*o)}return i}},wv.T.hmtx={parseTab:function(e,t,r,n){for(var i=wv.B,s=[],o=[],a=n.maxp.numGlyphs,u=n.hhea.numberOfHMetrics,l=0,h=0,c=0;c<u;)l=i.readUshort(e,t+(c<<2)),h=i.readShort(e,t+(c<<2)+2),s.push(l),o.push(h),c++;for(;c<a;)s.push(l),o.push(h),c++;return{aWidth:s,lsBearing:o}}},wv.T.kern={parseTab:function(e,t,r,n){var i=wv.B,s=wv.T.kern;if(1==i.readUshort(e,t))return s.parseV1(e,t,r,n);var o=i.readUshort(e,t+2);t+=4;for(var a={glyph1:[],rval:[]},u=0;u<o;u++){t+=2;r=i.readUshort(e,t);t+=2;var l=i.readUshort(e,t);t+=2;var h=l>>>8;0==(h&=15)&&(t=s.readFormat0(e,t,a))}return a},parseV1:function(e,t,r,n){var i=wv.B,s=wv.T.kern;i.readFixed(e,t);var o=i.readUint(e,t+4);t+=8;for(var a={glyph1:[],rval:[]},u=0;u<o;u++){i.readUint(e,t),t+=4;var l=i.readUshort(e,t);t+=2,i.readUshort(e,t),t+=2,0==(255&l)&&(t=s.readFormat0(e,t,a))}return a},readFormat0:function(e,t,r){var n=wv.B,i=n.readUshort,s=-1,o=i(e,t);i(e,t+2),i(e,t+4),i(e,t+6),t+=8;for(var a=0;a<o;a++){var u=i(e,t),l=i(e,t+=2);t+=2;var h=n.readShort(e,t);t+=2,u!=s&&(r.glyph1.push(u),r.rval.push({glyph2:[],vals:[]}));var c=r.rval[r.rval.length-1];c.glyph2.push(l),c.vals.push(h),s=u}return t}},wv.T.loca={parseTab:function(e,t,r,n){var i=wv.B,s=[],o=n.head.indexToLocFormat,a=n.maxp.numGlyphs+1;if(0==o)for(var u=0;u<a;u++)s.push(i.readUshort(e,t+(u<<1))<<1);if(1==o)for(u=0;u<a;u++)s.push(i.readUint(e,t+(u<<2)));return s}},wv.T.maxp={parseTab:function(e,t,r){var n=wv.B,i=n.readUshort,s={};return n.readUint(e,t),t+=4,s.numGlyphs=i(e,t),t+=2,s}},wv.T.name={parseTab:function(e,t,r){var n=wv.B,i={};n.readUshort(e,t),t+=2;var s=n.readUshort(e,t);t+=2;for(var o=n.readUshort(e,t),a=(t+=2)-6+o,u=["copyright","fontFamily","fontSubfamily","ID","fullName","version","postScriptName","trademark","manufacturer","designer","description","urlVendor","urlDesigner","licence","licenceURL","---","typoFamilyName","typoSubfamilyName","compatibleFull","sampleText","postScriptCID","wwsFamilyName","wwsSubfamilyName","lightPalette","darkPalette"],l=n.readUshort,h=0;h<s;h++){var c=l(e,t),d=l(e,t+=2),p=l(e,t+=2),f=l(e,t+=2),m=l(e,t+=2),g=l(e,t+=2);t+=2;var y,v=a+g;0==c||3==c&&0==d||1==c&&25==d?y=n.readUnicode(e,v,m/2):0==d?y=n.readASCII(e,v,m):1==d||3==d||4==d||5==d||10==d?y=n.readUnicode(e,v,m/2):1==c?(y=n.readASCII(e,v,m),console.log("reading unknown MAC encoding "+d+" as ASCII")):(console.log("unknown encoding "+d+", platformID: "+c),y=n.readASCII(e,v,m));var b="p"+c+","+p.toString(16);null==i[b]&&(i[b]={});var x=u[f];null==x&&(x="_"+f),i[b][x]=y,i[b]._lang=p}var _=wv.T.name.selectOne(i),w="fontFamily";if(null==_[w])for(var C in i)null!=i[C][w]&&(_[w]=i[C][w]);return _},selectOne:function(e){var t,r="postScriptName";for(var n in e)if(null!=e[n][r]&&1033==e[n]._lang)return e[n];for(var n in e)if(null!=e[n][r]&&0==e[n]._lang)return e[n];for(var n in e)if(null!=e[n][r]&&3084==e[n]._lang)return e[n];for(var n in e)if(null!=e[n][r])return e[n];for(var n in e){t=e[n];break}return console.log("returning name table with languageID "+t._lang),null==t[r]&&null!=t.ID&&(t[r]=t.ID),t}},wv.T.OS2={parseTab:function(e,t,r){var n=wv.B.readUshort(e,t);t+=2;var i=wv.T.OS2,s={};if(0==n)i.version0(e,t,s);else if(1==n)i.version1(e,t,s);else if(2==n||3==n||4==n)i.version2(e,t,s);else{if(5!=n)throw"unknown OS/2 table version: "+n;i.version5(e,t,s)}return s},version0:function(e,t,r){var n=wv.B;return r.xAvgCharWidth=n.readShort(e,t),t+=2,r.usWeightClass=n.readUshort(e,t),t+=2,r.usWidthClass=n.readUshort(e,t),t+=2,r.fsType=n.readUshort(e,t),t+=2,r.ySubscriptXSize=n.readShort(e,t),t+=2,r.ySubscriptYSize=n.readShort(e,t),t+=2,r.ySubscriptXOffset=n.readShort(e,t),t+=2,r.ySubscriptYOffset=n.readShort(e,t),t+=2,r.ySuperscriptXSize=n.readShort(e,t),t+=2,r.ySuperscriptYSize=n.readShort(e,t),t+=2,r.ySuperscriptXOffset=n.readShort(e,t),t+=2,r.ySuperscriptYOffset=n.readShort(e,t),t+=2,r.yStrikeoutSize=n.readShort(e,t),t+=2,r.yStrikeoutPosition=n.readShort(e,t),t+=2,r.sFamilyClass=n.readShort(e,t),t+=2,r.panose=n.readBytes(e,t,10),t+=10,r.ulUnicodeRange1=n.readUint(e,t),t+=4,r.ulUnicodeRange2=n.readUint(e,t),t+=4,r.ulUnicodeRange3=n.readUint(e,t),t+=4,r.ulUnicodeRange4=n.readUint(e,t),t+=4,r.achVendID=n.readASCII(e,t,4),t+=4,r.fsSelection=n.readUshort(e,t),t+=2,r.usFirstCharIndex=n.readUshort(e,t),t+=2,r.usLastCharIndex=n.readUshort(e,t),t+=2,r.sTypoAscender=n.readShort(e,t),t+=2,r.sTypoDescender=n.readShort(e,t),t+=2,r.sTypoLineGap=n.readShort(e,t),t+=2,r.usWinAscent=n.readUshort(e,t),t+=2,r.usWinDescent=n.readUshort(e,t),t+=2},version1:function(e,t,r){var n=wv.B;return t=wv.T.OS2.version0(e,t,r),r.ulCodePageRange1=n.readUint(e,t),t+=4,r.ulCodePageRange2=n.readUint(e,t),t+=4},version2:function(e,t,r){var n=wv.B,i=n.readUshort;return t=wv.T.OS2.version1(e,t,r),r.sxHeight=n.readShort(e,t),t+=2,r.sCapHeight=n.readShort(e,t),t+=2,r.usDefault=i(e,t),t+=2,r.usBreak=i(e,t),t+=2,r.usMaxContext=i(e,t),t+=2},version5:function(e,t,r){var n=wv.B.readUshort;return t=wv.T.OS2.version2(e,t,r),r.usLowerOpticalPointSize=n(e,t),t+=2,r.usUpperOpticalPointSize=n(e,t),t+=2}},wv.T.post={parseTab:function(e,t,r){var n=wv.B,i={};return i.version=n.readFixed(e,t),t+=4,i.italicAngle=n.readFixed(e,t),t+=4,i.underlinePosition=n.readShort(e,t),t+=2,i.underlineThickness=n.readShort(e,t),t+=2,i}},wv.T.SVG={parseTab:function(e,t,r){var n=wv.B,i={entries:[],svgs:[]},s=t;n.readUshort(e,t),t+=2;var o=n.readUint(e,t);t+=4,n.readUint(e,t),t+=4,t=o+s;var a=n.readUshort(e,t);t+=2;for(var u=0;u<a;u++){var l=n.readUshort(e,t);t+=2;var h=n.readUshort(e,t);t+=2;var c=n.readUint(e,t);t+=4;var d=n.readUint(e,t);t+=4;var p=new Uint8Array(e.buffer,s+c+o,d);31==p[0]&&139==p[1]&&8==p[2]&&(p=xv.inflate(p));for(var f=n.readUTF8(p,0,p.length),m=l;m<=h;m++)i.entries[m]=i.svgs.length;i.svgs.push(f)}return i}},wv.T.sbix={parseTab:function(e,t,r,n){for(var i=n.maxp.numGlyphs,s=t,o=wv.B,a=o.readUint(e,t+4),u=[],l=a-1;l<a;l++)for(var h=s+o.readUint(e,t+8+4*l),c=0;c<i;c++){var d=o.readUint(e,h+4+4*c),p=o.readUint(e,h+4+4*c+4);if(d!=p){var f=h+d,m=o.readASCII(e,f+4,4);if("png "!=m)throw m;u[c]=new Uint8Array(e.buffer,e.byteOffset+f+8,p-d-8)}else u[c]=null}return u}},wv.T.colr={parseTab:function(e,t,r){var n=wv.B,i=t;t+=2;var s=n.readUshort(e,t);t+=2;var o=n.readUint(e,t);t+=4;var a=n.readUint(e,t);t+=4;var u=n.readUshort(e,t);t+=2;for(var l={},h=i+o,c=0;c<s;c++)l["g"+n.readUshort(e,h)]=[n.readUshort(e,h+2),n.readUshort(e,h+4)],h+=6;var d=[];h=i+a;for(c=0;c<u;c++)d.push(n.readUshort(e,h),n.readUshort(e,h+2)),h+=4;return[l,d]}},wv.T.cpal={parseTab:function(e,t,r){var n=wv.B,i=t,s=n.readUshort(e,t);if(t+=2,0==s){n.readUshort(e,t),t+=2,n.readUshort(e,t),t+=2;var o=n.readUshort(e,t);t+=2;var a=n.readUint(e,t);return t+=4,new Uint8Array(e.buffer,i+a,4*o)}throw s}},wv.T.GSUB={parseTab:function(e,t,r,n){var i=wv.B,s=i.readUshort,o=t;s(e,o),s(e,o+=2),s(e,o+=2);var a=s(e,o+=2);s(e,o+=2),o+=2;var u={},l=s(e,o=t+a);o+=2;for(var h=0;h<l;h++){var c=i.readASCII(e,o,4);s(e,o+=4),o+=2,u[c]=!0}return u}},wv.T.fvar={parseTab:function(e,t,r,n){var i=n.name,s=t,o=wv.B,a=[],u=[];s+=8;var l=o.readUshort(e,s);s+=2,s+=2;var h=o.readUshort(e,s);s+=2;var c=o.readUshort(e,s);s+=2;for(var d=0;d<l;d++){var p=o.readASCII(e,s,4),f=o.readFixed(e,s+4),m=o.readFixed(e,s+8),g=o.readFixed(e,s+12),y=o.readUshort(e,s+16),v=o.readUshort(e,s+18);a.push([p,f,m,g,y,i["_"+v]]),s+=20}for(d=0;d<h;d++){for(var b=o.readUshort(e,s),x=null,_=(y=o.readUshort(e,s+2),[]),w=0;w<l;w++)_.push(o.readFixed(e,s+4+4*w));s+=4+4*l,2==(3&c)&&(x=o.readUshort(e,s),s+=2),u.push([i["_"+b],y,_,x])}return[a,u]}},wv.T.gvar=function(){var e=wv.B;function t(t,r,n){for(var i=[],s=0;s<n;s++)i.push(e.readF2dot14(t,r+2*s));return i}function r(r,n,i,s,o){for(var a=[],u=0;u<i;u++){var l=e.readUshort(r,n);n+=2;var h=e.readUshort(r,n),c=61440&h;h&=4095,n+=2;var d=null,p=null,f=null;32768&c&&(d=t(r,n,s),n+=2*s),16384&c&&(p=t(r,n,s),n+=2*s),16384&c&&(f=t(r,n,s),n+=2*s),a.push([l,h,c,p,d,f])}return a}function n(t,r,n){var i=t[r];if(r++,0==i)return[[],r];127<i&&(i=(127&i)<<8|t[r++]);for(var s=[],o=0;s.length<i;){var a=t[r];r++;var u=!!(128&a);a=1+(127&a);for(var l=0;l<a;l++){var h=0;u?(h=e.readUshort(t,r),r+=2):(h=t[r],r++),o+=h,s.push(o)}}return[s,r]}return{parseTab:function(i,s,o,a){var u=s+4,l=e.readUshort(i,u);u+=2;var h=e.readUshort(i,u);u+=2;var c=e.readUint(i,u);u+=4;var d=e.readUshort(i,u);u+=2,e.readUshort(i,u),u+=2;var p=e.readUint(i,u);u+=4;for(var f=[],m=0;m<d+1;m++)f.push(e.readUint(i,u+4*m));var g=[],y=[],v=[];for(u=s+c,m=0;m<h;m++){var b=t(i,u+m*l*2,l),x=[],_=[];g.push(b),y.push(x),v.push(_);for(var w=0;w<l;w++)x[w]=Math.min(b[w],0),_[w]=Math.max(b[w],0)}var C=new Int8Array(i.buffer),E=[];for(m=0;m<d;m++){u=s+p+f[m];var S=e.readUshort(i,u);u+=2;var A=32768&S;S&=4095;var D=e.readUshort(i,u),T=r(i,u+=2,S,l),F=[];E.push(F),u=s+p+f[m]+D;var I=null;if(A)I=(N=n(i,u))[0],u=N[1];for(var k=0;k<S;k++){var N,M=T[k],O=u+M[0],B=I;if(8192&M[2])B=(N=n(i,u))[0],u=N[1];for(var L=[];u<O;){var P=i[u++],R=1+(63&P);if(128&P)for(w=0;w<R;w++)L.push(0);else if(64&P){for(w=0;w<R;w++)L.push(e.readShort(i,u+2*w));u+=2*R}else{for(w=0;w<R;w++)L.push(C[u+w]);u+=R}}var V=M[1];if(F.push([[M[3]?M[3]:y[V],M[4]?M[4]:g[V],M[5]?M[5]:v[V]],L,0==B.length?null:B]),0!=B.length&&2*B.length!=L.length)throw"e"}}return E}}}(),wv.T.avar={parseTab:function(e,t,r,n){var i=t,s=wv.B,o=[];i+=6;var a=s.readUshort(e,i);i+=2;for(var u=0;u<a;u++){var l=s.readUshort(e,i);i+=2;var h=[];o.push(h);for(var c=0;c<l;c++){var d=s.readF2dot14(e,i),p=s.readF2dot14(e,i+2);i+=4,h.push(d,p)}}return o}},wv.T.HVAR={parseTab:function(e,t,r,n){var i=t,s=t,o=wv.B;i+=4;var a=o.readUint(e,i);i+=4;var u=o.readUint(e,i);i+=4;var l=o.readUint(e,i);i+=4;var h=o.readUint(e,i);if(i+=4,0!=l||0!=h)throw l;var c=i=s+a,d=o.readUshort(e,i);if(i+=2,1!=d)throw"e";var p=o.readUint(e,i);i+=4;var f=o.readUshort(e,i);i+=2;for(var m=[],g=0;g<f;g++)m.push(o.readUint(e,i+4*g));i+=4*f,i=c+p;var y=o.readUshort(e,i);i+=2;var v=o.readUshort(e,i);i+=2;var b=[];for(g=0;g<v;g++){var x=[[],[],[]];b.push(x);for(var _=0;_<y;_++)x[0].push(o.readF2dot14(e,i+0)),x[1].push(o.readF2dot14(e,i+2)),x[2].push(o.readF2dot14(e,i+4)),i+=6}var w=new Int8Array(e.buffer),C=[];for(g=0;g<m.length;g++){i=s+a+m[g];var E=[];C.push(E);var S=o.readUshort(e,i);i+=2;var A=o.readUshort(e,i);if(i+=2,32768&A)throw"e";v=o.readUshort(e,i);i+=2;var D=[];for(_=0;_<v;_++)D.push(o.readUshort(e,i+2*_));i+=2*v;for(var T=0;T<S;T++){for(var F=[],I=0;I<v;I++)F.push(I<A?o.readShort(e,i):w[i]),i+=I<A?2:1;var k=new Array(b.length);k.fill(0),E.push(k);for(_=0;_<D.length;_++)k[D[_]]=F[_]}}if(i=s+u,0!=(d=e[i++]))throw"e";var N=e[i++],M=o.readUshort(e,i);i+=2;var O=1+((48&N)>>4),B=[];for(g=0;g<M;g++){var L=0;1==O?L=e[i++]:(L=o.readUshort(e,i),i+=2);var P=L>>1+(15&N),R=L&(1<<1+(15&N))-1;B.push(C[P][R])}return[b,B]}},wv.U=function(){var e=function(e,t,r){e.cmds.push("M"),e.crds.push(t,r)},t=function(e,t,r){e.cmds.push("L"),e.crds.push(t,r)},r=function(e,t,r,n,i,s,o){e.cmds.push("C"),e.crds.push(t,r,n,i,s,o)},n=function(e,t,r,n,i){e.cmds.push("Q"),e.crds.push(t,r,n,i)},i=function(e){e.cmds.push("Z")};function s(e,t,r,n){var i=t[r],s=t[r+1],o=e.kern;if(o){var a=o.glyph1.indexOf(i);if(-1!=a){var u=o.rval[a].glyph2.indexOf(s);if(-1!=u)return[0,0,o.rval[a].vals[u],0]}}return[0,0,0,0]}function o(e,t,r){for(var n=0,i=~~(e.length/t);n+1!=i;){var s=n+(i-n>>>1);e[s*t]<=r?n=s:i=s}return n*t}for(var a,u,l=[9,10,11,12,13,32,133,160,5760,6158,8232,8233,8239,8288,12288,65279],h={},c=0;c<l.length;c++)h[l[c]]=1;for(c=8192;c<=8205;c++)h[c]=1;function d(e,t){if(null==e._ctab){for(var r=e.cmap,n=-1,i=["p3e10","p0e4","p3e1","p1e0","p0e3","p0e1","p3e0","p3e5"],s=0;s<i.length;s++)if(null!=r.ids[i[s]]){n=r.ids[i[s]];break}if(-1==n)throw"no familiar platform and encoding!";e._ctab=r.tables[n]}var a=e._ctab,u=a.format,l=-1;if(0==u)l=t>=a.map.length?0:a.map[t];else if(4==u){var c=a.endCount;if(l=0,t<=c[c.length-1]){var d=o(c,1,t);if(c[d]<t&&d++,t>=a.startCount[d]){l=65535&(0!=a.idRangeOffset[d]?a.glyphIdArray[t-a.startCount[d]+(a.idRangeOffset[d]>>1)-(a.idRangeOffset.length-d)]:t+a.idDelta[d])}}}else if(6==u){var p=t-a.firstCode,f=a.glyphIdArray;l=p<0||p>=f.length?0:f[p]}else{if(12!=u)throw"unknown cmap table format "+a.format;var m=a.groups;l=0,t<=m[m.length-2]&&m[s=o(m,3,t)]<=t&&t<=m[s+1]&&(l=m[s+2]+(t-m[s]))}var g=e["SVG "],y=e.loca;return 0==l||null!=e["CFF "]||null!=g&&null!=g.entries[l]||!y||y[l]!=y[l+1]||null!=h[t]||(l=0),l}function p(e,t,r,n){var i={cmds:[],crds:[]};e.fvar&&(null==n&&(n=e.fvar[1][e._index][2]),n=g(e,n));var s=e["SVG "],o=e["CFF "],a=e.COLR,u=e.CBLC,l=e.CBDT,h=e.sbix,c=window.UPNG,d=null;if(u&&c)for(var m=0;m<u.length;m++)u[m][0]<=t&&t<=u[m][1]&&(d=u[m]);if(d||h&&h[t]){if(d&&17!=d[2])throw"not a PNG";null==e.__tmp&&(e.__tmp={});var y=e.__tmp["g"+t];if(null==y){var v,x;if(h)x=(v=h[t]).length;else{var _=d[3][t-d[0]]+5;x=l[_+1]<<16|l[_+2]<<8|l[_+3],_+=4,v=new Uint8Array(l.buffer,l.byteOffset+_,x)}var w="";for(m=0;m<x;m++)w+=String.fromCharCode(v[m]);y=e.__tmp["g"+t]="data:image/png;base64,"+btoa(w)}i.cmds.push(y);var C=1.15*e.head.unitsPerEm,E=Math.round(C),S=Math.round(C),A=Math.round(.15*-S);i.crds.push(0,S+A,E,S+A,E,A,0,A)}else if(s&&s.entries[t]){var D=s.entries[t];if(null!=D){if("number"==typeof D){var T=s.svgs[D];if("string"==typeof T){var F=(new DOMParser).parseFromString(T,"image/svg+xml");T=s.svgs[D]=F.getElementsByTagName("svg")[0]}D=wv.U.SVG.toPath(T,t),s.entries[t]=D}i=D}}else if(1!=r&&a&&a[0]["g"+t]&&a[0]["g"+t][1]>1){function U(e){var t=e.toString(16);return(1==t.length?"0":"")+t}var I=e.CPAL,k=a[0]["g"+t];for(m=0;m<k[1];m++){var N=k[0]+m,M=a[1][2*N],O=4*a[1][2*N+1],B=p(e,M,M==t),L="#"+U(I[O+2])+U(I[O+1])+U(I[O+0]);i.cmds.push(L),i.cmds=i.cmds.concat(B.cmds),i.crds=i.crds.concat(B.crds),i.cmds.push("X")}}else if(o){var P=o.Private,R={x:0,y:0,stack:[],nStems:0,haveWidth:!1,width:P?P.defaultWidthX:0,open:!1};if(o.ROS){for(var V=0;o.FDSelect[V+2]<=t;)V+=2;P=o.FDArray[o.FDSelect[V+1]].Private}b(o.CharStrings[t],R,o,P,i)}else e.glyf&&f(t,e,i,n);return{cmds:i.cmds,crds:i.crds}}function f(r,s,o,a){var u=s.glyf[r];null==u&&(u=s.glyf[r]=wv.T.glyf._parseGlyf(s,r)),null!=u&&(u.noc>-1?function(r,s,o,a,u){var l=r.xs,h=r.ys;if(s.fvar&&u){l=l.slice(0),h=h.slice(0);for(var c=s.gvar,d=c?c[o]:null,p=0;p<d.length;p++){var f=m(d[p][0],u);if(!(f<1e-9)){var g=d[p][1],v=d[p][2];if(v&&(g=d[p][1]=y(g,v,l,h,r.endPts),d[p][2]=null),g.length==2*l.length+8)for(var b=0;b<l.length;b++)l[b]+=f*g[b],h[b]+=f*g[b+l.length+4]}}}for(var x=0;x<r.noc;x++){var _=0==x?0:r.endPts[x-1]+1,w=r.endPts[x];for(b=_;b<=w;b++){var C=b==_?w:b-1,E=b==w?_:b+1,S=1&r.flags[b],A=1&r.flags[C],D=1&r.flags[E],T=l[b],F=h[b];if(b==_)if(S){if(!A){e(a,T,F);continue}e(a,l[C],h[C])}else A?e(a,l[C],h[C]):e(a,Math.floor(.5*(l[C]+T)),Math.floor(.5*(h[C]+F)));S?A&&t(a,T,F):D?n(a,T,F,l[E],h[E]):n(a,T,F,Math.floor(.5*(T+l[E])),Math.floor(.5*(F+h[E])))}i(a)}}(u,s,r,o,a):function(e,t,r,n,i){var s=[0,0,0,0,0,0],o=[0,0,0,0,0,0],a=e.parts.length;if(t.fvar&&i)for(var u=t.gvar,l=u?u[r]:null,h=0;h<l.length;h++){var c=m(l[h][0],i);if(!(c<1e-6)){var d=l[h][1],p=l[h][2];if(null==p)for(var g=0;g<a;g++)s[g]+=c*d[g],o[g]+=c*d[g+a+4];else for(var y=0;y<p.length;y++){s[g=p[y]]+=c*d[0],o[g]+=c*d[0+a]}}}for(y=0;y<a;y++){var v={cmds:[],crds:[]},b=e.parts[y];f(b.glyphIndex,t,v,i);var x=b.m,_=x.tx+s[y],w=x.ty+o[y];for(g=0;g<v.crds.length;g+=2){var C=v.crds[g],E=v.crds[g+1];n.crds.push(C*x.a+E*x.c+_),n.crds.push(C*x.b+E*x.d+w)}for(g=0;g<v.cmds.length;g++)n.cmds.push(v.cmds[g])}}(u,s,r,o,a))}function m(e,t){for(var r=1,n=e[0],i=e[1],s=e[2],o=0;o<t.length;o++){r*=n[o]>i[o]||i[o]>s[o]||n[o]<0&&s[o]>0&&0!=i[o]||0==i[o]?1:t[o]<n[o]||t[o]>s[o]?0:t[o]==i[o]?1:t[o]<i[o]?(t[o]-n[o])/(i[o]-n[o]):(s[o]-t[o])/(s[o]-i[o])}return r}function g(e,t){for(var r=e.fvar,n=e.avar,i=r?r[0]:null,s=[],o=0;o<i.length;o++){var a=i[o][1],u=i[o][2],l=i[o][3],h=Math.max(a,Math.min(l,t[o]));if(s[o]=h<u?(u-h)/(a-u):h>u?(h-u)/(l-u):0,n&&-1!=s[o]){for(var c=n[o],d=0;d<c.length&&!(c[d]>=s[o]);d+=2);var p=(s[o]-c[d-2])/(c[d]-c[d-2]);s[o]=p*c[d+1]+(1-p)*c[d-1]}}return s}function y(e,t,r,n,i){var s=r.length,o=new Array(2*s+8);o.fill(0);for(var a=0;a<s;a++){var u=0,l=0,h=t.indexOf(a);if(-1!=h)u=e[h],l=e[t.length+h];else{for(var c=0;i[c]<a;)c++;for(var d=0==c?0:i[c-1]+1,p=i[c],f=-1,m=-1,g=0;g<t.length;g++){(y=t[g])<d||y>p||y>=s||(f=g,-1==m&&(m=g))}for(g=0;g<t.length;g++){var y;if(!((y=t[g])<d||y>p||y>=s)&&(y<a&&(f=g),a<y)){m=g;break}}for(var v=0;v<2;v++){var b=0==v?r:n,x=v*t.length,_=0,w=b[t[f]],C=b[t[m]],E=b[a],S=e[x+f],A=e[x+m];if(w==C)_=S==A?S:0;else if(E<=Math.min(w,C))_=w<C?S:A;else if(Math.max(w,C)<=E)_=w<C?A:S;else{var D=(E-w)/(C-w);_=D*A+(1-D)*S}0==v?u=_:l=_}}o[a]=u,o[s+4+a]=l}return o}function v(e,t,r,n){for(var i=t>>1,s=r>>1,o=new Uint8Array(i*s*4),a=new Uint32Array(e.buffer),u=new Uint32Array(o.buffer),l=0;l<s;l++)for(var h=0;h<i;h++){var c=l*i+h,d=(l<<1)*t+(h<<1),p=a[d],f=a[d+1],m=a[d+t],g=a[d+t+1],y=p>>>24,v=f>>>24,b=m>>>24,x=g>>>24,_=y+v+b+x;if(1020==_){var w=(p>>>0&255)+(f>>>0&255)+(m>>>0&255)+(g>>>0&255)+2>>>2,C=(p>>>8&255)+(f>>>8&255)+(m>>>8&255)+(g>>>8&255)+2>>>2,E=(p>>>16&255)+(f>>>16&255)+(m>>>16&255)+(g>>>16&255)+2>>>2;u[c]=255<<24|E<<16|C<<8|w}else if(0==_)u[c]=0;else{var S=1/_;w=~~((w=(p>>>0&255)*y+(f>>>0&255)*v+(m>>>0&255)*b+(g>>>0&255)*x)*S+.5),C=~~((C=(p>>>8&255)*y+(f>>>8&255)*v+(m>>>8&255)*b+(g>>>8&255)*x)*S+.5),E=~~((E=(p>>>16&255)*y+(f>>>16&255)*v+(m>>>16&255)*b+(g>>>16&255)*x)*S+.5),u[c]=_+2>>>2<<24|E<<16|C<<8|w}}return{buff:o,w:i,h:s}}function b(n,s,o,a,u){for(var l=s.stack,h=s.nStems,c=s.haveWidth,d=s.width,p=s.open,f=0,m=s.x,g=s.y,y=0,v=0,x=0,_=0,w=0,C=0,E=0,S=0,A=0,D=0,T=wv.T.CFF,F=a.nominalWidthX,I={val:0,size:0};f<n.length;){T.getCharString(n,f,I);var k=I.val;if(f+=I.size,"o1"==k||"o18"==k)l.length%2!=0&&!c&&(d=l.shift()+F),h+=l.length>>1,l.length=0,c=!0;else if("o3"==k||"o23"==k){l.length%2!=0&&!c&&(d=l.shift()+F),h+=l.length>>1,l.length=0,c=!0}else if("o4"==k)l.length>1&&!c&&(d=l.shift()+F,c=!0),p&&i(u),g+=l.pop(),e(u,m,g),p=!0;else if("o5"==k)for(;l.length>0;)m+=l.shift(),g+=l.shift(),t(u,m,g);else if("o6"==k||"o7"==k)for(var N=l.length,M="o6"==k,O=0;O<N;O++){var B=l.shift();M?m+=B:g+=B,M=!M,t(u,m,g)}else if("o8"==k||"o24"==k){N=l.length;for(var L=0;L+6<=N;)y=m+l.shift(),v=g+l.shift(),x=y+l.shift(),_=v+l.shift(),m=x+l.shift(),g=_+l.shift(),r(u,y,v,x,_,m,g),L+=6;"o24"==k&&(m+=l.shift(),g+=l.shift(),t(u,m,g))}else{if("o11"==k)break;if("o1234"==k||"o1235"==k||"o1236"==k||"o1237"==k)"o1234"==k&&(v=g,x=(y=m+l.shift())+l.shift(),D=_=v+l.shift(),C=_,S=g,m=(E=(w=(A=x+l.shift())+l.shift())+l.shift())+l.shift(),r(u,y,v,x,_,A,D),r(u,w,C,E,S,m,g)),"o1235"==k&&(y=m+l.shift(),v=g+l.shift(),x=y+l.shift(),_=v+l.shift(),A=x+l.shift(),D=_+l.shift(),w=A+l.shift(),C=D+l.shift(),E=w+l.shift(),S=C+l.shift(),m=E+l.shift(),g=S+l.shift(),l.shift(),r(u,y,v,x,_,A,D),r(u,w,C,E,S,m,g)),"o1236"==k&&(y=m+l.shift(),v=g+l.shift(),x=y+l.shift(),D=_=v+l.shift(),C=_,E=(w=(A=x+l.shift())+l.shift())+l.shift(),S=C+l.shift(),m=E+l.shift(),r(u,y,v,x,_,A,D),r(u,w,C,E,S,m,g)),"o1237"==k&&(y=m+l.shift(),v=g+l.shift(),x=y+l.shift(),_=v+l.shift(),A=x+l.shift(),D=_+l.shift(),w=A+l.shift(),C=D+l.shift(),E=w+l.shift(),S=C+l.shift(),Math.abs(E-m)>Math.abs(S-g)?m=E+l.shift():g=S+l.shift(),r(u,y,v,x,_,A,D),r(u,w,C,E,S,m,g));else if("o14"==k){if(l.length>0&&4!=l.length&&!c&&(d=l.shift()+o.nominalWidthX,c=!0),4==l.length){var P=l.shift(),R=l.shift(),V=l.shift(),U=l.shift(),z=T.glyphBySE(o,V),j=T.glyphBySE(o,U);b(o.CharStrings[z],s,o,a,u),s.x=P,s.y=R,b(o.CharStrings[j],s,o,a,u)}p&&(i(u),p=!1)}else if("o19"==k||"o20"==k){l.length%2!=0&&!c&&(d=l.shift()+F),h+=l.length>>1,l.length=0,c=!0,f+=h+7>>3}else if("o21"==k)l.length>2&&!c&&(d=l.shift()+F,c=!0),g+=l.pop(),m+=l.pop(),p&&i(u),e(u,m,g),p=!0;else if("o22"==k)l.length>1&&!c&&(d=l.shift()+F,c=!0),m+=l.pop(),p&&i(u),e(u,m,g),p=!0;else if("o25"==k){for(;l.length>6;)m+=l.shift(),g+=l.shift(),t(u,m,g);y=m+l.shift(),v=g+l.shift(),x=y+l.shift(),_=v+l.shift(),m=x+l.shift(),g=_+l.shift(),r(u,y,v,x,_,m,g)}else if("o26"==k)for(l.length%2&&(m+=l.shift());l.length>0;)y=m,v=g+l.shift(),m=x=y+l.shift(),g=(_=v+l.shift())+l.shift(),r(u,y,v,x,_,m,g);else if("o27"==k)for(l.length%2&&(g+=l.shift());l.length>0;)v=g,x=(y=m+l.shift())+l.shift(),_=v+l.shift(),m=x+l.shift(),r(u,y,v,x,_,m,g=_);else if("o10"==k||"o29"==k){var G="o10"==k?a:o;if(0==l.length)console.log("error: empty stack");else{var $=l.pop(),H=G.Subrs[$+G.Bias];s.x=m,s.y=g,s.nStems=h,s.haveWidth=c,s.width=d,s.open=p,b(H,s,o,a,u),m=s.x,g=s.y,h=s.nStems,c=s.haveWidth,d=s.width,p=s.open}}else if("o30"==k||"o31"==k){var q=l.length,W=(L=0,"o31"==k);for(L+=q-(N=-3&q);L<N;)W?(v=g,x=(y=m+l.shift())+l.shift(),g=(_=v+l.shift())+l.shift(),N-L==5?(m=x+l.shift(),L++):m=x,W=!1):(y=m,v=g+l.shift(),x=y+l.shift(),_=v+l.shift(),m=x+l.shift(),N-L==5?(g=_+l.shift(),L++):g=_,W=!0),r(u,y,v,x,_,m,g),L+=4}else{if("o"==(k+"").charAt(0))throw console.log("Unknown operation: "+k,n),k;l.push(k)}}}s.x=m,s.y=g,s.nStems=h,s.haveWidth=c,s.width=d,s.open=p}return{shape:function(e,t,r){null==r&&(r={});var n=r.axs;e.fvar&&null==n&&(n=e.fvar[1][e._index][2]);var i=e.HVAR;n&&i&&(n=g(e,n));for(var o=[],a=0;a<t.length;a++){var u=t.codePointAt(a);u>65535&&a++,o.push(d(e,u))}var l=[];for(a=0;a<o.length;a++){var h=s(e,o,a),c=o[a],p=e.hmtx.aWidth[c]+h[2];if(i&&i[1][c])for(var f=i[1][c],y=0;y<i[0].length;y++)p+=m(i[0][y],n)*f[y];l.push({g:c,cl:a,dx:0,dy:0,ax:p,ay:0})}return l},shapeToPath:function(e,t,r){var n,i,s={cmds:[],crds:[]},o=0,a=0;r&&(n=r.clr,i=r.axs);for(var u=0;u<t.length;u++){for(var l=t[u],h=p(e,l.g,!1,i),c=h.crds,d=0;d<c.length;d+=2)s.crds.push(c[d]+o+l.dx),s.crds.push(c[d+1]+a+l.dy);n&&s.cmds.push(n);for(d=0;d<h.cmds.length;d++)s.cmds.push(h.cmds[d]);var f=s.cmds.length;n&&0!=f&&"X"!=s.cmds[f-1]&&s.cmds.push("X"),o+=l.ax,a+=l.ay}return{cmds:s.cmds,crds:s.crds}},codeToGlyph:d,glyphToPath:p,pathToSVG:function(e,t){var r=e.cmds,n=e.crds;function i(e){return parseFloat(e.toFixed(t))}null==t&&(t=5);for(var s=[],o=0,a={M:2,L:2,Q:4,C:6},u=0,l=0,h=0,c=0,d=0,p=0,f=0;f<r.length;f++){var m,g,y,v,b=r[f],x=a[b]?a[b]:0,_=[];if("L"==b)m=n[o]-u,g=n[o+1]-l,y=i(m+h),v=i(g+c),"Z"==r[f+1]&&n[o]==d&&n[o+1]==p?(y=m,v=g):0==y&&0==v||(0==y?_.push("v",v):0==v?_.push("h",y):_.push("l",y,v));else{_.push(b.toLowerCase());for(var w=0;w<x;w+=2)m=n[o+w]-u,g=n[o+w+1]-l,y=i(m+h),v=i(g+c),_.push(y,v)}0!=x&&(h+=m-y,c+=g-v);var C=_;for(w=0;w<C.length;w++)s.push(C[w]);0!=x&&(u=n[(o+=x)-2],l=n[o-1]),"M"==b&&(d=u,p=l),"Z"==b&&(u=d,l=p)}return function(e){for(var t=[],r=!1,n="",i=0;i<e.length;i++){var s=e[i],o="number"==typeof s;if(!o){if(s==n&&1==s.length&&"m"!=s)continue;n=s}r&&o&&s>=0&&t.push(" "),t.push(s),r=o}return t.join("")}(s)},SVGToPath:function(e){var t={cmds:[],crds:[]};return wv.U.SVG.svgToPath(e,t),{cmds:t.cmds,crds:t.crds}},pathToContext:function(e,t){for(var r=0,n=e.cmds,i=e.crds,s=0;s<n.length;s++){var o=n[s];if("M"==o)t.moveTo(i[r],i[r+1]),r+=2;else if("L"==o)t.lineTo(i[r],i[r+1]),r+=2;else if("C"==o)t.bezierCurveTo(i[r],i[r+1],i[r+2],i[r+3],i[r+4],i[r+5]),r+=6;else if("Q"==o)t.quadraticCurveTo(i[r],i[r+1],i[r+2],i[r+3]),r+=4;else if("d"==o[0]){var l=window.UPNG,h=i[r],c=i[r+1],d=i[r+2],p=i[r+3],f=i[r+4],m=i[r+5],g=i[r+6],y=i[r+7];if(r+=8,null==l){t.moveTo(h,c),t.lineTo(d,p),t.lineTo(f,m),t.lineTo(g,y),t.closePath();continue}for(var b=d-h,x=p-c,_=g-h,w=y-c,C=atob(o.slice(22)),E=new Uint8Array(C.length),S=0;S<C.length;S++)E[S]=C.charCodeAt(S);for(var A=l.decode(E.buffer),D=A.width,T=A.height,F=new Uint8Array(l.toRGBA8(A)[0]),I=t.getTransform(),k=Math.sqrt(Math.abs(I.a*I.d-I.b*I.c))*Math.sqrt(_*_+w*w)/T;k<.5;){var N=v(F,D,T);F=N.buff,D=N.w,T=N.h,k*=2}null==a&&(a=document.createElement("canvas"),u=a.getContext("2d")),a.width==D&&a.height==T||(a.width=D,a.height=T),u.putImageData(new ImageData(new Uint8ClampedArray(F.buffer),D,T),0,0),t.save(),t.transform(b,x,_,w,h,c),t.scale(1/D,1/T),t.drawImage(a,0,0),t.restore()}else if("#"==o.charAt(0)||"r"==o.charAt(0))t.beginPath(),t.fillStyle=o;else if("O"==o.charAt(0)&&"OX"!=o){t.beginPath();var M=o.split("-");t.lineWidth=parseFloat(M[2]),t.lineCap=["butt","round","square"][parseFloat(M[3])],t.lineJoin=["miter","round","bevel"][parseFloat(M[4])],t.miterLimit=parseFloat(M[5]),t.lineDashOffset=parseFloat(M[6]),t.setLineDash(M[7].split(",").map(parseFloat)),t.strokeStyle=M[1]}else"Z"==o?t.closePath():"X"==o?t.fill():"OX"==o&&t.stroke()}},initHB:function(e,t){var r=function(e){var t=0;return 4294967168&e?4294965248&e?4294901760&e?4292870144&e||(t=4):t=3:t=2:t=1,t};fetch(e).then((function(e){return e.arrayBuffer()})).then((function(e){return WebAssembly.instantiate(e)})).then((function(e){console.log("HB ready");var n,i,s,o,a,u,l,h,c,d,p=e.instance.exports,f=p.memory;wv.U.shapeHB=function(e,t,m){var g=e._data,y=e.name.postScriptName,v=m.ltr,b=m.fts,x=m.axs;if(e.fvar&&null==x&&(x=e.fvar[1][e._index][2]),n=new Uint8Array(f.buffer),i=new Uint32Array(f.buffer),s=new Int32Array(f.buffer),o=new Float32Array(f.buffer),a!=y&&(null!=u&&(p.hb_blob_destroy(u),p.free(l),p.hb_face_destroy(h),p.hb_font_destroy(c)),l=p.malloc(g.byteLength),n.set(g,l),u=p.hb_blob_create(l,g.byteLength,2,0,0),h=p.hb_face_create(u,e._index),c=p.hb_font_create(h),a=y),null!=window.TextEncoder){null==d&&(d=new window.TextEncoder("utf8"));var _=p.hb_buffer_create(),w=d.encode(t),C=w.length,E=p.malloc(C);n.set(w,E),p.hb_buffer_add_utf8(_,E,C,0,C),p.free(E);var S=wv.B,A=0;if(b){A=p.malloc(16*b.length);for(var D=0;D<b.length;D++){var T=b[D],F=(N=A+16*D)>>>2;S.writeASCII(n,N,T[0].split("").reverse().join("")),i[F+1]=T[1],i[F+2]=T[2],i[F+3]=T[3]}}var I=0;if(x&&e.fvar){var k=e.fvar[0];for(I=p.malloc(8*x.length),D=0;D<x.length;D++){var N;F=(N=I+8*D)>>>2,S.writeASCII(n,N,k[D][0].split("").reverse().join("")),o[F+1]=x[D]}}x&&p.hb_font_set_variations(c,I,x.length),p.hb_buffer_set_direction(_,v?4:5),p.hb_buffer_guess_segment_properties(_),p.hb_shape(c,_,A,b?b.length:0);var M=function(e){for(var t=p.hb_buffer_get_length(e),r=[],n=p.hb_buffer_get_glyph_infos(e,0)>>>2,o=p.hb_buffer_get_glyph_positions(e,0)>>>2,a=0;a<t;++a){var u=n+5*a,l=o+5*a;r.push({g:i[u+0],cl:i[u+2],ax:s[l+0],ay:s[l+1],dx:s[l+2],dy:s[l+3]})}return r}(_);p.hb_buffer_destroy(_),b&&p.free(A),x&&p.free(I);var O=M.slice(0);v||O.reverse();var B=0,L=0;for(D=1;D<O.length;D++){for(var P=O[D],R=P.cl;;){var V=t.codePointAt(B),U=r(V);if(!(L+U<=R))break;L+=U,B+=V<=65535?1:2}P.cl=B}return M}alert("Your browser is too old. Please, update it.")},t()}))}}}();class Ev{constructor(e,t,r,n){this._totalLength=void 0,this.A=e,this.B=t,this.C=r,this.D=n}static sampleSpacing(){return 2}tangentAtParameter(e){const t=Math.max(0,Math.min(1,e));if(0===t||1===t){let e,r;0===t?this.A.x===this.B.x&&this.A.y===this.B.y?(e=this.C.x-this.A.x,r=this.C.y-this.A.y):(e=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?(e=this.D.x-this.B.x,r=this.D.y-this.B.y):(e=this.D.x-this.C.x,r=this.D.y-this.C.y);const n=Math.hypot(e,r);return Math.abs(n)>1e-4&&(e/=n,r/=n),{x:e,y:r}}const r=1-t;let n=3*this.D.x*Math.pow(t,2)-3*this.C.x*Math.pow(t,2)+6*this.C.x*r*t-6*this.B.x*r*t+3*this.B.x*Math.pow(r,2)-3*this.A.x*Math.pow(r,2),i=3*this.D.y*Math.pow(t,2)-3*this.C.y*Math.pow(t,2)+6*this.C.y*r*t-6*this.B.y*r*t+3*this.B.y*Math.pow(r,2)-3*this.A.y*Math.pow(r,2);const s=Math.hypot(n,i);return Math.abs(s)>1e-4&&(n/=s,i/=s),{x:n,y:i}}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(e){const t=Math.max(0,Math.min(1,e));return{x:Math.pow(1-t,3)*this.A.x+3*Math.pow(1-t,2)*t*this.B.x+3*(1-t)*Math.pow(t,2)*this.C.x+Math.pow(t,3)*this.D.x,y:Math.pow(1-t,3)*this.A.y+3*Math.pow(1-t,2)*t*this.B.y+3*(1-t)*Math.pow(t,2)*this.C.y+Math.pow(t,3)*this.D.y}}getTotalLength(){if(void 0===this._totalLength)if(this.isLinear())this._totalLength=Math.hypot(this.D.x-this.A.x,this.D.y-this.A.y);else{const e=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))/Ev.sampleSpacing())),t=Cv(e).map((t=>this.pointAtParameter(t/(e-1))));let r=0;for(let e=1;e<t.length;e++)r+=Math.hypot(t[e].x-t[e-1].x,t[e].y-t[e-1].y);this._totalLength=r}return this._totalLength}}class Sv{constructor(e){this.samples=[],this.segments=e;const t=e.map((e=>e.getTotalLength())),r=[0];for(let e=1;e<t.length;e++)r.push(r[e-1]+t[e-1]);this._totalLength=r[r.length-1]+t[t.length-1];const n=e.map((e=>Math.max(4,Math.ceil(e.getTotalLength()/Ev.sampleSpacing())))),i=n.reduce(((e,t)=>e+t)),s=1/i/10,o=this._totalLength/i;this.samples.push({dist:0,pt:this.segments[0].A,tan:this.segments[0].tangentAtParameter(0),segIdx:0,t:0}),e.forEach(((e,t)=>{const i=n[t],a=Cv(i+1).map((e=>e/i)),u=a.map((t=>e.pointAtParameter(t)));let l;for(let t=0;t<4;t++){l=Cv(i).map((e=>Math.hypot(u[e+1].x-u[e].x,u[e+1].y-u[e].y)));const t=l.map((e=>e-o));let r=0;for(let n=1;n<a.length-1;n++)r+=t[n-1],a[n]-=s*r,u[n]=e.pointAtParameter(a[n])}let h=0;u.slice(1).forEach(((e,n)=>{h+=l[n],this.samples.push({dist:r[t]+h,pt:e,tan:this.segments[t].tangentAtParameter(a[n+1]),segIdx:t,t:a[n+1]})}))})),this._jumps=[],this.segmentStartEnds=[{start:0,end:0}];for(let e=1;e<this.samples.length;e++){let t=this.samples[e-1],r=this.samples[e];if(r.segIdx===t.segIdx)this.segmentStartEnds[this.segmentStartEnds.length-1].end=r.dist;else{const n=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[t.segIdx].D.x!==this.segments[r.segIdx].A.x||this.segments[t.segIdx].D.y!==this.segments[r.segIdx].A.y){const i={dist:n-1e-8,pt:this.segments[t.segIdx].D,tan:this.segments[t.segIdx].tangentAtParameter(1),segIdx:t.segIdx,t:1},s={dist:n+1e-8,pt:this.segments[r.segIdx].A,tan:this.segments[r.segIdx].tangentAtParameter(0),segIdx:r.segIdx,t:0};this._jumps.push(n),this.samples.splice(e,0,i,s),this.segmentStartEnds[i.segIdx].end=i.dist,this.segmentStartEnds[s.segIdx]={start:s.dist,end:r.dist},e+=2}else if(0!==r.t){const t=Object.assign(Object.assign({},r),{t:0,pt:this.segments[r.segIdx].A,tan:this.segments[r.segIdx].tangentAtParameter(0),dist:n});this.samples.splice(e,0,t),this.segmentStartEnds[r.segIdx]={start:t.dist,end:r.dist},e++}else this.segmentStartEnds[r.segIdx]={start:r.dist,end:r.dist}}}}jumps(){return[...this._jumps]}getTotalLength(){return this._totalLength}findClosestSampleIdx(e){let t=0,r=this.samples.length-1;for(;t<r;){const n=Math.floor((t+r)/2);if(this.samples[n].dist>e)r=n-1;else{if(!(this.samples[n].dist<e))return n;t=n+1}}return Math.max(0,Math.min(this.samples.length-1,Math.floor((t+r)/2)))}getPointAtLength(e,t=!1){if(e<=0)return this.samples[0].pt;if(e>=this._totalLength)return this.samples[this.samples.length-1].pt;const r=this.findClosestSampleIdx(e),n=this.samples[r].dist<e?Math.min(r+1,this.samples.length-1):Math.max(0,r-1),i=Math.abs(this.samples[n].dist-this.samples[r].dist)<1e-6?0:(e-this.samples[r].dist)/(this.samples[n].dist-this.samples[r].dist);if(t||this.samples[r].segIdx>this.samples[n].segIdx){return{x:(1-i)*this.samples[r].pt.x+i*this.samples[n].pt.x,y:(1-i)*this.samples[r].pt.y+i*this.samples[n].pt.y}}if(this.samples[r].segIdx!==this.samples[n].segIdx){const e=1-this.samples[r].t+this.samples[n].t,t=e>0?(1-this.samples[r].t)/e:.5;if(i<t){const e=this.segments[this.samples[r].segIdx],n=i/t,s=(1-n)*this.samples[r].t+n;return e.pointAtParameter(s)}{const e=this.segments[this.samples[n].segIdx],r=(i-t)/(1-t)*this.samples[n].t;return e.pointAtParameter(r)}}{const e=this.segments[this.samples[r].segIdx],t=(1-i)*this.samples[r].t+i*this.samples[n].t;return e.pointAtParameter(t)}}getAngleAtLength(e,t=!1){const r=this.getTangentAtLength(e,t);return Math.atan2(r.y,r.x)}getTangentAtLength(e,t=!1){if(e<=0)return this.samples[0].tan;if(e>=this._totalLength)return this.samples[this.samples.length-1].tan;const r=this.findClosestSampleIdx(e),n=this.samples[r].dist<e?Math.min(r+1,this.samples.length-1):Math.max(0,r-1),i=(e-this.samples[r].dist)/(this.samples[n].dist-this.samples[r].dist);if(t||this.samples[r].segIdx>this.samples[n].segIdx){let e=(1-i)*this.samples[r].tan.x+i*this.samples[n].tan.x,t=(1-i)*this.samples[r].tan.y+i*this.samples[n].tan.y;const s=Math.max(Math.hypot(e,t),1e-4);return e/=s,t/=s,{x:e,y:t}}if(this.samples[r].segIdx!==this.samples[n].segIdx){if(i<.5){const e=this.segments[this.samples[r].segIdx],t=2*i,n=(1-t)*this.samples[r].t+t;return e.tangentAtParameter(n)}{const e=this.segments[this.samples[n].segIdx],t=2*(i-.5)*this.samples[n].t;return e.tangentAtParameter(t)}}{const e=this.segments[this.samples[r].segIdx],t=(1-i)*this.samples[r].t+i*this.samples[n].t;return e.tangentAtParameter(t)}}}const Av={M:2,L:2,C:6,Q:4},Dv=["ttf","otf","woff"],Tv=new RegExp(`\\.(${Dv.join("|")})`,"i"),Fv=new RegExp(`([^/]+)(\\.(?:${Dv.join("|")}))`,"i"),Iv="Sorry, only TTF, OTF and WOFF files are supported.",kv=["weight","stretch","style"];class Nv{constructor(e,t,r,n,i){if(!(t instanceof FontFace))throw Error("FontFace is required");this._pInst=e,this.name=r,this.path=n,this.data=i,this.face=t}static hasGlyphData(e){let{font:t}=e;return"object"==typeof t&&void 0!==t.data}fontBounds(e,t,r,n,i,s){({width:n,height:i,options:s}=this._parseArgs(n,i,s));let o=s?.graphics?._renderer||this._pInst._renderer;if(!o)throw Error("p5 or graphics required for fontBounds()");return o.fontBounds(e,t,r,n,i)}textBounds(e,t,r,n,i,s){({width:n,height:i,options:s}=this._parseArgs(n,i,s));let o=s?.graphics?._renderer||this._pInst._renderer;if(!o)throw Error("p5 or graphics required for fontBounds()");return o.textBounds(e,t,r,n,i)}textToPaths(e,t,r,n,i,s){if(({width:n,height:i,options:s}=this._parseArgs(n,i,s)),!this.data)throw Error('No font data available for "'+this.name+'"\nTry downloading a local copy of the font file');return this._lineateAndPathify(e,t,r,n,i,s).map((e=>e.glyphs)).flat().map((e=>e.path.commands)).flat()}textToPoints(e,t,r,n,i,s){return this.textToContours(e,t,r,n,i,s).reduce(((e,t)=>(e.push(...t),e)),[])}textToContours(e,t=0,r=0,n,i,s){({width:n,height:i,options:s}=this._parseArgs(n,i,s));const o=this.textToPaths(e,t,r,n,i,s),a=[];for(const e of o)"M"===e[0]&&a.push([]),a[a.length-1].push(e);return a.map((e=>function(e,t,r){const n=(e,t)=>{if("object"!=typeof e)e=t;else for(const r in t)void 0===e[r]&&(e[r]=t[r]);return e},i=(e,t)=>{const r=e.length;return e[t<0?t%r+r:t%r]},s=(e,t)=>{t=t||0;let r=0;for(let n=e.length-1;e.length>3&&n>=0;--n)o(i(e,n-1),i(e,n),i(e,n+1),t)&&(e.splice(n%e.length,1),r++);return r},o=(e,t,r,n)=>{if(!n)return 0===a(e,t,r);void 0===o.tmpPoint1&&(o.tmpPoint1=[],o.tmpPoint2=[]);const i=o.tmpPoint1,s=o.tmpPoint2;i.x=t.x-e.x,i.y=t.y-e.y,s.x=r.x-t.x,s.y=r.y-t.y;const u=i.x*s.x+i.y*s.y,l=Math.sqrt(i.x*i.x+i.y*i.y),h=Math.sqrt(s.x*s.x+s.y*s.y);return Math.acos(u/(l*h))<n},a=(e,t,r)=>(t[0]-e[0])*(r[1]-e[1])-(r[0]-e[0])*(t[1]-e[1]),u=(e=>{const t=e.slice();if(t.length<2)throw new Error(`Path doesn't have enough commands: ${JSON.stringify(t)}`);if("M"!==t[0].type)throw new Error(`Path starts with ${t[0].type} instead of M!`);let r={x:t[0].x,y:t[0].y},n=Object.assign({},r);const i=[];for(;t.length>0;){const e=t.shift();if("M"===e.type)n={x:e.x,y:e.y},r=n;else if("C"===e.type)i.push(new Ev(r,{x:e.x1,y:e.y1},{x:e.x2,y:e.y2},{x:e.x,y:e.y})),r={x:e.x,y:e.y};else if("L"===e.type)e.x===r.x&&e.y===r.y||i.push(new Ev(r,r,{x:e.x,y:e.y},{x:e.x,y:e.y})),r={x:e.x,y:e.y};else if("H"===e.type)e.x!==r.x&&i.push(new Ev(r,r,{x:e.x,y:r.y},{x:e.x,y:r.y})),r={x:e.x,y:r.y};else if("V"===e.type)e.y!==r.y&&i.push(new Ev(r,r,{x:r.x,y:e.y},{x:r.x,y:e.y})),r={x:r.x,y:e.y};else if("Q"===e.type)i.push(new Ev(r,{x:r.x+2/3*(e.x1-r.x),y:r.y+2/3*(e.y1-r.y)},{x:e.x+2/3*(e.x1-e.x),y:e.y+2/3*(e.y1-e.y)},{x:e.x,y:e.y})),r={x:e.x,y:e.y};else{if("Z"!==e.type)throw new Error(`Unsupported path command ${e.type}; use only H, V, M, L, C, Z!`);Math.hypot(r.x-n.x,r.y-n.y)>0&&i.push(new Ev(r,r,n,n))}}return new Sv(i)})(Pv(e));let l=n(t,{sampleFactor:.1,simplifyThreshold:0});const h=Math.max(1,Math.ceil(u.getTotalLength()*l.sampleFactor));let c=[];const d=r._pInst.angleMode(),p=r._pInst.DEGREES;for(let e=0;e<h;e++){const t=u.getTotalLength()*(1===h?0:e/(h-1));c.push({...u.getPointAtLength(t),get angle(){const e=u.getAngleAtLength(t);return d===p?180*e/Math.PI:e},get alpha(){return this.angle}})}l.simplifyThreshold&&s(c,l.simplifyThreshold);return c}(e,s,this)))}textToModel(e,t,r,n,i,s){({width:n,height:i,options:s}=this._parseArgs(n,i,s));const o=s?.extrude||0;let a=this.textToContours(e,t,r,n,i,s);if(!a||0===a.length)return new p5.Geometry;const u=this._pInst.buildGeometry((()=>{const e=this._pInst._renderer._validateFaces;this._pInst._renderer._validateFaces=!0,this._pInst.beginShape();for(const e of a){this._pInst.beginContour();for(const t of e)this._pInst.vertex(t.x,t.y,0);this._pInst.endContour(this._pInst.CLOSE)}this._pInst.endShape(this._pInst.CLOSE),this._pInst._renderer._validateFaces=e}));if(0===o)return u;const l={},h=e=>`${e.x.toFixed(6)}-${e.y.toFixed(6)}-${e.z.toFixed(6)}`,c=[],d=[];for(const e of u.vertices){const t=h(e);if(!(t in l)){const r=c.length;l[t]=r,c.push(e.copy())}d.push(l[t])}const p=u.faces.map((e=>e.map((e=>d[e])))),f={};for(const e of p)for(let t=0;t<e.length;t++){const r=e[t],n=e[(t+1)%e.length],i=`${Math.min(r,n)}-${Math.max(r,n)}`;f[i]||(f[i]=[]),f[i].push([r,n])}const m=[];for(const e in f)1===f[e].length&&m.push(f[e][0]);const g=this._pInst.buildGeometry((()=>{})),y=.5*o;g.vertices=[],g.faces=[],g.edges=[];for(const[e,t]of m){const r=c[e],n=c[t],i=new Pi(n.x-r.x,n.y-r.y,n.z-r.z),s=new Pi(0,0,o),a=Pi.cross(i,s),u=i.mag();if(a.mag()<1e-4||u<1e-4)continue;const l=g.vertices.length;g.vertices.push(new Pi(r.x,r.y,r.z+y));const h=g.vertices.length;g.vertices.push(new Pi(n.x,n.y,n.z+y));const d=g.vertices.length;g.vertices.push(new Pi(r.x,r.y,r.z-y));const p=g.vertices.length;g.vertices.push(new Pi(n.x,n.y,n.z-y)),g.faces.push([l,d,p]),g.faces.push([l,p,h]),g.edges.push([l,h]),g.edges.push([d,p]),g.edges.push([l,d]),g.edges.push([h,p])}const v=g.vertices.length;for(const e of c)g.vertices.push(new Pi(e.x,e.y,e.z+y));for(const e of p){if(e.length<3)continue;const t=e.map((e=>e+v));g.faces.push(t);for(let e=0;e<t.length;e++){const r=(e+1)%t.length;g.edges.push([t[e],t[r]])}}const b=g.vertices.length;for(const e of c)g.vertices.push(new Pi(e.x,e.y,e.z-y));for(const e of p){if(e.length<3)continue;const t=[...e].reverse().map((e=>e+b));g.faces.push(t);for(let e=0;e<t.length;e++){const r=(e+1)%t.length;g.edges.push([t[e],t[r]])}}return g.computeNormals(),g}variations(){let e={};if(this.data){let t=this.face?.axes;t&&t.forEach((t=>{e[t.tag]=t.value}))}return kv.forEach((t=>{let r=this.face[t];"normal"!==r&&(e[t]=e[t]||r)})),e}metadata(){let e=this.data?.name||{};for(let t in this.face)/^load/.test(t)||(e[t]=e[t]||this.face[t]);return e}static async list(e=!1){if(e){console.log("There are",document.fonts.size,"font-faces\n");let e=0;for(let t of document.fonts.values()){console.log("FontFace: {");for(let e in t)console.log("  "+e+": "+t[e]);console.log("}\n"),"loaded"===t.status&&e++}console.log(e+" loaded")}return await Array.from(document.fonts)}_lineateAndPathify(e,t,r,n,i,s={}){let o=s?.graphics?._renderer||this._pInst._renderer;o.push(),o.textFont(this);let{lines:a,bounds:u}=o._computeBounds(No,e,t,r,n,i,{ignoreRectMode:!0,...s});a=this._position(o,a,u,n,i);let l=this.data?.head?.unitsPerEm||1e3,h=o.states.textSize/l;const c=this._currentAxes(o);let d=a.map((e=>this._lineToGlyphs(e,{scale:h,axs:c})));return o.pop(),d}_currentAxes(e){let t;if((this.data?.fvar?.length??0)>0){t=this.data.fvar[0].map((([t,r,n,i,s,o])=>{if(!e)return n;if("wght"===t)return e.states.fontWeight;if("wdth"===t)return 100;if(e.textCanvas().style.fontVariationSettings){const r=new RegExp(`\\b${t}s+(d+)`).exec(e.textCanvas().style.fontVariationSettings);return r?parseInt(r[1]):n}return n}))}return t}_textToPathPoints(e,t,r,n,i,s){({width:n,height:i,options:s}=this._parseArgs(n,i,s));let o=this.textToPaths(e,t,r,n,i,s);const a=(e,t,r,n)=>{if(fn.dist(t.x,t.y,r.x,r.y)>n){let i={x:(t.x+r.x)/2,y:(t.y+r.y)/2};e.push(i),a(e,t,i,n),a(e,i,r,n)}};let u=[],{textSize:l}=this._pInst._renderer.states,h=l/this.data.head.unitsPerEm*500;for(let e=0;e<o.length;e++){let{type:t,data:r}=o[e];if("Z"!==t){let e={x:r[r.length-2],y:r[r.length-1]};"L"===t&&u.length&&!s?.nodivide>0&&a(u,u[u.length-1],e,h),u.push(e)}}return u}_parseArgs(e,t,r={}){return"object"==typeof e?(r=e,e=t=void 0):"object"==typeof t&&(r=t,t=void 0),{width:e,height:t,options:r}}_position(e,t,r,n,i){let{textAlign:s,textLeading:o}=e.states,a=this._measureTextDefault(e,"X").fontBoundingBoxAscent;return t.map(((t,u)=>{let l=r.x,h=r.y+u*o+a,c=e._fontWidthSingle(t);if(s===D?l+=(r.w-c)/2:s===S&&(l+=r.w-c),void 0!==n)switch(e.states.rectMode){case D:l-=n/2,h-=i/2;break;case E:l-=n,h-=i}return{text:t,x:l,y:h}}))}_lineToGlyphs(e,{scale:t=1,axs:r}={}){if(!this.data)throw Error('No font data available for "'+this.name+'"\nTry downloading a local copy of the font file');let n=wv.U.shape(this.data,e.text,{axs:r});return e.glyphShapes=n,e.glyphs=this._shapeToPaths(n,e,{scale:t,axs:r}),e}_positionGlyphs(e,t){let r=t?.graphics?._renderer||this._pInst._renderer;const n=this._currentAxes(r),i=wv.U.shape(this.data,e,{axs:n}),s=[];let o=0;for(const e of i)s.push({x:o,index:e.g,shape:e}),o+=e.ax;return s}_singleShapeToPath(e,{scale:t=1,x:r=0,y:n=0,lineX:i=0,lineY:s=0,axs:o}={}){let a=this.data,u=0,{g:l,ax:h,ay:c,dx:d,dy:p}=e,{crds:f,cmds:m}=wv.U.glyphToPath(a,l,!0,o),g={path:{commands:[]}};for(let e=0;e<m.length;e++){let o=m[e],a=[o];if(o in Av){let e=Av[o];for(let o=0;o<e;o+=2){let e=i+(f[o+u]+r+d)*t,l=s+(f[o+u+1]+n+p)*-t;a.push(e),a.push(l)}u+=e}g.path.commands.push(a)}return{glyph:g,ax:h,ay:c}}_shapeToPaths(e,t,{scale:r=1,axs:n}={}){let i=0,s=0,o=[];if(e.length!==t.text.length)throw Error("Invalid shape data");for(let a=0;a<e.length;a++){const{glyph:u,ax:l,ay:h}=this._singleShapeToPath(e[a],{scale:r,x:i,y:s,lineX:t.x,lineY:t.y,axs:n});o.push(u),i+=l,s+=h}return o}_measureTextDefault(e,t){let{textAlign:r,textBaseline:n}=e.states,i=e.textDrawingContext();i.textAlign="left",i.textBaseline="alphabetic";let s=i.measureText(t);return i.textAlign=r,i.textBaseline=n,s}drawPaths(e,t,r){e.strokeStyle=r?.stroke||e.strokeStyle,e.fillStyle=r?.fill||e.fillStyle,e.beginPath(),t.forEach((([t,...r])=>{"M"===t?e.moveTo(...r):"L"===t?e.lineTo(...r):"C"===t?e.bezierCurveTo(...r):"Q"===t?e.quadraticCurveTo(...r):"Z"===t&&e.closePath()})),r?.fill&&e.fill(),r?.stroke&&e.stroke()}_pathsToCommands(e,t){let r=[];for(let n=0;n<e.length;n++){let i=e[n],{x:s,y:o,path:a}=i,{crds:u,cmds:l}=a;for(let e=0,n=0;n<l.length;n++){let i=l[n],a={type:i,data:[]};if("M"===i||"L"===i)a.data.push(s+u[e]*t,o+u[e+1]*-t),e+=2;else if("C"===i){for(let r=0;r<6;r+=2)a.data.push(s+u[e+r]*t,o+u[e+r+1]*-t);e+=6}else if("Q"===i){for(let r=0;r<4;r+=2)a.data.push(s+u[e+r]*t,o+u[e+r+1]*-t);e+=4}r.push(a)}}return r}}async function Mv(e,t,r,n,i){let s=function(e,t,r,n){e=function(e){/^[A-Za-z][A-Za-z0-9_-]*$/.test(e)||(e="'"+String(e).replace(/'/g,"\\'")+"'");return e}(e);let i=n?._compressedData??n?._data;if(!i){if(!Tv.test(t))throw Error(Iv);t.startsWith("url(")||(t="url("+t+")"),i=t}if((n?.fvar?.length??0)>0){r=r||{};for(const[e,t,i,s,o,a]of n.fvar[0])"wght"===e?r.weight=`${t} ${s}`:"wdth"===e&&(r.stretch=`${t}% ${s}%`)}let s=new FontFace(e,i,r);if("error"===s.status)throw Error('Failed to create FontFace for "'+e+'"');return s}(t,r,n,i);return"loaded"!==s.status&&await s.load(),document.fonts.add(s),await document.fonts.ready,new Nv(e,s,t,r,i)}function Ov(e){return(e.startsWith('"')||e.startsWith("'"))&&e.at(0)===e.at(-1)?e.slice(1,-1).replace(/\/(['"])/g,"$1"):e}function Bv(...e){let t,r,n,i,s=e.shift();"string"==typeof s&&0!==s.length||p5._friendlyError(Iv,"p5.loadFont"),"string"==typeof e[0]&&(t=e.shift());for(let t=0;t<e.length;t++){const s=e[t];"function"==typeof s?r?n=s:r=s:"object"==typeof s&&(i=s)}return{path:s,name:t,success:r,error:n,options:i}}function Lv(e,t){e.Font=Nv,t.parseFontData=async function(e){let r=e instanceof Uint8Array?e:await t.loadBytes(e);if(!r)throw Error("Failed to load font data");let n=wv.parse(r);if(0===n.length||void 0===n[0].cmap)throw Error("parsing font data");return n[0]},t.loadFont=async function(...e){let r,{path:n,name:i,success:s,error:o,options:{sets:a,...u}={}}=Bv(...e),l=n.includes("@font-face");if(!l){let e;try{e=await fetch(n,{method:"HEAD"})}catch(t){e=await fetch(n)}const t=e.headers.get("content-type")?.startsWith("text/css");t&&(l=!0,n=await fetch(n).then((e=>e.text())))}if(l){const e=new CSSStyleSheet;await e.replace(n);const r=[];for(const n of e.cssRules)if(n instanceof CSSFontFaceRule){const e=n.style;let i=Ov(e.getPropertyValue("font-family"));const s=e.getPropertyValue("src"),o={...u||{}};for(const t of e){if("font-family"===t||"src"===t)continue;const r=t.replace(/^font-/,"").split("-").map(((e,t)=>0===t?e:`${e[0].toUpperCase()}${e.slice(1)}`)).join("");o[r]=e.getPropertyValue(t)}r.push({name:i,src:s,fontDescriptors:o,loadWithData:async()=>{let e;try{const r=/url\(([^\)]+)\)/.exec(s);if(r){let n=r[1];/^['"]/.exec(n)&&n.at(0)===n.at(-1)&&(n=n.slice(1,-1)),e=await t.parseFontData(n)}}catch(e){}return Mv(this,i,s,o,e)},loadWithoutData:()=>Mv(this,i,s,o)})}a=a||["latin"];const i=(a instanceof Array?a:[a]).map((e=>e.toLowerCase())),s=ny.filter((e=>i.some((t=>e.category.includes(t)&&e.category.includes("ext")===t.includes("ext"))))),o=new Set(ry.parse(s.map((e=>`U+${e.hexrange[0]}-${e.hexrange[1]}`))));let l,h=0,c=0;for(const e of r){if(!e.fontDescriptors.unicodeRange)continue;const t=[...new Set(ry.parse(e.fontDescriptors.unicodeRange.split(/,\s*/g))).values()].filter((e=>o.has(e))).length,r={style:"normal",weight:400,...u},n=Object.keys(e.fontDescriptors).filter((t=>e.fontDescriptors[t]===r[t])).length;(n>c||n===c&&t>=h)&&(c=n,h=t,l=e)}const d=l||r.at(-1);for(const e of r)e!==d&&e.loadWithoutData();return d?.loadWithData()}try{const e=await t.parseFontData(n);i=i||function(e,t){let r,n=e?.name;if(n){if(n.fullName)return n.fullName;n.familyName&&(r=n.familyName)}if(!r){let e=Fv.exec(t);r=e&&e.length>=3?e[1]:t}return r.includes(" ")&&(r=r.replace(/ /g,"_")),r}(e,n),r=await Mv(this,i,n,u,e)}catch(e){let t=i||n.substring(n.lastIndexOf("/")+1).replace(/\.[^/.]+$/,"");console.warn(`WARN: No glyph data for '${t}', retrying as FontFace`);try{r=await Mv(this,t,n,u)}catch(e){if(o)return o(e);throw e}}const h=()=>s?s(r):r;return this._internal?this._internal(h):h()}}const Pv=e=>e.map((e=>{const t=e[0];switch(t){case"Z":return{type:t};case"M":case"L":{const[,r,n]=e;return{type:t,x:r,y:n}}case"Q":{const[,r,n,i,s]=e;return{type:t,x1:r,y1:n,x:i,y:s}}case"C":{const[,r,n,i,s,o,a]=e;return{type:t,x1:r,y1:n,x2:i,y2:s,x:o,y:a}}default:throw new Error(`Unexpected path command: ${t}`)}}));function Rv(e,t){zo.prototype.maxCachedGlyphs=function(){return 200},Nv.prototype._getFontInfo=function(e){this._fontInfos=this._fontInfos||{};const t=JSON.stringify(e);if(this._fontInfos[t]){return this._fontInfos[t]}{const r=new s(this,{axs:e});return this._fontInfos[t]=r,r}};class r{constructor(e,t){this.width=e,this.height=t,this.infos=[]}findImage(e){const t=this.width*this.height;if(e>t)throw new Error("font is too complex to render in 3D");let r,n;for(let i=this.infos.length-1;i>=0;--i){const s=this.infos[i];if(s.index+e<t){r=s,n=s.imageData;break}}if(!r){try{n=new ImageData(this.width,this.height)}catch(e){let t=document.getElementsByTagName("canvas")[0];const r=!t;t||(t=document.createElement("canvas"),t.style.display="none",document.body.appendChild(t));const i=t.getContext("2d");i&&(n=i.createImageData(this.width,this.height)),r&&document.body.removeChild(t)}r={index:0,imageData:n},this.infos.push(r)}const i=r.index;return r.index+=e,n._dirty=!0,{imageData:n,index:i}}}function n(e,t,r,n,i){const s=e.imageData.data;let o=4*e.index++;s[o++]=t,s[o++]=r,s[o++]=n,s[o++]=i}const i=Math.sqrt(3);class s{constructor(e,{axs:t}={}){this.font=e,this.axs=t,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(e){let t=this.glyphInfos[e.index];if(t)return t;const r=this.axs,{glyph:{path:{commands:s}}}=this.font._singleShapeToPath(e.shape,{axs:r});let o=1/0,a=-1/0,u=1/0,l=-1/0;for(const e of s)for(let t=1;t<e.length;t+=2)o=Math.min(o,e[t]),a=Math.max(a,e[t]),u=Math.min(u,e[t+1]),l=Math.max(l,e[t+1]);if(o>=a||u>=l||!s.length)return this.glyphInfos[e.index]={};const h=a-o,c=l-u,d=Pv(s);let p;const f=[],m=[],g=[];for(p=8;p>=0;--p)g.push([]);for(p=8;p>=0;--p)m.push([]);function y(e,t,r){const n=f.length;function i(e,t,r){for(let n=e.length;n-- >0;){const i=e[n];t>i&&(t=i),r<i&&(r=i)}return{min:t,max:r}}f.push(r);const s=.5,o=i(e,1,0),a=Math.max(Math.floor(9*o.min-s),0),u=Math.min(Math.ceil(9*o.max+s),9);for(let e=a;e<u;++e)g[e].push(n);const l=i(t,1,0),h=Math.max(Math.floor(9*l.min-s),0),c=Math.min(Math.ceil(9*l.max+s),9);for(let e=h;e<c;++e)m[e].push(n)}function v(e){return function(e,t,r){return e<t?t:e>r?r:e}(255*e,0,255)}class b{constructor(e,t,r,n){this.p0=e,this.c0=t,this.c1=r,this.p1=n}toQuadratic(){return{x:this.p0.x,y:this.p0.y,x1:this.p1.x,y1:this.p1.y,cx:(3*(this.c0.x+this.c1.x)-(this.p0.x+this.p1.x))/4,cy:(3*(this.c0.y+this.c1.y)-(this.p0.y+this.p1.y))/4}}quadError(){return Pi.sub(Pi.sub(this.p1,this.p0),Pi.mult(Pi.sub(this.c1,this.c0),3)).mag()/2}split(e){const t=Pi.lerp(this.p0,this.c0,e),r=Pi.lerp(this.c0,this.c1,e),n=Pi.lerp(t,r,e);this.c1=Pi.lerp(this.c1,this.p1,e),this.c0=Pi.lerp(r,this.c1,e);const i=Pi.lerp(n,this.c0,e),s=new b(this.p0,t,n,i);return this.p0=i,s}splitInflections(){const e=Pi.sub(this.c0,this.p0),t=Pi.sub(Pi.sub(this.c1,this.c0),e),r=Pi.sub(Pi.sub(Pi.sub(this.p1,this.c1),e),Pi.mult(t,2)),n=[];let i=t.x*r.y-t.y*r.x;if(0!==i){let s=e.x*r.y-e.y*r.x,o=e.x*t.y-e.y*t.x;const a=s*s-4*i*o;if(a>=0){i<0&&(i=-i,s=-s,o=-o);const e=Math.sqrt(a),t=(-s-e)/(2*i);let r=(-s+e)/(2*i);t>0&&t<1&&(n.push(this.split(t)),r=1-(1-r)/(1-t)),r>0&&r<1&&n.push(this.split(r))}}return n.push(this),n}}function x(e,t,r,n,s,o,a,u){const l=new b(new Pi(e,t),new Pi(r,n),new Pi(s,o),new Pi(a,u)).splitInflections(),h=[],c=30/i;for(let e of l){const t=[];let r;for(;r=c/e.quadError(),!(r>=.125);){const n=Math.pow(r,1/3),i=e.split(n),s=e.split(1-n/(1-n));h.push(i),t.push(e),e=s}r<1&&h.push(e.split(.5)),h.push(e),Array.prototype.push.apply(h,t.reverse())}return h}function _(e,t,r,n){y([e,r],[t,n],{x:e,y:t,cx:(e+r)/2,cy:(t+n)/2})}function w(e,t,r,n){return Math.abs(r-e)<1e-5&&Math.abs(n-t)<1e-5}let C,E,S,A;for(const e of d){const t=(e.x-o)/h,r=(e.y-u)/c;if(!w(C,E,t,r)){switch(e.type){case"M":S=t,A=r;break;case"L":_(C,E,t,r);break;case"Q":{const n=(e.x1-o)/h,i=(e.y1-u)/c;y([C,t,n],[E,r,i],{x:C,y:E,cx:n,cy:i});break}case"Z":w(C,E,S,A)?f.push({x:C,y:E}):(_(C,E,S,A),f.push({x:S,y:A}));break;case"C":{const n=x(C,E,(e.x1-o)/h,(e.y1-u)/c,(e.x2-o)/h,(e.y2-u)/c,t,r);for(let e=0;e<n.length;e++){const t=n[e].toQuadratic();y([t.x,t.x1,t.cx],[t.y,t.y1,t.cy],t)}break}default:throw new Error(`unknown command type: ${e.type}`)}C=t,E=r}}const D=f.length,T=this.strokeImageInfos.findImage(D),F=T.index;for(let e=0;e<D;++e){const t=f[e];n(T,v(t.x),v(t.y),v(t.cx),v(t.cy))}function I(e,t,r){const i=e.length,s=t.findImage(i),o=s.index;let a=0;for(let t=0;t<i;++t)a+=e[t].length;const u=r.findImage(a);for(let t=0;t<i;++t){const r=e[t],i=r.length,o=u.index;n(s,o>>7,127&o,i>>7,127&i);for(let e=0;e<i;++e){const t=r[e]+F;n(u,t>>7,127&t,0,0)}}return{cellImageInfo:u,dimOffset:o,dimImageInfo:s}}return t=this.glyphInfos[e.index]={glyph:e,uGlyphRect:[o,u,a,l],strokeImageInfo:T,strokes:f,colInfo:I(g,this.colDimImageInfos,this.colCellImageInfos),rowInfo:I(m,this.rowDimImageInfos,this.rowCellImageInfos)},t.uGridOffset=[t.colInfo.dimOffset,t.rowInfo.dimOffset],t}}zo.prototype._renderText=function(t,r,n,i,s){if(!this.states.textFont||"string"==typeof this.states.textFont)return void console.log("WEBGL: you must load and set a font before drawing text. See `loadFont` and `textFont` for more details.");if(n>=i||!this.states.fillColor)return;if(!e.Font.hasGlyphData(this.states.textFont))return void 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.");this.push();const o=this.states.strokeColor,a=this.states.drawMode;this.states.setValue("strokeColor",null),this.states.setValue("drawMode",Ee);const{font:u}=this.states.textFont;if(!u)throw new Error("In WebGL mode, textFont() needs to be given the result of loadFont() instead of a font family name.");const l=u._currentAxes(this);let h=u._getFontInfo(l);const c={x:r,y:n},d=this.states.textSize/(u.data?.head?.unitsPerEm||1e3);this.translate(c.x,c.y,0),this.scale(d,d,1);const p=!this._defaultFontShader,f=this._getFontShader();f.init(),f.bindShader("text"),p&&(f.setUniform("uGridImageSize",[64,64]),f.setUniform("uCellsImageSize",[64,64]),f.setUniform("uStrokeImageSize",[64,64]),f.setUniform("uGridSize",[9,9]));const m=this.states.fillSet?this.states.curFillColor:[0,0,0,1];this._setGlobalUniforms(f),this._applyColorBlend(m);let g=this.geometryBufferCache.getGeometryByID("glyph");g||(g=this._textGeom=new po(1,1,(function(){for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)this.vertices.push(new Pi(t,e,0)),this.uvs.push(t,e)}),this),g.gid="glyph",g.computeFaces().computeNormals(),this.geometryBufferCache.ensureCached(g));for(const e of this.buffers.text)e._prepareBuffer(g,f);f.setUniform("uMaterialColor",m),this._disableRemainingAttributes(f),this._beforeDrawText(),this.glyphDataCache=this.glyphDataCache||new Set;try{const e=u._positionGlyphs(t);for(const t of e){const e=h.getGlyphInfo(t);if(e.uGlyphRect){const r=e.rowInfo,n=e.colInfo,i=[e.strokeImageInfo.imageData,r.cellImageInfo.imageData,r.dimImageInfo.imageData,n.cellImageInfo.imageData,n.dimImageInfo.imageData];for(const e of i)this.glyphDataCache.delete(e),this.glyphDataCache.add(e);for(;this.glyphDataCache.size>this.maxCachedGlyphs();){const e=this.glyphDataCache.values().next().value;this.glyphDataCache.delete(e);const t=this.textures.get(e);t&&(t.remove(),this.textures.delete(e))}f.setUniform("uSamplerStrokes",e.strokeImageInfo.imageData),f.setUniform("uSamplerRowStrokes",r.cellImageInfo.imageData),f.setUniform("uSamplerRows",r.dimImageInfo.imageData),f.setUniform("uSamplerColStrokes",n.cellImageInfo.imageData),f.setUniform("uSamplerCols",n.dimImageInfo.imageData),f.setUniform("uGridOffset",e.uGridOffset),f.setUniform("uGlyphRect",e.uGlyphRect),f.setUniform("uGlyphOffset",t.x),f.bindTextures(),this._drawBuffers(g,{mode:4,count:1})}}}finally{f.unbindShader(),this.states.setValue("strokeColor",o),this.states.setValue("drawMode",a),this._afterDrawText(),this.pop()}}}"undefined"!=typeof p5&&Lv(p5,p5.prototype);var Vv='#define PI 3.141592\n\nprecision highp float;\nprecision highp int;\n\nuniform mat4 uViewMatrix;\nuniform mat3 uCameraNormalMatrix;\n\nuniform bool uUseLighting;\n\nuniform int uDirectionalLightCount;\nuniform vec3 uLightingDirection[5];\nuniform vec3 uDirectionalDiffuseColors[5];\nuniform vec3 uDirectionalSpecularColors[5];\n\nuniform int uPointLightCount;\nuniform vec3 uPointLightLocation[5];\nuniform vec3 uPointLightDiffuseColors[5];\t\nuniform vec3 uPointLightSpecularColors[5];\n\nuniform int uSpotLightCount;\nuniform float uSpotLightAngle[5];\nuniform float uSpotLightConc[5];\nuniform vec3 uSpotLightDiffuseColors[5];\nuniform vec3 uSpotLightSpecularColors[5];\nuniform vec3 uSpotLightLocation[5];\nuniform vec3 uSpotLightDirection[5];\n\nuniform bool uSpecular;\nuniform float uShininess;\nuniform float uMetallic;\n\nuniform float uConstantAttenuation;\nuniform float uLinearAttenuation;\nuniform float uQuadraticAttenuation;\n\n// setting from  _setImageLightUniforms()\n// boolean to initiate the calculateImageDiffuse and calculateImageSpecular\nuniform bool uUseImageLight;\n// texture for use in calculateImageDiffuse\nuniform sampler2D environmentMapDiffused;\n// texture for use in calculateImageSpecular\nuniform sampler2D environmentMapSpecular;\n\nconst float specularFactor = 2.0;\nconst float diffuseFactor = 0.73;\n\nstruct LightResult {\n  float specular;\n  float diffuse;\n};\n\nfloat _phongSpecular(\n  vec3 lightDirection,\n  vec3 viewDirection,\n  vec3 surfaceNormal,\n  float shininess) {\n\n  vec3 R = reflect(lightDirection, surfaceNormal);\n  return pow(max(0.0, dot(R, viewDirection)), shininess);\n}\n\nfloat _lambertDiffuse(vec3 lightDirection, vec3 surfaceNormal) {\n  return max(0.0, dot(-lightDirection, surfaceNormal));\n}\n\nLightResult _light(vec3 viewDirection, vec3 normal, vec3 lightVector, float shininess, float metallic) {\n\n  vec3 lightDir = normalize(lightVector);\n\n  //compute our diffuse & specular terms\n  LightResult lr;\n  float specularIntensity = mix(1.0, 0.4, metallic);\n  float diffuseIntensity = mix(1.0, 0.1, metallic);\n  if (uSpecular)\n    lr.specular = (_phongSpecular(lightDir, viewDirection, normal, shininess)) * specularIntensity;\n    lr.diffuse = _lambertDiffuse(lightDir, normal) * diffuseIntensity;\n  return lr;\n}\n\n// converts the range of "value" from [min1 to max1] to [min2 to max2]\nfloat map(float value, float min1, float max1, float min2, float max2) {\n  return min2 + (value - min1) * (max2 - min2) / (max1 - min1);\n}\n\nvec2 mapTextureToNormal( vec3 v ){\n  // x = r sin(phi) cos(theta)   \n  // y = r cos(phi)  \n  // z = r sin(phi) sin(theta)\n  float phi = acos( v.y );\n  // if phi is 0, then there are no x, z components\n  float theta = 0.0;\n  // else \n  theta = acos(v.x / sin(phi));\n  float sinTheta = v.z / sin(phi);\n  if (sinTheta < 0.0) {\n    // Turn it into -theta, but in the 0-2PI range\n    theta = 2.0 * PI - theta;\n  }\n  theta = theta / (2.0 * 3.14159);\n  phi = phi / 3.14159 ;\n  \n  vec2 angles = vec2( fract(theta + 0.25), 1.0 - phi );\n  return angles;\n}\n\n\nvec3 calculateImageDiffuse(vec3 vNormal, vec3 vViewPosition, float metallic){\n  // make 2 seperate builds \n  vec3 worldCameraPosition =  vec3(0.0, 0.0, 0.0);  // hardcoded world camera position\n  vec3 worldNormal = normalize(vNormal * uCameraNormalMatrix);\n  vec2 newTexCoor = mapTextureToNormal( worldNormal );\n  vec4 texture = TEXTURE( environmentMapDiffused, newTexCoor );\n  // this is to make the darker sections more dark\n  // png and jpg usually flatten the brightness so it is to reverse that\n  return mix(smoothstep(vec3(0.0), vec3(1.0), texture.xyz), vec3(0.0), metallic);\n}\n\nvec3 calculateImageSpecular(vec3 vNormal, vec3 vViewPosition, float shininess, float metallic){\n  vec3 worldCameraPosition =  vec3(0.0, 0.0, 0.0);\n  vec3 worldNormal = normalize(vNormal);\n  vec3 lightDirection = normalize( vViewPosition - worldCameraPosition );\n  vec3 R = reflect(lightDirection, worldNormal) * uCameraNormalMatrix;\n  vec2 newTexCoor = mapTextureToNormal( R );\n#ifdef WEBGL2\n  // In p5js the range of shininess is >= 1,\n  // Therefore roughness range will be ([0,1]*8)*20 or [0, 160]\n  // The factor of 8 is because currently the getSpecularTexture\n  // only calculated 8 different levels of roughness\n  // The factor of 20 is just to spread up this range so that,\n  // [1, max] of shininess is converted to [0,160] of roughness\n  float roughness = 20. / shininess;\n  vec4 outColor = textureLod(environmentMapSpecular, newTexCoor, roughness * 8.);\n#else\n  vec4 outColor = TEXTURE(environmentMapSpecular, newTexCoor);\n#endif\n  // this is to make the darker sections more dark\n  // png and jpg usually flatten the brightness so it is to reverse that\n  return mix(\n    pow(outColor.xyz, vec3(10)),\n    pow(outColor.xyz, vec3(1.2)),\n    metallic \n  );\n}\n\nvoid totalLight(\n  vec3 modelPosition,\n  vec3 normal,\n  float shininess,\n  float metallic,\n  out vec3 totalDiffuse,\n  out vec3 totalSpecular\n) {\n\n  totalSpecular = vec3(0.0);\n\n  if (!uUseLighting) {\n    totalDiffuse = vec3(1.0);\n    return;\n  }\n\n  totalDiffuse = vec3(0.0);\n\n  vec3 viewDirection = normalize(-modelPosition);\n\n  for (int j = 0; j < 5; j++) {\n    if (j < uDirectionalLightCount) {\n      vec3 lightVector = (uViewMatrix * vec4(uLightingDirection[j], 0.0)).xyz;\n      vec3 lightColor = uDirectionalDiffuseColors[j];\n      vec3 specularColor = uDirectionalSpecularColors[j];\n      LightResult result = _light(viewDirection, normal, lightVector, shininess, metallic);\n      totalDiffuse += result.diffuse * lightColor;\n      totalSpecular += result.specular * lightColor * specularColor;\n    }\n\n    if (j < uPointLightCount) {\n      vec3 lightPosition = (uViewMatrix * vec4(uPointLightLocation[j], 1.0)).xyz;\n      vec3 lightVector = modelPosition - lightPosition;\n      //calculate attenuation\n      float lightDistance = length(lightVector);\n      float lightFalloff = 1.0 / (uConstantAttenuation + lightDistance * uLinearAttenuation + (lightDistance * lightDistance) * uQuadraticAttenuation);\n      vec3 lightColor = lightFalloff * uPointLightDiffuseColors[j];\n      vec3 specularColor = lightFalloff * uPointLightSpecularColors[j];\n\n      LightResult result = _light(viewDirection, normal, lightVector, shininess, metallic);\n      totalDiffuse += result.diffuse * lightColor;\n      totalSpecular += result.specular * lightColor * specularColor;\n    }\n\n    if(j < uSpotLightCount) {\n      vec3 lightPosition = (uViewMatrix * vec4(uSpotLightLocation[j], 1.0)).xyz;\n      vec3 lightVector = modelPosition - lightPosition;\n    \n      float lightDistance = length(lightVector);\n      float lightFalloff = 1.0 / (uConstantAttenuation + lightDistance * uLinearAttenuation + (lightDistance * lightDistance) * uQuadraticAttenuation);\n\n      vec3 lightDirection = (uViewMatrix * vec4(uSpotLightDirection[j], 0.0)).xyz;\n      float spotDot = dot(normalize(lightVector), normalize(lightDirection));\n      float spotFalloff;\n      if(spotDot < uSpotLightAngle[j]) {\n        spotFalloff = 0.0;\n      }\n      else {\n        spotFalloff = pow(spotDot, uSpotLightConc[j]);\n      }\n      lightFalloff *= spotFalloff;\n\n      vec3 lightColor = uSpotLightDiffuseColors[j];\n      vec3 specularColor = uSpotLightSpecularColors[j];\n     \n      LightResult result = _light(viewDirection, normal, lightVector, shininess, metallic);\n      \n      totalDiffuse += result.diffuse * lightColor * lightFalloff;\n      totalSpecular += result.specular * lightColor * specularColor * lightFalloff;\n    }\n  }\n\n  if( uUseImageLight ){\n    totalDiffuse += calculateImageDiffuse(normal, modelPosition, metallic);\n    totalSpecular += calculateImageSpecular(normal, modelPosition, shininess, metallic);\n  }\n\n  totalDiffuse *= diffuseFactor;\n  totalSpecular *= specularFactor;\n}\n';const{lineDefs:Uv}=Ro(((e,t)=>`#define ${e} ${t}\n`)),zv={normalVert:"IN vec3 aPosition;\nIN vec3 aNormal;\nIN vec2 aTexCoord;\nIN vec4 aVertexColor;\n\n#define HOOK_DEFINES\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\nuniform mat4 uModelMatrix;\nuniform mat4 uViewMatrix;\nuniform mat3 uModelNormalMatrix;\nuniform mat3 uCameraNormalMatrix;\n#else\nuniform mat4 uModelViewMatrix;\nuniform mat3 uNormalMatrix;\n#endif\nuniform mat4 uProjectionMatrix;\n\nuniform vec4 uMaterialColor;\nuniform bool uUseVertexColor;\n\nOUT vec3 vVertexNormal;\nOUT highp vec2 vVertTexCoord;\nOUT vec4 vColor;\n\nstruct Vertex {\n  vec3 position;\n  vec3 normal;\n  vec2 texCoord;\n  vec4 color;\n};\n\nvoid main(void) {\n  HOOK_beforeVertex();\n\n  Vertex inputs;\n  inputs.position = aPosition;\n  inputs.normal = aNormal;\n  inputs.texCoord = aTexCoord;\n  inputs.color = (uUseVertexColor && aVertexColor.x >= 0.0) ? aVertexColor : uMaterialColor;\n#ifdef AUGMENTED_HOOK_getObjectInputs\n  inputs = HOOK_getObjectInputs(inputs);\n#endif\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\n  inputs.position = (uModelMatrix * vec4(inputs.position, 1.)).xyz;\n  inputs.normal = uModelNormalMatrix * inputs.normal;\n  inputs = HOOK_getWorldInputs(inputs);\n#endif\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\n  // Already multiplied by the model matrix, just apply view\n  inputs.position = (uViewMatrix * vec4(inputs.position, 1.)).xyz;\n  inputs.normal = uCameraNormalMatrix * inputs.normal;\n#else\n  // Apply both at once\n  inputs.position = (uModelViewMatrix * vec4(inputs.position, 1.)).xyz;\n  inputs.normal = uNormalMatrix * inputs.normal;\n#endif\n#ifdef AUGMENTED_HOOK_getCameraInputs\n  inputs = HOOK_getCameraInputs(inputs);\n#endif\n\n  // Pass varyings to fragment shader\n  vVertTexCoord = inputs.texCoord;\n  vVertexNormal = normalize(inputs.normal);\n  vColor = inputs.color;\n\n  gl_Position = uProjectionMatrix * vec4(inputs.position, 1.);\n\n  HOOK_afterVertex();\n}\n",normalFrag:"IN vec3 vVertexNormal;\nIN highp vec2 vVertTexCoord;\nvoid main(void) {\n  HOOK_beforeFragment();\n  OUT_COLOR = HOOK_getFinalColor(vec4(vVertexNormal, 1.0), vVertTexCoord);\n  HOOK_afterFragment();\n}",basicFrag:"IN vec4 vColor;\nIN highp vec2 vVertTexCoord;\nvoid main(void) {\n  HOOK_beforeFragment();\n  OUT_COLOR = HOOK_getFinalColor(vColor, vVertTexCoord);\n  OUT_COLOR.rgb *= OUT_COLOR.a; // Premultiply alpha before rendering\n  HOOK_afterFragment();\n}",lightVert:Vv+"// include lighting.glgl\n\nIN vec3 aPosition;\nIN vec3 aNormal;\nIN vec2 aTexCoord;\nIN vec4 aVertexColor;\n\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\nuniform mat3 uNormalMatrix;\n\nuniform bool uUseVertexColor;\nuniform vec4 uMaterialColor;\n\nOUT highp vec2 vVertTexCoord;\nOUT vec3 vDiffuseColor;\nOUT vec3 vSpecularColor;\nOUT vec4 vColor;\n\nvoid main(void) {\n\n  vec4 viewModelPosition = uModelViewMatrix * vec4(aPosition, 1.0);\n  gl_Position = uProjectionMatrix * viewModelPosition;\n\n  vec3 vertexNormal = normalize(uNormalMatrix * aNormal);\n  vVertTexCoord = aTexCoord;\n\n  totalLight(viewModelPosition.xyz, vertexNormal, vDiffuseColor, vSpecularColor);\n\n  for (int i = 0; i < 8; i++) {\n    if (i < uAmbientLightCount) {\n      vDiffuseColor += uAmbientColor[i];\n    }\n  }\n  \n  vColor = ((uUseVertexColor && aVertexColor.x >= 0.0) ? aVertexColor : uMaterialColor);\n}\n",lightTextureFrag:"uniform vec4 uTint;\nuniform sampler2D uSampler;\nuniform bool isTexture;\nuniform bool uEmissive;\n\nIN highp vec2 vVertTexCoord;\nIN vec3 vDiffuseColor;\nIN vec3 vSpecularColor;\nIN vec4 vColor;\n\nvoid main(void) {\n  if(uEmissive && !isTexture) {\n    OUT_COLOR = vColor;\n  }\n  else {\n    vec4 baseColor = isTexture\n      // Textures come in with premultiplied alpha. To apply tint and still have\n      // premultiplied alpha output, we need to multiply the RGB channels by the\n      // tint RGB, and all channels by the tint alpha.\n      ? TEXTURE(uSampler, vVertTexCoord) * vec4(uTint.rgb/255., 1.) * (uTint.a/255.)\n      // Colors come in with unmultiplied alpha, so we need to multiply the RGB\n      // channels by alpha to convert it to premultiplied alpha.\n      : vec4(vColor.rgb * vColor.a, vColor.a);\n    OUT_COLOR = vec4(baseColor.rgb * vDiffuseColor + vSpecularColor, baseColor.a);\n  }\n}\n",phongVert:"precision highp int;\n\n#define HOOK_DEFINES\n\nIN vec3 aPosition;\nIN vec3 aNormal;\nIN vec2 aTexCoord;\nIN vec4 aVertexColor;\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\nuniform mat4 uModelMatrix;\nuniform mat4 uViewMatrix;\nuniform mat3 uModelNormalMatrix;\nuniform mat3 uCameraNormalMatrix;\n#else\nuniform mat4 uModelViewMatrix;\nuniform mat3 uNormalMatrix;\n#endif\nuniform mat4 uProjectionMatrix;\n\nuniform bool uUseVertexColor;\nuniform vec4 uMaterialColor;\n\nOUT vec3 vNormal;\nOUT vec2 vTexCoord;\nOUT vec3 vViewPosition;\nOUT vec3 vAmbientColor;\nOUT vec4 vColor;\n\nstruct Vertex {\n  vec3 position;\n  vec3 normal;\n  vec2 texCoord;\n  vec4 color;\n};\n\nvoid main(void) {\n  HOOK_beforeVertex();\n\n  Vertex inputs;\n  inputs.position = aPosition;\n  inputs.normal = aNormal;\n  inputs.texCoord = aTexCoord;\n  inputs.color = (uUseVertexColor && aVertexColor.x >= 0.0) ? aVertexColor : uMaterialColor;\n#ifdef AUGMENTED_HOOK_getObjectInputs\n  inputs = HOOK_getObjectInputs(inputs);\n#endif\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\n  inputs.position = (uModelMatrix * vec4(inputs.position, 1.)).xyz;\n  inputs.normal = uModelNormalMatrix * inputs.normal;\n  inputs = HOOK_getWorldInputs(inputs);\n#endif\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\n  // Already multiplied by the model matrix, just apply view\n  inputs.position = (uViewMatrix * vec4(inputs.position, 1.)).xyz;\n  inputs.normal = uCameraNormalMatrix * inputs.normal;\n#else\n  // Apply both at once\n  inputs.position = (uModelViewMatrix * vec4(inputs.position, 1.)).xyz;\n  inputs.normal = uNormalMatrix * inputs.normal;\n#endif\n#ifdef AUGMENTED_HOOK_getCameraInputs\n  inputs = HOOK_getCameraInputs(inputs);\n#endif\n\n  // Pass varyings to fragment shader\n  vViewPosition = inputs.position;\n  vTexCoord = inputs.texCoord;\n  vNormal = inputs.normal;\n  vColor = inputs.color;\n\n  gl_Position = uProjectionMatrix * vec4(inputs.position, 1.);\n  HOOK_afterVertex();\n}\n",phongFrag:Vv+"// include lighting.glsl\nprecision highp int;\n\nuniform bool uHasSetAmbient;\nuniform vec3 uAmbientColor;\nuniform vec4 uSpecularMatColor;\nuniform vec4 uAmbientMatColor;\nuniform vec4 uEmissiveMatColor;\n\nuniform vec4 uTint;\nuniform sampler2D uSampler;\nuniform bool isTexture;\n\nIN vec3 vNormal;\nIN vec2 vTexCoord;\nIN vec3 vViewPosition;\nIN vec4 vColor;\n\nstruct ColorComponents {\n  vec3 baseColor;\n  float opacity;\n  vec3 ambientColor;\n  vec3 specularColor;\n  vec3 diffuse;\n  vec3 ambient;\n  vec3 specular;\n  vec3 emissive;\n};\n\nstruct Inputs {\n  vec3 normal;\n  vec2 texCoord;\n  vec3 ambientLight;\n  vec3 ambientMaterial;\n  vec3 specularMaterial;\n  vec3 emissiveMaterial;\n  vec4 color;\n  float shininess;\n  float metalness;\n};\n\nvoid main(void) {\n  HOOK_beforeFragment();\n\n  Inputs inputs;\n  inputs.normal = normalize(vNormal);\n  inputs.texCoord = vTexCoord;\n  inputs.ambientLight = uAmbientColor;\n  inputs.color = isTexture\n      ? TEXTURE(uSampler, vTexCoord) * (vec4(uTint.rgb/255., 1.) * uTint.a/255.)\n      : vColor;\n  if (isTexture && inputs.color.a > 0.0) {\n    // Textures come in with premultiplied alpha. Temporarily unpremultiply it\n    // so hooks users don't have to think about premultiplied alpha.\n    inputs.color.rgb /= inputs.color.a;\n  }\n  inputs.shininess = uShininess;\n  inputs.metalness = uMetallic;\n  inputs.ambientMaterial = uHasSetAmbient ? uAmbientMatColor.rgb : inputs.color.rgb;\n  inputs.specularMaterial = uSpecularMatColor.rgb;\n  inputs.emissiveMaterial = uEmissiveMatColor.rgb;\n  inputs = HOOK_getPixelInputs(inputs);\n\n  vec3 diffuse;\n  vec3 specular;\n  totalLight(vViewPosition, inputs.normal, inputs.shininess, inputs.metalness, diffuse, specular);\n\n  // Calculating final color as result of all lights (plus emissive term).\n\n  vec4 baseColor = inputs.color;\n  ColorComponents c;\n  c.opacity = baseColor.a;\n  c.baseColor = baseColor.rgb;\n  c.ambientColor = inputs.ambientMaterial;\n  c.specularColor = inputs.specularMaterial;\n  c.diffuse = diffuse;\n  c.ambient = inputs.ambientLight;\n  c.specular = specular;\n  c.emissive = inputs.emissiveMaterial;\n  OUT_COLOR = HOOK_getFinalColor(HOOK_combineColors(c), vTexCoord);\n  OUT_COLOR.rgb *= OUT_COLOR.a; // Premultiply alpha before rendering\n  HOOK_afterFragment();\n}\n",fontVert:"IN vec3 aPosition;\nIN vec2 aTexCoord;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nuniform vec4 uGlyphRect;\nuniform float uGlyphOffset;\n\nOUT vec2 vTexCoord;\n\nvoid main() {\n  vec4 positionVec4 = vec4(aPosition, 1.0);\n\n  // scale by the size of the glyph's rectangle\n  positionVec4.xy *= uGlyphRect.zw - uGlyphRect.xy;\n\n  // Expand glyph bounding boxes by 1px on each side to give a bit of room\n  // for antialiasing\n  vec3 newOrigin = (uModelViewMatrix * vec4(0., 0., 0., 1.)).xyz;\n  vec3 newDX = (uModelViewMatrix * vec4(1., 0., 0., 1.)).xyz;\n  vec3 newDY = (uModelViewMatrix * vec4(0., 1., 0., 1.)).xyz;\n  vec2 pixelScale = vec2(\n    1. / length(newOrigin - newDX),\n    1. / length(newOrigin - newDY)\n  );\n  vec2 offset = pixelScale * normalize(aTexCoord - vec2(0.5, 0.5));\n  vec2 textureOffset = offset * (1. / vec2(\n    uGlyphRect.z - uGlyphRect.x,\n    uGlyphRect.w - uGlyphRect.y\n  ));\n\n  // move to the corner of the glyph\n  positionVec4.xy += uGlyphRect.xy;\n\n  // move to the letter's line offset\n  positionVec4.x += uGlyphOffset;\n\n  positionVec4.xy += offset;\n  \n  gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n  vTexCoord = aTexCoord + textureOffset;\n}\n",fontFrag:"#ifndef WEBGL2\n#extension GL_OES_standard_derivatives : enable\n#endif\n\n#if 0\n  // simulate integer math using floats\n\t#define int float\n\t#define ivec2 vec2\n\t#define INT(x) float(x)\n\n\tint ifloor(float v) { return floor(v); }\n\tivec2 ifloor(vec2 v) { return floor(v); }\n\n#else\n  // use native integer math\n\tprecision highp int;\n\t#define INT(x) x\n\n\tint ifloor(float v) { return int(v); }\n\tint ifloor(int v) { return v; }\n\tivec2 ifloor(vec2 v) { return ivec2(v); }\n\n#endif\n\nuniform sampler2D uSamplerStrokes;\nuniform sampler2D uSamplerRowStrokes;\nuniform sampler2D uSamplerRows;\nuniform sampler2D uSamplerColStrokes;\nuniform sampler2D uSamplerCols;\n\nuniform ivec2 uStrokeImageSize;\nuniform ivec2 uCellsImageSize;\nuniform ivec2 uGridImageSize;\n\nuniform ivec2 uGridOffset;\nuniform ivec2 uGridSize;\nuniform vec4 uMaterialColor;\n\nIN vec2 vTexCoord;\n\n// some helper functions\nint ROUND(float v) { return ifloor(v + 0.5); }\nivec2 ROUND(vec2 v) { return ifloor(v + 0.5); }\nfloat saturate(float v) { return clamp(v, 0.0, 1.0); }\nvec2 saturate(vec2 v) { return clamp(v, 0.0, 1.0); }\n\nint mul(float v1, int v2) {\n  return ifloor(v1 * float(v2));\n}\n\nivec2 mul(vec2 v1, ivec2 v2) {\n  return ifloor(v1 * vec2(v2) + 0.5);\n}\n\n// unpack a 16-bit integer from a float vec2\nint getInt16(vec2 v) {\n  ivec2 iv = ROUND(v * 255.0);\n  return iv.x * INT(128) + iv.y;\n}\n\nvec2 pixelScale;\nvec2 coverage = vec2(0.0);\nvec2 weight = vec2(0.5);\nconst float minDistance = 1.0/8192.0;\nconst float hardness = 1.05; // amount of antialias\n\n// the maximum number of curves in a glyph\nconst int N = INT(250);\n\n// retrieves an indexed pixel from a sampler\nvec4 getTexel(sampler2D sampler, int pos, ivec2 size) {\n  int width = size.x;\n  int y = ifloor(pos / width);\n  int x = pos - y * width;  // pos % width\n\n  return TEXTURE(sampler, (vec2(x, y) + 0.5) / vec2(size));\n}\n\nvoid calulateCrossings(vec2 p0, vec2 p1, vec2 p2, out vec2 C1, out vec2 C2) {\n\n  // get the coefficients of the quadratic in t\n  vec2 a = p0 - p1 * 2.0 + p2;\n  vec2 b = p0 - p1;\n  vec2 c = p0 - vTexCoord;\n\n  // found out which values of 't' it crosses the axes\n  vec2 surd = sqrt(max(vec2(0.0), b * b - a * c));\n  vec2 t1 = ((b - surd) / a).yx;\n  vec2 t2 = ((b + surd) / a).yx;\n\n  // approximate straight lines to avoid rounding errors\n  if (abs(a.y) < 0.001)\n    t1.x = t2.x = c.y / (2.0 * b.y);\n\n  if (abs(a.x) < 0.001)\n    t1.y = t2.y = c.x / (2.0 * b.x);\n\n  // plug into quadratic formula to find the corrdinates of the crossings\n  C1 = ((a * t1 - b * 2.0) * t1 + c) * pixelScale;\n  C2 = ((a * t2 - b * 2.0) * t2 + c) * pixelScale;\n}\n\nvoid coverageX(vec2 p0, vec2 p1, vec2 p2) {\n\n  vec2 C1, C2;\n  calulateCrossings(p0, p1, p2, C1, C2);\n\n  // determine on which side of the x-axis the points lie\n  bool y0 = p0.y > vTexCoord.y;\n  bool y1 = p1.y > vTexCoord.y;\n  bool y2 = p2.y > vTexCoord.y;\n\n  // could web be under the curve (after t1)?\n  if (y1 ? !y2 : y0) {\n    // add the coverage for t1\n    coverage.x += saturate(C1.x + 0.5);\n    // calculate the anti-aliasing for t1\n    weight.x = min(weight.x, abs(C1.x));\n  }\n\n  // are we outside the curve (after t2)?\n  if (y1 ? !y0 : y2) {\n    // subtract the coverage for t2\n    coverage.x -= saturate(C2.x + 0.5);\n    // calculate the anti-aliasing for t2\n    weight.x = min(weight.x, abs(C2.x));\n  }\n}\n\n// this is essentially the same as coverageX, but with the axes swapped\nvoid coverageY(vec2 p0, vec2 p1, vec2 p2) {\n\n  vec2 C1, C2;\n  calulateCrossings(p0, p1, p2, C1, C2);\n\n  bool x0 = p0.x > vTexCoord.x;\n  bool x1 = p1.x > vTexCoord.x;\n  bool x2 = p2.x > vTexCoord.x;\n\n  if (x1 ? !x2 : x0) {\n    coverage.y -= saturate(C1.y + 0.5);\n    weight.y = min(weight.y, abs(C1.y));\n  }\n\n  if (x1 ? !x0 : x2) {\n    coverage.y += saturate(C2.y + 0.5);\n    weight.y = min(weight.y, abs(C2.y));\n  }\n}\n\nvoid main() {\n\n  // calculate the pixel scale based on screen-coordinates\n  pixelScale = hardness / fwidth(vTexCoord);\n\n  // which grid cell is this pixel in?\n  ivec2 gridCoord = ifloor(vTexCoord * vec2(uGridSize));\n\n  // intersect curves in this row\n  {\n    // the index into the row info bitmap\n    int rowIndex = gridCoord.y + uGridOffset.y;\n    // fetch the info texel\n    vec4 rowInfo = getTexel(uSamplerRows, rowIndex, uGridImageSize);\n    // unpack the rowInfo\n    int rowStrokeIndex = getInt16(rowInfo.xy);\n    int rowStrokeCount = getInt16(rowInfo.zw);\n\n    for (int iRowStroke = INT(0); iRowStroke < N; iRowStroke++) {\n      if (iRowStroke >= rowStrokeCount)\n        break;\n\n      // each stroke is made up of 3 points: the start and control point\n      // and the start of the next curve.\n      // fetch the indices of this pair of strokes:\n      vec4 strokeIndices = getTexel(uSamplerRowStrokes, rowStrokeIndex++, uCellsImageSize);\n\n      // unpack the stroke index\n      int strokePos = getInt16(strokeIndices.xy);\n\n      // fetch the two strokes\n      vec4 stroke0 = getTexel(uSamplerStrokes, strokePos + INT(0), uStrokeImageSize);\n      vec4 stroke1 = getTexel(uSamplerStrokes, strokePos + INT(1), uStrokeImageSize);\n\n      // calculate the coverage\n      coverageX(stroke0.xy, stroke0.zw, stroke1.xy);\n    }\n  }\n\n  // intersect curves in this column\n  {\n    int colIndex = gridCoord.x + uGridOffset.x;\n    vec4 colInfo = getTexel(uSamplerCols, colIndex, uGridImageSize);\n    int colStrokeIndex = getInt16(colInfo.xy);\n    int colStrokeCount = getInt16(colInfo.zw);\n    \n    for (int iColStroke = INT(0); iColStroke < N; iColStroke++) {\n      if (iColStroke >= colStrokeCount)\n        break;\n\n      vec4 strokeIndices = getTexel(uSamplerColStrokes, colStrokeIndex++, uCellsImageSize);\n\n      int strokePos = getInt16(strokeIndices.xy);\n      vec4 stroke0 = getTexel(uSamplerStrokes, strokePos + INT(0), uStrokeImageSize);\n      vec4 stroke1 = getTexel(uSamplerStrokes, strokePos + INT(1), uStrokeImageSize);\n      coverageY(stroke0.xy, stroke0.zw, stroke1.xy);\n    }\n  }\n\n  weight = saturate(1.0 - weight * 2.0);\n  float distance = max(weight.x + weight.y, minDistance); // manhattan approx.\n  float antialias = abs(dot(coverage, weight) / distance);\n  float cover = min(abs(coverage.x), abs(coverage.y));\n  OUT_COLOR = vec4(uMaterialColor.rgb, 1.) * uMaterialColor.a;\n  OUT_COLOR *= saturate(max(antialias, cover));\n}\n",lineVert:Uv+"/*\n  Part of the Processing project - http://processing.org\n  Copyright (c) 2012-15 The Processing Foundation\n  Copyright (c) 2004-12 Ben Fry and Casey Reas\n  Copyright (c) 2001-04 Massachusetts Institute of Technology\n  This library is free software; you can redistribute it and/or\n  modify it under the terms of the GNU Lesser General Public\n  License as published by the Free Software Foundation, version 2.1.\n  This library is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n  Lesser General Public License for more details.\n  You should have received a copy of the GNU Lesser General\n  Public License along with this library; if not, write to the\n  Free Software Foundation, Inc., 59 Temple Place, Suite 330,\n  Boston, MA  02111-1307  USA\n*/\n\n#define PROCESSING_LINE_SHADER\n\n#define HOOK_DEFINES\n\nprecision highp int;\nprecision highp float;\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\nuniform mat4 uModelMatrix;\nuniform mat4 uViewMatrix;\n#else\nuniform mat4 uModelViewMatrix;\n#endif\n\nuniform mat4 uProjectionMatrix;\nuniform float uStrokeWeight;\n\nuniform bool uUseLineColor;\nuniform bool uSimpleLines;\nuniform vec4 uMaterialColor;\n\nuniform vec4 uViewport;\nuniform int uPerspective;\nuniform int uStrokeJoin;\n\nIN vec3 aPosition;\nIN vec3 aTangentIn;\nIN vec3 aTangentOut;\nIN float aSide;\nIN vec4 aVertexColor;\n\nOUT vec4 vColor;\nOUT vec2 vTangent;\nOUT vec2 vCenter;\nOUT vec2 vPosition;\nOUT float vMaxDist;\nOUT float vCap;\nOUT float vJoin;\nOUT float vStrokeWeight;\n\nvec2 lineIntersection(vec2 aPoint, vec2 aDir, vec2 bPoint, vec2 bDir) {\n  // Rotate and translate so a starts at the origin and goes out to the right\n  bPoint -= aPoint;\n  vec2 rotatedBFrom = vec2(\n    bPoint.x*aDir.x + bPoint.y*aDir.y,\n    bPoint.y*aDir.x - bPoint.x*aDir.y\n  );\n  vec2 bTo = bPoint + bDir;\n  vec2 rotatedBTo = vec2(\n    bTo.x*aDir.x + bTo.y*aDir.y,\n    bTo.y*aDir.x - bTo.x*aDir.y\n  );\n  float intersectionDistance =\n    rotatedBTo.x + (rotatedBFrom.x - rotatedBTo.x) * rotatedBTo.y /\n    (rotatedBTo.y - rotatedBFrom.y);\n  return aPoint + aDir * intersectionDistance;\n}\n\nstruct StrokeVertex {\n  vec3 position;\n  vec3 tangentIn;\n  vec3 tangentOut;\n  vec4 color;\n  float weight;\n};\n\nvoid main() {\n  HOOK_beforeVertex();\n\n  if (!uSimpleLines) {\n      // Caps have one of either the in or out tangent set to 0\n      vCap = (aTangentIn == vec3(0.)) != (aTangentOut == vec3(0.)) ? 1. : 0.;\n\n      // Joins have two unique, defined tangents\n      vJoin = (\n          aTangentIn != vec3(0.) &&\n          aTangentOut != vec3(0.) &&\n          aTangentIn != aTangentOut\n      ) ? 1. : 0.;\n  }\n\n  StrokeVertex inputs;\n  inputs.position = aPosition.xyz;\n  inputs.color = uUseLineColor ? aVertexColor : uMaterialColor;\n  inputs.weight = uStrokeWeight;\n  inputs.tangentIn = aTangentIn;\n  inputs.tangentOut = aTangentOut;\n\n#ifdef AUGMENTED_HOOK_getObjectInputs\n  inputs = HOOK_getObjectInputs(inputs);\n#endif\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\n  inputs.position = (uModelMatrix * vec4(inputs.position, 1.)).xyz;\n  inputs.tangentIn = (uModelMatrix * vec4(aTangentIn, 0.)).xyz;\n  inputs.tangentOut = (uModelMatrix * vec4(aTangentOut, 0.)).xyz;\n  inputs = HOOK_getWorldInputs(inputs);\n#endif\n\n#ifdef AUGMENTED_HOOK_getWorldInputs\n  // Already multiplied by the model matrix, just apply view\n  inputs.position = (uViewMatrix * vec4(inputs.position, 1.)).xyz;\n  inputs.tangentIn = (uViewMatrix * vec4(aTangentIn, 0.)).xyz;\n  inputs.tangentOut = (uViewMatrix * vec4(aTangentOut, 0.)).xyz;\n#else\n  // Apply both at once\n  inputs.position = (uModelViewMatrix * vec4(inputs.position, 1.)).xyz;\n  inputs.tangentIn = (uModelViewMatrix * vec4(aTangentIn, 0.)).xyz;\n  inputs.tangentOut = (uModelViewMatrix * vec4(aTangentOut, 0.)).xyz;\n#endif\n#ifdef AUGMENTED_HOOK_getCameraInputs\n  inputs = HOOK_getCameraInputs(inputs);\n#endif\n\n  vec4 posp = vec4(inputs.position, 1.);\n  vec4 posqIn = vec4(inputs.position + inputs.tangentIn, 1.);\n  vec4 posqOut = vec4(inputs.position + inputs.tangentOut, 1.);\n  vStrokeWeight = inputs.weight;\n\n  float facingCamera = pow(\n    // The word space tangent's z value is 0 if it's facing the camera\n    abs(normalize(posqIn-posp).z),\n\n    // Using pow() here to ramp `facingCamera` up from 0 to 1 really quickly\n    // so most lines get scaled and don't get clipped\n    0.25\n  );\n\n  // Moving vertices slightly toward the camera\n  // to avoid depth-fighting with the fill triangles.\n  // A mix of scaling and offsetting is used based on distance\n  // Discussion here:\n  // https://github.com/processing/p5.js/issues/7200 \n\n  // using a scale <1 moves the lines towards nearby camera\n  // in order to prevent popping effects due to half of\n  // the line disappearing behind the geometry faces.\n  float zDistance = -posp.z; \n  float distanceFactor = smoothstep(0.0, 800.0, zDistance); \n  \n  // Discussed here:\n  // http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=252848  \n  float scale = mix(1., 0.995, facingCamera);\n  float dynamicScale = mix(scale, 1.0, distanceFactor); // Closer = more scale, farther = less\n\n  posp.xyz = posp.xyz * dynamicScale;\n  posqIn.xyz = posqIn.xyz * dynamicScale;\n  posqOut.xyz = posqOut.xyz * dynamicScale;\n\n  // Moving vertices slightly toward camera when far away \n  // https://github.com/processing/p5.js/issues/6956 \n  float zOffset = mix(0., -1., facingCamera);\n  float dynamicZAdjustment = mix(0.0, zOffset, distanceFactor); // Closer = less zAdjustment, farther = more\n\n  posp.z -= dynamicZAdjustment;\n  posqIn.z -= dynamicZAdjustment;\n  posqOut.z -= dynamicZAdjustment;\n  \n  vec4 p = uProjectionMatrix * posp;\n  vec4 qIn = uProjectionMatrix * posqIn;\n  vec4 qOut = uProjectionMatrix * posqOut;\n\n  // formula to convert from clip space (range -1..1) to screen space (range 0..[width or height])\n  // screen_p = (p.xy/p.w + <1,1>) * 0.5 * uViewport.zw\n\n  // prevent division by W by transforming the tangent formula (div by 0 causes\n  // the line to disappear, see https://github.com/processing/processing/issues/5183)\n  // t = screen_q - screen_p\n  //\n  // tangent is normalized and we don't care which aDirection it points to (+-)\n  // t = +- normalize( screen_q - screen_p )\n  // t = +- normalize( (q.xy/q.w+<1,1>)*0.5*uViewport.zw - (p.xy/p.w+<1,1>)*0.5*uViewport.zw )\n  //\n  // extract common factor, <1,1> - <1,1> cancels out\n  // t = +- normalize( (q.xy/q.w - p.xy/p.w) * 0.5 * uViewport.zw )\n  //\n  // convert to common divisor\n  // t = +- normalize( ((q.xy*p.w - p.xy*q.w) / (p.w*q.w)) * 0.5 * uViewport.zw )\n  //\n  // remove the common scalar divisor/factor, not needed due to normalize and +-\n  // (keep uViewport - can't remove because it has different components for x and y\n  //  and corrects for aspect ratio, see https://github.com/processing/processing/issues/5181)\n  // t = +- normalize( (q.xy*p.w - p.xy*q.w) * uViewport.zw )\n\n  vec2 tangentIn = normalize((qIn.xy*p.w - p.xy*qIn.w) * uViewport.zw);\n  vec2 tangentOut = normalize((qOut.xy*p.w - p.xy*qOut.w) * uViewport.zw);\n\n  vec2 curPerspScale;\n  if(uPerspective == 1) {\n    // Perspective ---\n    // convert from world to clip by multiplying with projection scaling factor\n    // to get the right thickness (see https://github.com/processing/processing/issues/5182)\n\n    // The y value of the projection matrix may be flipped if rendering to a Framebuffer.\n    // Multiplying again by its sign here negates the flip to get just the scale.\n    curPerspScale = (uProjectionMatrix * vec4(1, sign(uProjectionMatrix[1][1]), 0, 0)).xy;\n  } else {\n    // No Perspective ---\n    // multiply by W (to cancel out division by W later in the pipeline) and\n    // convert from screen to clip (derived from clip to screen above)\n    curPerspScale = p.w / (0.5 * uViewport.zw);\n  }\n\n  vec2 offset;\n  if (vJoin == 1. && !uSimpleLines) {\n    vTangent = normalize(tangentIn + tangentOut);\n    vec2 normalIn = vec2(-tangentIn.y, tangentIn.x);\n    vec2 normalOut = vec2(-tangentOut.y, tangentOut.x);\n    float side = sign(aSide);\n    float sideEnum = abs(aSide);\n\n    // We generate vertices for joins on either side of the centerline, but\n    // the \"elbow\" side is the only one needing a join. By not setting the\n    // offset for the other side, all its vertices will end up in the same\n    // spot and not render, effectively discarding it.\n    if (sign(dot(tangentOut, vec2(-tangentIn.y, tangentIn.x))) != side) {\n      // Side enums:\n      //   1: the side going into the join\n      //   2: the middle of the join\n      //   3: the side going out of the join\n      if (sideEnum == 2.) {\n        // Calculate the position + tangent on either side of the join, and\n        // find where the lines intersect to find the elbow of the join\n        vec2 c = (posp.xy/posp.w + vec2(1.,1.)) * 0.5 * uViewport.zw;\n        vec2 intersection = lineIntersection(\n          c + (side * normalIn * inputs.weight / 2.),\n          tangentIn,\n          c + (side * normalOut * inputs.weight / 2.),\n          tangentOut\n        );\n        offset = (intersection - c);\n\n        // When lines are thick and the angle of the join approaches 180, the\n        // elbow might be really far from the center. We'll apply a limit to\n        // the magnitude to avoid lines going across the whole screen when this\n        // happens.\n        float mag = length(offset);\n        float maxMag = 3. * inputs.weight;\n        if (mag > maxMag) {\n          offset *= maxMag / mag;\n        }\n      } else if (sideEnum == 1.) {\n        offset = side * normalIn * inputs.weight / 2.;\n      } else if (sideEnum == 3.) {\n        offset = side * normalOut * inputs.weight / 2.;\n      }\n    }\n    if (uStrokeJoin == STROKE_JOIN_BEVEL) {\n      vec2 avgNormal = vec2(-vTangent.y, vTangent.x);\n      vMaxDist = abs(dot(avgNormal, normalIn * inputs.weight / 2.));\n    } else {\n      vMaxDist = inputs.weight / 2.;\n    }\n  } else {\n    vec2 tangent = aTangentIn == vec3(0.) ? tangentOut : tangentIn;\n\n    vTangent = tangent;\n    vec2 normal = vec2(-tangent.y, tangent.x);\n\n    float normalOffset = sign(aSide);\n    // Caps will have side values of -2 or 2 on the edge of the cap that\n    // extends out from the line\n    float tangentOffset = abs(aSide) - 1.;\n    offset = (normal * normalOffset + tangent * tangentOffset) *\n      inputs.weight * 0.5;\n    vMaxDist = inputs.weight / 2.;\n  }\n\n  vCenter = p.xy;\n  vPosition = vCenter + offset;\n  vColor = inputs.color;\n\n  gl_Position.xy = p.xy + offset.xy * curPerspScale;\n  gl_Position.zw = p.zw;\n  \n  HOOK_afterVertex();\n}\n",lineFrag:Uv+"precision highp int;\nprecision highp float;\n\nuniform vec4 uMaterialColor;\nuniform int uStrokeCap;\nuniform int uStrokeJoin;\n\nIN vec4 vColor;\nIN vec2 vTangent;\nIN vec2 vCenter;\nIN vec2 vPosition;\nIN float vStrokeWeight;\nIN float vMaxDist;\nIN float vCap;\nIN float vJoin;\n\nfloat distSquared(vec2 a, vec2 b) {\n  vec2 aToB = b - a;\n  return dot(aToB, aToB);\n}\n\nstruct Inputs {\n  vec4 color;\n  vec2 tangent;\n  vec2 center;\n  vec2 position;\n  float strokeWeight;\n};\n\nvoid main() {\n  HOOK_beforeFragment();\n\n  Inputs inputs;\n  inputs.color = vColor;\n  inputs.tangent = vTangent;\n  inputs.center = vCenter;\n  inputs.position = vPosition;\n  inputs.strokeWeight = vStrokeWeight;\n  inputs = HOOK_getPixelInputs(inputs);\n\n  if (vCap > 0.) {\n    if (\n      uStrokeCap == STROKE_CAP_ROUND &&\n      HOOK_shouldDiscard(distSquared(inputs.position, inputs.center) > inputs.strokeWeight * inputs.strokeWeight * 0.25)\n    ) {\n      discard;\n    } else if (\n      uStrokeCap == STROKE_CAP_SQUARE &&\n      HOOK_shouldDiscard(dot(inputs.position - inputs.center, inputs.tangent) > 0.)\n    ) {\n      discard;\n    // Use full area for PROJECT\n    } else if (HOOK_shouldDiscard(false)) {\n      discard;\n    }\n  } else if (vJoin > 0.) {\n    if (\n      uStrokeJoin == STROKE_JOIN_ROUND &&\n      HOOK_shouldDiscard(distSquared(inputs.position, inputs.center) > inputs.strokeWeight * inputs.strokeWeight * 0.25)\n    ) {\n      discard;\n    } else if (uStrokeJoin == STROKE_JOIN_BEVEL) {\n      vec2 normal = vec2(-inputs.tangent.y, inputs.tangent.x);\n      if (HOOK_shouldDiscard(abs(dot(inputs.position - inputs.center, normal)) > vMaxDist)) {\n        discard;\n      }\n    // Use full area for MITER\n    } else if (HOOK_shouldDiscard(false)) {\n      discard;\n    }\n  }\n  OUT_COLOR = HOOK_getFinalColor(inputs.color, vec2(0.0, 0.0));\n  OUT_COLOR.rgb *= OUT_COLOR.a;\n  HOOK_afterFragment();\n}\n",imageLightVert:"precision highp float;\nIN vec3 aPosition;\nIN vec3 aNormal;\nIN vec2 aTexCoord;\n\nOUT vec3 localPos;\nOUT vec3 vWorldNormal;\nOUT vec3 vWorldPosition;\nOUT vec2 vTexCoord;\n\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\nuniform mat3 uNormalMatrix;\n\nvoid main() {\n  // Multiply the position by the matrix.\n  vec4 viewModelPosition = uModelViewMatrix * vec4(aPosition, 1.0);\n  gl_Position = uProjectionMatrix * viewModelPosition;  \n  \n  // orient the normals and pass to the fragment shader\n  vWorldNormal = uNormalMatrix * aNormal;\n  \n  // send the view position to the fragment shader\n  vWorldPosition = (uModelViewMatrix * vec4(aPosition, 1.0)).xyz;\n  \n  localPos = vWorldPosition;\n  vTexCoord = aTexCoord;\n}\n\n\n/*\nin 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.\n*/\n",imageLightDiffusedFrag:"precision highp float;\nIN vec3 localPos;\n\n// the HDR cubemap converted (can be from an equirectangular environment map.)\nuniform sampler2D environmentMap;\nIN vec2 vTexCoord;\n\nconst float PI = 3.14159265359;\n\nvec2 nTOE( vec3 v ){\n  // x = r sin(phi) cos(theta)   \n  // y = r cos(phi)  \n  // z = r sin(phi) sin(theta)\n  float phi = acos( v.y );\n  // if phi is 0, then there are no x, z components\n  float theta = 0.0;\n  // else \n  theta = acos(v.x / sin(phi));\n  float sinTheta = v.z / sin(phi);\n  if (sinTheta < 0.0) {\n    // Turn it into -theta, but in the 0-2PI range\n    theta = 2.0 * PI - theta;\n  }\n  theta = theta / (2.0 * 3.14159);\n  phi = phi / 3.14159 ;\n  \n  vec2 angles = vec2( phi, theta );\n  return angles;\n}\n\nfloat random(vec2 p) {\n  vec3 p3  = fract(vec3(p.xyx) * .1031);\n  p3 += dot(p3, p3.yzx + 33.33);\n  return fract((p3.x + p3.y) * p3.z);\n}\n\nvoid main()\n{   \t \n\t// the sample direction equals the hemisphere's orientation\n  float phi = vTexCoord.x * 2.0 * PI;\n  float theta = vTexCoord.y * PI;\n  float x = sin(theta) * cos(phi);\n  float y = sin(theta) * sin(phi);\n  float z = cos(theta);\n  vec3 normal = vec3( x, y, z);\n\n\t// Discretely sampling the hemisphere given the integral's\n  // spherical coordinates translates to the following fragment code:\n\tvec3 irradiance = vec3(0.0);  \n\tvec3 up\t= vec3(0.0, 1.0, 0.0);\n\tvec3 right = normalize(cross(up, normal));\n\tup = normalize(cross(normal, right));\n\n\t//  We specify a fixed sampleDelta delta value to traverse\n  // the hemisphere; decreasing or increasing the sample delta\n  // will increase or decrease the accuracy respectively.\n\tconst float sampleDelta = 0.100;\n\tfloat nrSamples = 0.0;\n  float randomOffset = random(gl_FragCoord.xy) * sampleDelta;\n\tfor(float rawPhi = 0.0; rawPhi < 2.0 * PI; rawPhi += sampleDelta)\n\t{\n    float phi = rawPhi + randomOffset;\n    for(float rawTheta = 0.0; rawTheta < ( 0.5 ) * PI; rawTheta += sampleDelta)\n    {\n      float theta = rawTheta + randomOffset;\n      // spherical to cartesian (in tangent space) // tangent space to world // add each sample result to irradiance\n      float x = sin(theta) * cos(phi);\n      float y = sin(theta) * sin(phi);\n      float z = cos(theta);\n      vec3 tangentSample = vec3( x, y, z);\n      \n      vec3 sampleVec = tangentSample.x * right + tangentSample.y * up + tangentSample.z * normal;\n        irradiance += (TEXTURE(environmentMap, nTOE(sampleVec)).xyz) * cos(theta) * sin(theta);\n      nrSamples++;\n    }\n\t}\n\t// divide by the total number of samples taken, giving us the average sampled irradiance.\n\tirradiance = PI * irradiance * (1.0 / float(nrSamples )) ;\n  \n \n\tOUT_COLOR = vec4(irradiance, 1.0);\n}",imageLightSpecularFrag:"precision highp float;\r\nIN vec3 localPos;\r\nIN vec2 vTexCoord;\r\n\r\n// our texture\r\nuniform sampler2D environmentMap;\r\nuniform float roughness;\r\n\r\nconst float PI = 3.14159265359;\r\n\r\nfloat VanDerCorput(int bits);\r\nvec2 HammersleyNoBitOps(int i, int N);\r\nvec3 ImportanceSampleGGX(vec2 Xi, vec3 N, float roughness);\r\n\r\n\r\nvec2 nTOE( vec3 v ){\r\n  // x = r sin(phi) cos(theta)   \r\n  // y = r cos(phi)  \r\n  // z = r sin(phi) sin(theta)\r\n  float phi = acos( v.y );\r\n  // if phi is 0, then there are no x, z components\r\n  float theta = 0.0;\r\n  // else \r\n  theta = acos(v.x / sin(phi));\r\n  float sinTheta = v.z / sin(phi);\r\n  if (sinTheta < 0.0) {\r\n    // Turn it into -theta, but in the 0-2PI range\r\n    theta = 2.0 * PI - theta;\r\n  }\r\n  theta = theta / (2.0 * 3.14159);\r\n  phi = phi / 3.14159 ;\r\n  \r\n  vec2 angles = vec2( phi, theta );\r\n  return angles;\r\n}\r\n\r\n\r\nvoid main(){\r\n  const int SAMPLE_COUNT = 400; // 4096\r\n  int lowRoughnessLimit = int(pow(2.0,(roughness+0.1)*20.0));\r\n  float totalWeight = 0.0;\r\n  vec3 prefilteredColor = vec3(0.0);\r\n  float phi = vTexCoord.x * 2.0 * PI;\r\n  float theta = vTexCoord.y * PI;\r\n  float x = sin(theta) * cos(phi);\r\n  float y = sin(theta) * sin(phi);\r\n  float z = cos(theta);\r\n  vec3 N = vec3(x,y,z);\r\n  vec3 V = N;\r\n  for (int i = 0; i < SAMPLE_COUNT; ++i)\r\n  {\r\n    // break at smaller sample numbers for low roughness levels\r\n    if(i == lowRoughnessLimit)\r\n    {\r\n      break;\r\n    }\r\n    vec2 Xi = HammersleyNoBitOps(i, SAMPLE_COUNT);\r\n    vec3 H = ImportanceSampleGGX(Xi, N, roughness);\r\n    vec3 L = normalize(2.0 * dot(V, H) * H - V);\r\n\r\n    float NdotL = max(dot(N, L), 0.0);\r\n    if (NdotL > 0.0)\r\n    {\r\n      prefilteredColor += TEXTURE(environmentMap, nTOE(L)).xyz * NdotL;\r\n      totalWeight += NdotL;\r\n    }\r\n  }\r\n  prefilteredColor = prefilteredColor / totalWeight;\r\n\r\n OUT_COLOR  = vec4(prefilteredColor, 1.0);\r\n}\r\n\r\nvec3 ImportanceSampleGGX(vec2 Xi, vec3 N, float roughness){\r\n  float a = roughness * roughness;\r\n\r\n  float phi = 2.0 * PI * Xi.x;\r\n  float cosTheta = sqrt((1.0 - Xi.y) / (1.0 + (a * a - 1.0) * Xi.y));\r\n  float sinTheta = sqrt(1.0 - cosTheta * cosTheta);\r\n  // from spherical coordinates to cartesian coordinates\r\n  vec3 H;\r\n  H.x = cos(phi) * sinTheta;\r\n  H.y = sin(phi) * sinTheta;\r\n  H.z = cosTheta;\r\n\r\n  // from tangent-space vector to world-space sample vector\r\n  vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\r\n  vec3 tangent = normalize(cross(up, N));\r\n  vec3 bitangent = cross(N, tangent);\r\n\r\n  vec3 sampleVec = tangent * H.x + bitangent * H.y + N * H.z;\r\n  return normalize(sampleVec);\r\n}\r\n\r\n\r\nfloat VanDerCorput(int n, int base)\r\n{\r\n#ifdef WEBGL2\r\n\r\n    uint bits = uint(n);\r\n    bits = (bits << 16u) | (bits >> 16u);\r\n    bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\r\n    bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\r\n    bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\r\n    bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\r\n    return float(bits) * 2.3283064365386963e-10; // / 0x100000000\r\n\r\n#else\r\n\r\n  float invBase = 1.0 / float(base);\r\n  float denom = 1.0;\r\n  float result = 0.0;\r\n\r\n\r\n  for (int i = 0; i < 32; ++i)\r\n  {\r\n        if (n > 0)\r\n        {\r\n        denom = mod(float(n), 2.0);\r\n        result += denom * invBase;\r\n        invBase = invBase / 2.0;\r\n        n = int(float(n) / 2.0);\r\n        }\r\n  }\r\n\r\n\r\n  return result;\r\n\r\n#endif\r\n}\r\n\r\nvec2 HammersleyNoBitOps(int i, int N)\r\n{\r\n  return vec2(float(i) / float(N), VanDerCorput(i, 2));\r\n}\r\n",filterBaseVert:ba,filterBaseFrag:va};for(const e in zv)zv[e]=xa+zv[e];class jv extends zo{constructor(e,t,r,n,i){super(e,t,r,n,i),this.webglVersion===s?this.blendExt=this.GL:this.blendExt=this.GL.getExtension("EXT_blend_minmax"),this._userEnabledStencil=!1,this._internalEnable=this.drawingContext.enable,this._internalDisable=this.drawingContext.disable,this.drawingContext.enable=e=>(e===this.drawingContext.STENCIL_TEST&&(this._clipping||(this._userEnabledStencil=!0)),this._internalEnable.call(this.drawingContext,e)),this.drawingContext.disable=e=>(e===this.drawingContext.STENCIL_TEST&&(this._userEnabledStencil=!1),this._internalDisable.call(this.drawingContext,e)),this._cachedBlendMode=void 0,this.strandsBackend=iu}setupContext(){this._setAttributeDefaults(this._pInst),this._initContext(),this.GL=this.drawingContext}_applyBlendMode(){if(this._cachedBlendMode===this.states.curBlendMode)return;const e=this.GL;switch(this.states.curBlendMode){case Y:e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case J:e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ONE);break;case K:e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_ALPHA);break;case ie:e.blendEquation(e.FUNC_ADD),e.blendFunc(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA);break;case se:e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ONE_MINUS_SRC_COLOR);break;case ne:e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.ONE_MINUS_DST_COLOR,e.ONE_MINUS_SRC_COLOR,e.ONE,e.ONE);break;case oe:e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO);break;case re:e.blendEquationSeparate(e.FUNC_REVERSE_SUBTRACT,e.FUNC_ADD),e.blendFuncSeparate(e.ONE,e.ONE,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Q:this.blendExt?(e.blendEquationSeparate(this.blendExt.MIN||this.blendExt.MIN_EXT,e.FUNC_ADD),e.blendFuncSeparate(e.ONE,e.ONE,e.ONE,e.ONE)):console.warn("blendMode(DARKEST) does not work in your browser in WEBGL mode.");break;case ee:this.blendExt?(e.blendEquationSeparate(this.blendExt.MAX||this.blendExt.MAX_EXT,e.FUNC_ADD),e.blendFuncSeparate(e.ONE,e.ONE,e.ONE,e.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(){}_useShader(e){this.GL.useProgram(e._glProgram)}_disableRemainingAttributes(e){for(const t of this.registerEnabled.values())Object.keys(e.attributes).some((r=>e.attributes[r].location===t))||(this.GL.disableVertexAttribArray(t),this.registerEnabled.delete(t))}_drawBuffers(e,{mode:t=4,count:r}){const n=this.GL,i=this.geometryBufferCache.getCached(e);if(i)if("stroke"===this._curShader.shaderType)if(1===r)n.drawArrays(n.TRIANGLES,0,e.lineVertices.length/3);else try{n.drawArraysInstanced(n.TRIANGLES,0,e.lineVertices.length/3,r)}catch(e){console.log("🌸 p5.js says: Instancing is only supported in WebGL2 mode")}else if("text"===this._curShader.shaderType)this._bindBuffer(i.indexBuffer,n.ELEMENT_ARRAY_BUFFER),n.drawElements(n.TRIANGLES,6,n.UNSIGNED_SHORT,0);else if(i.indexBuffer){if(this._bindBuffer(i.indexBuffer,n.ELEMENT_ARRAY_BUFFER),this._pInst.webglVersion!==s&&i.indexBufferType===n.UNSIGNED_INT&&!n.getExtension("OES_element_index_uint"))throw new Error("Unable to render a 3d model with > 65535 triangles. Your web browser does not support the WebGL Extension OES_element_index_uint.");if(1===r)n.drawElements(n.TRIANGLES,3*e.faces.length,i.indexBufferType,0);else try{n.drawElementsInstanced(n.TRIANGLES,3*e.faces.length,i.indexBufferType,0,r)}catch(e){console.log("🌸 p5.js says: Instancing is only supported in WebGL2 mode")}}else{let i;if(i=4===t?n.TRIANGLES:6===t?n.TRIANGLE_FAN:n.TRIANGLE_STRIP,1===r)n.drawArrays(i,0,e.vertices.length);else try{n.drawArraysInstanced(i,0,e.vertices.length,r)}catch(e){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(e){const t={alpha:!0,depth:!0,stencil:!0,antialias:navigator.userAgent.toLowerCase().includes("safari"),premultipliedAlpha:!0,preserveDrawingBuffer:!0,perPixelLighting:!0,version:2};null===e._glAttributes?e._glAttributes=t:e._glAttributes=Object.assign(t,e._glAttributes)}_setAttributes(e,t){if(void 0===this._pInst._glAttributes)return void console.log("You are trying to use setAttributes on a p5.Graphics object that does not use a WEBGL renderer.");let r=!0;void 0!==t?(null===this._pInst._glAttributes&&(this._pInst._glAttributes={}),this._pInst._glAttributes[e]!==t&&(this._pInst._glAttributes[e]=t,r=!1)):e instanceof Object&&this._pInst._glAttributes!==e&&(this._pInst._glAttributes=e,r=!1),this.isP3D&&!r&&(!this._pInst._setupDone&&this.geometryBufferCache.numCached()>0?p5._friendlyError("Sorry, Could not set the attributes, you need to call setAttributes() before calling the other drawing methods in setup()"):(this._resetContext(null,null,jv),this.states.curCamera&&(this.states.curCamera._renderer=this._renderer)))}_initContext(){if(1!==this._pInst._glAttributes?.version&&(this.drawingContext=this.canvas.getContext("webgl2",this._pInst._glAttributes)),this.webglVersion=this.drawingContext?s:i,this._pInst.webglVersion=this.webglVersion,this.drawingContext||(this.drawingContext=this.canvas.getContext("webgl",this._pInst._glAttributes)||this.canvas.getContext("experimental-webgl",this._pInst._glAttributes)),null===this.drawingContext)throw new Error("Error creating webgl context");{const e=this.drawingContext;e.enable(e.DEPTH_TEST),e.depthFunc(e.LEQUAL),e.viewport(0,0,e.drawingBufferWidth,e.drawingBufferHeight),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this._viewport=this.drawingContext.getParameter(this.drawingContext.VIEWPORT)}}_updateSize(){}_getMaxTextureSize(){const e=this.drawingContext;return e.getParameter(e.MAX_TEXTURE_SIZE)}_adjustDimensions(e,t,r=this._pixelDensity){this._maxTextureSize||(this._maxTextureSize=this._getMaxTextureSize());let n=this._maxTextureSize,i=Math.floor(n/r),s=Math.min(e,i),o=Math.min(t,i);return s===e&&o===t||console.warn(`Warning: The requested width/height exceeds hardware limits. Adjusting dimensions to width: ${s}, height: ${o}.`),{adjustedWidth:s,adjustedHeight:o}}_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(){const e=this.GL;e.clearStencil(0),e.clear(e.STENCIL_BUFFER_BIT),this._internalEnable.call(e,e.STENCIL_TEST),this._stencilTestOn=!0,e.stencilFunc(e.ALWAYS,1,255),e.stencilOp(e.KEEP,e.KEEP,e.REPLACE),e.disable(e.DEPTH_TEST)}_unapplyClip(){const e=this.GL;e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.stencilFunc(this._clipInvert?e.EQUAL:e.NOTEQUAL,0,255),e.enable(e.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(e,t){const r=this.GL;return ia(r,null,e,t,r.RGBA,r.UNSIGNED_BYTE,this._pInst.height*this._pInst.pixelDensity())}loadPixels(){if(!0!==this._pInst._glAttributes.preserveDrawingBuffer)return void console.log("loadPixels only works in WebGL when preserveDrawingBuffer is true.");const e=this._pixelDensity,t=this.GL;this.pixels=na(this.pixels,t,null,0,0,this.width*e,this.height*e,t.RGBA,t.UNSIGNED_BYTE,this.height*e)}updatePixels(){const e=this._getTempFramebuffer();e.pixels=this.pixels,e.updatePixels(),this.push(),this.resetMatrix(),this.clear(),this.states.setValue("imageMode",w),this.image(e,0,0,e.width,e.height,-e.width/2,-e.height/2,e.width,e.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}viewport(e,t){this._viewport=[0,0,e,t],this.GL.viewport(0,0,e,t)}_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(...e){const t=e[0]||0,r=e[1]||0,n=e[2]||0;let i=e[3]||0;const s=this.activeFramebuffer();s&&s.format===Ve&&!s.antialias&&0===i&&(i=1e-10),this.GL.clearColor(t*i,r*i,n*i,i),this.GL.clearDepth(1),this.GL.clear(this.GL.COLOR_BUFFER_BIT|this.GL.DEPTH_BUFFER_BIT)}clearDepth(e=1){this.GL.clearDepth(e),this.GL.clear(this.GL.DEPTH_BUFFER_BIT)}_applyStencilTestIfClipping(){const e=this.drawTarget();e._isClipApplied!==this._stencilTestOn&&(e._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 new Error("The material shader does not support hooks without perPixelLighting. Try turning it back on.");return super.baseMaterialShader()}_getLightShader(){return this._defaultLightShader||(this._pInst._glAttributes.perPixelLighting?this._defaultLightShader=new Wo(this,this._webGL2CompatibilityPrefix("vert","highp")+zv.phongVert,this._webGL2CompatibilityPrefix("frag","highp")+zv.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) {\n                vec4 color = vec4(0.);\n                color.rgb += components.diffuse * components.baseColor;\n                color.rgb += components.ambient * components.ambientColor;\n                color.rgb += components.specular * components.specularColor;\n                color.rgb += components.emissive;\n                color.a = components.opacity;\n                return color;\n              }","vec4 getFinalColor":"(vec4 color, vec2 texCoord) { return color; }","void afterFragment":"() {}"}}):this._defaultLightShader=new Wo(this,this._webGL2CompatibilityPrefix("vert","highp")+zv.lightVert,this._webGL2CompatibilityPrefix("frag","highp")+zv.lightTextureFrag)),this._defaultLightShader}_getNormalShader(){return this._defaultNormalShader||(this._defaultNormalShader=new Wo(this,this._webGL2CompatibilityPrefix("vert","highp")+zv.normalVert,this._webGL2CompatibilityPrefix("frag","highp")+zv.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||(this._defaultColorShader=new Wo(this,this._webGL2CompatibilityPrefix("vert","highp")+zv.normalVert,this._webGL2CompatibilityPrefix("frag","highp")+zv.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||(this._defaultLineShader=new Wo(this,this._webGL2CompatibilityPrefix("vert","highp")+zv.lineVert,this._webGL2CompatibilityPrefix("frag","highp")+zv.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===i&&this.GL.getExtension("OES_standard_derivatives"),this._defaultFontShader=new Wo(this,this._webGL2CompatibilityPrefix("vert","highp")+zv.fontVert,this._webGL2CompatibilityPrefix("frag","highp")+zv.fontFrag)),this._defaultFontShader}baseFilterShader(){return this._baseFilterShader||(this._baseFilterShader=new Wo(this,this._webGL2CompatibilityPrefix("vert","highp")+zv.filterBaseVert,this._webGL2CompatibilityPrefix("frag","highp")+zv.filterBaseFrag,{vertex:{},fragment:{"vec4 getColor":"(FilterInputs inputs, in sampler2D canvasContent) {\n              return getTexture(canvasContent, inputs.texCoord);\n            }"},hookAliases:{getColor:["filterColor"]}})),this._baseFilterShader}_webGL2CompatibilityPrefix(e,t){let r="";return this.webglVersion===s&&(r+="#version 300 es\n#define WEBGL2\n"),"vert"===e?r+="#define VERTEX_SHADER\n":"frag"===e&&(r+="#define FRAGMENT_SHADER\n"),t&&(r+=`precision ${t} float;\n`),r}_createImageLightShader(e){if("diffused"===e)return new Wo(this,this._webGL2CompatibilityPrefix("vert","highp")+zv.imageLightVert,this._webGL2CompatibilityPrefix("frag","highp")+zv.imageLightDiffusedFrag);if("specular"===e)return new Wo(this,this._webGL2CompatibilityPrefix("vert","highp")+zv.imageLightVert,this._webGL2CompatibilityPrefix("frag","highp")+zv.imageLightSpecularFrag);throw new Error(`Unknown imageLight shader type: ${e}`)}_createMipmapTexture(e){return new ta(this,e,{})}_prepareMipmapData(e,t){return{levels:[],size:e,mipLevels:t}}_accumulateMipLevel(e,t,r,n,i){const s=e.get().drawingContext.getImageData(0,0,n,i);t.levels.push(s)}_finalizeMipmapTexture(e){return new ta(this,e.levels,{minFilter:Ae,magFilter:we})}createMipmapTextureHandle({levels:e,format:t,dataType:r,width:n,height:i}){const s=this.GL,o=s.createTexture();s.bindTexture(s.TEXTURE_2D,o);const a=s.RGBA,u=s.UNSIGNED_BYTE;for(let t=0;t<e.length;t++)s.texImage2D(s.TEXTURE_2D,t,a,a,u,e[t]);return s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR_MIPMAP_LINEAR),s.bindTexture(s.TEXTURE_2D,null),{texture:o,glFormat:a,glDataType:u}}_bindBuffer(e,t,r,n,i){const s=this.GL;if(t||(t=s.ARRAY_BUFFER),s.bindBuffer(t,e),void 0!==r){const e=this._normalizeBufferData(r,n);s.bufferData(t,e,i||s.STATIC_DRAW)}}_prepareBuffer(e,t,r){const n=r.attributes,i=this.GL,s=this._getOrMakeCachedBuffers(t),o=n[e.attr];if(!o)return;let a=s[e.dst];const u=t[e.src];if(u&&u.length>0){const n=!a;if(n&&(s[e.dst]=a=i.createBuffer()),i.bindBuffer(i.ARRAY_BUFFER,a),n||!1!==t.dirtyFlags[e.src]){const r=e.map,n=r?r(u):u;this._bindBuffer(a,i.ARRAY_BUFFER,n),t.dirtyFlags[e.src]=!1}r.enableAttrib(o,e.size)}else{const e=o.location;if(-1===e||!this.registerEnabled.has(e))return;i.disableVertexAttribArray(e),this.registerEnabled.delete(e)}}_enableAttrib(e,t,r,n,i,s,o){const a=t.location,u=this.GL;this.registerEnabled.has(a)||(u.enableVertexAttribArray(a),this.registerEnabled.add(a)),u.vertexAttribPointer(a,r,n||u.FLOAT,i||!1,s||0,o||0)}_ensureGeometryBuffers(e,t,r){const n=this.GL;if(t){let i=e.indexBuffer;i||(i=n.createBuffer()),this._bindBuffer(i,n.ELEMENT_ARRAY_BUFFER,t,r),e.indexBuffer=i,e.indexBufferType=r===Uint32Array?n.UNSIGNED_INT:n.UNSIGNED_SHORT}else e.indexBuffer&&(n.deleteBuffer(e.indexBuffer),e.indexBuffer=null)}_freeBuffers(e){const t=this.GL;function r(r){for(const n of r)e[n.dst]&&(t.deleteBuffer(e[n.dst]),e[n.dst]=null)}e.indexBuffer&&t.deleteBuffer(e.indexBuffer),r(this.buffers.stroke),r(this.buffers.fill),r(this.buffers.user)}_initShader(e){const t=this.GL,r=t.createShader(t.VERTEX_SHADER);if(t.shaderSource(r,e.vertSrc()),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new Error(`Yikes! An error occurred compiling the vertex shader: ${t.getShaderInfoLog(r)} in:\n\n${e.vertSrc()}`);const n=t.createShader(t.FRAGMENT_SHADER);if(t.shaderSource(n,e.fragSrc()),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new Error(`Darn! An error occurred compiling the fragment shader: ${t.getShaderInfoLog(n)}`);const i=t.createProgram();if(t.attachShader(i,r),t.attachShader(i,n),t.linkProgram(i),!t.getProgramParameter(i,t.LINK_STATUS))throw new Error(`Snap! Error linking shader program: ${t.getProgramInfoLog(i)}`);e._compiled=!0,e._glProgram=i,e._vertShader=r,e._fragShader=n}_finalizeShader(){}_getShaderAttributes(e){return ua(e,this.GL)}getUniformMetadata(e){return aa(e,this.GL)}updateUniformValue(e,t,r){return oa(e,t,r,(e=>this.getTexture(e)),this.GL)}_updateTexture(e,t){const r=this.GL;r.activeTexture(r.TEXTURE0+e.samplerIndex),t.bindTexture(),t.update(),r.uniform1i(e.location,e.samplerIndex)}bindTexture(e){this.GL.bindTexture(this.GL.TEXTURE_2D,e.getTexture().texture)}unbindTexture(){this.GL.bindTexture(this.GL.TEXTURE_2D,null)}_unbindFramebufferTexture(e){const t=this.GL,r=this._getEmptyTexture();t.activeTexture(t.TEXTURE0+e.samplerIndex),r.bindTexture(),t.uniform1i(e.location,e.samplerIndex)}createTexture({width:e,height:t,format:r,dataType:n}){const i=this.GL,s=i.createTexture();return i.bindTexture(i.TEXTURE_2D,s),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,e,t,0,i.RGBA,i.UNSIGNED_BYTE,null),{texture:s,glFormat:i.RGBA,glDataType:i.UNSIGNED_BYTE}}createFramebufferTextureHandle(e){return null}uploadTextureFromSource({texture:e,glFormat:t,glDataType:r},n){const i=this.GL;i.texImage2D(i.TEXTURE_2D,0,t,t,r,n)}uploadTextureFromData({texture:e,glFormat:t,glDataType:r},n,i,s){const o=this.GL;o.texImage2D(o.TEXTURE_2D,0,t,i,s,0,t,r,n)}getSampler(e){}bindTextureToShader({texture:e},t,r,n){const i=this.GL;i.activeTexture(i.TEXTURE0+n),i.bindTexture(i.TEXTURE_2D,e);const s=i.getUniformLocation(glProgram,r);i.uniform1i(s,n)}setTextureParams(e){return sa(e,this.GL,this.webglVersion)}deleteTexture({texture:e}){this.GL.deleteTexture(e)}_applyColorBlend(e,t){const r=this.GL,n=this.states.drawMode===Ee,i=t||this.states.userFillShader||this.states.userStrokeShader||n||this.states.curBlendMode!==Y||e[e.length-1]<1||this._isErasing;return i!==this._isBlending&&(i||this.states.curBlendMode!==Y&&this.states.curBlendMode!==J?r.enable(r.BLEND):r.disable(r.BLEND),r.depthMask(!0),this._isBlending=i),this._applyBlendMode(),e}uniformNameFromHookKey(e){return e.slice(e.indexOf(" ")+1)}populateHooks(e,t,r){return la(e,t,r)}getShaderHookTypes(e,t){return su(e,t)}defaultFramebufferAlpha(){return this._pInst._glAttributes.alpha}defaultFramebufferAntialias(){return!!this.supportsFramebufferAntialias()&&this._pInst._glAttributes.antialias}supportsFramebufferAntialias(){return this.webglVersion===s}createFramebufferResources(e){const t=this.GL;if(e.framebuffer=t.createFramebuffer(),!e.framebuffer)throw new Error("Unable to create a framebuffer");if(e.antialias&&(e.aaFramebuffer=t.createFramebuffer(),!e.aaFramebuffer))throw new Error("Unable to create a framebuffer for antialiasing")}validateFramebufferFormats(e){const t=this.GL;e.useDepth&&this.webglVersion===i&&!t.getExtension("WEBGL_depth_texture")&&(console.warn("Unable to create depth textures in this environment. Falling back to a framebuffer without depth."),e.useDepth=!1),e.useDepth&&this.webglVersion===i&&e.depthFormat===ze&&(console.warn("FLOAT depth format is unavailable in WebGL 1. Defaulting to UNSIGNED_INT."),e.depthFormat=Ue),[Ve,ze,je].includes(e.format)||(console.warn("Unknown Framebuffer format. Please use UNSIGNED_BYTE, FLOAT, or HALF_FLOAT. Defaulting to UNSIGNED_BYTE."),e.format=Ve),e.useDepth&&![Ue,ze].includes(e.depthFormat)&&(console.warn("Unknown Framebuffer depth format. Please use UNSIGNED_INT or FLOAT. Defaulting to FLOAT."),e.depthFormat=ze);const r=ha(this);r.float||e.format!==ze||(console.warn("This environment does not support FLOAT textures. Falling back to UNSIGNED_BYTE."),e.format=Ve),e.useDepth&&!r.float&&e.depthFormat===ze&&(console.warn("This environment does not support FLOAT depth textures. Falling back to UNSIGNED_INT."),e.depthFormat=Ue),r.halfFloat||e.format!==je||(console.warn("This environment does not support HALF_FLOAT textures. Falling back to UNSIGNED_BYTE."),e.format=Ve),e.channels===In&&[ze,je].includes(e.format)&&(console.warn("FLOAT and HALF_FLOAT formats do not work cross-platform with only RGB channels. Falling back to RGBA."),e.channels=Vn)}recreateFramebufferTextures(e){const t=this.GL,r=t.getParameter(t.TEXTURE_BINDING_2D),n=t.getParameter(t.FRAMEBUFFER_BINDING),i=t.createTexture();if(!i)throw new Error("Unable to create color texture");t.bindTexture(t.TEXTURE_2D,i);const s=this._getFramebufferColorFormat(e);if(t.texImage2D(t.TEXTURE_2D,0,s.internalFormat,e.width*e.density,e.height*e.density,0,s.format,s.type,null),e.colorTexture=i,t.bindFramebuffer(t.FRAMEBUFFER,e.framebuffer),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0),e.useDepth){const r=t.createTexture();if(!r)throw new Error("Unable to create depth texture");const n=this._getFramebufferDepthFormat(e);t.bindTexture(t.TEXTURE_2D,r),t.texImage2D(t.TEXTURE_2D,0,n.internalFormat,e.width*e.density,e.height*e.density,0,n.format,n.type,null),t.framebufferTexture2D(t.FRAMEBUFFER,e.useStencil?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,t.TEXTURE_2D,r,0),e.depthTexture=r}if(e.antialias){if(e.colorRenderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,e.colorRenderbuffer),t.renderbufferStorageMultisample(t.RENDERBUFFER,Math.max(0,Math.min(e.antialiasSamples,t.getParameter(t.MAX_SAMPLES))),s.internalFormat,e.width*e.density,e.height*e.density),e.useDepth){const r=this._getFramebufferDepthFormat(e);e.depthRenderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,e.depthRenderbuffer),t.renderbufferStorageMultisample(t.RENDERBUFFER,Math.max(0,Math.min(e.antialiasSamples,t.getParameter(t.MAX_SAMPLES))),r.internalFormat,e.width*e.density,e.height*e.density)}t.bindFramebuffer(t.FRAMEBUFFER,e.aaFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,e.colorRenderbuffer),e.useDepth&&t.framebufferRenderbuffer(t.FRAMEBUFFER,e.useStencil?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e.depthRenderbuffer)}t.bindTexture(t.TEXTURE_2D,r),t.bindFramebuffer(t.FRAMEBUFFER,n)}_getFramebufferColorFormat(e){let t,r,n;const i=this.GL;if(t=e.format===ze?i.FLOAT:e.format===je?this.webglVersion===s?i.HALF_FLOAT:i.getExtension("OES_texture_half_float").HALF_FLOAT_OES:i.UNSIGNED_BYTE,r=e.channels===Vn?i.RGBA:i.RGB,this.webglVersion===s){n={[i.FLOAT]:{[i.RGBA]:i.RGBA32F},[i.HALF_FLOAT]:{[i.RGBA]:i.RGBA16F},[i.UNSIGNED_BYTE]:{[i.RGBA]:i.RGBA8,[i.RGB]:i.RGB8}}[t][r]}else n=e.format===je?i.RGBA:r;return{internalFormat:n,format:r,type:t}}_getFramebufferDepthFormat(e){let t,r,n;const i=this.GL;return t=e.useStencil?e.depthFormat===ze?i.FLOAT_32_UNSIGNED_INT_24_8_REV:this.webglVersion===s?i.UNSIGNED_INT_24_8:i.getExtension("WEBGL_depth_texture").UNSIGNED_INT_24_8_WEBGL:e.depthFormat===ze?i.FLOAT:i.UNSIGNED_INT,r=e.useStencil?i.DEPTH_STENCIL:i.DEPTH_COMPONENT,n=e.useStencil?e.depthFormat===ze?i.DEPTH32F_STENCIL8:this.webglVersion===s?i.DEPTH24_STENCIL8:i.DEPTH_STENCIL:this.webglVersion===s?e.depthFormat===ze?i.DEPTH_COMPONENT32F:i.DEPTH_COMPONENT24:i.DEPTH_COMPONENT,{internalFormat:n,format:r,type:t}}_deleteFramebufferTexture(e){this.GL.deleteTexture(e.rawTexture().texture),this.textures.delete(e)}deleteFramebufferTextures(e){this._deleteFramebufferTexture(e.color),e.depth&&this._deleteFramebufferTexture(e.depth);const t=this.GL;e.colorRenderbuffer&&t.deleteRenderbuffer(e.colorRenderbuffer),e.depthRenderbuffer&&t.deleteRenderbuffer(e.depthRenderbuffer)}deleteFramebufferResources(e){const t=this.GL;t.deleteFramebuffer(e.framebuffer),e.aaFramebuffer&&t.deleteFramebuffer(e.aaFramebuffer),e.depthRenderbuffer&&t.deleteRenderbuffer(e.depthRenderbuffer),e.colorRenderbuffer&&t.deleteRenderbuffer(e.colorRenderbuffer)}getFramebufferToBind(e){return e.antialias?e.aaFramebuffer:e.framebuffer}updateFramebufferTexture(e,t){if(e.antialias){const r=this.GL;r.bindFramebuffer(r.READ_FRAMEBUFFER,e.aaFramebuffer),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,e.framebuffer);const n={colorTexture:[r.COLOR_BUFFER_BIT,e.colorP5Texture.magFilter===we?r.LINEAR:r.NEAREST]};e.useDepth&&(n.depthTexture=[r.DEPTH_BUFFER_BIT,e.depthP5Texture.magFilter===we?r.LINEAR:r.NEAREST]);const[i,s]=n[t];r.blitFramebuffer(0,0,e.width*e.density,e.height*e.density,0,0,e.width*e.density,e.height*e.density,i,s);const o=this.activeFramebuffer();this.bindFramebuffer(o)}}bindFramebuffer(e){const t=this.GL;t.bindFramebuffer(t.FRAMEBUFFER,e?this.getFramebufferToBind(e):null)}framebufferYScale(){return-1}readFramebufferPixels(e){const t=this.GL,r=this.activeFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,e.framebuffer);const n=this._getFramebufferColorFormat(e),i=na(e.pixels,t,e.framebuffer,0,0,e.width*e.density,e.height*e.density,n.format,n.type);return this.bindFramebuffer(r),i}readFramebufferPixel(e,t,r){const n=this._getFramebufferColorFormat(e);return ia(this.GL,e.framebuffer,t,r,n.format,n.type)}readFramebufferRegion(e,t,r,n,i){const s=this.GL,o=this._getFramebufferColorFormat(e),a=na(void 0,s,e.framebuffer,t*e.density,r*e.density,n*e.density,i*e.density,o.format,o.type),u=new Uint8ClampedArray(n*i*e.density*e.density*4);u.fill(255);const l=o.format===s.RGB?3:4;for(let t=0;t<i*e.density;t++)for(let r=0;r<n*e.density;r++)for(let i=0;i<4;i++){const s=4*(t*n*e.density+r)+i;if(i<l){const o=4===l?s:(t*n*e.density+r)*l+i;u[s]=a[o]}}const h=new Mi(n*e.density,i*e.density);return h.imageData=h.canvas.getContext("2d").createImageData(h.width,h.height),h.imageData.data.set(u),h.pixels=h.imageData.data,h.updatePixels(),1!==e.density&&h.pixelDensity(e.density),h}updateFramebufferPixels(e){const t=this.GL;e.colorP5Texture.bindTexture();const r=this._getFramebufferColorFormat(e),n=r.format===t.RGBA?4:3,i=e.width*e.height*e.density*e.density*n,s=r.type===t.UNSIGNED_BYTE?Uint8Array:Float32Array;if(!(e.pixels instanceof s)||e.pixels.length!==i)throw new Error("The pixels array has not been set correctly. Please call loadPixels() before updatePixels().");t.texImage2D(t.TEXTURE_2D,0,r.internalFormat,e.width*e.density,e.height*e.density,0,r.format,r.type,e.pixels),e.colorP5Texture.unbindTexture(),e.dirty.colorTexture=!1;const o=this.activeFramebuffer();e.antialias?(e.begin(),this.push(),this.states.setValue("imageMode",w),this.setCamera(e.filterCamera),this.resetMatrix(),this.states.setValue("strokeColor",null),this.clear(),this._drawingFilter=!0,this.image(e,0,0,e.width,e.height,-this.width/2,-this.height/2,this.width,this.height),this._drawingFilter=!1,this.pop(),e.useDepth&&(t.clearDepth(1),t.clear(t.DEPTH_BUFFER_BIT)),e.end()):(t.bindFramebuffer(t.FRAMEBUFFER,e.framebuffer),e.useDepth&&(t.clearDepth(1),t.clear(t.DEPTH_BUFFER_BIT)),this.bindFramebuffer(o))}}function Gv(e,t){e.RendererGL=jv,t.setAttributes=function(e,t){return this._renderer._setAttributes(e,t)},t._assert3d=function(e){if(!this._renderer.isP3D)throw new Error(`${e}() 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.`)},e.renderers[i]=e.RendererGL,e.renderers[s]=e.RendererGL}"undefined"!=typeof p5&&Gv(p5,p5.prototype);var $v={},Hv={};!function e(t){var r,n,i,s,o,a;function u(e){var t,r,n={};for(t in e)e.hasOwnProperty(t)&&(r=e[t],n[t]="object"==typeof r&&null!==r?u(r):r);return n}function l(e,t){this.parent=e,this.key=t}function h(e,t,r,n){this.node=e,this.path=t,this.wrap=r,this.ref=n}function c(){}function d(e){return null!=e&&"object"==typeof e&&"string"==typeof e.type}function p(e,t){return(e===r.ObjectExpression||e===r.ObjectPattern)&&"properties"===t}function f(e,t){for(var r=e.length-1;r>=0;--r)if(e[r].node===t)return!0;return!1}function m(e,t){return(new c).traverse(e,t)}function g(e,t){var r;return r=function(e,t){var r,n,i,s;for(n=e.length,i=0;n;)t(e[s=i+(r=n>>>1)])?n=r:(i=s+1,n-=r+1);return i}(t,(function(t){return t.range[0]>e.range[0]})),e.extendedRange=[e.range[0],e.range[1]],r!==t.length&&(e.extendedRange[1]=t[r].range[0]),(r-=1)>=0&&(e.extendedRange[0]=t[r].range[1]),e}return 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"},i={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"]},n={Break:s={},Skip:o={},Remove:a={}},l.prototype.replace=function(e){this.parent[this.key]=e},l.prototype.remove=function(){return Array.isArray(this.parent)?(this.parent.splice(this.key,1),!0):(this.replace(null),!1)},c.prototype.path=function(){var e,t,r,n,i;function s(e,t){if(Array.isArray(t))for(r=0,n=t.length;r<n;++r)e.push(t[r]);else e.push(t)}if(!this.__current.path)return null;for(i=[],e=2,t=this.__leavelist.length;e<t;++e)s(i,this.__leavelist[e].path);return s(i,this.__current.path),i},c.prototype.type=function(){return this.current().type||this.__current.wrap},c.prototype.parents=function(){var e,t,r;for(r=[],e=1,t=this.__leavelist.length;e<t;++e)r.push(this.__leavelist[e].node);return r},c.prototype.current=function(){return this.__current.node},c.prototype.__execute=function(e,t){var r,n;return n=void 0,r=this.__current,this.__current=t,this.__state=null,e&&(n=e.call(this,t.node,this.__leavelist[this.__leavelist.length-1].node)),this.__current=r,n},c.prototype.notify=function(e){this.__state=e},c.prototype.skip=function(){this.notify(o)},c.prototype.break=function(){this.notify(s)},c.prototype.remove=function(){this.notify(a)},c.prototype.__initialize=function(e,t){this.visitor=t,this.root=e,this.__worklist=[],this.__leavelist=[],this.__current=null,this.__state=null,this.__fallback=null,"iteration"===t.fallback?this.__fallback=Object.keys:"function"==typeof t.fallback&&(this.__fallback=t.fallback),this.__keys=i,t.keys&&(this.__keys=Object.assign(Object.create(this.__keys),t.keys))},c.prototype.traverse=function(e,t){var r,n,i,a,u,l,c,m,g,y,v,b;for(this.__initialize(e,t),b={},r=this.__worklist,n=this.__leavelist,r.push(new h(e,null,null,null)),n.push(new h(null,null,null,null));r.length;)if((i=r.pop())!==b){if(i.node){if(l=this.__execute(t.enter,i),this.__state===s||l===s)return;if(r.push(b),n.push(i),this.__state===o||l===o)continue;if(u=(a=i.node).type||i.wrap,!(y=this.__keys[u])){if(!this.__fallback)throw new Error("Unknown node type "+u+".");y=this.__fallback(a)}for(m=y.length;(m-=1)>=0;)if(v=a[c=y[m]])if(Array.isArray(v)){for(g=v.length;(g-=1)>=0;)if(v[g]&&!f(n,v[g])){if(p(u,y[m]))i=new h(v[g],[c,g],"Property",null);else{if(!d(v[g]))continue;i=new h(v[g],[c,g],null,null)}r.push(i)}}else if(d(v)){if(f(n,v))continue;r.push(new h(v,c,null,null))}}}else if(i=n.pop(),l=this.__execute(t.leave,i),this.__state===s||l===s)return},c.prototype.replace=function(e,t){var r,n,i,u,c,f,m,g,y,v,b,x,_;function w(e){var t,n,i,s;if(e.ref.remove())for(n=e.ref.key,s=e.ref.parent,t=r.length;t--;)if((i=r[t]).ref&&i.ref.parent===s){if(i.ref.key<n)break;--i.ref.key}}for(this.__initialize(e,t),b={},r=this.__worklist,n=this.__leavelist,f=new h(e,null,null,new l(x={root:e},"root")),r.push(f),n.push(f);r.length;)if((f=r.pop())!==b){if(void 0!==(c=this.__execute(t.enter,f))&&c!==s&&c!==o&&c!==a&&(f.ref.replace(c),f.node=c),this.__state!==a&&c!==a||(w(f),f.node=null),this.__state===s||c===s)return x.root;if((i=f.node)&&(r.push(b),n.push(f),this.__state!==o&&c!==o)){if(u=i.type||f.wrap,!(y=this.__keys[u])){if(!this.__fallback)throw new Error("Unknown node type "+u+".");y=this.__fallback(i)}for(m=y.length;(m-=1)>=0;)if(v=i[_=y[m]])if(Array.isArray(v)){for(g=v.length;(g-=1)>=0;)if(v[g]){if(p(u,y[m]))f=new h(v[g],[_,g],"Property",new l(v,g));else{if(!d(v[g]))continue;f=new h(v[g],[_,g],null,new l(v,g))}r.push(f)}}else d(v)&&r.push(new h(v,_,null,new l(i,_)))}}else if(f=n.pop(),void 0!==(c=this.__execute(t.leave,f))&&c!==s&&c!==o&&c!==a&&f.ref.replace(c),this.__state!==a&&c!==a||w(f),this.__state===s||c===s)return x.root;return x.root},t.Syntax=r,t.traverse=m,t.replace=function(e,t){return(new c).replace(e,t)},t.attachComments=function(e,t,r){var i,s,o,a,l=[];if(!e.range)throw new Error("attachComments needs range information");if(!r.length){if(t.length){for(o=0,s=t.length;o<s;o+=1)(i=u(t[o])).extendedRange=[0,e.range[0]],l.push(i);e.leadingComments=l}return e}for(o=0,s=t.length;o<s;o+=1)l.push(g(u(t[o]),r));return a=0,m(e,{enter:function(e){for(var t;a<l.length&&!((t=l[a]).extendedRange[1]>e.range[0]);)t.extendedRange[1]===e.range[0]?(e.leadingComments||(e.leadingComments=[]),e.leadingComments.push(t),l.splice(a,1)):a+=1;return a===l.length?n.Break:l[a].extendedRange[0]>e.range[1]?n.Skip:void 0}}),a=0,m(e,{leave:function(e){for(var t;a<l.length&&(t=l[a],!(e.range[1]<t.extendedRange[0]));)e.range[1]===t.extendedRange[0]?(e.trailingComments||(e.trailingComments=[]),e.trailingComments.push(t),l.splice(a,1)):a+=1;return a===l.length?n.Break:l[a].extendedRange[0]>e.range[1]?n.Skip:void 0}}),e},t.VisitorKeys=i,t.VisitorOption=n,t.Controller=c,t.cloneEnvironment=function(){return e({})},t}(Hv);var qv={},Wv={exports:{}};!function(){function e(e){if(null==e)return!1;switch(e.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 t(e){switch(e.type){case"IfStatement":return null!=e.alternate?e.alternate:e.consequent;case"LabeledStatement":case"ForStatement":case"ForInStatement":case"WhileStatement":case"WithStatement":return e.body}return null}Wv.exports={isExpression:function(e){if(null==e)return!1;switch(e.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},isStatement:e,isIterationStatement:function(e){if(null==e)return!1;switch(e.type){case"DoWhileStatement":case"ForInStatement":case"ForStatement":case"WhileStatement":return!0}return!1},isSourceElement:function(t){return e(t)||null!=t&&"FunctionDeclaration"===t.type},isProblematicIfStatement:function(e){var r;if("IfStatement"!==e.type)return!1;if(null==e.alternate)return!1;r=e.consequent;do{if("IfStatement"===r.type&&null==r.alternate)return!0;r=t(r)}while(r);return!1},trailingStatement:t}}();var Xv=Wv.exports,Zv={exports:{}};!function(){var e,t,r,n,i,s;function o(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(Math.floor((e-65536)/1024)+55296)+String.fromCharCode((e-65536)%1024+56320)}for(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-\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]/},e={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]/},r=[5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279],n=new Array(128),s=0;s<128;++s)n[s]=s>=97&&s<=122||s>=65&&s<=90||36===s||95===s;for(i=new Array(128),s=0;s<128;++s)i[s]=s>=97&&s<=122||s>=65&&s<=90||s>=48&&s<=57||36===s||95===s;Zv.exports={isDecimalDigit:function(e){return 48<=e&&e<=57},isHexDigit:function(e){return 48<=e&&e<=57||97<=e&&e<=102||65<=e&&e<=70},isOctalDigit:function(e){return e>=48&&e<=55},isWhiteSpace:function(e){return 32===e||9===e||11===e||12===e||160===e||e>=5760&&r.indexOf(e)>=0},isLineTerminator:function(e){return 10===e||13===e||8232===e||8233===e},isIdentifierStartES5:function(e){return e<128?n[e]:t.NonAsciiIdentifierStart.test(o(e))},isIdentifierPartES5:function(e){return e<128?i[e]:t.NonAsciiIdentifierPart.test(o(e))},isIdentifierStartES6:function(t){return t<128?n[t]:e.NonAsciiIdentifierStart.test(o(t))},isIdentifierPartES6:function(t){return t<128?i[t]:e.NonAsciiIdentifierPart.test(o(t))}}}();var Yv=Zv.exports,Kv={exports:{}};!function(){var e=Yv;function t(e,t){return!(!t&&"yield"===e)&&r(e,t)}function r(e,t){if(t&&function(e){switch(e){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"let":return!0;default:return!1}}(e))return!0;switch(e.length){case 2:return"if"===e||"in"===e||"do"===e;case 3:return"var"===e||"for"===e||"new"===e||"try"===e;case 4:return"this"===e||"else"===e||"case"===e||"void"===e||"with"===e||"enum"===e;case 5:return"while"===e||"break"===e||"catch"===e||"throw"===e||"const"===e||"yield"===e||"class"===e||"super"===e;case 6:return"return"===e||"typeof"===e||"delete"===e||"switch"===e||"export"===e||"import"===e;case 7:return"default"===e||"finally"===e||"extends"===e;case 8:return"function"===e||"continue"===e||"debugger"===e;case 10:return"instanceof"===e;default:return!1}}function n(e,r){return"null"===e||"true"===e||"false"===e||t(e,r)}function i(e,t){return"null"===e||"true"===e||"false"===e||r(e,t)}function s(t){var r,n,i;if(0===t.length)return!1;if(i=t.charCodeAt(0),!e.isIdentifierStartES5(i))return!1;for(r=1,n=t.length;r<n;++r)if(i=t.charCodeAt(r),!e.isIdentifierPartES5(i))return!1;return!0}function o(t){var r,n,i,s,o;if(0===t.length)return!1;for(o=e.isIdentifierStartES6,r=0,n=t.length;r<n;++r){if(55296<=(i=t.charCodeAt(r))&&i<=56319){if(++r>=n)return!1;if(!(56320<=(s=t.charCodeAt(r))&&s<=57343))return!1;i=1024*(i-55296)+(s-56320)+65536}if(!o(i))return!1;o=e.isIdentifierPartES6}return!0}Kv.exports={isKeywordES5:t,isKeywordES6:r,isReservedWordES5:n,isReservedWordES6:i,isRestrictedWord:function(e){return"eval"===e||"arguments"===e},isIdentifierNameES5:s,isIdentifierNameES6:o,isIdentifierES5:function(e,t){return s(e)&&!n(e,t)},isIdentifierES6:function(e,t){return o(e)&&!i(e,t)}}}();var Jv=Kv.exports;qv.ast=Xv,qv.code=Yv,qv.keyword=Jv;var Qv,eb,tb={},rb={},nb={},ib={};function sb(){if(Qv)return ib;Qv=1;var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");return ib.encode=function(t){if(0<=t&&t<e.length)return e[t];throw new TypeError("Must be between 0 and 63: "+t)},ib.decode=function(e){return 65<=e&&e<=90?e-65:97<=e&&e<=122?e-97+26:48<=e&&e<=57?e-48+52:43==e?62:47==e?63:-1},ib}function ob(){if(eb)return nb;eb=1;var e=sb();return nb.encode=function(t){var r,n="",i=function(e){return e<0?1+(-e<<1):0+(e<<1)}(t);do{r=31&i,(i>>>=5)>0&&(r|=32),n+=e.encode(r)}while(i>0);return n},nb.decode=function(t,r,n){var i,s,o,a,u=t.length,l=0,h=0;do{if(r>=u)throw new Error("Expected more digits in base 64 VLQ value.");if(-1===(s=e.decode(t.charCodeAt(r++))))throw new Error("Invalid base64 digit: "+t.charAt(r-1));i=!!(32&s),l+=(s&=31)<<h,h+=5}while(i);n.value=(a=(o=l)>>1,1&~o?a:-a),n.rest=r},nb}var ab,ub={};function lb(){return ab||(ab=1,function(e){e.getArg=function(e,t,r){if(t in e)return e[t];if(3===arguments.length)return r;throw new Error('"'+t+'" is a required argument.')};var t=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,r=/^data:.+\,.+$/;function n(e){var r=e.match(t);return r?{scheme:r[1],auth:r[2],host:r[3],port:r[4],path:r[5]}:null}function i(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}function s(t){var r=t,s=n(t);if(s){if(!s.path)return t;r=s.path}for(var o,a=e.isAbsolute(r),u=r.split(/\/+/),l=0,h=u.length-1;h>=0;h--)"."===(o=u[h])?u.splice(h,1):".."===o?l++:l>0&&(""===o?(u.splice(h+1,l),l=0):(u.splice(h,2),l--));return""===(r=u.join("/"))&&(r=a?"/":"."),s?(s.path=r,i(s)):r}function o(e,t){""===e&&(e="."),""===t&&(t=".");var o=n(t),a=n(e);if(a&&(e=a.path||"/"),o&&!o.scheme)return a&&(o.scheme=a.scheme),i(o);if(o||t.match(r))return t;if(a&&!a.host&&!a.path)return a.host=t,i(a);var u="/"===t.charAt(0)?t:s(e.replace(/\/+$/,"")+"/"+t);return a?(a.path=u,i(a)):u}e.urlParse=n,e.urlGenerate=i,e.normalize=s,e.join=o,e.isAbsolute=function(e){return"/"===e.charAt(0)||t.test(e)},e.relative=function(e,t){""===e&&(e="."),e=e.replace(/\/$/,"");for(var r=0;0!==t.indexOf(e+"/");){var n=e.lastIndexOf("/");if(n<0)return t;if((e=e.slice(0,n)).match(/^([^\/]+:\/)?\/*$/))return t;++r}return Array(r+1).join("../")+t.substr(e.length+1)};var a=!("__proto__"in Object.create(null));function u(e){return e}function l(e){if(!e)return!1;var t=e.length;if(t<9)return!1;if(95!==e.charCodeAt(t-1)||95!==e.charCodeAt(t-2)||111!==e.charCodeAt(t-3)||116!==e.charCodeAt(t-4)||111!==e.charCodeAt(t-5)||114!==e.charCodeAt(t-6)||112!==e.charCodeAt(t-7)||95!==e.charCodeAt(t-8)||95!==e.charCodeAt(t-9))return!1;for(var r=t-10;r>=0;r--)if(36!==e.charCodeAt(r))return!1;return!0}function h(e,t){return e===t?0:null===e?1:null===t?-1:e>t?1:-1}e.toSetString=a?u:function(e){return l(e)?"$"+e:e},e.fromSetString=a?u:function(e){return l(e)?e.slice(1):e},e.compareByOriginalPositions=function(e,t,r){var n=h(e.source,t.source);return 0!==n||0!==(n=e.originalLine-t.originalLine)||0!==(n=e.originalColumn-t.originalColumn)||r||0!==(n=e.generatedColumn-t.generatedColumn)||0!==(n=e.generatedLine-t.generatedLine)?n:h(e.name,t.name)},e.compareByGeneratedPositionsDeflated=function(e,t,r){var n=e.generatedLine-t.generatedLine;return 0!==n||0!==(n=e.generatedColumn-t.generatedColumn)||r||0!==(n=h(e.source,t.source))||0!==(n=e.originalLine-t.originalLine)||0!==(n=e.originalColumn-t.originalColumn)?n:h(e.name,t.name)},e.compareByGeneratedPositionsInflated=function(e,t){var r=e.generatedLine-t.generatedLine;return 0!==r||0!==(r=e.generatedColumn-t.generatedColumn)||0!==(r=h(e.source,t.source))||0!==(r=e.originalLine-t.originalLine)||0!==(r=e.originalColumn-t.originalColumn)?r:h(e.name,t.name)},e.parseSourceMapInput=function(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))},e.computeSourceURL=function(e,t,r){if(t=t||"",e&&("/"!==e[e.length-1]&&"/"!==t[0]&&(e+="/"),t=e+t),r){var a=n(r);if(!a)throw new Error("sourceMapURL could not be parsed");if(a.path){var u=a.path.lastIndexOf("/");u>=0&&(a.path=a.path.substring(0,u+1))}t=o(i(a),t)}return s(t)}}(ub)),ub}var hb,cb={};function db(){if(hb)return cb;hb=1;var e=lb(),t=Object.prototype.hasOwnProperty,r="undefined"!=typeof Map;function n(){this._array=[],this._set=r?new Map:Object.create(null)}return n.fromArray=function(e,t){for(var r=new n,i=0,s=e.length;i<s;i++)r.add(e[i],t);return r},n.prototype.size=function(){return r?this._set.size:Object.getOwnPropertyNames(this._set).length},n.prototype.add=function(n,i){var s=r?n:e.toSetString(n),o=r?this.has(n):t.call(this._set,s),a=this._array.length;o&&!i||this._array.push(n),o||(r?this._set.set(n,a):this._set[s]=a)},n.prototype.has=function(n){if(r)return this._set.has(n);var i=e.toSetString(n);return t.call(this._set,i)},n.prototype.indexOf=function(n){if(r){var i=this._set.get(n);if(i>=0)return i}else{var s=e.toSetString(n);if(t.call(this._set,s))return this._set[s]}throw new Error('"'+n+'" is not in the set.')},n.prototype.at=function(e){if(e>=0&&e<this._array.length)return this._array[e];throw new Error("No element indexed by "+e)},n.prototype.toArray=function(){return this._array.slice()},cb.ArraySet=n,cb}var pb,fb,mb={};function gb(){if(pb)return mb;pb=1;var e=lb();function t(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}return t.prototype.unsortedForEach=function(e,t){this._array.forEach(e,t)},t.prototype.add=function(t){var r,n,i,s,o,a;r=this._last,n=t,i=r.generatedLine,s=n.generatedLine,o=r.generatedColumn,a=n.generatedColumn,s>i||s==i&&a>=o||e.compareByGeneratedPositionsInflated(r,n)<=0?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))},t.prototype.toArray=function(){return this._sorted||(this._array.sort(e.compareByGeneratedPositionsInflated),this._sorted=!0),this._array},mb.MappingList=t,mb}function yb(){if(fb)return rb;fb=1;var e=ob(),t=lb(),r=db().ArraySet,n=gb().MappingList;function i(e){e||(e={}),this._file=t.getArg(e,"file",null),this._sourceRoot=t.getArg(e,"sourceRoot",null),this._skipValidation=t.getArg(e,"skipValidation",!1),this._sources=new r,this._names=new r,this._mappings=new n,this._sourcesContents=null}return i.prototype._version=3,i.fromSourceMap=function(e){var r=e.sourceRoot,n=new i({file:e.file,sourceRoot:r});return e.eachMapping((function(e){var i={generated:{line:e.generatedLine,column:e.generatedColumn}};null!=e.source&&(i.source=e.source,null!=r&&(i.source=t.relative(r,i.source)),i.original={line:e.originalLine,column:e.originalColumn},null!=e.name&&(i.name=e.name)),n.addMapping(i)})),e.sources.forEach((function(i){var s=i;null!==r&&(s=t.relative(r,i)),n._sources.has(s)||n._sources.add(s);var o=e.sourceContentFor(i);null!=o&&n.setSourceContent(i,o)})),n},i.prototype.addMapping=function(e){var r=t.getArg(e,"generated"),n=t.getArg(e,"original",null),i=t.getArg(e,"source",null),s=t.getArg(e,"name",null);this._skipValidation||this._validateMapping(r,n,i,s),null!=i&&(i=String(i),this._sources.has(i)||this._sources.add(i)),null!=s&&(s=String(s),this._names.has(s)||this._names.add(s)),this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:null!=n&&n.line,originalColumn:null!=n&&n.column,source:i,name:s})},i.prototype.setSourceContent=function(e,r){var n=e;null!=this._sourceRoot&&(n=t.relative(this._sourceRoot,n)),null!=r?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[t.toSetString(n)]=r):this._sourcesContents&&(delete this._sourcesContents[t.toSetString(n)],0===Object.keys(this._sourcesContents).length&&(this._sourcesContents=null))},i.prototype.applySourceMap=function(e,n,i){var s=n;if(null==n){if(null==e.file)throw new Error('SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map\'s "file" property. Both were omitted.');s=e.file}var o=this._sourceRoot;null!=o&&(s=t.relative(o,s));var a=new r,u=new r;this._mappings.unsortedForEach((function(r){if(r.source===s&&null!=r.originalLine){var n=e.originalPositionFor({line:r.originalLine,column:r.originalColumn});null!=n.source&&(r.source=n.source,null!=i&&(r.source=t.join(i,r.source)),null!=o&&(r.source=t.relative(o,r.source)),r.originalLine=n.line,r.originalColumn=n.column,null!=n.name&&(r.name=n.name))}var l=r.source;null==l||a.has(l)||a.add(l);var h=r.name;null==h||u.has(h)||u.add(h)}),this),this._sources=a,this._names=u,e.sources.forEach((function(r){var n=e.sourceContentFor(r);null!=n&&(null!=i&&(r=t.join(i,r)),null!=o&&(r=t.relative(o,r)),this.setSourceContent(r,n))}),this)},i.prototype._validateMapping=function(e,t,r,n){if(t&&"number"!=typeof t.line&&"number"!=typeof t.column)throw new 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((!(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0)||t||r||n)&&!(e&&"line"in e&&"column"in e&&t&&"line"in t&&"column"in t&&e.line>0&&e.column>=0&&t.line>0&&t.column>=0&&r))throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:r,original:t,name:n}))},i.prototype._serializeMappings=function(){for(var r,n,i,s,o=0,a=1,u=0,l=0,h=0,c=0,d="",p=this._mappings.toArray(),f=0,m=p.length;f<m;f++){if(r="",(n=p[f]).generatedLine!==a)for(o=0;n.generatedLine!==a;)r+=";",a++;else if(f>0){if(!t.compareByGeneratedPositionsInflated(n,p[f-1]))continue;r+=","}r+=e.encode(n.generatedColumn-o),o=n.generatedColumn,null!=n.source&&(s=this._sources.indexOf(n.source),r+=e.encode(s-c),c=s,r+=e.encode(n.originalLine-1-l),l=n.originalLine-1,r+=e.encode(n.originalColumn-u),u=n.originalColumn,null!=n.name&&(i=this._names.indexOf(n.name),r+=e.encode(i-h),h=i)),d+=r}return d},i.prototype._generateSourcesContent=function(e,r){return e.map((function(e){if(!this._sourcesContents)return null;null!=r&&(e=t.relative(r,e));var n=t.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,n)?this._sourcesContents[n]:null}),this)},i.prototype.toJSON=function(){var e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return null!=this._file&&(e.file=this._file),null!=this._sourceRoot&&(e.sourceRoot=this._sourceRoot),this._sourcesContents&&(e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)),e},i.prototype.toString=function(){return JSON.stringify(this.toJSON())},rb.SourceMapGenerator=i,rb}var vb,bb={},xb={};function _b(){return vb||(vb=1,function(e){function t(r,n,i,s,o,a){var u=Math.floor((n-r)/2)+r,l=o(i,s[u],!0);return 0===l?u:l>0?n-u>1?t(u,n,i,s,o,a):a==e.LEAST_UPPER_BOUND?n<s.length?n:-1:u:u-r>1?t(r,u,i,s,o,a):a==e.LEAST_UPPER_BOUND?u:r<0?-1:r}e.GREATEST_LOWER_BOUND=1,e.LEAST_UPPER_BOUND=2,e.search=function(r,n,i,s){if(0===n.length)return-1;var o=t(-1,n.length,r,n,i,s||e.GREATEST_LOWER_BOUND);if(o<0)return-1;for(;o-1>=0&&0===i(n[o],n[o-1],!0);)--o;return o}}(xb)),xb}var wb,Cb,Eb={};function Sb(){if(wb)return Eb;function e(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function t(r,n,i,s){if(i<s){var o=i-1;e(r,(h=i,c=s,Math.round(h+Math.random()*(c-h))),s);for(var a=r[s],u=i;u<s;u++)n(r[u],a)<=0&&e(r,o+=1,u);e(r,o+1,u);var l=o+1;t(r,n,i,l-1),t(r,n,l+1,s)}var h,c}return wb=1,Eb.quickSort=function(e,r){t(e,r,0,e.length-1)},Eb}var Ab,Db,Tb={};function Fb(){return Db||(Db=1,tb.SourceMapGenerator=yb().SourceMapGenerator,tb.SourceMapConsumer=function(){if(Cb)return bb;Cb=1;var e=lb(),t=_b(),r=db().ArraySet,n=ob(),i=Sb().quickSort;function s(t,r){var n=t;return"string"==typeof t&&(n=e.parseSourceMapInput(t)),null!=n.sections?new u(n,r):new o(n,r)}function o(t,n){var i=t;"string"==typeof t&&(i=e.parseSourceMapInput(t));var s=e.getArg(i,"version"),o=e.getArg(i,"sources"),a=e.getArg(i,"names",[]),u=e.getArg(i,"sourceRoot",null),l=e.getArg(i,"sourcesContent",null),h=e.getArg(i,"mappings"),c=e.getArg(i,"file",null);if(s!=this._version)throw new Error("Unsupported version: "+s);u&&(u=e.normalize(u)),o=o.map(String).map(e.normalize).map((function(t){return u&&e.isAbsolute(u)&&e.isAbsolute(t)?e.relative(u,t):t})),this._names=r.fromArray(a.map(String),!0),this._sources=r.fromArray(o,!0),this._absoluteSources=this._sources.toArray().map((function(t){return e.computeSourceURL(u,t,n)})),this.sourceRoot=u,this.sourcesContent=l,this._mappings=h,this._sourceMapURL=n,this.file=c}function a(){this.generatedLine=0,this.generatedColumn=0,this.source=null,this.originalLine=null,this.originalColumn=null,this.name=null}function u(t,n){var i=t;"string"==typeof t&&(i=e.parseSourceMapInput(t));var o=e.getArg(i,"version"),a=e.getArg(i,"sections");if(o!=this._version)throw new Error("Unsupported version: "+o);this._sources=new r,this._names=new r;var u={line:-1,column:0};this._sections=a.map((function(t){if(t.url)throw new Error("Support for url field in sections not implemented.");var r=e.getArg(t,"offset"),i=e.getArg(r,"line"),o=e.getArg(r,"column");if(i<u.line||i===u.line&&o<u.column)throw new Error("Section offsets must be ordered and non-overlapping.");return u=r,{generatedOffset:{generatedLine:i+1,generatedColumn:o+1},consumer:new s(e.getArg(t,"map"),n)}}))}return s.fromSourceMap=function(e,t){return o.fromSourceMap(e,t)},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(e,t){var r=e.charAt(t);return";"===r||","===r},s.prototype._parseMappings=function(e,t){throw new 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,n){var i,o=r||null;switch(n||s.GENERATED_ORDER){case s.GENERATED_ORDER:i=this._generatedMappings;break;case s.ORIGINAL_ORDER:i=this._originalMappings;break;default:throw new Error("Unknown order of iteration.")}var a=this.sourceRoot;i.map((function(t){var r=null===t.source?null:this._sources.at(t.source);return{source:r=e.computeSourceURL(a,r,this._sourceMapURL),generatedLine:t.generatedLine,generatedColumn:t.generatedColumn,originalLine:t.originalLine,originalColumn:t.originalColumn,name:null===t.name?null:this._names.at(t.name)}}),this).forEach(t,o)},s.prototype.allGeneratedPositionsFor=function(r){var n=e.getArg(r,"line"),i={source:e.getArg(r,"source"),originalLine:n,originalColumn:e.getArg(r,"column",0)};if(i.source=this._findSourceIndex(i.source),i.source<0)return[];var s=[],o=this._findMapping(i,this._originalMappings,"originalLine","originalColumn",e.compareByOriginalPositions,t.LEAST_UPPER_BOUND);if(o>=0){var a=this._originalMappings[o];if(void 0===r.column)for(var u=a.originalLine;a&&a.originalLine===u;)s.push({line:e.getArg(a,"generatedLine",null),column:e.getArg(a,"generatedColumn",null),lastColumn:e.getArg(a,"lastGeneratedColumn",null)}),a=this._originalMappings[++o];else for(var l=a.originalColumn;a&&a.originalLine===n&&a.originalColumn==l;)s.push({line:e.getArg(a,"generatedLine",null),column:e.getArg(a,"generatedColumn",null),lastColumn:e.getArg(a,"lastGeneratedColumn",null)}),a=this._originalMappings[++o]}return s},bb.SourceMapConsumer=s,o.prototype=Object.create(s.prototype),o.prototype.consumer=s,o.prototype._findSourceIndex=function(t){var r,n=t;if(null!=this.sourceRoot&&(n=e.relative(this.sourceRoot,n)),this._sources.has(n))return this._sources.indexOf(n);for(r=0;r<this._absoluteSources.length;++r)if(this._absoluteSources[r]==t)return r;return-1},o.fromSourceMap=function(t,n){var s=Object.create(o.prototype),u=s._names=r.fromArray(t._names.toArray(),!0),l=s._sources=r.fromArray(t._sources.toArray(),!0);s.sourceRoot=t._sourceRoot,s.sourcesContent=t._generateSourcesContent(s._sources.toArray(),s.sourceRoot),s.file=t._file,s._sourceMapURL=n,s._absoluteSources=s._sources.toArray().map((function(t){return e.computeSourceURL(s.sourceRoot,t,n)}));for(var h=t._mappings.toArray().slice(),c=s.__generatedMappings=[],d=s.__originalMappings=[],p=0,f=h.length;p<f;p++){var m=h[p],g=new a;g.generatedLine=m.generatedLine,g.generatedColumn=m.generatedColumn,m.source&&(g.source=l.indexOf(m.source),g.originalLine=m.originalLine,g.originalColumn=m.originalColumn,m.name&&(g.name=u.indexOf(m.name)),d.push(g)),c.push(g)}return i(s.__originalMappings,e.compareByOriginalPositions),s},o.prototype._version=3,Object.defineProperty(o.prototype,"sources",{get:function(){return this._absoluteSources.slice()}}),o.prototype._parseMappings=function(t,r){for(var s,o,u,l,h,c=1,d=0,p=0,f=0,m=0,g=0,y=t.length,v=0,b={},x={},_=[],w=[];v<y;)if(";"===t.charAt(v))c++,v++,d=0;else if(","===t.charAt(v))v++;else{for((s=new a).generatedLine=c,l=v;l<y&&!this._charIsMappingSeparator(t,l);l++);if(u=b[o=t.slice(v,l)])v+=o.length;else{for(u=[];v<l;)n.decode(t,v,x),h=x.value,v=x.rest,u.push(h);if(2===u.length)throw new Error("Found a source, but no line and column");if(3===u.length)throw new Error("Found a source and line, but no column");b[o]=u}s.generatedColumn=d+u[0],d=s.generatedColumn,u.length>1&&(s.source=m+u[1],m+=u[1],s.originalLine=p+u[2],p=s.originalLine,s.originalLine+=1,s.originalColumn=f+u[3],f=s.originalColumn,u.length>4&&(s.name=g+u[4],g+=u[4])),w.push(s),"number"==typeof s.originalLine&&_.push(s)}i(w,e.compareByGeneratedPositionsDeflated),this.__generatedMappings=w,i(_,e.compareByOriginalPositions),this.__originalMappings=_},o.prototype._findMapping=function(e,r,n,i,s,o){if(e[n]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+e[n]);if(e[i]<0)throw new TypeError("Column must be greater than or equal to 0, got "+e[i]);return t.search(e,r,s,o)},o.prototype.computeColumnSpans=function(){for(var e=0;e<this._generatedMappings.length;++e){var t=this._generatedMappings[e];if(e+1<this._generatedMappings.length){var r=this._generatedMappings[e+1];if(t.generatedLine===r.generatedLine){t.lastGeneratedColumn=r.generatedColumn-1;continue}}t.lastGeneratedColumn=1/0}},o.prototype.originalPositionFor=function(t){var r={generatedLine:e.getArg(t,"line"),generatedColumn:e.getArg(t,"column")},n=this._findMapping(r,this._generatedMappings,"generatedLine","generatedColumn",e.compareByGeneratedPositionsDeflated,e.getArg(t,"bias",s.GREATEST_LOWER_BOUND));if(n>=0){var i=this._generatedMappings[n];if(i.generatedLine===r.generatedLine){var o=e.getArg(i,"source",null);null!==o&&(o=this._sources.at(o),o=e.computeSourceURL(this.sourceRoot,o,this._sourceMapURL));var a=e.getArg(i,"name",null);return null!==a&&(a=this._names.at(a)),{source:o,line:e.getArg(i,"originalLine",null),column:e.getArg(i,"originalColumn",null),name:a}}}return{source:null,line:null,column:null,name:null}},o.prototype.hasContentsOfAllSources=function(){return!!this.sourcesContent&&this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some((function(e){return null==e}))},o.prototype.sourceContentFor=function(t,r){if(!this.sourcesContent)return null;var n=this._findSourceIndex(t);if(n>=0)return this.sourcesContent[n];var i,s=t;if(null!=this.sourceRoot&&(s=e.relative(this.sourceRoot,s)),null!=this.sourceRoot&&(i=e.urlParse(this.sourceRoot))){var o=s.replace(/^file:\/\//,"");if("file"==i.scheme&&this._sources.has(o))return this.sourcesContent[this._sources.indexOf(o)];if((!i.path||"/"==i.path)&&this._sources.has("/"+s))return this.sourcesContent[this._sources.indexOf("/"+s)]}if(r)return null;throw new Error('"'+s+'" is not in the SourceMap.')},o.prototype.generatedPositionFor=function(t){var r=e.getArg(t,"source");if((r=this._findSourceIndex(r))<0)return{line:null,column:null,lastColumn:null};var n={source:r,originalLine:e.getArg(t,"line"),originalColumn:e.getArg(t,"column")},i=this._findMapping(n,this._originalMappings,"originalLine","originalColumn",e.compareByOriginalPositions,e.getArg(t,"bias",s.GREATEST_LOWER_BOUND));if(i>=0){var o=this._originalMappings[i];if(o.source===n.source)return{line:e.getArg(o,"generatedLine",null),column:e.getArg(o,"generatedColumn",null),lastColumn:e.getArg(o,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}},bb.BasicSourceMapConsumer=o,u.prototype=Object.create(s.prototype),u.prototype.constructor=s,u.prototype._version=3,Object.defineProperty(u.prototype,"sources",{get:function(){for(var e=[],t=0;t<this._sections.length;t++)for(var r=0;r<this._sections[t].consumer.sources.length;r++)e.push(this._sections[t].consumer.sources[r]);return e}}),u.prototype.originalPositionFor=function(r){var n={generatedLine:e.getArg(r,"line"),generatedColumn:e.getArg(r,"column")},i=t.search(n,this._sections,(function(e,t){return e.generatedLine-t.generatedOffset.generatedLine||e.generatedColumn-t.generatedOffset.generatedColumn})),s=this._sections[i];return s?s.consumer.originalPositionFor({line:n.generatedLine-(s.generatedOffset.generatedLine-1),column:n.generatedColumn-(s.generatedOffset.generatedLine===n.generatedLine?s.generatedOffset.generatedColumn-1:0),bias:r.bias}):{source:null,line:null,column:null,name:null}},u.prototype.hasContentsOfAllSources=function(){return this._sections.every((function(e){return e.consumer.hasContentsOfAllSources()}))},u.prototype.sourceContentFor=function(e,t){for(var r=0;r<this._sections.length;r++){var n=this._sections[r].consumer.sourceContentFor(e,!0);if(n)return n}if(t)return null;throw new Error('"'+e+'" is not in the SourceMap.')},u.prototype.generatedPositionFor=function(t){for(var r=0;r<this._sections.length;r++){var n=this._sections[r];if(-1!==n.consumer._findSourceIndex(e.getArg(t,"source"))){var i=n.consumer.generatedPositionFor(t);if(i)return{line:i.line+(n.generatedOffset.generatedLine-1),column:i.column+(n.generatedOffset.generatedLine===i.line?n.generatedOffset.generatedColumn-1:0)}}}return{line:null,column:null}},u.prototype._parseMappings=function(t,r){this.__generatedMappings=[],this.__originalMappings=[];for(var n=0;n<this._sections.length;n++)for(var s=this._sections[n],o=s.consumer._generatedMappings,a=0;a<o.length;a++){var u=o[a],l=s.consumer._sources.at(u.source);l=e.computeSourceURL(s.consumer.sourceRoot,l,this._sourceMapURL),this._sources.add(l),l=this._sources.indexOf(l);var h=null;u.name&&(h=s.consumer._names.at(u.name),this._names.add(h),h=this._names.indexOf(h));var c={source:l,generatedLine:u.generatedLine+(s.generatedOffset.generatedLine-1),generatedColumn:u.generatedColumn+(s.generatedOffset.generatedLine===u.generatedLine?s.generatedOffset.generatedColumn-1:0),originalLine:u.originalLine,originalColumn:u.originalColumn,name:h};this.__generatedMappings.push(c),"number"==typeof c.originalLine&&this.__originalMappings.push(c)}i(this.__generatedMappings,e.compareByGeneratedPositionsDeflated),i(this.__originalMappings,e.compareByOriginalPositions)},bb.IndexedSourceMapConsumer=u,bb}().SourceMapConsumer,tb.SourceNode=function(){if(Ab)return Tb;Ab=1;var e=yb().SourceMapGenerator,t=lb(),r=/(\r?\n)/,n="$$$isSourceNode$$$";function i(e,t,r,i,s){this.children=[],this.sourceContents={},this.line=null==e?null:e,this.column=null==t?null:t,this.source=null==r?null:r,this.name=null==s?null:s,this[n]=!0,null!=i&&this.add(i)}return i.fromStringWithSourceMap=function(e,n,s){var o=new i,a=e.split(r),u=0,l=function(){return e()+(e()||"");function e(){return u<a.length?a[u++]:void 0}},h=1,c=0,d=null;return n.eachMapping((function(e){if(null!==d){if(!(h<e.generatedLine)){var t=(r=a[u]||"").substr(0,e.generatedColumn-c);return a[u]=r.substr(e.generatedColumn-c),c=e.generatedColumn,p(d,t),void(d=e)}p(d,l()),h++,c=0}for(;h<e.generatedLine;)o.add(l()),h++;if(c<e.generatedColumn){var r=a[u]||"";o.add(r.substr(0,e.generatedColumn)),a[u]=r.substr(e.generatedColumn),c=e.generatedColumn}d=e}),this),u<a.length&&(d&&p(d,l()),o.add(a.splice(u).join(""))),n.sources.forEach((function(e){var r=n.sourceContentFor(e);null!=r&&(null!=s&&(e=t.join(s,e)),o.setSourceContent(e,r))})),o;function p(e,r){if(null===e||void 0===e.source)o.add(r);else{var n=s?t.join(s,e.source):e.source;o.add(new i(e.originalLine,e.originalColumn,n,r,e.name))}}},i.prototype.add=function(e){if(Array.isArray(e))e.forEach((function(e){this.add(e)}),this);else{if(!e[n]&&"string"!=typeof e)throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);e&&this.children.push(e)}return this},i.prototype.prepend=function(e){if(Array.isArray(e))for(var t=e.length-1;t>=0;t--)this.prepend(e[t]);else{if(!e[n]&&"string"!=typeof e)throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);this.children.unshift(e)}return this},i.prototype.walk=function(e){for(var t,r=0,i=this.children.length;r<i;r++)(t=this.children[r])[n]?t.walk(e):""!==t&&e(t,{source:this.source,line:this.line,column:this.column,name:this.name})},i.prototype.join=function(e){var t,r,n=this.children.length;if(n>0){for(t=[],r=0;r<n-1;r++)t.push(this.children[r]),t.push(e);t.push(this.children[r]),this.children=t}return this},i.prototype.replaceRight=function(e,t){var r=this.children[this.children.length-1];return r[n]?r.replaceRight(e,t):"string"==typeof r?this.children[this.children.length-1]=r.replace(e,t):this.children.push("".replace(e,t)),this},i.prototype.setSourceContent=function(e,r){this.sourceContents[t.toSetString(e)]=r},i.prototype.walkSourceContents=function(e){for(var r=0,i=this.children.length;r<i;r++)this.children[r][n]&&this.children[r].walkSourceContents(e);var s=Object.keys(this.sourceContents);for(r=0,i=s.length;r<i;r++)e(t.fromSetString(s[r]),this.sourceContents[s[r]])},i.prototype.toString=function(){var e="";return this.walk((function(t){e+=t})),e},i.prototype.toStringWithSourceMap=function(t){var r={code:"",line:1,column:0},n=new e(t),i=!1,s=null,o=null,a=null,u=null;return this.walk((function(e,t){r.code+=e,null!==t.source&&null!==t.line&&null!==t.column?(s===t.source&&o===t.line&&a===t.column&&u===t.name||n.addMapping({source:t.source,original:{line:t.line,column:t.column},generated:{line:r.line,column:r.column},name:t.name}),s=t.source,o=t.line,a=t.column,u=t.name,i=!0):i&&(n.addMapping({generated:{line:r.line,column:r.column}}),s=null,i=!1);for(var l=0,h=e.length;l<h;l++)10===e.charCodeAt(l)?(r.line++,r.column=0,l+1===h?(s=null,i=!1):i&&n.addMapping({source:t.source,original:{line:t.line,column:t.column},generated:{line:r.line,column:r.column},name:t.name})):r.column++})),this.walkSourceContents((function(e,t){n.setSourceContent(e,t)})),{code:r.code,map:n}},Tb.SourceNode=i,Tb}().SourceNode),tb}var Ib,kb="2.1.0";Ib=$v,function(){var e,t,r,n,i,s,o,a,u,l,h,c,d,p,f,m,g,y,v,b,x,_,w,C,E,S;function A(e){return W.Statement.hasOwnProperty(e.type)}s=qv,e=(i=Hv).Syntax,r={"??":(t={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}).Coalesce,"||":t.LogicalOR,"&&":t.LogicalAND,"|":t.BitwiseOR,"^":t.BitwiseXOR,"&":t.BitwiseAND,"==":t.Equality,"!=":t.Equality,"===":t.Equality,"!==":t.Equality,is:t.Equality,isnt:t.Equality,"<":t.Relational,">":t.Relational,"<=":t.Relational,">=":t.Relational,in:t.Relational,instanceof:t.Relational,"<<":t.BitwiseSHIFT,">>":t.BitwiseSHIFT,">>>":t.BitwiseSHIFT,"+":t.Additive,"-":t.Additive,"*":t.Multiplicative,"%":t.Multiplicative,"/":t.Multiplicative,"**":t.Exponentiation};var D=32,T=33;function F(e,t){var r="";for(t|=0;t>0;t>>>=1,e+=e)1&t&&(r+=e);return r}function I(e){var t=e.length;return t&&s.code.isLineTerminator(e.charCodeAt(t-1))}function k(e,t){var r;for(r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e}function N(e,t){var r,n;function i(e){return"object"==typeof e&&e instanceof Object&&!(e instanceof RegExp)}for(r in t)t.hasOwnProperty(r)&&(i(n=t[r])?i(e[r])?N(e[r],n):e[r]=N({},n):e[r]=n);return e}function M(e,t){return 8232==(-2&e)?(t?"u":"\\u")+(8232===e?"2028":"2029"):10===e||13===e?(t?"":"\\")+(10===e?"n":"r"):String.fromCharCode(e)}function O(e,t){var r;return 8===e?"\\b":12===e?"\\f":9===e?"\\t":(r=e.toString(16).toUpperCase(),u||e>255?"\\u"+"0000".slice(r.length)+r:0!==e||s.code.isDecimalDigit(t)?11===e?"\\x0B":"\\x"+"00".slice(r.length)+r:"\\0")}function B(e){if(92===e)return"\\\\";if(10===e)return"\\n";if(13===e)return"\\r";if(8232===e)return"\\u2028";if(8233===e)return"\\u2029";throw new Error("Incorrectly classified character")}function L(e){var t,r,n,i="";for(t=0,r=e.length;t<r;++t)n=e[t],i+=Array.isArray(n)?L(n):n;return i}function P(e,t){if(!_)return Array.isArray(e)?L(e):e;if(null==t){if(e instanceof n)return e;t={}}return null==t.loc?new n(null,null,_,e,t.name||null):new n(t.loc.start.line,t.loc.start.column,!0===_?t.loc.source||null:_,e,t.name||null)}function R(){return f||" "}function V(e,t){var r,n,i,o;return 0===(r=P(e).toString()).length?[t]:0===(n=P(t).toString()).length?[e]:(i=r.charCodeAt(r.length-1),o=n.charCodeAt(0),(43===i||45===i)&&i===o||s.code.isIdentifierPartES5(i)&&s.code.isIdentifierPartES5(o)||47===i&&105===o?[e,R(),t]:s.code.isWhiteSpace(i)||s.code.isLineTerminator(i)||s.code.isWhiteSpace(o)||s.code.isLineTerminator(o)?[e,t]:[e,f,t])}function U(e){return[o,e]}function z(e){var t;t=o,e(o+=a),o=t}function j(e,t){if("Line"===e.type){if(I(e.value))return"//"+e.value;var r="//"+e.value;return C||(r+="\n"),r}return b.format.indent.adjustMultilineComment&&/[\n\r]/.test(e.value)?function(e,t){var r,n,i,a,u,l,h,c;for(r=e.split(/\r\n|[\r\n]/),l=Number.MAX_VALUE,n=1,i=r.length;n<i;++n){for(a=r[n],u=0;u<a.length&&s.code.isWhiteSpace(a.charCodeAt(u));)++u;l>u&&(l=u)}for(void 0!==t?(h=o,"*"===r[1][l]&&(t+=" "),o=t):(1&l&&--l,h=o),n=1,i=r.length;n<i;++n)c=P(U(r[n].slice(l))),r[n]=_?c.join(""):c;return o=h,r.join("\n")}("/*"+e.value+"*/",t):"/*"+e.value+"*/"}function G(t,r){var n,i,u,l,h,c,d,p,f,m,g,v;if(t.leadingComments&&t.leadingComments.length>0){if(l=r,C){for(r=[],p=(u=t.leadingComments[0]).extendedRange,f=u.range,(v=((g=w.substring(p[0],f[0])).match(/\n/g)||[]).length)>0?(r.push(F("\n",v)),r.push(U(j(u)))):(r.push(g),r.push(j(u))),m=f,n=1,i=t.leadingComments.length;n<i;n++)f=(u=t.leadingComments[n]).range,v=(w.substring(m[1],f[0]).match(/\n/g)||[]).length,r.push(F("\n",v)),r.push(U(j(u))),m=f;v=(w.substring(f[1],p[1]).match(/\n/g)||[]).length,r.push(F("\n",v))}else for(u=t.leadingComments[0],r=[],y&&t.type===e.Program&&0===t.body.length&&r.push("\n"),r.push(j(u)),I(P(r).toString())||r.push("\n"),n=1,i=t.leadingComments.length;n<i;++n)I(P(d=[j(u=t.leadingComments[n])]).toString())||d.push("\n"),r.push(U(d));r.push(U(l))}if(t.trailingComments)if(C)p=(u=t.trailingComments[0]).extendedRange,f=u.range,(v=((g=w.substring(p[0],f[0])).match(/\n/g)||[]).length)>0?(r.push(F("\n",v)),r.push(U(j(u)))):(r.push(g),r.push(j(u)));else for(h=!I(P(r).toString()),c=F(" ",function(e){var t;for(t=e.length-1;t>=0&&!s.code.isLineTerminator(e.charCodeAt(t));--t);return e.length-1-t}(P([o,r,a]).toString())),n=0,i=t.trailingComments.length;n<i;++n)u=t.trailingComments[n],h?(r=0===n?[r,a]:[r,c]).push(j(u,c)):r=[r,U(j(u))],n===i-1||I(P(r).toString())||(r=[r,"\n"]);return r}function $(e,t,r){var n,i=0;for(n=e;n<t;n++)"\n"===w[n]&&i++;for(n=1;n<i;n++)r.push(p)}function H(e,t,r){return t<r?["(",e,")"]:e}function q(e){var t,r,n;for(t=1,r=(n=e.split(/\r\n|\n/)).length;t<r;t++)n[t]=p+o+n[t];return n}function W(){}function X(e){return P(e.name,e)}function Z(e,t){return e.async?"async"+(t?R():f):""}function Y(e){return e.generator&&!b.moz.starlessGenerator?"*"+f:""}function K(e){var t=e.value,r="";return t.async&&(r+=Z(t,!e.computed)),t.generator&&(r+=Y(t)?"*":""),r}function J(e){var r;if(r=new W,A(e))return r.generateStatement(e,1);if(function(e){return W.Expression.hasOwnProperty(e.type)}(e))return r.generateExpression(e,t.Sequence,7);throw new Error("Unknown node type: "+e.type)}W.prototype.maybeBlock=function(t,r){var n,i,s=this;return i=!b.comment||!t.leadingComments,t.type===e.BlockStatement&&i?[f,this.generateStatement(t,r)]:t.type===e.EmptyStatement&&i?";":(z((function(){n=[p,U(s.generateStatement(t,r))]})),n)},W.prototype.maybeBlockSuffix=function(t,r){var n=I(P(r).toString());return t.type!==e.BlockStatement||b.comment&&t.leadingComments||n?n?[r,o]:[r,p,o]:[r,f]},W.prototype.generatePattern=function(t,r,n){return t.type===e.Identifier?X(t):this.generateExpression(t,r,n)},W.prototype.generateFunctionParams=function(r){var n,i,s,o;if(o=!1,r.type!==e.ArrowFunctionExpression||r.rest||r.defaults&&0!==r.defaults.length||1!==r.params.length||r.params[0].type!==e.Identifier){for((s=r.type===e.ArrowFunctionExpression?[Z(r,!1)]:[]).push("("),r.defaults&&(o=!0),n=0,i=r.params.length;n<i;++n)o&&r.defaults[n]?s.push(this.generateAssignment(r.params[n],r.defaults[n],"=",t.Assignment,7)):s.push(this.generatePattern(r.params[n],t.Assignment,7)),n+1<i&&s.push(","+f);r.rest&&(r.params.length&&s.push(","+f),s.push("..."),s.push(X(r.rest))),s.push(")")}else s=[Z(r,!0),X(r.params[0])];return s},W.prototype.generateFunctionBody=function(r){var n,i;return n=this.generateFunctionParams(r),r.type===e.ArrowFunctionExpression&&(n.push(f),n.push("=>")),r.expression?(n.push(f),"{"===(i=this.generateExpression(r.body,t.Assignment,7)).toString().charAt(0)&&(i=["(",i,")"]),n.push(i)):n.push(this.maybeBlock(r.body,9)),n},W.prototype.generateIterationForStatement=function(r,n,i){var s=["for"+(n.await?R()+"await":"")+f+"("],o=this;return z((function(){n.left.type===e.VariableDeclaration?z((function(){s.push(n.left.kind+R()),s.push(o.generateStatement(n.left.declarations[0],0))})):s.push(o.generateExpression(n.left,t.Call,7)),s=V(s,r),s=[V(s,o.generateExpression(n.right,t.Assignment,7)),")"]})),s.push(this.maybeBlock(n.body,i)),s},W.prototype.generatePropertyKey=function(e,r){var n=[];return r&&n.push("["),n.push(this.generateExpression(e,t.Assignment,7)),r&&n.push("]"),n},W.prototype.generateAssignment=function(e,r,n,i,s){return t.Assignment<i&&(s|=1),H([this.generateExpression(e,t.Call,s),f+n+f,this.generateExpression(r,t.Assignment,s)],t.Assignment,i)},W.prototype.semicolon=function(e){return!g&&e&D?"":";"},W.Statement={BlockStatement:function(e,t){var r,n,i=["{",p],s=this;return z((function(){var o,a,u,l;for(0===e.body.length&&C&&(r=e.range)[1]-r[0]>2&&("\n"===(n=w.substring(r[0]+1,r[1]-1))[0]&&(i=["{"]),i.push(n)),l=1,8&t&&(l|=16),o=0,a=e.body.length;o<a;++o)C&&(0===o&&(e.body[0].leadingComments&&(r=e.body[0].leadingComments[0].extendedRange,"\n"===(n=w.substring(r[0],r[1]))[0]&&(i=["{"])),e.body[0].leadingComments||$(e.range[0],e.body[0].range[0],i)),o>0&&(e.body[o-1].trailingComments||e.body[o].leadingComments||$(e.body[o-1].range[1],e.body[o].range[0],i))),o===a-1&&(l|=D),u=e.body[o].leadingComments&&C?s.generateStatement(e.body[o],l):U(s.generateStatement(e.body[o],l)),i.push(u),I(P(u).toString())||C&&o<a-1&&e.body[o+1].leadingComments||i.push(p),C&&o===a-1&&(e.body[o].trailingComments||$(e.body[o].range[1],e.range[1],i))})),i.push(U("}")),i},BreakStatement:function(e,t){return e.label?"break "+e.label.name+this.semicolon(t):"break"+this.semicolon(t)},ContinueStatement:function(e,t){return e.label?"continue "+e.label.name+this.semicolon(t):"continue"+this.semicolon(t)},ClassBody:function(e,r){var n=["{",p],i=this;return z((function(r){var s,o;for(s=0,o=e.body.length;s<o;++s)n.push(r),n.push(i.generateExpression(e.body[s],t.Sequence,7)),s+1<o&&n.push(p)})),I(P(n).toString())||n.push(p),n.push(o),n.push("}"),n},ClassDeclaration:function(e,r){var n,i;return n=["class"],e.id&&(n=V(n,this.generateExpression(e.id,t.Sequence,7))),e.superClass&&(i=V("extends",this.generateExpression(e.superClass,t.Unary,7)),n=V(n,i)),n.push(f),n.push(this.generateStatement(e.body,T)),n},DirectiveStatement:function(e,t){return b.raw&&e.raw?e.raw+this.semicolon(t):function(e){var t,r,n,i;for(i="double"===c?'"':"'",t=0,r=e.length;t<r;++t){if(39===(n=e.charCodeAt(t))){i='"';break}if(34===n){i="'";break}92===n&&++t}return i+e+i}(e.directive)+this.semicolon(t)},DoWhileStatement:function(e,r){var n=V("do",this.maybeBlock(e.body,1));return V(n=this.maybeBlockSuffix(e.body,n),["while"+f+"(",this.generateExpression(e.test,t.Sequence,7),")"+this.semicolon(r)])},CatchClause:function(e,r){var n,i=this;return z((function(){var r;e.param?(n=["catch"+f+"(",i.generateExpression(e.param,t.Sequence,7),")"],e.guard&&(r=i.generateExpression(e.guard,t.Sequence,7),n.splice(2,0," if ",r))):n=["catch"]})),n.push(this.maybeBlock(e.body,1)),n},DebuggerStatement:function(e,t){return"debugger"+this.semicolon(t)},EmptyStatement:function(e,t){return";"},ExportDefaultDeclaration:function(e,r){var n,i=["export"];return n=r&D?T:1,i=V(i,"default"),i=A(e.declaration)?V(i,this.generateStatement(e.declaration,n)):V(i,this.generateExpression(e.declaration,t.Assignment,7)+this.semicolon(r))},ExportNamedDeclaration:function(r,n){var i,s=["export"],a=this;return i=n&D?T:1,r.declaration?V(s,this.generateStatement(r.declaration,i)):(r.specifiers&&(0===r.specifiers.length?s=V(s,"{"+f+"}"):r.specifiers[0].type===e.ExportBatchSpecifier?s=V(s,this.generateExpression(r.specifiers[0],t.Sequence,7)):(s=V(s,"{"),z((function(e){var n,i;for(s.push(p),n=0,i=r.specifiers.length;n<i;++n)s.push(e),s.push(a.generateExpression(r.specifiers[n],t.Sequence,7)),n+1<i&&s.push(","+p)})),I(P(s).toString())||s.push(p),s.push(o+"}")),r.source?s=V(s,["from"+f,this.generateExpression(r.source,t.Sequence,7),this.semicolon(n)]):s.push(this.semicolon(n))),s)},ExportAllDeclaration:function(e,r){return["export"+f,"*"+f,"from"+f,this.generateExpression(e.source,t.Sequence,7),this.semicolon(r)]},ExpressionStatement:function(r,n){var i,o;return 123===(o=P(i=[this.generateExpression(r.expression,t.Sequence,7)]).toString()).charCodeAt(0)||function(e){var t;return"class"===e.slice(0,5)&&(123===(t=e.charCodeAt(5))||s.code.isWhiteSpace(t)||s.code.isLineTerminator(t))}(o)||function(e){var t;return"function"===e.slice(0,8)&&(40===(t=e.charCodeAt(8))||s.code.isWhiteSpace(t)||42===t||s.code.isLineTerminator(t))}(o)||function(e){var t,r,n;if("async"!==e.slice(0,5))return!1;if(!s.code.isWhiteSpace(e.charCodeAt(5)))return!1;for(r=6,n=e.length;r<n&&s.code.isWhiteSpace(e.charCodeAt(r));++r);return r!==n&&"function"===e.slice(r,r+8)&&(40===(t=e.charCodeAt(r+8))||s.code.isWhiteSpace(t)||42===t||s.code.isLineTerminator(t))}(o)||v&&16&n&&r.expression.type===e.Literal&&"string"==typeof r.expression.value?i=["(",i,")"+this.semicolon(n)]:i.push(this.semicolon(n)),i},ImportDeclaration:function(r,n){var i,s,a=this;return 0===r.specifiers.length?["import",f,this.generateExpression(r.source,t.Sequence,7),this.semicolon(n)]:(i=["import"],s=0,r.specifiers[s].type===e.ImportDefaultSpecifier&&(i=V(i,[this.generateExpression(r.specifiers[s],t.Sequence,7)]),++s),r.specifiers[s]&&(0!==s&&i.push(","),r.specifiers[s].type===e.ImportNamespaceSpecifier?i=V(i,[f,this.generateExpression(r.specifiers[s],t.Sequence,7)]):(i.push(f+"{"),r.specifiers.length-s==1?(i.push(f),i.push(this.generateExpression(r.specifiers[s],t.Sequence,7)),i.push(f+"}"+f)):(z((function(e){var n,o;for(i.push(p),n=s,o=r.specifiers.length;n<o;++n)i.push(e),i.push(a.generateExpression(r.specifiers[n],t.Sequence,7)),n+1<o&&i.push(","+p)})),I(P(i).toString())||i.push(p),i.push(o+"}"+f)))),i=V(i,["from"+f,this.generateExpression(r.source,t.Sequence,7),this.semicolon(n)]))},VariableDeclarator:function(e,r){var n=1&r?7:6;return e.init?[this.generateExpression(e.id,t.Assignment,n),f,"=",f,this.generateExpression(e.init,t.Assignment,n)]:this.generatePattern(e.id,t.Assignment,n)},VariableDeclaration:function(e,t){var r,n,i,s,o,a=this;function u(){for(s=e.declarations[0],b.comment&&s.leadingComments?(r.push("\n"),r.push(U(a.generateStatement(s,o)))):(r.push(R()),r.push(a.generateStatement(s,o))),n=1,i=e.declarations.length;n<i;++n)s=e.declarations[n],b.comment&&s.leadingComments?(r.push(","+p),r.push(U(a.generateStatement(s,o)))):(r.push(","+f),r.push(a.generateStatement(s,o)))}return r=[e.kind],o=1&t?1:0,e.declarations.length>1?z(u):u(),r.push(this.semicolon(t)),r},ThrowStatement:function(e,r){return[V("throw",this.generateExpression(e.argument,t.Sequence,7)),this.semicolon(r)]},TryStatement:function(e,t){var r,n,i,s;if(r=["try",this.maybeBlock(e.block,1)],r=this.maybeBlockSuffix(e.block,r),e.handlers)for(n=0,i=e.handlers.length;n<i;++n)r=V(r,this.generateStatement(e.handlers[n],1)),(e.finalizer||n+1!==i)&&(r=this.maybeBlockSuffix(e.handlers[n].body,r));else{for(n=0,i=(s=e.guardedHandlers||[]).length;n<i;++n)r=V(r,this.generateStatement(s[n],1)),(e.finalizer||n+1!==i)&&(r=this.maybeBlockSuffix(s[n].body,r));if(e.handler)if(Array.isArray(e.handler))for(n=0,i=e.handler.length;n<i;++n)r=V(r,this.generateStatement(e.handler[n],1)),(e.finalizer||n+1!==i)&&(r=this.maybeBlockSuffix(e.handler[n].body,r));else r=V(r,this.generateStatement(e.handler,1)),e.finalizer&&(r=this.maybeBlockSuffix(e.handler.body,r))}return e.finalizer&&(r=V(r,["finally",this.maybeBlock(e.finalizer,1)])),r},SwitchStatement:function(e,r){var n,i,s,o,a,u=this;if(z((function(){n=["switch"+f+"(",u.generateExpression(e.discriminant,t.Sequence,7),")"+f+"{"+p]})),e.cases)for(a=1,s=0,o=e.cases.length;s<o;++s)s===o-1&&(a|=D),i=U(this.generateStatement(e.cases[s],a)),n.push(i),I(P(i).toString())||n.push(p);return n.push(U("}")),n},SwitchCase:function(r,n){var i,s,o,a,u,l=this;return z((function(){for(i=r.test?[V("case",l.generateExpression(r.test,t.Sequence,7)),":"]:["default:"],o=0,(a=r.consequent.length)&&r.consequent[0].type===e.BlockStatement&&(s=l.maybeBlock(r.consequent[0],1),i.push(s),o=1),o===a||I(P(i).toString())||i.push(p),u=1;o<a;++o)o===a-1&&n&D&&(u|=D),s=U(l.generateStatement(r.consequent[o],u)),i.push(s),o+1===a||I(P(s).toString())||i.push(p)})),i},IfStatement:function(r,n){var i,s,o=this;return z((function(){i=["if"+f+"(",o.generateExpression(r.test,t.Sequence,7),")"]})),s=1,n&D&&(s|=D),r.alternate?(i.push(this.maybeBlock(r.consequent,1)),i=this.maybeBlockSuffix(r.consequent,i),i=r.alternate.type===e.IfStatement?V(i,["else ",this.generateStatement(r.alternate,s)]):V(i,V("else",this.maybeBlock(r.alternate,s)))):i.push(this.maybeBlock(r.consequent,s)),i},ForStatement:function(r,n){var i,s=this;return z((function(){i=["for"+f+"("],r.init?r.init.type===e.VariableDeclaration?i.push(s.generateStatement(r.init,0)):(i.push(s.generateExpression(r.init,t.Sequence,6)),i.push(";")):i.push(";"),r.test?(i.push(f),i.push(s.generateExpression(r.test,t.Sequence,7)),i.push(";")):i.push(";"),r.update?(i.push(f),i.push(s.generateExpression(r.update,t.Sequence,7)),i.push(")")):i.push(")")})),i.push(this.maybeBlock(r.body,n&D?T:1)),i},ForInStatement:function(e,t){return this.generateIterationForStatement("in",e,t&D?T:1)},ForOfStatement:function(e,t){return this.generateIterationForStatement("of",e,t&D?T:1)},LabeledStatement:function(e,t){return[e.label.name+":",this.maybeBlock(e.body,t&D?T:1)]},Program:function(e,t){var r,n,i,s,o;for(s=e.body.length,r=[y&&s>0?"\n":""],o=17,i=0;i<s;++i)y||i!==s-1||(o|=D),C&&(0===i&&(e.body[0].leadingComments||$(e.range[0],e.body[i].range[0],r)),i>0&&(e.body[i-1].trailingComments||e.body[i].leadingComments||$(e.body[i-1].range[1],e.body[i].range[0],r))),n=U(this.generateStatement(e.body[i],o)),r.push(n),i+1<s&&!I(P(n).toString())&&(C&&e.body[i+1].leadingComments||r.push(p)),C&&i===s-1&&(e.body[i].trailingComments||$(e.body[i].range[1],e.range[1],r));return r},FunctionDeclaration:function(e,t){return[Z(e,!0),"function",Y(e)||R(),e.id?X(e.id):"",this.generateFunctionBody(e)]},ReturnStatement:function(e,r){return e.argument?[V("return",this.generateExpression(e.argument,t.Sequence,7)),this.semicolon(r)]:["return"+this.semicolon(r)]},WhileStatement:function(e,r){var n,i=this;return z((function(){n=["while"+f+"(",i.generateExpression(e.test,t.Sequence,7),")"]})),n.push(this.maybeBlock(e.body,r&D?T:1)),n},WithStatement:function(e,r){var n,i=this;return z((function(){n=["with"+f+"(",i.generateExpression(e.object,t.Sequence,7),")"]})),n.push(this.maybeBlock(e.body,r&D?T:1)),n}},k(W.prototype,W.Statement),W.Expression={SequenceExpression:function(e,r,n){var i,s,o;for(t.Sequence<r&&(n|=1),i=[],s=0,o=e.expressions.length;s<o;++s)i.push(this.generateExpression(e.expressions[s],t.Assignment,n)),s+1<o&&i.push(","+f);return H(i,t.Sequence,r)},AssignmentExpression:function(e,t,r){return this.generateAssignment(e.left,e.right,e.operator,t,r)},ArrowFunctionExpression:function(e,r,n){return H(this.generateFunctionBody(e),t.ArrowFunction,r)},ConditionalExpression:function(e,r,n){return t.Conditional<r&&(n|=1),H([this.generateExpression(e.test,t.Coalesce,n),f+"?"+f,this.generateExpression(e.consequent,t.Assignment,n),f+":"+f,this.generateExpression(e.alternate,t.Assignment,n)],t.Conditional,r)},LogicalExpression:function(e,t,r){return"??"===e.operator&&(r|=64),this.BinaryExpression(e,t,r)},BinaryExpression:function(e,n,i){var o,a,u,l,h,c;return l=r[e.operator],a="**"===e.operator?t.Postfix:l,u="**"===e.operator?l:l+1,l<n&&(i|=1),o=47===(c=(h=this.generateExpression(e.left,a,i)).toString()).charCodeAt(c.length-1)&&s.code.isIdentifierPartES5(e.operator.charCodeAt(0))?[h,R(),e.operator]:V(h,e.operator),h=this.generateExpression(e.right,u,i),"/"===e.operator&&"/"===h.toString().charAt(0)||"<"===e.operator.slice(-1)&&"!--"===h.toString().slice(0,3)?(o.push(R()),o.push(h)):o=V(o,h),"in"!==e.operator||1&i?("||"===e.operator||"&&"===e.operator)&&64&i?["(",o,")"]:H(o,l,n):["(",o,")"]},CallExpression:function(e,r,n){var i,s,o;for(i=[this.generateExpression(e.callee,t.Call,3)],e.optional&&i.push("?."),i.push("("),s=0,o=e.arguments.length;s<o;++s)i.push(this.generateExpression(e.arguments[s],t.Assignment,7)),s+1<o&&i.push(","+f);return i.push(")"),2&n?H(i,t.Call,r):["(",i,")"]},ChainExpression:function(e,r,n){return t.OptionalChaining<r&&(n|=2),H(this.generateExpression(e.expression,t.OptionalChaining,n),t.OptionalChaining,r)},NewExpression:function(e,r,n){var i,s,o,a,u;if(s=e.arguments.length,u=4&n&&!m&&0===s?5:1,i=V("new",this.generateExpression(e.callee,t.New,u)),!(4&n)||m||s>0){for(i.push("("),o=0,a=s;o<a;++o)i.push(this.generateExpression(e.arguments[o],t.Assignment,7)),o+1<a&&i.push(","+f);i.push(")")}return H(i,t.New,r)},MemberExpression:function(r,n,i){var o,a;return o=[this.generateExpression(r.object,t.Call,2&i?3:1)],r.computed?(r.optional&&o.push("?."),o.push("["),o.push(this.generateExpression(r.property,t.Sequence,2&i?7:5)),o.push("]")):(r.optional||r.object.type!==e.Literal||"number"!=typeof r.object.value||(a=P(o).toString()).indexOf(".")<0&&!/[eExX]/.test(a)&&s.code.isDecimalDigit(a.charCodeAt(a.length-1))&&!(a.length>=2&&48===a.charCodeAt(0))&&o.push(" "),o.push(r.optional?"?.":"."),o.push(X(r.property))),H(o,t.Member,n)},MetaProperty:function(e,r,n){var i;return(i=[]).push("string"==typeof e.meta?e.meta:X(e.meta)),i.push("."),i.push("string"==typeof e.property?e.property:X(e.property)),H(i,t.Member,r)},UnaryExpression:function(e,r,n){var i,o,a,u,l;return o=this.generateExpression(e.argument,t.Unary,7),""===f?i=V(e.operator,o):(i=[e.operator],e.operator.length>2?i=V(i,o):(l=(u=P(i).toString()).charCodeAt(u.length-1),a=o.toString().charCodeAt(0),(43===l||45===l)&&l===a||s.code.isIdentifierPartES5(l)&&s.code.isIdentifierPartES5(a)?(i.push(R()),i.push(o)):i.push(o))),H(i,t.Unary,r)},YieldExpression:function(e,r,n){var i;return i=e.delegate?"yield*":"yield",e.argument&&(i=V(i,this.generateExpression(e.argument,t.Yield,7))),H(i,t.Yield,r)},AwaitExpression:function(e,r,n){return H(V(e.all?"await*":"await",this.generateExpression(e.argument,t.Await,7)),t.Await,r)},UpdateExpression:function(e,r,n){return e.prefix?H([e.operator,this.generateExpression(e.argument,t.Unary,7)],t.Unary,r):H([this.generateExpression(e.argument,t.Postfix,7),e.operator],t.Postfix,r)},FunctionExpression:function(e,t,r){var n=[Z(e,!0),"function"];return e.id?(n.push(Y(e)||R()),n.push(X(e.id))):n.push(Y(e)||f),n.push(this.generateFunctionBody(e)),n},ArrayPattern:function(e,t,r){return this.ArrayExpression(e,t,r,!0)},ArrayExpression:function(e,r,n,i){var s,a,u=this;return e.elements.length?(a=!i&&e.elements.length>1,s=["[",a?p:""],z((function(r){var n,i;for(n=0,i=e.elements.length;n<i;++n)e.elements[n]?(s.push(a?r:""),s.push(u.generateExpression(e.elements[n],t.Assignment,7))):(a&&s.push(r),n+1===i&&s.push(",")),n+1<i&&s.push(","+(a?p:f))})),a&&!I(P(s).toString())&&s.push(p),s.push(a?o:""),s.push("]"),s):"[]"},RestElement:function(e,t,r){return"..."+this.generatePattern(e.argument)},ClassExpression:function(e,r,n){var i,s;return i=["class"],e.id&&(i=V(i,this.generateExpression(e.id,t.Sequence,7))),e.superClass&&(s=V("extends",this.generateExpression(e.superClass,t.Unary,7)),i=V(i,s)),i.push(f),i.push(this.generateStatement(e.body,T)),i},MethodDefinition:function(e,t,r){var n,i;return n=e.static?["static"+f]:[],i="get"===e.kind||"set"===e.kind?[V(e.kind,this.generatePropertyKey(e.key,e.computed)),this.generateFunctionBody(e.value)]:[K(e),this.generatePropertyKey(e.key,e.computed),this.generateFunctionBody(e.value)],V(n,i)},Property:function(e,r,n){return"get"===e.kind||"set"===e.kind?[e.kind,R(),this.generatePropertyKey(e.key,e.computed),this.generateFunctionBody(e.value)]:e.shorthand?"AssignmentPattern"===e.value.type?this.AssignmentPattern(e.value,t.Sequence,7):this.generatePropertyKey(e.key,e.computed):e.method?[K(e),this.generatePropertyKey(e.key,e.computed),this.generateFunctionBody(e.value)]:[this.generatePropertyKey(e.key,e.computed),":"+f,this.generateExpression(e.value,t.Assignment,7)]},ObjectExpression:function(e,r,n){var i,s,a,u,l=this;return e.properties.length?(i=e.properties.length>1,z((function(){a=l.generateExpression(e.properties[0],t.Sequence,7)})),i||(u=P(a).toString(),/[\r\n]/g.test(u))?(z((function(r){var n,o;if(s=["{",p,r,a],i)for(s.push(","+p),n=1,o=e.properties.length;n<o;++n)s.push(r),s.push(l.generateExpression(e.properties[n],t.Sequence,7)),n+1<o&&s.push(","+p)})),I(P(s).toString())||s.push(p),s.push(o),s.push("}"),s):["{",f,a,f,"}"]):"{}"},AssignmentPattern:function(e,t,r){return this.generateAssignment(e.left,e.right,"=",t,r)},ObjectPattern:function(r,n,i){var s,a,u,l,h,c=this;if(!r.properties.length)return"{}";if(l=!1,1===r.properties.length)(h=r.properties[0]).type===e.Property&&h.value.type!==e.Identifier&&(l=!0);else for(a=0,u=r.properties.length;a<u;++a)if((h=r.properties[a]).type===e.Property&&!h.shorthand){l=!0;break}return s=["{",l?p:""],z((function(e){var n,i;for(n=0,i=r.properties.length;n<i;++n)s.push(l?e:""),s.push(c.generateExpression(r.properties[n],t.Sequence,7)),n+1<i&&s.push(","+(l?p:f))})),l&&!I(P(s).toString())&&s.push(p),s.push(l?o:""),s.push("}"),s},ThisExpression:function(e,t,r){return"this"},Super:function(e,t,r){return"super"},Identifier:function(e,t,r){return X(e)},ImportDefaultSpecifier:function(e,t,r){return X(e.id||e.local)},ImportNamespaceSpecifier:function(e,t,r){var n=["*"],i=e.id||e.local;return i&&n.push(f+"as"+R()+X(i)),n},ImportSpecifier:function(e,t,r){var n=e.imported,i=[n.name],s=e.local;return s&&s.name!==n.name&&i.push(R()+"as"+R()+X(s)),i},ExportSpecifier:function(e,t,r){var n=e.local,i=[n.name],s=e.exported;return s&&s.name!==n.name&&i.push(R()+"as"+R()+X(s)),i},Literal:function(t,r,n){var i;if(t.hasOwnProperty("raw")&&x&&b.raw)try{if((i=x(t.raw).body[0].expression).type===e.Literal&&i.value===t.value)return t.raw}catch(e){}return t.regex?"/"+t.regex.pattern+"/"+t.regex.flags:"bigint"==typeof t.value?t.value.toString()+"n":t.bigint?t.bigint+"n":null===t.value?"null":"string"==typeof t.value?function(e){var t,r,n,i,o,a="",l=0,h=0;for(t=0,r=e.length;t<r;++t){if(39===(n=e.charCodeAt(t)))++l;else if(34===n)++h;else if(47===n&&u)a+="\\";else{if(s.code.isLineTerminator(n)||92===n){a+=B(n);continue}if(!s.code.isIdentifierPartES5(n)&&(u&&n<32||!u&&!d&&(n<32||n>126))){a+=O(n,e.charCodeAt(t+1));continue}}a+=String.fromCharCode(n)}if(o=(i=!("double"===c||"auto"===c&&h<l))?"'":'"',!(i?l:h))return o+a+o;for(e=a,a=o,t=0,r=e.length;t<r;++t)(39===(n=e.charCodeAt(t))&&i||34===n&&!i)&&(a+="\\"),a+=String.fromCharCode(n);return a+o}(t.value):"number"==typeof t.value?function(e){var t,r,n,i,s;if(e!=e)throw new Error("Numeric literal whose value is NaN");if(e<0||0===e&&1/e<0)throw new Error("Numeric literal whose value is negative");if(e===1/0)return u?"null":l?"1e400":"1e+400";if(t=""+e,!l||t.length<3)return t;for(r=t.indexOf("."),u||48!==t.charCodeAt(0)||1!==r||(r=0,t=t.slice(1)),n=t,t=t.replace("e+","e"),i=0,(s=n.indexOf("e"))>0&&(i=+n.slice(s+1),n=n.slice(0,s)),r>=0&&(i-=n.length-r-1,n=+(n.slice(0,r)+n.slice(r+1))+""),s=0;48===n.charCodeAt(n.length+s-1);)--s;return 0!==s&&(i-=s,n=n.slice(0,s)),0!==i&&(n+="e"+i),(n.length<t.length||h&&e>1e12&&Math.floor(e)===e&&(n="0x"+e.toString(16)).length<t.length)&&+n===e&&(t=n),t}(t.value):"boolean"==typeof t.value?t.value?"true":"false":function(e){var t,r,n,i,s,o,a,u;if(r=e.toString(),e.source){if(!(t=r.match(/\/([^/]*)$/)))return r;for(n=t[1],r="",a=!1,u=!1,i=0,s=e.source.length;i<s;++i)o=e.source.charCodeAt(i),u?(r+=M(o,u),u=!1):(a?93===o&&(a=!1):47===o?r+="\\":91===o&&(a=!0),r+=M(o,u),u=92===o);return"/"+r+"/"+n}return r}(t.value)},GeneratorExpression:function(e,t,r){return this.ComprehensionExpression(e,t,r)},ComprehensionExpression:function(r,n,i){var s,o,a,u,l=this;return s=r.type===e.GeneratorExpression?["("]:["["],b.moz.comprehensionExpressionStartsWithAssignment&&(u=this.generateExpression(r.body,t.Assignment,7),s.push(u)),r.blocks&&z((function(){for(o=0,a=r.blocks.length;o<a;++o)u=l.generateExpression(r.blocks[o],t.Sequence,7),o>0||b.moz.comprehensionExpressionStartsWithAssignment?s=V(s,u):s.push(u)})),r.filter&&(s=V(s,"if"+f),u=this.generateExpression(r.filter,t.Sequence,7),s=V(s,["(",u,")"])),b.moz.comprehensionExpressionStartsWithAssignment||(u=this.generateExpression(r.body,t.Assignment,7),s=V(s,u)),s.push(r.type===e.GeneratorExpression?")":"]"),s},ComprehensionBlock:function(r,n,i){var s;return s=V(s=r.left.type===e.VariableDeclaration?[r.left.kind,R(),this.generateStatement(r.left.declarations[0],0)]:this.generateExpression(r.left,t.Call,7),r.of?"of":"in"),s=V(s,this.generateExpression(r.right,t.Sequence,7)),["for"+f+"(",s,")"]},SpreadElement:function(e,r,n){return["...",this.generateExpression(e.argument,t.Assignment,7)]},TaggedTemplateExpression:function(e,r,n){var i=3;return 2&n||(i=1),H([this.generateExpression(e.tag,t.Call,i),this.generateExpression(e.quasi,t.Primary,4)],t.TaggedTemplate,r)},TemplateElement:function(e,t,r){return e.value.raw},TemplateLiteral:function(e,r,n){var i,s,o;for(i=["`"],s=0,o=e.quasis.length;s<o;++s)i.push(this.generateExpression(e.quasis[s],t.Primary,7)),s+1<o&&(i.push("${"+f),i.push(this.generateExpression(e.expressions[s],t.Sequence,7)),i.push(f+"}"));return i.push("`"),i},ModuleSpecifier:function(e,t,r){return this.Literal(e,t,r)},ImportExpression:function(e,r,n){return H(["import(",this.generateExpression(e.source,t.Assignment,7),")"],t.Call,r)}},k(W.prototype,W.Expression),W.prototype.generateExpression=function(r,n,i){var s,o;return o=r.type||e.Property,b.verbatim&&r.hasOwnProperty(b.verbatim)?function(e,r){var n;return P("string"==typeof(n=e[b.verbatim])?H(q(n),t.Sequence,r):H(q(n.content),null!=n.precedence?n.precedence:t.Sequence,r),e)}(r,n):(s=this[o](r,n,i),b.comment&&(s=G(r,s)),P(s,r))},W.prototype.generateStatement=function(t,r){var n,i;return n=this[t.type](t,r),b.comment&&(n=G(t,n)),i=P(n).toString(),t.type!==e.Program||y||""!==p||"\n"!==i.charAt(i.length-1)||(n=_?P(n).replaceRight(/\s+$/,""):i.replace(/\s+$/,"")),P(n,t)},E={indent:{style:"",base:0},renumber:!0,hexadecimal:!0,quotes:"auto",escapeless:!0,compact:!0,parentheses:!1,semicolons:!1},S={indent:{style:"    ",base:0,adjustMultilineComment:!1},newline:"\n",space:" ",json:!1,renumber:!1,hexadecimal:!1,quotes:"single",escapeless:!1,compact:!1,parentheses:!0,semicolons:!0,safeConcatenation:!1,preserveBlankLines:!1},Ib.version=kb,Ib.generate=function(e,t){var r,i,s={indent:null,base:null,parse:null,comment:!1,format:{indent:{style:"    ",base:0,adjustMultilineComment:!1},newline:"\n",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};return null!=t?("string"==typeof t.indent&&(s.format.indent.style=t.indent),"number"==typeof t.base&&(s.format.indent.base=t.base),t=N(s,t),a=t.format.indent.style,o="string"==typeof t.base?t.base:F(a,t.format.indent.base)):(a=(t=s).format.indent.style,o=F(a,t.format.indent.base)),u=t.format.json,l=t.format.renumber,h=!u&&t.format.hexadecimal,c=u?"double":t.format.quotes,d=t.format.escapeless,p=t.format.newline,f=t.format.space,t.format.compact&&(p=f=a=o=""),m=t.format.parentheses,g=t.format.semicolons,y=t.format.safeConcatenation,v=t.directive,x=u?null:t.parse,_=t.sourceMap,w=t.sourceCode,C=t.format.preserveBlankLines&&null!==w,b=t,_&&(n=Ib.browser?Ds.sourceMap.SourceNode:Fb().SourceNode),r=J(e),_?(i=r.toStringWithSourceMap({file:t.file,sourceRoot:t.sourceMapRoot}),t.sourceContent&&i.map.setSourceContent(t.sourceMap,t.sourceContent),t.sourceMapWithCode?i:i.map.toString()):(i={code:r.toString(),map:null},t.sourceMapWithCode?i:i.code)},Ib.attachComments=i.attachComments,Ib.Precedence=N({},t),Ib.browser=!1,Ib.FORMAT_MINIFY=E,Ib.FORMAT_DEFAULTS=S}();var Nb=Ts($v);let Mb=0,Ob=0;function Bb(e){switch(e){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 Lb(e){return e&&"CallExpression"===e.type&&("Identifier"===e.callee?.type&&e.callee?.name.startsWith("uniform")||"MemberExpression"===e.callee?.type&&e.callee?.property.name.startsWith("uniform"))}function Pb(e,t){return!!t?.size&&(!("FunctionDeclaration"!==e.type||!t.has(e.id?.name))||!("VariableDeclarator"!==e.type||!t.has(e.id?.name)||"FunctionExpression"!==e.init?.type&&"ArrowFunctionExpression"!==e.init?.type))}function Rb(e){if("Identifier"===e?.type)return e.name;if("MemberExpression"!==e?.type||e.computed)return null;const t=Rb(e.object),r=e.property?.name;return t&&r?`${t}.${r}`:null}function Vb(e){if("CallExpression"!==e?.type)return!1;const t=Rb(e.callee);return!!t&&("loopProtect.protect"===t||t.endsWith(".loopProtect")||t.endsWith(".loopProtect.protect"))}function Ub(e){if("VariableDeclaration"===e.type){return e.declarations.some((e=>"CallExpression"===e.init?.type&&("MemberExpression"===e.init?.callee?.type&&"Identifier"===e.init?.callee?.object?.type&&"__p5"===e.init?.callee?.object?.name&&("strandsFor"===e.init?.callee?.property?.name||"strandsIf"===e.init?.callee?.property?.name)||"Identifier"===e.init?.callee?.type&&("__p5.strandsFor"===e.init?.callee?.name||"__p5.strandsIf"===e.init?.callee?.name))))}return!1}function zb(e){if(!e||"string"!=typeof e)return!1;return[["x","y","z","w"],["r","g","b","a"],["s","t","p","q"]].some((t=>[...e].every((e=>t.includes(e)))))}function jb(e){const t=[];let r=e;for(;"MemberExpression"===r.type;){if(r.computed)return null;const e=r.property.name||r.property.value;if(zb(e)){r=r.object;break}t.unshift(e),r=r.object}return"Identifier"!==r.type?null:(t.unshift(r.name),t.join("."))}function Gb(e,t,r){if(!e||"object"!=typeof e)return e;const n=e=>{if(!e||"object"!=typeof e)return e;if("Identifier"===e.type&&e.name===t)return{...e,name:r};const i={...e};for(const t in e)e.hasOwnProperty(t)&&"parent"!==t&&(Array.isArray(e[t])?i[t]=e[t].map(n):"object"==typeof e[t]&&(i[t]=n(e[t])));return i};return n(e)}function $b(e,t,r){r.some((e=>Lb(e)||Pb(e,t.uniformCallbackNames)))||(e.left={type:"CallExpression",callee:{type:"Identifier",name:"__p5.strandsNode"},arguments:[e.left]},e.type="CallExpression",e.callee={type:"MemberExpression",object:e.left,property:{type:"Identifier",name:Bb(e.operator)}},e.arguments=[e.right])}function Hb(e,t,r=null){if("BlockStatement"!==e.type)return;const n=new Map,i=[];for(const e of t){const t=e.split("."),s=`__copy_${t.join("_")}_${Mb++}`;n.set(e,s);let o=r?{type:"Identifier",name:r}:{type:"Identifier",name:t[0]};const a=r?t:t.slice(1);for(const e of a)o={type:"MemberExpression",object:o,property:{type:"Identifier",name:e},computed:!1};i.push({type:"VariableDeclaration",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:s},init:{type:"CallExpression",callee:{type:"MemberExpression",object:o,property:{type:"Identifier",name:"copy"},computed:!1},arguments:[]}}],kind:"let"})}e.body.forEach((e=>function(e,t){const r=e=>{if(e&&"object"==typeof e){if("MemberExpression"===e.type){if(zb(e.property.name||e.property.value))return void r(e.object);const n=jb(e);if(n&&t.has(n))return void Object.assign(e,{type:"Identifier",name:t.get(n)})}if("Identifier"===e.type&&t.has(e.name)&&(e.name=t.get(e.name)),"AssignmentExpression"===e.type){let r=null;"Identifier"===e.left.type?r=e.left.name:"MemberExpression"===e.left.type&&(r=jb(e.left)),r&&t.has(r)&&("Literal"===e.right.type||"ArrayExpression"===e.right.type)&&(e.right={type:"CallExpression",callee:{type:"Identifier",name:"__p5.strandsNode"},arguments:[e.right]})}for(const t in e)if(e.hasOwnProperty(t)&&"parent"!==t){if("MemberExpression"===e.type&&"property"===t&&!e.computed)continue;Array.isArray(e[t])?e[t].forEach(r):"object"==typeof e[t]&&r(e[t])}}};r(e)}(e,n))),e.body.unshift(...i);const s={type:"ObjectExpression",properties:Array.from(t).map((e=>({type:"Property",key:{type:"Literal",value:e},value:{type:"Identifier",name:n.get(e)},kind:"init",computed:!1,shorthand:!1})))};e.body.push({type:"ReturnStatement",argument:s})}const qb={UnaryExpression(e,t,r){if(r.some((e=>Lb(e)||Pb(e,t.uniformCallbackNames))))return;const n=gi[e.operator],i=e=>{e.type="CallExpression",e.callee={type:"Identifier",name:`__p5.${n}`},e.arguments=[e.argument]};if("MemberExpression"===e.type){const t=e.argument.property.name;let r=[["x","y","z","w"],["r","g","b","a"],["s","t","p","q"]].some((e=>[...t].every((t=>e.includes(t)))))&&"MemberExpression"===e.argument.type&&!e.argument.computed;r?(e.type="MemberExpression",e.object={type:"CallExpression",callee:{type:"Identifier",name:`__p5.${n}`},arguments:[e.argument.object]},e.property={type:"Identifier",name:t}):i(e)}else i(e);delete e.argument,delete e.operator},BreakStatement(e,t,r){r.some((e=>Lb(e)||Pb(e,t.uniformCallbackNames)))||(e.callee={type:"Identifier",name:"__p5.break"},e.arguments=[],e.type="CallExpression")},MemberExpression(e,t,r){if(!r.some((e=>Lb(e)||Pb(e,t.uniformCallbackNames)))&&("AssignmentExpression"!==r.at(-2)?.type||r.at(-2).left!==e)&&e.computed){const t=e.object,r=e.property;e.computed=void 0,e.object=void 0,e.callee={type:"MemberExpression",object:t,property:{type:"Identifier",name:"get"}},e.arguments=[r],e.type="CallExpression"}},VariableDeclarator(e,t,r){if(!r.some((e=>Lb(e)||Pb(e,t.uniformCallbackNames)))){if(Lb(e.init)&&(0===e.init.arguments.length||"Literal"!==e.init.arguments[0].type||"string"!=typeof e.init.arguments[0].value)){const t={type:"Literal",value:e.id.name};e.init.arguments.unshift(t)}if(function(e){return e&&"CallExpression"===e.type&&("Identifier"===e.callee?.type&&(e.callee?.name.startsWith("varying")||e.callee?.name.startsWith("shared"))||"MemberExpression"===e.callee?.type&&(e.callee?.property.name.startsWith("varying")||e.callee?.property.name.startsWith("shared")))}(e.init))if(0===e.init.arguments.length||"Literal"!==e.init.arguments[0].type||"string"!=typeof e.init.arguments[0].value){const r={type:"Literal",value:e.id.name};e.init.arguments.unshift(r),t.varyings[e.id.name]=r}else t.varyings[e.id.name]=e.init.arguments[0]}},Identifier(e,t,r){r.some((e=>Lb(e)||Pb(e,t.uniformCallbackNames)))||t.varyings[e.name]&&!r.some((t=>"AssignmentExpression"===t.type&&t.left===e))&&(e.type="CallExpression",e.callee={type:"MemberExpression",object:{type:"Identifier",name:e.name},property:{type:"Identifier",name:"getValue"}},e.arguments=[])},ArrayExpression(e,t,r){if(r.some((e=>Lb(e)||Pb(e,t.uniformCallbackNames))))return;(e.elements.length<2||e.elements.length>4)&&Ea("type error",`Array literals in shader functions are transpiled to vectors and must have 2-4 elements (got ${e.elements.length}).`);const n=JSON.parse(JSON.stringify(e));e.type="CallExpression",e.callee={type:"Identifier",name:"__p5.strandsNode"},e.arguments=[n]},AssignmentExpression(e,t,r){if(r.some((e=>Lb(e)||Pb(e,t.uniformCallbackNames))))return;const n=["Literal","ArrayExpression","Identifier"];if("="!==e.operator){const t=Bb(e.operator.replace("=","")),r={type:"CallExpression",callee:{type:"MemberExpression",object:n.includes(e.left.type)?{type:"CallExpression",callee:{type:"Identifier",name:"__p5.strandsNode"},arguments:[e.left]}:e.left,property:{type:"Identifier",name:t}},arguments:[e.right]};e.operator="=",e.right=r}if(t.varyings[e.left.name])e.type="ExpressionStatement",e.expression={type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier",name:e.left.name},property:{type:"Identifier",name:"bridge"}},arguments:[e.right]};else if("MemberExpression"===e.left.type){if(e.left.computed){const t=e.left,r=e.right,n=t.object,i=t.property;return e.right=void 0,e.left=void 0,e.operator=void 0,e.callee={type:"MemberExpression",object:n,property:{type:"Identifier",name:"set"}},e.arguments=[i,r],void(e.type="CallExpression")}let r=null;if("Identifier"===e.left.object.type&&t.varyings[e.left.object.name]?r=e.left.object.name:"CallExpression"===e.left.object.type&&"MemberExpression"===e.left.object.callee?.type&&"getValue"===e.left.object.callee.property?.name&&"Identifier"===e.left.object.callee.object?.type&&t.varyings[e.left.object.callee.object.name]&&(r=e.left.object.callee.object.name),r){const t=e.left.property.name;e.type="ExpressionStatement",e.expression={type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier",name:r},property:{type:"Identifier",name:"bridgeSwizzle"}},arguments:[{type:"Literal",value:t},e.right]}}}},BinaryExpression:$b,LogicalExpression:$b,ConditionalExpression(e,t,r){if(r.some((e=>Lb(e)||Pb(e,t.uniformCallbackNames))))return;const n=e.test,i=e.consequent,s=e.alternate;e.type="CallExpression",e.callee={type:"Identifier",name:"__p5.strandsTernary"},e.arguments=[n,i,s],delete e.test,delete e.consequent,delete e.alternate},IfStatement(e,t,r){if(r.some((e=>Lb(e)||Pb(e,t.uniformCallbackNames))))return;const n=e.test,i={type:"ArrowFunctionExpression",params:[],body:"BlockStatement"===e.consequent.type?e.consequent:{type:"BlockStatement",body:[e.consequent]}};let s,o={type:"CallExpression",callee:{type:"Identifier",name:"__p5.strandsIf"},arguments:[n,i]};s=e.alternate?{type:"ArrowFunctionExpression",params:[],body:"BlockStatement"===e.alternate.type?e.alternate:{type:"BlockStatement",body:[e.alternate]}}:{type:"ArrowFunctionExpression",params:[],body:{type:"BlockStatement",body:[]}},o={type:"CallExpression",callee:{type:"MemberExpression",object:o,property:{type:"Identifier",name:"Else"}},arguments:[s]};const a=new Set,u=e=>{const t=new Set;Cg(e,{VariableDeclarator(e,r){r.some(Ub)||"Identifier"===e.id.type&&t.add(e.id.name)}}),Cg(e,{AssignmentExpression(e,r){if(r.some(Ub))return;const n=e.left;if("Identifier"===n.type)t.has(n.name)||a.add(n.name);else if("MemberExpression"===n.type){const e=jb(n);if(e){const r=e.split(".")[0];t.has(r)||a.add(e)}}}})};if(u(i.body),u(s.body),a.size>0){Hb(i.body,a),Hb(s.body,a);const t="__block_"+Mb++,r=[];for(const e of a){const t=e.split(".");let n={type:"Identifier",name:t[0]};for(let e=1;e<t.length;e++)n={type:"MemberExpression",object:n,property:{type:"Identifier",name:t[e]},computed:!1};let i={type:"Identifier",name:t[0]};for(let e=1;e<t.length;e++)i={type:"MemberExpression",object:i,property:{type:"Identifier",name:t[e]},computed:!1};r.push({type:"ExpressionStatement",expression:{type:"AssignmentExpression",operator:"=",left:n,right:{type:"CallExpression",callee:{type:"Identifier",name:"__p5.strandsNode"},arguments:[i]}}})}r.push({type:"VariableDeclaration",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:t},init:o}],kind:"const"});for(const e of a){const n=e.split(".");let i={type:"Identifier",name:n[0]};for(let e=1;e<n.length;e++)i={type:"MemberExpression",object:i,property:{type:"Identifier",name:n[e]},computed:!1};const s={type:"MemberExpression",object:{type:"Identifier",name:t},property:{type:"Literal",value:e},computed:!0};r.push({type:"ExpressionStatement",expression:{type:"AssignmentExpression",operator:"=",left:i,right:s}})}e.type="BlockStatement",e.body=r}else e.type="ExpressionStatement",e.expression=o;delete e.test,delete e.consequent,delete e.alternate},UpdateExpression(e,t,r){if(r.some((e=>Lb(e)||Pb(e,t.uniformCallbackNames))))return;let n;if("++"===e.operator)n="+";else{if("--"!==e.operator)return;n="-"}const i={type:"AssignmentExpression",operator:"=",left:e.argument,right:{type:"BinaryExpression",operator:n,left:e.argument,right:{type:"Literal",value:1}}};Object.assign(e,i),delete e.prefix,qb.BinaryExpression(e.right,t,[...r,e]),qb.AssignmentExpression(e,t,r)},ForStatement(e,t,r){if(r.some((e=>Lb(e)||Pb(e,t.uniformCallbackNames))))return;const n="loopVar"+Ob++;let i;if(e.init&&"VariableDeclaration"===e.init.type){let t=e.init.declarations[0].init;t={body:[{type:"ExpressionStatement",expression:t}]}.body[0].expression,i={type:"ArrowFunctionExpression",params:[],body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:t}]}}}else i={type:"ArrowFunctionExpression",params:[],body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:{type:"Literal",value:0}}]}};let s=e.test||{type:"Literal",value:!0};if("VariableDeclaration"===e.init?.type){s=Gb(s,e.init.declarations[0].id.name,n)}s={body:[{type:"ExpressionStatement",expression:s}]}.body[0].expression;const o={type:"ArrowFunctionExpression",params:[{type:"Identifier",name:n}],body:s};let a;if(e.update){let t=e.update;if("VariableDeclaration"===e.init?.type){t=Gb(t,e.init.declarations[0].id.name,n)}t={body:[{type:"ExpressionStatement",expression:t}]}.body[0].expression,a={type:"ArrowFunctionExpression",params:[{type:"Identifier",name:n}],body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:t}]}}}else a={type:"ArrowFunctionExpression",params:[{type:"Identifier",name:n}],body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:{type:"Identifier",name:n}}]}};let u="BlockStatement"===e.body.type?e.body:{type:"BlockStatement",body:[e.body]};if("VariableDeclaration"===e.init?.type){u=Gb(u,e.init.declarations[0].id.name,n)}const l={type:"ArrowFunctionExpression",params:[{type:"Identifier",name:n},{type:"Identifier",name:"vars"}],body:u},h=new Set,c=new Set;if(Cg(l.body,{VariableDeclarator(e,t){t.some(Ub)||"Identifier"===e.id.type&&c.add(e.id.name)}}),Cg(l.body,{AssignmentExpression(e,t){if(t.some(Ub))return;const r=e.left;if("Identifier"===r.type)c.has(r.name)||h.add(r.name);else if("MemberExpression"===r.type){const e=jb(r);if(e){const t=e.split(".")[0];c.has(t)||h.add(e)}}}}),h.size>0){Hb(l.body,h,"vars");const t="__block_"+Mb++,r=[],n={type:"ObjectExpression",properties:Array.from(h).map((e=>{const t=e.split(".");let r={type:"Identifier",name:t[0]};for(let e=1;e<t.length;e++)r={type:"MemberExpression",object:r,property:{type:"Identifier",name:t[e]},computed:!1};return{type:"Property",key:{type:"Literal",value:e},value:{type:"CallExpression",callee:{type:"Identifier",name:"__p5.strandsNode"},arguments:[r]},kind:"init",computed:!1,shorthand:!1}}))},s={type:"CallExpression",callee:{type:"Identifier",name:"__p5.strandsFor"},arguments:[i,o,a,l,n]};r.push({type:"VariableDeclaration",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:t},init:s}],kind:"const"});for(const e of h){const n=e.split(".");let i={type:"Identifier",name:n[0]};for(let e=1;e<n.length;e++)i={type:"MemberExpression",object:i,property:{type:"Identifier",name:n[e]},computed:!1};let s={type:"Identifier",name:t};for(const e of n)s={type:"MemberExpression",object:s,property:{type:"Identifier",name:e},computed:!1};r.push({type:"ExpressionStatement",expression:{type:"AssignmentExpression",operator:"=",left:i,right:s}})}e.type="BlockStatement",e.body=r}else e.type="ExpressionStatement",e.expression={type:"CallExpression",callee:{type:"Identifier",name:"__p5.strandsFor"},arguments:[i,o,a,l,{type:"ObjectExpression",properties:[]}]};delete e.init,delete e.test,delete e.update}};function Wb(e){let t=!1,r=0;const n={IfStatement(e,t,n){r++,e.test&&n(e.test,t),e.consequent&&n(e.consequent,t),e.alternate&&n(e.alternate,t),r--},ForStatement(e,t,n){r++,e.init&&n(e.init,t),e.test&&n(e.test,t),e.update&&n(e.update,t),e.body&&n(e.body,t),r--},ReturnStatement(e){r>0&&(t=!0)}};return e.body&&"BlockStatement"===e.body.type&&Eg(e.body,{},n),t}function Xb(e){let t=!1;return e&&Eg(e,{},{ReturnStatement(){t=!0}}),t}function Zb(e){if(!e.body||"BlockStatement"!==e.body.type)return;e.body.body.unshift({type:"VariableDeclaration",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:"__returnValue"},init:null}],kind:"let"}),function e(t){for(let r=0;r<t.length;r++){const n=t[r];if("IfStatement"===n.type&&Xb(n.consequent)&&!n.alternate){const i=t.slice(r+1);i.length>0&&(n.alternate={type:"BlockStatement",body:i},t.splice(r+1),e(n.alternate.body))}"IfStatement"===n.type?(n.consequent&&"BlockStatement"===n.consequent.type&&e(n.consequent.body),n.alternate&&"BlockStatement"===n.alternate.type&&e(n.alternate.body)):"ForStatement"===n.type&&n.body&&"BlockStatement"===n.body.type?e(n.body.body):"BlockStatement"===n.type&&e(n.body)}}(e.body.body);const t={ReturnStatement(e){e.type="ExpressionStatement",e.expression={type:"AssignmentExpression",operator:"=",left:{type:"Identifier",name:"__returnValue"},right:e.argument||{type:"Identifier",name:"undefined"}},delete e.argument}};Eg(e.body,{},t);e.body.body.push({type:"ReturnStatement",argument:{type:"Identifier",name:"__returnValue"}})}function Yb(e){let t=!1,r=0;const n={IfStatement(e,t,n){r++,e.test&&n(e.test,t),e.consequent&&n(e.consequent,t),e.alternate&&n(e.alternate,t),r--},ForStatement(e,t,n){r++,e.init&&n(e.init,t),e.test&&n(e.test,t),e.update&&n(e.update,t),e.body&&n(e.body,t),r--},CallExpression(e){r>0&&"MemberExpression"===e.callee?.type&&"set"===e.callee?.property?.name&&(t=!0)}};return e.body&&"BlockStatement"===e.body.type&&Eg(e.body,{},n),t}function Kb(e){if(!e.body||"BlockStatement"!==e.body.type)return;const t=new Map,r={CallExpression(e){if("MemberExpression"===e.callee?.type&&"set"===e.callee?.property?.name&&e.callee?.object){const r=e.callee.object,n=Nb.generate(r);t.has(n)||t.set(n,r)}}};if(Eg(e.body,{},r),0!==t.size)for(const[r,n]of t){const t=`__${r.replace(/[^a-zA-Z0-9_]/g,"_")}_value`,i={type:"VariableDeclaration",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:t},init:null}],kind:"let"};let s=-1;for(let t=0;t<e.body.body.length;t++){const n=e.body.body[t];if("ExpressionStatement"===n.type&&"CallExpression"===n.expression?.type&&"MemberExpression"===n.expression?.callee?.type&&"begin"===n.expression?.callee?.property?.name){if(Nb.generate(n.expression.callee.object)===r){s=t;break}}}-1!==s?e.body.body.splice(s+1,0,i):e.body.body.unshift(i);const o={CallExpression(e,n,i){if("MemberExpression"===e.callee?.type&&"set"===e.callee?.property?.name&&e.callee?.object){if(Nb.generate(e.callee.object)===r&&e.arguments.length>0){let r=null;for(let e=i.length-1;e>=0;e--)if("ExpressionStatement"===i[e].type){r=i[e];break}r&&(r.type="ExpressionStatement",r.expression={type:"AssignmentExpression",operator:"=",left:{type:"Identifier",name:t},right:e.arguments[0]})}}}};Cg(e.body,o);const a={type:"ExpressionStatement",expression:{type:"CallExpression",callee:{type:"MemberExpression",object:JSON.parse(JSON.stringify(n)),property:{type:"Identifier",name:"set"},computed:!1},arguments:[{type:"Identifier",name:t}]}};let u=-1;for(let t=0;t<e.body.body.length;t++){const n=e.body.body[t];if("ExpressionStatement"===n.type&&"CallExpression"===n.expression?.type&&"MemberExpression"===n.expression?.callee?.type&&"end"===n.expression?.callee?.property?.name){if(Nb.generate(n.expression.callee.object)===r){u=t;break}}}if(-1!==u)e.body.body.splice(u,0,a);else{const t=e.body.body[e.body.body.length-1];t&&"ReturnStatement"===t.type?e.body.body.splice(e.body.body.length-1,0,a):e.body.body.push(a)}}}function Jb(e,t,r,n){Mb=0,Ob=0;const i=wg(t,{ecmaVersion:2021,locations:r});!function(e){let t=!1;Cg(e,{CallExpression(e){Vb(e)&&(t=!0)},LogicalExpression(e){"CallExpression"===e.right?.type&&Vb(e.right)&&(t=!0)}}),t&&Ca("loop protection error Loop protection code detected. Add `// noprotect` at the top of your sketch and run again.")}(i);const s=function(e){const t=new Set;Cg(e,{FunctionDeclaration(e){e.id&&t.add(e.id.name)},VariableDeclarator(e){"Identifier"!==e.id?.type||"FunctionExpression"!==e.init?.type&&"ArrowFunctionExpression"!==e.init?.type||t.add(e.id.name)}});const r=new Set;return Cg(e,{CallExpression(e){if(Lb(e))for(const n of e.arguments)"Identifier"===n.type&&t.has(n.name)&&r.add(n.name)}}),r}(i);return function(e,t){const r=[];Cg(e,{ArrowFunctionExpression(e,n){n.some((e=>Lb(e)||Pb(e,t)))||Yb(e)&&r.push(e)},FunctionExpression(e,n){n.some((e=>Lb(e)||Pb(e,t)))||Yb(e)&&r.push(e)},FunctionDeclaration(e,n){n.some((e=>Lb(e)||Pb(e,t)))||Yb(e)&&r.push(e)}});for(const e of r)Kb(e)}(i,s),function(e,t){const r={...qb};delete r.IfStatement,delete r.ForStatement,Cg(e,r,void 0,{varyings:{},uniformCallbackNames:t})}(i,s),function(e,t){const r=[];Cg(e,{VariableDeclarator(e,n){if(n.some((e=>Lb(e)||Pb(e,t))))return;const i=e.init;!i||"ArrowFunctionExpression"!==i.type&&"FunctionExpression"!==i.type||Wb(i)&&r.push(i)},FunctionDeclaration(e,n){n.some((e=>Lb(e)||Pb(e,t)))||Wb(e)&&r.push(e)},CallExpression(e,t){}});for(const e of r)Zb(e)}(i,s),function(e,t){Eg(e,{varyings:{},inControlFlow:0,uniformCallbackNames:t},{CallExpression(e,t,r){if(!Lb(e)){e.callee&&r(e.callee,t);for(const n of e.arguments)r(n,t)}},FunctionDeclaration(e,t,r){t.uniformCallbackNames?.has(e.id?.name)||e.body&&r(e.body,t)},VariableDeclarator(e,t,r){(!t.uniformCallbackNames?.has(e.id?.name)||"FunctionExpression"!==e.init?.type&&"ArrowFunctionExpression"!==e.init?.type)&&e.init&&r(e.init,t)},IfStatement(e,t,r){t.inControlFlow++,e.test&&r(e.test,t),e.consequent&&r(e.consequent,t),e.alternate&&r(e.alternate,t),qb.IfStatement(e,t,[]),t.inControlFlow--},ForStatement(e,t,r){t.inControlFlow++,e.init&&r(e.init,t),e.test&&r(e.test,t),e.update&&r(e.update,t),e.body&&r(e.body,t),qb.ForStatement(e,t,[]),t.inControlFlow--},ReturnStatement(e,t,r){t.inControlFlow&&(e.type="ExpressionStatement",e.expression={type:"CallExpression",callee:{type:"Identifier",name:"__p5.strandsEarlyReturn"},arguments:e.argument?[e.argument]:[]},delete e.argument)}})}(i,s),function(e,t,r){const n=Nb.generate(t),i=Object.keys(r),s=/\(?\s*(?:function)?\s*\w*\s*\(([^)]*)\)\s*(?:=>)?\s*{((?:.|\n)*)}\s*;?\s*\)?/.exec(n);if(!s)throw console.log(n),new Error("Could not parse p5.strands function!");const o=s[1].split(/,\s*/).filter((e=>!!e.trim()));let a,u;o.length>0?(u=o,a=[r]):(u=i,a=i.map((e=>r[e])));const l=s[2];try{const t=new Function("__p5",...u,l);return()=>t(e,...a)}catch(e){throw console.error(e),console.log(u),console.log(l),new Error("Error transpiling p5.strands callback!")}}(e,i,n)}function Qb(e,t,r){const n=t.filter((e=>null!==e.value.id));if(0===n.length)throw new Error(`No valid inputs for phi node for variable ${r}`);const i=n.map((t=>Fa(e.dag,t.value.id)));let s=i.find((e=>e.baseType!==ri&&e.dimension))??i.find((e=>e.baseType!==ri));s||(s=i[0]);const o=s.dimension,a=s.baseType;if(a!==ri)for(const t of i)t.baseType===ri&&ka(e.dag,t.id,a,o);const u={nodeType:zn.PHI,dimension:o,baseType:a,dependsOn:t.map((e=>e.value.id)).filter((e=>null!==e)),phiBlocks:t.map((e=>e.blockId))},l=Da(e.dag,u);return Pa(e.cfg,e.cfg.currentBlock,l),{id:l,dimension:o,baseType:a}}class ex{constructor(e,t,r){this.branches=[{condition:t,branchCallback:r,blockType:vi.IF_BODY}],this.ctx=e}ElseIf(e,t){return this.branches.push({condition:e,branchCallback:t,blockType:vi.IF_BODY}),this}Else(e=()=>({})){this.branches.push({condition:null,branchCallback:e,blockType:vi.IF_BODY});const t=function(e,t){const r=e.cfg,n=t.branches,i=Ba(r,vi.MERGE),s=[],o=[],a={},u={},l=Ba(r,vi.BRANCH);La(r,r.currentBlock,l),La(r,l,i);let h=l;for(let t=0;t<n.length;t++){const{condition:a,branchCallback:l,blockType:c}=n[t];if(null!==a){const e=Ba(r,vi.IF_COND);La(r,h,e),Na(r,e),r.blockConditions[e]=a.id,h=e,Ma(r)}else{const e=Ba(r,vi.ELSE_COND);La(r,h,e),h=e}const d=Ba(r,vi.SCOPE_START);La(r,h,d);const p=Ba(r,c);La(r,d,p),Na(r,p);const f=l();for(const t in f)f[t]=e.p5.strandsNode(f[t]);for(const e in f)u[e]?u[e].push({value:f[e],blockId:p}):u[e]=[{value:f[e],blockId:p}];s.push(f);const m=Ba(r,vi.DEFAULT);La(r,r.currentBlock,m),o.push(m),Ma(r);const g=Ba(r,vi.SCOPE_END);La(r,m,g),La(r,g,i),h=d}Oa(r,l);for(const t in u)a[t]=Qb(e,u[t],t);Ma(r);for(let t=0;t<s.length;t++){const n=s[t],i=o[t];Oa(r,i);for(const t in n)if(a[t]){const s=a[t].id,o=n[t].id,u={nodeType:zn.ASSIGNMENT,dependsOn:[s,o],phiBlocks:[]};Pa(r,i,Da(e.dag,u))}Ma(r)}return Na(r,i),a}(this.ctx,this),r={};for(const[e,n]of Object.entries(t))r[e]=Ua(n.id,n.dimension,this.ctx);return r}}class tx{constructor(e,t,r,n,i,s){this.strandsContext=e,this.initialCb=t,this.conditionCb=r,this.updateCb=n,this.bodyCb=i,this.initialVars=s}build(){const e=this.strandsContext.cfg,t=Ba(e,vi.MERGE),r=Ba(e,vi.BRANCH);La(e,e.currentBlock,r),La(e,r,t);const{initialVar:n,phiNode:i}=this.initializeLoopVariable(e,r);Na(e,e.currentBlock);const s=Ua(i.id,i.dimension,this.strandsContext),o=this.conditionCb(s),a=this.updateCb(s);Ma(e);this.loopIsBounded(n,o,a)?this.buildBoundedLoop(e,r,t,n,i,o,a):this.buildUnboundedLoop(e,r,t,n,i,o,a);const u=this.phiNodesForBody;Oa(e,r);for(const[e,t]of Object.entries(this.bodyResults))if("loopVar"!==e&&u[e]){const r=u[e].id,n=Fa(this.strandsContext.dag,r);n.dependsOn.length>1&&(n.dependsOn[1]=t.id),n.phiInputs&&n.phiInputs.length>1&&(n.phiInputs[1].value=t)}Ma(e),Oa(e,r);for(const[t,n]of Object.entries(this.initialVars))if("loopVar"!==t&&u[t]){const i=u[t].id,s=n.id,o=Ta({nodeType:zn.ASSIGNMENT,dependsOn:[i,s],phiBlocks:[]});Pa(e,r,Da(this.strandsContext.dag,o))}Ma(e),Oa(e,this.finalBodyBlock);for(const[t,r]of Object.entries(this.bodyResults))if("loopVar"!==t&&u[t]){const n=u[t].id,i=r.id,s=Ta({nodeType:zn.ASSIGNMENT,dependsOn:[n,i],phiBlocks:[]}),o=Da(this.strandsContext.dag,s);Pa(e,this.finalBodyBlock,o)}Ma(e);const l={};for(const[e,t]of Object.entries(u))l[e]=Ua(t.id,t.dimension,this.strandsContext);return Na(e,t),l}buildBoundedLoop(e,t,r,n,i,s,o){const a=Ba(e,vi.FOR);if(La(e,t,a),Na(e,a),n){const t=Ta({nodeType:zn.ASSIGNMENT,dependsOn:[i.id,n.id],phiBlocks:[]});Pa(e,a,Da(this.strandsContext.dag,t))}const u=Ta({nodeType:zn.STATEMENT,statementType:Zn,dependsOn:[s.id],phiBlocks:[]});Pa(e,a,Da(this.strandsContext.dag,u));const l=Ta({nodeType:zn.ASSIGNMENT,dependsOn:[i.id,o.id],phiBlocks:[]});Pa(e,a,Da(this.strandsContext.dag,l)),Ma(e);const h=e.blockInstructions[a]||[],c=n?3:2;if(h.length!==c)throw new Error(`FOR block must have exactly ${c} statements, got ${h.length}`);const d=Ba(e,vi.SCOPE_START);La(e,a,d);const p=Ba(e,vi.DEFAULT);this.bodyBlock=p,La(e,d,p),this.executeBodyCallback(e,t,p,i);const f=Ba(e,vi.SCOPE_END);La(e,p,f),La(e,f,r)}buildUnboundedLoop(e,t,r,n,i,s,o){const a=Ba(e,vi.FOR);if(La(e,t,a),Na(e,a),n){const t=Ta({nodeType:zn.ASSIGNMENT,dependsOn:[i.id,n.id],phiBlocks:[]});Pa(e,a,Da(this.strandsContext.dag,t))}else{const t=Ta({nodeType:zn.STATEMENT,statementType:Yn,dependsOn:[],phiBlocks:[]});Pa(e,a,Da(this.strandsContext.dag,t))}const u=Ta({nodeType:zn.STATEMENT,statementType:Yn,dependsOn:[],phiBlocks:[]});Pa(e,a,Da(this.strandsContext.dag,u));const l=Ta({nodeType:zn.STATEMENT,statementType:Yn,dependsOn:[],phiBlocks:[]});Pa(e,a,Da(this.strandsContext.dag,l)),Ma(e);const h=Ba(e,vi.SCOPE_START);La(e,a,h);const c=Ba(e,vi.DEFAULT);La(e,h,c),Na(e,c);const d=s,p=this.createLogicalNotNode(d),f=Ba(e,vi.IF_COND);La(e,c,f),e.blockConditions[f]=p.id;const m=Ba(e,vi.SCOPE_START);La(e,f,m);const g=Ba(e,vi.DEFAULT);La(e,m,g),Na(e,g);const y=Ta({nodeType:zn.STATEMENT,statementType:Wn,dependsOn:[],phiBlocks:[]});Pa(e,g,Da(this.strandsContext.dag,y)),Ma(e);const v=Ba(e,vi.SCOPE_END);La(e,g,v),La(e,v,r),Ma(e);const b=Ba(e,vi.DEFAULT);this.bodyBlock=b,La(e,c,b),this.executeBodyCallback(e,t,b,i);const x=Ba(e,vi.DEFAULT);La(e,b,x),Na(e,x);const _=Ta({nodeType:zn.ASSIGNMENT,dependsOn:[i.id,o.id],phiBlocks:[]});Pa(e,x,Da(this.strandsContext.dag,_)),Ma(e);const w=Ba(e,vi.SCOPE_END);La(e,x,w),La(e,w,r),La(e,c,r)}initializeLoopVariable(e,t){Na(e,t);let r=this.initialCb();if(!r?.isStrandsNode){const{id:e,dimension:t}=Za(this.strandsContext,{baseType:Kn,dimension:1},r);r=Ua(e,t,this.strandsContext)}const n=Qb(this.strandsContext,[{value:r,blockId:t},{value:r,blockId:t}],"loopVar");return Ma(e),{initialVar:r,phiNode:n}}createLogicalNotNode(e){const t=Ta({nodeType:zn.OPERATION,opCode:di.LOGICAL_NOT,baseType:Qn,dimension:1,dependsOn:[e.id],phiBlocks:[],usedBy:[]});return Ua(Da(this.strandsContext.dag,t),1,this.strandsContext)}executeBodyCallback(e,t,r,n){Na(e,r);const i={},s={};Oa(e,t);for(const[e,n]of Object.entries(this.initialVars))if("loopVar"!==e){const o=Qb(this.strandsContext,[{value:n,blockId:t},{value:n,blockId:r}],e);s[e]=o,i[e]=Ua(o.id,o.dimension,this.strandsContext)}Ma(e);const o=Ua(n.id,n.dimension,this.strandsContext);this.bodyResults=this.bodyCb(o,i)||{};for(const e in this.bodyResults)this.bodyResults[e]=this.strandsContext.p5.strandsNode(this.bodyResults[e]);this.phiNodesForBody=s,this.finalBodyBlock=e.currentBlock,Ma(e)}loopIsBounded(e,t,r){if(!t)return!1;const n=Fa(this.strandsContext.dag,t.id);if(n.nodeType!==zn.OPERATION)return!1;if(!n.dependsOn||2!==n.dependsOn.length)return!1;const i=Ua(n.dependsOn[0],1,this.strandsContext),s=Ua(n.dependsOn[1],1,this.strandsContext),o=this.nodeUsesOnlyLiterals(i),a=this.nodeUsesOnlyLiterals(s);return o||a}nodeUsesOnlyLiterals(e){const t=Fa(this.strandsContext.dag,e.id);switch(t.nodeType){case zn.LITERAL:return!0;case zn.VARIABLE:case zn.PHI:return!1;case zn.OPERATION:if(t.dependsOn)for(const e of t.dependsOn){const t=Ua(e,1,this.strandsContext);if(!this.nodeUsesOnlyLiterals(t))return!1}return!0;default:return!1}}}const rx={width:{typeInfo:oi.float1,get:e=>e.width},height:{typeInfo:oi.float1,get:e=>e.height},mouseX:{typeInfo:oi.float1,get:e=>e.mouseX},mouseY:{typeInfo:oi.float1,get:e=>e.mouseY},pmouseX:{typeInfo:oi.float1,get:e=>e.pmouseX},pmouseY:{typeInfo:oi.float1,get:e=>e.pmouseY},winMouseX:{typeInfo:oi.float1,get:e=>e.winMouseX},winMouseY:{typeInfo:oi.float1,get:e=>e.winMouseY},pwinMouseX:{typeInfo:oi.float1,get:e=>e.pwinMouseX},pwinMouseY:{typeInfo:oi.float1,get:e=>e.pwinMouseY},frameCount:{typeInfo:oi.float1,get:e=>e.frameCount},deltaTime:{typeInfo:oi.float1,get:e=>e.deltaTime},displayWidth:{typeInfo:oi.float1,get:e=>e.displayWidth},displayHeight:{typeInfo:oi.float1,get:e=>e.displayHeight},windowWidth:{typeInfo:oi.float1,get:e=>e.windowWidth},windowHeight:{typeInfo:oi.float1,get:e=>e.windowHeight},mouseIsPressed:{typeInfo:oi.bool1,get:e=>e.mouseIsPressed}};function nx(e,t,r,n){const i=function(e){return e._builtinGlobals&&e._builtinGlobals.dag===e.dag||(e._builtinGlobals={dag:e.dag,nodes:new Map,uniformsAdded:new Set}),e._builtinGlobals}(e),s=i.nodes.get(t);if(s)return s;i.uniformsAdded.has(t)||(i.uniformsAdded.add(t),e.uniforms.push({name:t,typeInfo:r,defaultValue:n}));const{id:o,dimension:a}=Ga(e,r,t),u=Ua(o,a,e);return i.nodes.set(t,u),u}function ix(e,t){const r=rx[t];if(!r)return null;const n=`_p5_global_${t}`,i=e.renderer?._pInst||e.p5?.instance,s=nx(e,n,r.typeInfo,(()=>i?r.get(i):void 0));return s._originalBuiltinName=t,s}function sx(e,t,r,n){e[r]=n;const i=t?.Graphics?.prototype;i&&(i[r]=n)}function ox(e,t,r,n){t.windowOverrides[r]=window[r],t.fnOverrides[r]=e[r],window[r]=n,e[r]=n;const i=t.p5?.Graphics?.prototype;i&&(t.graphicsOverrides[r]=Object.prototype.hasOwnProperty.call(i,r)?i[r]:void 0,i[r]=n)}function ax(e,t,r){for(const{name:t,arity:n,opCode:i}of fi)"binary"===n&&(Va.prototype[t]=function(...e){const{id:t,dimension:n}=Ha(r,this,e,i);return Ua(t,n,r)}),"unary"===n&&(e[t]=function(e){const{id:t,dimension:n}=$a(r,e,i);return Ua(t,n,r)});sx(t,e,"discard",(function(){Ja(r,qn)})),sx(t,e,"break",(function(){Ja(r,Wn)})),e.break=t.break,sx(t,e,"instanceID",(function(){const e=Ga(r,{baseType:Jn,dimension:1},r.backend.instanceIdReference());return Ua(e.id,e.dimension,r)})),e.strandsIf=function(e,t){return new ex(r,e,t)},sx(t,e,"strandsIf",e.strandsIf),e.strandsFor=function(e,t,n,i,s){return new tx(r,e,t,n,i,s).build()},sx(t,e,"strandsFor",e.strandsFor),e.strandsTernary=function(e,t,n){return function(e,t,r,n){const{dag:i,cfg:s,p5:o}=e,a=t?.isStrandsNode?t:o.strandsNode(t),u=r?.isStrandsNode?r:o.strandsNode(r),l=n?.isStrandsNode?n:o.strandsNode(n);let h=Ia(i,u.id),c=Ia(i,l.id);h.baseType===ri&&c.baseType!==ri?(ka(i,u.id,c.baseType,c.dimension),h=Ia(i,u.id)):c.baseType===ri&&h.baseType!==ri&&(ka(i,l.id,h.baseType,h.dimension),c=Ia(i,l.id)),h.baseType===ri||c.baseType===ri||h.baseType===c.baseType&&h.dimension===c.dimension||Ea("type error",`The true and false branches of a ternary expression must have the same type. Right now, the true branch is a ${h.baseType}${h.dimension}, and the false branch is a ${c.baseType}${c.dimension}.`);const d=h,p=Da(i,Ta({nodeType:zn.OPERATION,opCode:pi.TERNARY,dependsOn:[a.id,u.id,l.id],baseType:d.baseType,dimension:d.dimension}));return Pa(s,s.currentBlock,p),Ua(p,d.dimension,e)}(r,e,t,n)},sx(t,e,"strandsTernary",e.strandsTernary),e.strandsEarlyReturn=function(t){const{dag:n,cfg:i}=r;if(!r.activeHook)throw new Error("strandsEarlyReturn can only be used inside a hook callback");const s=t?.isStrandsNode?t:e.strandsNode(t),o=Ba(i,vi.DEFAULT);La(i,i.currentBlock,o),Na(i,o);const a=Da(n,Ta({nodeType:zn.STATEMENT,statementType:Xn,dependsOn:void 0!==t?[s.id]:[]}));return Pa(i,i.currentBlock,a),r.activeHook.earlyReturns.push({earlyReturnID:a,valueNode:s}),Ma(i),s},sx(t,e,"strandsEarlyReturn",e.strandsEarlyReturn),e.strandsNode=function(...e){if(1===e.length&&e[0]instanceof Va)return e[0];e.length>4&&Ea("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.");const t=e.flat().filter((e=>null!=e));if(0===t.length){const{id:e,dimension:t}=Za(r,{baseType:ri,dimension:null},[0]);return Ua(e,t,r)}const{id:n,dimension:i}=Za(r,{baseType:Kn,dimension:null},t);return Ua(n,i,r)};for(const[n,i]of Object.entries(za)){if(i[0].isp5Function){const i=t[n];sx(t,e,n,(function(...e){if(r.active){const{id:t,dimension:i}=Ka(r,n,e);return Ua(t,i,r)}return i.apply(this,e)}))}else sx(t,e,n,(function(...t){if(r.active){const{id:e,dimension:i}=Ka(r,n,t);return Ua(e,i,r)}e._friendlyError(`It looks like you've called ${n} outside of a shader's modify() function.`)}))}const n=t.lerp;sx(t,e,"lerp",(function(...e){return r.active?this.mix(...e):n.apply(this,e)}));const i=t.map;sx(t,e,"map",(function(...t){if(!r.active)return i.apply(this,t);const[n,s,o,a,u,l]=t,h=e.strandsNode(n),c=e.strandsNode(s),d=e.strandsNode(o),p=h.sub(c).div(d.sub(c)),f=this.mix(a,u,p);return l?this.clamp(f,this.min(a,u),this.max(a,u)):f}));const s=t.color;sx(t,e,"color",(function(...e){if(!r.active)return s.apply(this,e);const t=s.apply(this,e)._getRGBA(),{id:n,dimension:i}=Za(r,{baseType:Kn,dimension:null},t);return Ua(n,i,r)}));const o=t.lerpColor;sx(t,e,"lerpColor",(function(...e){return r.active?this.mix(...e):o.apply(this,e)}));const a=t.red;sx(t,e,"red",(function(...t){return r.active?e.strandsNode(t[0]).x:a.apply(this,t)}));const u=t.green;sx(t,e,"green",(function(...t){return r.active?e.strandsNode(t[0]).y:u.apply(this,t)}));const l=t.blue;sx(t,e,"blue",(function(...t){return r.active?e.strandsNode(t[0]).z:l.apply(this,t)}));const h=t.alpha;sx(t,e,"alpha",(function(...t){return r.active?e.strandsNode(t[0]).w:h.apply(this,t)}));const c=(t,r)=>{const n=r.x,i=r.y,s=r.z,o=t.max(n,t.max(i,s)),a=t.min(n,t.min(i,s)),u=o.add(a).div(2),l=o.sub(a),h=e.strandsNode(1e-10),c=t.mix(e.strandsNode(0),l.div(e.strandsNode(1).sub(t.abs(u.mult(2).sub(1)))),t.step(h,l)),d=t.mod(i.sub(s).div(l.add(h)),e.strandsNode(6)).div(6),p=s.sub(n).div(l.add(h)).add(2).div(6),f=n.sub(i).div(l.add(h)).add(4).div(6),m=t.step(o.sub(h),n).mult(t.step(n.sub(h),o)),g=t.step(o.sub(h),i).mult(t.step(i.sub(h),o)),y=t.mix(t.mix(f,p,g),d,m);return t.vec3(y,c,u)},d=t.hue;sx(t,e,"hue",(function(...t){if(!r.active)return d.apply(this,t);const n=e.strandsNode(t[0]);return c(this,this.vec3(n.x,n.y,n.z)).x}));const p=t.saturation;sx(t,e,"saturation",(function(...t){if(!r.active)return p.apply(this,t);const n=e.strandsNode(t[0]);return c(this,this.vec3(n.x,n.y,n.z)).y}));const f=t.brightness;sx(t,e,"brightness",(function(...t){if(!r.active)return f.apply(this,t);const n=e.strandsNode(t[0]);return((t,r)=>{const n=r.x,i=r.y,s=r.z,o=t.vec4(0,-1/3,2/3,-1),a=t.mix(t.vec4(s,i,o.w,o.z),t.vec4(i,s,o.x,o.y),t.step(s,i)),u=t.mix(t.vec4(a.x,a.y,a.w,n),t.vec4(n,a.y,a.z,a.x),t.step(a.x,n)),l=u.x.sub(t.min(u.w,u.y)),h=e.strandsNode(1e-10),c=t.abs(u.z.add(u.w.sub(u.y).div(l.mult(6).add(h)))),d=l.div(u.x.add(h));return t.vec3(c,d,u.x)})(this,this.vec3(n.x,n.y,n.z)).z}));const m=t.lightness;sx(t,e,"lightness",(function(...t){if(!r.active)return m.apply(this,t);const n=e.strandsNode(t[0]);return c(this,this.vec3(n.x,n.y,n.z)).z})),sx(t,e,"getTexture",(function(...t){if(r.active){const{id:e,dimension:n}=r.backend.createGetTextureCall(r,t);return Ua(e,n,r)}e._friendlyError("It looks like you've called getTexture outside of a shader's modify() function.")}));const g=t.texture;sx(t,e,"texture",(function(...e){return r.active?this.getTexture(...e):g.apply(this,e)}));const y=t.noise,v=t.noiseDetail,b=t.random,x=t.randomGaussian,_=t.randomSeed,w=t.millis;r._noiseOctaves=null,r._noiseAmpFalloff=null,sx(t,e,"noiseDetail",(function(e,t=.5){if(!r.active)return v.apply(this,arguments);r._noiseOctaves=e,r._noiseAmpFalloff=t})),sx(t,e,"noise",(function(...n){if(!r.active)return y.apply(this,n);const i=r.backend.getNoiseShaderSnippet();r.vertexDeclarations.add(i),r.fragmentDeclarations.add(i),r.computeDeclarations.add(i);const s=n.flat().map((t=>e.strandsNode(t)));let o;3===s.length?o=[t.vec3(s[0],s[1],s[2])]:2===s.length?o=[t.vec3(s[0],s[1],0)]:1===s.length&&s[0].dimension<=3?o=3===s[0].dimension?s:2===s[0].dimension?[t.vec3(s[0],0)]:[t.vec3(s[0],0,0)]:e._friendlyError(`It looks like you've called noise() with ${n.length} arguments. It only supports 1D to 3D input.`);const a=null!==r._noiseOctaves?r._noiseOctaves:t._getNoiseOctaves(),u=null!==r._noiseAmpFalloff?r._noiseAmpFalloff:t._getNoiseAmpFalloff();o.push(a),o.push(u);const{id:l,dimension:h}=Ka(r,"noise",o,{overloads:[{params:[oi.float3,oi.int1,oi.float1],returnType:oi.float1}]});return Ua(l,h,r)})),r._randomSeed=null,sx(t,e,"randomSeed",(function(e){if(!r.active)return _.apply(this,arguments);r._randomSeed=e})),sx(t,e,"random",(function(...t){if(!r.active)return b.apply(this,t);const n=r.backend.getRandomVertexShaderSnippet(),i=r.backend.getRandomFragmentShaderSnippet();if(r.vertexDeclarations.add(n),r.fragmentDeclarations.add(i),r.backend.getRandomComputeShaderSnippet){const e=r.backend.getRandomComputeShaderSnippet();r.computeDeclarations.add(e)}let s;if(null!==r._randomSeed&&r._randomSeed.isStrandsNode)s=r._randomSeed;else{const e=r._randomSeed;s=nx(r,"_p5_randomSeed",oi.float1,null!==e?()=>e:()=>performance.now())}const o=[s],a=[{params:[oi.float1],returnType:oi.float1}];if(0===t.length){const{id:e,dimension:t}=Ka(r,"random",o,{overloads:a});return Ua(e,t,r)}if(1===t.length){const n=Ka(r,"random",o,{overloads:a});return Ua(n.id,n.dimension,r).mult(e.strandsNode(t[0]))}if(2===t.length){const n=Ka(r,"random",o,{overloads:a}),i=Ua(n.id,n.dimension,r),s=e.strandsNode(t[0]),u=e.strandsNode(t[1]);return i.mult(u.sub(s)).add(s)}e._friendlyError(`It looks like you've called random() with ${t.length} arguments. In strands, random() supports 0, 1, or 2 numeric arguments.`)})),sx(t,e,"randomGaussian",(function(...e){if(!r.active)return x.apply(this,e);const t=e.length>=1?e[0]:0,n=e.length>=2?e[1]:1,i=this.max(this.random(),1e-6),s=this.random();return this.sqrt(this.log(i).mult(-2)).mult(this.cos(s.mult(2*Math.PI))).mult(n).add(t)})),sx(t,e,"millis",(function(...e){if(!r.active)return w.apply(this,e);const t=r.renderer?._pInst||r.p5?.instance;return nx(r,"_p5_global_millis",oi.float1,(()=>t?t.millis():void 0))}));for(const n in oi){if(n===ti||n===ri||"sampler"===n)continue;const i=oi[n],s=[];let o;/^[ib]vec/.test(i.fnName)?(o=i.fnName.slice(0,2).toUpperCase()+i.fnName.slice(2).toLowerCase(),s.push(o.replace("Vec","Vector"))):(o=i.fnName.charAt(0).toUpperCase()+i.fnName.slice(1),"Sampler2D"===o?s.push("Texture"):/^vec/.test(i.fnName)&&s.push(o.replace("Vec","Vector"))),sx(t,e,`uniform${o}`,(function(e,t){const{id:n,dimension:s}=Ga(r,i,e);return r.uniforms.push({name:e,typeInfo:i,defaultValue:t}),Ua(n,s,r)})),sx(t,e,`shared${o}`,(function(e){const{id:t,dimension:n}=Ga(r,i,e);return r.sharedVariables||(r.sharedVariables=new Map),r.sharedVariables.set(e,{typeInfo:i,usedInVertex:!1,usedInFragment:!1}),Ua(t,n,r)})),sx(t,e,`varying${o}`,t[`shared${o}`]);for(const r of s)sx(t,e,`uniform${r}`,t[`uniform${o}`]),sx(t,e,`varying${r}`,t[`varying${o}`]),sx(t,e,`shared${r}`,t[`shared${o}`]);const a=t[i.fnName];sx(t,e,i.fnName,(function(...t){if(r.active){if(1===t.length&&t[0].dimension&&t[0].dimension===i.dimension){const{id:e,dimension:n}=Ka(r,r.backend.getTypeName(i.baseType,i.dimension),t,{overloads:[{params:[t[0].typeInfo()],returnType:i}]});return Ua(e,n,r)}{!(i.dimension>1&&1===t.length)||Array.isArray(t[0])||t[0]instanceof Va&&t[0].dimension>1||i.baseType!==Kn&&i.baseType!==Jn&&i.baseType!==Qn||(t=Array(i.dimension).fill(t[0]));const{id:e,dimension:n}=Za(r,i,t);return Ua(e,n,r)}}if(a)return a.apply(this,t);e._friendlyError(`It looks like you've called ${i.fnName} outside of a shader's modify() function.`)}))}t.uniformStorage=function(e,t){let n=null,i=null,s=t;"function"==typeof t&&(s=t(),s?._schema&&(i=t)),s?._schema?(n=s._schema,null===i&&(i=s)):s&&"object"==typeof s&&!s._isStorageBuffer?n=r.renderer?._inferStructSchema(s)??null:s?._isStorageBuffer&&(i=t);const{id:o,dimension:a}=Ga(r,{baseType:"storage",dimension:1},e);r.uniforms.push({name:e,typeInfo:{baseType:"storage",dimension:1,schema:n},defaultValue:i});const u=Ua(o,a,r);return u._originalIdentifier=e,u._originalBaseType="storage",u._originalDimension=1,u._schema=n,u}}function ux(e,t){const r=[],n=e.dag;for(const i of t)if(ui(i.type)){const t=ai(i),{id:s,dimension:o}=qa(e,t,`${Gn}${i.name}`,[]),a=Ua(s,o,e).withStructProperties(t.properties.map((e=>e.name)));for(let r=0;r<t.properties.length;r++){const s=t.properties[r];Object.defineProperty(a,s.name,{get(){const s=Fa(n,n.dependsOn[a.id][r]);return Ua(s.id,s.dimension,e,(s=>{const o=n.dependsOn[a.id].slice();o[r]=s;const u=qa(e,t,`${Gn}${i.name}`,o);a.id=u.id}))},set(o){const u=o?.isStrandsNode?o.dimension:Array.isArray(o)?o.length:1;u!==s.dataType.dimension&&1!==u&&Sa(s.dataType.dimension,u,`${i.name}.${s.name}`);const l=[...n.dependsOn[a.id]];let h;if(o?.isStrandsNode)h=o.id;else{h=Za(e,s.dataType,o).id}l[r]=h;const c=qa(e,t,`${Gn}${i.name}`,l);a.id=c.id}})}r.push(a)}else{if("sampler"===i.type.typeName)continue;if(!i.type.dataType)throw new Error(`Missing dataType for parameter ${i.name} of type ${i.type.typeName}`);const t=i.type.dataType,{id:n,dimension:s}=Ga(e,t,`${Gn}${i.name}`),o=Ua(n,s,e);r.push(o)}return r}function lx(e,t,r,n){if(!r?.isStrandsNode){return Za(e,t,r).id}const i=e.dag;let s=r.id;const o=i.baseTypes[s],a=i.dimensions[s];if(a!==t.dimension)if(1!==a){Ea("type error",`You have returned a ${o+(a>1?a:"")} in ${n} when a ${t.baseType+t.dimension} was expected!\n\nMake sure your hook returns the correct type.`)}else{s=Za(e,t,r).id}else if(o!==t.baseType){s=Za(e,t,r).id}return s}function hx(e,t,r){!function(e){if(e._builtinGlobalsAccessorsInstalled)return;const t=()=>e.renderer?._pInst||e.p5?.instance;for(const r of Object.keys(rx)){const n=rx[r],i=`_strands_${r}`,s=t();s?._isGlobal&&Object.defineProperty(window,r,{get:()=>{if(e.active)return ix(e,r);const i=t();return n.get(i)},configurable:!0});const o=Object.getOwnPropertyDescriptor(e.p5.prototype,r);Object.defineProperty(e.p5.prototype,r,{get:function(){return e.active?ix(e,r):Object.prototype.hasOwnProperty.call(this,i)?this[i]:o?.get?o.get.call(this):o?.value},set:function(e){this[i]=e},configurable:!0});const a=e.p5?.Graphics?.prototype;if(a){const t=Object.getOwnPropertyDescriptor(a,r);Object.defineProperty(a,r,{get:function(){return e.active?ix(e,r):t?.get?t.get.call(this):this[i]},set:function(e){t?.set?t.set.call(this,e):this[i]=e},configurable:!0})}}e._builtinGlobalsAccessorsInstalled=!0}(e),function(e){if(e._instanceIndexAccessorInstalled)return;const t=function(){if(e.active){const t=Ga(e,{baseType:Jn,dimension:1},e.backend.instanceIdReference());return Ua(t.id,t.dimension,e)}},r=e.renderer?._pInst||e.p5?.instance;r?._isGlobal&&Object.defineProperty(window,"instanceIndex",{get:t,configurable:!0}),Object.defineProperty(e.p5.prototype,"instanceIndex",{get:t,configurable:!0});const n=e.p5?.Graphics?.prototype;n&&Object.defineProperty(n,"instanceIndex",{get:t,configurable:!0}),e._instanceIndexAccessorInstalled=!0}(e);const n={...Object.fromEntries(Object.entries(r.hooks.vertex).map((([e,t])=>[e,{...t,shaderContext:"vertex"}]))),...Object.fromEntries(Object.entries(r.hooks.fragment).map((([e,t])=>[e,{...t,shaderContext:"fragment"}]))),...Object.fromEntries(Object.entries(r.hooks.compute).map((([e,t])=>[e,{...t,shaderContext:"compute"}])))},i=Object.keys(n).map((e=>r.hookTypes(e))),{cfg:s,dag:o}=e;for(const a of i){const u=function(e){const t=d();u._result=e(...t)??u._result,p()};u.set=function(e){u._result=e},u._active=!1;const l=a.parameters.filter((e=>e.type&&e.type.properties)).length;let h,c=-1;if(1===l&&(c=a.parameters.findIndex((e=>e.type&&e.type.properties))),c>=0){const g=a.parameters[c];if(g.type.properties){const y=/^get([A-Z0-9]\w*)$/.exec(a.name),v=y?y[1][0].toLowerCase()+y[1].slice(1):a.name;for(const b of g.type.properties){const x=b.name;Object.defineProperty(u,x,{get(){return this._active||Ea("scope error",`It looks like you're trying to access "${v}.${x}" outside of its begin()/end() block.\n\nProperties of ${v} are only available between ${v}.begin() and ${v}.end().\n\nTo share data between hooks, use sharedVec3() or sharedFloat() to pass values between them.`),this._args[this._argIdx][x]},set(e){this._active||Ea("scope error",`It looks like you're trying to set "${v}.${x}" outside of its begin()/end() block.`),this._args[this._argIdx][x]=e},enumerable:!0})}}}function d(){e.activeHook=u,h=Ba(s,vi.FUNCTION),La(s,s.currentBlock,h),Na(s,h);const t=ux(e,a.parameters);u._active=!0,u._args=t,u._argIdx=c,u._properties=[];for(let e=0;e<t.length;e++)if(e===c){for(const e of t[c].structProperties||[])u._properties.push(e);a.returnType?.typeName===a.parameters[c].type.typeName&&u.set(t[c])}else u._properties.push(a.parameters[e].name),u[a.parameters[e].name]=t[e];return t}function p(){u._active=!1;const t=u._result;e.activeHook=void 0;const r=a.returnType;let i=null;const l=t=>{if(ui(r)){const n=ai(r);if(t?.isStrandsNode){const r=Fa(e.dag,t.id);if(r.baseType!==n.typeName){const e=r.baseType||"undefined",i=o.dimensions[t.id],s=i>1?`${e}${i}`:e,u=n.properties.map((e=>e.name)).join(", ");Ea("type error",`You have returned a ${s} from ${a.name} when a ${n.typeName} was expected.\n\nThe ${n.typeName} struct has these properties: { ${u} }\n\nInstead of returning a different type, you should modify and return the ${n.typeName} struct that was passed to your hook.\n\nFor example:\n${a.name}((inputs) => {\n  // Modify properties of inputs\n  inputs.someProperty = ...;\n  return inputs; // Return the modified struct\n})`)}const i=r.dependsOn.slice();for(let s=0;s<n.properties.length;s++){const u=n.properties[s].dataType,l=Ua(r.dependsOn[s],o.dependsOn[t.id],e);i[s]=lx(e,u,l,a.name)}return o.dependsOn[t.id]=i,t.id}{const i=n.properties,s=[];for(let o=0;o<i.length;o++){const u=i[o],l=t[u.name];if(void 0===l){const e=r.properties.map((e=>e.name)).join(", "),i=Object.keys(t).join(", ");Ea("type error",`You've returned an incomplete ${n.typeName} struct from ${a.name}.\n\nExpected properties: { ${e} }\nReceived properties: { ${i} }\n\nAll properties are required! Make sure to include all properties in the returned struct.`)}const h=u.dataType,c=lx(e,h,l,a.name);s.push(c)}return Ya(e,n,s).id}}if(r.dataType&&"void"!==r.typeName?.trim()){const n=r.dataType;return lx(e,n,t,a.name)}return null};for(const{valueNode:e,earlyReturnID:t}of u.earlyReturns){const r=l(e);o.dependsOn[t]=null!==r?[r]:[]}i=t?l(t):void 0;const c=`${a.returnType.typeName} ${a.name}`,d=n[c];e.hooks.push({hookType:a,entryBlockID:h,rootNodeID:i,shaderContext:d?.shaderContext}),Ma(s)}u.begin=d,u.end=p;const f=[a.name];e.baseShader?.hooks?.hookAliases?.[a.name]&&f.push(...e.baseShader.hooks.hookAliases[a.name]);const m=/^get([A-Z0-9]\w*)$/.exec(a.name);if(m){const _=m[1][0].toLowerCase()+m[1].slice(1);t[_]||f.push(_)}for(const w of f)ox(t,e,w,u);u.earlyReturns=[]}}function cx(e,t){function r(t,r,{active:n=!1,renderer:i=null,baseShader:s=null}={}){t.dag=Aa(),t.cfg={blockTypes:[],incomingEdges:[],outgoingEdges:[],blockInstructions:[],nextID:0,blockStack:[],blockOrder:[],blockConditions:{},currentBlock:-1},t.uniforms=[],t.vertexDeclarations=new Set,t.fragmentDeclarations=new Set,t.computeDeclarations=new Set,t.hooks=[],t.backend=r,t.active=n,t.renderer=i,t.baseShader=s,t.previousFES=e.disableFriendlyErrors,t.windowOverrides={},t.fnOverrides={},t.graphicsOverrides={},t._randomSeed=null,n&&(e.disableFriendlyErrors=!0),t.p5=e}t._runStrandsInGlobalMode=!1;const n={};r(n),ax(e,t,n);const i=e.Shader.prototype.modify;e.Shader.prototype.modify=function(s,o={},a={}){const u={},l={},h={};try{if(s instanceof Function||"string"==typeof s){let c;if(r(n,this._renderer.strandsBackend,{active:!0,renderer:this._renderer,baseShader:this}),hx(n,t,this),a.parser=!0,a.srcLocations=!1,a.parser){const t="string"==typeof s?`(${s})`:`(${s.toString()})`;c=Jb(e,t,a.srcLocations,o)}else c=s;const d=Ba(n.cfg,vi.GLOBAL);if(Na(n.cfg,d),a.hook){n.renderer._pInst[a.hook].begin();for(const r of n.renderer._pInst[a.hook]._properties){const i=n.renderer._pInst[a.hook][r];u[r]=t[r],t[r]=i,l[r]=window[r],window[r]=i,h[r]=e.Graphics.prototype[r],e.Graphics.prototype[r]=i}}n.renderer?._pInst?._runStrandsInGlobalMode?function(e,r){if(e._isGlobal)return r();const n={};for(const r of Object.getOwnPropertyNames(t)){const i=Object.getOwnPropertyDescriptor(t,r);i&&!i.get&&"function"==typeof t[r]&&(n[r]=window[r],window[r]=t[r].bind(e))}try{r()}finally{for(const e in n)window[e]=n[e]}}(n.renderer._pInst,c):c(),a.hook&&n.renderer._pInst[a.hook].end(),Ma(n.cfg);const p=function(e){const{cfg:t,backend:r,vertexDeclarations:n,fragmentDeclarations:i,computeDeclarations:s}=e,o={uniforms:{},storageUniforms:{},varyingVariables:[]};for(const{name:t,typeInfo:n,defaultValue:i}of e.uniforms)if("storage"===n.baseType)null!=i&&(o.storageUniforms[t]=i);else{const e=r.generateHookUniformKey(t,n);null!==e&&(o.uniforms[e]=i)}r.addTextureBindingsToDeclarations&&r.addTextureBindingsToDeclarations(e),r.addStorageBufferBindingsToDeclarations&&r.addStorageBufferBindingsToDeclarations(e);for(const{hookType:n,rootNodeID:i,entryBlockID:s,shaderContext:a}of e.hooks){const u={indent:1,codeLines:[],write(e){this.codeLines.push("  ".repeat(this.indent)+e)},tempNames:{},declarations:[],nextTempID:0,visitedNodes:new Set,shaderContext:a,strandsContext:e},l=Ra(t.outgoingEdges,s);for(const t of l)r.generateBlock(t,e,u);const h=r.hookEntry(n);let c;c=n.returnType.properties?ai(n.returnType):n.returnType.dataType&&"void"!==n.returnType.typeName?.trim()?n.returnType.dataType:null,void 0!==i&&r.generateReturnStatement(e,u,i,c),o[`${n.returnType.typeName} ${n.name}`]=[h,...u.codeLines,"}"].join("\n")}if(e.sharedVariables)for(const[t,s]of e.sharedVariables)s.usedInVertex&&s.usedInFragment?o.varyingVariables.push(r.generateVaryingVariable(t,s.typeInfo)):s.usedInVertex?n.add(r.generateLocalDeclaration(t,s.typeInfo)):s.usedInFragment&&i.add(r.generateLocalDeclaration(t,s.typeInfo));return e._instanceIDUsedInFragment&&(o.instanceIDVarying=r.generateInstanceIDVarying()),o.vertexDeclarations=[...n].join("\n"),o.fragmentDeclarations=[...i].join("\n"),o.computeDeclarations=[...s].join("\n"),o}(n);return i.call(this,p)}return i.call(this,s)}finally{for(const e in u)t[e]=u[e];for(const e in l)window[e]=l[e];for(const t in h)e.Graphics[t]=h[t];!function(r){r.dag=Aa(),r.cfg={blockTypes:[],incomingEdges:[],outgoingEdges:[],blockInstructions:[],nextID:0,blockStack:[],blockOrder:[],blockConditions:{},currentBlock:-1},r.uniforms=[],r.vertexDeclarations=new Set,r.fragmentDeclarations=new Set,r.computeDeclarations=new Set,r.hooks=[],r.active=!1,r._randomSeed=null,e.disableFriendlyErrors=r.previousFES;for(const e in r.windowOverrides)window[e]=r.windowOverrides[e];for(const e in r.fnOverrides)t[e]=r.fnOverrides[e];const n=e.Graphics?.prototype;if(n)for(const e in r.graphicsOverrides)void 0===r.graphicsOverrides[e]?delete n[e]:n[e]=r.graphicsOverrides[e]}(n)}}}"undefined"!=typeof p5&&p5.registerAddon(cx);const dx=Promise.resolve();!function(e){e.registerAddon(xs),e.registerAddon(_s),e.registerAddon(ws),e.registerAddon(Cs),e.registerAddon(hs)}(uu),function(e){e.registerAddon(hu),e.registerAddon(cu),e.registerAddon(du),e.registerAddon(pu),e.registerAddon(mu)}(uu),function(e){e.registerAddon(Un),e.registerAddon(Fn),e.registerAddon(Es)}(uu),function(e){e.registerAddon(Sl),e.registerAddon(Dl),e.registerAddon(Df),e.registerAddon(Ig),e.registerAddon(kg)}(uu),function(e){e.registerAddon(Ng)}(uu),function(e){e.registerAddon(Mg),e.registerAddon(Si),e.registerAddon(vs),e.registerAddon(Ci)}(uu),function(e){e.registerAddon(Og),e.registerAddon(Bg),e.registerAddon(Lg)}(uu),function(e){e.registerAddon(Is),e.registerAddon(ro),e.registerAddon(Oi),e.registerAddon(no),e.registerAddon(Xo),e.registerAddon(ra)}(uu),function(e){e.registerAddon(Ls),e.registerAddon(Rg),e.registerAddon(Ug),e.registerAddon(_i)}(uu),function(e){e.registerAddon(zg),e.registerAddon(jg),e.registerAddon(Gg),e.registerAddon(Jo),e.registerAddon($g),e.registerAddon(Ri),e.registerAddon(Wg)}(uu),function(e){e.registerAddon(Xg),e.registerAddon(Zg),e.registerAddon(Yg)}(uu),function(e){e.registerAddon(Go),e.registerAddon(Gv),e.registerAddon($o),e.registerAddon(Kg),e.registerAddon(Ho),e.registerAddon(Qg),e.registerAddon(Ko),e.registerAddon(Rv),e.registerAddon(Co),e.registerAddon(yo),e.registerAddon(lo),e.registerAddon(fo),e.registerAddon(bo),e.registerAddon(ga),e.registerAddon(co),e.registerAddon(ra)}(uu),function(e){e.registerAddon(Lo),e.registerAddon(Lv)}(uu),uu.registerAddon(Xo),uu.registerAddon(cx),Promise.all([(()=>{if("undefined"!=typeof document)return new Promise(((e,t)=>{"complete"===document.readyState?e():window.addEventListener("load",e,!1)}))})(),dx]).then((()=>{if("undefined"!=typeof window)if(void 0===window._setupDone){if(!window.mocha){const e=new Event("p5Ready");window.dispatchEvent(e),(window.setup&&"function"==typeof window.setup||window.draw&&"function"==typeof window.draw)&&!uu.instance&&new uu}}else console.warn("p5.js seems to have been imported multiple times. Please remove the duplicate import")}));export{uu as default};