@fabiplay/engine 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fabi-play-engine.js +1 -105
- package/dist/fabi-play-engine.lite.js +1 -105
- package/dist/fabi-play-engine.lite.umd.js +1038 -972
- package/dist/fabi-play-engine.lite.umd.min.js +1 -105
- package/dist/fabi-play-engine.umd.js +1225 -1131
- package/dist/fabi-play-engine.umd.min.js +1 -105
- package/dist/index.development.js +2 -2
- package/dist/index.js +1 -1
- package/dist/integrity.json +7 -7
- package/package.json +5 -5
package/dist/fabi-play-engine.js
CHANGED
|
@@ -1,105 +1 @@
|
|
|
1
|
-
"use strict";(()=>{var Ls=Object.defineProperty;var ja=(s,n,e)=>n in s?Ls(s,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[n]=e;var qa=(s,n)=>{for(var e in n)Ls(s,e,{get:n[e],enumerable:!0})};var p=(s,n,e)=>ja(s,typeof n!="symbol"?n+"":n,e);var Ms={};qa(Ms,{AnimatedSprite:()=>Ne,Atlas:()=>pt,AvatarPainter:()=>Ct,AvatarsNode:()=>Cn,BitmapFont:()=>en,DEFAULT_FONT:()=>jr,EASE:()=>ht,Group:()=>Rt,HALO:()=>Ft,MAX_LAYERS:()=>xn,NameTags:()=>yt,Node:()=>Ie,NodePool:()=>Fn,Particles:()=>Ut,STAGE_HEIGHT:()=>he,Shape:()=>Xe,ShelfPacker:()=>vn,Sound:()=>rn,Sprite:()=>Te,TIERS:()=>Ke,Text:()=>Ye,Timeline:()=>sn,Tweens:()=>on,avatarPortrait:()=>ta,blur:()=>La,brightness:()=>Ma,colorMatrix:()=>_a,contrast:()=>Ta,createAvatarRenderer:()=>ea,createEngine:()=>xa,createRenderer:()=>Qt,dropShadow:()=>Oa,grayscale:()=>Ra,handsOf:()=>lr,hits:()=>En,hueRotate:()=>Fa,invert:()=>Pa,nodePool:()=>za,packColor:()=>ut,parseBMFont:()=>tn,parseColor:()=>de,pickTier:()=>hr,playerColor:()=>nn,rendererOrder:()=>Xr,rng:()=>fo,saturate:()=>Ea,sepia:()=>Ca,shader:()=>Ia,shapeBounds:()=>ar,tier:()=>it,tint:()=>Sa,touching:()=>cr,wrists:()=>Qr});var Ar=33,z={nose:0,leftShoulder:11,rightShoulder:12,leftElbow:13,rightElbow:14,leftWrist:15,rightWrist:16,leftHip:23,rightHip:24,leftKnee:25,rightKnee:26,leftAnkle:27,rightAnkle:28},Is=["3-5","6-8","9-12"],Ya=s=>Is.includes(s);var Ka=4,fn=["#EE6A43","#6FA0E0","#8CC9A0","#C49BE0"];var Ns={"3-5":["bunny","bear","panda","penguin"],"6-8":["fox","lion","dragon","unicorn"],"9-12":["robot","astronaut","ninja","skater"]},Qa=Ns["6-8"],Sr=(s,n)=>{let e=Ya(n)?Ns[n]:Qa;return e[Number.isInteger(s)&&s>=0?s%e.length:0]};var Mr=(s,n)=>s?{x:s.x+n.x*s.w,y:s.y+n.y*s.h}:{x:n.x,y:n.y},Za=.5,Bn={left:1.6,top:1.6,w:3.2,h:3},Ja=1.2;function Ds(s,n,e={}){let t=Array.isArray(s)?s:s.body;if(!Array.isArray(t))return null;let r=n==="left"?z.leftWrist:z.rightWrist,o=x=>hn(t[x*3])&&hn(t[x*3+1])&&(t[x*3+2]??0)>=Za?x:-1;if(o(r)<0)return null;let a=t[r*3],i=t[r*3+1];if(e.orientation!=="portrait")return Mr(e.view,{x:a,y:i});if(o(z.leftShoulder)<0||o(z.rightShoulder)<0)return null;let u=z.leftShoulder*3,c=z.rightShoulder*3,l=(t[u]+t[c])/2,f=(t[u+1]+t[c+1])/2,h=z.leftHip*3,m=z.rightHip*3,b=(t[h]+t[m])/2,y=(t[h+1]+t[m+1])/2,d=hn(b)&&hn(y)?Math.hypot(b-l,y-f):0;return(o(z.leftHip)<0||o(z.rightHip)<0)&&(d=Math.max(d,Ja*Math.hypot(t[u]-t[c],t[u+1]-t[c+1]))),d=Math.max(d,.01),{x:Os((a-l+Bn.left*d)/(Bn.w*d)),y:Os((i-f+Bn.top*d)/(Bn.h*d))}}var ei=300,Ot=class{constructor(n=ei){p(this,"holdMs",n);p(this,"last",new Map)}static key(n,e){return n*2+(e==="right"?1:0)}at(n,e,t){let r=this.last.get(n);return e?(r?(r.x=e.x,r.y=e.y,r.t=t):this.last.set(n,{x:e.x,y:e.y,t}),e):r?t-r.t<=this.holdMs?{x:r.x,y:r.y}:(this.last.delete(n),null):null}clear(){this.last.clear()}},ti=.25,Bs=Object.freeze({top:0,bottom:0,left:0,right:0});function zs(s){if(!ni(s))return;let n=e=>hn(e)?Math.min(Math.max(e,0),ti):0;return{top:n(s.top),bottom:n(s.bottom),left:n(s.left),right:n(s.right)}}var Hl=16/9;var ni=s=>typeof s=="object"&&s!==null&&!Array.isArray(s),hn=s=>typeof s=="number"&&Number.isFinite(s),Os=s=>Math.min(Math.max(s,0),1);var ri=12,si=Ar*4,oi=s=>ri+s*si,$l=oi(Ka);var ai=s=>s.startsWith("fabi-play.")?`fablee-play.${s.slice(10)}`:null;function Hs(s,n,e=ai(n)){if(!(!s||!e))try{let t=s.getItem(e);if(t===null)return;s.getItem(n)===null&&s.setItem(n,t),s.removeItem(e)}catch{}}var Ae="#4a382c",ce="#2b2118",Oe="#1c1f2b",$s="#fbefe3",He="#f4897a",pn="#3a2a22",Tr=[{id:"fox",name:{en:"Fox",it:"Volpe"},band:"6-8",palette:{body:"#ee6a43",limbs:"#ee6a43",belly:$s,accent:"#ffd9c2",outline:ce,hands:"#5a3426",feet:"#5a3426"},head:"wide",ears:"pointy",face:{eyes:"dot",mouth:"cat",nose:pn,muzzle:"cheeks"},tail:"fluffy",headExtras:[],bodyExtras:[]},{id:"mascot",name:{en:"Fabi",it:"Fabi"},band:"all",special:!0,palette:{body:"#ee6a43",limbs:"#ee6a43",belly:$s,accent:"#5a3426",outline:ce,hands:"#5a3426",feet:"#5a3426"},head:"wide",ears:"pointy",face:{eyes:"bead",mouth:"open",nose:pn,muzzle:"band",cheeks:He},tail:"brush",headExtras:[],bodyExtras:["star"],extraColors:["#ffd84a"]},{id:"bunny",name:{en:"Bunny",it:"Coniglietto"},band:"3-5",palette:{body:"#f9d0de",limbs:"#f9d0de",belly:"#fff6f8",accent:"#f4a0b9",outline:Ae},head:"round",ears:"long",face:{eyes:"dot",mouth:"cat",nose:"#e0607e",muzzle:"none",cheeks:He},tail:"pom",headExtras:[],bodyExtras:[]},{id:"bear",name:{en:"Bear",it:"Orsetto"},band:"3-5",palette:{body:"#cf9f78",limbs:"#cf9f78",belly:"#f7e0bf",accent:"#f7e0bf",outline:Ae},head:"round",ears:"round",face:{eyes:"dot",mouth:"smile",nose:pn,muzzle:"oval",cheeks:He},tail:"none",headExtras:[],bodyExtras:[]},{id:"cat",name:{en:"Cat",it:"Gattino"},band:"3-5",palette:{body:"#c8b6ee",limbs:"#c8b6ee",belly:"#f4eeff",accent:"#f7b3c8",outline:Ae,hands:"#f4eeff",feet:"#f4eeff"},head:"wide",ears:"pointy",face:{eyes:"big",eyeColor:"#3f9a5a",mouth:"cat",nose:"#f07a9a",muzzle:"none",cheeks:He},tail:"long",headExtras:["whiskers"],bodyExtras:[]},{id:"panda",name:{en:"Panda",it:"Panda"},band:"3-5",palette:{body:"#ffffff",limbs:"#6e6674",belly:"#ffffff",accent:"#6e6674",outline:Ae,ears:"#6e6674"},head:"wide",ears:"round",face:{eyes:"mask",mouth:"smile",nose:"#2f2a2c",muzzle:"none",cheeks:"#f6a3a3"},tail:"none",headExtras:[],bodyExtras:[]},{id:"penguin",name:{en:"Penguin",it:"Pinguino"},band:"3-5",palette:{body:"#6c8fca",limbs:"#6c8fca",belly:"#ffffff",accent:"#f9b95c",outline:Ae,feet:"#f9b95c"},head:"tall",ears:"none",face:{eyes:"dot",mouth:"beak",muzzle:"heart",cheeks:"#f6a3a3"},tail:"none",headExtras:[],bodyExtras:["flippers","scarf"],extraColors:["#f6907a"]},{id:"frog",name:{en:"Frog",it:"Ranocchio"},band:"3-5",palette:{body:"#8fd487",limbs:"#8fd487",belly:"#e6f7cc",accent:"#62ad62",outline:Ae},head:"wide",ears:"none",face:{eyes:"big",eyesOnTop:!0,mouth:"open",muzzle:"none",cheeks:"#f59b8f"},tail:"none",headExtras:[],bodyExtras:["flippers","spots"],extraColors:["#62ad62","#b0e6a4"]},{id:"lion",name:{en:"Lion",it:"Leoncino"},band:"6-8",alsoIn:["3-5"],palette:{body:"#f6c454",limbs:"#f6c454",belly:"#fde7b0",accent:"#fde7b0",outline:ce},head:"round",ears:"round",face:{eyes:"dot",mouth:"cat",nose:"#8a4b2a",muzzle:"oval",cheeks:He},tail:"tuft",headExtras:["mane"],bodyExtras:[],extraColors:["#c8692e"]},{id:"unicorn",name:{en:"Unicorn",it:"Unicorno"},band:"6-8",palette:{body:"#fbf5ff",limbs:"#fbf5ff",belly:"#efe0ff",accent:"#fbd46a",outline:ce,hands:"#c9a6f2",feet:"#c9a6f2"},head:"tall",ears:"unicorn",face:{eyes:"dot",mouth:"smile",muzzle:"none",cheeks:"#f7a6c8"},tail:"none",headExtras:["rainbow-mane"],bodyExtras:[],extraColors:["#f58cc0","#8fd3f4","#a98ff2"]},{id:"dragon",name:{en:"Little Dragon",it:"Draghetto"},band:"6-8",palette:{body:"#8a63d2",limbs:"#8a63d2",belly:"#fbd46a",accent:"#5fd0b5",outline:ce},head:"wide",ears:"horns",face:{eyes:"big",eyeColor:"#3a2a6a",mouth:"teeth",muzzle:"none",cheeks:"#f59bc0"},tail:"arrow",headExtras:[],bodyExtras:["wings"]},{id:"robot",name:{en:"Robot",it:"Robot"},band:"9-12",palette:{body:"#b9c7d2",limbs:"#8b9aa6",belly:"#b9c7d2",accent:"#ee6a43",outline:Oe,hands:"#ee6a43",feet:"#6b7a86"},head:"square",ears:"antenna",face:{eyes:"screen",eyeColor:"#7ff0ff",mouth:"grill",muzzle:"none"},tail:"none",headExtras:["bolts"],bodyExtras:["panel","joints","boots"],extraColors:["#ff7a6b","#fbd46a","#7ff0ff"]},{id:"astronaut",name:{en:"Astronaut",it:"Astronauta"},band:"9-12",palette:{body:"#f4f1ec",limbs:"#f4f1ec",belly:"#f4f1ec",accent:"#ee6a43",outline:Oe,hands:"#9fb0bd",feet:"#9fb0bd"},head:"round",ears:"none",face:{eyes:"visor",mouth:"smile",muzzle:"none"},tail:"none",headExtras:["helmet"],bodyExtras:["backpack","badge","boots"],extraColors:["#c9d3db"]},{id:"dinosaur",name:{en:"Dinosaur",it:"Dinosauro"},band:"6-8",palette:{body:"#3fb3a6",limbs:"#3fb3a6",belly:"#c9f0d6",accent:"#f79a3e",outline:ce},head:"wide",ears:"none",face:{eyes:"dot",mouth:"teeth",muzzle:"none",cheeks:"#f59b8f"},tail:"spiky",headExtras:["spikes","spots"],bodyExtras:[],extraColors:["#2b8f84","#7fd3c6"]},{id:"monkey",name:{en:"Monkey",it:"Scimmietta"},band:"6-8",palette:{body:"#7b5234",limbs:"#7b5234",belly:"#f2c9a0",accent:"#f2c9a0",outline:ce,hands:"#f2c9a0",feet:"#f2c9a0"},head:"round",ears:"side",face:{eyes:"dot",mouth:"open",nose:"#5a3a26",muzzle:"monkey",cheeks:He},tail:"curl",headExtras:["tuft"],bodyExtras:[]},{id:"koala",name:{en:"Koala",it:"Koala"},band:"3-5",palette:{body:"#b7bcc6",limbs:"#b7bcc6",belly:"#eef0f3",accent:"#f4dbe2",outline:Ae},head:"wide",ears:"big-round",face:{eyes:"dot",mouth:"smile",nose:"#3b3438",muzzle:"none",cheeks:"#f4a3b0"},tail:"none",headExtras:[],bodyExtras:[]},{id:"tiger",name:{en:"Tiger",it:"Tigrotto"},band:"6-8",palette:{body:"#f9a33a",limbs:"#f9a33a",belly:"#fff1dc",accent:"#fff1dc",outline:ce},head:"wide",ears:"round",face:{eyes:"dot",mouth:"cat",nose:"#e2607a",muzzle:"oval",cheeks:He},tail:"striped",headExtras:["stripes","whiskers"],bodyExtras:[],extraColors:["#3a2a22"]},{id:"owl",name:{en:"Owl",it:"Gufetto"},band:"3-5",palette:{body:"#8ec0e6",limbs:"#8ec0e6",belly:"#e3f2fc",accent:"#639cc9",outline:Ae,feet:"#f9b95c",hands:"#639cc9"},head:"tall",ears:"tufts",face:{eyes:"big",eyeColor:Ae,eyeRing:"#fde08a",mouth:"beak",muzzle:"none",cheeks:"#f6a8b4"},tail:"none",headExtras:[],bodyExtras:["feathers"]},{id:"alien",name:{en:"Alien",it:"Alieno"},band:"9-12",palette:{body:"#9ee05a",limbs:"#9ee05a",belly:"#d8f5a8",accent:"#b07cf2",outline:Oe},head:"bulb",ears:"antennae",face:{eyes:"almond",eyeColor:"#1e1838",mouth:"smirk",muzzle:"none"},tail:"none",headExtras:[],bodyExtras:["spots"],extraColors:["#7cc23e","#7cc23e"]},{id:"ghost",name:{en:"Friendly Ghost",it:"Fantasmino"},band:"6-8",palette:{body:"#e6f4ff",limbs:"#e6f4ff",belly:"#e6f4ff",accent:"#bcd9f2",outline:ce},head:"round",ears:"none",face:{eyes:"dot",mouth:"open",muzzle:"none",cheeks:"#f7a6c8"},tail:"none",headExtras:["curl"],bodyExtras:["sheet"]},{id:"octopus",name:{en:"Octopus",it:"Polpetto"},band:"6-8",palette:{body:"#e0578a",limbs:"#e0578a",belly:"#f7b3cc",accent:"#f7b3cc",outline:ce,hands:"#f7b3cc",feet:"#f7b3cc"},head:"tall",ears:"none",face:{eyes:"big",eyeColor:"#3a2140",mouth:"smile",muzzle:"none",cheeks:"#ffd0a0"},tail:"none",headExtras:["spots"],bodyExtras:["tentacles"],extraColors:["#f7b3cc","#f7b3cc"]},{id:"chick",name:{en:"Chick",it:"Pulcino"},band:"3-5",palette:{body:"#ffd45e",limbs:"#ffd45e",belly:"#fff2c2",accent:"#ffa04a",outline:Ae,hands:"#ffc23d",feet:"#ffa04a"},head:"round",ears:"none",face:{eyes:"dot",mouth:"beak",muzzle:"none",cheeks:He},tail:"none",headExtras:["eggshell"],bodyExtras:[],extraColors:["#fffaf0"]},{id:"puppy",name:{en:"Puppy",it:"Cucciolo"},band:"3-5",palette:{body:"#f4e4cf",limbs:"#f4e4cf",belly:"#fffaf2",accent:"#f29aa4",outline:Ae,ears:"#b58262",hands:"#e6caa6",feet:"#e6caa6"},head:"wide",ears:"floppy",face:{eyes:"dot",mouth:"open",nose:pn,muzzle:"oval",cheeks:He},tail:"curl",headExtras:["eye-spot"],bodyExtras:[]},{id:"lamb",name:{en:"Lamb",it:"Agnellino"},band:"3-5",palette:{body:"#fdf8ee",limbs:"#e3d1c2",belly:"#fffdf8",accent:"#f6bcc2",outline:Ae,skin:"#f7dccb",hands:"#a58c7e",feet:"#a58c7e"},head:"round",ears:"droopy",face:{eyes:"dot",mouth:"smile",nose:"#e591a0",muzzle:"none",cheeks:He},tail:"pom",headExtras:["wool"],bodyExtras:["wool"]},{id:"duckling",name:{en:"Duckling",it:"Anatroccolo"},band:"3-5",palette:{body:"#fff1a6",limbs:"#fff1a6",belly:"#fffbe0",accent:"#ff9f43",outline:Ae,feet:"#ff9f43"},head:"tall",ears:"none",face:{eyes:"dot",mouth:"bill",muzzle:"none",cheeks:He},tail:"none",headExtras:["curl"],bodyExtras:["flippers","scarf"],extraColors:["#86cfe0"]},{id:"shark",name:{en:"Shark",it:"Squalo"},band:"6-8",palette:{body:"#6c95c4",limbs:"#6c95c4",belly:"#eef5fb",accent:"#4c76a8",outline:ce,hands:"#eef5fb",feet:"#4c76a8"},head:"wide",ears:"fin",face:{eyes:"dot",mouth:"jaws",muzzle:"none",cheeks:"#f59bb0"},tail:"fish",headExtras:["gills"],bodyExtras:[]},{id:"wolf",name:{en:"Wolf",it:"Lupo"},band:"6-8",palette:{body:"#8f9bb3",limbs:"#8f9bb3",belly:"#eef1f6",accent:"#f3b8c4",outline:ce,hands:"#5a647a",feet:"#5a647a"},head:"round",ears:"pointy",face:{eyes:"dot",mouth:"open",nose:pn,muzzle:"oval",cheeks:"#f4a3b0"},tail:"fluffy",headExtras:["ruff","forehead"],bodyExtras:[],extraColors:["#636d84"]},{id:"parrot",name:{en:"Parrot",it:"Pappagallo"},band:"6-8",palette:{body:"#e8503f",limbs:"#e8503f",belly:"#ffd25a",accent:"#f6e6c4",outline:ce,hands:"#3a9bdc",feet:"#8a7a70"},head:"round",ears:"none",face:{eyes:"big",eyeColor:ce,eyeRing:"#ffffff",mouth:"hook",muzzle:"none",cheeks:"#ffb0a0"},tail:"plume",headExtras:["crest"],bodyExtras:["feathers"],extraColors:["#ffd25a","#3fae5a","#3a9bdc"]},{id:"ninja",name:{en:"Ninja",it:"Ninja"},band:"9-12",palette:{body:"#2f3a56",limbs:"#2f3a56",belly:"#2f3a56",accent:"#36c9bb",outline:Oe,skin:"#b07a52",hands:"#222a40",feet:"#222a40"},head:"round",ears:"none",face:{eyes:"calm",mouth:"none",muzzle:"none",brows:"#2a1d16"},tail:"none",headExtras:["ninja-hood"],bodyExtras:["belt"],extraColors:["#36c9bb","#36c9bb","#36c9bb"]},{id:"skater",name:{en:"Skater",it:"Skater"},band:"9-12",palette:{body:"#3a8fc0",limbs:"#2c3e57",belly:"#2f7aa6",accent:"#ffcf3a",outline:Oe,skin:"#f2c9a5",hair:"#7a4a2a",hands:"#f2c9a5",feet:"#eef1f5"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smirk",muzzle:"none",brows:"#5a3520"},tail:"none",headExtras:["hair","cap"],bodyExtras:["pocket","joints"],extraColors:["#ff5d73"]},{id:"explorer",name:{en:"Explorer",it:"Giramondo"},band:"9-12",palette:{body:"#5f8f5b",limbs:"#5f8f5b",belly:"#5f8f5b",accent:"#d9bb7e",outline:Oe,skin:"#7a4a30",hair:"#1d1410",hands:"#7a4a30",feet:"#6b4a2a"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smile",muzzle:"none",brows:"#1d1410"},tail:"none",headExtras:["curls","safari-hat"],bodyExtras:["backpack","straps","boots"],extraColors:["#e07b39","#6b4a2a"]},{id:"wizard",name:{en:"Wizard",it:"Mago"},band:"9-12",palette:{body:"#5b3fa0",limbs:"#5b3fa0",belly:"#5b3fa0",accent:"#3d5fc8",outline:Oe,skin:"#c98d62",hair:"#a8452a",hands:"#c98d62",feet:"#33255e"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smile",muzzle:"none",brows:"#7a301c"},tail:"none",headExtras:["locks","wizard-hat"],bodyExtras:["robe","belt"],extraColors:["#ffd84a","#ffd84a","#ffd84a"]},{id:"knight",name:{en:"Knight",it:"Cavaliere"},band:"9-12",palette:{body:"#bcc7d3",limbs:"#8e9aa8",belly:"#dce3ea",accent:"#d8443a",outline:Oe,hands:"#6c7786",feet:"#6c7786"},head:"bucket",ears:"none",face:{eyes:"slit",eyeColor:"#bfefff",mouth:"none",muzzle:"none"},tail:"none",headExtras:["plume"],bodyExtras:["pauldrons","emblem","boots"],extraColors:["#d8443a"]},{id:"racer",name:{en:"Racer",it:"Pilota"},band:"9-12",palette:{body:"#ff6a2b",limbs:"#ff6a2b",belly:"#ffffff",accent:"#ffffff",outline:Oe,hands:"#232838",feet:"#232838"},head:"round",ears:"none",face:{eyes:"goggle",eyeColor:"#7fd6ff",mouth:"none",muzzle:"none"},tail:"none",headExtras:["stripe"],bodyExtras:["racing-stripe","boots"]},{id:"pirate",name:{en:"Pirate",it:"Pirata"},band:"9-12",palette:{body:"#f2efe6",limbs:"#2a3d6e",belly:"#f2efe6",accent:"#d94545",outline:Oe,skin:"#d9a072",hair:"#2b1a12",hands:"#d9a072",feet:"#3a2a20"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smirk",muzzle:"none",brows:"#2b1a12"},tail:"none",headExtras:["locks","bandana","eye-patch"],bodyExtras:["stripes","belt","boots"],extraColors:["#d94545","#2a3d6e","#4a3426"]},{id:"diver",name:{en:"Diver",it:"Sub"},band:"9-12",palette:{body:"#1f6582",limbs:"#1f6582",belly:"#1f6582",accent:"#ffb020",outline:Oe,skin:"#e8b48a",hair:"#c98f2e",hands:"#1b4f66",feet:"#ffb020"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smile",muzzle:"none",brows:"#8a5a1a"},tail:"none",headExtras:["curls","dive-mask"],bodyExtras:["tank","fins"],extraColors:["#c9d3db"]},{id:"hero",name:{en:"Hero",it:"Supereroe"},band:"9-12",palette:{body:"#3557c8",limbs:"#3557c8",belly:"#3557c8",accent:"#e0403a",outline:Oe,skin:"#5a3825",hair:"#141010",hands:"#e0403a",feet:"#e0403a"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smirk",muzzle:"none",brows:"#141010"},tail:"none",headExtras:["hair","domino"],bodyExtras:["cape","emblem","boots"],extraColors:["#ffd84a"]},{id:"trex",name:{en:"T-Rex",it:"T-Rex"},band:"6-8",alsoIn:["3-5"],palette:{body:"#6cb84e",limbs:"#6cb84e",belly:"#f4e8a8",accent:"#f4e8a8",outline:ce},head:"snout-long",ears:"none",face:{eyes:"dot",mouth:"toothy",muzzle:"none",cheeks:"#f59b8f"},tail:"thick",headExtras:["stripes"],bodyExtras:["tiny-arms","strong-legs"],extraColors:["#4a9235","#58a23f"]},{id:"fairy",name:{en:"Fairy",it:"Fatina"},band:"6-8",alsoIn:["3-5"],palette:{body:"#b99af0",limbs:"#a8693f",belly:"#b99af0",accent:"#ffd84a",outline:ce,skin:"#a8693f",hair:"#2e1d17",hands:"#a8693f",feet:"#f58cbc"},head:"round",ears:"pixie",face:{eyes:"dot",mouth:"smile",muzzle:"none",cheeks:"#f0857a"},tail:"none",headExtras:["bun","flower-crown"],bodyExtras:["wings-fairy","petals","wand"],extraColors:["#c4ecff","#f7a8cf","#fff3a0","#ffffff"]}];var re={M:0,L:1,Q:2,C:3,Z:4},Gs=[2,2,4,6,0];function It(s,n){for(let e of n)ii(s,e)}function ii(s,n){if(n.k==="group"){s.save(),s.translate(n.x,n.y),n.rot&&s.rotate(n.rot),n.s!==void 0&&n.s!==1&&s.scale(n.s,n.s),n.alpha!==void 0&&(s.globalAlpha*=n.alpha),It(s,n.items),s.restore();return}switch(s.save(),n.alpha!==void 0&&(s.globalAlpha*=n.alpha),s.beginPath(),n.k){case"circle":s.arc(n.x,n.y,Math.max(n.r,0),0,Math.PI*2);break;case"ellipse":s.ellipse(n.x,n.y,Math.max(n.rx,0),Math.max(n.ry,0),n.rot??0,0,Math.PI*2);break;case"rect":li(s,n);break;case"path":typeof n.d=="string"?ui(s,n.d):ci(s,n.d);break;case"line":s.moveTo(n.pts[0]??0,n.pts[1]??0);for(let e=2;e+1<n.pts.length;e+=2)s.lineTo(n.pts[e],n.pts[e+1]);break}s.lineCap="round",s.lineJoin="round",n.fill&&n.k!=="line"&&(s.fillStyle=n.fill,s.fill()),n.stroke&&(n.lw??1)>0&&(s.strokeStyle=n.stroke,s.lineWidth=n.lw??1,s.stroke()),s.restore()}function li(s,n){let e=Math.max(0,Math.min(n.r,n.w/2,n.h/2));s.translate(n.x,n.y),n.rot&&s.rotate(n.rot);let t=-n.w/2,r=-n.h/2;s.moveTo(t+e,r),s.lineTo(t+n.w-e,r),s.quadraticCurveTo(t+n.w,r,t+n.w,r+e),s.lineTo(t+n.w,r+n.h-e),s.quadraticCurveTo(t+n.w,r+n.h,t+n.w-e,r+n.h),s.lineTo(t+e,r+n.h),s.quadraticCurveTo(t,r+n.h,t,r+n.h-e),s.lineTo(t,r+e),s.quadraticCurveTo(t,r,t+e,r),s.closePath()}function ci(s,n){for(let e=0;e<n.length;){let t=n[e++];if(t===re.M)s.moveTo(n[e],n[e+1]);else if(t===re.L)s.lineTo(n[e],n[e+1]);else if(t===re.Q)s.quadraticCurveTo(n[e],n[e+1],n[e+2],n[e+3]);else if(t===re.C)s.bezierCurveTo(n[e],n[e+1],n[e+2],n[e+3],n[e+4],n[e+5]);else if(t===re.Z)s.closePath();else return;e+=Gs[t]}}function Er(s){if(typeof s=="string")return(s.match(/-?\d*\.?\d+(?:e-?\d+)?/gi)??[]).map(Number);let n=[];for(let e=0;e<s.length;){let t=Gs[s[e++]];if(t===void 0)break;for(let r=0;r<t;r++)n.push(s[e+r]);e+=t}return n}function ui(s,n){let e=n.match(/[MLQCZ]|-?\d*\.?\d+(?:e-?\d+)?/gi)??[],t="",r=0,o=()=>Number(e[r++]);for(;r<e.length;){let a=e[r];if(/[MLQCZ]/i.test(a)&&(t=a.toUpperCase(),r++,t==="Z")){s.closePath();continue}t==="M"?(s.moveTo(o(),o()),t="L"):t==="L"?s.lineTo(o(),o()):t==="Q"?s.quadraticCurveTo(o(),o(),o(),o()):t==="C"?s.bezierCurveTo(o(),o(),o(),o(),o(),o()):r++}}var J=s=>{let n=Math.round(s*100)/100;return n===0?0:n};function Q(s,n=.5){let e=s.length;if(e<3)return[];let t=(i,u,c)=>({x:i.x+(u.x-i.x)*c,y:i.y+(u.y-i.y)*c}),r=Math.min(Math.max(n,0),.5),o=t(s[0],s[1],r),a=[re.M,J(o.x),J(o.y)];for(let i=1;i<=e;i++){let u=s[(i-1)%e],c=s[i%e],l=s[(i+1)%e],f=t(u,c,1-r),h=t(c,l,r);a.push(re.L,J(f.x),J(f.y),re.Q,J(c.x),J(c.y),J(h.x),J(h.y))}return a.push(re.Z),a}function K(s,n=1){let e=s.length;if(e<3)return[];let t=[re.M,J(s[0].x),J(s[0].y)],r=n/6;for(let o=0;o<e;o++){let a=s[(o-1+e)%e],i=s[o],u=s[(o+1)%e],c=s[(o+2)%e];t.push(re.C,J(i.x+(u.x-a.x)*r),J(i.y+(u.y-a.y)*r),J(u.x-(c.x-i.x)*r),J(u.y-(c.y-i.y)*r),J(u.x),J(u.y))}return t.push(re.Z),t}function Nt(s){let n=s.length;if(n<2)return[];let e=[re.M,J(s[0].x),J(s[0].y)];for(let t=0;t<n-1;t++){let r=s[Math.max(t-1,0)],o=s[t],a=s[t+1],i=s[Math.min(t+2,n-1)];e.push(re.C,J(o.x+(a.x-r.x)/6),J(o.y+(a.y-r.y)/6),J(a.x-(i.x-o.x)/6),J(a.y-(i.y-o.y)/6),J(a.x),J(a.y))}return e}var tt="M0 -1 L0.29 -0.4 L0.95 -0.31 L0.47 0.15 L0.59 0.81 L0 0.5 L-0.59 0.81 L-0.47 0.15 L-0.95 -0.31 L-0.29 -0.4 Z";var ie="#ffffff",X=[-1,1],Us="#3a2420",Vs="#f2808f",Rr="#26324a",hi="#ffd84a",se=(...s)=>{let n=[];for(let e=0;e+1<s.length;e+=2)n.push({x:s[e],y:s[e+1]});return n};function zn(s,n){let e=s.palette,t=[],r={stroke:e.outline,lw:n},o=l=>s.headExtras.includes(l),a=(l,f)=>s.extraColors?.[l]??f;if(o("mane")){for(let f=0;f<12;f++){let h=f/12*Math.PI*2;t.push({k:"circle",x:Math.cos(h)*1.02,y:Math.sin(h)*1+.04,r:.42,fill:a(0,e.accent),...r})}t.push({k:"circle",x:0,y:.04,r:1.08,fill:a(0,e.accent)})}if(o("rainbow-mane")){let l=s.extraColors??["#f59ac0","#fbd46a","#8fd3f4"];[[.98,.05,.3,.5,-.25],[.92,.58,.26,.42,-.1],[.62,.92,.22,.32,.4]].forEach(([h,m,b,y,d],x)=>t.push({k:"ellipse",x:h,y:m,rx:b,ry:y,rot:d,fill:l[x%l.length],...r}))}if(o("spikes"))for(let l of[-.55,0,.55]){let f=vt(l,1.48),h=vt(l-.32,.86),m=vt(l+.32,.86);t.push({k:"path",d:Q([h,f,m],.22),fill:e.accent,...r})}if(o("curl")&&t.push({k:"path",d:K([{x:-.2,y:-.9},{x:-.05,y:-1.3},{x:.32,y:-1.42},{x:.16,y:-1.18},{x:.2,y:-.9}]),fill:e.body,...r}),o("wool"))for(let l=0;l<=8;l++){let f=-1.75+l/8*3.5;t.push({k:"circle",x:Math.sin(f)*.98,y:-Math.cos(f)*.92-.04,r:.34,fill:e.body,...r})}if(o("crest")&&[-.38,0,.38].forEach((l,f)=>{let h=vt(l,1.12);t.push({k:"ellipse",x:h.x,y:h.y,rx:.15,ry:.42,rot:l,fill:a(f,e.accent),...r})}),o("plume")&&t.push({k:"path",d:K(se(-.12,-.92,-.2,-1.42,.1,-1.78,.62,-1.74,.36,-1.46,.16,-.98)),fill:e.accent,...r}),o("locks")&&t.push({k:"path",d:K(se(-1.14,.58,-1.24,-.2,-.86,-.98,0,-1.2,.86,-.98,1.24,-.2,1.14,.58,.8,.66,0,.2,-.8,.66)),fill:e.hair??e.outline,...r}),o("bun")&&t.push({k:"circle",x:.04,y:-1.14,r:.4,fill:e.hair??e.outline,...r}),o("ninja-hood"))for(let[l,f]of[[.35,.5],[.85,.42]])t.push({k:"ellipse",x:1+Math.cos(l)*f*.8,y:-.5+Math.sin(l)*f*.8,rx:f,ry:.11,rot:l,fill:e.accent,...r});if(o("bandana"))for(let[l,f]of[[Math.PI-.5,.42],[Math.PI-1,.36]])t.push({k:"ellipse",x:-.98+Math.cos(l)*f*.8,y:-.36+Math.sin(l)*f*.8,rx:f,ry:.12,rot:l,fill:e.accent,...r});if(o("ruff"))for(let l of X)t.push({k:"path",d:Q(se(l*.7,-.3,l*1.32,0,l*1.02,.18,l*1.26,.46,l*.86,.56,l*.98,.84,l*.4,.7),.25),fill:e.body,...r});if(s.face.eyesOnTop)for(let l of X)t.push({k:"circle",x:l*.46,y:-.72,r:.38,fill:e.body,...r});t.push(...bi(s,n)),t.push(fi(s,r));let i=s.face.muzzle,u=e.belly;if(i==="oval"&&t.push({k:"ellipse",x:0,y:.4,rx:.46,ry:.32,fill:u}),i==="monkey"){for(let l of X)t.push({k:"circle",x:l*.32,y:-.04,r:.38,fill:u});t.push({k:"ellipse",x:0,y:.4,rx:.56,ry:.4,fill:u})}if(i==="heart"){for(let l of X)t.push({k:"circle",x:l*.36,y:.02,r:.5,fill:u});t.push({k:"ellipse",x:0,y:.38,rx:.66,ry:.48,fill:u})}if(i==="disc")for(let l of X)t.push({k:"circle",x:l*.4,y:.02,r:.44,fill:u});if(i==="cheeks")for(let l of X)t.push({k:"ellipse",x:l*.4,y:.44,rx:.44,ry:.32,fill:u});if(i==="band"&&t.push({k:"path",d:yi(s,n),fill:u}),o("stripes")&&s.head==="snout-long"){let l=a(0,e.outline);for(let[f,h,m,b]of[[.46,-.94,.36,-.66],[.8,-.72,.62,-.5],[1,-.36,.78,-.24]])t.push({k:"line",pts:[f,h,m,b],stroke:l,lw:.11})}else if(o("stripes")){let l=a(0,e.outline);t.push({k:"line",pts:[0,-.97,0,-.66],stroke:l,lw:.13});for(let f of X)t.push({k:"line",pts:[f*.3,-.93,f*.24,-.7],stroke:l,lw:.1}),t.push({k:"line",pts:[f*.98,-.05,f*.74,0],stroke:l,lw:.1}),t.push({k:"line",pts:[f*.94,.22,f*.74,.22],stroke:l,lw:.09})}if(o("spots")){let l=a(1,e.belly);t.push({k:"circle",x:-.55,y:-.5,r:.15,fill:l}),t.push({k:"circle",x:.58,y:-.42,r:.11,fill:l}),t.push({k:"circle",x:.22,y:-.76,r:.09,fill:l})}if(s.head==="snout-long")for(let[l,f,h]of[[-1.38,-.14,.06],[-1.14,-.22,.055]])t.push({k:"ellipse",x:l,y:f,rx:h,ry:h*.8,rot:-.3,fill:e.outline,alpha:.85});if(o("forehead")&&t.push({k:"path",d:K(se(-.62,-.66,0,-.86,.62,-.66,.26,-.36,0,-.1,-.26,-.36),.9),fill:a(0,e.accent)}),o("eye-spot")&&t.push({k:"ellipse",x:.42,y:-.06,rx:.3,ry:.33,rot:.3,fill:e.ears??e.accent}),o("gills"))for(let l of X)for(let f of[0,.12,.24])t.push({k:"path",d:`M${l*(.66+f)} 0.06 Q${l*(.6+f)} 0.22 ${l*(.66+f)} 0.38`,stroke:e.accent,lw:n*.9});let c=e.hair??e.outline;if(o("hair")&&t.push({k:"path",d:K(se(-1.02,-.06,-1.02,-.58,-.62,-1.04,.08,-1.14,.76,-.92,1.05,-.42,1,-.06,.84,-.4,.42,-.5,.06,-.4,-.34,-.56,-.74,-.38)),fill:c,...r}),o("locks")&&t.push({k:"path",d:K(se(-1,-.08,-.98,-.62,-.56,-1.02,0,-1.1,.56,-1.02,.98,-.62,1,-.08,.8,-.38,.36,-.44,0,-.4,-.36,-.44,-.8,-.38)),fill:c,...r}),o("bun")&&t.push({k:"path",d:K(se(-1.02,-.1,-.98,-.62,-.56,-1.02,0,-1.1,.56,-1.02,.98,-.62,1.02,-.1,.84,-.36,.5,-.56,.12,-.48,-.22,-.6,-.6,-.5,-.86,-.36)),fill:c,...r}),o("curls")){for(let l=0;l<7;l++){let f=vt(-1.3+l/6*2.6,.86);t.push({k:"circle",x:f.x,y:f.y,r:.3,fill:c,...r})}t.push({k:"ellipse",x:0,y:-.64,rx:.8,ry:.36,fill:c})}if(o("ninja-hood")&&(t.push({k:"rect",x:0,y:0,w:1.56,h:.6,r:.28,fill:e.skin??ie,stroke:e.outline,lw:n*.8}),t.push({k:"path",d:"M-0.98 -0.42 Q0 -0.74 0.98 -0.42 L1.0 -0.62 Q0 -0.94 -1.0 -0.62 Z",fill:e.accent,...r})),o("domino")){t.push({k:"path",d:K(se(-.86,-.04,-.62,-.3,-.18,-.24,0,-.16,.18,-.24,.62,-.3,.86,-.04,.6,.22,.16,.16,0,.1,-.16,.16,-.6,.22),.9),fill:e.accent,...r});for(let l of X)t.push({k:"ellipse",x:l*.38,y:0,rx:.19,ry:.13,fill:ie})}if(t.push(...xi(s,n)),o("brows"))for(let l of X)t.push({k:"line",pts:[l*.72,-.5,l*.14,-.3],stroke:e.accent,lw:.16});if(s.face.brows)for(let l of X)t.push({k:"line",pts:[l*.2,-.2,l*.54,-.28],stroke:s.face.brows,lw:.09});if(t.push(...gi(s,n)),s.face.cheeks)for(let l of di(s))t.push({k:"ellipse",x:l.x,y:l.y,rx:.15,ry:.1,fill:s.face.cheeks,alpha:.8});if(o("whiskers"))for(let l of X)for(let f of[-.1,.06])t.push({k:"line",pts:[l*.62,.38+f,l*1.06,.3+f*2.2],stroke:e.outline,lw:n*.7,alpha:.75});if(o("rainbow-mane")){let l=s.extraColors??["#f59ac0","#fbd46a","#8fd3f4"];t.push({k:"ellipse",x:.42,y:-.82,rx:.34,ry:.22,rot:.5,fill:l[0],...r}),t.push({k:"ellipse",x:.1,y:-.92,rx:.3,ry:.2,rot:.25,fill:l[1%l.length],...r})}if(s.ears==="unicorn"){let l=[{x:-.18,y:-.84},{x:.02,y:-1.72},{x:.18,y:-.84}];t.push({k:"path",d:Q(l,.12),fill:e.accent,...r});for(let f of[-1,-1.2,-1.4]){let h=.16*((f+1.72)/.88);t.push({k:"line",pts:[-h,f+.04,h,f-.04],stroke:e.outline,lw:n*.7,alpha:.6})}}if(o("flower-crown")){let l=[a(1,"#f7a8cf"),a(2,"#fff3a0"),a(3,ie)];for(let f of[-.84,-.28,.28,.84]){let h=vt(f,.9);t.push({k:"ellipse",x:h.x,y:h.y,rx:.14,ry:.07,rot:f+.5,fill:"#7cc76a",stroke:e.outline,lw:n*.7})}[-1.12,-.56,0,.56,1.12].forEach((f,h)=>{let m=vt(f,.9),b=h===2?.13:.11;for(let y=0;y<5;y++){let d=f+y/5*Math.PI*2;t.push({k:"circle",x:m.x+Math.sin(d)*b,y:m.y-Math.cos(d)*b,r:b*.82,fill:l[h%l.length],stroke:e.outline,lw:n*.7})}t.push({k:"circle",x:m.x,y:m.y,r:b*.62,fill:l[h%l.length]}),t.push({k:"circle",x:m.x,y:m.y,r:b*.42,fill:e.accent})})}if(o("helmet")){for(let l of X)t.push({k:"rect",x:l*1,y:.05,w:.26,h:.56,r:.12,fill:e.accent,...r});t.push({k:"path",d:"M-0.62 -0.62 Q-0.3 -0.92 0.12 -0.9",stroke:ie,lw:.1,alpha:.9})}if(o("bolts"))for(let l of X)t.push({k:"rect",x:l*1.08,y:.08,w:.2,h:.44,r:.08,fill:e.accent,...r});if(o("tuft")&&t.push({k:"path",d:K([{x:-.26,y:-.95},{x:-.12,y:-1.22},{x:.02,y:-1.04},{x:.16,y:-1.28},{x:.28,y:-.95},{x:0,y:-.86}]),fill:e.body,...r}),o("eggshell")&&t.push({k:"path",d:"M-0.88 -0.5 C-0.88 -1.12 -0.46 -1.42 0 -1.42 C0.46 -1.42 0.88 -1.12 0.88 -0.5 L0.66 -0.66 L0.44 -0.48 L0.22 -0.66 L0 -0.48 L-0.22 -0.66 L-0.44 -0.48 L-0.66 -0.66 Z",fill:a(0,ie),...r}),o("wool"))for(let[l,f]of[[-.36,-.84],[.02,-.94],[.4,-.82]])t.push({k:"circle",x:l,y:f,r:.27,fill:e.body,...r});if(o("stripe")&&t.push({k:"rect",x:0,y:-.64,w:.38,h:.62,r:.06,fill:e.accent}),o("eye-patch")&&(t.push({k:"line",pts:[-.97,-.5,.97,.13],stroke:e.outline,lw:.07}),t.push({k:"ellipse",x:.38,y:.02,rx:.21,ry:.19,fill:e.outline})),o("bandana")){t.push({k:"path",d:K(se(-1.05,-.22,-.96,-.72,-.5,-1.08,.1,-1.14,.72,-.96,1.04,-.56,1.05,-.22,.5,-.46,-.5,-.46)),fill:e.accent,...r});for(let[l,f]of[[-.5,-.8],[.08,-.92],[.6,-.74],[-.12,-.62],[.36,-.6]])t.push({k:"circle",x:l,y:f,r:.06,fill:ie,alpha:.85});t.push({k:"circle",x:-.98,y:-.34,r:.15,fill:e.accent,...r})}if(o("cap")){for(let l of X)t.push({k:"line",pts:[l*.98,-.2,l*.5,.82,-l*.05,.98],stroke:e.outline,lw:.06});t.push({k:"path",d:K(se(-1.1,-.16,-1.04,-.66,-.6,-1.12,0,-1.24,.6,-1.12,1.04,-.66,1.1,-.16,.5,-.4,-.5,-.4)),fill:e.accent,...r}),t.push({k:"path",d:"M-0.74 -0.4 Q0 -0.6 0.74 -0.4 Q0.8 -0.24 0.6 -0.22 Q0 -0.36 -0.6 -0.22 Q-0.8 -0.24 -0.74 -0.4 Z",fill:e.accent,...r}),t.push({k:"circle",x:.5,y:-.82,r:.15,fill:a(0,ie),...r});for(let l of[-.42,-.14])t.push({k:"line",pts:[l,-1.04,l+.02,-.78],stroke:e.outline,lw:.07,alpha:.7})}if(o("safari-hat")&&(t.push({k:"ellipse",x:0,y:-.56,rx:1.48,ry:.3,fill:e.accent,...r}),t.push({k:"path",d:K(se(-.78,-.58,-.7,-1.1,-.3,-1.38,.3,-1.38,.7,-1.1,.78,-.58,0,-.5),.8),fill:e.accent,...r}),t.push({k:"path",d:"M-0.77 -0.72 Q0 -0.62 0.77 -0.72 L0.74 -0.9 Q0 -0.8 -0.74 -0.9 Z",fill:a(1,e.outline),stroke:e.outline,lw:n*.8})),o("wizard-hat")){t.push({k:"ellipse",x:0,y:-.62,rx:1.32,ry:.26,fill:e.accent,...r}),t.push({k:"path",d:Q(se(-.8,-.66,-.36,-1.5,.5,-2.2,.3,-1.46,.8,-.66),.3),fill:e.accent,...r});let l=a(0,hi);for(let[f,h,m]of[[.02,-1.08,.18],[-.38,-.84,.1],[.36,-1.5,.11]])t.push({k:"group",x:f,y:h,s:m,items:[{k:"path",d:tt,fill:l}]})}if(o("dive-mask")){for(let f of X)t.push({k:"line",pts:[f*.7,-.04,f*1,-.12],stroke:e.outline,lw:.2},{k:"line",pts:[f*.7,-.04,f*1,-.12],stroke:e.accent,lw:.11});t.push({k:"rect",x:0,y:0,w:1.42,h:.62,r:.28,fill:"#bfe9f5",alpha:.35}),t.push({k:"rect",x:0,y:0,w:1.42,h:.62,r:.28,stroke:e.outline,lw:.2}),t.push({k:"rect",x:0,y:0,w:1.42,h:.62,r:.28,stroke:e.accent,lw:.11}),t.push({k:"path",d:"M-0.5 -0.16 Q-0.4 -0.24 -0.22 -0.24",stroke:ie,lw:.06,alpha:.9});let l="M0.5 0.52 Q0.98 0.56 1.04 0.1 L1.12 -0.92";t.push({k:"path",d:l,stroke:e.outline,lw:.24},{k:"path",d:l,stroke:e.accent,lw:.13})}return t}function fi(s,n){let e=s.headExtras.includes("ninja-hood")?s.palette.body:s.palette.skin??s.palette.body;switch(s.head){case"round":return{k:"circle",x:0,y:0,r:1,fill:e,...n};case"wide":return{k:"ellipse",x:0,y:.03,rx:1.12,ry:.94,fill:e,...n};case"tall":return{k:"ellipse",x:0,y:-.02,rx:.94,ry:1.04,fill:e,...n};case"square":return{k:"rect",x:0,y:0,w:2,h:1.8,r:.46,fill:e,...n};case"bucket":return{k:"path",d:Q(se(-.94,.96,-.98,-.36,-.62,-1.04,.62,-1.04,.98,-.36,.94,.96),.42),fill:e,...n};case"snout-long":return{k:"path",d:K(pi,.95),fill:e,...n};case"bulb":return{k:"path",d:K([{x:0,y:-1.02},{x:.86,y:-.74},{x:1.08,y:-.12},{x:.72,y:.62},{x:0,y:.92},{x:-.72,y:.62},{x:-1.08,y:-.12},{x:-.86,y:-.74}]),fill:e,...n}}}var pi=se(.7,-.88,.12,-1.04,-.3,-.98,-.72,-.74,-1.2,-.56,-1.5,-.32,-1.6,.04,-1.44,.42,-.9,.72,-.2,.92,.5,.88,.96,.56,1.08,0,.98,-.5);function Ws(s,n,e){return s.head==="snout-long"?[{x:-.36,y:-.5,k:.95},{x:.26,y:-.48,k:1.1}]:X.map(t=>({x:t*n,y:e,k:1}))}function di(s){return s.head==="snout-long"?se(-.66,-.14,.66,.1):X.map(n=>({x:n*.64,y:.3}))}function mi(s){return s.head==="round"?{cy:0,rx:1,ry:1}:s.head==="tall"?{cy:-.02,rx:.94,ry:1.04}:{cy:.03,rx:1.12,ry:.94}}function yi(s,n){let{cy:e,rx:t,ry:r}=mi(s),o=t-n/2,a=r-n/2,i=.15,u=Math.asin(Math.min(1,(i-e)/a)),c=Math.cos(u)*o,l=b=>Math.round(b*100)/100||0,f=[re.M,l(-c),i],h=[[-.84*c,.02,-.53*c,.06,-.32*c,.24],[-.17*c,.11,.17*c,.11,.32*c,.24],[.53*c,.06,.84*c,.02,c,i]];for(let b of h)f.push(re.C,...b.map(l));let m=24;for(let b=1;b<=m;b++){let y=u+(Math.PI-2*u)*b/m;f.push(re.L,l(Math.cos(y)*o),l(e+Math.sin(y)*a))}return f.push(re.Z),f}function bi(s,n){let e=s.palette,t={stroke:e.outline,lw:n},r=[];for(let o of X)switch(s.ears){case"pointy":case"unicorn":{let a=s.ears==="unicorn"?.8:1,i={x:o*.3,y:-.82},u={x:o*.86,y:-.82-.62*a},c={x:o*.94,y:-.36};r.push({k:"path",d:Q([i,u,c],.2),fill:e.body,...t});let l={x:(i.x+u.x+c.x)/3,y:(i.y+u.y+c.y)/3},f=[i,u,c].map(h=>({x:l.x+(h.x-l.x)*.55,y:l.y+(h.y-l.y)*.55+.04}));r.push({k:"path",d:Q(f,.25),fill:e.accent});break}case"round":r.push({k:"circle",x:o*.72,y:-.72,r:.36,fill:e.ears??e.body,...t}),e.ears||r.push({k:"circle",x:o*.74,y:-.74,r:.19,fill:e.accent});break;case"big-round":r.push({k:"circle",x:o*.96,y:-.46,r:.52,fill:e.body,...t}),r.push({k:"circle",x:o*1,y:-.44,r:.32,fill:e.accent});break;case"long":r.push({k:"ellipse",x:o*.38,y:-1.42,rx:.25,ry:.68,rot:o*.14,fill:e.body,...t}),r.push({k:"ellipse",x:o*.39,y:-1.36,rx:.12,ry:.48,rot:o*.14,fill:e.accent});break;case"side":r.push({k:"circle",x:o*1,y:.02,r:.34,fill:e.body,...t}),r.push({k:"circle",x:o*1.02,y:.02,r:.2,fill:e.belly});break;case"tufts":r.push({k:"path",d:Q([{x:o*.3,y:-.84},{x:o*1.22,y:-1.12},{x:o*.92,y:-.42}],.16),fill:e.body,...t}),r.push({k:"line",pts:[o*.62,-.78,o*1,-.98],stroke:e.accent,lw:.08});break;case"antennae":{let a={x:o*.62,y:-1.42};r.push({k:"path",d:`M${o*.3} -0.8 Q${o*.36} -1.2 ${a.x} ${a.y}`,stroke:e.outline,lw:n*2.6}),r.push({k:"path",d:`M${o*.3} -0.8 Q${o*.36} -1.2 ${a.x} ${a.y}`,stroke:e.body,lw:n*1.2}),r.push({k:"circle",x:a.x,y:a.y,r:.17,fill:e.accent,...t});break}case"floppy":r.push({k:"ellipse",x:o*.96,y:.02,rx:.3,ry:.62,rot:-o*.36,fill:e.ears??e.body,...t});break;case"droopy":r.push({k:"ellipse",x:o*1.04,y:-.22,rx:.4,ry:.18,rot:o*.32,fill:e.skin??e.body,...t}),r.push({k:"ellipse",x:o*1.08,y:-.2,rx:.24,ry:.08,rot:o*.32,fill:e.accent});break;case"pixie":r.push({k:"path",d:Q(se(o*.86,-.22,o*1.36,-.5,o*1.02,.26),.28),fill:e.skin??e.body,...t}),r.push({k:"line",pts:[o*.98,-.12,o*1.16,-.3],stroke:e.accent,lw:n*.8,alpha:.5});break;case"human":r.push({k:"ellipse",x:o*.98,y:.06,rx:.17,ry:.23,fill:e.skin??e.body,...t});break;case"horns":{let a=[{x:o*.3,y:-.84},{x:o*.6,y:-1.5},{x:o*.66,y:-.68}];r.push({k:"path",d:Q(a,.18),fill:e.accent,...t});break}}return s.ears==="fin"&&r.push({k:"path",d:Q(se(-.4,-.82,.2,-1.62,.46,-.78),.2),fill:e.body,...t}),s.ears==="antenna"&&(r.push({k:"line",pts:[0,-.85,0,-1.42],stroke:e.outline,lw:n*2.6}),r.push({k:"line",pts:[0,-.85,0,-1.42],stroke:e.limbs,lw:n*1.2}),r.push({k:"circle",x:0,y:-1.5,r:.18,fill:e.accent,...t})),r}function xi(s,n){let e=s.palette,t=s.face,r=[],o=e.outline,a=t.eyesOnTop?.46:.4,i=t.eyesOnTop?-.72:-.04,u=(c,l,f)=>({k:"circle",x:c,y:l,r:f,fill:ie});switch(t.eyes){case"dot":for(let c of Ws(s,a,i))r.push({k:"ellipse",x:c.x,y:c.y,rx:.12*c.k,ry:.155*c.k,fill:o}),r.push(u(c.x+.04*c.k,c.y-.06*c.k,.045*c.k));break;case"bead":for(let c of Ws(s,a,i))r.push({k:"ellipse",x:c.x,y:c.y,rx:.16*c.k,ry:.22*c.k,fill:o}),r.push(u(c.x+.05*c.k,c.y-.08*c.k,.065*c.k));break;case"big":for(let c of X)t.eyeRing&&r.push({k:"circle",x:c*a,y:i,r:.36,fill:t.eyeRing,stroke:o,lw:n*.8}),r.push({k:"circle",x:c*a,y:i,r:.25,fill:ie,stroke:o,lw:n*.8}),r.push({k:"circle",x:c*a+c*-.03,y:i+.03,r:.14,fill:t.eyeColor??o}),r.push(u(c*a+c*-.03+.05,i-.03,.05));break;case"mask":for(let c of X)r.push({k:"ellipse",x:c*.4,y:0,rx:.24,ry:.32,rot:c*-.55,fill:e.limbs}),r.push({k:"circle",x:c*.4,y:-.02,r:.11,fill:ie}),r.push({k:"circle",x:c*.39,y:-0,r:.065,fill:o});break;case"screen":r.push({k:"rect",x:0,y:0,w:1.5,h:.66,r:.26,fill:"#24323d",stroke:o,lw:n*.8});for(let c of X)r.push({k:"ellipse",x:c*.36,y:0,rx:.2,ry:.24,fill:t.eyeColor??"#7ff0ff",alpha:.3}),r.push({k:"ellipse",x:c*.36,y:0,rx:.12,ry:.16,fill:t.eyeColor??"#7ff0ff"});break;case"almond":for(let c of X)r.push({k:"ellipse",x:c*.42,y:-.02,rx:.3,ry:.2,rot:-c*.5,fill:t.eyeColor??o}),r.push(u(c*.42-c*.07,-.08,.07));break;case"calm":for(let c of X)r.push({k:"ellipse",x:c*.38,y:.02,rx:.085,ry:.12,fill:o}),r.push(u(c*.38+.03,-.02,.03));break;case"slit":r.push({k:"line",pts:[0,-.98,0,-.2],stroke:o,lw:n*.8,alpha:.5}),r.push({k:"rect",x:0,y:-.04,w:1.56,h:.26,r:.1,fill:Rr,stroke:o,lw:n*.8}),r.push({k:"rect",x:0,y:.3,w:.22,h:.46,r:.08,fill:Rr,stroke:o,lw:n*.8});for(let c of X){r.push({k:"ellipse",x:c*.4,y:-.04,rx:.12,ry:.07,fill:t.eyeColor??ie});for(let l of[.36,.56])r.push({k:"circle",x:c*.42,y:l,r:.05,fill:o,alpha:.6})}break;case"goggle":for(let c of X)r.push({k:"circle",x:c*.9,y:0,r:.13,fill:e.accent,stroke:o,lw:n*.8});r.push({k:"rect",x:0,y:0,w:1.66,h:.62,r:.3,fill:Rr,stroke:o,lw:n*.8}),r.push({k:"path",d:"M-0.6 -0.16 Q-0.42 -0.24 -0.12 -0.24",stroke:ie,lw:.07,alpha:.8});for(let c of X)r.push({k:"path",d:`M${c*.5} 0.04 Q${c*.34} -0.08 ${c*.16} 0.02`,stroke:t.eyeColor??"#7fd6ff",lw:.08});for(let c of[-.18,0,.18])r.push({k:"line",pts:[c,.56,c,.72],stroke:o,lw:n*.8,alpha:.6});break;case"visor":r.push({k:"ellipse",x:0,y:.08,rx:.8,ry:.64,fill:"#2a3f6b",stroke:o,lw:n*.8}),r.push({k:"path",d:"M-0.56 -0.14 Q-0.46 -0.4 -0.16 -0.46",stroke:ie,lw:.08,alpha:.7});for(let c of X)r.push({k:"ellipse",x:c*.28,y:.04,rx:.1,ry:.14,fill:t.eyeColor??"#cfeeff"});break}return r}function gi(s,n){let e=s.palette,t=s.face,r=[],o=t.eyes==="visor"?"#cfeeff":Us,a=n*1.05;switch(t.nose&&t.mouth!=="beak"&&(t.mouth==="cat"?r.push({k:"path",d:Q([{x:-.1,y:.22},{x:.1,y:.22},{x:0,y:.33}],.3),fill:t.nose,stroke:t.nose,lw:n*.6}):s.ears==="big-round"?r.push({k:"ellipse",x:0,y:.22,rx:.2,ry:.25,fill:t.nose}):r.push({k:"ellipse",x:0,y:.25,rx:.13,ry:.085,fill:t.nose})),t.mouth){case"smile":r.push({k:"path",d:t.eyes==="visor"?"M-0.16 0.32 Q0 0.46 0.16 0.32":"M-0.17 0.42 Q0 0.58 0.17 0.42",stroke:o,lw:a});break;case"open":r.push({k:"path",d:"M-0.21 0.4 Q0 0.46 0.21 0.4 Q0.19 0.68 0 0.68 Q-0.19 0.68 -0.21 0.4 Z",fill:o,stroke:o,lw:n*.5}),r.push({k:"ellipse",x:0,y:.6,rx:.1,ry:.06,fill:Vs});break;case"cat":r.push({k:"path",d:"M-0.19 0.4 Q-0.1 0.5 0 0.37 Q0.1 0.5 0.19 0.4",stroke:o,lw:a});break;case"beak":r.push({k:"path",d:Q([{x:-.17,y:.2},{x:.17,y:.2},{x:0,y:.48}],.25),fill:e.accent,stroke:e.outline,lw:n*.8});break;case"teeth":r.push({k:"path",d:"M-0.36 0.34 Q0 0.44 0.36 0.34 Q0.28 0.66 0 0.66 Q-0.28 0.66 -0.36 0.34 Z",fill:o,stroke:o,lw:n*.5});for(let i of X)r.push({k:"rect",x:i*.12,y:.43,w:.1,h:.1,r:.03,fill:ie});break;case"grill":r.push({k:"rect",x:0,y:.56,w:.62,h:.2,r:.08,fill:"#24323d",stroke:e.outline,lw:n*.7});for(let i of[-.15,0,.15])r.push({k:"line",pts:[i,.51,i,.61],stroke:"#9fb0bd",lw:n*.6});break;case"tiny":r.push({k:"ellipse",x:0,y:.44,rx:.08,ry:.1,fill:o});break;case"smirk":r.push({k:"path",d:"M-0.16 0.46 Q0.06 0.54 0.22 0.38",stroke:o,lw:a});break;case"bill":r.push({k:"ellipse",x:0,y:.36,rx:.44,ry:.2,fill:e.accent,stroke:e.outline,lw:n*.8}),r.push({k:"path",d:"M-0.36 0.38 Q0 0.46 0.36 0.38",stroke:e.outline,lw:n*.7});for(let i of X)r.push({k:"circle",x:i*.1,y:.28,r:.03,fill:e.outline});break;case"hook":r.push({k:"ellipse",x:0,y:.48,rx:.16,ry:.11,fill:Us}),r.push({k:"path",d:"M-0.3 0.12 Q0 -0.02 0.3 0.12 Q0.36 0.52 0.04 0.76 Q0.08 0.52 -0.08 0.46 Q-0.28 0.38 -0.3 0.12 Z",fill:e.accent,stroke:e.outline,lw:n*.8});break;case"toothy":{r.push({k:"path",d:"M-1.4 0.1 Q-0.5 0.36 0.5 0.2 Q0.64 0.16 0.68 0.02 Q0.78 0.28 0.52 0.38 Q-0.4 0.78 -1.3 0.26 Z",fill:o,stroke:o,lw:n*.6}),r.push({k:"ellipse",x:-.38,y:.5,rx:.24,ry:.08,fill:Vs});for(let i of[.12,.27,.42,.57,.72,.86]){let u=(1-i)*(1-i)*-1.4+2*(1-i)*i*-.5+i*i*.5,c=(1-i)*(1-i)*.1+2*(1-i)*i*.36+i*i*.2-.01;r.push({k:"path",d:Q(se(u-.08,c,u+.08,c,u,c+.14),.3),fill:ie})}for(let i of[.3,.7]){let u=(1-i)*(1-i)*.52+2*(1-i)*i*-.4+i*i*-1.3,c=(1-i)*(1-i)*.38+2*(1-i)*i*.78+i*i*.26+.01;r.push({k:"path",d:Q(se(u-.07,c,u+.07,c,u,c-.12),.3),fill:ie})}break}case"jaws":{r.push({k:"path",d:"M-0.5 0.3 Q0 0.5 0.5 0.3 Q0.38 0.72 0 0.72 Q-0.38 0.72 -0.5 0.3 Z",fill:o,stroke:o,lw:n*.5});for(let i of[-.34,-.17,0,.17,.34]){let u=.3+.4*(i+.5)*(.5-i)-.01;r.push({k:"path",d:Q(se(i-.075,u,i+.075,u,i,u+.13),.15),fill:ie})}break}}return r}var vt=(s,n)=>({x:Math.sin(s)*n,y:-Math.cos(s)*n});var Ks=.5,We={leftEye:2,rightEye:5,leftEar:7,rightEar:8},nt={"3-5":{head:.75,neck:.74,arm:.3,leg:.36,hand:.19,foot:1.2,shoulderMin:.4,shoulderPad:.07,hipMin:.5,hipPad:.22,bottom:.26,bulge:1.12,armsOverHead:!0},"6-8":{head:.6,neck:.78,arm:.22,leg:.28,hand:.15,foot:1,shoulderMin:.34,shoulderPad:.04,hipMin:.4,hipPad:.16,bottom:.14,bulge:1.04,armsOverHead:!1},"9-12":{head:.5,neck:.92,arm:.17,leg:.21,hand:.125,foot:.9,shoulderMin:.36,shoulderPad:.07,hipMin:.32,hipPad:.08,bottom:.1,bulge:1,armsOverHead:!1}},Hn="6-8",Gn=(s,n)=>n!==void 0&&s.band!=="all"&&s.alsoIn?.includes(n)&&n in nt?n:s.band in nt?s.band:Hn,ki=nt[Hn].head,Qs=.3,Zs=.12,wi=.9,Xs=.5,js=.65,vi=.35,Ai=.2,Si=.25,$e=(s,n)=>({x:s.x-n.x,y:s.y-n.y}),te=(s,n)=>({x:s.x+n.x,y:s.y+n.y}),Z=(s,n)=>({x:s.x*n,y:s.y*n}),At=s=>Math.hypot(s.x,s.y),qs=(s,n)=>({x:(s.x+n.x)/2,y:(s.y+n.y)/2}),$n=s=>{let n=At(s);return n>1e-9?{x:s.x/n,y:s.y/n}:{x:0,y:1}},Mi=(...s)=>s.every(Number.isFinite),Ti=s=>Math.atan2(Math.sin(s),Math.cos(s)),Ei=(s,n,e)=>Math.min(Math.max(s,n),e);function Js(s,n,e=!1){return t=>{let r=s[t*3],o=s[t*3+1],a=s[t*3+2];return r===void 0||o===void 0||a===void 0||!Mi(r,o,a)?{x:0,y:0,ok:!1}:{x:n.x+(e?1-r:r)*n.w,y:n.y+o*n.h,ok:a>=Ks}}}function Dt(s,n,e={}){let t=Js(s,n,e.mirrored),r=t(z.leftShoulder),o=t(z.rightShoulder);if(!r.ok||!o.ok)return null;let a=t(z.leftHip),i=t(z.rightHip),u=qs(r,o),c=At($e(o,r)),l=a.ok&&i.ok,f=$n($e(o,r));c<1e-6&&(f={x:1,y:0});let h,m,b;if(l){let M=qs(a,i);m=At($e(M,u)),m>=c*Si?h=$n($e(M,u)):(h={x:-f.y,y:f.x},h.y<0&&(h=Z(h,-1))),b=Math.max(m,c*1.15)}else h={x:-f.y,y:f.x},h.y<0&&(h=Z(h,-1)),b=c*1.15,m=b;b=Math.max(b,1e-6);let y={x:h.y,y:-h.x},d=Math.atan2(y.y,y.x),x=Z(h,-1),g=nt[e.band??Hn]??nt[Hn],v=g.head*b,w=te(u,Z(x,v*g.neck)),T=t(z.nose);if(T.ok){let M=te(T,Z(x,v*.15)),P=Z($e(M,w),vi),L=Math.min(1,v*Ai/Math.max(At(P),1e-6));w=te(w,Z(P,L))}return{S:u,r:y,d:h,U:b,L:m,hipsOk:l,head:w,headR:v,headRot:d+Ri(s,t,d,b),angle:d}}function Ri(s,n,e,t){let r=[[We.leftEar,We.rightEar],[We.leftEye,We.rightEye]];for(let[o,a]of r){let i=n(o),u=n(a);if(!i.ok||!u.ok||!(s[o*3+2]>=js&&s[a*3+2]>=js)||At($e(u,i))<t*.05)continue;let c=Ti(Math.atan2(u.y-i.y,u.x-i.x)-e),l=Math.max(Math.abs(c)-Zs,0),f=Ei((wi+Xs-Math.abs(c))/Xs,0,1);return Math.sign(c)*Math.min(l,Qs)*f}return 0}function dn(s,n,e,t={}){let r=Gn(n,t.band),o=nt[r],a=Dt(s,e,{...t,band:r});if(!a)return[];let i=Js(s,e,t.mirrored),u=n.palette,{S:c,r:l,d:f,U:h,L:m}=a,b=A=>n.bodyExtras.includes(A),y=Math.max(1.2,h*.045),d={stroke:u.outline,lw:y},x=(A,O)=>({x:c.x+l.x*A+f.x*O,y:c.y+l.y*A+f.y*O}),g=A=>A.map(([O,N])=>x(O,N)),v=i(z.leftShoulder),w=i(z.rightShoulder),T=i(z.leftHip),M=i(z.rightHip),P=At($e(w,v)),L=a.hipsOk?At($e(M,T)):P*.7,F=Math.max(P/2+o.shoulderPad*h,o.shoulderMin*h),B=Math.max(L/2+o.hipPad*h,o.hipMin*h),G=-.1*h,W=m+o.bottom*h,H=[],me=[],U=[],oe=[],ye=[],De=(A,O,N,q)=>{let j=O.flatMap(ae=>[ae.x,ae.y]);A.push({k:"line",pts:j,stroke:u.outline,lw:N+y*2}),A.push({k:"line",pts:j,stroke:q,lw:N})},mr=o.leg*h*(b("strong-legs")?1.3:1),ke=o.arm*h*(b("tiny-arms")?.6:1),Be=Math.max(o.arm/.22,.9);if(a.hipsOk)for(let[A,O,N,q]of[[T,z.leftKnee,z.leftAnkle,-1],[M,z.rightKnee,z.rightAnkle,1]]){let j=i(O),ae=i(N);if(!j.ok)continue;let Ze=te(A,Z(f,-.12*h)),Ce=ae.ok?[Ze,j,ae]:[Ze,j];De(me,Ce,mr,u.limbs),b("joints")&&me.push({k:"circle",x:j.x,y:j.y,r:.15*h*Be,fill:u.accent,...d}),ae.ok&&me.push(...Pi(n,ae,a,q,y,o.foot))}for(let[A,O,N,q]of[[v,z.leftElbow,z.leftWrist,-1],[w,z.rightElbow,z.rightWrist,1]]){let j=i(O),ae=i(N);if(b("pauldrons")){let Fe=te(A,Z(f,.02*h));oe.push({k:"ellipse",x:Fe.x,y:Fe.y,rx:.25*h,ry:.17*h,rot:a.angle+q*.25,fill:u.body,...d});let Pe=te(Fe,Z(f,.05*h));oe.push({k:"ellipse",x:Pe.x,y:Pe.y,rx:.17*h,ry:.07*h,rot:a.angle+q*.25,fill:u.belly})}if(!j.ok)continue;let Ce=o.armsOverHead&&(j.x-c.x)*f.x+(j.y-c.y)*f.y<-.25*h?ye:oe,an=te(A,Z(f,.04*h));if(De(Ce,ae.ok?[an,j,ae]:[an,j],ke,u.limbs),b("joints")&&Ce.push({k:"circle",x:j.x,y:j.y,r:.13*h*Be,fill:u.accent,...d}),!ae.ok)continue;let we=$n($e(ae,j)),Je=te(ae,Z(we,.05*h));if(b("feathers"))for(let Fe of[-.55,0,.55]){let Pe=Math.cos(Fe),et=Math.sin(Fe)*q,_e={x:we.x*Pe-we.y*et,y:we.x*et+we.y*Pe},bt=te(Je,Z(_e,.16*h));Ce.push({k:"ellipse",x:bt.x,y:bt.y,rx:.2*h,ry:.09*h,rot:Math.atan2(_e.y,_e.x),fill:u.hands??u.accent,...d})}b("wand")&&q===1&&!t.portrait&&Ce.push(...Oi(n,Je,$n(te(Z(we,.4),$e(Z(l,.6),f))),h,y));let Ve=o.hand*h*(b("tiny-arms")?.72:1);if(b("tiny-arms"))for(let Fe of[-.45,.45]){let Pe=Math.cos(Fe),et=Math.sin(Fe),_e={x:we.x*Pe-we.y*et,y:we.x*et+we.y*Pe},bt=te(Je,Z(_e,Ve*.75)),yr=te(Je,Z(_e,Ve*1.6)),xt={x:-_e.y*Ve*.32,y:_e.x*Ve*.32};Ce.push({k:"path",d:Q([te(bt,xt),yr,$e(bt,xt)],.2),fill:u.belly,...d})}Ce.push({k:"circle",x:Je.x,y:Je.y,r:Ve,fill:u.hands??u.limbs,...d})}if(b("wings"))for(let A of[-1,1]){let O=g([[A*F*.5,.05*h],[A*(F+.85*h),-.6*h],[A*(F+.72*h),.05*h],[A*(F+.45*h),-.02*h],[A*(F+.3*h),.32*h],[A*F*.6,.55*h]]);H.push({k:"path",d:Q(O,.18),fill:u.accent,...d})}if(b("wings-fairy")&&H.push(...Ii(n,x,F,h,y)),b("cape")){let A=m+.8*h,O=B+.36*h,N=g([[-F*.92,G+.04*h],[F*.92,G+.04*h],[F+.16*h,m*.5],[O,A],[O*.5,A-.1*h],[0,A],[-O*.5,A-.1*h],[-O,A],[-F-.16*h,m*.5]]);H.push({k:"path",d:K(N,.6),fill:u.accent,...d})}if(b("backpack")){let A=x(0,.35*h);H.push({k:"rect",x:A.x,y:A.y,w:F*2+.34*h,h:.8*h,r:.16*h,rot:a.angle,fill:n.extraColors?.[0]??u.limbs,...d})}if(b("tank")){let A=x(F*.95,.24*h),O=n.extraColors?.[0]??u.accent,N=x(F*.95,-.3*h);H.push({k:"rect",x:N.x,y:N.y,w:.14*h,h:.16*h,r:.04*h,rot:a.angle,fill:u.outline}),H.push({k:"rect",x:A.x,y:A.y,w:.34*h,h:1*h,r:.17*h,rot:a.angle,fill:O,...d})}if(a.hipsOk&&!t.portrait&&H.push(...Li(n,a,B,y)),b("tentacles")&&a.hipsOk)for(let A of[-1,1]){let O=g([[A*B*.7,m*.9],[A*(B+.22*h),m+.3*h],[A*(B+.48*h),m+.22*h],[A*(B+.5*h),m-.02*h],[A*(B+.34*h),m-.06*h]]);H.push({k:"path",d:Nt(O),stroke:u.outline,lw:.2*h+y*2}),H.push({k:"path",d:Nt(O),stroke:u.limbs,lw:.2*h})}let be=Math.max(F,B)*o.bulge;if(b("wool")){for(let[O,N]of[[F*.7,G+.02*h],[be,m*.3],[be*1.02,m*.62],[(be+B)/2,m*.92],[B*.55,W]])for(let q of[-1,1]){let j=x(q*O,N);U.push({k:"circle",x:j.x,y:j.y,r:.2*h,fill:u.body,...d})}let A=x(0,W+.02*h);U.push({k:"circle",x:A.x,y:A.y,r:.2*h,fill:u.body,...d})}if(b("robe")){let A=m+.58*h,O=B*1.4;U.push({k:"path",d:K(g([[-F,G],[0,G-.04*h],[F,G],[be,m*.55],[O,A],[0,A+.06*h],[-O,A],[-be,m*.55]]),.7),fill:u.body,...d});let N=g([[-O*.94,A-.1*h],[0,A-.04*h],[O*.94,A-.1*h]]);U.push({k:"path",d:Nt(N),stroke:n.extraColors?.[0]??u.accent,lw:.07*h})}else if(b("sheet")){let A=m+.78*h,O=B*1.3;U.push({k:"path",d:K(g([[-F,G],[F,G],[be,m*.55],[O,A],[O*.5,A-.2*h],[0,A],[-O*.5,A-.2*h],[-O,A],[-be,m*.55]]),.9),fill:u.body,...d})}else U.push({k:"path",d:K(g([[-F,G],[0,G-.04*h],[F,G],[be,m*.55],[B,W],[0,W+.03*h],[-B,W],[-be,m*.55]]),.85),fill:u.body,...d});let fe=Math.min(F,B);if(b("pocket")){let A=x(0,m*.74);U.push({k:"rect",x:A.x,y:A.y,w:fe*1.3,h:.3*h,r:.1*h,rot:a.angle,fill:u.belly,stroke:u.outline,lw:y*.8})}else if(b("racing-stripe"))for(let A of[-.1,.1]){let O=x(A*h,G+.02*h),N=x(A*h,W-.04*h);U.push({k:"line",pts:[O.x,O.y,N.x,N.y],stroke:u.belly,lw:.1*h})}else if(u.belly&&u.belly!==u.body&&!b("panel")&&!b("sheet")&&!b("stripes")){let A=x(0,m*.58);U.push({k:"ellipse",x:A.x,y:A.y,rx:fe*.64,ry:Math.max(m*.36,.2*h),rot:a.angle,fill:u.belly})}if(b("spots")){let A=n.extraColors?.[1]??u.belly;for(let[O,N,q]of[[-.55,.35,.09],[.5,.62,.11],[-.35,.86,.07]]){let j=x(O*fe,N*m);U.push({k:"circle",x:j.x,y:j.y,r:q*h,fill:A})}}if(b("stripes")){let A=n.extraColors?.[1]??u.accent;for(let O of[.22,.44,.66]){let N=x(-fe*.98,m*O),q=x(fe*.98,m*O);U.push({k:"line",pts:[N.x,N.y,q.x,q.y],stroke:A,lw:.1*h})}}if(b("straps")){let A=n.extraColors?.[1]??u.outline;for(let O of[-1,1]){let N=x(O*F*.62,G+.02*h),q=x(O*fe*.62,m*.72);U.push({k:"line",pts:[N.x,N.y,q.x,q.y],stroke:u.outline,lw:.13*h+y*2}),U.push({k:"line",pts:[N.x,N.y,q.x,q.y],stroke:A,lw:.13*h})}}if(b("belt")){let A=x(0,m*.9);U.push({k:"rect",x:A.x,y:A.y,w:B*1.92,h:.17*h,r:.06*h,rot:a.angle,fill:n.extraColors?.[2]??"#4a3426",...d}),U.push({k:"rect",x:A.x,y:A.y,w:.2*h,h:.19*h,r:.04*h,rot:a.angle,fill:"#ffd84a",...d})}if(b("emblem")){let A=x(0,m*.4),O=n.extraColors?.[0]??u.accent,N=Q([{x:-.22,y:-.2},{x:.22,y:-.2},{x:.22,y:.04},{x:0,y:.26},{x:-.22,y:.04}],.25);U.push({k:"group",x:A.x,y:A.y,rot:a.angle,s:h,items:[{k:"path",d:N,fill:O,stroke:u.outline,lw:y/h},{k:"group",x:0,y:.01,s:.12,items:[{k:"path",d:tt,fill:O===u.accent?"#ffffff":u.accent}]}]})}if(b("panel")){let A=x(0,m*.5);U.push({k:"rect",x:A.x,y:A.y,w:fe*1.2,h:.38*h,r:.1*h,rot:a.angle,fill:"#24323d",...d}),(n.extraColors??["#ff7a6b","#fbd46a","#7ff0ff"]).slice(0,3).forEach((N,q)=>{let j=x((q-1)*fe*.34,m*.5);U.push({k:"circle",x:j.x,y:j.y,r:.075*h,fill:N})})}if(b("badge")){let A=x(-fe*.42,m*.36);U.push({k:"circle",x:A.x,y:A.y,r:.15*h,fill:u.accent,...d}),U.push({k:"group",x:A.x,y:A.y,rot:a.angle,s:.09*h,items:[{k:"path",d:tt,fill:"#ffffff"}]})}if(b("star")){let A=x(-fe*.5,m*.3),O=.15*h;U.push({k:"group",x:A.x,y:A.y,rot:a.angle-.2,s:O,items:[{k:"path",d:tt,fill:n.extraColors?.[0]??"#ffd84a",stroke:u.outline,lw:y*.8/O}]})}if(b("petals")&&U.push(...Ni(n,x,F,B,be,m,W,h,y,o)),b("scarf")){let A=Math.max(.04,o.head*(1-o.neck)-.06)*h,O=x(0,A),N=n.extraColors?.[0]??u.accent,q=x(F*.45,A+.28*h);U.push({k:"rect",x:q.x,y:q.y,w:.16*h,h:.42*h,r:.06*h,rot:a.angle+.15,fill:N,...d}),U.push({k:"rect",x:O.x,y:O.y,w:F*2.05,h:.2*h,r:.1*h,rot:a.angle,fill:N,...d})}let ze={k:"group",x:a.head.x,y:a.head.y,rot:a.headRot,s:a.headR,items:Fi(n,y/a.headR)};return[...H,...me,...U,...oe,ze,...ye]}var Ys=new WeakMap,Ci=64;function Fi(s,n){let e=Number(n.toPrecision(4)),t=Ys.get(s);t||Ys.set(s,t=new Map);let r=t.get(e);return r||(t.size>=Ci&&t.clear(),t.set(e,r=zn(s,e))),r}function Pi(s,n,e,t,r,o){let a=_i(s,n,e,t,r,o);if(!s.bodyExtras.includes("strong-legs"))return[a];let i=e.U*o,u=te(te(n,Z(e.d,.07*i)),Z(e.r,t*.06*i)),c=[a];for(let l of[-1,0,1]){let f=te(te(u,Z(e.r,l*.12*i)),Z(e.d,.09*i));c.push({k:"ellipse",x:f.x,y:f.y,rx:.05*i,ry:.045*i,rot:e.angle,fill:s.palette.belly,stroke:s.palette.outline,lw:r*.8})}return c}function _i(s,n,e,t,r,o){let a=s.palette,{d:i,r:u}=e,c=e.U*o,l=te(te(n,Z(i,.07*c)),Z(u,t*.06*c)),f={stroke:a.outline,lw:r},h=a.feet??a.limbs;if(s.bodyExtras.includes("fins")){let m=Q([{x:-.13,y:-.06},{x:.13,y:-.06},{x:.24,y:.46},{x:-.24,y:.46}],.22);return{k:"group",x:l.x,y:l.y,rot:e.angle,s:c,items:[{k:"path",d:m,fill:h,stroke:a.outline,lw:r/c},{k:"line",pts:[0,.06,0,.38],stroke:a.outline,lw:r/c,alpha:.5}]}}return s.bodyExtras.includes("flippers")?{k:"ellipse",x:l.x,y:l.y,rx:.27*c,ry:.11*c,rot:e.angle,fill:h,...f}:s.bodyExtras.includes("boots")?{k:"rect",x:l.x,y:l.y,w:.4*c,h:.24*c,r:.09*c,rot:e.angle,fill:h,...f}:{k:"ellipse",x:l.x,y:l.y,rx:.2*c,ry:.13*c,rot:e.angle,fill:h,...f}}function Li(s,n,e,t){let r=s.palette,{U:o,L:a,S:i,r:u,d:c}=n,l=(y,d)=>({x:i.x+u.x*y+c.x*d,y:i.y+u.y*y+c.y*d}),f=y=>y.map(([d,x])=>l(d,x)),h={stroke:r.outline,lw:t},m=(y,d,x)=>[{k:"path",d:Nt(y),stroke:r.outline,lw:d+t*2},{k:"path",d:Nt(y),stroke:x,lw:d}],b=[];switch(s.tail){case"none":break;case"fluffy":{let y=f([[e*.5,a*.95],[e+.28*o,a*1],[e+.72*o,a*.62],[e+.78*o,a*.12],[e+.52*o,a*.32],[e+.3*o,a*.6],[e*.6,a*.7]]);b.push({k:"path",d:K(y),fill:r.body,...h});let d=l(e+.72*o,a*.2);b.push({k:"ellipse",x:d.x,y:d.y,rx:.13*o,ry:.2*o,rot:n.angle+.25,fill:r.belly,...h});break}case"brush":{let y=f([[e*.4,a*.98],[e+.42*o,a*1.06],[e+.98*o,a*.66],[e+1.06*o,a*.12],[e+.86*o,-.04*o],[e+.66*o,a*.36],[e+.3*o,a*.66],[e*.5,a*.68]]);b.push({k:"path",d:K(y),fill:r.body,...h});let d=f([[e+1.03*o,a*.36],[e+1.06*o,a*.12],[e+.86*o,-.04*o],[e+.72*o,a*.24],[e+.86*o,a*.34]]);b.push({k:"path",d:K(d),fill:r.belly,...h});break}case"pom":{let y=l(e+.06*o,a*.88);b.push({k:"circle",x:y.x,y:y.y,r:.2*o,fill:r.belly,...h});break}case"long":case"striped":case"tuft":{let y=f([[e*.6,a*.9],[e+.35*o,a*.85],[e+.58*o,a*.4],[e+.5*o,-.02*o]]);if(b.push(...m(y,.14*o,r.body)),s.tail==="tuft"){let d=y[y.length-1];b.push({k:"circle",x:d.x,y:d.y,r:.16*o,fill:s.extraColors?.[0]??r.accent,...h})}if(s.tail==="striped"){for(let x of[.35,.6,.85]){let g=l(e+.35*o+.22999999999999998*o*(x*1.4>1?1:x*1.4),a*(.85-.85*x));b.push({k:"line",pts:[g.x-u.x*.08*o,g.y-u.y*.08*o,g.x+u.x*.08*o,g.y+u.y*.08*o],stroke:s.extraColors?.[0]??r.outline,lw:.06*o})}let d=y[y.length-1];b.push({k:"circle",x:d.x,y:d.y,r:.07*o,fill:s.extraColors?.[0]??r.outline})}break}case"curl":{let y=f([[e*.6,a*.9],[e+.4*o,a*.88],[e+.62*o,a*.45],[e+.5*o,a*.12],[e+.3*o,a*.24],[e+.36*o,a*.42]]);b.push(...m(y,.12*o,r.limbs));break}case"fish":{let y=f([[e*.6,a*.9],[e+.36*o,a*.86],[e+.6*o,a*.5]]);b.push(...m(y,.17*o,r.body));let d=y[y.length-1],x=Q([{x:0,y:.06},{x:-.26,y:-.34},{x:.02,y:-.12},{x:.32,y:-.3}],.2);b.push({k:"group",x:d.x,y:d.y,rot:n.angle+.35,s:o,items:[{k:"path",d:x,fill:r.body,stroke:r.outline,lw:t/o}]});break}case"plume":{let y=s.extraColors??[r.accent];[0,1,2].forEach(d=>{let x=l(e+(.12+d*.13)*o,a+(.32-d*.06)*o);b.push({k:"ellipse",x:x.x,y:x.y,rx:.11*o,ry:.44*o,rot:n.angle-.55+d*.28,fill:y[(d+1)%y.length],...h})});break}case"thick":{let y=f([[e*.3,a*.42],[e+.42*o,a*.62],[e+.92*o,a*.96],[e+1.32*o,a*1.08],[e+1.44*o,a*.98],[e+.98*o,a*1.2],[e+.4*o,a*1.22],[e*.3,a*1.12]]);b.push({k:"path",d:K(y,.8),fill:r.body,...h});let d=s.extraColors?.[0]??r.accent;for(let[x,g,v]of[[.28,.58,.26],[.62,.8,.22],[.96,1,.16]]){let w=l(e+x*o,a*g+.03*o),T=l(e+(x-.1)*o,a*g+v*o);b.push({k:"line",pts:[w.x,w.y,T.x,T.y],stroke:d,lw:.09*o})}break}case"spiky":case"arrow":{let y=f([[e*.3,a*.55],[e+.35*o,a*.68],[e+.95*o,a*.86],[e+.35*o,a*1.08],[e*.3,a*1.08]]);if(s.tail==="spiky"){for(let d of[.15,.45,.72]){let x=e+(.2+d*.7)*o,g=a*(.66+d*.19);b.push({k:"path",d:Q(f([[x-.12*o,g+.05*o],[x,g-.2*o],[x+.12*o,g+.07*o]]),.2),fill:r.accent,...h})}b.push({k:"path",d:K(y,.7),fill:r.body,...h})}else{let d=f([[e*.6,a*.9],[e+.4*o,a*.92],[e+.62*o,a*.5],[e+.62*o,a*.18]]);b.push(...m(d,.13*o,r.body));let x=d[d.length-1];b.push({k:"group",x:x.x,y:x.y,rot:n.angle,s:o,items:[{k:"path",d:Q([{x:-.15,y:.04},{x:0,y:-.22},{x:.15,y:.04}],.2),fill:r.accent,stroke:r.outline,lw:t/o}]})}break}}return b}function Oi(s,n,e,t,r){let o=s.palette,a=te(n,Z(e,-.08*t)),i=te(n,Z(e,.52*t)),u=.2*t;return[{k:"line",pts:[a.x,a.y,i.x,i.y],stroke:o.outline,lw:.06*t+r*2},{k:"line",pts:[a.x,a.y,i.x,i.y],stroke:"#fff3d6",lw:.06*t},{k:"circle",x:i.x,y:i.y,r:.24*t,fill:o.accent,alpha:.28},{k:"group",x:i.x,y:i.y,rot:Math.atan2(e.y,e.x)+Math.PI/2,s:u,items:[{k:"path",d:tt,fill:o.accent,stroke:o.outline,lw:r*.9/u}]}]}function Ii(s,n,e,t,r){let o=s.palette,a=s.extraColors?.[0]??"#cdeeff",i=[];for(let u of[-1,1]){let c=[[[u*e*.3,.12*t],[u*(e+.42*t),-.66*t],[u*(e+1*t),-.74*t],[u*(e+1.02*t),-.18*t],[u*(e+.5*t),.26*t]],[[u*e*.4,.3*t],[u*(e+.6*t),.36*t],[u*(e+.74*t),.78*t],[u*(e+.3*t),.9*t]]];for(let l of c){let f=K(l.map(([y,d])=>n(y,d)),.9);i.push({k:"path",d:f,fill:a,alpha:.6}),i.push({k:"path",d:f,stroke:o.outline,lw:r*.9});let h=l[Math.floor(l.length/2)],m=n(l[0][0],l[0][1]),b=n(l[0][0]+(h[0]-l[0][0])*.75,l[0][1]+(h[1]-l[0][1])*.75);i.push({k:"line",pts:[m.x,m.y,b.x,b.y],stroke:"#ffffff",lw:r*.9,alpha:.85})}for(let[l,f,h]of[[e+.72*t,-.42*t,.075*t],[e+.44*t,-.16*t,.05*t],[e+.5*t,.6*t,.055*t]]){let m=n(u*l,f);i.push({k:"group",x:m.x,y:m.y,s:h,items:[{k:"path",d:tt,fill:"#ffffff"}]})}}return i}function Ni(s,n,e,t,r,o,a,i,u,c){let l=s.palette,f=s.extraColors?.[1]??l.belly,h=[],m=Math.atan2(n(1,0).y-n(0,0).y,n(1,0).x-n(0,0).x),b=5,y=Math.max(t,r*.92)*1.08,d=(o*.8+a)/2,x=[0,4,1,3,2];for(let v of x){let w=v/(b-1)-.5,T=n(w*2*y,d+(.5-Math.abs(w))*.1*i);h.push({k:"ellipse",x:T.x,y:T.y,rx:y*.3,ry:.34*i,rot:m-w*.6,fill:v%2?f:l.body,stroke:l.outline,lw:u})}let g=Math.max(.04,c.head*(1-c.neck)-.04)*i;for(let v of[-1,1,0]){let w=n(v*e*.32,g+(v?0:.05*i));h.push({k:"ellipse",x:w.x,y:w.y,rx:e*.26,ry:.12*i,rot:m+v*.5,fill:v?f:l.body,stroke:l.outline,lw:u*.9})}return h}var Di={nose:[0,-.62],leftShoulder:[-.42,0],rightShoulder:[.42,0],leftElbow:[-.58,.5],rightElbow:[.58,.5],leftWrist:[-.66,.98],rightWrist:[.66,.98],leftHip:[-.27,1],rightHip:[.27,1],leftKnee:[-.31,1.6],rightKnee:[.31,1.6],leftAnkle:[-.33,2.18],rightAnkle:[.33,2.18]};function Bi(s,{cx:n=.5,cy:e=.36,T:t=.18}={}){let r={...Di,...s},o=new Array(Ar*3).fill(0),a=(c,[l,f],h=.99)=>{o[c*3]=n+l*t,o[c*3+1]=e+f*t,o[c*3+2]=h};for(let c of Object.keys(z))a(z[c],r[c]);let i=r.tilt??0,u=(c,l)=>[r.nose[0]+c*Math.cos(i)-l*Math.sin(i),r.nose[1]+c*Math.sin(i)+l*Math.cos(i)];return a(We.leftEye,u(-.1,-.08)),a(We.rightEye,u(.1,-.08)),a(We.leftEar,u(-.22,-.02)),a(We.rightEar,u(.22,-.02)),o}var eo=()=>Bi({});var Cr=Object.freeze({lag:.5,extrapolate:.75,maxExtrapolateMs:50}),Bt=class{constructor(n={}){p(this,"tracks",new Map);p(this,"offset",NaN);p(this,"lastArrival",NaN);p(this,"interval",33);p(this,"lastT",NaN);p(this,"lostMs");p(this,"maxExtrapolateMs");p(this,"lag");p(this,"extrapolate");this.lostMs=n.lostMs??250,this.maxExtrapolateMs=n.maxExtrapolateMs??25,this.lag=no(n.lag,1),this.extrapolate=no(n.extrapolate,.5)}get delayMs(){return this.interval*this.lag}push(n,e,t,r=to()){Number.isFinite(e)||(e=r),this.clock(e,r);let o=this.tracks.get(n);if(!o||e-o.tb>this.lostMs||e<o.tb-this.lostMs||t.length!==o.b.length){this.tracks.set(n,{a:null,ta:e,b:t,tb:e,out:null,outAt:NaN});return}if(t===o.b||e<=o.tb){e===o.tb&&t!==o.b&&(o.b=t,o.out=null);return}o.a=o.b,o.ta=o.tb,o.b=t,o.tb=e,o.out=null}at(n,e=to()){let t=this.tracks.get(n);if(!t)return null;if(!t.a)return t.b;if(t.out&&t.outAt===e)return t.out;let r=e-this.offset-this.interval*this.lag,o=t.tb-t.ta,a=Math.min(o*this.extrapolate,this.maxExtrapolateMs),i=Math.min(Math.max((r-t.ta)/o,0),1+a/o);return t.out=ro(t.a,t.b,i),t.outAt=e,t.out}forget(n){this.tracks.delete(n)}clear(){this.tracks.clear()}clock(n,e){let t=e-n;if(!Number.isFinite(this.offset)||t<this.offset||t>this.offset+1e3?this.offset=t:Number.isFinite(this.lastArrival)&&(this.offset+=Math.min(t-this.offset,(e-this.lastArrival)/1e3)),this.lastArrival=e,Number.isFinite(this.lastT)&&n>this.lastT){let r=n-this.lastT;r<this.interval*3+20&&(this.interval+=(Math.min(Math.max(r,8),100)-this.interval)*.1)}n<=this.lastT||(this.lastT=n)}},to=()=>globalThis.performance?.now()??Date.now(),no=(s,n)=>typeof s=="number"&&Number.isFinite(s)?Math.min(Math.max(s,0),1):n;function ro(s,n,e){let t=n.slice(),r=e<.5?s:n;for(let o=0;o+2<n.length;o+=3){let a=s[o],i=s[o+1],u=n[o],c=n[o+1];s[o+2]>=.5&&n[o+2]>=.5&&Math.abs(u-a)+Math.abs(c-i)<.15?(t[o]=a+(u-a)*e,t[o+1]=i+(c-i)*e,t[o+2]=s[o+2]+(n[o+2]-s[o+2])*Math.min(e,1)):(t[o]=r[o],t[o+1]=r[o+1],t[o+2]=r[o+2])}return t}var fc=Tr.map(s=>s.id);var Un=new Map(Tr.map(s=>[s.id,s])),St=Un.get("fox"),oo=s=>typeof s=="string"&&Un.has(s),zt=s=>Un.get(s);var Hi=s=>typeof s=="string"?Un.get(s)??St:s;function ao(s,n,e){let t=Hi(s),r=eo(),o=Gn(t,e),a=Dt(r,{x:0,y:0,w:1,h:1},{band:o}),i=co(zn(t,.05)),u=-i.minY,c=Math.min(.27,.43/Math.max(u,1))*n,l=t.head==="snout-long"?(i.minX+i.maxX)/2*c:0,f=c/nt[o].head/a.U,h=.5*n+Math.min(0,(u-1.6)*.06*n),m={x:n/2-l-a.head.x*f,y:h-a.head.y*f,w:f,h:f};return dn(r,t,m,{portrait:!0,band:o})}function io(s,n,e=.5){if(!s||s.length!==n.length)return n.slice();let t=n.slice();for(let r=0;r+2<n.length;r+=3){let o=s[r+2],a=n[r+2],i=o>=.5,u=a>=.5;i&&a>=.3&&(t[r+2]=Math.max(a,.5));let c=Math.hypot(n[r]-s[r],n[r+1]-s[r+1]);if(i&&u&&c<.15){let l=e*Math.min(1,so+(1-so)*c/$i);t[r]=s[r]+(n[r]-s[r])*l,t[r+1]=s[r+1]+(n[r+1]-s[r+1])*l}else i&&!u&&t[r+2]>=.5&&(t[r]=s[r],t[r+1]=s[r+1])}return Vi(s,n,t,e*Gi),t}var lo=.8,so=.1,$i=.03,Gi=.35,Ui=11;function Vi(s,n,e,t){let r=z.leftShoulder*3,o=z.rightShoulder*3,a=(f,h)=>f[h+2]>=.5;if(!a(s,r)||!a(s,o)||!a(n,r)||!a(n,o))return;let i=(f,h)=>(f[r+h]+f[o+h])/2,u=[i(s,0),i(s,1)],c=[i(n,0),i(n,1)],l=[i(e,0),i(e,1)];for(let f=0;f<Ui&&f*3+2<n.length;f++){let h=f*3;if(!a(s,h)||!a(n,h))continue;let m=[s[h]-u[0],s[h+1]-u[1]],b=[n[h]-c[0],n[h+1]-c[1]];Math.hypot(b[0]-m[0],b[1]-m[1])>=.15||(e[h]=l[0]+m[0]+(b[0]-m[0])*t,e[h+1]=l[1]+m[1]+(b[1]-m[1])*t)}}function co(s){let n={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},e=(t,r)=>{n.minX=Math.min(n.minX,t),n.minY=Math.min(n.minY,r),n.maxX=Math.max(n.maxX,t),n.maxY=Math.max(n.maxY,r)};for(let t of s){let r="lw"in t&&t.stroke?(t.lw??1)/2:0;switch(t.k){case"circle":e(t.x-t.r-r,t.y-t.r-r),e(t.x+t.r+r,t.y+t.r+r);break;case"ellipse":case"rect":{let o=t.k==="ellipse"?t.rx:t.w/2,a=t.k==="ellipse"?t.ry:t.h/2,i=Math.max(o,a)+r;e(t.x-i,t.y-i),e(t.x+i,t.y+i);break}case"path":{let o=Er(t.d);for(let a=0;a+1<o.length;a+=2)e(o[a]-r,o[a+1]-r),e(o[a]+r,o[a+1]+r);break}case"line":for(let o=0;o+1<t.pts.length;o+=2)e(t.pts[o]-r,t.pts[o+1]-r),e(t.pts[o]+r,t.pts[o+1]+r);break;case"group":{let o=co(t.items);if(!Number.isFinite(o.minX))break;let a=t.s??1,i=Math.cos(t.rot??0),u=Math.sin(t.rot??0);for(let[c,l]of[[o.minX,o.minY],[o.maxX,o.minY],[o.minX,o.maxY],[o.maxX,o.maxY]])e(t.x+(c*i-l*u)*a,t.y+(c*u+l*i)*a);break}}}return n}var rt=()=>Float64Array.of(1,0,0,1,0,0);function Se(s,n,e,t,r,o,a){let i=r?Math.cos(r):1,u=r?Math.sin(r):0,c=i*o,l=u*o,f=-u*a,h=i*a;if(!n)return s[0]=c,s[1]=l,s[2]=f,s[3]=h,s[4]=e,s[5]=t,s;let m=n[0],b=n[1],y=n[2],d=n[3];return s[0]=m*c+y*l,s[1]=b*c+d*l,s[2]=m*f+y*h,s[3]=b*f+d*h,s[4]=m*e+y*t+n[4],s[5]=b*e+d*t+n[5],s}function ho(s,n,e){let t=s[0]*s[3]-s[1]*s[2];if(Math.abs(t)<1e-12)return null;let r=n-s[4],o=e-s[5];return[(s[3]*r-s[2]*o)/t,(-s[1]*r+s[0]*o)/t]}var uo={white:16777215,black:0,red:16711680,transparent:0},mn=new Map;function de(s){if(typeof s=="number")return[s&16777215,1];let n=mn.get(s);if(n)return n;let e=[16777215,1],t=s.trim().toLowerCase();if(t[0]==="#"){let r=t.slice(1),o=r.length<=4?[...r].map(i=>i+i).join(""):r,a=parseInt(o.slice(0,6),16);Number.isFinite(a)&&(e=[a,o.length===8?parseInt(o.slice(6,8),16)/255:1])}else if(t.startsWith("rgb")){let r=t.match(/-?\d*\.?\d+%?/g)?.map(c=>c.endsWith("%")?parseFloat(c)/100*255:parseFloat(c))??[],[o=255,a=255,i=255]=r,u=r[3]===void 0?1:t.match(/,\s*[\d.]+%\s*\)$/)?r[3]/255:r[3];e=[(Fr(o)<<16|Fr(a)<<8|Fr(i))>>>0,Math.min(Math.max(u,0),1)]}else if(t in uo)e=[uo[t],t==="transparent"?0:1];else if(typeof document<"u"){let r=document.createElement("canvas").getContext("2d");if(r){r.fillStyle="#ffffff",r.fillStyle=t;let o=r.fillStyle;if(o!==t)return mn.set(s,e=de(o)),e}}return mn.size>512&&mn.clear(),mn.set(s,e),e}var Fr=s=>Math.min(Math.max(Math.round(s),0),255);function ut(s,n,e=!1){let t=Math.min(Math.max(n,0),1),r=(s>>16&255)*t,o=(s>>8&255)*t,a=(s&255)*t,i=e?0:t*255;return(Math.round(i)<<24|Math.round(a)<<16|Math.round(o)<<8|Math.round(r))>>>0}var Mt=(s,n=1)=>`rgba(${s>>16&255},${s>>8&255},${s&255},${n})`;function Pr(s,n){if(s===16777215)return n;if(n===16777215)return s;let e=t=>Math.round((s>>t&255)*(n>>t&255)/255);return(e(16)<<16|e(8)<<8|e(0))>>>0}var ht={linear:s=>s,quadIn:s=>s*s,quadOut:s=>s*(2-s),quadInOut:s=>s<.5?2*s*s:-1+(4-2*s)*s,cubicOut:s=>1-(1-s)**3,sineInOut:s=>-(Math.cos(Math.PI*s)-1)/2,backOut:s=>1+(1.70158+1)*(s-1)**3+1.70158*(s-1)**2,elasticOut:s=>s===0||s===1?s:2**(-10*s)*Math.sin((s*10-.75)*(2*Math.PI/3))+1,bounceOut:s=>s<1/2.75?7.5625*s*s:s<2/2.75?7.5625*(s-=1.5/2.75)*s+.75:s<2.5/2.75?7.5625*(s-=2.25/2.75)*s+.9375:7.5625*(s-=2.625/2.75)*s+.984375};function fo(s){let n=s>>>0;return()=>{n=n+1831565813>>>0;let e=n;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}var E={cap:0,epoch:0,x:new Float64Array(0),y:new Float64Array(0),rot:new Float64Array(0),sx:new Float64Array(0),sy:new Float64Array(0),alpha:new Float64Array(0),la:new Float64Array(0),lb:new Float64Array(0),lc:new Float64Array(0),ld:new Float64Array(0),world:new Float64Array(0),tint:new Uint32Array(0),flags:new Uint8Array(0),moved:new Uint8Array(0),dirty:new Uint8Array(0),gen:new Uint32Array(0),parent:new Int32Array(0),first:new Int32Array(0),next:new Int32Array(0),prev:new Int32Array(0),stamp:new Uint32Array(0),pass:0,free:new Int32Array(0),freeHead:0,freeCount:0,top:2},ft=[],Wi="x y rot sx sy alpha la lb lc ld world tint flags moved dirty gen parent first next prev stamp".split(" ");function po(s){let n=E;for(let t of Wi){let r=n[t],o=new r.constructor(t==="world"?s*6:s);o.set(r),n[t]=o}let e=new Int32Array(s);for(let t=0;t<E.freeCount;t++)e[t]=E.free[(E.freeHead+t)%E.cap];for(E.free=e,E.freeHead=0,E.cap=s,E.epoch++;ft.length<s;)ft.push(null)}function Lr(s){E.x[s]=E.y[s]=E.rot[s]=0,E.sx[s]=E.sy[s]=E.alpha[s]=1,E.la[s]=E.ld[s]=1,E.lb[s]=E.lc[s]=0;let n=s*6,e=E.world;e[n]=e[n+3]=1,e[n+1]=e[n+2]=e[n+4]=e[n+5]=0,E.tint[s]=16777215,E.flags[s]=3,E.moved[s]=1,E.dirty[s]=0,E.parent[s]=E.first[s]=E.next[s]=E.prev[s]=-1}po(256);Lr(0);E.flags[0]=0;Lr(1);E.flags[1]=0;function mo(){let s;if(E.freeCount){s=E.free[E.freeHead],E.freeHead=(E.freeHead+1)%E.cap,E.freeCount--;let n=ft[s];n&&(n._i=0,n._g=-1,ft[s]=null)}else E.top===E.cap&&po(E.cap*2),s=E.top++;return Lr(s),s}function Or(s,n){Vn(s);for(let t=E.first[s];t>=0;){let r=E.next[t];E.parent[t]=E.next[t]=E.prev[t]=-1,t=r}E.first[s]=-1,E.flags[s]=E.flags[s]&-3,E.moved[s]=0;let e=E.gen[s]+1;E.gen[s]=e,e!==4294967295&&(n&&(ft[s]=n),E.free[(E.freeHead+E.freeCount)%E.cap]=s,E.freeCount++)}function yo(s){for(let n=0;n<ft.length;n++){let e=ft[n];e&&s(e)&&(e._i=0,e._g=-1,ft[n]=null)}}function bo(s,n){Vn(s);let e=E.first[n];E.parent[s]=n,E.next[s]=e,E.prev[s]=-1,e>=0&&(E.prev[e]=s),E.first[n]=s,E.moved[s]=1}function Vn(s){let n=E.parent[s];if(n<0)return;let e=E.next[s],t=E.prev[s];t>=0?E.next[t]=e:E.first[n]=e,e>=0&&(E.prev[e]=t),E.parent[s]=E.next[s]=E.prev[s]=-1}var yn={root:-1,gen:-1,world:new Float64Array(6)};function xo(s){let n=++E.pass,e=E.world,t=s*6,r=yn.world,o=yn.root!==s||yn.gen!==E.gen[s];for(let a=0;a<6;a++)r[a]!==e[t+a]&&(o=!0),r[a]=e[t+a];yn.root=s,yn.gen=E.gen[s],E.stamp[s]=o?n:n-1}function go(s){E.stamp[s]=E.pass}function ko(s){for(let n=E.first[s];n>=0;){let e=E.next[n];ko(n),n=e}Or(s)}var _r=typeof FinalizationRegistry=="function"?new FinalizationRegistry(s=>E.gen[s.i]===s.g&&ko(s.i)):null;function Ir(s){s._reg||!_r||(s._reg=!0,_r.register(s,{i:s._i,g:s._g},s))}function wo(s){s._reg&&_r.unregister(s)}function bn(s){if(s){for(let n=0;n<s.length;n++)if(s[n].enabled)return!0}return!1}function vo(s,n){let e=0;for(let t=0;t<s.length;t++){let r=s[t];r.enabled&&r.pad&&(e+=r.pad(n))}return e}var Me={gl:null,c2d:null,live:null};var Y=new Float64Array(3),xn=4,Xi=1,gn=()=>Xi++;var le=rt(),_=E,Ie=class{constructor(n){p(this,"kernel",n);p(this,"_i",mo());p(this,"_g",_.gen[this._i]);p(this,"_wv",null);p(this,"_wi",-1);p(this,"_we",-1);p(this,"blend","normal");p(this,"_data",null);p(this,"parent",null);p(this,"hitRadius",null);p(this,"clip",null);p(this,"mask",null);p(this,"filters",null);p(this,"_z",0);p(this,"anchorX",0);p(this,"anchorY",0);p(this,"_pool",null);p(this,"_free",!1);p(this,"_reg",!1)}get x(){return _.x[this._i]}set x(n){let e=this._i||1;_.x[e]=n,_.moved[e]=1}get y(){return _.y[this._i]}set y(n){let e=this._i||1;_.y[e]=n,_.moved[e]=1}get rotation(){return _.rot[this._i]}set rotation(n){let e=this._i||1;_.rot[e]=n,_.dirty[e]=_.moved[e]=1}get scaleX(){return _.sx[this._i]}set scaleX(n){let e=this._i||1;_.sx[e]=n,_.dirty[e]=_.moved[e]=1}get scaleY(){return _.sy[this._i]}set scaleY(n){let e=this._i||1;_.sy[e]=n,_.dirty[e]=_.moved[e]=1}get alpha(){return _.alpha[this._i]}set alpha(n){let e=this._i||1;_.alpha[e]=n,_.moved[e]=1}get visible(){return(_.flags[this._i]&1)!==0}set visible(n){let e=this._i||1;n?_.flags[e]=_.flags[e]|1:_.flags[e]=_.flags[e]&-2,_.moved[e]=1}get destroyed(){return _.gen[this._i]!==this._g}get world(){let n=this._i||1;return(this._wi!==n||this._we!==_.epoch)&&(this._wv=_.world.subarray(n*6,n*6+6),this._wi=n,this._we=_.epoch),this._wv}get data(){return this._data??(this._data={})}set data(n){this._data=n}get scale(){return this.scaleX}set scale(n){this.scaleX=this.scaleY=n}get z(){return this._z}set z(n){n!==this._z&&(this._z=n,this.parent&&(this.parent.sortDirty=!0))}get tint(){return _.tint[this._i]}set tint(n){_.tint[this._i||1]=typeof n=="number"?n&16777215:de(n)[0]}set anchor(n){typeof n=="number"?this.anchorX=this.anchorY=n:(this.anchorX=n.x,this.anchorY=n.y)}get width(){return 0}set width(n){}get height(){return 0}set height(n){}set(n){for(let e in n){let t=n[e];t!==void 0&&(this[e]=t)}return this}destroy(){this.destroyed||(this.visible=!1,this.parent&&(this.parent.dead=!0,this.parent=null),Or(this._i,this),wo(this),this.kernel.tweens.stopAll(this),this._pool?.forget(this))}updateWorld(){let n=this.parent?this.parent.updateWorld():null;return Se(this.world,n,this.x,this.y,this.rotation,this.scaleX,this.scaleY)}draw(n,e,t){}};function To(s){yo(n=>n.kernel===s)}var Nr=!1,Ao=Object.freeze([]),Rt=class s extends Ie{constructor(e){super(e);p(this,"children",Ao);p(this,"sortDirty",!1);p(this,"dead",!1);Ir(this)}add(e,...t){this.adopt(e);for(let r=0;r<t.length;r++)this.adopt(t[r]);return e}adopt(e){e.parent&&e.parent.detach(e),e.parent=this,!e.destroyed&&!this.destroyed&&bo(e._i,this._i),this.children===Ao&&(this.children=[]),this.children.push(e),(e.z!==0||this.sortDirty)&&(this.sortDirty=!0)}remove(e){this.detach(e),e._pool||Ir(e)}detach(e){let t=this.children,r=t.indexOf(e);if(r>=0){for(let o=r+1;o<t.length;o++)t[o-1]=t[o];t.pop()}e.parent===this&&(e.parent=null,e.destroyed||Vn(e._i))}clear(){for(let e of this.children)e.destroy()}destroy(){for(let e of this.children)e.destroy();super.destroy()}sweep(){if(this.dead){this.dead=!1;let e=0;for(let t of this.children)t.destroyed?t.parent===this&&(t.parent=null):this.children[e++]=t;this.children.length=e}for(let e of this.children)e instanceof s&&e.sweep()}draw(e,t,r){if(Nr)return _.parent[this._i]<0&&!this.destroyed&&go(this._i),this.drawChildren(e,t,r);Nr=!0;try{this.destroyed||xo(this._i),this.drawChildren(e,t,r)}finally{Nr=!1}}drawChildren(e,t,r){if(this.sortDirty){let u=new Map(this.children.map((c,l)=>[c,l]));this.children.sort((c,l)=>c.z-l.z||u.get(c)-u.get(l)),this.sortDirty=!1}let o=this.children,a=this._i,i=_.stamp[a]===_.pass;for(let u=0;u<o.length;u++){let c=o[u],l=c._i,f=_.alpha[l];if(_.gen[l]!==c._g||!(_.flags[l]&1)||f<=0)continue;if(i||_.moved[l]){_.moved[l]=0,_.stamp[l]=_.pass;let b,y,d,x;if(_.dirty[l]){_.dirty[l]=0;let G=_.rot[l],W=G?Math.cos(G):1,H=G?Math.sin(G):0,me=_.sx[l],U=_.sy[l];_.la[l]=b=W*me,_.lb[l]=y=H*me,_.lc[l]=d=-H*U,_.ld[l]=x=W*U}else b=_.la[l],y=_.lb[l],d=_.lc[l],x=_.ld[l];let g=_.world,v=_.x[l],w=_.y[l],T=l*6,M=a*6,P=g[M],L=g[M+1],F=g[M+2],B=g[M+3];g[T]=P*b+F*y,g[T+1]=L*b+B*y,g[T+2]=P*d+F*x,g[T+3]=L*d+B*x,g[T+4]=P*v+F*w+g[M+4],g[T+5]=L*v+B*w+g[M+5]}let h=t*f,m=Pr(r,_.tint[l]);c.clip||c.mask||c.filters?Eo(e,c,h,m):c.draw(e,h,m)}}},xe=new Float64Array(128),Tt=0,Dr=new Float64Array(8);function Br(s,n,e,t){n.clip||n.mask||n.filters?Eo(s,n,e,t):n.draw(s,e,t)}function Eo(s,n,e,t){let r=s.r,o=n.world,a=n.clip,i=!1,u=!1;if(a)if(Math.abs(o[1])<1e-9&&Math.abs(o[2])<1e-9&&Tt<32){let f=o[0]*a.x+o[4],h=o[0]*(a.x+a.width)+o[4],m=o[3]*a.y+o[5],b=o[3]*(a.y+a.height)+o[5],y=Math.min(f,h),d=Math.max(f,h),x=Math.min(m,b),g=Math.max(m,b);if(Tt){let w=(Tt-1)*4;y=Math.max(y,xe[w]),x=Math.max(x,xe[w+1]),d=Math.min(d,xe[w+2]),g=Math.min(g,xe[w+3])}let v=Tt++*4;xe[v]=y,xe[v+1]=x,xe[v+2]=d,xe[v+3]=g,r.clip(y,x,Math.max(d-y,0),Math.max(g-x,0)),u=!0}else i=!0;let c=n.mask&&n.mask.visible?n.mask:null,l=bn(n.filters)?n.filters:null;try{if(i&&r.beginLayer(),c&&r.beginLayer(),l?(n.draw(s,r.beginLayer()?1:e,t),r.endLayer(e,l)):n.draw(s,e,t),c&&(r.beginMask(),Se(c.world,o,c.x,c.y,c.rotation,c.scaleX,c.scaleY),Br(s,c,c.alpha,16777215),r.endLayer(1)),i&&a){r.beginMask();for(let f=0;f<4;f++){let h=f===1||f===2?a.x+a.width:a.x,m=f>1?a.y+a.height:a.y;Dr[f*2]=o[0]*h+o[2]*m+o[4],Dr[f*2+1]=o[1]*h+o[3]*m+o[5]}r.polygon(Dr,4,16777215,1),r.endLayer(1)}}finally{if(u)if(Tt--,Tt){let f=(Tt-1)*4;r.clip(xe[f],xe[f+1],xe[f+2]-xe[f],xe[f+3]-xe[f+1])}else r.unclip()}}var Te=class extends Ie{constructor(e,t,r){super(e);p(this,"_frame",null);p(this,"_w",null);p(this,"_h",null);p(this,"slice",0);p(this,"autoAnchor",!0);p(this,"frameName",null);t&&(this.frame=t),r?.anchor===void 0&&this.useFrameAnchor(),r&&this.set(r)}get frame(){return this._frame}set frame(e){this.frameName=typeof e=="string"?e:null,this._frame=typeof e=="string"?this.kernel.frame(e):e,this.autoAnchor&&this.useFrameAnchor()}set anchor(e){this.autoAnchor=!1,super.anchor=e}get naturalWidth(){let e=this.frameNow();return e?(e.sw??e.w)/e.scale-e.margin*2:0}get naturalHeight(){let e=this.frameNow();return e?(e.sh??e.h)/e.scale-e.margin*2:0}get width(){return this._w??this.naturalWidth}set width(e){this._w=e}get height(){return this._h??this.naturalHeight}set height(e){this._h=e}sizeQ(e){Gt[0]=this._w??(e.sw??e.w)/e.scale-e.margin*2,Gt[1]=this._h??(e.sh??e.h)/e.scale-e.margin*2}frameNow(){return this.frameName&&!this.kernel.atlas.valid(this._frame)&&(this._frame=this.kernel.frame(this.frameName)),this._frame}useFrameAnchor(){let e=this._frame;if(!e)return;let t=(e.sw??e.w)/e.scale-e.margin*2,r=(e.sh??e.h)/e.scale-e.margin*2;this.anchorX=t>0?(e.ox-e.margin)/t:0,this.anchorY=r>0?(e.oy-e.margin)/r:0}draw(e,t,r){let o=this.frameNow();if(!o)return;let a=Gt;this.sizeQ(o),a[2]=this.anchorX,a[3]=this.anchorY,a[4]=t,ji(e,o,this.world,this.slice,r,this.blend)}},Ht=new Float64Array(12),$t=new Float64Array(12),kn={x:0,y:0,w:0,h:0};function So(s,n,e,t,r,o){n=Math.max(n,0),e=Math.max(e,0),t=Math.max(t,0);let a=e+t>r?e*r/(e+t):e,i=e+t>r?t*r/(e+t):t,u=a/o,c=i/o;if(u+c>n){let l=n/(u+c);u*=l,c*=l}s[0]=0,s[1]=u,s[2]=0,s[3]=a,s[4]=u,s[5]=n-u-c,s[6]=a,s[7]=r-a-i,s[8]=n-c,s[9]=c,s[10]=r-i,s[11]=i}var Gt=new Float64Array(5);function ji(s,n,e,t,r,o){let a=Gt,i=a[0],u=a[1],c=a[2],l=a[3],f=a[4],h=s.tex(n.surface),m=t===0?n.slice??0:t;if(m===0){let w=(n.sw??n.w)/n.scale-n.margin*2,T=(n.sh??n.h)/n.scale-n.margin*2,M=w>0?i/w:1,P=T>0?u/T:1,L=-c*i+((n.tx??0)/n.scale-n.margin)*M,F=-l*u+((n.ty??0)/n.scale-n.margin)*P;wn(e,L,F),Y[0]=n.w/n.scale*M,Y[1]=n.h/n.scale*P,Y[2]=f,s.r.quadQ(h,n,le,r,o);return}let b=n.tx??0,y=n.ty??0,d=(n.sw??n.w)-n.w-b,x=(n.sh??n.h)-n.h-y,g=-c*i-n.margin+b/n.scale,v=-l*u-n.margin+y/n.scale;if(So(Ht,i+n.margin*2-(b+d)/n.scale,(typeof m=="number"?m:m[3])-b,(typeof m=="number"?m:m[1])-d,n.w,n.scale),So($t,u+n.margin*2-(y+x)/n.scale,(typeof m=="number"?m:m[0])-y,(typeof m=="number"?m:m[2])-x,n.h,n.scale),wn(e,g,v),Y[2]=f,!s.r.nineQ?.(h,n,Ht,$t,le,r,o))for(let w=0;w<12;w+=4){let T=$t[w+1],M=$t[w+3];if(!(T<=0||M<=0))for(let P=0;P<12;P+=4){let L=Ht[P+1],F=Ht[P+3];L<=0||F<=0||(kn.x=n.x+Ht[P+2],kn.y=n.y+$t[w+2],kn.w=F,kn.h=M,wn(e,g+Ht[P],v+$t[w]),Y[0]=L,Y[1]=T,Y[2]=f,s.r.quadQ(h,kn,le,r,o))}}}function wn(s,n,e){le[0]=s[0],le[1]=s[1],le[2]=s[2],le[3]=s[3],le[4]=s[0]*n+s[2]*e+s[4],le[5]=s[1]*n+s[3]*e+s[5]}var Xe=class extends Te{constructor(e,t,r={}){super(e,null);p(this,"_spec");p(this,"baked",null);p(this,"bakedEffects",!0);this._spec=t,this.bake(),r.anchor===void 0&&this.useFrameAnchor(),this.set(r)}get spec(){return this._spec}set spec(e){this._spec=e,this.baked=null,this._w=this._h=null,this.bake()}bake(){let e=this.kernel;return this.baked&&e.atlas.valid(this.baked.frame)&&this.baked.frame.scale===e.pixelScale&&this.bakedEffects===e.effects?this.baked:(this.bakedEffects=e.effects,this.baked=e.shape(this._spec),this._frame=this.baked.frame,this.slice=this.baked.slice,this.autoAnchor&&this.useFrameAnchor(),this.baked)}frameNow(){return this.bake().frame}sizeQ(){let e=this.bake();Gt[0]=this._w??e.w,Gt[1]=this._h??e.h}get width(){return this._w??this.bake().w}set width(e){this._w=e}get height(){return this._h??this.bake().h}set height(e){this._h=e}},Mo=(s,n,e)=>s===void 0?n:typeof s=="number"?s:s[0]+(s[1]-s[0])*e(),Et=class Et extends Ie{constructor(e,t,r={}){super(e);p(this,"max");p(this,"f");p(this,"tints");p(this,"count",0);p(this,"gravity");p(this,"drag");p(this,"frameRef");p(this,"random",Math.random);this.frameRef=t,this.max=Math.max(1,Math.floor(r.max??200)),this.f=new Float32Array(this.max*Et.W),this.tints=new Uint32Array(this.max),this.blend=r.blend??"normal",this.gravity=r.gravity??0,this.drag=r.drag??1}get alive(){return this.count}burst(e,t,r,o={}){let a=Et.W,i=this.random,u=o.tint===void 0?16777215:de(o.tint)[0];for(let c=0;c<r;c++){let l=this.count;if(l>=this.max){let d=0,x=1/0;for(let g=0;g<this.max;g++){let v=this.f[g*a+5]-this.f[g*a+4];v<x&&(x=v,d=g)}l=d}else this.count++;let f=(o.angle??0)+(o.spread===void 0?i()*Math.PI*2:(i()-.5)*o.spread),h=Mo(o.speed,200,i),m=Array.isArray(o.scale)?o.scale[0]:o.scale??1,b=Array.isArray(o.scale)?o.scale[1]:o.scale??1,y=l*a;this.f[y]=e,this.f[y+1]=t,this.f[y+2]=Math.cos(f)*h,this.f[y+3]=Math.sin(f)*h,this.f[y+4]=0,this.f[y+5]=Math.max(Mo(o.life,.8,i),.01),this.f[y+6]=i()*Math.PI*2,this.f[y+7]=(i()-.5)*2*(o.spin??0),this.f[y+8]=m,this.f[y+9]=b,this.f[y+10]=o.alpha??1,this.tints[l]=u}}update(e){let t=Et.W,r=this.f,o=this.drag>=1?1:Math.pow(Math.max(this.drag,0),e);for(let a=0;a<this.count;){let i=a*t;if(r[i+4]=r[i+4]+e,r[i+4]>=r[i+5]){let u=--this.count;a!==u&&(r.copyWithin(i,u*t,u*t+t),this.tints[a]=this.tints[u]);continue}r[i+3]=(r[i+3]+this.gravity*e)*o,r[i+2]=r[i+2]*o,r[i]=r[i]+r[i+2]*e,r[i+1]=r[i+1]+r[i+3]*e,r[i+6]=r[i+6]+r[i+7]*e,a++}}clear(){this.count=0}draw(e,t,r){if(!this.count)return;let o=typeof this.frameRef=="string"?this.frameRef=this.kernel.frame(this.frameRef):this.frameRef,a=Et.W,i=this.f,u=this.world,c=o.w/o.scale,l=o.h/o.scale;for(let f=0;f<this.count;f++){let h=f*a,m=i[h+4]/i[h+5],b=i[h+8]+(i[h+9]-i[h+8])*m,y=t*i[h+10]*(1-m*m),d=i[h+6],x=Math.cos(d)*b,g=Math.sin(d)*b,v=i[h],w=i[h+1],T=u[0],M=u[1],P=u[2],L=u[3],F=T*x+P*g,B=M*x+L*g,G=P*x-T*g,W=L*x-M*g;le[0]=F,le[1]=B,le[2]=G,le[3]=W,le[4]=T*v+P*w+u[4]-(F*c+G*l)/2,le[5]=M*v+L*w+u[5]-(B*c+W*l)/2,Y[0]=c,Y[1]=l,Y[2]=y,e.r.quadQ(e.tex(o.surface),o,le,Pr(r,this.tints[f]),this.blend)}}};p(Et,"W",11);var Ut=Et;var Ne=class extends Te{constructor(e,t,r={}){let{fps:o,loop:a,playing:i,speed:u,onComplete:c,...l}=r;if(!t.frames.length)throw new Error("[engine] an animation needs at least one frame");super(e,t.frames[0],l);p(this,"frames");p(this,"durations");p(this,"fps");p(this,"loop");p(this,"speed");p(this,"onComplete");p(this,"_playing");p(this,"index",0);p(this,"t",0);this.frames=t.frames,this.durations=t.durations&&o===void 0?t.durations:null,this.fps=o??12,this.loop=a!==!1,this.speed=u??1,this.onComplete=c??null,this._playing=i!==!1,this.speed<0&&this.show(t.frames.length-1)}get frameIndex(){return this.index}get frameCount(){return this.frames.length}get playing(){return this._playing}play(){return!this.loop&&!this._playing&&this.index===(this.speed<0?0:this.frames.length-1)&&this.show(this.speed<0?this.frames.length-1:0),this._playing=!0,this}stop(){return this._playing=!1,this}gotoFrame(e){let t=this.frames.length;return this.show((Math.floor(e)%t+t)%t),this.t=0,this}gotoAndPlay(e){return this._playing=!0,this.gotoFrame(e)}gotoAndStop(e){return this._playing=!1,this.gotoFrame(e)}show(e){e===this.index&&this._frame||(this.index=e,this.frame=this.frames[e])}secondsOf(e){let t=this.durations?.[e];return t!==void 0&&t>0?t:1/Math.max(this.fps,.001)}update(e){if(!this._playing||this.destroyed||this.speed===0)return;let t=this.frames.length,r=this.speed<0;this.t+=e*Math.abs(this.speed);let o=this.index;for(let a=0;a<1e3;a++){let i=this.secondsOf(o);if(this.t<i)break;this.t-=i;let u=r?o-1:o+1;if(u<0||u>=t){if(!this.loop){this.t=0,this._playing=!1,this.show(o),this.onComplete?.();return}o=r?t-1:0}else o=u}this.show(o)}},Ro=(s,n)=>s.localeCompare(n,void 0,{numeric:!0});var vn=class{constructor(n,e,t=2){p(this,"width",n);p(this,"height",e);p(this,"padding",t);p(this,"shelves",[]);p(this,"free",[]);p(this,"bottom",0)}alloc(n,e){let t=Math.ceil(n)+this.padding*2,r=Math.ceil(e)+this.padding*2;if(t>this.width||r>this.height)return null;for(let i=0;i<this.free.length;i++){let u=this.free[i];if(u.w>=t&&u.h>=r&&u.w*u.h<=t*r*2)return this.free.splice(i,1),{...this.inner(u.x,u.y,n,e),slot:u}}let o=null;for(let i of this.shelves)i.h>=r&&i.h<=r*1.5+8&&this.width-i.x>=t&&(!o||i.h<o.h)&&(o=i);if(!o)if(this.bottom+r>this.height){for(let i of this.shelves)i.h>=r&&this.width-i.x>=t&&(o=i);if(!o)return null}else o={y:this.bottom,h:r,x:0},this.shelves.push(o),this.bottom+=r;let a=o.x;return o.x+=t,this.inner(a,o.y,n,e)}release(n){this.free.push({x:n.x-this.padding,y:n.y-this.padding,w:Math.ceil(n.w)+this.padding*2,h:Math.ceil(n.h)+this.padding*2})}get fill(){return this.bottom/this.height}reset(){this.shelves=[],this.free=[],this.bottom=0}inner(n,e,t,r){return{x:n+this.padding,y:e+this.padding,w:t,h:r}}},Vt=s=>({source:s,texture:null,pending:[]}),pt=class{constructor(n=2048,e=4){p(this,"pageSize",n);p(this,"maxPages",e);p(this,"pages",[]);p(this,"gen",1);p(this,"onPage",()=>{});p(this,"onDrop",()=>{})}valid(n){return!!n&&(n.gen===this.gen||n.gen===0)}bake(n,e,t,r=1,o=0,a=0,i=0){let u=Math.max(1,Math.ceil(n)),c=Math.max(1,Math.ceil(e)),l=document.createElement("canvas");l.width=u,l.height=c;let f=l.getContext("2d");return t(f),this.put(l,u,c,r,o,a,i)}add(n,e=1,t=0,r=0){let o=document.createElement("canvas");return o.width=Math.max(1,n.width),o.height=Math.max(1,n.height),o.getContext("2d").drawImage(n,0,0),this.put(o,o.width,o.height,e,t,r,0)}release(n){if(n.gen!==this.gen)return;this.pages.find(t=>t.surface===n.surface)?.packer.release(n)}rebake(n,e,t,r,o=n.w,a=n.h){if(!this.valid(n)||e>o||t>a)return null;let i=Math.max(1,Math.ceil(e)),u=Math.max(1,Math.ceil(t)),c=this.pages.find(f=>f.surface===n.surface);if(!c)return null;let l=document.createElement("canvas");return l.width=Math.ceil(o),l.height=Math.ceil(a),r(l.getContext("2d")),c.ctx.clearRect(n.x,n.y,l.width,l.height),c.ctx.drawImage(l,n.x,n.y),n.surface.pending.push([l,n.x,n.y]),n.w=i,n.h=u,n}put(n,e,t,r,o,a,i){let u=null,c=this.pages.find(f=>(u=f.packer.alloc(e,t))!==null);if(c||(!(Math.max(e,t)+4>this.pageSize)&&this.pages.length>=this.maxPages&&(this.wipe(),c=this.pages[0],u=c?c.packer.alloc(e,t):null),(!c||!u)&&(c=this.newPage(Math.max(e,t)),u=c.packer.alloc(e,t))),!u)throw new Error(`[engine] ${e}\xD7${t} does not fit an atlas page`);let l=u;if(l.slot){let f=l.slot;c.ctx.clearRect(f.x,f.y,f.w,f.h);let h=document.createElement("canvas");h.width=f.w,h.height=f.h,h.getContext("2d").drawImage(n,l.x-f.x,l.y-f.y),c.surface.pending.push([h,f.x,f.y])}else c.surface.pending.push([n,l.x,l.y]);return c.ctx.drawImage(n,l.x,l.y),{surface:c.surface,x:l.x,y:l.y,w:e,h:t,scale:r,gen:this.gen,ox:o,oy:a,margin:i}}newPage(n){let e=this.pageSize;for(;e<n+4;)e*=2;let t=document.createElement("canvas");t.width=t.height=e;let r=t.getContext("2d"),o=Vt(t),a={surface:o,packer:new vn(e,e),ctx:r};return this.pages.push(a),this.onPage(o),a}wipe(){this.gen++;let n=0;for(let e=0;e<this.pages.length;e++){let t=this.pages[e];if(n<this.maxPages&&t.surface.source.width===this.pageSize){this.pages[n++]=t;continue}t.surface.pending=[],this.onDrop(t.surface)}this.pages.length=n;for(let e of this.pages)e.packer.reset(),e.ctx.clearRect(0,0,e.surface.source.width,e.surface.source.height),e.surface.pending=[],e.surface.pending.push([e.surface.source,0,0])}};var qi=()=>{let s=typeof document<"u"?document.timeline?.currentTime:null;return typeof s=="number"&&Number.isFinite(s)?s:globalThis.performance?.now()??Date.now()},Co=()=>globalThis.performance?.now()??Date.now(),Xn=class{constructor(n=qi){p(this,"now",n);p(this,"known",new Map);p(this,"smoothed",new Map);p(this,"times",new WeakMap);p(this,"lerp",new Bt);p(this,"amount",zr);p(this,"drawnAt",NaN);p(this,"drawn",0);p(this,"smoothedBody",(n,e={})=>{let t=e.interpolate!==!1;if(typeof n=="number"){let r=this.smoothed.get(n);return r?t?this.lerp.at(n,this.tick())??r.body:r.body:null}return typeof n!="object"||n===null||!Array.isArray(n.body)?null:this.posed(n.id,n.body,Yi(e.smooth,this.defaultAmount),t)})}setLocal(n){this.amount=n?lo:zr,this.lerp=new Bt(n?Cr:{}),this.smoothed.clear()}get defaultAmount(){return this.amount}note(n,e,t=Co()){for(let r of n)this.known.set(r.id,this.resolve(r.id,r.avatar)),e!==void 0&&Number.isFinite(e)&&Array.isArray(r.body)&&this.times.set(r.body,{t:e,arrival:t})}of(n){return typeof n=="object"&&n!==null?n.avatar!==void 0?this.resolve(n.id,n.avatar):this.of(n.id):this.known.get(n)??Sr(n-1)}posed(n,e,t,r=!0){let o=this.smooth(n,e,t);return r?this.lerp.at(n,this.tick())??o:o}smooth(n,e,t){let r=this.smoothed.get(n);if(r&&r.raw===e&&r.amount===t)return r.body;r&&r.amount!==t&&this.lerp.forget(n);let o=t<1?io(r?.body,e,t):e;this.smoothed.set(n,{raw:e,body:o,amount:t});let a=this.times.get(e),i=a?.arrival??Co();return this.lerp.push(n,a?.t??i,o,i),o}takeDrawn(){let n=this.drawn;return this.drawn=0,n}tick(){let n=this.now();return n!==this.drawnAt&&(this.drawnAt=n,this.drawn++),n}resolve(n,e){return oo(e)?e:Sr(n-1)}};var zr=.5,Yi=(s,n=zr)=>s===!1?1:typeof s=="number"?Math.min(Math.max(s,.05),1):n;var _o=new Float64Array(1),Fo=new Int32Array(_o.buffer),Wt=(s,n)=>(s=Math.imul(s^n,1540483477),s^s>>>15);function ot(s,n=2538058380){return s!==s?Wt(n,2146959360):(_o[0]=s===0?0:s,Wt(Wt(n,Fo[0]),Fo[1]))}function Po(s,n=2166136261){for(let e=0;e<s.length;e++)n=Math.imul(n^s.charCodeAt(e),16777619);return n}function Ge(s){switch(typeof s){case"number":return ot(s);case"string":return Po(s);case"boolean":return s?1013904242:461845907;case"object":{if(s===null)return 625341585;if(Array.isArray(s)||s instanceof Float64Array){let t=1779033703^s.length;for(let r=0;r<s.length;r++){let o=s[r];t=Wt(t,typeof o=="number"?ot(o):Ge(o))}return t}let n=1359893119,e=s;for(let t in e){let r=e[t];r!==void 0&&(n=n+Wt(Po(t),Ge(r))|0)}return Wt(n,2600822924)}default:return 0}}function Xt(s,n){if(s===n)return!0;if(typeof s!="object"||typeof n!="object"||s===null||n===null)return typeof s=="number"&&typeof n=="number"&&s!==s&&n!==n;let e=Array.isArray(s)||s instanceof Float64Array;if(e!==(Array.isArray(n)||n instanceof Float64Array))return!1;if(e){let o=s,a=n;if(o.length!==a.length)return!1;for(let i=0;i<o.length;i++)if(o[i]!==a[i]&&!Xt(o[i],a[i]))return!1;return!0}let t=s,r=n;for(let o in t)if(t[o]!==void 0&&!Xt(t[o],r[o]))return!1;for(let o in r)if(r[o]!==void 0&&t[o]===void 0)return!1;return!0}function An(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return s.map(An);if(s instanceof Float64Array)return s.slice();let n={};for(let e in s)s[e]!==void 0&&(n[e]=An(s[e]));return n}var jt=class{constructor(n=1/0){p(this,"max",n);p(this,"buckets",new Map);p(this,"n",0)}get size(){return this.n}get(n,e=Ge(n)){let t=this.buckets.get(e);if(t){for(let r=0;r<t.length;r++)if(Xt(t[r].key,n))return t[r].value}}set(n,e,t=Ge(n)){let r=this.buckets.get(t);if(r){for(let o of r)if(Xt(o.key,n)){o.value=e;return}}this.n>=this.max&&this.clear(),(!r||!this.buckets.has(t))&&this.buckets.set(t,r=[]),r.push({key:An(n),value:e}),this.n++}clear(){this.buckets.clear(),this.n=0}};var Hr=0,Lo=1,jn=2,$r=3,qt=class{constructor(){p(this,"scale",1);p(this,"cOn",!1);p(this,"px0",0);p(this,"py0",0);p(this,"px1",0);p(this,"py1",0);p(this,"clipVer",0);p(this,"stack",[]);p(this,"sp",0);p(this,"real",0);p(this,"mute",0);p(this,"bnd",new Float64Array(4*(xn+1)));p(this,"rx0",0);p(this,"ry0",0);p(this,"rx1",0);p(this,"ry1",0);p(this,"maxBlur",1/0);p(this,"time",0);p(this,"skipped",0);p(this,"gq",new Float64Array(4))}resetLayers(n){this.scale=n,this.sp=this.real=this.mute=0,this.skipped=0,this.cOn=!1,this.clipVer++}growQ(){let n=this.gq;this.grow(n[0],n[1],n[2],n[3])}grow(n,e,t,r){if(!this.real)return;let o=this.bnd,a=(this.real-1)*4;n<o[a]&&(o[a]=n),e<o[a+1]&&(o[a+1]=e),t>o[a+2]&&(o[a+2]=t),r>o[a+3]&&(o[a+3]=r)}area(n,e){let t=this.bnd,r=n*4,o=this.scale;return this.rx0=Math.max(Math.floor((t[r]-e)*o)-1,0),this.ry0=Math.max(Math.floor((t[r+1]-e)*o)-1,0),this.rx1=Math.min(Math.ceil((t[r+2]+e)*o)+1,this.canvas.width),this.ry1=Math.min(Math.ceil((t[r+3]+e)*o)+1,this.canvas.height),this.rx1>this.rx0&&this.ry1>this.ry0}clip(n,e,t,r){let o=this.scale,a=this.canvas.width,i=this.canvas.height,u=Math.min(Math.max(Math.round(n*o),0),a),c=Math.min(Math.max(Math.round(e*o),0),i),l=Math.min(Math.max(Math.round((n+t)*o),u),a),f=Math.min(Math.max(Math.round((e+r)*o),c),i);this.cOn&&u===this.px0&&c===this.py0&&l===this.px1&&f===this.py1||(this.cOn=!0,this.px0=u,this.py0=c,this.px1=l,this.py1=f,this.clipVer++)}unclip(){this.cOn&&(this.cOn=!1,this.clipVer++)}push(n){if(n<jn&&(this.mute||this.real>=xn||!this.pushLayer())&&(n+=2),n===$r)this.mute++;else if(n!==jn){let e=this.real*4;this.bnd[e]=this.bnd[e+1]=1/0,this.bnd[e+2]=this.bnd[e+3]=-1/0,this.real++}return this.stack[this.sp++]=n,n<jn}beginLayer(){return this.push(Hr)}beginMask(){this.push(this.sp&&this.stack[this.sp-1]===Hr?Lo:$r)}endLayer(n,e){if(!this.sp)return;let t=this.stack[--this.sp];if(t===$r){if(this.mute--,!this.sp)return;t=this.stack[--this.sp]}if(t===Lo){let r=--this.real,o=this.popLayer();this.area(r-1,0)&&this.composite(o,!0,1,null);let a=this.bnd,i=(r-1)*4,u=r*4;a[i]=Math.max(a[i],a[u]),a[i+1]=Math.max(a[i+1],a[u+1]),a[i+2]=Math.min(a[i+2],a[u+2]),a[i+3]=Math.min(a[i+3],a[u+3]),t=this.stack[--this.sp]}if(t===jn)bn(e)&&(this.skipped+=e.length);else if(t===Hr){let r=--this.real,o=bn(e)?e:null,a=this.popLayer();if(this.area(r,o?vo(o,this.maxBlur):0)){this.composite(a,!1,n,o);let i=this.scale;this.grow(this.rx0/i,this.ry0/i,this.rx1/i,this.ry1/i)}}}closeLayers(){for(;this.sp;)this.endLayer(1)}};var Ki=256,Oo=8<<20,Ee=new Float64Array(32),Re={x:0,y:0,w:0,h:0};function Qi(s){if(typeof s.filter!="string")return!1;s.filter="blur(1px)";let n=s.filter==="blur(1px)";return s.filter="none",n}function Yt(s){let n=s.getContext("2d",{alpha:!0});return n?new Gr(s,n):null}var Gr=class extends qt{constructor(e,t){super();p(this,"canvas",e);p(this,"ctx",t);p(this,"kind","canvas2d");p(this,"maxTextureSize",4096);p(this,"features",{});p(this,"info",{renderer:"canvas2d"});p(this,"support");p(this,"lost",!1);p(this,"fxr",null);p(this,"quads",0);p(this,"stats",{drawCalls:0,quads:0,filtersSkipped:0});p(this,"tinted",new Map);p(this,"tintedN",0);p(this,"lostListeners",[]);p(this,"restoredListeners",[]);p(this,"base");p(this,"top");p(this,"layers",[]);p(this,"scratch",[]);p(this,"nines",new Map);p(this,"ninePx",0);p(this,"frame",0);p(this,"hit",!1);p(this,"missed",new Map);this.support={filters:Qi(t),shaders:!1},this.base=this.top={ctx:t,clipped:!1,ver:0},e.addEventListener("contextlost",()=>{this.lost=!0,this.lostListeners.forEach(r=>r())}),e.addEventListener("contextrestored",()=>{this.lost=!1,this.tinted.clear(),this.tintedN=0,this.dropNines(),this.restoredListeners.forEach(r=>r())})}resize(e,t){this.canvas.width!==e&&(this.canvas.width=e),this.canvas.height!==t&&(this.canvas.height=t)}createTexture(e){return{id:gn(),width:e.width,height:e.height,source:e}}updateTexture(e,t,r=0,o=0){let a=t?r+t.width:1/0,i=t?o+t.height:1/0;for(let u of this.nines.values()){let c=u.key;c[0]===e.id&&c[1]<a&&c[1]+c[3]>r&&c[2]<i&&c[2]+c[4]>o&&this.dropNine(u)}for(let[u,c]of this.tinted){let l=c.filter(f=>f.id!==e.id);this.tintedN-=c.length-l.length,l.length?this.tinted.set(u,l):this.tinted.delete(u)}}destroyTexture(e){this.updateTexture(e)}begin(e,t,r){this.resetLayers(r),this.fxr?.tick(),this.frame++,this.quads=0,this.top=this.base,this.ctx=this.base.ctx;let o=this.ctx;this.base.clipped&&o.restore(),this.base.clipped=!1,this.base.ver=this.clipVer,o.setTransform(1,0,0,1,0,0),o.globalAlpha=1,o.globalCompositeOperation="source-over",o.clearRect(0,0,this.canvas.width,this.canvas.height),t>0&&(o.fillStyle=Mt(e,t),o.fillRect(0,0,this.canvas.width,this.canvas.height))}quad(e,t,r,o,a,i,u,c){Y[0]=o,Y[1]=a,Y[2]=u,this.quadQ(e,t,r,i,c)}quadQ(e,t,r,o,a){t.w<=0||t.h<=0||(o===16777215?this.blit(e.source,t.x,t.y,t.w,t.h,r,a):this.blit(this.tint(e,t,o),0,0,t.w,t.h,r,a))}blit(e,t,r,o,a,i,u){let c=Y[0],l=Y[1],f=Y[2];if(f<=0||this.mute)return;this.sync();let h=this.ctx,m=this.scale;if(this.real){let b=i[0]*c,y=i[1]*c,d=i[2]*l,x=i[3]*l;this.grow(i[4]+Math.min(0,b,d,b+d),i[5]+Math.min(0,y,x,y+x),i[4]+Math.max(0,b,d,b+d),i[5]+Math.max(0,y,x,y+x))}h.setTransform(i[0]*m,i[1]*m,i[2]*m,i[3]*m,i[4]*m,i[5]*m),h.globalAlpha=Math.min(f,1),u==="add"&&(h.globalCompositeOperation="lighter"),h.drawImage(e,t,r,o,a,0,0,c,l),u==="add"&&(h.globalCompositeOperation="source-over"),this.quads++}nineQ(e,t,r,o,a,i,u){var y,d;let c=r[8]+r[9],l=o[8]+o[9],f=Math.ceil(c*Math.hypot(a[0],a[1])*this.scale-1e-6),h=Math.ceil(l*Math.hypot(a[2],a[3])*this.scale-1e-6);if(a[1]===0&&a[2]===0||f>4096||h>4096)return!1;if(!(f>0&&h>0&&Y[2]>0)||this.mute)return!0;let m=this.kept(e,t,r,o,f,h,i),b=(m??(m=(y=this.scratch)[d=13*Math.ceil(Math.log2(f))+Math.ceil(Math.log2(h))]??(y[d]=document.createElement("canvas").getContext("2d")))).canvas;if(b.width<f&&(b.width=f),b.height<h&&(b.height=h),!this.hit){m.clearRect(0,0,f+2,h+2);for(let x=0;x<12;x+=4){let g=Math.round(o[x]*h/l),v=Math.round((o[x]+o[x+1])*h/l);for(let w=0;w<12;w+=4){let T=Math.round(r[w]*f/c),M=Math.round((r[w]+r[w+1])*f/c);Re.x=t.x+r[w+2],Re.y=t.y+o[x+2],Re.w=r[w+3],Re.h=o[x+3],!(M<=T||v<=g||Re.w<=0||Re.h<=0)&&(i===16777215?m.drawImage(e.source,Re.x,Re.y,Re.w,Re.h,T,g,M-T,v-g):m.drawImage(this.tint(e,Re,i),0,0,Re.w,Re.h,T,g,M-T,v-g))}}}return Y[0]=c,Y[1]=l,this.blit(b,0,0,f,h,a,u),!0}kept(e,t,r,o,a,i,u){Ee[0]=e.id,Ee[1]=t.x,Ee[2]=t.y,Ee[3]=t.w,Ee[4]=t.h,Ee[5]=a,Ee[6]=i,Ee[7]=u,Ee.set(r,8),Ee.set(o,20);let c=Ge(Ee),l=this.nines.get(c);if(this.hit=!1,l)return Xt(l.key,Ee)?(l.used=this.frame,this.hit=!0,l.ctx):null;let f=this.missed,h=f.get(c);f.size>4096&&f.clear(),f.set(c,this.frame);let m=a*i;if(h!==this.frame-1||m>Oo)return null;let b;for(;this.ninePx+m>Oo;){let x;for(let w of this.nines.values())w.used<this.frame-1&&!(x&&x.used<=w.used)&&(x=w);if(!x)return null;let g=x.ctx.canvas,v=!b&&g.width>=a&&g.height>=i&&g.width*g.height<=2*m;this.dropNine(x,v),v&&(b=x.ctx)}let y=b??document.createElement("canvas").getContext("2d"),d=y.canvas;return b||(d.width=a,d.height=i),this.ninePx+=d.width*d.height,this.nines.set(c,{key:An(Ee),ctx:y,used:this.frame}),y}dropNine(e,t=!1){this.nines.delete(Ge(e.key));let r=e.ctx.canvas;this.ninePx-=r.width*r.height,t||(r.width=0)}dropNines(){for(let e of this.nines.values())this.dropNine(e)}tint(e,t,r){let o=ot(r,ot(t.h,ot(t.w,ot(t.y,ot(t.x,ot(e.id)))))),a=this.tinted.get(o);if(a)for(let c=0;c<a.length;c++){let l=a[c];if(l.id===e.id&&l.x===t.x&&l.y===t.y&&l.w===t.w&&l.h===t.h&&l.color===r)return l.canvas}this.tintedN>=Ki&&(this.tinted.clear(),this.tintedN=0,a=void 0);let i=document.createElement("canvas");i.width=Math.ceil(t.w),i.height=Math.ceil(t.h);let u=i.getContext("2d");return u.drawImage(e.source,t.x,t.y,t.w,t.h,0,0,t.w,t.h),u.globalCompositeOperation="multiply",u.fillStyle=Mt(r),u.fillRect(0,0,t.w,t.h),u.globalCompositeOperation="destination-in",u.drawImage(e.source,t.x,t.y,t.w,t.h,0,0,t.w,t.h),a||this.tinted.set(o,a=[]),a.push({id:e.id,x:t.x,y:t.y,w:t.w,h:t.h,color:r,canvas:i}),this.tintedN++,i}paint(e,t){this.sync();let r=this.ctx,o=this.scale;return r.setTransform(o,0,0,o,0,0),r.globalAlpha=Math.min(t,1),Mt(e)}ellipse(e,t,r,o,a,i,u){if(u<=0||r<=0||o<=0||this.mute)return;let c=Math.max(r,o);this.grow(e-c,t-c,e+c,t+c);let l=this.ctx;l.fillStyle=this.paint(i,u),l.beginPath(),l.ellipse(e,t,r,o,a,0,Math.PI*2),l.fill(),this.quads++}trace(e,t,r=0){if(this.real)for(let a=0;a<t;a++)this.grow(e[a*2]-r,e[a*2+1]-r,e[a*2]+r,e[a*2+1]+r);let o=this.ctx;o.beginPath(),o.moveTo(e[0],e[1]);for(let a=1;a<t;a++)o.lineTo(e[a*2],e[a*2+1])}polygon(e,t,r,o){if(o<=0||t<3||this.mute)return;let a=this.ctx;a.fillStyle=this.paint(r,o),this.trace(e,t),a.closePath(),a.fill(),this.quads++}stroke(e,t,r,o,a,i){if(a<=0||r<=0||t<1||this.mute)return;let u=this.ctx;u.strokeStyle=this.paint(o,a),u.lineWidth=r,u.lineCap="round",u.lineJoin="round",this.trace(e,t,r/2),t===1&&u.lineTo(e[0],e[1]),i&&u.closePath(),u.stroke(),this.quads++}sync(){let e=this.top;if(e.ver===this.clipVer)return;let t=e.ctx;e.clipped&&t.restore(),e.clipped=this.cOn,e.ver=this.clipVer,this.cOn&&(t.save(),t.setTransform(1,0,0,1,0,0),t.beginPath(),t.rect(this.px0,this.py0,this.px1-this.px0,this.py1-this.py0),t.clip())}pushLayer(){let e=this.canvas.width,t=this.canvas.height,r=this.layers[this.real];if(!r||r.ctx.canvas.width!==e||r.ctx.canvas.height!==t){let a=document.createElement("canvas");a.width=e,a.height=t;let i=a.getContext("2d");if(!i)return!1;r=this.layers[this.real]={ctx:i,clipped:!1,ver:-1}}let o=r.ctx;return r.clipped&&o.restore(),r.clipped=!1,r.ver=-1,o.setTransform(1,0,0,1,0,0),o.globalAlpha=1,o.globalCompositeOperation="source-over",o.clearRect(0,0,e,t),this.top=r,this.ctx=o,!0}popLayer(){return this.top=this.real>0?this.layers[this.real-1]:this.base,this.ctx=this.top.ctx,this.layers[this.real].ctx.canvas}composite(e,t,r,o){let a=e,i="none",u=o&&Me.c2d?this.fxr??(this.fxr=Me.c2d(this)):null;u&&(a=u.chain(e,o),i=u.css),this.sync();let c=this.ctx,l=this.rx0,f=this.ry0,h=this.rx1-l,m=this.ry1-f;c.setTransform(1,0,0,1,0,0),c.globalAlpha=Math.min(r,1),c.globalCompositeOperation=t?"destination-in":"source-over",i!=="none"&&(c.filter=i),c.drawImage(a,l,f,h,m,l,f,h,m),i!=="none"&&(c.filter="none"),c.globalCompositeOperation="source-over",this.quads++}end(){this.closeLayers();let e=this.stats;return e.drawCalls=e.quads=this.quads,e.filtersSkipped=this.skipped,e}onLost(e){this.lostListeners.push(e)}onRestored(e){this.restoredListeners.push(e)}destroy(){this.tinted.clear(),this.dropNines(),this.layers=[],this.scratch=[],this.fxr?.destroy(),this.fxr=null}};var qn=class{constructor(n,e,t=8192){p(this,"instanced",n);p(this,"slots",e);p(this,"capacity",t);p(this,"f32");p(this,"u32");p(this,"quads",0);p(this,"textures");p(this,"bound",0);this.textures=new Array(e).fill(null);let r=t*(n?14:24),o=new ArrayBuffer(r*4);this.f32=new Float32Array(o),this.u32=new Uint32Array(o)}slot(n){let e=this.textures;for(let t=0;t<this.bound;t++)if(e[t]===n)return t;return this.bound>=this.slots?-1:(e[this.bound]=n,this.bound++)}has(n){for(let e=0;e<this.bound;e++)if(this.textures[e]===n)return!0;return!1}get full(){return this.quads>=this.capacity}get words(){return this.quads*(this.instanced?14:24)}reset(){this.quads=0;for(let n=0;n<this.bound;n++)this.textures[n]=null;this.bound=0}push(n,e,t,r,o,a,i,u,c,l,f,h,m,b){let y=this.f32;if(this.instanced){let d=this.quads*14;y[d++]=n,y[d++]=e,y[d++]=t,y[d++]=r,y[d++]=o,y[d++]=a,y[d++]=i,y[d++]=u,y[d++]=c,y[d++]=l,y[d++]=f,y[d++]=h,this.u32[d++]=m,y[d]=b}else{let d=this.quads*6*4;this.vertex(d,n,e,c,l,m,b),this.vertex(d+6,t,r,f,l,m,b),this.vertex(d+12,o,a,f,h,m,b),this.vertex(d+18,i,u,c,h,m,b)}this.quads++}pushQ(n,e){let t=this.f32;if(this.instanced){let r=this.quads*14;for(let o=0;o<12;o++)t[r+o]=n[o];this.u32[r+12]=n[12],t[r+13]=e}else{let r=this.quads*6*4,o=n[12];for(let a=0;a<4;a++,r+=6)t[r]=n[a*2],t[r+1]=n[a*2+1],t[r+2]=a===1||a===2?n[10]:n[8],t[r+3]=a>=2?n[11]:n[9],this.u32[r+4]=o,t[r+5]=e}this.quads++}vertex(n,e,t,r,o,a,i){let u=this.f32;u[n]=e,u[n+1]=t,u[n+2]=r,u[n+3]=o,this.u32[n+4]=a,u[n+5]=i}};function Io(s){let n=new Uint16Array(s*6);for(let e=0,t=0,r=0;e<s;e++,t+=6,r+=4)n[t]=r,n[t+1]=r+1,n[t+2]=r+2,n[t+3]=r,n[t+4]=r+2,n[t+5]=r+3;return n}var ge={M:0,L:1,Q:2,C:3,Z:4},Uo=[2,2,4,6,0],Zi={M:0,L:1,Q:2,C:3,Z:4};function er(s,n){if(s.length>=n)return s;let e=new Float64Array(Math.max(n,s.length*2,16));return e.set(s),e}var Yn=new Map;function Ji(s){if(typeof s!="string")return s;let n=Yn.get(s);if(n)return n;n=[];let e=s.match(/[MLQCZ]|-?\d*\.?\d+(?:e-?\d+)?/gi)??[],t=-1;for(let r=0;r<e.length;){let o=e[r],a=Zi[o.toUpperCase()];if(a!==void 0){t=a,r++,a===ge.Z&&n.push(ge.Z);continue}if(t<0||t===ge.Z){r++;continue}let i=Uo[t];n.push(t);for(let u=0;u<i;u++)n.push(Number(e[r+u]??0));r+=i,t===ge.M&&(t=ge.L)}return Yn.size>256&&Yn.clear(),Yn.set(s,n),n}var mt={subs:[],count:0},Ur=null,dt=null;function Kn(s,n){let e=dt;e||(e=mt.subs[mt.count]??null,e||mt.subs.push(e={pts:new Float64Array(64),n:0,closed:!1}),e.n=0,e.closed=!1,mt.count++,dt=e);let t=e.n*2;t+2>e.pts.length&&(e.pts=er(e.pts,t+2));let r=Ur;r?(e.pts[t]=r[0]*s+r[2]*n+r[4],e.pts[t+1]=r[1]*s+r[3]*n+r[5]):(e.pts[t]=s,e.pts[t+1]=n),e.n++}function tr(s,n=null,e=1,t=6){let r=Ji(s);mt.count=0,dt=null,Ur=n;let o=0,a=0,i=0,u=0,c=e/t;for(let l=0;l<r.length;){let f=r[l++],h=r;if(f===ge.M)dt=null,o=i=h[l],a=u=h[l+1],Kn(o,a);else if(f===ge.L)o=h[l],a=h[l+1],Kn(o,a);else if(f===ge.Q){let m=h[l],b=h[l+1],y=h[l+2],d=h[l+3],x=No((je(m-o,b-a)+je(y-m,d-b))*c);for(let g=1;g<=x;g++){let v=g/x,w=1-v;Kn(w*w*o+2*w*v*m+v*v*y,w*w*a+2*w*v*b+v*v*d)}o=y,a=d}else if(f===ge.C){let m=h[l],b=h[l+1],y=h[l+2],d=h[l+3],x=h[l+4],g=h[l+5],v=No((je(m-o,b-a)+je(y-m,d-b)+je(x-y,g-d))*c);for(let w=1;w<=v;w++){let T=w/v,M=1-T,P=M*M*M,L=3*M*M*T,F=3*M*T*T,B=T*T*T;Kn(P*o+L*m+F*y+B*x,P*a+L*b+F*d+B*g)}o=x,a=g}else if(f===ge.Z){dt&&(dt.closed=!0),dt=null,o=i,a=u;continue}else break;l+=Uo[f]}dt=null,Ur=null;for(let l=0;l<mt.count;l++){let f=mt.subs[l],h=f.n*2;f.closed&&f.n>=2&&Math.abs(f.pts[0]-f.pts[h-2])<1e-6&&Math.abs(f.pts[1]-f.pts[h-1])<1e-6&&f.n--}return mt}var je=(s,n)=>Math.sqrt(s*s+n*n),No=s=>Math.min(Math.max(Math.ceil(s),2),24);function el(s,n){let e=0;for(let t=0,r=n-1;t<n;r=t++)e+=(s[r*2]-s[t*2])*(s[r*2+1]+s[t*2+1]);return e}var Qn=new Int32Array(64),Zn=(s,n,e,t,r)=>((s[t*2]-s[e*2])*(s[r*2+1]-s[e*2+1])-(s[t*2+1]-s[e*2+1])*(s[r*2]-s[e*2]))*n;function Vo(s,n,e){if(n<3)return 0;Qn.length<n&&(Qn=new Int32Array(Math.max(n,Qn.length*2)));let t=Qn,r=n,o=0;for(let c=0;c<n;c++)t[c]=c;let a=el(s,n)>0?1:-1,i=n*n+8,u=0;for(;r>3&&i-- >0;){let c=t[(u+r-1)%r],l=t[u%r],f=t[(u+1)%r],h=Zn(s,a,c,l,f)>0;if(h)for(let m=0;m<r;m++){let b=t[m];if(!(b===c||b===l||b===f)&&Zn(s,a,c,l,b)>=0&&Zn(s,a,l,f,b)>=0&&Zn(s,a,f,c,b)>=0){h=!1;break}}h?(e[o++]=c,e[o++]=l,e[o++]=f,t.copyWithin(u%r,u%r+1,r),r--,u=Math.max(u-1,0)):u=(u+1)%r}if(r===3)e[o++]=t[0],e[o++]=t[1],e[o++]=t[2];else if(r>3)for(let c=1;c+1<r;c++)e[o++]=t[0],e[o++]=t[c],e[o++]=t[c+1];return o}var tl=.85,Jn=new Float64Array(64),Do=new Float64Array(64),Bo=new Float64Array(64),zo=new Float64Array(64),Ho=new Float64Array(64),$o=new Float64Array(64),Go=new Uint8Array(64),Sn=new Float64Array(8);function Wo(s,n,e,t,r,o){let a=Sn;if(Jn.length<n){let d=Math.max(n,Jn.length*2);Jn=new Float64Array(d),Do=new Float64Array(d),Bo=new Float64Array(d),zo=new Float64Array(d),Ho=new Float64Array(d),$o=new Float64Array(d),Go=new Uint8Array(d)}let i=Jn,u=Do,c=0;for(let d=0;d<n;d++){let x=s[d*2],g=s[d*2+1];!Number.isFinite(x)||!Number.isFinite(g)||c&&Math.abs(i[c-1]-x)<.001&&Math.abs(u[c-1]-g)<.001||(i[c]=x,u[c]=g,c++)}if(t&&c>2&&Math.abs(i[0]-i[c-1])<.001&&Math.abs(u[0]-u[c-1])<.001&&c--,c===0)return;if(c===1)return a[0]=i[0],a[1]=u[0],o();let l=t?c:c-1,f=Bo,h=zo;for(let d=0;d<l;d++){let x=(d+1)%c,g=i[x]-i[d],v=u[x]-u[d],w=je(g,v)||1;f[d]=-v/w,h[d]=g/w}let m=Ho,b=$o,y=Go;for(let d=0;d<c;d++){let x=t?(d-1+l)%l:d-1,g=d<l?d:-1;if(y[d]=1,x<0||g<0||f[x]*f[g]+h[x]*h[g]<tl)continue;let w=f[x]+f[g],T=h[x]+h[g],M=je(w,T)||1;w/=M,T/=M;let P=e/Math.max(w*f[g]+T*h[g],.5);m[d]=w*P,b[d]=T*P,y[d]=0}for(let d=0;d<l;d++){let x=(d+1)%c,g=y[d]?f[d]*e:m[d],v=y[d]?h[d]*e:b[d],w=y[x]?f[d]*e:m[x],T=y[x]?h[d]*e:b[x];a[0]=i[d]+g,a[1]=u[d]+v,a[2]=i[x]+w,a[3]=u[x]+T,a[4]=i[x]-w,a[5]=u[x]-T,a[6]=i[d]-g,a[7]=u[d]-v,r()}for(let d=0;d<c;d++)y[d]&&(a[0]=i[d],a[1]=u[d],o())}function Vr(s,n){let e=0,t=1/0;for(let r=0;r<n.length;r++){let o=Math.abs(Math.log(Math.max(s,.5)/n[r]));o<t&&(t=o,e=r)}return e}var nr=[{x:240,y:0,w:8,h:8,r:3},{x:224,y:0,w:16,h:16,r:7},{x:192,y:0,w:32,h:32,r:15},{x:128,y:0,w:64,h:64,r:31},{x:0,y:0,w:128,h:128,r:63}],rr=[4,8,16,32,64,128].map((s,n)=>({x:n*4,y:128,w:4,h:s,r:s/2-1})),at={x:248,y:248,w:8,h:8},jo=nr.map(s=>s.r*2),qo=rr.map(s=>s.r*2),Xo=(s,n)=>Math.min(Math.max(s+.5-n,0),1);function nl(){let s=new Uint8ClampedArray(262144),n=(e,t,r)=>{let o=(t*256+e)*4;s[o]=s[o+1]=s[o+2]=255,s[o+3]=Math.round(r*255)};for(let e of nr){let t=e.w/2;for(let r=0;r<e.h;r++)for(let o=0;o<e.w;o++)n(e.x+o,e.y+r,Xo(e.r,Math.hypot(o+.5-t,r+.5-t)))}for(let e of rr){let t=e.h/2;for(let r=0;r<e.h;r++)for(let o=0;o<e.w;o++)n(e.x+o,e.y+r,Xo(e.r,Math.abs(r+.5-t)))}for(let e=0;e<at.h;e++)for(let t=0;t<at.w;t++)n(at.x+t,at.y+e,1);return s}function Yo(){let s=document.createElement("canvas");return s.width=s.height=256,s.getContext("2d").putImageData(new ImageData(nl(),256,256),0,0),s}var Ko=8,sr=`
|
|
2
|
-
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
3
|
-
precision highp float;
|
|
4
|
-
#else
|
|
5
|
-
precision mediump float;
|
|
6
|
-
#endif
|
|
7
|
-
`,al=s=>`${sr}
|
|
8
|
-
uniform sampler2D uTex[${s}];
|
|
9
|
-
varying vec2 vUv;
|
|
10
|
-
varying vec4 vColor;
|
|
11
|
-
varying float vSlot;
|
|
12
|
-
void main() {
|
|
13
|
-
vec4 c;
|
|
14
|
-
${Array.from({length:s},(n,e)=>e===s-1?`c = texture2D(uTex[${e}], vUv);`:`if (vSlot < ${e}.5) c = texture2D(uTex[${e}], vUv); else `).join(`
|
|
15
|
-
`)}
|
|
16
|
-
gl_FragColor = c * vColor;
|
|
17
|
-
}`,il=`
|
|
18
|
-
attribute vec2 aPos;
|
|
19
|
-
attribute vec2 aUv;
|
|
20
|
-
attribute vec4 aColor;
|
|
21
|
-
attribute float aSlot;
|
|
22
|
-
uniform vec2 uScale;
|
|
23
|
-
varying vec2 vUv;
|
|
24
|
-
varying vec4 vColor;
|
|
25
|
-
varying float vSlot;
|
|
26
|
-
void main() {
|
|
27
|
-
vUv = aUv;
|
|
28
|
-
vColor = aColor;
|
|
29
|
-
vSlot = aSlot;
|
|
30
|
-
gl_Position = vec4(aPos * uScale + vec2(-1.0, 1.0), 0.0, 1.0);
|
|
31
|
-
}`,ll=`
|
|
32
|
-
attribute vec4 aCorner;
|
|
33
|
-
attribute vec4 aP01;
|
|
34
|
-
attribute vec4 aP23;
|
|
35
|
-
attribute vec4 aUvRect;
|
|
36
|
-
attribute vec4 aColor;
|
|
37
|
-
attribute float aSlot;
|
|
38
|
-
uniform vec2 uScale;
|
|
39
|
-
varying vec2 vUv;
|
|
40
|
-
varying vec4 vColor;
|
|
41
|
-
varying float vSlot;
|
|
42
|
-
void main() {
|
|
43
|
-
vec2 p = aP01.xy * aCorner.x + aP01.zw * aCorner.y + aP23.xy * aCorner.z + aP23.zw * aCorner.w;
|
|
44
|
-
vUv = vec2(mix(aUvRect.x, aUvRect.z, aCorner.y + aCorner.z), mix(aUvRect.y, aUvRect.w, aCorner.z + aCorner.w));
|
|
45
|
-
vColor = aColor;
|
|
46
|
-
vSlot = aSlot;
|
|
47
|
-
gl_Position = vec4(p * uScale + vec2(-1.0, 1.0), 0.0, 1.0);
|
|
48
|
-
}`,cl={alpha:!0,premultipliedAlpha:!0,antialias:!1,depth:!1,stencil:!1,preserveDrawingBuffer:!1,powerPreference:"high-performance"},ul=["aCorner","aP01","aP23","aUvRect","aColor","aSlot"],hl=["aPos","aUv","aColor","aSlot"];function Zo(s,n,e={}){let t={...cl,failIfMajorPerformanceCaveat:e.failIfMajorPerformanceCaveat!==!1},r=n===2?s.getContext("webgl2",t):s.getContext("webgl",t)??s.getContext("experimental-webgl",t);if(!r||r.isContextLost())return null;try{return new Wr(s,r,n,e)}catch(o){return console.warn("[engine] WebGL setup failed:",o),r.getExtension("WEBGL_lose_context")?.loseContext(),null}}var Wr=class extends qt{constructor(e,t,r,o){super();p(this,"canvas",e);p(this,"gl",t);p(this,"opts",o);p(this,"kind");p(this,"maxTextureSize");p(this,"support",{filters:!0,shaders:!0});p(this,"features",{});p(this,"info",{});p(this,"lost",!1);p(this,"main");p(this,"cur");p(this,"unit",-1);p(this,"onUnit",new Array(Ko).fill(void 0));p(this,"fbNow");p(this,"mapped",!0);p(this,"calls",{useProgram:0,bindTexture:0,activeTexture:0,bindFramebuffer:0});p(this,"vsrc","");p(this,"attrs",[]);p(this,"fxr",null);p(this,"batch");p(this,"dynamic");p(this,"staticBuf",null);p(this,"index");p(this,"vao",null);p(this,"inst",null);p(this,"vaoApi",null);p(this,"uScale",null);p(this,"textures",new Map);p(this,"kit");p(this,"stats",{drawCalls:0,quads:0,filtersSkipped:0});p(this,"lostListeners",[]);p(this,"restoredListeners",[]);p(this,"tris",new Int32Array(192));p(this,"sU",0);p(this,"sV0",0);p(this,"sV1",0);p(this,"sColor",0);p(this,"sPacked",0);p(this,"sAlpha",0);p(this,"sHw",0);p(this,"strokeSeg",()=>{let e=this.q;e.set(Sn),e[8]=e[10]=this.sU,e[9]=this.sV0,e[11]=this.sV1,e[12]=this.sPacked,this.put(this.kit)});p(this,"strokeDisc",()=>this.ellipse(Sn[0],Sn[1],this.sHw,this.sHw,0,this.sColor,this.sAlpha));p(this,"q",new Float64Array(13));p(this,"layers",[]);p(this,"layerTex",new Map);p(this,"bScis",!1);p(this,"bx0",0);p(this,"by0",0);p(this,"bx1",0);p(this,"by1",0);p(this,"onContextLost",e=>{e.preventDefault(),this.lost=!0;for(let t of this.lostListeners)t()});p(this,"onContextRestored",()=>{try{this.layers=[],this.layerTex.clear(),this.fxr=null,this.resetLayers(this.scale),this.setup();for(let e of this.textures.keys())this.textures.set(e,this.upload(e.source));this.lost=!1;for(let e of this.restoredListeners)e()}catch(e){console.warn("[engine] WebGL restore failed:",e)}});p(this,"views",new Map);this.kind=r===2?"webgl2":"webgl1",this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),this.setup(),this.kit=this.createTexture(Yo()),Me.live=this,e.addEventListener("webglcontextlost",this.onContextLost,!1),e.addEventListener("webglcontextrestored",this.onContextRestored,!1)}setup(){let e=this.gl,t=this.kind==="webgl2"?e:null;if(this.inst=null,this.opts.instancing!==!1)if(t)this.inst={divisor:(f,h)=>t.vertexAttribDivisor(f,h),draw:(f,h)=>t.drawElementsInstanced(e.TRIANGLES,f,e.UNSIGNED_SHORT,0,h)};else{let f=e.getExtension("ANGLE_instanced_arrays");f&&(this.inst={divisor:(h,m)=>f.vertexAttribDivisorANGLE(h,m),draw:(h,m)=>f.drawElementsInstancedANGLE(e.TRIANGLES,h,e.UNSIGNED_SHORT,0,m)})}if(this.vaoApi=null,this.opts.vao!==!1)if(t)this.vaoApi={create:()=>t.createVertexArray(),bind:f=>t.bindVertexArray(f),remove:f=>t.deleteVertexArray(f)};else{let f=e.getExtension("OES_vertex_array_object");f&&(this.vaoApi={create:()=>f.createVertexArrayOES(),bind:h=>f.bindVertexArrayOES(h),remove:h=>f.deleteVertexArrayOES(h)})}let r=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),o=Math.max(1,Math.min(Ko,r)),a=this.inst!==null;this.vsrc=a?ll:il,this.attrs=a?ul:hl,this.main=this.cur=this.build(al(o));let i=this.main.p;e.useProgram(i),this.calls.useProgram++,this.unit=-1,this.onUnit.fill(void 0),this.fbNow=void 0,this.uScale=this.main.uScale,e.uniform1iv(e.getUniformLocation(i,"uTex"),Int32Array.from({length:o},(f,h)=>h)),this.batch=new qn(a,o),this.vaoApi&&(this.vao=this.vaoApi.create(),this.vaoApi.bind(this.vao)),this.dynamic=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.dynamic),e.bufferData(e.ARRAY_BUFFER,this.batch.f32.byteLength,e.DYNAMIC_DRAW),this.index=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.index),e.bufferData(e.ELEMENT_ARRAY_BUFFER,Io(a?1:8192),e.STATIC_DRAW);let u=f=>e.getAttribLocation(i,f),c=(f,h,m,b,y,d,x)=>{let g=u(f);g<0||(e.enableVertexAttribArray(g),e.vertexAttribPointer(g,h,m,b,y,d),this.inst&&this.inst.divisor(g,x))};if(a){let f=56;c("aP01",4,e.FLOAT,!1,f,0,1),c("aP23",4,e.FLOAT,!1,f,16,1),c("aUvRect",4,e.FLOAT,!1,f,32,1),c("aColor",4,e.UNSIGNED_BYTE,!0,f,48,1),c("aSlot",1,e.FLOAT,!1,f,52,1),this.staticBuf=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.staticBuf),e.bufferData(e.ARRAY_BUFFER,Float32Array.of(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),e.STATIC_DRAW),c("aCorner",4,e.FLOAT,!1,16,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.dynamic)}else{let f=24;c("aPos",2,e.FLOAT,!1,f,0,0),c("aUv",2,e.FLOAT,!1,f,8,0),c("aColor",4,e.UNSIGNED_BYTE,!0,f,16,0),c("aSlot",1,e.FLOAT,!1,f,20,0)}e.enable(e.BLEND),e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA),e.disable(e.DEPTH_TEST),e.disable(e.CULL_FACE),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);let l=e.getExtension("WEBGL_debug_renderer_info");this.info={version:e.getParameter(e.VERSION),renderer:l?e.getParameter(l.UNMASKED_RENDERER_WEBGL):e.getParameter(e.RENDERER),vendor:l?e.getParameter(l.UNMASKED_VENDOR_WEBGL):e.getParameter(e.VENDOR)},this.features={instancing:a,vao:this.vaoApi!==null,textureSlots:o,maxTextureSize:this.maxTextureSize}}upload(e){let t=this.gl,r=t.createTexture();return this.bindTex(r),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),r}resize(e,t){this.canvas.width!==e&&(this.canvas.width=e),this.canvas.height!==t&&(this.canvas.height=t)}createTexture(e){let t={id:gn(),width:e.width,height:e.height,source:e};return this.textures.set(t,this.lost?null:this.upload(e)),t}updateTexture(e,t,r=0,o=0){if(this.lost)return;this.batch.has(e)&&this.flush();let a=this.gl,i=this.textures.get(e);i&&(this.bindTex(i),!t||t===e.source&&r===0&&o===0?a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,e.source):a.texSubImage2D(a.TEXTURE_2D,0,r,o,a.RGBA,a.UNSIGNED_BYTE,t))}destroyTexture(e){this.batch.has(e)&&this.flush();let t=this.textures.get(e);t&&!this.lost&&this.deleteTex(t),this.textures.delete(e)}begin(e,t,r){if(this.stats.drawCalls=this.stats.quads=this.stats.filtersSkipped=0,this.batch.reset(),this.resetLayers(r),this.bScis=!1,this.lost)return;let o=this.gl;o.disable(o.SCISSOR_TEST),this.bindFb(null),o.viewport(0,0,this.canvas.width,this.canvas.height);let a=t;o.clearColor((e>>16&255)/255*a,(e>>8&255)/255*a,(e&255)/255*a,a),o.clear(o.COLOR_BUFFER_BIT),this.use(this.main),o.uniform2f(this.uScale,2*r/this.canvas.width,-2*r/this.canvas.height),this.mapped=!0}build(e){let t=this.gl,r=Qo(t,t.VERTEX_SHADER,this.vsrc),o;try{o=Qo(t,t.FRAGMENT_SHADER,e)}catch(i){throw t.deleteShader(r),i}let a=t.createProgram();if(t.attachShader(a,r),t.attachShader(a,o),this.attrs.forEach((i,u)=>t.bindAttribLocation(a,u,i)),t.linkProgram(a),t.deleteShader(r),t.deleteShader(o),!t.getProgramParameter(a,t.LINK_STATUS)){let i=t.getProgramInfoLog(a)??"?";throw t.deleteProgram(a),new Error(`link: ${i}`)}return{p:a,uScale:t.getUniformLocation(a,"uScale"),locs:new Map}}u(e,t){let r=e.locs.get(t);return r===void 0&&e.locs.set(t,r=this.gl.getUniformLocation(e.p,t)),r}use(e){this.cur!==e&&(this.cur=e,this.gl.useProgram(e.p),this.calls.useProgram++)}bindTex(e,t=this.unit<0?0:this.unit){let r=this.gl;this.onUnit[t]!==e&&(this.unit!==t&&(r.activeTexture(r.TEXTURE0+t),this.calls.activeTexture++,this.unit=t),r.bindTexture(r.TEXTURE_2D,e),this.calls.bindTexture++,this.onUnit[t]=e)}deleteTex(e){this.gl.deleteTexture(e);for(let t=0;t<this.onUnit.length;t++)this.onUnit[t]===e&&(this.onUnit[t]=null)}bindFb(e){if(e)for(let r=0;r<this.onUnit.length;r++)this.onUnit[r]===e.gl&&this.bindTex(null,r);let t=e?e.fb:null;this.fbNow!==t&&(this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,t),this.calls.bindFramebuffer++,this.fbNow=t)}slotOf(e){this.batch.full&&this.flush();let t=this.batch.slot(e);return t<0&&(this.flush(),t=this.batch.slot(e)),t}quad(e,t,r,o,a,i,u,c){Y[0]=o,Y[1]=a,Y[2]=u,this.quadQ(e,t,r,i,c)}quadQ(e,t,r,o,a){let i=Y[2];if(this.lost||i<=0)return;let u=this.q,c=Y[0],l=Y[1],f=r[4],h=r[5],m=r[0]*c,b=r[1]*c,y=r[2]*l,d=r[3]*l;u[0]=f,u[1]=h,u[2]=m+f,u[3]=b+h,u[4]=m+y+f,u[5]=b+d+h,u[6]=y+f,u[7]=d+h;let x=1/e.width,g=1/e.height;u[8]=t.x*x,u[9]=t.y*g,u[10]=(t.x+t.w)*x,u[11]=(t.y+t.h)*g,u[12]=ut(o,i,a==="add"),this.put(e)}put(e){if(this.mute)return;let t=this.q,r=!1,o=Math.min(t[0],t[2],t[4],t[6]),a=Math.max(t[0],t[2],t[4],t[6]),i=Math.min(t[1],t[3],t[5],t[7]),u=Math.max(t[1],t[3],t[5],t[7]);if(this.cOn){if(this.px1<=this.px0||this.py1<=this.py0)return;let l=this.scale,f=this.px0/l,h=this.py0/l,m=this.px1/l,b=this.py1/l;if(a<=f||o>=m||u<=h||i>=b)return;if(o<f||a>m||i<h||u>b){let y=t[0],d=t[1],x=t[2],g=t[5];if(d===t[3]&&x===t[4]&&g===t[7]&&t[6]===y){if(y!==x){let v=Math.min(Math.max(y,f),m),w=Math.min(Math.max(x,f),m),T=t[8],M=(t[10]-T)/(x-y);t[10]=T+(w-y)*M,t[8]=T+(v-y)*M,t[0]=t[6]=v,t[2]=t[4]=w}if(d!==g){let v=Math.min(Math.max(d,h),b),w=Math.min(Math.max(g,h),b),T=t[9],M=(t[11]-T)/(g-d);t[11]=T+(w-d)*M,t[9]=T+(v-d)*M,t[1]=t[3]=v,t[5]=t[7]=w}}else r=!0}}let c=this.bx0===this.px0&&this.by0===this.py0&&this.bx1===this.px1&&this.by1===this.py1;if(r?(!this.bScis||!c)&&(this.flush(),this.bScis=!0,this.bx0=this.px0,this.by0=this.py0,this.bx1=this.px1,this.by1=this.py1):this.bScis&&!(this.cOn&&c)&&(this.flush(),this.bScis=!1),this.real){let l=this.gq;l[0]=o,l[1]=i,l[2]=a,l[3]=u,this.growQ()}this.batch.pushQ(t,this.slotOf(e))}ellipse(e,t,r,o,a,i,u){if(this.lost||u<=0||r<=0||o<=0)return;let c=nr[Vr(Math.max(r,o)*2*this.scale,jo)],l=c.w/2/c.r,f=r*l,h=o*l,m=Math.cos(a),b=Math.sin(a),y=m*f,d=b*f,x=-b*h,g=m*h,v=1/256,w=this.q;w[0]=e-y-x,w[1]=t-d-g,w[2]=e+y-x,w[3]=t+d-g,w[4]=e+y+x,w[5]=t+d+g,w[6]=e-y+x,w[7]=t-d+g,w[8]=c.x*v,w[9]=c.y*v,w[10]=(c.x+c.w)*v,w[11]=(c.y+c.h)*v,w[12]=ut(i,u),this.put(this.kit)}polygon(e,t,r,o){if(this.lost||o<=0||t<3)return;this.tris.length<t*3&&(this.tris=new Int32Array(Math.max(t*3,this.tris.length*2)));let a=this.tris,i=Vo(e,t,a),u=ut(r,o),c=(at.x+at.w/2)/256,l=(at.y+at.h/2)/256;for(let f=0;f<i;f+=3){let h=a[f]*2,m=a[f+1]*2,b=a[f+2]*2,y=this.q;y[0]=e[h],y[1]=e[h+1],y[2]=e[m],y[3]=e[m+1],y[4]=y[6]=e[b],y[5]=y[7]=e[b+1],y[8]=y[10]=c,y[9]=y[11]=l,y[12]=u,this.put(this.kit)}}stroke(e,t,r,o,a,i){if(this.lost||a<=0||r<=0||t<1)return;let u=rr[Vr(r*this.scale,qo)],c=r/2*(u.h/2/u.r);this.sPacked=ut(o,a),this.sColor=o,this.sAlpha=a,this.sU=(u.x+u.w/2)/256,this.sV0=u.y/256,this.sV1=(u.y+u.h)/256,this.sHw=r/2,Wo(e,t,c,i,this.strokeSeg,this.strokeDisc)}target(e,t,r,o){let a=this.gl,i=a.createTexture();this.bindTex(i),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,e,t,0,a.RGBA,a.UNSIGNED_BYTE,null);let u=o?a.LINEAR:a.NEAREST;a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,u),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,u),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),this.bindTex(null);let c=a.createFramebuffer();a.bindFramebuffer(a.FRAMEBUFFER,c),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,i,0);let l=a.checkFramebufferStatus(a.FRAMEBUFFER)===a.FRAMEBUFFER_COMPLETE;if(this.fbNow=c,this.bindFb(this.parent()),!l)return this.deleteTex(i),a.deleteFramebuffer(c),null;let f={tex:{id:gn(),width:e,height:t,source:this.canvas},gl:i,fb:c,w:e,h:t,f:r};return this.layerTex.set(f.tex,i),f}drop(e){this.batch.has(e.tex)&&this.flush(),this.deleteTex(e.gl),this.gl.deleteFramebuffer(e.fb),this.layerTex.delete(e.tex)}parent(){return this.real>0?this.layers[this.real-1]:null}layerAt(e){let t=this.canvas.width,r=this.canvas.height,o=this.layers[e]??null;return o&&(o.w!==t||o.h!==r)&&(this.drop(o),o=this.layers[e]=null),o??(this.layers[e]=this.target(t,r,1,!1))}pushLayer(){if(this.lost)return!1;this.flush();let e=this.layerAt(this.real);if(!e)return!1;let t=this.gl;return this.bindFb(e),t.disable(t.SCISSOR_TEST),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),!0}popLayer(){return this.flush(),this.bindFb(this.parent()),this.layers[this.real].tex}filters(){return this.lost||!Me.gl?null:this.fxr??(this.fxr=Me.gl(this))}composite(e,t,r,o){if(o&&this.filters()?.chain(e,r,o))return;let a=this.gl;t&&a.blendFunc(a.ZERO,a.SRC_ALPHA),this.final(this.main,e,1,r),t&&(this.flush(),a.blendFunc(a.ONE,a.ONE_MINUS_SRC_ALPHA))}final(e,t,r,o){let a=this.gl,i=this.canvas.width,u=this.canvas.height,c=this.scale;(e!==this.main||!this.mapped)&&(this.bindFb(this.parent()),a.viewport(0,0,i,u),this.use(e),a.uniform2f(e.uScale,2*c/i,-2*c/u),this.mapped=e===this.main);let l=this.rx0/c,f=this.ry0/c,h=this.rx1/c,m=this.ry1/c,b=1/(r*t.width),y=1/(r*t.height),d=this.q;d[0]=d[6]=l,d[1]=d[3]=f,d[2]=d[4]=h,d[5]=d[7]=m,d[8]=this.rx0*b,d[9]=1-this.ry0*y,d[10]=this.rx1*b,d[11]=1-this.ry1*y,d[12]=ut(16777215,o),this.put(t),e!==this.main&&this.flush()}remap(){let e=this.gl;this.bindFb(this.parent()),e.viewport(0,0,this.canvas.width,this.canvas.height),this.use(this.main),e.uniform2f(this.uScale,2*this.scale/this.canvas.width,-2*this.scale/this.canvas.height),this.mapped=!0}upload2(e){let t=this.gl,r=e.words;if(this.kind==="webgl2")return t.bufferSubData(t.ARRAY_BUFFER,0,e.f32,0,r);let o=this.views.get(r);o||(this.views.size>=256&&this.views.clear(),this.views.set(r,o=e.f32.subarray(0,r))),t.bufferSubData(t.ARRAY_BUFFER,0,o)}flush(){let e=this.batch;if(!e.quads||this.lost)return e.reset();let t=this.gl;this.bScis?(t.enable(t.SCISSOR_TEST),t.scissor(this.bx0,this.canvas.height-this.by1,this.bx1-this.bx0,this.by1-this.by0)):t.disable(t.SCISSOR_TEST),this.upload2(e);for(let r=0;r<e.bound;r++){let o=e.textures[r];this.bindTex(this.textures.get(o)??this.layerTex.get(o)??null,r)}this.inst?this.inst.draw(6,e.quads):t.drawElements(t.TRIANGLES,e.quads*6,t.UNSIGNED_SHORT,0),this.stats.drawCalls++,this.stats.quads+=e.quads,e.reset()}end(){return this.closeLayers(),this.flush(),this.stats.filtersSkipped=this.skipped,this.stats}onLost(e){this.lostListeners.push(e)}onRestored(e){this.restoredListeners.push(e)}destroy(){let e=this.gl;Me.live===this&&(Me.live=null),this.canvas.removeEventListener("webglcontextlost",this.onContextLost),this.canvas.removeEventListener("webglcontextrestored",this.onContextRestored);try{for(let t of this.textures.values())t&&e.deleteTexture(t);for(let t of this.layers)t&&(e.deleteTexture(t.gl),e.deleteFramebuffer(t.fb));this.fxr?.destroy(),this.fxr=null,e.deleteBuffer(this.dynamic),e.deleteBuffer(this.index),this.staticBuf&&e.deleteBuffer(this.staticBuf),this.vao&&this.vaoApi&&this.vaoApi.remove(this.vao),e.deleteProgram(this.main.p),e.getExtension("WEBGL_lose_context")?.loseContext()}catch{}this.textures.clear()}};function Qo(s,n,e){let t=s.createShader(n);if(s.shaderSource(t,e),s.compileShader(t),!s.getShaderParameter(t,s.COMPILE_STATUS)){let r=s.getShaderInfoLog(t)??"?";throw s.deleteShader(t),new Error(r)}return t}function Xr(s="auto"){switch(s){case"canvas2d":return["canvas2d"];case"webgl1":return["webgl1","canvas2d"];default:return["webgl2","webgl1","canvas2d"]}}function Qt(s,n={}){let e=s;for(let t of Xr(n.renderer)){let r=t==="canvas2d"?Yt(e):Zo(e,t==="webgl2"?2:1,n);if(r)return r;e=Mn(e)}throw new Error("No renderer: this browser has neither WebGL nor Canvas 2D")}function Mn(s){let n=s.cloneNode(!1);return s.parentNode?.replaceChild(n,s),n}function Jo(s=typeof location<"u"?location.search:""){let n=new URLSearchParams(s).get("renderer");return n==="canvas"?"canvas2d":n==="webgl2"||n==="webgl1"||n==="canvas2d"||n==="webgl"||n==="auto"?n:void 0}var yt=class{constructor(n,e={}){p(this,"atlas",n);p(this,"tags",new Map);p(this,"count",0);p(this,"m",rt());p(this,"measure",null);p(this,"height");p(this,"font");this.height=e.tagHeight??34,this.font=e.tagFont??"Nunito, sans-serif"}drop(){for(let n of this.tags.values())for(let e of n.values())for(let t of e.values())this.atlas.release(t);this.tags.clear(),this.count=0}get(n,e,t){let r=this.tags.get(n);r||this.tags.set(n,r=new Map);let o=r.get(e);o||r.set(e,o=new Map);let a=o.get(t);return a&&this.atlas.valid(a)?a:this.bake(n,e,t)}bake(n,e,t){let r=this.height,o=`700 ${Math.round(r*.65)}px ${this.font}`,a=this.measure??(this.measure=document.createElement("canvas").getContext("2d"));a.font=o;let i=Math.round(r*.4),u=Math.ceil(a.measureText(n).width)+i*2,c=this.atlas.bake((u+2)*t,(r+2)*t,h=>{h.scale(t,t),h.translate(1,1);let m=r/2;h.beginPath(),h.moveTo(m,0),h.lineTo(u-m,0),h.arc(u-m,m,m,-Math.PI/2,Math.PI/2),h.lineTo(m,r),h.arc(m,m,m,Math.PI/2,Math.PI*3/2),h.closePath(),h.fillStyle=e,h.fill(),h.fillStyle="#fff",h.font=o,h.textAlign="center",h.textBaseline="middle",h.fillText(n,u/2,r/2+1)},t,1,1,1);++this.count>64&&(this.drop(),this.count=1);let l=this.tags.get(n);l||this.tags.set(n,l=new Map);let f=l.get(e);return f||l.set(e,f=new Map),f.set(t,c),c}draw(n,e,t,r,o,a,i,u,c,l,f){let h=Dt(t,o,{band:fl(r)});if(!h)return;let m=this.height,b=this.get(a,i,c),y=b.w/b.scale-2,d=Math.min(Math.max(h.head.x-y/2,4),l-y-4),x=Math.min(Math.max(h.head.y-h.headR*2.2-m,4),f-m-4);Se(this.m,null,d-1,x-1,0,1,1),n.quad(e(b.surface),b,this.m,b.w/b.scale,b.h/b.scale,16777215,u,"normal")}},fl=s=>s.band==="3-5"||s.band==="9-12"?s.band:"6-8";var pl=(s,n=!1)=>n?Math.min(2**Math.round(Math.log2(Math.max(s,8))),256):Math.min(2**(Math.ceil(Math.log2(Math.max(s,8))*2)/2),512);function ar(s,n=null){let e={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},t=(r,o,a)=>{let i=n?n[0]*r+n[2]*o+n[4]:r,u=n?n[1]*r+n[3]*o+n[5]:o,c=n?Math.hypot(n[0],n[1]):1;e.minX=Math.min(e.minX,i-a*c),e.minY=Math.min(e.minY,u-a*c),e.maxX=Math.max(e.maxX,i+a*c),e.maxY=Math.max(e.maxY,u+a*c)};for(let r of s){let o="lw"in r&&r.stroke?(r.lw??1)/2:0;switch(r.k){case"circle":t(r.x-r.r,r.y-r.r,o),t(r.x+r.r,r.y+r.r,o),t(r.x-r.r,r.y+r.r,o),t(r.x+r.r,r.y-r.r,o);break;case"ellipse":case"rect":{let a=r.k==="ellipse"?Math.max(r.rx,r.ry):Math.hypot(r.w,r.h)/2;t(r.x-a,r.y-a,o),t(r.x+a,r.y+a,o),t(r.x-a,r.y+a,o),t(r.x+a,r.y-a,o);break}case"path":{let a=tr(r.d);for(let i=0;i<a.count;i++){let u=a.subs[i];for(let c=0;c<u.n;c++)t(u.pts[c*2],u.pts[c*2+1],o)}break}case"line":for(let a=0;a+1<r.pts.length;a+=2)t(r.pts[a],r.pts[a+1],o);break;case"group":{let a=Se(rt(),n,r.x,r.y,r.rot??0,r.s??1,r.s??1),i=ar(r.items,a);Number.isFinite(i.minX)&&(e.minX=Math.min(e.minX,i.minX),e.minY=Math.min(e.minY,i.minY),e.maxX=Math.max(e.maxX,i.maxX),e.maxY=Math.max(e.maxY,i.maxY));break}}}return e}var Ct=class{constructor(n){p(this,"atlas",n);p(this,"seen",new WeakSet);p(this,"baked",new WeakMap);p(this,"m",rt());p(this,"stack",[]);p(this,"local",rt());p(this,"pts",new Float64Array(128));p(this,"stats",{baked:0,vector:0});p(this,"bakeGroups",!0);p(this,"coarse",!1);p(this,"gen",0);p(this,"live",new Set)}setTier(n){let e=n==="low";if(e!==this.coarse){this.coarse=e,this.gen++;for(let t of this.live)this.atlas.release(t.frame);this.live.clear()}}draw(n,e,t,r,o,a,i){let u=typeof r=="string"?zt(r)??St:r,c=dn(t,u,o);return c.length?(a<=0||(a<1?(this.paint(n,e,c,null,n.beginLayer()?1:a,i),n.endLayer(a)):this.paint(n,e,c,null,a,i)),!0):!1}paint(n,e,t,r,o,a,i=0){var u;for(let c=0;c<t.length;c++){let l=t[c];if(l.k==="group"){let g=Se((u=this.stack)[i]??(u[i]=rt()),r,l.x,l.y,l.rot??0,l.s??1,l.s??1),v=o*(l.alpha??1);if(this.bakeGroups&&this.seen.has(l.items)){let w=je(g[0],g[1])*a,T=this.bake(l.items,w);if(T){let M=T.frame,P=this.m;P.set(g),P[4]=g[0]*-T.ox+g[2]*-T.oy+g[4],P[5]=g[1]*-T.ox+g[3]*-T.oy+g[5],n.quad(e(M.surface),M,P,M.w/T.k,M.h/T.k,16777215,v,"normal"),this.stats.baked++;continue}}this.seen.add(l.items),this.stats.vector++,this.paint(n,e,l.items,g,v,a,i+1);continue}let f=o*(l.alpha??1),h=r?je(r[0],r[1]):1,m=r?Math.atan2(r[1],r[0]):0,b=(l.lw??1)*h,y=l.stroke&&(l.lw??1)>0?de(l.stroke):null,d=l.fill&&l.k!=="line"?de(l.fill):null;if(l.k==="circle"||l.k==="ellipse"){let g=r?r[0]*l.x+r[2]*l.y+r[4]:l.x,v=r?r[1]*l.x+r[3]*l.y+r[5]:l.y,w=(l.k==="circle"?l.r:l.rx)*h,T=(l.k==="circle"?l.r:l.ry)*h,M=(l.k==="ellipse"?l.rot??0:0)+m;if(d&&y)n.ellipse(g,v,w+b/2,T+b/2,M,y[0],f*y[1]),n.ellipse(g,v,Math.max(w-b/2,0),Math.max(T-b/2,0),M,d[0],f*d[1]);else if(d)n.ellipse(g,v,w,T,M,d[0],f*d[1]);else if(y){let P=Math.min(Math.max(Math.ceil(Math.max(w,T)*a*.6),12),64),L=this.pts=er(this.pts,P*2),F=Math.cos(M),B=Math.sin(M);for(let G=0;G<P;G++){let W=G/P*Math.PI*2,H=Math.cos(W)*w,me=Math.sin(W)*T;L[G*2]=g+H*F-me*B,L[G*2+1]=v+H*B+me*F}n.stroke(L,P,b,y[0],f*y[1],!0)}continue}if(l.k==="line"){if(!y)continue;let g=l.pts.length>>1,v=this.pts=er(this.pts,g*2);for(let w=0;w<g;w++){let T=l.pts[w*2],M=l.pts[w*2+1];v[w*2]=r?r[0]*T+r[2]*M+r[4]:T,v[w*2+1]=r?r[1]*T+r[3]*M+r[5]:M}n.stroke(v,g,b,y[0],f*y[1],!1);continue}let x=l.k==="path"?tr(l.d,r,h*a):dl(l,Se(this.local,r,l.x,l.y,l.rot??0,1,1),a*h);for(let g=0;g<x.count;g++){let v=x.subs[g],w=v.n,T=l.k==="rect"||v.closed;d&&w>=3&&(n.polygon(v.pts,w,d[0],f*d[1]),y||n.stroke(v.pts,w,1/a,d[0],f*d[1],!0)),y&&n.stroke(v.pts,w,b,y[0],f*y[1],T)}}}bake(n,e){let t=pl(e,this.coarse),r=this.baked.get(n),o=r?.get(t);if(o&&o.gen===this.gen&&this.atlas.valid(o.frame))return o;o&&this.live.delete(o);let a=ar(n);if(!Number.isFinite(a.minX))return null;let i=2/t,u=(a.maxX-a.minX+i*2)*t,c=(a.maxY-a.minY+i*2)*t;if(u>1024||c>1024)return null;let l=-a.minX+i,f=-a.minY+i,m={frame:this.atlas.bake(u,c,b=>{b.scale(t,t),b.translate(l,f),It(b,n)}),k:t,ox:l,oy:f,gen:this.gen};return r||this.baked.set(n,r=new Map),r.set(t,m),this.live.add(m),m}},Zt=new Array(36).fill(0),Jt=0,qe=(s,n=NaN,e=NaN,t=NaN,r=NaN)=>{Zt[Jt++]=s,s!==ge.Z&&(Zt[Jt++]=n,Zt[Jt++]=e,s===ge.Q&&(Zt[Jt++]=t,Zt[Jt++]=r))};function dl(s,n,e){let t=Math.max(0,Math.min(s.r,s.w/2,s.h/2)),r=-s.w/2,o=-s.h/2,{M:a,L:i,Q:u,Z:c}=ge;return Jt=0,qe(a,r+t,o),qe(i,r+s.w-t,o),qe(u,r+s.w,o,r+s.w,o+t),qe(i,r+s.w,o+s.h-t),qe(u,r+s.w,o+s.h,r+s.w-t,o+s.h),qe(i,r+t,o+s.h),qe(u,r,o+s.h,r,o+s.h-t),qe(i,r,o+t),qe(u,r,o,r+t,o),qe(c),tr(Zt,n,e)}function ea(s,n={}){let e=Qt(s,n),t=new pt(Math.min(1024,e.maxTextureSize),2);t.onDrop=M=>{M.texture&&e.destroyTexture(M.texture),M.texture=null};let r=new Ct(t),o=()=>{let M=new Xn;return n.local&&M.setLocal(!0),M},a=o(),i=new Map,u=1e6,c=n.smooth===!1?1:typeof n.smooth=="number"?Math.min(Math.max(n.smooth,.05),1):a.defaultAmount,l=Tn(e),f=new yt(t,n),h={w:1,h:1},m=1,b=0,y=!1,d=()=>f.drop(),x=typeof document<"u"?document.fonts:void 0;x?.ready?.then(()=>{y||d()}),x?.addEventListener?.("loadingdone",d);let g=()=>{let M=Mn(e.canvas),P=Yt(M);if(P){console.warn("[engine] avatars: WebGL context lost for good, switching to Canvas 2D"),e.destroy(),e=P;for(let L of t.pages)L.surface.texture=null;l=Tn(e),b=0}},v=()=>{if(!e.lost)return b=0,!0;let M=performance.now();return b||(b=M),M-b>3e3&&g(),!e.lost},w=()=>{let M=e.canvas;n.units?(m=n.pixelRatio??1,h.w=n.units.width,h.h=n.units.height):(m=n.pixelRatio??Math.min(globalThis.devicePixelRatio||1,2),h.w=M.clientWidth||M.width/m,h.h=M.clientHeight||M.height/m),e.resize(Math.max(1,Math.round(h.w*m)),Math.max(1,Math.round(h.h*m))),e.begin(0,0,m)},T=(M,P)=>{if(M.key===void 0)return M.id??P+1;let L=i.get(M.key);return L===void 0&&(i.size>256&&i.clear(),i.set(M.key,L=u++)),L};return{get renderer(){return e},get kind(){return e.kind},get lost(){return e.lost},get canvas(){return e.canvas},draw(M,P){if(v()){w();for(let L=0;L<M.length;L++){let F=M[L];if(!Array.isArray(F.body))continue;let B=T(F,L),G=c<1||n.interpolate!==!1?a.posed(B,F.body,c,n.interpolate!==!1):F.body,W=zt(F.avatar??"")??St,H=F.alpha??1;!r.draw(e,l,G,W,P,H,m)||!F.name||f.draw(e,l,G,W,P,F.name,F.color??"#6FA0E0",H,m,h.w,h.h)}e.end()}},clear(){v()&&(w(),e.end())},reset(){a=o(),i.clear()},destroy(){y=!0,x?.removeEventListener?.("loadingdone",d),e.destroy()}}}var or=new Map;function ta(s,n,e=Math.min(globalThis.devicePixelRatio||1,2)){let t=`${s}|${n}|${e}`,r=or.get(t);if(r)return r;r=document.createElement("canvas"),r.width=r.height=Math.round(n*e);let o=r.getContext("2d");return o.scale(e,e),o.beginPath(),o.rect(0,0,n,n),o.clip(),It(o,ao(zt(s)??St,n)),or.size>64&&or.clear(),or.set(t,r),r}function Tn(s){return n=>{if(n.texture||(n.texture=s.createTexture(n.source),n.pending.length=0),n.pending.length){for(let[e,t,r]of n.pending)s.updateTexture(n.texture,e,t,r);n.pending.length=0}return n.texture}}var jr='Fredoka, Nunito, "Varela Round", system-ui, sans-serif',Ft="rgba(10,16,30,0.75)";function qr(s,n){let e=s.size??40,t=s.outline?s.outline===!0?Ft:s.outline:null,r=t?s.outlineWidth??Math.max(e*.12,3):0,o=s.shadow&&n?s.shadow===!0?Ft:s.shadow:null,a=o?s.shadowBlur??e*.25:0;return{size:e,font:s.font??jr,weight:s.weight??700,color:s.color??"#FBEFE3",outline:t,ow:r,shadow:o,blur:a,pad:r/2+a*1.2+2,th:e*1.25}}var na=(s,n)=>`${s.weight} ${s.size*n}px ${s.font}`;function Yr(s,n,e,t,r,o){s.scale(t,t),s.font=na(e,1),s.textBaseline="middle",s.textAlign="left",s.lineJoin="round",e.shadow&&(s.shadowColor=e.shadow,s.shadowBlur=e.blur*t),e.outline&&(s.strokeStyle=e.outline,s.lineWidth=e.ow,s.strokeText(n,r,o),s.shadowColor="transparent"),s.fillStyle=e.color,s.fillText(n,r,o)}var ir=null;function Kr(s,n,e){return ir??(ir=document.createElement("canvas").getContext("2d")),ir.font=na(n,e),ir.measureText(s).width/e}var Ye=class extends Te{constructor(e,t,r={}){super(e,null);p(this,"_text");p(this,"_style");p(this,"dirty",!0);p(this,"bakedScale",0);p(this,"bakedFontGen",-1);p(this,"bakedEffects",!0);p(this,"capW",0);p(this,"capH",0);this._text=t;let{x:o,y:a,rotation:i,scale:u,scaleX:c,scaleY:l,alpha:f,visible:h,tint:m,blend:b,z:y,anchor:d,hitRadius:x,clip:g,mask:v,filters:w,...T}=r;this._style=T,this.bake(),this.set({x:o,y:a,rotation:i,scale:u,scaleX:c,scaleY:l,alpha:f,visible:h,tint:m,blend:b,z:y,hitRadius:x,clip:g,mask:v,filters:w}),d!==void 0&&(this.anchor=d)}get text(){return this._text}set text(e){let t=String(e);t!==this._text&&(this._text=t,this.dirty=!0)}get style(){return this._style}set style(e){this._style={...this._style,...e},this.dirty=!0}bitmap(){let e=this._style.bitmapFont;if(!e)return null;let t=typeof e=="string"?this.kernel.bitmapFont(e):e;if(this.autoAnchor){let r=this._style.align;this.anchorX=r==="left"?0:r==="right"?1:.5,this.anchorY=.5}return t}get naturalWidth(){let e=this.bitmap();return e?e.measure(this._text)*((this._style.size??e.size)/e.size):super.naturalWidth}get naturalHeight(){let e=this.bitmap();return e?e.lineHeight*((this._style.size??e.size)/e.size):super.naturalHeight}frameNow(){return this._style.bitmapFont?null:this.bake()}draw(e,t,r){let o=this.bitmap();if(!o)return super.draw(e,t,r);let a=(this._style.size??o.size)/o.size,i=o.measure(this._text)*a,u=o.lineHeight*a,c=this.width,l=this.height,f=i>0?c/i:1,h=u>0?l/u:1;o.run(this._text,e,this.world,-this.anchorX*c,-this.anchorY*l,a*f,a*h,r,t,this.blend)}destroy(){this._frame&&this.kernel.atlas.release(this._frame),super.destroy()}bake(){let e=this.kernel;if(this._style.bitmapFont)return null;let t=e.pixelScale,r=e.effects;return!this.dirty&&t===this.bakedScale&&e.fontGen===this.bakedFontGen&&r===this.bakedEffects&&e.atlas.valid(this._frame)?this._frame:this.rebake()}rebake(){let e=this.kernel,t=e.pixelScale,r=e.effects;this.dirty=!1,this.bakedScale=t,this.bakedFontGen=e.fontGen,this.bakedEffects=r;let o=qr(this._style,r),{pad:a,th:i}=o,u=Kr(this._text,o,t),c=(u+a*2)*t,l=(i+a*2)*t,f=this._style.align??"center",h=f==="left"?a:f==="right"?a+u:a+u/2,m=d=>Yr(d,this._text,o,t,a,a+i/2),b=this._frame,y=null;return b&&e.atlas.valid(b)&&b.scale===t&&(y=e.atlas.rebake(b,c,l,m,this.capW,this.capH),y?Object.assign(y,{ox:h,oy:a+i/2,margin:a}):e.atlas.release(b)),y||(this.capW=Math.ceil(c*1.25+16),this.capH=Math.ceil(l),y=e.atlas.bake(this.capW,this.capH,m,t,h,a+i/2,a),y.w=Math.ceil(c),y.h=Math.ceil(l)),this._frame=y,this.autoAnchor&&this.useFrameAnchor(),this._w=this._h=null,y}};var ue=(s,n=0)=>{let e=Number(s);return Number.isFinite(e)?e:n};function tn(s){typeof s=="string"&&/^\s*[{[]/.test(s)&&(s=JSON.parse(s));let n={size:0,lineHeight:0,base:0,pages:[],chars:[],kernings:[]},e=(t,r)=>{t==="info"?n.size=Math.abs(ue(r.size)):t==="common"?(n.lineHeight=ue(r.lineHeight),n.base=ue(r.base)):t==="page"?n.pages[ue(r.id)]=String(r.file??""):t==="char"?n.chars.push({id:ue(r.id),x:ue(r.x),y:ue(r.y),width:ue(r.width),height:ue(r.height),xoffset:ue(r.xoffset),yoffset:ue(r.yoffset),xadvance:ue(r.xadvance),page:ue(r.page)}):n.kernings.push({first:ue(r.first),second:ue(r.second),amount:ue(r.amount)})};if(typeof s=="object"){let t=s;e("info",t.info??{}),e("common",t.common??{});for(let[r,o]of(t.pages??[]).entries())e("page",{id:r,file:o});for(let r of t.chars??[])e("char",r);for(let r of t.kernings??[])e("kerning",r)}else{let t=/(?:^|<)\s*(info|common|page|char|kerning)\s([^\n<>]*)/gm,r=/(\w+)=(?:"([^"]*)"|([^\s/>]+))/g;for(let o=t.exec(s);o;o=t.exec(s)){let a={};for(let i=r.exec(o[2]);i;i=r.exec(o[2]))a[i[1]]=i[2]??i[3];e(o[1],a)}}return n.size||(n.size=n.lineHeight),n}var en=class{constructor(n,e,t,r=null,o=null){p(this,"baker",r);p(this,"host",o);p(this,"size");p(this,"lineHeight");p(this,"base");p(this,"ascii",new Array(128));p(this,"more",new Map);p(this,"kern",new Map);p(this,"bScale",0);p(this,"bFontGen",-1);p(this,"bEffects",!1);p(this,"bGen",-1);this.size=n,this.lineHeight=e,this.base=t}set(n,e){n<128?this.ascii[n]=e:this.more.set(n,e)}setKerning(n,e,t){this.kern.set(n*1114112+e,t)}prepare(){let n=this.host;if(!(!n||n.pixelScale===this.bScale&&n.fontGen===this.bFontGen&&n.effects===this.bEffects&&n.atlas.gen===this.bGen)){this.bScale=n.pixelScale,this.bFontGen=n.fontGen,this.bEffects=n.effects,this.bGen=n.atlas.gen;for(let e of this.ascii)e&&n.atlas.release(e.frame);for(let e of this.more.values())e&&n.atlas.release(e.frame);this.ascii.fill(void 0),this.more.clear()}}glyph(n){let e=n<128?this.ascii[n]:this.more.get(n);return(e===void 0||e&&this.host&&!this.host.atlas.valid(e.frame))&&(e=this.baker?this.baker(n):null,this.set(n,e)),e}kerning(n,e){return this.kern.size?this.kern.get(n*1114112+e)??0:0}measure(n){return this.run(n)}run(n,e,t,r=0,o=0,a=1,i=1,u=0,c=1,l="normal"){this.prepare();let f=0,h=-1;for(let m=0;m<n.length;m++){let b=n.charCodeAt(m);b>=55296&&b<56320&&m+1<n.length&&(b=n.codePointAt(m),m++),h>=0&&(f+=this.kerning(h,b)),h=b;let y=this.glyph(b);y&&(e&&y.w>0&&y.h>0&&(wn(t,r+(f+y.x)*a,o+y.y*i),e.r.quad(e.tex(y.frame.surface),y.frame,le,y.w*a,y.h*i,u,c,l)),f+=y.advance)}return f}};function ra(s,n){let e=new en(s.size,s.lineHeight,s.base);for(let t of s.chars){let r=n[t.page];if(!r)continue;let o={surface:r,x:t.x,y:t.y,w:t.width,h:t.height,scale:1,gen:0,ox:0,oy:0,margin:0};e.set(t.id,{frame:o,x:t.xoffset,y:t.yoffset,w:t.width,h:t.height,advance:t.xadvance})}for(let t of s.kernings)e.setKerning(t.first,t.second,t.amount);return e}function sa(s,n){let e={...n},t=n.size??40,r=a=>{let i=String.fromCodePoint(a),u=s.pixelScale,c=qr(e,s.effects),l=Kr(i,c,u),f=s.atlas.bake((l+c.pad*2)*u,(c.th+c.pad*2)*u,h=>Yr(h,i,c,u,c.pad,c.pad+c.th/2),u);return{frame:f,x:-c.pad,y:-c.pad,w:f.w/u,h:f.h/u,advance:l}},o=new en(t,t*1.25,t,r,s);o.prepare();for(let a of n.chars??"0123456789")o.glyph(a.codePointAt(0));return o}var ml=.5;function Qr(s){let n=[];for(let[e,t]of[["left",z.leftWrist],["right",z.rightWrist]]){let r=s[t*3],o=s[t*3+1],a=s[t*3+2];r!==void 0&&o!==void 0&&Number.isFinite(r)&&Number.isFinite(o)&&(a??0)>=ml&&n.push({side:e,x:r,y:o})}return n}var nn=s=>fn[((s-1)%fn.length+fn.length)%fn.length],yl=["left","right"];function lr(s,n,e,t,r=()=>null,o={}){let a=[];for(let i of s){let u=r(i)??i.body;if(Array.isArray(u)){if(o.orientation==="portrait"){for(let c of yl){let l=Ds(u,c,{orientation:"portrait"});o.hold&&(l=o.hold.at(Ot.key(i.id,c),l,o.t??0)),l&&a.push({player:i.id,side:c,x:l.x*e,y:l.y*t,color:nn(i.id)})}continue}for(let c of Qr(u)){let l=n(c);a.push({player:i.id,side:c.side,x:l.x*e,y:l.y*t,color:nn(i.id)})}}}return a}function En(s,n,e,t=0){let r=s.world,o=ho(r,n,e);if(!o)return!1;let a=Math.hypot(r[0],r[1])||1,i=Math.hypot(r[2],r[3])||1,[u,c]=o;if(s.hitRadius!=null){let b=s.hitRadius+t/((a+i)/2);return u*u+c*c<=b*b}let l=-s.anchorX*s.width-t/a,f=-s.anchorY*s.height-t/i,h=(1-s.anchorX)*s.width+t/a,m=(1-s.anchorY)*s.height+t/i;return u>=l&&u<=h&&c>=f&&c<=m}function cr(s,n,e,t=0){for(let r of n)if((e===void 0||r.player===e)&&En(s,r.x,r.y,t))return r;return null}function bl(s){switch(s.type){case"circle":case"ring":case"star":return[s.r*2,s.r*2];case"ellipse":return[s.rx*2,s.ry*2];case"roundRect":return[s.w,s.h];case"line":return[s.length,s.lw??4];case"path":return s.r?[s.r*2,s.r*2]:[s.size,s.size]}}function xl(s){let n=s.type==="line"?0:s.stroke?(s.lw??2)/2:0,e=s.shadow?s.shadow.blur*1.5+Math.max(Math.abs(s.shadow.x??0),Math.abs(s.shadow.y??0)):0;return Math.ceil(n+e+1)}var oa=(s,n)=>n||!s.shadow?s:{...s,shadow:void 0};function Zr(s,n,e){let t=xl(n),r=n.type==="roundRect",[o,a]=r?[Math.min(n.w,n.r*2+4/e),Math.min(n.h,n.r*2+4/e)]:bl(n),i=(o+t*2)*e,u=(a+t*2)*e;return{frame:s.bake(i,u,l=>{l.scale(e,e),l.translate(t+o/2,t+a/2),gl(l,n,o,a)},e,t+o/2,t+a/2,t),slice:r?Math.ceil((n.r+t)*e):0,w:r?n.w:o,h:r?n.h:a}}function gl(s,n,e,t){s.lineJoin="round",s.lineCap="round";let r=new Path2D;switch(n.type){case"circle":case"ring":r.arc(0,0,n.r,0,Math.PI*2);break;case"ellipse":r.ellipse(0,0,n.rx,n.ry,0,0,Math.PI*2);break;case"roundRect":r.roundRect(-e/2,-t/2,e,t,Math.min(n.r,e/2,t/2));break;case"star":{let c=n.points??5,l=n.r*(n.inner??.5);for(let f=0;f<c*2;f++){let h=f%2?l:n.r,m=-Math.PI/2+f*Math.PI/c;f?r.lineTo(Math.cos(m)*h,Math.sin(m)*h):r.moveTo(Math.cos(m)*h,Math.sin(m)*h)}r.closePath();break}case"line":r.moveTo(-e/2+t/2,0),r.lineTo(e/2-t/2,0);break;case"path":{let c=n.r?n.r*2/n.size:1,l=new DOMMatrix([c,0,0,c,-n.size/2*c,-n.size/2*c]);r.addPath(new Path2D(n.d),l);break}}let o=n.shadow,a=()=>{if(!o)return;let c=s.getTransform();s.shadowColor=o.color,s.shadowBlur=o.blur*c.a,s.shadowOffsetX=(o.x??0)*c.a,s.shadowOffsetY=(o.y??0)*c.a},i=()=>{s.shadowColor="transparent",s.shadowBlur=0};if(n.type==="line"){a(),s.strokeStyle=n.stroke??n.fill??"#fff",s.lineWidth=t,s.stroke(r);return}let u=n.type==="ring";if(n.outlineBelow&&n.fill&&n.stroke&&!u){a(),s.strokeStyle=n.stroke,s.lineWidth=n.lw??2,s.stroke(r),i(),s.fillStyle=n.fill,s.fill(r);return}n.fill&&!u&&(a(),s.fillStyle=n.fill,s.fill(r),i()),(n.stroke||u)&&((!n.fill||u)&&a(),u&&n.fill&&(s.fillStyle=n.fill,s.fill(r)),s.strokeStyle=n.stroke??"#fff",s.lineWidth=n.lw??2,s.stroke(r),i())}var rn=class{constructor(){p(this,"ctx",null);p(this,"master",null);p(this,"buffers",new Map);p(this,"held",!1);p(this,"muted",!1);p(this,"volume",1);if(typeof addEventListener=="function"){let n=()=>{this.context()?.resume().catch(()=>{})};for(let e of["pointerdown","keydown","touchstart"])addEventListener(e,n,{once:!0,capture:!0})}}context(){if(this.ctx)return this.ctx;let n=globalThis.AudioContext??globalThis.webkitAudioContext;if(!n)return null;try{this.ctx=new n,this.master=this.ctx.createGain(),this.master.connect(this.ctx.destination),this.held&&this.ctx.suspend()}catch{return null}return this.ctx}async load(n,e){let t=this.context();if(!t)return;let r=await(await fetch(e)).arrayBuffer();this.buffers.set(n,await t.decodeAudioData(r))}has(n){return this.buffers.has(n)}play(n,e={}){let t=this.context(),r=this.buffers.get(n);if(!t||!r||!this.audible)return()=>{};let o=t.createBufferSource();o.buffer=r,o.loop=e.loop??!1,o.playbackRate.value=e.rate??1;let a=t.createGain();return a.gain.value=(e.volume??1)*this.volume,o.connect(a).connect(this.master),o.start(),()=>{try{o.stop()}catch{}}}tone(n,e=.25,t={}){let r=this.context();if(!(!r||!this.audible))try{let o=r.createOscillator(),a=r.createGain();o.type=t.type??"sine",o.frequency.setValueAtTime(n,r.currentTime),t.to&&o.frequency.exponentialRampToValueAtTime(t.to,r.currentTime+e),a.gain.setValueAtTime((t.volume??.12)*this.volume,r.currentTime),a.gain.exponentialRampToValueAtTime(.001,r.currentTime+e),o.connect(a).connect(this.master),o.start(),o.stop(r.currentTime+e)}catch{}}get audible(){return!this.muted&&!this.held}hold(){this.held=!0,this.ctx?.suspend().catch(()=>{})}release(){this.held=!1,this.ctx?.resume().catch(()=>{})}destroy(){this.ctx?.close().catch(()=>{}),this.ctx=null}};var kl={high:{resolution:1.5,particles:1,effects:!0,maxBlur:32},medium:{resolution:1,particles:.5,effects:!1,maxBlur:16},low:{resolution:.75,particles:.2,effects:!1,maxBlur:0}},Ke=["high","medium","low"];function it(s){let n=kl[s];return{name:s,...n,scale:e=>e<=0?0:Math.max(1,Math.round(e*n.particles))}}var aa=s=>Ke[Math.min(Ke.indexOf(s)+1,Ke.length-1)],ur=(s,n)=>{if(!s.length)return NaN;let e=[...s].sort((t,r)=>t-r);return e[Math.min(e.length-1,Math.max(0,Math.floor(n*(e.length-1)+.5)))]},ia=12,la=s=>Rn(s,.5);function Rn(s,n=.1){let e=ur(s,n);if(!Number.isFinite(e))return 1e3/60;let t=[144,120,90,75,60,50,30],r=60;for(let o of t)Math.abs(1e3/o-e)<Math.abs(1e3/r-e)&&(r=o);return 1e3/r}function hr(s,n){let e=n.refresh!==void 0&&Number.isFinite(n.refresh)&&n.refresh>0?n.refresh:Rn(n.intervals),t=ur(n.intervals,.5),r=ur(n.intervals,.9),o=ur(n.cpu,.5);if(!Number.isFinite(t))return s==="canvas2d"?"low":"medium";let a=u=>u<=e*1.25,i=u=>!Number.isFinite(o)||o<e*u;return s==="canvas2d"?a(r)&&i(.25)?"medium":"low":a(r)&&i(.5)?"high":a(t)?"medium":"low"}function ca(s,n){return s.length<30?!1:s.filter(t=>t>n*1.5).length/s.length>.5}var ua="0.1.1",wl=720*3600*1e3,ha=(s,n,e)=>`fabi-play.engine-tier:${ua}:${s}:${n}:${e}`,fa=(s,n,e)=>`fablee-engine-tier:${ua}:${s}:${n}:${e}`;function pa(s,n,e=Date.now()){try{let t=JSON.parse(s?.getItem(n)??"null");if(t&&Ke.includes(t.tier)&&typeof t.at=="number"&&e-t.at<wl)return typeof t.refresh=="number"&&t.refresh>0?{name:t.tier,refresh:t.refresh}:{name:t.tier}}catch{}return null}function Jr(s,n,e,t,r=Date.now()){try{s?.setItem(n,JSON.stringify(t!==void 0&&Number.isFinite(t)?{tier:e,at:r,refresh:t}:{tier:e,at:r}))}catch{}}function da(s=typeof location<"u"?location.search:""){let n=new URLSearchParams(s).get("tier");return Ke.includes(n)?n:void 0}function es(s,n){let e=n?.tier;if(Ke.includes(e))return s==="canvas2d"&&e==="high"?"medium":e}var ts=s=>typeof s?.hz=="number"&&s.hz>=20&&s.hz<=240?Rn([1e3/s.hz],.5):NaN,ns=(s,n)=>Ke.indexOf(s)>=Ke.indexOf(n)?s:n;function ma(s,n,e){return s?{name:s,from:"forced"}:n?{name:e?ns(n,e):n,from:"hint"}:e?{name:e,from:"cache"}:null}var vl=/^\s*(<|>|[^+\-<>=\s][^+=]*?)?\s*(?:([+-])=\s*(\d*\.?\d+))?\s*$/,sn=class{constructor(n={}){p(this,"steps",[]);p(this,"labels",new Map);p(this,"end",0);p(this,"prevStart",0);p(this,"elapsed",0);p(this,"iter",0);p(this,"last",0);p(this,"delayLeft");p(this,"_paused");p(this,"done",!1);p(this,"rewinding",!1);p(this,"promise");p(this,"resolve");p(this,"repeat");p(this,"yoyo");p(this,"onComplete");this.repeat=Math.floor(n.repeat??0),this.yoyo=!!n.yoyo,this.delayLeft=n.delay??0,this._paused=!!n.paused,this.onComplete=n.onComplete,this.promise=new Promise(e=>this.resolve=e)}get duration(){return this.end}get time(){return this.last}get paused(){return this._paused}get finished(){return this.done}at(n){if(n===void 0)return this.end;if(typeof n=="number")return Math.max(n,0);let e=vl.exec(n);if(!e)throw new Error(`[engine] timeline: bad position "${n}"`);let[,t,r,o]=e,a=o?(r==="-"?-1:1)*Number(o):0,i=this.end;if(t==="<")i=this.prevStart;else if(t&&t!==">"){let u=this.labels.get(t.trim());u===void 0?this.labels.set(t.trim(),this.end):i=u}return Math.max(i+a,0)}add(n){let e=this.steps.length;for(;e>0&&this.steps[e-1].start>n.start;)e--;return this.steps.splice(e,0,n),this.prevStart=n.start,this.end=Math.max(this.end,n.start+n.dur),this}to(n,e,t,r="quadOut"){let o=typeof r=="object"?r:{ease:r},a=typeof o.ease=="function"?o.ease:ht[o.ease??"quadOut"];return this.add({target:n,to:e,from:null,fn:null,start:this.at(o.at)+(o.delay??0),dur:Math.max(t,0),ease:a,onUpdate:o.onUpdate,p:-1})}set(n,e,t){return this.add({target:n,to:e,from:null,fn:null,start:this.at(t),dur:0,ease:ht.linear,p:-1})}call(n,e){return this.add({target:null,to:null,from:null,fn:n,start:this.at(e),dur:0,ease:ht.linear,p:-1})}label(n,e){return this.labels.set(n,this.at(e)),this}wait(n){return this.end+=Math.max(n,0),this.prevStart=this.end,this}pause(){return this._paused=!0,this}resume(){return this._paused=!1,this}stop(){this.done||(this.done=!0,this.resolve())}seek(n){let e=Math.min(typeof n=="string"&&this.labels.has(n)?this.labels.get(n):this.at(n),this.end),t=this.yoyo&&this.iter%2===1;return this.elapsed=this.iter*this.end+(t?this.end-e:e),this.render(e),this}then(n,e){return this.promise.then(n,e)}update(n){if(this._paused||this.done)return;if(this.delayLeft>0){if(this.delayLeft-=n,this.delayLeft>0)return;n=-this.delayLeft,this.delayLeft=0}let e=this.end;if(e<=0)return this.render(0),this.complete();this.elapsed+=n;let t=this.repeat<0?1/0:e*(this.repeat+1),r=Math.min(this.elapsed,t),o=r>=t?this.repeat:Math.floor(r/e);for(;this.iter<o;){let i=this.yoyo&&this.iter%2===1;this.render(i?0:e),this.iter++,this.yoyo||(this.rewinding=!0,this.render(0),this.rewinding=!1)}let a=r-o*e;this.render(this.yoyo&&o%2===1?e-a:a),r>=t&&this.complete()}complete(){this.done||(this.done=!0,this.onComplete?.(),this.resolve())}render(n){let e=this.steps;if(n>=this.last)for(let t=0;t<e.length;t++){let r=e[t];n>=r.start&&this.apply(r,n)}else for(let t=e.length-1;t>=0;t--){let r=e[t];r.p>=0&&this.apply(r,n)}this.last=n}apply(n,e){let t=n.dur>0?Math.min(Math.max((e-n.start)/n.dur,0),1):e>n.start||e===n.start&&!this.rewinding?1:0;if(t===n.p)return;if(n.p=t,n.fn){this.rewinding||n.fn();return}let r=n.target;if(r.destroyed||r._free)return;let o=n.to;if(!n.from){n.from={};for(let i in o)n.from[i]=Number(r[i]??0)}let a=n.ease(t);for(let i in o)r[i]=n.from[i]+(o[i]-n.from[i])*a;n.onUpdate?.(a)}};var on=class{constructor(){p(this,"list",[]);p(this,"timelines",[])}timeline(n){let e=new sn(n);return this.timelines.push(e),e}tween(n,e,t,r="quadOut"){let o=typeof r=="object"?r:{ease:r},a=typeof o.ease=="function"?o.ease:ht[o.ease??"quadOut"],i,u=new Promise(c=>{let l=Object.keys(e),f=new Float64Array(l.length);l.forEach((h,m)=>f[m]=Number(e[h])),i={target:n,keys:l,to:f,from:new Float64Array(l.length),started:!1,duration:Math.max(t,0),time:0,delay:o.delay??0,ease:a,onUpdate:o.onUpdate,done:c,dead:!1}});return this.list.push(i),Object.assign(u,{stop:()=>this.finish(i)})}stopAll(n){let e=this.list;for(let t=0;t<e.length;t++)e[t].target===n&&this.finish(e[t])}get size(){return this.list.length}update(n){if(this.timelines.length){let r=0,o=this.timelines;for(let a=0;a<o.length;a++){let i=o[a];i.update(n),i.finished||(o[r++]=i)}o.length=r}let e=this.list;if(!e.length)return;let t=0;for(let r=0;r<e.length;r++){let o=e[r];o.dead||this.step(o,n),o.dead||(e[t++]=o)}t!==e.length&&(e.length=t)}step(n,e){if(n.target.destroyed)return this.finish(n);let t=e;if(n.delay>0){if(n.delay-=e,n.delay>0)return;t=-n.delay}let r=n.keys;if(!n.started){n.started=!0;for(let i=0;i<r.length;i++)n.from[i]=Number(n.target[r[i]]??0)}n.time+=t;let o=n.duration>0?Math.min(n.time/n.duration,1):1,a=n.ease(o);for(let i=0;i<r.length;i++)n.target[r[i]]=n.from[i]+(n.to[i]-n.from[i])*a;n.onUpdate?.(a),o>=1&&this.finish(n)}finish(n){n.dead||(n.dead=!0,n.done())}clear(){for(let n of this.list)this.finish(n);this.list.length=0;for(let n of this.timelines)n.stop();this.timelines=[]}};var he=720,Cn=class extends Ie{constructor(e,t){super(e);p(this,"paintAll",t)}draw(e,t){this.paintAll(e,t)}},ss=class extends Ie{constructor(e,t){super(e);p(this,"paintAll",t)}draw(e,t){this.paintAll(e,t)}},lt=()=>performance.now(),ya=s=>{let n=zs(s);return n&&Object.freeze(n)};async function xa(s={}){let n=s.play??null,e=s.canvas??null;e||(e=document.createElement("canvas"),e.style.cssText="position:fixed;inset:0;width:100%;height:100%;display:block;touch-action:none",document.body.appendChild(e));let t=Qt(e,{renderer:s.renderer??Jo(),failIfMajorPerformanceCaveat:s.failIfMajorPerformanceCaveat,instancing:s.instancing});e=t.canvas;let r=new Set,o=new pt(Math.min(2048,t.maxTextureSize),4);o.onPage=k=>r.add(k),o.onDrop=k=>{r.delete(k),k.texture&&t.destroyTexture(k.texture),k.texture=null};let a=Tn(t),i=new on,u=new rn,c=new Ct(o),l=new Map,f=new Map,h=new Map,m=new Map,b=new Map,y=new Set,d=0,x=s.tier??da(),g=String(t.info.renderer??""),v=(()=>{try{return globalThis.localStorage??null}catch{return null}})(),w=typeof screen<"u"?`${screen.width}x${screen.height}`:"",T=ha(t.kind,g,w);Hs(v,T,fa(t.kind,g,w));let M=pa(v,T),P=ma(x,es(t.kind,n?.device),M?.name),L=P?.name??"medium",F=it(L);c.setTier(L);let B=P?.from==="hint",G=M?.name,W=M?.refresh??ts(n?.device),H=1,me=1,U=1,oe={atlas:o,get pixelScale(){return H},get fontGen(){return d},get effects(){return F.effects},tweens:i,frame:k=>In.frame(k),shape:k=>{let S=F.effects,C=S?H:-H,R=l.get(C);R||(l.size>=8&&l.clear(),l.set(C,R=new jt(2e3)));let I=Ge(k),ne=R.get(k,I);return(!ne||!o.valid(ne.frame))&&R.set(k,ne=Zr(o,oa(k,S),H),I),ne},bitmapFont:k=>In.bitmapFont(k)},ye=1280,De=null;class mr extends Rt{get width(){return ye}set width(S){}get height(){return he}set height(S){}get safe(){let S=Math.min(ye,he*16/9);return{x:(ye-S)/2,y:0,w:S,h:he}}}let ke=new mr(oe),Be=()=>{let k=t.canvas,S=k.getBoundingClientRect();me=Math.max(1,S.width||k.clientWidth||innerWidth),U=Math.max(1,S.height||k.clientHeight||innerHeight),ye=he*me/U;let C=Math.min(globalThis.devicePixelRatio||1,s.maxPixelRatio??2);if(U*C/he<=F.resolution){let I=Math.max(1,Math.round(U*C));H=I/he,t.resize(Math.max(1,Math.round(me*C)),I)}else H=F.resolution,t.resize(Math.round(ye*H),Math.round(he*H));De&&De.style.setProperty("--unit",`${U/he}px`)};addEventListener("resize",Be);let be=k=>{L=k,F=it(k),c.setTier(k),Be()},fe=typeof ResizeObserver<"u"?new ResizeObserver(Be):null;fe?.observe(e);let ze=n?.backdrop==="video"?"video":"none",A=n?.view??null,O=n?.orientation==="portrait"?"portrait":"landscape",N=ya(n?.safeArea)??Bs,q=[],j=-1/0,ae=!1,Ze=!1,Ce=new Set,an=()=>{let k=ze==="video"?"transparent":"";document.documentElement.style.background=k,document.body.style.background=k},we=(k,S)=>{let C=k==="video"?"video":"none",R=S??null;if(!(C===ze&&(R===A||R&&A&&R.x===A.x&&R.y===A.y&&R.w===A.w&&R.h===A.h))){ze=C,A=R,an();for(let I of[...Ce])I(ze,A)}},Je=[];if(n){let k=R=>{Array.isArray(R)&&(q=R,j=lt())},S=R=>{ae=R,Ve()},C=R=>{if(x||B)return;Number.isFinite(W)||(W=ts(R));let I=es(t.kind,R);I&&(B=!0,be(G?ns(I,G):I))};Je.push(n.on("start",R=>C(R?.device)),n.on("start",R=>{(R?.orientation==="portrait"||R?.orientation==="landscape")&&(O=R.orientation);let I=ya(R?.safeArea);I&&(N=I)}),n.on("start",R=>{typeof R?.muted=="boolean"&&(u.muted=R.muted)}),n.on("frame",R=>k(R?.players)),n.on("players",R=>k(R?.players)),n.on("backdrop",R=>we(R?.backdrop,R?.view)),n.on("start",R=>we(R?.backdrop,R?.view??n.view)),n.on("pause",()=>S(!0)),n.on("resume",()=>S(!1)),n.on("break-start",()=>S(!0)),n.on("break-done",()=>S(!1)),n.on("break-end",()=>S(!1))),u.muted=n.muted===!0}an();let Ve=()=>ae||Ze||document.hidden?u.hold():u.release(),Fe=-1,Pe=[],et=0,_e=()=>lt()-j<1e3?q:[],bt=k=>n?n.toScreen(k):Mr(A,k),yr=new Ot,xt=()=>{if(Fe===et)return Pe;Fe=et;let k=O==="portrait",S=ze==="video"&&!k||!n?.smoothedBody?()=>null:C=>n.smoothedBody(C);return Pe=lr(_e(),bt,ye,he,S,k?{orientation:O,hold:yr,t:lt()}:void 0),Pe},ln={x:0,y:0,w:1,h:1},Ha=()=>(ln.x=A?A.x*ye:0,ln.y=A?A.y*he:0,ln.w=A?A.w*ye:ye,ln.h=A?A.h*he:he,ln),$a=k=>{let S=k.alpha??1,C=k.tags?new yt(o,k):null;C&&y.add(C);let R=typeof k.tags=="function"?k.tags:I=>String(I);return(I,ne)=>{if(ze==="video")return;let $=Ha();for(let V of _e()){let pe=n?.smoothedBody?.(V)??V.body,ee=zt(n?.avatarOf?.(V)??V.avatar??"")??St;if(!c.draw(I.r,I.tex,pe,ee,$,S*ne,H)||!C)continue;let Le=R(V.id);Le&&C.draw(I.r,I.tex,pe,ee,$,Le,nn(V.id),S*ne,H,ye,he)}}},br=new Set,xr=new Set,cn=new Set,Pn=!1,gr=0,_t=0,_n=0,gt={fps:0,cpuMs:0,drawCalls:0,quads:0,filtersSkipped:0},Ln=0,kr=0,wr=lt(),un=[],On=0,Ts=()=>({r:t,kernel:oe,tex:a}),Es=Ts(),Ga=()=>{if(t.lost)return;let[k,S]=ze==="video"||s.background===void 0?[0,0]:de(s.background);t.time=_n,t.maxBlur=F.maxBlur,t.begin(k,S,H),Se(ke.world,null,ke.x,ke.y,ke.rotation,ke.scaleX,ke.scaleY),Br(Es,ke,ke.alpha,ke.tint);let C=t.end();gt.drawCalls=C.drawCalls,gt.quads=C.quads,gt.filtersSkipped=C.filtersSkipped},Rs=k=>{if(!Pn)return;gr=requestAnimationFrame(Rs);let S=Math.min(Math.max((k-_t)/1e3,0),.1);_t&&un.push(k-_t),_t=k,et++;let C=lt(),R=ae||Ze;if(!R){_n+=S,i.update(S);for(let I of cn)I.destroyed||I.update(S);for(let I of br)I(S,_n)}for(let I of xr)I(S);ke.sweep();for(let I of cn)I.destroyed&&cn.delete(I);if(t.lost?(On||(On=k),k-On>3e3&&Ua()):(On=0,Ga()),Ln++,kr+=lt()-C,C-wr>=1e3&&(gt.fps=Math.round(Ln*1e3/(C-wr)),gt.cpuMs=Math.round(kr/Math.max(Ln,1)*100)/100,n?.reportStats?.({fps:gt.fps,renderer:t.kind,tier:L}),Ln=0,kr=0,wr=C),un.length>=180){let I=Number.isFinite(W)?W:Rn(un);!x&&!R&&ca(un,I)&&L!=="low"&&(be(aa(L)),G=L,Jr(v,T,L,Number.isFinite(W)?W:void 0),console.info(`[engine] slow frames: tier ${L}`)),un.length=0}},Ua=()=>{let k=Mn(t.canvas),S=Yt(k);if(S){console.warn("[engine] WebGL context lost for good: switching to Canvas 2D"),t.destroy(),t=S;for(let C of r)C.texture=null;for(let C of o.pages)r.add(C.surface);a=Tn(t),Es=Ts(),fe?.disconnect(),fe?.observe(k),Be()}},Cs=()=>{Ve(),document.hidden||(_t=0)};document.addEventListener("visibilitychange",Cs);let Fs=()=>{d++;for(let k of y)k.drop()};if(document.fonts?.addEventListener?.("loadingdone",Fs),Be(),!P&&s.probe!==!1&&(Number.isFinite(W)||(W=la(await Al(ia))),!B)){F=it("high"),Be();let k=await Sl(t,o,()=>a,()=>H,ye,()=>B);if(k.refresh=W,!B){let S=hr(t.kind,k);Jr(v,T,S,W),G=S,be(S)}}let In={stage:ke,get tier(){return F},get renderer(){return t},get canvas(){return t.canvas},get pixelScale(){return H},get backdrop(){return ze},get view(){return A},get orientation(){return O},get safeArea(){return N},get paused(){return ae||Ze},sound:u,stats:gt,get time(){return _n},get supports(){let k=t.support;return{filters:k.filters,blur:k.filters&&F.maxBlur>0,shaders:k.shaders,maxBlur:k.filters?F.maxBlur:0,tiers:{high:{maxBlur:it("high").maxBlur},medium:{maxBlur:it("medium").maxBlur},low:{maxBlur:it("low").maxBlur}}}},sprite:(k,S)=>new Te(oe,k,S),shape:(k,S)=>new Xe(oe,k,S),text:(k,S)=>new Ye(oe,k,S),group:k=>new Rt(oe).set(k??{}),particles(k,S={}){let C=typeof k=="object"&&"type"in k?oe.shape(k).frame:k,R=new Ut(oe,C,S),{max:I,blend:ne,gravity:$,drag:V,...pe}=S;return R.set(pe),cn.add(R),R},tween:(k,S,C,R)=>i.tween(k,S,C,R),bake(k,S,C,R,I){return h.set(k,{w:S,h:C,draw:R,origin:I}),f.delete(k),In.frame(k)},frame(k){let S=f.get(k);if(S&&o.valid(S)&&(S.gen===0||S.scale===H))return S;let C=h.get(k);if(C){let R=H,I=o.bake(C.w*R,C.h*R,ne=>(ne.scale(R,R),C.draw(ne)),R,C.origin?.x??0,C.origin?.y??0);return f.set(k,I),I}if(S)return S;throw new Error(`[engine] no frame "${k}": load it or bake it first`)},async load(k){await Promise.all(Object.entries(k).map(([S,C])=>Wa(S,C)))},hands:k=>k===void 0?xt():xt().filter(S=>S.player===k),touched(k,S,C={}){return k.updateWorld(),cr(k,xt(),S,C.padding??0)},hits(k,S,C,R=0){return k.updateWorld(),En(k,S,C,R)},avatars:(k={})=>new Cn(oe,$a(k)),handMarkers(k={}){let S=k.radius??36,C=k.look??"auto",R=new Float64Array(6),I=Math.max(S*.12,3),ne={type:"ring",r:S,lw:I,fill:"rgba(251,231,184,0.3)",stroke:"#ffffff"},$={type:"ring",r:S,lw:I*1.8,stroke:Ft,shadow:{color:Ft,blur:S*.2}},V=(kt,ve,Lt,vr,Nn,wt)=>{let Dn=ve.w/ve.scale;Se(R,null,Lt-Dn/2,vr-Dn/2,0,1,1),kt.r.quad(kt.tex(ve.surface),ve,R,Dn,Dn,Nn,wt,"normal")},pe=kt=>{let ve=null,Lt=!1;return()=>(ve&&o.valid(ve.frame)&&ve.frame.scale===H&&Lt===F.effects?ve:(Lt=F.effects,ve=oe.shape(kt))).frame},ee=pe(ne),Le=pe($);return new ss(oe,(kt,ve)=>{let Lt=C==="video"||C==="auto"&&ze==="video",vr=ee(),Nn=Lt?Le():null;for(let wt of xt())Nn&&V(kt,Nn,wt.x,wt.y,16777215,ve),V(kt,vr,wt.x,wt.y,de(wt.color)[0],ve)})},timeline:k=>i.timeline(k),animation(k,S){let C=typeof k=="string"?Va(k):{frames:k},R=new Ne(oe,C,S);return cn.add(R),R},bitmapFont(k,S){if(!S){let R=m.get(k);if(!R)throw new Error(`[engine] no bitmap font "${k}": load or make it first`);return R}let C="data"in S?Ps(tn(S.data),S.pages):sa(oe,S);return m.set(k,C),C},players:()=>_e(),onFrame(k){return br.add(k),()=>{br.delete(k)}},onRender(k){return xr.add(k),()=>{xr.delete(k)}},onBackdrop(k){return Ce.add(k),()=>{Ce.delete(k)}},get hud(){return De||(De=document.createElement("div"),De.style.cssText="position:fixed;inset:0;pointer-events:none;overflow:hidden",document.body.appendChild(De),Be()),De},random:(k=0,S=1)=>k+Math.random()*(S-k),start(){Pn||(Pn=!0,_t=0,gr=requestAnimationFrame(Rs))},pause(){Ze=!0,Ve()},resume(){Ze=!1,Ve()},destroy(){Pn=!1,cancelAnimationFrame(gr),Je.forEach(k=>k()),removeEventListener("resize",Be),fe?.disconnect(),document.removeEventListener("visibilitychange",Cs),document.fonts?.removeEventListener?.("loadingdone",Fs),i.clear(),To(oe),u.destroy(),t.destroy(),De?.remove()}};function Va(k){let S=b.get(k);if(S)return S;let C=[...new Set([...f.keys(),...h.keys()])].filter(R=>R.startsWith(k)).sort(Ro);if(!C.length)throw new Error(`[engine] no animation or frames "${k}\u2026"`);return{frames:C}}async function Wa(k,S){let C=S.split("?")[0].split(".").pop().toLowerCase();if(["mp3","ogg","wav","m4a","aac","webm"].includes(C))return u.load(k,S);if(["woff","woff2","ttf","otf"].includes(C)){let $=new FontFace(k,`url(${S})`);document.fonts.add(await $.load()),d++;return}let R=new URL(S,location.href);if(C==="fnt")return _s(k,tn(await(await fetch(S)).text()),R);if(C==="json"){let $=await(await fetch(S)).json();if(Array.isArray($.chars)&&!$.frames)return _s(k,tn($),R);let V=await rs(new URL($.meta?.image??S.replace(/\.json$/,".png"),R).href);Xa(k,$,Vt(V));return}let I=await rs(S),ne=Vt(I);r.add(ne),f.set(k,{surface:ne,x:0,y:0,w:I.width,h:I.height,scale:1,gen:0,ox:0,oy:0,margin:0})}function Ps(k,S){return ra(k,S.map(C=>{let R=Vt(C);return r.add(R),R}))}async function _s(k,S,C){m.set(k,Ps(S,await Promise.all(S.pages.map(R=>rs(new URL(R,C).href)))))}function Xa(k,S,C){r.add(C);let R=Array.isArray(S.frames)?S.frames:Object.entries(S.frames).map(([$,V])=>({...V,filename:$})),I=[],ne=[];for(let $ of R){let V=$.frame,pe=$.filename.replace(ba,"");$.rotated&&console.warn(`[engine] ${k}/${pe} is rotated: export without rotation`);let ee={surface:C,x:V.x,y:V.y,w:V.w,h:V.h,scale:1,gen:0,ox:0,oy:0,margin:0};$.trimmed&&$.sourceSize&&$.spriteSourceSize&&(ee.sw=$.sourceSize.w,ee.sh=$.sourceSize.h,ee.tx=$.spriteSourceSize.x,ee.ty=$.spriteSourceSize.y);let Le=$.scale9Borders;Le&&(ee.slice=[Le.y,(ee.sw??V.w)-Le.x-Le.w,(ee.sh??V.h)-Le.y-Le.h,Le.x]),f.set(`${k}/${pe}`,ee),I.push(`${k}/${pe}`),ne.push(($.duration??0)/1e3)}for(let[$,V]of Object.entries(S.animations??{}))b.set(`${k}/${$}`,{frames:V.map(pe=>`${k}/${pe.replace(ba,"")}`)});for(let $ of S.meta?.frameTags??[]){let V=[];for(let ee=$.from;ee<=$.to;ee++)V.push(ee);$.direction==="reverse"&&V.reverse(),$.direction==="pingpong"&&V.push(...V.slice(1,-1).reverse());let pe=V.every(ee=>ne[ee]>0);b.set(`${k}/${$.name}`,{frames:V.map(ee=>I[ee]),...pe?{durations:V.map(ee=>ne[ee])}:{}})}}return In}var ba=/\.(png|webp|jpe?g|gif|bmp)$/i;function rs(s){return new Promise((n,e)=>{let t=new Image;t.onload=()=>n(t),t.onerror=()=>e(new Error(`[engine] image did not load: ${s}`)),t.src=s})}function Al(s){return new Promise(n=>{let e=[],t=0,r=o=>{t&&e.push(o-t),t=o,e.length<s?requestAnimationFrame(r):n(e)};requestAnimationFrame(r)})}async function Sl(s,n,e,t,r,o=()=>!1){let a=t(),i=Zr(n,{type:"star",r:30,fill:"#ffd23f",stroke:"#3a2a10",lw:3},a).frame,u=[],c=[],l=new Float64Array(6),f=.004,h=s.kind==="canvas2d"?s.canvas.getContext("2d"):null,m=lt(),b=0;return await new Promise(y=>{let d=x=>{b&&x-m>250&&u.push(x-b),b=x;let g=lt();s.begin(0,0,a);let v=e();for(let w=0;w<300;w++){let T=x/1e3+w;Se(l,null,w*37%r,w*53%he,T,1,1),s.quad(v(i.surface),i,l,i.w/a,i.h/a,16777215,f,"normal")}for(let w=0;w<40;w++)s.ellipse(100+w*20,300,20,14,w,16746496,f),s.stroke([100+w*20,400,120+w*20,460,100+w*20,520],3,18,3368703,f,!1);s.end(),h?.getImageData(0,0,1,1),x-m>250&&c.push(lt()-g),x-m<750&&!o()?requestAnimationFrame(d):(s.begin(0,0,a),s.end(),y())};requestAnimationFrame(d)}),{intervals:u,cpu:c}}var Ml=64,ga=32,Tl=0,El=`fabi-cm-${Math.random().toString(36).slice(2,7)}-`,ka=new Set,wa=(s,n)=>{ka.has(s)||(ka.add(s),console.warn(n))},va=s=>new os(s),os=class{constructor(n){p(this,"r",n);p(this,"css","none");p(this,"plans",new jt(Ml));p(this,"buf",new Float64Array(64));p(this,"keys",[]);p(this,"classes",new Map);p(this,"live",new Set);p(this,"svgs",new Map);p(this,"t",0);p(this,"cur",null);p(this,"svgFn",n=>this.svg(n));p(this,"scr",[]);p(this,"flip",0)}chain(n,e){var b;let t=this.r,r=this.buf;r[0]=t.scale,r[1]=t.maxBlur;let o=2;for(let y=0;y<e.length;y++){let d=e[y];if(o+22>r.length){let g=new Float64Array(r.length*2);g.set(r),r=this.buf=g}let x=this.classes.get(d.constructor);x===void 0&&this.classes.set(d.constructor,x=this.classes.size),r[o++]=x,r[o++]=d.enabled?1:0,d.params&&(o=d.params(r,o))}let a=(b=this.keys)[o]??(b[o]=new Float64Array(o));for(let y=0;y<o;y++)a[y]=r[y];let i=Ge(a),u=this.plans.get(a,i);u||this.plans.set(a,u=this.plan(e),i);for(let y=0;y<u.svgs.length;y++){let d=u.svgs[y];d.used<0&&this.attach(d),d.used=this.t}t.skipped+=u.skip;let c=n,l=t.rx0,f=t.ry0,h=t.rx1-l,m=t.ry1-f;for(let y=0;y<u.paints.length;y++)u.parts[y]&&(c=this.bake(c,u.parts[y])),e[u.paints[y]].paint2d(c.getContext("2d"),l,f,h,m);return this.css=u.parts[u.paints.length]||"none",c}tick(){let n=++this.t;if(!(n%ga||!this.live.size))for(let e of this.live)n-e.used>ga&&this.detach(e)}destroy(){for(let n of this.live)this.detach(n);this.plans.clear()}svg(n){if(typeof document>"u"||!document.body)return null;let e=Array.from({length:20},(r,o)=>n[o]??0).join(" "),t=this.svgs.get(e);if(!t){let r="http://www.w3.org/2000/svg",o=document.createElementNS(r,"svg");o.setAttribute("width","0"),o.setAttribute("height","0"),o.setAttribute("aria-hidden","true"),o.style.position="absolute";let a=document.createElementNS(r,"filter"),i=El+ ++Tl;a.setAttribute("id",i),a.setAttribute("color-interpolation-filters","sRGB");let u=document.createElementNS(r,"feColorMatrix");u.setAttribute("type","matrix"),u.setAttribute("values",e),a.append(u),o.append(a),this.attach(t={key:e,id:i,el:o,used:this.t})}return this.cur.svgs.push(t),`url(#${t.id})`}attach(n){document.body.append(n.el),this.live.add(n),this.svgs.has(n.key)||this.svgs.set(n.key,n)}detach(n){n.el.remove(),n.used=-1,this.live.delete(n),this.svgs.get(n.key)===n&&this.svgs.delete(n.key)}plan(n){let e=this.r,t=this.cur={parts:[],paints:[],skip:0,svgs:[]},r="";for(let o=0;o<n.length;o++){let a=n[o];if(!a.enabled)continue;if(a.kind===4){t.skip++,wa("shader","[engine] shader() filters are WebGL only: on Canvas 2D they are skipped (check engine.supports.shaders)");continue}let i=e.support.filters&&a.css?a.css(e.scale,e.maxBlur,this.svgFn):null;i!==null?r+=r?` ${i}`:i:a.paint2d?(t.parts.push(r),t.paints.push(o),r=""):(t.skip++,wa("css","[engine] this browser's Canvas 2D has no ctx.filter: colour filters, blur and shadows are skipped (tint works; check engine.supports.filters)"))}return t.parts.push(r),t}bake(n,e){let t=this.r,r=this.flip^=1,o=this.scr[r];(!o||o.width!==t.canvas.width||o.height!==t.canvas.height)&&(o=this.scr[r]=document.createElement("canvas"),o.width=t.canvas.width,o.height=t.canvas.height);let a=o.getContext("2d"),i=t.rx0,u=t.ry0,c=t.rx1-i,l=t.ry1-u;return a.clearRect(i,u,c,l),a.filter=e,a.drawImage(n,i,u,c,l,i,u,c,l),a.filter="none",o}};var Rl=64,fr=17,Cl=s=>`${sr}
|
|
49
|
-
uniform sampler2D uTexture;
|
|
50
|
-
uniform mat4 uM[${s}];
|
|
51
|
-
uniform vec4 uO[${s}];
|
|
52
|
-
uniform int uK;
|
|
53
|
-
varying vec2 vUv;
|
|
54
|
-
varying vec4 vColor;
|
|
55
|
-
void main() {
|
|
56
|
-
vec4 c = texture2D(uTexture, vUv);
|
|
57
|
-
if (c.a > 0.0) c.rgb /= c.a;
|
|
58
|
-
for (int i = 0; i < ${s}; i++) {
|
|
59
|
-
if (i >= uK) break;
|
|
60
|
-
c = clamp(uM[i] * c + uO[i], 0.0, 1.0);
|
|
61
|
-
}
|
|
62
|
-
c.rgb *= c.a;
|
|
63
|
-
gl_FragColor = c * vColor;
|
|
64
|
-
}`,Fl=()=>`${sr}
|
|
65
|
-
uniform sampler2D uTexture;
|
|
66
|
-
uniform vec2 uDir;
|
|
67
|
-
uniform vec2 uOff;
|
|
68
|
-
uniform vec2 uTaps[${fr}];
|
|
69
|
-
uniform int uN;
|
|
70
|
-
uniform float uMode;
|
|
71
|
-
uniform vec4 uShadow;
|
|
72
|
-
varying vec2 vUv;
|
|
73
|
-
varying vec4 vColor;
|
|
74
|
-
void main() {
|
|
75
|
-
vec2 p = vUv + uOff;
|
|
76
|
-
vec4 c = texture2D(uTexture, p) * uTaps[0].y;
|
|
77
|
-
for (int i = 1; i < ${fr}; i++) {
|
|
78
|
-
if (i >= uN) break;
|
|
79
|
-
vec2 d = uDir * uTaps[i].x;
|
|
80
|
-
c += (texture2D(uTexture, p + d) + texture2D(uTexture, p - d)) * uTaps[i].y;
|
|
81
|
-
}
|
|
82
|
-
if (uMode > 0.5) c = uShadow * c.a;
|
|
83
|
-
gl_FragColor = c * vColor;
|
|
84
|
-
}`;function Pl(s,n,e=new Float32Array(20)){for(let t=0;t<4;t++)for(let r=0;r<5;r++){let o=r===4?n[t*5+4]:0;for(let a=0;a<4;a++)o+=n[t*5+a]*s[a*5+r];e[t*5+r]=o}return s.set(e),s}var Aa=s=>new cs(s),cs=class{constructor(n){p(this,"r",n);p(this,"colorProg",null);p(this,"blurProg",null);p(this,"user",new Map);p(this,"uses",0);p(this,"userErr",new Map);p(this,"scratchT",new Map);p(this,"steps",[]);p(this,"mats",[]);p(this,"counts",[]);p(this,"colorN");p(this,"fm",new Float32Array(20));p(this,"fm2",new Float32Array(20));p(this,"fm3",new Float32Array(20));p(this,"m16");p(this,"o4");p(this,"taps",new Float32Array(fr*2));let e=n.gl;this.colorN=Math.max(1,Math.min(8,Math.floor((e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS)-4)/5))),this.m16=new Float32Array(16*this.colorN),this.o4=new Float32Array(4*this.colorN)}check(n){return this.r.lost?null:(this.userProg(n,!1),this.userErr.get(n)??null)}destroy(){let n=this.r.gl;for(let e of this.scratchT.values())n.deleteTexture(e.gl),n.deleteFramebuffer(e.fb);this.scratchT.clear();for(let e of[this.colorProg,this.blurProg])e&&n.deleteProgram(e.p);for(let e of this.user.values())e.p&&n.deleteProgram(e.p.p);this.user.clear()}userProg(n,e){let t=this.user,r=t.get(n);if(r)return r.t=++this.uses,r.p;if(this.r.lost)return null;if(t.size>=Rl){let a="",i=1/0;for(let[c,l]of t)l.t<i&&(i=l.t,a=c);let u=t.get(a).p;u&&this.r.gl.deleteProgram(u.p),t.delete(a),this.userErr.delete(a)}let o;try{o=this.r.build(n)}catch(a){o=null;let i=a.message;this.userErr.set(n,i),e&&console.error(`[engine] a shader filter does not compile: it is skipped.
|
|
85
|
-
${i}`)}return t.set(n,{p:o,t:++this.uses}),o}scratch(n,e){let t=this.r,r=Math.ceil(t.canvas.width/n),o=Math.ceil(t.canvas.height/n),a=n*8+e,i=this.scratchT.get(a)??null;return i&&(i.w!==r||i.h!==o)&&(t.drop(i),i=null),i||(i=t.target(r,o,n,!0),i?this.scratchT.set(a,i):this.scratchT.delete(a)),i}pass(n,e,t,r,o=!1){let a=this.r,i=a.gl;a.flush(),a.mapped=!1,a.bindFb(r),i.viewport(0,0,r.w,r.h),o||(i.disable(i.SCISSOR_TEST),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT)),a.use(n);let u=r.f;i.uniform2f(n.uScale,2/(u*r.w),-2/(u*r.h));let c=Math.floor(a.rx0/u)*u,l=Math.floor(a.ry0/u)*u,f=Math.min(Math.ceil(a.rx1/u),r.w)*u,h=Math.min(Math.ceil(a.ry1/u),r.h)*u,m=1/(t*e.width),b=1/(t*e.height);a.bScis=!1,a.batch.push(c,l,f,l,f,h,c,h,c*m,1-l*b,f*m,1-h*b,4294967295,a.slotOf(e)),a.flush()}post(n){return n==="color"?this.colorProg??(this.colorProg=this.r.build(Cl(this.colorN))):this.blurProg??(this.blurProg=this.r.build(Fl()))}linear(n,e){let t=this.r,r=t.gl;t.bindTex(t.layerTex.get(n)??null,0);let o=e?r.LINEAR:r.NEAREST;r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,o)}chain(n,e,t){let r=this.r,o=this.steps,a=r.scale,i=r.maxBlur,u=0;for(let h=0;h<t.length;h++){let m=t[h];if(m.enabled)if(m.kind===1&&m.toMatrix){(!u||o[u-1]!==null)&&(o[u]=null,(!this.mats[u]||this.mats[u].length<20*this.colorN)&&(this.mats[u]=new Float32Array(20*this.colorN)),this.counts[u]=0,u++);let b=this.mats[u-1],y=this.counts[u-1];if(y<this.colorN)m.toMatrix(this.fm),b.set(this.fm,y*20),this.counts[u-1]=y+1;else{let d=(y-1)*20;for(let x=0;x<20;x++)this.fm2[x]=b[d+x];m.toMatrix(this.fm),Pl(this.fm2,this.fm,this.fm3),b.set(this.fm2,d)}}else m.kind===4?this.userProg(m.source,!0)?o[u++]=m:r.skipped++:m.kind===2?Math.min(m.radius,i)*a>=.25&&(o[u++]=m):m.kind===3?o[u++]=m:r.skipped++}if(!u)return!1;let c=r.gl,l=n,f=-1;for(let h=0;h<u;h++){let m=h===u-1,b=f===0?1:0,y=m?null:this.scratch(1,b);if(!m&&!y)break;let d=o[h];if(d===null){let x=this.post("color");r.use(x);let g=this.mats[h],v=this.counts[h],w=this.m16,T=this.o4;for(let M=0;M<v;M++)for(let P=0;P<4;P++){for(let L=0;L<4;L++)w[M*16+L*4+P]=g[M*20+P*5+L];T[M*4+P]=g[M*20+P*5+4]}c.uniformMatrix4fv(r.u(x,"uM"),!1,w),c.uniform4fv(r.u(x,"uO"),T),c.uniform1i(r.u(x,"uK"),v),y?this.pass(x,l,1,y):r.final(x,l,1,e)}else if(d.kind===2)this.blur(l,f<0,Math.min(d.radius,i)*a,y,e,null);else if(d.kind===3){let x=d,g=this.scratch(1,2);if(!g)break;this.blur(l,f<0,Math.max(Math.min(x.blur,i),0)*a,g,1,x);let v=y??(e<1?this.scratch(1,b):null);v?(this.pass(r.main,g.tex,1,v),this.pass(r.main,l,1,v,!0),y||r.final(r.main,v.tex,1,e)):(r.final(r.main,g.tex,1,1),r.final(r.main,l,1,1))}else{let x=d,g=this.userProg(x.source,!0);r.use(g);let v=r.canvas.width,w=r.canvas.height;c.uniform2f(r.u(g,"uResolution"),v,w),c.uniform1f(r.u(g,"uTime"),r.time),c.uniform4f(r.u(g,"uRect"),r.rx0/v,1-r.ry1/w,r.rx1/v,1-r.ry0/w);let T=x.uniforms;for(let M in T){let P=r.u(g,M);if(!P)continue;let L=T[M];typeof L=="number"?c.uniform1f(P,L):L.length===2?c.uniform2fv(P,L):L.length===3?c.uniform3fv(P,L):L.length===4?c.uniform4fv(P,L):L.length===1&&c.uniform1fv(P,L)}y?this.pass(g,l,1,y):r.final(g,l,1,e)}y&&(l=y.tex,f=b)}return r.remap(),!0}blur(n,e,t,r,o,a){let i=this.r,u=i.gl,c=this.post("blur"),l=1;for(;l<16&&t/l>8;)l*=2;e&&this.linear(n,!0);let f=n,h=1,m=Math.sqrt(Math.max(t*t-(l*l-1)/12,0))/l,b=t>=.25?this.tapsFor(m):this.tapsFor(0),y=!0;if(b>1){for(let x=2;x<=l&&y;x*=2){let g=this.scratch(x,0);g?(this.pass(i.main,f,h,g),f=g.tex,h=x):y=!1}let d=y?this.scratch(l,3):null;d&&(i.use(c),u.uniform2fv(i.u(c,"uTaps"),this.taps),u.uniform1i(i.u(c,"uN"),b),u.uniform2f(i.u(c,"uDir"),1/f.width,0),u.uniform2f(i.u(c,"uOff"),0,0),u.uniform1f(i.u(c,"uMode"),0),this.pass(c,f,h,d),f=d.tex)}if(i.use(c),u.uniform2fv(i.u(c,"uTaps"),this.taps),u.uniform1i(i.u(c,"uN"),b),u.uniform2f(i.u(c,"uDir"),0,1/f.height),a){let d=a.opacity,x=a.rgb;u.uniform4f(i.u(c,"uShadow"),(x>>16&255)/255*d,(x>>8&255)/255*d,(x&255)/255*d,d),u.uniform1f(i.u(c,"uMode"),1),u.uniform2f(i.u(c,"uOff"),-a.dx*i.scale/(h*f.width),a.dy*i.scale/(h*f.height))}else u.uniform1f(i.u(c,"uMode"),0),u.uniform2f(i.u(c,"uOff"),0,0);r?this.pass(c,f,h,r):i.final(c,f,h,o),e&&this.linear(n,!1)}tapsFor(n){let e=this.taps;if(e.fill(0),e[1]=1,n<.2)return 1;let t=Math.min(Math.ceil(3*n),(fr-1)*2),r=-1/(2*n*n),o=1,a=1;for(let i=1;i<=t;i+=2){let u=Math.exp(i*i*r),c=i+1<=t?Math.exp((i+1)*(i+1)*r):0,l=u+c;e[a*2]=(i*u+(i+1)*c)/l,e[a*2+1]=l,o+=2*l,a++}for(let i=0;i<a;i++)e[i*2+1]=e[i*2+1]/o;return a}};var ct=s=>Math.min(Math.max(s,0),1),Ue=s=>Math.max(s,0),Pt=class{constructor(){p(this,"enabled",!0);Me.gl=Aa,Me.c2d=va}},Qe=class extends Pt{constructor(e){super();p(this,"amount",e);p(this,"kind",1)}params(e,t){return e[t]=this.amount,t+1}};function pr(s,n,e){s.fill(0),s[0]=s[6]=s[12]=n,s[4]=s[9]=s[14]=e,s[18]=1}function dr(s,n){s.fill(0);for(let e=0;e<3;e++)for(let t=0;t<3;t++)s[e*5+t]=n[e*3+t];s[18]=1}var D=new Float64Array(9),hs=class extends Qe{toMatrix(n){pr(n,Ue(this.amount),0)}css(){return`brightness(${Ue(this.amount)})`}},fs=class extends Qe{toMatrix(n){let e=Ue(this.amount);pr(n,e,.5-.5*e)}css(){return`contrast(${Ue(this.amount)})`}},ps=class extends Qe{toMatrix(n){let e=ct(this.amount);pr(n,1-2*e,e)}css(){return`invert(${ct(this.amount)})`}},ds=class extends Qe{toMatrix(n){let e=Ue(this.amount);D[0]=.213+.787*e,D[1]=.715-.715*e,D[2]=.072-.072*e,D[3]=.213-.213*e,D[4]=.715+.285*e,D[5]=.072-.072*e,D[6]=.213-.213*e,D[7]=.715-.715*e,D[8]=.072+.928*e,dr(n,D)}css(){return`saturate(${Ue(this.amount)})`}},ms=class extends Qe{toMatrix(n){let e=1-ct(this.amount);D[0]=.2126+.7874*e,D[1]=.7152-.7152*e,D[2]=.0722-.0722*e,D[3]=.2126-.2126*e,D[4]=.7152+.2848*e,D[5]=.0722-.0722*e,D[6]=.2126-.2126*e,D[7]=.7152-.7152*e,D[8]=.0722+.9278*e,dr(n,D)}css(){return`grayscale(${ct(this.amount)})`}},ys=class extends Qe{toMatrix(n){let e=1-ct(this.amount);D[0]=.393+.607*e,D[1]=.769-.769*e,D[2]=.189-.189*e,D[3]=.349-.349*e,D[4]=.686+.314*e,D[5]=.168-.168*e,D[6]=.272-.272*e,D[7]=.534-.534*e,D[8]=.131+.869*e,dr(n,D)}css(){return`sepia(${ct(this.amount)})`}},bs=class extends Qe{get angle(){return this.amount}set angle(n){this.amount=n}toMatrix(n){let e=this.amount*Math.PI/180,t=Math.cos(e),r=Math.sin(e);D[0]=.213+t*.787-r*.213,D[1]=.715-t*.715-r*.715,D[2]=.072-t*.072+r*.928,D[3]=.213-t*.213+r*.143,D[4]=.715+t*.285+r*.14,D[5]=.072-t*.072-r*.283,D[6]=.213-t*.213-r*.787,D[7]=.715-t*.715+r*.715,D[8]=.072+t*.928+r*.072,dr(n,D)}css(){return`hue-rotate(${this.amount}deg)`}},xs=class extends Qe{constructor(e,t){super(t);p(this,"c",16777215);p(this,"cs","");this.color=e}get color(){return this.c}set color(e){this.c=de(e)[0],this.cs=Mt(this.c)}params(e,t){return e[t]=this.amount,e[t+1]=this.c,t+2}toMatrix(e){let t=ct(this.amount);pr(e,1-t,0),e[4]=(this.c>>16&255)/255*t,e[9]=(this.c>>8&255)/255*t,e[14]=(this.c&255)/255*t}css(){return null}paint2d(e,t,r,o,a){let i=ct(this.amount);i<=0||(e.save(),e.setTransform(1,0,0,1,0,0),e.globalAlpha=i,e.globalCompositeOperation="source-atop",e.fillStyle=this.cs,e.fillRect(t,r,o,a),e.restore())}},gs=class extends Pt{constructor(e){super();p(this,"kind",1);p(this,"values");if(e.length!==20)throw new Error(`colorMatrix: 20 numbers expected (4 rows of 5), got ${e.length}`);this.values=Array.from(e)}toMatrix(e){for(let t=0;t<20;t++)e[t]=this.values[t]??0}params(e,t){for(let r=0;r<20;r++)e[t+r]=this.values[r]??0;return t+20}css(e,t,r){return r?r(this.values):null}},ks=class extends Pt{constructor(e){super();p(this,"radius",e);p(this,"kind",2)}params(e,t){return e[t]=this.radius,t+1}pad(e){return 3*Math.min(Ue(this.radius),e)}css(e,t){return`blur(${Math.min(Ue(this.radius),t)*e}px)`}},ws=class extends Pt{constructor(e,t,r,o){super();p(this,"dx",e);p(this,"dy",t);p(this,"blur",r);p(this,"kind",3);p(this,"rgb",0);p(this,"a",1);this.color=o}get opacity(){return this.a}set opacity(e){this.a=ct(e)}get color(){return this.rgb}set color(e){let[t,r]=de(e);this.rgb=t,this.a=r}params(e,t){return e[t]=this.dx,e[t+1]=this.dy,e[t+2]=this.blur,e[t+3]=this.rgb,e[t+4]=this.a,t+5}pad(e){return 3*Math.min(Ue(this.blur),e)+Math.max(Math.abs(this.dx),Math.abs(this.dy))}css(e,t){return`drop-shadow(${this.dx*e}px ${this.dy*e}px ${2*Math.min(Ue(this.blur),t)*e}px ${Mt(this.rgb,this.opacity)})`}},_l=`#ifdef GL_FRAGMENT_PRECISION_HIGH
|
|
86
|
-
precision highp float;
|
|
87
|
-
#else
|
|
88
|
-
precision mediump float;
|
|
89
|
-
#endif
|
|
90
|
-
uniform sampler2D uTexture;
|
|
91
|
-
uniform vec2 uResolution;
|
|
92
|
-
uniform float uTime;
|
|
93
|
-
uniform vec4 uRect;
|
|
94
|
-
varying vec2 vUv;
|
|
95
|
-
varying vec4 vColor;
|
|
96
|
-
#define main fabiUserMain
|
|
97
|
-
#line 1
|
|
98
|
-
`,Ll=s=>`${_l}${s}
|
|
99
|
-
#undef main
|
|
100
|
-
void main() {
|
|
101
|
-
fabiUserMain();
|
|
102
|
-
gl_FragColor *= vColor.a;
|
|
103
|
-
}
|
|
104
|
-
`,vs=class extends Pt{constructor(e){super();p(this,"kind",4);p(this,"source");p(this,"uniforms",{});p(this,"padding");this.source=Ll(e.fragment),this.padding=e.padding??0;for(let t in e.uniforms??{}){let r=e.uniforms[t];this.uniforms[t]=typeof r=="number"?r:Float32Array.from(r)}}pad(){return Ue(this.padding)}},Sa=(s,n=1)=>new xs(s,n),Ma=s=>new hs(s),Ta=s=>new fs(s),Ea=s=>new ds(s),Ra=(s=1)=>new ms(s),Ca=(s=1)=>new ys(s),Fa=s=>new bs(s),Pa=(s=1)=>new ps(s),_a=s=>new gs(s),La=s=>new ks(s),Oa=(s,n,e,t="rgba(0,0,0,0.5)")=>new ws(s,n,e,t);function Ia(s){let n=new vs(s),e=Me.live?.filters()?.check(n.source);if(e)throw new Error(`shader(): the fragment does not compile:
|
|
105
|
-
${e}`);return n}var As="x y rotation scaleX scaleY alpha visible blend tint z hitRadius clip mask filters".split(" "),Da="frameName _frame _w _h slice autoAnchor".split(" "),Ol="fps loop speed onComplete durations".split(" "),Ss=["anchorX","anchorY"],Il=[...As,...Da,...Ol,...Ss],Nl=[...As,...Da,...Ss],Dl=[...As,...Ss],Ba=s=>s instanceof Ne?Il:s instanceof Te?Nl:Dl;function Bl(s){let n={},e=s;for(let t of Ba(s))n[t]=e[t];return s instanceof Xe&&(n.spec=s.spec),s instanceof Ye&&(n.text=s.text,n.style=s.style),s instanceof Ne&&(n.playing=s.playing),n}function Na(s,n){let e=s;s instanceof Xe&&s.spec!==n.spec&&(s.spec=n.spec),s instanceof Ye&&(s.text=n.text,s.style!==n.style&&(e._style=n.style,e.dirty=!0)),s instanceof Ne&&s.gotoFrame(n.speed<0?s.frameCount-1:0);let t=s instanceof Xe||s instanceof Ye,r=Ba(s);for(let o=0;o<r.length;o++){let a=r[o];(!t||a!=="_frame"&&a!=="frameName")&&(e[a]=n[a])}}var Fn=class{constructor(n,e={}){p(this,"factory",n);p(this,"opts",e);p(this,"stats",{live:0,free:0,created:0});p(this,"free",[]);p(this,"states",new Map);p(this,"dead",!1)}get(n){if(this.dead)throw new Error("[engine] nodePool.get() after destroy()");let e=this.free.pop();if(e){this.stats.free--,e._free=!1;let t=this.states.get(e);Na(e,t),e.visible=t.visible,e instanceof Ne&&t.playing&&e.play()}else{if(e=this.factory(),!(e instanceof Ie))throw new Error("[engine] a nodePool factory must return a node (engine.sprite, engine.shape, \u2026)");if(e._pool)throw new Error("[engine] a nodePool factory returned a node of another pool: make a new node in it");this.states.set(e,Bl(e)),e._pool=this,this.stats.created++}return this.stats.live++,n&&e.set(n),e}release(n){let e=this.states.get(n);if(!(!e||n.destroyed)&&!n._free){if(this.opts.max!==void 0&&this.free.length>=this.opts.max)return n.destroy();n.parent?.remove(n),n.kernel.tweens.stopAll(n),this.stats.live--,Na(n,e),n instanceof Ne&&n.stop(),n.visible=!1,n._free=!0,this.opts.reset?.(n),this.free.push(n),this.stats.free++}}forget(n){let e=n;if(this.states.delete(e))if(e._free){let t=this.free.indexOf(e);t>=0&&(this.free[t]=this.free[this.free.length-1],this.free.pop()),this.stats.free--}else this.stats.live--}clear(){for(;this.free.length;)this.free[this.free.length-1].destroy()}destroy(){this.dead=!0;for(let n of[...this.states.keys()])n.destroy()}},za=(s,n)=>new Fn(s,n);window.FabiEngine=Ms;})();
|
|
1
|
+
"use strict";(()=>{var so=Object.defineProperty,bi=Object.defineProperties;var yi=Object.getOwnPropertyDescriptors;var hr=Object.getOwnPropertySymbols;var oo=Object.prototype.hasOwnProperty,ao=Object.prototype.propertyIsEnumerable;var wt=Math.pow,Gr=(r,t,e)=>t in r?so(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,M=(r,t)=>{for(var e in t||(t={}))oo.call(t,e)&&Gr(r,e,t[e]);if(hr)for(var e of hr(t))ao.call(t,e)&&Gr(r,e,t[e]);return r},Ie=(r,t)=>bi(r,yi(t));var en=(r,t)=>{var e={};for(var n in r)oo.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&hr)for(var n of hr(r))t.indexOf(n)<0&&ao.call(r,n)&&(e[n]=r[n]);return e};var xi=(r,t)=>{for(var e in t)so(r,e,{get:t[e],enumerable:!0})};var p=(r,t,e)=>Gr(r,typeof t!="symbol"?t+"":t,e);var lt=(r,t,e)=>new Promise((n,s)=>{var o=l=>{try{i(e.next(l))}catch(c){s(c)}},a=l=>{try{i(e.throw(l))}catch(c){s(c)}},i=l=>l.done?n(l.value):Promise.resolve(l.value).then(o,a);i((e=e.apply(r,t)).next())});var $=typeof self!="undefined"?self:typeof window!="undefined"?window:typeof global!="undefined"?global:{};var Ws={};xi(Ws,{AnimatedSprite:()=>Xe,Atlas:()=>Mt,AvatarPainter:()=>Wt,AvatarsNode:()=>tr,BitmapFont:()=>An,DEFAULT_FONT:()=>ps,EASE:()=>At,Group:()=>Vt,HALO:()=>Xt,MAX_LAYERS:()=>Vn,NameTags:()=>Rt,Node:()=>We,NodePool:()=>nr,Particles:()=>hn,STAGE_HEIGHT:()=>Se,Shape:()=>nt,ShelfPacker:()=>qn,Sound:()=>Tn,Sprite:()=>ze,TIERS:()=>at,Text:()=>ot,Timeline:()=>En,Tweens:()=>Rn,avatarPortrait:()=>Ra,blur:()=>ai,brightness:()=>Za,colorMatrix:()=>oi,contrast:()=>Ja,createAvatarRenderer:()=>Ea,createEngine:()=>Wa,createRenderer:()=>gn,dropShadow:()=>ii,grayscale:()=>ti,handsOf:()=>Ir,hits:()=>Jn,hueRotate:()=>ri,invert:()=>si,nodePool:()=>fi,packColor:()=>vt,parseBMFont:()=>Sn,parseColor:()=>Te,pickTier:()=>Br,playerColor:()=>Mn,rendererOrder:()=>fs,rng:()=>Ho,saturate:()=>ei,sepia:()=>ni,shader:()=>li,shapeBounds:()=>Or,tier:()=>mt,tint:()=>Qa,touching:()=>Nr,wrists:()=>ys});var Ur=33,q={nose:0,leftShoulder:11,rightShoulder:12,leftElbow:13,rightElbow:14,leftWrist:15,rightWrist:16,leftHip:23,rightHip:24,leftKnee:25,rightKnee:26,leftAnkle:27,rightAnkle:28},lo=["3-5","6-8","9-12"],gi=r=>lo.includes(r);var ki=4,Bn=["#EE6A43","#6FA0E0","#8CC9A0","#C49BE0"];var co={"3-5":["bunny","bear","panda","penguin"],"6-8":["fox","lion","dragon","unicorn"],"9-12":["robot","astronaut","ninja","skater"]},wi=co["6-8"],Vr=(r,t)=>{let e=gi(t)?co[t]:wi;return e[Number.isInteger(r)&&r>=0?r%e.length:0]};var Wr=(r,t)=>r?{x:r.x+t.x*r.w,y:r.y+t.y*r.h}:{x:t.x,y:t.y},vi=.5,fr={left:1.6,top:1.6,w:3.2,h:3},Ai=1.2;function uo(r,t,e={}){let n=Array.isArray(r)?r:r.body;if(!Array.isArray(n))return null;let s=t==="left"?q.leftWrist:q.rightWrist,o=m=>{var g;return Dn(n[m*3])&&Dn(n[m*3+1])&&((g=n[m*3+2])!=null?g:0)>=vi?m:-1};if(o(s)<0)return null;let a=n[s*3],i=n[s*3+1];if(e.orientation!=="portrait")return Wr(e.view,{x:a,y:i});if(o(q.leftShoulder)<0||o(q.rightShoulder)<0)return null;let l=q.leftShoulder*3,c=q.rightShoulder*3,u=(n[l]+n[c])/2,f=(n[l+1]+n[c+1])/2,h=q.leftHip*3,b=q.rightHip*3,y=(n[h]+n[b])/2,x=(n[h+1]+n[b+1])/2,d=Dn(y)&&Dn(x)?Math.hypot(y-u,x-f):0;return(o(q.leftHip)<0||o(q.rightHip)<0)&&(d=Math.max(d,Ai*Math.hypot(n[l]-n[c],n[l+1]-n[c+1]))),d=Math.max(d,.01),{x:io((a-u+fr.left*d)/(fr.w*d)),y:io((i-f+fr.top*d)/(fr.h*d))}}var Si=300,tn=class{constructor(t=Si){p(this,"holdMs",t);p(this,"last",new Map)}static key(t,e){return t*2+(e==="right"?1:0)}at(t,e,n){let s=this.last.get(t);return e?(s?(s.x=e.x,s.y=e.y,s.t=n):this.last.set(t,{x:e.x,y:e.y,t:n}),e):s?n-s.t<=this.holdMs?{x:s.x,y:s.y}:(this.last.delete(t),null):null}clear(){this.last.clear()}},Mi=.25,ho=Object.freeze({top:0,bottom:0,left:0,right:0});function fo(r){if(!Ti(r))return;let t=e=>Dn(e)?Math.min(Math.max(e,0),Mi):0;return{top:t(r.top),bottom:t(r.bottom),left:t(r.left),right:t(r.right)}}var hc=16/9;var Ti=r=>typeof r=="object"&&r!==null&&!Array.isArray(r),Dn=r=>typeof r=="number"&&Number.isFinite(r),io=r=>Math.min(Math.max(r,0),1);var Ei=12,Ri=Ur*4,Ci=r=>Ei+r*Ri,fc=Ci(ki);var Fi=r=>r.startsWith("fabi-play.")?"fablee-play.".concat(r.slice(10)):null;function po(r,t,e=Fi(t)){if(!(!r||!e))try{let n=r.getItem(e);if(n===null)return;r.getItem(t)===null&&r.setItem(t,n),r.removeItem(e)}catch(n){}}var Ne="#4a382c",ve="#2b2118",Ve="#1c1f2b",mo="#fbefe3",Ke="#f4897a",zn="#3a2a22",Xr=[{id:"fox",name:{en:"Fox",it:"Volpe"},band:"6-8",palette:{body:"#ee6a43",limbs:"#ee6a43",belly:mo,accent:"#ffd9c2",outline:ve,hands:"#5a3426",feet:"#5a3426"},head:"wide",ears:"pointy",face:{eyes:"dot",mouth:"cat",nose:zn,muzzle:"cheeks"},tail:"fluffy",headExtras:[],bodyExtras:[]},{id:"mascot",name:{en:"Fabi",it:"Fabi"},band:"all",special:!0,palette:{body:"#ee6a43",limbs:"#ee6a43",belly:mo,accent:"#5a3426",outline:ve,hands:"#5a3426",feet:"#5a3426"},head:"wide",ears:"pointy",face:{eyes:"bead",mouth:"open",nose:zn,muzzle:"band",cheeks:Ke},tail:"brush",headExtras:[],bodyExtras:["star"],extraColors:["#ffd84a"]},{id:"bunny",name:{en:"Bunny",it:"Coniglietto"},band:"3-5",palette:{body:"#f9d0de",limbs:"#f9d0de",belly:"#fff6f8",accent:"#f4a0b9",outline:Ne},head:"round",ears:"long",face:{eyes:"dot",mouth:"cat",nose:"#e0607e",muzzle:"none",cheeks:Ke},tail:"pom",headExtras:[],bodyExtras:[]},{id:"bear",name:{en:"Bear",it:"Orsetto"},band:"3-5",palette:{body:"#cf9f78",limbs:"#cf9f78",belly:"#f7e0bf",accent:"#f7e0bf",outline:Ne},head:"round",ears:"round",face:{eyes:"dot",mouth:"smile",nose:zn,muzzle:"oval",cheeks:Ke},tail:"none",headExtras:[],bodyExtras:[]},{id:"cat",name:{en:"Cat",it:"Gattino"},band:"3-5",palette:{body:"#c8b6ee",limbs:"#c8b6ee",belly:"#f4eeff",accent:"#f7b3c8",outline:Ne,hands:"#f4eeff",feet:"#f4eeff"},head:"wide",ears:"pointy",face:{eyes:"big",eyeColor:"#3f9a5a",mouth:"cat",nose:"#f07a9a",muzzle:"none",cheeks:Ke},tail:"long",headExtras:["whiskers"],bodyExtras:[]},{id:"panda",name:{en:"Panda",it:"Panda"},band:"3-5",palette:{body:"#ffffff",limbs:"#6e6674",belly:"#ffffff",accent:"#6e6674",outline:Ne,ears:"#6e6674"},head:"wide",ears:"round",face:{eyes:"mask",mouth:"smile",nose:"#2f2a2c",muzzle:"none",cheeks:"#f6a3a3"},tail:"none",headExtras:[],bodyExtras:[]},{id:"penguin",name:{en:"Penguin",it:"Pinguino"},band:"3-5",palette:{body:"#6c8fca",limbs:"#6c8fca",belly:"#ffffff",accent:"#f9b95c",outline:Ne,feet:"#f9b95c"},head:"tall",ears:"none",face:{eyes:"dot",mouth:"beak",muzzle:"heart",cheeks:"#f6a3a3"},tail:"none",headExtras:[],bodyExtras:["flippers","scarf"],extraColors:["#f6907a"]},{id:"frog",name:{en:"Frog",it:"Ranocchio"},band:"3-5",palette:{body:"#8fd487",limbs:"#8fd487",belly:"#e6f7cc",accent:"#62ad62",outline:Ne},head:"wide",ears:"none",face:{eyes:"big",eyesOnTop:!0,mouth:"open",muzzle:"none",cheeks:"#f59b8f"},tail:"none",headExtras:[],bodyExtras:["flippers","spots"],extraColors:["#62ad62","#b0e6a4"]},{id:"lion",name:{en:"Lion",it:"Leoncino"},band:"6-8",alsoIn:["3-5"],palette:{body:"#f6c454",limbs:"#f6c454",belly:"#fde7b0",accent:"#fde7b0",outline:ve},head:"round",ears:"round",face:{eyes:"dot",mouth:"cat",nose:"#8a4b2a",muzzle:"oval",cheeks:Ke},tail:"tuft",headExtras:["mane"],bodyExtras:[],extraColors:["#c8692e"]},{id:"unicorn",name:{en:"Unicorn",it:"Unicorno"},band:"6-8",palette:{body:"#fbf5ff",limbs:"#fbf5ff",belly:"#efe0ff",accent:"#fbd46a",outline:ve,hands:"#c9a6f2",feet:"#c9a6f2"},head:"tall",ears:"unicorn",face:{eyes:"dot",mouth:"smile",muzzle:"none",cheeks:"#f7a6c8"},tail:"none",headExtras:["rainbow-mane"],bodyExtras:[],extraColors:["#f58cc0","#8fd3f4","#a98ff2"]},{id:"dragon",name:{en:"Little Dragon",it:"Draghetto"},band:"6-8",palette:{body:"#8a63d2",limbs:"#8a63d2",belly:"#fbd46a",accent:"#5fd0b5",outline:ve},head:"wide",ears:"horns",face:{eyes:"big",eyeColor:"#3a2a6a",mouth:"teeth",muzzle:"none",cheeks:"#f59bc0"},tail:"arrow",headExtras:[],bodyExtras:["wings"]},{id:"robot",name:{en:"Robot",it:"Robot"},band:"9-12",palette:{body:"#b9c7d2",limbs:"#8b9aa6",belly:"#b9c7d2",accent:"#ee6a43",outline:Ve,hands:"#ee6a43",feet:"#6b7a86"},head:"square",ears:"antenna",face:{eyes:"screen",eyeColor:"#7ff0ff",mouth:"grill",muzzle:"none"},tail:"none",headExtras:["bolts"],bodyExtras:["panel","joints","boots"],extraColors:["#ff7a6b","#fbd46a","#7ff0ff"]},{id:"astronaut",name:{en:"Astronaut",it:"Astronauta"},band:"9-12",palette:{body:"#f4f1ec",limbs:"#f4f1ec",belly:"#f4f1ec",accent:"#ee6a43",outline:Ve,hands:"#9fb0bd",feet:"#9fb0bd"},head:"round",ears:"none",face:{eyes:"visor",mouth:"smile",muzzle:"none"},tail:"none",headExtras:["helmet"],bodyExtras:["backpack","badge","boots"],extraColors:["#c9d3db"]},{id:"dinosaur",name:{en:"Dinosaur",it:"Dinosauro"},band:"6-8",palette:{body:"#3fb3a6",limbs:"#3fb3a6",belly:"#c9f0d6",accent:"#f79a3e",outline:ve},head:"wide",ears:"none",face:{eyes:"dot",mouth:"teeth",muzzle:"none",cheeks:"#f59b8f"},tail:"spiky",headExtras:["spikes","spots"],bodyExtras:[],extraColors:["#2b8f84","#7fd3c6"]},{id:"monkey",name:{en:"Monkey",it:"Scimmietta"},band:"6-8",palette:{body:"#7b5234",limbs:"#7b5234",belly:"#f2c9a0",accent:"#f2c9a0",outline:ve,hands:"#f2c9a0",feet:"#f2c9a0"},head:"round",ears:"side",face:{eyes:"dot",mouth:"open",nose:"#5a3a26",muzzle:"monkey",cheeks:Ke},tail:"curl",headExtras:["tuft"],bodyExtras:[]},{id:"koala",name:{en:"Koala",it:"Koala"},band:"3-5",palette:{body:"#b7bcc6",limbs:"#b7bcc6",belly:"#eef0f3",accent:"#f4dbe2",outline:Ne},head:"wide",ears:"big-round",face:{eyes:"dot",mouth:"smile",nose:"#3b3438",muzzle:"none",cheeks:"#f4a3b0"},tail:"none",headExtras:[],bodyExtras:[]},{id:"tiger",name:{en:"Tiger",it:"Tigrotto"},band:"6-8",palette:{body:"#f9a33a",limbs:"#f9a33a",belly:"#fff1dc",accent:"#fff1dc",outline:ve},head:"wide",ears:"round",face:{eyes:"dot",mouth:"cat",nose:"#e2607a",muzzle:"oval",cheeks:Ke},tail:"striped",headExtras:["stripes","whiskers"],bodyExtras:[],extraColors:["#3a2a22"]},{id:"owl",name:{en:"Owl",it:"Gufetto"},band:"3-5",palette:{body:"#8ec0e6",limbs:"#8ec0e6",belly:"#e3f2fc",accent:"#639cc9",outline:Ne,feet:"#f9b95c",hands:"#639cc9"},head:"tall",ears:"tufts",face:{eyes:"big",eyeColor:Ne,eyeRing:"#fde08a",mouth:"beak",muzzle:"none",cheeks:"#f6a8b4"},tail:"none",headExtras:[],bodyExtras:["feathers"]},{id:"alien",name:{en:"Alien",it:"Alieno"},band:"9-12",palette:{body:"#9ee05a",limbs:"#9ee05a",belly:"#d8f5a8",accent:"#b07cf2",outline:Ve},head:"bulb",ears:"antennae",face:{eyes:"almond",eyeColor:"#1e1838",mouth:"smirk",muzzle:"none"},tail:"none",headExtras:[],bodyExtras:["spots"],extraColors:["#7cc23e","#7cc23e"]},{id:"ghost",name:{en:"Friendly Ghost",it:"Fantasmino"},band:"6-8",palette:{body:"#e6f4ff",limbs:"#e6f4ff",belly:"#e6f4ff",accent:"#bcd9f2",outline:ve},head:"round",ears:"none",face:{eyes:"dot",mouth:"open",muzzle:"none",cheeks:"#f7a6c8"},tail:"none",headExtras:["curl"],bodyExtras:["sheet"]},{id:"octopus",name:{en:"Octopus",it:"Polpetto"},band:"6-8",palette:{body:"#e0578a",limbs:"#e0578a",belly:"#f7b3cc",accent:"#f7b3cc",outline:ve,hands:"#f7b3cc",feet:"#f7b3cc"},head:"tall",ears:"none",face:{eyes:"big",eyeColor:"#3a2140",mouth:"smile",muzzle:"none",cheeks:"#ffd0a0"},tail:"none",headExtras:["spots"],bodyExtras:["tentacles"],extraColors:["#f7b3cc","#f7b3cc"]},{id:"chick",name:{en:"Chick",it:"Pulcino"},band:"3-5",palette:{body:"#ffd45e",limbs:"#ffd45e",belly:"#fff2c2",accent:"#ffa04a",outline:Ne,hands:"#ffc23d",feet:"#ffa04a"},head:"round",ears:"none",face:{eyes:"dot",mouth:"beak",muzzle:"none",cheeks:Ke},tail:"none",headExtras:["eggshell"],bodyExtras:[],extraColors:["#fffaf0"]},{id:"puppy",name:{en:"Puppy",it:"Cucciolo"},band:"3-5",palette:{body:"#f4e4cf",limbs:"#f4e4cf",belly:"#fffaf2",accent:"#f29aa4",outline:Ne,ears:"#b58262",hands:"#e6caa6",feet:"#e6caa6"},head:"wide",ears:"floppy",face:{eyes:"dot",mouth:"open",nose:zn,muzzle:"oval",cheeks:Ke},tail:"curl",headExtras:["eye-spot"],bodyExtras:[]},{id:"lamb",name:{en:"Lamb",it:"Agnellino"},band:"3-5",palette:{body:"#fdf8ee",limbs:"#e3d1c2",belly:"#fffdf8",accent:"#f6bcc2",outline:Ne,skin:"#f7dccb",hands:"#a58c7e",feet:"#a58c7e"},head:"round",ears:"droopy",face:{eyes:"dot",mouth:"smile",nose:"#e591a0",muzzle:"none",cheeks:Ke},tail:"pom",headExtras:["wool"],bodyExtras:["wool"]},{id:"duckling",name:{en:"Duckling",it:"Anatroccolo"},band:"3-5",palette:{body:"#fff1a6",limbs:"#fff1a6",belly:"#fffbe0",accent:"#ff9f43",outline:Ne,feet:"#ff9f43"},head:"tall",ears:"none",face:{eyes:"dot",mouth:"bill",muzzle:"none",cheeks:Ke},tail:"none",headExtras:["curl"],bodyExtras:["flippers","scarf"],extraColors:["#86cfe0"]},{id:"shark",name:{en:"Shark",it:"Squalo"},band:"6-8",palette:{body:"#6c95c4",limbs:"#6c95c4",belly:"#eef5fb",accent:"#4c76a8",outline:ve,hands:"#eef5fb",feet:"#4c76a8"},head:"wide",ears:"fin",face:{eyes:"dot",mouth:"jaws",muzzle:"none",cheeks:"#f59bb0"},tail:"fish",headExtras:["gills"],bodyExtras:[]},{id:"wolf",name:{en:"Wolf",it:"Lupo"},band:"6-8",palette:{body:"#8f9bb3",limbs:"#8f9bb3",belly:"#eef1f6",accent:"#f3b8c4",outline:ve,hands:"#5a647a",feet:"#5a647a"},head:"round",ears:"pointy",face:{eyes:"dot",mouth:"open",nose:zn,muzzle:"oval",cheeks:"#f4a3b0"},tail:"fluffy",headExtras:["ruff","forehead"],bodyExtras:[],extraColors:["#636d84"]},{id:"parrot",name:{en:"Parrot",it:"Pappagallo"},band:"6-8",palette:{body:"#e8503f",limbs:"#e8503f",belly:"#ffd25a",accent:"#f6e6c4",outline:ve,hands:"#3a9bdc",feet:"#8a7a70"},head:"round",ears:"none",face:{eyes:"big",eyeColor:ve,eyeRing:"#ffffff",mouth:"hook",muzzle:"none",cheeks:"#ffb0a0"},tail:"plume",headExtras:["crest"],bodyExtras:["feathers"],extraColors:["#ffd25a","#3fae5a","#3a9bdc"]},{id:"ninja",name:{en:"Ninja",it:"Ninja"},band:"9-12",palette:{body:"#2f3a56",limbs:"#2f3a56",belly:"#2f3a56",accent:"#36c9bb",outline:Ve,skin:"#b07a52",hands:"#222a40",feet:"#222a40"},head:"round",ears:"none",face:{eyes:"calm",mouth:"none",muzzle:"none",brows:"#2a1d16"},tail:"none",headExtras:["ninja-hood"],bodyExtras:["belt"],extraColors:["#36c9bb","#36c9bb","#36c9bb"]},{id:"skater",name:{en:"Skater",it:"Skater"},band:"9-12",palette:{body:"#3a8fc0",limbs:"#2c3e57",belly:"#2f7aa6",accent:"#ffcf3a",outline:Ve,skin:"#f2c9a5",hair:"#7a4a2a",hands:"#f2c9a5",feet:"#eef1f5"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smirk",muzzle:"none",brows:"#5a3520"},tail:"none",headExtras:["hair","cap"],bodyExtras:["pocket","joints"],extraColors:["#ff5d73"]},{id:"explorer",name:{en:"Explorer",it:"Giramondo"},band:"9-12",palette:{body:"#5f8f5b",limbs:"#5f8f5b",belly:"#5f8f5b",accent:"#d9bb7e",outline:Ve,skin:"#7a4a30",hair:"#1d1410",hands:"#7a4a30",feet:"#6b4a2a"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smile",muzzle:"none",brows:"#1d1410"},tail:"none",headExtras:["curls","safari-hat"],bodyExtras:["backpack","straps","boots"],extraColors:["#e07b39","#6b4a2a"]},{id:"wizard",name:{en:"Wizard",it:"Mago"},band:"9-12",palette:{body:"#5b3fa0",limbs:"#5b3fa0",belly:"#5b3fa0",accent:"#3d5fc8",outline:Ve,skin:"#c98d62",hair:"#a8452a",hands:"#c98d62",feet:"#33255e"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smile",muzzle:"none",brows:"#7a301c"},tail:"none",headExtras:["locks","wizard-hat"],bodyExtras:["robe","belt"],extraColors:["#ffd84a","#ffd84a","#ffd84a"]},{id:"knight",name:{en:"Knight",it:"Cavaliere"},band:"9-12",palette:{body:"#bcc7d3",limbs:"#8e9aa8",belly:"#dce3ea",accent:"#d8443a",outline:Ve,hands:"#6c7786",feet:"#6c7786"},head:"bucket",ears:"none",face:{eyes:"slit",eyeColor:"#bfefff",mouth:"none",muzzle:"none"},tail:"none",headExtras:["plume"],bodyExtras:["pauldrons","emblem","boots"],extraColors:["#d8443a"]},{id:"racer",name:{en:"Racer",it:"Pilota"},band:"9-12",palette:{body:"#ff6a2b",limbs:"#ff6a2b",belly:"#ffffff",accent:"#ffffff",outline:Ve,hands:"#232838",feet:"#232838"},head:"round",ears:"none",face:{eyes:"goggle",eyeColor:"#7fd6ff",mouth:"none",muzzle:"none"},tail:"none",headExtras:["stripe"],bodyExtras:["racing-stripe","boots"]},{id:"pirate",name:{en:"Pirate",it:"Pirata"},band:"9-12",palette:{body:"#f2efe6",limbs:"#2a3d6e",belly:"#f2efe6",accent:"#d94545",outline:Ve,skin:"#d9a072",hair:"#2b1a12",hands:"#d9a072",feet:"#3a2a20"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smirk",muzzle:"none",brows:"#2b1a12"},tail:"none",headExtras:["locks","bandana","eye-patch"],bodyExtras:["stripes","belt","boots"],extraColors:["#d94545","#2a3d6e","#4a3426"]},{id:"diver",name:{en:"Diver",it:"Sub"},band:"9-12",palette:{body:"#1f6582",limbs:"#1f6582",belly:"#1f6582",accent:"#ffb020",outline:Ve,skin:"#e8b48a",hair:"#c98f2e",hands:"#1b4f66",feet:"#ffb020"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smile",muzzle:"none",brows:"#8a5a1a"},tail:"none",headExtras:["curls","dive-mask"],bodyExtras:["tank","fins"],extraColors:["#c9d3db"]},{id:"hero",name:{en:"Hero",it:"Supereroe"},band:"9-12",palette:{body:"#3557c8",limbs:"#3557c8",belly:"#3557c8",accent:"#e0403a",outline:Ve,skin:"#5a3825",hair:"#141010",hands:"#e0403a",feet:"#e0403a"},head:"round",ears:"human",face:{eyes:"calm",mouth:"smirk",muzzle:"none",brows:"#141010"},tail:"none",headExtras:["hair","domino"],bodyExtras:["cape","emblem","boots"],extraColors:["#ffd84a"]},{id:"trex",name:{en:"T-Rex",it:"T-Rex"},band:"6-8",alsoIn:["3-5"],palette:{body:"#6cb84e",limbs:"#6cb84e",belly:"#f4e8a8",accent:"#f4e8a8",outline:ve},head:"snout-long",ears:"none",face:{eyes:"dot",mouth:"toothy",muzzle:"none",cheeks:"#f59b8f"},tail:"thick",headExtras:["stripes"],bodyExtras:["tiny-arms","strong-legs"],extraColors:["#4a9235","#58a23f"]},{id:"fairy",name:{en:"Fairy",it:"Fatina"},band:"6-8",alsoIn:["3-5"],palette:{body:"#b99af0",limbs:"#a8693f",belly:"#b99af0",accent:"#ffd84a",outline:ve,skin:"#a8693f",hair:"#2e1d17",hands:"#a8693f",feet:"#f58cbc"},head:"round",ears:"pixie",face:{eyes:"dot",mouth:"smile",muzzle:"none",cheeks:"#f0857a"},tail:"none",headExtras:["bun","flower-crown"],bodyExtras:["wings-fairy","petals","wand"],extraColors:["#c4ecff","#f7a8cf","#fff3a0","#ffffff"]}];var de={M:0,L:1,Q:2,C:3,Z:4},bo=[2,2,4,6,0];function nn(r,t){for(let e of t)Pi(r,e)}function Pi(r,t){var e,n,s,o,a;if(t.k==="group"){r.save(),r.translate(t.x,t.y),t.rot&&r.rotate(t.rot),t.s!==void 0&&t.s!==1&&r.scale(t.s,t.s),t.alpha!==void 0&&(r.globalAlpha*=t.alpha),nn(r,t.items),r.restore();return}switch(r.save(),t.alpha!==void 0&&(r.globalAlpha*=t.alpha),r.beginPath(),t.k){case"circle":r.arc(t.x,t.y,Math.max(t.r,0),0,Math.PI*2);break;case"ellipse":r.ellipse(t.x,t.y,Math.max(t.rx,0),Math.max(t.ry,0),(e=t.rot)!=null?e:0,0,Math.PI*2);break;case"rect":_i(r,t);break;case"path":typeof t.d=="string"?Oi(r,t.d):Li(r,t.d);break;case"line":r.moveTo((n=t.pts[0])!=null?n:0,(s=t.pts[1])!=null?s:0);for(let i=2;i+1<t.pts.length;i+=2)r.lineTo(t.pts[i],t.pts[i+1]);break}r.lineCap="round",r.lineJoin="round",t.fill&&t.k!=="line"&&(r.fillStyle=t.fill,r.fill()),t.stroke&&((o=t.lw)!=null?o:1)>0&&(r.strokeStyle=t.stroke,r.lineWidth=(a=t.lw)!=null?a:1,r.stroke()),r.restore()}function _i(r,t){let e=Math.max(0,Math.min(t.r,t.w/2,t.h/2));r.translate(t.x,t.y),t.rot&&r.rotate(t.rot);let n=-t.w/2,s=-t.h/2;r.moveTo(n+e,s),r.lineTo(n+t.w-e,s),r.quadraticCurveTo(n+t.w,s,n+t.w,s+e),r.lineTo(n+t.w,s+t.h-e),r.quadraticCurveTo(n+t.w,s+t.h,n+t.w-e,s+t.h),r.lineTo(n+e,s+t.h),r.quadraticCurveTo(n,s+t.h,n,s+t.h-e),r.lineTo(n,s+e),r.quadraticCurveTo(n,s,n+e,s),r.closePath()}function Li(r,t){for(let e=0;e<t.length;){let n=t[e++];if(n===de.M)r.moveTo(t[e],t[e+1]);else if(n===de.L)r.lineTo(t[e],t[e+1]);else if(n===de.Q)r.quadraticCurveTo(t[e],t[e+1],t[e+2],t[e+3]);else if(n===de.C)r.bezierCurveTo(t[e],t[e+1],t[e+2],t[e+3],t[e+4],t[e+5]);else if(n===de.Z)r.closePath();else return;e+=bo[n]}}function jr(r){var e;if(typeof r=="string")return((e=r.match(/-?\d*\.?\d+(?:e-?\d+)?/gi))!=null?e:[]).map(Number);let t=[];for(let n=0;n<r.length;){let s=bo[r[n++]];if(s===void 0)break;for(let o=0;o<s;o++)t.push(r[n+o]);n+=s}return t}function Oi(r,t){var a;let e=(a=t.match(/[MLQCZ]|-?\d*\.?\d+(?:e-?\d+)?/gi))!=null?a:[],n="",s=0,o=()=>Number(e[s++]);for(;s<e.length;){let i=e[s];if(/[MLQCZ]/i.test(i)&&(n=i.toUpperCase(),s++,n==="Z")){r.closePath();continue}n==="M"?(r.moveTo(o(),o()),n="L"):n==="L"?r.lineTo(o(),o()):n==="Q"?r.quadraticCurveTo(o(),o(),o(),o()):n==="C"?r.bezierCurveTo(o(),o(),o(),o(),o(),o()):s++}}var ce=r=>{let t=Math.round(r*100)/100;return t===0?0:t};function ie(r,t=.5){let e=r.length;if(e<3)return[];let n=(i,l,c)=>({x:i.x+(l.x-i.x)*c,y:i.y+(l.y-i.y)*c}),s=Math.min(Math.max(t,0),.5),o=n(r[0],r[1],s),a=[de.M,ce(o.x),ce(o.y)];for(let i=1;i<=e;i++){let l=r[(i-1)%e],c=r[i%e],u=r[(i+1)%e],f=n(l,c,1-s),h=n(c,u,s);a.push(de.L,ce(f.x),ce(f.y),de.Q,ce(c.x),ce(c.y),ce(h.x),ce(h.y))}return a.push(de.Z),a}function ae(r,t=1){let e=r.length;if(e<3)return[];let n=[de.M,ce(r[0].x),ce(r[0].y)],s=t/6;for(let o=0;o<e;o++){let a=r[(o-1+e)%e],i=r[o],l=r[(o+1)%e],c=r[(o+2)%e];n.push(de.C,ce(i.x+(l.x-a.x)*s),ce(i.y+(l.y-a.y)*s),ce(l.x-(c.x-i.x)*s),ce(l.y-(c.y-i.y)*s),ce(l.x),ce(l.y))}return n.push(de.Z),n}function rn(r){let t=r.length;if(t<2)return[];let e=[de.M,ce(r[0].x),ce(r[0].y)];for(let n=0;n<t-1;n++){let s=r[Math.max(n-1,0)],o=r[n],a=r[n+1],i=r[Math.min(n+2,t-1)];e.push(de.C,ce(o.x+(a.x-s.x)/6),ce(o.y+(a.y-s.y)/6),ce(a.x-(i.x-o.x)/6),ce(a.y-(i.y-o.y)/6),ce(a.x),ce(a.y))}return e}var ct="M0 -1 L0.29 -0.4 L0.95 -0.31 L0.47 0.15 L0.59 0.81 L0 0.5 L-0.59 0.81 L-0.47 0.15 L-0.95 -0.31 L-0.29 -0.4 Z";var xe="#ffffff",Z=[-1,1],yo="#3a2420",xo="#f2808f",qr="#26324a",Ii="#ffd84a",me=(...r)=>{let t=[];for(let e=0;e+1<r.length;e+=2)t.push({x:r[e],y:r[e+1]});return t};function pr(r,t){var u,f,h,b,y,x,d;let e=r.palette,n=[],s={stroke:e.outline,lw:t},o=m=>r.headExtras.includes(m),a=(m,g)=>{var v,k;return(k=(v=r.extraColors)==null?void 0:v[m])!=null?k:g};if(o("mane")){for(let g=0;g<12;g++){let v=g/12*Math.PI*2;n.push(M({k:"circle",x:Math.cos(v)*1.02,y:Math.sin(v)*1+.04,r:.42,fill:a(0,e.accent)},s))}n.push({k:"circle",x:0,y:.04,r:1.08,fill:a(0,e.accent)})}if(o("rainbow-mane")){let m=(u=r.extraColors)!=null?u:["#f59ac0","#fbd46a","#8fd3f4"];[[.98,.05,.3,.5,-.25],[.92,.58,.26,.42,-.1],[.62,.92,.22,.32,.4]].forEach(([v,k,R,F,I],A)=>n.push(M({k:"ellipse",x:v,y:k,rx:R,ry:F,rot:I,fill:m[A%m.length]},s)))}if(o("spikes"))for(let m of[-.55,0,.55]){let g=Bt(m,1.48),v=Bt(m-.32,.86),k=Bt(m+.32,.86);n.push(M({k:"path",d:ie([v,g,k],.22),fill:e.accent},s))}if(o("curl")&&n.push(M({k:"path",d:ae([{x:-.2,y:-.9},{x:-.05,y:-1.3},{x:.32,y:-1.42},{x:.16,y:-1.18},{x:.2,y:-.9}]),fill:e.body},s)),o("wool"))for(let m=0;m<=8;m++){let g=-1.75+m/8*3.5;n.push(M({k:"circle",x:Math.sin(g)*.98,y:-Math.cos(g)*.92-.04,r:.34,fill:e.body},s))}if(o("crest")&&[-.38,0,.38].forEach((m,g)=>{let v=Bt(m,1.12);n.push(M({k:"ellipse",x:v.x,y:v.y,rx:.15,ry:.42,rot:m,fill:a(g,e.accent)},s))}),o("plume")&&n.push(M({k:"path",d:ae(me(-.12,-.92,-.2,-1.42,.1,-1.78,.62,-1.74,.36,-1.46,.16,-.98)),fill:e.accent},s)),o("locks")&&n.push(M({k:"path",d:ae(me(-1.14,.58,-1.24,-.2,-.86,-.98,0,-1.2,.86,-.98,1.24,-.2,1.14,.58,.8,.66,0,.2,-.8,.66)),fill:(f=e.hair)!=null?f:e.outline},s)),o("bun")&&n.push(M({k:"circle",x:.04,y:-1.14,r:.4,fill:(h=e.hair)!=null?h:e.outline},s)),o("ninja-hood"))for(let[m,g]of[[.35,.5],[.85,.42]])n.push(M({k:"ellipse",x:1+Math.cos(m)*g*.8,y:-.5+Math.sin(m)*g*.8,rx:g,ry:.11,rot:m,fill:e.accent},s));if(o("bandana"))for(let[m,g]of[[Math.PI-.5,.42],[Math.PI-1,.36]])n.push(M({k:"ellipse",x:-.98+Math.cos(m)*g*.8,y:-.36+Math.sin(m)*g*.8,rx:g,ry:.12,rot:m,fill:e.accent},s));if(o("ruff"))for(let m of Z)n.push(M({k:"path",d:ie(me(m*.7,-.3,m*1.32,0,m*1.02,.18,m*1.26,.46,m*.86,.56,m*.98,.84,m*.4,.7),.25),fill:e.body},s));if(r.face.eyesOnTop)for(let m of Z)n.push(M({k:"circle",x:m*.46,y:-.72,r:.38,fill:e.body},s));n.push(...$i(r,t)),n.push(Ni(r,s));let i=r.face.muzzle,l=e.belly;if(i==="oval"&&n.push({k:"ellipse",x:0,y:.4,rx:.46,ry:.32,fill:l}),i==="monkey"){for(let m of Z)n.push({k:"circle",x:m*.32,y:-.04,r:.38,fill:l});n.push({k:"ellipse",x:0,y:.4,rx:.56,ry:.4,fill:l})}if(i==="heart"){for(let m of Z)n.push({k:"circle",x:m*.36,y:.02,r:.5,fill:l});n.push({k:"ellipse",x:0,y:.38,rx:.66,ry:.48,fill:l})}if(i==="disc")for(let m of Z)n.push({k:"circle",x:m*.4,y:.02,r:.44,fill:l});if(i==="cheeks")for(let m of Z)n.push({k:"ellipse",x:m*.4,y:.44,rx:.44,ry:.32,fill:l});if(i==="band"&&n.push({k:"path",d:Hi(r,t),fill:l}),o("stripes")&&r.head==="snout-long"){let m=a(0,e.outline);for(let[g,v,k,R]of[[.46,-.94,.36,-.66],[.8,-.72,.62,-.5],[1,-.36,.78,-.24]])n.push({k:"line",pts:[g,v,k,R],stroke:m,lw:.11})}else if(o("stripes")){let m=a(0,e.outline);n.push({k:"line",pts:[0,-.97,0,-.66],stroke:m,lw:.13});for(let g of Z)n.push({k:"line",pts:[g*.3,-.93,g*.24,-.7],stroke:m,lw:.1}),n.push({k:"line",pts:[g*.98,-.05,g*.74,0],stroke:m,lw:.1}),n.push({k:"line",pts:[g*.94,.22,g*.74,.22],stroke:m,lw:.09})}if(o("spots")){let m=a(1,e.belly);n.push({k:"circle",x:-.55,y:-.5,r:.15,fill:m}),n.push({k:"circle",x:.58,y:-.42,r:.11,fill:m}),n.push({k:"circle",x:.22,y:-.76,r:.09,fill:m})}if(r.head==="snout-long")for(let[m,g,v]of[[-1.38,-.14,.06],[-1.14,-.22,.055]])n.push({k:"ellipse",x:m,y:g,rx:v,ry:v*.8,rot:-.3,fill:e.outline,alpha:.85});if(o("forehead")&&n.push({k:"path",d:ae(me(-.62,-.66,0,-.86,.62,-.66,.26,-.36,0,-.1,-.26,-.36),.9),fill:a(0,e.accent)}),o("eye-spot")&&n.push({k:"ellipse",x:.42,y:-.06,rx:.3,ry:.33,rot:.3,fill:(b=e.ears)!=null?b:e.accent}),o("gills"))for(let m of Z)for(let g of[0,.12,.24])n.push({k:"path",d:"M".concat(m*(.66+g)," 0.06 Q").concat(m*(.6+g)," 0.22 ").concat(m*(.66+g)," 0.38"),stroke:e.accent,lw:t*.9});let c=(y=e.hair)!=null?y:e.outline;if(o("hair")&&n.push(M({k:"path",d:ae(me(-1.02,-.06,-1.02,-.58,-.62,-1.04,.08,-1.14,.76,-.92,1.05,-.42,1,-.06,.84,-.4,.42,-.5,.06,-.4,-.34,-.56,-.74,-.38)),fill:c},s)),o("locks")&&n.push(M({k:"path",d:ae(me(-1,-.08,-.98,-.62,-.56,-1.02,0,-1.1,.56,-1.02,.98,-.62,1,-.08,.8,-.38,.36,-.44,0,-.4,-.36,-.44,-.8,-.38)),fill:c},s)),o("bun")&&n.push(M({k:"path",d:ae(me(-1.02,-.1,-.98,-.62,-.56,-1.02,0,-1.1,.56,-1.02,.98,-.62,1.02,-.1,.84,-.36,.5,-.56,.12,-.48,-.22,-.6,-.6,-.5,-.86,-.36)),fill:c},s)),o("curls")){for(let m=0;m<7;m++){let g=Bt(-1.3+m/6*2.6,.86);n.push(M({k:"circle",x:g.x,y:g.y,r:.3,fill:c},s))}n.push({k:"ellipse",x:0,y:-.64,rx:.8,ry:.36,fill:c})}if(o("ninja-hood")&&(n.push({k:"rect",x:0,y:0,w:1.56,h:.6,r:.28,fill:(x=e.skin)!=null?x:xe,stroke:e.outline,lw:t*.8}),n.push(M({k:"path",d:"M-0.98 -0.42 Q0 -0.74 0.98 -0.42 L1.0 -0.62 Q0 -0.94 -1.0 -0.62 Z",fill:e.accent},s))),o("domino")){n.push(M({k:"path",d:ae(me(-.86,-.04,-.62,-.3,-.18,-.24,0,-.16,.18,-.24,.62,-.3,.86,-.04,.6,.22,.16,.16,0,.1,-.16,.16,-.6,.22),.9),fill:e.accent},s));for(let m of Z)n.push({k:"ellipse",x:m*.38,y:0,rx:.19,ry:.13,fill:xe})}if(n.push(...Gi(r,t)),o("brows"))for(let m of Z)n.push({k:"line",pts:[m*.72,-.5,m*.14,-.3],stroke:e.accent,lw:.16});if(r.face.brows)for(let m of Z)n.push({k:"line",pts:[m*.2,-.2,m*.54,-.28],stroke:r.face.brows,lw:.09});if(n.push(...Ui(r,t)),r.face.cheeks)for(let m of Bi(r))n.push({k:"ellipse",x:m.x,y:m.y,rx:.15,ry:.1,fill:r.face.cheeks,alpha:.8});if(o("whiskers"))for(let m of Z)for(let g of[-.1,.06])n.push({k:"line",pts:[m*.62,.38+g,m*1.06,.3+g*2.2],stroke:e.outline,lw:t*.7,alpha:.75});if(o("rainbow-mane")){let m=(d=r.extraColors)!=null?d:["#f59ac0","#fbd46a","#8fd3f4"];n.push(M({k:"ellipse",x:.42,y:-.82,rx:.34,ry:.22,rot:.5,fill:m[0]},s)),n.push(M({k:"ellipse",x:.1,y:-.92,rx:.3,ry:.2,rot:.25,fill:m[1%m.length]},s))}if(r.ears==="unicorn"){let m=[{x:-.18,y:-.84},{x:.02,y:-1.72},{x:.18,y:-.84}];n.push(M({k:"path",d:ie(m,.12),fill:e.accent},s));for(let g of[-1,-1.2,-1.4]){let v=.16*((g+1.72)/.88);n.push({k:"line",pts:[-v,g+.04,v,g-.04],stroke:e.outline,lw:t*.7,alpha:.6})}}if(o("flower-crown")){let m=[a(1,"#f7a8cf"),a(2,"#fff3a0"),a(3,xe)];for(let g of[-.84,-.28,.28,.84]){let v=Bt(g,.9);n.push({k:"ellipse",x:v.x,y:v.y,rx:.14,ry:.07,rot:g+.5,fill:"#7cc76a",stroke:e.outline,lw:t*.7})}[-1.12,-.56,0,.56,1.12].forEach((g,v)=>{let k=Bt(g,.9),R=v===2?.13:.11;for(let F=0;F<5;F++){let I=g+F/5*Math.PI*2;n.push({k:"circle",x:k.x+Math.sin(I)*R,y:k.y-Math.cos(I)*R,r:R*.82,fill:m[v%m.length],stroke:e.outline,lw:t*.7})}n.push({k:"circle",x:k.x,y:k.y,r:R*.62,fill:m[v%m.length]}),n.push({k:"circle",x:k.x,y:k.y,r:R*.42,fill:e.accent})})}if(o("helmet")){for(let m of Z)n.push(M({k:"rect",x:m*1,y:.05,w:.26,h:.56,r:.12,fill:e.accent},s));n.push({k:"path",d:"M-0.62 -0.62 Q-0.3 -0.92 0.12 -0.9",stroke:xe,lw:.1,alpha:.9})}if(o("bolts"))for(let m of Z)n.push(M({k:"rect",x:m*1.08,y:.08,w:.2,h:.44,r:.08,fill:e.accent},s));if(o("tuft")&&n.push(M({k:"path",d:ae([{x:-.26,y:-.95},{x:-.12,y:-1.22},{x:.02,y:-1.04},{x:.16,y:-1.28},{x:.28,y:-.95},{x:0,y:-.86}]),fill:e.body},s)),o("eggshell")&&n.push(M({k:"path",d:"M-0.88 -0.5 C-0.88 -1.12 -0.46 -1.42 0 -1.42 C0.46 -1.42 0.88 -1.12 0.88 -0.5 L0.66 -0.66 L0.44 -0.48 L0.22 -0.66 L0 -0.48 L-0.22 -0.66 L-0.44 -0.48 L-0.66 -0.66 Z",fill:a(0,xe)},s)),o("wool"))for(let[m,g]of[[-.36,-.84],[.02,-.94],[.4,-.82]])n.push(M({k:"circle",x:m,y:g,r:.27,fill:e.body},s));if(o("stripe")&&n.push({k:"rect",x:0,y:-.64,w:.38,h:.62,r:.06,fill:e.accent}),o("eye-patch")&&(n.push({k:"line",pts:[-.97,-.5,.97,.13],stroke:e.outline,lw:.07}),n.push({k:"ellipse",x:.38,y:.02,rx:.21,ry:.19,fill:e.outline})),o("bandana")){n.push(M({k:"path",d:ae(me(-1.05,-.22,-.96,-.72,-.5,-1.08,.1,-1.14,.72,-.96,1.04,-.56,1.05,-.22,.5,-.46,-.5,-.46)),fill:e.accent},s));for(let[m,g]of[[-.5,-.8],[.08,-.92],[.6,-.74],[-.12,-.62],[.36,-.6]])n.push({k:"circle",x:m,y:g,r:.06,fill:xe,alpha:.85});n.push(M({k:"circle",x:-.98,y:-.34,r:.15,fill:e.accent},s))}if(o("cap")){for(let m of Z)n.push({k:"line",pts:[m*.98,-.2,m*.5,.82,-m*.05,.98],stroke:e.outline,lw:.06});n.push(M({k:"path",d:ae(me(-1.1,-.16,-1.04,-.66,-.6,-1.12,0,-1.24,.6,-1.12,1.04,-.66,1.1,-.16,.5,-.4,-.5,-.4)),fill:e.accent},s)),n.push(M({k:"path",d:"M-0.74 -0.4 Q0 -0.6 0.74 -0.4 Q0.8 -0.24 0.6 -0.22 Q0 -0.36 -0.6 -0.22 Q-0.8 -0.24 -0.74 -0.4 Z",fill:e.accent},s)),n.push(M({k:"circle",x:.5,y:-.82,r:.15,fill:a(0,xe)},s));for(let m of[-.42,-.14])n.push({k:"line",pts:[m,-1.04,m+.02,-.78],stroke:e.outline,lw:.07,alpha:.7})}if(o("safari-hat")&&(n.push(M({k:"ellipse",x:0,y:-.56,rx:1.48,ry:.3,fill:e.accent},s)),n.push(M({k:"path",d:ae(me(-.78,-.58,-.7,-1.1,-.3,-1.38,.3,-1.38,.7,-1.1,.78,-.58,0,-.5),.8),fill:e.accent},s)),n.push({k:"path",d:"M-0.77 -0.72 Q0 -0.62 0.77 -0.72 L0.74 -0.9 Q0 -0.8 -0.74 -0.9 Z",fill:a(1,e.outline),stroke:e.outline,lw:t*.8})),o("wizard-hat")){n.push(M({k:"ellipse",x:0,y:-.62,rx:1.32,ry:.26,fill:e.accent},s)),n.push(M({k:"path",d:ie(me(-.8,-.66,-.36,-1.5,.5,-2.2,.3,-1.46,.8,-.66),.3),fill:e.accent},s));let m=a(0,Ii);for(let[g,v,k]of[[.02,-1.08,.18],[-.38,-.84,.1],[.36,-1.5,.11]])n.push({k:"group",x:g,y:v,s:k,items:[{k:"path",d:ct,fill:m}]})}if(o("dive-mask")){for(let g of Z)n.push({k:"line",pts:[g*.7,-.04,g*1,-.12],stroke:e.outline,lw:.2},{k:"line",pts:[g*.7,-.04,g*1,-.12],stroke:e.accent,lw:.11});n.push({k:"rect",x:0,y:0,w:1.42,h:.62,r:.28,fill:"#bfe9f5",alpha:.35}),n.push({k:"rect",x:0,y:0,w:1.42,h:.62,r:.28,stroke:e.outline,lw:.2}),n.push({k:"rect",x:0,y:0,w:1.42,h:.62,r:.28,stroke:e.accent,lw:.11}),n.push({k:"path",d:"M-0.5 -0.16 Q-0.4 -0.24 -0.22 -0.24",stroke:xe,lw:.06,alpha:.9});let m="M0.5 0.52 Q0.98 0.56 1.04 0.1 L1.12 -0.92";n.push({k:"path",d:m,stroke:e.outline,lw:.24},{k:"path",d:m,stroke:e.accent,lw:.13})}return n}function Ni(r,t){var n;let e=r.headExtras.includes("ninja-hood")?r.palette.body:(n=r.palette.skin)!=null?n:r.palette.body;switch(r.head){case"round":return M({k:"circle",x:0,y:0,r:1,fill:e},t);case"wide":return M({k:"ellipse",x:0,y:.03,rx:1.12,ry:.94,fill:e},t);case"tall":return M({k:"ellipse",x:0,y:-.02,rx:.94,ry:1.04,fill:e},t);case"square":return M({k:"rect",x:0,y:0,w:2,h:1.8,r:.46,fill:e},t);case"bucket":return M({k:"path",d:ie(me(-.94,.96,-.98,-.36,-.62,-1.04,.62,-1.04,.98,-.36,.94,.96),.42),fill:e},t);case"snout-long":return M({k:"path",d:ae(Di,.95),fill:e},t);case"bulb":return M({k:"path",d:ae([{x:0,y:-1.02},{x:.86,y:-.74},{x:1.08,y:-.12},{x:.72,y:.62},{x:0,y:.92},{x:-.72,y:.62},{x:-1.08,y:-.12},{x:-.86,y:-.74}]),fill:e},t)}}var Di=me(.7,-.88,.12,-1.04,-.3,-.98,-.72,-.74,-1.2,-.56,-1.5,-.32,-1.6,.04,-1.44,.42,-.9,.72,-.2,.92,.5,.88,.96,.56,1.08,0,.98,-.5);function go(r,t,e){return r.head==="snout-long"?[{x:-.36,y:-.5,k:.95},{x:.26,y:-.48,k:1.1}]:Z.map(n=>({x:n*t,y:e,k:1}))}function Bi(r){return r.head==="snout-long"?me(-.66,-.14,.66,.1):Z.map(t=>({x:t*.64,y:.3}))}function zi(r){return r.head==="round"?{cy:0,rx:1,ry:1}:r.head==="tall"?{cy:-.02,rx:.94,ry:1.04}:{cy:.03,rx:1.12,ry:.94}}function Hi(r,t){let{cy:e,rx:n,ry:s}=zi(r),o=n-t/2,a=s-t/2,i=.15,l=Math.asin(Math.min(1,(i-e)/a)),c=Math.cos(l)*o,u=y=>Math.round(y*100)/100||0,f=[de.M,u(-c),i],h=[[-.84*c,.02,-.53*c,.06,-.32*c,.24],[-.17*c,.11,.17*c,.11,.32*c,.24],[.53*c,.06,.84*c,.02,c,i]];for(let y of h)f.push(de.C,...y.map(u));let b=24;for(let y=1;y<=b;y++){let x=l+(Math.PI-2*l)*y/b;f.push(de.L,u(Math.cos(x)*o),u(e+Math.sin(x)*a))}return f.push(de.Z),f}function $i(r,t){var o,a,i,l,c;let e=r.palette,n={stroke:e.outline,lw:t},s=[];for(let u of Z)switch(r.ears){case"pointy":case"unicorn":{let f=r.ears==="unicorn"?.8:1,h={x:u*.3,y:-.82},b={x:u*.86,y:-.82-.62*f},y={x:u*.94,y:-.36};s.push(M({k:"path",d:ie([h,b,y],.2),fill:e.body},n));let x={x:(h.x+b.x+y.x)/3,y:(h.y+b.y+y.y)/3},d=[h,b,y].map(m=>({x:x.x+(m.x-x.x)*.55,y:x.y+(m.y-x.y)*.55+.04}));s.push({k:"path",d:ie(d,.25),fill:e.accent});break}case"round":s.push(M({k:"circle",x:u*.72,y:-.72,r:.36,fill:(o=e.ears)!=null?o:e.body},n)),e.ears||s.push({k:"circle",x:u*.74,y:-.74,r:.19,fill:e.accent});break;case"big-round":s.push(M({k:"circle",x:u*.96,y:-.46,r:.52,fill:e.body},n)),s.push({k:"circle",x:u*1,y:-.44,r:.32,fill:e.accent});break;case"long":s.push(M({k:"ellipse",x:u*.38,y:-1.42,rx:.25,ry:.68,rot:u*.14,fill:e.body},n)),s.push({k:"ellipse",x:u*.39,y:-1.36,rx:.12,ry:.48,rot:u*.14,fill:e.accent});break;case"side":s.push(M({k:"circle",x:u*1,y:.02,r:.34,fill:e.body},n)),s.push({k:"circle",x:u*1.02,y:.02,r:.2,fill:e.belly});break;case"tufts":s.push(M({k:"path",d:ie([{x:u*.3,y:-.84},{x:u*1.22,y:-1.12},{x:u*.92,y:-.42}],.16),fill:e.body},n)),s.push({k:"line",pts:[u*.62,-.78,u*1,-.98],stroke:e.accent,lw:.08});break;case"antennae":{let f={x:u*.62,y:-1.42};s.push({k:"path",d:"M".concat(u*.3," -0.8 Q").concat(u*.36," -1.2 ").concat(f.x," ").concat(f.y),stroke:e.outline,lw:t*2.6}),s.push({k:"path",d:"M".concat(u*.3," -0.8 Q").concat(u*.36," -1.2 ").concat(f.x," ").concat(f.y),stroke:e.body,lw:t*1.2}),s.push(M({k:"circle",x:f.x,y:f.y,r:.17,fill:e.accent},n));break}case"floppy":s.push(M({k:"ellipse",x:u*.96,y:.02,rx:.3,ry:.62,rot:-u*.36,fill:(a=e.ears)!=null?a:e.body},n));break;case"droopy":s.push(M({k:"ellipse",x:u*1.04,y:-.22,rx:.4,ry:.18,rot:u*.32,fill:(i=e.skin)!=null?i:e.body},n)),s.push({k:"ellipse",x:u*1.08,y:-.2,rx:.24,ry:.08,rot:u*.32,fill:e.accent});break;case"pixie":s.push(M({k:"path",d:ie(me(u*.86,-.22,u*1.36,-.5,u*1.02,.26),.28),fill:(l=e.skin)!=null?l:e.body},n)),s.push({k:"line",pts:[u*.98,-.12,u*1.16,-.3],stroke:e.accent,lw:t*.8,alpha:.5});break;case"human":s.push(M({k:"ellipse",x:u*.98,y:.06,rx:.17,ry:.23,fill:(c=e.skin)!=null?c:e.body},n));break;case"horns":{let f=[{x:u*.3,y:-.84},{x:u*.6,y:-1.5},{x:u*.66,y:-.68}];s.push(M({k:"path",d:ie(f,.18),fill:e.accent},n));break}}return r.ears==="fin"&&s.push(M({k:"path",d:ie(me(-.4,-.82,.2,-1.62,.46,-.78),.2),fill:e.body},n)),r.ears==="antenna"&&(s.push({k:"line",pts:[0,-.85,0,-1.42],stroke:e.outline,lw:t*2.6}),s.push({k:"line",pts:[0,-.85,0,-1.42],stroke:e.limbs,lw:t*1.2}),s.push(M({k:"circle",x:0,y:-1.5,r:.18,fill:e.accent},n))),s}function Gi(r,t){var c,u,f,h,b,y,x;let e=r.palette,n=r.face,s=[],o=e.outline,a=n.eyesOnTop?.46:.4,i=n.eyesOnTop?-.72:-.04,l=(d,m,g)=>({k:"circle",x:d,y:m,r:g,fill:xe});switch(n.eyes){case"dot":for(let d of go(r,a,i))s.push({k:"ellipse",x:d.x,y:d.y,rx:.12*d.k,ry:.155*d.k,fill:o}),s.push(l(d.x+.04*d.k,d.y-.06*d.k,.045*d.k));break;case"bead":for(let d of go(r,a,i))s.push({k:"ellipse",x:d.x,y:d.y,rx:.16*d.k,ry:.22*d.k,fill:o}),s.push(l(d.x+.05*d.k,d.y-.08*d.k,.065*d.k));break;case"big":for(let d of Z)n.eyeRing&&s.push({k:"circle",x:d*a,y:i,r:.36,fill:n.eyeRing,stroke:o,lw:t*.8}),s.push({k:"circle",x:d*a,y:i,r:.25,fill:xe,stroke:o,lw:t*.8}),s.push({k:"circle",x:d*a+d*-.03,y:i+.03,r:.14,fill:(c=n.eyeColor)!=null?c:o}),s.push(l(d*a+d*-.03+.05,i-.03,.05));break;case"mask":for(let d of Z)s.push({k:"ellipse",x:d*.4,y:0,rx:.24,ry:.32,rot:d*-.55,fill:e.limbs}),s.push({k:"circle",x:d*.4,y:-.02,r:.11,fill:xe}),s.push({k:"circle",x:d*.39,y:-0,r:.065,fill:o});break;case"screen":s.push({k:"rect",x:0,y:0,w:1.5,h:.66,r:.26,fill:"#24323d",stroke:o,lw:t*.8});for(let d of Z)s.push({k:"ellipse",x:d*.36,y:0,rx:.2,ry:.24,fill:(u=n.eyeColor)!=null?u:"#7ff0ff",alpha:.3}),s.push({k:"ellipse",x:d*.36,y:0,rx:.12,ry:.16,fill:(f=n.eyeColor)!=null?f:"#7ff0ff"});break;case"almond":for(let d of Z)s.push({k:"ellipse",x:d*.42,y:-.02,rx:.3,ry:.2,rot:-d*.5,fill:(h=n.eyeColor)!=null?h:o}),s.push(l(d*.42-d*.07,-.08,.07));break;case"calm":for(let d of Z)s.push({k:"ellipse",x:d*.38,y:.02,rx:.085,ry:.12,fill:o}),s.push(l(d*.38+.03,-.02,.03));break;case"slit":s.push({k:"line",pts:[0,-.98,0,-.2],stroke:o,lw:t*.8,alpha:.5}),s.push({k:"rect",x:0,y:-.04,w:1.56,h:.26,r:.1,fill:qr,stroke:o,lw:t*.8}),s.push({k:"rect",x:0,y:.3,w:.22,h:.46,r:.08,fill:qr,stroke:o,lw:t*.8});for(let d of Z){s.push({k:"ellipse",x:d*.4,y:-.04,rx:.12,ry:.07,fill:(b=n.eyeColor)!=null?b:xe});for(let m of[.36,.56])s.push({k:"circle",x:d*.42,y:m,r:.05,fill:o,alpha:.6})}break;case"goggle":for(let d of Z)s.push({k:"circle",x:d*.9,y:0,r:.13,fill:e.accent,stroke:o,lw:t*.8});s.push({k:"rect",x:0,y:0,w:1.66,h:.62,r:.3,fill:qr,stroke:o,lw:t*.8}),s.push({k:"path",d:"M-0.6 -0.16 Q-0.42 -0.24 -0.12 -0.24",stroke:xe,lw:.07,alpha:.8});for(let d of Z)s.push({k:"path",d:"M".concat(d*.5," 0.04 Q").concat(d*.34," -0.08 ").concat(d*.16," 0.02"),stroke:(y=n.eyeColor)!=null?y:"#7fd6ff",lw:.08});for(let d of[-.18,0,.18])s.push({k:"line",pts:[d,.56,d,.72],stroke:o,lw:t*.8,alpha:.6});break;case"visor":s.push({k:"ellipse",x:0,y:.08,rx:.8,ry:.64,fill:"#2a3f6b",stroke:o,lw:t*.8}),s.push({k:"path",d:"M-0.56 -0.14 Q-0.46 -0.4 -0.16 -0.46",stroke:xe,lw:.08,alpha:.7});for(let d of Z)s.push({k:"ellipse",x:d*.28,y:.04,rx:.1,ry:.14,fill:(x=n.eyeColor)!=null?x:"#cfeeff"});break}return s}function Ui(r,t){let e=r.palette,n=r.face,s=[],o=n.eyes==="visor"?"#cfeeff":yo,a=t*1.05;switch(n.nose&&n.mouth!=="beak"&&(n.mouth==="cat"?s.push({k:"path",d:ie([{x:-.1,y:.22},{x:.1,y:.22},{x:0,y:.33}],.3),fill:n.nose,stroke:n.nose,lw:t*.6}):r.ears==="big-round"?s.push({k:"ellipse",x:0,y:.22,rx:.2,ry:.25,fill:n.nose}):s.push({k:"ellipse",x:0,y:.25,rx:.13,ry:.085,fill:n.nose})),n.mouth){case"smile":s.push({k:"path",d:n.eyes==="visor"?"M-0.16 0.32 Q0 0.46 0.16 0.32":"M-0.17 0.42 Q0 0.58 0.17 0.42",stroke:o,lw:a});break;case"open":s.push({k:"path",d:"M-0.21 0.4 Q0 0.46 0.21 0.4 Q0.19 0.68 0 0.68 Q-0.19 0.68 -0.21 0.4 Z",fill:o,stroke:o,lw:t*.5}),s.push({k:"ellipse",x:0,y:.6,rx:.1,ry:.06,fill:xo});break;case"cat":s.push({k:"path",d:"M-0.19 0.4 Q-0.1 0.5 0 0.37 Q0.1 0.5 0.19 0.4",stroke:o,lw:a});break;case"beak":s.push({k:"path",d:ie([{x:-.17,y:.2},{x:.17,y:.2},{x:0,y:.48}],.25),fill:e.accent,stroke:e.outline,lw:t*.8});break;case"teeth":s.push({k:"path",d:"M-0.36 0.34 Q0 0.44 0.36 0.34 Q0.28 0.66 0 0.66 Q-0.28 0.66 -0.36 0.34 Z",fill:o,stroke:o,lw:t*.5});for(let i of Z)s.push({k:"rect",x:i*.12,y:.43,w:.1,h:.1,r:.03,fill:xe});break;case"grill":s.push({k:"rect",x:0,y:.56,w:.62,h:.2,r:.08,fill:"#24323d",stroke:e.outline,lw:t*.7});for(let i of[-.15,0,.15])s.push({k:"line",pts:[i,.51,i,.61],stroke:"#9fb0bd",lw:t*.6});break;case"tiny":s.push({k:"ellipse",x:0,y:.44,rx:.08,ry:.1,fill:o});break;case"smirk":s.push({k:"path",d:"M-0.16 0.46 Q0.06 0.54 0.22 0.38",stroke:o,lw:a});break;case"bill":s.push({k:"ellipse",x:0,y:.36,rx:.44,ry:.2,fill:e.accent,stroke:e.outline,lw:t*.8}),s.push({k:"path",d:"M-0.36 0.38 Q0 0.46 0.36 0.38",stroke:e.outline,lw:t*.7});for(let i of Z)s.push({k:"circle",x:i*.1,y:.28,r:.03,fill:e.outline});break;case"hook":s.push({k:"ellipse",x:0,y:.48,rx:.16,ry:.11,fill:yo}),s.push({k:"path",d:"M-0.3 0.12 Q0 -0.02 0.3 0.12 Q0.36 0.52 0.04 0.76 Q0.08 0.52 -0.08 0.46 Q-0.28 0.38 -0.3 0.12 Z",fill:e.accent,stroke:e.outline,lw:t*.8});break;case"toothy":{s.push({k:"path",d:"M-1.4 0.1 Q-0.5 0.36 0.5 0.2 Q0.64 0.16 0.68 0.02 Q0.78 0.28 0.52 0.38 Q-0.4 0.78 -1.3 0.26 Z",fill:o,stroke:o,lw:t*.6}),s.push({k:"ellipse",x:-.38,y:.5,rx:.24,ry:.08,fill:xo});for(let i of[.12,.27,.42,.57,.72,.86]){let l=(1-i)*(1-i)*-1.4+2*(1-i)*i*-.5+i*i*.5,c=(1-i)*(1-i)*.1+2*(1-i)*i*.36+i*i*.2-.01;s.push({k:"path",d:ie(me(l-.08,c,l+.08,c,l,c+.14),.3),fill:xe})}for(let i of[.3,.7]){let l=(1-i)*(1-i)*.52+2*(1-i)*i*-.4+i*i*-1.3,c=(1-i)*(1-i)*.38+2*(1-i)*i*.78+i*i*.26+.01;s.push({k:"path",d:ie(me(l-.07,c,l+.07,c,l,c-.12),.3),fill:xe})}break}case"jaws":{s.push({k:"path",d:"M-0.5 0.3 Q0 0.5 0.5 0.3 Q0.38 0.72 0 0.72 Q-0.38 0.72 -0.5 0.3 Z",fill:o,stroke:o,lw:t*.5});for(let i of[-.34,-.17,0,.17,.34]){let l=.3+.4*(i+.5)*(.5-i)-.01;s.push({k:"path",d:ie(me(i-.075,l,i+.075,l,i,l+.13),.15),fill:xe})}break}}return s}var Bt=(r,t)=>({x:Math.sin(r)*t,y:-Math.cos(r)*t});var So=.5,tt={leftEye:2,rightEye:5,leftEar:7,rightEar:8},ut={"3-5":{head:.75,neck:.74,arm:.3,leg:.36,hand:.19,foot:1.2,shoulderMin:.4,shoulderPad:.07,hipMin:.5,hipPad:.22,bottom:.26,bulge:1.12,armsOverHead:!0},"6-8":{head:.6,neck:.78,arm:.22,leg:.28,hand:.15,foot:1,shoulderMin:.34,shoulderPad:.04,hipMin:.4,hipPad:.16,bottom:.14,bulge:1.04,armsOverHead:!1},"9-12":{head:.5,neck:.92,arm:.17,leg:.21,hand:.125,foot:.9,shoulderMin:.36,shoulderPad:.07,hipMin:.32,hipPad:.08,bottom:.1,bulge:1,armsOverHead:!1}},dr="6-8",br=(r,t)=>{var e;return t!==void 0&&r.band!=="all"&&((e=r.alsoIn)!=null&&e.includes(t))&&t in ut?t:r.band in ut?r.band:dr},Vi=ut[dr].head,Mo=.3,To=.12,Wi=.9,ko=.5,wo=.65,Xi=.35,ji=.2,qi=.25,Qe=(r,t)=>({x:r.x-t.x,y:r.y-t.y}),pe=(r,t)=>({x:r.x+t.x,y:r.y+t.y}),le=(r,t)=>({x:r.x*t,y:r.y*t}),zt=r=>Math.hypot(r.x,r.y),vo=(r,t)=>({x:(r.x+t.x)/2,y:(r.y+t.y)/2}),mr=r=>{let t=zt(r);return t>1e-9?{x:r.x/t,y:r.y/t}:{x:0,y:1}},Yi=(...r)=>r.every(Number.isFinite),Ki=r=>Math.atan2(Math.sin(r),Math.cos(r)),Qi=(r,t,e)=>Math.min(Math.max(r,t),e);function Eo(r,t,e=!1){return n=>{let s=r[n*3],o=r[n*3+1],a=r[n*3+2];return s===void 0||o===void 0||a===void 0||!Yi(s,o,a)?{x:0,y:0,ok:!1}:{x:t.x+(e?1-s:s)*t.w,y:t.y+o*t.h,ok:a>=So}}}function sn(r,t,e={}){var F,I;let n=Eo(r,t,e.mirrored),s=n(q.leftShoulder),o=n(q.rightShoulder);if(!s.ok||!o.ok)return null;let a=n(q.leftHip),i=n(q.rightHip),l=vo(s,o),c=zt(Qe(o,s)),u=a.ok&&i.ok,f=mr(Qe(o,s));c<1e-6&&(f={x:1,y:0});let h,b,y;if(u){let A=vo(a,i);b=zt(Qe(A,l)),b>=c*qi?h=mr(Qe(A,l)):(h={x:-f.y,y:f.x},h.y<0&&(h=le(h,-1))),y=Math.max(b,c*1.15)}else h={x:-f.y,y:f.x},h.y<0&&(h=le(h,-1)),y=c*1.15,b=y;y=Math.max(y,1e-6);let x={x:h.y,y:-h.x},d=Math.atan2(x.y,x.x),m=le(h,-1),g=(I=ut[(F=e.band)!=null?F:dr])!=null?I:ut[dr],v=g.head*y,k=pe(l,le(m,v*g.neck)),R=n(q.nose);if(R.ok){let A=pe(R,le(m,v*.15)),S=le(Qe(A,k),Xi),P=Math.min(1,v*ji/Math.max(zt(S),1e-6));k=pe(k,le(S,P))}return{S:l,r:x,d:h,U:y,L:b,hipsOk:u,head:k,headR:v,headRot:d+Zi(r,n,d,y),angle:d}}function Zi(r,t,e,n){let s=[[tt.leftEar,tt.rightEar],[tt.leftEye,tt.rightEye]];for(let[o,a]of s){let i=t(o),l=t(a);if(!i.ok||!l.ok||!(r[o*3+2]>=wo&&r[a*3+2]>=wo)||zt(Qe(l,i))<n*.05)continue;let c=Ki(Math.atan2(l.y-i.y,l.x-i.x)-e),u=Math.max(Math.abs(c)-To,0),f=Qi((Wi+ko-Math.abs(c))/ko,0,1);return Math.sign(c)*Math.min(u,Mo)*f}return 0}function Hn(r,t,e,n={}){var he,Ct,Cn,Fn,Pn,Ft,xt,qt,_n,Ln,On,Pt,In,Yt,Kt,Qt,rr,sr,_t,gt,or,ar,Zt;let s=br(t,n.band),o=ut[s],a=sn(r,e,Ie(M({},n),{band:s}));if(!a)return[];let i=Eo(r,e,n.mirrored),l=t.palette,{S:c,r:u,d:f,U:h,L:b}=a,y=C=>t.bodyExtras.includes(C),x=Math.max(1.2,h*.045),d={stroke:l.outline,lw:x},m=(C,N)=>({x:c.x+u.x*C+f.x*N,y:c.y+u.y*C+f.y*N}),g=C=>C.map(([N,V])=>m(N,V)),v=i(q.leftShoulder),k=i(q.rightShoulder),R=i(q.leftHip),F=i(q.rightHip),I=zt(Qe(k,v)),A=a.hipsOk?zt(Qe(F,R)):I*.7,S=Math.max(I/2+o.shoulderPad*h,o.shoulderMin*h),P=Math.max(A/2+o.hipPad*h,o.hipMin*h),H=-.1*h,z=b+o.bottom*h,B=[],G=[],L=[],U=[],Y=[],Q=(C,N,V,J)=>{let K=N.flatMap(be=>[be.x,be.y]);C.push({k:"line",pts:K,stroke:l.outline,lw:V+x*2}),C.push({k:"line",pts:K,stroke:J,lw:V})},Ee=o.leg*h*(y("strong-legs")?1.3:1),ue=o.arm*h*(y("tiny-arms")?.6:1),ke=Math.max(o.arm/.22,.9);if(a.hipsOk)for(let[C,N,V,J]of[[R,q.leftKnee,q.leftAnkle,-1],[F,q.rightKnee,q.rightAnkle,1]]){let K=i(N),be=i(V);if(!K.ok)continue;let je=pe(C,le(f,-.12*h)),Oe=be.ok?[je,K,be]:[je,K];Q(G,Oe,Ee,l.limbs),y("joints")&&G.push(M({k:"circle",x:K.x,y:K.y,r:.15*h*ke,fill:l.accent},d)),be.ok&&G.push(...tl(t,be,a,J,x,o.foot))}for(let[C,N,V,J]of[[v,q.leftElbow,q.leftWrist,-1],[k,q.rightElbow,q.rightWrist,1]]){let K=i(N),be=i(V);if(y("pauldrons")){let Ue=pe(C,le(f,.02*h));U.push(M({k:"ellipse",x:Ue.x,y:Ue.y,rx:.25*h,ry:.17*h,rot:a.angle+J*.25,fill:l.body},d));let qe=pe(Ue,le(f,.05*h));U.push({k:"ellipse",x:qe.x,y:qe.y,rx:.17*h,ry:.07*h,rot:a.angle+J*.25,fill:l.belly})}if(!K.ok)continue;let Oe=o.armsOverHead&&(K.x-c.x)*f.x+(K.y-c.y)*f.y<-.25*h?Y:U,Jt=pe(C,le(f,.04*h));if(Q(Oe,be.ok?[Jt,K,be]:[Jt,K],ue,l.limbs),y("joints")&&Oe.push(M({k:"circle",x:K.x,y:K.y,r:.13*h*ke,fill:l.accent},d)),!be.ok)continue;let Ce=mr(Qe(be,K)),Ge=pe(be,le(Ce,.05*h));if(y("feathers"))for(let Ue of[-.55,0,.55]){let qe=Math.cos(Ue),Lt=Math.sin(Ue)*J,Ye={x:Ce.x*qe-Ce.y*Lt,y:Ce.x*Lt+Ce.y*qe},Ot=pe(Ge,le(Ye,.16*h));Oe.push(M({k:"ellipse",x:Ot.x,y:Ot.y,rx:.2*h,ry:.09*h,rot:Math.atan2(Ye.y,Ye.x),fill:(he=l.hands)!=null?he:l.accent},d))}y("wand")&&J===1&&!n.portrait&&Oe.push(...sl(t,Ge,mr(pe(le(Ce,.4),Qe(le(u,.6),f))),h,x));let et=o.hand*h*(y("tiny-arms")?.72:1);if(y("tiny-arms"))for(let Ue of[-.45,.45]){let qe=Math.cos(Ue),Lt=Math.sin(Ue),Ye={x:Ce.x*qe-Ce.y*Lt,y:Ce.x*Lt+Ce.y*qe},Ot=pe(Ge,le(Ye,et*.75)),ir=pe(Ge,le(Ye,et*1.6)),Nn={x:-Ye.y*et*.32,y:Ye.x*et*.32};Oe.push(M({k:"path",d:ie([pe(Ot,Nn),ir,Qe(Ot,Nn)],.2),fill:l.belly},d))}Oe.push(M({k:"circle",x:Ge.x,y:Ge.y,r:et,fill:(Ct=l.hands)!=null?Ct:l.limbs},d))}if(y("wings"))for(let C of[-1,1]){let N=g([[C*S*.5,.05*h],[C*(S+.85*h),-.6*h],[C*(S+.72*h),.05*h],[C*(S+.45*h),-.02*h],[C*(S+.3*h),.32*h],[C*S*.6,.55*h]]);B.push(M({k:"path",d:ie(N,.18),fill:l.accent},d))}if(y("wings-fairy")&&B.push(...ol(t,m,S,h,x)),y("cape")){let C=b+.8*h,N=P+.36*h,V=g([[-S*.92,H+.04*h],[S*.92,H+.04*h],[S+.16*h,b*.5],[N,C],[N*.5,C-.1*h],[0,C],[-N*.5,C-.1*h],[-N,C],[-S-.16*h,b*.5]]);B.push(M({k:"path",d:ae(V,.6),fill:l.accent},d))}if(y("backpack")){let C=m(0,.35*h);B.push(M({k:"rect",x:C.x,y:C.y,w:S*2+.34*h,h:.8*h,r:.16*h,rot:a.angle,fill:(Fn=(Cn=t.extraColors)==null?void 0:Cn[0])!=null?Fn:l.limbs},d))}if(y("tank")){let C=m(S*.95,.24*h),N=(Ft=(Pn=t.extraColors)==null?void 0:Pn[0])!=null?Ft:l.accent,V=m(S*.95,-.3*h);B.push({k:"rect",x:V.x,y:V.y,w:.14*h,h:.16*h,r:.04*h,rot:a.angle,fill:l.outline}),B.push(M({k:"rect",x:C.x,y:C.y,w:.34*h,h:1*h,r:.17*h,rot:a.angle,fill:N},d))}if(a.hipsOk&&!n.portrait&&B.push(...rl(t,a,P,x)),y("tentacles")&&a.hipsOk)for(let C of[-1,1]){let N=g([[C*P*.7,b*.9],[C*(P+.22*h),b+.3*h],[C*(P+.48*h),b+.22*h],[C*(P+.5*h),b-.02*h],[C*(P+.34*h),b-.06*h]]);B.push({k:"path",d:rn(N),stroke:l.outline,lw:.2*h+x*2}),B.push({k:"path",d:rn(N),stroke:l.limbs,lw:.2*h})}let we=Math.max(S,P)*o.bulge;if(y("wool")){for(let[N,V]of[[S*.7,H+.02*h],[we,b*.3],[we*1.02,b*.62],[(we+P)/2,b*.92],[P*.55,z]])for(let J of[-1,1]){let K=m(J*N,V);L.push(M({k:"circle",x:K.x,y:K.y,r:.2*h,fill:l.body},d))}let C=m(0,z+.02*h);L.push(M({k:"circle",x:C.x,y:C.y,r:.2*h,fill:l.body},d))}if(y("robe")){let C=b+.58*h,N=P*1.4;L.push(M({k:"path",d:ae(g([[-S,H],[0,H-.04*h],[S,H],[we,b*.55],[N,C],[0,C+.06*h],[-N,C],[-we,b*.55]]),.7),fill:l.body},d));let V=g([[-N*.94,C-.1*h],[0,C-.04*h],[N*.94,C-.1*h]]);L.push({k:"path",d:rn(V),stroke:(qt=(xt=t.extraColors)==null?void 0:xt[0])!=null?qt:l.accent,lw:.07*h})}else if(y("sheet")){let C=b+.78*h,N=P*1.3;L.push(M({k:"path",d:ae(g([[-S,H],[S,H],[we,b*.55],[N,C],[N*.5,C-.2*h],[0,C],[-N*.5,C-.2*h],[-N,C],[-we,b*.55]]),.9),fill:l.body},d))}else L.push(M({k:"path",d:ae(g([[-S,H],[0,H-.04*h],[S,H],[we,b*.55],[P,z],[0,z+.03*h],[-P,z],[-we,b*.55]]),.85),fill:l.body},d));let oe=Math.min(S,P);if(y("pocket")){let C=m(0,b*.74);L.push({k:"rect",x:C.x,y:C.y,w:oe*1.3,h:.3*h,r:.1*h,rot:a.angle,fill:l.belly,stroke:l.outline,lw:x*.8})}else if(y("racing-stripe"))for(let C of[-.1,.1]){let N=m(C*h,H+.02*h),V=m(C*h,z-.04*h);L.push({k:"line",pts:[N.x,N.y,V.x,V.y],stroke:l.belly,lw:.1*h})}else if(l.belly&&l.belly!==l.body&&!y("panel")&&!y("sheet")&&!y("stripes")){let C=m(0,b*.58);L.push({k:"ellipse",x:C.x,y:C.y,rx:oe*.64,ry:Math.max(b*.36,.2*h),rot:a.angle,fill:l.belly})}if(y("spots")){let C=(Ln=(_n=t.extraColors)==null?void 0:_n[1])!=null?Ln:l.belly;for(let[N,V,J]of[[-.55,.35,.09],[.5,.62,.11],[-.35,.86,.07]]){let K=m(N*oe,V*b);L.push({k:"circle",x:K.x,y:K.y,r:J*h,fill:C})}}if(y("stripes")){let C=(Pt=(On=t.extraColors)==null?void 0:On[1])!=null?Pt:l.accent;for(let N of[.22,.44,.66]){let V=m(-oe*.98,b*N),J=m(oe*.98,b*N);L.push({k:"line",pts:[V.x,V.y,J.x,J.y],stroke:C,lw:.1*h})}}if(y("straps")){let C=(Yt=(In=t.extraColors)==null?void 0:In[1])!=null?Yt:l.outline;for(let N of[-1,1]){let V=m(N*S*.62,H+.02*h),J=m(N*oe*.62,b*.72);L.push({k:"line",pts:[V.x,V.y,J.x,J.y],stroke:l.outline,lw:.13*h+x*2}),L.push({k:"line",pts:[V.x,V.y,J.x,J.y],stroke:C,lw:.13*h})}}if(y("belt")){let C=m(0,b*.9);L.push(M({k:"rect",x:C.x,y:C.y,w:P*1.92,h:.17*h,r:.06*h,rot:a.angle,fill:(Qt=(Kt=t.extraColors)==null?void 0:Kt[2])!=null?Qt:"#4a3426"},d)),L.push(M({k:"rect",x:C.x,y:C.y,w:.2*h,h:.19*h,r:.04*h,rot:a.angle,fill:"#ffd84a"},d))}if(y("emblem")){let C=m(0,b*.4),N=(sr=(rr=t.extraColors)==null?void 0:rr[0])!=null?sr:l.accent,V=ie([{x:-.22,y:-.2},{x:.22,y:-.2},{x:.22,y:.04},{x:0,y:.26},{x:-.22,y:.04}],.25);L.push({k:"group",x:C.x,y:C.y,rot:a.angle,s:h,items:[{k:"path",d:V,fill:N,stroke:l.outline,lw:x/h},{k:"group",x:0,y:.01,s:.12,items:[{k:"path",d:ct,fill:N===l.accent?"#ffffff":l.accent}]}]})}if(y("panel")){let C=m(0,b*.5);L.push(M({k:"rect",x:C.x,y:C.y,w:oe*1.2,h:.38*h,r:.1*h,rot:a.angle,fill:"#24323d"},d)),((_t=t.extraColors)!=null?_t:["#ff7a6b","#fbd46a","#7ff0ff"]).slice(0,3).forEach((V,J)=>{let K=m((J-1)*oe*.34,b*.5);L.push({k:"circle",x:K.x,y:K.y,r:.075*h,fill:V})})}if(y("badge")){let C=m(-oe*.42,b*.36);L.push(M({k:"circle",x:C.x,y:C.y,r:.15*h,fill:l.accent},d)),L.push({k:"group",x:C.x,y:C.y,rot:a.angle,s:.09*h,items:[{k:"path",d:ct,fill:"#ffffff"}]})}if(y("star")){let C=m(-oe*.5,b*.3),N=.15*h;L.push({k:"group",x:C.x,y:C.y,rot:a.angle-.2,s:N,items:[{k:"path",d:ct,fill:(or=(gt=t.extraColors)==null?void 0:gt[0])!=null?or:"#ffd84a",stroke:l.outline,lw:x*.8/N}]})}if(y("petals")&&L.push(...al(t,m,S,P,we,b,z,h,x,o)),y("scarf")){let C=Math.max(.04,o.head*(1-o.neck)-.06)*h,N=m(0,C),V=(Zt=(ar=t.extraColors)==null?void 0:ar[0])!=null?Zt:l.accent,J=m(S*.45,C+.28*h);L.push(M({k:"rect",x:J.x,y:J.y,w:.16*h,h:.42*h,r:.06*h,rot:a.angle+.15,fill:V},d)),L.push(M({k:"rect",x:N.x,y:N.y,w:S*2.05,h:.2*h,r:.1*h,rot:a.angle,fill:V},d))}let Re={k:"group",x:a.head.x,y:a.head.y,rot:a.headRot,s:a.headR,items:el(t,x/a.headR)};return[...B,...G,...L,...U,Re,...Y]}var Ao=new WeakMap,Ji=64;function el(r,t){let e=Number(t.toPrecision(4)),n=Ao.get(r);n||Ao.set(r,n=new Map);let s=n.get(e);return s||(n.size>=Ji&&n.clear(),n.set(e,s=pr(r,e))),s}function tl(r,t,e,n,s,o){let a=nl(r,t,e,n,s,o);if(!r.bodyExtras.includes("strong-legs"))return[a];let i=e.U*o,l=pe(pe(t,le(e.d,.07*i)),le(e.r,n*.06*i)),c=[a];for(let u of[-1,0,1]){let f=pe(pe(l,le(e.r,u*.12*i)),le(e.d,.09*i));c.push({k:"ellipse",x:f.x,y:f.y,rx:.05*i,ry:.045*i,rot:e.angle,fill:r.palette.belly,stroke:r.palette.outline,lw:s*.8})}return c}function nl(r,t,e,n,s,o){var b;let a=r.palette,{d:i,r:l}=e,c=e.U*o,u=pe(pe(t,le(i,.07*c)),le(l,n*.06*c)),f={stroke:a.outline,lw:s},h=(b=a.feet)!=null?b:a.limbs;if(r.bodyExtras.includes("fins")){let y=ie([{x:-.13,y:-.06},{x:.13,y:-.06},{x:.24,y:.46},{x:-.24,y:.46}],.22);return{k:"group",x:u.x,y:u.y,rot:e.angle,s:c,items:[{k:"path",d:y,fill:h,stroke:a.outline,lw:s/c},{k:"line",pts:[0,.06,0,.38],stroke:a.outline,lw:s/c,alpha:.5}]}}return r.bodyExtras.includes("flippers")?M({k:"ellipse",x:u.x,y:u.y,rx:.27*c,ry:.11*c,rot:e.angle,fill:h},f):r.bodyExtras.includes("boots")?M({k:"rect",x:u.x,y:u.y,w:.4*c,h:.24*c,r:.09*c,rot:e.angle,fill:h},f):M({k:"ellipse",x:u.x,y:u.y,rx:.2*c,ry:.13*c,rot:e.angle,fill:h},f)}function rl(r,t,e,n){var x,d,m,g,v,k,R,F,I;let s=r.palette,{U:o,L:a,S:i,r:l,d:c}=t,u=(A,S)=>({x:i.x+l.x*A+c.x*S,y:i.y+l.y*A+c.y*S}),f=A=>A.map(([S,P])=>u(S,P)),h={stroke:s.outline,lw:n},b=(A,S,P)=>[{k:"path",d:rn(A),stroke:s.outline,lw:S+n*2},{k:"path",d:rn(A),stroke:P,lw:S}],y=[];switch(r.tail){case"none":break;case"fluffy":{let A=f([[e*.5,a*.95],[e+.28*o,a*1],[e+.72*o,a*.62],[e+.78*o,a*.12],[e+.52*o,a*.32],[e+.3*o,a*.6],[e*.6,a*.7]]);y.push(M({k:"path",d:ae(A),fill:s.body},h));let S=u(e+.72*o,a*.2);y.push(M({k:"ellipse",x:S.x,y:S.y,rx:.13*o,ry:.2*o,rot:t.angle+.25,fill:s.belly},h));break}case"brush":{let A=f([[e*.4,a*.98],[e+.42*o,a*1.06],[e+.98*o,a*.66],[e+1.06*o,a*.12],[e+.86*o,-.04*o],[e+.66*o,a*.36],[e+.3*o,a*.66],[e*.5,a*.68]]);y.push(M({k:"path",d:ae(A),fill:s.body},h));let S=f([[e+1.03*o,a*.36],[e+1.06*o,a*.12],[e+.86*o,-.04*o],[e+.72*o,a*.24],[e+.86*o,a*.34]]);y.push(M({k:"path",d:ae(S),fill:s.belly},h));break}case"pom":{let A=u(e+.06*o,a*.88);y.push(M({k:"circle",x:A.x,y:A.y,r:.2*o,fill:s.belly},h));break}case"long":case"striped":case"tuft":{let A=f([[e*.6,a*.9],[e+.35*o,a*.85],[e+.58*o,a*.4],[e+.5*o,-.02*o]]);if(y.push(...b(A,.14*o,s.body)),r.tail==="tuft"){let S=A[A.length-1];y.push(M({k:"circle",x:S.x,y:S.y,r:.16*o,fill:(d=(x=r.extraColors)==null?void 0:x[0])!=null?d:s.accent},h))}if(r.tail==="striped"){for(let P of[.35,.6,.85]){let H=u(e+.35*o+.22999999999999998*o*(P*1.4>1?1:P*1.4),a*(.85-.85*P));y.push({k:"line",pts:[H.x-l.x*.08*o,H.y-l.y*.08*o,H.x+l.x*.08*o,H.y+l.y*.08*o],stroke:(g=(m=r.extraColors)==null?void 0:m[0])!=null?g:s.outline,lw:.06*o})}let S=A[A.length-1];y.push({k:"circle",x:S.x,y:S.y,r:.07*o,fill:(k=(v=r.extraColors)==null?void 0:v[0])!=null?k:s.outline})}break}case"curl":{let A=f([[e*.6,a*.9],[e+.4*o,a*.88],[e+.62*o,a*.45],[e+.5*o,a*.12],[e+.3*o,a*.24],[e+.36*o,a*.42]]);y.push(...b(A,.12*o,s.limbs));break}case"fish":{let A=f([[e*.6,a*.9],[e+.36*o,a*.86],[e+.6*o,a*.5]]);y.push(...b(A,.17*o,s.body));let S=A[A.length-1],P=ie([{x:0,y:.06},{x:-.26,y:-.34},{x:.02,y:-.12},{x:.32,y:-.3}],.2);y.push({k:"group",x:S.x,y:S.y,rot:t.angle+.35,s:o,items:[{k:"path",d:P,fill:s.body,stroke:s.outline,lw:n/o}]});break}case"plume":{let A=(R=r.extraColors)!=null?R:[s.accent];[0,1,2].forEach(S=>{let P=u(e+(.12+S*.13)*o,a+(.32-S*.06)*o);y.push(M({k:"ellipse",x:P.x,y:P.y,rx:.11*o,ry:.44*o,rot:t.angle-.55+S*.28,fill:A[(S+1)%A.length]},h))});break}case"thick":{let A=f([[e*.3,a*.42],[e+.42*o,a*.62],[e+.92*o,a*.96],[e+1.32*o,a*1.08],[e+1.44*o,a*.98],[e+.98*o,a*1.2],[e+.4*o,a*1.22],[e*.3,a*1.12]]);y.push(M({k:"path",d:ae(A,.8),fill:s.body},h));let S=(I=(F=r.extraColors)==null?void 0:F[0])!=null?I:s.accent;for(let[P,H,z]of[[.28,.58,.26],[.62,.8,.22],[.96,1,.16]]){let B=u(e+P*o,a*H+.03*o),G=u(e+(P-.1)*o,a*H+z*o);y.push({k:"line",pts:[B.x,B.y,G.x,G.y],stroke:S,lw:.09*o})}break}case"spiky":case"arrow":{let A=f([[e*.3,a*.55],[e+.35*o,a*.68],[e+.95*o,a*.86],[e+.35*o,a*1.08],[e*.3,a*1.08]]);if(r.tail==="spiky"){for(let S of[.15,.45,.72]){let P=e+(.2+S*.7)*o,H=a*(.66+S*.19);y.push(M({k:"path",d:ie(f([[P-.12*o,H+.05*o],[P,H-.2*o],[P+.12*o,H+.07*o]]),.2),fill:s.accent},h))}y.push(M({k:"path",d:ae(A,.7),fill:s.body},h))}else{let S=f([[e*.6,a*.9],[e+.4*o,a*.92],[e+.62*o,a*.5],[e+.62*o,a*.18]]);y.push(...b(S,.13*o,s.body));let P=S[S.length-1];y.push({k:"group",x:P.x,y:P.y,rot:t.angle,s:o,items:[{k:"path",d:ie([{x:-.15,y:.04},{x:0,y:-.22},{x:.15,y:.04}],.2),fill:s.accent,stroke:s.outline,lw:n/o}]})}break}}return y}function sl(r,t,e,n,s){let o=r.palette,a=pe(t,le(e,-.08*n)),i=pe(t,le(e,.52*n)),l=.2*n;return[{k:"line",pts:[a.x,a.y,i.x,i.y],stroke:o.outline,lw:.06*n+s*2},{k:"line",pts:[a.x,a.y,i.x,i.y],stroke:"#fff3d6",lw:.06*n},{k:"circle",x:i.x,y:i.y,r:.24*n,fill:o.accent,alpha:.28},{k:"group",x:i.x,y:i.y,rot:Math.atan2(e.y,e.x)+Math.PI/2,s:l,items:[{k:"path",d:ct,fill:o.accent,stroke:o.outline,lw:s*.9/l}]}]}function ol(r,t,e,n,s){var l,c;let o=r.palette,a=(c=(l=r.extraColors)==null?void 0:l[0])!=null?c:"#cdeeff",i=[];for(let u of[-1,1]){let f=[[[u*e*.3,.12*n],[u*(e+.42*n),-.66*n],[u*(e+1*n),-.74*n],[u*(e+1.02*n),-.18*n],[u*(e+.5*n),.26*n]],[[u*e*.4,.3*n],[u*(e+.6*n),.36*n],[u*(e+.74*n),.78*n],[u*(e+.3*n),.9*n]]];for(let h of f){let b=ae(h.map(([m,g])=>t(m,g)),.9);i.push({k:"path",d:b,fill:a,alpha:.6}),i.push({k:"path",d:b,stroke:o.outline,lw:s*.9});let y=h[Math.floor(h.length/2)],x=t(h[0][0],h[0][1]),d=t(h[0][0]+(y[0]-h[0][0])*.75,h[0][1]+(y[1]-h[0][1])*.75);i.push({k:"line",pts:[x.x,x.y,d.x,d.y],stroke:"#ffffff",lw:s*.9,alpha:.85})}for(let[h,b,y]of[[e+.72*n,-.42*n,.075*n],[e+.44*n,-.16*n,.05*n],[e+.5*n,.6*n,.055*n]]){let x=t(u*h,b);i.push({k:"group",x:x.x,y:x.y,s:y,items:[{k:"path",d:ct,fill:"#ffffff"}]})}}return i}function al(r,t,e,n,s,o,a,i,l,c){var v,k;let u=r.palette,f=(k=(v=r.extraColors)==null?void 0:v[1])!=null?k:u.belly,h=[],b=Math.atan2(t(1,0).y-t(0,0).y,t(1,0).x-t(0,0).x),y=5,x=Math.max(n,s*.92)*1.08,d=(o*.8+a)/2,m=[0,4,1,3,2];for(let R of m){let F=R/(y-1)-.5,I=t(F*2*x,d+(.5-Math.abs(F))*.1*i);h.push({k:"ellipse",x:I.x,y:I.y,rx:x*.3,ry:.34*i,rot:b-F*.6,fill:R%2?f:u.body,stroke:u.outline,lw:l})}let g=Math.max(.04,c.head*(1-c.neck)-.04)*i;for(let R of[-1,1,0]){let F=t(R*e*.32,g+(R?0:.05*i));h.push({k:"ellipse",x:F.x,y:F.y,rx:e*.26,ry:.12*i,rot:b+R*.5,fill:R?f:u.body,stroke:u.outline,lw:l*.9})}return h}var il={nose:[0,-.62],leftShoulder:[-.42,0],rightShoulder:[.42,0],leftElbow:[-.58,.5],rightElbow:[.58,.5],leftWrist:[-.66,.98],rightWrist:[.66,.98],leftHip:[-.27,1],rightHip:[.27,1],leftKnee:[-.31,1.6],rightKnee:[.31,1.6],leftAnkle:[-.33,2.18],rightAnkle:[.33,2.18]};function ll(r,{cx:t=.5,cy:e=.36,T:n=.18}={}){var c;let s=M(M({},il),r),o=new Array(Ur*3).fill(0),a=(u,[f,h],b=.99)=>{o[u*3]=t+f*n,o[u*3+1]=e+h*n,o[u*3+2]=b};for(let u of Object.keys(q))a(q[u],s[u]);let i=(c=s.tilt)!=null?c:0,l=(u,f)=>[s.nose[0]+u*Math.cos(i)-f*Math.sin(i),s.nose[1]+u*Math.sin(i)+f*Math.cos(i)];return a(tt.leftEye,l(-.1,-.08)),a(tt.rightEye,l(.1,-.08)),a(tt.leftEar,l(-.22,-.02)),a(tt.rightEar,l(.22,-.02)),o}var Ro=()=>ll({});var Yr=Object.freeze({lag:.5,extrapolate:.75,maxExtrapolateMs:50}),on=class{constructor(t={}){p(this,"tracks",new Map);p(this,"offset",NaN);p(this,"lastArrival",NaN);p(this,"interval",33);p(this,"lastT",NaN);p(this,"lostMs");p(this,"maxExtrapolateMs");p(this,"lag");p(this,"extrapolate");var e,n;this.lostMs=(e=t.lostMs)!=null?e:250,this.maxExtrapolateMs=(n=t.maxExtrapolateMs)!=null?n:25,this.lag=Fo(t.lag,1),this.extrapolate=Fo(t.extrapolate,.5)}get delayMs(){return this.interval*this.lag}push(t,e,n,s=Co()){Number.isFinite(e)||(e=s),this.clock(e,s);let o=this.tracks.get(t);if(!o||e-o.tb>this.lostMs||e<o.tb-this.lostMs||n.length!==o.b.length){this.tracks.set(t,{a:null,ta:e,b:n,tb:e,out:null,outAt:NaN});return}if(n===o.b||e<=o.tb){e===o.tb&&n!==o.b&&(o.b=n,o.out=null);return}o.a=o.b,o.ta=o.tb,o.b=n,o.tb=e,o.out=null}at(t,e=Co()){let n=this.tracks.get(t);if(!n)return null;if(!n.a)return n.b;if(n.out&&n.outAt===e)return n.out;let s=e-this.offset-this.interval*this.lag,o=n.tb-n.ta,a=Math.min(o*this.extrapolate,this.maxExtrapolateMs),i=Math.min(Math.max((s-n.ta)/o,0),1+a/o);return n.out=Po(n.a,n.b,i),n.outAt=e,n.out}forget(t){this.tracks.delete(t)}clear(){this.tracks.clear()}clock(t,e){let n=e-t;if(!Number.isFinite(this.offset)||n<this.offset||n>this.offset+1e3?this.offset=n:Number.isFinite(this.lastArrival)&&(this.offset+=Math.min(n-this.offset,(e-this.lastArrival)/1e3)),this.lastArrival=e,Number.isFinite(this.lastT)&&t>this.lastT){let s=t-this.lastT;s<this.interval*3+20&&(this.interval+=(Math.min(Math.max(s,8),100)-this.interval)*.1)}t<=this.lastT||(this.lastT=t)}},Co=()=>{var r,t;return(t=(r=$.performance)==null?void 0:r.now())!=null?t:Date.now()},Fo=(r,t)=>typeof r=="number"&&Number.isFinite(r)?Math.min(Math.max(r,0),1):t;function Po(r,t,e){let n=t.slice(),s=e<.5?r:t;for(let o=0;o+2<t.length;o+=3){let a=r[o],i=r[o+1],l=t[o],c=t[o+1];r[o+2]>=.5&&t[o+2]>=.5&&Math.abs(l-a)+Math.abs(c-i)<.15?(n[o]=a+(l-a)*e,n[o+1]=i+(c-i)*e,n[o+2]=r[o+2]+(t[o+2]-r[o+2])*Math.min(e,1)):(n[o]=s[o],n[o+1]=s[o+1],n[o+2]=s[o+2])}return n}var jc=Xr.map(r=>r.id);var yr=new Map(Xr.map(r=>[r.id,r])),Ht=yr.get("fox"),Lo=r=>typeof r=="string"&&yr.has(r),an=r=>yr.get(r);var ul=r=>{var t;return typeof r=="string"?(t=yr.get(r))!=null?t:Ht:r};function Oo(r,t,e){let n=ul(r),s=Ro(),o=br(n,e),a=sn(s,{x:0,y:0,w:1,h:1},{band:o}),i=Do(pr(n,.05)),l=-i.minY,c=Math.min(.27,.43/Math.max(l,1))*t,u=n.head==="snout-long"?(i.minX+i.maxX)/2*c:0,f=c/ut[o].head/a.U,h=.5*t+Math.min(0,(l-1.6)*.06*t),b={x:t/2-u-a.head.x*f,y:h-a.head.y*f,w:f,h:f};return Hn(s,n,b,{portrait:!0,band:o})}function Io(r,t,e=.5){if(!r||r.length!==t.length)return t.slice();let n=t.slice();for(let s=0;s+2<t.length;s+=3){let o=r[s+2],a=t[s+2],i=o>=.5,l=a>=.5;i&&a>=.3&&(n[s+2]=Math.max(a,.5));let c=Math.hypot(t[s]-r[s],t[s+1]-r[s+1]);if(i&&l&&c<.15){let u=e*Math.min(1,_o+(1-_o)*c/hl);n[s]=r[s]+(t[s]-r[s])*u,n[s+1]=r[s+1]+(t[s+1]-r[s+1])*u}else i&&!l&&n[s+2]>=.5&&(n[s]=r[s],n[s+1]=r[s+1])}return dl(r,t,n,e*fl),n}var No=.8,_o=.1,hl=.03,fl=.35,pl=11;function dl(r,t,e,n){let s=q.leftShoulder*3,o=q.rightShoulder*3,a=(f,h)=>f[h+2]>=.5;if(!a(r,s)||!a(r,o)||!a(t,s)||!a(t,o))return;let i=(f,h)=>(f[s+h]+f[o+h])/2,l=[i(r,0),i(r,1)],c=[i(t,0),i(t,1)],u=[i(e,0),i(e,1)];for(let f=0;f<pl&&f*3+2<t.length;f++){let h=f*3;if(!a(r,h)||!a(t,h))continue;let b=[r[h]-l[0],r[h+1]-l[1]],y=[t[h]-c[0],t[h+1]-c[1]];Math.hypot(y[0]-b[0],y[1]-b[1])>=.15||(e[h]=u[0]+b[0]+(y[0]-b[0])*n,e[h+1]=u[1]+b[1]+(y[1]-b[1])*n)}}function Do(r){var n,s,o,a;let t={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},e=(i,l)=>{t.minX=Math.min(t.minX,i),t.minY=Math.min(t.minY,l),t.maxX=Math.max(t.maxX,i),t.maxY=Math.max(t.maxY,l)};for(let i of r){let l="lw"in i&&i.stroke?((n=i.lw)!=null?n:1)/2:0;switch(i.k){case"circle":e(i.x-i.r-l,i.y-i.r-l),e(i.x+i.r+l,i.y+i.r+l);break;case"ellipse":case"rect":{let c=i.k==="ellipse"?i.rx:i.w/2,u=i.k==="ellipse"?i.ry:i.h/2,f=Math.max(c,u)+l;e(i.x-f,i.y-f),e(i.x+f,i.y+f);break}case"path":{let c=jr(i.d);for(let u=0;u+1<c.length;u+=2)e(c[u]-l,c[u+1]-l),e(c[u]+l,c[u+1]+l);break}case"line":for(let c=0;c+1<i.pts.length;c+=2)e(i.pts[c]-l,i.pts[c+1]-l),e(i.pts[c]+l,i.pts[c+1]+l);break;case"group":{let c=Do(i.items);if(!Number.isFinite(c.minX))break;let u=(s=i.s)!=null?s:1,f=Math.cos((o=i.rot)!=null?o:0),h=Math.sin((a=i.rot)!=null?a:0);for(let[b,y]of[[c.minX,c.minY],[c.maxX,c.minY],[c.minX,c.maxY],[c.maxX,c.maxY]])e(i.x+(b*f-y*h)*u,i.y+(b*h+y*f)*u);break}}}return t}var ht=()=>Float64Array.of(1,0,0,1,0,0);function De(r,t,e,n,s,o,a){let i=s?Math.cos(s):1,l=s?Math.sin(s):0,c=i*o,u=l*o,f=-l*a,h=i*a;if(!t)return r[0]=c,r[1]=u,r[2]=f,r[3]=h,r[4]=e,r[5]=n,r;let b=t[0],y=t[1],x=t[2],d=t[3];return r[0]=b*c+x*u,r[1]=y*c+d*u,r[2]=b*f+x*h,r[3]=y*f+d*h,r[4]=b*e+x*n+t[4],r[5]=y*e+d*n+t[5],r}function zo(r,t,e){let n=r[0]*r[3]-r[1]*r[2];if(Math.abs(n)<1e-12)return null;let s=t-r[4],o=e-r[5];return[(r[3]*s-r[2]*o)/n,(-r[1]*s+r[0]*o)/n]}var Bo={white:16777215,black:0,red:16711680,transparent:0},$n=new Map;function Te(r){var s,o;if(typeof r=="number")return[r&16777215,1];let t=$n.get(r);if(t)return t;let e=[16777215,1],n=r.trim().toLowerCase();if(n[0]==="#"){let a=n.slice(1),i=a.length<=4?[...a].map(c=>c+c).join(""):a,l=parseInt(i.slice(0,6),16);Number.isFinite(l)&&(e=[l,i.length===8?parseInt(i.slice(6,8),16)/255:1])}else if(n.startsWith("rgb")){let a=(o=(s=n.match(/-?\d*\.?\d+%?/g))==null?void 0:s.map(f=>f.endsWith("%")?parseFloat(f)/100*255:parseFloat(f)))!=null?o:[],[i=255,l=255,c=255]=a,u=a[3]===void 0?1:n.match(/,\s*[\d.]+%\s*\)$/)?a[3]/255:a[3];e=[(Kr(i)<<16|Kr(l)<<8|Kr(c))>>>0,Math.min(Math.max(u,0),1)]}else if(n in Bo)e=[Bo[n],n==="transparent"?0:1];else if(typeof document!="undefined"){let a=document.createElement("canvas").getContext("2d");if(a){a.fillStyle="#ffffff",a.fillStyle=n;let i=a.fillStyle;if(i!==n)return $n.set(r,e=Te(i)),e}}return $n.size>512&&$n.clear(),$n.set(r,e),e}var Kr=r=>Math.min(Math.max(Math.round(r),0),255);function vt(r,t,e=!1){let n=Math.min(Math.max(t,0),1),s=(r>>16&255)*n,o=(r>>8&255)*n,a=(r&255)*n,i=e?0:n*255;return(Math.round(i)<<24|Math.round(a)<<16|Math.round(o)<<8|Math.round(s))>>>0}var $t=(r,t=1)=>"rgba(".concat(r>>16&255,",").concat(r>>8&255,",").concat(r&255,",").concat(t,")");function Qr(r,t){if(r===16777215)return t;if(t===16777215)return r;let e=n=>Math.round((r>>n&255)*(t>>n&255)/255);return(e(16)<<16|e(8)<<8|e(0))>>>0}var At={linear:r=>r,quadIn:r=>r*r,quadOut:r=>r*(2-r),quadInOut:r=>r<.5?2*r*r:-1+(4-2*r)*r,cubicOut:r=>1-wt(1-r,3),sineInOut:r=>-(Math.cos(Math.PI*r)-1)/2,backOut:r=>1+(1.70158+1)*wt(r-1,3)+1.70158*wt(r-1,2),elasticOut:r=>r===0||r===1?r:wt(2,-10*r)*Math.sin((r*10-.75)*(2*Math.PI/3))+1,bounceOut:r=>r<1/2.75?7.5625*r*r:r<2/2.75?7.5625*(r-=1.5/2.75)*r+.75:r<2.5/2.75?7.5625*(r-=2.25/2.75)*r+.9375:7.5625*(r-=2.625/2.75)*r+.984375};function Ho(r){let t=r>>>0;return()=>{t=t+1831565813>>>0;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}var _={cap:0,epoch:0,x:new Float64Array(0),y:new Float64Array(0),rot:new Float64Array(0),sx:new Float64Array(0),sy:new Float64Array(0),alpha:new Float64Array(0),la:new Float64Array(0),lb:new Float64Array(0),lc:new Float64Array(0),ld:new Float64Array(0),world:new Float64Array(0),tint:new Uint32Array(0),flags:new Uint8Array(0),moved:new Uint8Array(0),dirty:new Uint8Array(0),gen:new Uint32Array(0),parent:new Int32Array(0),first:new Int32Array(0),next:new Int32Array(0),prev:new Int32Array(0),stamp:new Uint32Array(0),pass:0,free:new Int32Array(0),freeHead:0,freeCount:0,top:2},St=[],ml="x y rot sx sy alpha la lb lc ld world tint flags moved dirty gen parent first next prev stamp".split(" ");function $o(r){let t=_;for(let n of ml){let s=t[n],o=new s.constructor(n==="world"?r*6:r);o.set(s),t[n]=o}let e=new Int32Array(r);for(let n=0;n<_.freeCount;n++)e[n]=_.free[(_.freeHead+n)%_.cap];for(_.free=e,_.freeHead=0,_.cap=r,_.epoch++;St.length<r;)St.push(null)}function Jr(r){_.x[r]=_.y[r]=_.rot[r]=0,_.sx[r]=_.sy[r]=_.alpha[r]=1,_.la[r]=_.ld[r]=1,_.lb[r]=_.lc[r]=0;let t=r*6,e=_.world;e[t]=e[t+3]=1,e[t+1]=e[t+2]=e[t+4]=e[t+5]=0,_.tint[r]=16777215,_.flags[r]=3,_.moved[r]=1,_.dirty[r]=0,_.parent[r]=_.first[r]=_.next[r]=_.prev[r]=-1}$o(256);Jr(0);_.flags[0]=0;Jr(1);_.flags[1]=0;function Go(){let r;if(_.freeCount){r=_.free[_.freeHead],_.freeHead=(_.freeHead+1)%_.cap,_.freeCount--;let t=St[r];t&&(t._i=0,t._g=-1,St[r]=null)}else _.top===_.cap&&$o(_.cap*2),r=_.top++;return Jr(r),r}function es(r,t){xr(r);for(let n=_.first[r];n>=0;){let s=_.next[n];_.parent[n]=_.next[n]=_.prev[n]=-1,n=s}_.first[r]=-1,_.flags[r]=_.flags[r]&-3,_.moved[r]=0;let e=_.gen[r]+1;_.gen[r]=e,e!==4294967295&&(t&&(St[r]=t),_.free[(_.freeHead+_.freeCount)%_.cap]=r,_.freeCount++)}function Uo(r){for(let t=0;t<St.length;t++){let e=St[t];e&&r(e)&&(e._i=0,e._g=-1,St[t]=null)}}function Vo(r,t){xr(r);let e=_.first[t];_.parent[r]=t,_.next[r]=e,_.prev[r]=-1,e>=0&&(_.prev[e]=r),_.first[t]=r,_.moved[r]=1}function xr(r){let t=_.parent[r];if(t<0)return;let e=_.next[r],n=_.prev[r];n>=0?_.next[n]=e:_.first[t]=e,e>=0&&(_.prev[e]=n),_.parent[r]=_.next[r]=_.prev[r]=-1}var Gn={root:-1,gen:-1,world:new Float64Array(6)};function Wo(r){let t=++_.pass,e=_.world,n=r*6,s=Gn.world,o=Gn.root!==r||Gn.gen!==_.gen[r];for(let a=0;a<6;a++)s[a]!==e[n+a]&&(o=!0),s[a]=e[n+a];Gn.root=r,Gn.gen=_.gen[r],_.stamp[r]=o?t:t-1}function Xo(r){_.stamp[r]=_.pass}function jo(r){for(let t=_.first[r];t>=0;){let e=_.next[t];jo(t),t=e}es(r)}var Zr=typeof FinalizationRegistry=="function"?new FinalizationRegistry(r=>_.gen[r.i]===r.g&&jo(r.i)):null;function ts(r){r._reg||!Zr||(r._reg=!0,Zr.register(r,{i:r._i,g:r._g},r))}function qo(r){r._reg&&Zr.unregister(r)}function Un(r){if(r){for(let t=0;t<r.length;t++)if(r[t].enabled)return!0}return!1}function Yo(r,t){let e=0;for(let n=0;n<r.length;n++){let s=r[n];s.enabled&&s.pad&&(e+=s.pad(t))}return e}var Be={gl:null,c2d:null,live:null};var se=new Float64Array(3),Vn=4,bl=1,Wn=()=>bl++;var ge=ht(),D=_,We=class{constructor(t){p(this,"kernel",t);p(this,"_i",Go());p(this,"_g",D.gen[this._i]);p(this,"_wv",null);p(this,"_wi",-1);p(this,"_we",-1);p(this,"blend","normal");p(this,"_data",null);p(this,"parent",null);p(this,"hitRadius",null);p(this,"clip",null);p(this,"mask",null);p(this,"filters",null);p(this,"_z",0);p(this,"anchorX",0);p(this,"anchorY",0);p(this,"_pool",null);p(this,"_free",!1);p(this,"_reg",!1)}get x(){return D.x[this._i]}set x(t){let e=this._i||1;D.x[e]=t,D.moved[e]=1}get y(){return D.y[this._i]}set y(t){let e=this._i||1;D.y[e]=t,D.moved[e]=1}get rotation(){return D.rot[this._i]}set rotation(t){let e=this._i||1;D.rot[e]=t,D.dirty[e]=D.moved[e]=1}get scaleX(){return D.sx[this._i]}set scaleX(t){let e=this._i||1;D.sx[e]=t,D.dirty[e]=D.moved[e]=1}get scaleY(){return D.sy[this._i]}set scaleY(t){let e=this._i||1;D.sy[e]=t,D.dirty[e]=D.moved[e]=1}get alpha(){return D.alpha[this._i]}set alpha(t){let e=this._i||1;D.alpha[e]=t,D.moved[e]=1}get visible(){return(D.flags[this._i]&1)!==0}set visible(t){let e=this._i||1;t?D.flags[e]=D.flags[e]|1:D.flags[e]=D.flags[e]&-2,D.moved[e]=1}get destroyed(){return D.gen[this._i]!==this._g}get world(){let t=this._i||1;return(this._wi!==t||this._we!==D.epoch)&&(this._wv=D.world.subarray(t*6,t*6+6),this._wi=t,this._we=D.epoch),this._wv}get data(){var t;return(t=this._data)!=null?t:this._data={}}set data(t){this._data=t}get scale(){return this.scaleX}set scale(t){this.scaleX=this.scaleY=t}get z(){return this._z}set z(t){t!==this._z&&(this._z=t,this.parent&&(this.parent.sortDirty=!0))}get tint(){return D.tint[this._i]}set tint(t){D.tint[this._i||1]=typeof t=="number"?t&16777215:Te(t)[0]}set anchor(t){typeof t=="number"?this.anchorX=this.anchorY=t:(this.anchorX=t.x,this.anchorY=t.y)}get width(){return 0}set width(t){}get height(){return 0}set height(t){}set(t){for(let e in t){let n=t[e];n!==void 0&&(this[e]=n)}return this}destroy(){var t;this.destroyed||(this.visible=!1,this.parent&&(this.parent.dead=!0,this.parent=null),es(this._i,this),qo(this),this.kernel.tweens.stopAll(this),(t=this._pool)==null||t.forget(this))}updateWorld(){let t=this.parent?this.parent.updateWorld():null;return De(this.world,t,this.x,this.y,this.rotation,this.scaleX,this.scaleY)}draw(t,e,n){}};function Jo(r){Uo(t=>t.kernel===r)}var ns=!1,Ko=Object.freeze([]),Vt=class r extends We{constructor(e){super(e);p(this,"children",Ko);p(this,"sortDirty",!1);p(this,"dead",!1);ts(this)}add(e,...n){this.adopt(e);for(let s=0;s<n.length;s++)this.adopt(n[s]);return e}adopt(e){e.parent&&e.parent.detach(e),e.parent=this,!e.destroyed&&!this.destroyed&&Vo(e._i,this._i),this.children===Ko&&(this.children=[]),this.children.push(e),(e.z!==0||this.sortDirty)&&(this.sortDirty=!0)}remove(e){this.detach(e),e._pool||ts(e)}detach(e){let n=this.children,s=n.indexOf(e);if(s>=0){for(let o=s+1;o<n.length;o++)n[o-1]=n[o];n.pop()}e.parent===this&&(e.parent=null,e.destroyed||xr(e._i))}clear(){for(let e of this.children)e.destroy()}destroy(){for(let e of this.children)e.destroy();super.destroy()}sweep(){if(this.dead){this.dead=!1;let e=0;for(let n of this.children)n.destroyed?n.parent===this&&(n.parent=null):this.children[e++]=n;this.children.length=e}for(let e of this.children)e instanceof r&&e.sweep()}draw(e,n,s){if(ns)return D.parent[this._i]<0&&!this.destroyed&&Xo(this._i),this.drawChildren(e,n,s);ns=!0;try{this.destroyed||Wo(this._i),this.drawChildren(e,n,s)}finally{ns=!1}}drawChildren(e,n,s){if(this.sortDirty){let l=new Map(this.children.map((c,u)=>[c,u]));this.children.sort((c,u)=>c.z-u.z||l.get(c)-l.get(u)),this.sortDirty=!1}let o=this.children,a=this._i,i=D.stamp[a]===D.pass;for(let l=0;l<o.length;l++){let c=o[l],u=c._i,f=D.alpha[u];if(D.gen[u]!==c._g||!(D.flags[u]&1)||f<=0)continue;if(i||D.moved[u]){D.moved[u]=0,D.stamp[u]=D.pass;let y,x,d,m;if(D.dirty[u]){D.dirty[u]=0;let H=D.rot[u],z=H?Math.cos(H):1,B=H?Math.sin(H):0,G=D.sx[u],L=D.sy[u];D.la[u]=y=z*G,D.lb[u]=x=B*G,D.lc[u]=d=-B*L,D.ld[u]=m=z*L}else y=D.la[u],x=D.lb[u],d=D.lc[u],m=D.ld[u];let g=D.world,v=D.x[u],k=D.y[u],R=u*6,F=a*6,I=g[F],A=g[F+1],S=g[F+2],P=g[F+3];g[R]=I*y+S*x,g[R+1]=A*y+P*x,g[R+2]=I*d+S*m,g[R+3]=A*d+P*m,g[R+4]=I*v+S*k+g[F+4],g[R+5]=A*v+P*k+g[F+5]}let h=n*f,b=Qr(s,D.tint[u]);c.clip||c.mask||c.filters?ea(e,c,h,b):c.draw(e,h,b)}}},_e=new Float64Array(128),Gt=0,rs=new Float64Array(8);function ss(r,t,e,n){t.clip||t.mask||t.filters?ea(r,t,e,n):t.draw(r,e,n)}function ea(r,t,e,n){let s=r.r,o=t.world,a=t.clip,i=!1,l=!1;if(a)if(Math.abs(o[1])<1e-9&&Math.abs(o[2])<1e-9&&Gt<32){let f=o[0]*a.x+o[4],h=o[0]*(a.x+a.width)+o[4],b=o[3]*a.y+o[5],y=o[3]*(a.y+a.height)+o[5],x=Math.min(f,h),d=Math.max(f,h),m=Math.min(b,y),g=Math.max(b,y);if(Gt){let k=(Gt-1)*4;x=Math.max(x,_e[k]),m=Math.max(m,_e[k+1]),d=Math.min(d,_e[k+2]),g=Math.min(g,_e[k+3])}let v=Gt++*4;_e[v]=x,_e[v+1]=m,_e[v+2]=d,_e[v+3]=g,s.clip(x,m,Math.max(d-x,0),Math.max(g-m,0)),l=!0}else i=!0;let c=t.mask&&t.mask.visible?t.mask:null,u=Un(t.filters)?t.filters:null;try{if(i&&s.beginLayer(),c&&s.beginLayer(),u?(t.draw(r,s.beginLayer()?1:e,n),s.endLayer(e,u)):t.draw(r,e,n),c&&(s.beginMask(),De(c.world,o,c.x,c.y,c.rotation,c.scaleX,c.scaleY),ss(r,c,c.alpha,16777215),s.endLayer(1)),i&&a){s.beginMask();for(let f=0;f<4;f++){let h=f===1||f===2?a.x+a.width:a.x,b=f>1?a.y+a.height:a.y;rs[f*2]=o[0]*h+o[2]*b+o[4],rs[f*2+1]=o[1]*h+o[3]*b+o[5]}s.polygon(rs,4,16777215,1),s.endLayer(1)}}finally{if(l)if(Gt--,Gt){let f=(Gt-1)*4;s.clip(_e[f],_e[f+1],_e[f+2]-_e[f],_e[f+3]-_e[f+1])}else s.unclip()}}var ze=class extends We{constructor(e,n,s){super(e);p(this,"_frame",null);p(this,"_w",null);p(this,"_h",null);p(this,"slice",0);p(this,"autoAnchor",!0);p(this,"frameName",null);n&&(this.frame=n),(s==null?void 0:s.anchor)===void 0&&this.useFrameAnchor(),s&&this.set(s)}get frame(){return this._frame}set frame(e){this.frameName=typeof e=="string"?e:null,this._frame=typeof e=="string"?this.kernel.frame(e):e,this.autoAnchor&&this.useFrameAnchor()}set anchor(e){this.autoAnchor=!1,super.anchor=e}get naturalWidth(){var n;let e=this.frameNow();return e?((n=e.sw)!=null?n:e.w)/e.scale-e.margin*2:0}get naturalHeight(){var n;let e=this.frameNow();return e?((n=e.sh)!=null?n:e.h)/e.scale-e.margin*2:0}get width(){var e;return(e=this._w)!=null?e:this.naturalWidth}set width(e){this._w=e}get height(){var e;return(e=this._h)!=null?e:this.naturalHeight}set height(e){this._h=e}sizeQ(e){var n,s,o,a;un[0]=(s=this._w)!=null?s:((n=e.sw)!=null?n:e.w)/e.scale-e.margin*2,un[1]=(a=this._h)!=null?a:((o=e.sh)!=null?o:e.h)/e.scale-e.margin*2}frameNow(){return this.frameName&&!this.kernel.atlas.valid(this._frame)&&(this._frame=this.kernel.frame(this.frameName)),this._frame}useFrameAnchor(){var o,a;let e=this._frame;if(!e)return;let n=((o=e.sw)!=null?o:e.w)/e.scale-e.margin*2,s=((a=e.sh)!=null?a:e.h)/e.scale-e.margin*2;this.anchorX=n>0?(e.ox-e.margin)/n:0,this.anchorY=s>0?(e.oy-e.margin)/s:0}draw(e,n,s){let o=this.frameNow();if(!o)return;let a=un;this.sizeQ(o),a[2]=this.anchorX,a[3]=this.anchorY,a[4]=n,yl(e,o,this.world,this.slice,s,this.blend)}},ln=new Float64Array(12),cn=new Float64Array(12),Xn={x:0,y:0,w:0,h:0};function Qo(r,t,e,n,s,o){t=Math.max(t,0),e=Math.max(e,0),n=Math.max(n,0);let a=e+n>s?e*s/(e+n):e,i=e+n>s?n*s/(e+n):n,l=a/o,c=i/o;if(l+c>t){let u=t/(l+c);l*=u,c*=u}r[0]=0,r[1]=l,r[2]=0,r[3]=a,r[4]=l,r[5]=t-l-c,r[6]=a,r[7]=s-a-i,r[8]=t-c,r[9]=c,r[10]=s-i,r[11]=i}var un=new Float64Array(5);function yl(r,t,e,n,s,o){var k,R,F,I,A,S,P,H,z,B,G;let a=un,i=a[0],l=a[1],c=a[2],u=a[3],f=a[4],h=r.tex(t.surface),b=n===0?(k=t.slice)!=null?k:0:n;if(b===0){let L=((R=t.sw)!=null?R:t.w)/t.scale-t.margin*2,U=((F=t.sh)!=null?F:t.h)/t.scale-t.margin*2,Y=L>0?i/L:1,Q=U>0?l/U:1,Ee=-c*i+(((I=t.tx)!=null?I:0)/t.scale-t.margin)*Y,ue=-u*l+(((A=t.ty)!=null?A:0)/t.scale-t.margin)*Q;jn(e,Ee,ue),se[0]=t.w/t.scale*Y,se[1]=t.h/t.scale*Q,se[2]=f,r.r.quadQ(h,t,ge,s,o);return}let y=(S=t.tx)!=null?S:0,x=(P=t.ty)!=null?P:0,d=((H=t.sw)!=null?H:t.w)-t.w-y,m=((z=t.sh)!=null?z:t.h)-t.h-x,g=-c*i-t.margin+y/t.scale,v=-u*l-t.margin+x/t.scale;if(Qo(ln,i+t.margin*2-(y+d)/t.scale,(typeof b=="number"?b:b[3])-y,(typeof b=="number"?b:b[1])-d,t.w,t.scale),Qo(cn,l+t.margin*2-(x+m)/t.scale,(typeof b=="number"?b:b[0])-x,(typeof b=="number"?b:b[2])-m,t.h,t.scale),jn(e,g,v),se[2]=f,!((G=(B=r.r).nineQ)!=null&&G.call(B,h,t,ln,cn,ge,s,o)))for(let L=0;L<12;L+=4){let U=cn[L+1],Y=cn[L+3];if(!(U<=0||Y<=0))for(let Q=0;Q<12;Q+=4){let Ee=ln[Q+1],ue=ln[Q+3];Ee<=0||ue<=0||(Xn.x=t.x+ln[Q+2],Xn.y=t.y+cn[L+2],Xn.w=ue,Xn.h=Y,jn(e,g+ln[Q],v+cn[L]),se[0]=Ee,se[1]=U,se[2]=f,r.r.quadQ(h,Xn,ge,s,o))}}}function jn(r,t,e){ge[0]=r[0],ge[1]=r[1],ge[2]=r[2],ge[3]=r[3],ge[4]=r[0]*t+r[2]*e+r[4],ge[5]=r[1]*t+r[3]*e+r[5]}var nt=class extends ze{constructor(e,n,s={}){super(e,null);p(this,"_spec");p(this,"baked",null);p(this,"bakedEffects",!0);this._spec=n,this.bake(),s.anchor===void 0&&this.useFrameAnchor(),this.set(s)}get spec(){return this._spec}set spec(e){this._spec=e,this.baked=null,this._w=this._h=null,this.bake()}bake(){let e=this.kernel;return this.baked&&e.atlas.valid(this.baked.frame)&&this.baked.frame.scale===e.pixelScale&&this.bakedEffects===e.effects?this.baked:(this.bakedEffects=e.effects,this.baked=e.shape(this._spec),this._frame=this.baked.frame,this.slice=this.baked.slice,this.autoAnchor&&this.useFrameAnchor(),this.baked)}frameNow(){return this.bake().frame}sizeQ(){var n,s;let e=this.bake();un[0]=(n=this._w)!=null?n:e.w,un[1]=(s=this._h)!=null?s:e.h}get width(){var e;return(e=this._w)!=null?e:this.bake().w}set width(e){this._w=e}get height(){var e;return(e=this._h)!=null?e:this.bake().h}set height(e){this._h=e}},Zo=(r,t,e)=>r===void 0?t:typeof r=="number"?r:r[0]+(r[1]-r[0])*e(),Ut=class Ut extends We{constructor(e,n,s={}){var o,a,i,l;super(e);p(this,"max");p(this,"f");p(this,"tints");p(this,"count",0);p(this,"gravity");p(this,"drag");p(this,"frameRef");p(this,"random",Math.random);this.frameRef=n,this.max=Math.max(1,Math.floor((o=s.max)!=null?o:200)),this.f=new Float32Array(this.max*Ut.W),this.tints=new Uint32Array(this.max),this.blend=(a=s.blend)!=null?a:"normal",this.gravity=(i=s.gravity)!=null?i:0,this.drag=(l=s.drag)!=null?l:1}get alive(){return this.count}burst(e,n,s,o={}){var c,u,f,h,b;let a=Ut.W,i=this.random,l=o.tint===void 0?16777215:Te(o.tint)[0];for(let y=0;y<s;y++){let x=this.count;if(x>=this.max){let R=0,F=1/0;for(let I=0;I<this.max;I++){let A=this.f[I*a+5]-this.f[I*a+4];A<F&&(F=A,R=I)}x=R}else this.count++;let d=((c=o.angle)!=null?c:0)+(o.spread===void 0?i()*Math.PI*2:(i()-.5)*o.spread),m=Zo(o.speed,200,i),g=Array.isArray(o.scale)?o.scale[0]:(u=o.scale)!=null?u:1,v=Array.isArray(o.scale)?o.scale[1]:(f=o.scale)!=null?f:1,k=x*a;this.f[k]=e,this.f[k+1]=n,this.f[k+2]=Math.cos(d)*m,this.f[k+3]=Math.sin(d)*m,this.f[k+4]=0,this.f[k+5]=Math.max(Zo(o.life,.8,i),.01),this.f[k+6]=i()*Math.PI*2,this.f[k+7]=(i()-.5)*2*((h=o.spin)!=null?h:0),this.f[k+8]=g,this.f[k+9]=v,this.f[k+10]=(b=o.alpha)!=null?b:1,this.tints[x]=l}}update(e){let n=Ut.W,s=this.f,o=this.drag>=1?1:Math.pow(Math.max(this.drag,0),e);for(let a=0;a<this.count;){let i=a*n;if(s[i+4]=s[i+4]+e,s[i+4]>=s[i+5]){let l=--this.count;a!==l&&(s.copyWithin(i,l*n,l*n+n),this.tints[a]=this.tints[l]);continue}s[i+3]=(s[i+3]+this.gravity*e)*o,s[i+2]=s[i+2]*o,s[i]=s[i]+s[i+2]*e,s[i+1]=s[i+1]+s[i+3]*e,s[i+6]=s[i+6]+s[i+7]*e,a++}}clear(){this.count=0}draw(e,n,s){if(!this.count)return;let o=typeof this.frameRef=="string"?this.frameRef=this.kernel.frame(this.frameRef):this.frameRef,a=Ut.W,i=this.f,l=this.world,c=o.w/o.scale,u=o.h/o.scale;for(let f=0;f<this.count;f++){let h=f*a,b=i[h+4]/i[h+5],y=i[h+8]+(i[h+9]-i[h+8])*b,x=n*i[h+10]*(1-b*b),d=i[h+6],m=Math.cos(d)*y,g=Math.sin(d)*y,v=i[h],k=i[h+1],R=l[0],F=l[1],I=l[2],A=l[3],S=R*m+I*g,P=F*m+A*g,H=I*m-R*g,z=A*m-F*g;ge[0]=S,ge[1]=P,ge[2]=H,ge[3]=z,ge[4]=R*v+I*k+l[4]-(S*c+H*u)/2,ge[5]=F*v+A*k+l[5]-(P*c+z*u)/2,se[0]=c,se[1]=u,se[2]=x,e.r.quadQ(e.tex(o.surface),o,ge,Qr(s,this.tints[f]),this.blend)}}};p(Ut,"W",11);var hn=Ut;var Xe=class extends ze{constructor(e,n,s={}){let f=s,{fps:o,loop:a,playing:i,speed:l,onComplete:c}=f,u=en(f,["fps","loop","playing","speed","onComplete"]);if(!n.frames.length)throw new Error("[engine] an animation needs at least one frame");super(e,n.frames[0],u);p(this,"frames");p(this,"durations");p(this,"fps");p(this,"loop");p(this,"speed");p(this,"onComplete");p(this,"_playing");p(this,"index",0);p(this,"t",0);this.frames=n.frames,this.durations=n.durations&&o===void 0?n.durations:null,this.fps=o!=null?o:12,this.loop=a!==!1,this.speed=l!=null?l:1,this.onComplete=c!=null?c:null,this._playing=i!==!1,this.speed<0&&this.show(n.frames.length-1)}get frameIndex(){return this.index}get frameCount(){return this.frames.length}get playing(){return this._playing}play(){return!this.loop&&!this._playing&&this.index===(this.speed<0?0:this.frames.length-1)&&this.show(this.speed<0?this.frames.length-1:0),this._playing=!0,this}stop(){return this._playing=!1,this}gotoFrame(e){let n=this.frames.length;return this.show((Math.floor(e)%n+n)%n),this.t=0,this}gotoAndPlay(e){return this._playing=!0,this.gotoFrame(e)}gotoAndStop(e){return this._playing=!1,this.gotoFrame(e)}show(e){e===this.index&&this._frame||(this.index=e,this.frame=this.frames[e])}secondsOf(e){var s;let n=(s=this.durations)==null?void 0:s[e];return n!==void 0&&n>0?n:1/Math.max(this.fps,.001)}update(e){var a;if(!this._playing||this.destroyed||this.speed===0)return;let n=this.frames.length,s=this.speed<0;this.t+=e*Math.abs(this.speed);let o=this.index;for(let i=0;i<1e3;i++){let l=this.secondsOf(o);if(this.t<l)break;this.t-=l;let c=s?o-1:o+1;if(c<0||c>=n){if(!this.loop){this.t=0,this._playing=!1,this.show(o),(a=this.onComplete)==null||a.call(this);return}o=s?n-1:0}else o=c}this.show(o)}},ta=(r,t)=>r.localeCompare(t,void 0,{numeric:!0});var qn=class{constructor(t,e,n=2){p(this,"width",t);p(this,"height",e);p(this,"padding",n);p(this,"shelves",[]);p(this,"free",[]);p(this,"bottom",0)}alloc(t,e){let n=Math.ceil(t)+this.padding*2,s=Math.ceil(e)+this.padding*2;if(n>this.width||s>this.height)return null;for(let i=0;i<this.free.length;i++){let l=this.free[i];if(l.w>=n&&l.h>=s&&l.w*l.h<=n*s*2)return this.free.splice(i,1),Ie(M({},this.inner(l.x,l.y,t,e)),{slot:l})}let o=null;for(let i of this.shelves)i.h>=s&&i.h<=s*1.5+8&&this.width-i.x>=n&&(!o||i.h<o.h)&&(o=i);if(!o)if(this.bottom+s>this.height){for(let i of this.shelves)i.h>=s&&this.width-i.x>=n&&(o=i);if(!o)return null}else o={y:this.bottom,h:s,x:0},this.shelves.push(o),this.bottom+=s;let a=o.x;return o.x+=n,this.inner(a,o.y,t,e)}release(t){this.free.push({x:t.x-this.padding,y:t.y-this.padding,w:Math.ceil(t.w)+this.padding*2,h:Math.ceil(t.h)+this.padding*2})}get fill(){return this.bottom/this.height}reset(){this.shelves=[],this.free=[],this.bottom=0}inner(t,e,n,s){return{x:t+this.padding,y:e+this.padding,w:n,h:s}}},fn=r=>({source:r,texture:null,pending:[]}),Mt=class{constructor(t=2048,e=4){p(this,"pageSize",t);p(this,"maxPages",e);p(this,"pages",[]);p(this,"gen",1);p(this,"onPage",()=>{});p(this,"onDrop",()=>{})}valid(t){return!!t&&(t.gen===this.gen||t.gen===0)}bake(t,e,n,s=1,o=0,a=0,i=0){let l=Math.max(1,Math.ceil(t)),c=Math.max(1,Math.ceil(e)),u=document.createElement("canvas");u.width=l,u.height=c;let f=u.getContext("2d");return n(f),this.put(u,l,c,s,o,a,i)}add(t,e=1,n=0,s=0){let o=document.createElement("canvas");return o.width=Math.max(1,t.width),o.height=Math.max(1,t.height),o.getContext("2d").drawImage(t,0,0),this.put(o,o.width,o.height,e,n,s,0)}release(t){if(t.gen!==this.gen)return;let e=this.pages.find(n=>n.surface===t.surface);e==null||e.packer.release(t)}rebake(t,e,n,s,o=t.w,a=t.h){if(!this.valid(t)||e>o||n>a)return null;let i=Math.max(1,Math.ceil(e)),l=Math.max(1,Math.ceil(n)),c=this.pages.find(f=>f.surface===t.surface);if(!c)return null;let u=document.createElement("canvas");return u.width=Math.ceil(o),u.height=Math.ceil(a),s(u.getContext("2d")),c.ctx.clearRect(t.x,t.y,u.width,u.height),c.ctx.drawImage(u,t.x,t.y),t.surface.pending.push([u,t.x,t.y]),t.w=i,t.h=l,t}put(t,e,n,s,o,a,i){let l=null,c=this.pages.find(f=>(l=f.packer.alloc(e,n))!==null);if(c||(!(Math.max(e,n)+4>this.pageSize)&&this.pages.length>=this.maxPages&&(this.wipe(),c=this.pages[0],l=c?c.packer.alloc(e,n):null),(!c||!l)&&(c=this.newPage(Math.max(e,n)),l=c.packer.alloc(e,n))),!l)throw new Error("[engine] ".concat(e,"\xD7").concat(n," does not fit an atlas page"));let u=l;if(u.slot){let f=u.slot;c.ctx.clearRect(f.x,f.y,f.w,f.h);let h=document.createElement("canvas");h.width=f.w,h.height=f.h,h.getContext("2d").drawImage(t,u.x-f.x,u.y-f.y),c.surface.pending.push([h,f.x,f.y])}else c.surface.pending.push([t,u.x,u.y]);return c.ctx.drawImage(t,u.x,u.y),{surface:c.surface,x:u.x,y:u.y,w:e,h:n,scale:s,gen:this.gen,ox:o,oy:a,margin:i}}newPage(t){let e=this.pageSize;for(;e<t+4;)e*=2;let n=document.createElement("canvas");n.width=n.height=e;let s=n.getContext("2d"),o=fn(n),a={surface:o,packer:new qn(e,e),ctx:s};return this.pages.push(a),this.onPage(o),a}wipe(){this.gen++;let t=0;for(let e=0;e<this.pages.length;e++){let n=this.pages[e];if(t<this.maxPages&&n.surface.source.width===this.pageSize){this.pages[t++]=n;continue}n.surface.pending=[],this.onDrop(n.surface)}this.pages.length=t;for(let e of this.pages)e.packer.reset(),e.ctx.clearRect(0,0,e.surface.source.width,e.surface.source.height),e.surface.pending=[],e.surface.pending.push([e.surface.source,0,0])}};var xl=()=>{var t,e,n;let r=typeof document!="undefined"?(t=document.timeline)==null?void 0:t.currentTime:null;return typeof r=="number"&&Number.isFinite(r)?r:(n=(e=$.performance)==null?void 0:e.now())!=null?n:Date.now()},na=()=>{var r,t;return(t=(r=$.performance)==null?void 0:r.now())!=null?t:Date.now()},kr=class{constructor(t=xl){p(this,"now",t);p(this,"known",new Map);p(this,"smoothed",new Map);p(this,"times",new WeakMap);p(this,"lerp",new on);p(this,"amount",os);p(this,"drawnAt",NaN);p(this,"drawn",0);p(this,"smoothedBody",(t,e={})=>{var s;let n=e.interpolate!==!1;if(typeof t=="number"){let o=this.smoothed.get(t);return o?n&&(s=this.lerp.at(t,this.tick()))!=null?s:o.body:null}return typeof t!="object"||t===null||!Array.isArray(t.body)?null:this.posed(t.id,t.body,gl(e.smooth,this.defaultAmount),n)})}setLocal(t){this.amount=t?No:os,this.lerp=new on(t?Yr:{}),this.smoothed.clear()}get defaultAmount(){return this.amount}note(t,e,n=na()){for(let s of t)this.known.set(s.id,this.resolve(s.id,s.avatar)),e!==void 0&&Number.isFinite(e)&&Array.isArray(s.body)&&this.times.set(s.body,{t:e,arrival:n})}of(t){var e;return typeof t=="object"&&t!==null?t.avatar!==void 0?this.resolve(t.id,t.avatar):this.of(t.id):(e=this.known.get(t))!=null?e:Vr(t-1)}posed(t,e,n,s=!0){var a;let o=this.smooth(t,e,n);return s&&(a=this.lerp.at(t,this.tick()))!=null?a:o}smooth(t,e,n){var l,c;let s=this.smoothed.get(t);if(s&&s.raw===e&&s.amount===n)return s.body;s&&s.amount!==n&&this.lerp.forget(t);let o=n<1?Io(s==null?void 0:s.body,e,n):e;this.smoothed.set(t,{raw:e,body:o,amount:n});let a=this.times.get(e),i=(l=a==null?void 0:a.arrival)!=null?l:na();return this.lerp.push(t,(c=a==null?void 0:a.t)!=null?c:i,o,i),o}takeDrawn(){let t=this.drawn;return this.drawn=0,t}tick(){let t=this.now();return t!==this.drawnAt&&(this.drawnAt=t,this.drawn++),t}resolve(t,e){return Lo(e)?e:Vr(t-1)}};var os=.5,gl=(r,t=os)=>r===!1?1:typeof r=="number"?Math.min(Math.max(r,.05),1):t;var oa=new Float64Array(1),ra=new Int32Array(oa.buffer),pn=(r,t)=>(r=Math.imul(r^t,1540483477),r^r>>>15);function pt(r,t=2538058380){return r!==r?pn(t,2146959360):(oa[0]=r===0?0:r,pn(pn(t,ra[0]),ra[1]))}function sa(r,t=2166136261){for(let e=0;e<r.length;e++)t=Math.imul(t^r.charCodeAt(e),16777619);return t}function Ze(r){switch(typeof r){case"number":return pt(r);case"string":return sa(r);case"boolean":return r?1013904242:461845907;case"object":{if(r===null)return 625341585;if(Array.isArray(r)||r instanceof Float64Array){let n=1779033703^r.length;for(let s=0;s<r.length;s++){let o=r[s];n=pn(n,typeof o=="number"?pt(o):Ze(o))}return n}let t=1359893119,e=r;for(let n in e){let s=e[n];s!==void 0&&(t=t+pn(sa(n),Ze(s))|0)}return pn(t,2600822924)}default:return 0}}function dn(r,t){if(r===t)return!0;if(typeof r!="object"||typeof t!="object"||r===null||t===null)return typeof r=="number"&&typeof t=="number"&&r!==r&&t!==t;let e=Array.isArray(r)||r instanceof Float64Array;if(e!==(Array.isArray(t)||t instanceof Float64Array))return!1;if(e){let o=r,a=t;if(o.length!==a.length)return!1;for(let i=0;i<o.length;i++)if(o[i]!==a[i]&&!dn(o[i],a[i]))return!1;return!0}let n=r,s=t;for(let o in n)if(n[o]!==void 0&&!dn(n[o],s[o]))return!1;for(let o in s)if(s[o]!==void 0&&n[o]===void 0)return!1;return!0}function Yn(r){if(typeof r!="object"||r===null)return r;if(Array.isArray(r))return r.map(Yn);if(r instanceof Float64Array)return r.slice();let t={};for(let e in r)r[e]!==void 0&&(t[e]=Yn(r[e]));return t}var mn=class{constructor(t=1/0){p(this,"max",t);p(this,"buckets",new Map);p(this,"n",0)}get size(){return this.n}get(t,e=Ze(t)){let n=this.buckets.get(e);if(n){for(let s=0;s<n.length;s++)if(dn(n[s].key,t))return n[s].value}}set(t,e,n=Ze(t)){let s=this.buckets.get(n);if(s){for(let o of s)if(dn(o.key,t)){o.value=e;return}}this.n>=this.max&&this.clear(),(!s||!this.buckets.has(n))&&this.buckets.set(n,s=[]),s.push({key:Yn(t),value:e}),this.n++}clear(){this.buckets.clear(),this.n=0}};var as=0,aa=1,wr=2,is=3,bn=class{constructor(){p(this,"scale",1);p(this,"cOn",!1);p(this,"px0",0);p(this,"py0",0);p(this,"px1",0);p(this,"py1",0);p(this,"clipVer",0);p(this,"stack",[]);p(this,"sp",0);p(this,"real",0);p(this,"mute",0);p(this,"bnd",new Float64Array(4*(Vn+1)));p(this,"rx0",0);p(this,"ry0",0);p(this,"rx1",0);p(this,"ry1",0);p(this,"maxBlur",1/0);p(this,"time",0);p(this,"skipped",0);p(this,"gq",new Float64Array(4))}resetLayers(t){this.scale=t,this.sp=this.real=this.mute=0,this.skipped=0,this.cOn=!1,this.clipVer++}growQ(){let t=this.gq;this.grow(t[0],t[1],t[2],t[3])}grow(t,e,n,s){if(!this.real)return;let o=this.bnd,a=(this.real-1)*4;t<o[a]&&(o[a]=t),e<o[a+1]&&(o[a+1]=e),n>o[a+2]&&(o[a+2]=n),s>o[a+3]&&(o[a+3]=s)}area(t,e){let n=this.bnd,s=t*4,o=this.scale;return this.rx0=Math.max(Math.floor((n[s]-e)*o)-1,0),this.ry0=Math.max(Math.floor((n[s+1]-e)*o)-1,0),this.rx1=Math.min(Math.ceil((n[s+2]+e)*o)+1,this.canvas.width),this.ry1=Math.min(Math.ceil((n[s+3]+e)*o)+1,this.canvas.height),this.rx1>this.rx0&&this.ry1>this.ry0}clip(t,e,n,s){let o=this.scale,a=this.canvas.width,i=this.canvas.height,l=Math.min(Math.max(Math.round(t*o),0),a),c=Math.min(Math.max(Math.round(e*o),0),i),u=Math.min(Math.max(Math.round((t+n)*o),l),a),f=Math.min(Math.max(Math.round((e+s)*o),c),i);this.cOn&&l===this.px0&&c===this.py0&&u===this.px1&&f===this.py1||(this.cOn=!0,this.px0=l,this.py0=c,this.px1=u,this.py1=f,this.clipVer++)}unclip(){this.cOn&&(this.cOn=!1,this.clipVer++)}push(t){if(t<wr&&(this.mute||this.real>=Vn||!this.pushLayer())&&(t+=2),t===is)this.mute++;else if(t!==wr){let e=this.real*4;this.bnd[e]=this.bnd[e+1]=1/0,this.bnd[e+2]=this.bnd[e+3]=-1/0,this.real++}return this.stack[this.sp++]=t,t<wr}beginLayer(){return this.push(as)}beginMask(){this.push(this.sp&&this.stack[this.sp-1]===as?aa:is)}endLayer(t,e){if(!this.sp)return;let n=this.stack[--this.sp];if(n===is){if(this.mute--,!this.sp)return;n=this.stack[--this.sp]}if(n===aa){let s=--this.real,o=this.popLayer();this.area(s-1,0)&&this.composite(o,!0,1,null);let a=this.bnd,i=(s-1)*4,l=s*4;a[i]=Math.max(a[i],a[l]),a[i+1]=Math.max(a[i+1],a[l+1]),a[i+2]=Math.min(a[i+2],a[l+2]),a[i+3]=Math.min(a[i+3],a[l+3]),n=this.stack[--this.sp]}if(n===wr)Un(e)&&(this.skipped+=e.length);else if(n===as){let s=--this.real,o=Un(e)?e:null,a=this.popLayer();if(this.area(s,o?Yo(o,this.maxBlur):0)){this.composite(a,!1,t,o);let i=this.scale;this.grow(this.rx0/i,this.ry0/i,this.rx1/i,this.ry1/i)}}}closeLayers(){for(;this.sp;)this.endLayer(1)}};var kl=256,ia=8<<20,He=new Float64Array(32),$e={x:0,y:0,w:0,h:0};function wl(r){if(typeof r.filter!="string")return!1;r.filter="blur(1px)";let t=r.filter==="blur(1px)";return r.filter="none",t}function yn(r){let t=r.getContext("2d",{alpha:!0});return t?new ls(r,t):null}var ls=class extends bn{constructor(e,n){super();p(this,"canvas",e);p(this,"ctx",n);p(this,"kind","canvas2d");p(this,"maxTextureSize",4096);p(this,"features",{});p(this,"info",{renderer:"canvas2d"});p(this,"support");p(this,"lost",!1);p(this,"fxr",null);p(this,"quads",0);p(this,"stats",{drawCalls:0,quads:0,filtersSkipped:0});p(this,"tinted",new Map);p(this,"tintedN",0);p(this,"lostListeners",[]);p(this,"restoredListeners",[]);p(this,"base");p(this,"top");p(this,"layers",[]);p(this,"scratch",[]);p(this,"nines",new Map);p(this,"ninePx",0);p(this,"frame",0);p(this,"hit",!1);p(this,"missed",new Map);this.support={filters:wl(n),shaders:!1},this.base=this.top={ctx:n,clipped:!1,ver:0},e.addEventListener("contextlost",()=>{this.lost=!0,this.lostListeners.forEach(s=>s())}),e.addEventListener("contextrestored",()=>{this.lost=!1,this.tinted.clear(),this.tintedN=0,this.dropNines(),this.restoredListeners.forEach(s=>s())})}resize(e,n){this.canvas.width!==e&&(this.canvas.width=e),this.canvas.height!==n&&(this.canvas.height=n)}createTexture(e){return{id:Wn(),width:e.width,height:e.height,source:e}}updateTexture(e,n,s=0,o=0){let a=n?s+n.width:1/0,i=n?o+n.height:1/0;for(let l of this.nines.values()){let c=l.key;c[0]===e.id&&c[1]<a&&c[1]+c[3]>s&&c[2]<i&&c[2]+c[4]>o&&this.dropNine(l)}for(let[l,c]of this.tinted){let u=c.filter(f=>f.id!==e.id);this.tintedN-=c.length-u.length,u.length?this.tinted.set(l,u):this.tinted.delete(l)}}destroyTexture(e){this.updateTexture(e)}begin(e,n,s){var a;this.resetLayers(s),(a=this.fxr)==null||a.tick(),this.frame++,this.quads=0,this.top=this.base,this.ctx=this.base.ctx;let o=this.ctx;this.base.clipped&&o.restore(),this.base.clipped=!1,this.base.ver=this.clipVer,o.setTransform(1,0,0,1,0,0),o.globalAlpha=1,o.globalCompositeOperation="source-over",o.clearRect(0,0,this.canvas.width,this.canvas.height),n>0&&(o.fillStyle=$t(e,n),o.fillRect(0,0,this.canvas.width,this.canvas.height))}quad(e,n,s,o,a,i,l,c){se[0]=o,se[1]=a,se[2]=l,this.quadQ(e,n,s,i,c)}quadQ(e,n,s,o,a){n.w<=0||n.h<=0||(o===16777215?this.blit(e.source,n.x,n.y,n.w,n.h,s,a):this.blit(this.tint(e,n,o),0,0,n.w,n.h,s,a))}blit(e,n,s,o,a,i,l){let c=se[0],u=se[1],f=se[2];if(f<=0||this.mute)return;this.sync();let h=this.ctx,b=this.scale;if(this.real){let y=i[0]*c,x=i[1]*c,d=i[2]*u,m=i[3]*u;this.grow(i[4]+Math.min(0,y,d,y+d),i[5]+Math.min(0,x,m,x+m),i[4]+Math.max(0,y,d,y+d),i[5]+Math.max(0,x,m,x+m))}h.setTransform(i[0]*b,i[1]*b,i[2]*b,i[3]*b,i[4]*b,i[5]*b),h.globalAlpha=Math.min(f,1),l==="add"&&(h.globalCompositeOperation="lighter"),h.drawImage(e,n,s,o,a,0,0,c,u),l==="add"&&(h.globalCompositeOperation="source-over"),this.quads++}nineQ(e,n,s,o,a,i,l){var x,d,m;let c=s[8]+s[9],u=o[8]+o[9],f=Math.ceil(c*Math.hypot(a[0],a[1])*this.scale-1e-6),h=Math.ceil(u*Math.hypot(a[2],a[3])*this.scale-1e-6);if(a[1]===0&&a[2]===0||f>4096||h>4096)return!1;if(!(f>0&&h>0&&se[2]>0)||this.mute)return!0;let b=this.kept(e,n,s,o,f,h,i),y=(b!=null?b:b=(m=(x=this.scratch)[d=13*Math.ceil(Math.log2(f))+Math.ceil(Math.log2(h))])!=null?m:x[d]=document.createElement("canvas").getContext("2d")).canvas;if(y.width<f&&(y.width=f),y.height<h&&(y.height=h),!this.hit){b.clearRect(0,0,f+2,h+2);for(let g=0;g<12;g+=4){let v=Math.round(o[g]*h/u),k=Math.round((o[g]+o[g+1])*h/u);for(let R=0;R<12;R+=4){let F=Math.round(s[R]*f/c),I=Math.round((s[R]+s[R+1])*f/c);$e.x=n.x+s[R+2],$e.y=n.y+o[g+2],$e.w=s[R+3],$e.h=o[g+3],!(I<=F||k<=v||$e.w<=0||$e.h<=0)&&(i===16777215?b.drawImage(e.source,$e.x,$e.y,$e.w,$e.h,F,v,I-F,k-v):b.drawImage(this.tint(e,$e,i),0,0,$e.w,$e.h,F,v,I-F,k-v))}}}return se[0]=c,se[1]=u,this.blit(y,0,0,f,h,a,l),!0}kept(e,n,s,o,a,i,l){He[0]=e.id,He[1]=n.x,He[2]=n.y,He[3]=n.w,He[4]=n.h,He[5]=a,He[6]=i,He[7]=l,He.set(s,8),He.set(o,20);let c=Ze(He),u=this.nines.get(c);if(this.hit=!1,u)return dn(u.key,He)?(u.used=this.frame,this.hit=!0,u.ctx):null;let f=this.missed,h=f.get(c);f.size>4096&&f.clear(),f.set(c,this.frame);let b=a*i;if(h!==this.frame-1||b>ia)return null;let y;for(;this.ninePx+b>ia;){let m;for(let k of this.nines.values())k.used<this.frame-1&&!(m&&m.used<=k.used)&&(m=k);if(!m)return null;let g=m.ctx.canvas,v=!y&&g.width>=a&&g.height>=i&&g.width*g.height<=2*b;this.dropNine(m,v),v&&(y=m.ctx)}let x=y!=null?y:document.createElement("canvas").getContext("2d"),d=x.canvas;return y||(d.width=a,d.height=i),this.ninePx+=d.width*d.height,this.nines.set(c,{key:Yn(He),ctx:x,used:this.frame}),x}dropNine(e,n=!1){this.nines.delete(Ze(e.key));let s=e.ctx.canvas;this.ninePx-=s.width*s.height,n||(s.width=0)}dropNines(){for(let e of this.nines.values())this.dropNine(e)}tint(e,n,s){let o=pt(s,pt(n.h,pt(n.w,pt(n.y,pt(n.x,pt(e.id)))))),a=this.tinted.get(o);if(a)for(let c=0;c<a.length;c++){let u=a[c];if(u.id===e.id&&u.x===n.x&&u.y===n.y&&u.w===n.w&&u.h===n.h&&u.color===s)return u.canvas}this.tintedN>=kl&&(this.tinted.clear(),this.tintedN=0,a=void 0);let i=document.createElement("canvas");i.width=Math.ceil(n.w),i.height=Math.ceil(n.h);let l=i.getContext("2d");return l.drawImage(e.source,n.x,n.y,n.w,n.h,0,0,n.w,n.h),l.globalCompositeOperation="multiply",l.fillStyle=$t(s),l.fillRect(0,0,n.w,n.h),l.globalCompositeOperation="destination-in",l.drawImage(e.source,n.x,n.y,n.w,n.h,0,0,n.w,n.h),a||this.tinted.set(o,a=[]),a.push({id:e.id,x:n.x,y:n.y,w:n.w,h:n.h,color:s,canvas:i}),this.tintedN++,i}paint(e,n){this.sync();let s=this.ctx,o=this.scale;return s.setTransform(o,0,0,o,0,0),s.globalAlpha=Math.min(n,1),$t(e)}ellipse(e,n,s,o,a,i,l){if(l<=0||s<=0||o<=0||this.mute)return;let c=Math.max(s,o);this.grow(e-c,n-c,e+c,n+c);let u=this.ctx;u.fillStyle=this.paint(i,l),u.beginPath(),u.ellipse(e,n,s,o,a,0,Math.PI*2),u.fill(),this.quads++}trace(e,n,s=0){if(this.real)for(let a=0;a<n;a++)this.grow(e[a*2]-s,e[a*2+1]-s,e[a*2]+s,e[a*2+1]+s);let o=this.ctx;o.beginPath(),o.moveTo(e[0],e[1]);for(let a=1;a<n;a++)o.lineTo(e[a*2],e[a*2+1])}polygon(e,n,s,o){if(o<=0||n<3||this.mute)return;let a=this.ctx;a.fillStyle=this.paint(s,o),this.trace(e,n),a.closePath(),a.fill(),this.quads++}stroke(e,n,s,o,a,i){if(a<=0||s<=0||n<1||this.mute)return;let l=this.ctx;l.strokeStyle=this.paint(o,a),l.lineWidth=s,l.lineCap="round",l.lineJoin="round",this.trace(e,n,s/2),n===1&&l.lineTo(e[0],e[1]),i&&l.closePath(),l.stroke(),this.quads++}sync(){let e=this.top;if(e.ver===this.clipVer)return;let n=e.ctx;e.clipped&&n.restore(),e.clipped=this.cOn,e.ver=this.clipVer,this.cOn&&(n.save(),n.setTransform(1,0,0,1,0,0),n.beginPath(),n.rect(this.px0,this.py0,this.px1-this.px0,this.py1-this.py0),n.clip())}pushLayer(){let e=this.canvas.width,n=this.canvas.height,s=this.layers[this.real];if(!s||s.ctx.canvas.width!==e||s.ctx.canvas.height!==n){let a=document.createElement("canvas");a.width=e,a.height=n;let i=a.getContext("2d");if(!i)return!1;s=this.layers[this.real]={ctx:i,clipped:!1,ver:-1}}let o=s.ctx;return s.clipped&&o.restore(),s.clipped=!1,s.ver=-1,o.setTransform(1,0,0,1,0,0),o.globalAlpha=1,o.globalCompositeOperation="source-over",o.clearRect(0,0,e,n),this.top=s,this.ctx=o,!0}popLayer(){return this.top=this.real>0?this.layers[this.real-1]:this.base,this.ctx=this.top.ctx,this.layers[this.real].ctx.canvas}composite(e,n,s,o){var y;let a=e,i="none",l=o&&Be.c2d?(y=this.fxr)!=null?y:this.fxr=Be.c2d(this):null;l&&(a=l.chain(e,o),i=l.css),this.sync();let c=this.ctx,u=this.rx0,f=this.ry0,h=this.rx1-u,b=this.ry1-f;c.setTransform(1,0,0,1,0,0),c.globalAlpha=Math.min(s,1),c.globalCompositeOperation=n?"destination-in":"source-over",i!=="none"&&(c.filter=i),c.drawImage(a,u,f,h,b,u,f,h,b),i!=="none"&&(c.filter="none"),c.globalCompositeOperation="source-over",this.quads++}end(){this.closeLayers();let e=this.stats;return e.drawCalls=e.quads=this.quads,e.filtersSkipped=this.skipped,e}onLost(e){this.lostListeners.push(e)}onRestored(e){this.restoredListeners.push(e)}destroy(){var e;this.tinted.clear(),this.dropNines(),this.layers=[],this.scratch=[],(e=this.fxr)==null||e.destroy(),this.fxr=null}};var vr=class{constructor(t,e,n=8192){p(this,"instanced",t);p(this,"slots",e);p(this,"capacity",n);p(this,"f32");p(this,"u32");p(this,"quads",0);p(this,"textures");p(this,"bound",0);this.textures=new Array(e).fill(null);let s=n*(t?14:24),o=new ArrayBuffer(s*4);this.f32=new Float32Array(o),this.u32=new Uint32Array(o)}slot(t){let e=this.textures;for(let n=0;n<this.bound;n++)if(e[n]===t)return n;return this.bound>=this.slots?-1:(e[this.bound]=t,this.bound++)}has(t){for(let e=0;e<this.bound;e++)if(this.textures[e]===t)return!0;return!1}get full(){return this.quads>=this.capacity}get words(){return this.quads*(this.instanced?14:24)}reset(){this.quads=0;for(let t=0;t<this.bound;t++)this.textures[t]=null;this.bound=0}push(t,e,n,s,o,a,i,l,c,u,f,h,b,y){let x=this.f32;if(this.instanced){let d=this.quads*14;x[d++]=t,x[d++]=e,x[d++]=n,x[d++]=s,x[d++]=o,x[d++]=a,x[d++]=i,x[d++]=l,x[d++]=c,x[d++]=u,x[d++]=f,x[d++]=h,this.u32[d++]=b,x[d]=y}else{let d=this.quads*6*4;this.vertex(d,t,e,c,u,b,y),this.vertex(d+6,n,s,f,u,b,y),this.vertex(d+12,o,a,f,h,b,y),this.vertex(d+18,i,l,c,h,b,y)}this.quads++}pushQ(t,e){let n=this.f32;if(this.instanced){let s=this.quads*14;for(let o=0;o<12;o++)n[s+o]=t[o];this.u32[s+12]=t[12],n[s+13]=e}else{let s=this.quads*6*4,o=t[12];for(let a=0;a<4;a++,s+=6)n[s]=t[a*2],n[s+1]=t[a*2+1],n[s+2]=a===1||a===2?t[10]:t[8],n[s+3]=a>=2?t[11]:t[9],this.u32[s+4]=o,n[s+5]=e}this.quads++}vertex(t,e,n,s,o,a,i){let l=this.f32;l[t]=e,l[t+1]=n,l[t+2]=s,l[t+3]=o,this.u32[t+4]=a,l[t+5]=i}};function la(r){let t=new Uint16Array(r*6);for(let e=0,n=0,s=0;e<r;e++,n+=6,s+=4)t[n]=s,t[n+1]=s+1,t[n+2]=s+2,t[n+3]=s,t[n+4]=s+2,t[n+5]=s+3;return t}var Le={M:0,L:1,Q:2,C:3,Z:4},ba=[2,2,4,6,0],vl={M:0,L:1,Q:2,C:3,Z:4};function Rr(r,t){if(r.length>=t)return r;let e=new Float64Array(Math.max(t,r.length*2,16));return e.set(r),e}var Ar=new Map;function Al(r){var s,o;if(typeof r!="string")return r;let t=Ar.get(r);if(t)return t;t=[];let e=(s=r.match(/[MLQCZ]|-?\d*\.?\d+(?:e-?\d+)?/gi))!=null?s:[],n=-1;for(let a=0;a<e.length;){let i=e[a],l=vl[i.toUpperCase()];if(l!==void 0){n=l,a++,l===Le.Z&&t.push(Le.Z);continue}if(n<0||n===Le.Z){a++;continue}let c=ba[n];t.push(n);for(let u=0;u<c;u++)t.push(Number((o=e[a+u])!=null?o:0));a+=c,n===Le.M&&(n=Le.L)}return Ar.size>256&&Ar.clear(),Ar.set(r,t),t}var Et={subs:[],count:0},cs=null,Tt=null;function Sr(r,t){var o;let e=Tt;e||(e=(o=Et.subs[Et.count])!=null?o:null,e||Et.subs.push(e={pts:new Float64Array(64),n:0,closed:!1}),e.n=0,e.closed=!1,Et.count++,Tt=e);let n=e.n*2;n+2>e.pts.length&&(e.pts=Rr(e.pts,n+2));let s=cs;s?(e.pts[n]=s[0]*r+s[2]*t+s[4],e.pts[n+1]=s[1]*r+s[3]*t+s[5]):(e.pts[n]=r,e.pts[n+1]=t),e.n++}function Cr(r,t=null,e=1,n=6){let s=Al(r);Et.count=0,Tt=null,cs=t;let o=0,a=0,i=0,l=0,c=e/n;for(let u=0;u<s.length;){let f=s[u++],h=s;if(f===Le.M)Tt=null,o=i=h[u],a=l=h[u+1],Sr(o,a);else if(f===Le.L)o=h[u],a=h[u+1],Sr(o,a);else if(f===Le.Q){let b=h[u],y=h[u+1],x=h[u+2],d=h[u+3],m=ca((rt(b-o,y-a)+rt(x-b,d-y))*c);for(let g=1;g<=m;g++){let v=g/m,k=1-v;Sr(k*k*o+2*k*v*b+v*v*x,k*k*a+2*k*v*y+v*v*d)}o=x,a=d}else if(f===Le.C){let b=h[u],y=h[u+1],x=h[u+2],d=h[u+3],m=h[u+4],g=h[u+5],v=ca((rt(b-o,y-a)+rt(x-b,d-y)+rt(m-x,g-d))*c);for(let k=1;k<=v;k++){let R=k/v,F=1-R,I=F*F*F,A=3*F*F*R,S=3*F*R*R,P=R*R*R;Sr(I*o+A*b+S*x+P*m,I*a+A*y+S*d+P*g)}o=m,a=g}else if(f===Le.Z){Tt&&(Tt.closed=!0),Tt=null,o=i,a=l;continue}else break;u+=ba[f]}Tt=null,cs=null;for(let u=0;u<Et.count;u++){let f=Et.subs[u],h=f.n*2;f.closed&&f.n>=2&&Math.abs(f.pts[0]-f.pts[h-2])<1e-6&&Math.abs(f.pts[1]-f.pts[h-1])<1e-6&&f.n--}return Et}var rt=(r,t)=>Math.sqrt(r*r+t*t),ca=r=>Math.min(Math.max(Math.ceil(r),2),24);function Sl(r,t){let e=0;for(let n=0,s=t-1;n<t;s=n++)e+=(r[s*2]-r[n*2])*(r[s*2+1]+r[n*2+1]);return e}var Mr=new Int32Array(64),Tr=(r,t,e,n,s)=>((r[n*2]-r[e*2])*(r[s*2+1]-r[e*2+1])-(r[n*2+1]-r[e*2+1])*(r[s*2]-r[e*2]))*t;function ya(r,t,e){if(t<3)return 0;Mr.length<t&&(Mr=new Int32Array(Math.max(t,Mr.length*2)));let n=Mr,s=t,o=0;for(let c=0;c<t;c++)n[c]=c;let a=Sl(r,t)>0?1:-1,i=t*t+8,l=0;for(;s>3&&i-- >0;){let c=n[(l+s-1)%s],u=n[l%s],f=n[(l+1)%s],h=Tr(r,a,c,u,f)>0;if(h)for(let b=0;b<s;b++){let y=n[b];if(!(y===c||y===u||y===f)&&Tr(r,a,c,u,y)>=0&&Tr(r,a,u,f,y)>=0&&Tr(r,a,f,c,y)>=0){h=!1;break}}h?(e[o++]=c,e[o++]=u,e[o++]=f,n.copyWithin(l%s,l%s+1,s),s--,l=Math.max(l-1,0)):l=(l+1)%s}if(s===3)e[o++]=n[0],e[o++]=n[1],e[o++]=n[2];else if(s>3)for(let c=1;c+1<s;c++)e[o++]=n[0],e[o++]=n[c],e[o++]=n[c+1];return o}var Ml=.85,Er=new Float64Array(64),ua=new Float64Array(64),ha=new Float64Array(64),fa=new Float64Array(64),pa=new Float64Array(64),da=new Float64Array(64),ma=new Uint8Array(64),Kn=new Float64Array(8);function xa(r,t,e,n,s,o){let a=Kn;if(Er.length<t){let d=Math.max(t,Er.length*2);Er=new Float64Array(d),ua=new Float64Array(d),ha=new Float64Array(d),fa=new Float64Array(d),pa=new Float64Array(d),da=new Float64Array(d),ma=new Uint8Array(d)}let i=Er,l=ua,c=0;for(let d=0;d<t;d++){let m=r[d*2],g=r[d*2+1];!Number.isFinite(m)||!Number.isFinite(g)||c&&Math.abs(i[c-1]-m)<.001&&Math.abs(l[c-1]-g)<.001||(i[c]=m,l[c]=g,c++)}if(n&&c>2&&Math.abs(i[0]-i[c-1])<.001&&Math.abs(l[0]-l[c-1])<.001&&c--,c===0)return;if(c===1)return a[0]=i[0],a[1]=l[0],o();let u=n?c:c-1,f=ha,h=fa;for(let d=0;d<u;d++){let m=(d+1)%c,g=i[m]-i[d],v=l[m]-l[d],k=rt(g,v)||1;f[d]=-v/k,h[d]=g/k}let b=pa,y=da,x=ma;for(let d=0;d<c;d++){let m=n?(d-1+u)%u:d-1,g=d<u?d:-1;if(x[d]=1,m<0||g<0||f[m]*f[g]+h[m]*h[g]<Ml)continue;let k=f[m]+f[g],R=h[m]+h[g],F=rt(k,R)||1;k/=F,R/=F;let I=e/Math.max(k*f[g]+R*h[g],.5);b[d]=k*I,y[d]=R*I,x[d]=0}for(let d=0;d<u;d++){let m=(d+1)%c,g=x[d]?f[d]*e:b[d],v=x[d]?h[d]*e:y[d],k=x[m]?f[d]*e:b[m],R=x[m]?h[d]*e:y[m];a[0]=i[d]+g,a[1]=l[d]+v,a[2]=i[m]+k,a[3]=l[m]+R,a[4]=i[m]-k,a[5]=l[m]-R,a[6]=i[d]-g,a[7]=l[d]-v,s()}for(let d=0;d<c;d++)x[d]&&(a[0]=i[d],a[1]=l[d],o())}function us(r,t){let e=0,n=1/0;for(let s=0;s<t.length;s++){let o=Math.abs(Math.log(Math.max(r,.5)/t[s]));o<n&&(n=o,e=s)}return e}var Fr=[{x:240,y:0,w:8,h:8,r:3},{x:224,y:0,w:16,h:16,r:7},{x:192,y:0,w:32,h:32,r:15},{x:128,y:0,w:64,h:64,r:31},{x:0,y:0,w:128,h:128,r:63}],Pr=[4,8,16,32,64,128].map((r,t)=>({x:t*4,y:128,w:4,h:r,r:r/2-1})),dt={x:248,y:248,w:8,h:8},ka=Fr.map(r=>r.r*2),wa=Pr.map(r=>r.r*2),ga=(r,t)=>Math.min(Math.max(r+.5-t,0),1);function Tl(){let r=new Uint8ClampedArray(262144),t=(e,n,s)=>{let o=(n*256+e)*4;r[o]=r[o+1]=r[o+2]=255,r[o+3]=Math.round(s*255)};for(let e of Fr){let n=e.w/2;for(let s=0;s<e.h;s++)for(let o=0;o<e.w;o++)t(e.x+o,e.y+s,ga(e.r,Math.hypot(o+.5-n,s+.5-n)))}for(let e of Pr){let n=e.h/2;for(let s=0;s<e.h;s++)for(let o=0;o<e.w;o++)t(e.x+o,e.y+s,ga(e.r,Math.abs(s+.5-n)))}for(let e=0;e<dt.h;e++)for(let n=0;n<dt.w;n++)t(dt.x+n,dt.y+e,1);return r}function va(){let r=document.createElement("canvas");return r.width=r.height=256,r.getContext("2d").putImageData(new ImageData(Tl(),256,256),0,0),r}var Aa=8,_r="\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n",Fl=r=>"".concat(_r,"\nuniform sampler2D uTex[").concat(r,"];\nvarying vec2 vUv;\nvarying vec4 vColor;\nvarying float vSlot;\nvoid main() {\n vec4 c;\n ").concat(Array.from({length:r},(t,e)=>e===r-1?"c = texture2D(uTex[".concat(e,"], vUv);"):"if (vSlot < ".concat(e,".5) c = texture2D(uTex[").concat(e,"], vUv); else ")).join("\n "),"\n gl_FragColor = c * vColor;\n}"),Pl="\nattribute vec2 aPos;\nattribute vec2 aUv;\nattribute vec4 aColor;\nattribute float aSlot;\nuniform vec2 uScale;\nvarying vec2 vUv;\nvarying vec4 vColor;\nvarying float vSlot;\nvoid main() {\n vUv = aUv;\n vColor = aColor;\n vSlot = aSlot;\n gl_Position = vec4(aPos * uScale + vec2(-1.0, 1.0), 0.0, 1.0);\n}",_l="\nattribute vec4 aCorner;\nattribute vec4 aP01;\nattribute vec4 aP23;\nattribute vec4 aUvRect;\nattribute vec4 aColor;\nattribute float aSlot;\nuniform vec2 uScale;\nvarying vec2 vUv;\nvarying vec4 vColor;\nvarying float vSlot;\nvoid main() {\n vec2 p = aP01.xy * aCorner.x + aP01.zw * aCorner.y + aP23.xy * aCorner.z + aP23.zw * aCorner.w;\n vUv = vec2(mix(aUvRect.x, aUvRect.z, aCorner.y + aCorner.z), mix(aUvRect.y, aUvRect.w, aCorner.z + aCorner.w));\n vColor = aColor;\n vSlot = aSlot;\n gl_Position = vec4(p * uScale + vec2(-1.0, 1.0), 0.0, 1.0);\n}",Ll={alpha:!0,premultipliedAlpha:!0,antialias:!1,depth:!1,stencil:!1,preserveDrawingBuffer:!1,powerPreference:"high-performance"},Ol=["aCorner","aP01","aP23","aUvRect","aColor","aSlot"],Il=["aPos","aUv","aColor","aSlot"];function Ma(r,t,e={}){var o,a;let n=Ie(M({},Ll),{failIfMajorPerformanceCaveat:e.failIfMajorPerformanceCaveat!==!1}),s=t===2?r.getContext("webgl2",n):(o=r.getContext("webgl",n))!=null?o:r.getContext("experimental-webgl",n);if(!s||s.isContextLost())return null;try{return new hs(r,s,t,e)}catch(i){return console.warn("[engine] WebGL setup failed:",i),(a=s.getExtension("WEBGL_lose_context"))==null||a.loseContext(),null}}var hs=class extends bn{constructor(e,n,s,o){super();p(this,"canvas",e);p(this,"gl",n);p(this,"opts",o);p(this,"kind");p(this,"maxTextureSize");p(this,"support",{filters:!0,shaders:!0});p(this,"features",{});p(this,"info",{});p(this,"lost",!1);p(this,"main");p(this,"cur");p(this,"unit",-1);p(this,"onUnit",new Array(Aa).fill(void 0));p(this,"fbNow");p(this,"mapped",!0);p(this,"calls",{useProgram:0,bindTexture:0,activeTexture:0,bindFramebuffer:0});p(this,"vsrc","");p(this,"attrs",[]);p(this,"fxr",null);p(this,"batch");p(this,"dynamic");p(this,"staticBuf",null);p(this,"index");p(this,"vao",null);p(this,"inst",null);p(this,"vaoApi",null);p(this,"uScale",null);p(this,"textures",new Map);p(this,"kit");p(this,"stats",{drawCalls:0,quads:0,filtersSkipped:0});p(this,"lostListeners",[]);p(this,"restoredListeners",[]);p(this,"tris",new Int32Array(192));p(this,"sU",0);p(this,"sV0",0);p(this,"sV1",0);p(this,"sColor",0);p(this,"sPacked",0);p(this,"sAlpha",0);p(this,"sHw",0);p(this,"strokeSeg",()=>{let e=this.q;e.set(Kn),e[8]=e[10]=this.sU,e[9]=this.sV0,e[11]=this.sV1,e[12]=this.sPacked,this.put(this.kit)});p(this,"strokeDisc",()=>this.ellipse(Kn[0],Kn[1],this.sHw,this.sHw,0,this.sColor,this.sAlpha));p(this,"q",new Float64Array(13));p(this,"layers",[]);p(this,"layerTex",new Map);p(this,"bScis",!1);p(this,"bx0",0);p(this,"by0",0);p(this,"bx1",0);p(this,"by1",0);p(this,"onContextLost",e=>{e.preventDefault(),this.lost=!0;for(let n of this.lostListeners)n()});p(this,"onContextRestored",()=>{try{this.layers=[],this.layerTex.clear(),this.fxr=null,this.resetLayers(this.scale),this.setup();for(let e of this.textures.keys())this.textures.set(e,this.upload(e.source));this.lost=!1;for(let e of this.restoredListeners)e()}catch(e){console.warn("[engine] WebGL restore failed:",e)}});p(this,"views",new Map);this.kind=s===2?"webgl2":"webgl1",this.maxTextureSize=n.getParameter(n.MAX_TEXTURE_SIZE),this.setup(),this.kit=this.createTexture(va()),Be.live=this,e.addEventListener("webglcontextlost",this.onContextLost,!1),e.addEventListener("webglcontextrestored",this.onContextRestored,!1)}setup(){let e=this.gl,n=this.kind==="webgl2"?e:null;if(this.inst=null,this.opts.instancing!==!1)if(n)this.inst={divisor:(f,h)=>n.vertexAttribDivisor(f,h),draw:(f,h)=>n.drawElementsInstanced(e.TRIANGLES,f,e.UNSIGNED_SHORT,0,h)};else{let f=e.getExtension("ANGLE_instanced_arrays");f&&(this.inst={divisor:(h,b)=>f.vertexAttribDivisorANGLE(h,b),draw:(h,b)=>f.drawElementsInstancedANGLE(e.TRIANGLES,h,e.UNSIGNED_SHORT,0,b)})}if(this.vaoApi=null,this.opts.vao!==!1)if(n)this.vaoApi={create:()=>n.createVertexArray(),bind:f=>n.bindVertexArray(f),remove:f=>n.deleteVertexArray(f)};else{let f=e.getExtension("OES_vertex_array_object");f&&(this.vaoApi={create:()=>f.createVertexArrayOES(),bind:h=>f.bindVertexArrayOES(h),remove:h=>f.deleteVertexArrayOES(h)})}let s=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),o=Math.max(1,Math.min(Aa,s)),a=this.inst!==null;this.vsrc=a?_l:Pl,this.attrs=a?Ol:Il,this.main=this.cur=this.build(Fl(o));let i=this.main.p;e.useProgram(i),this.calls.useProgram++,this.unit=-1,this.onUnit.fill(void 0),this.fbNow=void 0,this.uScale=this.main.uScale,e.uniform1iv(e.getUniformLocation(i,"uTex"),Int32Array.from({length:o},(f,h)=>h)),this.batch=new vr(a,o),this.vaoApi&&(this.vao=this.vaoApi.create(),this.vaoApi.bind(this.vao)),this.dynamic=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.dynamic),e.bufferData(e.ARRAY_BUFFER,this.batch.f32.byteLength,e.DYNAMIC_DRAW),this.index=e.createBuffer(),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.index),e.bufferData(e.ELEMENT_ARRAY_BUFFER,la(a?1:8192),e.STATIC_DRAW);let l=f=>e.getAttribLocation(i,f),c=(f,h,b,y,x,d,m)=>{let g=l(f);g<0||(e.enableVertexAttribArray(g),e.vertexAttribPointer(g,h,b,y,x,d),this.inst&&this.inst.divisor(g,m))};if(a){let f=56;c("aP01",4,e.FLOAT,!1,f,0,1),c("aP23",4,e.FLOAT,!1,f,16,1),c("aUvRect",4,e.FLOAT,!1,f,32,1),c("aColor",4,e.UNSIGNED_BYTE,!0,f,48,1),c("aSlot",1,e.FLOAT,!1,f,52,1),this.staticBuf=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this.staticBuf),e.bufferData(e.ARRAY_BUFFER,Float32Array.of(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),e.STATIC_DRAW),c("aCorner",4,e.FLOAT,!1,16,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.dynamic)}else{let f=24;c("aPos",2,e.FLOAT,!1,f,0,0),c("aUv",2,e.FLOAT,!1,f,8,0),c("aColor",4,e.UNSIGNED_BYTE,!0,f,16,0),c("aSlot",1,e.FLOAT,!1,f,20,0)}e.enable(e.BLEND),e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA),e.disable(e.DEPTH_TEST),e.disable(e.CULL_FACE),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);let u=e.getExtension("WEBGL_debug_renderer_info");this.info={version:e.getParameter(e.VERSION),renderer:u?e.getParameter(u.UNMASKED_RENDERER_WEBGL):e.getParameter(e.RENDERER),vendor:u?e.getParameter(u.UNMASKED_VENDOR_WEBGL):e.getParameter(e.VENDOR)},this.features={instancing:a,vao:this.vaoApi!==null,textureSlots:o,maxTextureSize:this.maxTextureSize}}upload(e){let n=this.gl,s=n.createTexture();return this.bindTex(s),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),s}resize(e,n){this.canvas.width!==e&&(this.canvas.width=e),this.canvas.height!==n&&(this.canvas.height=n)}createTexture(e){let n={id:Wn(),width:e.width,height:e.height,source:e};return this.textures.set(n,this.lost?null:this.upload(e)),n}updateTexture(e,n,s=0,o=0){if(this.lost)return;this.batch.has(e)&&this.flush();let a=this.gl,i=this.textures.get(e);i&&(this.bindTex(i),!n||n===e.source&&s===0&&o===0?a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,e.source):a.texSubImage2D(a.TEXTURE_2D,0,s,o,a.RGBA,a.UNSIGNED_BYTE,n))}destroyTexture(e){this.batch.has(e)&&this.flush();let n=this.textures.get(e);n&&!this.lost&&this.deleteTex(n),this.textures.delete(e)}begin(e,n,s){if(this.stats.drawCalls=this.stats.quads=this.stats.filtersSkipped=0,this.batch.reset(),this.resetLayers(s),this.bScis=!1,this.lost)return;let o=this.gl;o.disable(o.SCISSOR_TEST),this.bindFb(null),o.viewport(0,0,this.canvas.width,this.canvas.height);let a=n;o.clearColor((e>>16&255)/255*a,(e>>8&255)/255*a,(e&255)/255*a,a),o.clear(o.COLOR_BUFFER_BIT),this.use(this.main),o.uniform2f(this.uScale,2*s/this.canvas.width,-2*s/this.canvas.height),this.mapped=!0}build(e){var i;let n=this.gl,s=Sa(n,n.VERTEX_SHADER,this.vsrc),o;try{o=Sa(n,n.FRAGMENT_SHADER,e)}catch(l){throw n.deleteShader(s),l}let a=n.createProgram();if(n.attachShader(a,s),n.attachShader(a,o),this.attrs.forEach((l,c)=>n.bindAttribLocation(a,c,l)),n.linkProgram(a),n.deleteShader(s),n.deleteShader(o),!n.getProgramParameter(a,n.LINK_STATUS)){let l=(i=n.getProgramInfoLog(a))!=null?i:"?";throw n.deleteProgram(a),new Error("link: ".concat(l))}return{p:a,uScale:n.getUniformLocation(a,"uScale"),locs:new Map}}u(e,n){let s=e.locs.get(n);return s===void 0&&e.locs.set(n,s=this.gl.getUniformLocation(e.p,n)),s}use(e){this.cur!==e&&(this.cur=e,this.gl.useProgram(e.p),this.calls.useProgram++)}bindTex(e,n=this.unit<0?0:this.unit){let s=this.gl;this.onUnit[n]!==e&&(this.unit!==n&&(s.activeTexture(s.TEXTURE0+n),this.calls.activeTexture++,this.unit=n),s.bindTexture(s.TEXTURE_2D,e),this.calls.bindTexture++,this.onUnit[n]=e)}deleteTex(e){this.gl.deleteTexture(e);for(let n=0;n<this.onUnit.length;n++)this.onUnit[n]===e&&(this.onUnit[n]=null)}bindFb(e){if(e)for(let s=0;s<this.onUnit.length;s++)this.onUnit[s]===e.gl&&this.bindTex(null,s);let n=e?e.fb:null;this.fbNow!==n&&(this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,n),this.calls.bindFramebuffer++,this.fbNow=n)}slotOf(e){this.batch.full&&this.flush();let n=this.batch.slot(e);return n<0&&(this.flush(),n=this.batch.slot(e)),n}quad(e,n,s,o,a,i,l,c){se[0]=o,se[1]=a,se[2]=l,this.quadQ(e,n,s,i,c)}quadQ(e,n,s,o,a){let i=se[2];if(this.lost||i<=0)return;let l=this.q,c=se[0],u=se[1],f=s[4],h=s[5],b=s[0]*c,y=s[1]*c,x=s[2]*u,d=s[3]*u;l[0]=f,l[1]=h,l[2]=b+f,l[3]=y+h,l[4]=b+x+f,l[5]=y+d+h,l[6]=x+f,l[7]=d+h;let m=1/e.width,g=1/e.height;l[8]=n.x*m,l[9]=n.y*g,l[10]=(n.x+n.w)*m,l[11]=(n.y+n.h)*g,l[12]=vt(o,i,a==="add"),this.put(e)}put(e){if(this.mute)return;let n=this.q,s=!1,o=Math.min(n[0],n[2],n[4],n[6]),a=Math.max(n[0],n[2],n[4],n[6]),i=Math.min(n[1],n[3],n[5],n[7]),l=Math.max(n[1],n[3],n[5],n[7]);if(this.cOn){if(this.px1<=this.px0||this.py1<=this.py0)return;let u=this.scale,f=this.px0/u,h=this.py0/u,b=this.px1/u,y=this.py1/u;if(a<=f||o>=b||l<=h||i>=y)return;if(o<f||a>b||i<h||l>y){let x=n[0],d=n[1],m=n[2],g=n[5];if(d===n[3]&&m===n[4]&&g===n[7]&&n[6]===x){if(x!==m){let v=Math.min(Math.max(x,f),b),k=Math.min(Math.max(m,f),b),R=n[8],F=(n[10]-R)/(m-x);n[10]=R+(k-x)*F,n[8]=R+(v-x)*F,n[0]=n[6]=v,n[2]=n[4]=k}if(d!==g){let v=Math.min(Math.max(d,h),y),k=Math.min(Math.max(g,h),y),R=n[9],F=(n[11]-R)/(g-d);n[11]=R+(k-d)*F,n[9]=R+(v-d)*F,n[1]=n[3]=v,n[5]=n[7]=k}}else s=!0}}let c=this.bx0===this.px0&&this.by0===this.py0&&this.bx1===this.px1&&this.by1===this.py1;if(s?(!this.bScis||!c)&&(this.flush(),this.bScis=!0,this.bx0=this.px0,this.by0=this.py0,this.bx1=this.px1,this.by1=this.py1):this.bScis&&!(this.cOn&&c)&&(this.flush(),this.bScis=!1),this.real){let u=this.gq;u[0]=o,u[1]=i,u[2]=a,u[3]=l,this.growQ()}this.batch.pushQ(n,this.slotOf(e))}ellipse(e,n,s,o,a,i,l){if(this.lost||l<=0||s<=0||o<=0)return;let c=Fr[us(Math.max(s,o)*2*this.scale,ka)],u=c.w/2/c.r,f=s*u,h=o*u,b=Math.cos(a),y=Math.sin(a),x=b*f,d=y*f,m=-y*h,g=b*h,v=1/256,k=this.q;k[0]=e-x-m,k[1]=n-d-g,k[2]=e+x-m,k[3]=n+d-g,k[4]=e+x+m,k[5]=n+d+g,k[6]=e-x+m,k[7]=n-d+g,k[8]=c.x*v,k[9]=c.y*v,k[10]=(c.x+c.w)*v,k[11]=(c.y+c.h)*v,k[12]=vt(i,l),this.put(this.kit)}polygon(e,n,s,o){if(this.lost||o<=0||n<3)return;this.tris.length<n*3&&(this.tris=new Int32Array(Math.max(n*3,this.tris.length*2)));let a=this.tris,i=ya(e,n,a),l=vt(s,o),c=(dt.x+dt.w/2)/256,u=(dt.y+dt.h/2)/256;for(let f=0;f<i;f+=3){let h=a[f]*2,b=a[f+1]*2,y=a[f+2]*2,x=this.q;x[0]=e[h],x[1]=e[h+1],x[2]=e[b],x[3]=e[b+1],x[4]=x[6]=e[y],x[5]=x[7]=e[y+1],x[8]=x[10]=c,x[9]=x[11]=u,x[12]=l,this.put(this.kit)}}stroke(e,n,s,o,a,i){if(this.lost||a<=0||s<=0||n<1)return;let l=Pr[us(s*this.scale,wa)],c=s/2*(l.h/2/l.r);this.sPacked=vt(o,a),this.sColor=o,this.sAlpha=a,this.sU=(l.x+l.w/2)/256,this.sV0=l.y/256,this.sV1=(l.y+l.h)/256,this.sHw=s/2,xa(e,n,c,i,this.strokeSeg,this.strokeDisc)}target(e,n,s,o){let a=this.gl,i=a.createTexture();this.bindTex(i),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,e,n,0,a.RGBA,a.UNSIGNED_BYTE,null);let l=o?a.LINEAR:a.NEAREST;a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,l),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,l),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),this.bindTex(null);let c=a.createFramebuffer();a.bindFramebuffer(a.FRAMEBUFFER,c),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,i,0);let u=a.checkFramebufferStatus(a.FRAMEBUFFER)===a.FRAMEBUFFER_COMPLETE;if(this.fbNow=c,this.bindFb(this.parent()),!u)return this.deleteTex(i),a.deleteFramebuffer(c),null;let f={tex:{id:Wn(),width:e,height:n,source:this.canvas},gl:i,fb:c,w:e,h:n,f:s};return this.layerTex.set(f.tex,i),f}drop(e){this.batch.has(e.tex)&&this.flush(),this.deleteTex(e.gl),this.gl.deleteFramebuffer(e.fb),this.layerTex.delete(e.tex)}parent(){return this.real>0?this.layers[this.real-1]:null}layerAt(e){var a;let n=this.canvas.width,s=this.canvas.height,o=(a=this.layers[e])!=null?a:null;return o&&(o.w!==n||o.h!==s)&&(this.drop(o),o=this.layers[e]=null),o!=null?o:this.layers[e]=this.target(n,s,1,!1)}pushLayer(){if(this.lost)return!1;this.flush();let e=this.layerAt(this.real);if(!e)return!1;let n=this.gl;return this.bindFb(e),n.disable(n.SCISSOR_TEST),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),!0}popLayer(){return this.flush(),this.bindFb(this.parent()),this.layers[this.real].tex}filters(){var e;return this.lost||!Be.gl?null:(e=this.fxr)!=null?e:this.fxr=Be.gl(this)}composite(e,n,s,o){var i;if(o&&((i=this.filters())!=null&&i.chain(e,s,o)))return;let a=this.gl;n&&a.blendFunc(a.ZERO,a.SRC_ALPHA),this.final(this.main,e,1,s),n&&(this.flush(),a.blendFunc(a.ONE,a.ONE_MINUS_SRC_ALPHA))}final(e,n,s,o){let a=this.gl,i=this.canvas.width,l=this.canvas.height,c=this.scale;(e!==this.main||!this.mapped)&&(this.bindFb(this.parent()),a.viewport(0,0,i,l),this.use(e),a.uniform2f(e.uScale,2*c/i,-2*c/l),this.mapped=e===this.main);let u=this.rx0/c,f=this.ry0/c,h=this.rx1/c,b=this.ry1/c,y=1/(s*n.width),x=1/(s*n.height),d=this.q;d[0]=d[6]=u,d[1]=d[3]=f,d[2]=d[4]=h,d[5]=d[7]=b,d[8]=this.rx0*y,d[9]=1-this.ry0*x,d[10]=this.rx1*y,d[11]=1-this.ry1*x,d[12]=vt(16777215,o),this.put(n),e!==this.main&&this.flush()}remap(){let e=this.gl;this.bindFb(this.parent()),e.viewport(0,0,this.canvas.width,this.canvas.height),this.use(this.main),e.uniform2f(this.uScale,2*this.scale/this.canvas.width,-2*this.scale/this.canvas.height),this.mapped=!0}upload2(e){let n=this.gl,s=e.words;if(this.kind==="webgl2")return n.bufferSubData(n.ARRAY_BUFFER,0,e.f32,0,s);let o=this.views.get(s);o||(this.views.size>=256&&this.views.clear(),this.views.set(s,o=e.f32.subarray(0,s))),n.bufferSubData(n.ARRAY_BUFFER,0,o)}flush(){var s,o;let e=this.batch;if(!e.quads||this.lost)return e.reset();let n=this.gl;this.bScis?(n.enable(n.SCISSOR_TEST),n.scissor(this.bx0,this.canvas.height-this.by1,this.bx1-this.bx0,this.by1-this.by0)):n.disable(n.SCISSOR_TEST),this.upload2(e);for(let a=0;a<e.bound;a++){let i=e.textures[a];this.bindTex((o=(s=this.textures.get(i))!=null?s:this.layerTex.get(i))!=null?o:null,a)}this.inst?this.inst.draw(6,e.quads):n.drawElements(n.TRIANGLES,e.quads*6,n.UNSIGNED_SHORT,0),this.stats.drawCalls++,this.stats.quads+=e.quads,e.reset()}end(){return this.closeLayers(),this.flush(),this.stats.filtersSkipped=this.skipped,this.stats}onLost(e){this.lostListeners.push(e)}onRestored(e){this.restoredListeners.push(e)}destroy(){var n,s;let e=this.gl;Be.live===this&&(Be.live=null),this.canvas.removeEventListener("webglcontextlost",this.onContextLost),this.canvas.removeEventListener("webglcontextrestored",this.onContextRestored);try{for(let o of this.textures.values())o&&e.deleteTexture(o);for(let o of this.layers)o&&(e.deleteTexture(o.gl),e.deleteFramebuffer(o.fb));(n=this.fxr)==null||n.destroy(),this.fxr=null,e.deleteBuffer(this.dynamic),e.deleteBuffer(this.index),this.staticBuf&&e.deleteBuffer(this.staticBuf),this.vao&&this.vaoApi&&this.vaoApi.remove(this.vao),e.deleteProgram(this.main.p),(s=e.getExtension("WEBGL_lose_context"))==null||s.loseContext()}catch(o){}this.textures.clear()}};function Sa(r,t,e){var s;let n=r.createShader(t);if(r.shaderSource(n,e),r.compileShader(n),!r.getShaderParameter(n,r.COMPILE_STATUS)){let o=(s=r.getShaderInfoLog(n))!=null?s:"?";throw r.deleteShader(n),new Error(o)}return n}function fs(r="auto"){switch(r){case"canvas2d":return["canvas2d"];case"webgl1":return["webgl1","canvas2d"];default:return["webgl2","webgl1","canvas2d"]}}function gn(r,t={}){let e=r;for(let n of fs(t.renderer)){let s=n==="canvas2d"?yn(e):Ma(e,n==="webgl2"?2:1,t);if(s)return s;e=Qn(e)}throw new Error("No renderer: this browser has neither WebGL nor Canvas 2D")}function Qn(r){var e;let t=r.cloneNode(!1);return(e=r.parentNode)==null||e.replaceChild(t,r),t}function Ta(r=typeof location!="undefined"?location.search:""){let t=new URLSearchParams(r).get("renderer");return t==="canvas"?"canvas2d":t==="webgl2"||t==="webgl1"||t==="canvas2d"||t==="webgl"||t==="auto"?t:void 0}var Rt=class{constructor(t,e={}){p(this,"atlas",t);p(this,"tags",new Map);p(this,"count",0);p(this,"m",ht());p(this,"measure",null);p(this,"height");p(this,"font");var n,s;this.height=(n=e.tagHeight)!=null?n:34,this.font=(s=e.tagFont)!=null?s:"Nunito, sans-serif"}drop(){for(let t of this.tags.values())for(let e of t.values())for(let n of e.values())this.atlas.release(n);this.tags.clear(),this.count=0}get(t,e,n){let s=this.tags.get(t);s||this.tags.set(t,s=new Map);let o=s.get(e);o||s.set(e,o=new Map);let a=o.get(n);return a&&this.atlas.valid(a)?a:this.bake(t,e,n)}bake(t,e,n){var h;let s=this.height,o="700 ".concat(Math.round(s*.65),"px ").concat(this.font),a=(h=this.measure)!=null?h:this.measure=document.createElement("canvas").getContext("2d");a.font=o;let i=Math.round(s*.4),l=Math.ceil(a.measureText(t).width)+i*2,c=this.atlas.bake((l+2)*n,(s+2)*n,b=>{b.scale(n,n),b.translate(1,1);let y=s/2;b.beginPath(),b.moveTo(y,0),b.lineTo(l-y,0),b.arc(l-y,y,y,-Math.PI/2,Math.PI/2),b.lineTo(y,s),b.arc(y,y,y,Math.PI/2,Math.PI*3/2),b.closePath(),b.fillStyle=e,b.fill(),b.fillStyle="#fff",b.font=o,b.textAlign="center",b.textBaseline="middle",b.fillText(t,l/2,s/2+1)},n,1,1,1);++this.count>64&&(this.drop(),this.count=1);let u=this.tags.get(t);u||this.tags.set(t,u=new Map);let f=u.get(e);return f||u.set(e,f=new Map),f.set(n,c),c}draw(t,e,n,s,o,a,i,l,c,u,f){let h=sn(n,o,{band:Nl(s)});if(!h)return;let b=this.height,y=this.get(a,i,c),x=y.w/y.scale-2,d=Math.min(Math.max(h.head.x-x/2,4),u-x-4),m=Math.min(Math.max(h.head.y-h.headR*2.2-b,4),f-b-4);De(this.m,null,d-1,m-1,0,1,1),t.quad(e(y.surface),y,this.m,y.w/y.scale,y.h/y.scale,16777215,l,"normal")}},Nl=r=>r.band==="3-5"||r.band==="9-12"?r.band:"6-8";var Dl=(r,t=!1)=>t?Math.min(wt(2,Math.round(Math.log2(Math.max(r,8)))),256):Math.min(wt(2,Math.ceil(Math.log2(Math.max(r,8))*2)/2),512);function Or(r,t=null){var s,o,a,i;let e={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},n=(l,c,u)=>{let f=t?t[0]*l+t[2]*c+t[4]:l,h=t?t[1]*l+t[3]*c+t[5]:c,b=t?Math.hypot(t[0],t[1]):1;e.minX=Math.min(e.minX,f-u*b),e.minY=Math.min(e.minY,h-u*b),e.maxX=Math.max(e.maxX,f+u*b),e.maxY=Math.max(e.maxY,h+u*b)};for(let l of r){let c="lw"in l&&l.stroke?((s=l.lw)!=null?s:1)/2:0;switch(l.k){case"circle":n(l.x-l.r,l.y-l.r,c),n(l.x+l.r,l.y+l.r,c),n(l.x-l.r,l.y+l.r,c),n(l.x+l.r,l.y-l.r,c);break;case"ellipse":case"rect":{let u=l.k==="ellipse"?Math.max(l.rx,l.ry):Math.hypot(l.w,l.h)/2;n(l.x-u,l.y-u,c),n(l.x+u,l.y+u,c),n(l.x-u,l.y+u,c),n(l.x+u,l.y-u,c);break}case"path":{let u=Cr(l.d);for(let f=0;f<u.count;f++){let h=u.subs[f];for(let b=0;b<h.n;b++)n(h.pts[b*2],h.pts[b*2+1],c)}break}case"line":for(let u=0;u+1<l.pts.length;u+=2)n(l.pts[u],l.pts[u+1],c);break;case"group":{let u=De(ht(),t,l.x,l.y,(o=l.rot)!=null?o:0,(a=l.s)!=null?a:1,(i=l.s)!=null?i:1),f=Or(l.items,u);Number.isFinite(f.minX)&&(e.minX=Math.min(e.minX,f.minX),e.minY=Math.min(e.minY,f.minY),e.maxX=Math.max(e.maxX,f.maxX),e.maxY=Math.max(e.maxY,f.maxY));break}}}return e}var Wt=class{constructor(t){p(this,"atlas",t);p(this,"seen",new WeakSet);p(this,"baked",new WeakMap);p(this,"m",ht());p(this,"stack",[]);p(this,"local",ht());p(this,"pts",new Float64Array(128));p(this,"stats",{baked:0,vector:0});p(this,"bakeGroups",!0);p(this,"coarse",!1);p(this,"gen",0);p(this,"live",new Set)}setTier(t){let e=t==="low";if(e!==this.coarse){this.coarse=e,this.gen++;for(let n of this.live)this.atlas.release(n.frame);this.live.clear()}}draw(t,e,n,s,o,a,i){var u;let l=typeof s=="string"?(u=an(s))!=null?u:Ht:s,c=Hn(n,l,o);return c.length?(a<=0||(a<1?(this.paint(t,e,c,null,t.beginLayer()?1:a,i),t.endLayer(a)):this.paint(t,e,c,null,a,i)),!0):!1}paint(t,e,n,s,o,a,i=0){var l,c,u,f,h,b,y,x,d,m,g;for(let v=0;v<n.length;v++){let k=n[v];if(k.k==="group"){let z=De((c=(l=this.stack)[i])!=null?c:l[i]=ht(),s,k.x,k.y,(u=k.rot)!=null?u:0,(f=k.s)!=null?f:1,(h=k.s)!=null?h:1),B=o*((b=k.alpha)!=null?b:1);if(this.bakeGroups&&this.seen.has(k.items)){let G=rt(z[0],z[1])*a,L=this.bake(k.items,G);if(L){let U=L.frame,Y=this.m;Y.set(z),Y[4]=z[0]*-L.ox+z[2]*-L.oy+z[4],Y[5]=z[1]*-L.ox+z[3]*-L.oy+z[5],t.quad(e(U.surface),U,Y,U.w/L.k,U.h/L.k,16777215,B,"normal"),this.stats.baked++;continue}}this.seen.add(k.items),this.stats.vector++,this.paint(t,e,k.items,z,B,a,i+1);continue}let R=o*((y=k.alpha)!=null?y:1),F=s?rt(s[0],s[1]):1,I=s?Math.atan2(s[1],s[0]):0,A=((x=k.lw)!=null?x:1)*F,S=k.stroke&&((d=k.lw)!=null?d:1)>0?Te(k.stroke):null,P=k.fill&&k.k!=="line"?Te(k.fill):null;if(k.k==="circle"||k.k==="ellipse"){let z=s?s[0]*k.x+s[2]*k.y+s[4]:k.x,B=s?s[1]*k.x+s[3]*k.y+s[5]:k.y,G=(k.k==="circle"?k.r:k.rx)*F,L=(k.k==="circle"?k.r:k.ry)*F,U=(k.k==="ellipse"&&(m=k.rot)!=null?m:0)+I;if(P&&S)t.ellipse(z,B,G+A/2,L+A/2,U,S[0],R*S[1]),t.ellipse(z,B,Math.max(G-A/2,0),Math.max(L-A/2,0),U,P[0],R*P[1]);else if(P)t.ellipse(z,B,G,L,U,P[0],R*P[1]);else if(S){let Y=Math.min(Math.max(Math.ceil(Math.max(G,L)*a*.6),12),64),Q=this.pts=Rr(this.pts,Y*2),Ee=Math.cos(U),ue=Math.sin(U);for(let ke=0;ke<Y;ke++){let we=ke/Y*Math.PI*2,oe=Math.cos(we)*G,Re=Math.sin(we)*L;Q[ke*2]=z+oe*Ee-Re*ue,Q[ke*2+1]=B+oe*ue+Re*Ee}t.stroke(Q,Y,A,S[0],R*S[1],!0)}continue}if(k.k==="line"){if(!S)continue;let z=k.pts.length>>1,B=this.pts=Rr(this.pts,z*2);for(let G=0;G<z;G++){let L=k.pts[G*2],U=k.pts[G*2+1];B[G*2]=s?s[0]*L+s[2]*U+s[4]:L,B[G*2+1]=s?s[1]*L+s[3]*U+s[5]:U}t.stroke(B,z,A,S[0],R*S[1],!1);continue}let H=k.k==="path"?Cr(k.d,s,F*a):Bl(k,De(this.local,s,k.x,k.y,(g=k.rot)!=null?g:0,1,1),a*F);for(let z=0;z<H.count;z++){let B=H.subs[z],G=B.n,L=k.k==="rect"||B.closed;P&&G>=3&&(t.polygon(B.pts,G,P[0],R*P[1]),S||t.stroke(B.pts,G,1/a,P[0],R*P[1],!0)),S&&t.stroke(B.pts,G,A,S[0],R*S[1],L)}}}bake(t,e){let n=Dl(e,this.coarse),s=this.baked.get(t),o=s==null?void 0:s.get(n);if(o&&o.gen===this.gen&&this.atlas.valid(o.frame))return o;o&&this.live.delete(o);let a=Or(t);if(!Number.isFinite(a.minX))return null;let i=2/n,l=(a.maxX-a.minX+i*2)*n,c=(a.maxY-a.minY+i*2)*n;if(l>1024||c>1024)return null;let u=-a.minX+i,f=-a.minY+i,b={frame:this.atlas.bake(l,c,y=>{y.scale(n,n),y.translate(u,f),nn(y,t)}),k:n,ox:u,oy:f,gen:this.gen};return s||this.baked.set(t,s=new Map),s.set(n,b),this.live.add(b),b}},kn=new Array(36).fill(0),wn=0,st=(r,t=NaN,e=NaN,n=NaN,s=NaN)=>{kn[wn++]=r,r!==Le.Z&&(kn[wn++]=t,kn[wn++]=e,r===Le.Q&&(kn[wn++]=n,kn[wn++]=s))};function Bl(r,t,e){let n=Math.max(0,Math.min(r.r,r.w/2,r.h/2)),s=-r.w/2,o=-r.h/2,{M:a,L:i,Q:l,Z:c}=Le;return wn=0,st(a,s+n,o),st(i,s+r.w-n,o),st(l,s+r.w,o,s+r.w,o+n),st(i,s+r.w,o+r.h-n),st(l,s+r.w,o+r.h,s+r.w-n,o+r.h),st(i,s+n,o+r.h),st(l,s,o+r.h,s,o+r.h-n),st(i,s,o+n),st(l,s,o,s+n,o),st(c),Cr(kn,t,e)}function Ea(r,t={}){var F,I;let e=gn(r,t),n=new Mt(Math.min(1024,e.maxTextureSize),2);n.onDrop=A=>{A.texture&&e.destroyTexture(A.texture),A.texture=null};let s=new Wt(n),o=()=>{let A=new kr;return t.local&&A.setLocal(!0),A},a=o(),i=new Map,l=1e6,c=t.smooth===!1?1:typeof t.smooth=="number"?Math.min(Math.max(t.smooth,.05),1):a.defaultAmount,u=Zn(e),f=new Rt(n,t),h={w:1,h:1},b=1,y=0,x=!1,d=()=>f.drop(),m=typeof document!="undefined"?document.fonts:void 0;(F=m==null?void 0:m.ready)==null||F.then(()=>{x||d()}),(I=m==null?void 0:m.addEventListener)==null||I.call(m,"loadingdone",d);let g=()=>{let A=Qn(e.canvas),S=yn(A);if(S){console.warn("[engine] avatars: WebGL context lost for good, switching to Canvas 2D"),e.destroy(),e=S;for(let P of n.pages)P.surface.texture=null;u=Zn(e),y=0}},v=()=>{if(!e.lost)return y=0,!0;let A=performance.now();return y||(y=A),A-y>3e3&&g(),!e.lost},k=()=>{var S,P;let A=e.canvas;t.units?(b=(S=t.pixelRatio)!=null?S:1,h.w=t.units.width,h.h=t.units.height):(b=(P=t.pixelRatio)!=null?P:Math.min($.devicePixelRatio||1,2),h.w=A.clientWidth||A.width/b,h.h=A.clientHeight||A.height/b),e.resize(Math.max(1,Math.round(h.w*b)),Math.max(1,Math.round(h.h*b))),e.begin(0,0,b)},R=(A,S)=>{var H;if(A.key===void 0)return(H=A.id)!=null?H:S+1;let P=i.get(A.key);return P===void 0&&(i.size>256&&i.clear(),i.set(A.key,P=l++)),P};return{get renderer(){return e},get kind(){return e.kind},get lost(){return e.lost},get canvas(){return e.canvas},draw(A,S){var P,H,z,B;if(v()){k();for(let G=0;G<A.length;G++){let L=A[G];if(!Array.isArray(L.body))continue;let U=R(L,G),Y=c<1||t.interpolate!==!1?a.posed(U,L.body,c,t.interpolate!==!1):L.body,Q=(H=an((P=L.avatar)!=null?P:""))!=null?H:Ht,Ee=(z=L.alpha)!=null?z:1;!s.draw(e,u,Y,Q,S,Ee,b)||!L.name||f.draw(e,u,Y,Q,S,L.name,(B=L.color)!=null?B:"#6FA0E0",Ee,b,h.w,h.h)}e.end()}},clear(){v()&&(k(),e.end())},reset(){a=o(),i.clear()},destroy(){var A;x=!0,(A=m==null?void 0:m.removeEventListener)==null||A.call(m,"loadingdone",d),e.destroy()}}}var Lr=new Map;function Ra(r,t,e=Math.min($.devicePixelRatio||1,2)){var a;let n="".concat(r,"|").concat(t,"|").concat(e),s=Lr.get(n);if(s)return s;s=document.createElement("canvas"),s.width=s.height=Math.round(t*e);let o=s.getContext("2d");return o.scale(e,e),o.beginPath(),o.rect(0,0,t,t),o.clip(),nn(o,Oo((a=an(r))!=null?a:Ht,t)),Lr.size>64&&Lr.clear(),Lr.set(n,s),s}function Zn(r){return t=>{if(t.texture||(t.texture=r.createTexture(t.source),t.pending.length=0),t.pending.length){for(let[e,n,s]of t.pending)r.updateTexture(t.texture,e,n,s);t.pending.length=0}return t.texture}}var ps='Fredoka, Nunito, "Varela Round", system-ui, sans-serif',Xt="rgba(10,16,30,0.75)";function ds(r,t){var i,l,c,u,f,h;let e=(i=r.size)!=null?i:40,n=r.outline?r.outline===!0?Xt:r.outline:null,s=n?(l=r.outlineWidth)!=null?l:Math.max(e*.12,3):0,o=r.shadow&&t?r.shadow===!0?Xt:r.shadow:null,a=o?(c=r.shadowBlur)!=null?c:e*.25:0;return{size:e,font:(u=r.font)!=null?u:ps,weight:(f=r.weight)!=null?f:700,color:(h=r.color)!=null?h:"#FBEFE3",outline:n,ow:s,shadow:o,blur:a,pad:s/2+a*1.2+2,th:e*1.25}}var Ca=(r,t)=>"".concat(r.weight," ").concat(r.size*t,"px ").concat(r.font);function ms(r,t,e,n,s,o){r.scale(n,n),r.font=Ca(e,1),r.textBaseline="middle",r.textAlign="left",r.lineJoin="round",e.shadow&&(r.shadowColor=e.shadow,r.shadowBlur=e.blur*n),e.outline&&(r.strokeStyle=e.outline,r.lineWidth=e.ow,r.strokeText(t,s,o),r.shadowColor="transparent"),r.fillStyle=e.color,r.fillText(t,s,o)}var vn=null;function bs(r,t,e){return vn!=null||(vn=document.createElement("canvas").getContext("2d")),vn.font=Ca(t,e),vn.measureText(r).width/e}var ot=class extends ze{constructor(e,n,s={}){super(e,null);p(this,"_text");p(this,"_style");p(this,"dirty",!0);p(this,"bakedScale",0);p(this,"bakedFontGen",-1);p(this,"bakedEffects",!0);p(this,"capW",0);p(this,"capH",0);this._text=n;let F=s,{x:o,y:a,rotation:i,scale:l,scaleX:c,scaleY:u,alpha:f,visible:h,tint:b,blend:y,z:x,anchor:d,hitRadius:m,clip:g,mask:v,filters:k}=F,R=en(F,["x","y","rotation","scale","scaleX","scaleY","alpha","visible","tint","blend","z","anchor","hitRadius","clip","mask","filters"]);this._style=R,this.bake(),this.set({x:o,y:a,rotation:i,scale:l,scaleX:c,scaleY:u,alpha:f,visible:h,tint:b,blend:y,z:x,hitRadius:m,clip:g,mask:v,filters:k}),d!==void 0&&(this.anchor=d)}get text(){return this._text}set text(e){let n=String(e);n!==this._text&&(this._text=n,this.dirty=!0)}get style(){return this._style}set style(e){this._style=M(M({},this._style),e),this.dirty=!0}bitmap(){let e=this._style.bitmapFont;if(!e)return null;let n=typeof e=="string"?this.kernel.bitmapFont(e):e;if(this.autoAnchor){let s=this._style.align;this.anchorX=s==="left"?0:s==="right"?1:.5,this.anchorY=.5}return n}get naturalWidth(){var n;let e=this.bitmap();return e?e.measure(this._text)*(((n=this._style.size)!=null?n:e.size)/e.size):super.naturalWidth}get naturalHeight(){var n;let e=this.bitmap();return e?e.lineHeight*(((n=this._style.size)!=null?n:e.size)/e.size):super.naturalHeight}frameNow(){return this._style.bitmapFont?null:this.bake()}draw(e,n,s){var b;let o=this.bitmap();if(!o)return super.draw(e,n,s);let a=((b=this._style.size)!=null?b:o.size)/o.size,i=o.measure(this._text)*a,l=o.lineHeight*a,c=this.width,u=this.height,f=i>0?c/i:1,h=l>0?u/l:1;o.run(this._text,e,this.world,-this.anchorX*c,-this.anchorY*u,a*f,a*h,s,n,this.blend)}destroy(){this._frame&&this.kernel.atlas.release(this._frame),super.destroy()}bake(){let e=this.kernel;if(this._style.bitmapFont)return null;let n=e.pixelScale,s=e.effects;return!this.dirty&&n===this.bakedScale&&e.fontGen===this.bakedFontGen&&s===this.bakedEffects&&e.atlas.valid(this._frame)?this._frame:this.rebake()}rebake(){var d;let e=this.kernel,n=e.pixelScale,s=e.effects;this.dirty=!1,this.bakedScale=n,this.bakedFontGen=e.fontGen,this.bakedEffects=s;let o=ds(this._style,s),{pad:a,th:i}=o,l=bs(this._text,o,n),c=(l+a*2)*n,u=(i+a*2)*n,f=(d=this._style.align)!=null?d:"center",h=f==="left"?a:f==="right"?a+l:a+l/2,b=m=>ms(m,this._text,o,n,a,a+i/2),y=this._frame,x=null;return y&&e.atlas.valid(y)&&y.scale===n&&(x=e.atlas.rebake(y,c,u,b,this.capW,this.capH),x?Object.assign(x,{ox:h,oy:a+i/2,margin:a}):e.atlas.release(y)),x||(this.capW=Math.ceil(c*1.25+16),this.capH=Math.ceil(u),x=e.atlas.bake(this.capW,this.capH,b,n,h,a+i/2,a),x.w=Math.ceil(c),x.h=Math.ceil(u)),this._frame=x,this.autoAnchor&&this.useFrameAnchor(),this._w=this._h=null,x}};var Ae=(r,t=0)=>{let e=Number(r);return Number.isFinite(e)?e:t};function Sn(r){var n,s,o,a,i,l;typeof r=="string"&&/^\s*[{[]/.test(r)&&(r=JSON.parse(r));let t={size:0,lineHeight:0,base:0,pages:[],chars:[],kernings:[]},e=(c,u)=>{var f;c==="info"?t.size=Math.abs(Ae(u.size)):c==="common"?(t.lineHeight=Ae(u.lineHeight),t.base=Ae(u.base)):c==="page"?t.pages[Ae(u.id)]=String((f=u.file)!=null?f:""):c==="char"?t.chars.push({id:Ae(u.id),x:Ae(u.x),y:Ae(u.y),width:Ae(u.width),height:Ae(u.height),xoffset:Ae(u.xoffset),yoffset:Ae(u.yoffset),xadvance:Ae(u.xadvance),page:Ae(u.page)}):t.kernings.push({first:Ae(u.first),second:Ae(u.second),amount:Ae(u.amount)})};if(typeof r=="object"){let c=r;e("info",(n=c.info)!=null?n:{}),e("common",(s=c.common)!=null?s:{});for(let[u,f]of((o=c.pages)!=null?o:[]).entries())e("page",{id:u,file:f});for(let u of(a=c.chars)!=null?a:[])e("char",u);for(let u of(i=c.kernings)!=null?i:[])e("kerning",u)}else{let c=/(?:^|<)\s*(info|common|page|char|kerning)\s([^\n<>]*)/gm,u=/(\w+)=(?:"([^"]*)"|([^\s/>]+))/g;for(let f=c.exec(r);f;f=c.exec(r)){let h={};for(let b=u.exec(f[2]);b;b=u.exec(f[2]))h[b[1]]=(l=b[2])!=null?l:b[3];e(f[1],h)}}return t.size||(t.size=t.lineHeight),t}var An=class{constructor(t,e,n,s=null,o=null){p(this,"baker",s);p(this,"host",o);p(this,"size");p(this,"lineHeight");p(this,"base");p(this,"ascii",new Array(128));p(this,"more",new Map);p(this,"kern",new Map);p(this,"bScale",0);p(this,"bFontGen",-1);p(this,"bEffects",!1);p(this,"bGen",-1);this.size=t,this.lineHeight=e,this.base=n}set(t,e){t<128?this.ascii[t]=e:this.more.set(t,e)}setKerning(t,e,n){this.kern.set(t*1114112+e,n)}prepare(){let t=this.host;if(!(!t||t.pixelScale===this.bScale&&t.fontGen===this.bFontGen&&t.effects===this.bEffects&&t.atlas.gen===this.bGen)){this.bScale=t.pixelScale,this.bFontGen=t.fontGen,this.bEffects=t.effects,this.bGen=t.atlas.gen;for(let e of this.ascii)e&&t.atlas.release(e.frame);for(let e of this.more.values())e&&t.atlas.release(e.frame);this.ascii.fill(void 0),this.more.clear()}}glyph(t){let e=t<128?this.ascii[t]:this.more.get(t);return(e===void 0||e&&this.host&&!this.host.atlas.valid(e.frame))&&(e=this.baker?this.baker(t):null,this.set(t,e)),e}kerning(t,e){var n;return this.kern.size&&(n=this.kern.get(t*1114112+e))!=null?n:0}measure(t){return this.run(t)}run(t,e,n,s=0,o=0,a=1,i=1,l=0,c=1,u="normal"){this.prepare();let f=0,h=-1;for(let b=0;b<t.length;b++){let y=t.charCodeAt(b);y>=55296&&y<56320&&b+1<t.length&&(y=t.codePointAt(b),b++),h>=0&&(f+=this.kerning(h,y)),h=y;let x=this.glyph(y);x&&(e&&x.w>0&&x.h>0&&(jn(n,s+(f+x.x)*a,o+x.y*i),e.r.quad(e.tex(x.frame.surface),x.frame,ge,x.w*a,x.h*i,l,c,u)),f+=x.advance)}return f}};function Fa(r,t){let e=new An(r.size,r.lineHeight,r.base);for(let n of r.chars){let s=t[n.page];if(!s)continue;let o={surface:s,x:n.x,y:n.y,w:n.width,h:n.height,scale:1,gen:0,ox:0,oy:0,margin:0};e.set(n.id,{frame:o,x:n.xoffset,y:n.yoffset,w:n.width,h:n.height,advance:n.xadvance})}for(let n of r.kernings)e.setKerning(n.first,n.second,n.amount);return e}function Pa(r,t){var a,i;let e=M({},t),n=(a=t.size)!=null?a:40,s=l=>{let c=String.fromCodePoint(l),u=r.pixelScale,f=ds(e,r.effects),h=bs(c,f,u),b=r.atlas.bake((h+f.pad*2)*u,(f.th+f.pad*2)*u,y=>ms(y,c,f,u,f.pad,f.pad+f.th/2),u);return{frame:b,x:-f.pad,y:-f.pad,w:b.w/u,h:b.h/u,advance:h}},o=new An(n,n*1.25,n,s,r);o.prepare();for(let l of(i=t.chars)!=null?i:"0123456789")o.glyph(l.codePointAt(0));return o}var zl=.5;function ys(r){let t=[];for(let[e,n]of[["left",q.leftWrist],["right",q.rightWrist]]){let s=r[n*3],o=r[n*3+1],a=r[n*3+2];s!==void 0&&o!==void 0&&Number.isFinite(s)&&Number.isFinite(o)&&(a!=null?a:0)>=zl&&t.push({side:e,x:s,y:o})}return t}var Mn=r=>Bn[((r-1)%Bn.length+Bn.length)%Bn.length],Hl=["left","right"];function Ir(r,t,e,n,s=()=>null,o={}){var i,l;let a=[];for(let c of r){let u=(i=s(c))!=null?i:c.body;if(Array.isArray(u)){if(o.orientation==="portrait"){for(let f of Hl){let h=uo(u,f,{orientation:"portrait"});o.hold&&(h=o.hold.at(tn.key(c.id,f),h,(l=o.t)!=null?l:0)),h&&a.push({player:c.id,side:f,x:h.x*e,y:h.y*n,color:Mn(c.id)})}continue}for(let f of ys(u)){let h=t(f);a.push({player:c.id,side:f.side,x:h.x*e,y:h.y*n,color:Mn(c.id)})}}}return a}function Jn(r,t,e,n=0){let s=r.world,o=zo(s,t,e);if(!o)return!1;let a=Math.hypot(s[0],s[1])||1,i=Math.hypot(s[2],s[3])||1,[l,c]=o;if(r.hitRadius!=null){let y=r.hitRadius+n/((a+i)/2);return l*l+c*c<=y*y}let u=-r.anchorX*r.width-n/a,f=-r.anchorY*r.height-n/i,h=(1-r.anchorX)*r.width+n/a,b=(1-r.anchorY)*r.height+n/i;return l>=u&&l<=h&&c>=f&&c<=b}function Nr(r,t,e,n=0){for(let s of t)if((e===void 0||s.player===e)&&Jn(r,s.x,s.y,n))return s;return null}function $l(r){var t;switch(r.type){case"circle":case"ring":case"star":return[r.r*2,r.r*2];case"ellipse":return[r.rx*2,r.ry*2];case"roundRect":return[r.w,r.h];case"line":return[r.length,(t=r.lw)!=null?t:4];case"path":return r.r?[r.r*2,r.r*2]:[r.size,r.size]}}function Gl(r){var n,s,o;let t=r.type==="line"?0:r.stroke?((n=r.lw)!=null?n:2)/2:0,e=r.shadow?r.shadow.blur*1.5+Math.max(Math.abs((s=r.shadow.x)!=null?s:0),Math.abs((o=r.shadow.y)!=null?o:0)):0;return Math.ceil(t+e+1)}var _a=(r,t)=>t||!r.shadow?r:Ie(M({},r),{shadow:void 0});function xs(r,t,e){let n=Gl(t),s=t.type==="roundRect",[o,a]=s?[Math.min(t.w,t.r*2+4/e),Math.min(t.h,t.r*2+4/e)]:$l(t),i=(o+n*2)*e,l=(a+n*2)*e;return{frame:r.bake(i,l,u=>{u.scale(e,e),u.translate(n+o/2,n+a/2),Ul(u,t,o,a)},e,n+o/2,n+a/2,n),slice:s?Math.ceil((t.r+n)*e):0,w:s?t.w:o,h:s?t.h:a}}function Ul(r,t,e,n){var c,u,f,h,b,y,x;r.lineJoin="round",r.lineCap="round";let s=new Path2D;switch(t.type){case"circle":case"ring":s.arc(0,0,t.r,0,Math.PI*2);break;case"ellipse":s.ellipse(0,0,t.rx,t.ry,0,0,Math.PI*2);break;case"roundRect":s.roundRect(-e/2,-n/2,e,n,Math.min(t.r,e/2,n/2));break;case"star":{let d=(c=t.points)!=null?c:5,m=t.r*((u=t.inner)!=null?u:.5);for(let g=0;g<d*2;g++){let v=g%2?m:t.r,k=-Math.PI/2+g*Math.PI/d;g?s.lineTo(Math.cos(k)*v,Math.sin(k)*v):s.moveTo(Math.cos(k)*v,Math.sin(k)*v)}s.closePath();break}case"line":s.moveTo(-e/2+n/2,0),s.lineTo(e/2-n/2,0);break;case"path":{let d=t.r?t.r*2/t.size:1,m=new DOMMatrix([d,0,0,d,-t.size/2*d,-t.size/2*d]);s.addPath(new Path2D(t.d),m);break}}let o=t.shadow,a=()=>{var m,g;if(!o)return;let d=r.getTransform();r.shadowColor=o.color,r.shadowBlur=o.blur*d.a,r.shadowOffsetX=((m=o.x)!=null?m:0)*d.a,r.shadowOffsetY=((g=o.y)!=null?g:0)*d.a},i=()=>{r.shadowColor="transparent",r.shadowBlur=0};if(t.type==="line"){a(),r.strokeStyle=(h=(f=t.stroke)!=null?f:t.fill)!=null?h:"#fff",r.lineWidth=n,r.stroke(s);return}let l=t.type==="ring";if(t.outlineBelow&&t.fill&&t.stroke&&!l){a(),r.strokeStyle=t.stroke,r.lineWidth=(b=t.lw)!=null?b:2,r.stroke(s),i(),r.fillStyle=t.fill,r.fill(s);return}t.fill&&!l&&(a(),r.fillStyle=t.fill,r.fill(s),i()),(t.stroke||l)&&((!t.fill||l)&&a(),l&&t.fill&&(r.fillStyle=t.fill,r.fill(s)),r.strokeStyle=(y=t.stroke)!=null?y:"#fff",r.lineWidth=(x=t.lw)!=null?x:2,r.stroke(s),i())}var Tn=class{constructor(){p(this,"ctx",null);p(this,"master",null);p(this,"buffers",new Map);p(this,"held",!1);p(this,"muted",!1);p(this,"volume",1);if(typeof addEventListener=="function"){let t=()=>{var e;(e=this.context())==null?void 0:e.resume().catch(()=>{})};for(let e of["pointerdown","keydown","touchstart"])addEventListener(e,t,{once:!0,capture:!0})}}context(){var e;if(this.ctx)return this.ctx;let t=(e=$.AudioContext)!=null?e:$.webkitAudioContext;if(!t)return null;try{this.ctx=new t,this.master=this.ctx.createGain(),this.master.connect(this.ctx.destination),this.held&&this.ctx.suspend()}catch(n){return null}return this.ctx}load(t,e){return lt(this,null,function*(){let n=this.context();if(!n)return;let s=yield(yield fetch(e)).arrayBuffer();this.buffers.set(t,yield n.decodeAudioData(s))})}has(t){return this.buffers.has(t)}play(t,e={}){var i,l,c;let n=this.context(),s=this.buffers.get(t);if(!n||!s||!this.audible)return()=>{};let o=n.createBufferSource();o.buffer=s,o.loop=(i=e.loop)!=null?i:!1,o.playbackRate.value=(l=e.rate)!=null?l:1;let a=n.createGain();return a.gain.value=((c=e.volume)!=null?c:1)*this.volume,o.connect(a).connect(this.master),o.start(),()=>{try{o.stop()}catch(u){}}}tone(t,e=.25,n={}){var o,a;let s=this.context();if(!(!s||!this.audible))try{let i=s.createOscillator(),l=s.createGain();i.type=(o=n.type)!=null?o:"sine",i.frequency.setValueAtTime(t,s.currentTime),n.to&&i.frequency.exponentialRampToValueAtTime(n.to,s.currentTime+e),l.gain.setValueAtTime(((a=n.volume)!=null?a:.12)*this.volume,s.currentTime),l.gain.exponentialRampToValueAtTime(.001,s.currentTime+e),i.connect(l).connect(this.master),i.start(),i.stop(s.currentTime+e)}catch(i){}}get audible(){return!this.muted&&!this.held}hold(){var t;this.held=!0,(t=this.ctx)==null||t.suspend().catch(()=>{})}release(){var t;this.held=!1,(t=this.ctx)==null||t.resume().catch(()=>{})}destroy(){var t;(t=this.ctx)==null||t.close().catch(()=>{}),this.ctx=null}};var Vl={high:{resolution:1.5,particles:1,effects:!0,maxBlur:32},medium:{resolution:1,particles:.5,effects:!1,maxBlur:16},low:{resolution:.75,particles:.2,effects:!1,maxBlur:0}},at=["high","medium","low"];function mt(r){let t=Vl[r];return Ie(M({name:r},t),{scale:e=>e<=0?0:Math.max(1,Math.round(e*t.particles))})}var La=r=>at[Math.min(at.indexOf(r)+1,at.length-1)],Dr=(r,t)=>{if(!r.length)return NaN;let e=[...r].sort((n,s)=>n-s);return e[Math.min(e.length-1,Math.max(0,Math.floor(t*(e.length-1)+.5)))]},Oa=12,Ia=r=>er(r,.5);function er(r,t=.1){let e=Dr(r,t);if(!Number.isFinite(e))return 1e3/60;let n=[144,120,90,75,60,50,30],s=60;for(let o of n)Math.abs(1e3/o-e)<Math.abs(1e3/s-e)&&(s=o);return 1e3/s}function Br(r,t){let e=t.refresh!==void 0&&Number.isFinite(t.refresh)&&t.refresh>0?t.refresh:er(t.intervals),n=Dr(t.intervals,.5),s=Dr(t.intervals,.9),o=Dr(t.cpu,.5);if(!Number.isFinite(n))return r==="canvas2d"?"low":"medium";let a=l=>l<=e*1.25,i=l=>!Number.isFinite(o)||o<e*l;return r==="canvas2d"?a(s)&&i(.25)?"medium":"low":a(s)&&i(.5)?"high":a(n)?"medium":"low"}function Na(r,t){return r.length<30?!1:r.filter(n=>n>t*1.5).length/r.length>.5}var Da="0.1.1",Wl=720*3600*1e3,Ba=(r,t,e)=>"fabi-play.engine-tier:".concat(Da,":").concat(r,":").concat(t,":").concat(e),za=(r,t,e)=>"fablee-engine-tier:".concat(Da,":").concat(r,":").concat(t,":").concat(e);function Ha(r,t,e=Date.now()){var n;try{let s=JSON.parse((n=r==null?void 0:r.getItem(t))!=null?n:"null");if(s&&at.includes(s.tier)&&typeof s.at=="number"&&e-s.at<Wl)return typeof s.refresh=="number"&&s.refresh>0?{name:s.tier,refresh:s.refresh}:{name:s.tier}}catch(s){}return null}function gs(r,t,e,n,s=Date.now()){try{r==null||r.setItem(t,JSON.stringify(n!==void 0&&Number.isFinite(n)?{tier:e,at:s,refresh:n}:{tier:e,at:s}))}catch(o){}}function $a(r=typeof location!="undefined"?location.search:""){let t=new URLSearchParams(r).get("tier");return at.includes(t)?t:void 0}function ks(r,t){let e=t==null?void 0:t.tier;if(at.includes(e))return r==="canvas2d"&&e==="high"?"medium":e}var ws=r=>typeof(r==null?void 0:r.hz)=="number"&&r.hz>=20&&r.hz<=240?er([1e3/r.hz],.5):NaN,vs=(r,t)=>at.indexOf(r)>=at.indexOf(t)?r:t;function Ga(r,t,e){return r?{name:r,from:"forced"}:t?{name:e?vs(t,e):t,from:"hint"}:e?{name:e,from:"cache"}:null}var Xl=/^\s*(<|>|[^+\-<>=\s][^+=]*?)?\s*(?:([+-])=\s*(\d*\.?\d+))?\s*$/,En=class{constructor(t={}){p(this,"steps",[]);p(this,"labels",new Map);p(this,"end",0);p(this,"prevStart",0);p(this,"elapsed",0);p(this,"iter",0);p(this,"last",0);p(this,"delayLeft");p(this,"_paused");p(this,"done",!1);p(this,"rewinding",!1);p(this,"promise");p(this,"resolve");p(this,"repeat");p(this,"yoyo");p(this,"onComplete");var e,n;this.repeat=Math.floor((e=t.repeat)!=null?e:0),this.yoyo=!!t.yoyo,this.delayLeft=(n=t.delay)!=null?n:0,this._paused=!!t.paused,this.onComplete=t.onComplete,this.promise=new Promise(s=>this.resolve=s)}get duration(){return this.end}get time(){return this.last}get paused(){return this._paused}get finished(){return this.done}at(t){if(t===void 0)return this.end;if(typeof t=="number")return Math.max(t,0);let e=Xl.exec(t);if(!e)throw new Error('[engine] timeline: bad position "'.concat(t,'"'));let[,n,s,o]=e,a=o?(s==="-"?-1:1)*Number(o):0,i=this.end;if(n==="<")i=this.prevStart;else if(n&&n!==">"){let l=this.labels.get(n.trim());l===void 0?this.labels.set(n.trim(),this.end):i=l}return Math.max(i+a,0)}add(t){let e=this.steps.length;for(;e>0&&this.steps[e-1].start>t.start;)e--;return this.steps.splice(e,0,t),this.prevStart=t.start,this.end=Math.max(this.end,t.start+t.dur),this}to(t,e,n,s="quadOut"){var i,l;let o=typeof s=="object"?s:{ease:s},a=typeof o.ease=="function"?o.ease:At[(i=o.ease)!=null?i:"quadOut"];return this.add({target:t,to:e,from:null,fn:null,start:this.at(o.at)+((l=o.delay)!=null?l:0),dur:Math.max(n,0),ease:a,onUpdate:o.onUpdate,p:-1})}set(t,e,n){return this.add({target:t,to:e,from:null,fn:null,start:this.at(n),dur:0,ease:At.linear,p:-1})}call(t,e){return this.add({target:null,to:null,from:null,fn:t,start:this.at(e),dur:0,ease:At.linear,p:-1})}label(t,e){return this.labels.set(t,this.at(e)),this}wait(t){return this.end+=Math.max(t,0),this.prevStart=this.end,this}pause(){return this._paused=!0,this}resume(){return this._paused=!1,this}stop(){this.done||(this.done=!0,this.resolve())}seek(t){let e=Math.min(typeof t=="string"&&this.labels.has(t)?this.labels.get(t):this.at(t),this.end),n=this.yoyo&&this.iter%2===1;return this.elapsed=this.iter*this.end+(n?this.end-e:e),this.render(e),this}then(t,e){return this.promise.then(t,e)}update(t){if(this._paused||this.done)return;if(this.delayLeft>0){if(this.delayLeft-=t,this.delayLeft>0)return;t=-this.delayLeft,this.delayLeft=0}let e=this.end;if(e<=0)return this.render(0),this.complete();this.elapsed+=t;let n=this.repeat<0?1/0:e*(this.repeat+1),s=Math.min(this.elapsed,n),o=s>=n?this.repeat:Math.floor(s/e);for(;this.iter<o;){let i=this.yoyo&&this.iter%2===1;this.render(i?0:e),this.iter++,this.yoyo||(this.rewinding=!0,this.render(0),this.rewinding=!1)}let a=s-o*e;this.render(this.yoyo&&o%2===1?e-a:a),s>=n&&this.complete()}complete(){var t;this.done||(this.done=!0,(t=this.onComplete)==null||t.call(this),this.resolve())}render(t){let e=this.steps;if(t>=this.last)for(let n=0;n<e.length;n++){let s=e[n];t>=s.start&&this.apply(s,t)}else for(let n=e.length-1;n>=0;n--){let s=e[n];s.p>=0&&this.apply(s,t)}this.last=t}apply(t,e){var i,l;let n=t.dur>0?Math.min(Math.max((e-t.start)/t.dur,0),1):e>t.start||e===t.start&&!this.rewinding?1:0;if(n===t.p)return;if(t.p=n,t.fn){this.rewinding||t.fn();return}let s=t.target;if(s.destroyed||s._free)return;let o=t.to;if(!t.from){t.from={};for(let c in o)t.from[c]=Number((i=s[c])!=null?i:0)}let a=t.ease(n);for(let c in o)s[c]=t.from[c]+(o[c]-t.from[c])*a;(l=t.onUpdate)==null||l.call(t,a)}};var Rn=class{constructor(){p(this,"list",[]);p(this,"timelines",[])}timeline(t){let e=new En(t);return this.timelines.push(e),e}tween(t,e,n,s="quadOut"){var c;let o=typeof s=="object"?s:{ease:s},a=typeof o.ease=="function"?o.ease:At[(c=o.ease)!=null?c:"quadOut"],i,l=new Promise(u=>{var b;let f=Object.keys(e),h=new Float64Array(f.length);f.forEach((y,x)=>h[x]=Number(e[y])),i={target:t,keys:f,to:h,from:new Float64Array(f.length),started:!1,duration:Math.max(n,0),time:0,delay:(b=o.delay)!=null?b:0,ease:a,onUpdate:o.onUpdate,done:u,dead:!1}});return this.list.push(i),Object.assign(l,{stop:()=>this.finish(i)})}stopAll(t){let e=this.list;for(let n=0;n<e.length;n++)e[n].target===t&&this.finish(e[n])}get size(){return this.list.length}update(t){if(this.timelines.length){let s=0,o=this.timelines;for(let a=0;a<o.length;a++){let i=o[a];i.update(t),i.finished||(o[s++]=i)}o.length=s}let e=this.list;if(!e.length)return;let n=0;for(let s=0;s<e.length;s++){let o=e[s];o.dead||this.step(o,t),o.dead||(e[n++]=o)}n!==e.length&&(e.length=n)}step(t,e){var i,l;if(t.target.destroyed)return this.finish(t);let n=e;if(t.delay>0){if(t.delay-=e,t.delay>0)return;n=-t.delay}let s=t.keys;if(!t.started){t.started=!0;for(let c=0;c<s.length;c++)t.from[c]=Number((i=t.target[s[c]])!=null?i:0)}t.time+=n;let o=t.duration>0?Math.min(t.time/t.duration,1):1,a=t.ease(o);for(let c=0;c<s.length;c++)t.target[s[c]]=t.from[c]+(t.to[c]-t.from[c])*a;(l=t.onUpdate)==null||l.call(t,a),o>=1&&this.finish(t)}finish(t){t.dead||(t.dead=!0,t.done())}clear(){for(let t of this.list)this.finish(t);this.list.length=0;for(let t of this.timelines)t.stop();this.timelines=[]}};var Se=720,tr=class extends We{constructor(e,n){super(e);p(this,"paintAll",n)}draw(e,n){this.paintAll(e,n)}},Ss=class extends We{constructor(e,n){super(e);p(this,"paintAll",n)}draw(e,n){this.paintAll(e,n)}},bt=()=>performance.now(),Ua=r=>{let t=fo(r);return t&&Object.freeze(t)};function Wa(){return lt(this,arguments,function*(r={}){var qs,Ys,Ks,Qs,Zs,Js,eo,to,no,cr,ro;let t=(qs=r.play)!=null?qs:null,e=(Ys=r.canvas)!=null?Ys:null;e||(e=document.createElement("canvas"),e.style.cssText="position:fixed;top:0;left:0;width:100%;height:100%;display:block;touch-action:none",document.body.appendChild(e));let n=gn(e,{renderer:(Ks=r.renderer)!=null?Ks:Ta(),failIfMajorPerformanceCaveat:r.failIfMajorPerformanceCaveat,instancing:r.instancing});e=n.canvas;let s=new Set,o=new Mt(Math.min(2048,n.maxTextureSize),4);o.onPage=w=>s.add(w),o.onDrop=w=>{s.delete(w),w.texture&&n.destroyTexture(w.texture),w.texture=null};let a=Zn(n),i=new Rn,l=new Tn,c=new Wt(o),u=new Map,f=new Map,h=new Map,b=new Map,y=new Map,x=new Set,d=0,m=(Qs=r.tier)!=null?Qs:$a(),g=String((Zs=n.info.renderer)!=null?Zs:""),v=(()=>{var w;try{return(w=$.localStorage)!=null?w:null}catch(T){return null}})(),k=typeof screen!="undefined"?"".concat(screen.width,"x").concat(screen.height):"",R=Ba(n.kind,g,k);po(v,R,za(n.kind,g,k));let F=Ha(v,R),I=Ga(m,ks(n.kind,t==null?void 0:t.device),F==null?void 0:F.name),A=(Js=I==null?void 0:I.name)!=null?Js:"medium",S=mt(A);c.setTier(A);let P=(I==null?void 0:I.from)==="hint",H=F==null?void 0:F.name,z=(eo=F==null?void 0:F.refresh)!=null?eo:ws(t==null?void 0:t.device),B=1,G=1,L=1,U={atlas:o,get pixelScale(){return B},get fontGen(){return d},get effects(){return S.effects},tweens:i,frame:w=>lr.frame(w),shape:w=>{let T=S.effects,O=T?B:-B,E=u.get(O);E||(u.size>=8&&u.clear(),u.set(O,E=new mn(2e3)));let X=Ze(w),j=E.get(w,X);return(!j||!o.valid(j.frame))&&E.set(w,j=xs(o,_a(w,T),B),X),j},bitmapFont:w=>lr.bitmapFont(w)},Y=1280,Q=null;class Ee extends Vt{get width(){return Y}set width(T){}get height(){return Se}set height(T){}get safe(){let T=Math.min(Y,Se*16/9);return{x:(Y-T)/2,y:0,w:T,h:Se}}}let ue=new Ee(U),ke=()=>{var X;let w=n.canvas,T=w.getBoundingClientRect();G=Math.max(1,T.width||w.clientWidth||innerWidth),L=Math.max(1,T.height||w.clientHeight||innerHeight),Y=Se*G/L;let O=Math.min($.devicePixelRatio||1,(X=r.maxPixelRatio)!=null?X:2);if(L*O/Se<=S.resolution){let j=Math.max(1,Math.round(L*O));B=j/Se,n.resize(Math.max(1,Math.round(G*O)),j)}else B=S.resolution,n.resize(Math.round(Y*B),Math.round(Se*B));Q&&Q.style.setProperty("--unit","".concat(L/Se,"px"))};addEventListener("resize",ke);let we=w=>{A=w,S=mt(w),c.setTier(w),ke()},oe=typeof ResizeObserver!="undefined"?new ResizeObserver(ke):null;oe==null||oe.observe(e);let Re=(t==null?void 0:t.backdrop)==="video"?"video":"none",he=(to=t==null?void 0:t.view)!=null?to:null,Ct=(t==null?void 0:t.orientation)==="portrait"?"portrait":"landscape",Cn=(no=Ua(t==null?void 0:t.safeArea))!=null?no:ho,Fn=[],Pn=-1/0,Ft=!1,xt=!1,qt=new Set,_n=()=>{let w=Re==="video"?"transparent":"";document.documentElement.style.background=w,document.body.style.background=w},Ln=(w,T)=>{let O=w==="video"?"video":"none",E=T!=null?T:null;if(!(O===Re&&(E===he||E&&he&&E.x===he.x&&E.y===he.y&&E.w===he.w&&E.h===he.h))){Re=O,he=E,_n();for(let X of[...qt])X(Re,he)}},On=[];if(t){let w=E=>{Array.isArray(E)&&(Fn=E,Pn=bt())},T=E=>{Ft=E,Pt()},O=E=>{if(m||P)return;Number.isFinite(z)||(z=ws(E));let X=ks(n.kind,E);X&&(P=!0,we(H?vs(X,H):X))};On.push(t.on("start",E=>O(E==null?void 0:E.device)),t.on("start",E=>{((E==null?void 0:E.orientation)==="portrait"||(E==null?void 0:E.orientation)==="landscape")&&(Ct=E.orientation);let X=Ua(E==null?void 0:E.safeArea);X&&(Cn=X)}),t.on("start",E=>{typeof(E==null?void 0:E.muted)=="boolean"&&(l.muted=E.muted)}),t.on("frame",E=>w(E==null?void 0:E.players)),t.on("players",E=>w(E==null?void 0:E.players)),t.on("backdrop",E=>Ln(E==null?void 0:E.backdrop,E==null?void 0:E.view)),t.on("start",E=>{var X;return Ln(E==null?void 0:E.backdrop,(X=E==null?void 0:E.view)!=null?X:t.view)}),t.on("pause",()=>T(!0)),t.on("resume",()=>T(!1)),t.on("break-start",()=>T(!0)),t.on("break-done",()=>T(!1)),t.on("break-end",()=>T(!1))),l.muted=t.muted===!0}_n();let Pt=()=>Ft||xt||document.hidden?l.hold():l.release(),In=-1,Yt=[],Kt=0,Qt=()=>bt()-Pn<1e3?Fn:[],rr=w=>t?t.toScreen(w):Wr(he,w),sr=new tn,_t=()=>{if(In===Kt)return Yt;In=Kt;let w=Ct==="portrait",T=Re==="video"&&!w||!(t!=null&&t.smoothedBody)?()=>null:O=>t.smoothedBody(O);return Yt=Ir(Qt(),rr,Y,Se,T,w?{orientation:Ct,hold:sr,t:bt()}:void 0),Yt},gt={x:0,y:0,w:1,h:1},or=()=>(gt.x=he?he.x*Y:0,gt.y=he?he.y*Se:0,gt.w=he?he.w*Y:Y,gt.h=he?he.h*Se:Se,gt),ar=w=>{var X;let T=(X=w.alpha)!=null?X:1,O=w.tags?new Rt(o,w):null;O&&x.add(O);let E=typeof w.tags=="function"?w.tags:j=>String(j);return(j,Fe)=>{var fe,Me,It,kt,te,ee;if(Re==="video")return;let ye=or();for(let ne of Qt()){let re=(Me=(fe=t==null?void 0:t.smoothedBody)==null?void 0:fe.call(t,ne))!=null?Me:ne.body,Pe=(ee=an((te=(kt=(It=t==null?void 0:t.avatarOf)==null?void 0:It.call(t,ne))!=null?kt:ne.avatar)!=null?te:""))!=null?ee:Ht;if(!c.draw(j.r,j.tex,re,Pe,ye,T*Fe,B)||!O)continue;let Nt=E(ne.id);Nt&&O.draw(j.r,j.tex,re,Pe,ye,Nt,Mn(ne.id),T*Fe,B,Y,Se)}}},Zt=new Set,C=new Set,N=new Set,V=!1,J=0,K=0,be=0,je={fps:0,cpuMs:0,drawCalls:0,quads:0,filtersSkipped:0},Oe=0,Jt=0,Ce=bt(),Ge=[],et=0,Ue=()=>({r:n,kernel:U,tex:a}),qe=Ue(),Lt=()=>{if(n.lost)return;let[w,T]=Re==="video"||r.background===void 0?[0,0]:Te(r.background);n.time=be,n.maxBlur=S.maxBlur,n.begin(w,T,B),De(ue.world,null,ue.x,ue.y,ue.rotation,ue.scaleX,ue.scaleY),ss(qe,ue,ue.alpha,ue.tint);let O=n.end();je.drawCalls=O.drawCalls,je.quads=O.quads,je.filtersSkipped=O.filtersSkipped},Ye=w=>{var X;if(!V)return;J=requestAnimationFrame(Ye);let T=Math.min(Math.max((w-K)/1e3,0),.1);K&&Ge.push(w-K),K=w,Kt++;let O=bt(),E=Ft||xt;if(!E){be+=T,i.update(T);for(let j of N)j.destroyed||j.update(T);for(let j of Zt)j(T,be)}for(let j of C)j(T);ue.sweep();for(let j of N)j.destroyed&&N.delete(j);if(n.lost?(et||(et=w),w-et>3e3&&Ot()):(et=0,Lt()),Oe++,Jt+=bt()-O,O-Ce>=1e3&&(je.fps=Math.round(Oe*1e3/(O-Ce)),je.cpuMs=Math.round(Jt/Math.max(Oe,1)*100)/100,(X=t==null?void 0:t.reportStats)==null||X.call(t,{fps:je.fps,renderer:n.kind,tier:A}),Oe=0,Jt=0,Ce=O),Ge.length>=180){let j=Number.isFinite(z)?z:er(Ge);!m&&!E&&Na(Ge,j)&&A!=="low"&&(we(La(A)),H=A,gs(v,R,A,Number.isFinite(z)?z:void 0),console.info("[engine] slow frames: tier ".concat(A))),Ge.length=0}},Ot=()=>{let w=Qn(n.canvas),T=yn(w);if(T){console.warn("[engine] WebGL context lost for good: switching to Canvas 2D"),n.destroy(),n=T;for(let O of s)O.texture=null;for(let O of o.pages)s.add(O.surface);a=Zn(n),qe=Ue(),oe==null||oe.disconnect(),oe==null||oe.observe(w),ke()}},ir=()=>{Pt(),document.hidden||(K=0)};document.addEventListener("visibilitychange",ir);let Nn=()=>{d++;for(let w of x)w.drop()};if((ro=(cr=document.fonts)==null?void 0:cr.addEventListener)==null||ro.call(cr,"loadingdone",Nn),ke(),!I&&r.probe!==!1&&(Number.isFinite(z)||(z=Ia(yield jl(Oa))),!P)){S=mt("high"),ke();let w=yield ql(n,o,()=>a,()=>B,Y,()=>P);if(w.refresh=z,!P){let T=Br(n.kind,w);gs(v,R,T,z),H=T,we(T)}}let lr={stage:ue,get tier(){return S},get renderer(){return n},get canvas(){return n.canvas},get pixelScale(){return B},get backdrop(){return Re},get view(){return he},get orientation(){return Ct},get safeArea(){return Cn},get paused(){return Ft||xt},sound:l,stats:je,get time(){return be},get supports(){let w=n.support;return{filters:w.filters,blur:w.filters&&S.maxBlur>0,shaders:w.shaders,maxBlur:w.filters?S.maxBlur:0,tiers:{high:{maxBlur:mt("high").maxBlur},medium:{maxBlur:mt("medium").maxBlur},low:{maxBlur:mt("low").maxBlur}}}},sprite:(w,T)=>new ze(U,w,T),shape:(w,T)=>new nt(U,w,T),text:(w,T)=>new ot(U,w,T),group:w=>new Vt(U).set(w!=null?w:{}),particles(w,T={}){let O=typeof w=="object"&&"type"in w?U.shape(w).frame:w,E=new hn(U,O,T),Me=T,{max:X,blend:j,gravity:Fe,drag:ye}=Me,fe=en(Me,["max","blend","gravity","drag"]);return E.set(fe),N.add(E),E},tween:(w,T,O,E)=>i.tween(w,T,O,E),bake(w,T,O,E,X){return h.set(w,{w:T,h:O,draw:E,origin:X}),f.delete(w),lr.frame(w)},frame(w){var E,X,j,Fe;let T=f.get(w);if(T&&o.valid(T)&&(T.gen===0||T.scale===B))return T;let O=h.get(w);if(O){let ye=B,fe=o.bake(O.w*ye,O.h*ye,Me=>(Me.scale(ye,ye),O.draw(Me)),ye,(X=(E=O.origin)==null?void 0:E.x)!=null?X:0,(Fe=(j=O.origin)==null?void 0:j.y)!=null?Fe:0);return f.set(w,fe),fe}if(T)return T;throw new Error('[engine] no frame "'.concat(w,'": load it or bake it first'))},load(w){return lt(this,null,function*(){yield Promise.all(Object.entries(w).map(([T,O])=>di(T,O)))})},hands:w=>w===void 0?_t():_t().filter(T=>T.player===w),touched(w,T,O={}){var E;return w.updateWorld(),Nr(w,_t(),T,(E=O.padding)!=null?E:0)},hits(w,T,O,E=0){return w.updateWorld(),Jn(w,T,O,E)},avatars:(w={})=>new tr(U,ar(w)),handMarkers(w={}){var kt,te;let T=(kt=w.radius)!=null?kt:36,O=(te=w.look)!=null?te:"auto",E=new Float64Array(6),X=Math.max(T*.12,3),j={type:"ring",r:T,lw:X,fill:"rgba(251,231,184,0.3)",stroke:"#ffffff"},Fe={type:"ring",r:T,lw:X*1.8,stroke:Xt,shadow:{color:Xt,blur:T*.2}},ye=(ee,ne,re,Pe,Nt,Dt)=>{let ur=ne.w/ne.scale;De(E,null,re-ur/2,Pe-ur/2,0,1,1),ee.r.quad(ee.tex(ne.surface),ne,E,ur,ur,Nt,Dt,"normal")},fe=ee=>{let ne=null,re=!1;return()=>(ne&&o.valid(ne.frame)&&ne.frame.scale===B&&re===S.effects?ne:(re=S.effects,ne=U.shape(ee))).frame},Me=fe(j),It=fe(Fe);return new Ss(U,(ee,ne)=>{let re=O==="video"||O==="auto"&&Re==="video",Pe=Me(),Nt=re?It():null;for(let Dt of _t())Nt&&ye(ee,Nt,Dt.x,Dt.y,16777215,ne),ye(ee,Pe,Dt.x,Dt.y,Te(Dt.color)[0],ne)})},timeline:w=>i.timeline(w),animation(w,T){let O=typeof w=="string"?pi(w):{frames:w},E=new Xe(U,O,T);return N.add(E),E},bitmapFont(w,T){if(!T){let E=b.get(w);if(!E)throw new Error('[engine] no bitmap font "'.concat(w,'": load or make it first'));return E}let O="data"in T?Xs(Sn(T.data),T.pages):Pa(U,T);return b.set(w,O),O},players:()=>Qt(),onFrame(w){return Zt.add(w),()=>{Zt.delete(w)}},onRender(w){return C.add(w),()=>{C.delete(w)}},onBackdrop(w){return qt.add(w),()=>{qt.delete(w)}},get hud(){return Q||(Q=document.createElement("div"),Q.style.cssText="position:fixed;top:0;right:0;bottom:0;left:0;pointer-events:none;overflow:hidden",document.body.appendChild(Q),ke()),Q},random:(w=0,T=1)=>w+Math.random()*(T-w),start(){V||(V=!0,K=0,J=requestAnimationFrame(Ye))},pause(){xt=!0,Pt()},resume(){xt=!1,Pt()},destroy(){var w,T;V=!1,cancelAnimationFrame(J),On.forEach(O=>O()),removeEventListener("resize",ke),oe==null||oe.disconnect(),document.removeEventListener("visibilitychange",ir),(T=(w=document.fonts)==null?void 0:w.removeEventListener)==null||T.call(w,"loadingdone",Nn),i.clear(),Jo(U),l.destroy(),n.destroy(),Q==null||Q.remove()}};function pi(w){let T=y.get(w);if(T)return T;let O=[...new Set([...f.keys(),...h.keys()])].filter(E=>E.startsWith(w)).sort(ta);if(!O.length)throw new Error('[engine] no animation or frames "'.concat(w,'\u2026"'));return{frames:O}}function di(w,T){return lt(this,null,function*(){var Fe,ye;let O=T.split("?")[0].split(".").pop().toLowerCase();if(["mp3","ogg","wav","m4a","aac","webm"].includes(O))return l.load(w,T);if(["woff","woff2","ttf","otf"].includes(O)){let fe=new FontFace(w,"url(".concat(T,")"));document.fonts.add(yield fe.load()),d++;return}let E=new URL(T,location.href);if(O==="fnt")return js(w,Sn(yield(yield fetch(T)).text()),E);if(O==="json"){let fe=yield(yield fetch(T)).json();if(Array.isArray(fe.chars)&&!fe.frames)return js(w,Sn(fe),E);let Me=yield As(new URL((ye=(Fe=fe.meta)==null?void 0:Fe.image)!=null?ye:T.replace(/\.json$/,".png"),E).href);mi(w,fe,fn(Me));return}let X=yield As(T),j=fn(X);s.add(j),f.set(w,{surface:j,x:0,y:0,w:X.width,h:X.height,scale:1,gen:0,ox:0,oy:0,margin:0})})}function Xs(w,T){return Fa(w,T.map(O=>{let E=fn(O);return s.add(E),E}))}function js(w,T,O){return lt(this,null,function*(){b.set(w,Xs(T,yield Promise.all(T.pages.map(E=>As(new URL(E,O).href)))))})}function mi(w,T,O){var Fe,ye,fe,Me,It,kt;s.add(O);let E=Array.isArray(T.frames)?T.frames:Object.entries(T.frames).map(([te,ee])=>Ie(M({},ee),{filename:te})),X=[],j=[];for(let te of E){let ee=te.frame,ne=te.filename.replace(Va,"");te.rotated&&console.warn("[engine] ".concat(w,"/").concat(ne," is rotated: export without rotation"));let re={surface:O,x:ee.x,y:ee.y,w:ee.w,h:ee.h,scale:1,gen:0,ox:0,oy:0,margin:0};te.trimmed&&te.sourceSize&&te.spriteSourceSize&&(re.sw=te.sourceSize.w,re.sh=te.sourceSize.h,re.tx=te.spriteSourceSize.x,re.ty=te.spriteSourceSize.y);let Pe=te.scale9Borders;Pe&&(re.slice=[Pe.y,((Fe=re.sw)!=null?Fe:ee.w)-Pe.x-Pe.w,((ye=re.sh)!=null?ye:ee.h)-Pe.y-Pe.h,Pe.x]),f.set("".concat(w,"/").concat(ne),re),X.push("".concat(w,"/").concat(ne)),j.push(((fe=te.duration)!=null?fe:0)/1e3)}for(let[te,ee]of Object.entries((Me=T.animations)!=null?Me:{}))y.set("".concat(w,"/").concat(te),{frames:ee.map(ne=>"".concat(w,"/").concat(ne.replace(Va,"")))});for(let te of(kt=(It=T.meta)==null?void 0:It.frameTags)!=null?kt:[]){let ee=[];for(let re=te.from;re<=te.to;re++)ee.push(re);te.direction==="reverse"&&ee.reverse(),te.direction==="pingpong"&&ee.push(...ee.slice(1,-1).reverse());let ne=ee.every(re=>j[re]>0);y.set("".concat(w,"/").concat(te.name),M({frames:ee.map(re=>X[re])},ne?{durations:ee.map(re=>j[re])}:{}))}}return lr})}var Va=/\.(png|webp|jpe?g|gif|bmp)$/i;function As(r){return new Promise((t,e)=>{let n=new Image;n.onload=()=>t(n),n.onerror=()=>e(new Error("[engine] image did not load: ".concat(r))),n.src=r})}function jl(r){return new Promise(t=>{let e=[],n=0,s=o=>{n&&e.push(o-n),n=o,e.length<r?requestAnimationFrame(s):t(e)};requestAnimationFrame(s)})}function ql(r,t,e,n,s,o=()=>!1){return lt(this,null,function*(){let a=n(),i=xs(t,{type:"star",r:30,fill:"#ffd23f",stroke:"#3a2a10",lw:3},a).frame,l=[],c=[],u=new Float64Array(6),f=.004,h=r.kind==="canvas2d"?r.canvas.getContext("2d"):null,b=bt(),y=0;return yield new Promise(x=>{let d=m=>{y&&m-b>250&&l.push(m-y),y=m;let g=bt();r.begin(0,0,a);let v=e();for(let k=0;k<300;k++){let R=m/1e3+k;De(u,null,k*37%s,k*53%Se,R,1,1),r.quad(v(i.surface),i,u,i.w/a,i.h/a,16777215,f,"normal")}for(let k=0;k<40;k++)r.ellipse(100+k*20,300,20,14,k,16746496,f),r.stroke([100+k*20,400,120+k*20,460,100+k*20,520],3,18,3368703,f,!1);r.end(),h==null||h.getImageData(0,0,1,1),m-b>250&&c.push(bt()-g),m-b<750&&!o()?requestAnimationFrame(d):(r.begin(0,0,a),r.end(),x())};requestAnimationFrame(d)}),{intervals:l,cpu:c}})}var Yl=64,Xa=32,Kl=0,Ql="fabi-cm-".concat(Math.random().toString(36).slice(2,7),"-"),ja=new Set,qa=(r,t)=>{ja.has(r)||(ja.add(r),console.warn(t))},Ya=r=>new Ms(r),Ms=class{constructor(t){p(this,"r",t);p(this,"css","none");p(this,"plans",new mn(Yl));p(this,"buf",new Float64Array(64));p(this,"keys",[]);p(this,"classes",new Map);p(this,"live",new Set);p(this,"svgs",new Map);p(this,"t",0);p(this,"cur",null);p(this,"svgFn",t=>this.svg(t));p(this,"scr",[]);p(this,"flip",0)}chain(t,e){var y,x;let n=this.r,s=this.buf;s[0]=n.scale,s[1]=n.maxBlur;let o=2;for(let d=0;d<e.length;d++){let m=e[d];if(o+22>s.length){let v=new Float64Array(s.length*2);v.set(s),s=this.buf=v}let g=this.classes.get(m.constructor);g===void 0&&this.classes.set(m.constructor,g=this.classes.size),s[o++]=g,s[o++]=m.enabled?1:0,m.params&&(o=m.params(s,o))}let a=(x=(y=this.keys)[o])!=null?x:y[o]=new Float64Array(o);for(let d=0;d<o;d++)a[d]=s[d];let i=Ze(a),l=this.plans.get(a,i);l||this.plans.set(a,l=this.plan(e),i);for(let d=0;d<l.svgs.length;d++){let m=l.svgs[d];m.used<0&&this.attach(m),m.used=this.t}n.skipped+=l.skip;let c=t,u=n.rx0,f=n.ry0,h=n.rx1-u,b=n.ry1-f;for(let d=0;d<l.paints.length;d++)l.parts[d]&&(c=this.bake(c,l.parts[d])),e[l.paints[d]].paint2d(c.getContext("2d"),u,f,h,b);return this.css=l.parts[l.paints.length]||"none",c}tick(){let t=++this.t;if(!(t%Xa||!this.live.size))for(let e of this.live)t-e.used>Xa&&this.detach(e)}destroy(){for(let t of this.live)this.detach(t);this.plans.clear()}svg(t){if(typeof document=="undefined"||!document.body)return null;let e=Array.from({length:20},(s,o)=>{var a;return(a=t[o])!=null?a:0}).join(" "),n=this.svgs.get(e);if(!n){let s="http://www.w3.org/2000/svg",o=document.createElementNS(s,"svg");o.setAttribute("width","0"),o.setAttribute("height","0"),o.setAttribute("aria-hidden","true"),o.style.position="absolute";let a=document.createElementNS(s,"filter"),i=Ql+ ++Kl;a.setAttribute("id",i),a.setAttribute("color-interpolation-filters","sRGB");let l=document.createElementNS(s,"feColorMatrix");l.setAttribute("type","matrix"),l.setAttribute("values",e),a.append(l),o.append(a),this.attach(n={key:e,id:i,el:o,used:this.t})}return this.cur.svgs.push(n),"url(#".concat(n.id,")")}attach(t){document.body.append(t.el),this.live.add(t),this.svgs.has(t.key)||this.svgs.set(t.key,t)}detach(t){t.el.remove(),t.used=-1,this.live.delete(t),this.svgs.get(t.key)===t&&this.svgs.delete(t.key)}plan(t){let e=this.r,n=this.cur={parts:[],paints:[],skip:0,svgs:[]},s="";for(let o=0;o<t.length;o++){let a=t[o];if(!a.enabled)continue;if(a.kind===4){n.skip++,qa("shader","[engine] shader() filters are WebGL only: on Canvas 2D they are skipped (check engine.supports.shaders)");continue}let i=e.support.filters&&a.css?a.css(e.scale,e.maxBlur,this.svgFn):null;i!==null?s+=s?" ".concat(i):i:a.paint2d?(n.parts.push(s),n.paints.push(o),s=""):(n.skip++,qa("css","[engine] this browser's Canvas 2D has no ctx.filter: colour filters, blur and shadows are skipped (tint works; check engine.supports.filters)"))}return n.parts.push(s),n}bake(t,e){let n=this.r,s=this.flip^=1,o=this.scr[s];(!o||o.width!==n.canvas.width||o.height!==n.canvas.height)&&(o=this.scr[s]=document.createElement("canvas"),o.width=n.canvas.width,o.height=n.canvas.height);let a=o.getContext("2d"),i=n.rx0,l=n.ry0,c=n.rx1-i,u=n.ry1-l;return a.clearRect(i,l,c,u),a.filter=e,a.drawImage(t,i,l,c,u,i,l,c,u),a.filter="none",o}};var Zl=64,zr=17,Jl=r=>"".concat(_r,"\nuniform sampler2D uTexture;\nuniform mat4 uM[").concat(r,"];\nuniform vec4 uO[").concat(r,"];\nuniform int uK;\nvarying vec2 vUv;\nvarying vec4 vColor;\nvoid main() {\n vec4 c = texture2D(uTexture, vUv);\n if (c.a > 0.0) c.rgb /= c.a;\n for (int i = 0; i < ").concat(r,"; i++) {\n if (i >= uK) break;\n c = clamp(uM[i] * c + uO[i], 0.0, 1.0);\n }\n c.rgb *= c.a;\n gl_FragColor = c * vColor;\n}"),ec=()=>"".concat(_r,"\nuniform sampler2D uTexture;\nuniform vec2 uDir;\nuniform vec2 uOff;\nuniform vec2 uTaps[").concat(zr,"];\nuniform int uN;\nuniform float uMode;\nuniform vec4 uShadow;\nvarying vec2 vUv;\nvarying vec4 vColor;\nvoid main() {\n vec2 p = vUv + uOff;\n vec4 c = texture2D(uTexture, p) * uTaps[0].y;\n for (int i = 1; i < ").concat(zr,"; i++) {\n if (i >= uN) break;\n vec2 d = uDir * uTaps[i].x;\n c += (texture2D(uTexture, p + d) + texture2D(uTexture, p - d)) * uTaps[i].y;\n }\n if (uMode > 0.5) c = uShadow * c.a;\n gl_FragColor = c * vColor;\n}");function tc(r,t,e=new Float32Array(20)){for(let n=0;n<4;n++)for(let s=0;s<5;s++){let o=s===4?t[n*5+4]:0;for(let a=0;a<4;a++)o+=t[n*5+a]*r[a*5+s];e[n*5+s]=o}return r.set(e),r}var Ka=r=>new Cs(r),Cs=class{constructor(t){p(this,"r",t);p(this,"colorProg",null);p(this,"blurProg",null);p(this,"user",new Map);p(this,"uses",0);p(this,"userErr",new Map);p(this,"scratchT",new Map);p(this,"steps",[]);p(this,"mats",[]);p(this,"counts",[]);p(this,"colorN");p(this,"fm",new Float32Array(20));p(this,"fm2",new Float32Array(20));p(this,"fm3",new Float32Array(20));p(this,"m16");p(this,"o4");p(this,"taps",new Float32Array(zr*2));let e=t.gl;this.colorN=Math.max(1,Math.min(8,Math.floor((e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS)-4)/5))),this.m16=new Float32Array(16*this.colorN),this.o4=new Float32Array(4*this.colorN)}check(t){var e;return this.r.lost?null:(this.userProg(t,!1),(e=this.userErr.get(t))!=null?e:null)}destroy(){let t=this.r.gl;for(let e of this.scratchT.values())t.deleteTexture(e.gl),t.deleteFramebuffer(e.fb);this.scratchT.clear();for(let e of[this.colorProg,this.blurProg])e&&t.deleteProgram(e.p);for(let e of this.user.values())e.p&&t.deleteProgram(e.p.p);this.user.clear()}userProg(t,e){let n=this.user,s=n.get(t);if(s)return s.t=++this.uses,s.p;if(this.r.lost)return null;if(n.size>=Zl){let a="",i=1/0;for(let[c,u]of n)u.t<i&&(i=u.t,a=c);let l=n.get(a).p;l&&this.r.gl.deleteProgram(l.p),n.delete(a),this.userErr.delete(a)}let o;try{o=this.r.build(t)}catch(a){o=null;let i=a.message;this.userErr.set(t,i),e&&console.error("[engine] a shader filter does not compile: it is skipped.\n".concat(i))}return n.set(t,{p:o,t:++this.uses}),o}scratch(t,e){var l;let n=this.r,s=Math.ceil(n.canvas.width/t),o=Math.ceil(n.canvas.height/t),a=t*8+e,i=(l=this.scratchT.get(a))!=null?l:null;return i&&(i.w!==s||i.h!==o)&&(n.drop(i),i=null),i||(i=n.target(s,o,t,!0),i?this.scratchT.set(a,i):this.scratchT.delete(a)),i}pass(t,e,n,s,o=!1){let a=this.r,i=a.gl;a.flush(),a.mapped=!1,a.bindFb(s),i.viewport(0,0,s.w,s.h),o||(i.disable(i.SCISSOR_TEST),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT)),a.use(t);let l=s.f;i.uniform2f(t.uScale,2/(l*s.w),-2/(l*s.h));let c=Math.floor(a.rx0/l)*l,u=Math.floor(a.ry0/l)*l,f=Math.min(Math.ceil(a.rx1/l),s.w)*l,h=Math.min(Math.ceil(a.ry1/l),s.h)*l,b=1/(n*e.width),y=1/(n*e.height);a.bScis=!1,a.batch.push(c,u,f,u,f,h,c,h,c*b,1-u*y,f*b,1-h*y,4294967295,a.slotOf(e)),a.flush()}post(t){var e,n;return t==="color"?(e=this.colorProg)!=null?e:this.colorProg=this.r.build(Jl(this.colorN)):(n=this.blurProg)!=null?n:this.blurProg=this.r.build(ec())}linear(t,e){var a;let n=this.r,s=n.gl;n.bindTex((a=n.layerTex.get(t))!=null?a:null,0);let o=e?s.LINEAR:s.NEAREST;s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,o),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,o)}chain(t,e,n){let s=this.r,o=this.steps,a=s.scale,i=s.maxBlur,l=0;for(let h=0;h<n.length;h++){let b=n[h];if(b.enabled)if(b.kind===1&&b.toMatrix){(!l||o[l-1]!==null)&&(o[l]=null,(!this.mats[l]||this.mats[l].length<20*this.colorN)&&(this.mats[l]=new Float32Array(20*this.colorN)),this.counts[l]=0,l++);let y=this.mats[l-1],x=this.counts[l-1];if(x<this.colorN)b.toMatrix(this.fm),y.set(this.fm,x*20),this.counts[l-1]=x+1;else{let d=(x-1)*20;for(let m=0;m<20;m++)this.fm2[m]=y[d+m];b.toMatrix(this.fm),tc(this.fm2,this.fm,this.fm3),y.set(this.fm2,d)}}else b.kind===4?this.userProg(b.source,!0)?o[l++]=b:s.skipped++:b.kind===2?Math.min(b.radius,i)*a>=.25&&(o[l++]=b):b.kind===3?o[l++]=b:s.skipped++}if(!l)return!1;let c=s.gl,u=t,f=-1;for(let h=0;h<l;h++){let b=h===l-1,y=f===0?1:0,x=b?null:this.scratch(1,y);if(!b&&!x)break;let d=o[h];if(d===null){let m=this.post("color");s.use(m);let g=this.mats[h],v=this.counts[h],k=this.m16,R=this.o4;for(let F=0;F<v;F++)for(let I=0;I<4;I++){for(let A=0;A<4;A++)k[F*16+A*4+I]=g[F*20+I*5+A];R[F*4+I]=g[F*20+I*5+4]}c.uniformMatrix4fv(s.u(m,"uM"),!1,k),c.uniform4fv(s.u(m,"uO"),R),c.uniform1i(s.u(m,"uK"),v),x?this.pass(m,u,1,x):s.final(m,u,1,e)}else if(d.kind===2)this.blur(u,f<0,Math.min(d.radius,i)*a,x,e,null);else if(d.kind===3){let m=d,g=this.scratch(1,2);if(!g)break;this.blur(u,f<0,Math.max(Math.min(m.blur,i),0)*a,g,1,m);let v=x!=null?x:e<1?this.scratch(1,y):null;v?(this.pass(s.main,g.tex,1,v),this.pass(s.main,u,1,v,!0),x||s.final(s.main,v.tex,1,e)):(s.final(s.main,g.tex,1,1),s.final(s.main,u,1,1))}else{let m=d,g=this.userProg(m.source,!0);s.use(g);let v=s.canvas.width,k=s.canvas.height;c.uniform2f(s.u(g,"uResolution"),v,k),c.uniform1f(s.u(g,"uTime"),s.time),c.uniform4f(s.u(g,"uRect"),s.rx0/v,1-s.ry1/k,s.rx1/v,1-s.ry0/k);let R=m.uniforms;for(let F in R){let I=s.u(g,F);if(!I)continue;let A=R[F];typeof A=="number"?c.uniform1f(I,A):A.length===2?c.uniform2fv(I,A):A.length===3?c.uniform3fv(I,A):A.length===4?c.uniform4fv(I,A):A.length===1&&c.uniform1fv(I,A)}x?this.pass(g,u,1,x):s.final(g,u,1,e)}x&&(u=x.tex,f=y)}return s.remap(),!0}blur(t,e,n,s,o,a){let i=this.r,l=i.gl,c=this.post("blur"),u=1;for(;u<16&&n/u>8;)u*=2;e&&this.linear(t,!0);let f=t,h=1,b=Math.sqrt(Math.max(n*n-(u*u-1)/12,0))/u,y=n>=.25?this.tapsFor(b):this.tapsFor(0),x=!0;if(y>1){for(let m=2;m<=u&&x;m*=2){let g=this.scratch(m,0);g?(this.pass(i.main,f,h,g),f=g.tex,h=m):x=!1}let d=x?this.scratch(u,3):null;d&&(i.use(c),l.uniform2fv(i.u(c,"uTaps"),this.taps),l.uniform1i(i.u(c,"uN"),y),l.uniform2f(i.u(c,"uDir"),1/f.width,0),l.uniform2f(i.u(c,"uOff"),0,0),l.uniform1f(i.u(c,"uMode"),0),this.pass(c,f,h,d),f=d.tex)}if(i.use(c),l.uniform2fv(i.u(c,"uTaps"),this.taps),l.uniform1i(i.u(c,"uN"),y),l.uniform2f(i.u(c,"uDir"),0,1/f.height),a){let d=a.opacity,m=a.rgb;l.uniform4f(i.u(c,"uShadow"),(m>>16&255)/255*d,(m>>8&255)/255*d,(m&255)/255*d,d),l.uniform1f(i.u(c,"uMode"),1),l.uniform2f(i.u(c,"uOff"),-a.dx*i.scale/(h*f.width),a.dy*i.scale/(h*f.height))}else l.uniform1f(i.u(c,"uMode"),0),l.uniform2f(i.u(c,"uOff"),0,0);s?this.pass(c,f,h,s):i.final(c,f,h,o),e&&this.linear(t,!1)}tapsFor(t){let e=this.taps;if(e.fill(0),e[1]=1,t<.2)return 1;let n=Math.min(Math.ceil(3*t),(zr-1)*2),s=-1/(2*t*t),o=1,a=1;for(let i=1;i<=n;i+=2){let l=Math.exp(i*i*s),c=i+1<=n?Math.exp((i+1)*(i+1)*s):0,u=l+c;e[a*2]=(i*l+(i+1)*c)/u,e[a*2+1]=u,o+=2*u,a++}for(let i=0;i<a;i++)e[i*2+1]=e[i*2+1]/o;return a}};var yt=r=>Math.min(Math.max(r,0),1),Je=r=>Math.max(r,0),jt=class{constructor(){p(this,"enabled",!0);Be.gl=Ka,Be.c2d=Ya}},it=class extends jt{constructor(e){super();p(this,"amount",e);p(this,"kind",1)}params(e,n){return e[n]=this.amount,n+1}};function Hr(r,t,e){r.fill(0),r[0]=r[6]=r[12]=t,r[4]=r[9]=r[14]=e,r[18]=1}function $r(r,t){r.fill(0);for(let e=0;e<3;e++)for(let n=0;n<3;n++)r[e*5+n]=t[e*3+n];r[18]=1}var W=new Float64Array(9),Ps=class extends it{toMatrix(t){Hr(t,Je(this.amount),0)}css(){return"brightness(".concat(Je(this.amount),")")}},_s=class extends it{toMatrix(t){let e=Je(this.amount);Hr(t,e,.5-.5*e)}css(){return"contrast(".concat(Je(this.amount),")")}},Ls=class extends it{toMatrix(t){let e=yt(this.amount);Hr(t,1-2*e,e)}css(){return"invert(".concat(yt(this.amount),")")}},Os=class extends it{toMatrix(t){let e=Je(this.amount);W[0]=.213+.787*e,W[1]=.715-.715*e,W[2]=.072-.072*e,W[3]=.213-.213*e,W[4]=.715+.285*e,W[5]=.072-.072*e,W[6]=.213-.213*e,W[7]=.715-.715*e,W[8]=.072+.928*e,$r(t,W)}css(){return"saturate(".concat(Je(this.amount),")")}},Is=class extends it{toMatrix(t){let e=1-yt(this.amount);W[0]=.2126+.7874*e,W[1]=.7152-.7152*e,W[2]=.0722-.0722*e,W[3]=.2126-.2126*e,W[4]=.7152+.2848*e,W[5]=.0722-.0722*e,W[6]=.2126-.2126*e,W[7]=.7152-.7152*e,W[8]=.0722+.9278*e,$r(t,W)}css(){return"grayscale(".concat(yt(this.amount),")")}},Ns=class extends it{toMatrix(t){let e=1-yt(this.amount);W[0]=.393+.607*e,W[1]=.769-.769*e,W[2]=.189-.189*e,W[3]=.349-.349*e,W[4]=.686+.314*e,W[5]=.168-.168*e,W[6]=.272-.272*e,W[7]=.534-.534*e,W[8]=.131+.869*e,$r(t,W)}css(){return"sepia(".concat(yt(this.amount),")")}},Ds=class extends it{get angle(){return this.amount}set angle(t){this.amount=t}toMatrix(t){let e=this.amount*Math.PI/180,n=Math.cos(e),s=Math.sin(e);W[0]=.213+n*.787-s*.213,W[1]=.715-n*.715-s*.715,W[2]=.072-n*.072+s*.928,W[3]=.213-n*.213+s*.143,W[4]=.715+n*.285+s*.14,W[5]=.072-n*.072-s*.283,W[6]=.213-n*.213-s*.787,W[7]=.715-n*.715+s*.715,W[8]=.072+n*.928+s*.072,$r(t,W)}css(){return"hue-rotate(".concat(this.amount,"deg)")}},Bs=class extends it{constructor(e,n){super(n);p(this,"c",16777215);p(this,"cs","");this.color=e}get color(){return this.c}set color(e){this.c=Te(e)[0],this.cs=$t(this.c)}params(e,n){return e[n]=this.amount,e[n+1]=this.c,n+2}toMatrix(e){let n=yt(this.amount);Hr(e,1-n,0),e[4]=(this.c>>16&255)/255*n,e[9]=(this.c>>8&255)/255*n,e[14]=(this.c&255)/255*n}css(){return null}paint2d(e,n,s,o,a){let i=yt(this.amount);i<=0||(e.save(),e.setTransform(1,0,0,1,0,0),e.globalAlpha=i,e.globalCompositeOperation="source-atop",e.fillStyle=this.cs,e.fillRect(n,s,o,a),e.restore())}},zs=class extends jt{constructor(e){super();p(this,"kind",1);p(this,"values");if(e.length!==20)throw new Error("colorMatrix: 20 numbers expected (4 rows of 5), got ".concat(e.length));this.values=Array.from(e)}toMatrix(e){var n;for(let s=0;s<20;s++)e[s]=(n=this.values[s])!=null?n:0}params(e,n){var s;for(let o=0;o<20;o++)e[n+o]=(s=this.values[o])!=null?s:0;return n+20}css(e,n,s){return s?s(this.values):null}},Hs=class extends jt{constructor(e){super();p(this,"radius",e);p(this,"kind",2)}params(e,n){return e[n]=this.radius,n+1}pad(e){return 3*Math.min(Je(this.radius),e)}css(e,n){return"blur(".concat(Math.min(Je(this.radius),n)*e,"px)")}},$s=class extends jt{constructor(e,n,s,o){super();p(this,"dx",e);p(this,"dy",n);p(this,"blur",s);p(this,"kind",3);p(this,"rgb",0);p(this,"a",1);this.color=o}get opacity(){return this.a}set opacity(e){this.a=yt(e)}get color(){return this.rgb}set color(e){let[n,s]=Te(e);this.rgb=n,this.a=s}params(e,n){return e[n]=this.dx,e[n+1]=this.dy,e[n+2]=this.blur,e[n+3]=this.rgb,e[n+4]=this.a,n+5}pad(e){return 3*Math.min(Je(this.blur),e)+Math.max(Math.abs(this.dx),Math.abs(this.dy))}css(e,n){return"drop-shadow(".concat(this.dx*e,"px ").concat(this.dy*e,"px ").concat(2*Math.min(Je(this.blur),n)*e,"px ").concat($t(this.rgb,this.opacity),")")}},nc="#ifdef GL_FRAGMENT_PRECISION_HIGH\nprecision highp float;\n#else\nprecision mediump float;\n#endif\nuniform sampler2D uTexture;\nuniform vec2 uResolution;\nuniform float uTime;\nuniform vec4 uRect;\nvarying vec2 vUv;\nvarying vec4 vColor;\n#define main fabiUserMain\n#line 1\n",rc=r=>"".concat(nc).concat(r,"\n#undef main\nvoid main() {\n fabiUserMain();\n gl_FragColor *= vColor.a;\n}\n"),Gs=class extends jt{constructor(e){var n,s;super();p(this,"kind",4);p(this,"source");p(this,"uniforms",{});p(this,"padding");this.source=rc(e.fragment),this.padding=(n=e.padding)!=null?n:0;for(let o in(s=e.uniforms)!=null?s:{}){let a=e.uniforms[o];this.uniforms[o]=typeof a=="number"?a:Float32Array.from(a)}}pad(){return Je(this.padding)}},Qa=(r,t=1)=>new Bs(r,t),Za=r=>new Ps(r),Ja=r=>new _s(r),ei=r=>new Os(r),ti=(r=1)=>new Is(r),ni=(r=1)=>new Ns(r),ri=r=>new Ds(r),si=(r=1)=>new Ls(r),oi=r=>new zs(r),ai=r=>new Hs(r),ii=(r,t,e,n="rgba(0,0,0,0.5)")=>new $s(r,t,e,n);function li(r){var n,s;let t=new Gs(r),e=(s=(n=Be.live)==null?void 0:n.filters())==null?void 0:s.check(t.source);if(e)throw new Error("shader(): the fragment does not compile:\n".concat(e));return t}var Us="x y rotation scaleX scaleY alpha visible blend tint z hitRadius clip mask filters".split(" "),ui="frameName _frame _w _h slice autoAnchor".split(" "),sc="fps loop speed onComplete durations".split(" "),Vs=["anchorX","anchorY"],oc=[...Us,...ui,...sc,...Vs],ac=[...Us,...ui,...Vs],ic=[...Us,...Vs],hi=r=>r instanceof Xe?oc:r instanceof ze?ac:ic;function lc(r){let t={},e=r;for(let n of hi(r))t[n]=e[n];return r instanceof nt&&(t.spec=r.spec),r instanceof ot&&(t.text=r.text,t.style=r.style),r instanceof Xe&&(t.playing=r.playing),t}function ci(r,t){let e=r;r instanceof nt&&r.spec!==t.spec&&(r.spec=t.spec),r instanceof ot&&(r.text=t.text,r.style!==t.style&&(e._style=t.style,e.dirty=!0)),r instanceof Xe&&r.gotoFrame(t.speed<0?r.frameCount-1:0);let n=r instanceof nt||r instanceof ot,s=hi(r);for(let o=0;o<s.length;o++){let a=s[o];(!n||a!=="_frame"&&a!=="frameName")&&(e[a]=t[a])}}var nr=class{constructor(t,e={}){p(this,"factory",t);p(this,"opts",e);p(this,"stats",{live:0,free:0,created:0});p(this,"free",[]);p(this,"states",new Map);p(this,"dead",!1)}get(t){if(this.dead)throw new Error("[engine] nodePool.get() after destroy()");let e=this.free.pop();if(e){this.stats.free--,e._free=!1;let n=this.states.get(e);ci(e,n),e.visible=n.visible,e instanceof Xe&&n.playing&&e.play()}else{if(e=this.factory(),!(e instanceof We))throw new Error("[engine] a nodePool factory must return a node (engine.sprite, engine.shape, \u2026)");if(e._pool)throw new Error("[engine] a nodePool factory returned a node of another pool: make a new node in it");this.states.set(e,lc(e)),e._pool=this,this.stats.created++}return this.stats.live++,t&&e.set(t),e}release(t){var n,s,o;let e=this.states.get(t);if(!(!e||t.destroyed)&&!t._free){if(this.opts.max!==void 0&&this.free.length>=this.opts.max)return t.destroy();(n=t.parent)==null||n.remove(t),t.kernel.tweens.stopAll(t),this.stats.live--,ci(t,e),t instanceof Xe&&t.stop(),t.visible=!1,t._free=!0,(o=(s=this.opts).reset)==null||o.call(s,t),this.free.push(t),this.stats.free++}}forget(t){let e=t;if(this.states.delete(e))if(e._free){let n=this.free.indexOf(e);n>=0&&(this.free[n]=this.free[this.free.length-1],this.free.pop()),this.stats.free--}else this.stats.live--}clear(){for(;this.free.length;)this.free[this.free.length-1].destroy()}destroy(){this.dead=!0;for(let t of[...this.states.keys()])t.destroy()}},fi=(r,t)=>new nr(r,t);window.FabiEngine=Ws;})();
|