@idosgames/characters 0.1.6 → 0.1.8
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/voxel/index.cjs +31 -8
- package/dist/voxel/index.d.cts +43 -6
- package/dist/voxel/index.d.ts +43 -6
- package/dist/voxel/index.js +31 -8
- package/package.json +1 -1
package/dist/voxel/index.js
CHANGED
|
@@ -1,19 +1,42 @@
|
|
|
1
|
-
import {a as a$1}from'../chunk-64D567CX.js';export{a as EMOTIONS,b as isEmotion}from'../chunk-64D567CX.js';import {c,d}from'../chunk-YOAPVGXE.js';import {b,a}from'../chunk-CGF2TQVK.js';import*as _ from'three';import {mergeGeometries}from'three/examples/jsm/utils/BufferGeometryUtils.js';var or={id:"avatar",label:"\u0410\u0432\u0430\u0442\u0430\u0440",hint:"the iDos Games account avatar: soft blocks with elbows and knees",bones:[{name:"body",role:"body",parent:null,pivot:[0,12.4,0]},{name:"head",role:"head",parent:"body",pivot:[0,22.4,0]},{name:"armL",role:"armL",parent:"body",pivot:[-6.3,21.4,0]},{name:"armR",role:"armR",parent:"body",pivot:[6.3,21.4,0]},{name:"foreArmL",role:"foreArmL",parent:"armL",pivot:[-6.3,17.2,0]},{name:"foreArmR",role:"foreArmR",parent:"armR",pivot:[6.3,17.2,0]},{name:"legL",role:"legL",parent:null,pivot:[-2.1,12.4,0]},{name:"legR",role:"legR",parent:null,pivot:[2.1,12.4,0]},{name:"shinL",role:"shinL",parent:"legL",pivot:[-2.1,6.4,0]},{name:"shinR",role:"shinR",parent:"legR",pivot:[2.1,6.4,0]}],sockets:[{name:"handR",bone:"foreArmR",at:[6.3,11.6,-1]},{name:"handL",bone:"foreArmL",at:[-6.3,11.6,-1]},{name:"headTop",bone:"head",at:[0,30.3,0]},{name:"face",bone:"head",at:[0,26.7,-4]},{name:"back",bone:"body",at:[0,18.5,2.3]},{name:"waist",bone:"body",at:[0,12.8,0]},{name:"shoulders",bone:"body",at:[0,22.4,0]}],hitbox:{w:.6,h:1.9},eye:26.4,height:{min:24,max:40},faceBone:"head",defaultParts:[{bone:"head",size:[8.5,7.5,8],pos:[0,26.5,0],color:"s",name:"head"},{bone:"head",size:[2.9,.8,2.7],pos:[0,22.6,0],color:"s",name:"neck"},{bone:"body",size:[9,6,4.6],pos:[0,19.4,0],color:"t",name:"torso"},{bone:"body",size:[8.5,5.2,4.3],pos:[0,15,0],color:"t",name:"torso"},{bone:"armL",size:[3.6,5,3.6],pos:[-6.3,19.7,0],color:"s",name:"sleeveL"},{bone:"armR",size:[3.6,5,3.6],pos:[6.3,19.7,0],color:"s",name:"sleeveR"},{bone:"foreArmL",size:[3.45,5.4,3.45],pos:[-6.3,15.7,0],color:"s",name:"forearmL"},{bone:"foreArmR",size:[3.45,5.4,3.45],pos:[6.3,15.7,0],color:"s",name:"forearmR"},{bone:"foreArmL",size:[3.3,3,3.3],pos:[-6.3,12.7,0],color:"s",name:"handL"},{bone:"foreArmR",size:[3.3,3,3.3],pos:[6.3,12.7,0],color:"s",name:"handR"},{bone:"legL",size:[4.2,6,4.2],pos:[-2.1,9.4,0],color:"p",name:"legL"},{bone:"legR",size:[4.2,6,4.2],pos:[2.1,9.4,0],color:"p",name:"legR"},{bone:"shinL",size:[4.05,7.2,4.05],pos:[-2.1,4,0],color:"p",name:"legL"},{bone:"shinR",size:[4.05,7.2,4.05],pos:[2.1,4,0],color:"p",name:"legR"},{bone:"shinL",size:[4.2,1.6,5.2],pos:[-2.1,.8,-0.5],color:"p",name:"footL"},{bone:"shinR",size:[4.2,1.6,5.2],pos:[2.1,.8,-0.5],color:"p",name:"footR"}]};var nr={id:"blob",label:"\u041A\u0430\u043F\u043B\u044F",hint:"slimes, ghosts, spirits, living objects \u2014 one body with a face, moves by hopping",bones:[{name:"body",role:"body",parent:null,pivot:[0,0,0]}],sockets:[{name:"headTop",bone:"body",at:[0,12,0]},{name:"face",bone:"body",at:[0,7,-6]},{name:"back",bone:"body",at:[0,6,6]},{name:"waist",bone:"body",at:[0,3,0]},{name:"shoulders",bone:"body",at:[0,10,0]},{name:"handR",bone:"body",at:[6,5,-2]},{name:"handL",bone:"body",at:[-6,5,-2]}],hitbox:{w:.8,h:.8},eye:8,height:{min:4,max:40},faceBone:"body",defaultParts:[{bone:"body",size:[12,12,12],pos:[0,6,0],color:"t"}]};var ar={id:"flyer",label:"\u041A\u0440\u044B\u043B\u0430\u0442\u044B\u0439",hint:"birds, bats, dragons, fairies, insects \u2014 creatures whose wings matter",bones:[{name:"body",role:"body",parent:null,pivot:[0,6,0]},{name:"head",role:"head",parent:"body",pivot:[0,11,-3]},{name:"wingL",role:"wingL",parent:"body",pivot:[-3,10,0]},{name:"wingR",role:"wingR",parent:"body",pivot:[3,10,0]},{name:"legL",role:"legL",parent:null,pivot:[-1.5,4,0]},{name:"legR",role:"legR",parent:null,pivot:[1.5,4,0]},{name:"tail",role:"tail",parent:"body",pivot:[0,8,4]}],sockets:[{name:"headTop",bone:"head",at:[0,16,-4]},{name:"face",bone:"head",at:[0,13,-7]},{name:"back",bone:"body",at:[0,11,1]},{name:"waist",bone:"body",at:[0,6,0]},{name:"shoulders",bone:"body",at:[0,10,-2]},{name:"handR",bone:"legR",at:[1.5,0,-1]},{name:"handL",bone:"legL",at:[-1.5,0,-1]}],hitbox:{w:.6,h:.9},eye:14,height:{min:6,max:40},faceBone:"head",defaultParts:[{bone:"body",size:[6,6,8],pos:[0,8,0],color:"t"},{bone:"head",size:[5,5,5],pos:[0,13,-4],color:"s"},{bone:"wingL",size:[8,1,6],pos:[-7,10,0],color:"t"},{bone:"wingR",size:[8,1,6],pos:[7,10,0],color:"t"},{bone:"legL",size:[1,4,1],pos:[-1.5,2,0],color:"p"},{bone:"legR",size:[1,4,1],pos:[1.5,2,0],color:"p"},{bone:"tail",size:[4,1,4],pos:[0,8,6],color:"t"}]};var sr={id:"humanoid",label:"\u0427\u0435\u043B\u043E\u0432\u0435\u043A",hint:"people, humanoids, robots, elves, zombies \u2014 anything on two legs with two arms",bones:[{name:"body",role:"body",parent:null,pivot:[0,12,0]},{name:"head",role:"head",parent:"body",pivot:[0,24,0]},{name:"armL",role:"armL",parent:"body",pivot:[-6,22,0]},{name:"armR",role:"armR",parent:"body",pivot:[6,22,0]},{name:"legL",role:"legL",parent:null,pivot:[-2,12,0]},{name:"legR",role:"legR",parent:null,pivot:[2,12,0]}],sockets:[{name:"handR",bone:"armR",at:[6,11,-1]},{name:"handL",bone:"armL",at:[-6,11,-1]},{name:"headTop",bone:"head",at:[0,32,0]},{name:"face",bone:"head",at:[0,28,-4]},{name:"back",bone:"body",at:[0,18,2]},{name:"waist",bone:"body",at:[0,12,0]},{name:"shoulders",bone:"body",at:[0,24,0]}],hitbox:{w:.6,h:1.8},eye:27,height:{min:16,max:48},faceBone:"head",defaultParts:[{bone:"head",size:[8,8,8],pos:[0,28,0],color:"s"},{bone:"body",size:[8,12,4],pos:[0,18,0],color:"t"},{bone:"armL",size:[4,12,4],pos:[-6,18,0],color:"s"},{bone:"armR",size:[4,12,4],pos:[6,18,0],color:"s"},{bone:"legL",size:[4,12,4],pos:[-2,6,0],color:"p"},{bone:"legR",size:[4,12,4],pos:[2,6,0],color:"p"}]};var ir={id:"quadruped",label:"\u0427\u0435\u0442\u0432\u0435\u0440\u043E\u043D\u043E\u0433\u043E\u0435",hint:"dogs, cats, horses, wolves, bears, lizards \u2014 any animal on four legs",bones:[{name:"body",role:"body",parent:null,pivot:[0,12,0]},{name:"head",role:"head",parent:"body",pivot:[0,14,-8]},{name:"legFL",role:"legFL",parent:null,pivot:[-3,8,-6]},{name:"legFR",role:"legFR",parent:null,pivot:[3,8,-6]},{name:"legBL",role:"legBL",parent:null,pivot:[-3,8,6]},{name:"legBR",role:"legBR",parent:null,pivot:[3,8,6]},{name:"tail",role:"tail",parent:"body",pivot:[0,14,8]}],sockets:[{name:"headTop",bone:"head",at:[0,20,-12]},{name:"face",bone:"head",at:[0,16,-16]},{name:"back",bone:"body",at:[0,16,0]},{name:"waist",bone:"body",at:[0,12,4]},{name:"shoulders",bone:"body",at:[0,16,-6]},{name:"handR",bone:"head",at:[2,13,-16]},{name:"handL",bone:"head",at:[-2,13,-16]}],hitbox:{w:.9,h:1},eye:17,height:{min:8,max:40},faceBone:"head",defaultParts:[{bone:"body",size:[8,8,16],pos:[0,12,0],color:"t"},{bone:"head",size:[8,8,8],pos:[0,16,-12],color:"s"},{bone:"legFL",size:[3,8,3],pos:[-3,4,-6],color:"p"},{bone:"legFR",size:[3,8,3],pos:[3,4,-6],color:"p"},{bone:"legBL",size:[3,8,3],pos:[-3,4,6],color:"p"},{bone:"legBR",size:[3,8,3],pos:[3,4,6],color:"p"},{bone:"tail",size:[2,2,8],pos:[0,14,12],color:"t"}]};var ja=["root","body","head","armL","armR","legL","legR","foreArmL","foreArmR","shinL","shinR","legFL","legFR","legBL","legBR","tail","wingL","wingR","ear","hair","cape","antenna","static"],Ze=["tail","wingL","wingR","ear","hair","cape","antenna","static"],Ga=["handR","handL","headTop","face","back","waist","shoulders"],Fe=["humanoid","quadruped","flyer","blob"],Me="avatar";var ne={humanoid:sr,quadruped:ir,flyer:ar,blob:nr,avatar:or};var lr=1,fe=["front","back","left","right","top","bottom"],He=["neutral","blink","happy","sad","angry","surprised","scared","tired","hurt","talk"],Tt=["normal","bouncy","heavy","sneaky","robotic"],Ct=["calm","fidgety","proud"],hr={parts:64,bones:16,palette:32,textures:48,texturePixels:32768,textureSide:32,partSide:32,coord:64},Ie={noise:.5,outline:.4,shade:.25,density:2},H=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Ne=e=>Array.isArray(e)?e:[];function Q(e,t,r,o){let n=typeof e=="number"?e:typeof e=="string"?Number(e):NaN;return Number.isFinite(n)?Math.min(o,Math.max(r,n)):t}function kt(e,t,r){if(typeof e!="string")return r;let o=e.trim();if(t.includes(o))return o;let n=o.toLowerCase().replace(/[\s-]+/g,"_");return t.find(i=>i.toLowerCase()===n)??r}function me(e,t,r){return typeof e=="string"?e.trim().slice(0,r):t}function Qe(e,t,r=null){if(!Array.isArray(e)||e.length<3)return r;let o=e.slice(0,3).map(n=>Q(n,NaN,-t,t));return o.every(Number.isFinite)?o:r}var cr={black:"#1d1d21",white:"#f0f0f0",gray:"#808080",grey:"#808080",red:"#c0392b",green:"#3c9a3c",blue:"#2f5fd0",yellow:"#f2d33c",orange:"#e8862a",purple:"#8a4fc4",pink:"#f08cb4",brown:"#7a4f2a",cyan:"#2ab0c0",gold:"#d8b030",silver:"#c0c4c8",skin:"#c69c7c"};function de(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();if(cr[t])return cr[t];let r=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/.exec(t);if(!r)return null;let o=r[1];return "#"+(o.length===3?o.split("").map(n=>n+n).join(""):o)}var ue=new Set(["."," "]),pr=e=>/^[A-Za-z0-9_]{1,24}$/.test(e),Qr={human:"humanoid",biped:"humanoid",person:"humanoid",animal:"quadruped",four_legs:"quadruped",quadrupedal:"quadruped",bird:"flyer",winged:"flyer",dragon:"flyer",slime:"blob",ghost:"blob"};function eo(e){if(typeof e!="string")return "humanoid";let t=e.trim().toLowerCase().replace(/[\s-]+/g,"_");return Fe.includes(t)?t:t===Me?Me:Qr[t]??"humanoid"}function mr(e,t){let r=/^(.*?)(L|R)$/.exec(e);if(!r)return e;let o=r[1]+(r[2]==="L"?"R":"L");return t(o)?o:e}function ae(e){if(typeof e=="string"){let d$1=d(e);if(!d$1.ok)return {ok:false,error:d$1.error,truncated:d$1.truncated};e=d$1.value;}if(!H(e))return {ok:false,error:c({en:"the character recipe is not an object",ru:"\u0440\u0435\u0446\u0435\u043F\u0442 \u043F\u0435\u0440\u0441\u043E\u043D\u0430\u0436\u0430 \u2014 \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442"})};if(!("parts"in e)&&!("rig"in e)){let d=e.character??e.spec??e.characterSpec;H(d)&&(e=d);}let t=e,r=hr,o=[];typeof t.version=="number"&&t.version>lr&&o.push(c({en:"recipe version {v} is newer than the game \u2014 read what could be read",ru:"\u0440\u0435\u0446\u0435\u043F\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 {v} \u2014 \u043D\u043E\u0432\u0435\u0435 \u0438\u0433\u0440\u044B, \u0440\u0430\u0437\u043E\u0431\u0440\u0430\u043D\u043E \u0447\u0442\u043E \u043F\u043E\u043D\u044F\u0442\u043D\u043E"},{v:t.version}));let n=eo(t.rig),a=ne[n],i={};if(H(t.palette))for(let[d,v]of Object.entries(t.palette)){if(Object.keys(i).length>=r.palette){o.push(c({en:"the palette is longer than {n} \u2014 the rest was dropped",ru:"\u043F\u0430\u043B\u0438\u0442\u0440\u0430 \u0434\u043B\u0438\u043D\u043D\u0435\u0435 {n} \u2014 \u043B\u0438\u0448\u043D\u0435\u0435 \u043E\u0442\u0431\u0440\u043E\u0448\u0435\u043D\u043E"},{n:r.palette}));break}let A=de(v);if(d.length!==1||ue.has(d)||!A){o.push(c({en:"palette colour \xAB{k}\xBB was not understood",ru:"\u0446\u0432\u0435\u0442 \u043F\u0430\u043B\u0438\u0442\u0440\u044B \xAB{k}\xBB \u043D\u0435 \u043F\u043E\u043D\u044F\u0442"},{k:d}));continue}i[d]=A;}let c$1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",s=(d,v)=>{if(typeof d!="string")return v;if(d.length===1&&i[d])return d;let A=de(d);if(!A)return v;let R=Object.entries(i).find(([,I])=>I===A);if(R)return R[0];if(Object.keys(i).length>=r.palette)return v;let C=[...c$1].find(I=>!i[I]);return C?(i[C]=A,C):v},l={},h=0;if(H(t.textures))for(let[d,v]of Object.entries(t.textures)){if(!pr(d)){o.push(c({en:"texture name \xAB{id}\xBB does not fit",ru:"\u0438\u043C\u044F \u0442\u0435\u043A\u0441\u0442\u0443\u0440\u044B \xAB{id}\xBB \u043D\u0435 \u043F\u043E\u0434\u0445\u043E\u0434\u0438\u0442"},{id:d.slice(0,30)}));continue}if(Object.keys(l).length>=r.textures){o.push(c({en:"more than {n} textures \u2014 the rest were dropped",ru:"\u0442\u0435\u043A\u0441\u0442\u0443\u0440 \u0431\u043E\u043B\u044C\u0448\u0435 {n} \u2014 \u043B\u0438\u0448\u043D\u0438\u0435 \u043E\u0442\u0431\u0440\u043E\u0448\u0435\u043D\u044B"},{n:r.textures}));break}let A=oo(v,i,o,d);if(A){if(h+A.w*A.h>r.texturePixels){o.push(c({en:"texture \xAB{id}\xBB did not fit the pixel limit",ru:"\u0442\u0435\u043A\u0441\u0442\u0443\u0440\u0430 \xAB{id}\xBB \u043D\u0435 \u0432\u043B\u0435\u0437\u043B\u0430 \u0432 \u043B\u0438\u043C\u0438\u0442 \u043F\u0438\u043A\u0441\u0435\u043B\u0435\u0439"},{id:d}));continue}h+=A.w*A.h,l[d]=A;}}let m=new Set(a.bones.map(d=>d.name)),p=[];for(let d of Ne(t.bones)){if(!H(d))continue;let v=me(d.name,"",24);if(!v||!pr(v))continue;let A=Qe(d.pivot,r.coord);if(!A||p.some(F=>F.name===v))continue;if(p.length>=r.bones){o.push(c({en:"more than {n} bones \u2014 the rest were dropped",ru:"\u043A\u043E\u0441\u0442\u0435\u0439 \u0431\u043E\u043B\u044C\u0448\u0435 {n} \u2014 \u043B\u0438\u0448\u043D\u0438\u0435 \u043E\u0442\u0431\u0440\u043E\u0448\u0435\u043D\u044B"},{n:r.bones}));break}let R=m.has(v),C=me(d.parent,"",24),I=R?a.bones.find(F=>F.name===v).parent??"":m.has(C)||p.some(F=>F.name===C)?C:a.bones.find(F=>F.role==="body").name;p.push({name:v,parent:I,pivot:A,role:R?"static":kt(d.role,Ze,"static")}),m.add(v);}let u=Object.keys(i)[0]??"s",x=[];for(let d of Ne(t.parts)){if(x.length>=r.parts){o.push(c({en:"more than {n} parts \u2014 the rest were dropped",ru:"\u0434\u0435\u0442\u0430\u043B\u0435\u0439 \u0431\u043E\u043B\u044C\u0448\u0435 {n} \u2014 \u043B\u0438\u0448\u043D\u0438\u0435 \u043E\u0442\u0431\u0440\u043E\u0448\u0435\u043D\u044B"},{n:r.parts}));break}if(!H(d))continue;let v=Qe(d.size,r.partSide),A=Qe(d.pos??d.center??d.at,r.coord);if(!v||!A||v.some(w=>w<=0))continue;let R=me(d.bone,"",24);m.has(R)||(R&&o.push(c({en:"bone \xAB{b}\xBB not found \u2014 the part is on the body",ru:"\u043A\u043E\u0441\u0442\u044C \xAB{b}\xBB \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u0430 \u2014 \u0434\u0435\u0442\u0430\u043B\u044C \u043D\u0430 \u0442\u0435\u043B\u0435"},{b:R})),R=a.bones.find(w=>w.role==="body").name);let C={bone:R,size:v,pos:A,color:s(d.color,u)};if(H(d.faces)){let w={};for(let E of fe){let M=d.faces[E];if(typeof M=="string")if(l[M])w[E]=M;else {let P=s(M,"");P&&(w[E]=P);}}Object.keys(w).length&&(C.faces=w);}let I=Qe(d.rot??d.rotation,180);I&&I.some(w=>w!==0)&&(C.rot=I),(d.mirror===true||d.mirror==="x")&&(C.mirror=true);let F=me(d.name,"",24);F&&(C.name=F),x.push(C);}if(!x.length){for(let[d,v]of Object.entries(to))i[d]||(i[d]=v);x.push(...a.defaultParts.map(ro));}let y=null;if(H(t.face)){let d=t.face,v=m.has(me(d.bone,"",24))?me(d.bone,"",24):a.faceBone,A=Ne(d.rect).map(C=>Math.round(Q(C,NaN,0,r.partSide)*10)/10),R={};if(H(d.expressions))for(let C of He){let I=d.expressions[C];typeof I=="string"&&l[I]&&(R[C]=I);}if(!R.neutral){let C=Object.values(R)[0];C&&(R.neutral=C);}if(R.neutral){let C=l[R.neutral];y={bone:v,rect:A.length===4&&A.every(Number.isFinite)&&A[2]>0&&A[3]>0?A:[0,0,C.w,C.h],expressions:R};}else Object.keys(d).length&&o.push(c({en:"the face has no pictures \u2014 no face is drawn",ru:"\u0443 \u043B\u0438\u0446\u0430 \u043D\u0435\u0442 \u043D\u0438 \u043E\u0434\u043D\u043E\u0439 \u043A\u0430\u0440\u0442\u0438\u043D\u043A\u0438 \u2014 \u043B\u0438\u0446\u043E \u043D\u0435 \u043D\u0430\u0440\u0438\u0441\u043E\u0432\u0430\u043D\u043E"}));}let T=H(t.style)?t.style:{},k=H(t.voice)?t.voice:{},g=H(t.finish)?t.finish:{},b={version:lr,name:me(t.name,et(),40)||et(),description:me(t.description,"",300),rig:n,scale:Q(t.scale,1,.25,3),palette:i,textures:l,parts:x,bones:p,face:y,style:{walk:kt(T.walk,Tt,"normal"),idle:kt(T.idle,Ct,"calm"),energy:Q(T.energy,.5,0,1)},voice:{pitch:Q(k.pitch,1,.5,2)},tags:Ne(t.tags).filter(d=>typeof d=="string"&&!!d.trim()).slice(0,8).map(d=>d.trim().slice(0,24)),finish:{noise:Q(g.noise,Ie.noise,0,1),outline:Q(g.outline,Ie.outline,0,1),shade:Q(g.shade,Ie.shade,0,1),density:Math.round(Q(g.density,Ie.density,1,4))}},S=Q(g.round,0,0,1);return S>0&&(b.finish.round=S),{ok:true,spec:b,warnings:o}}var to={s:"#c69c7c",t:"#3a8fd6",p:"#2c3e6b"};function ro(e){return JSON.parse(JSON.stringify(e))}function oo(e,t,r,o){let n=Array.isArray(e)?{rows:e}:H(e)?e:null;if(!n)return null;let a=hr.textureSide,i=Ne(n.rows??n.pixels).filter(h=>typeof h=="string");if(!i.length)return null;let c$1=Math.round(Q(n.h??n.height,i.length,1,a)),s=Math.round(Q(n.w??n.width,Math.max(...i.map(h=>h.length)),1,a)),l=false;for(i=i.slice(0,c$1).map(h=>{let m="";for(let p=0;p<s;p++){let u=h[p]??".";ue.has(u)||t[u]?m+=u===" "?".":u:(l=true,m+=".");}return m});i.length<c$1;)i.push(".".repeat(s));return l&&r.push(c({en:"texture \xAB{id}\xBB has symbols not in the palette \u2014 they became transparent",ru:"\u0432 \u0442\u0435\u043A\u0441\u0442\u0443\u0440\u0435 \xAB{id}\xBB \u0441\u0438\u043C\u0432\u043E\u043B\u044B \u043D\u0435 \u0438\u0437 \u043F\u0430\u043B\u0438\u0442\u0440\u044B \u2014 \u0441\u0442\u0430\u043B\u0438 \u043F\u0440\u043E\u0437\u0440\u0430\u0447\u043D\u044B\u043C\u0438"},{id:o})),{w:s,h:c$1,rows:i}}function St(e){return Array.isArray(e)?"["+e.map(St).join(",")+"]":H(e)?"{"+Object.keys(e).filter(t=>e[t]!==void 0).sort().map(t=>JSON.stringify(t)+":"+St(e[t])).join(",")+"}":JSON.stringify(e)}function Pe(e){let t=St(e),r=b(t),o=b("~"+t);return r.toString(16).padStart(8,"0")+o.toString(16).padStart(8,"0")}function rs(e){return ne[e.rig]}function dr(e){let r=ne[e.rig].bones.map(o=>{let n=e.bones.find(a=>a.name===o.name);return {name:o.name,role:o.role,parent:o.parent,pivot:(n?.pivot??o.pivot).slice()}});for(let o of e.bones)r.some(n=>n.name===o.name)||r.push({name:o.name,role:o.role,parent:o.parent,pivot:o.pivot.slice()});return r}function et(){return c({en:"Character",ru:"\u041F\u0435\u0440\u0441\u043E\u043D\u0430\u0436"})}var os=e=>e==="\u041F\u0435\u0440\u0441\u043E\u043D\u0430\u0436"||e==="Character";var no={front:{tl:[1,1,-1],u:[-1,0,0],d:[0,-1,0],n:[0,0,-1]},back:{tl:[-1,1,1],u:[1,0,0],d:[0,-1,0],n:[0,0,1]},right:{tl:[1,1,1],u:[0,0,-1],d:[0,-1,0],n:[1,0,0]},left:{tl:[-1,1,-1],u:[0,0,1],d:[0,-1,0],n:[-1,0,0]},top:{tl:[1,1,1],u:[-1,0,0],d:[0,0,-1],n:[0,1,0]},bottom:{tl:[-1,-1,1],u:[1,0,0],d:[0,0,-1],n:[0,-1,0]}};function Mt(e){let t=parseInt(e.slice(1),16);return [t>>16&255,t>>8&255,t&255]}function fr(e,t,r,o,n,a){let i=((r-1-n)*t+o)*4;e[i]=a[0],e[i+1]=a[1],e[i+2]=a[2],e[i+3]=255;}function ao(e){e.sort((t,r)=>r.h-t.h||r.w-t.w||(t.key<r.key?-1:1));for(let t=16;;t*=2){let r=0,o=0,n=0;for(let i of e)r+i.w>t&&(r=0,o+=n,n=0),i.x=r,i.y=o,r+=i.w,n=Math.max(n,i.h);let a=o+n;if(a<=t||t>=1024){let i=16;for(;i<a;)i*=2;return {w:t,h:i}}}}function ur(e,t,r){let o=Math.imul(t,374761393)+Math.imul(r,668265263)+Math.imul(e,2246822519);return o=Math.imul(o^o>>>13,1274126177),((o^o>>>16)>>>0)/4294967296}function so(e,t,r,o,n,a,i,c){let l=1+(.55*ur(i,t,r)+.45*ur(i^1540483477,Math.floor(t/3),Math.floor(r/3))-.5)*2*c.noise*.14;return a==="s"?l+=c.shade*.16*(.5-(r+.5)/n):a==="t"?l+=c.shade*.08:l-=c.shade*.2,o>=3&&n>=3&&(t===0||r===0||t===o-1||r===n-1)&&(l*=1-.5*c.outline),[Math.max(0,Math.min(255,e[0]*l)),Math.max(0,Math.min(255,e[1]*l)),Math.max(0,Math.min(255,e[2]*l))]}var Le=Math.PI/180;function tt(e,t){if(!t)return e;let[r,o,n]=e,[a,i,c]=[t[0]*Le,t[1]*Le,t[2]*Le],s=Math.cos(c),l=Math.sin(c);return [r,o]=[r*s-o*l,r*l+o*s],s=Math.cos(i),l=Math.sin(i),[r,n]=[r*s+n*l,-r*l+n*s],s=Math.cos(a),l=Math.sin(a),[o,n]=[o*s-n*l,o*l+n*s],[r,o,n]}function io(e,t){let r=[];for(let o of e.parts){if(r.push({...o,flip:false}),!o.mirror)continue;let n=o.faces?{...o.faces,left:o.faces.right,right:o.faces.left}:void 0;n&&(n.left===void 0&&delete n.left,n.right===void 0&&delete n.right);let a={...o,bone:mr(o.bone,t),pos:[-o.pos[0],o.pos[1],o.pos[2]],flip:true};n?a.faces=n:delete a.faces,o.rot&&(a.rot=[o.rot[0],-o.rot[1],-o.rot[2]]),r.push(a);}return r}function gr(e){let t=ne[e.rig],r=dr(e),o=w=>r.some(E=>E.name===w),n=io(e,o),a=e.finish??Ie,i=a.round??0,c=new Map,s=(w,E)=>{let M=w.faces?.[E],P=M!==void 0?e.textures[M]:void 0,z=M!==void 0&&e.palette[M]?M:w.color,[B,K]=E==="front"||E==="back"?[w.size[0],w.size[1]]:E==="left"||E==="right"?[w.size[2],w.size[1]]:[w.size[0],w.size[2]],G=(Ce,ye)=>Math.max(1,Math.min(64,ye*Math.max(1,Math.round(Ce*a.density/ye)))),W=P?G(B,P.w):G(B,1),O=P?G(K,P.h):G(K,1),ee=E==="top"?"t":E==="bottom"?"b":"s",X=(P?"t:"+M:"c:"+z)+"|"+W+"x"+O+ee,q=c.get(X);if(q)return q;let pe=b(X),he=P?null:Mt(e.palette[z]??"#ff00ff");return q={key:X,w:W,h:O,x:0,y:0,paint:(Ce,ye,Ke,Xe,At)=>{for(let J=0;J<O;J++)for(let Z=0;Z<W;Z++){let le=he;if(P){let oe=P.rows[Math.floor(J*P.h/O)][Math.floor(Z*P.w/W)];if(ue.has(oe))continue;let tr=e.palette[oe];if(!tr)continue;le=Mt(tr);}fr(Ce,ye,Ke,Xe+Z,At+J,so(le,Z,J,W,O,ee,pe,a));}}},c.set(X,q),q},l=(w,E)=>{let M="e:"+w,P=c.get(M);return P||(P={key:M,w:E.w,h:E.h,x:0,y:0,paint:(z,B,K,G,W)=>{for(let O=0;O<E.h;O++)for(let ee=0;ee<E.w;ee++){let X=E.rows[O][ee];if(ue.has(X))continue;let q=e.palette[X];q&&fr(z,B,K,G+ee,W+O,Mt(q));}}},c.set(M,P)),P},h=n.map(w=>({p:w,faces:fe.map(E=>({f:E,cell:s(w,E)}))})),m=e.face,p=[];if(m)for(let[w,E]of Object.entries(m.expressions)){let M=e.textures[E];M&&p.push([w,l(E,M)]);}let{w:u,h:x}=ao([...c.values()]),y=new Uint8Array(u*x*4);for(let w of c.values())w.paint(y,u,x,w.x,w.y);let T=.01,k=(w,E=T)=>[(w.x+E)/u,1-(w.y+E)/x,(w.x+w.w-E)/u,1-(w.y+w.h-E)/x],g=new Map;for(let w of r)g.set(w.name,{pos:[],nrm:[],uv:[],idx:[]});let b$1=new Map,S=w=>{let E=b$1.get(w);if(E===void 0){E=true;for(let M=0;M<w.h&&E;M++)for(let P=0;P<w.w;P++)if(y[((w.y+M)*u+w.x+P)*4+3]<128){E=false;break}b$1.set(w,E);}return E},d=new Map;for(let{p:w,faces:E}of h)if(E.every(({cell:M})=>S(M))){let M=d.get(w.bone)??[];M.push(w),d.set(w.bone,M);}let v=0;for(let{p:w,faces:E}of h){let M=g.get(w.bone),P=r.find(G=>G.name===w.bone).pivot,z=[w.size[0]/2,w.size[1]/2,w.size[2]/2];v=Math.max(v,w.pos[1]+z[1]);let B=(d.get(w.bone)??[]).filter(G=>G!==w),K=(G,W)=>{let O=no[G],ee=(J,Z)=>{let le=[z[0]*(O.tl[0]+2*(O.u[0]*J+O.d[0]*Z)),z[1]*(O.tl[1]+2*(O.u[1]*J+O.d[1]*Z)),z[2]*(O.tl[2]+2*(O.u[2]*J+O.d[2]*Z))],oe=tt(le,w.rot);return [w.pos[0]+oe[0]-P[0],w.pos[1]+oe[1]-P[1],w.pos[2]+oe[2]-P[2]]},X=tt(O.n,w.rot),q=M.pos.length/3,[pe,he,Ce,ye]=k(W),[Ke,Xe]=w.flip?[Ce,pe]:[pe,Ce];if(i>0){let[J,Z,le,oe]=k(W,.5);co(M,w,z,O,P,i,w.flip?[le,Z,J,oe]:[J,Z,le,oe]);return}let At=[[0,0,Ke,he],[1,0,Xe,he],[1,1,Xe,ye],[0,1,Ke,ye]];for(let[J,Z,le,oe]of At)M.pos.push(...ee(J,Z)),M.nrm.push(...X),M.uv.push(le,oe);M.idx.push(q,q+2,q+1,q,q+3,q+2);};for(let{f:G,cell:W}of E){let O=[M.pos.length,M.nrm.length,M.uv.length,M.idx.length];K(G,W),B.length&&ho(M.pos,O[0],P,B,i)&&(M.pos.length=O[0],M.nrm.length=O[1],M.uv.length=O[2],M.idx.length=O[3]);}}let A=r.map(w=>{let E=g.get(w.name);return {name:w.name,role:w.role,parent:w.parent,pivot:w.pivot,positions:Float32Array.from(E.pos),normals:Float32Array.from(E.nrm),uvs:Float32Array.from(E.uv),indices:Uint16Array.from(E.idx)}}),R=null;if(m&&p.length){let E=e.parts.filter(P=>P.bone===m.bone).sort((P,z)=>z.size[0]*z.size[1]*z.size[2]-P.size[0]*P.size[1]*P.size[2])[0],M=r.find(P=>P.name===m.bone);if(E&&M){let[P,z,B,K]=m.rect,G=E.pos[0]+E.size[0]/2-P,W=E.pos[1]+E.size[1]/2-z,O=E.pos[2]-E.size[2]/2-.05,ee=M.pivot,X=(pe,he)=>[pe-ee[0],he-ee[1],O-ee[2]],q={};for(let[pe,he]of p)q[pe]=k(he);R={bone:m.bone,corners:Float32Array.from([...X(G,W),...X(G-B,W),...X(G-B,W-K),...X(G,W-K)]),uv:q};}}let C=t.sockets.filter(w=>o(w.bone)).map(w=>{let E=t.bones.find(M=>M.name===w.bone);return {name:w.name,bone:w.bone,at:[w.at[0]-E.pivot[0],w.at[1]-E.pivot[1],w.at[2]-E.pivot[2]]}}),I=Math.max(1,v),F=I>t.height.max?t.height.max/I:I<t.height.min?t.height.min/I:1;return {hash:Pe(e),rig:e.rig,bones:A,atlas:{w:u,h:x,data:y},face:R,sockets:C,height:I,scale:e.scale*F,eye:t.eye*I/mo(e.rig)}}var wr=3,lo=2.5,br=1,yr=0;function co(e,t,r,o,n,a,i){let c=Math.min(r[0],r[1],r[2]),s=Math.min(c,a*wr),l=Math.min(c,s*lo),h=[r[0]-s,r[1]-s,r[2]-s],m=[r[0]-l,r[1]-l,r[2]-l],p=v=>Math.abs(v[0])*t.size[0]+Math.abs(v[1])*t.size[1]+Math.abs(v[2])*t.size[2],u=v=>{let A=[];for(let C=0;C<=br;C++)A.push(Math.min(.5,s*C/br/v));for(let C=1;C<=yr;C++)A.push(Math.min(.5,(s+(l-s)*C/yr)/v));let R=[...A,...A.map(C=>1-C)].sort((C,I)=>C-I);return R.filter((C,I)=>I===0||C-R[I-1]>1e-6)},x=u(p(o.u)),y=u(p(o.d)),T=e.pos.length/3,[k,g,b,S]=i;for(let v of y)for(let A of x){let R=[0,0,0],C=[0,0,0],I=[0,0,0];for(let B=0;B<3;B++){let K=r[B]*(o.tl[B]+2*(o.u[B]*A+o.d[B]*v)),G=Math.max(-h[B],Math.min(h[B],K));C[B]=K-G,R[B]=G,I[B]=K-Math.max(-m[B],Math.min(m[B],K));}let F=Math.hypot(C[0],C[1],C[2]),w=F>1e-9?[C[0]/F,C[1]/F,C[2]/F]:[o.n[0],o.n[1],o.n[2]],E=Math.hypot(I[0],I[1],I[2]),M=E>1e-9?[I[0]/E,I[1]/E,I[2]/E]:w,P=[R[0]+w[0]*s,R[1]+w[1]*s,R[2]+w[2]*s],z=tt(P,t.rot);e.pos.push(t.pos[0]+z[0]-n[0],t.pos[1]+z[1]-n[1],t.pos[2]+z[2]-n[2]),e.nrm.push(...tt(M,t.rot)),e.uv.push(k+(b-k)*A,g+(S-g)*v);}let d=x.length;for(let v=0;v+1<y.length;v++)for(let A=0;A+1<d;A++){let R=T+v*d+A;e.idx.push(R,R+d+1,R+1,R,R+d,R+d+1);}}function po(e,t){if(!t)return e;let[r,o,n]=e,[a,i,c]=[-t[0]*Le,-t[1]*Le,-t[2]*Le],s=Math.cos(a),l=Math.sin(a);return [o,n]=[o*s-n*l,o*l+n*s],s=Math.cos(i),l=Math.sin(i),[r,n]=[r*s+n*l,-r*l+n*s],s=Math.cos(c),l=Math.sin(c),[r,o]=[r*s-o*l,r*l+o*s],[r,o,n]}function ho(e,t,r,o,n){for(let i of o){let c=[i.size[0]/2,i.size[1]/2,i.size[2]/2],s=n>0?Math.min(c[0],c[1],c[2],n*wr):0,l=true;for(let h=t;h<e.length&&l;h+=3){let m=po([e[h]+r[0]-i.pos[0],e[h+1]+r[1]-i.pos[1],e[h+2]+r[2]-i.pos[2]],i.rot),p=Math.abs(m[0])-(c[0]-s),u=Math.abs(m[1])-(c[1]-s),x=Math.abs(m[2])-(c[2]-s);Math.hypot(Math.max(p,0),Math.max(u,0),Math.max(x,0))+Math.min(Math.max(p,u,x),0)-s>=-0.01&&(l=false);}if(l)return true}return false}function mo(e){let t=1;for(let r of ne[e].defaultParts)t=Math.max(t,r.pos[1]+r.size[1]/2);return t}var It=new Map;function fo(e){let t=new Map;for(let c of e.bones){if(!c.indices.length){t.set(c.name,null);continue}let s=new _.BufferGeometry;s.setAttribute("position",new _.BufferAttribute(c.positions,3)),s.setAttribute("normal",new _.BufferAttribute(c.normals,3)),s.setAttribute("uv",new _.BufferAttribute(c.uvs,2)),s.setIndex(new _.BufferAttribute(c.indices,1)),s.computeBoundingSphere(),s.userData.shared=true,t.set(c.name,s);}let r=uo(e),{w:o,h:n,data:a}=e.atlas,i=new _.DataTexture(a,o,n,_.RGBAFormat);return i.magFilter=_.NearestFilter,i.minFilter=_.NearestFilter,i.generateMipmaps=false,i.colorSpace=_.SRGBColorSpace,i.needsUpdate=true,{layout:e,geometries:t,skinned:r,texture:i,refs:0}}function uo(e){let t=0,r=0;for(let p of e.bones)t+=p.positions.length/3,r+=p.indices.length;if(!r)return null;let o=new Float32Array(t*3),n=new Float32Array(t*3),a=new Float32Array(t*2),i=new Uint16Array(t*4),c=new Float32Array(t*4),s=t>65535?new Uint32Array(r):new Uint16Array(r),l=0,h=0;e.bones.forEach((p,u)=>{let x=p.positions.length/3;for(let y=0;y<x;y++)o[(l+y)*3]=p.positions[y*3]+p.pivot[0],o[(l+y)*3+1]=p.positions[y*3+1]+p.pivot[1],o[(l+y)*3+2]=p.positions[y*3+2]+p.pivot[2],i[(l+y)*4]=u,c[(l+y)*4]=1;n.set(p.normals,l*3),a.set(p.uvs,l*2);for(let y=0;y<p.indices.length;y++)s[h+y]=p.indices[y]+l;l+=x,h+=p.indices.length;});let m=new _.BufferGeometry;return m.setAttribute("position",new _.BufferAttribute(o,3)),m.setAttribute("normal",new _.BufferAttribute(n,3)),m.setAttribute("uv",new _.BufferAttribute(a,2)),m.setAttribute("skinIndex",new _.Uint16BufferAttribute(i,4)),m.setAttribute("skinWeight",new _.BufferAttribute(c,4)),m.setIndex(new _.BufferAttribute(s,1)),m.computeBoundingSphere(),m.userData.shared=true,m}function Pt(e){let t=It.get(Pe(e));return t||(t=fo(gr(e)),It.set(t.layout.hash,t)),t.refs++,t}function rt(e){if(!(--e.refs>0)){It.delete(e.layout.hash);for(let t of e.geometries.values())t?.dispose();e.skinned?.dispose(),e.texture.dispose();}}var L=class e{constructor(t,r,o="."){this.w=t;this.h=r;this.g=Array.from({length:r},()=>new Array(t).fill(o));}w;h;g;px(t,r,o){return t>=0&&r>=0&&t<this.w&&r<this.h&&(this.g[r][t]=o),this}rect(t,r,o,n,a){for(let i=r;i<r+n;i++)for(let c=t;c<t+o;c++)this.px(c,i,a);return this}row(t,r,o,n){return this.rect(r,t,o-r+1,1,n)}col(t,r,o,n){return this.rect(t,r,1,o-r+1,n)}where(t,r){for(let o=0;o<this.h;o++)for(let n=0;n<this.w;n++)t(n,o)&&this.px(n,o,r);return this}flipped(){let t=new e(this.w,this.h);for(let r=0;r<this.h;r++)for(let o=0;o<this.w;o++)t.px(this.w-1-o,r,this.g[r][o]);return t}tex(){return {w:this.w,h:this.h,rows:this.g.map(t=>t.join(""))}}};var bo={s:"#d9a982",S:"#bf8d68",h:"#6b4a2f",H:"#8a6644",k:"#3a2818",w:"#f4f4ef",b:"#3f8f9c",m:"#9a5544",o:"#4a2219",t:"#a7bea9",T:"#c4d6c4",D:"#84a08a",u:"#ece6d2",B:"#6a4e33",g:"#d8c48c",p:"#8c9ca6",P:"#6f808a",z:"#a07a55",Z:"#7c5c3f",l:"#e9e3cf"};function ce(e,t){let r=parseInt(e.slice(1),16);return "#"+[r>>16&255,r>>8&255,r&255].map(n=>Math.max(0,Math.min(255,Math.round(n*t)))).map(n=>n.toString(16).padStart(2,"0")).join("")}function zt(e,t){let r={...e};return t.skin&&(r.s=t.skin,r.S=ce(t.skin,.86),r.m=ce(t.skin,.66)),t.hair&&(r.h=t.hair,r.H=ce(t.hair,1.25),r.k=ce(t.hair,.6)),t.shirt&&(r.t=t.shirt,r.T=ce(t.shirt,1.15),r.D=ce(t.shirt,.8)),t.pants&&(r.p=t.pants,r.P=ce(t.pants,.8)),t.boots&&(r.z=t.boots,r.Z=ce(t.boots,.78)),t.eyes&&(r.b=t.eyes),r}var yo=new L(16,16,"s").rect(0,0,16,3,"h").row(3,0,4,"h").row(3,10,15,"h").row(4,0,1,"h").row(4,13,15,"h").col(0,5,8,"h").col(15,5,8,"h").row(1,3,6,"H").row(1,9,12,"H").row(15,2,13,"S"),xr=new L(16,16,"s").rect(0,0,16,4,"h").rect(7,4,9,7,"h").rect(10,11,6,2,"h").rect(5,7,2,3,"S").row(1,2,13,"H").where((e,t)=>t>4&&t<11&&e>8&&(e+t)%4===0,"k"),go=xr.flipped(),wo=new L(16,16,"h").where((e,t)=>(e+2*t)%5===0,"H").where((e,t)=>t>8&&(e*3+t)%7===0,"k").rect(4,14,8,2,"s"),xo=new L(16,16,"h").where((e,t)=>(e+2*t)%5===0,"H").where((e,t)=>(3*e+t)%9===0,"k"),vo=new L(18,4,"h").where((e,t)=>(e*7+t*3)%5===0,"H").where((e,t)=>t===3&&e*5%3===0,"k"),Ro=new L(16,24,"t").row(0,6,9,"s").row(1,7,8,"s").row(0,3,5,"T").row(0,10,12,"T").row(1,4,6,"T").row(1,9,11,"T").row(2,5,6,"T").row(2,9,10,"T").col(8,2,19,"D").px(7,5,"u").px(7,9,"u").px(7,13,"u").px(7,17,"u").row(6,2,5,"D").col(2,7,10,"D").col(5,7,10,"D").row(10,2,5,"D").px(4,7,"u").row(6,10,13,"D").col(10,7,10,"D").col(13,7,10,"D").row(10,10,13,"D").px(11,7,"u").row(19,0,15,"D").rect(0,20,16,2,"B").rect(7,20,2,2,"g").rect(0,22,16,2,"p"),Ao=new L(16,24,"t").row(5,0,15,"D").col(8,6,19,"D").row(19,0,15,"D").rect(0,20,16,2,"B").rect(0,22,16,2,"p"),Eo=new L(8,24,"t").col(4,0,19,"D").row(19,0,7,"D").rect(0,20,8,2,"B").rect(0,22,8,2,"p"),ko=new L(16,2,"B").rect(7,0,2,2,"g").px(3,0,"k").px(12,0,"k"),So=new L(6,24,"s").row(23,0,5,"S").col(2,21,23,"S"),To=new L(8,13,"t").col(0,0,9,"D").row(9,0,7,"D").rect(0,10,8,3,"T").row(12,0,7,"D"),Co=new L(8,24,"p").col(4,1,21,"P").row(0,0,7,"P"),Mo=new L(8,24,"p").col(3,0,21,"P").row(0,0,7,"P"),Io=new L(8,24,"p").col(3,0,21,"P"),Po=new L(10,9,"z").row(0,0,9,"Z").row(2,3,6,"l").row(4,3,6,"l").row(6,3,6,"l").col(2,1,6,"Z").col(7,1,6,"Z").rect(0,7,10,2,"Z"),Lo=new L(10,9,"z").row(0,0,9,"Z").rect(0,7,10,2,"Z").col(5,1,6,"Z");function se(e){let t=new L(16,10,"."),r=(n,a,i)=>{if(e.brows==="flat")t.row(1,n,n+2,"k");else if(e.brows==="high")t.row(0,n,n+2,"k");else {let c=e.brows==="down"?1:0,s=1-c;t.px(a,c,"k").px(n+1,e.brows==="down"?0:1,"k"),t.px(i,s,"k");}};r(3,5,3),r(10,10,12);let o=n=>{if(e.eyes===0){t.row(3,n,n+2,"k");return}let a=e.eyes===3||e.eyes===2?2:3;for(let i=a;i<a+e.eyes;i++)t.px(n,i,"w").px(n+1,i,"b").px(n+2,i,"w");};switch(o(3),o(10),e.mouth){case "line":t.row(7,6,9,"m");break;case "smile":t.px(5,6,"m").px(10,6,"m").row(7,6,9,"m");break;case "frown":t.row(7,6,9,"m").px(5,8,"m").px(10,8,"m");break;case "open":t.rect(6,7,4,2,"o");break;case "small":t.rect(7,7,2,2,"o");break;case "wide":t.row(7,5,10,"m").rect(6,8,4,1,"o");break}return t}var vr={f_neutral:se({brows:"flat",eyes:2,mouth:"line"}),f_blink:se({brows:"flat",eyes:0,mouth:"line"}),f_happy:se({brows:"high",eyes:2,mouth:"smile"}),f_sad:se({brows:"up",eyes:2,mouth:"frown"}),f_angry:se({brows:"down",eyes:1,mouth:"wide"}),f_surprised:se({brows:"high",eyes:3,mouth:"small"}),f_scared:se({brows:"up",eyes:3,mouth:"open"}),f_tired:se({brows:"flat",eyes:1,mouth:"line"}),f_hurt:se({brows:"down",eyes:0,mouth:"open"}),f_talk:se({brows:"flat",eyes:2,mouth:"open"})},zo=new L(16,24,"t").row(0,5,10,"s").row(1,6,9,"s").px(5,1,"T").px(10,1,"T").row(7,0,15,"D").row(10,0,15,"D").rect(0,18,16,2,"T").rect(0,20,16,4,"p").row(20,0,15,"P"),_o=new L(16,24,"t").row(0,5,10,"T").row(7,0,15,"D").row(10,0,15,"D").rect(0,18,16,2,"T").rect(0,20,16,4,"p").row(20,0,15,"P"),Oo=new L(8,24,"t").row(7,0,7,"D").row(10,0,7,"D").rect(0,18,8,2,"T").rect(0,20,8,4,"p").row(20,0,7,"P"),Fo=new L(8,9,"t").row(3,0,7,"D").rect(0,7,8,2,"T"),ot=(e,t)=>e.row(t-1,0,e.w-1,"D").where((r,o)=>o>=t&&o<=t+3&&(r+o)%2===0,"T").row(t+4,0,e.w-1,"D"),No=ot(new L(16,24,"t"),6).row(0,6,9,"s").row(0,4,5,"T").row(0,10,11,"T").row(1,4,11,"T").where((e,t)=>t>=18&&t<=19&&e%2===0,"D").where((e,t)=>t>=18&&t<=19&&e%2===1,"T").rect(0,20,16,4,"p"),Ho=ot(new L(16,24,"t"),6).row(0,4,11,"T").where((e,t)=>t>=18&&t<=19,"D").rect(0,20,16,4,"p"),Do=ot(new L(8,24,"t"),6).where((e,t)=>t>=18&&t<=19,"D").rect(0,20,8,4,"p"),Bo=ot(new L(8,22,"t"),9).where((e,t)=>t>=19&&e%2===0,"D"),Rr=e=>new L(8,24,"s").rect(0,0,8,12,"p").col(e,1,10,"P").row(11,0,7,"P").row(12,0,7,"S").rect(0,19,8,5,"l"),Vo=Rr(4),jo=Rr(3),Go=new L(9,5,"z").row(1,3,5,"l").rect(0,3,9,2,"l"),Uo=new L(10,5,"z").row(1,3,6,"Z").rect(0,3,10,2,"l"),Yo=new L(17,6,"a").rect(0,4,17,2,"A"),qo=new L(22,22,"a").where((e,t)=>(e*3+t*5)%11===0,"A"),$o=new L(17,20,"h").where((e,t)=>(e*5+t)%4===0,"H").where((e,t)=>t>10&&(e*3+t*2)%7===0,"k"),D=e=>e.tex(),Ar=["shirt","tee","sweater"],Er=["pants","shorts"],kr=["boots","sneakers"],bs=["short","long","curly","none"],we=(e,t={})=>({front:e,back:e,left:e,right:e,...t});function _t(e={}){let t=e.top??"shirt",r=e.bottom??"pants",o=e.shoes??"boots",n=e.hair??"short",a=zt(bo,e.colors??{});a={...a,a:e.colors?.hat??"#d9c9a3"},a.A=ce(a.a,.72);let i={head_front:D(yo),head_left:D(xr),head_right:D(go),head_back:D(wo),hair_top:D(xo),hair_band:D(vo),arm_skin:D(So),...Object.fromEntries(Object.entries(vr).map(([x,y])=>[x,D(y)]))},c$1=[{name:"head",bone:"head",size:[8,8,8],pos:[0,28,0],color:"s",faces:{front:"head_front",left:"head_left",right:"head_right",back:"head_back",top:"hair_top"}},{name:"nose",bone:"head",size:[1,1.5,.8],pos:[0,26.9,-4.4],color:"S",faces:{front:"s"}}];if(n!=="none"){if(e.hat||c$1.push({name:"hair",bone:"head",size:n==="curly"?[9,2.2,9]:[8.6,1.6,8.6],pos:[0,n==="curly"?32.5:32.2,.15],color:"h",faces:we("hair_band",{top:"hair_top"})}),n==="curly"&&!e.hat)for(let[x,y]of [[-2,-1.5],[2,.5],[-0.5,2.5]])c$1.push({name:"curl",bone:"head",size:[3.2,1.4,3.2],pos:[x,33.9,y],color:"h",faces:we("hair_band",{top:"hair_top"})});n==="long"?(i.hair_long=D($o),c$1.push({name:"hairLong",bone:"head",size:[8.8,10,1],pos:[0,27,4.4],color:"h",faces:we("hair_long",{top:"hair_top"})},{name:"hairSide",bone:"head",size:[.8,9,6],pos:[-4.4,27.5,1],color:"h",faces:we("hair_long",{top:"hair_top"}),mirror:true})):c$1.push({name:"hairBack",bone:"head",size:[8.6,5,.8],pos:[0,29.6,4.25],color:"h",faces:{back:"head_back",left:"hair_band",right:"hair_band"}});}e.hat&&(i.hat_crown=D(Yo),i.hat_brim=D(qo),c$1.push({name:"hatBrim",bone:"head",size:[11,.8,11],pos:[0,32.4,0],color:"a",faces:{top:"hat_brim",bottom:"hat_brim"}},{name:"hatCrown",bone:"head",size:[8.4,3,8.4],pos:[0,34.3,0],color:"a",faces:we("hat_crown")}));let s={shirt:[Ro,Ao,Eo],tee:[zo,_o,Oo],sweater:[No,Ho,Do]},[l,h,m]=s[t];i.top_front=D(l),i.top_back=D(h),i.top_side=D(m),c$1.push({name:"torso",bone:"body",size:[8,12,4],pos:[0,18,0],color:"t",faces:{front:"top_front",back:"top_back",left:"top_side",right:"top_side",bottom:"p"}}),t==="shirt"&&(i.belt=D(ko),c$1.push({name:"belt",bone:"body",size:[8.4,1,4.4],pos:[0,13.5,0],color:"B",faces:{front:"belt",back:"belt"}})),c$1.push({name:"arm",bone:"armL",size:[3,12,3],pos:[-5.5,18,0],color:"s",faces:we("arm_skin",{top:"t",bottom:"S"}),mirror:true});let p=t==="sweater"?11:t==="tee"?4.5:6.5;i.sleeve=D(t==="sweater"?Bo:t==="tee"?Fo:To),c$1.push({name:"sleeve",bone:"armL",size:[3.6,p,3.6],pos:[-5.5,24-p/2,0],color:"t",faces:we("sleeve",{bottom:"D"}),mirror:true}),r==="shorts"?(i.leg_front=D(Vo),i.leg_side=D(jo)):(i.leg_front=D(Co),i.leg_back=D(Mo),i.leg_side=D(Io)),c$1.push({name:"leg",bone:"legL",size:[4,12,4],pos:[-2,6,0],color:"p",faces:{front:"leg_front",back:r==="shorts"?"leg_front":"leg_back",left:"leg_side",right:"leg_side"},mirror:true}),o==="boots"?(i.shoe_front=D(Po),i.shoe_side=D(Lo)):(i.shoe_front=D(Go),i.shoe_side=D(Uo));let u=o==="boots"?4.5:2.5;return c$1.push({name:"shoe",bone:"legL",size:[4.6,u,5.2],pos:[-2,u/2,-0.3],color:"z",faces:{front:"shoe_front",back:"shoe_side",left:"shoe_side",right:"shoe_side",bottom:"Z"},mirror:true}),{version:1,name:e.name??c({en:"Traveler",ru:"\u041F\u0443\u0442\u043D\u0438\u043A"}),description:e.description??c({en:"A traveler in a shirt with pockets, trousers and laced boots",ru:"\u041F\u0443\u0442\u043D\u0438\u043A \u0432 \u0440\u0443\u0431\u0430\u0448\u043A\u0435 \u0441 \u043A\u0430\u0440\u043C\u0430\u043D\u0430\u043C\u0438, \u0431\u0440\u044E\u043A\u0430\u0445 \u0438 \u0448\u043D\u0443\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0445 \u0431\u043E\u0442\u0438\u043D\u043A\u0430\u0445"}),rig:"humanoid",palette:a,textures:i,parts:c$1,face:{bone:"head",rect:[0,3,8,5],expressions:{neutral:"f_neutral",blink:"f_blink",happy:"f_happy",sad:"f_sad",angry:"f_angry",surprised:"f_surprised",scared:"f_scared",tired:"f_tired",hurt:"f_hurt",talk:"f_talk"}},style:{walk:"normal",idle:"calm",energy:.5},finish:{noise:.5,outline:.4,shade:.25,density:2},tags:e.tags??["player"]}}function nt(e,t){return {textures:Object.fromEntries(Object.entries(vr).map(([r,o])=>[r,D(o)])),face:{bone:e,rect:t,expressions:{neutral:"f_neutral",blink:"f_blink",happy:"f_happy",sad:"f_sad",angry:"f_angry",surprised:"f_surprised",scared:"f_scared",tired:"f_tired",hurt:"f_hurt",talk:"f_talk"}}}}var Ot=_t(),Lt=null;function xe(){if(!Lt){let e=ae(Ot);if(!e.ok)throw new Error(e.error);Lt=e.spec;}return Lt}function Sr(e){let t=document.createElement("canvas");t.width=256,t.height=48;let r=t.getContext("2d");r&&(r.fillStyle="rgba(0,0,0,0.45)",r.fillRect(0,0,256,48),r.font="bold 28px sans-serif",r.fillStyle="#fff",r.textAlign="center",r.textBaseline="middle",r.fillText(e.slice(0,18),128,25));let o=new _.CanvasTexture(t),n=new _.Sprite(new _.SpriteMaterial({map:o,depthTest:false,transparent:true}));return n.scale.set(1.6,.3,1),n.renderOrder=10,n}function Ft(e){e.removeFromParent(),e.material.map?.dispose(),e.material.dispose();}var j={rx:0,ry:1,rz:2,px:3,py:4,pz:5,sx:6,sy:7,sz:8},ws=Object.keys(j),_e=[0,0,0,0,0,0,1,1,1];function Oe(e,t){let r=e.get(t);return r||(r=Float64Array.from(_e),e.set(t,r)),r}function ie(e,t,r,o){let n=Oe(e,t),a=j[r];a>=6?n[a]=n[a]*o:n[a]=n[a]+o;}function f(e,t,r,o){Oe(e,t)[j[r]]=o;}function ve(e){for(let t of e.values())t.set(_e);}function Tr(e,t,r,o){let n=new Set([...t.keys(),...r.keys()]);for(let a of n){let i=t.get(a)??_e,c=r.get(a)??_e,s=Oe(e,a);for(let l=0;l<9;l++)s[l]=i[l]+(c[l]-i[l])*o;}}function at(e,t){ve(e);for(let[r,o]of t)Oe(e,r).set(o);}var xs=["none","block","tool","sword","bow","shield","food","staff","item"];function st(){return {speed:0,vy:0,onGround:true,inWater:false,flying:false,gliding:false,sneaking:false,sprinting:false,riding:false,sitting:false,sleeping:false,dead:false,lookYaw:0,lookPitch:0,yawRate:0,held:"none",use:null,talk:false}}var vs=["swing","hurt","place","land","jump","throw"];var De=1/16,Cr=5921370,it=class{group=new _.Group;root=new _.Group;asset;spec;bones=new Map;byRole=new Map;meshes=[];material;decalMat;decal=null;expression=null;sockets=new Map;attached=new Map;label=null;shadows;layer;brightness=1;painter;prints=[];printMeshes=[];printMats=new Map;constructor(t=xe(),r={}){this.spec=t,this.shadows=r.shadows??true,this.layer=r.layer??0,this.painter=r.facePainter??null,this.material=new _.MeshLambertMaterial({alphaTest:.5}),this.decalMat=new _.MeshLambertMaterial({alphaTest:.5,polygonOffset:true,polygonOffsetFactor:-2,polygonOffsetUnits:-2}),this.group.add(this.root),this.asset=Pt(t),this.build(),r.name&&this.setName(r.name);}get height(){let t=this.asset.layout;return t.height*t.scale*De}get eye(){let t=this.asset.layout;return t.eye*t.scale*De}get expressions(){return Object.keys(this.asset.layout.face?.uv??{})}get hash(){return this.asset.layout.hash}setSpec(t){let r=Pt(t);if(r===this.asset){rt(r);return}this.clear(),rt(this.asset),this.asset=r,this.spec=t,this.build();}build(){let{layout:t,skinned:r,texture:o}=this.asset;this.material.map=o,this.material.needsUpdate=true,this.useFaceMap(),this.root.scale.setScalar(t.scale*De);let n=new Map(t.bones.map(s=>[s.name,s.pivot])),a=[],i=[];for(let s of t.bones){let l=new _.Bone;a.push(l),i.push(new _.Matrix4().makeTranslation(-s.pivot[0],-s.pivot[1],-s.pivot[2]));let h=s.parent?n.get(s.parent)??[0,0,0]:[0,0,0],m=[s.pivot[0]-h[0],s.pivot[1]-h[1],s.pivot[2]-h[2]];l.position.set(...m);let p={name:s.name,role:s.role,group:l,rest:m};this.bones.set(s.name,p);let u=this.byRole.get(s.role)??[];u.push(p),this.byRole.set(s.role,u);}for(let s of t.bones){let l=this.bones.get(s.name);((s.parent?this.bones.get(s.parent):void 0)?.group??this.root).add(l.group);}if(r){let s=new _.SkinnedMesh(r,this.material);s.bind(new _.Skeleton(a,i),new _.Matrix4);let l=r.boundingSphere;l&&(s.boundingSphere=new _.Sphere(l.center.clone(),l.radius*1.6)),s.castShadow=s.receiveShadow=this.shadows,s.layers.set(this.layer),this.meshes.push(s),this.root.add(s);}let c=t.face;if(c){let s=new _.BufferGeometry;s.setAttribute("position",new _.BufferAttribute(c.corners,3));let l=new Float32Array(12);for(let h=0;h<4;h++)l[h*3+2]=-1;s.setAttribute("normal",new _.BufferAttribute(l,3)),s.setAttribute("uv",new _.BufferAttribute(new Float32Array(8),2)),s.setIndex([0,2,1,0,3,2]),this.decal=new _.Mesh(s,this.decalMat),this.decal.layers.set(this.layer),this.bones.get(c.bone)?.group.add(this.decal),this.expression=null,this.setExpression("neutral");}for(let s of t.sockets){let l=new _.Object3D;l.position.set(...s.at),l.scale.setScalar(1/(t.scale*De)),this.bones.get(s.bone)?.group.add(l),this.sockets.set(s.name,l);let h=this.attached.get(s.name);h&&l.add(h);}this.buildPrints(),this.placeLabel(),this.setBrightness(this.brightness);}setPrints(t){this.prints=t??[],this.buildPrints(),this.setBrightness(this.brightness);}buildPrints(){for(let o of this.printMeshes)o.removeFromParent(),o.geometry.dispose();this.printMeshes=[];let t=new Set,r=new Map;for(let o of this.prints){let n=this.bones.get(o.bone),a=this.asset.layout.bones.find(h=>h.name===o.bone);if(!n||!a)continue;let i=this.printMats.get(o.texture);i||(i=new _.MeshLambertMaterial({map:o.texture,emissiveMap:o.texture,emissive:Cr,transparent:true,alphaTest:.02,polygonOffset:true,polygonOffsetFactor:-2,polygonOffsetUnits:-2}),this.printMats.set(o.texture,i)),t.add(o.texture);let c=new _.PlaneGeometry(o.w,o.h);o.facing==="front"&&c.rotateY(Math.PI),c.translate(o.center[0]-a.pivot[0],o.center[1]-a.pivot[1],o.center[2]-a.pivot[2]);let s=`${o.bone}|${o.texture.uuid}`,l=r.get(s)??{node:n,mat:i,geos:[]};l.geos.push(c),r.set(s,l);}for(let{node:o,mat:n,geos:a}of r.values()){let i=a.length===1?a[0]:mergeGeometries(a)??a[0];if(i!==a[0])for(let s of a)s.dispose();let c=new _.Mesh(i,n);c.layers.set(this.layer),o.group.add(c),this.printMeshes.push(c);}for(let[o,n]of this.printMats)t.has(o)||(n.dispose(),this.printMats.delete(o));}clear(){for(let t of this.sockets.values())for(let r of [...t.children])t.remove(r);this.root.clear();for(let t of this.printMeshes)t.geometry.dispose();this.printMeshes=[],this.decal?.geometry.dispose(),this.decal=null;for(let t of this.meshes)t instanceof _.SkinnedMesh&&t.skeleton.dispose();this.meshes=[],this.bones=new Map,this.byRole=new Map,this.sockets.clear();}applyPose(t){let r=t.get("root");if(r){this.root.rotation.set(r[j.rx],r[j.ry],r[j.rz]);let o=this.asset.layout.scale*De;this.root.position.set(r[j.px]*o,r[j.py]*o,r[j.pz]*o);}else this.root.rotation.set(0,0,0),this.root.position.set(0,0,0);for(let[o,n]of this.byRole){let a=t.get(o);for(let i of n){let c=i.group;if(!a){c.rotation.set(0,0,0),c.position.set(...i.rest),c.scale.set(1,1,1);continue}c.rotation.set(a[j.rx],a[j.ry],a[j.rz]),c.position.set(i.rest[0]+a[j.px],i.rest[1]+a[j.py],i.rest[2]+a[j.pz]),c.scale.set(a[j.sx],a[j.sy],a[j.sz]);}}}setFacePainter(t){if(t===this.painter)return;this.painter=t,this.useFaceMap();let r=this.expression??"neutral";this.expression=null,this.setExpression(r);}useFaceMap(){let t=this.painter;this.decalMat.map=t?t.texture:this.asset.texture,this.decalMat.transparent=!!t,this.decalMat.alphaTest=t?.02:.5,this.decalMat.needsUpdate=true;}setExpression(t){if(t===this.expression||!this.decal)return;let r=this.asset.layout.face?.uv,o=this.painter?[0,1,1,0]:r?.[t]??r?.neutral;if(!o)return;this.expression=t,this.painter?.paint(t);let[n,a,i,c]=o,s=this.decal.geometry.getAttribute("uv");s.setXY(0,n,a),s.setXY(1,i,a),s.setXY(2,i,c),s.setXY(3,n,c),s.needsUpdate=true;}materials(){return [this.material,this.decalMat]}setBrightness(t){this.brightness=t,this.material.color.setScalar(t),this.decalMat.color.setScalar(t);for(let r of this.printMats.values())r.color.setScalar(t);}setEmissive(t){if(this.material.emissive.getHex()!==t){this.material.emissive.setHex(t),this.decalMat.emissive.setHex(t);for(let r of this.printMats.values())r.emissive.setHex(t||Cr);}}setShadows(t){if(t!==this.shadows){this.shadows=t;for(let r of this.meshes)r.castShadow=t;}}attach(t,r){let o=this.attached.get(t);if(o!==r){if(o&&o.removeFromParent(),!r){this.attached.delete(t);return}this.attached.set(t,r),this.sockets.get(t)?.add(r);}}attachedAt(t){return this.attached.get(t)??null}setName(t){this.label&&Ft(this.label),this.label=t?Sr(t):null,this.label&&this.group.add(this.label),this.placeLabel();}setLabelVisible(t){this.label&&(this.label.visible=t);}placeLabel(){this.label&&(this.label.position.y=this.height+.25);}forEachMesh(t){for(let r of this.meshes)t(r);this.decal&&t(this.decal);for(let r of this.printMeshes)t(r);}dispose(){this.group.removeFromParent();for(let t of this.attached.values())t.removeFromParent();this.attached.clear(),this.clear(),this.label&&Ft(this.label),this.label=null,this.material.dispose(),this.decalMat.dispose();for(let t of this.printMats.values())t.dispose();this.printMats.clear(),rt(this.asset);}};var lt=new Map,Nt=new Set;function Is(e){let t=Pe(e);if(!lt.has(t)){lt.set(t,e);for(let r of Nt)r(t);}return t}function Ps(e){return typeof e=="string"?lt.get(e):void 0}function Ls(e){let t={};for(let r of e){let o=lt.get(r);o&&(t[r]=o);}return t}function zs(e){return Nt.add(e),()=>Nt.delete(e)}var Ko=["#b08a62","#8a6a4a","#c8a878","#9a9a92","#7a5c44"],Xo=["#f1c9a5","#e6b892","#d9a982","#c08e68","#a0704c","#7a5238"],Jo=["#6b4a2f","#4a3424","#8a5a3a","#c27a48","#d8b878","#2e2622","#a07850","#9a9690"],Zo=["#a7bea9","#e6e0cc","#d9c9a3","#b9a083","#a9b8c4","#c8b4a0","#9fb0a0","#d8d2c4","#b98f74","#8fa3b5"],Qo=["#8c9ca6","#a9b8b4","#8a8e94","#9fb3ad","#7d8a8f","#b0a58f"],en=["#d9c9a3","#c8b48a","#a08a6a","#e6e0cc"];function Hs(e,t="",r=""){let o=a(b("npc:"+e+"|"+t)),n=c=>c[Math.floor(o()*c.length)],a$1=_t({top:n(Ar),bottom:n(Er),shoes:n(kr),hair:n(["short","short","long","curly"]),hat:o()<.2,colors:{skin:n(Xo),hair:n(Jo),shirt:n(Zo),pants:n(Qo),boots:n(Ko),hat:n(en)}});a$1.name=e.slice(0,40),a$1.description=[t,r].filter(Boolean).join(" \u2014 ").slice(0,300),a$1.style={walk:n(["normal","normal","bouncy","heavy","sneaky"]),idle:n(["calm","calm","fidgety","proud"]),energy:Math.round(o()*10)/10},a$1.tags=["npc",...t?[t.slice(0,24)]:[]];let i=ae(a$1);return i.ok?i.spec:xe()}var be=([e,t,r])=>"#"+[e,t,r].map(o=>Math.round(o).toString(16).padStart(2,"0")).join("");function tn(e){if(!e.length)return null;let t=r=>{let o=e.map(n=>n[r]).sort((n,a)=>n-a);return o[o.length>>1]};return [t(0),t(1),t(2)]}function rn(e,t){let{width:r,height:o,data:n}=e,a=(k,g)=>{let b=(g*r+k)*4;return [n[b],n[b+1],n[b+2]]},i=[a(0,0),a(r-1,0),a(0,o-1),a(r-1,o-1)],c=[0,1,2].map(k=>i.reduce((g,b)=>g+b[k],0)/4),s=k=>Math.abs(k[0]-c[0])+Math.abs(k[1]-c[1])+Math.abs(k[2]-c[2])>60,l=r,h=-1,m=o,p=-1;for(let k=0;k<o;k+=2)for(let g=0;g<r;g+=2)s(a(g,k))&&(l=Math.min(l,g),h=Math.max(h,g),m=Math.min(m,k),p=Math.max(p,k));h<0&&(l=0,h=r-1,m=0,p=o-1);let u=p-m+1,x=h-l+1,y=l+Math.floor(x*.3),T=l+Math.ceil(x*.7);return t.map(([k,g])=>{let b=[];for(let S=m+Math.floor(u*k);S<m+Math.ceil(u*g);S++)for(let d=y;d<T;d++){if(S<0||S>=o||d<0||d>=r)continue;let v=a(d,S);s(v)&&b.push(v);}return tn(b)})}var on=[[0,.06],[.1,.22],[.3,.52],[.6,.86],[.92,1]];function Gs(e,t="humanoid",r=et()){let[o,n,a,i,c]=rn(e,on);if(t==="humanoid"){let l=JSON.parse(JSON.stringify(Ot));l.palette=zt(l.palette,{...o?{hair:be(o)}:{},...n?{skin:be(n)}:{},...a?{shirt:be(a)}:{},...i?{pants:be(i)}:{},...c?{boots:be(c)}:{}}),l.name=r,l.tags=[];let h=ae(l);return h.ok?h.spec:xe()}let s=ae({name:r,rig:t,palette:{s:be(n??o??[198,156,124]),t:be(a??[58,143,214]),p:be(i??c??[44,62,107]),w:"#f4f4f4",b:"#1d1d21"},textures:{f_neutral:{w:4,h:2,rows:["wbbw","...."]},f_blink:{w:4,h:2,rows:["bbbb","...."]}},face:{rect:t==="blob"?[4,4,4,2]:t==="flyer"?[0,1,4,2]:[2,2,4,2],expressions:{neutral:"f_neutral",blink:"f_blink"}}});return s.ok?s.spec:xe()}var nn={normal:{},bouncy:{amp:.9,arm:.8,bob:1.6,tempo:1.1,sway:.04},heavy:{amp:.6,arm:.4,bob:.6,tempo:.8,sway:.12},sneaky:{amp:.5,arm:.3,tempo:1.2},robotic:{amp:.7,arm:.7,quant:true}},an={calm:{},fidgety:{fidget:1,breath:1.3},proud:{chest:.08,breath:.8}};function Ht(e){let t={amp:.8,arm:.6,bob:0,tempo:1,sway:0,quant:false,breath:1,fidget:0,chest:0,...nn[e.walk],...an[e.idle]};return t.tempo*=.8+.4*e.energy,t.amp*=.85+.3*e.energy,t}function ct(e,t=0){let r=Math.sin(e.phase+t);return e.style.quant?Math.max(-1,Math.min(1,r*3)):r}function Dt(e,t,r){let o=ct(t)*r;f(e,"legL","rx",o),f(e,"legR","rx",-o),f(e,"legFL","rx",o),f(e,"legBR","rx",o),f(e,"legFR","rx",-o),f(e,"legBL","rx",-o);}function Bt(e,t,r){let o=ct(t)*r;f(e,"armL","rx",-o),f(e,"armR","rx",o);}function Vt(e,t,r,o){let n=ct(t),a=Math.max(0,Math.cos(t.phase))*Math.max(0,-n+.3),i=Math.max(0,-Math.cos(t.phase))*Math.max(0,n+.3);f(e,"shinL","rx",-r*(.15+a)),f(e,"shinR","rx",-r*(.15+i)),f(e,"foreArmL","rx",o*(.6+.4*Math.max(0,-n))),f(e,"foreArmR","rx",o*(.6+.4*Math.max(0,n)));}var sn=(e,t)=>{let r=Math.sin(t.clock*2)*t.style.breath;f(e,"armL","rz",-0.04-.03*r),f(e,"armR","rz",.04+.03*r),f(e,"foreArmL","rx",.12+.02*r),f(e,"foreArmR","rx",.12+.02*r),f(e,"head","rx",.03*Math.sin(t.clock*1.7)+t.style.chest),f(e,"body","rx",t.style.chest*-0.5),t.style.fidget&&(f(e,"head","ry",.35*Math.sin(t.clock*.7)*Math.sin(t.clock*.31)),f(e,"root","ry",.05*Math.sin(t.clock*.9))),f(e,"body","sy",1+.04*Math.sin(t.clock*3));},ln=(e,t)=>{Dt(e,t,t.style.amp),Bt(e,t,t.style.arm),Vt(e,t,t.style.amp*1.1,.35),f(e,"root","py",t.style.bob*Math.abs(Math.cos(t.phase))),f(e,"body","rz",t.style.sway*ct(t));},cn=(e,t)=>{Dt(e,t,t.style.amp*1.3),Bt(e,t,t.style.arm*1.6),Vt(e,t,t.style.amp*1.6,1.1),f(e,"body","rx",-0.18),f(e,"head","rx",.18),f(e,"root","py",(.8+t.style.bob)*Math.abs(Math.cos(t.phase)));},pn=(e,t)=>{Dt(e,t,t.style.amp*.5*Math.min(1,t.input.speed)),Bt(e,t,t.style.arm*.4*Math.min(1,t.input.speed)),f(e,"body","rx",-0.45),f(e,"head","rx",.45),ie(e,"armL","rx",.25),ie(e,"armR","rx",.25),Vt(e,t,.9,.6),f(e,"root","py",-1.5);},hn=(e,t)=>{f(e,"root","rx",-1.3),f(e,"head","rx",1),f(e,"armL","rx",Math.PI-.5+.5*Math.sin(t.t*3)),f(e,"armR","rx",Math.PI-.5+.5*Math.sin(t.t*3+Math.PI)),f(e,"legL","rx",.3*Math.sin(t.t*8)),f(e,"legR","rx",-0.3*Math.sin(t.t*8));},mn=(e,t)=>{f(e,"legL","rx",.15),f(e,"legR","rx",.1),f(e,"armL","rz",-0.15),f(e,"armR","rz",.15),f(e,"root","py",.6*Math.sin(t.t*2));},dn=e=>{f(e,"root","rx",-1.35),f(e,"head","rx",1.1),f(e,"armL","rz",-1.3),f(e,"armR","rz",1.3);},fn=(e,t)=>{let r=.15*Math.sin(t.t*10);f(e,"armL","rz",-0.6-r),f(e,"armR","rz",.6+r),f(e,"legL","rx",.25),f(e,"legR","rx",-0.25),f(e,"shinL","rx",-0.5),f(e,"shinR","rx",-0.3),f(e,"foreArmL","rx",.4),f(e,"foreArmR","rx",.4);},un=e=>{f(e,"legL","rx",1.45),f(e,"legR","rx",1.45),f(e,"legL","ry",.1),f(e,"legR","ry",-0.1),f(e,"shinL","rx",-1.45),f(e,"shinR","rx",-1.45),f(e,"root","py",-10),f(e,"body","rx",.4),f(e,"legBL","rx",1.2),f(e,"legBR","rx",1.2);},bn=e=>{f(e,"legL","rx",1.4),f(e,"legR","rx",1.4),f(e,"legL","rz",-0.3),f(e,"legR","rz",.3),f(e,"armL","rx",.45),f(e,"armR","rx",.45),f(e,"shinL","rx",-1.2),f(e,"shinR","rx",-1.2),f(e,"foreArmL","rx",.5),f(e,"foreArmR","rx",.5);},yn=e=>{f(e,"root","rx",Math.PI/2),f(e,"root","py",2);},gn=e=>{f(e,"root","rz",Math.PI/2),f(e,"root","py",2);},wn=(e,t)=>{let r=Math.sin(t.phase*.5);f(e,"root","py",6*Math.max(0,r));let o=r<0?.2*-r:0;f(e,"body","sy",1-o+.1*Math.max(0,r)),f(e,"body","sx",1+o*.6),f(e,"body","sz",1+o*.6);},xn=(e,t)=>{let r=Math.sin(Math.PI*t.k);f(e,"armR","rx",1.9*r),f(e,"armR","ry",.3*r),f(e,"body","ry",-0.3*r),f(e,"foreArmR","rx",.6*r);},vn=(e,t)=>{let r=Math.sin(Math.PI*t.k);f(e,"armR","rx",.9*r);},Rn=(e,t)=>{let r=t.k<.4?-1.5*(t.k/.4):-1.5+3.5*((t.k-.4)/.6);f(e,"armR","rx",t.k>.9?r*(1-t.k)*10:r);},An=(e,t)=>{let r=Math.sin(Math.PI*t.k);f(e,"body","rx",.15*r),f(e,"head","rx",.2*r),f(e,"root","rz",.05*r);},En=(e,t)=>{let r=Math.sin(Math.PI*t.k);f(e,"root","py",-1.5*r),f(e,"legL","rx",.2*r),f(e,"legR","rx",.2*r),f(e,"shinL","rx",-0.5*r),f(e,"shinR","rx",-0.5*r),f(e,"body","sy",1-.2*r),f(e,"body","sx",1+.12*r),f(e,"body","sz",1+.12*r);},kn=(e,t)=>{f(e,"armR","rx",1.3+.1*Math.sin(t.t*16)),f(e,"armR","ry",-0.5),f(e,"head","rx",-0.1+.08*Math.sin(t.t*16));},Sn=e=>{f(e,"armR","rx",2),f(e,"armR","ry",-0.4),f(e,"head","rx",.35);},Tn=e=>{f(e,"armR","rx",1.57),f(e,"armR","ry",-0.1),f(e,"armL","rx",1.57),f(e,"armL","ry",.35);},Cn=e=>{f(e,"armL","rx",.9),f(e,"armL","ry",-0.6);},pt={idle:sn,walk:ln,run:cn,sneak:pn,swim:hn,fly:mn,glide:dn,fall:fn,sit:un,ride:bn,sleep:yn,dead:gn,hop:wn,swing:xn,place:vn,throw:Rn,hurt:An,land:En,eat:kn,drink:Sn,draw:Tn,block:Cn},Mr={blob:{walk:"hop",run:"hop",sneak:"hop"}},Ir={swing:.3,place:.2,throw:.45,hurt:.3,land:.22};var ht=Math.PI,mt={wave:{label:"\u041F\u043E\u043C\u0430\u0445\u0430\u0442\u044C",duration:2,emotion:"happy",tracks:{"armR.rz":[[0,0],[.25,2.7],[.5,2.3],[.75,2.8],[1,2.3],[1.25,2.8],[1.5,2.4],[2,0]],"armR.rx":[[0,0],[.25,.2],[1.75,.2],[2,0]],"head.rz":[[0,0],[.5,.1],[1.5,.1],[2,0]]}},cheer:{label:"\u0423\u0440\u0430!",duration:1.6,emotion:"happy",tracks:{"armL.rz":[[0,0],[.25,-2.8],[1.35,-2.8],[1.6,0]],"armR.rz":[[0,0],[.25,2.8],[1.35,2.8],[1.6,0]],"root.py":[[0,0],[.3,3],[.55,0],[.8,3],[1.05,0]]}},dance:{label:"\u0422\u0430\u043D\u0435\u0446",duration:2,loop:true,emotion:"happy",tracks:{"root.ry":[[0,.3],[.5,-0.3],[1,.3],[1.5,-0.3],[2,.3]],"armL.rz":[[0,-0.4],[.5,-2.4],[1,-0.4],[1.5,-2.4],[2,-0.4]],"armR.rz":[[0,2.4],[.5,.4],[1,2.4],[1.5,.4],[2,2.4]],"legL.rx":[[0,0],[.5,.5],[1,0],[2,0]],"legR.rx":[[0,0],[1,0],[1.5,.5],[2,0]],"root.py":[[0,0],[.25,1.5],[.5,0],[.75,1.5],[1,0],[1.25,1.5],[1.5,0],[1.75,1.5],[2,0]],"tail.ry":[[0,.6],[.5,-0.6],[1,.6],[1.5,-0.6],[2,.6]]}},point:{label:"\u0423\u043A\u0430\u0437\u0430\u0442\u044C",duration:1.6,tracks:{"armR.rx":[[0,0],[.2,1.55],[1.4,1.55],[1.6,0]]}},laugh:{label:"\u0421\u043C\u0435\u0445",duration:1.6,emotion:"happy",tracks:{"body.rx":[[0,0],[.2,.15],[.4,.05],[.6,.15],[.8,.05],[1,.15],[1.2,.05],[1.6,0]],"head.rx":[[0,0],[.2,.3],[1.4,.3],[1.6,0]],"armL.rx":[[0,0],[.2,.5],[1.4,.5],[1.6,0]],"armR.rx":[[0,0],[.2,.5],[1.4,.5],[1.6,0]]}},cry:{label:"\u041F\u043B\u0430\u043A\u0430\u0442\u044C",duration:2.4,emotion:"sad",tracks:{"head.rx":[[0,0],[.3,-0.4],[2.1,-0.4],[2.4,0]],"head.rz":[[0,0],[.6,.08],[.9,-0.08],[1.2,.08],[1.5,-0.08],[2.4,0]],"armR.rx":[[0,0],[.3,2.3],[2.1,2.3],[2.4,0]],"armR.ry":[[0,0],[.3,-0.6],[2.1,-0.6],[2.4,0]],"armL.rx":[[0,0],[.3,2.3],[2.1,2.3],[2.4,0]],"armL.ry":[[0,0],[.3,.6],[2.1,.6],[2.4,0]]}},bow:{label:"\u041F\u043E\u043A\u043B\u043E\u043D",duration:1.4,tracks:{"body.rx":[[0,0],[.4,-0.7],[1,-0.7],[1.4,0]],"armR.rx":[[0,0],[.4,.5],[1,.5],[1.4,0]]}},shrug:{label:"\u041F\u043E\u0436\u0430\u0442\u044C \u043F\u043B\u0435\u0447\u0430\u043C\u0438",duration:1.2,tracks:{"armL.rz":[[0,0],[.3,-0.5],[.9,-0.5],[1.2,0]],"armR.rz":[[0,0],[.3,.5],[.9,.5],[1.2,0]],"armL.rx":[[0,0],[.3,.6],[.9,.6],[1.2,0]],"armR.rx":[[0,0],[.3,.6],[.9,.6],[1.2,0]],"head.rz":[[0,0],[.3,.25],[.9,.25],[1.2,0]]}},facepalm:{label:"\u0420\u0443\u043A\u0430-\u043B\u0438\u0446\u043E",duration:1.6,emotion:"tired",tracks:{"armR.rx":[[0,0],[.3,2.5],[1.3,2.5],[1.6,0]],"armR.rz":[[0,0],[.3,-0.4],[1.3,-0.4],[1.6,0]],"head.rx":[[0,0],[.3,-0.35],[1.3,-0.35],[1.6,0]]}},sit:{label:"\u0421\u0435\u0441\u0442\u044C",duration:1,loop:true,tracks:{"legL.rx":[[0,ht*.46],[1,ht*.46]],"legR.rx":[[0,ht*.46],[1,ht*.46]],"root.py":[[0,-10],[1,-10]]}}},Ws=Object.keys(mt);function Ks(e){return typeof e=="string"&&e in mt}function Mn(e,t){let r=e[0];if(t<=r[0])return r[1];for(let o=1;o<e.length;o++){let n=e[o];if(t<=n[0]){let a=e[o-1],i=(t-a[0])/Math.max(1e-6,n[0]-a[0]),c=i*i*(3-2*i);return a[1]+(n[1]-a[1])*c}}return e[e.length-1][1]}function Pr(e,t,r){let o=t.loop?r%t.duration:Math.min(r,t.duration);for(let[n,a]of Object.entries(t.tracks)){let i=n.lastIndexOf("."),c=n.slice(0,i),s=n.slice(i+1);s in j&&f(e,c,s,Mn(a,o));}}var Lr={neutral:["neutral"],happy:["happy","neutral"],sad:["sad","tired","neutral"],angry:["angry","neutral"],surprised:["surprised","scared","neutral"],scared:["scared","surprised","sad","neutral"],tired:["tired","sad","neutral"],hurt:["hurt","angry","sad","neutral"]},jt={neutral:{add:{},tempo:1},happy:{add:{"head.rx":.08},tempo:1.1},sad:{add:{"head.rx":-0.3,"body.rx":-0.08,"tail.rx":.5},tempo:.8},angry:{add:{"body.rx":-0.12,"head.rx":.1,"armL.rz":-0.1,"armR.rz":.1},tempo:1.1},surprised:{add:{"head.rx":.15,"body.rx":.05},tempo:1},scared:{add:{"body.rx":-0.1,"head.rx":-0.1,"armL.rx":.3,"armR.rx":.3,"tail.rx":.6},tempo:1.3},tired:{add:{"head.rx":-0.35,"body.rx":-0.12},tempo:.7},hurt:{add:{"body.rx":-0.1},tempo:1}};function zr(e,t,r){if(!(r<=0))for(let[o,n]of Object.entries(jt[t].add)){let a=o.lastIndexOf(".");ie(e,o.slice(0,a),o.slice(a+1),(n??0)*r);}}var Qs={damaged:{emotion:"hurt",seconds:.8},lowHealth:{emotion:"tired"},nearDeath:{emotion:"scared"},achievement:{emotion:"happy",seconds:3},bossKilled:{emotion:"happy",seconds:5},tamed:{emotion:"happy",seconds:3},traded:{emotion:"happy",seconds:2},petDied:{emotion:"sad",seconds:6},explosion:{emotion:"surprised",seconds:1.5}};function ei(e){let t=[[/(>:\(|😠|😡|🤬)/u,"angry"],[/(:'\(|😢|😭)/u,"sad"],[/(:\(|☹|🙁|😞)/u,"sad"],[/(:o|:O|😮|😲)/u,"surprised"],[/(😱|😨)/u,"scared"],[/(-_-|😴|😩|🥱)/u,"tired"],[/(:\)|:D|\^\^|😀|😃|😄|😁|🙂|😊|😂)/u,"happy"]];for(let[r,o]of t)if(r.test(e))return o;return null}var In=[{state:"dead",when:e=>e.dead,clip:"dead",blend:.25},{state:"sleep",when:e=>e.sleeping,clip:"sleep",blend:.3},{state:"ride",when:e=>e.riding,clip:"ride",blend:.2},{state:"sit",when:e=>e.sitting,clip:"sit",blend:.3},{state:"swim",when:e=>e.inWater&&!e.onGround&&!e.flying,clip:"swim",blend:.3},{state:"glide",when:e=>e.gliding,clip:"glide",blend:.25},{state:"fly",when:e=>e.flying,clip:"fly",blend:.25},{state:"fall",when:(e,t)=>t.airTime>.35&&e.vy<-4,clip:"fall",blend:.2},{state:"sneak",when:e=>e.sneaking,clip:"sneak",blend:.15},{state:"run",when:e=>e.sprinting&&e.speed>3||e.speed>6.5,clip:"run",blend:.15},{state:"walk",when:e=>e.speed>.4,clip:"walk",blend:.15},{state:"idle",when:()=>true,clip:"idle",blend:.2}],Pn=new Set(["hurt","land"]),Ln={eat:"eat",drink:"drink",draw:"draw",block:"block"},zn={tail:(e,t)=>[["ry",-e.yawRate*.25+.12*Math.sin(t*2)],["rx",-(.1+Math.min(e.speed,8)*.06)]],cape:(e,t)=>[["rx",-(.05+Math.min(e.speed,8)*.12)-(e.speed>1?.06*Math.sin(t*9):0)-(e.vy<-3?.4:0)]],hair:e=>[["rx",-Math.min(e.speed,8)*.03]],ear:(e,t)=>[["rz",.08*Math.sin(t*1.3)+Math.min(e.speed,6)*.02]],antenna:(e,t)=>[["rx",.1*Math.sin(t*3)-e.vy*.02]],wingL:(e,t)=>e.flying||e.gliding||!e.onGround&&!e.inWater?[["rz",e.gliding?-0.05:-0.7*Math.sin(t*12)]]:[["rz",1.1+.05*Math.sin(t*1.5)]],wingR:(e,t)=>e.flying||e.gliding||!e.onGround&&!e.inWater?[["rz",e.gliding?.05:.7*Math.sin(t*12)]]:[["rz",-1.1-.05*Math.sin(t*1.5)]]},dt=e=>{let t=Math.max(0,Math.min(1,e));return t*t*(3-2*t)},ft=class{rig;style;faces;pose=new Map;expression="neutral";state="idle";stateT=0;clock=0;phase=0;airTime=0;wasOnGround=true;loco=new Map;from=new Map;lastLoco=new Map;blendT=1;blendDur=.2;tmp=new Map;actions=[];useClip=null;useW=0;emote=null;mood="neutral";flash=null;postureW=new Map;blinkT=3;blinking=0;talkT=0;springs=new Map;constructor(t,r,o=[]){this.rig=t,this.style=Ht(r),this.faces=new Set(o);}setRandom(t){this.random=t;}random=Math.random;setStyle(t){this.style=Ht(t);}setEmotion(t,r){r&&r>0?this.flash={emotion:t,left:r}:this.mood=t;}get emotion(){return this.emote?.def.emotion?this.emote.def.emotion:this.flash?.emotion??this.mood}get emoting(){return this.emote?.id??null}playEmote(t){this.emote={id:t,def:mt[t],t:0};}stopEmote(){this.emote=null;}trigger(t){switch(t){case "swing":case "place":case "throw":case "hurt":case "land":{let r=t;this.actions=this.actions.filter(o=>o.clip!==r),this.actions.push({clip:r,t:0,dur:Ir[r]??.3}),t==="hurt"&&this.setEmotion("hurt",.8);break}}}update(t,r=st()){t=Math.min(t,.1),this.clock+=t;let o=this.emotion,n=jt[o].tempo*this.style.tempo;!r.onGround&&!r.inWater?this.airTime+=t:(!this.wasOnGround&&this.airTime>.3&&r.onGround&&this.trigger("land"),this.airTime=0),this.wasOnGround=r.onGround,this.phase+=r.speed*t*3.5*n;let a=In.find(l=>l.when(r,this));a.state!==this.state&&(at(this.from,this.lastLoco),this.state=a.state,this.stateT=0,this.blendT=0,this.blendDur=a.blend),this.stateT+=t,ve(this.loco);let i=Mr[this.rig]?.[a.clip]??a.clip,c={t:this.stateT,k:0,phase:this.phase,input:r,style:this.style,clock:this.clock*n};if(pt[i](this.loco,c),ve(this.pose),this.blendT<this.blendDur?(this.blendT+=t,Tr(this.pose,this.from,this.loco,dt(this.blendT/this.blendDur))):at(this.pose,this.loco),at(this.lastLoco,this.pose),this.emote){let l=this.emote;if(l.t+=t,r.speed>1||this.state!=="idle"||!l.def.loop&&l.t>=l.def.duration)this.emote=null;else {let p=l.def.loop?dt(l.t/.15):dt(Math.min(l.t/.15,(l.def.duration-l.t)/.15));ve(this.tmp),Pr(this.tmp,l.def,l.t),this.overlay(this.tmp,p,false);}}let s=r.use?Ln[r.use]:null;s&&(this.useClip=s),this.useW=Math.max(0,Math.min(1,this.useW+(s?t:-t)*8)),this.useClip&&this.useW>0?(ve(this.tmp),pt[this.useClip](this.tmp,{...c,t:this.clock}),this.overlay(this.tmp,dt(this.useW),false)):r.held!=="none"&&!this.emote&&ie(this.pose,"armR","rx",r.held==="staff"?.35:.2);for(let l of this.actions){l.t+=t;let h=Math.min(1,l.t/l.dur);ve(this.tmp),pt[l.clip](this.tmp,{...c,t:l.t,k:h}),this.overlay(this.tmp,1,Pn.has(l.clip));}this.actions=this.actions.filter(l=>l.t<l.dur),this.state!=="dead"&&this.state!=="sleep"&&(ie(this.pose,"head","ry",Math.max(-1.1,Math.min(1.1,r.lookYaw))),ie(this.pose,"head","rx",Math.max(-1.2,Math.min(1.2,r.lookPitch)))),this.flash&&(this.flash.left-=t)<=0&&(this.flash=null);for(let l of a$1){let h=this.postureW.get(l)??0,m=h+((l===o?1:0)-h)*Math.min(1,t*6);this.postureW.set(l,m),this.state!=="dead"&&zr(this.pose,l,m);}for(let[l,h]of Object.entries(zn))for(let[m,p]of h(r,this.clock)){let u=l+"."+m,x=this.springs.get(u);x||this.springs.set(u,x={x:p,v:0});let y=60,T=9;x.v+=(y*(p-x.x)-T*x.v)*t,x.x+=x.v*t,ie(this.pose,l,m,x.x);}return this.expression=this.face(r,t,o),this.pose}overlay(t,r,o){for(let[n,a]of t){let i=Oe(this.pose,n);for(let c=0;c<9;c++)o?c>=j.sx?i[c]=i[c]*(1+(a[c]-1)*r):i[c]=i[c]+(a[c]-_e[c])*r:i[c]=i[c]+(a[c]-i[c])*r;}}face(t,r,o){let n=i=>i.find(c=>this.faces.has(c))??"neutral";if(t.dead||this.state==="dead"||t.sleeping)return n(["blink","hurt","neutral"]);let a=n(Lr[o]);return t.viseme!==void 0?(this.talkT=0,t.viseme!=="rest"&&t.viseme!=="MBP"?n(["talk",a]):a):t.talk?(this.talkT+=r,Math.floor(this.talkT/.12)%2===0?n(["talk",a]):a):(this.talkT=0,this.blinking>0?(this.blinking-=r,n(["blink",a])):(this.blinkT-=r,this.blinkT<=0&&(this.blinkT=2.5+this.random()*3,o!=="surprised"&&o!=="scared"&&o!=="hurt"&&(this.blinking=.13)),a))}};var _n={idle:{},talk:{},walk:{speed:1.6},run:{speed:5.2},surprised:{emote:"shrug"},point:{emote:"point"},sit:{sitting:true},wave:{emote:"wave"},jump:{air:true},fall:{emote:"facepalm"},dance:{emote:"dance"}},On={handR:"handR",handL:"handL",head:"headTop"},ut=class{view;animator;input=st();seed;pose="idle";jumpT=-1;constructor(t,r={}){this.view=new it(t,{shadows:false,...r}),this.seed=r.seed??1,this.animator=this.newAnimator();}get group(){return this.view.group}get height(){return this.view.height}setSpec(t){let r=this.view.hash;this.view.setSpec(t),this.view.hash!==r&&(this.animator=this.newAnimator());}setEmotion(t){this.animator.setEmotion(t);}setViseme(t){this.input.viseme=t;}setPose(t){if(t===this.pose)return;this.pose=t;let r=_n[t];this.input.speed=r.speed??0,this.input.sitting=!!r.sitting,r.emote&&this.animator.playEmote(r.emote),r.air&&(this.jumpT=0,this.animator.trigger("jump"));}playEmote(t){this.animator.playEmote(t);}trigger(t){if(t==="jump"){this.jumpT=0,this.animator.trigger("jump");return}this.animator.trigger(t);}attach(t,r){this.view.attach(On[t],r);}update(t){let r=this.input;this.jumpT>=0&&(this.jumpT+=t,r.onGround=this.jumpT>.6,r.vy=this.jumpT<.3?4:-4,r.onGround&&(this.jumpT=-1,r.vy=0,this.animator.trigger("land")));let o=this.animator.update(t,r);this.view.applyPose(o),this.view.setExpression(this.animator.expression);}dispose(){this.view.dispose();}newAnimator(){let t=this.view.spec,r=new ft(t.rig,t.style,this.view.expressions);return r.setRandom(a(this.seed)),r}};var Fn=Fe.map(e=>{let t=ne[e],r=t.bones.map(n=>`${n.name}@[${n.pivot.join(",")}]`).join(" "),o=t.defaultParts.map(n=>`${n.bone} ${n.size.join("x")} at [${n.pos.join(",")}]`).join("; ");return `- "${e}" \u2014 ${t.hint}. Bones (name@pivot): ${r}. Default body: ${o}.`}).join(`
|
|
2
|
-
|
|
1
|
+
import {a as a$1}from'../chunk-64D567CX.js';export{a as EMOTIONS,b as isEmotion}from'../chunk-64D567CX.js';import {c,d}from'../chunk-YOAPVGXE.js';import {b,a}from'../chunk-CGF2TQVK.js';import*as O from'three';import {mergeGeometries}from'three/examples/jsm/utils/BufferGeometryUtils.js';import {RoomEnvironment}from'three/examples/jsm/environments/RoomEnvironment.js';var ir={id:"avatar",label:"\u0410\u0432\u0430\u0442\u0430\u0440",hint:"the iDos Games account avatar: soft blocks with elbows and knees",bones:[{name:"body",role:"body",parent:null,pivot:[0,12.4,0]},{name:"head",role:"head",parent:"body",pivot:[0,22.4,0]},{name:"armL",role:"armL",parent:"body",pivot:[-6.3,21.4,0]},{name:"armR",role:"armR",parent:"body",pivot:[6.3,21.4,0]},{name:"foreArmL",role:"foreArmL",parent:"armL",pivot:[-6.3,17.2,0]},{name:"foreArmR",role:"foreArmR",parent:"armR",pivot:[6.3,17.2,0]},{name:"legL",role:"legL",parent:null,pivot:[-2.1,12.4,0]},{name:"legR",role:"legR",parent:null,pivot:[2.1,12.4,0]},{name:"shinL",role:"shinL",parent:"legL",pivot:[-2.1,6.4,0]},{name:"shinR",role:"shinR",parent:"legR",pivot:[2.1,6.4,0]}],sockets:[{name:"handR",bone:"foreArmR",at:[6.3,11.6,-1]},{name:"handL",bone:"foreArmL",at:[-6.3,11.6,-1]},{name:"headTop",bone:"head",at:[0,30.3,0]},{name:"face",bone:"head",at:[0,26.7,-4]},{name:"back",bone:"body",at:[0,18.5,2.3]},{name:"waist",bone:"body",at:[0,12.8,0]},{name:"shoulders",bone:"body",at:[0,22.4,0]}],hitbox:{w:.6,h:1.9},eye:26.4,height:{min:24,max:40},faceBone:"head",defaultParts:[{bone:"head",size:[8.5,7.5,8],pos:[0,26.5,0],color:"s",name:"head"},{bone:"head",size:[2.9,.8,2.7],pos:[0,22.6,0],color:"s",name:"neck"},{bone:"body",size:[9,6,4.6],pos:[0,19.4,0],color:"t",name:"torso"},{bone:"body",size:[8.5,5.2,4.3],pos:[0,15,0],color:"t",name:"torso"},{bone:"armL",size:[3.6,5,3.6],pos:[-6.3,19.7,0],color:"s",name:"sleeveL"},{bone:"armR",size:[3.6,5,3.6],pos:[6.3,19.7,0],color:"s",name:"sleeveR"},{bone:"foreArmL",size:[3.45,5.4,3.45],pos:[-6.3,15.7,0],color:"s",name:"forearmL"},{bone:"foreArmR",size:[3.45,5.4,3.45],pos:[6.3,15.7,0],color:"s",name:"forearmR"},{bone:"foreArmL",size:[3.3,3,3.3],pos:[-6.3,12.7,0],color:"s",name:"handL"},{bone:"foreArmR",size:[3.3,3,3.3],pos:[6.3,12.7,0],color:"s",name:"handR"},{bone:"legL",size:[4.2,6,4.2],pos:[-2.1,9.4,0],color:"p",name:"legL"},{bone:"legR",size:[4.2,6,4.2],pos:[2.1,9.4,0],color:"p",name:"legR"},{bone:"shinL",size:[4.05,7.2,4.05],pos:[-2.1,4,0],color:"p",name:"legL"},{bone:"shinR",size:[4.05,7.2,4.05],pos:[2.1,4,0],color:"p",name:"legR"},{bone:"shinL",size:[4.2,1.6,5.2],pos:[-2.1,.8,-0.5],color:"p",name:"footL"},{bone:"shinR",size:[4.2,1.6,5.2],pos:[2.1,.8,-0.5],color:"p",name:"footR"}]};var lr={id:"blob",label:"\u041A\u0430\u043F\u043B\u044F",hint:"slimes, ghosts, spirits, living objects \u2014 one body with a face, moves by hopping",bones:[{name:"body",role:"body",parent:null,pivot:[0,0,0]}],sockets:[{name:"headTop",bone:"body",at:[0,12,0]},{name:"face",bone:"body",at:[0,7,-6]},{name:"back",bone:"body",at:[0,6,6]},{name:"waist",bone:"body",at:[0,3,0]},{name:"shoulders",bone:"body",at:[0,10,0]},{name:"handR",bone:"body",at:[6,5,-2]},{name:"handL",bone:"body",at:[-6,5,-2]}],hitbox:{w:.8,h:.8},eye:8,height:{min:4,max:40},faceBone:"body",defaultParts:[{bone:"body",size:[12,12,12],pos:[0,6,0],color:"t"}]};var cr={id:"flyer",label:"\u041A\u0440\u044B\u043B\u0430\u0442\u044B\u0439",hint:"birds, bats, dragons, fairies, insects \u2014 creatures whose wings matter",bones:[{name:"body",role:"body",parent:null,pivot:[0,6,0]},{name:"head",role:"head",parent:"body",pivot:[0,11,-3]},{name:"wingL",role:"wingL",parent:"body",pivot:[-3,10,0]},{name:"wingR",role:"wingR",parent:"body",pivot:[3,10,0]},{name:"legL",role:"legL",parent:null,pivot:[-1.5,4,0]},{name:"legR",role:"legR",parent:null,pivot:[1.5,4,0]},{name:"tail",role:"tail",parent:"body",pivot:[0,8,4]}],sockets:[{name:"headTop",bone:"head",at:[0,16,-4]},{name:"face",bone:"head",at:[0,13,-7]},{name:"back",bone:"body",at:[0,11,1]},{name:"waist",bone:"body",at:[0,6,0]},{name:"shoulders",bone:"body",at:[0,10,-2]},{name:"handR",bone:"legR",at:[1.5,0,-1]},{name:"handL",bone:"legL",at:[-1.5,0,-1]}],hitbox:{w:.6,h:.9},eye:14,height:{min:6,max:40},faceBone:"head",defaultParts:[{bone:"body",size:[6,6,8],pos:[0,8,0],color:"t"},{bone:"head",size:[5,5,5],pos:[0,13,-4],color:"s"},{bone:"wingL",size:[8,1,6],pos:[-7,10,0],color:"t"},{bone:"wingR",size:[8,1,6],pos:[7,10,0],color:"t"},{bone:"legL",size:[1,4,1],pos:[-1.5,2,0],color:"p"},{bone:"legR",size:[1,4,1],pos:[1.5,2,0],color:"p"},{bone:"tail",size:[4,1,4],pos:[0,8,6],color:"t"}]};var pr={id:"humanoid",label:"\u0427\u0435\u043B\u043E\u0432\u0435\u043A",hint:"people, humanoids, robots, elves, zombies \u2014 anything on two legs with two arms",bones:[{name:"body",role:"body",parent:null,pivot:[0,12,0]},{name:"head",role:"head",parent:"body",pivot:[0,24,0]},{name:"armL",role:"armL",parent:"body",pivot:[-6,22,0]},{name:"armR",role:"armR",parent:"body",pivot:[6,22,0]},{name:"legL",role:"legL",parent:null,pivot:[-2,12,0]},{name:"legR",role:"legR",parent:null,pivot:[2,12,0]}],sockets:[{name:"handR",bone:"armR",at:[6,11,-1]},{name:"handL",bone:"armL",at:[-6,11,-1]},{name:"headTop",bone:"head",at:[0,32,0]},{name:"face",bone:"head",at:[0,28,-4]},{name:"back",bone:"body",at:[0,18,2]},{name:"waist",bone:"body",at:[0,12,0]},{name:"shoulders",bone:"body",at:[0,24,0]}],hitbox:{w:.6,h:1.8},eye:27,height:{min:16,max:48},faceBone:"head",defaultParts:[{bone:"head",size:[8,8,8],pos:[0,28,0],color:"s"},{bone:"body",size:[8,12,4],pos:[0,18,0],color:"t"},{bone:"armL",size:[4,12,4],pos:[-6,18,0],color:"s"},{bone:"armR",size:[4,12,4],pos:[6,18,0],color:"s"},{bone:"legL",size:[4,12,4],pos:[-2,6,0],color:"p"},{bone:"legR",size:[4,12,4],pos:[2,6,0],color:"p"}]};var hr={id:"quadruped",label:"\u0427\u0435\u0442\u0432\u0435\u0440\u043E\u043D\u043E\u0433\u043E\u0435",hint:"dogs, cats, horses, wolves, bears, lizards \u2014 any animal on four legs",bones:[{name:"body",role:"body",parent:null,pivot:[0,12,0]},{name:"head",role:"head",parent:"body",pivot:[0,14,-8]},{name:"legFL",role:"legFL",parent:null,pivot:[-3,8,-6]},{name:"legFR",role:"legFR",parent:null,pivot:[3,8,-6]},{name:"legBL",role:"legBL",parent:null,pivot:[-3,8,6]},{name:"legBR",role:"legBR",parent:null,pivot:[3,8,6]},{name:"tail",role:"tail",parent:"body",pivot:[0,14,8]}],sockets:[{name:"headTop",bone:"head",at:[0,20,-12]},{name:"face",bone:"head",at:[0,16,-16]},{name:"back",bone:"body",at:[0,16,0]},{name:"waist",bone:"body",at:[0,12,4]},{name:"shoulders",bone:"body",at:[0,16,-6]},{name:"handR",bone:"head",at:[2,13,-16]},{name:"handL",bone:"head",at:[-2,13,-16]}],hitbox:{w:.9,h:1},eye:17,height:{min:8,max:40},faceBone:"head",defaultParts:[{bone:"body",size:[8,8,16],pos:[0,12,0],color:"t"},{bone:"head",size:[8,8,8],pos:[0,16,-12],color:"s"},{bone:"legFL",size:[3,8,3],pos:[-3,4,-6],color:"p"},{bone:"legFR",size:[3,8,3],pos:[3,4,-6],color:"p"},{bone:"legBL",size:[3,8,3],pos:[-3,4,6],color:"p"},{bone:"legBR",size:[3,8,3],pos:[3,4,6],color:"p"},{bone:"tail",size:[2,2,8],pos:[0,14,12],color:"t"}]};var hs=["root","body","head","armL","armR","legL","legR","foreArmL","foreArmR","shinL","shinR","legFL","legFR","legBL","legBR","tail","wingL","wingR","ear","hair","cape","antenna","static"],ot=["tail","wingL","wingR","ear","hair","cape","antenna","static"],ms=["handR","handL","headTop","face","back","waist","shoulders"],Be=["humanoid","quadruped","flyer","blob"],_e="avatar";var ie={humanoid:pr,quadruped:hr,flyer:cr,blob:lr,avatar:ir};var mr=1,be=["front","back","left","right","top","bottom"],je=["neutral","blink","happy","sad","angry","surprised","scared","tired","hurt","talk"],Pt=["normal","bouncy","heavy","sneaky","robotic"],Lt=["calm","fidgety","proud"],ur={parts:64,bones:16,palette:32,textures:48,texturePixels:32768,textureSide:32,partSide:32,coord:64},Oe={noise:.5,outline:.4,shade:.25,density:2},N=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Ve=e=>Array.isArray(e)?e:[];function Q(e,t,r,o){let n=typeof e=="number"?e:typeof e=="string"?Number(e):NaN;return Number.isFinite(n)?Math.min(o,Math.max(r,n)):t}function Mt(e,t,r){if(typeof e!="string")return r;let o=e.trim();if(t.includes(o))return o;let n=o.toLowerCase().replace(/[\s-]+/g,"_");return t.find(i=>i.toLowerCase()===n)??r}function fe(e,t,r){return typeof e=="string"?e.trim().slice(0,r):t}function nt(e,t,r=null){if(!Array.isArray(e)||e.length<3)return r;let o=e.slice(0,3).map(n=>Q(n,NaN,-t,t));return o.every(Number.isFinite)?o:r}var dr={black:"#1d1d21",white:"#f0f0f0",gray:"#808080",grey:"#808080",red:"#c0392b",green:"#3c9a3c",blue:"#2f5fd0",yellow:"#f2d33c",orange:"#e8862a",purple:"#8a4fc4",pink:"#f08cb4",brown:"#7a4f2a",cyan:"#2ab0c0",gold:"#d8b030",silver:"#c0c4c8",skin:"#c69c7c"};function ue(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();if(dr[t])return dr[t];let r=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/.exec(t);if(!r)return null;let o=r[1];return "#"+(o.length===3?o.split("").map(n=>n+n).join(""):o)}var ye=new Set(["."," "]),fr=e=>/^[A-Za-z0-9_]{1,24}$/.test(e),lo={human:"humanoid",biped:"humanoid",person:"humanoid",animal:"quadruped",four_legs:"quadruped",quadrupedal:"quadruped",bird:"flyer",winged:"flyer",dragon:"flyer",slime:"blob",ghost:"blob"};function co(e){if(typeof e!="string")return "humanoid";let t=e.trim().toLowerCase().replace(/[\s-]+/g,"_");return Be.includes(t)?t:t===_e?_e:lo[t]??"humanoid"}function br(e,t){let r=/^(.*?)(L|R)$/.exec(e);if(!r)return e;let o=r[1]+(r[2]==="L"?"R":"L");return t(o)?o:e}function le(e){if(typeof e=="string"){let d$1=d(e);if(!d$1.ok)return {ok:false,error:d$1.error,truncated:d$1.truncated};e=d$1.value;}if(!N(e))return {ok:false,error:c({en:"the character recipe is not an object",ru:"\u0440\u0435\u0446\u0435\u043F\u0442 \u043F\u0435\u0440\u0441\u043E\u043D\u0430\u0436\u0430 \u2014 \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442"})};if(!("parts"in e)&&!("rig"in e)){let d=e.character??e.spec??e.characterSpec;N(d)&&(e=d);}let t=e,r=ur,o=[];typeof t.version=="number"&&t.version>mr&&o.push(c({en:"recipe version {v} is newer than the game \u2014 read what could be read",ru:"\u0440\u0435\u0446\u0435\u043F\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 {v} \u2014 \u043D\u043E\u0432\u0435\u0435 \u0438\u0433\u0440\u044B, \u0440\u0430\u0437\u043E\u0431\u0440\u0430\u043D\u043E \u0447\u0442\u043E \u043F\u043E\u043D\u044F\u0442\u043D\u043E"},{v:t.version}));let n=co(t.rig),a=ie[n],i={};if(N(t.palette))for(let[d,R]of Object.entries(t.palette)){if(Object.keys(i).length>=r.palette){o.push(c({en:"the palette is longer than {n} \u2014 the rest was dropped",ru:"\u043F\u0430\u043B\u0438\u0442\u0440\u0430 \u0434\u043B\u0438\u043D\u043D\u0435\u0435 {n} \u2014 \u043B\u0438\u0448\u043D\u0435\u0435 \u043E\u0442\u0431\u0440\u043E\u0448\u0435\u043D\u043E"},{n:r.palette}));break}let E=ue(R);if(d.length!==1||ye.has(d)||!E){o.push(c({en:"palette colour \xAB{k}\xBB was not understood",ru:"\u0446\u0432\u0435\u0442 \u043F\u0430\u043B\u0438\u0442\u0440\u044B \xAB{k}\xBB \u043D\u0435 \u043F\u043E\u043D\u044F\u0442"},{k:d}));continue}i[d]=E;}let c$1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",s=(d,R)=>{if(typeof d!="string")return R;if(d.length===1&&i[d])return d;let E=ue(d);if(!E)return R;let v=Object.entries(i).find(([,C])=>C===E);if(v)return v[0];if(Object.keys(i).length>=r.palette)return R;let I=[...c$1].find(C=>!i[C]);return I?(i[I]=E,I):R},l={},h=0;if(N(t.textures))for(let[d,R]of Object.entries(t.textures)){if(!fr(d)){o.push(c({en:"texture name \xAB{id}\xBB does not fit",ru:"\u0438\u043C\u044F \u0442\u0435\u043A\u0441\u0442\u0443\u0440\u044B \xAB{id}\xBB \u043D\u0435 \u043F\u043E\u0434\u0445\u043E\u0434\u0438\u0442"},{id:d.slice(0,30)}));continue}if(Object.keys(l).length>=r.textures){o.push(c({en:"more than {n} textures \u2014 the rest were dropped",ru:"\u0442\u0435\u043A\u0441\u0442\u0443\u0440 \u0431\u043E\u043B\u044C\u0448\u0435 {n} \u2014 \u043B\u0438\u0448\u043D\u0438\u0435 \u043E\u0442\u0431\u0440\u043E\u0448\u0435\u043D\u044B"},{n:r.textures}));break}let E=mo(R,i,o,d);if(E){if(h+E.w*E.h>r.texturePixels){o.push(c({en:"texture \xAB{id}\xBB did not fit the pixel limit",ru:"\u0442\u0435\u043A\u0441\u0442\u0443\u0440\u0430 \xAB{id}\xBB \u043D\u0435 \u0432\u043B\u0435\u0437\u043B\u0430 \u0432 \u043B\u0438\u043C\u0438\u0442 \u043F\u0438\u043A\u0441\u0435\u043B\u0435\u0439"},{id:d}));continue}h+=E.w*E.h,l[d]=E;}}let m=new Set(a.bones.map(d=>d.name)),p=[];for(let d of Ve(t.bones)){if(!N(d))continue;let R=fe(d.name,"",24);if(!R||!fr(R))continue;let E=nt(d.pivot,r.coord);if(!E||p.some(L=>L.name===R))continue;if(p.length>=r.bones){o.push(c({en:"more than {n} bones \u2014 the rest were dropped",ru:"\u043A\u043E\u0441\u0442\u0435\u0439 \u0431\u043E\u043B\u044C\u0448\u0435 {n} \u2014 \u043B\u0438\u0448\u043D\u0438\u0435 \u043E\u0442\u0431\u0440\u043E\u0448\u0435\u043D\u044B"},{n:r.bones}));break}let v=m.has(R),I=fe(d.parent,"",24),C=v?a.bones.find(L=>L.name===R).parent??"":m.has(I)||p.some(L=>L.name===I)?I:a.bones.find(L=>L.role==="body").name;p.push({name:R,parent:C,pivot:E,role:v?"static":Mt(d.role,ot,"static")}),m.add(R);}let y=Object.keys(i)[0]??"s",w=[];for(let d of Ve(t.parts)){if(w.length>=r.parts){o.push(c({en:"more than {n} parts \u2014 the rest were dropped",ru:"\u0434\u0435\u0442\u0430\u043B\u0435\u0439 \u0431\u043E\u043B\u044C\u0448\u0435 {n} \u2014 \u043B\u0438\u0448\u043D\u0438\u0435 \u043E\u0442\u0431\u0440\u043E\u0448\u0435\u043D\u044B"},{n:r.parts}));break}if(!N(d))continue;let R=nt(d.size,r.partSide),E=nt(d.pos??d.center??d.at,r.coord);if(!R||!E||R.some(j=>j<=0))continue;let v=fe(d.bone,"",24);m.has(v)||(v&&o.push(c({en:"bone \xAB{b}\xBB not found \u2014 the part is on the body",ru:"\u043A\u043E\u0441\u0442\u044C \xAB{b}\xBB \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u0430 \u2014 \u0434\u0435\u0442\u0430\u043B\u044C \u043D\u0430 \u0442\u0435\u043B\u0435"},{b:v})),v=a.bones.find(j=>j.role==="body").name);let I={bone:v,size:R,pos:E,color:s(d.color,y)};if(N(d.faces)){let j={};for(let x of be){let A=d.faces[x];if(typeof A=="string")if(l[A])j[x]=A;else {let M=s(A,"");M&&(j[x]=M);}}Object.keys(j).length&&(I.faces=j);}let C=nt(d.rot??d.rotation,180);C&&C.some(j=>j!==0)&&(I.rot=C),(d.mirror===true||d.mirror==="x")&&(I.mirror=true);let L=fe(d.name,"",24);L&&(I.name=L),w.push(I);}if(!w.length){for(let[d,R]of Object.entries(po))i[d]||(i[d]=R);w.push(...a.defaultParts.map(ho));}let b=null;if(N(t.face)){let d=t.face,R=m.has(fe(d.bone,"",24))?fe(d.bone,"",24):a.faceBone,E=Ve(d.rect).map(I=>Math.round(Q(I,NaN,0,r.partSide)*10)/10),v={};if(N(d.expressions))for(let I of je){let C=d.expressions[I];typeof C=="string"&&l[C]&&(v[I]=C);}if(!v.neutral){let I=Object.values(v)[0];I&&(v.neutral=I);}if(v.neutral){let I=l[v.neutral];b={bone:R,rect:E.length===4&&E.every(Number.isFinite)&&E[2]>0&&E[3]>0?E:[0,0,I.w,I.h],expressions:v};}else Object.keys(d).length&&o.push(c({en:"the face has no pictures \u2014 no face is drawn",ru:"\u0443 \u043B\u0438\u0446\u0430 \u043D\u0435\u0442 \u043D\u0438 \u043E\u0434\u043D\u043E\u0439 \u043A\u0430\u0440\u0442\u0438\u043D\u043A\u0438 \u2014 \u043B\u0438\u0446\u043E \u043D\u0435 \u043D\u0430\u0440\u0438\u0441\u043E\u0432\u0430\u043D\u043E"}));}let T=N(t.style)?t.style:{},k=N(t.voice)?t.voice:{},g=N(t.finish)?t.finish:{},f={version:mr,name:fe(t.name,at(),40)||at(),description:fe(t.description,"",300),rig:n,scale:Q(t.scale,1,.25,3),palette:i,textures:l,parts:w,bones:p,face:b,style:{walk:Mt(T.walk,Pt,"normal"),idle:Mt(T.idle,Lt,"calm"),energy:Q(T.energy,.5,0,1)},voice:{pitch:Q(k.pitch,1,.5,2)},tags:Ve(t.tags).filter(d=>typeof d=="string"&&!!d.trim()).slice(0,8).map(d=>d.trim().slice(0,24)),finish:{noise:Q(g.noise,Oe.noise,0,1),outline:Q(g.outline,Oe.outline,0,1),shade:Q(g.shade,Oe.shade,0,1),density:Math.round(Q(g.density,Oe.density,1,4))}},S=Q(g.round,0,0,1);return S>0&&(f.finish.round=S),{ok:true,spec:f,warnings:o}}var po={s:"#c69c7c",t:"#3a8fd6",p:"#2c3e6b"};function ho(e){return JSON.parse(JSON.stringify(e))}function mo(e,t,r,o){let n=Array.isArray(e)?{rows:e}:N(e)?e:null;if(!n)return null;let a=ur.textureSide,i=Ve(n.rows??n.pixels).filter(h=>typeof h=="string");if(!i.length)return null;let c$1=Math.round(Q(n.h??n.height,i.length,1,a)),s=Math.round(Q(n.w??n.width,Math.max(...i.map(h=>h.length)),1,a)),l=false;for(i=i.slice(0,c$1).map(h=>{let m="";for(let p=0;p<s;p++){let y=h[p]??".";ye.has(y)||t[y]?m+=y===" "?".":y:(l=true,m+=".");}return m});i.length<c$1;)i.push(".".repeat(s));return l&&r.push(c({en:"texture \xAB{id}\xBB has symbols not in the palette \u2014 they became transparent",ru:"\u0432 \u0442\u0435\u043A\u0441\u0442\u0443\u0440\u0435 \xAB{id}\xBB \u0441\u0438\u043C\u0432\u043E\u043B\u044B \u043D\u0435 \u0438\u0437 \u043F\u0430\u043B\u0438\u0442\u0440\u044B \u2014 \u0441\u0442\u0430\u043B\u0438 \u043F\u0440\u043E\u0437\u0440\u0430\u0447\u043D\u044B\u043C\u0438"},{id:o})),{w:s,h:c$1,rows:i}}function It(e){return Array.isArray(e)?"["+e.map(It).join(",")+"]":N(e)?"{"+Object.keys(e).filter(t=>e[t]!==void 0).sort().map(t=>JSON.stringify(t)+":"+It(e[t])).join(",")+"}":JSON.stringify(e)}function ze(e){let t=It(e),r=b(t),o=b("~"+t);return r.toString(16).padStart(8,"0")+o.toString(16).padStart(8,"0")}function As(e){return ie[e.rig]}function yr(e){let r=ie[e.rig].bones.map(o=>{let n=e.bones.find(a=>a.name===o.name);return {name:o.name,role:o.role,parent:o.parent,pivot:(n?.pivot??o.pivot).slice()}});for(let o of e.bones)r.some(n=>n.name===o.name)||r.push({name:o.name,role:o.role,parent:o.parent,pivot:o.pivot.slice()});return r}function at(){return c({en:"Character",ru:"\u041F\u0435\u0440\u0441\u043E\u043D\u0430\u0436"})}var ks=e=>e==="\u041F\u0435\u0440\u0441\u043E\u043D\u0430\u0436"||e==="Character";var fo={front:{tl:[1,1,-1],u:[-1,0,0],d:[0,-1,0],n:[0,0,-1]},back:{tl:[-1,1,1],u:[1,0,0],d:[0,-1,0],n:[0,0,1]},right:{tl:[1,1,1],u:[0,0,-1],d:[0,-1,0],n:[1,0,0]},left:{tl:[-1,1,-1],u:[0,0,1],d:[0,-1,0],n:[-1,0,0]},top:{tl:[1,1,1],u:[-1,0,0],d:[0,0,-1],n:[0,1,0]},bottom:{tl:[-1,-1,1],u:[1,0,0],d:[0,0,-1],n:[0,-1,0]}};function _t(e){let t=parseInt(e.slice(1),16);return [t>>16&255,t>>8&255,t&255]}function gr(e,t,r,o,n,a){let i=((r-1-n)*t+o)*4;e[i]=a[0],e[i+1]=a[1],e[i+2]=a[2],e[i+3]=255;}function uo(e,t=0){e.sort((r,o)=>o.h-r.h||o.w-r.w||(r.key<o.key?-1:1));for(let r=16;;r*=2){let o=0,n=0,a=0;for(let c of e)o+c.w+t*2>r&&(o=0,n+=a,a=0),c.x=o+t,c.y=n+t,o+=c.w+t*2,a=Math.max(a,c.h+t*2);let i=n+a;if(i<=r||r>=1024){let c=16;for(;c<i;)c*=2;return {w:r,h:c}}}}function bo(e,t,r,o,n){let a=(i,c)=>((r-1-o.y-c)*t+o.x+i)*4;for(let i=-n;i<o.h+n;i++)for(let c=-n;c<o.w+n;c++){let s=Math.max(0,Math.min(o.w-1,c)),l=Math.max(0,Math.min(o.h-1,i));if(s===c&&l===i)continue;let h=a(s,l);e.copyWithin(a(c,i),h,h+4);}}function wr(e,t,r){let o=Math.imul(t,374761393)+Math.imul(r,668265263)+Math.imul(e,2246822519);return o=Math.imul(o^o>>>13,1274126177),((o^o>>>16)>>>0)/4294967296}function yo(e,t,r,o,n,a,i,c){let l=1+(.55*wr(i,t,r)+.45*wr(i^1540483477,Math.floor(t/3),Math.floor(r/3))-.5)*2*c.noise*.14;return a==="s"?l+=c.shade*.16*(.5-(r+.5)/n):a==="t"?l+=c.shade*.08:l-=c.shade*.2,o>=3&&n>=3&&(t===0||r===0||t===o-1||r===n-1)&&(l*=1-.5*c.outline),[Math.max(0,Math.min(255,e[0]*l)),Math.max(0,Math.min(255,e[1]*l)),Math.max(0,Math.min(255,e[2]*l))]}var Fe=Math.PI/180;function st(e,t){if(!t)return e;let[r,o,n]=e,[a,i,c]=[t[0]*Fe,t[1]*Fe,t[2]*Fe],s=Math.cos(c),l=Math.sin(c);return [r,o]=[r*s-o*l,r*l+o*s],s=Math.cos(i),l=Math.sin(i),[r,n]=[r*s+n*l,-r*l+n*s],s=Math.cos(a),l=Math.sin(a),[o,n]=[o*s-n*l,o*l+n*s],[r,o,n]}function go(e,t){let r=[];for(let o of e.parts){if(r.push({...o,flip:false}),!o.mirror)continue;let n=o.faces?{...o.faces,left:o.faces.right,right:o.faces.left}:void 0;n&&(n.left===void 0&&delete n.left,n.right===void 0&&delete n.right);let a={...o,bone:br(o.bone,t),pos:[-o.pos[0],o.pos[1],o.pos[2]],flip:true};n?a.faces=n:delete a.faces,o.rot&&(a.rot=[o.rot[0],-o.rot[1],-o.rot[2]]),r.push(a);}return r}function vr(e){let t=ie[e.rig],r=yr(e),o=x=>r.some(A=>A.name===x),n=go(e,o),a=e.finish??Oe,i=a.round??0,c=new Map,s=(x,A)=>{let M=x.faces?.[A],P=M!==void 0?e.textures[M]:void 0,G=M!==void 0&&e.palette[M]?M:x.color,[D,X]=A==="front"||A==="back"?[x.size[0],x.size[1]]:A==="left"||A==="right"?[x.size[2],x.size[1]]:[x.size[0],x.size[2]],W=(Le,we)=>Math.max(1,Math.min(64,we*Math.max(1,Math.round(Le*a.density/we)))),U=P?W(D,P.w):W(D,1),q=P?W(X,P.h):W(X,1),z=A==="top"?"t":A==="bottom"?"b":"s",J=(P?"t:"+M:"c:"+G)+"|"+U+"x"+q+z,te=c.get(J);if(te)return te;let oe=b(J),de=P?null:_t(e.palette[G]??"#ff00ff");return te={key:J,w:U,h:q,x:0,y:0,paint:(Le,we,Qe,et,tt)=>{for(let xe=0;xe<q;xe++)for(let Z=0;Z<U;Z++){let ae=de;if(P){let he=P.rows[Math.floor(xe*P.h/q)][Math.floor(Z*P.w/U)];if(ye.has(he))continue;let se=e.palette[he];if(!se)continue;ae=_t(se);}gr(Le,we,Qe,et+Z,tt+xe,yo(ae,Z,xe,U,q,z,oe,a));}}},c.set(J,te),te},l=(x,A)=>{let M="e:"+x,P=c.get(M);return P||(P={key:M,w:A.w,h:A.h,x:0,y:0,paint:(G,D,X,W,U)=>{for(let q=0;q<A.h;q++)for(let z=0;z<A.w;z++){let J=A.rows[q][z];if(ye.has(J))continue;let te=e.palette[J];te&&gr(G,D,X,W+z,U+q,_t(te));}}},c.set(M,P)),P},h=n.map(x=>({p:x,faces:be.map(A=>({f:A,cell:s(x,A)}))})),m=e.face,p=[];if(m)for(let[x,A]of Object.entries(m.expressions)){let M=e.textures[A];M&&p.push([x,l(A,M)]);}let y=i>0?2:0,{w,h:b$1}=uo([...c.values()],y),T=new Uint8Array(w*b$1*4);for(let x of c.values())x.paint(T,w,b$1,x.x,x.y),y&&bo(T,w,b$1,x,y);let k=.01,g=(x,A=k)=>[(x.x+A)/w,1-(x.y+A)/b$1,(x.x+x.w-A)/w,1-(x.y+x.h-A)/b$1],f=new Map;for(let x of r)f.set(x.name,{pos:[],nrm:[],uv:[],idx:[]});let S=new Map,d=x=>{let A=S.get(x);if(A===void 0){A=true;for(let M=0;M<x.h&&A;M++)for(let P=0;P<x.w;P++)if(T[((b$1-1-x.y-M)*w+x.x+P)*4+3]<128){A=false;break}S.set(x,A);}return A},R=new Map;for(let{p:x,faces:A}of h)if(A.every(({cell:M})=>d(M))){let M=R.get(x.bone)??[];M.push(x),R.set(x.bone,M);}let E=0;for(let{p:x,faces:A}of h){let M=f.get(x.bone),P=r.find(U=>U.name===x.bone).pivot,G=[x.size[0]/2,x.size[1]/2,x.size[2]/2];E=Math.max(E,x.pos[1]+G[1]);let D=(R.get(x.bone)??[]).filter(U=>U!==x),X=Math.min(x.size[0],x.size[1],x.size[2])>=Ro?vo:xo,W=(U,q)=>{let z=fo[U],J=(Z,ae)=>{let he=[G[0]*(z.tl[0]+2*(z.u[0]*Z+z.d[0]*ae)),G[1]*(z.tl[1]+2*(z.u[1]*Z+z.d[1]*ae)),G[2]*(z.tl[2]+2*(z.u[2]*Z+z.d[2]*ae))],se=st(he,x.rot);return [x.pos[0]+se[0]-P[0],x.pos[1]+se[1]-P[1],x.pos[2]+se[2]-P[2]]},te=st(z.n,x.rot),oe=M.pos.length/3,[de,Le,we,Qe]=g(q),[et,tt]=x.flip?[we,de]:[de,we];if(i>0){let[Z,ae,he,se]=g(q,.5);Eo(M,x,G,z,P,i,X,x.flip?[he,ae,Z,se]:[Z,ae,he,se]);return}let xe=[[0,0,et,Le],[1,0,tt,Le],[1,1,tt,Qe],[0,1,et,Qe]];for(let[Z,ae,he,se]of xe)M.pos.push(...J(Z,ae)),M.nrm.push(...te),M.uv.push(he,se);M.idx.push(oe,oe+2,oe+1,oe,oe+3,oe+2);};for(let{f:U,cell:q}of A){let z=[M.pos.length,M.nrm.length,M.uv.length,M.idx.length];W(U,q),D.length&&Ao(M.pos,z[0],P,D,i)&&(M.pos.length=z[0],M.nrm.length=z[1],M.uv.length=z[2],M.idx.length=z[3]);}}let v=r.map(x=>{let A=f.get(x.name);return {name:x.name,role:x.role,parent:x.parent,pivot:x.pivot,positions:Float32Array.from(A.pos),normals:Float32Array.from(A.nrm),uvs:Float32Array.from(A.uv),indices:Uint16Array.from(A.idx)}}),I=null;if(m&&p.length){let A=e.parts.filter(P=>P.bone===m.bone).sort((P,G)=>G.size[0]*G.size[1]*G.size[2]-P.size[0]*P.size[1]*P.size[2])[0],M=r.find(P=>P.name===m.bone);if(A&&M){let[P,G,D,X]=m.rect,W=A.pos[0]+A.size[0]/2-P,U=A.pos[1]+A.size[1]/2-G,q=A.pos[2]-A.size[2]/2-.05,z=M.pivot,J=(oe,de)=>[oe-z[0],de-z[1],q-z[2]],te={};for(let[oe,de]of p)te[oe]=g(de);I={bone:m.bone,corners:Float32Array.from([...J(W,U),...J(W-D,U),...J(W-D,U-X),...J(W,U-X)]),uv:te};}}let C=t.sockets.filter(x=>o(x.bone)).map(x=>{let A=t.bones.find(M=>M.name===x.bone);return {name:x.name,bone:x.bone,at:[x.at[0]-A.pivot[0],x.at[1]-A.pivot[1],x.at[2]-A.pivot[2]]}}),L=Math.max(1,E),j=L>t.height.max?t.height.max/L:L<t.height.min?t.height.min/L:1;return {hash:ze(e),rig:e.rig,bones:v,atlas:{w,h:b$1,data:T},face:I,sockets:C,height:L,scale:e.scale*j,eye:t.eye*L/ko(e.rig)}}var Rr=3,wo=2.5,xo=1,xr=0,vo=2,Ro=4.1;function Eo(e,t,r,o,n,a,i,c){let s=Math.min(r[0],r[1],r[2]),l=Math.min(s,a*Rr),h=Math.min(s,l*wo),m=[r[0]-l,r[1]-l,r[2]-l],p=[r[0]-h,r[1]-h,r[2]-h],y=E=>Math.abs(E[0])*t.size[0]+Math.abs(E[1])*t.size[1]+Math.abs(E[2])*t.size[2],w=E=>{let v=[];for(let C=0;C<=i;C++)v.push(Math.min(.5,l*C/i/E));for(let C=1;C<=xr;C++)v.push(Math.min(.5,(l+(h-l)*C/xr)/E));let I=[...v,...v.map(C=>1-C)].sort((C,L)=>C-L);return I.filter((C,L)=>L===0||C-I[L-1]>1e-6)},b=w(y(o.u)),T=w(y(o.d)),k=e.pos.length/3,[g,f,S,d]=c;for(let E of T)for(let v of b){let I=[0,0,0],C=[0,0,0],L=[0,0,0];for(let D=0;D<3;D++){let X=r[D]*(o.tl[D]+2*(o.u[D]*v+o.d[D]*E)),W=Math.max(-m[D],Math.min(m[D],X));C[D]=X-W,I[D]=W,L[D]=X-Math.max(-p[D],Math.min(p[D],X));}let j=Math.hypot(C[0],C[1],C[2]),x=j>1e-9?[C[0]/j,C[1]/j,C[2]/j]:[o.n[0],o.n[1],o.n[2]],A=Math.hypot(L[0],L[1],L[2]),M=A>1e-9?[L[0]/A,L[1]/A,L[2]/A]:x,P=[I[0]+x[0]*l,I[1]+x[1]*l,I[2]+x[2]*l],G=st(P,t.rot);e.pos.push(t.pos[0]+G[0]-n[0],t.pos[1]+G[1]-n[1],t.pos[2]+G[2]-n[2]),e.nrm.push(...st(M,t.rot)),e.uv.push(g+(S-g)*v,f+(d-f)*E);}let R=b.length;for(let E=0;E+1<T.length;E++)for(let v=0;v+1<R;v++){let I=k+E*R+v;e.idx.push(I,I+R+1,I+1,I,I+R,I+R+1);}}function So(e,t){if(!t)return e;let[r,o,n]=e,[a,i,c]=[-t[0]*Fe,-t[1]*Fe,-t[2]*Fe],s=Math.cos(a),l=Math.sin(a);return [o,n]=[o*s-n*l,o*l+n*s],s=Math.cos(i),l=Math.sin(i),[r,n]=[r*s+n*l,-r*l+n*s],s=Math.cos(c),l=Math.sin(c),[r,o]=[r*s-o*l,r*l+o*s],[r,o,n]}function Ao(e,t,r,o,n){for(let i of o){let c=[i.size[0]/2,i.size[1]/2,i.size[2]/2],s=n>0?Math.min(c[0],c[1],c[2],n*Rr):0,l=true;for(let h=t;h<e.length&&l;h+=3){let m=So([e[h]+r[0]-i.pos[0],e[h+1]+r[1]-i.pos[1],e[h+2]+r[2]-i.pos[2]],i.rot),p=Math.abs(m[0])-(c[0]-s),y=Math.abs(m[1])-(c[1]-s),w=Math.abs(m[2])-(c[2]-s);Math.hypot(Math.max(p,0),Math.max(y,0),Math.max(w,0))+Math.min(Math.max(p,y,w),0)-s>=-0.01&&(l=false);}if(l)return true}return false}function ko(e){let t=1;for(let r of ie[e].defaultParts)t=Math.max(t,r.pos[1]+r.size[1]/2);return t}var Ot=new Map;function To(e){let t=new Map;for(let c of e.bones){if(!c.indices.length){t.set(c.name,null);continue}let s=new O.BufferGeometry;s.setAttribute("position",new O.BufferAttribute(c.positions,3)),s.setAttribute("normal",new O.BufferAttribute(c.normals,3)),s.setAttribute("uv",new O.BufferAttribute(c.uvs,2)),s.setIndex(new O.BufferAttribute(c.indices,1)),s.computeBoundingSphere(),s.userData.shared=true,t.set(c.name,s);}let r=Co(e),{w:o,h:n,data:a}=e.atlas,i=new O.DataTexture(a,o,n,O.RGBAFormat);return i.magFilter=O.NearestFilter,i.minFilter=O.NearestFilter,i.generateMipmaps=false,i.colorSpace=O.SRGBColorSpace,i.needsUpdate=true,{layout:e,geometries:t,skinned:r,texture:i,refs:0}}function Co(e){let t=0,r=0;for(let p of e.bones)t+=p.positions.length/3,r+=p.indices.length;if(!r)return null;let o=new Float32Array(t*3),n=new Float32Array(t*3),a=new Float32Array(t*2),i=new Uint16Array(t*4),c=new Float32Array(t*4),s=t>65535?new Uint32Array(r):new Uint16Array(r),l=0,h=0;e.bones.forEach((p,y)=>{let w=p.positions.length/3;for(let b=0;b<w;b++)o[(l+b)*3]=p.positions[b*3]+p.pivot[0],o[(l+b)*3+1]=p.positions[b*3+1]+p.pivot[1],o[(l+b)*3+2]=p.positions[b*3+2]+p.pivot[2],i[(l+b)*4]=y,c[(l+b)*4]=1;n.set(p.normals,l*3),a.set(p.uvs,l*2);for(let b=0;b<p.indices.length;b++)s[h+b]=p.indices[b]+l;l+=w,h+=p.indices.length;});let m=new O.BufferGeometry;return m.setAttribute("position",new O.BufferAttribute(o,3)),m.setAttribute("normal",new O.BufferAttribute(n,3)),m.setAttribute("uv",new O.BufferAttribute(a,2)),m.setAttribute("skinIndex",new O.Uint16BufferAttribute(i,4)),m.setAttribute("skinWeight",new O.BufferAttribute(c,4)),m.setIndex(new O.BufferAttribute(s,1)),m.computeBoundingSphere(),m.userData.shared=true,m}function zt(e){let t=Ot.get(ze(e));return t||(t=To(vr(e)),Ot.set(t.layout.hash,t)),t.refs++,t}function it(e){if(!(--e.refs>0)){Ot.delete(e.layout.hash);for(let t of e.geometries.values())t?.dispose();e.skinned?.dispose(),e.texture.dispose();}}var _=class e{constructor(t,r,o="."){this.w=t;this.h=r;this.g=Array.from({length:r},()=>new Array(t).fill(o));}w;h;g;px(t,r,o){return t>=0&&r>=0&&t<this.w&&r<this.h&&(this.g[r][t]=o),this}rect(t,r,o,n,a){for(let i=r;i<r+n;i++)for(let c=t;c<t+o;c++)this.px(c,i,a);return this}row(t,r,o,n){return this.rect(r,t,o-r+1,1,n)}col(t,r,o,n){return this.rect(t,r,1,o-r+1,n)}where(t,r){for(let o=0;o<this.h;o++)for(let n=0;n<this.w;n++)t(n,o)&&this.px(n,o,r);return this}flipped(){let t=new e(this.w,this.h);for(let r=0;r<this.h;r++)for(let o=0;o<this.w;o++)t.px(this.w-1-o,r,this.g[r][o]);return t}tex(){return {w:this.w,h:this.h,rows:this.g.map(t=>t.join(""))}}};var Mo={s:"#d9a982",S:"#bf8d68",h:"#6b4a2f",H:"#8a6644",k:"#3a2818",w:"#f4f4ef",b:"#3f8f9c",m:"#9a5544",o:"#4a2219",t:"#a7bea9",T:"#c4d6c4",D:"#84a08a",u:"#ece6d2",B:"#6a4e33",g:"#d8c48c",p:"#8c9ca6",P:"#6f808a",z:"#a07a55",Z:"#7c5c3f",l:"#e9e3cf"};function me(e,t){let r=parseInt(e.slice(1),16);return "#"+[r>>16&255,r>>8&255,r&255].map(n=>Math.max(0,Math.min(255,Math.round(n*t)))).map(n=>n.toString(16).padStart(2,"0")).join("")}function Nt(e,t){let r={...e};return t.skin&&(r.s=t.skin,r.S=me(t.skin,.86),r.m=me(t.skin,.66)),t.hair&&(r.h=t.hair,r.H=me(t.hair,1.25),r.k=me(t.hair,.6)),t.shirt&&(r.t=t.shirt,r.T=me(t.shirt,1.15),r.D=me(t.shirt,.8)),t.pants&&(r.p=t.pants,r.P=me(t.pants,.8)),t.boots&&(r.z=t.boots,r.Z=me(t.boots,.78)),t.eyes&&(r.b=t.eyes),r}var Io=new _(16,16,"s").rect(0,0,16,3,"h").row(3,0,4,"h").row(3,10,15,"h").row(4,0,1,"h").row(4,13,15,"h").col(0,5,8,"h").col(15,5,8,"h").row(1,3,6,"H").row(1,9,12,"H").row(15,2,13,"S"),Er=new _(16,16,"s").rect(0,0,16,4,"h").rect(7,4,9,7,"h").rect(10,11,6,2,"h").rect(5,7,2,3,"S").row(1,2,13,"H").where((e,t)=>t>4&&t<11&&e>8&&(e+t)%4===0,"k"),Po=Er.flipped(),Lo=new _(16,16,"h").where((e,t)=>(e+2*t)%5===0,"H").where((e,t)=>t>8&&(e*3+t)%7===0,"k").rect(4,14,8,2,"s"),_o=new _(16,16,"h").where((e,t)=>(e+2*t)%5===0,"H").where((e,t)=>(3*e+t)%9===0,"k"),Oo=new _(18,4,"h").where((e,t)=>(e*7+t*3)%5===0,"H").where((e,t)=>t===3&&e*5%3===0,"k"),zo=new _(16,24,"t").row(0,6,9,"s").row(1,7,8,"s").row(0,3,5,"T").row(0,10,12,"T").row(1,4,6,"T").row(1,9,11,"T").row(2,5,6,"T").row(2,9,10,"T").col(8,2,19,"D").px(7,5,"u").px(7,9,"u").px(7,13,"u").px(7,17,"u").row(6,2,5,"D").col(2,7,10,"D").col(5,7,10,"D").row(10,2,5,"D").px(4,7,"u").row(6,10,13,"D").col(10,7,10,"D").col(13,7,10,"D").row(10,10,13,"D").px(11,7,"u").row(19,0,15,"D").rect(0,20,16,2,"B").rect(7,20,2,2,"g").rect(0,22,16,2,"p"),Fo=new _(16,24,"t").row(5,0,15,"D").col(8,6,19,"D").row(19,0,15,"D").rect(0,20,16,2,"B").rect(0,22,16,2,"p"),No=new _(8,24,"t").col(4,0,19,"D").row(19,0,7,"D").rect(0,20,8,2,"B").rect(0,22,8,2,"p"),Ho=new _(16,2,"B").rect(7,0,2,2,"g").px(3,0,"k").px(12,0,"k"),Do=new _(6,24,"s").row(23,0,5,"S").col(2,21,23,"S"),Bo=new _(8,13,"t").col(0,0,9,"D").row(9,0,7,"D").rect(0,10,8,3,"T").row(12,0,7,"D"),Vo=new _(8,24,"p").col(4,1,21,"P").row(0,0,7,"P"),jo=new _(8,24,"p").col(3,0,21,"P").row(0,0,7,"P"),Go=new _(8,24,"p").col(3,0,21,"P"),Uo=new _(10,9,"z").row(0,0,9,"Z").row(2,3,6,"l").row(4,3,6,"l").row(6,3,6,"l").col(2,1,6,"Z").col(7,1,6,"Z").rect(0,7,10,2,"Z"),Yo=new _(10,9,"z").row(0,0,9,"Z").rect(0,7,10,2,"Z").col(5,1,6,"Z");function ce(e){let t=new _(16,10,"."),r=(n,a,i)=>{if(e.brows==="flat")t.row(1,n,n+2,"k");else if(e.brows==="high")t.row(0,n,n+2,"k");else {let c=e.brows==="down"?1:0,s=1-c;t.px(a,c,"k").px(n+1,e.brows==="down"?0:1,"k"),t.px(i,s,"k");}};r(3,5,3),r(10,10,12);let o=n=>{if(e.eyes===0){t.row(3,n,n+2,"k");return}let a=e.eyes===3||e.eyes===2?2:3;for(let i=a;i<a+e.eyes;i++)t.px(n,i,"w").px(n+1,i,"b").px(n+2,i,"w");};switch(o(3),o(10),e.mouth){case "line":t.row(7,6,9,"m");break;case "smile":t.px(5,6,"m").px(10,6,"m").row(7,6,9,"m");break;case "frown":t.row(7,6,9,"m").px(5,8,"m").px(10,8,"m");break;case "open":t.rect(6,7,4,2,"o");break;case "small":t.rect(7,7,2,2,"o");break;case "wide":t.row(7,5,10,"m").rect(6,8,4,1,"o");break}return t}var Sr={f_neutral:ce({brows:"flat",eyes:2,mouth:"line"}),f_blink:ce({brows:"flat",eyes:0,mouth:"line"}),f_happy:ce({brows:"high",eyes:2,mouth:"smile"}),f_sad:ce({brows:"up",eyes:2,mouth:"frown"}),f_angry:ce({brows:"down",eyes:1,mouth:"wide"}),f_surprised:ce({brows:"high",eyes:3,mouth:"small"}),f_scared:ce({brows:"up",eyes:3,mouth:"open"}),f_tired:ce({brows:"flat",eyes:1,mouth:"line"}),f_hurt:ce({brows:"down",eyes:0,mouth:"open"}),f_talk:ce({brows:"flat",eyes:2,mouth:"open"})},$o=new _(16,24,"t").row(0,5,10,"s").row(1,6,9,"s").px(5,1,"T").px(10,1,"T").row(7,0,15,"D").row(10,0,15,"D").rect(0,18,16,2,"T").rect(0,20,16,4,"p").row(20,0,15,"P"),qo=new _(16,24,"t").row(0,5,10,"T").row(7,0,15,"D").row(10,0,15,"D").rect(0,18,16,2,"T").rect(0,20,16,4,"p").row(20,0,15,"P"),Wo=new _(8,24,"t").row(7,0,7,"D").row(10,0,7,"D").rect(0,18,8,2,"T").rect(0,20,8,4,"p").row(20,0,7,"P"),Ko=new _(8,9,"t").row(3,0,7,"D").rect(0,7,8,2,"T"),lt=(e,t)=>e.row(t-1,0,e.w-1,"D").where((r,o)=>o>=t&&o<=t+3&&(r+o)%2===0,"T").row(t+4,0,e.w-1,"D"),Xo=lt(new _(16,24,"t"),6).row(0,6,9,"s").row(0,4,5,"T").row(0,10,11,"T").row(1,4,11,"T").where((e,t)=>t>=18&&t<=19&&e%2===0,"D").where((e,t)=>t>=18&&t<=19&&e%2===1,"T").rect(0,20,16,4,"p"),Jo=lt(new _(16,24,"t"),6).row(0,4,11,"T").where((e,t)=>t>=18&&t<=19,"D").rect(0,20,16,4,"p"),Zo=lt(new _(8,24,"t"),6).where((e,t)=>t>=18&&t<=19,"D").rect(0,20,8,4,"p"),Qo=lt(new _(8,22,"t"),9).where((e,t)=>t>=19&&e%2===0,"D"),Ar=e=>new _(8,24,"s").rect(0,0,8,12,"p").col(e,1,10,"P").row(11,0,7,"P").row(12,0,7,"S").rect(0,19,8,5,"l"),en=Ar(4),tn=Ar(3),rn=new _(9,5,"z").row(1,3,5,"l").rect(0,3,9,2,"l"),on=new _(10,5,"z").row(1,3,6,"Z").rect(0,3,10,2,"l"),nn=new _(17,6,"a").rect(0,4,17,2,"A"),an=new _(22,22,"a").where((e,t)=>(e*3+t*5)%11===0,"A"),sn=new _(17,20,"h").where((e,t)=>(e*5+t)%4===0,"H").where((e,t)=>t>10&&(e*3+t*2)%7===0,"k"),H=e=>e.tex(),kr=["shirt","tee","sweater"],Tr=["pants","shorts"],Cr=["boots","sneakers"],Ds=["short","long","curly","none"],Ee=(e,t={})=>({front:e,back:e,left:e,right:e,...t});function Ht(e={}){let t=e.top??"shirt",r=e.bottom??"pants",o=e.shoes??"boots",n=e.hair??"short",a=Nt(Mo,e.colors??{});a={...a,a:e.colors?.hat??"#d9c9a3"},a.A=me(a.a,.72);let i={head_front:H(Io),head_left:H(Er),head_right:H(Po),head_back:H(Lo),hair_top:H(_o),hair_band:H(Oo),arm_skin:H(Do),...Object.fromEntries(Object.entries(Sr).map(([w,b])=>[w,H(b)]))},c$1=[{name:"head",bone:"head",size:[8,8,8],pos:[0,28,0],color:"s",faces:{front:"head_front",left:"head_left",right:"head_right",back:"head_back",top:"hair_top"}},{name:"nose",bone:"head",size:[1,1.5,.8],pos:[0,26.9,-4.4],color:"S",faces:{front:"s"}}];if(n!=="none"){if(e.hat||c$1.push({name:"hair",bone:"head",size:n==="curly"?[9,2.2,9]:[8.6,1.6,8.6],pos:[0,n==="curly"?32.5:32.2,.15],color:"h",faces:Ee("hair_band",{top:"hair_top"})}),n==="curly"&&!e.hat)for(let[w,b]of [[-2,-1.5],[2,.5],[-0.5,2.5]])c$1.push({name:"curl",bone:"head",size:[3.2,1.4,3.2],pos:[w,33.9,b],color:"h",faces:Ee("hair_band",{top:"hair_top"})});n==="long"?(i.hair_long=H(sn),c$1.push({name:"hairLong",bone:"head",size:[8.8,10,1],pos:[0,27,4.4],color:"h",faces:Ee("hair_long",{top:"hair_top"})},{name:"hairSide",bone:"head",size:[.8,9,6],pos:[-4.4,27.5,1],color:"h",faces:Ee("hair_long",{top:"hair_top"}),mirror:true})):c$1.push({name:"hairBack",bone:"head",size:[8.6,5,.8],pos:[0,29.6,4.25],color:"h",faces:{back:"head_back",left:"hair_band",right:"hair_band"}});}e.hat&&(i.hat_crown=H(nn),i.hat_brim=H(an),c$1.push({name:"hatBrim",bone:"head",size:[11,.8,11],pos:[0,32.4,0],color:"a",faces:{top:"hat_brim",bottom:"hat_brim"}},{name:"hatCrown",bone:"head",size:[8.4,3,8.4],pos:[0,34.3,0],color:"a",faces:Ee("hat_crown")}));let s={shirt:[zo,Fo,No],tee:[$o,qo,Wo],sweater:[Xo,Jo,Zo]},[l,h,m]=s[t];i.top_front=H(l),i.top_back=H(h),i.top_side=H(m),c$1.push({name:"torso",bone:"body",size:[8,12,4],pos:[0,18,0],color:"t",faces:{front:"top_front",back:"top_back",left:"top_side",right:"top_side",bottom:"p"}}),t==="shirt"&&(i.belt=H(Ho),c$1.push({name:"belt",bone:"body",size:[8.4,1,4.4],pos:[0,13.5,0],color:"B",faces:{front:"belt",back:"belt"}})),c$1.push({name:"arm",bone:"armL",size:[3,12,3],pos:[-5.5,18,0],color:"s",faces:Ee("arm_skin",{top:"t",bottom:"S"}),mirror:true});let p=t==="sweater"?11:t==="tee"?4.5:6.5;i.sleeve=H(t==="sweater"?Qo:t==="tee"?Ko:Bo),c$1.push({name:"sleeve",bone:"armL",size:[3.6,p,3.6],pos:[-5.5,24-p/2,0],color:"t",faces:Ee("sleeve",{bottom:"D"}),mirror:true}),r==="shorts"?(i.leg_front=H(en),i.leg_side=H(tn)):(i.leg_front=H(Vo),i.leg_back=H(jo),i.leg_side=H(Go)),c$1.push({name:"leg",bone:"legL",size:[4,12,4],pos:[-2,6,0],color:"p",faces:{front:"leg_front",back:r==="shorts"?"leg_front":"leg_back",left:"leg_side",right:"leg_side"},mirror:true}),o==="boots"?(i.shoe_front=H(Uo),i.shoe_side=H(Yo)):(i.shoe_front=H(rn),i.shoe_side=H(on));let y=o==="boots"?4.5:2.5;return c$1.push({name:"shoe",bone:"legL",size:[4.6,y,5.2],pos:[-2,y/2,-0.3],color:"z",faces:{front:"shoe_front",back:"shoe_side",left:"shoe_side",right:"shoe_side",bottom:"Z"},mirror:true}),{version:1,name:e.name??c({en:"Traveler",ru:"\u041F\u0443\u0442\u043D\u0438\u043A"}),description:e.description??c({en:"A traveler in a shirt with pockets, trousers and laced boots",ru:"\u041F\u0443\u0442\u043D\u0438\u043A \u0432 \u0440\u0443\u0431\u0430\u0448\u043A\u0435 \u0441 \u043A\u0430\u0440\u043C\u0430\u043D\u0430\u043C\u0438, \u0431\u0440\u044E\u043A\u0430\u0445 \u0438 \u0448\u043D\u0443\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0445 \u0431\u043E\u0442\u0438\u043D\u043A\u0430\u0445"}),rig:"humanoid",palette:a,textures:i,parts:c$1,face:{bone:"head",rect:[0,3,8,5],expressions:{neutral:"f_neutral",blink:"f_blink",happy:"f_happy",sad:"f_sad",angry:"f_angry",surprised:"f_surprised",scared:"f_scared",tired:"f_tired",hurt:"f_hurt",talk:"f_talk"}},style:{walk:"normal",idle:"calm",energy:.5},finish:{noise:.5,outline:.4,shade:.25,density:2},tags:e.tags??["player"]}}function ct(e,t){return {textures:Object.fromEntries(Object.entries(Sr).map(([r,o])=>[r,H(o)])),face:{bone:e,rect:t,expressions:{neutral:"f_neutral",blink:"f_blink",happy:"f_happy",sad:"f_sad",angry:"f_angry",surprised:"f_surprised",scared:"f_scared",tired:"f_tired",hurt:"f_hurt",talk:"f_talk"}}}}var Dt=Ht(),Ft=null;function Se(){if(!Ft){let e=le(Dt);if(!e.ok)throw new Error(e.error);Ft=e.spec;}return Ft}function Mr(e){let t=document.createElement("canvas");t.width=256,t.height=48;let r=t.getContext("2d");r&&(r.fillStyle="rgba(0,0,0,0.45)",r.fillRect(0,0,256,48),r.font="bold 28px sans-serif",r.fillStyle="#fff",r.textAlign="center",r.textBaseline="middle",r.fillText(e.slice(0,18),128,25));let o=new O.CanvasTexture(t),n=new O.Sprite(new O.SpriteMaterial({map:o,depthTest:false,transparent:true}));return n.scale.set(1.6,.3,1),n.renderOrder=10,n}function Bt(e){e.removeFromParent(),e.material.map?.dispose(),e.material.dispose();}var V={rx:0,ry:1,rz:2,px:3,py:4,pz:5,sx:6,sy:7,sz:8},js=Object.keys(V),He=[0,0,0,0,0,0,1,1,1];function De(e,t){let r=e.get(t);return r||(r=Float64Array.from(He),e.set(t,r)),r}function pe(e,t,r,o){let n=De(e,t),a=V[r];a>=6?n[a]=n[a]*o:n[a]=n[a]+o;}function u(e,t,r,o){De(e,t)[V[r]]=o;}function Ae(e){for(let t of e.values())t.set(He);}function Ir(e,t,r,o){let n=new Set([...t.keys(),...r.keys()]);for(let a of n){let i=t.get(a)??He,c=r.get(a)??He,s=De(e,a);for(let l=0;l<9;l++)s[l]=i[l]+(c[l]-i[l])*o;}}function pt(e,t){Ae(e);for(let[r,o]of t)De(e,r).set(o);}var Gs=["none","block","tool","sword","bow","shield","food","staff","item"];function ht(){return {speed:0,vy:0,onGround:true,inWater:false,flying:false,gliding:false,sneaking:false,sprinting:false,riding:false,sitting:false,sleeping:false,dead:false,lookYaw:0,lookPitch:0,yawRate:0,held:"none",use:null,talk:false}}var Us=["swing","hurt","place","land","jump","throw"];var Ge=1/16,cn=.68,Pr=.85,pn=1.2,hn=1.03,mn=1.1,dn=.12,fn=.1,un=.1;function _r(e){let t=r=>r.toFixed(4);e.fragmentShader=e.fragmentShader.replace("#include <tonemapping_fragment>",`{
|
|
2
|
+
vec3 c = gl_FragColor.rgb;
|
|
3
|
+
float l = dot(c, vec3(0.2126, 0.7152, 0.0722));
|
|
4
|
+
c = mix(vec3(l), c, ${t(pn)});
|
|
5
|
+
#ifdef TONE_MAPPING
|
|
6
|
+
c = (c - 0.5) * ${t(hn)} + 0.5;
|
|
7
|
+
#else
|
|
8
|
+
c = (c - 0.5) * ${t(mn)} + 0.5;
|
|
9
|
+
#endif
|
|
10
|
+
gl_FragColor.rgb = clamp(c, 0.0, 1.0);
|
|
11
|
+
}
|
|
12
|
+
#include <tonemapping_fragment>
|
|
13
|
+
#ifdef TONE_MAPPING
|
|
14
|
+
{
|
|
15
|
+
vec3 c = gl_FragColor.rgb;
|
|
16
|
+
float avg = (c.r + c.g + c.b) / 3.0;
|
|
17
|
+
c += (avg - c) * (1.0 - 1.0 / (1.001 - ${t(dn)}));
|
|
18
|
+
c = min(c, 1.0);
|
|
19
|
+
c = clamp((c - 0.5) / (1.0 - ${t(fn)}) + 0.5, 0.0, 1.0);
|
|
20
|
+
float lu = dot(c, vec3(0.2126, 0.7152, 0.0722));
|
|
21
|
+
c += ${t(un)} * lu * lu;
|
|
22
|
+
gl_FragColor.rgb = clamp(c, 0.0, 1.0);
|
|
23
|
+
}
|
|
24
|
+
#endif`);}function Vt(e,t,r){if(!e)return new O.MeshLambertMaterial(r);let o=new O.MeshStandardMaterial({...r,roughness:t,metalness:0});return o.onBeforeCompile=_r,o}var Lr=5921370;function Or(e){let t=(r,o)=>r.replace(`#include <${o}>`,O.ShaderChunk[o].replace("varying vec2 vMapUv","centroid varying vec2 vMapUv"));e.vertexShader=t(e.vertexShader,"uv_pars_vertex"),e.fragmentShader=t(e.fragmentShader,"uv_pars_fragment");}function bn(e){Or(e),_r(e);}var mt=class{group=new O.Group;root=new O.Group;asset;spec;bones=new Map;byRole=new Map;meshes=[];material;decalMat;gloss;decal=null;expression=null;sockets=new Map;attached=new Map;label=null;shadows;layer;brightness=1;painter;prints=[];printMeshes=[];printMats=new Map;constructor(t=Se(),r={}){this.spec=t,this.shadows=r.shadows??true,this.layer=r.layer??0,this.painter=r.facePainter??null,this.gloss=r.gloss??false,this.material=Vt(this.gloss,cn,{alphaTest:.5}),this.material.onBeforeCompile=this.gloss?bn:Or,this.decalMat=Vt(this.gloss,Pr,{alphaTest:.5,polygonOffset:true,polygonOffsetFactor:-2,polygonOffsetUnits:-2}),this.group.add(this.root),this.asset=zt(t),this.build(),r.name&&this.setName(r.name);}get height(){let t=this.asset.layout;return t.height*t.scale*Ge}get eye(){let t=this.asset.layout;return t.eye*t.scale*Ge}get expressions(){return Object.keys(this.asset.layout.face?.uv??{})}get hash(){return this.asset.layout.hash}setSpec(t){let r=zt(t);if(r===this.asset){it(r);return}this.clear(),it(this.asset),this.asset=r,this.spec=t,this.build();}build(){let{layout:t,skinned:r,texture:o}=this.asset;this.material.map=o,this.material.needsUpdate=true,this.useFaceMap(),this.root.scale.setScalar(t.scale*Ge);let n=new Map(t.bones.map(s=>[s.name,s.pivot])),a=[],i=[];for(let s of t.bones){let l=new O.Bone;a.push(l),i.push(new O.Matrix4().makeTranslation(-s.pivot[0],-s.pivot[1],-s.pivot[2]));let h=s.parent?n.get(s.parent)??[0,0,0]:[0,0,0],m=[s.pivot[0]-h[0],s.pivot[1]-h[1],s.pivot[2]-h[2]];l.position.set(...m);let p={name:s.name,role:s.role,group:l,rest:m};this.bones.set(s.name,p);let y=this.byRole.get(s.role)??[];y.push(p),this.byRole.set(s.role,y);}for(let s of t.bones){let l=this.bones.get(s.name);((s.parent?this.bones.get(s.parent):void 0)?.group??this.root).add(l.group);}if(r){let s=new O.SkinnedMesh(r,this.material);s.bind(new O.Skeleton(a,i),new O.Matrix4);let l=r.boundingSphere;l&&(s.boundingSphere=new O.Sphere(l.center.clone(),l.radius*1.6)),s.castShadow=s.receiveShadow=this.shadows,s.layers.set(this.layer),this.meshes.push(s),this.root.add(s);}let c=t.face;if(c){let s=new O.BufferGeometry;s.setAttribute("position",new O.BufferAttribute(c.corners,3));let l=new Float32Array(12);for(let h=0;h<4;h++)l[h*3+2]=-1;s.setAttribute("normal",new O.BufferAttribute(l,3)),s.setAttribute("uv",new O.BufferAttribute(new Float32Array(8),2)),s.setIndex([0,2,1,0,3,2]),this.decal=new O.Mesh(s,this.decalMat),this.decal.layers.set(this.layer),this.bones.get(c.bone)?.group.add(this.decal),this.expression=null,this.setExpression("neutral");}for(let s of t.sockets){let l=new O.Object3D;l.position.set(...s.at),l.scale.setScalar(1/(t.scale*Ge)),this.bones.get(s.bone)?.group.add(l),this.sockets.set(s.name,l);let h=this.attached.get(s.name);h&&l.add(h);}this.buildPrints(),this.placeLabel(),this.setBrightness(this.brightness);}setPrints(t){this.prints=t??[],this.buildPrints(),this.setBrightness(this.brightness);}buildPrints(){for(let o of this.printMeshes)o.removeFromParent(),o.geometry.dispose();this.printMeshes=[];let t=new Set,r=new Map;for(let o of this.prints){let n=this.bones.get(o.bone),a=this.asset.layout.bones.find(h=>h.name===o.bone);if(!n||!a)continue;let i=this.printMats.get(o.texture);i||(i=Vt(this.gloss,Pr,{map:o.texture,emissiveMap:o.texture,emissive:Lr,transparent:true,alphaTest:.02,polygonOffset:true,polygonOffsetFactor:-2,polygonOffsetUnits:-2}),this.printMats.set(o.texture,i)),t.add(o.texture);let c=new O.PlaneGeometry(o.w,o.h);o.facing==="front"&&c.rotateY(Math.PI),c.translate(o.center[0]-a.pivot[0],o.center[1]-a.pivot[1],o.center[2]-a.pivot[2]);let s=`${o.bone}|${o.texture.uuid}`,l=r.get(s)??{node:n,mat:i,geos:[]};l.geos.push(c),r.set(s,l);}for(let{node:o,mat:n,geos:a}of r.values()){let i=a.length===1?a[0]:mergeGeometries(a)??a[0];if(i!==a[0])for(let s of a)s.dispose();let c=new O.Mesh(i,n);c.layers.set(this.layer),o.group.add(c),this.printMeshes.push(c);}for(let[o,n]of this.printMats)t.has(o)||(n.dispose(),this.printMats.delete(o));}clear(){for(let t of this.sockets.values())for(let r of [...t.children])t.remove(r);this.root.clear();for(let t of this.printMeshes)t.geometry.dispose();this.printMeshes=[],this.decal?.geometry.dispose(),this.decal=null;for(let t of this.meshes)t instanceof O.SkinnedMesh&&t.skeleton.dispose();this.meshes=[],this.bones=new Map,this.byRole=new Map,this.sockets.clear();}applyPose(t){let r=t.get("root");if(r){this.root.rotation.set(r[V.rx],r[V.ry],r[V.rz]);let o=this.asset.layout.scale*Ge;this.root.position.set(r[V.px]*o,r[V.py]*o,r[V.pz]*o);}else this.root.rotation.set(0,0,0),this.root.position.set(0,0,0);for(let[o,n]of this.byRole){let a=t.get(o);for(let i of n){let c=i.group;if(!a){c.rotation.set(0,0,0),c.position.set(...i.rest),c.scale.set(1,1,1);continue}c.rotation.set(a[V.rx],a[V.ry],a[V.rz]),c.position.set(i.rest[0]+a[V.px],i.rest[1]+a[V.py],i.rest[2]+a[V.pz]),c.scale.set(a[V.sx],a[V.sy],a[V.sz]);}}}setFacePainter(t){if(t===this.painter)return;this.painter=t,this.useFaceMap();let r=this.expression??"neutral";this.expression=null,this.setExpression(r);}useFaceMap(){let t=this.painter;this.decalMat.map=t?t.texture:this.asset.texture,this.decalMat.transparent=!!t,this.decalMat.alphaTest=t?.02:.5,this.decalMat.needsUpdate=true;}setExpression(t){if(t===this.expression||!this.decal)return;let r=this.asset.layout.face?.uv,o=this.painter?[0,1,1,0]:r?.[t]??r?.neutral;if(!o)return;this.expression=t,this.painter?.paint(t);let[n,a,i,c]=o,s=this.decal.geometry.getAttribute("uv");s.setXY(0,n,a),s.setXY(1,i,a),s.setXY(2,i,c),s.setXY(3,n,c),s.needsUpdate=true;}materials(){return [this.material,this.decalMat]}setBrightness(t){this.brightness=t,this.material.color.setScalar(t),this.decalMat.color.setScalar(t);for(let r of this.printMats.values())r.color.setScalar(t);}setEmissive(t){if(this.material.emissive.getHex()!==t){this.material.emissive.setHex(t),this.decalMat.emissive.setHex(t);for(let r of this.printMats.values())r.emissive.setHex(t||Lr);}}setShadows(t){if(t!==this.shadows){this.shadows=t;for(let r of this.meshes)r.castShadow=t;}}attach(t,r){let o=this.attached.get(t);if(o!==r){if(o&&o.removeFromParent(),!r){this.attached.delete(t);return}this.attached.set(t,r),this.sockets.get(t)?.add(r);}}attachedAt(t){return this.attached.get(t)??null}setName(t){this.label&&Bt(this.label),this.label=t?Mr(t):null,this.label&&this.group.add(this.label),this.placeLabel();}setLabelVisible(t){this.label&&(this.label.visible=t);}placeLabel(){this.label&&(this.label.position.y=this.height+.25);}forEachMesh(t){for(let r of this.meshes)t(r);this.decal&&t(this.decal);for(let r of this.printMeshes)t(r);}dispose(){this.group.removeFromParent();for(let t of this.attached.values())t.removeFromParent();this.attached.clear(),this.clear(),this.label&&Bt(this.label),this.label=null,this.material.dispose(),this.decalMat.dispose();for(let t of this.printMats.values())t.dispose();this.printMats.clear(),it(this.asset);}};var dt=new Map,jt=new Set;function Qs(e){let t=ze(e);if(!dt.has(t)){dt.set(t,e);for(let r of jt)r(t);}return t}function ei(e){return typeof e=="string"?dt.get(e):void 0}function ti(e){let t={};for(let r of e){let o=dt.get(r);o&&(t[r]=o);}return t}function ri(e){return jt.add(e),()=>jt.delete(e)}var yn=["#b08a62","#8a6a4a","#c8a878","#9a9a92","#7a5c44"],gn=["#f1c9a5","#e6b892","#d9a982","#c08e68","#a0704c","#7a5238"],wn=["#6b4a2f","#4a3424","#8a5a3a","#c27a48","#d8b878","#2e2622","#a07850","#9a9690"],xn=["#a7bea9","#e6e0cc","#d9c9a3","#b9a083","#a9b8c4","#c8b4a0","#9fb0a0","#d8d2c4","#b98f74","#8fa3b5"],vn=["#8c9ca6","#a9b8b4","#8a8e94","#9fb3ad","#7d8a8f","#b0a58f"],Rn=["#d9c9a3","#c8b48a","#a08a6a","#e6e0cc"];function ii(e,t="",r=""){let o=a(b("npc:"+e+"|"+t)),n=c=>c[Math.floor(o()*c.length)],a$1=Ht({top:n(kr),bottom:n(Tr),shoes:n(Cr),hair:n(["short","short","long","curly"]),hat:o()<.2,colors:{skin:n(gn),hair:n(wn),shirt:n(xn),pants:n(vn),boots:n(yn),hat:n(Rn)}});a$1.name=e.slice(0,40),a$1.description=[t,r].filter(Boolean).join(" \u2014 ").slice(0,300),a$1.style={walk:n(["normal","normal","bouncy","heavy","sneaky"]),idle:n(["calm","calm","fidgety","proud"]),energy:Math.round(o()*10)/10},a$1.tags=["npc",...t?[t.slice(0,24)]:[]];let i=le(a$1);return i.ok?i.spec:Se()}var ge=([e,t,r])=>"#"+[e,t,r].map(o=>Math.round(o).toString(16).padStart(2,"0")).join("");function En(e){if(!e.length)return null;let t=r=>{let o=e.map(n=>n[r]).sort((n,a)=>n-a);return o[o.length>>1]};return [t(0),t(1),t(2)]}function Sn(e,t){let{width:r,height:o,data:n}=e,a=(k,g)=>{let f=(g*r+k)*4;return [n[f],n[f+1],n[f+2]]},i=[a(0,0),a(r-1,0),a(0,o-1),a(r-1,o-1)],c=[0,1,2].map(k=>i.reduce((g,f)=>g+f[k],0)/4),s=k=>Math.abs(k[0]-c[0])+Math.abs(k[1]-c[1])+Math.abs(k[2]-c[2])>60,l=r,h=-1,m=o,p=-1;for(let k=0;k<o;k+=2)for(let g=0;g<r;g+=2)s(a(g,k))&&(l=Math.min(l,g),h=Math.max(h,g),m=Math.min(m,k),p=Math.max(p,k));h<0&&(l=0,h=r-1,m=0,p=o-1);let y=p-m+1,w=h-l+1,b=l+Math.floor(w*.3),T=l+Math.ceil(w*.7);return t.map(([k,g])=>{let f=[];for(let S=m+Math.floor(y*k);S<m+Math.ceil(y*g);S++)for(let d=b;d<T;d++){if(S<0||S>=o||d<0||d>=r)continue;let R=a(d,S);s(R)&&f.push(R);}return En(f)})}var An=[[0,.06],[.1,.22],[.3,.52],[.6,.86],[.92,1]];function mi(e,t="humanoid",r=at()){let[o,n,a,i,c]=Sn(e,An);if(t==="humanoid"){let l=JSON.parse(JSON.stringify(Dt));l.palette=Nt(l.palette,{...o?{hair:ge(o)}:{},...n?{skin:ge(n)}:{},...a?{shirt:ge(a)}:{},...i?{pants:ge(i)}:{},...c?{boots:ge(c)}:{}}),l.name=r,l.tags=[];let h=le(l);return h.ok?h.spec:Se()}let s=le({name:r,rig:t,palette:{s:ge(n??o??[198,156,124]),t:ge(a??[58,143,214]),p:ge(i??c??[44,62,107]),w:"#f4f4f4",b:"#1d1d21"},textures:{f_neutral:{w:4,h:2,rows:["wbbw","...."]},f_blink:{w:4,h:2,rows:["bbbb","...."]}},face:{rect:t==="blob"?[4,4,4,2]:t==="flyer"?[0,1,4,2]:[2,2,4,2],expressions:{neutral:"f_neutral",blink:"f_blink"}}});return s.ok?s.spec:Se()}var kn={normal:{},bouncy:{amp:.9,arm:.8,bob:1.6,tempo:1.1,sway:.04},heavy:{amp:.6,arm:.4,bob:.6,tempo:.8,sway:.12},sneaky:{amp:.5,arm:.3,tempo:1.2},robotic:{amp:.7,arm:.7,quant:true}},Tn={calm:{},fidgety:{fidget:1,breath:1.3},proud:{chest:.08,breath:.8}};function Gt(e){let t={amp:.8,arm:.6,bob:0,tempo:1,sway:0,quant:false,breath:1,fidget:0,chest:0,...kn[e.walk],...Tn[e.idle]};return t.tempo*=.8+.4*e.energy,t.amp*=.85+.3*e.energy,t}function ft(e,t=0){let r=Math.sin(e.phase+t);return e.style.quant?Math.max(-1,Math.min(1,r*3)):r}function Ut(e,t,r){let o=ft(t)*r;u(e,"legL","rx",o),u(e,"legR","rx",-o),u(e,"legFL","rx",o),u(e,"legBR","rx",o),u(e,"legFR","rx",-o),u(e,"legBL","rx",-o);}function Yt(e,t,r){let o=ft(t)*r;u(e,"armL","rx",-o),u(e,"armR","rx",o);}function $t(e,t,r,o){let n=ft(t),a=Math.max(0,Math.cos(t.phase))*Math.max(0,-n+.3),i=Math.max(0,-Math.cos(t.phase))*Math.max(0,n+.3);u(e,"shinL","rx",-r*(.15+a)),u(e,"shinR","rx",-r*(.15+i)),u(e,"foreArmL","rx",o*(.6+.4*Math.max(0,-n))),u(e,"foreArmR","rx",o*(.6+.4*Math.max(0,n)));}var Cn=(e,t)=>{let r=Math.sin(t.clock*2)*t.style.breath;u(e,"armL","rz",-0.04-.03*r),u(e,"armR","rz",.04+.03*r),u(e,"foreArmL","rx",.12+.02*r),u(e,"foreArmR","rx",.12+.02*r),u(e,"head","rx",.03*Math.sin(t.clock*1.7)+t.style.chest),u(e,"body","rx",t.style.chest*-0.5),t.style.fidget&&(u(e,"head","ry",.35*Math.sin(t.clock*.7)*Math.sin(t.clock*.31)),u(e,"root","ry",.05*Math.sin(t.clock*.9))),u(e,"body","sy",1+.04*Math.sin(t.clock*3));},Mn=(e,t)=>{Ut(e,t,t.style.amp),Yt(e,t,t.style.arm),$t(e,t,t.style.amp*1.1,.35),u(e,"root","py",t.style.bob*Math.abs(Math.cos(t.phase))),u(e,"body","rz",t.style.sway*ft(t));},In=(e,t)=>{Ut(e,t,t.style.amp*1.3),Yt(e,t,t.style.arm*1.6),$t(e,t,t.style.amp*1.6,1.1),u(e,"body","rx",-0.18),u(e,"head","rx",.18),u(e,"root","py",(.8+t.style.bob)*Math.abs(Math.cos(t.phase)));},Pn=(e,t)=>{Ut(e,t,t.style.amp*.5*Math.min(1,t.input.speed)),Yt(e,t,t.style.arm*.4*Math.min(1,t.input.speed)),u(e,"body","rx",-0.45),u(e,"head","rx",.45),pe(e,"armL","rx",.25),pe(e,"armR","rx",.25),$t(e,t,.9,.6),u(e,"root","py",-1.5);},Ln=(e,t)=>{u(e,"root","rx",-1.3),u(e,"head","rx",1),u(e,"armL","rx",Math.PI-.5+.5*Math.sin(t.t*3)),u(e,"armR","rx",Math.PI-.5+.5*Math.sin(t.t*3+Math.PI)),u(e,"legL","rx",.3*Math.sin(t.t*8)),u(e,"legR","rx",-0.3*Math.sin(t.t*8));},_n=(e,t)=>{u(e,"legL","rx",.15),u(e,"legR","rx",.1),u(e,"armL","rz",-0.15),u(e,"armR","rz",.15),u(e,"root","py",.6*Math.sin(t.t*2));},On=e=>{u(e,"root","rx",-1.35),u(e,"head","rx",1.1),u(e,"armL","rz",-1.3),u(e,"armR","rz",1.3);},zn=(e,t)=>{let r=.15*Math.sin(t.t*10);u(e,"armL","rz",-0.6-r),u(e,"armR","rz",.6+r),u(e,"legL","rx",.25),u(e,"legR","rx",-0.25),u(e,"shinL","rx",-0.5),u(e,"shinR","rx",-0.3),u(e,"foreArmL","rx",.4),u(e,"foreArmR","rx",.4);},Fn=e=>{u(e,"legL","rx",1.45),u(e,"legR","rx",1.45),u(e,"legL","ry",.1),u(e,"legR","ry",-0.1),u(e,"shinL","rx",-1.45),u(e,"shinR","rx",-1.45),u(e,"root","py",-10),u(e,"body","rx",.4),u(e,"legBL","rx",1.2),u(e,"legBR","rx",1.2);},Nn=e=>{u(e,"legL","rx",1.4),u(e,"legR","rx",1.4),u(e,"legL","rz",-0.3),u(e,"legR","rz",.3),u(e,"armL","rx",.45),u(e,"armR","rx",.45),u(e,"shinL","rx",-1.2),u(e,"shinR","rx",-1.2),u(e,"foreArmL","rx",.5),u(e,"foreArmR","rx",.5);},Hn=e=>{u(e,"root","rx",Math.PI/2),u(e,"root","py",2);},Dn=e=>{u(e,"root","rz",Math.PI/2),u(e,"root","py",2);},Bn=(e,t)=>{let r=Math.sin(t.phase*.5);u(e,"root","py",6*Math.max(0,r));let o=r<0?.2*-r:0;u(e,"body","sy",1-o+.1*Math.max(0,r)),u(e,"body","sx",1+o*.6),u(e,"body","sz",1+o*.6);},Vn=(e,t)=>{let r=Math.sin(Math.PI*t.k);u(e,"armR","rx",1.9*r),u(e,"armR","ry",.3*r),u(e,"body","ry",-0.3*r),u(e,"foreArmR","rx",.6*r);},jn=(e,t)=>{let r=Math.sin(Math.PI*t.k);u(e,"armR","rx",.9*r);},Gn=(e,t)=>{let r=t.k<.4?-1.5*(t.k/.4):-1.5+3.5*((t.k-.4)/.6);u(e,"armR","rx",t.k>.9?r*(1-t.k)*10:r);},Un=(e,t)=>{let r=Math.sin(Math.PI*t.k);u(e,"body","rx",.15*r),u(e,"head","rx",.2*r),u(e,"root","rz",.05*r);},Yn=(e,t)=>{let r=Math.sin(Math.PI*t.k);u(e,"root","py",-1.5*r),u(e,"legL","rx",.2*r),u(e,"legR","rx",.2*r),u(e,"shinL","rx",-0.5*r),u(e,"shinR","rx",-0.5*r),u(e,"body","sy",1-.2*r),u(e,"body","sx",1+.12*r),u(e,"body","sz",1+.12*r);},$n=(e,t)=>{u(e,"armR","rx",1.3+.1*Math.sin(t.t*16)),u(e,"armR","ry",-0.5),u(e,"head","rx",-0.1+.08*Math.sin(t.t*16));},qn=e=>{u(e,"armR","rx",2),u(e,"armR","ry",-0.4),u(e,"head","rx",.35);},Wn=e=>{u(e,"armR","rx",1.57),u(e,"armR","ry",-0.1),u(e,"armL","rx",1.57),u(e,"armL","ry",.35);},Kn=e=>{u(e,"armL","rx",.9),u(e,"armL","ry",-0.6);},ut={idle:Cn,walk:Mn,run:In,sneak:Pn,swim:Ln,fly:_n,glide:On,fall:zn,sit:Fn,ride:Nn,sleep:Hn,dead:Dn,hop:Bn,swing:Vn,place:jn,throw:Gn,hurt:Un,land:Yn,eat:$n,drink:qn,draw:Wn,block:Kn},zr={blob:{walk:"hop",run:"hop",sneak:"hop"}},Fr={swing:.3,place:.2,throw:.45,hurt:.3,land:.22};var bt=Math.PI,yt={wave:{label:"\u041F\u043E\u043C\u0430\u0445\u0430\u0442\u044C",duration:2,emotion:"happy",tracks:{"armR.rz":[[0,0],[.25,2.7],[.5,2.3],[.75,2.8],[1,2.3],[1.25,2.8],[1.5,2.4],[2,0]],"armR.rx":[[0,0],[.25,.2],[1.75,.2],[2,0]],"head.rz":[[0,0],[.5,.1],[1.5,.1],[2,0]]}},cheer:{label:"\u0423\u0440\u0430!",duration:1.6,emotion:"happy",tracks:{"armL.rz":[[0,0],[.25,-2.8],[1.35,-2.8],[1.6,0]],"armR.rz":[[0,0],[.25,2.8],[1.35,2.8],[1.6,0]],"root.py":[[0,0],[.3,3],[.55,0],[.8,3],[1.05,0]]}},dance:{label:"\u0422\u0430\u043D\u0435\u0446",duration:2,loop:true,emotion:"happy",tracks:{"root.ry":[[0,.3],[.5,-0.3],[1,.3],[1.5,-0.3],[2,.3]],"armL.rz":[[0,-0.4],[.5,-2.4],[1,-0.4],[1.5,-2.4],[2,-0.4]],"armR.rz":[[0,2.4],[.5,.4],[1,2.4],[1.5,.4],[2,2.4]],"legL.rx":[[0,0],[.5,.5],[1,0],[2,0]],"legR.rx":[[0,0],[1,0],[1.5,.5],[2,0]],"root.py":[[0,0],[.25,1.5],[.5,0],[.75,1.5],[1,0],[1.25,1.5],[1.5,0],[1.75,1.5],[2,0]],"tail.ry":[[0,.6],[.5,-0.6],[1,.6],[1.5,-0.6],[2,.6]]}},point:{label:"\u0423\u043A\u0430\u0437\u0430\u0442\u044C",duration:1.6,tracks:{"armR.rx":[[0,0],[.2,1.55],[1.4,1.55],[1.6,0]]}},laugh:{label:"\u0421\u043C\u0435\u0445",duration:1.6,emotion:"happy",tracks:{"body.rx":[[0,0],[.2,.15],[.4,.05],[.6,.15],[.8,.05],[1,.15],[1.2,.05],[1.6,0]],"head.rx":[[0,0],[.2,.3],[1.4,.3],[1.6,0]],"armL.rx":[[0,0],[.2,.5],[1.4,.5],[1.6,0]],"armR.rx":[[0,0],[.2,.5],[1.4,.5],[1.6,0]]}},cry:{label:"\u041F\u043B\u0430\u043A\u0430\u0442\u044C",duration:2.4,emotion:"sad",tracks:{"head.rx":[[0,0],[.3,-0.4],[2.1,-0.4],[2.4,0]],"head.rz":[[0,0],[.6,.08],[.9,-0.08],[1.2,.08],[1.5,-0.08],[2.4,0]],"armR.rx":[[0,0],[.3,2.3],[2.1,2.3],[2.4,0]],"armR.ry":[[0,0],[.3,-0.6],[2.1,-0.6],[2.4,0]],"armL.rx":[[0,0],[.3,2.3],[2.1,2.3],[2.4,0]],"armL.ry":[[0,0],[.3,.6],[2.1,.6],[2.4,0]]}},bow:{label:"\u041F\u043E\u043A\u043B\u043E\u043D",duration:1.4,tracks:{"body.rx":[[0,0],[.4,-0.7],[1,-0.7],[1.4,0]],"armR.rx":[[0,0],[.4,.5],[1,.5],[1.4,0]]}},shrug:{label:"\u041F\u043E\u0436\u0430\u0442\u044C \u043F\u043B\u0435\u0447\u0430\u043C\u0438",duration:1.2,tracks:{"armL.rz":[[0,0],[.3,-0.5],[.9,-0.5],[1.2,0]],"armR.rz":[[0,0],[.3,.5],[.9,.5],[1.2,0]],"armL.rx":[[0,0],[.3,.6],[.9,.6],[1.2,0]],"armR.rx":[[0,0],[.3,.6],[.9,.6],[1.2,0]],"head.rz":[[0,0],[.3,.25],[.9,.25],[1.2,0]]}},facepalm:{label:"\u0420\u0443\u043A\u0430-\u043B\u0438\u0446\u043E",duration:1.6,emotion:"tired",tracks:{"armR.rx":[[0,0],[.3,2.5],[1.3,2.5],[1.6,0]],"armR.rz":[[0,0],[.3,-0.4],[1.3,-0.4],[1.6,0]],"head.rx":[[0,0],[.3,-0.35],[1.3,-0.35],[1.6,0]]}},sit:{label:"\u0421\u0435\u0441\u0442\u044C",duration:1,loop:true,tracks:{"legL.rx":[[0,bt*.46],[1,bt*.46]],"legR.rx":[[0,bt*.46],[1,bt*.46]],"root.py":[[0,-10],[1,-10]]}}},yi=Object.keys(yt);function gi(e){return typeof e=="string"&&e in yt}function Xn(e,t){let r=e[0];if(t<=r[0])return r[1];for(let o=1;o<e.length;o++){let n=e[o];if(t<=n[0]){let a=e[o-1],i=(t-a[0])/Math.max(1e-6,n[0]-a[0]),c=i*i*(3-2*i);return a[1]+(n[1]-a[1])*c}}return e[e.length-1][1]}function Nr(e,t,r){let o=t.loop?r%t.duration:Math.min(r,t.duration);for(let[n,a]of Object.entries(t.tracks)){let i=n.lastIndexOf("."),c=n.slice(0,i),s=n.slice(i+1);s in V&&u(e,c,s,Xn(a,o));}}var Hr={neutral:["neutral"],happy:["happy","neutral"],sad:["sad","tired","neutral"],angry:["angry","neutral"],surprised:["surprised","scared","neutral"],scared:["scared","surprised","sad","neutral"],tired:["tired","sad","neutral"],hurt:["hurt","angry","sad","neutral"]},qt={neutral:{add:{},tempo:1},happy:{add:{"head.rx":.08},tempo:1.1},sad:{add:{"head.rx":-0.3,"body.rx":-0.08,"tail.rx":.5},tempo:.8},angry:{add:{"body.rx":-0.12,"head.rx":.1,"armL.rz":-0.1,"armR.rz":.1},tempo:1.1},surprised:{add:{"head.rx":.15,"body.rx":.05},tempo:1},scared:{add:{"body.rx":-0.1,"head.rx":-0.1,"armL.rx":.3,"armR.rx":.3,"tail.rx":.6},tempo:1.3},tired:{add:{"head.rx":-0.35,"body.rx":-0.12},tempo:.7},hurt:{add:{"body.rx":-0.1},tempo:1}};function Dr(e,t,r){if(!(r<=0))for(let[o,n]of Object.entries(qt[t].add)){let a=o.lastIndexOf(".");pe(e,o.slice(0,a),o.slice(a+1),(n??0)*r);}}var Ri={damaged:{emotion:"hurt",seconds:.8},lowHealth:{emotion:"tired"},nearDeath:{emotion:"scared"},achievement:{emotion:"happy",seconds:3},bossKilled:{emotion:"happy",seconds:5},tamed:{emotion:"happy",seconds:3},traded:{emotion:"happy",seconds:2},petDied:{emotion:"sad",seconds:6},explosion:{emotion:"surprised",seconds:1.5}};function Ei(e){let t=[[/(>:\(|😠|😡|🤬)/u,"angry"],[/(:'\(|😢|😭)/u,"sad"],[/(:\(|☹|🙁|😞)/u,"sad"],[/(:o|:O|😮|😲)/u,"surprised"],[/(😱|😨)/u,"scared"],[/(-_-|😴|😩|🥱)/u,"tired"],[/(:\)|:D|\^\^|😀|😃|😄|😁|🙂|😊|😂)/u,"happy"]];for(let[r,o]of t)if(r.test(e))return o;return null}var Jn=[{state:"dead",when:e=>e.dead,clip:"dead",blend:.25},{state:"sleep",when:e=>e.sleeping,clip:"sleep",blend:.3},{state:"ride",when:e=>e.riding,clip:"ride",blend:.2},{state:"sit",when:e=>e.sitting,clip:"sit",blend:.3},{state:"swim",when:e=>e.inWater&&!e.onGround&&!e.flying,clip:"swim",blend:.3},{state:"glide",when:e=>e.gliding,clip:"glide",blend:.25},{state:"fly",when:e=>e.flying,clip:"fly",blend:.25},{state:"fall",when:(e,t)=>t.airTime>.35&&e.vy<-4,clip:"fall",blend:.2},{state:"sneak",when:e=>e.sneaking,clip:"sneak",blend:.15},{state:"run",when:e=>e.sprinting&&e.speed>3||e.speed>6.5,clip:"run",blend:.15},{state:"walk",when:e=>e.speed>.4,clip:"walk",blend:.15},{state:"idle",when:()=>true,clip:"idle",blend:.2}],Zn=new Set(["hurt","land"]),Qn={eat:"eat",drink:"drink",draw:"draw",block:"block"},ea={tail:(e,t)=>[["ry",-e.yawRate*.25+.12*Math.sin(t*2)],["rx",-(.1+Math.min(e.speed,8)*.06)]],cape:(e,t)=>[["rx",-(.05+Math.min(e.speed,8)*.12)-(e.speed>1?.06*Math.sin(t*9):0)-(e.vy<-3?.4:0)]],hair:e=>[["rx",-Math.min(e.speed,8)*.03]],ear:(e,t)=>[["rz",.08*Math.sin(t*1.3)+Math.min(e.speed,6)*.02]],antenna:(e,t)=>[["rx",.1*Math.sin(t*3)-e.vy*.02]],wingL:(e,t)=>e.flying||e.gliding||!e.onGround&&!e.inWater?[["rz",e.gliding?-0.05:-0.7*Math.sin(t*12)]]:[["rz",1.1+.05*Math.sin(t*1.5)]],wingR:(e,t)=>e.flying||e.gliding||!e.onGround&&!e.inWater?[["rz",e.gliding?.05:.7*Math.sin(t*12)]]:[["rz",-1.1-.05*Math.sin(t*1.5)]]},gt=e=>{let t=Math.max(0,Math.min(1,e));return t*t*(3-2*t)},wt=class{rig;style;faces;pose=new Map;expression="neutral";state="idle";stateT=0;clock=0;phase=0;airTime=0;wasOnGround=true;loco=new Map;from=new Map;lastLoco=new Map;blendT=1;blendDur=.2;tmp=new Map;actions=[];useClip=null;useW=0;emote=null;mood="neutral";moodOverGestures=false;flash=null;postureW=new Map;blinkT=3;blinking=0;talkT=0;springs=new Map;constructor(t,r,o=[]){this.rig=t,this.style=Gt(r),this.faces=new Set(o);}setRandom(t){this.random=t;}random=Math.random;setStyle(t){this.style=Gt(t);}setEmotion(t,r){r&&r>0?this.flash={emotion:t,left:r}:this.mood=t;}get emotion(){return this.emote?.def.emotion&&!this.moodOverGestures?this.emote.def.emotion:this.flash?.emotion??this.mood}get emoting(){return this.emote?.id??null}playEmote(t){this.emote={id:t,def:yt[t],t:0};}stopEmote(){this.emote=null;}trigger(t){switch(t){case "swing":case "place":case "throw":case "hurt":case "land":{let r=t;this.actions=this.actions.filter(o=>o.clip!==r),this.actions.push({clip:r,t:0,dur:Fr[r]??.3}),t==="hurt"&&this.setEmotion("hurt",.8);break}}}update(t,r=ht()){t=Math.min(t,.1),this.clock+=t;let o=this.emotion,n=qt[o].tempo*this.style.tempo;!r.onGround&&!r.inWater?this.airTime+=t:(!this.wasOnGround&&this.airTime>.3&&r.onGround&&this.trigger("land"),this.airTime=0),this.wasOnGround=r.onGround,this.phase+=r.speed*t*3.5*n;let a=Jn.find(l=>l.when(r,this));a.state!==this.state&&(pt(this.from,this.lastLoco),this.state=a.state,this.stateT=0,this.blendT=0,this.blendDur=a.blend),this.stateT+=t,Ae(this.loco);let i=zr[this.rig]?.[a.clip]??a.clip,c={t:this.stateT,k:0,phase:this.phase,input:r,style:this.style,clock:this.clock*n};if(ut[i](this.loco,c),Ae(this.pose),this.blendT<this.blendDur?(this.blendT+=t,Ir(this.pose,this.from,this.loco,gt(this.blendT/this.blendDur))):pt(this.pose,this.loco),pt(this.lastLoco,this.pose),this.emote){let l=this.emote;if(l.t+=t,r.speed>1||this.state!=="idle"||!l.def.loop&&l.t>=l.def.duration)this.emote=null;else {let p=l.def.loop?gt(l.t/.15):gt(Math.min(l.t/.15,(l.def.duration-l.t)/.15));Ae(this.tmp),Nr(this.tmp,l.def,l.t),this.overlay(this.tmp,p,false);}}let s=r.use?Qn[r.use]:null;s&&(this.useClip=s),this.useW=Math.max(0,Math.min(1,this.useW+(s?t:-t)*8)),this.useClip&&this.useW>0?(Ae(this.tmp),ut[this.useClip](this.tmp,{...c,t:this.clock}),this.overlay(this.tmp,gt(this.useW),false)):r.held!=="none"&&!this.emote&&pe(this.pose,"armR","rx",r.held==="staff"?.35:.2);for(let l of this.actions){l.t+=t;let h=Math.min(1,l.t/l.dur);Ae(this.tmp),ut[l.clip](this.tmp,{...c,t:l.t,k:h}),this.overlay(this.tmp,1,Zn.has(l.clip));}this.actions=this.actions.filter(l=>l.t<l.dur),this.state!=="dead"&&this.state!=="sleep"&&(pe(this.pose,"head","ry",Math.max(-1.1,Math.min(1.1,r.lookYaw))),pe(this.pose,"head","rx",Math.max(-1.2,Math.min(1.2,r.lookPitch)))),this.flash&&(this.flash.left-=t)<=0&&(this.flash=null);for(let l of a$1){let h=this.postureW.get(l)??0,m=h+((l===o?1:0)-h)*Math.min(1,t*6);this.postureW.set(l,m),this.state!=="dead"&&Dr(this.pose,l,m);}for(let[l,h]of Object.entries(ea))for(let[m,p]of h(r,this.clock)){let y=l+"."+m,w=this.springs.get(y);w||this.springs.set(y,w={x:p,v:0});let b=60,T=9;w.v+=(b*(p-w.x)-T*w.v)*t,w.x+=w.v*t,pe(this.pose,l,m,w.x);}return this.expression=this.face(r,t,o),this.pose}overlay(t,r,o){for(let[n,a]of t){let i=De(this.pose,n);for(let c=0;c<9;c++)o?c>=V.sx?i[c]=i[c]*(1+(a[c]-1)*r):i[c]=i[c]+(a[c]-He[c])*r:i[c]=i[c]+(a[c]-i[c])*r;}}face(t,r,o){let n=i=>i.find(c=>this.faces.has(c))??"neutral";if(t.dead||this.state==="dead"||t.sleeping)return n(["blink","hurt","neutral"]);let a=n(Hr[o]);return t.viseme!==void 0?(this.talkT=0,t.viseme!=="rest"&&t.viseme!=="MBP"?n(["talk",a]):a):t.talk?(this.talkT+=r,Math.floor(this.talkT/.12)%2===0?n(["talk",a]):a):(this.talkT=0,this.blinking>0?(this.blinking-=r,n(["blink",a])):(this.blinkT-=r,this.blinkT<=0&&(this.blinkT=2.5+this.random()*3,o!=="surprised"&&o!=="scared"&&o!=="hurt"&&(this.blinking=.13)),a))}};var ta={idle:{},talk:{},walk:{speed:1.6},run:{speed:5.2},surprised:{emote:"shrug"},point:{emote:"point"},sit:{sitting:true},wave:{emote:"wave"},jump:{air:true},fall:{emote:"facepalm"},dance:{emote:"dance"}},ra={handR:"handR",handL:"handL",head:"headTop"},xt=class{view;animator;input=ht();seed;pose="idle";jumpT=-1;constructor(t,r={}){this.view=new mt(t,{shadows:false,...r}),this.seed=r.seed??1,this.animator=this.newAnimator();}get group(){return this.view.group}get height(){return this.view.height}setSpec(t){let r=this.view.hash;this.view.setSpec(t),this.view.hash!==r&&(this.animator=this.newAnimator());}setEmotion(t){this.animator.setEmotion(t);}setViseme(t){this.input.viseme=t;}setPose(t){if(t===this.pose)return;this.pose=t;let r=ta[t];this.input.speed=r.speed??0,this.input.sitting=!!r.sitting,r.emote&&this.animator.playEmote(r.emote),r.air&&(this.jumpT=0,this.animator.trigger("jump"));}playEmote(t){this.animator.playEmote(t);}trigger(t){if(t==="jump"){this.jumpT=0,this.animator.trigger("jump");return}this.animator.trigger(t);}attach(t,r){this.view.attach(ra[t],r);}update(t){let r=this.input;this.jumpT>=0&&(this.jumpT+=t,r.onGround=this.jumpT>.6,r.vy=this.jumpT<.3?4:-4,r.onGround&&(this.jumpT=-1,r.vy=0,this.animator.trigger("land")));let o=this.animator.update(t,r);this.view.applyPose(o),this.view.setExpression(this.animator.expression);}dispose(){this.view.dispose();}newAnimator(){let t=this.view.spec,r=new wt(t.rig,t.style,this.view.expressions);return r.setRandom(a(this.seed)),r}};var oa=Be.map(e=>{let t=ie[e],r=t.bones.map(n=>`${n.name}@[${n.pivot.join(",")}]`).join(" "),o=t.defaultParts.map(n=>`${n.bone} ${n.size.join("x")} at [${n.pos.join(",")}]`).join("; ");return `- "${e}" \u2014 ${t.hint}. Bones (name@pivot): ${r}. Default body: ${o}.`}).join(`
|
|
25
|
+
`),Ni=`You design blocky voxel characters for a Minecraft-like game. Reply with ONE JSON object \u2014 a CharacterSpec \u2014 and nothing else: no markdown, no comments, no explanations.
|
|
3
26
|
|
|
4
27
|
The game builds and animates the character from your recipe. You give the SHAPE (boxes on a skeleton), the COLOURS (a palette) and small PIXEL-ART pictures for faces and clothes. Animations (walk, run, sneak, swim, fly, emotes, emotions) come from the skeleton \u2014 you never animate.
|
|
5
28
|
|
|
6
29
|
COORDINATES are in model PIXELS (16 px = 1 block): x to the character's RIGHT hand, y UP (y = 0 is the soles of the feet), z BACKWARDS \u2014 the character LOOKS TOWARD -z (its face is on the -z side). A normal person is 32 px tall.
|
|
7
30
|
|
|
8
31
|
SKELETONS ("rig"):
|
|
9
|
-
${
|
|
32
|
+
${oa}
|
|
10
33
|
|
|
11
34
|
CharacterSpec:
|
|
12
35
|
{
|
|
13
36
|
"version": 1,
|
|
14
37
|
"name": string (<= 40 chars, in the player's language),
|
|
15
38
|
"description": string (<= 200 chars),
|
|
16
|
-
"rig": ${
|
|
39
|
+
"rig": ${Be.map(e=>`"${e}"`).join(" | ")},
|
|
17
40
|
"scale": 0.25..3 (overall size; 1 = normal),
|
|
18
41
|
"palette": { "<one character>": "#rrggbb", ... } (<= 32 colours; "." and " " are transparent),
|
|
19
42
|
"textures": { "<id>": { "w": 1..32, "h": 1..32, "rows": [ "<w palette characters>", ... h rows, top row first ] } },
|
|
@@ -25,11 +48,11 @@ CharacterSpec:
|
|
|
25
48
|
"mirror": true (also adds the mirrored copy on the paired bone: armL -> armR, legFL -> legFR),
|
|
26
49
|
"name": string } ],
|
|
27
50
|
"bones": [ <= 16 EXTRA bones for tails, ears, wings, capes, hair, antennas:
|
|
28
|
-
{ "name": string, "parent": "<bone>", "pivot": [x, y, z], "role": ${
|
|
51
|
+
{ "name": string, "parent": "<bone>", "pivot": [x, y, z], "role": ${ot.map(e=>`"${e}"`).join(" | ")} } ]
|
|
29
52
|
(a role makes the bone move by itself: a tail sways, ears twitch, a cape flutters when running, wings flap in flight; "static" \u2014 no motion),
|
|
30
53
|
"face": { "bone": "head", "rect": [x, y, w, h] (where the face sits on the FRONT face of the head box, px from its top-left corner as seen by a viewer),
|
|
31
|
-
"expressions": { ${
|
|
32
|
-
"style": { "walk": ${
|
|
54
|
+
"expressions": { ${je.map(e=>`"${e}"`).join(", ")}: "<texture id of size w x h>" } } \u2014 eyes and mouth, drawn over the head; "neutral" is required, draw as many others as you can (at least blink, happy, sad, angry, surprised),
|
|
55
|
+
"style": { "walk": ${Pt.map(e=>`"${e}"`).join(" | ")}, "idle": ${Lt.map(e=>`"${e}"`).join(" | ")}, "energy": 0..1 },
|
|
33
56
|
"voice": { "pitch": 0.5..2 },
|
|
34
57
|
"tags": [ <= 8 short words ],
|
|
35
58
|
"finish": { "noise": 0..1, "outline": 0..1, "shade": 0..1, "density": 1..4 } (optional; defaults 0.5 / 0.4 / 0.25 / 2 \u2014 the game adds fabric noise, a dark outline on the edge of every box face and top-to-bottom shading by itself; set 0 for a clean flat look)
|
|
@@ -51,4 +74,4 @@ HOW TO BUILD A GOOD, DETAILED CHARACTER (the game's style: blocky people with fi
|
|
|
51
74
|
- Clothes in the textures: a shirt front with a collar, a button placket and pockets; a striped t-shirt; a knitted sweater with a pattern band and a ribbed hem; trousers with a crease; shorts with skin below and socks; the belt with a buckle.
|
|
52
75
|
- The head front texture: hair on the top rows and the sides, skin elsewhere, a slightly darker chin row; the eyes, brows and mouth go into "face" (e.g. rect [0, 3, 8, 5] with 16x10 pictures): white eyes 3 texels wide with a coloured iris in the middle, brows above them, a 4-texel mouth \u2014 one picture per expression, the same size, transparent where the skin shows through.
|
|
53
76
|
- Add detail with extra boxes: hair fringe, a hood, armour plates, a crown, horns, a tail (an extra bone with role "tail").
|
|
54
|
-
- When the player sends pictures (possibly of ONE character from different angles: front, side, back) study EVERY picture: get the silhouette, proportions, colours, clothes and the face right. Pictures can be photos, drawings or 3D renders \u2014 turn them into a clean blocky version.`;var gi=["cat","dog","fox","bear","rabbit","bird","dragon","slime","ghost","robot"],Nn=e=>({k:"#2a1c14",w:"#f4f4ef",b:e,m:"#7a3a30",o:"#3a1a14"});function Hn(e){let t=e.light??e.body,r=e.accent??e.body,o={t:e.body,s:e.body,l:t,a:r,p:r,...Nn(e.eyes??"#3f6f3a")},n=[],a="quadruped",i=nt("head",[0,3,8,5]),c={walk:"normal",idle:"calm",energy:.6},s=(l,h,m,p,u,x={})=>n.push({name:l,bone:h,size:m,pos:p,color:u,...x});switch(e.kind){case "cat":case "fox":case "dog":case "bear":case "rabbit":{let l=e.kind;s("body","body",[8,8,16],[0,12,0],"t"),s("belly","body",[6,1,12],[0,8,0],"l"),s("head","head",[8,8,8],[0,16,-12],"s");for(let h of ["legFL","legFR","legBL","legBR"]){let m=h.endsWith("L")?-3:3,p=h.startsWith("legF")?-6:6;s(h,h,[3,8,3],[m,4,p],"t"),s(`${h}Paw`,h,[3.2,1.5,3.2],[m,.75,p],"a");}l==="cat"?(s("ear","head",[2,2.5,1],[-2.5,21,-11],"a",{mirror:true}),s("tail","tail",[1.6,1.6,10],[0,15,13],"t",{rot:[20,0,0]}),c={walk:"sneaky",idle:"calm",energy:.5}):l==="fox"?(s("ear","head",[2.4,3.2,1],[-2.5,21.4,-11],"t",{mirror:true}),s("snout","head",[4,3,3],[0,14.5,-17],"l"),s("nose","head",[1.2,1,.6],[0,15.6,-18.6],"a"),s("tail","tail",[3.5,3.5,10],[0,14,13],"t",{rot:[15,0,0]}),s("tailTip","tail",[3.6,3.6,2.5],[0,15.2,18],"l"),c={walk:"bouncy",idle:"fidgety",energy:.7}):l==="dog"?(s("ear","head",[1.5,4,3],[-4.6,17.5,-11.5],"a",{mirror:true}),s("snout","head",[4,3,3],[0,14.5,-17],"l"),s("nose","head",[1.6,1.2,.6],[0,15.8,-18.6],"a"),s("tail","tail",[2,2,7],[0,16,11],"t",{rot:[40,0,0]}),c={walk:"bouncy",idle:"fidgety",energy:.9}):l==="bear"?(s("ear","head",[2,2,1],[-3,20.6,-10.5],"a",{mirror:true}),s("snout","head",[4,3,2.5],[0,14.5,-16.8],"l"),s("nose","head",[1.6,1.2,.6],[0,15.8,-18.2],"a"),s("tail","tail",[2,2,2],[0,14,9],"t"),c={walk:"heavy",idle:"proud",energy:.4}):(s("ear","head",[1.6,7,1],[-1.8,23.5,-11],"t",{mirror:true}),s("earInner","head",[.8,5.5,.4],[-1.8,23.5,-11.6],"l",{mirror:true}),s("tail","tail",[3,3,3],[0,14,9.5],"l"),c={walk:"bouncy",idle:"fidgety",energy:.8});break}case "bird":case "dragon":{a="flyer",i=nt("head",[0,1,5,3]);let l=e.kind==="dragon";s("body","body",[6,6,8],[0,8,0],"t"),s("belly","body",[4.6,4,1],[0,7.5,-4.2],"l"),s("head","head",[5,5,5],[0,13,-4],"s"),s("wing","wingL",[8,1,6],[-7,10,0],"a",{mirror:true}),s("leg","legL",[1,4,1],[-1.5,2,0],"a",{mirror:true}),l?(s("horn","head",[.8,2,.8],[-1.4,16.4,-3],"l",{mirror:true}),s("snout","head",[3,2,2.4],[0,12.2,-7.4],"s"),s("tail","tail",[2,2,8],[0,7,7],"t"),s("spike","body",[1,1.5,6],[0,11.6,0],"a"),c={walk:"heavy",idle:"proud",energy:.6}):(s("beak","head",[1.6,1.2,2],[0,12.4,-7.2],"a"),s("tail","tail",[4,1,4],[0,8,6],"a"),s("crest","head",[1,2,2],[0,16.2,-3.6],"a"),c={walk:"bouncy",idle:"fidgety",energy:.8});break}case "slime":case "ghost":case "robot":{a="blob",i=nt("body",[2,3,8,5]),e.kind==="slime"?(s("body","body",[12,10,12],[0,5,0],"t"),s("shine","body",[3,2,.4],[-3,8,-6.2],"l"),c={walk:"bouncy",idle:"fidgety",energy:.9}):e.kind==="ghost"?(s("body","body",[10,12,10],[0,7,0],"t"),s("hem","body",[10.4,2,10.4],[0,1,0],"l"),c={walk:"sneaky",idle:"calm",energy:.4}):(s("body","body",[11,11,10],[0,5.5,0],"t"),s("antenna","body",[.8,3,.8],[0,12.5,0],"a"),s("bulb","body",[1.6,1.6,1.6],[0,14.6,0],"l"),s("screen","body",[9,6,.4],[0,6.5,-5.2],"l"),c={walk:"robotic",idle:"calm",energy:.5});break}}return {version:1,name:e.name,description:e.description??"",rig:a,palette:o,textures:i.textures,parts:n,face:i.face,style:c,finish:{noise:.45,outline:.4,shade:.25,density:2},tags:e.tags??[e.kind]}}function wi(e){let t=ae(Hn(e));if(!t.ok)throw new Error(`${e.kind}: ${t.error}`);return t.spec}var re="voxel-v1",Ae=1,Ee=["hair","top","bottom","shoes","hands","waist","back","faceAcc","hat"],qt=["head","torso","sleeveL","sleeveR","forearmL","forearmR","handL","handR","legL","legR","footL","footR"],$t={sleeves:["sleeveL","sleeveR"],forearms:["forearmL","forearmR"],arms:["sleeveL","sleeveR","forearmL","forearmR"],hands:["handL","handR"],legs:["legL","legR"],feet:["footL","footR"]},Re="@skin",Wt={hair:{bones:["head"],paint:["head"],paintFaces:["top","back","left","right"],parts:8,box:{min:[-6,22,-6],max:[6,35.5,6]}},hat:{bones:["head"],paint:[],parts:8,box:{min:[-7,26,-8],max:[7,38,7]}},top:{bones:["body","armL","armR","foreArmL","foreArmR"],paint:["torso","sleeveL","sleeveR","forearmL","forearmR"],parts:6,box:{min:[-10,9.5,-6],max:[10,26,6]}},bottom:{bones:["body","legL","legR","shinL","shinR"],paint:["legL","legR"],parts:4,box:{min:[-6.5,.5,-4.5],max:[6.5,17,4.5]}},shoes:{bones:["legL","legR","shinL","shinR"],paint:["footL","footR"],parts:4,box:{min:[-5.5,-0.5,-4.5],max:[5.5,7,4]}},hands:{bones:["armL","armR","foreArmL","foreArmR"],paint:["handL","handR"],parts:2,box:{min:[-10,9.5,-4],max:[10,16,4]}},waist:{bones:["body"],paint:[],parts:4,box:{min:[-7,9.5,-4],max:[7,16.5,4]}},back:{bones:["body"],paint:[],parts:8,box:{min:[-13.5,6,1.5],max:[13.5,36.5,13]}},faceAcc:{bones:["head"],paint:[],parts:4,box:{min:[-6,22.5,-6],max:[6,30.5,-2]}}},ke={palette:5,textures:4,textureSide:32,texturePixels:2048,id:40,textureId:12,name:40},Ve=["round","sparkle","wide","cat","sleepy","dot"],je=["soft","thick","arched","none"],Ge=["smile","grin","cat","small"],Ue=[.5,1.8,7.5,5.4],Dn={eyes:"round",eyeColor:"#3b2a20",brows:"soft",browColor:"#3b2a20",mouth:"smile",cheeks:true},Be={min:.9,max:1.1},Gt=(e,t,r)=>typeof e=="string"&&t.includes(e)?e:r,Yt=e=>typeof e=="string"&&Ee.includes(e);function bt(e){let t=H(e)?e:{},r=H(t.body)?t.body:{},o=H(t.face)?t.face:{},n=Dn,a={};if(H(t.wear))for(let[c,s]of Object.entries(t.wear))Yt(c)&&typeof s=="string"&&s.trim()&&(a[c]=s.trim().slice(0,ke.id));let i={};if(H(t.tint))for(let[c,s]of Object.entries(t.tint)){let l=de(s);Yt(c)&&l&&(i[c]=l);}return {version:Ae,style:re,body:{skin:de(r.skin)??"#f2c9a0",height:Q(r.height,1,Be.min,Be.max)},face:{eyes:Gt(o.eyes,Ve,n.eyes),eyeColor:de(o.eyeColor)??n.eyeColor,brows:Gt(o.brows,je,n.brows),browColor:de(o.browColor)??n.browColor,mouth:Gt(o.mouth,Ge,n.mouth),cheeks:typeof o.cheeks=="boolean"?o.cheeks:n.cheeks},wear:a,tint:i}}var Bn=/^[a-z0-9][a-z0-9_.-]*$/,Vn=/^[A-Za-z0-9]+$/;function Ut(e){return !Array.isArray(e)||e.length!==3?null:e.every(t=>typeof t=="number"&&Number.isFinite(t))?e:null}function jn(e,t){if(!t||t.every(o=>o===0))return [e[0]/2,e[1]/2,e[2]/2];let r=Math.hypot(e[0],e[1],e[2])/2;return [r,r,r]}function yt(e){let t=[],r=(g,b,S)=>t.push(c({en:g,ru:b},S));if(!H(e))return {ok:false,errors:[c({en:"the item is not an object",ru:"\u0432\u0435\u0449\u044C: \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442"})]};let o=e,n=ke;o.style!==void 0&&o.style!==re&&r("style \xAB{s}\xBB is not {need}","\u0441\u0442\u0438\u043B\u044C \xAB{s}\xBB: \u043D\u0435 {need}",{s:String(o.style),need:re});let a=typeof o.id=="string"?o.id.trim():"";if((!a||a.length>n.id||!Bn.test(a))&&r("id must be 1, {n} characters: a-z, 0-9, _ . -","id: 1, {n} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432: a-z, 0-9, _ . -",{n:n.id}),!Yt(o.slot))return r("unknown slot \xAB{s}\xBB","\u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u044B\u0439 \u0441\u043B\u043E\u0442 \xAB{s}\xBB",{s:String(o.slot)}),{ok:false,errors:t};let i=o.slot,c$1=Wt[i],s=typeof o.name=="string"&&o.name.trim()?o.name.trim().slice(0,n.name):a,l={};if(!H(o.palette)||!Object.keys(o.palette).length)r("the palette is empty","\u043F\u0430\u043B\u0438\u0442\u0440\u0430 \u043F\u0443\u0441\u0442\u0430");else {let g=Object.entries(o.palette);g.length>n.palette&&r("more than {n} colours in the palette","\u0432 \u043F\u0430\u043B\u0438\u0442\u0440\u0435 \u0431\u043E\u043B\u044C\u0448\u0435 {n} \u0446\u0432\u0435\u0442\u043E\u0432",{n:n.palette});for(let[b,S]of g){let d=S===Re?Re:de(S);b.length!==1||ue.has(b)||!d?r("palette colour \xAB{k}\xBB is not valid","\u0446\u0432\u0435\u0442 \u043F\u0430\u043B\u0438\u0442\u0440\u044B \xAB{k}\xBB \u043D\u0435 \u0433\u043E\u0434\u0438\u0442\u0441\u044F",{k:b}):l[b]=d;}}let h=typeof o.tint=="string"&&o.tint?o.tint:null;h!==null&&(!l[h]||l[h]===Re)&&r("tint \xAB{k}\xBB is not a colour of the palette","\u043F\u0435\u0440\u0435\u043A\u0440\u0430\u0441\u043A\u0430 \xAB{k}\xBB: \u043D\u0435 \u0446\u0432\u0435\u0442 \u043F\u0430\u043B\u0438\u0442\u0440\u044B",{k:h});let m={},p=0;if(o.textures!==void 0)if(!H(o.textures))r("textures is not an object","textures: \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442");else {let g=Object.entries(o.textures);g.length>n.textures&&r("more than {n} textures","\u0442\u0435\u043A\u0441\u0442\u0443\u0440 \u0431\u043E\u043B\u044C\u0448\u0435 {n}",{n:n.textures});for(let[b,S]of g){if(b.length>n.textureId||!Vn.test(b)){r("texture id \xAB{id}\xBB must be 1, {n} letters or digits","id \u0442\u0435\u043A\u0441\u0442\u0443\u0440\u044B \xAB{id}\xBB: 1, {n} \u0431\u0443\u043A\u0432 \u0438\u043B\u0438 \u0446\u0438\u0444\u0440",{id:b.slice(0,20),n:n.textureId});continue}let d=H(S)?S:null,v=d&&Array.isArray(d.rows)?d.rows:null,A=d?d.w:void 0,R=d?d.h:void 0;if(!v||typeof A!="number"||typeof R!="number"||!Number.isInteger(A)||!Number.isInteger(R)||A<1||R<1||A>n.textureSide||R>n.textureSide||v.length!==R||v.some(I=>typeof I!="string"||I.length!==A)){r("texture \xAB{id}\xBB must be w\xD7h \u2264 {n} with exactly h rows of w symbols","\u0442\u0435\u043A\u0441\u0442\u0443\u0440\u0430 \xAB{id}\xBB: w\xD7h \u2264 {n}, \u0440\u043E\u0432\u043D\u043E h \u0441\u0442\u0440\u043E\u043A \u043F\u043E w \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",{id:b,n:n.textureSide});continue}v.some(I=>[...I].some(F=>!ue.has(F)&&!l[F]))&&r("texture \xAB{id}\xBB uses symbols outside the palette","\u0432 \u0442\u0435\u043A\u0441\u0442\u0443\u0440\u0435 \xAB{id}\xBB \u0441\u0438\u043C\u0432\u043E\u043B\u044B \u043D\u0435 \u0438\u0437 \u043F\u0430\u043B\u0438\u0442\u0440\u044B",{id:b}),p+=A*R,m[b]={w:A,h:R,rows:v.map(I=>I.replace(/ /g,"."))};}p>n.texturePixels&&r("textures take {p} pixels, the limit is {n}","\u0442\u0435\u043A\u0441\u0442\u0443\u0440\u044B \u0437\u0430\u043D\u0438\u043C\u0430\u044E\u0442 {p} \u043F\u0438\u043A\u0441\u0435\u043B\u0435\u0439, \u043F\u0440\u0435\u0434\u0435\u043B {n}",{p,n:n.texturePixels});}let u=(g,b)=>typeof g!="string"?null:m[g]||l[g]?g:(r("{w}: \xAB{v}\xBB is neither a texture nor a palette colour","{w}: \xAB{v}\xBB: \u043D\u0438 \u0442\u0435\u043A\u0441\u0442\u0443\u0440\u0430, \u043D\u0438 \u0446\u0432\u0435\u0442 \u043F\u0430\u043B\u0438\u0442\u0440\u044B",{w:b,v:g}),null),x=(g,b,S=fe)=>{if(g===void 0)return;if(!H(g)){r("{w}: faces is not an object","{w}: faces: \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442",{w:b});return}let d={};for(let[v,A]of Object.entries(g)){if(!fe.includes(v)){r("{w}: unknown face \xAB{f}\xBB","{w}: \u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u0430\u044F \u0433\u0440\u0430\u043D\u044C \xAB{f}\xBB",{w:b,f:v});continue}if(!S.includes(v)){r("{w}: the {slot} slot may not paint the \xAB{f}\xBB face","{w}: \u0441\u043B\u043E\u0442 {slot} \u043D\u0435 \u043A\u0440\u0430\u0441\u0438\u0442 \u0433\u0440\u0430\u043D\u044C \xAB{f}\xBB",{w:b,slot:i,f:v});continue}let R=u(A,b);R&&(d[v]=R);}return Object.keys(d).length?d:void 0},y=[];o.paint!==void 0&&!Array.isArray(o.paint)&&r("paint is not a list","paint: \u043D\u0435 \u0441\u043F\u0438\u0441\u043E\u043A");for(let[g,b]of (Array.isArray(o.paint)?o.paint:[]).entries()){let S=`paint[${g}]`;if(!H(b)){r("{w} is not an object","{w}: \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442",{w:S});continue}let d=typeof b.region=="string"?b.region:"",v=$t[d]??(qt.includes(d)?[d]:[]);if(!v.length){r("{w}: unknown region \xAB{r}\xBB","{w}: \u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u0430\u044F \u043E\u0431\u043B\u0430\u0441\u0442\u044C \xAB{r}\xBB",{w:S,r:d});continue}let A=v.filter(I=>!c$1.paint.includes(I));if(A.length){r("{w}: the {slot} slot may not paint \xAB{r}\xBB","{w}: \u0441\u043B\u043E\u0442 {slot} \u043D\u0435 \u043A\u0440\u0430\u0441\u0438\u0442 \xAB{r}\xBB",{w:S,slot:i,r:A.join(", ")});continue}let R=typeof b.color=="string"&&l[b.color]?b.color:null;R||r("{w}: colour is not in the palette","{w}: \u0446\u0432\u0435\u0442\u0430 \u043D\u0435\u0442 \u0432 \u043F\u0430\u043B\u0438\u0442\u0440\u0435",{w:S});let C=x(b.faces,S,c$1.paintFaces);if(R)for(let I of v){let F={region:I,color:R};C&&(F.faces={...C}),y.push(F);}}let T=[];o.parts!==void 0&&!Array.isArray(o.parts)&&r("parts is not a list","parts: \u043D\u0435 \u0441\u043F\u0438\u0441\u043E\u043A");let k=Array.isArray(o.parts)?o.parts:[];k.length>c$1.parts&&r("the {slot} slot allows {n} boxes, the item has {m}","\u0441\u043B\u043E\u0442\u0443 {slot} \u043C\u043E\u0436\u043D\u043E {n} \u043A\u043E\u0440\u043E\u0431\u043E\u043A, \u0443 \u0432\u0435\u0449\u0438 {m}",{slot:i,n:c$1.parts,m:k.length});for(let[g,b]of k.entries()){let S=`parts[${g}]`;if(!H(b)){r("{w} is not an object","{w}: \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442",{w:S});continue}let d=typeof b.bone=="string"?b.bone:"";if(!c$1.bones.includes(d)){r("{w}: the {slot} slot puts boxes only on {b}","{w}: \u0441\u043B\u043E\u0442 {slot} \u0441\u0442\u0430\u0432\u0438\u0442 \u043A\u043E\u0440\u043E\u0431\u043A\u0438 \u0442\u043E\u043B\u044C\u043A\u043E \u043D\u0430 {b}",{w:S,slot:i,b:c$1.bones.join(", ")});continue}let v=Ut(b.size),A=Ut(b.pos);if(!v||!A||v.some(z=>z<=0)){r("{w}: size and pos must be [x, y, z]","{w}: size \u0438 pos: [x, y, z]",{w:S});continue}let R=b.rot===void 0?void 0:Ut(b.rot);b.rot!==void 0&&!R&&r("{w}: rot must be [x, y, z]","{w}: rot: [x, y, z]",{w:S});let C=b.mirror===true,I=jn(v,R??void 0),w=(C?[A[0],-A[0]]:[A[0]]).some(z=>z-I[0]<c$1.box.min[0]-1e-6||z+I[0]>c$1.box.max[0]+1e-6)||[1,2].some(z=>A[z]-I[z]<c$1.box.min[z]-1e-6||A[z]+I[z]>c$1.box.max[z]+1e-6);w&&r("{w}: the box leaves the {slot} slot frame","{w}: \u043A\u043E\u0440\u043E\u0431\u043A\u0430 \u0432\u044B\u0445\u043E\u0434\u0438\u0442 \u0437\u0430 \u0440\u0430\u043C\u043A\u0443 \u0441\u043B\u043E\u0442\u0430 {slot}",{w:S,slot:i});let E=typeof b.color=="string"&&l[b.color]?b.color:null;E||r("{w}: colour is not in the palette","{w}: \u0446\u0432\u0435\u0442\u0430 \u043D\u0435\u0442 \u0432 \u043F\u0430\u043B\u0438\u0442\u0440\u0435",{w:S});let M=x(b.faces,S);if(!E||w)continue;let P={bone:d,size:[...v],pos:[...A],color:E};M&&(P.faces=M),R&&R.some(z=>z!==0)&&(P.rot=[...R]),C&&(P.mirror=true),typeof b.name=="string"&&b.name.trim()&&(P.name=b.name.trim().slice(0,24)),T.push(P);}return !k.length&&!(Array.isArray(o.paint)&&o.paint.length)&&r("the item neither paints nor adds anything","\u0432\u0435\u0449\u044C \u043D\u0438\u0447\u0435\u0433\u043E \u043D\u0435 \u043A\u0440\u0430\u0441\u0438\u0442 \u0438 \u043D\u0435 \u0434\u043E\u0431\u0430\u0432\u043B\u044F\u0435\u0442"),t.length?{ok:false,errors:t}:{ok:true,item:{version:Ae,style:re,id:a,slot:i,name:s,palette:l,tint:h,textures:m,paint:y,parts:T}}}var _r={torso:"#d9d3c5",legs:"#5f6b7a"},Gn="#2b2140",Un="#7a2e2e",Yn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",qn=32,$n=[10,7],Wn={noise:0,outline:0,shade:.12,density:4,round:.35},Kn=["front","back","left","right"];function Or(e){let t=parseInt(e.slice(1),16);return [t>>16&255,t>>8&255,t&255]}var Kt=class{map={};next=0;key(t){let r=Object.entries(this.map).find(([,s])=>s===t);if(r)return r[0];if(this.next<qn){let s=Yn[this.next++];return this.map[s]=t,s}let[o,n,a]=Or(t),i=Object.keys(this.map)[0],c=1/0;for(let[s,l]of Object.entries(this.map)){let[h,m,p]=Or(l),u=(o-h)**2+(n-m)**2+(a-p)**2;u<c&&(c=u,i=s);}return i}};function Xn(e,t){return (typeof e=="function"?e(t):e[t])??null}function Jn(e){let[t,r]=$n,o=new L(t,r),n=a=>{a(1),a(6);};switch(e){case "blink":case "tired":n(a=>o.row(3,a,a+2,"k"));break;case "happy":n(a=>o.px(a,3,"k").px(a+1,2,"k").px(a+2,3,"k"));break;case "hurt":o.px(1,2,"k").px(2,3,"k").px(1,4,"k"),o.px(8,2,"k").px(7,3,"k").px(8,4,"k");break;case "surprised":case "scared":n(a=>o.rect(a,2,3,3,"w").px(a+1,3,"k"));break;default:n(a=>o.rect(a,2,3,3,"w").rect(a+1,3,2,2,"e").px(a+1,3,"k"));}switch(e==="angry"&&o.px(1,1,"k").px(2,1,"k").px(3,2,"k").px(8,1,"k").px(7,1,"k").px(6,2,"k"),e==="sad"&&o.px(3,1,"k").px(2,1,"k").px(6,1,"k").px(7,1,"k"),e){case "happy":case "talk":o.rect(4,5,2,2,"m");break;case "surprised":o.rect(4,5,2,2,"m");break;case "sad":o.px(3,6,"m").row(5,4,5,"m").px(6,6,"m");break;case "angry":case "tired":case "scared":case "hurt":o.row(6,4,5,"m");break;default:o.px(3,5,"m").row(6,4,5,"m").px(6,5,"m");}return o.tex()}function Xt(e,t){let r=ne[Me],o=new Kt,n=o.key(e.body.skin),a=r.defaultParts.map(p=>({...p,size:[...p.size],pos:[...p.pos],color:p.name==="torso"?o.key(_r.torso):p.name?.startsWith("leg")||p.name?.startsWith("foot")?o.key(_r.legs):n})),i=new Map;for(let p of a){let u=i.get(p.name)??[];u.push(p),i.set(p.name,u);}for(let p of i.values())p.sort((u,x)=>x.pos[1]+x.size[1]/2-(u.pos[1]+u.size[1]/2));let c={},s={k:o.key(Gn),w:o.key("#ffffff"),e:o.key(e.face.eyeColor),m:o.key(Un)},l={};for(let p of He){let u=Jn(p),x="face_"+p;c[x]={...u,rows:u.rows.map(y=>[...y].map(T=>s[T]??T).join(""))},l[p]=x;}for(let p of Ee){let u=e.wear[p];if(!u)continue;let x=Xn(t,u);if(!x||x.slot!==p||x.style!==re)continue;let y={};for(let[g,b]of Object.entries(x.palette))y[g]=b===Re?n:o.key(g===x.tint&&e.tint[p]?e.tint[p]:b);let T={};for(let[g,b]of Object.entries(x.textures)){let S=`${p}_${g}`;T[g]=S,c[S]={w:b.w,h:b.h,rows:b.rows.map(d=>[...d].map(v=>y[v]??v).join(""))};}let k=g=>{if(!g)return;let b={};for(let[S,d]of Object.entries(g)){let v=T[d]??y[d];v&&(b[S]=v);}return Object.keys(b).length?b:void 0};for(let g of x.paint){let b=i.get(g.region);if(!b)continue;let S=y[g.color],d=k(g.faces);b.forEach((v,A)=>{S&&(v.color=S);let R=d&&Zn(d,b,A,c);R?v.faces=R:delete v.faces;});}for(let g of x.parts){let b={bone:g.bone,size:[...g.size],pos:[...g.pos],color:y[g.color]??n},S=k(g.faces);S&&(b.faces=S),g.rot&&(b.rot=[...g.rot]),g.mirror&&(b.mirror=true),g.name&&(b.name=g.name),a.push(b);}}let h={version:1,name:"Avatar",description:"",rig:Me,scale:e.body.height,palette:o.map,textures:c,parts:a,bones:[],face:{bone:r.faceBone,rect:[...Ue],expressions:l},style:{walk:"bouncy",idle:"calm",energy:.6},voice:{pitch:1},tags:["avatar",re],finish:{...Wn}},m=ae(h);if(!m.ok)throw new Error("composeAvatar: "+m.error);return m.spec}function Zn(e,t,r,o){if(t.length===1)return {...e};let n=t[0].pos[1]+t[0].size[1]/2,a=Math.min(...t.map(l=>l.pos[1]-l.size[1]/2)),i=Math.max(1e-6,n-a),c=l=>l<=0?0:l>=t.length?1:(n-(t[l-1].pos[1]-t[l-1].size[1]/2))/i,s={};for(let[l,h]of Object.entries(e)){let m=o[h];if(!m){s[l]=h;continue}if(l==="top"){r===0&&(s[l]=h);continue}if(l==="bottom"){r===t.length-1&&(s[l]=h);continue}if(!Kn.includes(l))continue;let p=Math.min(m.h-1,Math.round(c(r)*m.h)),u=Math.max(p+1,Math.round(c(r+1)*m.h)),x=`${h}_${r}`;o[x]||(o[x]={w:m.w,h:u-p,rows:m.rows.slice(p,u)}),s[l]=x;}return Object.keys(s).length?s:void 0}var Se="#2b2140",Ye="#7a2e2e",Fr="#e8707a",Qn={neutral:{eye:"open",iris:1,white:1,lidOuter:0,lidInner:0,browUp:0,browInner:0,tear:false},happy:{eye:"happy",iris:1,white:1,lidOuter:0,lidInner:0,browUp:.04,browInner:0,tear:false},sad:{eye:"open",iris:1,white:1,lidOuter:.38,lidInner:.12,browUp:0,browInner:.09,tear:true},angry:{eye:"open",iris:.9,white:.95,lidOuter:.1,lidInner:.42,browUp:-0.02,browInner:-0.1,tear:false},surprised:{eye:"open",iris:.55,white:1.15,lidOuter:0,lidInner:0,browUp:.1,browInner:0,tear:false},scared:{eye:"open",iris:.42,white:1.08,lidOuter:0,lidInner:0,browUp:.08,browInner:.07,tear:false},tired:{eye:"open",iris:1,white:1,lidOuter:.5,lidInner:.5,browUp:-0.02,browInner:-0.02,tear:false},hurt:{eye:"hurt",iris:1,white:1,lidOuter:0,lidInner:0,browUp:0,browInner:-0.07,tear:false}};function Hr(e,t,r,o,n,a="neutral"){let i=n==="blink"||n==="talk"?a==="blink"||a==="talk"?"neutral":a:n,c=Qn[i];e.clearRect(0,0,t,r),e.lineCap="round",e.lineJoin="round";let s=r*.5,l=t*.105,h=r*.2,m=n==="blink"?"closed":c.eye;o.cheeks&&i!=="scared"&&(e.fillStyle=i==="happy"?"rgba(236,110,140,0.5)":"rgba(236,120,140,0.32)",$(e,t*.12,r*.8,t*.07,r*.075),e.fill(),$(e,t*.88,r*.8,t*.07,r*.075),e.fill());for(let p of [-1,1]){let u=t*(.5+p*.22);ea(e,u,s,l,h,p,o,m,c),ra(e,u,s-h-r*.07,t,r,p,o,c);}if(c.tear&&m==="open"){e.fillStyle="#85b7eb";let p=t*.5-t*.22-l*.6,u=s+h*1.05;e.beginPath(),e.moveTo(p,u-r*.07),e.quadraticCurveTo(p+t*.03,u,p,u+r*.04),e.quadraticCurveTo(p-t*.03,u,p,u-r*.07),e.fill();}oa(e,t*.5,r*.86,t,r,o,n==="talk"?"talk":i);}function $(e,t,r,o,n){e.beginPath(),e.ellipse(t,r,Math.max(.1,o),Math.max(.1,n),0,0,Math.PI*2);}function ea(e,t,r,o,n,a,i,c,s){let l=o*.26;if(e.strokeStyle=Se,e.lineWidth=l,c==="closed"){e.beginPath(),e.moveTo(t-o,r+n*.1),e.quadraticCurveTo(t,r+n*.55,t+o,r+n*.1),e.stroke(),i.eyes==="wide"&&Nr(e,t,r+n*.15,o,n*.3,a,l);return}if(c==="happy"){e.lineWidth=l*1.2,e.beginPath(),e.moveTo(t-o,r+n*.35),e.quadraticCurveTo(t,r-n*.75,t+o,r+n*.35),e.stroke();return}if(c==="hurt"){let A=t-a*o*.6,R=t+a*o*.8;e.lineWidth=l*1.2,e.beginPath(),e.moveTo(R,r-n*.55),e.lineTo(A,r),e.lineTo(R,r+n*.55),e.stroke();return}let h=o*s.white,m=n*s.white,p=i.eyes==="sleepy"?.32:0,u=Math.max(s.lidOuter,p),x=Math.max(s.lidInner,p),y=r-m,T=t+a*(h+l),k=t-a*(h+l),g=y+2*m*u,b=y+2*m*x,S=u>0||x>0;e.save(),S&&(e.beginPath(),e.moveTo(T,g),e.lineTo(k,b),e.lineTo(k,r+m*2),e.lineTo(T,r+m*2),e.closePath(),e.clip());let d=Math.min(h,m)*.8*s.iris,v=r+m*.12;switch(i.eyes){case "dot":{e.fillStyle=Se,$(e,t,r+m*.1,h*.55,m*.72),e.fill(),e.fillStyle="#ffffff",$(e,t-h*.18,r-m*.18,h*.17,h*.17),e.fill();break}case "cat":{e.fillStyle="#ffffff",Jt(e,t,r,h*1.08,m*.85,a),e.fill(),e.save(),Jt(e,t,r,h*1.08,m*.85,a),e.clip(),e.fillStyle=i.eyeColor,$(e,t,v,d*1.05,d*1.2),e.fill(),e.fillStyle=Se,$(e,t,v,d*.22*(s.iris<1?1.5:1),d*.95),e.fill(),e.fillStyle="#ffffff",$(e,t-d*.4,v-d*.45,d*.25,d*.25),e.fill(),e.restore(),e.strokeStyle=Se,e.lineWidth=l,Jt(e,t,r,h*1.08,m*.85,a),e.stroke();break}default:{let A=i.eyes==="sparkle"||i.eyes==="wide";e.fillStyle="#ffffff",$(e,t,r,h,m),e.fill(),e.save(),$(e,t,r,h,m),e.clip();let R=A?d*1.18:d;e.fillStyle=i.eyeColor,$(e,t,v,R*.95,R*(i.eyes==="sparkle"?1.15:1)),e.fill(),e.fillStyle="rgba(255,255,255,0.18)",$(e,t,v+R*.45,R*.7,R*.45),e.fill(),e.fillStyle=Se,$(e,t,v,R*.48,R*.52),e.fill(),e.fillStyle="#ffffff",$(e,t-R*.38,v-R*.42,R*.32,R*.32),e.fill(),$(e,t+R*.38,v+R*.38,R*.14,R*.14),e.fill(),i.eyes==="sparkle"&&(ta(e,t+R*.3,v-R*.55,R*.22),e.fill()),e.restore(),e.strokeStyle=Se,e.lineWidth=l,e.beginPath(),e.ellipse(t,r,h,m,0,Math.PI*1.08,Math.PI*1.92),e.stroke();break}}if(e.restore(),S){e.strokeStyle=Se,e.lineWidth=l;let A=F=>(F-T)/(k-T),R=F=>g+(b-g)*A(F),C=t-h*.95,I=t+h*.95;e.beginPath(),e.moveTo(C,R(C)),e.lineTo(I,R(I)),e.stroke();}i.eyes==="wide"&&Nr(e,t,r-m*.55,h,m*.45,a,l);}function Jt(e,t,r,o,n,a){let i=t+a*o,c=t-a*o;e.beginPath(),e.moveTo(c,r+n*.15),e.quadraticCurveTo(t,r-n*1.5,i,r-n*.35),e.quadraticCurveTo(t,r+n*1.4,c,r+n*.15),e.closePath();}function Nr(e,t,r,o,n,a,i){e.lineWidth=i*.8;let c=t+a*o;for(let s=0;s<2;s++){let l=r+s*n*.6;e.beginPath(),e.moveTo(c-a*o*.1,l),e.lineTo(c+a*o*.35,l-n*(.7-s*.2)),e.stroke();}}function ta(e,t,r,o){e.beginPath();for(let n=0;n<8;n++){let a=n%2?o*.35:o,i=n*Math.PI/4-Math.PI/2,c=t+Math.cos(i)*a,s=r+Math.sin(i)*a;n?e.lineTo(c,s):e.moveTo(c,s);}e.closePath(),e.fillStyle="#ffffff";}function ra(e,t,r,o,n,a,i,c){if(i.brows==="none")return;let s=o*.095,l=r-n*c.browUp,h=t-a*s,m=t+a*s,p=l-n*c.browInner,u=l+n*c.browInner*.3;if(e.strokeStyle=i.browColor,e.fillStyle=i.browColor,i.brows==="thick"){let y=n*.06;e.beginPath(),e.moveTo(m,u),e.quadraticCurveTo(t,Math.min(u,p)-y*.6,h,p),e.lineTo(h,p+y),e.quadraticCurveTo(t,Math.min(u,p)+y*.5,m,u+y*.6),e.closePath(),e.fill();return}e.lineWidth=o*(i.brows==="arched"?.026:.032),e.beginPath(),e.moveTo(m,u);let x=i.brows==="arched"?n*.09:n*.035;e.quadraticCurveTo(t+a*s*.2,Math.min(u,p)-x,h,p),e.stroke();}function oa(e,t,r,o,n,a,i){let c=o*.026;e.strokeStyle=Ye,e.lineWidth=c;let s=o*(a.mouth==="small"?.06:a.mouth==="grin"?.12:.09);switch(i){case "happy":{let l=Math.max(s,o*.1);e.fillStyle=Ye,e.beginPath(),e.moveTo(t-l,r-n*.06),e.quadraticCurveTo(t,r-n*.02,t+l,r-n*.06),e.quadraticCurveTo(t,r+n*.2,t-l,r-n*.06),e.closePath(),e.fill(),e.save(),e.clip(),e.fillStyle=Fr,$(e,t,r+n*.1,l*.55,n*.06),e.fill(),a.mouth==="grin"&&(e.fillStyle="#ffffff",e.fillRect(t-l,r-n*.08,l*2,n*.045)),e.restore();return}case "surprised":e.fillStyle=Ye,$(e,t,r,o*.045,n*.085),e.fill();return;case "talk":e.fillStyle=Ye,$(e,t,r,Math.max(s*.7,o*.06),n*.07),e.fill(),e.save(),e.clip(),e.fillStyle=Fr,$(e,t,r+n*.06,o*.045,n*.035),e.fill(),e.restore();return;case "sad":e.beginPath(),e.moveTo(t-s,r+n*.04),e.quadraticCurveTo(t,r-n*.07,t+s,r+n*.04),e.stroke();return;case "angry":e.beginPath(),e.moveTo(t-s,r+n*.01),e.quadraticCurveTo(t,r-n*.03,t+s,r+n*.01),e.stroke();return;case "scared":{e.beginPath();let l=4;for(let h=0;h<=l;h++){let m=t-s+2*s*h/l,p=r+(h%2?-1:1)*n*.022;h?e.lineTo(m,p):e.moveTo(m,p);}e.stroke();return}case "tired":e.beginPath(),e.moveTo(t-s*.6,r),e.lineTo(t+s*.6,r),e.stroke();return;case "hurt":{e.beginPath();let l=4;for(let h=0;h<=l;h++){let m=t-s+2*s*h/l,p=r+(h%2?-1:1)*n*.04;h?e.lineTo(m,p):e.moveTo(m,p);}e.stroke();return}}if(a.mouth==="cat"){e.beginPath(),e.moveTo(t-s,r-n*.03),e.quadraticCurveTo(t-s*.5,r+n*.06,t,r-n*.01),e.quadraticCurveTo(t+s*.5,r+n*.06,t+s,r-n*.03),e.stroke();return}if(a.mouth==="grin"){e.fillStyle=Ye,e.beginPath(),e.moveTo(t-s,r-n*.04),e.quadraticCurveTo(t,r-n*.01,t+s,r-n*.04),e.quadraticCurveTo(t,r+n*.12,t-s,r-n*.04),e.closePath(),e.fill(),e.save(),e.clip(),e.fillStyle="#ffffff",e.fillRect(t-s,r-n*.06,s*2,n*.04),e.restore();return}e.beginPath(),e.moveTo(t-s,r-n*.03),e.quadraticCurveTo(t,r+n*.06,t+s,r-n*.03),e.stroke();}var Dr=16;function na(e,t){if(typeof document<"u"){let r=document.createElement("canvas");return r.width=e,r.height=t,r}return new OffscreenCanvas(e,t)}var gt=class{texture;g;w;h;face;current="neutral";base="neutral";constructor(t){this.face=t,this.w=Math.round(Ue[2]*Dr),this.h=Math.round(Ue[3]*Dr);let r=na(this.w,this.h),o=r.getContext("2d");if(!o)throw new Error("DrawnFace: no 2D canvas");this.g=o,this.texture=new _.CanvasTexture(r),this.texture.colorSpace=_.SRGBColorSpace,this.texture.anisotropy=4,this.paint("neutral");}paint(t){t!=="blink"&&t!=="talk"&&(this.base=t),this.current=t,Hr(this.g,this.w,this.h,this.face,t,this.base),this.texture.needsUpdate=true;}setFace(t){this.face=t,this.paint(this.current);}dispose(){this.texture.dispose();}};var aa={paths:[{x:243,y:-2,d:"M147.333 12.333c-13.6 2.534-12.533 1.2-12.933 15.067l-.4 12.267-4.533-11.067c-2.534-6-5.067-10.933-5.734-10.933-2.666 0-27.866 8.666-36.533 12.666-11.733 5.334-26.667 14.8-36.133 22.934l-6.934 5.866L51.6 69.267c8.133 11.066 7.333 11.466-5.067 2.933-7.6-5.067-8.4-5.333-11.466-3.733-3.467 1.866-18.4 17.333-20.4 21.2-.8 1.6 7.066 8.8 33.733 30.933l34.667 28.933 8.8-8.266c14.666-13.867 28.666-22 48.133-28.267 9.067-2.933 14.8-3.733 28.533-4.4 34.267-1.333 60 7.467 81.6 28.133 21.6 20.4 34.934 49.6 37.467 81.734l.8 11.2 14.8 4.533c8.133 2.533 23.733 7.333 34.667 10.8 10.933 3.333 20.4 5.6 21.066 4.933 1.6-1.6 6.134-20.533 7.734-32.666.8-6 1.333-17.6 1.066-25.6l-.4-14.667-8-1.067c-4.4-.533-10.133-1.466-12.666-1.866l-4.667-.8 4.667-1.2c16.933-4.534 18.666-5.2 18.666-8 0-5.467-9.6-31.334-16.666-44.8-4-7.6-10.667-18.667-14.934-24.667-9.866-13.867-31.333-35.467-45.2-45.2-10.4-7.467-34.4-20.933-37.2-21.067-.8 0-4 4-7.333 8.8-3.2 4.8-6.133 8.134-6.4 7.334s.4-5.6 1.6-10.667c1.2-5.2 2.133-9.6 2.133-9.867 0-.933-19.866-6.133-34.4-9.066-14.8-2.934-49.333-4.4-59.6-2.534"},{x:243,y:-2,d:"M157.867 125.533c-21.067 3.334-42.134 14.8-57.467 31.334-13.333 14.133-13.733 12.8 5.6 22 9.2 4.4 16.667 8.266 16.667 8.533s-1.334.4-2.934.133c-13.866-2.133-41.6-5.866-41.733-5.6-.267.267-7.467 28.534-16.267 63.067l-16 62.667 7.334.4c4 .266 7.466.266 7.6 0 .266-.267 3.866-13.867 8.133-30.4 4.267-16.534 8.267-30.8 8.933-31.734.934-1.2 11.067-1.6 42.4-1.6 32.134 0 41.2.4 41.2 1.6 0 .934-1.733 4.667-3.866 8.4L153.733 261l-35.066 6.933c-19.334 3.867-35.2 7.2-35.467 7.467-.667.667-29.867 113.467-29.467 113.867.267.133 23.734-3.6 52.4-8.534l52-8.8 20.4-39.866c11.2-22 20.667-39.734 20.934-39.467.4.533-1.334 26.8-2.8 40.8l-.667 6.933 6.267-3.2c21.2-10.666 52.4-13.466 86.933-8l5.867.934-5.6-7.334C286.4 318.6 281.2 310.6 278 304.867c-5.867-10.134-6-10.8-6-21.867 0-6.267 1.467-20 3.333-30.667 1.867-10.666 3.334-19.466 3.334-19.466 0-.134-9.067-4.267-20.134-9.334s-19.466-9.333-18.8-9.6c.8-.266 7.734.8 15.6 2.267 7.734 1.6 14.4 2.8 14.8 2.8 1.2 0 .4-10.533-1.466-18-7.2-27.733-28-53.467-53.734-66-16.4-8-40.8-12-57.066-9.467"},{x:243,y:-2,d:"M235.6 346.333c-24 4.534-44.133 13.867-68.267 31.467-14 10.267-28.533 18.133-47.733 25.867-23.467 9.466-52.8 32.666-64.4 50.666l-2.533 4L58 454.2c9.333-7.333 30.133-19.467 49.333-28.667C173.733 393.667 246.4 382.2 312.8 393c11.2 1.733 39.2 8.533 45.067 10.8 2.266.8 2.266.667.8-2.267-4-7.6-15.6-21.866-25.867-31.466-12-11.467-24.667-18.934-37.6-22.4-11.467-3.067-46.267-3.867-59.6-1.334"},{x:-460,y:467,d:"M721.533 34.467c-14.933 5.466-22 17.466-22.933 38.666-.933 24.134 3.467 32.8 30.267 59.867 19.6 19.867 22.933 25.2 22.933 37.867.133 13.466-6.133 20.133-16.933 18.4-9.067-1.467-12.534-7.867-12.534-22.667V159H696.6l.667 13.333c.533 11.467 1.2 14.4 4.933 22 7.067 14.267 16.8 19.6 36.4 19.734 10.667.133 12.267-.134 20.667-4.4 7.6-3.867 9.733-5.867 13.2-11.734 7.6-12.533 9.066-32 3.733-47.6-3.733-11.066-10.667-20.4-27.867-37.2-19.866-19.6-22.533-24.133-22.666-38.4 0-8.933.4-10.533 3.2-13.6 6.266-6.666 18.266-5.6 22.133 2 1.067 2 2 7.067 2 11.2v7.334h27.067l-.934-9.2c-1.6-18.267-8.266-30.267-20-36.4-7.2-3.867-29.2-4.8-37.6-1.6M630.067 34.867c-11.734 4.666-18 11.6-21.734 24.4-1.866 6.4-2 15.333-1.733 67.2l.4 59.866 3.733 7.6c6.8 13.867 18.534 20.267 36.934 20.267 13.733 0 22.933-3.333 30.666-11.067 10.934-11.066 11.2-12.533 11.734-74.666.266-35.734-.134-56.934-1.067-62.8-2.667-16.134-11.6-27.467-24.8-31.467-8.933-2.667-26.4-2.267-34.133.667m28.666 26.8 3.6 4v56.666c0 40.934-.4 57.467-1.6 60-3.6 8-15.6 9.734-22.666 3.467l-4.4-3.867-.4-56.533c-.267-51.733-.134-56.8 2-61.067 3.066-5.866 7.6-8.266 14.4-7.466 3.733.4 6.4 1.866 9.066 4.8M511.667 123.133v89.334l29.066-.4c28.8-.4 28.934-.4 36.667-4.267 9.467-4.533 14.4-10.933 17.467-22.4 2-7.333 2.266-15.467 1.866-65.733l-.4-57.334-4.266-8.8c-8.267-16.666-17.2-19.866-55.334-19.866h-25.066zm53.6-60.266 4.4 3.866.4 52.8c.266 35.067-.134 54.4-1.067 58-2 7.467-5.733 9.6-18.667 10.4l-10.666.8V59h10.666c9.867 0 10.934.267 14.934 3.867M471.667 145v67.333h26.666V77.667h-26.666zM471.667 48.333V63h26.666V33.667h-26.666z"},{x:-106,y:244,d:"M893.4 259.733c-6.8 3.467-9.2 5.6-12.667 11.467-10.666 17.733-9.2 42.933 3.467 62.267 2.8 4.266 12.267 14.8 20.933 23.333 9.867 9.467 17.067 17.733 18.934 21.6 5.6 11.333 5.2 25.333-.934 30.8-3.466 3.067-11.333 4.133-16.133 2.133-5.867-2.4-8-7.466-8-19.333v-10h-27.067l.8 11.6c1.2 15.867 3.867 24.133 10.267 31.333 7.467 8.534 16.4 12.134 30 12.267 19.067.133 30.133-5.733 37.333-19.867 3.734-7.466 4-8.666 4-24 0-16 0-16.133-5.2-26.666-4.4-9.2-7.733-13.2-23.066-28.534-21.067-21.066-24.8-27.066-24.934-40.4-.133-10.4 2.8-15.6 9.734-17.6 10.133-2.933 17.2 3.334 18.4 16.267l.8 8.267H955.4l-.8-10.8c-.533-8.4-1.6-12.667-4.8-19.2-7.067-14.134-16.667-19.334-36.133-19.334-10.667 0-12.534.4-20.267 4.4M791 346v89.333h76v-24h-48v-54.666h37.333v-24H819V282h48v-25.333h-76zM661.667 346v89.333h22.666l.134-63.066c0-34.534.533-61.734 1.066-60.267.534 1.467 5.467 29.867 10.8 62.933l9.867 60.4h13.067c7.2 0 13.066-.4 13.066-1.066 0-3.067 18.8-124.8 19.334-125.334.4-.4.666 27.867.666 62.8v63.6h25.334V256.667h-38l-9.2 61.6c-5.067 34-9.6 62.133-10 62.666-.534.534-5.334-26.4-10.667-60-5.467-33.466-10.133-61.733-10.533-62.666-.4-1.2-5.467-1.6-19.067-1.6h-18.533zM586.467 258.267c-.8 2.666-27.467 172.4-27.467 174.933 0 1.867 1.733 2.133 12 2.133h11.867l.8-4.4c.533-2.266 1.6-9.333 2.4-15.6l1.6-11.333 17.6-.4 17.466-.4 1.467 8.4c.8 4.667 1.733 11.867 2.267 16l.933 7.733h13.733c7.6 0 13.867-.266 13.867-.666 0-.8-26.533-168.134-27.467-173.734l-.8-4.266h-19.866c-14.8 0-20.134.4-20.4 1.6M613 336.533c3.333 23.067 5.867 42.134 5.6 42.4-.4.267-6.533.267-13.867.134l-13.2-.4 4.934-33.334c2.8-18.4 5.733-38.4 6.666-44.666C604.2 292.533 605 290.133 605.8 292c.533 1.467 3.867 21.467 7.2 44.533M497.267 257.2c-10.134 3.733-15.2 8.267-19.867 17.733L473 284l-.4 59.067c-.4 51.2-.133 60.133 1.733 66.533 5.6 19.333 17.067 27.333 39.467 27.467 10.267.133 12.267-.267 20.133-4.134 9.334-4.533 13.867-9.733 17.867-20.266 2-4.934 2.4-12 2.933-41.067l.534-34.933h-38.934v23.866l6.4.4 6.267.4v19.334c0 13.466-.533 20.666-1.867 23.733-5.066 12-23.333 10.4-26.8-2.4-.933-3.6-1.333-23.2-1.066-59.067.4-48.533.666-54.133 2.666-57.333 3.334-4.8 11.2-7.067 17.6-4.933 6.934 2.266 9.067 7.2 9.867 22.933l.667 13.067H555.4l-.8-15.734c-.8-18-3.067-25.6-9.867-33.466-7.466-8.8-13.466-11.2-29.066-11.734-9.067-.266-14.934.134-18.4 1.467"}]},sa={helmet:{paths:[0,1,2],box:[258,10,353,447]},wordmark:{paths:[3,4],box:[12,499,837,182]}},ia={"top.idos":{color:"#f8f8fc",faces:["front","back"],layers:[{art:"helmet",y:19.4,z:2.3,height:3.9},{art:"wordmark",y:14.85,z:2.15,width:6.2}]}},Br=512,jr=.02,Vr=new Map;function la(e,t){if(typeof document<"u"){let r=document.createElement("canvas");return r.width=e,r.height=t,r}return new OffscreenCanvas(e,t)}function ca(e,t,r){let o=`${e}:${r}`,n=Vr.get(o);if(n)return n;if(typeof Path2D>"u")return null;let[a,i,c,s]=t.box,l=s*jr,h=Br/(s+2*l),m=la(Math.round((c+2*l)*h),Br),p=m.getContext("2d");if(!p)return null;p.clearRect(0,0,m.width,m.height),p.fillStyle=r;for(let x of t.paths){let y=aa.paths[x];p.setTransform(h,0,0,h,(y.x-a+l)*h,(y.y-i+l)*h),p.fill(new Path2D(y.d));}let u=new _.CanvasTexture(m);return u.colorSpace=_.SRGBColorSpace,u.anisotropy=4,Vr.set(o,u),u}function Zt(e){let t=[];for(let r of Ee){let o=e.wear[r],n=o?ia[o]:void 0;if(n)for(let a of n.layers){let i=sa[a.art],c=ca(a.art,i,n.color);if(!c)continue;let[,,s,l]=i.box,h=s/l,m=a.height??(a.width??1)/h,p=a.width??m*h,u=2*jr*m;for(let x of n.faces){let y=(x==="front"?-1:1)*(a.z+.03),T=[0,a.y,y];t.push({bone:"body",center:T,w:p+u,h:m+u,facing:x,texture:c});}}}return t}var vt=class extends ut{face;constructor(t,r,o={}){let n=new gt(t.face);super(Xt(t,r),{...o,facePainter:n}),this.face=n,this.view.setPrints(Zt(t));}setAvatar(t,r){this.face.setFace(t.face),this.setSpec(Xt(t,r)),this.view.setPrints(Zt(t));}dispose(){super.dispose(),this.face.dispose();}};var ji=["#a99cff","#5b4bd6"];function pa(e){e.add(new _.HemisphereLight(16777215,9076856,1.7));let t=new _.DirectionalLight(16777215,1.3);t.position.set(2,4,-3),e.add(t);}function ha(e,t){switch(t){case "full":return {center:new _.Vector3(0,e*.5,0),size:e*1.12,lift:.04};case "torso":return {center:new _.Vector3(0,e*.57,0),size:e*.5,lift:.06};case "legs":return {center:new _.Vector3(0,e*.2,0),size:e*.5,lift:.1};case "face":return {center:new _.Vector3(0,e*.86,0),size:e*.34,lift:.04};case "head":return {center:new _.Vector3(0,e*.88,0),size:e*.5,lift:.08};default:return {center:new _.Vector3(0,e*.8,0),size:e*.56,lift:.08}}}function ma(e){return typeof e=="number"?e:e==="side"?Math.PI/2:e==="back"?Math.PI:.18}function Gr(e,t,r,o,n,a){let i=a.frame??"portrait",c=new vt(o,n,{seed:7});try{e.setClearColor(0,0);let s=new _.Scene;pa(s),c.group.rotation.y=ma(a.view),s.add(c.group);for(let g=0;g<20;g++)c.update(1/30);c.view.setExpression(a.expression??"happy");let{center:l,size:h,lift:m}=ha(c.height,i),p=28,u=new _.PerspectiveCamera(p,1,.05,50),x=h/2/Math.tan(_.MathUtils.degToRad(p/2));u.position.set(l.x,l.y+h*m,l.z-x),u.lookAt(l),e.render(s,u);let y=document.createElement("canvas");y.width=r,y.height=r;let T=y.getContext("2d");if(!T)return t;let k=a.background;if(typeof k=="string")T.fillStyle=k,T.fillRect(0,0,r,r);else if(k){let g=T.createRadialGradient(r*.5,r*.38,r*.05,r*.5,r*.5,r*.72);g.addColorStop(0,k[0]),g.addColorStop(1,k[1]),T.fillStyle=g,T.fillRect(0,0,r,r);}return T.imageSmoothingEnabled=!a.pixelated,T.drawImage(t,0,0),y}finally{c.dispose();}}function Ur(e,t){let r=document.createElement("canvas");r.width=e,r.height=e;let o=new _.WebGLRenderer({canvas:r,antialias:!t,alpha:true,preserveDrawingBuffer:true});return o.setPixelRatio(1),o.setSize(e,e,false),{renderer:o,gl:r}}function da(e,t,r={}){let o=Math.max(16,Math.round(r.size??256)),{renderer:n,gl:a}=Ur(o,!!r.pixelated);try{return Gr(n,a,o,e,t,r)}finally{n.dispose(),n.forceContextLoss();}}function Yr(e={}){let t=Math.max(16,Math.round(e.size??256)),r=Ur(t,!!e.pixelated);return {render(o,n,a={}){if(!r)throw new Error("snapshotter disposed");return Gr(r.renderer,r.gl,t,o,n,{...a,pixelated:e.pixelated})},dispose(){r&&(r.renderer.dispose(),r.renderer.forceContextLoss(),r=null);}}}function Gi(e,t,r={}){let o=da(e,t,r);return new Promise(n=>o.toBlob(a=>n(a),"image/png"))}function Ui(e){if(!e?.spec)return null;let t={};for(let r of e.items??[])r&&typeof r.id=="string"&&(t[r.id]=r);return {spec:bt(e.spec),items:t}}function te(e){let t=yt(e);if(!t.ok)throw new Error(`avatar shop: ${String(e.id)}: ${t.errors.join("; ")}`);return t.item}var Qt=e=>({w:e[0].length,h:e.length,rows:e}),fa={bone:"head",size:[9.21,2.05,8.73],pos:[0,29.91,0],color:"a"},ua={bone:"head",size:[9.21,1.7,.73],pos:[0,28.72,-4.36],color:"a"},qr=[{price:250,item:te({id:"hat.crown",slot:"hat",name:"Crown",palette:{a:"#e8b730",g:"#d23c4a"},tint:"a",parts:[{bone:"head",size:[9.21,1.7,.73],pos:[0,30.93,-4.36],color:"a"},{bone:"head",size:[9.21,1.7,.73],pos:[0,30.93,4.36],color:"a"},{bone:"head",size:[.71,1.7,8.73],pos:[4.6,30.93,0],color:"a",mirror:true},{bone:"head",size:[1.13,1.36,.73],pos:[2.98,32.47,-4.36],color:"a",mirror:true},{bone:"head",size:[1.13,1.77,.73],pos:[0,32.67,-4.36],color:"a"},{bone:"head",size:[.99,.95,.29],pos:[0,30.93,-4.87],color:"g"}]})},{price:250,item:te({id:"back.wings",slot:"back",name:"Angel wings",palette:{a:"#f7f5ff",b:"#d9d4f2"},tint:"a",parts:[{bone:"body",size:[2.25,7.5,1.47],pos:[1.69,21.15,3.04],color:"b",mirror:true},{bone:"body",size:[10.13,3.13,.74],pos:[7.31,26.15,3.86],color:"a",mirror:true},{bone:"body",size:[10.13,3.13,.74],pos:[7.88,23.03,4.05],color:"b",mirror:true},{bone:"body",size:[9,3.13,.74],pos:[8.44,19.9,4.23],color:"a",mirror:true},{bone:"body",size:[6.75,3.13,.74],pos:[9,16.77,4.42],color:"b",mirror:true},{bone:"body",size:[4.5,3.13,.74],pos:[9.56,13.65,4.6],color:"a",mirror:true},{bone:"body",size:[3.38,1.88,.74],pos:[11.25,28.65,3.86],color:"a",mirror:true}]})},{price:200,item:te({id:"hat.wizard",slot:"hat",name:"Wizard hat",palette:{a:"#3c2f8f",s:"#f2c14e"},tint:"a",parts:[{bone:"head",size:[10.63,.55,10.18],pos:[0,30.39,0],color:"a"},{bone:"head",size:[8.5,1.77,8],pos:[0,31.55,0],color:"a"},{bone:"head",size:[6.38,1.77,5.82],pos:[0,33.32,.36],color:"a"},{bone:"head",size:[4.25,1.77,4],pos:[0,35.09,.73],color:"a"},{bone:"head",size:[2.13,1.64,2.18],pos:[0,36.8,1.09],color:"a"},{bone:"head",size:[1.13,1.09,.29],pos:[0,31.61,-4.15],color:"s"}]})},{price:200,item:te({id:"top.armor",slot:"top",name:"Knight armor",palette:{a:"#b8c2cc",b:"#5b6672",g:"#e8b730"},tint:"a",paint:[{region:"torso",color:"b"},{region:"arms",color:"b"}],parts:[{bone:"body",size:[9.67,7.5,.74],pos:[0,18.65,-2.67],color:"a"},{bone:"armR",size:[4.32,2.94,4.32],pos:[6.3,22.38,0],color:"a",mirror:true},{bone:"body",size:[2.25,2.5,.37],pos:[0,19.27,-3.22],color:"g"}]})},{price:200,item:te({id:"back.sword",slot:"back",name:"Sword",palette:{a:"#d8dde4",g:"#e8b730",h:"#5a3a22"},tint:"g",parts:[{bone:"body",size:[1.35,12.5,.55],pos:[2.81,17.4,3.04],color:"a"},{bone:"body",size:[4.5,1.13,.92],pos:[2.81,24.21,3.04],color:"g"},{bone:"body",size:[1.01,3.75,.83],pos:[2.81,26.65,3.04],color:"h"},{bone:"body",size:[1.58,1.5,1.1],pos:[2.81,29.28,3.04],color:"g"}]})},{price:150,item:te({id:"hat.headphones",slot:"hat",name:"Headphones",palette:{a:"#2b2140",b:"#4be0c8"},tint:"b",parts:[{bone:"head",size:[9.63,.82,1.45],pos:[0,31.07,0],color:"a"},{bone:"head",size:[.57,3.41,.87],pos:[4.89,29.57,0],color:"a",mirror:true},{bone:"head",size:[1.13,2.45,2.62],pos:[4.96,27.39,0],color:"a",mirror:true},{bone:"head",size:[.28,1.64,1.75],pos:[5.6,27.39,0],color:"b",mirror:true}]})},{price:150,item:te({id:"hair.mohawk",slot:"hair",name:"Mohawk",palette:{a:"#d4537e"},tint:"a",parts:[{bone:"head",size:[1.84,3.07,8],pos:[0,31.78,0],color:"a"},{bone:"head",size:[1.84,2.05,1.45],pos:[0,31.27,-4.73],color:"a"},{bone:"head",size:[2.13,4.09,.73],pos:[0,28.2,4.36],color:"a"}]})},{price:150,item:te({id:"top.suit",slot:"top",name:"Suit and tie",palette:{a:"#2c2f3a",w:"#f4f1ea",r:"#c0392b"},tint:"a",textures:{front:Qt(["awwrrwwa","aawrrwaa","aaarraaa","aaarraaa","aaarraaa","aaaaaaaa","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"front"}},{region:"arms",color:"a"}],parts:[{bone:"body",size:[1.35,1,.28],pos:[-2.92,19.9,-2.44],color:"w"}]})},{price:120,item:te({id:"hair.ponytail",slot:"hair",name:"Ponytail",palette:{a:"#3b2a20",b:"#d4537e"},tint:"a",parts:[fa,ua,{bone:"head",size:[.71,3.41,7.27],pos:[4.6,27.86,.36],color:"a",mirror:true},{bone:"head",size:[9.21,4.77,.73],pos:[0,27.18,4.36],color:"a"},{bone:"head",size:[2.27,1.02,1.75],pos:[0,28.55,4.95],color:"b"},{bone:"head",size:[1.84,5.45,1.45],pos:[0,25.82,5.09],color:"a"}]})},{price:120,item:te({id:"face.visor",slot:"faceAcc",name:"Cyber visor",palette:{a:"#33e0ff",b:"#1d1d21"},tint:"a",parts:[{bone:"head",size:[7.79,1.77,.36],pos:[0,25.89,-4.29],color:"a"},{bone:"head",size:[.35,1.02,1.89],pos:[4.07,26.16,-3.27],color:"b",mirror:true}]})},{price:100,item:te({id:"shoes.hightops",slot:"shoes",name:"High-tops",palette:{a:"#7f77dd",w:"#f4f1ea",b:"#2b2140"},tint:"a",textures:{toe:Qt(["aaaa","wwww"]),side:Qt(["aaaaa","wwwww"])},paint:[{region:"feet",color:"a",faces:{front:"toe",back:"toe",left:"side",right:"side",bottom:"w"}}],parts:[{bone:"shinR",size:[4.62,4.32,4.62],pos:[2.1,3.76,0],color:"b",mirror:true}]})},{price:50,item:te({id:"hands.gauntlets",slot:"hands",name:"Golden gauntlets",palette:{a:"#e8b730",b:"#b8862a"},tint:"a",paint:[{region:"hands",color:"a"}],parts:[{bone:"foreArmR",size:[4.32,1.75,4.32],pos:[6.3,13.78,0],color:"b",mirror:true}]})},{price:50,item:te({id:"waist.pouch",slot:"waist",name:"Belt pouch",palette:{a:"#3a2a22",b:"#7a5233"},tint:"b",parts:[{bone:"body",size:[9.45,1.25,4.97],pos:[0,13.15,0],color:"a"},{bone:"body",size:[2.7,2.5,1.29],pos:[2.93,11.9,-3.04],color:"b"}]})}],$r=qr.map(e=>e.item),er=Object.fromEntries(qr.map(e=>[e.item.id,e.price])),Wr=e=>Object.prototype.hasOwnProperty.call(er,e);function N(e){let t=yt(e);if(!t.ok)throw new Error(`avatar catalog: ${String(e.id)}: ${t.errors.join("; ")}`);return t.item}var Te=e=>({w:e[0].length,h:e.length,rows:e}),qe={bone:"head",size:[9.21,2.05,8.73],pos:[0,29.91,0],color:"a"},$e={bone:"head",size:[9.21,1.7,.73],pos:[0,28.72,-4.36],color:"a"},ba=[N({id:"hair.short",slot:"hair",name:"Short",palette:{a:"#3b2a20"},tint:"a",parts:[qe,$e,{bone:"head",size:[.71,3.41,7.27],pos:[4.6,27.86,.36],color:"a",mirror:true},{bone:"head",size:[9.21,4.77,.73],pos:[0,27.18,4.36],color:"a"}]}),N({id:"hair.bob",slot:"hair",name:"Bob",palette:{a:"#3b2a20"},tint:"a",parts:[qe,$e,{bone:"head",size:[1.06,5.45,8],pos:[4.78,26.5,0],color:"a",mirror:true},{bone:"head",size:[9.21,6.14,1.09],pos:[0,26.5,4.55],color:"a"}]}),N({id:"hair.spiky",slot:"hair",name:"Spiky",palette:{a:"#3b2a20"},tint:"a",parts:[qe,$e,{bone:"head",size:[.71,2.73,5.82],pos:[4.6,28.2,.73],color:"a",mirror:true},{bone:"head",size:[2.13,2.05,2.18],pos:[-2.83,31.61,-1.45],color:"a"},{bone:"head",size:[2.13,2.73,2.18],pos:[0,31.95,-0.73],color:"a"},{bone:"head",size:[2.13,2.05,2.18],pos:[2.83,31.61,0],color:"a"},{bone:"head",size:[2.13,2.05,2.18],pos:[-1.42,31.61,2.18],color:"a"},{bone:"head",size:[2.13,2.05,2.18],pos:[1.77,31.75,1.82],color:"a"}]}),N({id:"hair.long",slot:"hair",name:"Long",palette:{a:"#3b2a20"},tint:"a",parts:[qe,$e,{bone:"head",size:[1.06,6.82,7.27],pos:[4.78,26.16,.36],color:"a",mirror:true},{bone:"head",size:[9.21,7.5,1.09],pos:[0,26.16,4.55],color:"a"}]}),N({id:"hair.bun",slot:"hair",name:"Bun",palette:{a:"#3b2a20"},tint:"a",parts:[qe,$e,{bone:"head",size:[.71,2.73,5.82],pos:[4.6,28.2,.73],color:"a",mirror:true},{bone:"head",size:[9.21,4.09,.73],pos:[0,27.52,4.36],color:"a"},{bone:"head",size:[4.25,3.41,3.64],pos:[0,32.64,1.82],color:"a"}]}),N({id:"hair.curly",slot:"hair",name:"Curly",palette:{a:"#3b2a20"},tint:"a",parts:[{bone:"head",size:[9.92,2.39,9.45],pos:[0,30.08,0],color:"a"},{bone:"head",size:[9.21,1.36,.73],pos:[0,28.89,-4.8],color:"a"},{bone:"head",size:[2.83,2.73,2.91],pos:[3.54,28.89,-2.55],color:"a",mirror:true},{bone:"head",size:[2.83,2.73,2.91],pos:[3.54,28.89,1.82],color:"a",mirror:true},{bone:"head",size:[5.67,2.05,5.82],pos:[0,31.61,0],color:"a"},{bone:"head",size:[4.25,3.41,2.18],pos:[2.13,26.84,4],color:"a",mirror:true}]})],ya=[N({id:"top.idos",slot:"top",name:"iDos Games tee",palette:{a:"#1565ff"},tint:null,paint:[{region:"torso",color:"a"},{region:"sleeves",color:"a"}]}),N({id:"top.tee",slot:"top",name:"Star tee",palette:{a:"#1d9e75",b:"#f4f1ea"},tint:"a",textures:{print:Te(["aaaaaaaa","aaabbaaa","aabbbbaa","abbbbbba","aabbbbaa","aabaabaa","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"print"}},{region:"sleeves",color:"a"}]}),N({id:"top.hoodie",slot:"top",name:"Hoodie",palette:{a:"#378add",b:"#24578f",w:"#f0f0f0"},tint:"a",paint:[{region:"torso",color:"a"},{region:"arms",color:"a"}],parts:[{bone:"body",size:[7.88,4.38,1.84],pos:[0,21.78,3.04],color:"a"},{bone:"body",size:[5.63,2.5,.46],pos:[0,15.52,-2.53],color:"b"},{bone:"body",size:[.56,2.75,.37],pos:[1.24,19.65,-2.48],color:"w",mirror:true}]}),N({id:"top.stripes",slot:"top",name:"Striped sweater",palette:{a:"#d4537e",b:"#f4f1ea"},tint:"a",textures:{st:Te(["aaaaaaaa","aaaaaaaa","bbbbbbbb","aaaaaaaa","aaaaaaaa","bbbbbbbb","aaaaaaaa","aaaaaaaa"]),sl:Te(["aaa","bbb","aaa","bbb","aaa"])},paint:[{region:"torso",color:"a",faces:{front:"st",back:"st",left:"st",right:"st"}},{region:"arms",color:"a",faces:{front:"sl",back:"sl",left:"sl",right:"sl"}}]}),N({id:"top.jacket",slot:"top",name:"Jacket",palette:{a:"#444441",b:"#f4f1ea",c:"#c8c2b4"},tint:"a",textures:{open:Te(["aaabbaaa","aaabbaaa","aaabbaaa","aaabbaaa","aaabbaaa","aacbbcaa","aaabbaaa","aaabbaaa"])},paint:[{region:"torso",color:"a",faces:{front:"open"}},{region:"arms",color:"a"}],parts:[{bone:"body",size:[3.38,1.5,.92],pos:[2.48,22.53,-2.21],color:"a",mirror:true}]}),N({id:"top.tank",slot:"top",name:"Tank top",palette:{a:"#ef9f27"},tint:"a",paint:[{region:"torso",color:"a"}]})],ga=[N({id:"bottom.jeans",slot:"bottom",name:"Jeans",palette:{a:"#2f5fd0",b:"#24489e"},tint:"a",textures:{seam:Te(["aaab","aaab","aaab","aaab","aaab"])},paint:[{region:"legs",color:"a",faces:{front:"seam"}}]}),N({id:"bottom.shorts",slot:"bottom",name:"Shorts",palette:{a:"#5f6b7a",s:"@skin"},tint:"a",paint:[{region:"legs",color:"s"}],parts:[{bone:"legR",size:[4.62,5.4,4.62],pos:[2.1,9.7,0],color:"a",mirror:true}]}),N({id:"bottom.skirt",slot:"bottom",name:"Skirt",palette:{a:"#7f77dd",s:"@skin"},tint:"a",paint:[{region:"legs",color:"s"}],parts:[{bone:"body",size:[10.13,4.38,5.52],pos:[0,11.46,0],color:"a"}]}),N({id:"bottom.cargo",slot:"bottom",name:"Cargo pants",palette:{a:"#6b6b4a",b:"#55553a"},tint:"a",paint:[{region:"legs",color:"a"}],parts:[{bone:"legR",size:[.84,4.32,2.52],pos:[4.62,7,0],color:"b",mirror:true}]})],wa=[N({id:"shoes.sneakers",slot:"shoes",name:"Sneakers",palette:{a:"#d84a30",w:"#f4f1ea"},tint:"a",textures:{toe:Te(["aaaa","wwww"]),side:Te(["aaaaa","wwwww"])},paint:[{region:"feet",color:"a",faces:{front:"toe",back:"toe",left:"side",right:"side",bottom:"w"}}]}),N({id:"shoes.boots",slot:"shoes",name:"Boots",palette:{a:"#5a3a22",b:"#3a2414"},tint:"a",paint:[{region:"feet",color:"a",faces:{bottom:"b"}}],parts:[{bone:"shinR",size:[4.83,4.32,4.83],pos:[2.1,3.76,0],color:"a",mirror:true}]}),N({id:"shoes.sandals",slot:"shoes",name:"Sandals",palette:{a:"#b0773a",s:"@skin"},tint:"a",paint:[{region:"feet",color:"s"}],parts:[{bone:"shinR",size:[4.51,.48,5.57],pos:[2.1,.24,-0.53],color:"a",mirror:true},{bone:"shinR",size:[4.51,.4,1.05],pos:[2.1,1.12,-1.89],color:"a",mirror:true}]})],xa=[N({id:"hands.gloves",slot:"hands",name:"Gloves",palette:{a:"#2b2140"},tint:"a",paint:[{region:"hands",color:"a"}]})],va=[N({id:"waist.belt",slot:"waist",name:"Belt",palette:{a:"#5a3a22",g:"#d8b030"},tint:"a",parts:[{bone:"body",size:[9.45,1.25,4.97],pos:[0,13.15,0],color:"a"},{bone:"body",size:[1.8,1.5,.37],pos:[0,13.15,-2.67],color:"g"}]})],Ra=[N({id:"back.backpack",slot:"back",name:"Backpack",palette:{a:"#c0612b",b:"#8a3f18"},tint:"a",parts:[{bone:"body",size:[6.75,8.75,2.76],pos:[0,17.4,3.68],color:"a"},{bone:"body",size:[4.5,3.75,.55],pos:[0,14.9,5.34],color:"b"}]}),N({id:"back.cape",slot:"back",name:"Cape",palette:{a:"#a32d2d"},tint:"a",parts:[{bone:"body",size:[10.13,12.5,.55],pos:[0,16.15,2.67],color:"a"}]})],Aa=[N({id:"face.glasses",slot:"faceAcc",name:"Round glasses",palette:{a:"#2b2140"},tint:"a",parts:[{bone:"head",size:[2.41,.27,.29],pos:[1.56,26.84,-4.29],color:"a",mirror:true},{bone:"head",size:[2.41,.27,.29],pos:[1.56,24.73,-4.29],color:"a",mirror:true},{bone:"head",size:[.28,2.39,.29],pos:[2.9,25.78,-4.29],color:"a",mirror:true},{bone:"head",size:[1.13,.27,.29],pos:[0,26.3,-4.29],color:"a"}]}),N({id:"face.shades",slot:"faceAcc",name:"Sunglasses",palette:{a:"#1d1d21"},tint:"a",parts:[{bone:"head",size:[2.55,1.64,.29],pos:[1.56,25.89,-4.29],color:"a",mirror:true},{bone:"head",size:[6.23,.34,.29],pos:[0,26.77,-4.29],color:"a"}]})],Ea=[N({id:"hat.beanie",slot:"hat",name:"Beanie",palette:{a:"#534ab7",w:"#f4f1ea"},tint:"a",parts:[{bone:"head",size:[9.92,3.07,9.45],pos:[0,30.76,0],color:"a"},{bone:"head",size:[10.34,1.36,9.89],pos:[0,29.3,0],color:"a"},{bone:"head",size:[2.13,2.05,2.18],pos:[0,33.18,0],color:"w"}]}),N({id:"hat.cap",slot:"hat",name:"Cap",palette:{a:"#c0392b"},tint:"a",parts:[{bone:"head",size:[9.63,2.73,9.16],pos:[0,30.8,.15],color:"a"},{bone:"head",size:[7.79,.55,3.64],pos:[0,29.57,-5.96],color:"a"}]}),N({id:"hat.bucket",slot:"hat",name:"Bucket hat",palette:{a:"#c8b88a"},tint:"a",parts:[{bone:"head",size:[9.63,2.73,9.16],pos:[0,31.61,0],color:"a"},{bone:"head",size:[11.33,.55,10.91],pos:[0,30.39,0],color:"a"}]})],Rt=[...ba,...ya,...ga,...wa,...xa,...va,...Ra,...Aa,...Ea,...$r],Xi=Object.fromEntries(Rt.map(e=>[e.id,e]));function ka(e){return Rt.filter(t=>t.slot===e)}function Kr(e){return ka(e).filter(t=>!Wr(t.id))}var Sa=["#f9e0cf","#f2c9a0","#e2ad80","#c88d62","#9c6844","#6e4a32"],Ta=["#3b2a20","#1d1d21","#f2c14e","#c0612b","#ece6da","#7f77dd","#d4537e","#2ab0a0"],Ca=["#3b2a20","#2f5fd0","#1d9e75","#7f77dd","#c0392b","#d8b030"],Ma=["#1d9e75","#378add","#d4537e","#444441","#ef9f27","#534ab7","#c0392b","#e8e4da"],Jr={version:Ae,style:re,body:{skin:"#f2c9a0",height:1},face:{eyes:"round",eyeColor:"#3b2a20",brows:"soft",browColor:"#3b2a20",mouth:"smile",cheeks:true},wear:{hair:"hair.short",top:"top.idos",bottom:"bottom.jeans",shoes:"shoes.sneakers"},tint:{}},Xr={hair:.92,top:1,bottom:1,shoes:1,hands:.1,waist:.2,back:.2,faceAcc:.25,hat:.35};function el(e=Math.random){let t=a=>a[Math.floor(e()*a.length)],r=t(Ta),o={},n={};for(let a of Object.keys(Xr)){if(e()>=Xr[a])continue;let i=Kr(a);i.length&&(o[a]=t(i).id,n[a]=a==="hair"?r:t(Ma));}return {version:Ae,style:re,body:{skin:t(Sa),height:.95+e()*.1},face:{eyes:t(Ve),eyeColor:t(Ca),brows:t(je),browColor:r==="#ece6da"||r==="#f2c14e"?"#8a6a3a":r,mouth:t(Ge),cheeks:e()<.6},wear:o,tint:n}}var Ia={hair:{frame:"portrait",view:.5},hat:{frame:"head",view:.35},faceAcc:{frame:"portrait",view:.2},top:{frame:"torso",view:.3},waist:{frame:"torso",view:.3},hands:{frame:"torso",view:.55},bottom:{frame:"legs",view:.3},shoes:{frame:"legs",view:.6},back:{frame:"full",view:Math.PI-.6}},Pa=["hair","top","bottom","shoes"];function La(e,t){let r=bt(JSON.parse(JSON.stringify(Jr)));for(let o of Object.keys(r.wear))Pa.includes(o)||delete r.wear[o];return r.tint={},r.wear[e]=t,r}function al(e,t){return {key:`item:${e.id}`,make:()=>({spec:La(e.slot,e.id),items:{...t,[e.id]:e},opts:Ia[e.slot]})}}function sl(e={}){let t=e.size??224,r=e.limit??800,o=e.budgetMs??14,n=new Map,a=new Map,i=[],c=null,s=false,l=(p,u)=>{for(n.delete(p),n.set(p,u);n.size>r;){let x=n.keys().next().value;URL.revokeObjectURL(n.get(x)),n.delete(x);}},h=()=>{if(s)return;s=true;let p=globalThis.requestIdleCallback;p?p(m,{timeout:120}):setTimeout(m,16);};function m(){s=false;let p=performance.now();for(;i.length&&performance.now()-p<o;){let u=i.shift(),x=a.get(u);if(x&&(a.delete(u),x.listeners.size!==0))try{c??=Yr({size:t});let{spec:y,items:T,opts:k}=x.make(),g=c.render(y,T,k),b=[...x.listeners];g.toBlob(S=>{if(!S)return;let d=URL.createObjectURL(S);l(u,d);for(let v of b)v(d);},"image/png");}catch{c?.dispose(),c=null;}}i.length&&h();}return {peek:p=>n.get(p)??null,request(p,u){let x=n.get(p.key);if(x)return l(p.key,x),u(x),()=>{};let y=a.get(p.key);y||(y={make:p.make,listeners:new Set},a.set(p.key,y),i.push(p.key)),y.listeners.add(u),h();let T=y;return ()=>T.listeners.delete(u)},release(){c?.dispose(),c=null;}}}var za="voxel-avatar-v1";function ml(){return {standard:za,style:re,version:Ae,slots:[...Ee],eyes:[...Ve],brows:[...je],mouths:[...Ge],height:{min:Be.min,max:Be.max},items:[...Rt],shop:{...er},rules:{slots:{...Wt},limits:{...ke},regions:[...qt],regionPairs:Object.fromEntries(Object.entries($t).map(([e,t])=>[e,[...t]])),faces:[...fe],skinColor:Re}}}var _a=(e,t,r)=>"#"+[e,t,r].map(o=>Math.max(0,Math.min(255,Math.round(o))).toString(16).padStart(2,"0")).join("");function Oa(e,t,r){let o=[];for(let n=0;n<r;n++)for(let a=0;a<t;a++){let i=Math.floor(a*e.width/t),c=Math.max(i+1,Math.floor((a+1)*e.width/t)),s=Math.floor(n*e.height/r),l=Math.max(s+1,Math.floor((n+1)*e.height/r)),h=0,m=0,p=0,u=0,x=0;for(let y=s;y<l;y++)for(let T=i;T<c;T++){let k=(y*e.width+T)*4;x++,!((e.data[k+3]??0)<128)&&(h+=e.data[k]??0,m+=e.data[k+1]??0,p+=e.data[k+2]??0,u++);}o.push(u*2<x?null:[h/u,m/u,p/u]);}return o}var We=(e,t)=>(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2;function ul(e,t){let r=ke.textureSide,n=Math.min(1,16/Math.max(e.width,e.height,1)),a=Math.max(1,Math.min(r,Math.round(t.w??e.width*n))),i=Math.max(1,Math.min(r,Math.round(t.h??e.height*n))),c=[...new Set(t.symbols)].slice(0,ke.palette);if(!c.length)throw new Error("pixelTextureFromImage: no palette symbols to use");let s=Oa(e,a,i),l=s.filter(y=>!!y),h=new Map;for(let y of l){let T=y.map(g=>Math.round(g/8)).join(","),k=h.get(T);k?k.n++:h.set(T,{n:1,c:y});}let m=[...h.values()].sort((y,T)=>T.n-y.n||(y.c.join()<T.c.join()?-1:1)),p=[];for(let y of m){if(p.length>=c.length)break;p.every(T=>We(T,y.c)>576)&&p.push([...y.c]);}!p.length&&m[0]&&(p=[[...m[0].c]]);for(let y=0;y<8&&p.length;y++){let T=p.map(()=>[0,0,0,0]);for(let k of l){let g=0;for(let S=1;S<p.length;S++)We(k,p[S])<We(k,p[g])&&(g=S);let b=T[g];b[0]+=k[0],b[1]+=k[1],b[2]+=k[2],b[3]+=1;}p=p.map((k,g)=>{let b=T[g];return b[3]?[b[0]/b[3],b[1]/b[3],b[2]/b[3]]:k});}let u={};p.forEach((y,T)=>u[c[T]]=_a(y[0],y[1],y[2]));let x=[];for(let y=0;y<i;y++){let T="";for(let k=0;k<a;k++){let g=s[y*a+k];if(!g||!p.length){T+=".";continue}let b=0;for(let S=1;S<p.length;S++)We(g,p[S])<We(g,p[b])&&(b=S);T+=c[b];}x.push(T);}return {texture:{w:a,h:i,rows:x},palette:u}}var Fa="ugc.",bl=e=>e.startsWith(Fa);export{Ir as ACTION_TIME,vs as ANIM_EVENTS,Fa as AVATAR_AUTHOR_ITEM_PREFIX,_r as AVATAR_BASE_COLORS,Ue as AVATAR_FACE_RECT,Be as AVATAR_HEIGHT,Xi as AVATAR_ITEMS,ke as AVATAR_ITEM_LIMITS,Rt as AVATAR_ITEM_LIST,ia as AVATAR_ITEM_PRINTS,Ia as AVATAR_ITEM_SHOTS,ji as AVATAR_PORTRAIT_BACKGROUND,Me as AVATAR_RIG_ID,er as AVATAR_SHOP_DEFAULT_PRICES,$r as AVATAR_SHOP_ITEM_LIST,Ee as AVATAR_SLOTS,Ae as AVATAR_SPEC_VERSION,za as AVATAR_STANDARD_ID,re as AVATAR_STYLE,ft as Animator,L as Art,vt as AvatarActor,qt as BODY_REGIONS,ja as BONE_ROLES,je as BROW_STYLES,j as CH,ws as CHANNELS,hr as CHARACTER_LIMITS,lr as CHARACTER_SPEC_VERSION,ue as CLEAR,pt as CLIPS,Ma as CLOTH_COLORS,gi as CREATURE_KINDS,it as CharacterView,Jr as DEFAULT_AVATAR,Dn as DEFAULT_AVATAR_FACE,Ot as DEFAULT_CHARACTER_SOURCE,to as DEFAULT_COLORS,Ie as DEFAULT_FINISH,gt as DrawnFace,mt as EMOTES,Ws as EMOTE_IDS,Qs as EMOTION_EVENTS,He as EXPRESSIONS,Lr as EXPRESSION_CHAIN,Ze as EXTRA_BONE_ROLES,Ca as EYE_COLORS,Ve as EYE_STYLES,fe as FACE_NAMES,Dr as FACE_TEXELS,Ta as HAIR_COLORS,xs as HELD_KINDS,Er as HUMAN_BOTTOMS,bs as HUMAN_HAIR,kr as HUMAN_SHOES,Ar as HUMAN_TOPS,Ct as IDLE_STYLES,In as LOCOMOTION,Ge as MOUTH_STYLES,jt as POSTURE,$t as REGION_PAIRS,_e as REST,ne as RIGS,Mr as RIG_CLIPS,Fe as RIG_IDS,Re as SKIN_COLOR,Sa as SKIN_TONES,Wt as SLOT_RULES,Ga as SOCKETS,fi as VOXEL_CHARACTER_SYSTEM_PROMPT,ut as VoxelActor,Tt as WALK_STYLES,Pt as acquireCharacter,ie as add,zr as applyPosture,ml as avatarCatalogExport,Ui as avatarFromServer,al as avatarItemShot,ka as avatarItemsForSlot,La as avatarMannequinWith,Zt as avatarPrints,rn as bandColors,Oe as bone,dr as bonesOf,Gs as characterFromImage,Ps as characterOf,Ls as characterSpecs,ve as clearPose,Xt as composeAvatar,at as copyPose,Yr as createAvatarSnapshotter,sl as createAvatarThumbQueue,wi as creatureCharacter,Hn as creatureSource,xe as defaultCharacter,et as defaultCharacterName,Ft as disposeNameplate,Hr as drawAvatarFace,ei as emotionFromText,Kr as freeAvatarItemsForSlot,_t as humanSource,bl as isAuthorAvatarItem,Wr as isAvatarShopItem,os as isDefaultCharacterName,Ks as isEmote,H as isObj,gr as layoutCharacter,Tr as lerpPose,mr as mirrorBone,Sr as nameplate,st as newAnimInput,de as normColor,Hs as npcCharacter,Q as num,zs as onCharacterKnown,bt as parseAvatarSpec,ae as parseCharacterSpec,kt as pick,ul as pixelTextureFromImage,el as randomAvatar,zt as recolor,Is as registerCharacter,rt as releaseCharacter,da as renderAvatarCanvas,Gi as renderAvatarImage,rs as rigOfSpec,Pr as sampleEmote,Mn as sampleTrack,f as setCh,Pe as specHash,St as stableStringify,nt as standardFace,Ht as styleParams,yt as validateAvatarItem,Qe as vec3};
|
|
77
|
+
- When the player sends pictures (possibly of ONE character from different angles: front, side, back) study EVERY picture: get the silhouette, proportions, colours, clothes and the face right. Pictures can be photos, drawings or 3D renders \u2014 turn them into a clean blocky version.`;var Vi=["cat","dog","fox","bear","rabbit","bird","dragon","slime","ghost","robot"],na=e=>({k:"#2a1c14",w:"#f4f4ef",b:e,m:"#7a3a30",o:"#3a1a14"});function aa(e){let t=e.light??e.body,r=e.accent??e.body,o={t:e.body,s:e.body,l:t,a:r,p:r,...na(e.eyes??"#3f6f3a")},n=[],a="quadruped",i=ct("head",[0,3,8,5]),c={walk:"normal",idle:"calm",energy:.6},s=(l,h,m,p,y,w={})=>n.push({name:l,bone:h,size:m,pos:p,color:y,...w});switch(e.kind){case "cat":case "fox":case "dog":case "bear":case "rabbit":{let l=e.kind;s("body","body",[8,8,16],[0,12,0],"t"),s("belly","body",[6,1,12],[0,8,0],"l"),s("head","head",[8,8,8],[0,16,-12],"s");for(let h of ["legFL","legFR","legBL","legBR"]){let m=h.endsWith("L")?-3:3,p=h.startsWith("legF")?-6:6;s(h,h,[3,8,3],[m,4,p],"t"),s(`${h}Paw`,h,[3.2,1.5,3.2],[m,.75,p],"a");}l==="cat"?(s("ear","head",[2,2.5,1],[-2.5,21,-11],"a",{mirror:true}),s("tail","tail",[1.6,1.6,10],[0,15,13],"t",{rot:[20,0,0]}),c={walk:"sneaky",idle:"calm",energy:.5}):l==="fox"?(s("ear","head",[2.4,3.2,1],[-2.5,21.4,-11],"t",{mirror:true}),s("snout","head",[4,3,3],[0,14.5,-17],"l"),s("nose","head",[1.2,1,.6],[0,15.6,-18.6],"a"),s("tail","tail",[3.5,3.5,10],[0,14,13],"t",{rot:[15,0,0]}),s("tailTip","tail",[3.6,3.6,2.5],[0,15.2,18],"l"),c={walk:"bouncy",idle:"fidgety",energy:.7}):l==="dog"?(s("ear","head",[1.5,4,3],[-4.6,17.5,-11.5],"a",{mirror:true}),s("snout","head",[4,3,3],[0,14.5,-17],"l"),s("nose","head",[1.6,1.2,.6],[0,15.8,-18.6],"a"),s("tail","tail",[2,2,7],[0,16,11],"t",{rot:[40,0,0]}),c={walk:"bouncy",idle:"fidgety",energy:.9}):l==="bear"?(s("ear","head",[2,2,1],[-3,20.6,-10.5],"a",{mirror:true}),s("snout","head",[4,3,2.5],[0,14.5,-16.8],"l"),s("nose","head",[1.6,1.2,.6],[0,15.8,-18.2],"a"),s("tail","tail",[2,2,2],[0,14,9],"t"),c={walk:"heavy",idle:"proud",energy:.4}):(s("ear","head",[1.6,7,1],[-1.8,23.5,-11],"t",{mirror:true}),s("earInner","head",[.8,5.5,.4],[-1.8,23.5,-11.6],"l",{mirror:true}),s("tail","tail",[3,3,3],[0,14,9.5],"l"),c={walk:"bouncy",idle:"fidgety",energy:.8});break}case "bird":case "dragon":{a="flyer",i=ct("head",[0,1,5,3]);let l=e.kind==="dragon";s("body","body",[6,6,8],[0,8,0],"t"),s("belly","body",[4.6,4,1],[0,7.5,-4.2],"l"),s("head","head",[5,5,5],[0,13,-4],"s"),s("wing","wingL",[8,1,6],[-7,10,0],"a",{mirror:true}),s("leg","legL",[1,4,1],[-1.5,2,0],"a",{mirror:true}),l?(s("horn","head",[.8,2,.8],[-1.4,16.4,-3],"l",{mirror:true}),s("snout","head",[3,2,2.4],[0,12.2,-7.4],"s"),s("tail","tail",[2,2,8],[0,7,7],"t"),s("spike","body",[1,1.5,6],[0,11.6,0],"a"),c={walk:"heavy",idle:"proud",energy:.6}):(s("beak","head",[1.6,1.2,2],[0,12.4,-7.2],"a"),s("tail","tail",[4,1,4],[0,8,6],"a"),s("crest","head",[1,2,2],[0,16.2,-3.6],"a"),c={walk:"bouncy",idle:"fidgety",energy:.8});break}case "slime":case "ghost":case "robot":{a="blob",i=ct("body",[2,3,8,5]),e.kind==="slime"?(s("body","body",[12,10,12],[0,5,0],"t"),s("shine","body",[3,2,.4],[-3,8,-6.2],"l"),c={walk:"bouncy",idle:"fidgety",energy:.9}):e.kind==="ghost"?(s("body","body",[10,12,10],[0,7,0],"t"),s("hem","body",[10.4,2,10.4],[0,1,0],"l"),c={walk:"sneaky",idle:"calm",energy:.4}):(s("body","body",[11,11,10],[0,5.5,0],"t"),s("antenna","body",[.8,3,.8],[0,12.5,0],"a"),s("bulb","body",[1.6,1.6,1.6],[0,14.6,0],"l"),s("screen","body",[9,6,.4],[0,6.5,-5.2],"l"),c={walk:"robotic",idle:"calm",energy:.5});break}}return {version:1,name:e.name,description:e.description??"",rig:a,palette:o,textures:i.textures,parts:n,face:i.face,style:c,finish:{noise:.45,outline:.4,shade:.25,density:2},tags:e.tags??[e.kind]}}function ji(e){let t=le(aa(e));if(!t.ok)throw new Error(`${e.kind}: ${t.error}`);return t.spec}var ne="voxel-v1",Te=1,Ce=["hair","top","bottom","shoes","hands","waist","back","faceAcc","hat"],Xt=["head","torso","sleeveL","sleeveR","forearmL","forearmR","handL","handR","legL","legR","footL","footR"],Jt={sleeves:["sleeveL","sleeveR"],forearms:["forearmL","forearmR"],arms:["sleeveL","sleeveR","forearmL","forearmR"],hands:["handL","handR"],legs:["legL","legR"],feet:["footL","footR"]},ke="@skin",Zt={hair:{bones:["head"],paint:["head"],paintFaces:["top","back","left","right"],parts:8,box:{min:[-6,22,-6],max:[6,35.5,6]}},hat:{bones:["head"],paint:[],parts:8,box:{min:[-7,26,-8],max:[7,38,7]}},top:{bones:["body","armL","armR","foreArmL","foreArmR"],paint:["torso","sleeveL","sleeveR","forearmL","forearmR"],parts:6,box:{min:[-10,9.5,-6],max:[10,26,6]}},bottom:{bones:["body","legL","legR","shinL","shinR"],paint:["legL","legR"],parts:4,box:{min:[-6.5,.5,-4.5],max:[6.5,17,4.5]}},shoes:{bones:["legL","legR","shinL","shinR"],paint:["footL","footR"],parts:4,box:{min:[-5.5,-0.5,-4.5],max:[5.5,7,4]}},hands:{bones:["armL","armR","foreArmL","foreArmR"],paint:["handL","handR"],parts:2,box:{min:[-10,9.5,-4],max:[10,16,4]}},waist:{bones:["body"],paint:[],parts:4,box:{min:[-7,9.5,-4],max:[7,16.5,4]}},back:{bones:["body"],paint:[],parts:8,box:{min:[-13.5,6,1.5],max:[13.5,36.5,13]}},faceAcc:{bones:["head"],paint:[],parts:4,box:{min:[-6,22.5,-6],max:[6,30.5,-2]}}},Me={palette:5,textures:4,textureSide:32,texturePixels:2048,id:40,textureId:12,name:40},Ye=["round","sparkle","wide","cat","sleepy","dot"],$e=["soft","thick","arched","none"],qe=["smile","grin","cat","small"],We=[.5,1.8,7.5,5.4],sa={eyes:"round",eyeColor:"#3b2a20",brows:"soft",browColor:"#3b2a20",mouth:"smile",cheeks:true,emotion:"neutral"},Ue={min:.9,max:1.1},vt=(e,t,r)=>typeof e=="string"&&t.includes(e)?e:r,Kt=e=>typeof e=="string"&&Ce.includes(e);function Rt(e){let t=N(e)?e:{},r=N(t.body)?t.body:{},o=N(t.face)?t.face:{},n=sa,a={};if(N(t.wear))for(let[c,s]of Object.entries(t.wear))Kt(c)&&typeof s=="string"&&s.trim()&&(a[c]=s.trim().slice(0,Me.id));let i={};if(N(t.tint))for(let[c,s]of Object.entries(t.tint)){let l=ue(s);Kt(c)&&l&&(i[c]=l);}return {version:Te,style:ne,body:{skin:ue(r.skin)??"#f2c9a0",height:Math.round(Q(r.height,1,Ue.min,Ue.max)*1e3)/1e3},face:{eyes:vt(o.eyes,Ye,n.eyes),eyeColor:ue(o.eyeColor)??n.eyeColor,brows:vt(o.brows,$e,n.brows),browColor:ue(o.browColor)??n.browColor,mouth:vt(o.mouth,qe,n.mouth),cheeks:typeof o.cheeks=="boolean"?o.cheeks:n.cheeks,emotion:vt(o.emotion,a$1,n.emotion)},wear:a,tint:i}}var ia=/^[a-z0-9][a-z0-9_.-]*$/,la=/^[A-Za-z0-9]+$/;function Wt(e){return !Array.isArray(e)||e.length!==3?null:e.every(t=>typeof t=="number"&&Number.isFinite(t))?e:null}function ca(e,t){if(!t||t.every(o=>o===0))return [e[0]/2,e[1]/2,e[2]/2];let r=Math.hypot(e[0],e[1],e[2])/2;return [r,r,r]}function Et(e){let t=[],r=(g,f,S)=>t.push(c({en:g,ru:f},S));if(!N(e))return {ok:false,errors:[c({en:"the item is not an object",ru:"\u0432\u0435\u0449\u044C: \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442"})]};let o=e,n=Me;o.style!==void 0&&o.style!==ne&&r("style \xAB{s}\xBB is not {need}","\u0441\u0442\u0438\u043B\u044C \xAB{s}\xBB: \u043D\u0435 {need}",{s:String(o.style),need:ne});let a=typeof o.id=="string"?o.id.trim():"";if((!a||a.length>n.id||!ia.test(a))&&r("id must be 1, {n} characters: a-z, 0-9, _ . -","id: 1, {n} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432: a-z, 0-9, _ . -",{n:n.id}),!Kt(o.slot))return r("unknown slot \xAB{s}\xBB","\u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u044B\u0439 \u0441\u043B\u043E\u0442 \xAB{s}\xBB",{s:String(o.slot)}),{ok:false,errors:t};let i=o.slot,c$1=Zt[i],s=typeof o.name=="string"&&o.name.trim()?o.name.trim().slice(0,n.name):a,l={};if(!N(o.palette)||!Object.keys(o.palette).length)r("the palette is empty","\u043F\u0430\u043B\u0438\u0442\u0440\u0430 \u043F\u0443\u0441\u0442\u0430");else {let g=Object.entries(o.palette);g.length>n.palette&&r("more than {n} colours in the palette","\u0432 \u043F\u0430\u043B\u0438\u0442\u0440\u0435 \u0431\u043E\u043B\u044C\u0448\u0435 {n} \u0446\u0432\u0435\u0442\u043E\u0432",{n:n.palette});for(let[f,S]of g){let d=S===ke?ke:ue(S);f.length!==1||ye.has(f)||!d?r("palette colour \xAB{k}\xBB is not valid","\u0446\u0432\u0435\u0442 \u043F\u0430\u043B\u0438\u0442\u0440\u044B \xAB{k}\xBB \u043D\u0435 \u0433\u043E\u0434\u0438\u0442\u0441\u044F",{k:f}):l[f]=d;}}let h=typeof o.tint=="string"&&o.tint?o.tint:null;h!==null&&(!l[h]||l[h]===ke)&&r("tint \xAB{k}\xBB is not a colour of the palette","\u043F\u0435\u0440\u0435\u043A\u0440\u0430\u0441\u043A\u0430 \xAB{k}\xBB: \u043D\u0435 \u0446\u0432\u0435\u0442 \u043F\u0430\u043B\u0438\u0442\u0440\u044B",{k:h});let m={},p=0;if(o.textures!==void 0)if(!N(o.textures))r("textures is not an object","textures: \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442");else {let g=Object.entries(o.textures);g.length>n.textures&&r("more than {n} textures","\u0442\u0435\u043A\u0441\u0442\u0443\u0440 \u0431\u043E\u043B\u044C\u0448\u0435 {n}",{n:n.textures});for(let[f,S]of g){if(f.length>n.textureId||!la.test(f)){r("texture id \xAB{id}\xBB must be 1, {n} letters or digits","id \u0442\u0435\u043A\u0441\u0442\u0443\u0440\u044B \xAB{id}\xBB: 1, {n} \u0431\u0443\u043A\u0432 \u0438\u043B\u0438 \u0446\u0438\u0444\u0440",{id:f.slice(0,20),n:n.textureId});continue}let d=N(S)?S:null,R=d&&Array.isArray(d.rows)?d.rows:null,E=d?d.w:void 0,v=d?d.h:void 0;if(!R||typeof E!="number"||typeof v!="number"||!Number.isInteger(E)||!Number.isInteger(v)||E<1||v<1||E>n.textureSide||v>n.textureSide||R.length!==v||R.some(C=>typeof C!="string"||C.length!==E)){r("texture \xAB{id}\xBB must be w\xD7h \u2264 {n} with exactly h rows of w symbols","\u0442\u0435\u043A\u0441\u0442\u0443\u0440\u0430 \xAB{id}\xBB: w\xD7h \u2264 {n}, \u0440\u043E\u0432\u043D\u043E h \u0441\u0442\u0440\u043E\u043A \u043F\u043E w \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432",{id:f,n:n.textureSide});continue}R.some(C=>[...C].some(L=>!ye.has(L)&&!l[L]))&&r("texture \xAB{id}\xBB uses symbols outside the palette","\u0432 \u0442\u0435\u043A\u0441\u0442\u0443\u0440\u0435 \xAB{id}\xBB \u0441\u0438\u043C\u0432\u043E\u043B\u044B \u043D\u0435 \u0438\u0437 \u043F\u0430\u043B\u0438\u0442\u0440\u044B",{id:f}),p+=E*v,m[f]={w:E,h:v,rows:R.map(C=>C.replace(/ /g,"."))};}p>n.texturePixels&&r("textures take {p} pixels, the limit is {n}","\u0442\u0435\u043A\u0441\u0442\u0443\u0440\u044B \u0437\u0430\u043D\u0438\u043C\u0430\u044E\u0442 {p} \u043F\u0438\u043A\u0441\u0435\u043B\u0435\u0439, \u043F\u0440\u0435\u0434\u0435\u043B {n}",{p,n:n.texturePixels});}let y=(g,f)=>typeof g!="string"?null:m[g]||l[g]?g:(r("{w}: \xAB{v}\xBB is neither a texture nor a palette colour","{w}: \xAB{v}\xBB: \u043D\u0438 \u0442\u0435\u043A\u0441\u0442\u0443\u0440\u0430, \u043D\u0438 \u0446\u0432\u0435\u0442 \u043F\u0430\u043B\u0438\u0442\u0440\u044B",{w:f,v:g}),null),w=(g,f,S=be)=>{if(g===void 0)return;if(!N(g)){r("{w}: faces is not an object","{w}: faces: \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442",{w:f});return}let d={};for(let[R,E]of Object.entries(g)){if(!be.includes(R)){r("{w}: unknown face \xAB{f}\xBB","{w}: \u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u0430\u044F \u0433\u0440\u0430\u043D\u044C \xAB{f}\xBB",{w:f,f:R});continue}if(!S.includes(R)){r("{w}: the {slot} slot may not paint the \xAB{f}\xBB face","{w}: \u0441\u043B\u043E\u0442 {slot} \u043D\u0435 \u043A\u0440\u0430\u0441\u0438\u0442 \u0433\u0440\u0430\u043D\u044C \xAB{f}\xBB",{w:f,slot:i,f:R});continue}let v=y(E,f);v&&(d[R]=v);}return Object.keys(d).length?d:void 0},b=[];o.paint!==void 0&&!Array.isArray(o.paint)&&r("paint is not a list","paint: \u043D\u0435 \u0441\u043F\u0438\u0441\u043E\u043A");for(let[g,f]of (Array.isArray(o.paint)?o.paint:[]).entries()){let S=`paint[${g}]`;if(!N(f)){r("{w} is not an object","{w}: \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442",{w:S});continue}let d=typeof f.region=="string"?f.region:"",R=Jt[d]??(Xt.includes(d)?[d]:[]);if(!R.length){r("{w}: unknown region \xAB{r}\xBB","{w}: \u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u0430\u044F \u043E\u0431\u043B\u0430\u0441\u0442\u044C \xAB{r}\xBB",{w:S,r:d});continue}let E=R.filter(C=>!c$1.paint.includes(C));if(E.length){r("{w}: the {slot} slot may not paint \xAB{r}\xBB","{w}: \u0441\u043B\u043E\u0442 {slot} \u043D\u0435 \u043A\u0440\u0430\u0441\u0438\u0442 \xAB{r}\xBB",{w:S,slot:i,r:E.join(", ")});continue}let v=typeof f.color=="string"&&l[f.color]?f.color:null;v||r("{w}: colour is not in the palette","{w}: \u0446\u0432\u0435\u0442\u0430 \u043D\u0435\u0442 \u0432 \u043F\u0430\u043B\u0438\u0442\u0440\u0435",{w:S});let I=w(f.faces,S,c$1.paintFaces);if(v)for(let C of R){let L={region:C,color:v};I&&(L.faces={...I}),b.push(L);}}let T=[];o.parts!==void 0&&!Array.isArray(o.parts)&&r("parts is not a list","parts: \u043D\u0435 \u0441\u043F\u0438\u0441\u043E\u043A");let k=Array.isArray(o.parts)?o.parts:[];k.length>c$1.parts&&r("the {slot} slot allows {n} boxes, the item has {m}","\u0441\u043B\u043E\u0442\u0443 {slot} \u043C\u043E\u0436\u043D\u043E {n} \u043A\u043E\u0440\u043E\u0431\u043E\u043A, \u0443 \u0432\u0435\u0449\u0438 {m}",{slot:i,n:c$1.parts,m:k.length});for(let[g,f]of k.entries()){let S=`parts[${g}]`;if(!N(f)){r("{w} is not an object","{w}: \u043D\u0435 \u043E\u0431\u044A\u0435\u043A\u0442",{w:S});continue}let d=typeof f.bone=="string"?f.bone:"";if(!c$1.bones.includes(d)){r("{w}: the {slot} slot puts boxes only on {b}","{w}: \u0441\u043B\u043E\u0442 {slot} \u0441\u0442\u0430\u0432\u0438\u0442 \u043A\u043E\u0440\u043E\u0431\u043A\u0438 \u0442\u043E\u043B\u044C\u043A\u043E \u043D\u0430 {b}",{w:S,slot:i,b:c$1.bones.join(", ")});continue}let R=Wt(f.size),E=Wt(f.pos);if(!R||!E||R.some(P=>P<=0)){r("{w}: size and pos must be [x, y, z]","{w}: size \u0438 pos: [x, y, z]",{w:S});continue}let v=f.rot===void 0?void 0:Wt(f.rot);f.rot!==void 0&&!v&&r("{w}: rot must be [x, y, z]","{w}: rot: [x, y, z]",{w:S});let I=f.mirror===true,C=ca(R,v??void 0),j=(I?[E[0],-E[0]]:[E[0]]).some(P=>P-C[0]<c$1.box.min[0]-1e-6||P+C[0]>c$1.box.max[0]+1e-6)||[1,2].some(P=>E[P]-C[P]<c$1.box.min[P]-1e-6||E[P]+C[P]>c$1.box.max[P]+1e-6);j&&r("{w}: the box leaves the {slot} slot frame","{w}: \u043A\u043E\u0440\u043E\u0431\u043A\u0430 \u0432\u044B\u0445\u043E\u0434\u0438\u0442 \u0437\u0430 \u0440\u0430\u043C\u043A\u0443 \u0441\u043B\u043E\u0442\u0430 {slot}",{w:S,slot:i});let x=typeof f.color=="string"&&l[f.color]?f.color:null;x||r("{w}: colour is not in the palette","{w}: \u0446\u0432\u0435\u0442\u0430 \u043D\u0435\u0442 \u0432 \u043F\u0430\u043B\u0438\u0442\u0440\u0435",{w:S});let A=w(f.faces,S);if(!x||j)continue;let M={bone:d,size:[...R],pos:[...E],color:x};A&&(M.faces=A),v&&v.some(P=>P!==0)&&(M.rot=[...v]),I&&(M.mirror=true),typeof f.name=="string"&&f.name.trim()&&(M.name=f.name.trim().slice(0,24)),T.push(M);}return !k.length&&!(Array.isArray(o.paint)&&o.paint.length)&&r("the item neither paints nor adds anything","\u0432\u0435\u0449\u044C \u043D\u0438\u0447\u0435\u0433\u043E \u043D\u0435 \u043A\u0440\u0430\u0441\u0438\u0442 \u0438 \u043D\u0435 \u0434\u043E\u0431\u0430\u0432\u043B\u044F\u0435\u0442"),t.length?{ok:false,errors:t}:{ok:true,item:{version:Te,style:ne,id:a,slot:i,name:s,palette:l,tint:h,textures:m,paint:b,parts:T}}}var Br={torso:"#d9d3c5",legs:"#5f6b7a"},pa="#2b2140",ha="#7a2e2e",ma="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",da=32,fa=[10,7],ua={noise:0,outline:0,shade:.12,density:4,round:.35},ba=["front","back","left","right"];function Vr(e){let t=parseInt(e.slice(1),16);return [t>>16&255,t>>8&255,t&255]}var Qt=class{map={};next=0;key(t){let r=Object.entries(this.map).find(([,s])=>s===t);if(r)return r[0];if(this.next<da){let s=ma[this.next++];return this.map[s]=t,s}let[o,n,a]=Vr(t),i=Object.keys(this.map)[0],c=1/0;for(let[s,l]of Object.entries(this.map)){let[h,m,p]=Vr(l),y=(o-h)**2+(n-m)**2+(a-p)**2;y<c&&(c=y,i=s);}return i}};function ya(e,t){return (typeof e=="function"?e(t):e[t])??null}function ga(e){let[t,r]=fa,o=new _(t,r),n=a=>{a(1),a(6);};switch(e){case "blink":case "tired":n(a=>o.row(3,a,a+2,"k"));break;case "happy":n(a=>o.px(a,3,"k").px(a+1,2,"k").px(a+2,3,"k"));break;case "hurt":o.px(1,2,"k").px(2,3,"k").px(1,4,"k"),o.px(8,2,"k").px(7,3,"k").px(8,4,"k");break;case "surprised":case "scared":n(a=>o.rect(a,2,3,3,"w").px(a+1,3,"k"));break;default:n(a=>o.rect(a,2,3,3,"w").rect(a+1,3,2,2,"e").px(a+1,3,"k"));}switch(e==="angry"&&o.px(1,1,"k").px(2,1,"k").px(3,2,"k").px(8,1,"k").px(7,1,"k").px(6,2,"k"),e==="sad"&&o.px(3,1,"k").px(2,1,"k").px(6,1,"k").px(7,1,"k"),e){case "happy":case "talk":o.rect(4,5,2,2,"m");break;case "surprised":o.rect(4,5,2,2,"m");break;case "sad":o.px(3,6,"m").row(5,4,5,"m").px(6,6,"m");break;case "angry":case "tired":case "scared":case "hurt":o.row(6,4,5,"m");break;default:o.px(3,5,"m").row(6,4,5,"m").px(6,5,"m");}return o.tex()}function er(e,t){let r=ie[_e],o=new Qt,n=o.key(e.body.skin),a=r.defaultParts.map(p=>({...p,size:[...p.size],pos:[...p.pos],color:p.name==="torso"?o.key(Br.torso):p.name?.startsWith("leg")||p.name?.startsWith("foot")?o.key(Br.legs):n})),i=new Map;for(let p of a){let y=i.get(p.name)??[];y.push(p),i.set(p.name,y);}for(let p of i.values())p.sort((y,w)=>w.pos[1]+w.size[1]/2-(y.pos[1]+y.size[1]/2));let c={},s={k:o.key(pa),w:o.key("#ffffff"),e:o.key(e.face.eyeColor),m:o.key(ha)},l={};for(let p of je){let y=ga(p),w="face_"+p;c[w]={...y,rows:y.rows.map(b=>[...b].map(T=>s[T]??T).join(""))},l[p]=w;}l.neutral=l[e.face.emotion]??l.neutral;for(let p of Ce){let y=e.wear[p];if(!y)continue;let w=ya(t,y);if(!w||w.slot!==p||w.style!==ne)continue;let b={};for(let[g,f]of Object.entries(w.palette))b[g]=f===ke?n:o.key(g===w.tint&&e.tint[p]?e.tint[p]:f);let T={};for(let[g,f]of Object.entries(w.textures)){let S=`${p}_${g}`;T[g]=S,c[S]={w:f.w,h:f.h,rows:f.rows.map(d=>[...d].map(R=>b[R]??R).join(""))};}let k=g=>{if(!g)return;let f={};for(let[S,d]of Object.entries(g)){let R=T[d]??b[d];R&&(f[S]=R);}return Object.keys(f).length?f:void 0};for(let g of w.paint){let f=i.get(g.region);if(!f)continue;let S=b[g.color],d=k(g.faces);f.forEach((R,E)=>{S&&(R.color=S);let v=d&&wa(d,f,E,c);v?R.faces=v:delete R.faces;});}for(let g of w.parts){let f={bone:g.bone,size:[...g.size],pos:[...g.pos],color:b[g.color]??n},S=k(g.faces);S&&(f.faces=S),g.rot&&(f.rot=[...g.rot]),g.mirror&&(f.mirror=true),g.name&&(f.name=g.name),a.push(f);}}let h={version:1,name:"Avatar",description:"",rig:_e,scale:e.body.height,palette:o.map,textures:c,parts:a,bones:[],face:{bone:r.faceBone,rect:[...We],expressions:l},style:{walk:"bouncy",idle:"calm",energy:.6},voice:{pitch:1},tags:["avatar",ne],finish:{...ua}},m=le(h);if(!m.ok)throw new Error("composeAvatar: "+m.error);return m.spec}function wa(e,t,r,o){if(t.length===1)return {...e};let n=t[0].pos[1]+t[0].size[1]/2,a=Math.min(...t.map(l=>l.pos[1]-l.size[1]/2)),i=Math.max(1e-6,n-a),c=l=>l<=0?0:l>=t.length?1:(n-(t[l-1].pos[1]-t[l-1].size[1]/2))/i,s={};for(let[l,h]of Object.entries(e)){let m=o[h];if(!m){s[l]=h;continue}if(l==="top"){r===0&&(s[l]=h);continue}if(l==="bottom"){r===t.length-1&&(s[l]=h);continue}if(!ba.includes(l))continue;let p=Math.min(m.h-1,Math.round(c(r)*m.h)),y=Math.max(p+1,Math.round(c(r+1)*m.h)),w=`${h}_${r}`;o[w]||(o[w]={w:m.w,h:y-p,rows:m.rows.slice(p,y)}),s[l]=w;}return Object.keys(s).length?s:void 0}var Ie="#2b2140",Ke="#7a2e2e",jr="#e8707a",xa={neutral:{eye:"open",iris:1,white:1,lidOuter:0,lidInner:0,browUp:0,browInner:0,tear:false},happy:{eye:"happy",iris:1,white:1,lidOuter:0,lidInner:0,browUp:.04,browInner:0,tear:false},sad:{eye:"open",iris:1,white:1,lidOuter:.38,lidInner:.12,browUp:0,browInner:.09,tear:true},angry:{eye:"open",iris:.9,white:.95,lidOuter:.1,lidInner:.42,browUp:-0.02,browInner:-0.1,tear:false},surprised:{eye:"open",iris:.55,white:1.15,lidOuter:0,lidInner:0,browUp:.1,browInner:0,tear:false},scared:{eye:"open",iris:.42,white:1.08,lidOuter:0,lidInner:0,browUp:.08,browInner:.07,tear:false},tired:{eye:"open",iris:1,white:1,lidOuter:.5,lidInner:.5,browUp:-0.02,browInner:-0.02,tear:false},hurt:{eye:"hurt",iris:1,white:1,lidOuter:0,lidInner:0,browUp:0,browInner:-0.07,tear:false}};function Ur(e,t,r,o,n,a="neutral"){let i=n==="blink"||n==="talk"?a==="blink"||a==="talk"?"neutral":a:n,c=xa[i];e.clearRect(0,0,t,r),e.lineCap="round",e.lineJoin="round";let s=r*.5,l=t*.105,h=r*.2,m=n==="blink"?"closed":c.eye;o.cheeks&&i!=="scared"&&(e.fillStyle=i==="happy"?"rgba(236,110,140,0.5)":"rgba(236,120,140,0.32)",$(e,t*.12,r*.8,t*.07,r*.075),e.fill(),$(e,t*.88,r*.8,t*.07,r*.075),e.fill());for(let p of [-1,1]){let y=t*(.5+p*.22);va(e,y,s,l,h,p,o,m,c),Ea(e,y,s-h-r*.07,t,r,p,o,c);}if(c.tear&&m==="open"){e.fillStyle="#85b7eb";let p=t*.5-t*.22-l*.6,y=s+h*1.05;e.beginPath(),e.moveTo(p,y-r*.07),e.quadraticCurveTo(p+t*.03,y,p,y+r*.04),e.quadraticCurveTo(p-t*.03,y,p,y-r*.07),e.fill();}Sa(e,t*.5,r*.86,t,r,o,n==="talk"?"talk":i);}function $(e,t,r,o,n){e.beginPath(),e.ellipse(t,r,Math.max(.1,o),Math.max(.1,n),0,0,Math.PI*2);}function va(e,t,r,o,n,a,i,c,s){let l=o*.26;if(e.strokeStyle=Ie,e.lineWidth=l,c==="closed"){e.beginPath(),e.moveTo(t-o,r+n*.1),e.quadraticCurveTo(t,r+n*.55,t+o,r+n*.1),e.stroke(),i.eyes==="wide"&&Gr(e,t,r+n*.15,o,n*.3,a,l);return}if(c==="happy"){e.lineWidth=l*1.2,e.beginPath(),e.moveTo(t-o,r+n*.35),e.quadraticCurveTo(t,r-n*.75,t+o,r+n*.35),e.stroke();return}if(c==="hurt"){let E=t-a*o*.6,v=t+a*o*.8;e.lineWidth=l*1.2,e.beginPath(),e.moveTo(v,r-n*.55),e.lineTo(E,r),e.lineTo(v,r+n*.55),e.stroke();return}let h=o*s.white,m=n*s.white,p=i.eyes==="sleepy"?.32:0,y=Math.max(s.lidOuter,p),w=Math.max(s.lidInner,p),b=r-m,T=t+a*(h+l),k=t-a*(h+l),g=b+2*m*y,f=b+2*m*w,S=y>0||w>0;e.save(),S&&(e.beginPath(),e.moveTo(T,g),e.lineTo(k,f),e.lineTo(k,r+m*2),e.lineTo(T,r+m*2),e.closePath(),e.clip());let d=Math.min(h,m)*.8*s.iris,R=r+m*.12;switch(i.eyes){case "dot":{e.fillStyle=Ie,$(e,t,r+m*.1,h*.55,m*.72),e.fill(),e.fillStyle="#ffffff",$(e,t-h*.18,r-m*.18,h*.17,h*.17),e.fill();break}case "cat":{e.fillStyle="#ffffff",tr(e,t,r,h*1.08,m*.85,a),e.fill(),e.save(),tr(e,t,r,h*1.08,m*.85,a),e.clip(),e.fillStyle=i.eyeColor,$(e,t,R,d*1.05,d*1.2),e.fill(),e.fillStyle=Ie,$(e,t,R,d*.22*(s.iris<1?1.5:1),d*.95),e.fill(),e.fillStyle="#ffffff",$(e,t-d*.4,R-d*.45,d*.25,d*.25),e.fill(),e.restore(),e.strokeStyle=Ie,e.lineWidth=l,tr(e,t,r,h*1.08,m*.85,a),e.stroke();break}default:{let E=i.eyes==="sparkle"||i.eyes==="wide";e.fillStyle="#ffffff",$(e,t,r,h,m),e.fill(),e.save(),$(e,t,r,h,m),e.clip();let v=E?d*1.18:d;e.fillStyle=i.eyeColor,$(e,t,R,v*.95,v*(i.eyes==="sparkle"?1.15:1)),e.fill(),e.fillStyle="rgba(255,255,255,0.18)",$(e,t,R+v*.45,v*.7,v*.45),e.fill(),e.fillStyle=Ie,$(e,t,R,v*.48,v*.52),e.fill(),e.fillStyle="#ffffff",$(e,t-v*.38,R-v*.42,v*.32,v*.32),e.fill(),$(e,t+v*.38,R+v*.38,v*.14,v*.14),e.fill(),i.eyes==="sparkle"&&(Ra(e,t+v*.3,R-v*.55,v*.22),e.fill()),e.restore(),e.strokeStyle=Ie,e.lineWidth=l,e.beginPath(),e.ellipse(t,r,h,m,0,Math.PI*1.08,Math.PI*1.92),e.stroke();break}}if(e.restore(),S){e.strokeStyle=Ie,e.lineWidth=l;let E=L=>(L-T)/(k-T),v=L=>g+(f-g)*E(L),I=t-h*.95,C=t+h*.95;e.beginPath(),e.moveTo(I,v(I)),e.lineTo(C,v(C)),e.stroke();}i.eyes==="wide"&&Gr(e,t,r-m*.55,h,m*.45,a,l);}function tr(e,t,r,o,n,a){let i=t+a*o,c=t-a*o;e.beginPath(),e.moveTo(c,r+n*.15),e.quadraticCurveTo(t,r-n*1.5,i,r-n*.35),e.quadraticCurveTo(t,r+n*1.4,c,r+n*.15),e.closePath();}function Gr(e,t,r,o,n,a,i){e.lineWidth=i*.8;let c=t+a*o;for(let s=0;s<2;s++){let l=r+s*n*.6;e.beginPath(),e.moveTo(c-a*o*.1,l),e.lineTo(c+a*o*.35,l-n*(.7-s*.2)),e.stroke();}}function Ra(e,t,r,o){e.beginPath();for(let n=0;n<8;n++){let a=n%2?o*.35:o,i=n*Math.PI/4-Math.PI/2,c=t+Math.cos(i)*a,s=r+Math.sin(i)*a;n?e.lineTo(c,s):e.moveTo(c,s);}e.closePath(),e.fillStyle="#ffffff";}function Ea(e,t,r,o,n,a,i,c){if(i.brows==="none")return;let s=o*.095,l=r-n*c.browUp,h=t-a*s,m=t+a*s,p=l-n*c.browInner,y=l+n*c.browInner*.3;if(e.strokeStyle=i.browColor,e.fillStyle=i.browColor,i.brows==="thick"){let b=n*.06;e.beginPath(),e.moveTo(m,y),e.quadraticCurveTo(t,Math.min(y,p)-b*.6,h,p),e.lineTo(h,p+b),e.quadraticCurveTo(t,Math.min(y,p)+b*.5,m,y+b*.6),e.closePath(),e.fill();return}e.lineWidth=o*(i.brows==="arched"?.026:.032),e.beginPath(),e.moveTo(m,y);let w=i.brows==="arched"?n*.09:n*.035;e.quadraticCurveTo(t+a*s*.2,Math.min(y,p)-w,h,p),e.stroke();}function Sa(e,t,r,o,n,a,i){let c=o*.026;e.strokeStyle=Ke,e.lineWidth=c;let s=o*(a.mouth==="small"?.06:a.mouth==="grin"?.12:.09);switch(i){case "happy":{let l=Math.max(s,o*.1);e.fillStyle=Ke,e.beginPath(),e.moveTo(t-l,r-n*.06),e.quadraticCurveTo(t,r-n*.02,t+l,r-n*.06),e.quadraticCurveTo(t,r+n*.2,t-l,r-n*.06),e.closePath(),e.fill(),e.save(),e.clip(),e.fillStyle=jr,$(e,t,r+n*.1,l*.55,n*.06),e.fill(),a.mouth==="grin"&&(e.fillStyle="#ffffff",e.fillRect(t-l,r-n*.08,l*2,n*.045)),e.restore();return}case "surprised":e.fillStyle=Ke,$(e,t,r,o*.045,n*.085),e.fill();return;case "talk":e.fillStyle=Ke,$(e,t,r,Math.max(s*.7,o*.06),n*.07),e.fill(),e.save(),e.clip(),e.fillStyle=jr,$(e,t,r+n*.06,o*.045,n*.035),e.fill(),e.restore();return;case "sad":e.beginPath(),e.moveTo(t-s,r+n*.04),e.quadraticCurveTo(t,r-n*.07,t+s,r+n*.04),e.stroke();return;case "angry":e.beginPath(),e.moveTo(t-s,r+n*.01),e.quadraticCurveTo(t,r-n*.03,t+s,r+n*.01),e.stroke();return;case "scared":{e.beginPath();let l=4;for(let h=0;h<=l;h++){let m=t-s+2*s*h/l,p=r+(h%2?-1:1)*n*.022;h?e.lineTo(m,p):e.moveTo(m,p);}e.stroke();return}case "tired":e.beginPath(),e.moveTo(t-s*.6,r),e.lineTo(t+s*.6,r),e.stroke();return;case "hurt":{e.beginPath();let l=4;for(let h=0;h<=l;h++){let m=t-s+2*s*h/l,p=r+(h%2?-1:1)*n*.04;h?e.lineTo(m,p):e.moveTo(m,p);}e.stroke();return}}if(a.mouth==="cat"){e.beginPath(),e.moveTo(t-s,r-n*.03),e.quadraticCurveTo(t-s*.5,r+n*.06,t,r-n*.01),e.quadraticCurveTo(t+s*.5,r+n*.06,t+s,r-n*.03),e.stroke();return}if(a.mouth==="grin"){e.fillStyle=Ke,e.beginPath(),e.moveTo(t-s,r-n*.04),e.quadraticCurveTo(t,r-n*.01,t+s,r-n*.04),e.quadraticCurveTo(t,r+n*.12,t-s,r-n*.04),e.closePath(),e.fill(),e.save(),e.clip(),e.fillStyle="#ffffff",e.fillRect(t-s,r-n*.06,s*2,n*.04),e.restore();return}e.beginPath(),e.moveTo(t-s,r-n*.03),e.quadraticCurveTo(t,r+n*.06,t+s,r-n*.03),e.stroke();}var Yr=16;function Aa(e,t){if(typeof document<"u"){let r=document.createElement("canvas");return r.width=e,r.height=t,r}return new OffscreenCanvas(e,t)}var St=class{texture;g;w;h;face;current="neutral";base="neutral";constructor(t){this.face=t,this.w=Math.round(We[2]*Yr),this.h=Math.round(We[3]*Yr);let r=Aa(this.w,this.h),o=r.getContext("2d");if(!o)throw new Error("DrawnFace: no 2D canvas");this.g=o,this.texture=new O.CanvasTexture(r),this.texture.colorSpace=O.SRGBColorSpace,this.texture.anisotropy=4,this.paint("neutral");}paint(t){t!=="blink"&&t!=="talk"&&(this.base=t),this.current=t,Ur(this.g,this.w,this.h,this.face,t,this.base),this.texture.needsUpdate=true;}setFace(t){this.face=t,this.paint(this.current);}dispose(){this.texture.dispose();}};var ka={paths:[{x:243,y:-2,d:"M147.333 12.333c-13.6 2.534-12.533 1.2-12.933 15.067l-.4 12.267-4.533-11.067c-2.534-6-5.067-10.933-5.734-10.933-2.666 0-27.866 8.666-36.533 12.666-11.733 5.334-26.667 14.8-36.133 22.934l-6.934 5.866L51.6 69.267c8.133 11.066 7.333 11.466-5.067 2.933-7.6-5.067-8.4-5.333-11.466-3.733-3.467 1.866-18.4 17.333-20.4 21.2-.8 1.6 7.066 8.8 33.733 30.933l34.667 28.933 8.8-8.266c14.666-13.867 28.666-22 48.133-28.267 9.067-2.933 14.8-3.733 28.533-4.4 34.267-1.333 60 7.467 81.6 28.133 21.6 20.4 34.934 49.6 37.467 81.734l.8 11.2 14.8 4.533c8.133 2.533 23.733 7.333 34.667 10.8 10.933 3.333 20.4 5.6 21.066 4.933 1.6-1.6 6.134-20.533 7.734-32.666.8-6 1.333-17.6 1.066-25.6l-.4-14.667-8-1.067c-4.4-.533-10.133-1.466-12.666-1.866l-4.667-.8 4.667-1.2c16.933-4.534 18.666-5.2 18.666-8 0-5.467-9.6-31.334-16.666-44.8-4-7.6-10.667-18.667-14.934-24.667-9.866-13.867-31.333-35.467-45.2-45.2-10.4-7.467-34.4-20.933-37.2-21.067-.8 0-4 4-7.333 8.8-3.2 4.8-6.133 8.134-6.4 7.334s.4-5.6 1.6-10.667c1.2-5.2 2.133-9.6 2.133-9.867 0-.933-19.866-6.133-34.4-9.066-14.8-2.934-49.333-4.4-59.6-2.534"},{x:243,y:-2,d:"M157.867 125.533c-21.067 3.334-42.134 14.8-57.467 31.334-13.333 14.133-13.733 12.8 5.6 22 9.2 4.4 16.667 8.266 16.667 8.533s-1.334.4-2.934.133c-13.866-2.133-41.6-5.866-41.733-5.6-.267.267-7.467 28.534-16.267 63.067l-16 62.667 7.334.4c4 .266 7.466.266 7.6 0 .266-.267 3.866-13.867 8.133-30.4 4.267-16.534 8.267-30.8 8.933-31.734.934-1.2 11.067-1.6 42.4-1.6 32.134 0 41.2.4 41.2 1.6 0 .934-1.733 4.667-3.866 8.4L153.733 261l-35.066 6.933c-19.334 3.867-35.2 7.2-35.467 7.467-.667.667-29.867 113.467-29.467 113.867.267.133 23.734-3.6 52.4-8.534l52-8.8 20.4-39.866c11.2-22 20.667-39.734 20.934-39.467.4.533-1.334 26.8-2.8 40.8l-.667 6.933 6.267-3.2c21.2-10.666 52.4-13.466 86.933-8l5.867.934-5.6-7.334C286.4 318.6 281.2 310.6 278 304.867c-5.867-10.134-6-10.8-6-21.867 0-6.267 1.467-20 3.333-30.667 1.867-10.666 3.334-19.466 3.334-19.466 0-.134-9.067-4.267-20.134-9.334s-19.466-9.333-18.8-9.6c.8-.266 7.734.8 15.6 2.267 7.734 1.6 14.4 2.8 14.8 2.8 1.2 0 .4-10.533-1.466-18-7.2-27.733-28-53.467-53.734-66-16.4-8-40.8-12-57.066-9.467"},{x:243,y:-2,d:"M235.6 346.333c-24 4.534-44.133 13.867-68.267 31.467-14 10.267-28.533 18.133-47.733 25.867-23.467 9.466-52.8 32.666-64.4 50.666l-2.533 4L58 454.2c9.333-7.333 30.133-19.467 49.333-28.667C173.733 393.667 246.4 382.2 312.8 393c11.2 1.733 39.2 8.533 45.067 10.8 2.266.8 2.266.667.8-2.267-4-7.6-15.6-21.866-25.867-31.466-12-11.467-24.667-18.934-37.6-22.4-11.467-3.067-46.267-3.867-59.6-1.334"},{x:-460,y:467,d:"M721.533 34.467c-14.933 5.466-22 17.466-22.933 38.666-.933 24.134 3.467 32.8 30.267 59.867 19.6 19.867 22.933 25.2 22.933 37.867.133 13.466-6.133 20.133-16.933 18.4-9.067-1.467-12.534-7.867-12.534-22.667V159H696.6l.667 13.333c.533 11.467 1.2 14.4 4.933 22 7.067 14.267 16.8 19.6 36.4 19.734 10.667.133 12.267-.134 20.667-4.4 7.6-3.867 9.733-5.867 13.2-11.734 7.6-12.533 9.066-32 3.733-47.6-3.733-11.066-10.667-20.4-27.867-37.2-19.866-19.6-22.533-24.133-22.666-38.4 0-8.933.4-10.533 3.2-13.6 6.266-6.666 18.266-5.6 22.133 2 1.067 2 2 7.067 2 11.2v7.334h27.067l-.934-9.2c-1.6-18.267-8.266-30.267-20-36.4-7.2-3.867-29.2-4.8-37.6-1.6M630.067 34.867c-11.734 4.666-18 11.6-21.734 24.4-1.866 6.4-2 15.333-1.733 67.2l.4 59.866 3.733 7.6c6.8 13.867 18.534 20.267 36.934 20.267 13.733 0 22.933-3.333 30.666-11.067 10.934-11.066 11.2-12.533 11.734-74.666.266-35.734-.134-56.934-1.067-62.8-2.667-16.134-11.6-27.467-24.8-31.467-8.933-2.667-26.4-2.267-34.133.667m28.666 26.8 3.6 4v56.666c0 40.934-.4 57.467-1.6 60-3.6 8-15.6 9.734-22.666 3.467l-4.4-3.867-.4-56.533c-.267-51.733-.134-56.8 2-61.067 3.066-5.866 7.6-8.266 14.4-7.466 3.733.4 6.4 1.866 9.066 4.8M511.667 123.133v89.334l29.066-.4c28.8-.4 28.934-.4 36.667-4.267 9.467-4.533 14.4-10.933 17.467-22.4 2-7.333 2.266-15.467 1.866-65.733l-.4-57.334-4.266-8.8c-8.267-16.666-17.2-19.866-55.334-19.866h-25.066zm53.6-60.266 4.4 3.866.4 52.8c.266 35.067-.134 54.4-1.067 58-2 7.467-5.733 9.6-18.667 10.4l-10.666.8V59h10.666c9.867 0 10.934.267 14.934 3.867M471.667 145v67.333h26.666V77.667h-26.666zM471.667 48.333V63h26.666V33.667h-26.666z"},{x:-106,y:244,d:"M893.4 259.733c-6.8 3.467-9.2 5.6-12.667 11.467-10.666 17.733-9.2 42.933 3.467 62.267 2.8 4.266 12.267 14.8 20.933 23.333 9.867 9.467 17.067 17.733 18.934 21.6 5.6 11.333 5.2 25.333-.934 30.8-3.466 3.067-11.333 4.133-16.133 2.133-5.867-2.4-8-7.466-8-19.333v-10h-27.067l.8 11.6c1.2 15.867 3.867 24.133 10.267 31.333 7.467 8.534 16.4 12.134 30 12.267 19.067.133 30.133-5.733 37.333-19.867 3.734-7.466 4-8.666 4-24 0-16 0-16.133-5.2-26.666-4.4-9.2-7.733-13.2-23.066-28.534-21.067-21.066-24.8-27.066-24.934-40.4-.133-10.4 2.8-15.6 9.734-17.6 10.133-2.933 17.2 3.334 18.4 16.267l.8 8.267H955.4l-.8-10.8c-.533-8.4-1.6-12.667-4.8-19.2-7.067-14.134-16.667-19.334-36.133-19.334-10.667 0-12.534.4-20.267 4.4M791 346v89.333h76v-24h-48v-54.666h37.333v-24H819V282h48v-25.333h-76zM661.667 346v89.333h22.666l.134-63.066c0-34.534.533-61.734 1.066-60.267.534 1.467 5.467 29.867 10.8 62.933l9.867 60.4h13.067c7.2 0 13.066-.4 13.066-1.066 0-3.067 18.8-124.8 19.334-125.334.4-.4.666 27.867.666 62.8v63.6h25.334V256.667h-38l-9.2 61.6c-5.067 34-9.6 62.133-10 62.666-.534.534-5.334-26.4-10.667-60-5.467-33.466-10.133-61.733-10.533-62.666-.4-1.2-5.467-1.6-19.067-1.6h-18.533zM586.467 258.267c-.8 2.666-27.467 172.4-27.467 174.933 0 1.867 1.733 2.133 12 2.133h11.867l.8-4.4c.533-2.266 1.6-9.333 2.4-15.6l1.6-11.333 17.6-.4 17.466-.4 1.467 8.4c.8 4.667 1.733 11.867 2.267 16l.933 7.733h13.733c7.6 0 13.867-.266 13.867-.666 0-.8-26.533-168.134-27.467-173.734l-.8-4.266h-19.866c-14.8 0-20.134.4-20.4 1.6M613 336.533c3.333 23.067 5.867 42.134 5.6 42.4-.4.267-6.533.267-13.867.134l-13.2-.4 4.934-33.334c2.8-18.4 5.733-38.4 6.666-44.666C604.2 292.533 605 290.133 605.8 292c.533 1.467 3.867 21.467 7.2 44.533M497.267 257.2c-10.134 3.733-15.2 8.267-19.867 17.733L473 284l-.4 59.067c-.4 51.2-.133 60.133 1.733 66.533 5.6 19.333 17.067 27.333 39.467 27.467 10.267.133 12.267-.267 20.133-4.134 9.334-4.533 13.867-9.733 17.867-20.266 2-4.934 2.4-12 2.933-41.067l.534-34.933h-38.934v23.866l6.4.4 6.267.4v19.334c0 13.466-.533 20.666-1.867 23.733-5.066 12-23.333 10.4-26.8-2.4-.933-3.6-1.333-23.2-1.066-59.067.4-48.533.666-54.133 2.666-57.333 3.334-4.8 11.2-7.067 17.6-4.933 6.934 2.266 9.067 7.2 9.867 22.933l.667 13.067H555.4l-.8-15.734c-.8-18-3.067-25.6-9.867-33.466-7.466-8.8-13.466-11.2-29.066-11.734-9.067-.266-14.934.134-18.4 1.467"}]},Ta={helmet:{paths:[0,1,2],box:[258,10,353,447]},wordmark:{paths:[3,4],box:[12,499,837,182]}},Ca={"top.idos":{color:"#f8f8fc",faces:["front","back"],layers:[{art:"helmet",y:19.4,z:2.3,height:3.9},{art:"wordmark",y:14.85,z:2.15,width:6.2}]}},$r=512,Wr=.02,qr=new Map;function Ma(e,t){if(typeof document<"u"){let r=document.createElement("canvas");return r.width=e,r.height=t,r}return new OffscreenCanvas(e,t)}function Ia(e,t,r){let o=`${e}:${r}`,n=qr.get(o);if(n)return n;if(typeof Path2D>"u")return null;let[a,i,c,s]=t.box,l=s*Wr,h=$r/(s+2*l),m=Ma(Math.round((c+2*l)*h),$r),p=m.getContext("2d");if(!p)return null;p.clearRect(0,0,m.width,m.height),p.fillStyle=r;for(let w of t.paths){let b=ka.paths[w];p.setTransform(h,0,0,h,(b.x-a+l)*h,(b.y-i+l)*h),p.fill(new Path2D(b.d));}let y=new O.CanvasTexture(m);return y.colorSpace=O.SRGBColorSpace,y.anisotropy=4,qr.set(o,y),y}function rr(e){let t=[];for(let r of Ce){let o=e.wear[r],n=o?Ca[o]:void 0;if(n)for(let a of n.layers){let i=Ta[a.art],c=Ia(a.art,i,n.color);if(!c)continue;let[,,s,l]=i.box,h=s/l,m=a.height??(a.width??1)/h,p=a.width??m*h,y=2*Wr*m;for(let w of n.faces){let b=(w==="front"?-1:1)*(a.z+.03),T=[0,a.y,b];t.push({bone:"body",center:T,w:p+y,h:m+y,facing:w,texture:c});}}}return t}var Tt=class extends xt{face;rest;mood="neutral";constructor(t,r,o={}){let n=new St(t.face);super(er(t,r),{gloss:true,shadows:true,...o,facePainter:n}),this.face=n,this.rest=t.face.emotion,this.view.setPrints(rr(t)),this.applyMood();}setEmotion(t){this.mood=t,this.applyMood();}setAvatar(t,r){this.face.setFace(t.face),this.rest=t.face.emotion,this.setSpec(er(t,r)),this.view.setPrints(rr(t)),this.applyMood();}applyMood(){super.setEmotion(this.mood==="neutral"?this.rest:this.mood),this.animator.moodOverGestures=this.rest!=="neutral";}dispose(){super.dispose(),this.face.dispose();}};var La=1.12,_a=.25,Kr=1.6;function Xr(e){e.outputColorSpace=O.SRGBColorSpace,e.toneMapping=O.NeutralToneMapping,e.toneMappingExposure=La,e.shadowMap.enabled=true,e.shadowMap.type=O.PCFShadowMap;let t=new O.PMREMGenerator(e),r=new RoomEnvironment,o=t.fromScene(r,.04).texture;return r.dispose(),t.dispose(),{light(n){n.environment=o,n.environmentIntensity=_a,n.add(new O.HemisphereLight(14543103,8019024,.6));let a=new O.DirectionalLight(16772829,3.4);a.position.set(4,4.4,-2.2),a.castShadow=true;let i=a.shadow.camera;i.left=i.bottom=-Kr,i.right=i.top=Kr,i.near=.5,i.far=12,a.shadow.mapSize.set(1024,1024),a.shadow.bias=-5e-4,a.shadow.normalBias=.02,a.shadow.radius=4,a.shadow.intensity=.55,a.target.position.set(0,1,0),n.add(a,a.target);let c=new O.DirectionalLight(13623551,.45);c.position.set(-3,.8,-3),n.add(c);let s=new O.DirectionalLight(14478591,2.6);s.position.set(-3.2,2.6,2.6),n.add(s);},dispose(){o.dispose();}}}var ul=["#a99cff","#5b4bd6"];function Oa(e,t){switch(t){case "full":return {center:new O.Vector3(0,e*.5,0),size:e*1.12,lift:.04};case "torso":return {center:new O.Vector3(0,e*.57,0),size:e*.5,lift:.06};case "legs":return {center:new O.Vector3(0,e*.2,0),size:e*.5,lift:.1};case "feet":return {center:new O.Vector3(0,e*.08,0),size:e*.32,lift:.3};case "face":return {center:new O.Vector3(0,e*.86,0),size:e*.34,lift:.04};case "head":return {center:new O.Vector3(0,e*.88,0),size:e*.5,lift:.08};default:return {center:new O.Vector3(0,e*.8,0),size:e*.56,lift:.08}}}function za(e){return typeof e=="number"?e:e==="side"?Math.PI/2:e==="back"?Math.PI:.18}function Jr(e,t,r,o,n,a,i){let c=i.frame??"portrait",s={...n,face:{...n.face,emotion:"neutral"}},l=new Tt(s,a,{seed:7});try{e.setClearColor(0,0);let h=new O.Scene;t.light(h),l.group.rotation.y=za(i.view),h.add(l.group);for(let S=0;S<20;S++)l.update(1/30);l.view.setExpression(i.expression??n.face.emotion);let{center:m,size:p,lift:y}=Oa(l.height,c),w=28,b=new O.PerspectiveCamera(w,1,.05,50),T=p/2/Math.tan(O.MathUtils.degToRad(w/2));b.position.set(m.x,m.y+p*y,m.z-T),b.lookAt(m),e.render(h,b);let k=document.createElement("canvas");k.width=o,k.height=o;let g=k.getContext("2d");if(!g)return r;let f=i.background;if(typeof f=="string")g.fillStyle=f,g.fillRect(0,0,o,o);else if(f){let S=g.createRadialGradient(o*.5,o*.38,o*.05,o*.5,o*.5,o*.72);S.addColorStop(0,f[0]),S.addColorStop(1,f[1]),g.fillStyle=S,g.fillRect(0,0,o,o);}return g.imageSmoothingEnabled=!i.pixelated,g.drawImage(r,0,0),k}finally{l.dispose();}}function Zr(e,t){let r=document.createElement("canvas");r.width=e,r.height=e;let o=new O.WebGLRenderer({canvas:r,antialias:!t,alpha:true,preserveDrawingBuffer:true});return o.setPixelRatio(1),o.setSize(e,e,false),{renderer:o,lighting:Xr(o),gl:r}}function Qr(e){e.lighting.dispose(),e.renderer.dispose(),e.renderer.forceContextLoss();}function Fa(e,t,r={}){let o=Math.max(16,Math.round(r.size??256)),n=Zr(o,!!r.pixelated);try{return Jr(n.renderer,n.lighting,n.gl,o,e,t,r)}finally{Qr(n);}}function eo(e={}){let t=Math.max(16,Math.round(e.size??256)),r=Zr(t,!!e.pixelated);return {render(o,n,a={}){if(!r)throw new Error("snapshotter disposed");return Jr(r.renderer,r.lighting,r.gl,t,o,n,{...a,pixelated:e.pixelated})},dispose(){r&&(Qr(r),r=null);}}}function bl(e,t,r={}){let o=Fa(e,t,r);return new Promise(n=>o.toBlob(a=>n(a),"image/png"))}function yl(e){if(!e?.spec)return null;let t={};for(let r of e.items??[])r&&typeof r.id=="string"&&(t[r.id]=r);return {spec:Rt(e.spec),items:t}}function re(e){let t=Et(e);if(!t.ok)throw new Error(`avatar shop: ${String(e.id)}: ${t.errors.join("; ")}`);return t.item}var or=e=>({w:e[0].length,h:e.length,rows:e}),Na={bone:"head",size:[9.21,2.05,8.73],pos:[0,29.91,0],color:"a"},Ha={bone:"head",size:[9.21,1.7,.73],pos:[0,28.72,-4.36],color:"a"},to=[{price:250,item:re({id:"hat.crown",slot:"hat",name:"Crown",palette:{a:"#e8b730",g:"#d23c4a"},tint:"a",parts:[{bone:"head",size:[9.21,1.7,.73],pos:[0,30.93,-4.36],color:"a"},{bone:"head",size:[9.21,1.7,.73],pos:[0,30.93,4.36],color:"a"},{bone:"head",size:[.71,1.7,8.73],pos:[4.6,30.93,0],color:"a",mirror:true},{bone:"head",size:[1.13,1.36,.73],pos:[2.98,32.47,-4.36],color:"a",mirror:true},{bone:"head",size:[1.13,1.77,.73],pos:[0,32.67,-4.36],color:"a"},{bone:"head",size:[.99,.95,.29],pos:[0,30.93,-4.87],color:"g"}]})},{price:250,item:re({id:"back.wings",slot:"back",name:"Angel wings",palette:{a:"#f7f5ff",b:"#d9d4f2"},tint:"a",parts:[{bone:"body",size:[2.25,7.5,1.47],pos:[1.69,21.15,3.04],color:"b",mirror:true},{bone:"body",size:[10.13,3.13,.74],pos:[7.31,26.15,3.86],color:"a",mirror:true},{bone:"body",size:[10.13,3.13,.74],pos:[7.88,23.03,4.05],color:"b",mirror:true},{bone:"body",size:[9,3.13,.74],pos:[8.44,19.9,4.23],color:"a",mirror:true},{bone:"body",size:[6.75,3.13,.74],pos:[9,16.77,4.42],color:"b",mirror:true},{bone:"body",size:[4.5,3.13,.74],pos:[9.56,13.65,4.6],color:"a",mirror:true},{bone:"body",size:[3.38,1.88,.74],pos:[11.25,28.65,3.86],color:"a",mirror:true}]})},{price:200,item:re({id:"hat.wizard",slot:"hat",name:"Wizard hat",palette:{a:"#3c2f8f",s:"#f2c14e"},tint:"a",parts:[{bone:"head",size:[10.63,.55,10.18],pos:[0,30.39,0],color:"a"},{bone:"head",size:[8.5,1.77,8],pos:[0,31.55,0],color:"a"},{bone:"head",size:[6.38,1.77,5.82],pos:[0,33.32,.36],color:"a"},{bone:"head",size:[4.25,1.77,4],pos:[0,35.09,.73],color:"a"},{bone:"head",size:[2.13,1.64,2.18],pos:[0,36.8,1.09],color:"a"},{bone:"head",size:[1.13,1.09,.29],pos:[0,31.61,-4.15],color:"s"}]})},{price:200,item:re({id:"top.armor",slot:"top",name:"Knight armor",palette:{a:"#b8c2cc",b:"#5b6672",g:"#e8b730"},tint:"a",paint:[{region:"torso",color:"b"},{region:"arms",color:"b"}],parts:[{bone:"body",size:[9.67,7.5,.74],pos:[0,18.65,-2.67],color:"a"},{bone:"armR",size:[4.32,2.94,4.32],pos:[6.3,22.38,0],color:"a",mirror:true},{bone:"body",size:[2.25,2.5,.37],pos:[0,19.27,-3.22],color:"g"}]})},{price:200,item:re({id:"back.sword",slot:"back",name:"Sword",palette:{a:"#d8dde4",g:"#e8b730",h:"#5a3a22"},tint:"g",parts:[{bone:"body",size:[1.35,12.5,.55],pos:[2.81,17.4,3.04],color:"a"},{bone:"body",size:[4.5,1.13,.92],pos:[2.81,24.21,3.04],color:"g"},{bone:"body",size:[1.01,3.75,.83],pos:[2.81,26.65,3.04],color:"h"},{bone:"body",size:[1.58,1.5,1.1],pos:[2.81,29.28,3.04],color:"g"}]})},{price:150,item:re({id:"hat.headphones",slot:"hat",name:"Headphones",palette:{a:"#2b2140",b:"#4be0c8"},tint:"b",parts:[{bone:"head",size:[9.63,.82,1.45],pos:[0,31.07,0],color:"a"},{bone:"head",size:[.57,3.41,.87],pos:[4.89,29.57,0],color:"a",mirror:true},{bone:"head",size:[1.13,2.45,2.62],pos:[4.96,27.39,0],color:"a",mirror:true},{bone:"head",size:[.28,1.64,1.75],pos:[5.6,27.39,0],color:"b",mirror:true}]})},{price:150,item:re({id:"hair.mohawk",slot:"hair",name:"Mohawk",palette:{a:"#d4537e"},tint:"a",parts:[{bone:"head",size:[1.84,3.07,8],pos:[0,31.78,0],color:"a"},{bone:"head",size:[1.84,2.05,1.45],pos:[0,31.27,-4.73],color:"a"},{bone:"head",size:[2.13,4.09,.73],pos:[0,28.2,4.36],color:"a"}]})},{price:150,item:re({id:"top.suit",slot:"top",name:"Suit and tie",palette:{a:"#2c2f3a",w:"#f4f1ea",r:"#c0392b"},tint:"a",textures:{front:or(["awwrrwwa","aawrrwaa","aaarraaa","aaarraaa","aaarraaa","aaaaaaaa","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"front"}},{region:"arms",color:"a"}],parts:[{bone:"body",size:[1.35,1,.28],pos:[-2.92,19.9,-2.44],color:"w"}]})},{price:120,item:re({id:"hair.ponytail",slot:"hair",name:"Ponytail",palette:{a:"#3b2a20",b:"#d4537e"},tint:"a",parts:[Na,Ha,{bone:"head",size:[.71,3.41,7.27],pos:[4.6,27.86,.36],color:"a",mirror:true},{bone:"head",size:[9.21,4.77,.73],pos:[0,27.18,4.36],color:"a"},{bone:"head",size:[2.27,1.02,1.75],pos:[0,28.55,4.95],color:"b"},{bone:"head",size:[1.84,5.45,1.45],pos:[0,25.82,5.09],color:"a"}]})},{price:120,item:re({id:"face.visor",slot:"faceAcc",name:"Cyber visor",palette:{a:"#33e0ff",b:"#1d1d21"},tint:"a",parts:[{bone:"head",size:[7.79,1.77,.36],pos:[0,25.89,-4.29],color:"a"},{bone:"head",size:[.35,1.02,1.89],pos:[4.07,26.16,-3.27],color:"b",mirror:true}]})},{price:100,item:re({id:"shoes.hightops",slot:"shoes",name:"High-tops",palette:{a:"#7f77dd",w:"#f4f1ea",b:"#2b2140"},tint:"a",textures:{toe:or(["aaaa","wwww"]),side:or(["aaaaa","wwwww"])},paint:[{region:"feet",color:"a",faces:{front:"toe",back:"toe",left:"side",right:"side",bottom:"w"}}],parts:[{bone:"shinR",size:[4.62,4.32,4.62],pos:[2.1,3.76,0],color:"b",mirror:true}]})},{price:50,item:re({id:"hands.gauntlets",slot:"hands",name:"Golden gauntlets",palette:{a:"#e8b730",b:"#b8862a"},tint:"a",paint:[{region:"hands",color:"a"}],parts:[{bone:"foreArmR",size:[4.32,1.75,4.32],pos:[6.3,13.78,0],color:"b",mirror:true}]})},{price:50,item:re({id:"waist.pouch",slot:"waist",name:"Belt pouch",palette:{a:"#3a2a22",b:"#7a5233"},tint:"b",parts:[{bone:"body",size:[9.45,1.25,4.97],pos:[0,13.15,0],color:"a"},{bone:"body",size:[2.7,2.5,1.29],pos:[2.93,11.9,-3.04],color:"b"}]})}],ro=to.map(e=>e.item),nr=Object.fromEntries(to.map(e=>[e.item.id,e.price])),oo=e=>Object.prototype.hasOwnProperty.call(nr,e);function F(e){let t=Et(e);if(!t.ok)throw new Error(`avatar catalog: ${String(e.id)}: ${t.errors.join("; ")}`);return t.item}var Pe=e=>({w:e[0].length,h:e.length,rows:e}),Xe={bone:"head",size:[9.21,2.05,8.73],pos:[0,29.91,0],color:"a"},ar={bone:"head",size:[.71,1.7,2.8],pos:[4.5,28.72,-2.9],color:"a",mirror:true},Je={bone:"head",size:[9.21,1.7,.73],pos:[0,28.72,-4.36],color:"a"},Da=[F({id:"hair.short",slot:"hair",name:"Short",palette:{a:"#3b2a20"},tint:"a",parts:[Xe,Je,ar,{bone:"head",size:[.71,3.41,7.58],pos:[4.6,27.86,.51],color:"a",mirror:true},{bone:"head",size:[9.21,4.77,.73],pos:[0,27.18,4.36],color:"a"}]}),F({id:"hair.bob",slot:"hair",name:"Bob",palette:{a:"#3b2a20"},tint:"a",parts:[Xe,Je,{bone:"head",size:[1.06,6.13,8.6],pos:[4.78,26.84,.3],color:"a",mirror:true},{bone:"head",size:[9.21,6.14,1.09],pos:[0,26.5,4.55],color:"a"}]}),F({id:"hair.spiky",slot:"hair",name:"Spiky",palette:{a:"#3b2a20"},tint:"a",parts:[Xe,Je,{bone:"head",size:[.71,2.73,8.6],pos:[4.6,28.2,0],color:"a",mirror:true},{bone:"head",size:[9.21,2.73,.73],pos:[0,28.2,4.36],color:"a"},{bone:"head",size:[2.13,2.05,2.18],pos:[2.83,31.61,-0.73],color:"a",mirror:true},{bone:"head",size:[2.13,2.73,2.18],pos:[0,31.95,-0.73],color:"a"},{bone:"head",size:[2.13,2.05,2.18],pos:[-1.42,31.61,2.18],color:"a"},{bone:"head",size:[2.13,2.05,2.18],pos:[1.77,31.75,1.82],color:"a"}]}),F({id:"hair.long",slot:"hair",name:"Long",palette:{a:"#3b2a20"},tint:"a",parts:[Xe,Je,ar,{bone:"head",size:[1.06,6.82,7.88],pos:[4.78,26.16,.66],color:"a",mirror:true},{bone:"head",size:[9.21,7.5,1.09],pos:[0,26.16,4.55],color:"a"}]}),F({id:"hair.bun",slot:"hair",name:"Bun",palette:{a:"#3b2a20"},tint:"a",parts:[Xe,Je,ar,{bone:"head",size:[.71,2.73,6.48],pos:[4.6,28.2,1.06],color:"a",mirror:true},{bone:"head",size:[9.21,4.09,.73],pos:[0,27.52,4.36],color:"a"},{bone:"head",size:[4.25,3.41,3.64],pos:[0,32.64,1.82],color:"a"}]}),F({id:"hair.curly",slot:"hair",name:"Curly",palette:{a:"#3b2a20"},tint:"a",parts:[{bone:"head",size:[9.92,2.39,9.45],pos:[0,30.08,0],color:"a"},{bone:"head",size:[9.21,1.36,.73],pos:[0,28.89,-4.8],color:"a"},{bone:"head",size:[2.83,2.73,2.91],pos:[3.54,28.89,-2.55],color:"a",mirror:true},{bone:"head",size:[2.83,2.73,2.91],pos:[3.54,28.89,1.82],color:"a",mirror:true},{bone:"head",size:[5.67,2.05,5.82],pos:[0,31.61,0],color:"a"},{bone:"head",size:[4.25,4.27,2.18],pos:[2.13,27.27,4],color:"a",mirror:true}]})],Ba=[F({id:"top.idos",slot:"top",name:"iDos Games tee",palette:{a:"#1565ff"},tint:null,paint:[{region:"torso",color:"a"},{region:"sleeves",color:"a"}]}),F({id:"top.tee",slot:"top",name:"Star tee",palette:{a:"#1d9e75",b:"#f4f1ea"},tint:"a",textures:{print:Pe(["aaaaaaaa","aaabbaaa","aabbbbaa","abbbbbba","aabbbbaa","aabaabaa","aaaaaaaa","aaaaaaaa"])},paint:[{region:"torso",color:"a",faces:{front:"print"}},{region:"sleeves",color:"a"}]}),F({id:"top.hoodie",slot:"top",name:"Hoodie",palette:{a:"#378add",b:"#24578f",w:"#f0f0f0"},tint:"a",paint:[{region:"torso",color:"a"},{region:"arms",color:"a"}],parts:[{bone:"body",size:[7.88,4.38,1.84],pos:[0,21.78,3.04],color:"a"},{bone:"body",size:[5.63,2.5,.46],pos:[0,15.52,-2.53],color:"b"},{bone:"body",size:[.56,2.75,.37],pos:[1.24,19.65,-2.48],color:"w",mirror:true}]}),F({id:"top.stripes",slot:"top",name:"Striped sweater",palette:{a:"#d4537e",b:"#f4f1ea"},tint:"a",textures:{st:Pe(["aaaaaaaa","aaaaaaaa","bbbbbbbb","aaaaaaaa","aaaaaaaa","bbbbbbbb","aaaaaaaa","aaaaaaaa"]),sl:Pe(["aaa","bbb","aaa","bbb","aaa"])},paint:[{region:"torso",color:"a",faces:{front:"st",back:"st",left:"st",right:"st"}},{region:"arms",color:"a",faces:{front:"sl",back:"sl",left:"sl",right:"sl"}}]}),F({id:"top.jacket",slot:"top",name:"Jacket",palette:{a:"#444441",b:"#f4f1ea",c:"#c8c2b4"},tint:"a",textures:{open:Pe(["aaabbaaa","aaabbaaa","aaabbaaa","aaabbaaa","aaabbaaa","aacbbcaa","aaabbaaa","aaabbaaa"])},paint:[{region:"torso",color:"a",faces:{front:"open"}},{region:"arms",color:"a"}],parts:[{bone:"body",size:[3.38,1.5,.92],pos:[2.48,22.53,-2.21],color:"a",mirror:true}]}),F({id:"top.tank",slot:"top",name:"Tank top",palette:{a:"#ef9f27"},tint:"a",paint:[{region:"torso",color:"a"}]})],Va=[F({id:"bottom.jeans",slot:"bottom",name:"Jeans",palette:{a:"#2f5fd0",b:"#24489e"},tint:"a",textures:{seam:Pe(["aaab","aaab","aaab","aaab","aaab"])},paint:[{region:"legs",color:"a",faces:{front:"seam"}}]}),F({id:"bottom.shorts",slot:"bottom",name:"Shorts",palette:{a:"#5f6b7a",s:"@skin"},tint:"a",paint:[{region:"legs",color:"s"}],parts:[{bone:"legR",size:[4.62,5.4,4.62],pos:[2.1,9.7,0],color:"a",mirror:true}]}),F({id:"bottom.skirt",slot:"bottom",name:"Skirt",palette:{a:"#7f77dd",s:"@skin"},tint:"a",paint:[{region:"legs",color:"s"}],parts:[{bone:"body",size:[10.13,4.38,5.52],pos:[0,11.46,0],color:"a"}]}),F({id:"bottom.cargo",slot:"bottom",name:"Cargo pants",palette:{a:"#6b6b4a",b:"#55553a"},tint:"a",paint:[{region:"legs",color:"a"}],parts:[{bone:"legR",size:[.84,4.32,2.52],pos:[4.62,7,0],color:"b",mirror:true}]})],ja=[F({id:"shoes.sneakers",slot:"shoes",name:"Sneakers",palette:{a:"#d84a30",w:"#f4f1ea"},tint:"a",textures:{toe:Pe(["aaaa","wwww"]),side:Pe(["aaaaa","wwwww"])},paint:[{region:"feet",color:"a",faces:{front:"toe",back:"toe",left:"side",right:"side",bottom:"w"}}]}),F({id:"shoes.boots",slot:"shoes",name:"Boots",palette:{a:"#5a3a22",b:"#3a2414"},tint:"a",paint:[{region:"feet",color:"a",faces:{bottom:"b"}}],parts:[{bone:"shinR",size:[4.83,4.32,4.83],pos:[2.1,3.76,0],color:"a",mirror:true}]}),F({id:"shoes.sandals",slot:"shoes",name:"Sandals",palette:{a:"#b0773a",s:"@skin"},tint:"a",paint:[{region:"feet",color:"s"}],parts:[{bone:"shinR",size:[4.51,.48,5.57],pos:[2.1,.24,-0.53],color:"a",mirror:true},{bone:"shinR",size:[4.51,.4,1.05],pos:[2.1,1.12,-1.89],color:"a",mirror:true}]})],Ga=[F({id:"hands.gloves",slot:"hands",name:"Gloves",palette:{a:"#2b2140"},tint:"a",paint:[{region:"hands",color:"a"}]})],Ua=[F({id:"waist.belt",slot:"waist",name:"Belt",palette:{a:"#5a3a22",g:"#d8b030"},tint:"a",parts:[{bone:"body",size:[9.45,1.25,4.97],pos:[0,13.15,0],color:"a"},{bone:"body",size:[1.8,1.5,.37],pos:[0,13.15,-2.67],color:"g"}]})],Ya=[F({id:"back.backpack",slot:"back",name:"Backpack",palette:{a:"#c0612b",b:"#8a3f18"},tint:"a",parts:[{bone:"body",size:[6.75,8.75,2.76],pos:[0,17.4,3.68],color:"a"},{bone:"body",size:[4.5,3.75,.55],pos:[0,14.9,5.34],color:"b"}]}),F({id:"back.cape",slot:"back",name:"Cape",palette:{a:"#a32d2d"},tint:"a",parts:[{bone:"body",size:[10.13,12.5,.55],pos:[0,16.15,2.67],color:"a"}]})],$a=[F({id:"face.glasses",slot:"faceAcc",name:"Round glasses",palette:{a:"#2b2140"},tint:"a",parts:[{bone:"head",size:[2.41,.27,.29],pos:[1.56,26.84,-4.29],color:"a",mirror:true},{bone:"head",size:[2.41,.27,.29],pos:[1.56,24.73,-4.29],color:"a",mirror:true},{bone:"head",size:[.28,2.39,.29],pos:[2.9,25.78,-4.29],color:"a",mirror:true},{bone:"head",size:[1.13,.27,.29],pos:[0,26.3,-4.29],color:"a"}]}),F({id:"face.shades",slot:"faceAcc",name:"Sunglasses",palette:{a:"#1d1d21"},tint:"a",parts:[{bone:"head",size:[2.55,1.64,.29],pos:[1.56,25.89,-4.29],color:"a",mirror:true},{bone:"head",size:[6.23,.34,.29],pos:[0,26.77,-4.29],color:"a"}]})],qa=[F({id:"hat.beanie",slot:"hat",name:"Beanie",palette:{a:"#534ab7",w:"#f4f1ea"},tint:"a",parts:[{bone:"head",size:[9.92,3.07,9.45],pos:[0,30.76,0],color:"a"},{bone:"head",size:[10.34,1.36,9.89],pos:[0,29.3,0],color:"a"},{bone:"head",size:[2.13,2.05,2.18],pos:[0,33.18,0],color:"w"}]}),F({id:"hat.cap",slot:"hat",name:"Cap",palette:{a:"#c0392b"},tint:"a",parts:[{bone:"head",size:[9.63,2.73,9.16],pos:[0,30.8,.15],color:"a"},{bone:"head",size:[7.79,.55,3.64],pos:[0,29.57,-5.96],color:"a"}]}),F({id:"hat.bucket",slot:"hat",name:"Bucket hat",palette:{a:"#c8b88a"},tint:"a",parts:[{bone:"head",size:[9.63,2.73,9.16],pos:[0,31.61,0],color:"a"},{bone:"head",size:[11.33,.55,10.91],pos:[0,30.39,0],color:"a"}]})],Ct=[...Da,...Ba,...Va,...ja,...Ga,...Ua,...Ya,...$a,...qa,...ro],El=Object.fromEntries(Ct.map(e=>[e.id,e]));function Wa(e){return Ct.filter(t=>t.slot===e)}function no(e){return Wa(e).filter(t=>!oo(t.id))}var Ka=["#f9e0cf","#f2c9a0","#e2ad80","#c88d62","#9c6844","#6e4a32"],Xa=["#3b2a20","#1d1d21","#f2c14e","#c0612b","#ece6da","#7f77dd","#d4537e","#2ab0a0"],Ja=["#3b2a20","#2f5fd0","#1d9e75","#7f77dd","#c0392b","#d8b030"],Za=["#1d9e75","#378add","#d4537e","#444441","#ef9f27","#534ab7","#c0392b","#e8e4da"],so={version:Te,style:ne,body:{skin:"#f2c9a0",height:1},face:{eyes:"round",eyeColor:"#3b2a20",brows:"soft",browColor:"#3b2a20",mouth:"smile",cheeks:true,emotion:"neutral"},wear:{hair:"hair.short",top:"top.idos",bottom:"bottom.jeans",shoes:"shoes.sneakers"},tint:{}},ao={hair:.92,top:1,bottom:1,shoes:1,hands:.1,waist:.2,back:.2,faceAcc:.25,hat:.35};function Tl(e=Math.random){let t=a=>a[Math.floor(e()*a.length)],r=t(Xa),o={},n={};for(let a of Object.keys(ao)){if(e()>=ao[a])continue;let i=no(a);i.length&&(o[a]=t(i).id,n[a]=a==="hair"?r:t(Za));}return {version:Te,style:ne,body:{skin:t(Ka),height:.95+e()*.1},face:{eyes:t(Ye),eyeColor:t(Ja),brows:t($e),browColor:r==="#ece6da"||r==="#f2c14e"?"#8a6a3a":r,mouth:t(qe),cheeks:e()<.6,emotion:"neutral"},wear:o,tint:n}}var Qa={hair:{frame:"portrait",view:.5},hat:{frame:"head",view:.35},faceAcc:{frame:"portrait",view:.2},top:{frame:"torso",view:.3},waist:{frame:"torso",view:.3},hands:{frame:"torso",view:.55},bottom:{frame:"legs",view:.3},shoes:{frame:"feet",view:.6},back:{frame:"full",view:Math.PI-.6}},es=["hair","top","bottom","shoes"];function ts(e,t){let r=Rt(JSON.parse(JSON.stringify(so)));for(let o of Object.keys(r.wear))es.includes(o)||delete r.wear[o];return r.tint={},r.wear[e]=t,r}function Ll(e,t){return {key:`item:${e.id}`,make:()=>({spec:ts(e.slot,e.id),items:{...t,[e.id]:e},opts:Qa[e.slot]})}}function _l(e={}){let t=e.size??224,r=e.limit??800,o=e.budgetMs??14,n=new Map,a=new Map,i=[],c=null,s=false,l=(p,y)=>{for(n.delete(p),n.set(p,y);n.size>r;){let w=n.keys().next().value;URL.revokeObjectURL(n.get(w)),n.delete(w);}},h=()=>{if(s)return;s=true;let p=globalThis.requestIdleCallback;p?p(m,{timeout:120}):setTimeout(m,16);};function m(){s=false;let p=performance.now();for(;i.length&&performance.now()-p<o;){let y=i.shift(),w=a.get(y);if(w&&(a.delete(y),w.listeners.size!==0))try{c??=eo({size:t});let{spec:b,items:T,opts:k}=w.make(),g=c.render(b,T,k),f=[...w.listeners];g.toBlob(S=>{if(!S)return;let d=URL.createObjectURL(S);l(y,d);for(let R of f)R(d);},"image/png");}catch{c?.dispose(),c=null;}}i.length&&h();}return {peek:p=>n.get(p)??null,request(p,y){let w=n.get(p.key);if(w)return l(p.key,w),y(w),()=>{};let b=a.get(p.key);b||(b={make:p.make,listeners:new Set},a.set(p.key,b),i.push(p.key)),b.listeners.add(y),h();let T=b;return ()=>T.listeners.delete(y)},release(){c?.dispose(),c=null;}}}var rs="voxel-avatar-v1";function Bl(){return {standard:rs,style:ne,version:Te,slots:[...Ce],eyes:[...Ye],brows:[...$e],mouths:[...qe],emotions:[...a$1],height:{min:Ue.min,max:Ue.max},items:[...Ct],shop:{...nr},rules:{slots:{...Zt},limits:{...Me},regions:[...Xt],regionPairs:Object.fromEntries(Object.entries(Jt).map(([e,t])=>[e,[...t]])),faces:[...be],skinColor:ke}}}var os=(e,t,r)=>"#"+[e,t,r].map(o=>Math.max(0,Math.min(255,Math.round(o))).toString(16).padStart(2,"0")).join("");function ns(e,t,r){let o=[];for(let n=0;n<r;n++)for(let a=0;a<t;a++){let i=Math.floor(a*e.width/t),c=Math.max(i+1,Math.floor((a+1)*e.width/t)),s=Math.floor(n*e.height/r),l=Math.max(s+1,Math.floor((n+1)*e.height/r)),h=0,m=0,p=0,y=0,w=0;for(let b=s;b<l;b++)for(let T=i;T<c;T++){let k=(b*e.width+T)*4;w++,!((e.data[k+3]??0)<128)&&(h+=e.data[k]??0,m+=e.data[k+1]??0,p+=e.data[k+2]??0,y++);}o.push(y*2<w?null:[h/y,m/y,p/y]);}return o}var Ze=(e,t)=>(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2;function Gl(e,t){let r=Me.textureSide,n=Math.min(1,16/Math.max(e.width,e.height,1)),a=Math.max(1,Math.min(r,Math.round(t.w??e.width*n))),i=Math.max(1,Math.min(r,Math.round(t.h??e.height*n))),c=[...new Set(t.symbols)].slice(0,Me.palette);if(!c.length)throw new Error("pixelTextureFromImage: no palette symbols to use");let s=ns(e,a,i),l=s.filter(b=>!!b),h=new Map;for(let b of l){let T=b.map(g=>Math.round(g/8)).join(","),k=h.get(T);k?k.n++:h.set(T,{n:1,c:b});}let m=[...h.values()].sort((b,T)=>T.n-b.n||(b.c.join()<T.c.join()?-1:1)),p=[];for(let b of m){if(p.length>=c.length)break;p.every(T=>Ze(T,b.c)>576)&&p.push([...b.c]);}!p.length&&m[0]&&(p=[[...m[0].c]]);for(let b=0;b<8&&p.length;b++){let T=p.map(()=>[0,0,0,0]);for(let k of l){let g=0;for(let S=1;S<p.length;S++)Ze(k,p[S])<Ze(k,p[g])&&(g=S);let f=T[g];f[0]+=k[0],f[1]+=k[1],f[2]+=k[2],f[3]+=1;}p=p.map((k,g)=>{let f=T[g];return f[3]?[f[0]/f[3],f[1]/f[3],f[2]/f[3]]:k});}let y={};p.forEach((b,T)=>y[c[T]]=os(b[0],b[1],b[2]));let w=[];for(let b=0;b<i;b++){let T="";for(let k=0;k<a;k++){let g=s[b*a+k];if(!g||!p.length){T+=".";continue}let f=0;for(let S=1;S<p.length;S++)Ze(g,p[S])<Ze(g,p[f])&&(f=S);T+=c[f];}w.push(T);}return {texture:{w:a,h:i,rows:w},palette:y}}var as="ugc.",Ul=e=>e.startsWith(as);export{Fr as ACTION_TIME,Us as ANIM_EVENTS,as as AVATAR_AUTHOR_ITEM_PREFIX,Br as AVATAR_BASE_COLORS,We as AVATAR_FACE_RECT,Ue as AVATAR_HEIGHT,El as AVATAR_ITEMS,Me as AVATAR_ITEM_LIMITS,Ct as AVATAR_ITEM_LIST,Ca as AVATAR_ITEM_PRINTS,Qa as AVATAR_ITEM_SHOTS,ul as AVATAR_PORTRAIT_BACKGROUND,_e as AVATAR_RIG_ID,nr as AVATAR_SHOP_DEFAULT_PRICES,ro as AVATAR_SHOP_ITEM_LIST,Ce as AVATAR_SLOTS,Te as AVATAR_SPEC_VERSION,rs as AVATAR_STANDARD_ID,ne as AVATAR_STYLE,wt as Animator,_ as Art,Tt as AvatarActor,Xt as BODY_REGIONS,hs as BONE_ROLES,$e as BROW_STYLES,V as CH,js as CHANNELS,ur as CHARACTER_LIMITS,mr as CHARACTER_SPEC_VERSION,ye as CLEAR,ut as CLIPS,Za as CLOTH_COLORS,Vi as CREATURE_KINDS,mt as CharacterView,so as DEFAULT_AVATAR,sa as DEFAULT_AVATAR_FACE,Dt as DEFAULT_CHARACTER_SOURCE,po as DEFAULT_COLORS,Oe as DEFAULT_FINISH,St as DrawnFace,yt as EMOTES,yi as EMOTE_IDS,Ri as EMOTION_EVENTS,je as EXPRESSIONS,Hr as EXPRESSION_CHAIN,ot as EXTRA_BONE_ROLES,Ja as EYE_COLORS,Ye as EYE_STYLES,be as FACE_NAMES,Yr as FACE_TEXELS,Xa as HAIR_COLORS,Gs as HELD_KINDS,Tr as HUMAN_BOTTOMS,Ds as HUMAN_HAIR,Cr as HUMAN_SHOES,kr as HUMAN_TOPS,Lt as IDLE_STYLES,Jn as LOCOMOTION,qe as MOUTH_STYLES,qt as POSTURE,Jt as REGION_PAIRS,He as REST,ie as RIGS,zr as RIG_CLIPS,Be as RIG_IDS,ke as SKIN_COLOR,Ka as SKIN_TONES,Zt as SLOT_RULES,ms as SOCKETS,Ni as VOXEL_CHARACTER_SYSTEM_PROMPT,xt as VoxelActor,Pt as WALK_STYLES,zt as acquireCharacter,pe as add,Dr as applyPosture,Bl as avatarCatalogExport,yl as avatarFromServer,Ll as avatarItemShot,Wa as avatarItemsForSlot,ts as avatarMannequinWith,rr as avatarPrints,Sn as bandColors,De as bone,yr as bonesOf,mi as characterFromImage,ei as characterOf,ti as characterSpecs,Ae as clearPose,er as composeAvatar,pt as copyPose,Xr as createAvatarLighting,eo as createAvatarSnapshotter,_l as createAvatarThumbQueue,ji as creatureCharacter,aa as creatureSource,Se as defaultCharacter,at as defaultCharacterName,Bt as disposeNameplate,Ur as drawAvatarFace,Ei as emotionFromText,no as freeAvatarItemsForSlot,Ht as humanSource,Ul as isAuthorAvatarItem,oo as isAvatarShopItem,ks as isDefaultCharacterName,gi as isEmote,N as isObj,vr as layoutCharacter,Ir as lerpPose,br as mirrorBone,Mr as nameplate,ht as newAnimInput,ue as normColor,ii as npcCharacter,Q as num,ri as onCharacterKnown,Rt as parseAvatarSpec,le as parseCharacterSpec,Mt as pick,Gl as pixelTextureFromImage,Tl as randomAvatar,Nt as recolor,Qs as registerCharacter,it as releaseCharacter,Fa as renderAvatarCanvas,bl as renderAvatarImage,As as rigOfSpec,Nr as sampleEmote,Xn as sampleTrack,u as setCh,ze as specHash,It as stableStringify,ct as standardFace,Gt as styleParams,Et as validateAvatarItem,nt as vec3};
|