import{s as g,_ as E,o as f,l as C}from"./schemas-DQxGDFXJ.js";const M="pocket-humanoid-v2",l=["head","hair","headwear","top","outerwear","arms","armwear","legs","feet","belt","shoulders","neck","back","weapon"],R={triangles:4e4,joints:64,influences:4,drawCalls:1,materials:1},m=g().regex(/^[a-z0-9-]+$/).max(120),h=g().regex(/^#[a-f0-9]{6}$/i),w=E(["original","custom"]),j=f({version:C(1),packRevision:g().regex(/^[a-f0-9]{64}$/),rig:m,parts:f(Object.fromEntries(l.map(t=>[t,m.nullable().optional()]))).strict(),colors:f({skin:h,hair:h,cloth:h}).strict(),colorMode:w.optional(),partColorModes:f(Object.fromEntries(l.map(t=>[t,w.optional()]))).strict().optional()}).strict();function b(t,e){var a;const r=j.parse(t);if(r.packRevision!==e.revision)throw new Error("Character pack changed. Reload the builder.");const o=e.rigs.find(i=>i.id===r.rig);if(!o)throw new Error("Unknown character rig.");let s=0;const n=Object.values(r.parts).filter(Boolean);for(const i of l){const d=r.parts[i];if(!d){if(o.requiredSlots.includes(i))throw new Error(`Choose a ${i} part.`);continue}const c=e.parts.find(u=>u.id===d);if(!c||c.rig!==r.rig||c.slot!==i)throw new Error(`Incompatible ${i} part.`);if((a=c.requires)!=null&&a.length&&!c.requires.some(u=>n.includes(u)))throw new Error(`${c.name} needs its matching base part.`);const p=v(c,r,e);if(p)throw new Error(p);s+=c.triangles}if(s>R.triangles)throw new Error("This outfit exceeds the character geometry budget.");return r}function O(t,e=t.rigs[0].id){const r=t.rigs.find(o=>o.id===e);if(!r)throw new Error("Unknown character rig.");return{version:1,packRevision:t.revision,rig:r.id,parts:{...r.defaults},colors:{skin:"#c99069",hair:"#44302b",cloth:"#719b81"},colorMode:"original"}}function A(t,e){b(t,e);const r=e.rigs.find(s=>s.id===t.rig),o=$(t,e);return{recipe:t,rig:r.asset,defaultAnimations:r.defaultAnimations,parts:l.flatMap(s=>t.parts[s]&&!o.has(s)?[e.parts.find(n=>n.id===t.parts[s])]:[])}}function v(t,e,r){for(const[o,s]of Object.entries(t.compatibleWith??{}))if(!s.includes(e.parts[o]??"")){const n=s.map(a=>{var i;return((i=r.parts.find(d=>d.id===a))==null?void 0:i.name)??a});return`${t.name} fits ${n.join(" or ")}.`}return null}function $(t,e){const r=new Map;for(const o of e.parts.filter(s=>Object.values(t.parts).includes(s.id)))for(const s of o.hides??[])r.set(s,o.name);return r}function S(t,e){const r=structuredClone(t),o=[],s=e.rigs.find(n=>n.id===r.rig);for(const n of l){const a=e.parts.find(i=>i.id===r.parts[n]);a&&!s.requiredSlots.includes(n)&&v(a,r,e)&&(r.parts[n]=null,o.push(a.name))}return{recipe:b(r,e),removed:o}}export{M as C,$ as a,R as b,A as c,v as d,j as e,l as f,O as g,S as r,b as v};
