@idosgames/characters 0.1.1 → 0.1.3

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.
@@ -1,4 +1,4 @@
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-WKHHFTK2.js';import {b,a}from'../chunk-CGF2TQVK.js';import*as _ from'three';var ct={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 ht={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 pt={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 mt={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 Ro=["root","body","head","armL","armR","legL","legR","legFL","legFR","legBL","legBR","tail","wingL","wingR","ear","hair","cape","antenna","static"],ke=["tail","wingL","wingR","ear","hair","cape","antenna","static"],Eo=["handR","handL","headTop","face","back","waist","shoulders"],be=["humanoid","quadruped","flyer","blob"];var q={humanoid:pt,quadruped:mt,flyer:ht,blob:ct};var dt=1,De=["front","back","left","right","top","bottom"],je=["neutral","blink","happy","sad","angry","surprised","scared","tired","hurt","talk"],Ge=["normal","bouncy","heavy","sneaky","robotic"],Ve=["calm","fidgety","proud"],gt={parts:64,bones:16,palette:32,textures:48,texturePixels:32768,textureSide:32,partSide:32,coord:64},pe={noise:.5,outline:.4,shade:.25,density:2},j=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),ge=t=>Array.isArray(t)?t:[];function W(t,e,r,o){let s=typeof t=="number"?t:typeof t=="string"?Number(t):NaN;return Number.isFinite(s)?Math.min(o,Math.max(r,s)):e}function Ne(t,e,r){if(typeof t!="string")return r;let o=t.trim();if(e.includes(o))return o;let s=o.toLowerCase().replace(/[\s-]+/g,"_");return e.find(n=>n.toLowerCase()===s)??r}function te(t,e,r){return typeof t=="string"?t.trim().slice(0,r):e}function Re(t,e,r=null){if(!Array.isArray(t)||t.length<3)return r;let o=t.slice(0,3).map(s=>W(s,NaN,-e,e));return o.every(Number.isFinite)?o:r}var ut={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 ft(t){if(typeof t!="string")return null;let e=t.trim().toLowerCase();if(ut[e])return ut[e];let r=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/.exec(e);if(!r)return null;let o=r[1];return "#"+(o.length===3?o.split("").map(s=>s+s).join(""):o)}var ye=new Set(["."," "]),bt=t=>/^[A-Za-z0-9_]{1,24}$/.test(t),Bt={human:"humanoid",biped:"humanoid",person:"humanoid",animal:"quadruped",four_legs:"quadruped",quadrupedal:"quadruped",bird:"flyer",winged:"flyer",dragon:"flyer",slime:"blob",ghost:"blob"};function Dt(t){if(typeof t!="string")return "humanoid";let e=t.trim().toLowerCase().replace(/[\s-]+/g,"_");return be.includes(e)?e:Bt[e]??"humanoid"}function yt(t,e){let r=/^(.*?)(L|R)$/.exec(t);if(!r)return t;let o=r[1]+(r[2]==="L"?"R":"L");return e(o)?o:t}function Z(t){if(typeof t=="string"){let m=d(t);if(!m.ok)return {ok:false,error:m.error,truncated:m.truncated};t=m.value;}if(!j(t))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 t)&&!("rig"in t)){let m=t.character??t.spec??t.characterSpec;j(m)&&(t=m);}let e=t,r=gt,o=[];typeof e.version=="number"&&e.version>dt&&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:e.version}));let s=Dt(e.rig),a=q[s],n={};if(j(e.palette))for(let[m,k]of Object.entries(e.palette)){if(Object.keys(n).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 y=ft(k);if(m.length!==1||ye.has(m)||!y){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:m}));continue}n[m]=y;}let i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",l=(m,k)=>{if(typeof m!="string")return k;if(m.length===1&&n[m])return m;let y=ft(m);if(!y)return k;let M=Object.entries(n).find(([,d])=>d===y);if(M)return M[0];if(Object.keys(n).length>=r.palette)return k;let p=[...i].find(d=>!n[d]);return p?(n[p]=y,p):k},c$1={},u=0;if(j(e.textures))for(let[m,k]of Object.entries(e.textures)){if(!bt(m)){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:m.slice(0,30)}));continue}if(Object.keys(c$1).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 y=Vt(k,n,o,m);if(y){if(u+y.w*y.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:m}));continue}u+=y.w*y.h,c$1[m]=y;}}let b=new Set(a.bones.map(m=>m.name)),g=[];for(let m of ge(e.bones)){if(!j(m))continue;let k=te(m.name,"",24);if(!k||!bt(k))continue;let y=Re(m.pivot,r.coord);if(!y||g.some(x=>x.name===k))continue;if(g.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 M=b.has(k),p=te(m.parent,"",24),d=M?a.bones.find(x=>x.name===k).parent??"":b.has(p)||g.some(x=>x.name===p)?p:a.bones.find(x=>x.role==="body").name;g.push({name:k,parent:d,pivot:y,role:M?"static":Ne(m.role,ke,"static")}),b.add(k);}let R=Object.keys(n)[0]??"s",E=[];for(let m of ge(e.parts)){if(E.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(!j(m))continue;let k=Re(m.size,r.partSide),y=Re(m.pos??m.center??m.at,r.coord);if(!k||!y||k.some(f=>f<=0))continue;let M=te(m.bone,"",24);b.has(M)||(M&&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:M})),M=a.bones.find(f=>f.role==="body").name);let p={bone:M,size:k,pos:y,color:l(m.color,R)};if(j(m.faces)){let f={};for(let L of De){let I=m.faces[L];if(typeof I=="string")if(c$1[I])f[L]=I;else {let G=l(I,"");G&&(f[L]=G);}}Object.keys(f).length&&(p.faces=f);}let d=Re(m.rot??m.rotation,180);d&&d.some(f=>f!==0)&&(p.rot=d),(m.mirror===true||m.mirror==="x")&&(p.mirror=true);let x=te(m.name,"",24);x&&(p.name=x),E.push(p);}if(!E.length){for(let[m,k]of Object.entries(jt))n[m]||(n[m]=k);E.push(...a.defaultParts.map(Gt));}let F=null;if(j(e.face)){let m=e.face,k=b.has(te(m.bone,"",24))?te(m.bone,"",24):a.faceBone,y=ge(m.rect).map(p=>Math.round(W(p,NaN,0,r.partSide))),M={};if(j(m.expressions))for(let p of je){let d=m.expressions[p];typeof d=="string"&&c$1[d]&&(M[p]=d);}if(!M.neutral){let p=Object.values(M)[0];p&&(M.neutral=p);}if(M.neutral){let p=c$1[M.neutral];F={bone:k,rect:y.length===4&&y.every(Number.isFinite)&&y[2]>0&&y[3]>0?y:[0,0,p.w,p.h],expressions:M};}else Object.keys(m).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 K=j(e.style)?e.style:{},T=j(e.voice)?e.voice:{},A=j(e.finish)?e.finish:{};return {ok:true,spec:{version:dt,name:te(e.name,Ee(),40)||Ee(),description:te(e.description,"",300),rig:s,scale:W(e.scale,1,.25,3),palette:n,textures:c$1,parts:E,bones:g,face:F,style:{walk:Ne(K.walk,Ge,"normal"),idle:Ne(K.idle,Ve,"calm"),energy:W(K.energy,.5,0,1)},voice:{pitch:W(T.pitch,1,.5,2)},tags:ge(e.tags).filter(m=>typeof m=="string"&&!!m.trim()).slice(0,8).map(m=>m.trim().slice(0,24)),finish:{noise:W(A.noise,pe.noise,0,1),outline:W(A.outline,pe.outline,0,1),shade:W(A.shade,pe.shade,0,1),density:Math.round(W(A.density,pe.density,1,4))}},warnings:o}}var jt={s:"#c69c7c",t:"#3a8fd6",p:"#2c3e6b"};function Gt(t){return JSON.parse(JSON.stringify(t))}function Vt(t,e,r,o){let s=Array.isArray(t)?{rows:t}:j(t)?t:null;if(!s)return null;let a=gt.textureSide,n=ge(s.rows??s.pixels).filter(u=>typeof u=="string");if(!n.length)return null;let i=Math.round(W(s.h??s.height,n.length,1,a)),l=Math.round(W(s.w??s.width,Math.max(...n.map(u=>u.length)),1,a)),c$1=false;for(n=n.slice(0,i).map(u=>{let b="";for(let g=0;g<l;g++){let R=u[g]??".";ye.has(R)||e[R]?b+=R===" "?".":R:(c$1=true,b+=".");}return b});n.length<i;)n.push(".".repeat(l));return c$1&&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:l,h:i,rows:n}}function Be(t){return Array.isArray(t)?"["+t.map(Be).join(",")+"]":j(t)?"{"+Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>JSON.stringify(e)+":"+Be(t[e])).join(",")+"}":JSON.stringify(t)}function me(t){let e=Be(t),r=b(e),o=b("~"+e);return r.toString(16).padStart(8,"0")+o.toString(16).padStart(8,"0")}function zo(t){return q[t.rig]}function xt(t){let r=q[t.rig].bones.map(o=>{let s=t.bones.find(a=>a.name===o.name);return {name:o.name,role:o.role,parent:o.parent,pivot:(s?.pivot??o.pivot).slice()}});for(let o of t.bones)r.some(s=>s.name===o.name)||r.push({name:o.name,role:o.role,parent:o.parent,pivot:o.pivot.slice()});return r}function Ee(){return c({en:"Character",ru:"\u041F\u0435\u0440\u0441\u043E\u043D\u0430\u0436"})}var Fo=t=>t==="\u041F\u0435\u0440\u0441\u043E\u043D\u0430\u0436"||t==="Character";var Ut={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 Ue(t){let e=parseInt(t.slice(1),16);return [e>>16&255,e>>8&255,e&255]}function wt(t,e,r,o,s,a){let n=((r-1-s)*e+o)*4;t[n]=a[0],t[n+1]=a[1],t[n+2]=a[2],t[n+3]=255;}function Wt(t){t.sort((e,r)=>r.h-e.h||r.w-e.w||(e.key<r.key?-1:1));for(let e=16;;e*=2){let r=0,o=0,s=0;for(let n of t)r+n.w>e&&(r=0,o+=s,s=0),n.x=r,n.y=o,r+=n.w,s=Math.max(s,n.h);let a=o+s;if(a<=e||e>=1024){let n=16;for(;n<a;)n*=2;return {w:e,h:n}}}}function kt(t,e,r){let o=Math.imul(e,374761393)+Math.imul(r,668265263)+Math.imul(t,2246822519);return o=Math.imul(o^o>>>13,1274126177),((o^o>>>16)>>>0)/4294967296}function Kt(t,e,r,o,s,a,n,i){let c=1+(.55*kt(n,e,r)+.45*kt(n^1540483477,Math.floor(e/3),Math.floor(r/3))-.5)*2*i.noise*.14;return a==="s"?c+=i.shade*.16*(.5-(r+.5)/s):a==="t"?c+=i.shade*.08:c-=i.shade*.2,o>=3&&s>=3&&(e===0||r===0||e===o-1||r===s-1)&&(c*=1-.5*i.outline),[Math.max(0,Math.min(255,t[0]*c)),Math.max(0,Math.min(255,t[1]*c)),Math.max(0,Math.min(255,t[2]*c))]}var We=Math.PI/180;function Rt(t,e){if(!e)return t;let[r,o,s]=t,[a,n,i]=[e[0]*We,e[1]*We,e[2]*We],l=Math.cos(i),c=Math.sin(i);return [r,o]=[r*l-o*c,r*c+o*l],l=Math.cos(n),c=Math.sin(n),[r,s]=[r*l+s*c,-r*c+s*l],l=Math.cos(a),c=Math.sin(a),[o,s]=[o*l-s*c,o*c+s*l],[r,o,s]}function $t(t,e){let r=[];for(let o of t.parts){if(r.push({...o,flip:false}),!o.mirror)continue;let s=o.faces?{...o.faces,left:o.faces.right,right:o.faces.left}:void 0;s&&(s.left===void 0&&delete s.left,s.right===void 0&&delete s.right);let a={...o,bone:yt(o.bone,e),pos:[-o.pos[0],o.pos[1],o.pos[2]],flip:true};s?a.faces=s:delete a.faces,o.rot&&(a.rot=[o.rot[0],-o.rot[1],-o.rot[2]]),r.push(a);}return r}function Et(t){let e=q[t.rig],r=xt(t),o=p=>r.some(d=>d.name===p),s=$t(t,o),a=t.finish??pe,n=new Map,i=(p,d)=>{let x=p.faces?.[d],f=x!==void 0?t.textures[x]:void 0,L=x!==void 0&&t.palette[x]?x:p.color,[I,G]=d==="front"||d==="back"?[p.size[0],p.size[1]]:d==="left"||d==="right"?[p.size[2],p.size[1]]:[p.size[0],p.size[2]],C=(he,oe)=>Math.max(1,Math.min(64,oe*Math.max(1,Math.round(he*a.density/oe)))),N=f?C(I,f.w):C(I,1),B=f?C(G,f.h):C(G,1),P=d==="top"?"t":d==="bottom"?"b":"s",H=(f?"t:"+x:"c:"+L)+"|"+N+"x"+B+P,D=n.get(H);if(D)return D;let Q=b(H),ee=f?null:Ue(t.palette[L]??"#ff00ff");return D={key:H,w:N,h:B,x:0,y:0,paint:(he,oe,Fe,ne,se)=>{for(let Y=0;Y<B;Y++)for(let U=0;U<N;U++){let st=ee;if(f){let at=f.rows[Math.floor(Y*f.h/B)][Math.floor(U*f.w/N)];if(ye.has(at))continue;let it=t.palette[at];if(!it)continue;st=Ue(it);}wt(he,oe,Fe,ne+U,se+Y,Kt(st,U,Y,N,B,P,Q,a));}}},n.set(H,D),D},l=(p,d)=>{let x="e:"+p,f=n.get(x);return f||(f={key:x,w:d.w,h:d.h,x:0,y:0,paint:(L,I,G,C,N)=>{for(let B=0;B<d.h;B++)for(let P=0;P<d.w;P++){let H=d.rows[B][P];if(ye.has(H))continue;let D=t.palette[H];D&&wt(L,I,G,C+P,N+B,Ue(D));}}},n.set(x,f)),f},c=s.map(p=>({p,faces:De.map(d=>({f:d,cell:i(p,d)}))})),u=t.face,b$1=[];if(u)for(let[p,d]of Object.entries(u.expressions)){let x=t.textures[d];x&&b$1.push([p,l(d,x)]);}let{w:g,h:R}=Wt([...n.values()]),E=new Uint8Array(g*R*4);for(let p of n.values())p.paint(E,g,R,p.x,p.y);let F=.01,K=p=>[(p.x+F)/g,1-(p.y+F)/R,(p.x+p.w-F)/g,1-(p.y+p.h-F)/R],T=new Map;for(let p of r)T.set(p.name,{pos:[],nrm:[],uv:[],idx:[]});let A=0;for(let{p,faces:d}of c){let x=T.get(p.bone),f=r.find(I=>I.name===p.bone).pivot,L=[p.size[0]/2,p.size[1]/2,p.size[2]/2];A=Math.max(A,p.pos[1]+L[1]);for(let{f:I,cell:G}of d){let C=Ut[I],N=(ne,se)=>{let Y=[L[0]*(C.tl[0]+2*(C.u[0]*ne+C.d[0]*se)),L[1]*(C.tl[1]+2*(C.u[1]*ne+C.d[1]*se)),L[2]*(C.tl[2]+2*(C.u[2]*ne+C.d[2]*se))],U=Rt(Y,p.rot);return [p.pos[0]+U[0]-f[0],p.pos[1]+U[1]-f[1],p.pos[2]+U[2]-f[2]]},B=Rt(C.n,p.rot),P=x.pos.length/3,[H,D,Q,ee]=K(G),[he,oe]=p.flip?[Q,H]:[H,Q],Fe=[[0,0,he,D],[1,0,oe,D],[1,1,oe,ee],[0,1,he,ee]];for(let[ne,se,Y,U]of Fe)x.pos.push(...N(ne,se)),x.nrm.push(...B),x.uv.push(Y,U);x.idx.push(P,P+2,P+1,P,P+3,P+2);}}let V=r.map(p=>{let d=T.get(p.name);return {name:p.name,role:p.role,parent:p.parent,pivot:p.pivot,positions:Float32Array.from(d.pos),normals:Float32Array.from(d.nrm),uvs:Float32Array.from(d.uv),indices:Uint16Array.from(d.idx)}}),m=null;if(u&&b$1.length){let d=t.parts.filter(f=>f.bone===u.bone).sort((f,L)=>L.size[0]*L.size[1]*L.size[2]-f.size[0]*f.size[1]*f.size[2])[0],x=r.find(f=>f.name===u.bone);if(d&&x){let[f,L,I,G]=u.rect,C=d.pos[0]+d.size[0]/2-f,N=d.pos[1]+d.size[1]/2-L,B=d.pos[2]-d.size[2]/2-.05,P=x.pivot,H=(Q,ee)=>[Q-P[0],ee-P[1],B-P[2]],D={};for(let[Q,ee]of b$1)D[Q]=K(ee);m={bone:u.bone,corners:Float32Array.from([...H(C,N),...H(C-I,N),...H(C-I,N-G),...H(C,N-G)]),uv:D};}}let k=e.sockets.filter(p=>o(p.bone)).map(p=>{let d=e.bones.find(x=>x.name===p.bone);return {name:p.name,bone:p.bone,at:[p.at[0]-d.pivot[0],p.at[1]-d.pivot[1],p.at[2]-d.pivot[2]]}}),y=Math.max(1,A),M=y>e.height.max?e.height.max/y:y<e.height.min?e.height.min/y:1;return {hash:me(t),rig:t.rig,bones:V,atlas:{w:g,h:R,data:E},face:m,sockets:k,height:y,scale:t.scale*M,eye:e.eye*y/Xt(t.rig)}}function Xt(t){let e=1;for(let r of q[t].defaultParts)e=Math.max(e,r.pos[1]+r.size[1]/2);return e}var Ke=new Map;function Yt(t){let e=new Map;for(let n of t.bones){if(!n.indices.length){e.set(n.name,null);continue}let i=new _.BufferGeometry;i.setAttribute("position",new _.BufferAttribute(n.positions,3)),i.setAttribute("normal",new _.BufferAttribute(n.normals,3)),i.setAttribute("uv",new _.BufferAttribute(n.uvs,2)),i.setIndex(new _.BufferAttribute(n.indices,1)),i.computeBoundingSphere(),i.userData.shared=true,e.set(n.name,i);}let{w:r,h:o,data:s}=t.atlas,a=new _.DataTexture(s,r,o,_.RGBAFormat);return a.magFilter=_.NearestFilter,a.minFilter=_.NearestFilter,a.generateMipmaps=false,a.colorSpace=_.SRGBColorSpace,a.needsUpdate=true,{layout:t,geometries:e,texture:a,refs:0}}function $e(t){let e=Ke.get(me(t));return e||(e=Yt(Et(t)),Ke.set(e.layout.hash,e)),e.refs++,e}function Se(t){if(!(--t.refs>0)){Ke.delete(t.layout.hash);for(let e of t.geometries.values())e?.dispose();t.texture.dispose();}}var w=class t{constructor(e,r,o="."){this.w=e;this.h=r;this.g=Array.from({length:r},()=>new Array(e).fill(o));}w;h;g;px(e,r,o){return e>=0&&r>=0&&e<this.w&&r<this.h&&(this.g[r][e]=o),this}rect(e,r,o,s,a){for(let n=r;n<r+s;n++)for(let i=e;i<e+o;i++)this.px(i,n,a);return this}row(e,r,o,s){return this.rect(r,e,o-r+1,1,s)}col(e,r,o,s){return this.rect(e,r,1,o-r+1,s)}where(e,r){for(let o=0;o<this.h;o++)for(let s=0;s<this.w;s++)e(s,o)&&this.px(s,o,r);return this}flipped(){let e=new t(this.w,this.h);for(let r=0;r<this.h;r++)for(let o=0;o<this.w;o++)e.px(this.w-1-o,r,this.g[r][o]);return e}tex(){return {w:this.w,h:this.h,rows:this.g.map(e=>e.join(""))}}};var qt={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 J(t,e){let r=parseInt(t.slice(1),16);return "#"+[r>>16&255,r>>8&255,r&255].map(s=>Math.max(0,Math.min(255,Math.round(s*e)))).map(s=>s.toString(16).padStart(2,"0")).join("")}function Ye(t,e){let r={...t};return e.skin&&(r.s=e.skin,r.S=J(e.skin,.86),r.m=J(e.skin,.66)),e.hair&&(r.h=e.hair,r.H=J(e.hair,1.25),r.k=J(e.hair,.6)),e.shirt&&(r.t=e.shirt,r.T=J(e.shirt,1.15),r.D=J(e.shirt,.8)),e.pants&&(r.p=e.pants,r.P=J(e.pants,.8)),e.boots&&(r.z=e.boots,r.Z=J(e.boots,.78)),e.eyes&&(r.b=e.eyes),r}var Zt=new w(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"),St=new w(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((t,e)=>e>4&&e<11&&t>8&&(t+e)%4===0,"k"),Jt=St.flipped(),Qt=new w(16,16,"h").where((t,e)=>(t+2*e)%5===0,"H").where((t,e)=>e>8&&(t*3+e)%7===0,"k").rect(4,14,8,2,"s"),er=new w(16,16,"h").where((t,e)=>(t+2*e)%5===0,"H").where((t,e)=>(3*t+e)%9===0,"k"),tr=new w(18,4,"h").where((t,e)=>(t*7+e*3)%5===0,"H").where((t,e)=>e===3&&t*5%3===0,"k"),rr=new w(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"),or=new w(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"),nr=new w(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"),sr=new w(16,2,"B").rect(7,0,2,2,"g").px(3,0,"k").px(12,0,"k"),ar=new w(6,24,"s").row(23,0,5,"S").col(2,21,23,"S"),ir=new w(8,13,"t").col(0,0,9,"D").row(9,0,7,"D").rect(0,10,8,3,"T").row(12,0,7,"D"),lr=new w(8,24,"p").col(4,1,21,"P").row(0,0,7,"P"),cr=new w(8,24,"p").col(3,0,21,"P").row(0,0,7,"P"),hr=new w(8,24,"p").col(3,0,21,"P"),pr=new w(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"),mr=new w(10,9,"z").row(0,0,9,"Z").rect(0,7,10,2,"Z").col(5,1,6,"Z");function $(t){let e=new w(16,10,"."),r=(s,a,n)=>{if(t.brows==="flat")e.row(1,s,s+2,"k");else if(t.brows==="high")e.row(0,s,s+2,"k");else {let i=t.brows==="down"?1:0,l=1-i;e.px(a,i,"k").px(s+1,t.brows==="down"?0:1,"k"),e.px(n,l,"k");}};r(3,5,3),r(10,10,12);let o=s=>{if(t.eyes===0){e.row(3,s,s+2,"k");return}let a=t.eyes===3||t.eyes===2?2:3;for(let n=a;n<a+t.eyes;n++)e.px(s,n,"w").px(s+1,n,"b").px(s+2,n,"w");};switch(o(3),o(10),t.mouth){case "line":e.row(7,6,9,"m");break;case "smile":e.px(5,6,"m").px(10,6,"m").row(7,6,9,"m");break;case "frown":e.row(7,6,9,"m").px(5,8,"m").px(10,8,"m");break;case "open":e.rect(6,7,4,2,"o");break;case "small":e.rect(7,7,2,2,"o");break;case "wide":e.row(7,5,10,"m").rect(6,8,4,1,"o");break}return e}var vt={f_neutral:$({brows:"flat",eyes:2,mouth:"line"}),f_blink:$({brows:"flat",eyes:0,mouth:"line"}),f_happy:$({brows:"high",eyes:2,mouth:"smile"}),f_sad:$({brows:"up",eyes:2,mouth:"frown"}),f_angry:$({brows:"down",eyes:1,mouth:"wide"}),f_surprised:$({brows:"high",eyes:3,mouth:"small"}),f_scared:$({brows:"up",eyes:3,mouth:"open"}),f_tired:$({brows:"flat",eyes:1,mouth:"line"}),f_hurt:$({brows:"down",eyes:0,mouth:"open"}),f_talk:$({brows:"flat",eyes:2,mouth:"open"})},dr=new w(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"),ur=new w(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"),fr=new w(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"),br=new w(8,9,"t").row(3,0,7,"D").rect(0,7,8,2,"T"),ve=(t,e)=>t.row(e-1,0,t.w-1,"D").where((r,o)=>o>=e&&o<=e+3&&(r+o)%2===0,"T").row(e+4,0,t.w-1,"D"),gr=ve(new w(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((t,e)=>e>=18&&e<=19&&t%2===0,"D").where((t,e)=>e>=18&&e<=19&&t%2===1,"T").rect(0,20,16,4,"p"),yr=ve(new w(16,24,"t"),6).row(0,4,11,"T").where((t,e)=>e>=18&&e<=19,"D").rect(0,20,16,4,"p"),xr=ve(new w(8,24,"t"),6).where((t,e)=>e>=18&&e<=19,"D").rect(0,20,8,4,"p"),wr=ve(new w(8,22,"t"),9).where((t,e)=>e>=19&&t%2===0,"D"),Ct=t=>new w(8,24,"s").rect(0,0,8,12,"p").col(t,1,10,"P").row(11,0,7,"P").row(12,0,7,"S").rect(0,19,8,5,"l"),kr=Ct(4),Rr=Ct(3),Er=new w(9,5,"z").row(1,3,5,"l").rect(0,3,9,2,"l"),Sr=new w(10,5,"z").row(1,3,6,"Z").rect(0,3,10,2,"l"),vr=new w(17,6,"a").rect(0,4,17,2,"A"),Cr=new w(22,22,"a").where((t,e)=>(t*3+e*5)%11===0,"A"),Tr=new w(17,20,"h").where((t,e)=>(t*5+e)%4===0,"H").where((t,e)=>e>10&&(t*3+e*2)%7===0,"k"),S=t=>t.tex(),Tt=["shirt","tee","sweater"],Mt=["pants","shorts"],At=["boots","sneakers"],Yo=["short","long","curly","none"],ie=(t,e={})=>({front:t,back:t,left:t,right:t,...e});function qe(t={}){let e=t.top??"shirt",r=t.bottom??"pants",o=t.shoes??"boots",s=t.hair??"short",a=Ye(qt,t.colors??{});a={...a,a:t.colors?.hat??"#d9c9a3"},a.A=J(a.a,.72);let n={head_front:S(Zt),head_left:S(St),head_right:S(Jt),head_back:S(Qt),hair_top:S(er),hair_band:S(tr),arm_skin:S(ar),...Object.fromEntries(Object.entries(vt).map(([E,F])=>[E,S(F)]))},i=[{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(s!=="none"){if(t.hat||i.push({name:"hair",bone:"head",size:s==="curly"?[9,2.2,9]:[8.6,1.6,8.6],pos:[0,s==="curly"?32.5:32.2,.15],color:"h",faces:ie("hair_band",{top:"hair_top"})}),s==="curly"&&!t.hat)for(let[E,F]of [[-2,-1.5],[2,.5],[-0.5,2.5]])i.push({name:"curl",bone:"head",size:[3.2,1.4,3.2],pos:[E,33.9,F],color:"h",faces:ie("hair_band",{top:"hair_top"})});s==="long"?(n.hair_long=S(Tr),i.push({name:"hairLong",bone:"head",size:[8.8,10,1],pos:[0,27,4.4],color:"h",faces:ie("hair_long",{top:"hair_top"})},{name:"hairSide",bone:"head",size:[.8,9,6],pos:[-4.4,27.5,1],color:"h",faces:ie("hair_long",{top:"hair_top"}),mirror:true})):i.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"}});}t.hat&&(n.hat_crown=S(vr),n.hat_brim=S(Cr),i.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:ie("hat_crown")}));let l={shirt:[rr,or,nr],tee:[dr,ur,fr],sweater:[gr,yr,xr]},[c$1,u,b]=l[e];n.top_front=S(c$1),n.top_back=S(u),n.top_side=S(b),i.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"}}),e==="shirt"&&(n.belt=S(sr),i.push({name:"belt",bone:"body",size:[8.4,1,4.4],pos:[0,13.5,0],color:"B",faces:{front:"belt",back:"belt"}})),i.push({name:"arm",bone:"armL",size:[3,12,3],pos:[-5.5,18,0],color:"s",faces:ie("arm_skin",{top:"t",bottom:"S"}),mirror:true});let g=e==="sweater"?11:e==="tee"?4.5:6.5;n.sleeve=S(e==="sweater"?wr:e==="tee"?br:ir),i.push({name:"sleeve",bone:"armL",size:[3.6,g,3.6],pos:[-5.5,24-g/2,0],color:"t",faces:ie("sleeve",{bottom:"D"}),mirror:true}),r==="shorts"?(n.leg_front=S(kr),n.leg_side=S(Rr)):(n.leg_front=S(lr),n.leg_back=S(cr),n.leg_side=S(hr)),i.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"?(n.shoe_front=S(pr),n.shoe_side=S(mr)):(n.shoe_front=S(Er),n.shoe_side=S(Sr));let R=o==="boots"?4.5:2.5;return i.push({name:"shoe",bone:"legL",size:[4.6,R,5.2],pos:[-2,R/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:t.name??c({en:"Traveler",ru:"\u041F\u0443\u0442\u043D\u0438\u043A"}),description:t.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:n,parts:i,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:t.tags??["player"]}}function Ce(t,e){return {textures:Object.fromEntries(Object.entries(vt).map(([r,o])=>[r,S(o)])),face:{bone:t,rect:e,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 Ze=qe(),Xe=null;function le(){if(!Xe){let t=Z(Ze);if(!t.ok)throw new Error(t.error);Xe=t.spec;}return Xe}function Lt(t){let e=document.createElement("canvas");e.width=256,e.height=48;let r=e.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(t.slice(0,18),128,25));let o=new _.CanvasTexture(e),s=new _.Sprite(new _.SpriteMaterial({map:o,depthTest:false,transparent:true}));return s.scale.set(1.6,.3,1),s.renderOrder=10,s}function Je(t){t.removeFromParent(),t.material.map?.dispose(),t.material.dispose();}var v={rx:0,ry:1,rz:2,px:3,py:4,pz:5,sx:6,sy:7,sz:8},Jo=Object.keys(v),ue=[0,0,0,0,0,0,1,1,1];function fe(t,e){let r=t.get(e);return r||(r=Float64Array.from(ue),t.set(e,r)),r}function X(t,e,r,o){let s=fe(t,e),a=v[r];a>=6?s[a]=s[a]*o:s[a]=s[a]+o;}function h(t,e,r,o){fe(t,e)[v[r]]=o;}function ce(t){for(let e of t.values())e.set(ue);}function Pt(t,e,r,o){let s=new Set([...e.keys(),...r.keys()]);for(let a of s){let n=e.get(a)??ue,i=r.get(a)??ue,l=fe(t,a);for(let c=0;c<9;c++)l[c]=n[c]+(i[c]-n[c])*o;}}function Te(t,e){ce(t);for(let[r,o]of e)fe(t,r).set(o);}var Qo=["none","block","tool","sword","bow","shield","food","staff","item"];function Me(){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 en=["swing","hurt","place","land","jump","throw"];var xe=1/16,Ae=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;constructor(e=le(),r={}){this.spec=e,this.shadows=r.shadows??true,this.layer=r.layer??0,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=$e(e),this.build(),r.name&&this.setName(r.name);}get height(){let e=this.asset.layout;return e.height*e.scale*xe}get eye(){let e=this.asset.layout;return e.eye*e.scale*xe}get expressions(){return Object.keys(this.asset.layout.face?.uv??{})}get hash(){return this.asset.layout.hash}setSpec(e){let r=$e(e);if(r===this.asset){Se(r);return}this.clear(),Se(this.asset),this.asset=r,this.spec=e,this.build();}build(){let{layout:e,geometries:r,texture:o}=this.asset;this.material.map=o,this.material.needsUpdate=true,this.decalMat.map=o,this.decalMat.needsUpdate=true,this.root.scale.setScalar(e.scale*xe);let s=new Map(e.bones.map(n=>[n.name,n.pivot]));for(let n of e.bones){let i=new _.Group,l=n.parent?s.get(n.parent)??[0,0,0]:[0,0,0],c=[n.pivot[0]-l[0],n.pivot[1]-l[1],n.pivot[2]-l[2]];i.position.set(...c);let u={name:n.name,role:n.role,group:i,rest:c};this.bones.set(n.name,u);let b=this.byRole.get(n.role)??[];b.push(u),this.byRole.set(n.role,b);let g=r.get(n.name);if(g){let R=new _.Mesh(g,this.material);R.castShadow=R.receiveShadow=this.shadows,R.layers.set(this.layer),this.meshes.push(R),i.add(R);}}for(let n of e.bones){let i=this.bones.get(n.name);((n.parent?this.bones.get(n.parent):void 0)?.group??this.root).add(i.group);}let a=e.face;if(a){let n=new _.BufferGeometry;n.setAttribute("position",new _.BufferAttribute(a.corners,3));let i=new Float32Array(12);for(let l=0;l<4;l++)i[l*3+2]=-1;n.setAttribute("normal",new _.BufferAttribute(i,3)),n.setAttribute("uv",new _.BufferAttribute(new Float32Array(8),2)),n.setIndex([0,2,1,0,3,2]),this.decal=new _.Mesh(n,this.decalMat),this.decal.layers.set(this.layer),this.bones.get(a.bone)?.group.add(this.decal),this.expression=null,this.setExpression("neutral");}for(let n of e.sockets){let i=new _.Object3D;i.position.set(...n.at),i.scale.setScalar(1/(e.scale*xe)),this.bones.get(n.bone)?.group.add(i),this.sockets.set(n.name,i);let l=this.attached.get(n.name);l&&i.add(l);}this.placeLabel(),this.setBrightness(this.brightness);}clear(){for(let e of this.sockets.values())for(let r of [...e.children])e.remove(r);this.root.clear(),this.decal?.geometry.dispose(),this.decal=null,this.meshes=[],this.bones=new Map,this.byRole=new Map,this.sockets.clear();}applyPose(e){let r=e.get("root");if(r){this.root.rotation.set(r[v.rx],r[v.ry],r[v.rz]);let o=this.asset.layout.scale*xe;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,s]of this.byRole){let a=e.get(o);for(let n of s){let i=n.group;if(!a){i.rotation.set(0,0,0),i.position.set(...n.rest),i.scale.set(1,1,1);continue}i.rotation.set(a[v.rx],a[v.ry],a[v.rz]),i.position.set(n.rest[0]+a[v.px],n.rest[1]+a[v.py],n.rest[2]+a[v.pz]),i.scale.set(a[v.sx],a[v.sy],a[v.sz]);}}}setExpression(e){if(e===this.expression||!this.decal)return;let r=this.asset.layout.face?.uv,o=r?.[e]??r?.neutral;if(!o)return;this.expression=e;let[s,a,n,i]=o,l=this.decal.geometry.getAttribute("uv");l.setXY(0,s,a),l.setXY(1,n,a),l.setXY(2,n,i),l.setXY(3,s,i),l.needsUpdate=true;}setBrightness(e){this.brightness=e,this.material.color.setScalar(e),this.decalMat.color.setScalar(e);}setEmissive(e){this.material.emissive.getHex()!==e&&(this.material.emissive.setHex(e),this.decalMat.emissive.setHex(e));}setShadows(e){if(e!==this.shadows){this.shadows=e;for(let r of this.meshes)r.castShadow=e;}}attach(e,r){let o=this.attached.get(e);if(o!==r){if(o&&o.removeFromParent(),!r){this.attached.delete(e);return}this.attached.set(e,r),this.sockets.get(e)?.add(r);}}attachedAt(e){return this.attached.get(e)??null}setName(e){this.label&&Je(this.label),this.label=e?Lt(e):null,this.label&&this.group.add(this.label),this.placeLabel();}setLabelVisible(e){this.label&&(this.label.visible=e);}placeLabel(){this.label&&(this.label.position.y=this.height+.25);}forEachMesh(e){for(let r of this.meshes)e(r);this.decal&&e(this.decal);}dispose(){this.group.removeFromParent();for(let e of this.attached.values())e.removeFromParent();this.attached.clear(),this.clear(),this.label&&Je(this.label),this.label=null,this.material.dispose(),this.decalMat.dispose(),Se(this.asset);}};var Le=new Map,Qe=new Set;function cn(t){let e=me(t);if(!Le.has(e)){Le.set(e,t);for(let r of Qe)r(e);}return e}function hn(t){return typeof t=="string"?Le.get(t):void 0}function pn(t){let e={};for(let r of t){let o=Le.get(r);o&&(e[r]=o);}return e}function mn(t){return Qe.add(t),()=>Qe.delete(t)}var Mr=["#b08a62","#8a6a4a","#c8a878","#9a9a92","#7a5c44"],Ar=["#f1c9a5","#e6b892","#d9a982","#c08e68","#a0704c","#7a5238"],Lr=["#6b4a2f","#4a3424","#8a5a3a","#c27a48","#d8b878","#2e2622","#a07850","#9a9690"],Pr=["#a7bea9","#e6e0cc","#d9c9a3","#b9a083","#a9b8c4","#c8b4a0","#9fb0a0","#d8d2c4","#b98f74","#8fa3b5"],_r=["#8c9ca6","#a9b8b4","#8a8e94","#9fb3ad","#7d8a8f","#b0a58f"],Or=["#d9c9a3","#c8b48a","#a08a6a","#e6e0cc"];function gn(t,e="",r=""){let o=a(b("npc:"+t+"|"+e)),s=i=>i[Math.floor(o()*i.length)],a$1=qe({top:s(Tt),bottom:s(Mt),shoes:s(At),hair:s(["short","short","long","curly"]),hat:o()<.2,colors:{skin:s(Ar),hair:s(Lr),shirt:s(Pr),pants:s(_r),boots:s(Mr),hat:s(Or)}});a$1.name=t.slice(0,40),a$1.description=[e,r].filter(Boolean).join(" \u2014 ").slice(0,300),a$1.style={walk:s(["normal","normal","bouncy","heavy","sneaky"]),idle:s(["calm","calm","fidgety","proud"]),energy:Math.round(o()*10)/10},a$1.tags=["npc",...e?[e.slice(0,24)]:[]];let n=Z(a$1);return n.ok?n.spec:le()}var re=([t,e,r])=>"#"+[t,e,r].map(o=>Math.round(o).toString(16).padStart(2,"0")).join("");function Ir(t){if(!t.length)return null;let e=r=>{let o=t.map(s=>s[r]).sort((s,a)=>s-a);return o[o.length>>1]};return [e(0),e(1),e(2)]}function zr(t,e){let{width:r,height:o,data:s}=t,a=(T,A)=>{let V=(A*r+T)*4;return [s[V],s[V+1],s[V+2]]},n=[a(0,0),a(r-1,0),a(0,o-1),a(r-1,o-1)],i=[0,1,2].map(T=>n.reduce((A,V)=>A+V[T],0)/4),l=T=>Math.abs(T[0]-i[0])+Math.abs(T[1]-i[1])+Math.abs(T[2]-i[2])>60,c=r,u=-1,b=o,g=-1;for(let T=0;T<o;T+=2)for(let A=0;A<r;A+=2)l(a(A,T))&&(c=Math.min(c,A),u=Math.max(u,A),b=Math.min(b,T),g=Math.max(g,T));u<0&&(c=0,u=r-1,b=0,g=o-1);let R=g-b+1,E=u-c+1,F=c+Math.floor(E*.3),K=c+Math.ceil(E*.7);return e.map(([T,A])=>{let V=[];for(let m=b+Math.floor(R*T);m<b+Math.ceil(R*A);m++)for(let k=F;k<K;k++){if(m<0||m>=o||k<0||k>=r)continue;let y=a(k,m);l(y)&&V.push(y);}return Ir(V)})}var Fr=[[0,.06],[.1,.22],[.3,.52],[.6,.86],[.92,1]];function Rn(t,e="humanoid",r=Ee()){let[o,s,a,n,i]=zr(t,Fr);if(e==="humanoid"){let c=JSON.parse(JSON.stringify(Ze));c.palette=Ye(c.palette,{...o?{hair:re(o)}:{},...s?{skin:re(s)}:{},...a?{shirt:re(a)}:{},...n?{pants:re(n)}:{},...i?{boots:re(i)}:{}}),c.name=r,c.tags=[];let u=Z(c);return u.ok?u.spec:le()}let l=Z({name:r,rig:e,palette:{s:re(s??o??[198,156,124]),t:re(a??[58,143,214]),p:re(n??i??[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:e==="blob"?[4,4,4,2]:e==="flyer"?[0,1,4,2]:[2,2,4,2],expressions:{neutral:"f_neutral",blink:"f_blink"}}});return l.ok?l.spec:le()}var Hr={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}},Nr={calm:{},fidgety:{fidget:1,breath:1.3},proud:{chest:.08,breath:.8}};function et(t){let e={amp:.8,arm:.6,bob:0,tempo:1,sway:0,quant:false,breath:1,fidget:0,chest:0,...Hr[t.walk],...Nr[t.idle]};return e.tempo*=.8+.4*t.energy,e.amp*=.85+.3*t.energy,e}function tt(t,e=0){let r=Math.sin(t.phase+e);return t.style.quant?Math.max(-1,Math.min(1,r*3)):r}function rt(t,e,r){let o=tt(e)*r;h(t,"legL","rx",o),h(t,"legR","rx",-o),h(t,"legFL","rx",o),h(t,"legBR","rx",o),h(t,"legFR","rx",-o),h(t,"legBL","rx",-o);}function ot(t,e,r){let o=tt(e)*r;h(t,"armL","rx",-o),h(t,"armR","rx",o);}var Br=(t,e)=>{let r=Math.sin(e.clock*2)*e.style.breath;h(t,"armL","rz",-0.04-.03*r),h(t,"armR","rz",.04+.03*r),h(t,"head","rx",.03*Math.sin(e.clock*1.7)+e.style.chest),h(t,"body","rx",e.style.chest*-0.5),e.style.fidget&&(h(t,"head","ry",.35*Math.sin(e.clock*.7)*Math.sin(e.clock*.31)),h(t,"root","ry",.05*Math.sin(e.clock*.9))),h(t,"body","sy",1+.04*Math.sin(e.clock*3));},Dr=(t,e)=>{rt(t,e,e.style.amp),ot(t,e,e.style.arm),h(t,"root","py",e.style.bob*Math.abs(Math.cos(e.phase))),h(t,"body","rz",e.style.sway*tt(e));},jr=(t,e)=>{rt(t,e,e.style.amp*1.3),ot(t,e,e.style.arm*1.6),h(t,"body","rx",-0.18),h(t,"head","rx",.18),h(t,"root","py",(.8+e.style.bob)*Math.abs(Math.cos(e.phase)));},Gr=(t,e)=>{rt(t,e,e.style.amp*.5*Math.min(1,e.input.speed)),ot(t,e,e.style.arm*.4*Math.min(1,e.input.speed)),h(t,"body","rx",-0.45),h(t,"head","rx",.45),X(t,"armL","rx",.25),X(t,"armR","rx",.25),h(t,"root","py",-1.5);},Vr=(t,e)=>{h(t,"root","rx",-1.3),h(t,"head","rx",1),h(t,"armL","rx",Math.PI-.5+.5*Math.sin(e.t*3)),h(t,"armR","rx",Math.PI-.5+.5*Math.sin(e.t*3+Math.PI)),h(t,"legL","rx",.3*Math.sin(e.t*8)),h(t,"legR","rx",-0.3*Math.sin(e.t*8));},Ur=(t,e)=>{h(t,"legL","rx",.15),h(t,"legR","rx",.1),h(t,"armL","rz",-0.15),h(t,"armR","rz",.15),h(t,"root","py",.6*Math.sin(e.t*2));},Wr=t=>{h(t,"root","rx",-1.35),h(t,"head","rx",1.1),h(t,"armL","rz",-1.3),h(t,"armR","rz",1.3);},Kr=(t,e)=>{let r=.15*Math.sin(e.t*10);h(t,"armL","rz",-0.6-r),h(t,"armR","rz",.6+r),h(t,"legL","rx",.25),h(t,"legR","rx",-0.25);},$r=t=>{h(t,"legL","rx",1.45),h(t,"legR","rx",1.45),h(t,"legL","ry",.1),h(t,"legR","ry",-0.1),h(t,"root","py",-10),h(t,"body","rx",.4),h(t,"legBL","rx",1.2),h(t,"legBR","rx",1.2);},Xr=t=>{h(t,"legL","rx",1.4),h(t,"legR","rx",1.4),h(t,"legL","rz",-0.3),h(t,"legR","rz",.3),h(t,"armL","rx",.45),h(t,"armR","rx",.45);},Yr=t=>{h(t,"root","rx",Math.PI/2),h(t,"root","py",2);},qr=t=>{h(t,"root","rz",Math.PI/2),h(t,"root","py",2);},Zr=(t,e)=>{let r=Math.sin(e.phase*.5);h(t,"root","py",6*Math.max(0,r));let o=r<0?.2*-r:0;h(t,"body","sy",1-o+.1*Math.max(0,r)),h(t,"body","sx",1+o*.6),h(t,"body","sz",1+o*.6);},Jr=(t,e)=>{let r=Math.sin(Math.PI*e.k);h(t,"armR","rx",1.9*r),h(t,"armR","ry",.3*r),h(t,"body","ry",-0.3*r);},Qr=(t,e)=>{let r=Math.sin(Math.PI*e.k);h(t,"armR","rx",.9*r);},eo=(t,e)=>{let r=e.k<.4?-1.5*(e.k/.4):-1.5+3.5*((e.k-.4)/.6);h(t,"armR","rx",e.k>.9?r*(1-e.k)*10:r);},to=(t,e)=>{let r=Math.sin(Math.PI*e.k);h(t,"body","rx",.15*r),h(t,"head","rx",.2*r),h(t,"root","rz",.05*r);},ro=(t,e)=>{let r=Math.sin(Math.PI*e.k);h(t,"root","py",-1.5*r),h(t,"legL","rx",.2*r),h(t,"legR","rx",.2*r),h(t,"body","sy",1-.2*r),h(t,"body","sx",1+.12*r),h(t,"body","sz",1+.12*r);},oo=(t,e)=>{h(t,"armR","rx",1.3+.1*Math.sin(e.t*16)),h(t,"armR","ry",-0.5),h(t,"head","rx",-0.1+.08*Math.sin(e.t*16));},no=t=>{h(t,"armR","rx",2),h(t,"armR","ry",-0.4),h(t,"head","rx",.35);},so=t=>{h(t,"armR","rx",1.57),h(t,"armR","ry",-0.1),h(t,"armL","rx",1.57),h(t,"armL","ry",.35);},ao=t=>{h(t,"armL","rx",.9),h(t,"armL","ry",-0.6);},Pe={idle:Br,walk:Dr,run:jr,sneak:Gr,swim:Vr,fly:Ur,glide:Wr,fall:Kr,sit:$r,ride:Xr,sleep:Yr,dead:qr,hop:Zr,swing:Jr,place:Qr,throw:eo,hurt:to,land:ro,eat:oo,drink:no,draw:so,block:ao},_t={blob:{walk:"hop",run:"hop",sneak:"hop"}},Ot={swing:.3,place:.2,throw:.45,hurt:.3,land:.22};var _e=Math.PI,Oe={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,_e*.46],[1,_e*.46]],"legR.rx":[[0,_e*.46],[1,_e*.46]],"root.py":[[0,-10],[1,-10]]}}},Tn=Object.keys(Oe);function Mn(t){return typeof t=="string"&&t in Oe}function io(t,e){let r=t[0];if(e<=r[0])return r[1];for(let o=1;o<t.length;o++){let s=t[o];if(e<=s[0]){let a=t[o-1],n=(e-a[0])/Math.max(1e-6,s[0]-a[0]),i=n*n*(3-2*n);return a[1]+(s[1]-a[1])*i}}return t[t.length-1][1]}function It(t,e,r){let o=e.loop?r%e.duration:Math.min(r,e.duration);for(let[s,a]of Object.entries(e.tracks)){let n=s.lastIndexOf("."),i=s.slice(0,n),l=s.slice(n+1);l in v&&h(t,i,l,io(a,o));}}var zt={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"]},nt={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 Ft(t,e,r){if(!(r<=0))for(let[o,s]of Object.entries(nt[e].add)){let a=o.lastIndexOf(".");X(t,o.slice(0,a),o.slice(a+1),(s??0)*r);}}var _n={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 On(t){let e=[[/(>:\(|😠|😡|🤬)/u,"angry"],[/(:'\(|😢|😭)/u,"sad"],[/(:\(|☹|🙁|😞)/u,"sad"],[/(:o|:O|😮|😲)/u,"surprised"],[/(😱|😨)/u,"scared"],[/(-_-|😴|😩|🥱)/u,"tired"],[/(:\)|:D|\^\^|😀|😃|😄|😁|🙂|😊|😂)/u,"happy"]];for(let[r,o]of e)if(r.test(t))return o;return null}var lo=[{state:"dead",when:t=>t.dead,clip:"dead",blend:.25},{state:"sleep",when:t=>t.sleeping,clip:"sleep",blend:.3},{state:"ride",when:t=>t.riding,clip:"ride",blend:.2},{state:"sit",when:t=>t.sitting,clip:"sit",blend:.3},{state:"swim",when:t=>t.inWater&&!t.onGround&&!t.flying,clip:"swim",blend:.3},{state:"glide",when:t=>t.gliding,clip:"glide",blend:.25},{state:"fly",when:t=>t.flying,clip:"fly",blend:.25},{state:"fall",when:(t,e)=>e.airTime>.35&&t.vy<-4,clip:"fall",blend:.2},{state:"sneak",when:t=>t.sneaking,clip:"sneak",blend:.15},{state:"run",when:t=>t.sprinting&&t.speed>3||t.speed>6.5,clip:"run",blend:.15},{state:"walk",when:t=>t.speed>.4,clip:"walk",blend:.15},{state:"idle",when:()=>true,clip:"idle",blend:.2}],co=new Set(["hurt","land"]),ho={eat:"eat",drink:"drink",draw:"draw",block:"block"},po={tail:(t,e)=>[["ry",-t.yawRate*.25+.12*Math.sin(e*2)],["rx",-(.1+Math.min(t.speed,8)*.06)]],cape:(t,e)=>[["rx",-(.05+Math.min(t.speed,8)*.12)-(t.speed>1?.06*Math.sin(e*9):0)-(t.vy<-3?.4:0)]],hair:t=>[["rx",-Math.min(t.speed,8)*.03]],ear:(t,e)=>[["rz",.08*Math.sin(e*1.3)+Math.min(t.speed,6)*.02]],antenna:(t,e)=>[["rx",.1*Math.sin(e*3)-t.vy*.02]],wingL:(t,e)=>t.flying||t.gliding||!t.onGround&&!t.inWater?[["rz",t.gliding?-0.05:-0.7*Math.sin(e*12)]]:[["rz",1.1+.05*Math.sin(e*1.5)]],wingR:(t,e)=>t.flying||t.gliding||!t.onGround&&!t.inWater?[["rz",t.gliding?.05:.7*Math.sin(e*12)]]:[["rz",-1.1-.05*Math.sin(e*1.5)]]},Ie=t=>{let e=Math.max(0,Math.min(1,t));return e*e*(3-2*e)},ze=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(e,r,o=[]){this.rig=e,this.style=et(r),this.faces=new Set(o);}setRandom(e){this.random=e;}random=Math.random;setStyle(e){this.style=et(e);}setEmotion(e,r){r&&r>0?this.flash={emotion:e,left:r}:this.mood=e;}get emotion(){return this.emote?.def.emotion?this.emote.def.emotion:this.flash?.emotion??this.mood}get emoting(){return this.emote?.id??null}playEmote(e){this.emote={id:e,def:Oe[e],t:0};}stopEmote(){this.emote=null;}trigger(e){switch(e){case "swing":case "place":case "throw":case "hurt":case "land":{let r=e;this.actions=this.actions.filter(o=>o.clip!==r),this.actions.push({clip:r,t:0,dur:Ot[r]??.3}),e==="hurt"&&this.setEmotion("hurt",.8);break}}}update(e,r=Me()){e=Math.min(e,.1),this.clock+=e;let o=this.emotion,s=nt[o].tempo*this.style.tempo;!r.onGround&&!r.inWater?this.airTime+=e:(!this.wasOnGround&&this.airTime>.3&&r.onGround&&this.trigger("land"),this.airTime=0),this.wasOnGround=r.onGround,this.phase+=r.speed*e*3.5*s;let a=lo.find(c=>c.when(r,this));a.state!==this.state&&(Te(this.from,this.lastLoco),this.state=a.state,this.stateT=0,this.blendT=0,this.blendDur=a.blend),this.stateT+=e,ce(this.loco);let n=_t[this.rig]?.[a.clip]??a.clip,i={t:this.stateT,k:0,phase:this.phase,input:r,style:this.style,clock:this.clock*s};if(Pe[n](this.loco,i),ce(this.pose),this.blendT<this.blendDur?(this.blendT+=e,Pt(this.pose,this.from,this.loco,Ie(this.blendT/this.blendDur))):Te(this.pose,this.loco),Te(this.lastLoco,this.pose),this.emote){let c=this.emote;if(c.t+=e,r.speed>1||this.state!=="idle"||!c.def.loop&&c.t>=c.def.duration)this.emote=null;else {let g=c.def.loop?Ie(c.t/.15):Ie(Math.min(c.t/.15,(c.def.duration-c.t)/.15));ce(this.tmp),It(this.tmp,c.def,c.t),this.overlay(this.tmp,g,false);}}let l=r.use?ho[r.use]:null;l&&(this.useClip=l),this.useW=Math.max(0,Math.min(1,this.useW+(l?e:-e)*8)),this.useClip&&this.useW>0?(ce(this.tmp),Pe[this.useClip](this.tmp,{...i,t:this.clock}),this.overlay(this.tmp,Ie(this.useW),false)):r.held!=="none"&&!this.emote&&X(this.pose,"armR","rx",r.held==="staff"?.35:.2);for(let c of this.actions){c.t+=e;let u=Math.min(1,c.t/c.dur);ce(this.tmp),Pe[c.clip](this.tmp,{...i,t:c.t,k:u}),this.overlay(this.tmp,1,co.has(c.clip));}this.actions=this.actions.filter(c=>c.t<c.dur),this.state!=="dead"&&this.state!=="sleep"&&(X(this.pose,"head","ry",Math.max(-1.1,Math.min(1.1,r.lookYaw))),X(this.pose,"head","rx",Math.max(-1.2,Math.min(1.2,r.lookPitch)))),this.flash&&(this.flash.left-=e)<=0&&(this.flash=null);for(let c of a$1){let u=this.postureW.get(c)??0,b=u+((c===o?1:0)-u)*Math.min(1,e*6);this.postureW.set(c,b),this.state!=="dead"&&Ft(this.pose,c,b);}for(let[c,u]of Object.entries(po))for(let[b,g]of u(r,this.clock)){let R=c+"."+b,E=this.springs.get(R);E||this.springs.set(R,E={x:g,v:0});let F=60,K=9;E.v+=(F*(g-E.x)-K*E.v)*e,E.x+=E.v*e,X(this.pose,c,b,E.x);}return this.expression=this.face(r,e,o),this.pose}overlay(e,r,o){for(let[s,a]of e){let n=fe(this.pose,s);for(let i=0;i<9;i++)o?i>=v.sx?n[i]=n[i]*(1+(a[i]-1)*r):n[i]=n[i]+(a[i]-ue[i])*r:n[i]=n[i]+(a[i]-n[i])*r;}}face(e,r,o){let s=n=>n.find(i=>this.faces.has(i))??"neutral";if(e.dead||this.state==="dead"||e.sleeping)return s(["blink","hurt","neutral"]);let a=s(zt[o]);return e.viseme!==void 0?(this.talkT=0,e.viseme!=="rest"&&e.viseme!=="MBP"?s(["talk",a]):a):e.talk?(this.talkT+=r,Math.floor(this.talkT/.12)%2===0?s(["talk",a]):a):(this.talkT=0,this.blinking>0?(this.blinking-=r,s(["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 mo={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"}},uo={handR:"handR",handL:"handL",head:"headTop"},Ht=class{view;animator;input=Me();seed;pose="idle";jumpT=-1;constructor(e,r={}){this.view=new Ae(e,{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(e){let r=this.view.hash;this.view.setSpec(e),this.view.hash!==r&&(this.animator=this.newAnimator());}setEmotion(e){this.animator.setEmotion(e);}setViseme(e){this.input.viseme=e;}setPose(e){if(e===this.pose)return;this.pose=e;let r=mo[e];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(e){this.animator.playEmote(e);}attach(e,r){this.view.attach(uo[e],r);}update(e){let r=this.input;this.jumpT>=0&&(this.jumpT+=e,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(e,r);this.view.applyPose(o),this.view.setExpression(this.animator.expression);}dispose(){this.view.dispose();}newAnimator(){let e=this.view.spec,r=new ze(e.rig,e.style,this.view.expressions);return r.setRandom(a(this.seed)),r}};var fo=be.map(t=>{let e=q[t],r=e.bones.map(s=>`${s.name}@[${s.pivot.join(",")}]`).join(" "),o=e.defaultParts.map(s=>`${s.bone} ${s.size.join("x")} at [${s.pos.join(",")}]`).join("; ");return `- "${t}" \u2014 ${e.hint}. Bones (name@pivot): ${r}. Default body: ${o}.`}).join(`
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-WKHHFTK2.js';import {b,a}from'../chunk-CGF2TQVK.js';import*as _ from'three';var ct={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 ht={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 pt={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 mt={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 Ro=["root","body","head","armL","armR","legL","legR","legFL","legFR","legBL","legBR","tail","wingL","wingR","ear","hair","cape","antenna","static"],ke=["tail","wingL","wingR","ear","hair","cape","antenna","static"],Eo=["handR","handL","headTop","face","back","waist","shoulders"],be=["humanoid","quadruped","flyer","blob"];var q={humanoid:pt,quadruped:mt,flyer:ht,blob:ct};var dt=1,De=["front","back","left","right","top","bottom"],je=["neutral","blink","happy","sad","angry","surprised","scared","tired","hurt","talk"],Ge=["normal","bouncy","heavy","sneaky","robotic"],Ve=["calm","fidgety","proud"],gt={parts:64,bones:16,palette:32,textures:48,texturePixels:32768,textureSide:32,partSide:32,coord:64},pe={noise:.5,outline:.4,shade:.25,density:2},j=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),ge=t=>Array.isArray(t)?t:[];function W(t,e,r,o){let s=typeof t=="number"?t:typeof t=="string"?Number(t):NaN;return Number.isFinite(s)?Math.min(o,Math.max(r,s)):e}function Ne(t,e,r){if(typeof t!="string")return r;let o=t.trim();if(e.includes(o))return o;let s=o.toLowerCase().replace(/[\s-]+/g,"_");return e.find(n=>n.toLowerCase()===s)??r}function te(t,e,r){return typeof t=="string"?t.trim().slice(0,r):e}function Re(t,e,r=null){if(!Array.isArray(t)||t.length<3)return r;let o=t.slice(0,3).map(s=>W(s,NaN,-e,e));return o.every(Number.isFinite)?o:r}var ut={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 ft(t){if(typeof t!="string")return null;let e=t.trim().toLowerCase();if(ut[e])return ut[e];let r=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/.exec(e);if(!r)return null;let o=r[1];return "#"+(o.length===3?o.split("").map(s=>s+s).join(""):o)}var ye=new Set(["."," "]),bt=t=>/^[A-Za-z0-9_]{1,24}$/.test(t),Bt={human:"humanoid",biped:"humanoid",person:"humanoid",animal:"quadruped",four_legs:"quadruped",quadrupedal:"quadruped",bird:"flyer",winged:"flyer",dragon:"flyer",slime:"blob",ghost:"blob"};function Dt(t){if(typeof t!="string")return "humanoid";let e=t.trim().toLowerCase().replace(/[\s-]+/g,"_");return be.includes(e)?e:Bt[e]??"humanoid"}function yt(t,e){let r=/^(.*?)(L|R)$/.exec(t);if(!r)return t;let o=r[1]+(r[2]==="L"?"R":"L");return e(o)?o:t}function Z(t){if(typeof t=="string"){let m=d(t);if(!m.ok)return {ok:false,error:m.error,truncated:m.truncated};t=m.value;}if(!j(t))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 t)&&!("rig"in t)){let m=t.character??t.spec??t.characterSpec;j(m)&&(t=m);}let e=t,r=gt,o=[];typeof e.version=="number"&&e.version>dt&&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:e.version}));let s=Dt(e.rig),a=q[s],n={};if(j(e.palette))for(let[m,k]of Object.entries(e.palette)){if(Object.keys(n).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 y=ft(k);if(m.length!==1||ye.has(m)||!y){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:m}));continue}n[m]=y;}let i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",l=(m,k)=>{if(typeof m!="string")return k;if(m.length===1&&n[m])return m;let y=ft(m);if(!y)return k;let M=Object.entries(n).find(([,d])=>d===y);if(M)return M[0];if(Object.keys(n).length>=r.palette)return k;let p=[...i].find(d=>!n[d]);return p?(n[p]=y,p):k},c$1={},u=0;if(j(e.textures))for(let[m,k]of Object.entries(e.textures)){if(!bt(m)){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:m.slice(0,30)}));continue}if(Object.keys(c$1).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 y=Vt(k,n,o,m);if(y){if(u+y.w*y.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:m}));continue}u+=y.w*y.h,c$1[m]=y;}}let b=new Set(a.bones.map(m=>m.name)),g=[];for(let m of ge(e.bones)){if(!j(m))continue;let k=te(m.name,"",24);if(!k||!bt(k))continue;let y=Re(m.pivot,r.coord);if(!y||g.some(x=>x.name===k))continue;if(g.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 M=b.has(k),p=te(m.parent,"",24),d=M?a.bones.find(x=>x.name===k).parent??"":b.has(p)||g.some(x=>x.name===p)?p:a.bones.find(x=>x.role==="body").name;g.push({name:k,parent:d,pivot:y,role:M?"static":Ne(m.role,ke,"static")}),b.add(k);}let R=Object.keys(n)[0]??"s",E=[];for(let m of ge(e.parts)){if(E.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(!j(m))continue;let k=Re(m.size,r.partSide),y=Re(m.pos??m.center??m.at,r.coord);if(!k||!y||k.some(f=>f<=0))continue;let M=te(m.bone,"",24);b.has(M)||(M&&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:M})),M=a.bones.find(f=>f.role==="body").name);let p={bone:M,size:k,pos:y,color:l(m.color,R)};if(j(m.faces)){let f={};for(let L of De){let I=m.faces[L];if(typeof I=="string")if(c$1[I])f[L]=I;else {let G=l(I,"");G&&(f[L]=G);}}Object.keys(f).length&&(p.faces=f);}let d=Re(m.rot??m.rotation,180);d&&d.some(f=>f!==0)&&(p.rot=d),(m.mirror===true||m.mirror==="x")&&(p.mirror=true);let x=te(m.name,"",24);x&&(p.name=x),E.push(p);}if(!E.length){for(let[m,k]of Object.entries(jt))n[m]||(n[m]=k);E.push(...a.defaultParts.map(Gt));}let F=null;if(j(e.face)){let m=e.face,k=b.has(te(m.bone,"",24))?te(m.bone,"",24):a.faceBone,y=ge(m.rect).map(p=>Math.round(W(p,NaN,0,r.partSide))),M={};if(j(m.expressions))for(let p of je){let d=m.expressions[p];typeof d=="string"&&c$1[d]&&(M[p]=d);}if(!M.neutral){let p=Object.values(M)[0];p&&(M.neutral=p);}if(M.neutral){let p=c$1[M.neutral];F={bone:k,rect:y.length===4&&y.every(Number.isFinite)&&y[2]>0&&y[3]>0?y:[0,0,p.w,p.h],expressions:M};}else Object.keys(m).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 K=j(e.style)?e.style:{},T=j(e.voice)?e.voice:{},A=j(e.finish)?e.finish:{};return {ok:true,spec:{version:dt,name:te(e.name,Ee(),40)||Ee(),description:te(e.description,"",300),rig:s,scale:W(e.scale,1,.25,3),palette:n,textures:c$1,parts:E,bones:g,face:F,style:{walk:Ne(K.walk,Ge,"normal"),idle:Ne(K.idle,Ve,"calm"),energy:W(K.energy,.5,0,1)},voice:{pitch:W(T.pitch,1,.5,2)},tags:ge(e.tags).filter(m=>typeof m=="string"&&!!m.trim()).slice(0,8).map(m=>m.trim().slice(0,24)),finish:{noise:W(A.noise,pe.noise,0,1),outline:W(A.outline,pe.outline,0,1),shade:W(A.shade,pe.shade,0,1),density:Math.round(W(A.density,pe.density,1,4))}},warnings:o}}var jt={s:"#c69c7c",t:"#3a8fd6",p:"#2c3e6b"};function Gt(t){return JSON.parse(JSON.stringify(t))}function Vt(t,e,r,o){let s=Array.isArray(t)?{rows:t}:j(t)?t:null;if(!s)return null;let a=gt.textureSide,n=ge(s.rows??s.pixels).filter(u=>typeof u=="string");if(!n.length)return null;let i=Math.round(W(s.h??s.height,n.length,1,a)),l=Math.round(W(s.w??s.width,Math.max(...n.map(u=>u.length)),1,a)),c$1=false;for(n=n.slice(0,i).map(u=>{let b="";for(let g=0;g<l;g++){let R=u[g]??".";ye.has(R)||e[R]?b+=R===" "?".":R:(c$1=true,b+=".");}return b});n.length<i;)n.push(".".repeat(l));return c$1&&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:l,h:i,rows:n}}function Be(t){return Array.isArray(t)?"["+t.map(Be).join(",")+"]":j(t)?"{"+Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>JSON.stringify(e)+":"+Be(t[e])).join(",")+"}":JSON.stringify(t)}function me(t){let e=Be(t),r=b(e),o=b("~"+e);return r.toString(16).padStart(8,"0")+o.toString(16).padStart(8,"0")}function zo(t){return q[t.rig]}function xt(t){let r=q[t.rig].bones.map(o=>{let s=t.bones.find(a=>a.name===o.name);return {name:o.name,role:o.role,parent:o.parent,pivot:(s?.pivot??o.pivot).slice()}});for(let o of t.bones)r.some(s=>s.name===o.name)||r.push({name:o.name,role:o.role,parent:o.parent,pivot:o.pivot.slice()});return r}function Ee(){return c({en:"Character",ru:"\u041F\u0435\u0440\u0441\u043E\u043D\u0430\u0436"})}var Fo=t=>t==="\u041F\u0435\u0440\u0441\u043E\u043D\u0430\u0436"||t==="Character";var Ut={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 Ue(t){let e=parseInt(t.slice(1),16);return [e>>16&255,e>>8&255,e&255]}function wt(t,e,r,o,s,a){let n=((r-1-s)*e+o)*4;t[n]=a[0],t[n+1]=a[1],t[n+2]=a[2],t[n+3]=255;}function Wt(t){t.sort((e,r)=>r.h-e.h||r.w-e.w||(e.key<r.key?-1:1));for(let e=16;;e*=2){let r=0,o=0,s=0;for(let n of t)r+n.w>e&&(r=0,o+=s,s=0),n.x=r,n.y=o,r+=n.w,s=Math.max(s,n.h);let a=o+s;if(a<=e||e>=1024){let n=16;for(;n<a;)n*=2;return {w:e,h:n}}}}function kt(t,e,r){let o=Math.imul(e,374761393)+Math.imul(r,668265263)+Math.imul(t,2246822519);return o=Math.imul(o^o>>>13,1274126177),((o^o>>>16)>>>0)/4294967296}function Kt(t,e,r,o,s,a,n,i){let c=1+(.55*kt(n,e,r)+.45*kt(n^1540483477,Math.floor(e/3),Math.floor(r/3))-.5)*2*i.noise*.14;return a==="s"?c+=i.shade*.16*(.5-(r+.5)/s):a==="t"?c+=i.shade*.08:c-=i.shade*.2,o>=3&&s>=3&&(e===0||r===0||e===o-1||r===s-1)&&(c*=1-.5*i.outline),[Math.max(0,Math.min(255,t[0]*c)),Math.max(0,Math.min(255,t[1]*c)),Math.max(0,Math.min(255,t[2]*c))]}var We=Math.PI/180;function Rt(t,e){if(!e)return t;let[r,o,s]=t,[a,n,i]=[e[0]*We,e[1]*We,e[2]*We],l=Math.cos(i),c=Math.sin(i);return [r,o]=[r*l-o*c,r*c+o*l],l=Math.cos(n),c=Math.sin(n),[r,s]=[r*l+s*c,-r*c+s*l],l=Math.cos(a),c=Math.sin(a),[o,s]=[o*l-s*c,o*c+s*l],[r,o,s]}function $t(t,e){let r=[];for(let o of t.parts){if(r.push({...o,flip:false}),!o.mirror)continue;let s=o.faces?{...o.faces,left:o.faces.right,right:o.faces.left}:void 0;s&&(s.left===void 0&&delete s.left,s.right===void 0&&delete s.right);let a={...o,bone:yt(o.bone,e),pos:[-o.pos[0],o.pos[1],o.pos[2]],flip:true};s?a.faces=s:delete a.faces,o.rot&&(a.rot=[o.rot[0],-o.rot[1],-o.rot[2]]),r.push(a);}return r}function Et(t){let e=q[t.rig],r=xt(t),o=p=>r.some(d=>d.name===p),s=$t(t,o),a=t.finish??pe,n=new Map,i=(p,d)=>{let x=p.faces?.[d],f=x!==void 0?t.textures[x]:void 0,L=x!==void 0&&t.palette[x]?x:p.color,[I,G]=d==="front"||d==="back"?[p.size[0],p.size[1]]:d==="left"||d==="right"?[p.size[2],p.size[1]]:[p.size[0],p.size[2]],C=(he,oe)=>Math.max(1,Math.min(64,oe*Math.max(1,Math.round(he*a.density/oe)))),N=f?C(I,f.w):C(I,1),B=f?C(G,f.h):C(G,1),P=d==="top"?"t":d==="bottom"?"b":"s",H=(f?"t:"+x:"c:"+L)+"|"+N+"x"+B+P,D=n.get(H);if(D)return D;let Q=b(H),ee=f?null:Ue(t.palette[L]??"#ff00ff");return D={key:H,w:N,h:B,x:0,y:0,paint:(he,oe,Fe,ne,se)=>{for(let Y=0;Y<B;Y++)for(let U=0;U<N;U++){let st=ee;if(f){let at=f.rows[Math.floor(Y*f.h/B)][Math.floor(U*f.w/N)];if(ye.has(at))continue;let it=t.palette[at];if(!it)continue;st=Ue(it);}wt(he,oe,Fe,ne+U,se+Y,Kt(st,U,Y,N,B,P,Q,a));}}},n.set(H,D),D},l=(p,d)=>{let x="e:"+p,f=n.get(x);return f||(f={key:x,w:d.w,h:d.h,x:0,y:0,paint:(L,I,G,C,N)=>{for(let B=0;B<d.h;B++)for(let P=0;P<d.w;P++){let H=d.rows[B][P];if(ye.has(H))continue;let D=t.palette[H];D&&wt(L,I,G,C+P,N+B,Ue(D));}}},n.set(x,f)),f},c=s.map(p=>({p,faces:De.map(d=>({f:d,cell:i(p,d)}))})),u=t.face,b$1=[];if(u)for(let[p,d]of Object.entries(u.expressions)){let x=t.textures[d];x&&b$1.push([p,l(d,x)]);}let{w:g,h:R}=Wt([...n.values()]),E=new Uint8Array(g*R*4);for(let p of n.values())p.paint(E,g,R,p.x,p.y);let F=.01,K=p=>[(p.x+F)/g,1-(p.y+F)/R,(p.x+p.w-F)/g,1-(p.y+p.h-F)/R],T=new Map;for(let p of r)T.set(p.name,{pos:[],nrm:[],uv:[],idx:[]});let A=0;for(let{p,faces:d}of c){let x=T.get(p.bone),f=r.find(I=>I.name===p.bone).pivot,L=[p.size[0]/2,p.size[1]/2,p.size[2]/2];A=Math.max(A,p.pos[1]+L[1]);for(let{f:I,cell:G}of d){let C=Ut[I],N=(ne,se)=>{let Y=[L[0]*(C.tl[0]+2*(C.u[0]*ne+C.d[0]*se)),L[1]*(C.tl[1]+2*(C.u[1]*ne+C.d[1]*se)),L[2]*(C.tl[2]+2*(C.u[2]*ne+C.d[2]*se))],U=Rt(Y,p.rot);return [p.pos[0]+U[0]-f[0],p.pos[1]+U[1]-f[1],p.pos[2]+U[2]-f[2]]},B=Rt(C.n,p.rot),P=x.pos.length/3,[H,D,Q,ee]=K(G),[he,oe]=p.flip?[Q,H]:[H,Q],Fe=[[0,0,he,D],[1,0,oe,D],[1,1,oe,ee],[0,1,he,ee]];for(let[ne,se,Y,U]of Fe)x.pos.push(...N(ne,se)),x.nrm.push(...B),x.uv.push(Y,U);x.idx.push(P,P+2,P+1,P,P+3,P+2);}}let V=r.map(p=>{let d=T.get(p.name);return {name:p.name,role:p.role,parent:p.parent,pivot:p.pivot,positions:Float32Array.from(d.pos),normals:Float32Array.from(d.nrm),uvs:Float32Array.from(d.uv),indices:Uint16Array.from(d.idx)}}),m=null;if(u&&b$1.length){let d=t.parts.filter(f=>f.bone===u.bone).sort((f,L)=>L.size[0]*L.size[1]*L.size[2]-f.size[0]*f.size[1]*f.size[2])[0],x=r.find(f=>f.name===u.bone);if(d&&x){let[f,L,I,G]=u.rect,C=d.pos[0]+d.size[0]/2-f,N=d.pos[1]+d.size[1]/2-L,B=d.pos[2]-d.size[2]/2-.05,P=x.pivot,H=(Q,ee)=>[Q-P[0],ee-P[1],B-P[2]],D={};for(let[Q,ee]of b$1)D[Q]=K(ee);m={bone:u.bone,corners:Float32Array.from([...H(C,N),...H(C-I,N),...H(C-I,N-G),...H(C,N-G)]),uv:D};}}let k=e.sockets.filter(p=>o(p.bone)).map(p=>{let d=e.bones.find(x=>x.name===p.bone);return {name:p.name,bone:p.bone,at:[p.at[0]-d.pivot[0],p.at[1]-d.pivot[1],p.at[2]-d.pivot[2]]}}),y=Math.max(1,A),M=y>e.height.max?e.height.max/y:y<e.height.min?e.height.min/y:1;return {hash:me(t),rig:t.rig,bones:V,atlas:{w:g,h:R,data:E},face:m,sockets:k,height:y,scale:t.scale*M,eye:e.eye*y/Xt(t.rig)}}function Xt(t){let e=1;for(let r of q[t].defaultParts)e=Math.max(e,r.pos[1]+r.size[1]/2);return e}var Ke=new Map;function Yt(t){let e=new Map;for(let n of t.bones){if(!n.indices.length){e.set(n.name,null);continue}let i=new _.BufferGeometry;i.setAttribute("position",new _.BufferAttribute(n.positions,3)),i.setAttribute("normal",new _.BufferAttribute(n.normals,3)),i.setAttribute("uv",new _.BufferAttribute(n.uvs,2)),i.setIndex(new _.BufferAttribute(n.indices,1)),i.computeBoundingSphere(),i.userData.shared=true,e.set(n.name,i);}let{w:r,h:o,data:s}=t.atlas,a=new _.DataTexture(s,r,o,_.RGBAFormat);return a.magFilter=_.NearestFilter,a.minFilter=_.NearestFilter,a.generateMipmaps=false,a.colorSpace=_.SRGBColorSpace,a.needsUpdate=true,{layout:t,geometries:e,texture:a,refs:0}}function $e(t){let e=Ke.get(me(t));return e||(e=Yt(Et(t)),Ke.set(e.layout.hash,e)),e.refs++,e}function Se(t){if(!(--t.refs>0)){Ke.delete(t.layout.hash);for(let e of t.geometries.values())e?.dispose();t.texture.dispose();}}var w=class t{constructor(e,r,o="."){this.w=e;this.h=r;this.g=Array.from({length:r},()=>new Array(e).fill(o));}w;h;g;px(e,r,o){return e>=0&&r>=0&&e<this.w&&r<this.h&&(this.g[r][e]=o),this}rect(e,r,o,s,a){for(let n=r;n<r+s;n++)for(let i=e;i<e+o;i++)this.px(i,n,a);return this}row(e,r,o,s){return this.rect(r,e,o-r+1,1,s)}col(e,r,o,s){return this.rect(e,r,1,o-r+1,s)}where(e,r){for(let o=0;o<this.h;o++)for(let s=0;s<this.w;s++)e(s,o)&&this.px(s,o,r);return this}flipped(){let e=new t(this.w,this.h);for(let r=0;r<this.h;r++)for(let o=0;o<this.w;o++)e.px(this.w-1-o,r,this.g[r][o]);return e}tex(){return {w:this.w,h:this.h,rows:this.g.map(e=>e.join(""))}}};var qt={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 J(t,e){let r=parseInt(t.slice(1),16);return "#"+[r>>16&255,r>>8&255,r&255].map(s=>Math.max(0,Math.min(255,Math.round(s*e)))).map(s=>s.toString(16).padStart(2,"0")).join("")}function Ye(t,e){let r={...t};return e.skin&&(r.s=e.skin,r.S=J(e.skin,.86),r.m=J(e.skin,.66)),e.hair&&(r.h=e.hair,r.H=J(e.hair,1.25),r.k=J(e.hair,.6)),e.shirt&&(r.t=e.shirt,r.T=J(e.shirt,1.15),r.D=J(e.shirt,.8)),e.pants&&(r.p=e.pants,r.P=J(e.pants,.8)),e.boots&&(r.z=e.boots,r.Z=J(e.boots,.78)),e.eyes&&(r.b=e.eyes),r}var Zt=new w(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"),St=new w(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((t,e)=>e>4&&e<11&&t>8&&(t+e)%4===0,"k"),Jt=St.flipped(),Qt=new w(16,16,"h").where((t,e)=>(t+2*e)%5===0,"H").where((t,e)=>e>8&&(t*3+e)%7===0,"k").rect(4,14,8,2,"s"),er=new w(16,16,"h").where((t,e)=>(t+2*e)%5===0,"H").where((t,e)=>(3*t+e)%9===0,"k"),tr=new w(18,4,"h").where((t,e)=>(t*7+e*3)%5===0,"H").where((t,e)=>e===3&&t*5%3===0,"k"),rr=new w(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"),or=new w(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"),nr=new w(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"),sr=new w(16,2,"B").rect(7,0,2,2,"g").px(3,0,"k").px(12,0,"k"),ar=new w(6,24,"s").row(23,0,5,"S").col(2,21,23,"S"),ir=new w(8,13,"t").col(0,0,9,"D").row(9,0,7,"D").rect(0,10,8,3,"T").row(12,0,7,"D"),lr=new w(8,24,"p").col(4,1,21,"P").row(0,0,7,"P"),cr=new w(8,24,"p").col(3,0,21,"P").row(0,0,7,"P"),hr=new w(8,24,"p").col(3,0,21,"P"),pr=new w(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"),mr=new w(10,9,"z").row(0,0,9,"Z").rect(0,7,10,2,"Z").col(5,1,6,"Z");function $(t){let e=new w(16,10,"."),r=(s,a,n)=>{if(t.brows==="flat")e.row(1,s,s+2,"k");else if(t.brows==="high")e.row(0,s,s+2,"k");else {let i=t.brows==="down"?1:0,l=1-i;e.px(a,i,"k").px(s+1,t.brows==="down"?0:1,"k"),e.px(n,l,"k");}};r(3,5,3),r(10,10,12);let o=s=>{if(t.eyes===0){e.row(3,s,s+2,"k");return}let a=t.eyes===3||t.eyes===2?2:3;for(let n=a;n<a+t.eyes;n++)e.px(s,n,"w").px(s+1,n,"b").px(s+2,n,"w");};switch(o(3),o(10),t.mouth){case "line":e.row(7,6,9,"m");break;case "smile":e.px(5,6,"m").px(10,6,"m").row(7,6,9,"m");break;case "frown":e.row(7,6,9,"m").px(5,8,"m").px(10,8,"m");break;case "open":e.rect(6,7,4,2,"o");break;case "small":e.rect(7,7,2,2,"o");break;case "wide":e.row(7,5,10,"m").rect(6,8,4,1,"o");break}return e}var vt={f_neutral:$({brows:"flat",eyes:2,mouth:"line"}),f_blink:$({brows:"flat",eyes:0,mouth:"line"}),f_happy:$({brows:"high",eyes:2,mouth:"smile"}),f_sad:$({brows:"up",eyes:2,mouth:"frown"}),f_angry:$({brows:"down",eyes:1,mouth:"wide"}),f_surprised:$({brows:"high",eyes:3,mouth:"small"}),f_scared:$({brows:"up",eyes:3,mouth:"open"}),f_tired:$({brows:"flat",eyes:1,mouth:"line"}),f_hurt:$({brows:"down",eyes:0,mouth:"open"}),f_talk:$({brows:"flat",eyes:2,mouth:"open"})},dr=new w(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"),ur=new w(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"),fr=new w(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"),br=new w(8,9,"t").row(3,0,7,"D").rect(0,7,8,2,"T"),ve=(t,e)=>t.row(e-1,0,t.w-1,"D").where((r,o)=>o>=e&&o<=e+3&&(r+o)%2===0,"T").row(e+4,0,t.w-1,"D"),gr=ve(new w(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((t,e)=>e>=18&&e<=19&&t%2===0,"D").where((t,e)=>e>=18&&e<=19&&t%2===1,"T").rect(0,20,16,4,"p"),yr=ve(new w(16,24,"t"),6).row(0,4,11,"T").where((t,e)=>e>=18&&e<=19,"D").rect(0,20,16,4,"p"),xr=ve(new w(8,24,"t"),6).where((t,e)=>e>=18&&e<=19,"D").rect(0,20,8,4,"p"),wr=ve(new w(8,22,"t"),9).where((t,e)=>e>=19&&t%2===0,"D"),Ct=t=>new w(8,24,"s").rect(0,0,8,12,"p").col(t,1,10,"P").row(11,0,7,"P").row(12,0,7,"S").rect(0,19,8,5,"l"),kr=Ct(4),Rr=Ct(3),Er=new w(9,5,"z").row(1,3,5,"l").rect(0,3,9,2,"l"),Sr=new w(10,5,"z").row(1,3,6,"Z").rect(0,3,10,2,"l"),vr=new w(17,6,"a").rect(0,4,17,2,"A"),Cr=new w(22,22,"a").where((t,e)=>(t*3+e*5)%11===0,"A"),Tr=new w(17,20,"h").where((t,e)=>(t*5+e)%4===0,"H").where((t,e)=>e>10&&(t*3+e*2)%7===0,"k"),S=t=>t.tex(),Tt=["shirt","tee","sweater"],Mt=["pants","shorts"],At=["boots","sneakers"],Yo=["short","long","curly","none"],ie=(t,e={})=>({front:t,back:t,left:t,right:t,...e});function qe(t={}){let e=t.top??"shirt",r=t.bottom??"pants",o=t.shoes??"boots",s=t.hair??"short",a=Ye(qt,t.colors??{});a={...a,a:t.colors?.hat??"#d9c9a3"},a.A=J(a.a,.72);let n={head_front:S(Zt),head_left:S(St),head_right:S(Jt),head_back:S(Qt),hair_top:S(er),hair_band:S(tr),arm_skin:S(ar),...Object.fromEntries(Object.entries(vt).map(([E,F])=>[E,S(F)]))},i=[{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(s!=="none"){if(t.hat||i.push({name:"hair",bone:"head",size:s==="curly"?[9,2.2,9]:[8.6,1.6,8.6],pos:[0,s==="curly"?32.5:32.2,.15],color:"h",faces:ie("hair_band",{top:"hair_top"})}),s==="curly"&&!t.hat)for(let[E,F]of [[-2,-1.5],[2,.5],[-0.5,2.5]])i.push({name:"curl",bone:"head",size:[3.2,1.4,3.2],pos:[E,33.9,F],color:"h",faces:ie("hair_band",{top:"hair_top"})});s==="long"?(n.hair_long=S(Tr),i.push({name:"hairLong",bone:"head",size:[8.8,10,1],pos:[0,27,4.4],color:"h",faces:ie("hair_long",{top:"hair_top"})},{name:"hairSide",bone:"head",size:[.8,9,6],pos:[-4.4,27.5,1],color:"h",faces:ie("hair_long",{top:"hair_top"}),mirror:true})):i.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"}});}t.hat&&(n.hat_crown=S(vr),n.hat_brim=S(Cr),i.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:ie("hat_crown")}));let l={shirt:[rr,or,nr],tee:[dr,ur,fr],sweater:[gr,yr,xr]},[c$1,u,b]=l[e];n.top_front=S(c$1),n.top_back=S(u),n.top_side=S(b),i.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"}}),e==="shirt"&&(n.belt=S(sr),i.push({name:"belt",bone:"body",size:[8.4,1,4.4],pos:[0,13.5,0],color:"B",faces:{front:"belt",back:"belt"}})),i.push({name:"arm",bone:"armL",size:[3,12,3],pos:[-5.5,18,0],color:"s",faces:ie("arm_skin",{top:"t",bottom:"S"}),mirror:true});let g=e==="sweater"?11:e==="tee"?4.5:6.5;n.sleeve=S(e==="sweater"?wr:e==="tee"?br:ir),i.push({name:"sleeve",bone:"armL",size:[3.6,g,3.6],pos:[-5.5,24-g/2,0],color:"t",faces:ie("sleeve",{bottom:"D"}),mirror:true}),r==="shorts"?(n.leg_front=S(kr),n.leg_side=S(Rr)):(n.leg_front=S(lr),n.leg_back=S(cr),n.leg_side=S(hr)),i.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"?(n.shoe_front=S(pr),n.shoe_side=S(mr)):(n.shoe_front=S(Er),n.shoe_side=S(Sr));let R=o==="boots"?4.5:2.5;return i.push({name:"shoe",bone:"legL",size:[4.6,R,5.2],pos:[-2,R/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:t.name??c({en:"Traveler",ru:"\u041F\u0443\u0442\u043D\u0438\u043A"}),description:t.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:n,parts:i,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:t.tags??["player"]}}function Ce(t,e){return {textures:Object.fromEntries(Object.entries(vt).map(([r,o])=>[r,S(o)])),face:{bone:t,rect:e,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 Ze=qe(),Xe=null;function le(){if(!Xe){let t=Z(Ze);if(!t.ok)throw new Error(t.error);Xe=t.spec;}return Xe}function Lt(t){let e=document.createElement("canvas");e.width=256,e.height=48;let r=e.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(t.slice(0,18),128,25));let o=new _.CanvasTexture(e),s=new _.Sprite(new _.SpriteMaterial({map:o,depthTest:false,transparent:true}));return s.scale.set(1.6,.3,1),s.renderOrder=10,s}function Je(t){t.removeFromParent(),t.material.map?.dispose(),t.material.dispose();}var v={rx:0,ry:1,rz:2,px:3,py:4,pz:5,sx:6,sy:7,sz:8},Jo=Object.keys(v),ue=[0,0,0,0,0,0,1,1,1];function fe(t,e){let r=t.get(e);return r||(r=Float64Array.from(ue),t.set(e,r)),r}function X(t,e,r,o){let s=fe(t,e),a=v[r];a>=6?s[a]=s[a]*o:s[a]=s[a]+o;}function h(t,e,r,o){fe(t,e)[v[r]]=o;}function ce(t){for(let e of t.values())e.set(ue);}function Pt(t,e,r,o){let s=new Set([...e.keys(),...r.keys()]);for(let a of s){let n=e.get(a)??ue,i=r.get(a)??ue,l=fe(t,a);for(let c=0;c<9;c++)l[c]=n[c]+(i[c]-n[c])*o;}}function Te(t,e){ce(t);for(let[r,o]of e)fe(t,r).set(o);}var Qo=["none","block","tool","sword","bow","shield","food","staff","item"];function Me(){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 en=["swing","hurt","place","land","jump","throw"];var xe=1/16,Ae=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;constructor(e=le(),r={}){this.spec=e,this.shadows=r.shadows??true,this.layer=r.layer??0,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=$e(e),this.build(),r.name&&this.setName(r.name);}get height(){let e=this.asset.layout;return e.height*e.scale*xe}get eye(){let e=this.asset.layout;return e.eye*e.scale*xe}get expressions(){return Object.keys(this.asset.layout.face?.uv??{})}get hash(){return this.asset.layout.hash}setSpec(e){let r=$e(e);if(r===this.asset){Se(r);return}this.clear(),Se(this.asset),this.asset=r,this.spec=e,this.build();}build(){let{layout:e,geometries:r,texture:o}=this.asset;this.material.map=o,this.material.needsUpdate=true,this.decalMat.map=o,this.decalMat.needsUpdate=true,this.root.scale.setScalar(e.scale*xe);let s=new Map(e.bones.map(n=>[n.name,n.pivot]));for(let n of e.bones){let i=new _.Group,l=n.parent?s.get(n.parent)??[0,0,0]:[0,0,0],c=[n.pivot[0]-l[0],n.pivot[1]-l[1],n.pivot[2]-l[2]];i.position.set(...c);let u={name:n.name,role:n.role,group:i,rest:c};this.bones.set(n.name,u);let b=this.byRole.get(n.role)??[];b.push(u),this.byRole.set(n.role,b);let g=r.get(n.name);if(g){let R=new _.Mesh(g,this.material);R.castShadow=R.receiveShadow=this.shadows,R.layers.set(this.layer),this.meshes.push(R),i.add(R);}}for(let n of e.bones){let i=this.bones.get(n.name);((n.parent?this.bones.get(n.parent):void 0)?.group??this.root).add(i.group);}let a=e.face;if(a){let n=new _.BufferGeometry;n.setAttribute("position",new _.BufferAttribute(a.corners,3));let i=new Float32Array(12);for(let l=0;l<4;l++)i[l*3+2]=-1;n.setAttribute("normal",new _.BufferAttribute(i,3)),n.setAttribute("uv",new _.BufferAttribute(new Float32Array(8),2)),n.setIndex([0,2,1,0,3,2]),this.decal=new _.Mesh(n,this.decalMat),this.decal.layers.set(this.layer),this.bones.get(a.bone)?.group.add(this.decal),this.expression=null,this.setExpression("neutral");}for(let n of e.sockets){let i=new _.Object3D;i.position.set(...n.at),i.scale.setScalar(1/(e.scale*xe)),this.bones.get(n.bone)?.group.add(i),this.sockets.set(n.name,i);let l=this.attached.get(n.name);l&&i.add(l);}this.placeLabel(),this.setBrightness(this.brightness);}clear(){for(let e of this.sockets.values())for(let r of [...e.children])e.remove(r);this.root.clear(),this.decal?.geometry.dispose(),this.decal=null,this.meshes=[],this.bones=new Map,this.byRole=new Map,this.sockets.clear();}applyPose(e){let r=e.get("root");if(r){this.root.rotation.set(r[v.rx],r[v.ry],r[v.rz]);let o=this.asset.layout.scale*xe;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,s]of this.byRole){let a=e.get(o);for(let n of s){let i=n.group;if(!a){i.rotation.set(0,0,0),i.position.set(...n.rest),i.scale.set(1,1,1);continue}i.rotation.set(a[v.rx],a[v.ry],a[v.rz]),i.position.set(n.rest[0]+a[v.px],n.rest[1]+a[v.py],n.rest[2]+a[v.pz]),i.scale.set(a[v.sx],a[v.sy],a[v.sz]);}}}setExpression(e){if(e===this.expression||!this.decal)return;let r=this.asset.layout.face?.uv,o=r?.[e]??r?.neutral;if(!o)return;this.expression=e;let[s,a,n,i]=o,l=this.decal.geometry.getAttribute("uv");l.setXY(0,s,a),l.setXY(1,n,a),l.setXY(2,n,i),l.setXY(3,s,i),l.needsUpdate=true;}materials(){return [this.material,this.decalMat]}setBrightness(e){this.brightness=e,this.material.color.setScalar(e),this.decalMat.color.setScalar(e);}setEmissive(e){this.material.emissive.getHex()!==e&&(this.material.emissive.setHex(e),this.decalMat.emissive.setHex(e));}setShadows(e){if(e!==this.shadows){this.shadows=e;for(let r of this.meshes)r.castShadow=e;}}attach(e,r){let o=this.attached.get(e);if(o!==r){if(o&&o.removeFromParent(),!r){this.attached.delete(e);return}this.attached.set(e,r),this.sockets.get(e)?.add(r);}}attachedAt(e){return this.attached.get(e)??null}setName(e){this.label&&Je(this.label),this.label=e?Lt(e):null,this.label&&this.group.add(this.label),this.placeLabel();}setLabelVisible(e){this.label&&(this.label.visible=e);}placeLabel(){this.label&&(this.label.position.y=this.height+.25);}forEachMesh(e){for(let r of this.meshes)e(r);this.decal&&e(this.decal);}dispose(){this.group.removeFromParent();for(let e of this.attached.values())e.removeFromParent();this.attached.clear(),this.clear(),this.label&&Je(this.label),this.label=null,this.material.dispose(),this.decalMat.dispose(),Se(this.asset);}};var Le=new Map,Qe=new Set;function cn(t){let e=me(t);if(!Le.has(e)){Le.set(e,t);for(let r of Qe)r(e);}return e}function hn(t){return typeof t=="string"?Le.get(t):void 0}function pn(t){let e={};for(let r of t){let o=Le.get(r);o&&(e[r]=o);}return e}function mn(t){return Qe.add(t),()=>Qe.delete(t)}var Mr=["#b08a62","#8a6a4a","#c8a878","#9a9a92","#7a5c44"],Ar=["#f1c9a5","#e6b892","#d9a982","#c08e68","#a0704c","#7a5238"],Lr=["#6b4a2f","#4a3424","#8a5a3a","#c27a48","#d8b878","#2e2622","#a07850","#9a9690"],Pr=["#a7bea9","#e6e0cc","#d9c9a3","#b9a083","#a9b8c4","#c8b4a0","#9fb0a0","#d8d2c4","#b98f74","#8fa3b5"],_r=["#8c9ca6","#a9b8b4","#8a8e94","#9fb3ad","#7d8a8f","#b0a58f"],Or=["#d9c9a3","#c8b48a","#a08a6a","#e6e0cc"];function gn(t,e="",r=""){let o=a(b("npc:"+t+"|"+e)),s=i=>i[Math.floor(o()*i.length)],a$1=qe({top:s(Tt),bottom:s(Mt),shoes:s(At),hair:s(["short","short","long","curly"]),hat:o()<.2,colors:{skin:s(Ar),hair:s(Lr),shirt:s(Pr),pants:s(_r),boots:s(Mr),hat:s(Or)}});a$1.name=t.slice(0,40),a$1.description=[e,r].filter(Boolean).join(" \u2014 ").slice(0,300),a$1.style={walk:s(["normal","normal","bouncy","heavy","sneaky"]),idle:s(["calm","calm","fidgety","proud"]),energy:Math.round(o()*10)/10},a$1.tags=["npc",...e?[e.slice(0,24)]:[]];let n=Z(a$1);return n.ok?n.spec:le()}var re=([t,e,r])=>"#"+[t,e,r].map(o=>Math.round(o).toString(16).padStart(2,"0")).join("");function Ir(t){if(!t.length)return null;let e=r=>{let o=t.map(s=>s[r]).sort((s,a)=>s-a);return o[o.length>>1]};return [e(0),e(1),e(2)]}function zr(t,e){let{width:r,height:o,data:s}=t,a=(T,A)=>{let V=(A*r+T)*4;return [s[V],s[V+1],s[V+2]]},n=[a(0,0),a(r-1,0),a(0,o-1),a(r-1,o-1)],i=[0,1,2].map(T=>n.reduce((A,V)=>A+V[T],0)/4),l=T=>Math.abs(T[0]-i[0])+Math.abs(T[1]-i[1])+Math.abs(T[2]-i[2])>60,c=r,u=-1,b=o,g=-1;for(let T=0;T<o;T+=2)for(let A=0;A<r;A+=2)l(a(A,T))&&(c=Math.min(c,A),u=Math.max(u,A),b=Math.min(b,T),g=Math.max(g,T));u<0&&(c=0,u=r-1,b=0,g=o-1);let R=g-b+1,E=u-c+1,F=c+Math.floor(E*.3),K=c+Math.ceil(E*.7);return e.map(([T,A])=>{let V=[];for(let m=b+Math.floor(R*T);m<b+Math.ceil(R*A);m++)for(let k=F;k<K;k++){if(m<0||m>=o||k<0||k>=r)continue;let y=a(k,m);l(y)&&V.push(y);}return Ir(V)})}var Fr=[[0,.06],[.1,.22],[.3,.52],[.6,.86],[.92,1]];function Rn(t,e="humanoid",r=Ee()){let[o,s,a,n,i]=zr(t,Fr);if(e==="humanoid"){let c=JSON.parse(JSON.stringify(Ze));c.palette=Ye(c.palette,{...o?{hair:re(o)}:{},...s?{skin:re(s)}:{},...a?{shirt:re(a)}:{},...n?{pants:re(n)}:{},...i?{boots:re(i)}:{}}),c.name=r,c.tags=[];let u=Z(c);return u.ok?u.spec:le()}let l=Z({name:r,rig:e,palette:{s:re(s??o??[198,156,124]),t:re(a??[58,143,214]),p:re(n??i??[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:e==="blob"?[4,4,4,2]:e==="flyer"?[0,1,4,2]:[2,2,4,2],expressions:{neutral:"f_neutral",blink:"f_blink"}}});return l.ok?l.spec:le()}var Hr={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}},Nr={calm:{},fidgety:{fidget:1,breath:1.3},proud:{chest:.08,breath:.8}};function et(t){let e={amp:.8,arm:.6,bob:0,tempo:1,sway:0,quant:false,breath:1,fidget:0,chest:0,...Hr[t.walk],...Nr[t.idle]};return e.tempo*=.8+.4*t.energy,e.amp*=.85+.3*t.energy,e}function tt(t,e=0){let r=Math.sin(t.phase+e);return t.style.quant?Math.max(-1,Math.min(1,r*3)):r}function rt(t,e,r){let o=tt(e)*r;h(t,"legL","rx",o),h(t,"legR","rx",-o),h(t,"legFL","rx",o),h(t,"legBR","rx",o),h(t,"legFR","rx",-o),h(t,"legBL","rx",-o);}function ot(t,e,r){let o=tt(e)*r;h(t,"armL","rx",-o),h(t,"armR","rx",o);}var Br=(t,e)=>{let r=Math.sin(e.clock*2)*e.style.breath;h(t,"armL","rz",-0.04-.03*r),h(t,"armR","rz",.04+.03*r),h(t,"head","rx",.03*Math.sin(e.clock*1.7)+e.style.chest),h(t,"body","rx",e.style.chest*-0.5),e.style.fidget&&(h(t,"head","ry",.35*Math.sin(e.clock*.7)*Math.sin(e.clock*.31)),h(t,"root","ry",.05*Math.sin(e.clock*.9))),h(t,"body","sy",1+.04*Math.sin(e.clock*3));},Dr=(t,e)=>{rt(t,e,e.style.amp),ot(t,e,e.style.arm),h(t,"root","py",e.style.bob*Math.abs(Math.cos(e.phase))),h(t,"body","rz",e.style.sway*tt(e));},jr=(t,e)=>{rt(t,e,e.style.amp*1.3),ot(t,e,e.style.arm*1.6),h(t,"body","rx",-0.18),h(t,"head","rx",.18),h(t,"root","py",(.8+e.style.bob)*Math.abs(Math.cos(e.phase)));},Gr=(t,e)=>{rt(t,e,e.style.amp*.5*Math.min(1,e.input.speed)),ot(t,e,e.style.arm*.4*Math.min(1,e.input.speed)),h(t,"body","rx",-0.45),h(t,"head","rx",.45),X(t,"armL","rx",.25),X(t,"armR","rx",.25),h(t,"root","py",-1.5);},Vr=(t,e)=>{h(t,"root","rx",-1.3),h(t,"head","rx",1),h(t,"armL","rx",Math.PI-.5+.5*Math.sin(e.t*3)),h(t,"armR","rx",Math.PI-.5+.5*Math.sin(e.t*3+Math.PI)),h(t,"legL","rx",.3*Math.sin(e.t*8)),h(t,"legR","rx",-0.3*Math.sin(e.t*8));},Ur=(t,e)=>{h(t,"legL","rx",.15),h(t,"legR","rx",.1),h(t,"armL","rz",-0.15),h(t,"armR","rz",.15),h(t,"root","py",.6*Math.sin(e.t*2));},Wr=t=>{h(t,"root","rx",-1.35),h(t,"head","rx",1.1),h(t,"armL","rz",-1.3),h(t,"armR","rz",1.3);},Kr=(t,e)=>{let r=.15*Math.sin(e.t*10);h(t,"armL","rz",-0.6-r),h(t,"armR","rz",.6+r),h(t,"legL","rx",.25),h(t,"legR","rx",-0.25);},$r=t=>{h(t,"legL","rx",1.45),h(t,"legR","rx",1.45),h(t,"legL","ry",.1),h(t,"legR","ry",-0.1),h(t,"root","py",-10),h(t,"body","rx",.4),h(t,"legBL","rx",1.2),h(t,"legBR","rx",1.2);},Xr=t=>{h(t,"legL","rx",1.4),h(t,"legR","rx",1.4),h(t,"legL","rz",-0.3),h(t,"legR","rz",.3),h(t,"armL","rx",.45),h(t,"armR","rx",.45);},Yr=t=>{h(t,"root","rx",Math.PI/2),h(t,"root","py",2);},qr=t=>{h(t,"root","rz",Math.PI/2),h(t,"root","py",2);},Zr=(t,e)=>{let r=Math.sin(e.phase*.5);h(t,"root","py",6*Math.max(0,r));let o=r<0?.2*-r:0;h(t,"body","sy",1-o+.1*Math.max(0,r)),h(t,"body","sx",1+o*.6),h(t,"body","sz",1+o*.6);},Jr=(t,e)=>{let r=Math.sin(Math.PI*e.k);h(t,"armR","rx",1.9*r),h(t,"armR","ry",.3*r),h(t,"body","ry",-0.3*r);},Qr=(t,e)=>{let r=Math.sin(Math.PI*e.k);h(t,"armR","rx",.9*r);},eo=(t,e)=>{let r=e.k<.4?-1.5*(e.k/.4):-1.5+3.5*((e.k-.4)/.6);h(t,"armR","rx",e.k>.9?r*(1-e.k)*10:r);},to=(t,e)=>{let r=Math.sin(Math.PI*e.k);h(t,"body","rx",.15*r),h(t,"head","rx",.2*r),h(t,"root","rz",.05*r);},ro=(t,e)=>{let r=Math.sin(Math.PI*e.k);h(t,"root","py",-1.5*r),h(t,"legL","rx",.2*r),h(t,"legR","rx",.2*r),h(t,"body","sy",1-.2*r),h(t,"body","sx",1+.12*r),h(t,"body","sz",1+.12*r);},oo=(t,e)=>{h(t,"armR","rx",1.3+.1*Math.sin(e.t*16)),h(t,"armR","ry",-0.5),h(t,"head","rx",-0.1+.08*Math.sin(e.t*16));},no=t=>{h(t,"armR","rx",2),h(t,"armR","ry",-0.4),h(t,"head","rx",.35);},so=t=>{h(t,"armR","rx",1.57),h(t,"armR","ry",-0.1),h(t,"armL","rx",1.57),h(t,"armL","ry",.35);},ao=t=>{h(t,"armL","rx",.9),h(t,"armL","ry",-0.6);},Pe={idle:Br,walk:Dr,run:jr,sneak:Gr,swim:Vr,fly:Ur,glide:Wr,fall:Kr,sit:$r,ride:Xr,sleep:Yr,dead:qr,hop:Zr,swing:Jr,place:Qr,throw:eo,hurt:to,land:ro,eat:oo,drink:no,draw:so,block:ao},_t={blob:{walk:"hop",run:"hop",sneak:"hop"}},Ot={swing:.3,place:.2,throw:.45,hurt:.3,land:.22};var _e=Math.PI,Oe={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,_e*.46],[1,_e*.46]],"legR.rx":[[0,_e*.46],[1,_e*.46]],"root.py":[[0,-10],[1,-10]]}}},Tn=Object.keys(Oe);function Mn(t){return typeof t=="string"&&t in Oe}function io(t,e){let r=t[0];if(e<=r[0])return r[1];for(let o=1;o<t.length;o++){let s=t[o];if(e<=s[0]){let a=t[o-1],n=(e-a[0])/Math.max(1e-6,s[0]-a[0]),i=n*n*(3-2*n);return a[1]+(s[1]-a[1])*i}}return t[t.length-1][1]}function It(t,e,r){let o=e.loop?r%e.duration:Math.min(r,e.duration);for(let[s,a]of Object.entries(e.tracks)){let n=s.lastIndexOf("."),i=s.slice(0,n),l=s.slice(n+1);l in v&&h(t,i,l,io(a,o));}}var zt={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"]},nt={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 Ft(t,e,r){if(!(r<=0))for(let[o,s]of Object.entries(nt[e].add)){let a=o.lastIndexOf(".");X(t,o.slice(0,a),o.slice(a+1),(s??0)*r);}}var _n={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 On(t){let e=[[/(>:\(|😠|😡|🤬)/u,"angry"],[/(:'\(|😢|😭)/u,"sad"],[/(:\(|☹|🙁|😞)/u,"sad"],[/(:o|:O|😮|😲)/u,"surprised"],[/(😱|😨)/u,"scared"],[/(-_-|😴|😩|🥱)/u,"tired"],[/(:\)|:D|\^\^|😀|😃|😄|😁|🙂|😊|😂)/u,"happy"]];for(let[r,o]of e)if(r.test(t))return o;return null}var lo=[{state:"dead",when:t=>t.dead,clip:"dead",blend:.25},{state:"sleep",when:t=>t.sleeping,clip:"sleep",blend:.3},{state:"ride",when:t=>t.riding,clip:"ride",blend:.2},{state:"sit",when:t=>t.sitting,clip:"sit",blend:.3},{state:"swim",when:t=>t.inWater&&!t.onGround&&!t.flying,clip:"swim",blend:.3},{state:"glide",when:t=>t.gliding,clip:"glide",blend:.25},{state:"fly",when:t=>t.flying,clip:"fly",blend:.25},{state:"fall",when:(t,e)=>e.airTime>.35&&t.vy<-4,clip:"fall",blend:.2},{state:"sneak",when:t=>t.sneaking,clip:"sneak",blend:.15},{state:"run",when:t=>t.sprinting&&t.speed>3||t.speed>6.5,clip:"run",blend:.15},{state:"walk",when:t=>t.speed>.4,clip:"walk",blend:.15},{state:"idle",when:()=>true,clip:"idle",blend:.2}],co=new Set(["hurt","land"]),ho={eat:"eat",drink:"drink",draw:"draw",block:"block"},po={tail:(t,e)=>[["ry",-t.yawRate*.25+.12*Math.sin(e*2)],["rx",-(.1+Math.min(t.speed,8)*.06)]],cape:(t,e)=>[["rx",-(.05+Math.min(t.speed,8)*.12)-(t.speed>1?.06*Math.sin(e*9):0)-(t.vy<-3?.4:0)]],hair:t=>[["rx",-Math.min(t.speed,8)*.03]],ear:(t,e)=>[["rz",.08*Math.sin(e*1.3)+Math.min(t.speed,6)*.02]],antenna:(t,e)=>[["rx",.1*Math.sin(e*3)-t.vy*.02]],wingL:(t,e)=>t.flying||t.gliding||!t.onGround&&!t.inWater?[["rz",t.gliding?-0.05:-0.7*Math.sin(e*12)]]:[["rz",1.1+.05*Math.sin(e*1.5)]],wingR:(t,e)=>t.flying||t.gliding||!t.onGround&&!t.inWater?[["rz",t.gliding?.05:.7*Math.sin(e*12)]]:[["rz",-1.1-.05*Math.sin(e*1.5)]]},Ie=t=>{let e=Math.max(0,Math.min(1,t));return e*e*(3-2*e)},ze=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(e,r,o=[]){this.rig=e,this.style=et(r),this.faces=new Set(o);}setRandom(e){this.random=e;}random=Math.random;setStyle(e){this.style=et(e);}setEmotion(e,r){r&&r>0?this.flash={emotion:e,left:r}:this.mood=e;}get emotion(){return this.emote?.def.emotion?this.emote.def.emotion:this.flash?.emotion??this.mood}get emoting(){return this.emote?.id??null}playEmote(e){this.emote={id:e,def:Oe[e],t:0};}stopEmote(){this.emote=null;}trigger(e){switch(e){case "swing":case "place":case "throw":case "hurt":case "land":{let r=e;this.actions=this.actions.filter(o=>o.clip!==r),this.actions.push({clip:r,t:0,dur:Ot[r]??.3}),e==="hurt"&&this.setEmotion("hurt",.8);break}}}update(e,r=Me()){e=Math.min(e,.1),this.clock+=e;let o=this.emotion,s=nt[o].tempo*this.style.tempo;!r.onGround&&!r.inWater?this.airTime+=e:(!this.wasOnGround&&this.airTime>.3&&r.onGround&&this.trigger("land"),this.airTime=0),this.wasOnGround=r.onGround,this.phase+=r.speed*e*3.5*s;let a=lo.find(c=>c.when(r,this));a.state!==this.state&&(Te(this.from,this.lastLoco),this.state=a.state,this.stateT=0,this.blendT=0,this.blendDur=a.blend),this.stateT+=e,ce(this.loco);let n=_t[this.rig]?.[a.clip]??a.clip,i={t:this.stateT,k:0,phase:this.phase,input:r,style:this.style,clock:this.clock*s};if(Pe[n](this.loco,i),ce(this.pose),this.blendT<this.blendDur?(this.blendT+=e,Pt(this.pose,this.from,this.loco,Ie(this.blendT/this.blendDur))):Te(this.pose,this.loco),Te(this.lastLoco,this.pose),this.emote){let c=this.emote;if(c.t+=e,r.speed>1||this.state!=="idle"||!c.def.loop&&c.t>=c.def.duration)this.emote=null;else {let g=c.def.loop?Ie(c.t/.15):Ie(Math.min(c.t/.15,(c.def.duration-c.t)/.15));ce(this.tmp),It(this.tmp,c.def,c.t),this.overlay(this.tmp,g,false);}}let l=r.use?ho[r.use]:null;l&&(this.useClip=l),this.useW=Math.max(0,Math.min(1,this.useW+(l?e:-e)*8)),this.useClip&&this.useW>0?(ce(this.tmp),Pe[this.useClip](this.tmp,{...i,t:this.clock}),this.overlay(this.tmp,Ie(this.useW),false)):r.held!=="none"&&!this.emote&&X(this.pose,"armR","rx",r.held==="staff"?.35:.2);for(let c of this.actions){c.t+=e;let u=Math.min(1,c.t/c.dur);ce(this.tmp),Pe[c.clip](this.tmp,{...i,t:c.t,k:u}),this.overlay(this.tmp,1,co.has(c.clip));}this.actions=this.actions.filter(c=>c.t<c.dur),this.state!=="dead"&&this.state!=="sleep"&&(X(this.pose,"head","ry",Math.max(-1.1,Math.min(1.1,r.lookYaw))),X(this.pose,"head","rx",Math.max(-1.2,Math.min(1.2,r.lookPitch)))),this.flash&&(this.flash.left-=e)<=0&&(this.flash=null);for(let c of a$1){let u=this.postureW.get(c)??0,b=u+((c===o?1:0)-u)*Math.min(1,e*6);this.postureW.set(c,b),this.state!=="dead"&&Ft(this.pose,c,b);}for(let[c,u]of Object.entries(po))for(let[b,g]of u(r,this.clock)){let R=c+"."+b,E=this.springs.get(R);E||this.springs.set(R,E={x:g,v:0});let F=60,K=9;E.v+=(F*(g-E.x)-K*E.v)*e,E.x+=E.v*e,X(this.pose,c,b,E.x);}return this.expression=this.face(r,e,o),this.pose}overlay(e,r,o){for(let[s,a]of e){let n=fe(this.pose,s);for(let i=0;i<9;i++)o?i>=v.sx?n[i]=n[i]*(1+(a[i]-1)*r):n[i]=n[i]+(a[i]-ue[i])*r:n[i]=n[i]+(a[i]-n[i])*r;}}face(e,r,o){let s=n=>n.find(i=>this.faces.has(i))??"neutral";if(e.dead||this.state==="dead"||e.sleeping)return s(["blink","hurt","neutral"]);let a=s(zt[o]);return e.viseme!==void 0?(this.talkT=0,e.viseme!=="rest"&&e.viseme!=="MBP"?s(["talk",a]):a):e.talk?(this.talkT+=r,Math.floor(this.talkT/.12)%2===0?s(["talk",a]):a):(this.talkT=0,this.blinking>0?(this.blinking-=r,s(["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 mo={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"}},uo={handR:"handR",handL:"handL",head:"headTop"},Ht=class{view;animator;input=Me();seed;pose="idle";jumpT=-1;constructor(e,r={}){this.view=new Ae(e,{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(e){let r=this.view.hash;this.view.setSpec(e),this.view.hash!==r&&(this.animator=this.newAnimator());}setEmotion(e){this.animator.setEmotion(e);}setViseme(e){this.input.viseme=e;}setPose(e){if(e===this.pose)return;this.pose=e;let r=mo[e];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(e){this.animator.playEmote(e);}attach(e,r){this.view.attach(uo[e],r);}update(e){let r=this.input;this.jumpT>=0&&(this.jumpT+=e,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(e,r);this.view.applyPose(o),this.view.setExpression(this.animator.expression);}dispose(){this.view.dispose();}newAnimator(){let e=this.view.spec,r=new ze(e.rig,e.style,this.view.expressions);return r.setRandom(a(this.seed)),r}};var fo=be.map(t=>{let e=q[t],r=e.bones.map(s=>`${s.name}@[${s.pivot.join(",")}]`).join(" "),o=e.defaultParts.map(s=>`${s.bone} ${s.size.join("x")} at [${s.pos.join(",")}]`).join("; ");return `- "${t}" \u2014 ${e.hint}. Bones (name@pivot): ${r}. Default body: ${o}.`}).join(`
2
2
  `),$n=`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
3
 
4
4
  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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idosgames/characters",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Characters of the iDosGames platform in one standard for games and videos: voxel characters (CharacterSpec recipes on three.js), layered 2D characters on a skeleton with a full wardrobe (clothes, hair, weapons, shields) in vector art, and GLB characters on the humanoid-v1 skeleton — one actor contract (emotions, mouth visemes, poses, sockets) and lip-sync from text.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1 +0,0 @@
1
- import {w,s,D,C,x,n,y as y$1,t,c}from'./chunk-OF4BH3JZ.js';import y from'phaser';var b=class{constructor(t,r){this.scene=t;let e=this.rig=r.rig;this.art=r.art,this.skeleton=new w(e.data),this.sizes=s(e.data),this.lights=e.shading?D(e.data,e.shading):new Map,this.parts=new C(e,i=>this.drawsSkin(i)),r.look&&this.parts.applyLook(r.look),this.offs.push(this.parts.on(()=>this.skinsDirty=true)),this.animator=new x(this.skeleton,e.data,e.mix),this.animator.setBlink(e.blink??null),this.play(r.animation??e.defaultAnimation,{mix:0}),this.root=t.add.container(r.x??0,r.y??0);for(let i=0;i<this.skeleton.slots.length;i++){let s=new y.GameObjects.Mesh2D(t,0,0,"__DEFAULT",[],[],true);s.setRenderAsTriangles(true),s.setVisible(false),this.root.add(s),this.slots.push({mesh:s,positions:null,vertices:[],indices:[],path:null,key:null,paint:null,waiting:false});}if(this.setScale(r.scale??1),r.autoUpdate!==false){let i=(s,n)=>this.update(n/1e3);t.events.on(y.Scenes.Events.UPDATE,i),this.offs.push(()=>t.events.off(y.Scenes.Events.UPDATE,i));}this.root.once(y.GameObjects.Events.DESTROY,()=>{for(let i of this.offs.splice(0))i();}),this.update(0);}scene;root;skeleton;animator;parts;slots=[];sizes;lights;skinsDirty=true;overlay=null;flashUntil=0;flashColor=16777215;facing=1;size=1;offs=[];asked=null;rig;art;play(t,r){return this.asked={name:t,...r?{options:r}:{}},this.animator.play(this.stanceOf(t),r)}animation(){return this.asked?.name??null}stanceOf(t){let r=this.parts;return this.rig.stance?.(t,e=>r.isWorn(e)?r.part(e):null)??t}on(t,r){let e=this.animator.on(t,r);return this.offs.push(e),e}setLook(t){this.parts.applyLook(t);}setArt(t){this.art=t;for(let r of this.slots)r.key=r.path=null,r.waiting=false;this.parts.setDrawable(r=>this.drawsSkin(r));}setPosition(t,r){return this.root.setPosition(t,r),this}setScale(t){return this.size=t,this.root.setScale(t*this.facing,t),this}setFacing(t){return this.facing=t,this.setScale(this.size)}setDepth(t){return this.root.setDepth(t),this}setVisible(t){return this.root.setVisible(t),this}setAlpha(t){return this.root.setAlpha(t),this}setOverlay(t){return this.overlay=t,this}flash(t=16777215,r=90){this.flashColor=t,this.flashUntil=this.scene.time.now+r;}worldPoint(t){let r=this.rig.anchors[t]??t,e=this.skeleton.bone(r).applied,i=this.root.getWorldTransformMatrix();return {x:i.tx+i.a*e.worldX+i.c*-e.worldY,y:i.ty+i.b*e.worldX+i.d*-e.worldY}}get displayHeight(){return this.rig.data.height*this.size}destroy(){this.root.destroy();}update(t){let r=this.skeleton,e=this.rig.expressions;if(e&&this.parts.setExpression(e.byAnimation[this.animator.current()??""]??null),this.skinsDirty){this.skinsDirty=false,r.setSkins(this.parts.wornSkins().flatMap(n=>{let l=this.rig.data.skins.get(n);return l?[l]:[]}));let s=this.asked;s&&this.stanceOf(s.name)!==this.animator.current()&&this.animator.play(this.stanceOf(s.name),{...s.options,mix:.15});}this.animator.update(t),r.slots.forEach((s,n$1)=>{let l=this.parts.slotColor(n$1);if(!l)return;let a=n(l);s.color.r=(a>>16&255)/255,s.color.g=(a>>8&255)/255,s.color.b=(a&255)/255,s.color.a=1;}),r.updateWorldTransform();let i=this.flashUntil>this.scene.time.now;r.slots.forEach((s,n)=>this.drawSlot(n,i));}drawSlot(t,r){let e=this.slots[t],i=this.skeleton.slots[t],s=i.attachment,n=e.mesh;if(!s||i.color.a<=0){n.setVisible(false);return}let l=this.parts.artColor(t);if((e.path!==s.path||e.paint!==l)&&(e.path=s.path,e.paint=l,e.key=null,e.waiting=false),!e.key&&!e.waiting){let o=this.sizes.get(s.path)??{w:s.width,h:s.height},g=s.path,v=this.art.texture(g,o,()=>{e.path===g&&(e.waiting=false);},{paint:l,light:this.lights.get(g)??null});v?(e.key=v,n.setTexture(v)):e.waiting=true;}if(!e.key){n.setVisible(false);return}let a=y$1(this.skeleton,i,s,e.positions);e.positions=a.positions;let m=a.uvs.length/2,p=e.vertices;p.length=m*4;for(let o=0;o<m;o++)p[o*4]=a.positions[o*2],p[o*4+1]=-a.positions[o*2+1],p[o*4+2]=a.uvs[o*2],p[o*4+3]=a.uvs[o*2+1];let c=a.triangles,u=e.indices;if(u.length!==c.length/3*4){u.length=0;for(let o=0;o<c.length;o+=3)u.push(c[o],c[o+1],c[o+2],0);}else for(let o=0,g=0;o<c.length;o+=3,g+=4)u[g]=c[o],u[g+1]=c[o+1],u[g+2]=c[o+2];n.vertices=p,n.indices=u;let f=i.color,d=s.color,k=Math.round(f.r*d.r*255)<<16|Math.round(f.g*d.g*255)<<8|Math.round(f.b*d.b*255);this.overlay!==null&&(k=V(k,this.overlay)),r?n.setTint(this.flashColor).setTintMode(y.TintModes.FILL):n.setTint(k).setTintMode(y.TintModes.MULTIPLY),n.setAlpha(f.a*d.a),n.setVisible(true);}drawsSkin(t$1){return t(this.rig.data,t$1).every(r=>this.art.has(r))}};function V(h,t){let r=e=>Math.round((h>>e&255)*(t>>e&255)/255)<<e;return r(16)|r(8)|r(0)}var O=new WeakMap;function z(h,t,r){return `chr:${h}@${t}${r||""}`}function E(h,t,r,e,i,s,n={}){let l=r.paint?n.paint??null:null,a=z(t,i,l);if(h.exists(a))return a;let m=O.get(h);m||O.set(h,m=new Map);let p=m.get(a);if(p)return p.push(s),null;let c$1=[s];m.set(a,c$1);let u=new Image,f=()=>{m.delete(a);for(let d of c$1)d();};return u.onload=()=>{h.exists(a)||h.addImage(a,u),f();},u.onerror=()=>{console.warn(`[character] art ${t} did not render`),f();},u.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(c(r,e,i,{paint:l,light:n.light??null})),null}function I(h,t,r=2){return {has:e=>t.has(e),texture(e,i,s,n){let l=t.get(e);return l?E(h,e,l,i,r,s,n):null}}}function tt(h,t){return new Promise(r=>{let{width:e,height:i}=t;class s extends y.Scene{create(){let a=t.scale??1,m=I(this.textures,t.catalog,Math.max(2,Math.ceil(a*1.5))),p=new b(this,{rig:t.rig,art:m,...t.look?{look:t.look}:{},x:e/2,y:Math.round(i*.88),scale:a});r({view:p,game:n,vector:m,destroy:()=>n.destroy(true)});}}let n=new y.Game({type:y.WEBGL,parent:h,width:e,height:i,transparent:!t.background,...t.background?{backgroundColor:t.background}:{},scene:s,banner:false,audio:{noAudio:true}});})}export{b as a,I as b,tt as c};
@@ -1,2 +0,0 @@
1
- var Tt="#1f1a21";var Qt="currentColor";function zt(s,t,e=1,n={}){let o=Math.max(1,Math.ceil(t.w*e)),r=Math.max(1,Math.ceil(t.h*e)),a=n.paint??s.paint,i=n.light?$t(t,n.light):"";return `<svg xmlns="http://www.w3.org/2000/svg" width="${o}" height="${r}" viewBox="0 0 ${t.w} ${t.h}"${a?` color="${a}"`:""}>${i}<g stroke-linejoin="round" stroke-linecap="round"${i?' filter="url(#cel)"':""}>${s.svg}</g></svg>`}var K={depth:.18,min:2.6,max:11,dark:.3,shine:.36};function $t(s,t){let e=Math.max(K.min,Math.min(K.max,Math.min(s.w,s.h)*K.depth)),n=o=>+o.toFixed(2);return `<defs><filter id="cel" filterUnits="userSpaceOnUse" x="0" y="0" width="${s.w}" height="${s.h}" color-interpolation-filters="sRGB"><feMorphology in="SourceAlpha" operator="erode" radius="${n(3.6*.7)}" result="body"/><feOffset in="body" dx="${n(t.x*e)}" dy="${n(t.y*e)}" result="moved"/><feComposite in="body" in2="moved" operator="out" result="far"/><feFlood flood-color="#000000" flood-opacity="${K.dark}"/><feComposite in2="far" operator="in" result="dark"/><feMorphology in="SourceAlpha" operator="erode" radius="${n(3.6*1.05)}" result="inner"/><feOffset in="inner" dx="${n(-t.x*e*.42)}" dy="${n(-t.y*e*.42)}" result="back"/><feComposite in="inner" in2="back" operator="out" result="near"/><feFlood flood-color="#ffffff" flood-opacity="${K.shine}"/><feComposite in2="near" operator="in" result="shine"/><feMerge><feMergeNode in="SourceGraphic"/><feMergeNode in="dark"/><feMergeNode in="shine"/></feMerge></filter></defs>`}function lt(s={}){let t=s.stroke??Tt,e=(s.opacity!==void 0?` opacity="${s.opacity}"`:"")+(s.holes?' fill-rule="evenodd"':"");return t==="none"?` stroke="none"${e}`:` stroke="${t}" stroke-width="${s.width??3.6}"${e}`}var Rt=(s,t,e)=>`<path d="${s}" fill="${t}"${lt(e)}/>`,Ft=(s,t,e,n,o,r)=>`<ellipse cx="${s}" cy="${t}" rx="${e}" ry="${n}" fill="${o}"${lt(r)}/>`,te=(s,t,e,n,o)=>Ft(s,t,e,e,n,o),ee=(s,t,e,n,o,r,a)=>`<rect x="${s}" y="${t}" width="${e}" height="${n}" rx="${o}" fill="${r}"${lt(a)}/>`,ne=(s,t=Tt,e=2.2)=>`<path d="${s}" fill="none" stroke="${t}" stroke-width="${e}"/>`,oe=(s,t,e)=>Rt(s,t,{stroke:"none",...e!==void 0?{opacity:e}:{}}),se=(s,t,...e)=>`<clipPath id="${s}"><path d="${t}" clip-rule="evenodd"/></clipPath><g clip-path="url(#${s})">${e.join("")}</g>`,re=(s,...t)=>`<g transform="${s}">${t.join("")}</g>`;function ie(s,t){let e=parseInt(s.replace("#",""),16),n=i=>Math.max(0,Math.min(255,Math.round(t<0?i*(1+t):i+(255-i)*t))),o=n(e>>16&255),r=n(e>>8&255),a=n(e&255);return `#${(o<<16|r<<8|a).toString(16).padStart(6,"0")}`}var le="#ffffff";function ce(s){let t=/^#?([0-9a-f]{6})$/i.exec(s.trim());return t?parseInt(t[1],16):16777215}function he(s){return `#${(s&16777215).toString(16).padStart(6,"0")}`}function O(s){let t=(s??"ffffffff").replace("#","").padEnd(8,"f"),e=n=>parseInt(t.slice(n,n+2),16)/255;return {r:e(0),g:e(2),b:e(4),a:e(6)}}var L=Math.PI/180,ct=1e-5;function At(s,t){return s.type==="ik"?new I(s,t):new pt(s,t)}var ht=s=>s>180?s-360:s<=-180?s+360:s,I=class{constructor(t,e){this.data=t;this.bones=t.bones.map(n=>e.bones[n.index]),this.target=e.bones[t.target.index],this.mix=t.mix,this.bendDirection=t.bendDirection;}data;mix;bendDirection;bones;target;setupPose(){this.mix=this.data.mix,this.bendDirection=this.data.bendDirection;}sort(t){t.sortBone(this.target);let e=this.bones[0];t.sortBone(e),t.pushConstraint(this),e.sorted=false,t.sortReset(e.children);}update(t){if(this.mix===0)return;let e=this.target.applied;this.bones.length===1?Pt(t,this.bones[0].applied,e.worldX,e.worldY,this.mix):Nt(t,this.bones[0].applied,this.bones[1].applied,e.worldX,e.worldY,this.bendDirection,this.mix);}};function Pt(s,t,e,n,o){let r=t.bone.parent;if(!r)return;t.modifyLocal(s);let a=r.applied,i=a.a,p=a.b,l=a.c,c=a.d,d=-t.shearX-t.rotation,h=i*c-p*l,u=e-a.worldX,m=n-a.worldY,f=(u*c-m*p)/h-t.x,b=(m*i-u*l)/h-t.y;d+=Math.atan2(b,f)/L,t.scaleX<0&&(d+=180),t.rotation+=ht(d)*o;}function Nt(s,t,e,n,o,r,a){t.modifyLocal(s),e.modifyLocal(s);let i=t.x,p=t.y,l=t.scaleX,c=t.scaleY,d=e.scaleX,h,u,m;l<0?(l=-l,h=180,m=-1):(h=0,m=1),c<0&&(c=-c,m=-m),d<0?(d=-d,u=180):u=0;let f=Math.abs(l-c)<=ct,b,y;f?(b=t.a*e.x+t.b*e.y+t.worldX,y=t.c*e.x+t.d*e.y+t.worldY):(e.y=0,b=t.a*e.x+t.worldX,y=t.c*e.x+t.worldY);let x=t.bone.parent;if(!x)return;let g=x.applied,w=g.a,M=g.b,st=g.c,rt=g.d,Y=w*rt-M*st,F=b-g.worldX,N=y-g.worldY;Y=Math.abs(Y)<=ct?0:1/Y;let gt=(F*rt-N*M)*Y-i,xt=(N*w-F*st)*Y-p,k=Math.sqrt(gt*gt+xt*xt),P=e.bone.data.length*d;if(k<ct){Pt(s,t,n,o,a),e.rotation=0;return}F=n-g.worldX,N=o-g.worldY;let H=(F*rt-N*M)*Y-i,J=(N*w-F*st)*Y-p,G=H*H+J*J,D=0,T=0;if(f){P*=l;let v=(G-k*k-P*P)/(2*k*P);v<-1?(v=-1,T=Math.PI*r):v>1?(v=1,T=0):T=Math.acos(v)*r;let $=k+P*v,X=P*Math.sin(T);D=Math.atan2(J*$-H*X,H*$+J*X);}else {let v=l*P,$=c*P,X=v*v,q=$*$,it=Math.atan2(J,H),S=q*k*k+X*G-X*q,V=-2*q*k,vt=q-X,wt=V*V-4*vt*S,St=false;if(wt>=0){let A=Math.sqrt(wt);V<0&&(A=-A),A=-(V+A)*.5;let E=A/vt,R=S/A,B=Math.abs(E)<Math.abs(R)?E:R,W=G-B*B;if(W>=0){let C=Math.sqrt(W)*r;D=it-Math.atan2(C,B),T=Math.atan2(C/c,(B-k)/l),St=true;}}if(!St){let A=Math.PI,E=k-v,R=E*E,B=0,W=0,C=k+v,at=C*C,Mt=0;if(S=-v*k/(X-q),S>=-1&&S<=1){S=Math.acos(S);let U=v*Math.cos(S)+k,_=$*Math.sin(S),Z=U*U+_*_;Z<R&&(A=S,R=Z,E=U,B=_),Z>at&&(W=S,at=Z,C=U,Mt=_);}G<=(R+at)*.5?(D=it-Math.atan2(B*r,E),T=A*r):(D=it-Math.atan2(Mt*r,C),T=W*r);}}let kt=Math.atan2(e.y,e.x)*m;D=ht((D-kt)/L+h-t.rotation),T=ht(((T+kt)/L-e.shearX)*m+u-e.rotation),t.rotation+=D*a,e.rotation+=T*a;}var pt=class{constructor(t,e){this.data=t;this.source=e.bones[t.source.index],this.bones=t.bones.map(n=>e.bones[n.index]),this.mix={...t.mix};}data;mix;source;bones;setupPose(){Object.assign(this.mix,this.data.mix);}sort(t){t.sortBone(this.source);for(let e of this.bones)t.sortBone(e);t.pushConstraint(this);for(let e of this.bones)t.sortReset(e.children);for(let e of this.bones)e.sorted=true;}update(t){let e=this.mix;if(!e.rotate&&!e.x&&!e.y&&!e.scaleX&&!e.scaleY&&!e.shearY)return;let n=this.source.applied,o=this.data.offsets;for(let r of this.bones){let a=r.applied;a.modifyWorld(t);for(let i of this.data.properties){let p=Ht(t,n,i.prop,o)-i.offset;for(let l of i.to){let c=e[l.prop];c!==0&&Jt(t,a,l.prop,l.offset+p*l.scale,c);}}}}};function Ht(s,t,e,n){let o=s.scaleX,r=s.scaleY;switch(e){case "rotate":{let a=(t.a*t.d-t.b*t.c)*o*r>0?1:-1,i=Math.atan2(t.c/r,t.a/o)/L+a*n.rotate;return i<0&&(i+=360),i}case "x":return (n.x*t.a+n.y*t.b+t.worldX)/o;case "y":return (n.x*t.c+n.y*t.d+t.worldY)/r;case "scaleX":return Math.hypot(t.a/o,t.c/r)+n.scaleX;case "scaleY":return Math.hypot(t.b/o,t.d/r)+n.scaleY;case "shearY":return (Math.atan2(t.d/r,t.b/o)-Math.atan2(t.c/r,t.a/o))/L-90+n.shearY}}function Jt(s,t,e,n,o){let r=s.scaleX,a=s.scaleY;switch(e){case "rotate":{let i=t.a/r,p=t.b/r,l=t.c/a,c=t.d/a,d=n*L-Math.atan2(l,i);d>Math.PI?d-=2*Math.PI:d<-Math.PI&&(d+=2*Math.PI),d*=o;let h=Math.cos(d),u=Math.sin(d);t.a=(h*i-u*l)*r,t.b=(h*p-u*c)*r,t.c=(u*i+h*l)*a,t.d=(u*p+h*c)*a;return}case "x":t.worldX+=(n-t.worldX/r)*o*r;return;case "y":t.worldY+=(n-t.worldY/a)*o*a;return;case "scaleX":{let i=Math.hypot(t.a/r,t.c/a);i!==0&&(i=1+(n-i)*o/i,t.a*=i,t.c*=i);return}case "scaleY":{let i=Math.hypot(t.b/r,t.d/a);i!==0&&(i=1+(n-i)*o/i,t.b*=i,t.d*=i);return}case "shearY":{let i=t.b/r,p=t.d/a,l=Math.atan2(p,i),c=(n+90)*L;c-=l-Math.atan2(t.c/a,t.a/r),c>Math.PI?c-=2*Math.PI:c<-Math.PI&&(c+=2*Math.PI),c=l+c*o;let d=Math.hypot(i,p);t.b=Math.cos(c)*d*r,t.d=Math.sin(c)*d*a;return}}}var Q=class{constructor(t){this.channels=t;}channels;times=[];values=[];kinds=[];samples=[];get count(){return this.times.length}add(t,e){this.times.push(t);for(let n=0;n<this.channels;n++)this.values.push(e[n]??0);this.kinds.push(0);for(let n=0;n<this.channels;n++)this.samples.push(null);}setCurve(t,e){if(e==="stepped"){this.kinds[t]=1;return}if(!Array.isArray(e)||t+1>=this.count)return;this.kinds[t]=2;let n=this.times[t],o=this.times[t+1];for(let r=0;r<this.channels;r++){let a=r*4;if(e.length<a+4)continue;let i=this.values[t*this.channels+r],p=this.values[(t+1)*this.channels+r];this.samples[t*this.channels+r]=qt(n,i,Number(e[a]),Number(e[a+1]),Number(e[a+2]),Number(e[a+3]),o,p);}}keyAt(t){let e=this.times;if(!e.length||t<e[0])return -1;let n=0,o=e.length-1;for(;n<o;){let r=n+o+1>>1;e[r]<=t?n=r:o=r-1;}return n}value(t,e=0){let n=Math.max(0,this.keyAt(t)),o=this.channels,r=this.values[n*o+e];if(n+1>=this.count)return r;let a=this.kinds[n];if(a===1)return r;let i=this.times[n],p=this.times[n+1],l=this.values[(n+1)*o+e],c=this.samples[n*o+e];if(a!==2||!c)return r+(t-i)/(p-i)*(l-r);if(c[0]>t)return r+(t-i)/(c[0]-i)*(c[1]-r);for(let u=2;u<18;u+=2)if(c[u]>=t){let m=c[u-2],f=c[u-1];return f+(t-m)/(c[u]-m)*(c[u+1]-f)}let d=c[16],h=c[17];return h+(t-d)/(p-d)*(l-h)}};function qt(s,t,e,n,o,r,a,i){let p=new Float32Array(18);for(let l=1;l<=9;l++){let c=l/10,d=1-c,h=d*d*d,u=3*d*d*c,m=3*d*c*c,f=c*c*c;p[(l-1)*2]=h*s+u*e+m*o+f*a,p[(l-1)*2+1]=h*t+u*n+m*r+f*i;}return p}var It=(s,t)=>s.bone!==void 0&&t.bones.has(s.bone)||s.slot!==void 0&&t.slots.has(s.slot),dt=class{constructor(t,e,n,o){this.name=t;this.duration=e;this.timelines=n;this.events=o;}name;duration;timelines;events;apply(t,e){for(let n of this.timelines)n.apply(t,e);}applyOnly(t,e,n){for(let o of this.timelines)It(o,n)&&o.apply(t,e);}touches(t){return this.timelines.some(e=>It(e,t))}},ut=class{constructor(t,e,n){this.bone=t;this.keys=e;this.props=n;}bone;keys;props;apply(t,e){if(this.keys.keyAt(e)<0)return;let n=t.bones[this.bone],o=n.pose,r=n.data;this.props.forEach((a,i)=>{let p=this.keys.value(e,i);switch(a){case "rotate":o.rotation=r.rotation+p;break;case "x":o.x=r.x+p;break;case "y":o.y=r.y+p;break;case "scaleX":o.scaleX=r.scaleX*p;break;case "scaleY":o.scaleY=r.scaleY*p;break}});}},tt=class{constructor(t,e,n){this.slot=t;this.keys=e;this.channels=n;}slot;keys;channels;apply(t,e){if(this.keys.keyAt(e)<0)return;let n=t.slots[this.slot].color;this.channels.forEach((o,r)=>n[o]=this.keys.value(e,r));}},mt=class{constructor(t,e,n){this.slot=t;this.times=e;this.names=n;}slot;times;names;apply(t,e){if(e<this.times[0])return;let n=0;for(;n+1<this.times.length&&this.times[n+1]<=e;)n++;t.slots[this.slot].attachmentKey=this.names[n];}},ft=class{constructor(t,e,n){this.constraint=t;this.keys=e;this.bends=n;}constraint;keys;bends;apply(t,e){let n=this.keys.keyAt(e);if(n<0)return;let o=t.constraints[this.constraint];o instanceof I&&(o.mix=this.keys.value(e,0),o.bendDirection=this.bends[n]);}};function z(s,t,e){let n=new Q(t);for(let o of s)n.add(o.time??0,e(o));return s.forEach((o,r)=>n.setCurve(r,o.curve)),n}var Wt={rotate:{props:["rotate"],read:s=>[s.value??0]},translate:{props:["x","y"],read:s=>[s.x??0,s.y??0]},translatex:{props:["x"],read:s=>[s.value??0]},translatey:{props:["y"],read:s=>[s.value??0]},scale:{props:["scaleX","scaleY"],read:s=>[s.x??1,s.y??1]},scalex:{props:["scaleX"],read:s=>[s.value??1]},scaley:{props:["scaleY"],read:s=>[s.value??1]}};function Yt(s,t,e){let n=[],o=0,r=i=>{for(let p of i)o=Math.max(o,p.time??0);};for(let[i,p]of Object.entries(t.bones??{})){let l=e.bone(i).index;for(let[c,d]of Object.entries(p)){let h=Wt[c];!h||!d.length||(r(d),n.push(new ut(l,z(d,h.props.length,h.read),h.props)));}}for(let[i,p]of Object.entries(t.slots??{})){let l=e.slot(i).index;for(let[c,d]of Object.entries(p))if(d.length)if(r(d),c==="attachment")n.push(new mt(l,d.map(h=>h.time??0),d.map(h=>h.name??null)));else if(c==="rgba"||c==="rgb"){let h=c==="rgba"?["r","g","b","a"]:["r","g","b"],u=z(d,h.length,m=>{let f=O(m.color);return h.map(b=>f[b])});n.push(new tt(l,u,[...h]));}else c==="alpha"&&n.push(new tt(l,z(d,1,h=>[h.value??0]),["a"]));}for(let[i,p]of Object.entries(t.ik??{})){let l=e.constraints.find(c=>c.type==="ik"&&c.name===i);!l||!p.length||(r(p),n.push(new ft(l.index,z(p,1,c=>[c.mix??1]),p.map(c=>c.bendPositive===false?-1:1))));}let a=(t.events??[]).map(i=>({time:i.time??0,name:i.name}));for(let i of a)o=Math.max(o,i.time);return new dt(s,o,n,a)}function ve(s){let t=[],e=new Map;for(let h of s.bones){let u=h.parent?e.get(h.parent)??null:null,m={index:t.length,name:h.name,parent:u,children:[],length:h.length??0,x:h.x??0,y:h.y??0,rotation:h.rotation??0,scaleX:h.scaleX??1,scaleY:h.scaleY??1};u?.children.push(m),t.push(m),e.set(m.name,m);}let n=h=>{let u=e.get(h);if(!u)throw new Error(`no bone ${h}`);return u},o=[],r=new Map;for(let h of s.slots){let u={index:o.length,name:h.name,bone:n(h.bone),attachment:h.attachment??null,color:O(h.color)};o.push(u),r.set(u.name,u);}let a=h=>{let u=r.get(h);if(!u)throw new Error(`no slot ${h}`);return u},i=[];for(let h of s.constraints??[])if(h.type==="ik")i.push({type:"ik",index:i.length,name:h.name,bones:h.bones.map(n),target:n(h.target),mix:h.mix??1,bendDirection:h.bendPositive===false?-1:1});else if(h.type==="transform"){let u=[],m=new Set;for(let[y,x]of Object.entries(h.properties??{})){let g=[];for(let[w,M]of Object.entries(x.to??{}))m.add(w),g.push({prop:w,offset:M.offset??0,max:M.max??1,scale:M.scale??1});g.length&&u.push({prop:y,offset:x.offset??0,to:g});}let f=h.mixX??1,b=h.mixScaleX??1;i.push({type:"transform",index:i.length,name:h.name,source:n(h.source),bones:h.bones.map(n),offsets:{rotate:h.rotation??0,x:h.x??0,y:h.y??0,scaleX:h.scaleX??0,scaleY:h.scaleY??0,shearY:h.shearY??0},mix:{rotate:m.has("rotate")?h.mixRotate??1:0,x:m.has("x")?f:0,y:m.has("y")?h.mixY??f:0,scaleX:m.has("scaleX")?b:0,scaleY:m.has("scaleY")?h.mixScaleY??b:0,shearY:m.has("shearY")?h.mixShearY??1:0},properties:u});}let p=new Map,l=[],c=[];for(let h of s.skins){let u={name:h.name,attachments:new Map};for(let[m,f]of Object.entries(h.attachments??{})){let b=a(m).index,y=new Map;u.attachments.set(b,y);for(let[x,g]of Object.entries(f)){let w=g.type??"region";w==="linkedmesh"?c.push({skin:u,slot:b,key:x,a:g}):y.set(x,Kt(x,g,w));}}p.set(u.name,u),l.push(u.name);}for(let{skin:h,slot:u,key:m,a:f}of c){let y=(p.get(f.skin??"default")??h).attachments.get(u)?.get(f.source??f.parent);if(!y||y.type!=="mesh")throw new Error(`linked mesh ${h.name}/${m}: no source mesh`);h.attachments.get(u).set(m,{...y,key:m,path:f.path??f.name??m,width:f.width??y.width,height:f.height??y.height,color:O(f.color)});}let d={width:s.skeleton?.width??0,height:s.skeleton?.height??0,x:s.skeleton?.x??0,y:s.skeleton?.y??0,bones:t,slots:o,constraints:i,skins:p,skinOrder:l,animations:new Map,events:Object.keys(s.events??{}),bone:n,slot:a};for(let[h,u]of Object.entries(s.animations??{}))d.animations.set(h,Yt(h,u,d));return d}function Kt(s,t,e){let n=t.path??t.name??s;if(e==="mesh"){let o=Float32Array.from(t.uvs),r=o.length/2,a=t.vertices;return {type:"mesh",key:s,path:n,uvs:o,triangles:Uint16Array.from(t.triangles),vertices:Float32Array.from(a),weighted:a.length>o.length,vertexCount:r,width:t.width??0,height:t.height??0,color:O(t.color)}}return {type:"region",key:s,path:n,x:t.x??0,y:t.y??0,rotation:t.rotation??0,scaleX:t.scaleX??1,scaleY:t.scaleY??1,width:t.width??0,height:t.height??0,color:O(t.color)}}var Dt=new WeakMap;function we(s){let t=Dt.get(s);if(t)return t;t=new Map;for(let e of s.skins.values())for(let n of e.attachments.values())for(let o of n.values())t.has(o.path)||t.set(o.path,{w:o.width,h:o.height});return Dt.set(s,t),t}function Se(s,t){let e=s.skins.get(t);if(!e)return [];let n=new Set;for(let o of e.attachments.values())for(let r of o.values())n.add(r.path);return [...n]}var j=Math.PI/180,yt=1e-5,et=class{constructor(t){this.bone=t;}bone;x=0;y=0;rotation=0;scaleX=1;scaleY=1;shearX=0;shearY=0;a=1;b=0;c=0;d=1;worldX=0;worldY=0;world=0;local=0;copyLocal(t){this.x=t.x,this.y=t.y,this.rotation=t.rotation,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this.shearX=t.shearX,this.shearY=t.shearY;}update(t){this.world!==t.updateId&&this.updateWorldTransform(t);}updateWorldTransform(t){this.local===t.updateId?this.updateLocalTransform(t):this.world=t.updateId;let e=(this.rotation+this.shearX)*j,n=(this.rotation+90+this.shearY)*j,o=Math.cos(e)*this.scaleX,r=Math.cos(n)*this.scaleY,a=Math.sin(e)*this.scaleX,i=Math.sin(n)*this.scaleY,p=this.bone.parent;if(!p){let c=t.scaleX,d=t.scaleY;this.a=o*c,this.b=r*c,this.c=a*d,this.d=i*d,this.worldX=this.x*c+t.x,this.worldY=this.y*d+t.y;return}let l=p.applied;this.worldX=l.a*this.x+l.b*this.y+l.worldX,this.worldY=l.c*this.x+l.d*this.y+l.worldY,this.a=l.a*o+l.b*a,this.b=l.a*r+l.b*i,this.c=l.c*o+l.d*a,this.d=l.c*r+l.d*i;}updateLocalTransform(t){this.local=0,this.world=t.updateId;let e=this.bone.parent;if(!e){this.x=(this.worldX-t.x)/t.scaleX,this.y=(this.worldY-t.y)/t.scaleY,this.set5(this.a/t.scaleX,this.b/t.scaleX,this.c/t.scaleY,this.d/t.scaleY);return}let n=e.applied,o=1/(n.a*n.d-n.b*n.c),r=n.d*o,a=n.b*o,i=n.c*o,p=n.a*o,l=this.worldX-n.worldX,c=this.worldY-n.worldY;this.x=l*r-c*a,this.y=c*p-l*i,this.set5(r*this.a-a*this.c,r*this.b-a*this.d,p*this.c-i*this.a,p*this.d-i*this.b);}set5(t,e,n,o){this.shearX=0;let r=t*t+n*n,a=e*e+o*o;if(r>yt){let i=Math.atan2(n,t)/j;this.rotation=i,this.scaleX=Math.sqrt(r),this.scaleY=Math.sqrt(a),a>yt?(this.shearY=Math.atan2(o,e)/j,t*o-e*n<0?(this.scaleY=-this.scaleY,this.shearY+=90-i):this.shearY-=90+i,this.shearY>180?this.shearY-=360:this.shearY<=-180&&(this.shearY+=360)):this.shearY=0;}else this.scaleX=0,this.scaleY=Math.sqrt(a),this.shearY=0,this.rotation=a>yt?Math.atan2(o,e)/j-90:0;}modifyLocal(t){this.local===t.updateId&&this.updateLocalTransform(t),this.world=0,this.resetWorld(t);}modifyWorld(t){this.local=t.updateId,this.world=t.updateId,this.resetWorld(t);}resetWorld(t){for(let e of this.bone.children){let n=e.applied;n.world===t.updateId&&(n.local===t.updateId&&n.updateLocalTransform(t),n.world=0,n.resetWorld(t));}}},nt=class{constructor(t){this.data=t;this.pose=new et(this),this.applied=new et(this),this.setupPose();}data;pose;applied;parent=null;children=[];sorted=false;setupPose(){let t=this.data,e=this.pose;e.x=t.x,e.y=t.y,e.rotation=t.rotation,e.scaleX=t.scaleX,e.scaleY=t.scaleY,e.shearX=0,e.shearY=0;}},bt=class{constructor(t,e){this.data=t;this.bone=e;this.color={...t.color},this.attachmentKey=t.attachment;}data;bone;color;attachmentKey;attachment=null},ot=class{constructor(t){this.data=t;this.bones=t.bones.map(e=>new nt(e));for(let e of this.bones)e.data.parent&&(e.parent=this.bones[e.data.parent.index],e.parent.children.push(e));this.slots=t.slots.map(e=>new bt(e,this.bones[e.bone.index])),this.constraints=t.constraints.map(e=>At(e,this)),this.updateCache();}data;bones;slots;constraints;skins=[];scaleX=1;scaleY=1;x=0;y=0;updateId=0;cache=[];bone(t){return this.bones[this.data.bone(t).index]}slot(t){return this.slots[this.data.slot(t).index]}setSkins(t){this.skins=[...t],this.resolveAttachments();}getAttachment(t,e){for(let n=this.skins.length-1;n>=0;n--){let o=this.skins[n].attachments.get(t)?.get(e);if(o)return o}return null}resolveAttachments(){for(let t of this.slots)t.attachment=t.attachmentKey?this.getAttachment(t.data.index,t.attachmentKey):null;}setupPose(){for(let t of this.bones)t.setupPose();for(let t of this.constraints)t.setupPose();for(let t of this.slots)Object.assign(t.color,t.data.color),t.attachmentKey=t.data.attachment;}updateWorldTransform(){this.updateId++;for(let t of this.bones)t.applied.copyLocal(t.pose),t.applied.world=0,t.applied.local=0;for(let t of this.cache)t instanceof nt?t.applied.update(this):t.update(this);}updateCache(){this.cache=[];for(let t of this.bones)t.sorted=false;for(let t of this.constraints)t.sort(this);for(let t of this.bones)this.sortBone(t);}sortBone(t){t.sorted||(t.parent&&this.sortBone(t.parent),t.sorted=true,this.cache.push(t));}sortReset(t){for(let e of t)e.sorted&&this.sortReset(e.children),e.sorted=false;}pushConstraint(t){this.cache.push(t);}};var Xt=class{constructor(t,e,n=.2){this.skeleton=t;this.data=e;this.defaultMix=n;this.snapshot=new Float32Array(t.bones.length*5),this.slotSnapshot=new Float32Array(t.slots.length*4),this.ikSnapshot=new Float32Array(t.constraints.length);}skeleton;data;defaultMix;track=null;previous=null;mixTime=0;mixDuration=0;listeners=new Map;snapshot;slotSnapshot;ikSnapshot;blink=null;setBlink(t){let e=t?this.data.animations.get(t.animation):void 0;if(!t||!e){this.blink=null;return}let n={bones:new Set(t.bones.map(o=>this.data.bone(o).index)),slots:new Set(t.slots.map(o=>this.data.slot(o).index))};this.blink={source:e,filter:n,options:t,wait:this.nextBlink(t),at:-1};}blinkNow(){this.blink&&(this.blink.at=0);}blinking(){return (this.blink?.at??-1)>=0}setRandom(t){this.random=t;}random=Math.random;nextBlink(t){return t.every[0]+this.random()*(t.every[1]-t.every[0])}names(){return [...this.data.animations.keys()]}has(t){return this.data.animations.has(t)}play(t,e={}){let n=this.data.animations.get(t);if(!n)return false;let o=e.mix??this.defaultMix;return this.previous=this.track&&o>0?this.track:null,this.mixTime=0,this.mixDuration=this.previous?o:0,this.track={animation:n,time:Math.max(0,e.from??0),speed:e.speed??1,loop:e.loop??true,done:false},true}current(){return this.track?.animation.name??null}time(){return this.track?this.local(this.track):0}duration(){return this.track?.animation.duration??0}finished(){return this.track?.done??false}setSpeed(t){this.track&&(this.track.speed=t);}on(t,e){let n=this.listeners.get(t)??new Set;return n.add(e),this.listeners.set(t,n),()=>n.delete(e)}update(t){let e=[],n=this.track;if(n&&!n.done){let o=n.time;n.time+=Math.max(0,t)*n.speed,this.collect(n,o,n.time,e),!n.loop&&n.time>=n.animation.duration&&(n.time=n.animation.duration,n.done=true,e.push({name:"end",animation:n.animation.name}));}if(this.previous){let o=this.previous;o.time+=Math.max(0,t)*o.speed,this.mixTime+=Math.max(0,t),this.mixTime>=this.mixDuration&&(this.previous=null);}this.advanceBlink(Math.max(0,t)),this.pose();for(let o of e){for(let r of this.listeners.get(o.name)??[])r(o);for(let r of this.listeners.get("*")??[])r(o);}}pose(){let t=this.skeleton,e=this.previous;e&&this.mixDuration>0&&(t.setupPose(),e.animation.apply(t,this.local(e)),this.save()),t.setupPose(),this.track&&this.track.animation.apply(t,this.local(this.track)),e&&this.mixDuration>0&&this.blendFromSaved(Math.min(1,this.mixTime/this.mixDuration));let n=this.blink;n&&n.at>=0&&n.source.applyOnly(t,n.options.from+n.at,n.filter),t.resolveAttachments();}advanceBlink(t){let e=this.blink;if(e){if(this.track?.animation.touches(e.filter)){e.at=-1;return}if(e.at>=0){e.at+=t,e.at>=e.options.to-e.options.from&&(e.at=-1,e.wait=this.nextBlink(e.options));return}e.wait-=t,e.wait<=0&&(e.at=0);}}local(t){let e=t.animation.duration;return e<=0?0:t.loop?t.time%e:Math.min(t.time,e)}collect(t,e,n,o){let r=t.animation.duration;if(r<=0||n<=e)return;let a=Math.floor(e/r),i=t.loop?Math.floor(n/r):0;for(let p=a;p<=i;p++)for(let l of t.animation.events){let c=p*r+l.time;c>=e&&(c<n||!t.loop&&c<=n)&&o.push({name:l.name,animation:t.animation.name});}}save(){let t=this.skeleton;t.bones.forEach((e,n)=>{let o=e.pose;this.snapshot.set([o.x,o.y,o.rotation,o.scaleX,o.scaleY],n*5);}),t.slots.forEach((e,n)=>this.slotSnapshot.set([e.color.r,e.color.g,e.color.b,e.color.a],n*4)),t.constraints.forEach((e,n)=>{e instanceof I&&(this.ikSnapshot[n]=e.mix);});}blendFromSaved(t){let e=this.skeleton,n=(o,r)=>o+(r-o)*t;e.bones.forEach((o,r)=>{let a=this.snapshot,i=o.pose,p=r*5;i.x=n(a[p],i.x),i.y=n(a[p+1],i.y);let l=i.rotation-a[p+2];l-=Math.round(l/360)*360,i.rotation=a[p+2]+l*t,i.scaleX=n(a[p+3],i.scaleX),i.scaleY=n(a[p+4],i.scaleY);}),e.slots.forEach((o,r)=>{let a=this.slotSnapshot;o.color.r=n(a[r*4],o.color.r),o.color.g=n(a[r*4+1],o.color.g),o.color.b=n(a[r*4+2],o.color.b),o.color.a=n(a[r*4+3],o.color.a);}),e.constraints.forEach((o,r)=>{o instanceof I&&(o.mix=n(this.ikSnapshot[r],o.mix));});}};var Et=Math.PI/180,jt=new Float32Array([0,1,0,0,1,0,1,1]),Gt=new Uint16Array([0,1,2,2,3,0]),Bt=new WeakMap;function Vt(s){let t=Bt.get(s);if(t)return t;let e=-s.width/2*s.scaleX,n=-s.height/2*s.scaleY,o=s.width/2*s.scaleX,r=s.height/2*s.scaleY,a=Math.cos(s.rotation*Et),i=Math.sin(s.rotation*Et),p=(l,c)=>[l*a-c*i+s.x,l*i+c*a+s.y];return t=Float32Array.from([...p(e,n),...p(e,r),...p(o,r),...p(o,n)]),Bt.set(s,t),t}function Ct(s,t,e,n){if(e.type==="region"){let o=n&&n.length===8?n:new Float32Array(8),r=Vt(e),a=t.bone.applied;for(let i=0;i<8;i+=2){let p=r[i],l=r[i+1];o[i]=p*a.a+l*a.b+a.worldX,o[i+1]=p*a.c+l*a.d+a.worldY;}return {positions:o,uvs:jt,triangles:Gt}}return Ut(s,t,e,n)}function Ut(s,t,e,n){let o=e.vertexCount*2,r=n&&n.length===o?n:new Float32Array(o),a=e.vertices;if(e.weighted){let i=0;for(let p=0;p<o;p+=2){let l=a[i++],c=0,d=0;for(let h=0;h<l;h++,i+=4){let u=s.bones[a[i]].applied,m=a[i+1],f=a[i+2],b=a[i+3];c+=(m*u.a+f*u.b+u.worldX)*b,d+=(m*u.c+f*u.d+u.worldY)*b;}r[p]=c,r[p+1]=d;}}else {let i=t.bone.applied;for(let p=0;p<o;p+=2){let l=a[p],c=a[p+1];r[p]=l*i.a+c*i.b+i.worldX,r[p+1]=l*i.c+c*i.d+i.worldY;}}return {positions:r,uvs:e.uvs,triangles:e.triangles}}var _t=1;function De(...s){let t={v:1,parts:{},colors:{}};for(let e of s)e&&(Object.assign(t.parts,e.parts),Object.assign(t.colors,e.colors));return t}function Xe(s){if(!s||typeof s!="object")return null;let t=s;if(t.v!==1)return null;let e={},n={};if(t.parts&&typeof t.parts=="object")for(let[o,r]of Object.entries(t.parts))(r===null||typeof r=="string")&&(e[o]=r);if(t.colors&&typeof t.colors=="object")for(let[o,r]of Object.entries(t.colors))typeof r=="string"&&/^#[0-9a-f]{6}$/i.test(r)&&(n[o]=r);return {v:1,parts:e,colors:n}}var Ot=class{constructor(t,e=()=>true){this.rig=t;this.drawable=e;let n=(o,r)=>t.colorTargets.find(a=>(a.into??"tint")===r&&a.slotPrefixes.some(i=>o.startsWith(i)))?.id??null;this.slotTarget=t.data.slots.map(o=>n(o.name,"tint")),this.slotArt=t.data.slots.map(o=>n(o.name,"art")),this.rebuildLists(),this.init();}rig;drawable;chosen=new Map;hidden=new Map;colors=new Map;lists=new Map;listeners=new Set;slotTarget;slotArt;face=null;emotionFace=null;speech="rest";setDrawable(t){let e=new Set(this.rig.partTypes.filter(n=>!this.count(n.id)).map(n=>n.id));this.drawable=t,this.rebuildLists();for(let n of this.rig.partTypes){if(n.auto)continue;let o=this.chosen.get(n.id);(o&&!this.lists.get(n.id).includes(o)||!o&&e.has(n.id))&&this.chosen.set(n.id,this.first(n));}this.emit({kind:"part",type:"*",skin:null});}on(t){return this.listeners.add(t),()=>this.listeners.delete(t)}emit(t){for(let e of [...this.listeners])e(t);}typeDef(t){return this.rig.partTypes.find(e=>e.id===t)}list(t){return this.lists.get(t)??[]}count(t){return this.list(t).length}part(t){return this.chosen.get(t)??null}index(t){let e=this.part(t);return e?this.list(t).indexOf(e):-1}isHidden(t){return this.hidden.get(t)??false}isWorn(t){return this.part(t)!==null&&!this.isHidden(t)}color(t){return this.colors.get(t)??null}wornSkins(){let t=new Map;for(let l of this.rig.partTypes)t.set(l.id,!l.auto&&this.isWorn(l.id)?this.part(l.id):null);let e={worn:l=>t.get(l)??null,setWorn:(l,c)=>t.set(l,c),exists:l=>this.rig.data.skins.has(l)&&this.drawable(l)};for(let l of this.rig.rules)l.apply(e);let n=this.rig.expressions,o=this.face??this.emotionFace,r=o?n?.faces[o]:void 0;for(let[l,c]of Object.entries(r??{}))t.get(l)&&e.exists(c)&&t.set(l,c);let a=this.speech!=="rest"?n?.speech:void 0,i=a?.visemes[this.speech];a&&i&&t.get(a.type)&&e.exists(i)&&t.set(a.type,i);let p=[];for(let l of this.rig.partTypes){let c=t.get(l.id);c&&p.push(c);}return p}slotColor(t){let e=this.slotTarget[t];return e?this.color(e):null}artColor(t){let e=this.slotArt[t];return e?this.color(e):null}expression(){return this.face}equip(t,e){let n=this.lists.get(t);if(!n)return;let o;if(e===null||e===-1)o=null;else if(typeof e=="number")o=n[Math.max(0,Math.min(n.length-1,e))]??null;else if(n.includes(e))o=e;else return;o===null&&!this.typeDef(t)?.canHide||(this.chosen.set(t,o),this.emit({kind:"part",type:t,skin:o}));}unequip(t){this.equip(t,null);}setHidden(t,e){this.typeDef(t)?.canHide&&(this.hidden.set(t,e),this.emit({kind:"hidden",type:t,hidden:e}));}next(t){let e=this.count(t);if(!e)return;let n=this.index(t);this.typeDef(t)?.canHide?this.equip(t,n>=e-1?-1:n+1):this.equip(t,(n+1)%e);}prev(t){let e=this.count(t);if(!e)return;let n=this.index(t);this.typeDef(t)?.canHide?this.equip(t,n<=-1?e-1:n-1):this.equip(t,(n-1+e)%e);}setColor(t,e){this.colors.set(t,e),this.emit({kind:"color",target:t,color:e});}setExpression(t){let e=t&&this.rig.expressions?.faces[t]?t:null;e!==this.face&&(this.face=e,this.emit({kind:"expression",name:e}));}setEmotion(t){let e=this.rig.expressions?.emotions?.[t]??null,n=e&&this.rig.expressions?.faces[e]?e:null;n!==this.emotionFace&&(this.emotionFace=n,this.emit({kind:"expression",name:this.face??n}));}setSpeech(t){t!==this.speech&&(this.speech=t,this.emit({kind:"speech",viseme:t}));}randomize(t=Math.random){for(let e of this.rig.partTypes){if(e.auto)continue;let n=this.count(e.id);n&&this.equip(e.id,e.canHide&&t()<.3?-1:Math.floor(t()*n));}}reset(){this.init();for(let t of this.rig.partTypes)this.emit({kind:"part",type:t.id,skin:this.part(t.id)});}toLook(){let t={};for(let n of this.rig.partTypes)n.auto||(t[n.id]=this.isWorn(n.id)?this.part(n.id):null);let e={};for(let[n,o]of this.colors)o&&(e[n]=o);return {v:1,parts:t,colors:e}}applyLook(t){for(let[e,n]of Object.entries(t.parts??{}))n===void 0||this.typeDef(e)?.auto||(this.equip(e,n),n!==null&&this.part(e)===n&&this.hidden.set(e,false));for(let[e,n]of Object.entries(t.colors??{}))n&&this.setColor(e,n);}rebuildLists(){for(let t of this.rig.partTypes)this.lists.set(t.id,this.rig.data.skinOrder.filter(e=>e.startsWith(t.skinPrefix)&&this.drawable(e)));}first(t){return this.lists.get(t.id)?.[0]??null}init(){this.chosen.clear(),this.hidden.clear(),this.colors.clear();for(let t of this.rig.partTypes)this.chosen.set(t.id,t.auto?null:this.first(t));}};var Lt=new WeakMap;function Le(s,t){let e=Lt.get(s);if(e)return e;e=new Map;let n=new ot(s);n.setupPose(),n.updateWorldTransform();let[o,r]=t.light;for(let a of s.skins.values())for(let[i,p]of a.attachments)for(let l of p.values()){if(e.has(l.path)||t.skip?.some(b=>l.path.startsWith(b)))continue;let c=Ct(n,n.slots[i],l,null),d=Zt(c.positions,c.uvs,l.width,l.height);if(!d)continue;let h=d.a*d.d-d.b*d.c;if(Math.abs(h)<1e-9)continue;let u=(d.d*o-d.b*r)/h,m=(-d.c*o+d.a*r)/h,f=Math.hypot(u,m)||1;e.set(l.path,{x:u/f,y:m/f});}return Lt.set(s,e),e}function Zt(s,t,e,n){let o=t.length/2;if(o<3)return null;let r=0,a=0,i=0,p=0;for(let y=0;y<o;y++)r+=t[y*2]*e,a+=t[y*2+1]*n,i+=s[y*2],p+=s[y*2+1];r/=o,a/=o,i/=o,p/=o;let l=0,c=0,d=0,h=0,u=0,m=0,f=0;for(let y=0;y<o;y++){let x=t[y*2]*e-r,g=t[y*2+1]*n-a,w=s[y*2]-i,M=s[y*2+1]-p;l+=x*x,c+=x*g,d+=g*g,h+=w*x,u+=w*g,m+=M*x,f+=M*g;}let b=l*d-c*c;return Math.abs(b)<1e-9?null:{a:(h*d-u*c)/b,b:(u*l-h*c)/b,c:(m*d-f*c)/b,d:(f*l-m*c)/b}}
2
- export{De as A,Xe as B,Ot as C,Le as D,Tt as a,Qt as b,zt as c,Rt as d,Ft as e,te as f,ee as g,ne as h,oe as i,se as j,re as k,ie as l,le as m,ce as n,he as o,O as p,dt as q,ve as r,we as s,Se as t,nt as u,bt as v,ot as w,Xt as x,Ct as y,_t as z};