agent-office-studio 0.6.0 → 0.7.0

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
- var Kp=Object.defineProperty;var Zp=(i,t,e)=>t in i?Kp(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var _e=(i,t,e)=>Zp(i,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const r of a.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&n(r)}).observe(document,{childList:!0,subtree:!0});function e(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function n(s){if(s.ep)return;s.ep=!0;const a=e(s);fetch(s.href,a)}})();"serviceWorker"in navigator&&addEventListener("load",()=>navigator.serviceWorker.register("/sw.js").catch(()=>{}));const of=[{id:"paper",name:"Paper"},{id:"ocean",name:"Ocean"},{id:"forest",name:"Forest"},{id:"sunset",name:"Sunset"},{id:"lavender",name:"Lavender"}],oh=[{id:"light",name:"Light"},{id:"dark",name:"Dark"},{id:"auto",name:"Auto"}],Zo=document.documentElement,lf=matchMedia("(prefers-color-scheme: dark)"),cf=(i,t,e)=>{try{const n=localStorage.getItem(i);return e.some(s=>s.id===n)?n:t}catch{return t}},hu=(i,t)=>{try{localStorage.setItem(i,t)}catch{}};try{if(localStorage.getItem("office.appearance")===null){const i=localStorage.getItem("office.mode");oh.some(t=>t.id===i)&&(localStorage.setItem("office.appearance",i),localStorage.removeItem("office.mode"))}}catch{}let nc=cf("office.theme","paper",of),ar=cf("office.appearance","auto",oh);const Ya=document.getElementById("themeBtn"),Ln=document.getElementById("themePop");function _o(){const i=ar==="dark"||ar==="auto"&&lf.matches?"dark":"light";Zo.dataset.theme=nc,Zo.dataset.mode=i;const t=document.querySelector('meta[name="theme-color"]');t&&(t.content=getComputedStyle(Zo).getPropertyValue("--paper").trim()||t.content),Jp()}function Jp(){if(!Ln)return;Ln.replaceChildren();const i=e=>Object.assign(document.createElement("p"),{className:"theme-k",textContent:e}),t=(e,n,s,a)=>{const r=document.createElement("div");r.className=a,r.setAttribute("role","radiogroup");for(const o of e){const l=document.createElement("button");l.type="button",l.dataset.t=o.id,l.setAttribute("role","radio"),l.setAttribute("aria-checked",String(o.id===n)),l.innerHTML=a==="theme-swatches"?"<i></i><span></span>":"<span></span>",l.querySelector("span").textContent=o.name,l.addEventListener("click",()=>s(o.id)),r.appendChild(l)}return r};Ln.append(i("Theme"),t(of,nc,e=>{nc=e,hu("office.theme",e),_o()},"theme-swatches"),i("Mode"),t(oh,ar,e=>{ar=e,hu("office.appearance",e),_o()},"theme-modes"))}function lh(i){var t;Ln.hidden=!i,Ya.setAttribute("aria-expanded",String(i)),i&&((t=Ln.querySelector('[aria-checked="true"]'))==null||t.focus())}Ya==null||Ya.addEventListener("click",i=>{i.stopPropagation(),lh(Ln.hidden)});Ln==null||Ln.addEventListener("click",i=>i.stopPropagation());document.addEventListener("click",()=>{Ln&&!Ln.hidden&&lh(!1)});document.addEventListener("keydown",i=>{i.key==="Escape"&&Ln&&!Ln.hidden&&(lh(!1),Ya.focus())});lf.addEventListener("change",()=>{ar==="auto"&&_o()});_o();const da=document.getElementById("acctBtn"),Ce=document.getElementById("acctPop"),Qp=[{id:"login",name:"Claude Code login"},{id:"apikey",name:"API key"}];let An=null,xo=null,ws=!1,Jn="",Zi=null;const qe=(i,t={})=>Object.assign(document.createElement(i),t);function Ui(){if(!Ce)return;if(!An){Ce.replaceChildren(qe("p",{className:"theme-k",textContent:"Claude access"}),qe("p",{className:"acct-note",textContent:Jn||"Checking…"}));return}const i=xo||An.mode;Ce.replaceChildren();const t=qe("div",{className:"theme-modes acct-modes"});t.setAttribute("role","radiogroup");for(const n of Qp){const s=qe("button",{type:"button"});s.setAttribute("role","radio"),s.setAttribute("aria-checked",String(n.id===i)),s.append(qe("span",{textContent:n.name})),s.addEventListener("click",()=>{xo=n.id,Jn="",n.id==="login"||An.keySet?Qo({mode:n.id}):Ui()}),t.append(s)}Ce.append(qe("p",{className:"theme-k",textContent:"Claude access"}),t);const e=(n,s="acct-note")=>Ce.append(qe("p",{className:s,textContent:n}));if(i==="login")e("Jobs run on your Claude plan, using the login Claude Code keeps on this machine. If it isn’t signed in yet, run claude once in a terminal.");else{An.keySet&&An.mode==="apikey"?e(`Using the key ending ${An.keyHint}${An.keyFrom==="env"?", from ANTHROPIC_API_KEY":""}. Jobs are billed to that API account.`):e("Jobs are billed to the API account the key belongs to. It is kept on this machine only.");const n=qe("form",{className:"acct-form"}),s=qe("input",{type:"password",placeholder:An.keySet?"Replace with another key":"sk-ant-…",autocomplete:"off",spellcheck:!1});s.setAttribute("aria-label","Anthropic API key");const a=qe("button",{type:"submit",className:"primary small",textContent:ws?"Checking…":"Save",disabled:ws});if(n.append(s,a),n.addEventListener("submit",r=>{r.preventDefault(),s.value.trim()&&Qo({mode:"apikey",key:s.value})}),Ce.append(n),An.keyFrom==="office"){const r=qe("button",{type:"button",className:"acct-forget",textContent:"Forget this key"});r.addEventListener("click",()=>Qo(null)),Ce.append(r)}ws||queueMicrotask(()=>{An.keySet||s.focus()})}Jn&&e(Jn,"acct-note acct-err"),Ce.append(qe("p",{className:"acct-note acct-fine",textContent:"Jobs already running finish the way they started."})),tm()}function tm(){if(!Zi)return;Ce.append(qe("p",{className:"theme-k",textContent:"Context limit"}));const i=qe("form",{className:"acct-form"}),t=qe("input",{type:"number",min:0,step:1e4,value:Zi.tokens,required:!0});t.setAttribute("aria-label","Context limit in tokens");const e=qe("button",{type:"submit",className:"primary small",textContent:"Save"});if(i.append(t,e),i.addEventListener("submit",n=>{n.preventDefault();const s=Number(t.value);Number.isInteger(s)&&s>=0?uu(s):(Jn="Use a whole number of tokens, or 0 to turn it off.",Ui())}),Ce.append(i,qe("p",{className:"acct-note acct-fine",textContent:Zi.tokens?`Agents are nudged to clear their context past ${Zi.tokens.toLocaleString()} tokens.`:"Off: agents are never nudged to clear their context."})),Zi.custom){const n=qe("button",{type:"button",className:"acct-forget",textContent:`Back to the default (${Zi.default.toLocaleString()})`});n.addEventListener("click",()=>uu(null)),Ce.append(n)}}async function uu(i){Jn="";try{const t=await fetch("/api/context-limit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tokens:i})}),e=await t.json();if(!t.ok)throw new Error(e.error||"That didn’t save.");Zi=e}catch(t){Jn=t.message}Ui()}function Jo(i){i&&(Zi=i,!ws&&Ce&&!Ce.hidden&&Ui())}async function Qo(i){ws=!0,Jn="",Ui();try{const t=await fetch("/api/auth",i?{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i)}:{method:"DELETE"}),e=await t.json();if(!t.ok)throw new Error(e.error||"That didn’t save.");An=e,xo=null}catch(t){Jn=t.message}ws=!1,Ui()}function ic(i){i&&(An=i,ws||Ui())}function No(i){var t;Ce.hidden=!i,da.setAttribute("aria-expanded",String(i)),i||(xo=null,Jn=""),Ui(),i&&((t=Ce.querySelector('[aria-checked="true"]'))==null||t.focus()),i&&!An&&fetch("/api/auth").then(e=>e.ok?e.json():Promise.reject()).then(ic,()=>{Jn="Restart the office server to choose this.",Ui()})}da==null||da.addEventListener("click",()=>No(Ce.hidden));var sf;(sf=document.getElementById("themeBtn"))==null||sf.addEventListener("click",()=>{Ce.hidden||No(!1)});document.addEventListener("click",i=>{Ce&&!Ce.hidden&&!Ce.contains(i.target)&&!da.contains(i.target)&&No(!1)});document.addEventListener("keydown",i=>{i.key==="Escape"&&Ce&&!Ce.hidden&&(No(!1),da.focus())});const fa=document.getElementById("linkBtn"),Ne=document.getElementById("linkPop"),tl=document.getElementById("app"),ch=[{id:"plan",name:"Plan only"},{id:"edit",name:"Edit files"},{id:"auto",name:"Full autonomy"}],em=[{id:"off",name:"Off"},{id:"read",name:"Read only"},{id:"edit",name:"Edit a copy"}],rr={plan:0,edit:1,auto:2},du=2e6,nm=/^[0-9A-HJKMNP-TV-Z]{8}$/;let Qn=null,Xa={},Ii=null,as=null,He=null,Ms=null,tn="",Vn="",yo=!1;const St=(i,t={},...e)=>{const n=Object.assign(document.createElement(i),t);return n.append(...e.filter(s=>s!=null&&s!==!1)),n},Pn=(i,t="acct-note")=>St("p",{className:t,textContent:i});async function fi(i,t,e){const n=t===void 0?{method:e||"GET"}:{method:e||"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)},s=await fetch(i,n),a=await s.json().catch(()=>({}));if(!s.ok)throw new Error(a.error||(s.status===404?"Restart the office server to use links.":"That didn’t work."));return a}function im(i){const t=String(i||"").toUpperCase().replace(/[\s-]+/g,"").replace(/[IL]/g,"1").replace(/O/g,"0");return nm.test(t)?t:null}const sm=i=>{const t=String(i).toUpperCase().replace(/-/g,"");return`${t.slice(0,4)}-${t.slice(4)}`};function sc(i){return i>=1e6?`${+(i/1e6).toFixed(1)}M`:i>=1e3?`${Math.round(i/1e3)}k`:String(i)}function am(i){const t=typeof i=="number"?i:Date.parse(i);if(!t)return"";const e=t-Date.now();if(e<=0)return"Expired. Make a new one.";const n=Math.ceil(e/6e4),s=Math.floor(n/60),a=n%60,r=new Date(t).toLocaleString([],{weekday:"short",hour:"numeric",minute:"2-digit"});return`Works once. Expires in ${s?`${s} h ${a} min`:`${a} min`} (${r}).`}function rm(i){var s,a;const t=((s=i.repos)==null?void 0:s.length)||0,e=((a=ch.find(r=>r.id===i.clearance))==null?void 0:a.name)||i.clearance,n=i.theirAgents==="read"?"their agents read only":i.theirAgents==="edit"?"their agents edit a copy":"";return[t===1?i.repos[0]:`${t} projects`,...i.ourAgents===!1?["our agents not lent"]:[e,`${sc(i.tokensPerDay||0)} tokens a day`],n].filter(Boolean).join(" · ")}function om(i){return i.kind!=="guest"?"Linked office":i.role==="guest"?"Guest · you work with their agents":"Guest · they work with yours"}function Fe(){if(!Ne||Ne.hidden)return;const i=Xa.handle||(Ii==null?void 0:Ii.handle);Ne.replaceChildren(St("p",{className:"theme-k",textContent:"Linked offices"})),i?(Ne.append(St("p",{className:"lb-me"},"This office is ",St("strong",{textContent:`@${i}`}))),Ne.append(cm()),as&&Ne.append(hm()),He&&Ne.append(um())):Ne.append(...lm()),Vn&&Ne.append(Pn(Vn,"acct-note acct-err")),Xa.error?Ne.append(Pn(`Link service: ${Xa.error}`,"acct-note acct-err")):Qn!=null&&Qn.length&&Xa.connected===!1&&Ne.append(Pn("Connecting to the link service…","acct-note acct-fine")),Ne.append(fm())}function lm(){const i=[Pn("Linked offices see each other’s agents walk in as visitors, and a guest can run jobs here within the limits you set. First, pick a handle for this office.")];if(Ii&&!Ii.configured)return[...i,Pn("This office has no link service set up.","acct-note acct-err")];const t=St("form",{className:"acct-form"}),e=St("input",{type:"text",placeholder:"Pick a handle",autocomplete:"off",spellcheck:!1,maxLength:20});return e.setAttribute("aria-label","Handle"),t.append(e,St("button",{type:"submit",className:"primary small",textContent:tn==="claim"?"Claiming…":"Claim",disabled:!!tn})),t.addEventListener("submit",async n=>{n.preventDefault(),e.value.trim()&&await cr("claim",async()=>{gm(await fi("/api/leaderboard/handle",{handle:e.value.trim()}),!0),As(await fi("/api/links"))})}),[...i,t,Pn("Claiming a handle doesn’t put you on the leaderboard. Sharing your counters there is a separate choice.","acct-note acct-fine")]}function cm(){const i=St("div",{className:"link-actions"}),t=St("button",{type:"button",className:"ghost small",textContent:tn==="link"?"Making a code…":"Invite an office",disabled:!!tn});t.addEventListener("click",()=>{He=null,uf("link")});const e=St("button",{type:"button",className:"ghost small",textContent:"Invite a guest",disabled:!!tn});e.setAttribute("aria-expanded",String(!!He&&!He.edit)),e.addEventListener("click",()=>hf());const n=St("form",{className:"acct-form link-redeem"}),s=St("input",{type:"text",placeholder:"Enter a code, e.g. K7QX-M2PD",autocomplete:"off",spellcheck:!1,maxLength:12});return s.setAttribute("aria-label","Invite code"),n.append(s,St("button",{type:"submit",className:"primary small",textContent:tn==="redeem"?"Linking…":"Link",disabled:!!tn})),n.addEventListener("submit",a=>{a.preventDefault();const r=im(s.value);if(!r){Vn="A code is 8 letters and numbers, like K7QX-M2PD.",Fe();return}cr("redeem",async()=>{As(await fi("/api/links/redeem",{code:r})),as=null})}),i.append(St("div",{className:"link-row"},t,e),n),i}function hm(){const i=St("div",{className:"link-code"}),t=sm(as.code),e=St("button",{type:"button",className:"ghost small",textContent:yo?"Copied":"Copy"});return e.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(t),yo=!0}catch{Vn="Couldn’t copy. Select the code and copy it by hand."}Fe()}),i.append(St("p",{className:"theme-k",textContent:as.kind==="guest"?"Guest code":"Office code"}),St("div",{className:"link-code-row"},St("output",{className:"link-code-v",textContent:t}),e),Pn(`${as.kind==="guest"?"Give this to your guest. They enter it in their own office.":"Give this to the other office. They enter it under Linked offices."} ${am(as.expiresAt)}`,"acct-note acct-fine")),i}async function hf(i){if(i!=null&&i.id?(He==null?void 0:He.edit)===i.id:He&&!He.edit){He=null,Fe();return}const e=i==null?void 0:i.guest;if(He=e?{repos:new Set(e.repos||[]),clearance:e.clearance==="auto"?"edit":e.clearance||"edit",full:e.clearance==="auto",tokensPerDay:e.tokensPerDay||du,ourAgents:e.ourAgents!==!1,theirAgents:e.theirAgents||"off",edit:i.id,peer:i.peer}:{repos:new Set,clearance:"edit",full:!1,tokensPerDay:du,ourAgents:!0,theirAgents:"off",edit:null},as=null,Vn="",Fe(),!Ms){try{Ms=(await fi("/api/repos")).repos||[]}catch(n){Ms=[],Vn=n.message}Fe()}}function um(){const i=He,t=St("form",{className:"link-guest"});t.append(St("p",{className:"theme-k",textContent:i.edit?`What @${i.peer} can do`:"Invite a guest"}),Pn("Pick the projects they can work in, then whose agents do the work: yours, on your Claude account, or their own, on theirs.","acct-note acct-fine"));const e=St("fieldset",{className:"link-repos"},St("legend",{textContent:`Projects they can use (${i.repos.size} picked)`}));Ms?Ms.length||e.append(Pn("No projects found.","acct-note acct-fine")):e.append(Pn("Loading…","acct-note acct-fine"));for(const g of[...new Set([...Ms||[],...Ms?i.repos:[]])]){const _=St("input",{type:"checkbox",checked:i.repos.has(g)});_.addEventListener("change",()=>{_.checked?i.repos.add(g):i.repos.delete(g),Fe()}),e.append(St("label",{},_,St("span",{textContent:g})))}const n=St("input",{type:"checkbox",checked:i.ourAgents});n.addEventListener("change",()=>{i.ourAgents=n.checked,Fe()});const s=St("fieldset",{className:"link-ours",disabled:!i.ourAgents});s.classList.toggle("off",!i.ourAgents);const a=St("div",{className:"theme-modes acct-modes link-cap"});a.setAttribute("role","radiogroup"),a.setAttribute("aria-label","Clearance cap");for(const g of ch.slice(0,2)){const _=St("button",{type:"button",textContent:g.name,disabled:i.full});_.setAttribute("role","radio"),_.setAttribute("aria-checked",String(!i.full&&i.clearance===g.id)),_.addEventListener("click",()=>{i.clearance=g.id,Fe()}),a.append(_)}const r=St("input",{type:"checkbox",checked:i.full});r.addEventListener("change",()=>{i.full=r.checked,Fe()});const o=St("div",{className:"link-warn"},St("p",{textContent:"Full autonomy lets the guest run any command on this machine, with your files and your logins. Only allow it for someone you’d hand your laptop to."}),St("label",{},r,St("span",{textContent:"Allow full autonomy anyway"}))),l=St("input",{type:"number",min:1e5,step:1e5,value:i.tokensPerDay,required:i.ourAgents});l.setAttribute("aria-label","Tokens per day");const c=St("span",{className:"acct-fine",textContent:sc(i.tokensPerDay)});l.addEventListener("input",()=>{i.tokensPerDay=Math.floor(Number(l.value))||0,c.textContent=sc(i.tokensPerDay)}),s.append(St("p",{className:"link-k",textContent:"Clearance cap"}),a,o,St("label",{className:"link-k link-tokens"},St("span",{textContent:"Tokens per day"}),l,c));const h=St("div",{className:"theme-modes acct-modes link-cap link-theirs"});h.setAttribute("role","radiogroup"),h.setAttribute("aria-label","Their agents");for(const g of em){const _=St("button",{type:"button",textContent:g.name});_.setAttribute("role","radio"),_.setAttribute("aria-checked",String(i.theirAgents===g.id)),_.addEventListener("click",()=>{i.theirAgents=g.id,Fe()}),h.append(_)}const u=!i.ourAgents&&i.theirAgents==="off",d=i.repos.size>0&&!u&&!tn,f=i.repos.size?u?"Lend your agents, or let theirs in.":"":"Pick at least one project.";return t.append(e,St("label",{className:"link-switch"},n,St("span",{},St("strong",{textContent:"Lend our agents"}),St("span",{className:"acct-fine",textContent:"They start jobs with your agents, on your Claude account."}))),s,St("p",{className:"link-k",textContent:"Their agents"}),h,Pn(i.theirAgents==="off"?"Their own agents can’t work in your projects.":`Their own agents, on their account, work in a copy${i.theirAgents==="edit"?". Nothing reaches your folder until you apply it from the job.":" and can’t change anything."} They have no shell, so they can’t run anything here.`,"acct-note acct-fine"),St("div",{className:"link-row"},St("button",{type:"submit",className:"primary small",disabled:!d,textContent:i.edit?tn==="guest"?"Saving…":"Save":tn==="guest"?"Making a code…":"Make guest code"}),i.edit?dm():null,f?St("span",{className:"acct-fine",textContent:f}):null)),t.addEventListener("submit",g=>{if(g.preventDefault(),!i.repos.size||u){Vn=f,Fe();return}if(i.ourAgents&&i.tokensPerDay<1e5){Vn="Allow at least 100,000 tokens a day.",Fe();return}const _={repos:[...i.repos],clearance:i.full?"auto":i.clearance,tokensPerDay:Math.max(i.tokensPerDay,1e5),ourAgents:i.ourAgents,theirAgents:i.theirAgents};i.edit?pm(i.edit,_):uf("guest",_)}),t}function dm(){const i=St("button",{type:"button",className:"ghost small",textContent:"Cancel"});return i.addEventListener("click",()=>{He=null,Fe()}),i}function fm(){const i=St("div",{className:"lb-board"});if(!Qn)return i.append(Pn("Loading links…","acct-note acct-fine")),i;if(!Qn.length)return i.append(Pn("No links yet.","acct-note acct-fine")),i;const t=St("ul",{className:"lb-list link-list"});for(const e of Qn){const n=St("li",{className:"link-item"},St("span",{className:"link-who"},St("strong",{textContent:`@${e.peer}`}),St("span",{className:"acct-fine",textContent:om(e)}),e.guest?St("span",{className:"acct-fine link-policy",textContent:rm(e.guest)}):null));e.kind==="guest"&&e.role==="guest"&&n.querySelector(".link-who").append(St("span",{className:"acct-fine",textContent:"Tag their agents in chat with @"}));const s=St("span",{className:"link-row"});if(e.kind==="guest"&&e.role==="host"&&e.guest){const r=St("button",{type:"button",className:"ghost small",textContent:"Change",disabled:!!tn});r.setAttribute("aria-expanded",String((He==null?void 0:He.edit)===e.id)),r.addEventListener("click",()=>hf(e)),s.append(r)}const a=St("button",{type:"button",className:"acct-forget",textContent:tn===e.id?"Unlinking…":"Unlink",disabled:!!tn});a.addEventListener("click",()=>mm(e)),s.append(a),n.append(s),t.append(n)}return i.append(t),i}async function cr(i,t){tn=i,Vn="",Fe();try{await t()}catch(e){Vn=e.message}tn="",Fe()}function uf(i,t){return yo=!1,cr(i,async()=>{const e=await fi("/api/links/invite",t?{kind:i,guest:t}:{kind:i});as={kind:e.kind||i,code:e.code,expiresAt:e.expiresAt},He=null})}function pm(i,t){return cr("guest",async()=>{As(await fi(`/api/links/${encodeURIComponent(i)}/guest`,{guest:t})),He=null})}function mm(i){const t=i.kind!=="guest"?"You stop seeing each other’s agents.":i.role==="host"?"Their running jobs stop and they lose access right away.":"You can’t work with their agents again without a new code.";confirm(`Unlink @${i.peer}? ${t}`)&&cr(i.id,async()=>{As(await fi(`/api/links/${encodeURIComponent(i.id)}`,void 0,"DELETE"))})}function gm(i,t=!1){Ii=i,t&&document.dispatchEvent(new CustomEvent("office:leaderboard",{detail:i}))}function As(i){!i||!Array.isArray(i.links)||(Qn=i.links,Xa={handle:i.handle||null,connected:i.connected,error:i.error||null},Oo(),tn||Fe())}document.addEventListener("office:leaderboard",i=>{Ii=i.detail,tn||Fe()});function Uo(i){if(Ne.hidden=!i,fa.setAttribute("aria-expanded",String(i)),!i){Vn="",He=null,yo=!1;return}Fe(),fi("/api/links").then(As,t=>{Qn||(Qn=[]),Vn=t.message,Fe()}),Ii||fi("/api/leaderboard").then(t=>{Ii=t,Fe()},()=>{})}fa==null||fa.addEventListener("click",()=>Uo(Ne.hidden));var af;for(const i of["themeBtn","acctBtn"])(af=document.getElementById(i))==null||af.addEventListener("click",()=>{Ne.hidden||Uo(!1)});document.addEventListener("click",i=>{Ne&&!Ne.hidden&&i.target.isConnected&&!Ne.contains(i.target)&&!fa.contains(i.target)&&Uo(!1)});document.addEventListener("keydown",i=>{i.key==="Escape"&&Ne&&!Ne.hidden&&(Uo(!1),fa.focus())});const Gt={on:!1,link:null,host:"",repos:null,clearance:"edit",tokensPerDay:0};{const i=new URLSearchParams(location.search).get("visit");i&&Object.assign(Gt,{on:!0,link:i})}function vm(i){i&&(Es="",Object.assign(Gt,{on:!0,link:i.link??Gt.link,host:i.host??Gt.host,repos:Array.isArray(i.repos)?i.repos:Gt.repos,clearance:rr[i.clearance]!=null?i.clearance:Gt.clearance,tokensPerDay:i.tokensPerDay??Gt.tokensPerDay}),Oo())}function Gi(i,t=""){return i=encodeURIComponent(i),Gt.on?`/api/visit/${encodeURIComponent(Gt.link)}/jobs/${i}${t}`:`/api/jobs/${i}${t}`}function el(i,t,e){return Gt.on?{text:i,mode:t}:{message:i,mode:t,files:e}}const nl=i=>`#${i.replace(/\s+/g,"-")}`.toLowerCase();async function _m({text:i,mode:t,model:e}){const n=(i.match(/(^|\s)#[\w.-]+/g)||[]).map(c=>c.trim().toLowerCase()),s=Gt.repos||[],a=s.filter(c=>n.includes(nl(c)));if(a.length!==1){const c=s.map(nl).join(", ")||"none yet";throw new Error(a.length?"Name just one project per job.":`Name the project with a # tag. You can use: ${c}.`)}const r=a[0],o=i.replace(new RegExp(`(^|\\s)${nl(r).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?=\\s|$)`,"i")," ").replace(/\s+/g," ").trim();if(!o)throw new Error("Say what the job is, as well as the project.");const{job:l}=await fi(`/api/visit/${encodeURIComponent(Gt.link)}/jobs`,{repo:r,prompt:o,mode:t,model:e});return l}function xm(i){return!Gt.on||!i?i:Object.fromEntries(Object.entries(i).filter(([t])=>(rr[t]??9)<=rr[Gt.clearance]))}function il(i){return!Gt.on||!Array.isArray(i)?i:i.filter(t=>{var e;return(e=Gt.repos)==null?void 0:e.includes(t)})}let Es="",io=!1;function ym(i){if(!Gt.on)return null;if(i===4404)Es="The host ended this link. You can’t visit any more.";else if(i===4502)Es="Can’t reach the host’s office right now. Trying again…";else return Es="",null;return io=i===4404,Oo(),i===4404?0:1e4}function Oo(){var a,r,o,l;if(!Gt.on)return;const i=Gt.host||((a=Qn==null?void 0:Qn.find(c=>c.id===Gt.link))==null?void 0:a.peer)||"";i&&(Gt.host=i),tl.classList.add("visiting"),tl.dataset.visiting=i,tl.classList.toggle("visit-ended",!!io);const t=document.getElementById("input");if(t){t.placeholder=io?"This link has ended.":`Start a job${i?` at @${i}`:""} · #project`;for(const c of document.querySelectorAll("#composer textarea, #composer select, #composer button"))c.disabled=!!io}const e=document.getElementById("mode");if(e){for(const c of e.options)c.hidden=c.disabled=rr[c.value]>rr[Gt.clearance];(r=e.selectedOptions[0])!=null&&r.disabled&&(e.value=Gt.clearance)}let n=document.getElementById("visitBar");n||(n=St("div",{className:"visit-bar",id:"visitBar"}),n.setAttribute("role","status"),(o=document.querySelector(".brand"))==null||o.after(n));const s=St("a",{href:location.pathname,textContent:"Back to my office"});n.replaceChildren(St("span",{},"Visiting ",St("strong",{textContent:i?`@${i}`:"a linked office"}),Gt.repos?` · ${Gt.repos.length} ${Gt.repos.length===1?"project":"projects"}, up to ${(l=ch.find(c=>c.id===Gt.clearance))==null?void 0:l.name.toLowerCase()}`:""),s),n.classList.toggle("visit-off",!!Es),Es&&n.append(St("p",{className:"visit-note",textContent:Es}))}Oo();const ia=document.getElementById("setBtn"),De=document.getElementById("settings");let Ts=null,en={},pa=!1,ls="",df=()=>{};const Te=(i,t={})=>Object.assign(document.createElement(i),t);Te.kids=(i,t)=>(i.append(...t),i);const so=i=>i.key in en?en[i.key]:i.value,fu=(i,t)=>i.kind==="bool"?t?"on":"off":i.kind==="time"?t||"off":i.kind==="text"?t||"the account name":i.kind==="number"?`${Number(t).toLocaleString()}${i.unit?` ${i.unit}`:""}`:String(t),ff=(i,t)=>Number.isInteger(t)&&t>=i.min&&t<=i.max,pf=()=>Object.keys(en);function Mm(i){const t=so(i),e=`set-${i.key}`,n=a=>{Object.is(a,i.value)?delete en[i.key]:en[i.key]=a,hh(),mf(i)};if(i.kind==="bool"){const a=Te("button",{type:"button",id:e,className:"set-switch"});return a.setAttribute("role","switch"),a.setAttribute("aria-checked",String(!!t)),a.addEventListener("click",()=>{n(!so(i)),a.setAttribute("aria-checked",String(!!so(i)))}),a}if(i.kind==="choice"){const a=Te("div",{className:"theme-modes set-choice"});a.setAttribute("role","radiogroup"),a.setAttribute("aria-label",i.label),a.style.gridTemplateColumns=`repeat(${i.options.length}, 1fr)`;for(const r of i.options){const o=Te("button",{type:"button",textContent:r});o.setAttribute("role","radio"),o.setAttribute("aria-checked",String(r===t)),o.addEventListener("click",()=>{n(r);for(const l of a.children)l.setAttribute("aria-checked",String(l.textContent===r))}),a.append(o)}return a}const s=Te("input",{id:e,className:"set-input"});return s.spellcheck=!1,s.autocomplete="off",i.kind==="number"?Object.assign(s,{type:"number",min:i.min,max:i.max,step:i.step||1,value:t,inputMode:"numeric"}):i.kind==="time"?Object.assign(s,{type:"time",value:t}):Object.assign(s,{type:"text",value:t,maxLength:i.max,placeholder:i.default||"Your first name"}),s.addEventListener("input",()=>{const a=s.value;n(i.kind==="number"?a===""?NaN:Number(a):a)}),s}const ac=new Map;function mf(i){const t=ac.get(i.key);if(!t)return;t.classList.toggle("set-changed",i.key in en);const e=t.querySelector(".set-fine");e.replaceChildren();const n=so(i);if(i.kind==="number"&&!ff(i,n)){e.textContent=`Use a whole number from ${i.min.toLocaleString()} to ${i.max.toLocaleString()}.`,e.classList.add("acct-err");return}if(e.classList.remove("acct-err"),i.hint&&e.append(i.hint," "),i.custom&&!(i.key in en)){const s=Te("button",{type:"button",className:"acct-forget set-reset",textContent:`Use the default (${fu(i,i.default)})`});s.addEventListener("click",()=>rc({[i.key]:null})),e.append(s)}else i.custom||e.append(`Default: ${fu(i,i.default)}.`)}function hh(){const i=pf().length,t=De.querySelector(".set-save"),e=De.querySelector(".set-undo"),n=De.querySelector(".set-msg");if(!t)return;const s=Ts.some(a=>a.key in en&&a.kind==="number"&&!ff(a,en[a.key]));t.disabled=pa||!i||s,t.textContent=pa?"Saving…":i>1?`Save ${i} changes`:"Save",e.hidden=!i||pa,n.textContent=ls||(i?"Unsaved changes":""),n.classList.toggle("acct-err",!!ls)}function ma(){ac.clear();const i=De.querySelector(".set-body");if(i.replaceChildren(),!Ts){i.append(Te("p",{className:"acct-note",textContent:ls||"Loading…"}));return}const t=[...new Set(Ts.map(e=>e.group))];for(const e of t){const n=Te("section",{className:"set-group"});n.append(Te("h3",{className:"theme-k",textContent:e}));for(const s of Ts.filter(a=>a.group===e)){const a=Te("div",{className:"set-row"}),r=Te("div",{className:"set-text"}),o=Te("label",{className:"set-label",textContent:s.label});o.htmlFor=`set-${s.key}`,r.append(o,Te("p",{className:"acct-note acct-fine set-fine"})),a.append(r,Mm(s)),ac.set(s.key,a),n.append(a),mf(s)}i.append(n)}hh()}async function rc(i){pa=!0,ls="",hh();try{const t=await fetch("/api/settings",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i)}),e=await t.json();if(!t.ok)throw new Error(e.error||"That didn’t save.");for(const n of Object.keys(i))delete en[n];uh(e),df("Settings saved","good")}catch(t){ls=t.message}pa=!1,ma()}let gf=()=>{};function uh(i){Ts=i.settings;for(const t of Ts)t.key in en&&Object.is(en[t.key],t.value)&&delete en[t.key];i.owner!==void 0&&gf(i.owner)}function pu(i){i!=null&&i.settings&&(uh(i),De!=null&&De.open&&!pa&&ma())}function bm(){var i;ls="",De.showModal(),ia.setAttribute("aria-expanded","true"),ma(),Ts||fetch("/api/settings").then(t=>t.ok?t.json():Promise.reject()).then(t=>{uh(t),ma()},()=>{ls="Restart the office server to use Settings.",ma()}),(i=De.querySelector("input, button.set-switch, [role=radio]"))==null||i.focus()}function sl(){return pf().length&&!confirm("Discard your unsaved changes?")?!1:(en={},De.close(),!0)}function Sm({toast:i,renderOwner:t}){if(df=i,gf=t,!(!ia||!De)){if(Gt.on){ia.hidden=!0;return}De.append(Te.kids(Te("header",{className:"set-head"}),[Te("h2",{textContent:"Settings"}),Object.assign(Te("button",{type:"button",className:"theme-btn set-x"}),{innerHTML:'<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6 6 18"/></svg>',ariaLabel:"Close settings"})]),Te("div",{className:"set-body"}),Te.kids(Te("footer",{className:"set-foot"}),[Te("span",{className:"set-msg",role:"status"}),Te("button",{type:"button",className:"set-undo acct-forget",textContent:"Discard",hidden:!0}),Te("button",{type:"button",className:"primary small set-save",textContent:"Save",disabled:!0})])),De.querySelector(".set-x").addEventListener("click",sl),De.querySelector(".set-undo").addEventListener("click",()=>{en={},ls="",ma()}),De.querySelector(".set-save").addEventListener("click",()=>rc({...en})),ia.addEventListener("click",bm),De.addEventListener("cancel",e=>{e.preventDefault(),sl()}),De.addEventListener("click",e=>{e.target===De&&sl()}),De.addEventListener("close",()=>{ia.setAttribute("aria-expanded","false"),ia.focus()}),De.addEventListener("keydown",e=>{e.key==="Enter"&&e.target.matches("input")&&!De.querySelector(".set-save").disabled&&(e.preventDefault(),rc({...en}))})}}const ga=document.getElementById("lbBtn"),we=document.getElementById("lbPop"),vf=[{id:"jobs",name:"Jobs",value:i=>String(i.jobs)},{id:"tokens",name:"Tokens",value:i=>dh(i.tokens)},{id:"time",name:"Time",value:i=>fh(i.seconds)}],wm=[{id:"week",name:"This week"},{id:"all",name:"All time"}];let Kt=null,oc="week",Ka="jobs",Qi=null,lc=!1,Pi=!1,Un="",cc="";const Qt=(i,t={})=>Object.assign(document.createElement(i),t);function dh(i){return i>=1e9?`${(i/1e9).toFixed(1)}B`:i>=1e6?`${(i/1e6).toFixed(1)}M`:i>=1e3?`${(i/1e3).toFixed(i>=1e5?0:1)}k`:String(i)}function fh(i){const t=Math.round(i/60);return t<1?i>0?"<1m":"0m":t<60?`${t}m`:`${Math.floor(t/60)}h ${String(t%60).padStart(2,"0")}m`}function _f(i){const t=Math.max(0,Math.round((Date.now()-i)/1e3));return t<90?"just now":t<5400?`${Math.round(t/60)} min ago`:t<129600?`${Math.round(t/3600)} h ago`:`${Math.round(t/86400)} days ago`}function mu(i,t,e,n,s=""){const a=Qt("div",{className:`theme-modes lb-tabs ${s}`});a.setAttribute("role","radiogroup"),a.setAttribute("aria-label",e);for(const r of i){const o=Qt("button",{type:"button"});o.setAttribute("role","radio"),o.setAttribute("aria-checked",String(r.id===t)),o.append(Qt("span",{textContent:r.name})),o.addEventListener("click",()=>n(r.id)),a.append(o)}return a}function ti(){if(!we)return;we.replaceChildren(Qt("p",{className:"theme-k",textContent:"Leaderboard"}));const i=(t,e="acct-note")=>we.append(Qt("p",{className:e,textContent:t}));if(!Kt){i(Un||"Checking…");return}if(!Kt.configured){i("No leaderboard is set up for this office. Whoever hosts one gives you its address: set it as OFFICE_LEADERBOARD_URL and restart the office.");return}if(gu())Em();else if(Kt.joined){const t=Kt.week,e=Qt("p",{className:"lb-me"});we.append(e),e.append(Qt("strong",{textContent:Kt.handle}),Qt("span",{textContent:` · ${t.jobs} ${t.jobs===1?"job":"jobs"}, ${dh(t.tokens)} tokens, ${fh(t.seconds)} this week`}));const n=Kt.error?`Not shared yet: ${Kt.error}`:Kt.lastSync?`Shared ${_f(Kt.lastSync)}.`:"Sharing…";i(n,Kt.error?"acct-note acct-err":"acct-note acct-fine")}else{i("Compete on jobs finished, tokens used and time your agents spend working. Joining shares exactly these counters per day, for the last two weeks and from now on, under the handle you claim. Never prompts, projects, files, chat or cost.");const t=Qt("form",{className:"acct-form"}),e=Qt("input",{type:"text",placeholder:"Pick a handle",autocomplete:"off",spellcheck:!1,maxLength:20});e.setAttribute("aria-label","Handle"),t.append(e,Qt("button",{type:"submit",className:"primary small",textContent:Pi?"Joining…":"Join",disabled:Pi})),t.addEventListener("submit",n=>{n.preventDefault(),e.value.trim()&&bo("POST",{handle:e.value})}),we.append(t),Un&&i(Un,"acct-note acct-err")}if(we.append(mu(wm,oc,"Period",t=>{oc=t,Mo()},"lb-period"),mu(vf,Ka,"Ranked by",t=>{Ka=t,ti()},"lb-metric")),we.append(Tm()),Kt.joined&&!gu()){const t=Qt("button",{type:"button",className:"acct-forget",textContent:Pi?"Working…":"Leave and delete my data",disabled:Pi});t.addEventListener("click",()=>{confirm("Leave the leaderboard? Your handle is released and your counters are deleted from the service.")&&bo("DELETE")}),we.append(t),Un&&i(Un,"acct-note acct-err")}}const gu=()=>!!Kt&&"sharing"in Kt&&!!Kt.handle;function Em(){const i=(s,a="acct-note")=>we.append(Qt("p",{className:a,textContent:s})),t=Qt("p",{className:"lb-me"});if(t.append(Qt("strong",{textContent:Kt.handle})),Kt.sharing&&Kt.week){const s=Kt.week;t.append(Qt("span",{textContent:` · ${s.jobs} ${s.jobs===1?"job":"jobs"}, ${dh(s.tokens)} tokens, ${fh(s.seconds)} this week`}))}we.append(t);const e=Qt("input",{type:"checkbox",checked:!!Kt.sharing,disabled:Pi});e.addEventListener("change",()=>{if(e.checked){bo("POST",{handle:Kt.handle});return}confirm("Stop sharing? Your counters are deleted from the board. You keep your handle while you have linked offices; with none, the handle is released too.")?bo("DELETE"):e.checked=!0});const n=Qt("label",{className:"lb-share"});if(n.append(e,Qt("span",{textContent:"Share my counters on the board"})),we.append(n),Kt.sharing){const s=Kt.error?`Not shared yet: ${Kt.error}`:Kt.lastSync?`Shared ${_f(Kt.lastSync)}.`:"Sharing…";i(s,Kt.error?"acct-note acct-err":"acct-note acct-fine")}else i("Sharing sends jobs finished, tokens and agent time per day, for the last two weeks and from now on. Never prompts, projects, files, chat or cost.","acct-note acct-fine");Un&&i(Un,"acct-note acct-err")}function Tm(){var a;const i=Qt("div",{className:"lb-board"});if(!Qi)return i.append(Qt("p",{className:"acct-note",textContent:lc?"Loading…":cc||"No board yet."})),i;const e=Qi[Ka==="time"?"time":Ka]||[];if(!e.length)return i.append(Qt("p",{className:"acct-note",textContent:"Nobody on the board yet."})),i;const n=vf.find(r=>r.id===Ka),s=Qt("ol",{className:"lb-list"});for(const r of e){const o=Qt("li",{className:r.handle.toLowerCase()===((a=Kt.handle)==null?void 0:a.toLowerCase())?"lb-row lb-you":"lb-row"});o.append(Qt("span",{className:"lb-rank",textContent:String(r.rank)}),Qt("span",{className:"lb-name",textContent:r.handle}),Qt("span",{className:"lb-val",textContent:n.value(r)})),s.append(o)}return i.append(s),Qi.players>e.length&&i.append(Qt("p",{className:"acct-note acct-fine",textContent:`Top ${e.length} of ${Qi.players}.`})),Qi.since&&i.append(Qt("p",{className:"acct-note acct-fine",textContent:"Weeks start Monday, UTC."})),i}async function Mo(){if(Kt!=null&&Kt.configured){lc=!0,cc="",ti();try{const i=await fetch(`/api/leaderboard/board?period=${oc}`),t=await i.json();if(!i.ok)throw new Error(t.error||"Couldn’t load the board.");Qi=t}catch(i){Qi=null,cc=i.message}lc=!1,we.hidden||ti()}}async function bo(i,t){Pi=!0,Un="",ti();try{const e=await fetch("/api/leaderboard",i==="POST"?{method:i,headers:{"content-type":"application/json"},body:JSON.stringify(t)}:{method:i}),n=await e.json();if(!e.ok)throw new Error(n.error||"That didn’t work.");hr(n),Qi=null}catch(e){Un=e.message}Pi=!1,ti(),Un||Mo()}function vu(i){i&&(hr(i),!Pi&&!we.hidden&&ti())}function hr(i){Kt=i,document.dispatchEvent(new CustomEvent("office:leaderboard",{detail:i}))}document.addEventListener("office:leaderboard",i=>{i.detail!==Kt&&(Kt=i.detail,!Pi&&we&&!we.hidden&&ti())});function Fo(i){if(we.hidden=!i,ga.setAttribute("aria-expanded",String(i)),!i){Un="";return}ti(),Kt?Mo():fetch("/api/leaderboard").then(t=>t.ok?t.json():Promise.reject()).then(t=>{hr(t),ti(),Mo()},()=>{Un="Restart the office server to use this.",ti()})}ga==null||ga.addEventListener("click",()=>Fo(we.hidden));var rf;for(const i of["themeBtn","acctBtn"])(rf=document.getElementById(i))==null||rf.addEventListener("click",()=>{we.hidden||Fo(!1)});document.addEventListener("click",i=>{const t=i.composedPath();we&&!we.hidden&&!t.includes(we)&&!t.includes(ga)&&Fo(!1)});document.addEventListener("keydown",i=>{i.key==="Escape"&&we&&!we.hidden&&(Fo(!1),ga.focus())});const hc="office.nameAsked",Am="office.name";let xf=()=>{};function Cm(i){xf=i}const Rm=i=>i.trim().replace(/\s+/g,"_").replace(/[^A-Za-z0-9_-]/g,"").slice(0,20);function Pm(){const i=Qt("dialog",{className:"name-ask"}),t=Qt("form",{method:"dialog"}),e=Qt("input",{type:"text",placeholder:"Your name",autocomplete:"off",spellcheck:!1,maxLength:40});e.setAttribute("aria-label","Your name");const n=Qt("p",{className:"acct-note acct-err",hidden:!0}),s=Qt("button",{type:"submit",className:"primary small",textContent:"Continue"}),a=Qt("button",{type:"button",className:"acct-forget",textContent:"Not now"}),r=Qt("div",{className:"acct-form"});r.append(e,s),t.append(Qt("h2",{textContent:"Welcome to the office"}),Qt("p",{className:"acct-note",textContent:Kt!=null&&Kt.configured?"What should we call you? Your name becomes your handle on the leaderboard. Nothing is shared until you join it.":"What should we call you?"}),r,n,a),i.append(t);const o=()=>{try{localStorage.setItem(hc,"1")}catch{}i.close(),i.remove(),xf()};a.addEventListener("click",o),i.addEventListener("cancel",o),t.addEventListener("submit",async l=>{l.preventDefault();const c=e.value.trim(),h=Rm(c);if(c){n.hidden=!0,s.disabled=!0;try{if(Kt!=null&&Kt.configured){if(h.length<3)throw new Error("Use at least 3 letters or numbers.");const u=await fetch("/api/leaderboard/handle",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({handle:h})}),d=await u.json();if(!u.ok)throw new Error(d.error||"That handle didn’t work.");hr(d),we.hidden||ti()}try{localStorage.setItem(Am,c)}catch{}o()}catch(u){n.textContent=u.message,n.hidden=!1,s.disabled=!1,e.focus()}}}),document.body.append(i),i.showModal(),e.focus()}try{!localStorage.getItem(hc)&&!new URLSearchParams(location.search).has("visit")&&fetch("/api/leaderboard").then(i=>i.ok?i.json():null).catch(()=>null).then(i=>{if(i&&hr(i),i!=null&&i.handle){try{localStorage.setItem(hc,"1")}catch{}return}Pm()})}catch{}function ph(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Ds=ph();function yf(i){Ds=i}const Mf=/[&<>"']/,Lm=new RegExp(Mf.source,"g"),bf=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Dm=new RegExp(bf.source,"g"),Im={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},_u=i=>Im[i];function Cn(i,t){if(t){if(Mf.test(i))return i.replace(Lm,_u)}else if(bf.test(i))return i.replace(Dm,_u);return i}const km=/(^|[^\[])\^/g;function ve(i,t){let e=typeof i=="string"?i:i.source;t=t||"";const n={replace:(s,a)=>{let r=typeof a=="string"?a:a.source;return r=r.replace(km,"$1"),e=e.replace(s,r),n},getRegex:()=>new RegExp(e,t)};return n}function xu(i){try{i=encodeURI(i).replace(/%25/g,"%")}catch{return null}return i}const Za={exec:()=>null};function yu(i,t){const e=i.replace(/\|/g,(a,r,o)=>{let l=!1,c=r;for(;--c>=0&&o[c]==="\\";)l=!l;return l?"|":" |"}),n=e.split(/ \|/);let s=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;s<n.length;s++)n[s]=n[s].trim().replace(/\\\|/g,"|");return n}function Da(i,t,e){const n=i.length;if(n===0)return"";let s=0;for(;s<n&&i.charAt(n-s-1)===t;)s++;return i.slice(0,n-s)}function Nm(i,t){if(i.indexOf(t[1])===-1)return-1;let e=0;for(let n=0;n<i.length;n++)if(i[n]==="\\")n++;else if(i[n]===t[0])e++;else if(i[n]===t[1]&&(e--,e<0))return n;return-1}function Mu(i,t,e,n){const s=t.href,a=t.title?Cn(t.title):null,r=i[1].replace(/\\([\[\]])/g,"$1");if(i[0].charAt(0)!=="!"){n.state.inLink=!0;const o={type:"link",raw:e,href:s,title:a,text:r,tokens:n.inlineTokens(r)};return n.state.inLink=!1,o}return{type:"image",raw:e,href:s,title:a,text:Cn(r)}}function Um(i,t){const e=i.match(/^(\s+)(?:```)/);if(e===null)return t;const n=e[1];return t.split(`
1
+ var Yp=Object.defineProperty;var Kp=(i,t,e)=>t in i?Yp(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var _e=(i,t,e)=>Kp(i,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const r of a.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&n(r)}).observe(document,{childList:!0,subtree:!0});function e(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function n(s){if(s.ep)return;s.ep=!0;const a=e(s);fetch(s.href,a)}})();"serviceWorker"in navigator&&addEventListener("load",()=>navigator.serviceWorker.register("/sw.js").catch(()=>{}));const of=[{id:"paper",name:"Paper"},{id:"ocean",name:"Ocean"},{id:"forest",name:"Forest"},{id:"sunset",name:"Sunset"},{id:"lavender",name:"Lavender"}],oh=[{id:"light",name:"Light"},{id:"dark",name:"Dark"},{id:"auto",name:"Auto"}],Zo=document.documentElement,lf=matchMedia("(prefers-color-scheme: dark)"),cf=(i,t,e)=>{try{const n=localStorage.getItem(i);return e.some(s=>s.id===n)?n:t}catch{return t}},hu=(i,t)=>{try{localStorage.setItem(i,t)}catch{}};try{if(localStorage.getItem("office.appearance")===null){const i=localStorage.getItem("office.mode");oh.some(t=>t.id===i)&&(localStorage.setItem("office.appearance",i),localStorage.removeItem("office.mode"))}}catch{}let nc=cf("office.theme","paper",of),ar=cf("office.appearance","auto",oh);const Ya=document.getElementById("themeBtn"),Ln=document.getElementById("themePop");function _o(){const i=ar==="dark"||ar==="auto"&&lf.matches?"dark":"light";Zo.dataset.theme=nc,Zo.dataset.mode=i;const t=document.querySelector('meta[name="theme-color"]');t&&(t.content=getComputedStyle(Zo).getPropertyValue("--paper").trim()||t.content),Zp()}function Zp(){if(!Ln)return;Ln.replaceChildren();const i=e=>Object.assign(document.createElement("p"),{className:"theme-k",textContent:e}),t=(e,n,s,a)=>{const r=document.createElement("div");r.className=a,r.setAttribute("role","radiogroup");for(const o of e){const l=document.createElement("button");l.type="button",l.dataset.t=o.id,l.setAttribute("role","radio"),l.setAttribute("aria-checked",String(o.id===n)),l.innerHTML=a==="theme-swatches"?"<i></i><span></span>":"<span></span>",l.querySelector("span").textContent=o.name,l.addEventListener("click",()=>s(o.id)),r.appendChild(l)}return r};Ln.append(i("Theme"),t(of,nc,e=>{nc=e,hu("office.theme",e),_o()},"theme-swatches"),i("Mode"),t(oh,ar,e=>{ar=e,hu("office.appearance",e),_o()},"theme-modes"))}function lh(i){var t;Ln.hidden=!i,Ya.setAttribute("aria-expanded",String(i)),i&&((t=Ln.querySelector('[aria-checked="true"]'))==null||t.focus())}Ya==null||Ya.addEventListener("click",i=>{i.stopPropagation(),lh(Ln.hidden)});Ln==null||Ln.addEventListener("click",i=>i.stopPropagation());document.addEventListener("click",()=>{Ln&&!Ln.hidden&&lh(!1)});document.addEventListener("keydown",i=>{i.key==="Escape"&&Ln&&!Ln.hidden&&(lh(!1),Ya.focus())});lf.addEventListener("change",()=>{ar==="auto"&&_o()});_o();const da=document.getElementById("acctBtn"),Ce=document.getElementById("acctPop"),Jp=[{id:"login",name:"Claude Code login"},{id:"apikey",name:"API key"}];let An=null,xo=null,ws=!1,Jn="",Zi=null;const Xe=(i,t={})=>Object.assign(document.createElement(i),t);function Ui(){if(!Ce)return;if(!An){Ce.replaceChildren(Xe("p",{className:"theme-k",textContent:"Claude access"}),Xe("p",{className:"acct-note",textContent:Jn||"Checking…"}));return}const i=xo||An.mode;Ce.replaceChildren();const t=Xe("div",{className:"theme-modes acct-modes"});t.setAttribute("role","radiogroup");for(const n of Jp){const s=Xe("button",{type:"button"});s.setAttribute("role","radio"),s.setAttribute("aria-checked",String(n.id===i)),s.append(Xe("span",{textContent:n.name})),s.addEventListener("click",()=>{xo=n.id,Jn="",n.id==="login"||An.keySet?Qo({mode:n.id}):Ui()}),t.append(s)}Ce.append(Xe("p",{className:"theme-k",textContent:"Claude access"}),t);const e=(n,s="acct-note")=>Ce.append(Xe("p",{className:s,textContent:n}));if(i==="login")e("Jobs run on your Claude plan, using the login Claude Code keeps on this machine. If it isn’t signed in yet, run claude once in a terminal.");else{An.keySet&&An.mode==="apikey"?e(`Using the key ending ${An.keyHint}${An.keyFrom==="env"?", from ANTHROPIC_API_KEY":""}. Jobs are billed to that API account.`):e("Jobs are billed to the API account the key belongs to. It is kept on this machine only.");const n=Xe("form",{className:"acct-form"}),s=Xe("input",{type:"password",placeholder:An.keySet?"Replace with another key":"sk-ant-…",autocomplete:"off",spellcheck:!1});s.setAttribute("aria-label","Anthropic API key");const a=Xe("button",{type:"submit",className:"primary small",textContent:ws?"Checking…":"Save",disabled:ws});if(n.append(s,a),n.addEventListener("submit",r=>{r.preventDefault(),s.value.trim()&&Qo({mode:"apikey",key:s.value})}),Ce.append(n),An.keyFrom==="office"){const r=Xe("button",{type:"button",className:"acct-forget",textContent:"Forget this key"});r.addEventListener("click",()=>Qo(null)),Ce.append(r)}ws||queueMicrotask(()=>{An.keySet||s.focus()})}Jn&&e(Jn,"acct-note acct-err"),Ce.append(Xe("p",{className:"acct-note acct-fine",textContent:"Jobs already running finish the way they started."})),Qp()}function Qp(){if(!Zi)return;Ce.append(Xe("p",{className:"theme-k",textContent:"Context limit"}));const i=Xe("form",{className:"acct-form"}),t=Xe("input",{type:"number",min:0,step:1e4,value:Zi.tokens,required:!0});t.setAttribute("aria-label","Context limit in tokens");const e=Xe("button",{type:"submit",className:"primary small",textContent:"Save"});if(i.append(t,e),i.addEventListener("submit",n=>{n.preventDefault();const s=Number(t.value);Number.isInteger(s)&&s>=0?uu(s):(Jn="Use a whole number of tokens, or 0 to turn it off.",Ui())}),Ce.append(i,Xe("p",{className:"acct-note acct-fine",textContent:Zi.tokens?`Agents are nudged to clear their context past ${Zi.tokens.toLocaleString()} tokens.`:"Off: agents are never nudged to clear their context."})),Zi.custom){const n=Xe("button",{type:"button",className:"acct-forget",textContent:`Back to the default (${Zi.default.toLocaleString()})`});n.addEventListener("click",()=>uu(null)),Ce.append(n)}}async function uu(i){Jn="";try{const t=await fetch("/api/context-limit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tokens:i})}),e=await t.json();if(!t.ok)throw new Error(e.error||"That didn’t save.");Zi=e}catch(t){Jn=t.message}Ui()}function Jo(i){i&&(Zi=i,!ws&&Ce&&!Ce.hidden&&Ui())}async function Qo(i){ws=!0,Jn="",Ui();try{const t=await fetch("/api/auth",i?{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i)}:{method:"DELETE"}),e=await t.json();if(!t.ok)throw new Error(e.error||"That didn’t save.");An=e,xo=null}catch(t){Jn=t.message}ws=!1,Ui()}function ic(i){i&&(An=i,ws||Ui())}function No(i){var t;Ce.hidden=!i,da.setAttribute("aria-expanded",String(i)),i||(xo=null,Jn=""),Ui(),i&&((t=Ce.querySelector('[aria-checked="true"]'))==null||t.focus()),i&&!An&&fetch("/api/auth").then(e=>e.ok?e.json():Promise.reject()).then(ic,()=>{Jn="Restart the office server to choose this.",Ui()})}da==null||da.addEventListener("click",()=>No(Ce.hidden));var sf;(sf=document.getElementById("themeBtn"))==null||sf.addEventListener("click",()=>{Ce.hidden||No(!1)});document.addEventListener("click",i=>{Ce&&!Ce.hidden&&!Ce.contains(i.target)&&!da.contains(i.target)&&No(!1)});document.addEventListener("keydown",i=>{i.key==="Escape"&&Ce&&!Ce.hidden&&(No(!1),da.focus())});const fa=document.getElementById("linkBtn"),Ne=document.getElementById("linkPop"),tl=document.getElementById("app"),ch=[{id:"plan",name:"Plan only"},{id:"edit",name:"Edit files"},{id:"auto",name:"Full autonomy"}],tm=[{id:"off",name:"Off"},{id:"read",name:"Read only"},{id:"edit",name:"Edit a copy"}],rr={plan:0,edit:1,auto:2},du=2e6,em=/^[0-9A-HJKMNP-TV-Z]{8}$/;let Qn=null,Xa={},Ii=null,as=null,je=null,Ms=null,dn="",Vn="",yo=!1;const wt=(i,t={},...e)=>{const n=Object.assign(document.createElement(i),t);return n.append(...e.filter(s=>s!=null&&s!==!1)),n},Pn=(i,t="acct-note")=>wt("p",{className:t,textContent:i});async function fi(i,t,e){const n=t===void 0?{method:e||"GET"}:{method:e||"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)},s=await fetch(i,n),a=await s.json().catch(()=>({}));if(!s.ok)throw new Error(a.error||(s.status===404?"Restart the office server to use links.":"That didn’t work."));return a}function nm(i){const t=String(i||"").toUpperCase().replace(/[\s-]+/g,"").replace(/[IL]/g,"1").replace(/O/g,"0");return em.test(t)?t:null}const im=i=>{const t=String(i).toUpperCase().replace(/-/g,"");return`${t.slice(0,4)}-${t.slice(4)}`};function sc(i){return i>=1e6?`${+(i/1e6).toFixed(1)}M`:i>=1e3?`${Math.round(i/1e3)}k`:String(i)}function sm(i){const t=typeof i=="number"?i:Date.parse(i);if(!t)return"";const e=t-Date.now();if(e<=0)return"Expired. Make a new one.";const n=Math.ceil(e/6e4),s=Math.floor(n/60),a=n%60,r=new Date(t).toLocaleString([],{weekday:"short",hour:"numeric",minute:"2-digit"});return`Works once. Expires in ${s?`${s} h ${a} min`:`${a} min`} (${r}).`}function am(i){var s,a;const t=((s=i.repos)==null?void 0:s.length)||0,e=((a=ch.find(r=>r.id===i.clearance))==null?void 0:a.name)||i.clearance,n=i.theirAgents==="read"?"their agents read only":i.theirAgents==="edit"?"their agents edit a copy":"";return[t===1?i.repos[0]:`${t} projects`,...i.ourAgents===!1?["our agents not lent"]:[e,`${sc(i.tokensPerDay||0)} tokens a day`],n].filter(Boolean).join(" · ")}function rm(i){return i.kind!=="guest"?"Linked office":i.role==="guest"?"Guest · you work with their agents":"Guest · they work with yours"}function Fe(){if(!Ne||Ne.hidden)return;const i=Xa.handle||(Ii==null?void 0:Ii.handle);Ne.replaceChildren(wt("p",{className:"theme-k",textContent:"Linked offices"})),i?(Ne.append(wt("p",{className:"lb-me"},"This office is ",wt("strong",{textContent:`@${i}`}))),Ne.append(lm()),as&&Ne.append(cm()),je&&Ne.append(hm())):Ne.append(...om()),Vn&&Ne.append(Pn(Vn,"acct-note acct-err")),Xa.error?Ne.append(Pn(`Link service: ${Xa.error}`,"acct-note acct-err")):Qn!=null&&Qn.length&&Xa.connected===!1&&Ne.append(Pn("Connecting to the link service…","acct-note acct-fine")),Ne.append(dm())}function om(){const i=[Pn("Invite a guest to run jobs here within the limits you set. Their agents walk into your office as visitors. First, pick a handle for this office.")];if(Ii&&!Ii.configured)return[...i,Pn("This office has no link service set up.","acct-note acct-err")];const t=wt("form",{className:"acct-form"}),e=wt("input",{type:"text",placeholder:"Pick a handle",autocomplete:"off",spellcheck:!1,maxLength:20});return e.setAttribute("aria-label","Handle"),t.append(e,wt("button",{type:"submit",className:"primary small",textContent:dn==="claim"?"Claiming…":"Claim",disabled:!!dn})),t.addEventListener("submit",async n=>{n.preventDefault(),e.value.trim()&&await cr("claim",async()=>{gm(await fi("/api/leaderboard/handle",{handle:e.value.trim()}),!0),As(await fi("/api/links"))})}),[...i,t,Pn("Claiming a handle doesn’t put you on the leaderboard. Sharing your counters there is a separate choice.","acct-note acct-fine")]}function lm(){const i=wt("div",{className:"link-actions"}),t=wt("button",{type:"button",className:"ghost small",textContent:"Invite a guest",disabled:!!dn});t.setAttribute("aria-expanded",String(!!je&&!je.edit)),t.addEventListener("click",()=>hf());const e=wt("form",{className:"acct-form link-redeem"}),n=wt("input",{type:"text",placeholder:"Enter a code, e.g. K7QX-M2PD",autocomplete:"off",spellcheck:!1,maxLength:12});return n.setAttribute("aria-label","Invite code"),e.append(n,wt("button",{type:"submit",className:"primary small",textContent:dn==="redeem"?"Linking…":"Link",disabled:!!dn})),e.addEventListener("submit",s=>{s.preventDefault();const a=nm(n.value);if(!a){Vn="A code is 8 letters and numbers, like K7QX-M2PD.",Fe();return}cr("redeem",async()=>{As(await fi("/api/links/redeem",{code:a})),as=null})}),i.append(wt("div",{className:"link-row"},t),e),i}function cm(){const i=wt("div",{className:"link-code"}),t=im(as.code),e=wt("button",{type:"button",className:"ghost small",textContent:yo?"Copied":"Copy"});return e.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(t),yo=!0}catch{Vn="Couldn’t copy. Select the code and copy it by hand."}Fe()}),i.append(wt("p",{className:"theme-k",textContent:as.kind==="guest"?"Guest code":"Office code"}),wt("div",{className:"link-code-row"},wt("output",{className:"link-code-v",textContent:t}),e),Pn(`${as.kind==="guest"?"Give this to your guest. They enter it in their own office.":"Give this to the other office. They enter it under Linked offices."} ${sm(as.expiresAt)}`,"acct-note acct-fine")),i}async function hf(i){if(i!=null&&i.id?(je==null?void 0:je.edit)===i.id:je&&!je.edit){je=null,Fe();return}const e=i==null?void 0:i.guest;if(je=e?{repos:new Set(e.repos||[]),clearance:e.clearance==="auto"?"edit":e.clearance||"edit",full:e.clearance==="auto",tokensPerDay:e.tokensPerDay||du,ourAgents:e.ourAgents!==!1,theirAgents:e.theirAgents||"off",edit:i.id,peer:i.peer}:{repos:new Set,clearance:"edit",full:!1,tokensPerDay:du,ourAgents:!0,theirAgents:"off",edit:null},as=null,Vn="",Fe(),!Ms){try{Ms=(await fi("/api/repos")).repos||[]}catch(n){Ms=[],Vn=n.message}Fe()}}function hm(){const i=je,t=wt("form",{className:"link-guest"});t.append(wt("p",{className:"theme-k",textContent:i.edit?`What @${i.peer} can do`:"Invite a guest"}),Pn("Pick the projects they can work in, then whose agents do the work: yours, on your Claude account, or their own, on theirs.","acct-note acct-fine"));const e=wt("fieldset",{className:"link-repos"},wt("legend",{textContent:`Projects they can use (${i.repos.size} picked)`}));Ms?Ms.length||e.append(Pn("No projects found.","acct-note acct-fine")):e.append(Pn("Loading…","acct-note acct-fine"));for(const g of[...new Set([...Ms||[],...Ms?i.repos:[]])]){const _=wt("input",{type:"checkbox",checked:i.repos.has(g)});_.addEventListener("change",()=>{_.checked?i.repos.add(g):i.repos.delete(g),Fe()}),e.append(wt("label",{},_,wt("span",{textContent:g})))}const n=wt("input",{type:"checkbox",checked:i.ourAgents});n.addEventListener("change",()=>{i.ourAgents=n.checked,Fe()});const s=wt("fieldset",{className:"link-ours",disabled:!i.ourAgents});s.classList.toggle("off",!i.ourAgents);const a=wt("div",{className:"theme-modes acct-modes link-cap"});a.setAttribute("role","radiogroup"),a.setAttribute("aria-label","Clearance cap");for(const g of ch.slice(0,2)){const _=wt("button",{type:"button",textContent:g.name,disabled:i.full});_.setAttribute("role","radio"),_.setAttribute("aria-checked",String(!i.full&&i.clearance===g.id)),_.addEventListener("click",()=>{i.clearance=g.id,Fe()}),a.append(_)}const r=wt("input",{type:"checkbox",checked:i.full});r.addEventListener("change",()=>{i.full=r.checked,Fe()});const o=wt("div",{className:"link-warn"},wt("p",{textContent:"Full autonomy lets the guest run any command on this machine, with your files and your logins. Only allow it for someone you’d hand your laptop to."}),wt("label",{},r,wt("span",{textContent:"Allow full autonomy anyway"}))),l=wt("input",{type:"number",min:1e5,step:1e5,value:i.tokensPerDay,required:i.ourAgents});l.setAttribute("aria-label","Tokens per day");const c=wt("span",{className:"acct-fine",textContent:sc(i.tokensPerDay)});l.addEventListener("input",()=>{i.tokensPerDay=Math.floor(Number(l.value))||0,c.textContent=sc(i.tokensPerDay)}),s.append(wt("p",{className:"link-k",textContent:"Clearance cap"}),a,o,wt("label",{className:"link-k link-tokens"},wt("span",{textContent:"Tokens per day"}),l,c));const h=wt("div",{className:"theme-modes acct-modes link-cap link-theirs"});h.setAttribute("role","radiogroup"),h.setAttribute("aria-label","Their agents");for(const g of tm){const _=wt("button",{type:"button",textContent:g.name});_.setAttribute("role","radio"),_.setAttribute("aria-checked",String(i.theirAgents===g.id)),_.addEventListener("click",()=>{i.theirAgents=g.id,Fe()}),h.append(_)}const u=!i.ourAgents&&i.theirAgents==="off",d=i.repos.size>0&&!u&&!dn,f=i.repos.size?u?"Lend your agents, or let theirs in.":"":"Pick at least one project.";return t.append(e,wt("label",{className:"link-switch"},n,wt("span",{},wt("strong",{textContent:"Lend our agents"}),wt("span",{className:"acct-fine",textContent:"They start jobs with your agents, on your Claude account."}))),s,wt("p",{className:"link-k",textContent:"Their agents"}),h,Pn(i.theirAgents==="off"?"Their own agents can’t work in your projects.":`Their own agents, on their account, work in a copy${i.theirAgents==="edit"?". Nothing reaches your folder until you apply it from the job.":" and can’t change anything."} They have no shell, so they can’t run anything here.`,"acct-note acct-fine"),wt("div",{className:"link-row"},wt("button",{type:"submit",className:"primary small",disabled:!d,textContent:i.edit?dn==="guest"?"Saving…":"Save":dn==="guest"?"Making a code…":"Make guest code"}),i.edit?um():null,f?wt("span",{className:"acct-fine",textContent:f}):null)),t.addEventListener("submit",g=>{if(g.preventDefault(),!i.repos.size||u){Vn=f,Fe();return}if(i.ourAgents&&i.tokensPerDay<1e5){Vn="Allow at least 100,000 tokens a day.",Fe();return}const _={repos:[...i.repos],clearance:i.full?"auto":i.clearance,tokensPerDay:Math.max(i.tokensPerDay,1e5),ourAgents:i.ourAgents,theirAgents:i.theirAgents};i.edit?pm(i.edit,_):fm("guest",_)}),t}function um(){const i=wt("button",{type:"button",className:"ghost small",textContent:"Cancel"});return i.addEventListener("click",()=>{je=null,Fe()}),i}function dm(){const i=wt("div",{className:"lb-board"});if(!Qn)return i.append(Pn("Loading links…","acct-note acct-fine")),i;if(!Qn.length)return i.append(Pn("No links yet.","acct-note acct-fine")),i;const t=wt("ul",{className:"lb-list link-list"});for(const e of Qn){const n=wt("li",{className:"link-item"},wt("span",{className:"link-who"},wt("strong",{textContent:`@${e.peer}`}),wt("span",{className:"acct-fine",textContent:rm(e)}),e.guest?wt("span",{className:"acct-fine link-policy",textContent:am(e.guest)}):null));e.kind==="guest"&&e.role==="guest"&&n.querySelector(".link-who").append(wt("span",{className:"acct-fine",textContent:"Tag their agents in chat with @"}));const s=wt("span",{className:"link-row"});if(e.kind==="guest"&&e.role==="host"&&e.guest){const r=wt("button",{type:"button",className:"ghost small",textContent:"Change",disabled:!!dn});r.setAttribute("aria-expanded",String((je==null?void 0:je.edit)===e.id)),r.addEventListener("click",()=>hf(e)),s.append(r)}const a=wt("button",{type:"button",className:"acct-forget",textContent:dn===e.id?"Unlinking…":"Unlink",disabled:!!dn});a.addEventListener("click",()=>mm(e)),s.append(a),n.append(s),t.append(n)}return i.append(t),i}async function cr(i,t){dn=i,Vn="",Fe();try{await t()}catch(e){Vn=e.message}dn="",Fe()}function fm(i,t){return yo=!1,cr(i,async()=>{const e=await fi("/api/links/invite",t?{kind:i,guest:t}:{kind:i});as={kind:e.kind||i,code:e.code,expiresAt:e.expiresAt},je=null})}function pm(i,t){return cr("guest",async()=>{As(await fi(`/api/links/${encodeURIComponent(i)}/guest`,{guest:t})),je=null})}function mm(i){const t=i.kind!=="guest"?"You stop seeing each other’s agents.":i.role==="host"?"Their running jobs stop and they lose access right away.":"You can’t work with their agents again without a new code.";confirm(`Unlink @${i.peer}? ${t}`)&&cr(i.id,async()=>{As(await fi(`/api/links/${encodeURIComponent(i.id)}`,void 0,"DELETE"))})}function gm(i,t=!1){Ii=i,t&&document.dispatchEvent(new CustomEvent("office:leaderboard",{detail:i}))}function As(i){!i||!Array.isArray(i.links)||(Qn=i.links,Xa={handle:i.handle||null,connected:i.connected,error:i.error||null},Oo(),dn||Fe())}document.addEventListener("office:leaderboard",i=>{Ii=i.detail,dn||Fe()});function Uo(i){if(Ne.hidden=!i,fa.setAttribute("aria-expanded",String(i)),!i){Vn="",je=null,yo=!1;return}Fe(),fi("/api/links").then(As,t=>{Qn||(Qn=[]),Vn=t.message,Fe()}),Ii||fi("/api/leaderboard").then(t=>{Ii=t,Fe()},()=>{})}fa==null||fa.addEventListener("click",()=>Uo(Ne.hidden));var af;for(const i of["themeBtn","acctBtn"])(af=document.getElementById(i))==null||af.addEventListener("click",()=>{Ne.hidden||Uo(!1)});document.addEventListener("click",i=>{Ne&&!Ne.hidden&&i.target.isConnected&&!Ne.contains(i.target)&&!fa.contains(i.target)&&Uo(!1)});document.addEventListener("keydown",i=>{i.key==="Escape"&&Ne&&!Ne.hidden&&(Uo(!1),fa.focus())});const Gt={on:!1,link:null,host:"",repos:null,clearance:"edit",tokensPerDay:0};{const i=new URLSearchParams(location.search).get("visit");i&&Object.assign(Gt,{on:!0,link:i})}function vm(i){i&&(Es="",Object.assign(Gt,{on:!0,link:i.link??Gt.link,host:i.host??Gt.host,repos:Array.isArray(i.repos)?i.repos:Gt.repos,clearance:rr[i.clearance]!=null?i.clearance:Gt.clearance,tokensPerDay:i.tokensPerDay??Gt.tokensPerDay}),Oo())}function Gi(i,t=""){return i=encodeURIComponent(i),Gt.on?`/api/visit/${encodeURIComponent(Gt.link)}/jobs/${i}${t}`:`/api/jobs/${i}${t}`}function el(i,t,e){return Gt.on?{text:i,mode:t}:{message:i,mode:t,files:e}}const nl=i=>`#${i.replace(/\s+/g,"-")}`.toLowerCase();async function _m({text:i,mode:t,model:e}){const n=(i.match(/(^|\s)#[\w.-]+/g)||[]).map(c=>c.trim().toLowerCase()),s=Gt.repos||[],a=s.filter(c=>n.includes(nl(c)));if(a.length!==1){const c=s.map(nl).join(", ")||"none yet";throw new Error(a.length?"Name just one project per job.":`Name the project with a # tag. You can use: ${c}.`)}const r=a[0],o=i.replace(new RegExp(`(^|\\s)${nl(r).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?=\\s|$)`,"i")," ").replace(/\s+/g," ").trim();if(!o)throw new Error("Say what the job is, as well as the project.");const{job:l}=await fi(`/api/visit/${encodeURIComponent(Gt.link)}/jobs`,{repo:r,prompt:o,mode:t,model:e});return l}function xm(i){return!Gt.on||!i?i:Object.fromEntries(Object.entries(i).filter(([t])=>(rr[t]??9)<=rr[Gt.clearance]))}function il(i){return!Gt.on||!Array.isArray(i)?i:i.filter(t=>{var e;return(e=Gt.repos)==null?void 0:e.includes(t)})}let Es="",io=!1;function ym(i){if(!Gt.on)return null;if(i===4404)Es="The host ended this link. You can’t visit any more.";else if(i===4502)Es="Can’t reach the host’s office right now. Trying again…";else return Es="",null;return io=i===4404,Oo(),i===4404?0:1e4}function Oo(){var a,r,o,l;if(!Gt.on)return;const i=Gt.host||((a=Qn==null?void 0:Qn.find(c=>c.id===Gt.link))==null?void 0:a.peer)||"";i&&(Gt.host=i),tl.classList.add("visiting"),tl.dataset.visiting=i,tl.classList.toggle("visit-ended",!!io);const t=document.getElementById("input");if(t){t.placeholder=io?"This link has ended.":`Start a job${i?` at @${i}`:""} · #project`;for(const c of document.querySelectorAll("#composer textarea, #composer select, #composer button"))c.disabled=!!io}const e=document.getElementById("mode");if(e){for(const c of e.options)c.hidden=c.disabled=rr[c.value]>rr[Gt.clearance];(r=e.selectedOptions[0])!=null&&r.disabled&&(e.value=Gt.clearance)}let n=document.getElementById("visitBar");n||(n=wt("div",{className:"visit-bar",id:"visitBar"}),n.setAttribute("role","status"),(o=document.querySelector(".brand"))==null||o.after(n));const s=wt("a",{href:location.pathname,textContent:"Back to my office"});n.replaceChildren(wt("span",{},"Visiting ",wt("strong",{textContent:i?`@${i}`:"a linked office"}),Gt.repos?` · ${Gt.repos.length} ${Gt.repos.length===1?"project":"projects"}, up to ${(l=ch.find(c=>c.id===Gt.clearance))==null?void 0:l.name.toLowerCase()}`:""),s),n.classList.toggle("visit-off",!!Es),Es&&n.append(wt("p",{className:"visit-note",textContent:Es}))}Oo();const ia=document.getElementById("setBtn"),De=document.getElementById("settings");let Ts=null,tn={},pa=!1,ls="",uf=()=>{};const Te=(i,t={})=>Object.assign(document.createElement(i),t);Te.kids=(i,t)=>(i.append(...t),i);const so=i=>i.key in tn?tn[i.key]:i.value,fu=(i,t)=>i.kind==="bool"?t?"on":"off":i.kind==="time"?t||"off":i.kind==="text"?t||"the account name":i.kind==="number"?`${Number(t).toLocaleString()}${i.unit?` ${i.unit}`:""}`:String(t),df=(i,t)=>Number.isInteger(t)&&t>=i.min&&t<=i.max,ff=()=>Object.keys(tn);function Mm(i){const t=so(i),e=`set-${i.key}`,n=a=>{Object.is(a,i.value)?delete tn[i.key]:tn[i.key]=a,hh(),pf(i)};if(i.kind==="bool"){const a=Te("button",{type:"button",id:e,className:"set-switch"});return a.setAttribute("role","switch"),a.setAttribute("aria-checked",String(!!t)),a.addEventListener("click",()=>{n(!so(i)),a.setAttribute("aria-checked",String(!!so(i)))}),a}if(i.kind==="choice"){const a=Te("div",{className:"theme-modes set-choice"});a.setAttribute("role","radiogroup"),a.setAttribute("aria-label",i.label),a.style.gridTemplateColumns=`repeat(${i.options.length}, 1fr)`;for(const r of i.options){const o=Te("button",{type:"button",textContent:r});o.setAttribute("role","radio"),o.setAttribute("aria-checked",String(r===t)),o.addEventListener("click",()=>{n(r);for(const l of a.children)l.setAttribute("aria-checked",String(l.textContent===r))}),a.append(o)}return a}const s=Te("input",{id:e,className:"set-input"});return s.spellcheck=!1,s.autocomplete="off",i.kind==="number"?Object.assign(s,{type:"number",min:i.min,max:i.max,step:i.step||1,value:t,inputMode:"numeric"}):i.kind==="time"?Object.assign(s,{type:"time",value:t}):Object.assign(s,{type:"text",value:t,maxLength:i.max,placeholder:i.default||"Your first name"}),s.addEventListener("input",()=>{const a=s.value;n(i.kind==="number"?a===""?NaN:Number(a):a)}),s}const ac=new Map;function pf(i){const t=ac.get(i.key);if(!t)return;t.classList.toggle("set-changed",i.key in tn);const e=t.querySelector(".set-fine");e.replaceChildren();const n=so(i);if(i.kind==="number"&&!df(i,n)){e.textContent=`Use a whole number from ${i.min.toLocaleString()} to ${i.max.toLocaleString()}.`,e.classList.add("acct-err");return}if(e.classList.remove("acct-err"),i.hint&&e.append(i.hint," "),i.custom&&!(i.key in tn)){const s=Te("button",{type:"button",className:"acct-forget set-reset",textContent:`Use the default (${fu(i,i.default)})`});s.addEventListener("click",()=>rc({[i.key]:null})),e.append(s)}else i.custom||e.append(`Default: ${fu(i,i.default)}.`)}function hh(){const i=ff().length,t=De.querySelector(".set-save"),e=De.querySelector(".set-undo"),n=De.querySelector(".set-msg");if(!t)return;const s=Ts.some(a=>a.key in tn&&a.kind==="number"&&!df(a,tn[a.key]));t.disabled=pa||!i||s,t.textContent=pa?"Saving…":i>1?`Save ${i} changes`:"Save",e.hidden=!i||pa,n.textContent=ls||(i?"Unsaved changes":""),n.classList.toggle("acct-err",!!ls)}function ma(){ac.clear();const i=De.querySelector(".set-body");if(i.replaceChildren(),!Ts){i.append(Te("p",{className:"acct-note",textContent:ls||"Loading…"}));return}const t=[...new Set(Ts.map(e=>e.group))];for(const e of t){const n=Te("section",{className:"set-group"});n.append(Te("h3",{className:"theme-k",textContent:e}));for(const s of Ts.filter(a=>a.group===e)){const a=Te("div",{className:"set-row"}),r=Te("div",{className:"set-text"}),o=Te("label",{className:"set-label",textContent:s.label});o.htmlFor=`set-${s.key}`,r.append(o,Te("p",{className:"acct-note acct-fine set-fine"})),a.append(r,Mm(s)),ac.set(s.key,a),n.append(a),pf(s)}i.append(n)}hh()}async function rc(i){pa=!0,ls="",hh();try{const t=await fetch("/api/settings",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(i)}),e=await t.json();if(!t.ok)throw new Error(e.error||"That didn’t save.");for(const n of Object.keys(i))delete tn[n];uh(e),uf("Settings saved","good")}catch(t){ls=t.message}pa=!1,ma()}let mf=()=>{};function uh(i){Ts=i.settings;for(const t of Ts)t.key in tn&&Object.is(tn[t.key],t.value)&&delete tn[t.key];i.owner!==void 0&&mf(i.owner)}function pu(i){i!=null&&i.settings&&(uh(i),De!=null&&De.open&&!pa&&ma())}function bm(){var i;ls="",De.showModal(),ia.setAttribute("aria-expanded","true"),ma(),Ts||fetch("/api/settings").then(t=>t.ok?t.json():Promise.reject()).then(t=>{uh(t),ma()},()=>{ls="Restart the office server to use Settings.",ma()}),(i=De.querySelector("input, button.set-switch, [role=radio]"))==null||i.focus()}function sl(){return ff().length&&!confirm("Discard your unsaved changes?")?!1:(tn={},De.close(),!0)}function Sm({toast:i,renderOwner:t}){if(uf=i,mf=t,!(!ia||!De)){if(Gt.on){ia.hidden=!0;return}De.append(Te.kids(Te("header",{className:"set-head"}),[Te("h2",{textContent:"Settings"}),Object.assign(Te("button",{type:"button",className:"theme-btn set-x"}),{innerHTML:'<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6 6 18"/></svg>',ariaLabel:"Close settings"})]),Te("div",{className:"set-body"}),Te.kids(Te("footer",{className:"set-foot"}),[Te("span",{className:"set-msg",role:"status"}),Te("button",{type:"button",className:"set-undo acct-forget",textContent:"Discard",hidden:!0}),Te("button",{type:"button",className:"primary small set-save",textContent:"Save",disabled:!0})])),De.querySelector(".set-x").addEventListener("click",sl),De.querySelector(".set-undo").addEventListener("click",()=>{tn={},ls="",ma()}),De.querySelector(".set-save").addEventListener("click",()=>rc({...tn})),ia.addEventListener("click",bm),De.addEventListener("cancel",e=>{e.preventDefault(),sl()}),De.addEventListener("click",e=>{e.target===De&&sl()}),De.addEventListener("close",()=>{ia.setAttribute("aria-expanded","false"),ia.focus()}),De.addEventListener("keydown",e=>{e.key==="Enter"&&e.target.matches("input")&&!De.querySelector(".set-save").disabled&&(e.preventDefault(),rc({...tn}))})}}const ga=document.getElementById("lbBtn"),we=document.getElementById("lbPop"),gf=[{id:"jobs",name:"Jobs",value:i=>String(i.jobs)},{id:"tokens",name:"Tokens",value:i=>dh(i.tokens)},{id:"time",name:"Time",value:i=>fh(i.seconds)}],wm=[{id:"week",name:"This week"},{id:"all",name:"All time"}];let Kt=null,oc="week",Ka="jobs",Qi=null,lc=!1,Pi=!1,Un="",cc="";const Qt=(i,t={})=>Object.assign(document.createElement(i),t);function dh(i){return i>=1e9?`${(i/1e9).toFixed(1)}B`:i>=1e6?`${(i/1e6).toFixed(1)}M`:i>=1e3?`${(i/1e3).toFixed(i>=1e5?0:1)}k`:String(i)}function fh(i){const t=Math.round(i/60);return t<1?i>0?"<1m":"0m":t<60?`${t}m`:`${Math.floor(t/60)}h ${String(t%60).padStart(2,"0")}m`}function vf(i){const t=Math.max(0,Math.round((Date.now()-i)/1e3));return t<90?"just now":t<5400?`${Math.round(t/60)} min ago`:t<129600?`${Math.round(t/3600)} h ago`:`${Math.round(t/86400)} days ago`}function mu(i,t,e,n,s=""){const a=Qt("div",{className:`theme-modes lb-tabs ${s}`});a.setAttribute("role","radiogroup"),a.setAttribute("aria-label",e);for(const r of i){const o=Qt("button",{type:"button"});o.setAttribute("role","radio"),o.setAttribute("aria-checked",String(r.id===t)),o.append(Qt("span",{textContent:r.name})),o.addEventListener("click",()=>n(r.id)),a.append(o)}return a}function ti(){if(!we)return;we.replaceChildren(Qt("p",{className:"theme-k",textContent:"Leaderboard"}));const i=(t,e="acct-note")=>we.append(Qt("p",{className:e,textContent:t}));if(!Kt){i(Un||"Checking…");return}if(!Kt.configured){i("No leaderboard is set up for this office. Whoever hosts one gives you its address: set it as OFFICE_LEADERBOARD_URL and restart the office.");return}if(gu())Em();else if(Kt.joined){const t=Kt.week,e=Qt("p",{className:"lb-me"});we.append(e),e.append(Qt("strong",{textContent:Kt.handle}),Qt("span",{textContent:` · ${t.jobs} ${t.jobs===1?"job":"jobs"}, ${dh(t.tokens)} tokens, ${fh(t.seconds)} this week`}));const n=Kt.error?`Not shared yet: ${Kt.error}`:Kt.lastSync?`Shared ${vf(Kt.lastSync)}.`:"Sharing…";i(n,Kt.error?"acct-note acct-err":"acct-note acct-fine")}else{i("Compete on jobs finished, tokens used and time your agents spend working. Joining shares exactly these counters per day, for the last two weeks and from now on, under the handle you claim. Never prompts, projects, files, chat or cost.");const t=Qt("form",{className:"acct-form"}),e=Qt("input",{type:"text",placeholder:"Pick a handle",autocomplete:"off",spellcheck:!1,maxLength:20});e.setAttribute("aria-label","Handle"),t.append(e,Qt("button",{type:"submit",className:"primary small",textContent:Pi?"Joining…":"Join",disabled:Pi})),t.addEventListener("submit",n=>{n.preventDefault(),e.value.trim()&&bo("POST",{handle:e.value})}),we.append(t),Un&&i(Un,"acct-note acct-err")}if(we.append(mu(wm,oc,"Period",t=>{oc=t,Mo()},"lb-period"),mu(gf,Ka,"Ranked by",t=>{Ka=t,ti()},"lb-metric")),we.append(Tm()),Kt.joined&&!gu()){const t=Qt("button",{type:"button",className:"acct-forget",textContent:Pi?"Working…":"Leave and delete my data",disabled:Pi});t.addEventListener("click",()=>{confirm("Leave the leaderboard? Your handle is released and your counters are deleted from the service.")&&bo("DELETE")}),we.append(t),Un&&i(Un,"acct-note acct-err")}}const gu=()=>!!Kt&&"sharing"in Kt&&!!Kt.handle;function Em(){const i=(s,a="acct-note")=>we.append(Qt("p",{className:a,textContent:s})),t=Qt("p",{className:"lb-me"});if(t.append(Qt("strong",{textContent:Kt.handle})),Kt.sharing&&Kt.week){const s=Kt.week;t.append(Qt("span",{textContent:` · ${s.jobs} ${s.jobs===1?"job":"jobs"}, ${dh(s.tokens)} tokens, ${fh(s.seconds)} this week`}))}we.append(t);const e=Qt("input",{type:"checkbox",checked:!!Kt.sharing,disabled:Pi});e.addEventListener("change",()=>{if(e.checked){bo("POST",{handle:Kt.handle});return}confirm("Stop sharing? Your counters are deleted from the board. You keep your handle while you have linked offices; with none, the handle is released too.")?bo("DELETE"):e.checked=!0});const n=Qt("label",{className:"lb-share"});if(n.append(e,Qt("span",{textContent:"Share my counters on the board"})),we.append(n),Kt.sharing){const s=Kt.error?`Not shared yet: ${Kt.error}`:Kt.lastSync?`Shared ${vf(Kt.lastSync)}.`:"Sharing…";i(s,Kt.error?"acct-note acct-err":"acct-note acct-fine")}else i("Sharing sends jobs finished, tokens and agent time per day, for the last two weeks and from now on. Never prompts, projects, files, chat or cost.","acct-note acct-fine");Un&&i(Un,"acct-note acct-err")}function Tm(){var a;const i=Qt("div",{className:"lb-board"});if(!Qi)return i.append(Qt("p",{className:"acct-note",textContent:lc?"Loading…":cc||"No board yet."})),i;const e=Qi[Ka==="time"?"time":Ka]||[];if(!e.length)return i.append(Qt("p",{className:"acct-note",textContent:"Nobody on the board yet."})),i;const n=gf.find(r=>r.id===Ka),s=Qt("ol",{className:"lb-list"});for(const r of e){const o=Qt("li",{className:r.handle.toLowerCase()===((a=Kt.handle)==null?void 0:a.toLowerCase())?"lb-row lb-you":"lb-row"});o.append(Qt("span",{className:"lb-rank",textContent:String(r.rank)}),Qt("span",{className:"lb-name",textContent:r.handle}),Qt("span",{className:"lb-val",textContent:n.value(r)})),s.append(o)}return i.append(s),Qi.players>e.length&&i.append(Qt("p",{className:"acct-note acct-fine",textContent:`Top ${e.length} of ${Qi.players}.`})),Qi.since&&i.append(Qt("p",{className:"acct-note acct-fine",textContent:"Weeks start Monday, UTC."})),i}async function Mo(){if(Kt!=null&&Kt.configured){lc=!0,cc="",ti();try{const i=await fetch(`/api/leaderboard/board?period=${oc}`),t=await i.json();if(!i.ok)throw new Error(t.error||"Couldn’t load the board.");Qi=t}catch(i){Qi=null,cc=i.message}lc=!1,we.hidden||ti()}}async function bo(i,t){Pi=!0,Un="",ti();try{const e=await fetch("/api/leaderboard",i==="POST"?{method:i,headers:{"content-type":"application/json"},body:JSON.stringify(t)}:{method:i}),n=await e.json();if(!e.ok)throw new Error(n.error||"That didn’t work.");hr(n),Qi=null}catch(e){Un=e.message}Pi=!1,ti(),Un||Mo()}function vu(i){i&&(hr(i),!Pi&&!we.hidden&&ti())}function hr(i){Kt=i,document.dispatchEvent(new CustomEvent("office:leaderboard",{detail:i}))}document.addEventListener("office:leaderboard",i=>{i.detail!==Kt&&(Kt=i.detail,!Pi&&we&&!we.hidden&&ti())});function Fo(i){if(we.hidden=!i,ga.setAttribute("aria-expanded",String(i)),!i){Un="";return}ti(),Kt?Mo():fetch("/api/leaderboard").then(t=>t.ok?t.json():Promise.reject()).then(t=>{hr(t),ti(),Mo()},()=>{Un="Restart the office server to use this.",ti()})}ga==null||ga.addEventListener("click",()=>Fo(we.hidden));var rf;for(const i of["themeBtn","acctBtn"])(rf=document.getElementById(i))==null||rf.addEventListener("click",()=>{we.hidden||Fo(!1)});document.addEventListener("click",i=>{const t=i.composedPath();we&&!we.hidden&&!t.includes(we)&&!t.includes(ga)&&Fo(!1)});document.addEventListener("keydown",i=>{i.key==="Escape"&&we&&!we.hidden&&(Fo(!1),ga.focus())});const hc="office.nameAsked",Am="office.name";let _f=()=>{};function Cm(i){_f=i}const Rm=i=>i.trim().replace(/\s+/g,"_").replace(/[^A-Za-z0-9_-]/g,"").slice(0,20);function Pm(){const i=Qt("dialog",{className:"name-ask"}),t=Qt("form",{method:"dialog"}),e=Qt("input",{type:"text",placeholder:"Your name",autocomplete:"off",spellcheck:!1,maxLength:40});e.setAttribute("aria-label","Your name");const n=Qt("p",{className:"acct-note acct-err",hidden:!0}),s=Qt("button",{type:"submit",className:"primary small",textContent:"Continue"}),a=Qt("button",{type:"button",className:"acct-forget",textContent:"Not now"}),r=Qt("div",{className:"acct-form"});r.append(e,s),t.append(Qt("h2",{textContent:"Welcome to the office"}),Qt("p",{className:"acct-note",textContent:Kt!=null&&Kt.configured?"What should we call you? Your name becomes your handle on the leaderboard. Nothing is shared until you join it.":"What should we call you?"}),r,n,a),i.append(t);const o=()=>{try{localStorage.setItem(hc,"1")}catch{}i.close(),i.remove(),_f()};a.addEventListener("click",o),i.addEventListener("cancel",o),t.addEventListener("submit",async l=>{l.preventDefault();const c=e.value.trim(),h=Rm(c);if(c){n.hidden=!0,s.disabled=!0;try{if(Kt!=null&&Kt.configured){if(h.length<3)throw new Error("Use at least 3 letters or numbers.");const u=await fetch("/api/leaderboard/handle",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({handle:h})}),d=await u.json();if(!u.ok)throw new Error(d.error||"That handle didn’t work.");hr(d),we.hidden||ti()}try{localStorage.setItem(Am,c)}catch{}o()}catch(u){n.textContent=u.message,n.hidden=!1,s.disabled=!1,e.focus()}}}),document.body.append(i),i.showModal(),e.focus()}try{!localStorage.getItem(hc)&&!new URLSearchParams(location.search).has("visit")&&fetch("/api/leaderboard").then(i=>i.ok?i.json():null).catch(()=>null).then(i=>{if(i&&hr(i),i!=null&&i.handle){try{localStorage.setItem(hc,"1")}catch{}return}Pm()})}catch{}function ph(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}let Ds=ph();function xf(i){Ds=i}const yf=/[&<>"']/,Lm=new RegExp(yf.source,"g"),Mf=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Dm=new RegExp(Mf.source,"g"),Im={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},_u=i=>Im[i];function Cn(i,t){if(t){if(yf.test(i))return i.replace(Lm,_u)}else if(Mf.test(i))return i.replace(Dm,_u);return i}const km=/(^|[^\[])\^/g;function ve(i,t){let e=typeof i=="string"?i:i.source;t=t||"";const n={replace:(s,a)=>{let r=typeof a=="string"?a:a.source;return r=r.replace(km,"$1"),e=e.replace(s,r),n},getRegex:()=>new RegExp(e,t)};return n}function xu(i){try{i=encodeURI(i).replace(/%25/g,"%")}catch{return null}return i}const Za={exec:()=>null};function yu(i,t){const e=i.replace(/\|/g,(a,r,o)=>{let l=!1,c=r;for(;--c>=0&&o[c]==="\\";)l=!l;return l?"|":" |"}),n=e.split(/ \|/);let s=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;s<n.length;s++)n[s]=n[s].trim().replace(/\\\|/g,"|");return n}function Da(i,t,e){const n=i.length;if(n===0)return"";let s=0;for(;s<n&&i.charAt(n-s-1)===t;)s++;return i.slice(0,n-s)}function Nm(i,t){if(i.indexOf(t[1])===-1)return-1;let e=0;for(let n=0;n<i.length;n++)if(i[n]==="\\")n++;else if(i[n]===t[0])e++;else if(i[n]===t[1]&&(e--,e<0))return n;return-1}function Mu(i,t,e,n){const s=t.href,a=t.title?Cn(t.title):null,r=i[1].replace(/\\([\[\]])/g,"$1");if(i[0].charAt(0)!=="!"){n.state.inLink=!0;const o={type:"link",raw:e,href:s,title:a,text:r,tokens:n.inlineTokens(r)};return n.state.inLink=!1,o}return{type:"image",raw:e,href:s,title:a,text:Cn(r)}}function Um(i,t){const e=i.match(/^(\s+)(?:```)/);if(e===null)return t;const n=e[1];return t.split(`
2
2
  `).map(s=>{const a=s.match(/^\s+/);if(a===null)return s;const[r]=a;return r.length>=n.length?s.slice(n.length):s}).join(`
3
3
  `)}class So{constructor(t){_e(this,"options");_e(this,"rules");_e(this,"lexer");this.options=t||Ds}space(t){const e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){const e=this.rules.block.code.exec(t);if(e){const n=e[0].replace(/^(?: {1,4}| {0,3}\t)/gm,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Da(n,`
4
4
  `)}}}fences(t){const e=this.rules.block.fences.exec(t);if(e){const n=e[0],s=Um(n,e[3]||"");return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:s}}}heading(t){const e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(/#$/.test(n)){const s=Da(n,"#");(this.options.pedantic||!s||/ $/.test(s))&&(n=s.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){const e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Da(e[0],`
@@ -22,8 +22,8 @@ ${u}`:u;const d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.block
22
22
  `+d}!f&&!d.trim()&&(f=!0),c+=T+`
23
23
  `,t=t.substring(T.length+1),u=w.slice(g)}}a.loose||(o?a.loose=!0:/\n[ \t]*\n[ \t]*$/.test(c)&&(o=!0));let _=null,p;this.options.gfm&&(_=/^\[[ xX]\] /.exec(h),_&&(p=_[0]!=="[ ] ",h=h.replace(/^\[[ xX]\] +/,""))),a.items.push({type:"list_item",raw:c,task:!!_,checked:p,loose:!1,text:h,tokens:[]}),a.raw+=c}a.items[a.items.length-1].raw=a.items[a.items.length-1].raw.trimEnd(),a.items[a.items.length-1].text=a.items[a.items.length-1].text.trimEnd(),a.raw=a.raw.trimEnd();for(let l=0;l<a.items.length;l++)if(this.lexer.state.top=!1,a.items[l].tokens=this.lexer.blockTokens(a.items[l].text,[]),!a.loose){const c=a.items[l].tokens.filter(u=>u.type==="space"),h=c.length>0&&c.some(u=>/\n.*\n/.test(u.raw));a.loose=h}if(a.loose)for(let l=0;l<a.items.length;l++)a.items[l].loose=!0;return a}}html(t){const e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){const e=this.rules.block.def.exec(t);if(e){const n=e[1].toLowerCase().replace(/\s+/g," "),s=e[2]?e[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",a=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:s,title:a}}}table(t){const e=this.rules.block.table.exec(t);if(!e||!/[:|]/.test(e[2]))return;const n=yu(e[1]),s=e[2].replace(/^\||\| *$/g,"").split("|"),a=e[3]&&e[3].trim()?e[3].replace(/\n[ \t]*$/,"").split(`
24
24
  `):[],r={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===s.length){for(const o of s)/^ *-+: *$/.test(o)?r.align.push("right"):/^ *:-+: *$/.test(o)?r.align.push("center"):/^ *:-+ *$/.test(o)?r.align.push("left"):r.align.push(null);for(let o=0;o<n.length;o++)r.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:r.align[o]});for(const o of a)r.rows.push(yu(o,r.header.length).map((l,c)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:r.align[c]})));return r}}lheading(t){const e=this.rules.block.lheading.exec(t);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(t){const e=this.rules.block.paragraph.exec(t);if(e){const n=e[1].charAt(e[1].length-1)===`
25
- `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){const e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){const e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:Cn(e[1])}}tag(t){const e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&/^<a /i.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){const e=this.rules.inline.link.exec(t);if(e){const n=e[2].trim();if(!this.options.pedantic&&/^</.test(n)){if(!/>$/.test(n))return;const r=Da(n.slice(0,-1),"\\");if((n.length-r.length)%2===0)return}else{const r=Nm(e[2],"()");if(r>-1){const l=(e[0].indexOf("!")===0?5:4)+e[1].length+r;e[2]=e[2].substring(0,r),e[0]=e[0].substring(0,l).trim(),e[3]=""}}let s=e[2],a="";if(this.options.pedantic){const r=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(s);r&&(s=r[1],a=r[3])}else a=e[3]?e[3].slice(1,-1):"";return s=s.trim(),/^</.test(s)&&(this.options.pedantic&&!/>$/.test(n)?s=s.slice(1):s=s.slice(1,-1)),Mu(e,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:a&&a.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){const s=(n[2]||n[1]).replace(/\s+/g," "),a=e[s.toLowerCase()];if(!a){const r=n[0].charAt(0);return{type:"text",raw:r,text:r}}return Mu(n,a,n[0],this.lexer)}}emStrong(t,e,n=""){let s=this.rules.inline.emStrongLDelim.exec(t);if(!s||s[3]&&n.match(/[\p{L}\p{N}]/u))return;if(!(s[1]||s[2]||"")||!n||this.rules.inline.punctuation.exec(n)){const r=[...s[0]].length-1;let o,l,c=r,h=0;const u=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*t.length+r);(s=u.exec(e))!=null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o)continue;if(l=[...o].length,s[3]||s[4]){c+=l;continue}else if((s[5]||s[6])&&r%3&&!((r+l)%3)){h+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+h);const d=[...s[0]][0].length,f=t.slice(0,r+s.index+d+l);if(Math.min(r,l)%2){const _=f.slice(1,-1);return{type:"em",raw:f,text:_,tokens:this.lexer.inlineTokens(_)}}const g=f.slice(2,-2);return{type:"strong",raw:f,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(t){const e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(/\n/g," ");const s=/[^ ]/.test(n),a=/^ /.test(n)&&/ $/.test(n);return s&&a&&(n=n.substring(1,n.length-1)),n=Cn(n,!0),{type:"codespan",raw:e[0],text:n}}}br(t){const e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t){const e=this.rules.inline.del.exec(t);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(t){const e=this.rules.inline.autolink.exec(t);if(e){let n,s;return e[2]==="@"?(n=Cn(e[1]),s="mailto:"+n):(n=Cn(e[1]),s=n),{type:"link",raw:e[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(t){var n;let e;if(e=this.rules.inline.url.exec(t)){let s,a;if(e[2]==="@")s=Cn(e[0]),a="mailto:"+s;else{let r;do r=e[0],e[0]=((n=this.rules.inline._backpedal.exec(e[0]))==null?void 0:n[0])??"";while(r!==e[0]);s=Cn(e[0]),e[1]==="www."?a="http://"+e[0]:a=e[0]}return{type:"link",raw:e[0],text:s,href:a,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(t){const e=this.rules.inline.text.exec(t);if(e){let n;return this.lexer.state.inRawBlock?n=e[0]:n=Cn(e[0]),{type:"text",raw:e[0],text:n}}}}const Om=/^(?:[ \t]*(?:\n|$))+/,Fm=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,zm=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ur=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Bm=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Sf=/(?:[*+-]|\d{1,9}[.)])/,wf=ve(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,Sf).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),mh=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Hm=/^[^\n]+/,gh=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Vm=ve(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",gh).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Gm=ve(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Sf).getRegex(),zo="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",vh=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,$m=ve("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",vh).replace("tag",zo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ef=ve(mh).replace("hr",ur).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",zo).getRegex(),Wm=ve(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ef).getRegex(),_h={blockquote:Wm,code:Fm,def:Vm,fences:zm,heading:Bm,hr:ur,html:$m,lheading:wf,list:Gm,newline:Om,paragraph:Ef,table:Za,text:Hm},bu=ve("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ur).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",zo).getRegex(),Xm={..._h,table:bu,paragraph:ve(mh).replace("hr",ur).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",bu).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",zo).getRegex()},qm={..._h,html:ve(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",vh).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Za,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ve(mh).replace("hr",ur).replace("heading",` *#{1,6} *[^
26
- ]`).replace("lheading",wf).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Tf=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,jm=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Af=/^( {2,}|\\)\n(?!\s*$)/,Ym=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,dr="\\p{P}\\p{S}",Km=ve(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,dr).getRegex(),Zm=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Jm=ve(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,dr).getRegex(),Qm=ve("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,dr).getRegex(),t0=ve("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,dr).getRegex(),e0=ve(/\\([punct])/,"gu").replace(/punct/g,dr).getRegex(),n0=ve(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),i0=ve(vh).replace("(?:-->|$)","-->").getRegex(),s0=ve("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",i0).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),wo=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,a0=ve(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",wo).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Cf=ve(/^!?\[(label)\]\[(ref)\]/).replace("label",wo).replace("ref",gh).getRegex(),Rf=ve(/^!?\[(ref)\](?:\[\])?/).replace("ref",gh).getRegex(),r0=ve("reflink|nolink(?!\\()","g").replace("reflink",Cf).replace("nolink",Rf).getRegex(),xh={_backpedal:Za,anyPunctuation:e0,autolink:n0,blockSkip:Zm,br:Af,code:jm,del:Za,emStrongLDelim:Jm,emStrongRDelimAst:Qm,emStrongRDelimUnd:t0,escape:Tf,link:a0,nolink:Rf,punctuation:Km,reflink:Cf,reflinkSearch:r0,tag:s0,text:Ym,url:Za},o0={...xh,link:ve(/^!?\[(label)\]\((.*?)\)/).replace("label",wo).getRegex(),reflink:ve(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",wo).getRegex()},uc={...xh,escape:ve(Tf).replace("])","~|])").getRegex(),url:ve(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},l0={...uc,br:ve(Af).replace("{2,}","*").getRegex(),text:ve(uc.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},vr={normal:_h,gfm:Xm,pedantic:qm},Ia={normal:xh,gfm:uc,breaks:l0,pedantic:o0};class On{constructor(t){_e(this,"tokens");_e(this,"options");_e(this,"state");_e(this,"tokenizer");_e(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ds,this.options.tokenizer=this.options.tokenizer||new So,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const e={block:vr.normal,inline:Ia.normal};this.options.pedantic?(e.block=vr.pedantic,e.inline=Ia.pedantic):this.options.gfm&&(e.block=vr.gfm,this.options.breaks?e.inline=Ia.breaks:e.inline=Ia.gfm),this.tokenizer.rules=e}static get rules(){return{block:vr,inline:Ia}}static lex(t,e){return new On(e).lex(t)}static lexInline(t,e){return new On(e).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
25
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){const e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){const e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:Cn(e[1])}}tag(t){const e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&/^<a /i.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){const e=this.rules.inline.link.exec(t);if(e){const n=e[2].trim();if(!this.options.pedantic&&/^</.test(n)){if(!/>$/.test(n))return;const r=Da(n.slice(0,-1),"\\");if((n.length-r.length)%2===0)return}else{const r=Nm(e[2],"()");if(r>-1){const l=(e[0].indexOf("!")===0?5:4)+e[1].length+r;e[2]=e[2].substring(0,r),e[0]=e[0].substring(0,l).trim(),e[3]=""}}let s=e[2],a="";if(this.options.pedantic){const r=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(s);r&&(s=r[1],a=r[3])}else a=e[3]?e[3].slice(1,-1):"";return s=s.trim(),/^</.test(s)&&(this.options.pedantic&&!/>$/.test(n)?s=s.slice(1):s=s.slice(1,-1)),Mu(e,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:a&&a.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){const s=(n[2]||n[1]).replace(/\s+/g," "),a=e[s.toLowerCase()];if(!a){const r=n[0].charAt(0);return{type:"text",raw:r,text:r}}return Mu(n,a,n[0],this.lexer)}}emStrong(t,e,n=""){let s=this.rules.inline.emStrongLDelim.exec(t);if(!s||s[3]&&n.match(/[\p{L}\p{N}]/u))return;if(!(s[1]||s[2]||"")||!n||this.rules.inline.punctuation.exec(n)){const r=[...s[0]].length-1;let o,l,c=r,h=0;const u=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,e=e.slice(-1*t.length+r);(s=u.exec(e))!=null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o)continue;if(l=[...o].length,s[3]||s[4]){c+=l;continue}else if((s[5]||s[6])&&r%3&&!((r+l)%3)){h+=l;continue}if(c-=l,c>0)continue;l=Math.min(l,l+c+h);const d=[...s[0]][0].length,f=t.slice(0,r+s.index+d+l);if(Math.min(r,l)%2){const _=f.slice(1,-1);return{type:"em",raw:f,text:_,tokens:this.lexer.inlineTokens(_)}}const g=f.slice(2,-2);return{type:"strong",raw:f,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(t){const e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(/\n/g," ");const s=/[^ ]/.test(n),a=/^ /.test(n)&&/ $/.test(n);return s&&a&&(n=n.substring(1,n.length-1)),n=Cn(n,!0),{type:"codespan",raw:e[0],text:n}}}br(t){const e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t){const e=this.rules.inline.del.exec(t);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(t){const e=this.rules.inline.autolink.exec(t);if(e){let n,s;return e[2]==="@"?(n=Cn(e[1]),s="mailto:"+n):(n=Cn(e[1]),s=n),{type:"link",raw:e[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(t){var n;let e;if(e=this.rules.inline.url.exec(t)){let s,a;if(e[2]==="@")s=Cn(e[0]),a="mailto:"+s;else{let r;do r=e[0],e[0]=((n=this.rules.inline._backpedal.exec(e[0]))==null?void 0:n[0])??"";while(r!==e[0]);s=Cn(e[0]),e[1]==="www."?a="http://"+e[0]:a=e[0]}return{type:"link",raw:e[0],text:s,href:a,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(t){const e=this.rules.inline.text.exec(t);if(e){let n;return this.lexer.state.inRawBlock?n=e[0]:n=Cn(e[0]),{type:"text",raw:e[0],text:n}}}}const Om=/^(?:[ \t]*(?:\n|$))+/,Fm=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,zm=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ur=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Bm=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,bf=/(?:[*+-]|\d{1,9}[.)])/,Sf=ve(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,bf).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),mh=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Hm=/^[^\n]+/,gh=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Vm=ve(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",gh).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Gm=ve(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,bf).getRegex(),zo="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",vh=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,$m=ve("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",vh).replace("tag",zo).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),wf=ve(mh).replace("hr",ur).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",zo).getRegex(),Wm=ve(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",wf).getRegex(),_h={blockquote:Wm,code:Fm,def:Vm,fences:zm,heading:Bm,hr:ur,html:$m,lheading:Sf,list:Gm,newline:Om,paragraph:wf,table:Za,text:Hm},bu=ve("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",ur).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",zo).getRegex(),Xm={..._h,table:bu,paragraph:ve(mh).replace("hr",ur).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",bu).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",zo).getRegex()},qm={..._h,html:ve(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",vh).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Za,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ve(mh).replace("hr",ur).replace("heading",` *#{1,6} *[^
26
+ ]`).replace("lheading",Sf).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Ef=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,jm=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Tf=/^( {2,}|\\)\n(?!\s*$)/,Ym=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,dr="\\p{P}\\p{S}",Km=ve(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,dr).getRegex(),Zm=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Jm=ve(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,dr).getRegex(),Qm=ve("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,dr).getRegex(),t0=ve("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,dr).getRegex(),e0=ve(/\\([punct])/,"gu").replace(/punct/g,dr).getRegex(),n0=ve(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),i0=ve(vh).replace("(?:-->|$)","-->").getRegex(),s0=ve("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",i0).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),wo=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,a0=ve(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",wo).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Af=ve(/^!?\[(label)\]\[(ref)\]/).replace("label",wo).replace("ref",gh).getRegex(),Cf=ve(/^!?\[(ref)\](?:\[\])?/).replace("ref",gh).getRegex(),r0=ve("reflink|nolink(?!\\()","g").replace("reflink",Af).replace("nolink",Cf).getRegex(),xh={_backpedal:Za,anyPunctuation:e0,autolink:n0,blockSkip:Zm,br:Tf,code:jm,del:Za,emStrongLDelim:Jm,emStrongRDelimAst:Qm,emStrongRDelimUnd:t0,escape:Ef,link:a0,nolink:Cf,punctuation:Km,reflink:Af,reflinkSearch:r0,tag:s0,text:Ym,url:Za},o0={...xh,link:ve(/^!?\[(label)\]\((.*?)\)/).replace("label",wo).getRegex(),reflink:ve(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",wo).getRegex()},uc={...xh,escape:ve(Ef).replace("])","~|])").getRegex(),url:ve(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},l0={...uc,br:ve(Tf).replace("{2,}","*").getRegex(),text:ve(uc.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},vr={normal:_h,gfm:Xm,pedantic:qm},Ia={normal:xh,gfm:uc,breaks:l0,pedantic:o0};class On{constructor(t){_e(this,"tokens");_e(this,"options");_e(this,"state");_e(this,"tokenizer");_e(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ds,this.options.tokenizer=this.options.tokenizer||new So,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const e={block:vr.normal,inline:Ia.normal};this.options.pedantic?(e.block=vr.pedantic,e.inline=Ia.pedantic):this.options.gfm&&(e.block=vr.gfm,this.options.breaks?e.inline=Ia.breaks:e.inline=Ia.gfm),this.tokenizer.rules=e}static get rules(){return{block:vr,inline:Ia}}static lex(t,e){return new On(e).lex(t)}static lexInline(t,e){return new On(e).inlineTokens(t)}lex(t){t=t.replace(/\r\n|\r/g,`
27
27
  `),this.blockTokens(t,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){const n=this.inlineQueue[e];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,e=[],n=!1){this.options.pedantic&&(t=t.replace(/\t/g," ").replace(/^ +$/gm,""));let s,a,r;for(;t;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(o=>(s=o.call({lexer:this},t,e))?(t=t.substring(s.raw.length),e.push(s),!0):!1))){if(s=this.tokenizer.space(t)){t=t.substring(s.raw.length),s.raw.length===1&&e.length>0?e[e.length-1].raw+=`
28
28
  `:e.push(s);continue}if(s=this.tokenizer.code(t)){t=t.substring(s.raw.length),a=e[e.length-1],a&&(a.type==="paragraph"||a.type==="text")?(a.raw+=`
29
29
  `+s.raw,a.text+=`
@@ -52,16 +52,16 @@ ${this.parser.parse(t)}</blockquote>
52
52
  ${t}</tr>
53
53
  `}tablecell(t){const e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
54
54
  `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${t}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){const s=this.parser.parseInline(n),a=xu(t);if(a===null)return s;t=a;let r='<a href="'+t+'"';return e&&(r+=' title="'+e+'"'),r+=">"+s+"</a>",r}image({href:t,title:e,text:n}){const s=xu(t);if(s===null)return n;t=s;let a=`<img src="${t}" alt="${n}"`;return e&&(a+=` title="${e}"`),a+=">",a}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):t.text}}class yh{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}}class Fn{constructor(t){_e(this,"options");_e(this,"renderer");_e(this,"textRenderer");this.options=t||Ds,this.options.renderer=this.options.renderer||new Eo,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new yh}static parse(t,e){return new Fn(e).parse(t)}static parseInline(t,e){return new Fn(e).parseInline(t)}parse(t,e=!0){let n="";for(let s=0;s<t.length;s++){const a=t[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){const o=a,l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(o.type)){n+=l||"";continue}}const r=a;switch(r.type){case"space":{n+=this.renderer.space(r);continue}case"hr":{n+=this.renderer.hr(r);continue}case"heading":{n+=this.renderer.heading(r);continue}case"code":{n+=this.renderer.code(r);continue}case"table":{n+=this.renderer.table(r);continue}case"blockquote":{n+=this.renderer.blockquote(r);continue}case"list":{n+=this.renderer.list(r);continue}case"html":{n+=this.renderer.html(r);continue}case"paragraph":{n+=this.renderer.paragraph(r);continue}case"text":{let o=r,l=this.renderer.text(o);for(;s+1<t.length&&t[s+1].type==="text";)o=t[++s],l+=`
55
- `+this.renderer.text(o);e?n+=this.renderer.paragraph({type:"paragraph",raw:l,text:l,tokens:[{type:"text",raw:l,text:l}]}):n+=l;continue}default:{const o='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(t,e){e=e||this.renderer;let n="";for(let s=0;s<t.length;s++){const a=t[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){const o=this.options.extensions.renderers[a.type].call({parser:this},a);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){n+=o||"";continue}}const r=a;switch(r.type){case"escape":{n+=e.text(r);break}case"html":{n+=e.html(r);break}case"link":{n+=e.link(r);break}case"image":{n+=e.image(r);break}case"strong":{n+=e.strong(r);break}case"em":{n+=e.em(r);break}case"codespan":{n+=e.codespan(r);break}case"br":{n+=e.br(r);break}case"del":{n+=e.del(r);break}case"text":{n+=e.text(r);break}default:{const o='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}}class Ja{constructor(t){_e(this,"options");_e(this,"block");this.options=t||Ds}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?On.lex:On.lexInline}provideParser(){return this.block?Fn.parse:Fn.parseInline}}_e(Ja,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class Pf{constructor(...t){_e(this,"defaults",ph());_e(this,"options",this.setOptions);_e(this,"parse",this.parseMarkdown(!0));_e(this,"parseInline",this.parseMarkdown(!1));_e(this,"Parser",Fn);_e(this,"Renderer",Eo);_e(this,"TextRenderer",yh);_e(this,"Lexer",On);_e(this,"Tokenizer",So);_e(this,"Hooks",Ja);this.use(...t)}walkTokens(t,e){var s,a;let n=[];for(const r of t)switch(n=n.concat(e.call(this,r)),r.type){case"table":{const o=r;for(const l of o.header)n=n.concat(this.walkTokens(l.tokens,e));for(const l of o.rows)for(const c of l)n=n.concat(this.walkTokens(c.tokens,e));break}case"list":{const o=r;n=n.concat(this.walkTokens(o.items,e));break}default:{const o=r;(a=(s=this.defaults.extensions)==null?void 0:s.childTokens)!=null&&a[o.type]?this.defaults.extensions.childTokens[o.type].forEach(l=>{const c=o[l].flat(1/0);n=n.concat(this.walkTokens(c,e))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,e)))}}return n}use(...t){const e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{const s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){const r=e.renderers[a.name];r?e.renderers[a.name]=function(...o){let l=a.renderer.apply(this,o);return l===!1&&(l=r.apply(this,o)),l}:e.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const r=e[a.level];r?r.unshift(a.tokenizer):e[a.level]=[a.tokenizer],a.start&&(a.level==="block"?e.startBlock?e.startBlock.push(a.start):e.startBlock=[a.start]:a.level==="inline"&&(e.startInline?e.startInline.push(a.start):e.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(e.childTokens[a.name]=a.childTokens)}),s.extensions=e),n.renderer){const a=this.defaults.renderer||new Eo(this.defaults);for(const r in n.renderer){if(!(r in a))throw new Error(`renderer '${r}' does not exist`);if(["options","parser"].includes(r))continue;const o=r,l=n.renderer[o],c=a[o];a[o]=(...h)=>{let u=l.apply(a,h);return u===!1&&(u=c.apply(a,h)),u||""}}s.renderer=a}if(n.tokenizer){const a=this.defaults.tokenizer||new So(this.defaults);for(const r in n.tokenizer){if(!(r in a))throw new Error(`tokenizer '${r}' does not exist`);if(["options","rules","lexer"].includes(r))continue;const o=r,l=n.tokenizer[o],c=a[o];a[o]=(...h)=>{let u=l.apply(a,h);return u===!1&&(u=c.apply(a,h)),u}}s.tokenizer=a}if(n.hooks){const a=this.defaults.hooks||new Ja;for(const r in n.hooks){if(!(r in a))throw new Error(`hook '${r}' does not exist`);if(["options","block"].includes(r))continue;const o=r,l=n.hooks[o],c=a[o];Ja.passThroughHooks.has(r)?a[o]=h=>{if(this.defaults.async)return Promise.resolve(l.call(a,h)).then(d=>c.call(a,d));const u=l.call(a,h);return c.call(a,u)}:a[o]=(...h)=>{let u=l.apply(a,h);return u===!1&&(u=c.apply(a,h)),u}}s.hooks=a}if(n.walkTokens){const a=this.defaults.walkTokens,r=n.walkTokens;s.walkTokens=function(o){let l=[];return l.push(r.call(this,o)),a&&(l=l.concat(a.call(this,o))),l}}this.defaults={...this.defaults,...s}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return On.lex(t,e??this.defaults)}parser(t,e){return Fn.parse(t,e??this.defaults)}parseMarkdown(t){return(n,s)=>{const a={...s},r={...this.defaults,...a},o=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&a.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));r.hooks&&(r.hooks.options=r,r.hooks.block=t);const l=r.hooks?r.hooks.provideLexer():t?On.lex:On.lexInline,c=r.hooks?r.hooks.provideParser():t?Fn.parse:Fn.parseInline;if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(h=>l(h,r)).then(h=>r.hooks?r.hooks.processAllTokens(h):h).then(h=>r.walkTokens?Promise.all(this.walkTokens(h,r.walkTokens)).then(()=>h):h).then(h=>c(h,r)).then(h=>r.hooks?r.hooks.postprocess(h):h).catch(o);try{r.hooks&&(n=r.hooks.preprocess(n));let h=l(n,r);r.hooks&&(h=r.hooks.processAllTokens(h)),r.walkTokens&&this.walkTokens(h,r.walkTokens);let u=c(h,r);return r.hooks&&(u=r.hooks.postprocess(u)),u}catch(h){return o(h)}}}onError(t,e){return n=>{if(n.message+=`
56
- Please report this to https://github.com/markedjs/marked.`,t){const s="<p>An error occurred:</p><pre>"+Cn(n.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(n);throw n}}}const Cs=new Pf;function ge(i,t){return Cs.parse(i,t)}ge.options=ge.setOptions=function(i){return Cs.setOptions(i),ge.defaults=Cs.defaults,yf(ge.defaults),ge};ge.getDefaults=ph;ge.defaults=Ds;ge.use=function(...i){return Cs.use(...i),ge.defaults=Cs.defaults,yf(ge.defaults),ge};ge.walkTokens=function(i,t){return Cs.walkTokens(i,t)};ge.parseInline=Cs.parseInline;ge.Parser=Fn;ge.parser=Fn.parse;ge.Renderer=Eo;ge.TextRenderer=yh;ge.Lexer=On;ge.lexer=On.lex;ge.Tokenizer=So;ge.Hooks=Ja;ge.parse=ge;ge.options;ge.setOptions;ge.use;ge.walkTokens;ge.parseInline;Fn.parse;On.lex;function c0(i){let t=String(i??"");if(t=t.replace(/```[\s\S]*?```/g," (code) ").replace(/~~~[\s\S]*?~~~/g," (code) ").replace(/`([^`]*)`/g,(n,s)=>/[\/\\]/.test(s)?" that file ":/^\W*$/.test(s)?" ":` ${s} `).replace(/!\[[^\]]*\]\([^)]*\)/g," ").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/https?:\/\/\S+/g," a link ").replace(/^\s{0,3}#{1,6}\s*/gm,"").replace(/^\s*>\s?/gm,"").replace(/^\s*[-*+]\s+/gm,", ").replace(/^\s*\d+\.\s+/gm,", ").replace(/(\*\*|__|\*|_|~~)/g,"").replace(/^\s*\|.*\|\s*$/gm," ").replace(/^\s*[-=:|]{3,}\s*$/gm," ").replace(/(?:\.{0,2}\/)?(?:[\w.-]+\/){1,}[\w.-]+(?::\d+)?/g," that file ").replace(/\b[\w-]+\.(?:js|ts|tsx|jsx|css|html|json|md|py|go|rs|sh|yml|yaml)\b(?::\d+)?/gi," that file ").replace(/[#*`_~>|]/g," ").replace(/\s*,\s*,+/g,", ").replace(/[ \t]+/g," ").replace(/\n{2,}/g,". ").replace(/\n/g," ").replace(/\s+([.,!?;:])/g,"$1").replace(/([:;,])[.,]+/g,"$1").replace(/([.!?])\s*,\s*/g,"$1 ").replace(/\.{2,}/g,".").replace(/\s{2,}/g," ").replace(/^[\s.,;:!?]+/,"").trim(),!/[a-z0-9]/i.test(t))return"";const e=460;if(t.length>e){const n=t.slice(0,e),s=Math.max(n.lastIndexOf(". "),n.lastIndexOf("! "),n.lastIndexOf("? "));t=s>160?n.slice(0,s+1):n.replace(/\s+\S*$/,"")+"…"}return t}const Su=(i,t)=>{try{if(t===void 0)return localStorage.getItem(i);localStorage.setItem(i,t)}catch{}return null},h0=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus",""],si={rec:null,stream:null,startedAt:0,get active(){return!!this.rec&&this.rec.state!=="inactive"},get supported(){var i;return typeof window<"u"&&!!((i=navigator.mediaDevices)!=null&&i.getUserMedia&&window.MediaRecorder)},async start(){if(this.active)return;this.stream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}});const i=h0.find(t=>!t||MediaRecorder.isTypeSupported(t));this.rec=new MediaRecorder(this.stream,i?{mimeType:i}:{}),this.chunks=[],this.rec.ondataavailable=t=>{t.data.size&&this.chunks.push(t.data)},this.rec.start(250),this.startedAt=Date.now()},stop(){return this.active?new Promise(i=>{this.rec.onstop=()=>{var n;const t=((n=this.rec.mimeType)==null?void 0:n.split(";")[0])||"audio/webm",e=this.chunks.length?new Blob(this.chunks,{type:t}):null;this.release(),i(e&&e.size>1200?e:null)},this.rec.stop()}):Promise.resolve(null)},cancel(){this.active&&(this.rec.onstop=null,this.rec.stop()),this.release()},release(){var i;(i=this.stream)==null||i.getTracks().forEach(t=>t.stop()),this.rec=null,this.stream=null,this.startedAt=0}};function u0(i){const t={"audio/webm":"webm","audio/mp4":"m4a","audio/ogg":"ogg","audio/wav":"wav"}[i.type]||"webm",e=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");return new File([i],`voice-note-${e}.${t}`,{type:i.type})}const wu={chief:["Moira","Fiona","Serena","Karen"],ada:["Samantha","Ava","Allison","Susan"],tunde:["Daniel","Oliver","Arthur","Alex"],mira:["Karen","Zoe","Tessa","Fiona"],kai:["Reed","Tom","Alex","Rocko"],zola:["Tessa","Nicky","Joelle","Samantha"],remi:["Rishi","Veena","Aman","Tara"],obi:["Flo","Eddy","Daniel","Reed"],lin:["Sandy","Shelley","Kathy","Moira"]},Eu=i=>{const t=`${i.voiceURI||""} ${i.name||""}`.toLowerCase();return t.includes("premium")?3:t.includes("enhanced")?2:t.includes("compact")?0:1};class d0{constructor(){this.on=Su("office.speak")==="1",this.voices=[],this.queue=[],this.saying=null;const t=typeof window<"u"&&window.speechSynthesis;if(!t)return;const e=()=>{this.voices=t.getVoices()||[]};e(),t.onvoiceschanged=e}get supported(){return typeof window<"u"&&!!window.speechSynthesis}setOn(t){this.on=t,Su("office.speak",t?"1":"0"),t||this.stop()}voiceFor(t){this.voices.length||(this.voices=window.speechSynthesis.getVoices()||[]);const e=this.voices.filter(r=>/^en\b/i.test(r.lang)||/^en[-_]/i.test(r.lang)),n=e.length?e:this.voices;for(const r of wu[t]||[]){const o=n.filter(l=>l.name.toLowerCase().startsWith(r.toLowerCase()));if(o.length)return o.sort((l,c)=>Eu(c)-Eu(l))[0]}const s=Object.keys(wu),a=Math.max(0,s.indexOf(t));return n[a%n.length]||null}speak(t,e="chief",{force:n=!1}={}){if(!this.supported||!this.on&&!n)return;const s=c0(t);s&&(this.queue.push({say:s,from:e}),this.next())}next(){if(this.saying||!this.queue.length)return;const{say:t,from:e}=this.queue.shift(),n=new SpeechSynthesisUtterance(t),s=this.voiceFor(e);s&&(n.voice=s,n.lang=s.lang),n.rate=1.05,n.pitch=e==="chief"?1:1.02,this.saying=n;const a=()=>{this.saying=null,this.next()};n.onend=a,n.onerror=a,window.speechSynthesis.speak(n)}stop(){this.queue=[],this.saying=null;try{window.speechSynthesis.cancel()}catch{}}get busy(){return!!this.saying||!!this.queue.length}}const hi=new d0;/**
55
+ `+this.renderer.text(o);e?n+=this.renderer.paragraph({type:"paragraph",raw:l,text:l,tokens:[{type:"text",raw:l,text:l}]}):n+=l;continue}default:{const o='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(t,e){e=e||this.renderer;let n="";for(let s=0;s<t.length;s++){const a=t[s];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[a.type]){const o=this.options.extensions.renderers[a.type].call({parser:this},a);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){n+=o||"";continue}}const r=a;switch(r.type){case"escape":{n+=e.text(r);break}case"html":{n+=e.html(r);break}case"link":{n+=e.link(r);break}case"image":{n+=e.image(r);break}case"strong":{n+=e.strong(r);break}case"em":{n+=e.em(r);break}case"codespan":{n+=e.codespan(r);break}case"br":{n+=e.br(r);break}case"del":{n+=e.del(r);break}case"text":{n+=e.text(r);break}default:{const o='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}}class Ja{constructor(t){_e(this,"options");_e(this,"block");this.options=t||Ds}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?On.lex:On.lexInline}provideParser(){return this.block?Fn.parse:Fn.parseInline}}_e(Ja,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));class Rf{constructor(...t){_e(this,"defaults",ph());_e(this,"options",this.setOptions);_e(this,"parse",this.parseMarkdown(!0));_e(this,"parseInline",this.parseMarkdown(!1));_e(this,"Parser",Fn);_e(this,"Renderer",Eo);_e(this,"TextRenderer",yh);_e(this,"Lexer",On);_e(this,"Tokenizer",So);_e(this,"Hooks",Ja);this.use(...t)}walkTokens(t,e){var s,a;let n=[];for(const r of t)switch(n=n.concat(e.call(this,r)),r.type){case"table":{const o=r;for(const l of o.header)n=n.concat(this.walkTokens(l.tokens,e));for(const l of o.rows)for(const c of l)n=n.concat(this.walkTokens(c.tokens,e));break}case"list":{const o=r;n=n.concat(this.walkTokens(o.items,e));break}default:{const o=r;(a=(s=this.defaults.extensions)==null?void 0:s.childTokens)!=null&&a[o.type]?this.defaults.extensions.childTokens[o.type].forEach(l=>{const c=o[l].flat(1/0);n=n.concat(this.walkTokens(c,e))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,e)))}}return n}use(...t){const e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{const s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){const r=e.renderers[a.name];r?e.renderers[a.name]=function(...o){let l=a.renderer.apply(this,o);return l===!1&&(l=r.apply(this,o)),l}:e.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const r=e[a.level];r?r.unshift(a.tokenizer):e[a.level]=[a.tokenizer],a.start&&(a.level==="block"?e.startBlock?e.startBlock.push(a.start):e.startBlock=[a.start]:a.level==="inline"&&(e.startInline?e.startInline.push(a.start):e.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(e.childTokens[a.name]=a.childTokens)}),s.extensions=e),n.renderer){const a=this.defaults.renderer||new Eo(this.defaults);for(const r in n.renderer){if(!(r in a))throw new Error(`renderer '${r}' does not exist`);if(["options","parser"].includes(r))continue;const o=r,l=n.renderer[o],c=a[o];a[o]=(...h)=>{let u=l.apply(a,h);return u===!1&&(u=c.apply(a,h)),u||""}}s.renderer=a}if(n.tokenizer){const a=this.defaults.tokenizer||new So(this.defaults);for(const r in n.tokenizer){if(!(r in a))throw new Error(`tokenizer '${r}' does not exist`);if(["options","rules","lexer"].includes(r))continue;const o=r,l=n.tokenizer[o],c=a[o];a[o]=(...h)=>{let u=l.apply(a,h);return u===!1&&(u=c.apply(a,h)),u}}s.tokenizer=a}if(n.hooks){const a=this.defaults.hooks||new Ja;for(const r in n.hooks){if(!(r in a))throw new Error(`hook '${r}' does not exist`);if(["options","block"].includes(r))continue;const o=r,l=n.hooks[o],c=a[o];Ja.passThroughHooks.has(r)?a[o]=h=>{if(this.defaults.async)return Promise.resolve(l.call(a,h)).then(d=>c.call(a,d));const u=l.call(a,h);return c.call(a,u)}:a[o]=(...h)=>{let u=l.apply(a,h);return u===!1&&(u=c.apply(a,h)),u}}s.hooks=a}if(n.walkTokens){const a=this.defaults.walkTokens,r=n.walkTokens;s.walkTokens=function(o){let l=[];return l.push(r.call(this,o)),a&&(l=l.concat(a.call(this,o))),l}}this.defaults={...this.defaults,...s}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return On.lex(t,e??this.defaults)}parser(t,e){return Fn.parse(t,e??this.defaults)}parseMarkdown(t){return(n,s)=>{const a={...s},r={...this.defaults,...a},o=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&a.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));r.hooks&&(r.hooks.options=r,r.hooks.block=t);const l=r.hooks?r.hooks.provideLexer():t?On.lex:On.lexInline,c=r.hooks?r.hooks.provideParser():t?Fn.parse:Fn.parseInline;if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(h=>l(h,r)).then(h=>r.hooks?r.hooks.processAllTokens(h):h).then(h=>r.walkTokens?Promise.all(this.walkTokens(h,r.walkTokens)).then(()=>h):h).then(h=>c(h,r)).then(h=>r.hooks?r.hooks.postprocess(h):h).catch(o);try{r.hooks&&(n=r.hooks.preprocess(n));let h=l(n,r);r.hooks&&(h=r.hooks.processAllTokens(h)),r.walkTokens&&this.walkTokens(h,r.walkTokens);let u=c(h,r);return r.hooks&&(u=r.hooks.postprocess(u)),u}catch(h){return o(h)}}}onError(t,e){return n=>{if(n.message+=`
56
+ Please report this to https://github.com/markedjs/marked.`,t){const s="<p>An error occurred:</p><pre>"+Cn(n.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(n);throw n}}}const Cs=new Rf;function ge(i,t){return Cs.parse(i,t)}ge.options=ge.setOptions=function(i){return Cs.setOptions(i),ge.defaults=Cs.defaults,xf(ge.defaults),ge};ge.getDefaults=ph;ge.defaults=Ds;ge.use=function(...i){return Cs.use(...i),ge.defaults=Cs.defaults,xf(ge.defaults),ge};ge.walkTokens=function(i,t){return Cs.walkTokens(i,t)};ge.parseInline=Cs.parseInline;ge.Parser=Fn;ge.parser=Fn.parse;ge.Renderer=Eo;ge.TextRenderer=yh;ge.Lexer=On;ge.lexer=On.lex;ge.Tokenizer=So;ge.Hooks=Ja;ge.parse=ge;ge.options;ge.setOptions;ge.use;ge.walkTokens;ge.parseInline;Fn.parse;On.lex;function c0(i){let t=String(i??"");if(t=t.replace(/```[\s\S]*?```/g," (code) ").replace(/~~~[\s\S]*?~~~/g," (code) ").replace(/`([^`]*)`/g,(n,s)=>/[\/\\]/.test(s)?" that file ":/^\W*$/.test(s)?" ":` ${s} `).replace(/!\[[^\]]*\]\([^)]*\)/g," ").replace(/\[([^\]]+)\]\([^)]*\)/g,"$1").replace(/https?:\/\/\S+/g," a link ").replace(/^\s{0,3}#{1,6}\s*/gm,"").replace(/^\s*>\s?/gm,"").replace(/^\s*[-*+]\s+/gm,", ").replace(/^\s*\d+\.\s+/gm,", ").replace(/(\*\*|__|\*|_|~~)/g,"").replace(/^\s*\|.*\|\s*$/gm," ").replace(/^\s*[-=:|]{3,}\s*$/gm," ").replace(/(?:\.{0,2}\/)?(?:[\w.-]+\/){1,}[\w.-]+(?::\d+)?/g," that file ").replace(/\b[\w-]+\.(?:js|ts|tsx|jsx|css|html|json|md|py|go|rs|sh|yml|yaml)\b(?::\d+)?/gi," that file ").replace(/[#*`_~>|]/g," ").replace(/\s*,\s*,+/g,", ").replace(/[ \t]+/g," ").replace(/\n{2,}/g,". ").replace(/\n/g," ").replace(/\s+([.,!?;:])/g,"$1").replace(/([:;,])[.,]+/g,"$1").replace(/([.!?])\s*,\s*/g,"$1 ").replace(/\.{2,}/g,".").replace(/\s{2,}/g," ").replace(/^[\s.,;:!?]+/,"").trim(),!/[a-z0-9]/i.test(t))return"";const e=460;if(t.length>e){const n=t.slice(0,e),s=Math.max(n.lastIndexOf(". "),n.lastIndexOf("! "),n.lastIndexOf("? "));t=s>160?n.slice(0,s+1):n.replace(/\s+\S*$/,"")+"…"}return t}const Su=(i,t)=>{try{if(t===void 0)return localStorage.getItem(i);localStorage.setItem(i,t)}catch{}return null},h0=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus",""],si={rec:null,stream:null,startedAt:0,get active(){return!!this.rec&&this.rec.state!=="inactive"},get supported(){var i;return typeof window<"u"&&!!((i=navigator.mediaDevices)!=null&&i.getUserMedia&&window.MediaRecorder)},async start(){if(this.active)return;this.stream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}});const i=h0.find(t=>!t||MediaRecorder.isTypeSupported(t));this.rec=new MediaRecorder(this.stream,i?{mimeType:i}:{}),this.chunks=[],this.rec.ondataavailable=t=>{t.data.size&&this.chunks.push(t.data)},this.rec.start(250),this.startedAt=Date.now()},stop(){return this.active?new Promise(i=>{this.rec.onstop=()=>{var n;const t=((n=this.rec.mimeType)==null?void 0:n.split(";")[0])||"audio/webm",e=this.chunks.length?new Blob(this.chunks,{type:t}):null;this.release(),i(e&&e.size>1200?e:null)},this.rec.stop()}):Promise.resolve(null)},cancel(){this.active&&(this.rec.onstop=null,this.rec.stop()),this.release()},release(){var i;(i=this.stream)==null||i.getTracks().forEach(t=>t.stop()),this.rec=null,this.stream=null,this.startedAt=0}};function u0(i){const t={"audio/webm":"webm","audio/mp4":"m4a","audio/ogg":"ogg","audio/wav":"wav"}[i.type]||"webm",e=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");return new File([i],`voice-note-${e}.${t}`,{type:i.type})}const wu={chief:["Moira","Fiona","Serena","Karen"],ada:["Samantha","Ava","Allison","Susan"],tunde:["Daniel","Oliver","Arthur","Alex"],mira:["Karen","Zoe","Tessa","Fiona"],kai:["Reed","Tom","Alex","Rocko"],zola:["Tessa","Nicky","Joelle","Samantha"],remi:["Rishi","Veena","Aman","Tara"],obi:["Flo","Eddy","Daniel","Reed"],lin:["Sandy","Shelley","Kathy","Moira"]},Eu=i=>{const t=`${i.voiceURI||""} ${i.name||""}`.toLowerCase();return t.includes("premium")?3:t.includes("enhanced")?2:t.includes("compact")?0:1};class d0{constructor(){this.on=Su("office.speak")==="1",this.voices=[],this.queue=[],this.saying=null;const t=typeof window<"u"&&window.speechSynthesis;if(!t)return;const e=()=>{this.voices=t.getVoices()||[]};e(),t.onvoiceschanged=e}get supported(){return typeof window<"u"&&!!window.speechSynthesis}setOn(t){this.on=t,Su("office.speak",t?"1":"0"),t||this.stop()}voiceFor(t){this.voices.length||(this.voices=window.speechSynthesis.getVoices()||[]);const e=this.voices.filter(r=>/^en\b/i.test(r.lang)||/^en[-_]/i.test(r.lang)),n=e.length?e:this.voices;for(const r of wu[t]||[]){const o=n.filter(l=>l.name.toLowerCase().startsWith(r.toLowerCase()));if(o.length)return o.sort((l,c)=>Eu(c)-Eu(l))[0]}const s=Object.keys(wu),a=Math.max(0,s.indexOf(t));return n[a%n.length]||null}speak(t,e="chief",{force:n=!1}={}){if(!this.supported||!this.on&&!n)return;const s=c0(t);s&&(this.queue.push({say:s,from:e}),this.next())}next(){if(this.saying||!this.queue.length)return;const{say:t,from:e}=this.queue.shift(),n=new SpeechSynthesisUtterance(t),s=this.voiceFor(e);s&&(n.voice=s,n.lang=s.lang),n.rate=1.05,n.pitch=e==="chief"?1:1.02,this.saying=n;const a=()=>{this.saying=null,this.next()};n.onend=a,n.onerror=a,window.speechSynthesis.speak(n)}stop(){this.queue=[],this.saying=null;try{window.speechSynthesis.cancel()}catch{}}get busy(){return!!this.saying||!!this.queue.length}}const hi=new d0;/**
57
57
  * @license
58
58
  * Copyright 2010-2024 Three.js Authors
59
59
  * SPDX-License-Identifier: MIT
60
- */const Mh="169",ki={ROTATE:0,DOLLY:1,PAN:2},rs={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},f0=0,Tu=1,p0=2,Lf=1,Df=2,Ai=3,cs=0,fn=1,ci=2,Je=0,va=1,dc=2,Au=3,Cu=4,If=5,Yn=100,m0=101,g0=102,v0=103,_0=104,qa=200,x0=201,y0=202,M0=203,fc=204,pc=205,mc=206,b0=207,gc=208,S0=209,w0=210,E0=211,T0=212,A0=213,C0=214,vc=0,_c=1,xc=2,ba=3,yc=4,Mc=5,bc=6,Sc=7,kf=0,R0=1,P0=2,os=0,Nf=1,Uf=2,Of=3,Ff=4,L0=5,zf=6,bh=7,Bf=300,Sa=301,wa=302,wc=303,Ec=304,Bo=306,Oi=1e3,bs=1001,Tc=1002,on=1003,D0=1004,_r=1005,Kn=1006,al=1007,Ss=1008,pi=1009,Hf=1010,Vf=1011,or=1012,Sh=1013,Rs=1014,Li=1015,Fi=1016,wh=1017,Eh=1018,Ps=1020,Gf=35902,$f=1021,Wf=1022,zn=1023,Xf=1024,qf=1025,_a=1026,Ls=1027,jf=1028,Th=1029,Yf=1030,Ah=1031,Ch=1033,ao=33776,ro=33777,oo=33778,lo=33779,Ac=35840,Cc=35841,Rc=35842,Pc=35843,Lc=36196,Dc=37492,Ic=37496,kc=37808,Nc=37809,Uc=37810,Oc=37811,Fc=37812,zc=37813,Bc=37814,Hc=37815,Vc=37816,Gc=37817,$c=37818,Wc=37819,Xc=37820,qc=37821,co=36492,jc=36494,Yc=36495,Kf=36283,Kc=36284,Zc=36285,Jc=36286,I0=3200,k0=3201,Rh=0,N0=1,ts="",Qe="srgb",us="srgb-linear",Ph="display-p3",Ho="display-p3-linear",To="linear",ye="srgb",Ao="rec709",Co="p3",Us=7680,Ru=519,U0=512,O0=513,F0=514,Zf=515,z0=516,B0=517,H0=518,V0=519,Pu=35044,Lu="300 es",Di=2e3,Ro=2001;class Is{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const s=this._listeners[t];if(s!==void 0){const a=s.indexOf(e);a!==-1&&s.splice(a,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const n=this._listeners[t.type];if(n!==void 0){t.target=this;const s=n.slice(0);for(let a=0,r=s.length;a<r;a++)s[a].call(this,t);t.target=null}}}const sn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Du=1234567;const Qa=Math.PI/180,lr=180/Math.PI;function Ra(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(sn[i&255]+sn[i>>8&255]+sn[i>>16&255]+sn[i>>24&255]+"-"+sn[t&255]+sn[t>>8&255]+"-"+sn[t>>16&15|64]+sn[t>>24&255]+"-"+sn[e&63|128]+sn[e>>8&255]+"-"+sn[e>>16&255]+sn[e>>24&255]+sn[n&255]+sn[n>>8&255]+sn[n>>16&255]+sn[n>>24&255]).toLowerCase()}function Ve(i,t,e){return Math.max(t,Math.min(e,i))}function Lh(i,t){return(i%t+t)%t}function G0(i,t,e,n,s){return n+(i-t)*(s-n)/(e-t)}function $0(i,t,e){return i!==t?(e-i)/(t-i):0}function tr(i,t,e){return(1-e)*i+e*t}function W0(i,t,e,n){return tr(i,t,1-Math.exp(-e*n))}function X0(i,t=1){return t-Math.abs(Lh(i,t*2)-t)}function q0(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function j0(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Y0(i,t){return i+Math.floor(Math.random()*(t-i+1))}function K0(i,t){return i+Math.random()*(t-i)}function Z0(i){return i*(.5-Math.random())}function J0(i){i!==void 0&&(Du=i);let t=Du+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Q0(i){return i*Qa}function tg(i){return i*lr}function eg(i){return(i&i-1)===0&&i!==0}function ng(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function ig(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function sg(i,t,e,n,s){const a=Math.cos,r=Math.sin,o=a(e/2),l=r(e/2),c=a((t+n)/2),h=r((t+n)/2),u=a((t-n)/2),d=r((t-n)/2),f=a((n-t)/2),g=r((n-t)/2);switch(s){case"XYX":i.set(o*h,l*u,l*d,o*c);break;case"YZY":i.set(l*d,o*h,l*u,o*c);break;case"ZXZ":i.set(l*u,l*d,o*h,o*c);break;case"XZX":i.set(o*h,l*g,l*f,o*c);break;case"YXY":i.set(l*f,o*h,l*g,o*c);break;case"ZYZ":i.set(l*g,l*f,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function sa(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function hn(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const aa={DEG2RAD:Qa,RAD2DEG:lr,generateUUID:Ra,clamp:Ve,euclideanModulo:Lh,mapLinear:G0,inverseLerp:$0,lerp:tr,damp:W0,pingpong:X0,smoothstep:q0,smootherstep:j0,randInt:Y0,randFloat:K0,randFloatSpread:Z0,seededRandom:J0,degToRad:Q0,radToDeg:tg,isPowerOfTwo:eg,ceilPowerOfTwo:ng,floorPowerOfTwo:ig,setQuaternionFromProperEuler:sg,normalize:hn,denormalize:sa};class lt{constructor(t=0,e=0){lt.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Ve(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),s=Math.sin(e),a=this.x-t.x,r=this.y-t.y;return this.x=a*n-r*s+t.x,this.y=a*s+r*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Yt{constructor(t,e,n,s,a,r,o,l,c){Yt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,s,a,r,o,l,c)}set(t,e,n,s,a,r,o,l,c){const h=this.elements;return h[0]=t,h[1]=s,h[2]=o,h[3]=e,h[4]=a,h[5]=l,h[6]=n,h[7]=r,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,a=this.elements,r=n[0],o=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],f=n[5],g=n[8],_=s[0],p=s[3],m=s[6],y=s[1],x=s[4],S=s[7],P=s[2],T=s[5],w=s[8];return a[0]=r*_+o*y+l*P,a[3]=r*p+o*x+l*T,a[6]=r*m+o*S+l*w,a[1]=c*_+h*y+u*P,a[4]=c*p+h*x+u*T,a[7]=c*m+h*S+u*w,a[2]=d*_+f*y+g*P,a[5]=d*p+f*x+g*T,a[8]=d*m+f*S+g*w,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],s=t[2],a=t[3],r=t[4],o=t[5],l=t[6],c=t[7],h=t[8];return e*r*h-e*o*c-n*a*h+n*o*l+s*a*c-s*r*l}invert(){const t=this.elements,e=t[0],n=t[1],s=t[2],a=t[3],r=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=h*r-o*c,d=o*l-h*a,f=c*a-r*l,g=e*u+n*d+s*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/g;return t[0]=u*_,t[1]=(s*c-h*n)*_,t[2]=(o*n-s*r)*_,t[3]=d*_,t[4]=(h*e-s*l)*_,t[5]=(s*a-o*e)*_,t[6]=f*_,t[7]=(n*l-c*e)*_,t[8]=(r*e-n*a)*_,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,a,r,o){const l=Math.cos(a),c=Math.sin(a);return this.set(n*l,n*c,-n*(l*r+c*o)+r+t,-s*c,s*l,-s*(-c*r+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(rl.makeScale(t,e)),this}rotate(t){return this.premultiply(rl.makeRotation(-t)),this}translate(t,e){return this.premultiply(rl.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let s=0;s<9;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const rl=new Yt;function Jf(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function Po(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function ag(){const i=Po("canvas");return i.style.display="block",i}const Iu={};function ho(i){i in Iu||(Iu[i]=!0,console.warn(i))}function rg(i,t,e){return new Promise(function(n,s){function a(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(a,e);break;default:n()}}setTimeout(a,e)})}function og(i){const t=i.elements;t[2]=.5*t[2]+.5*t[3],t[6]=.5*t[6]+.5*t[7],t[10]=.5*t[10]+.5*t[11],t[14]=.5*t[14]+.5*t[15]}function lg(i){const t=i.elements;t[11]===-1?(t[10]=-t[10]-1,t[14]=-t[14]):(t[10]=-t[10],t[14]=-t[14]+1)}const ku=new Yt().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Nu=new Yt().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),ka={[us]:{transfer:To,primaries:Ao,luminanceCoefficients:[.2126,.7152,.0722],toReference:i=>i,fromReference:i=>i},[Qe]:{transfer:ye,primaries:Ao,luminanceCoefficients:[.2126,.7152,.0722],toReference:i=>i.convertSRGBToLinear(),fromReference:i=>i.convertLinearToSRGB()},[Ho]:{transfer:To,primaries:Co,luminanceCoefficients:[.2289,.6917,.0793],toReference:i=>i.applyMatrix3(Nu),fromReference:i=>i.applyMatrix3(ku)},[Ph]:{transfer:ye,primaries:Co,luminanceCoefficients:[.2289,.6917,.0793],toReference:i=>i.convertSRGBToLinear().applyMatrix3(Nu),fromReference:i=>i.applyMatrix3(ku).convertLinearToSRGB()}},cg=new Set([us,Ho]),le={enabled:!0,_workingColorSpace:us,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(i){if(!cg.has(i))throw new Error(`Unsupported working color space, "${i}".`);this._workingColorSpace=i},convert:function(i,t,e){if(this.enabled===!1||t===e||!t||!e)return i;const n=ka[t].toReference,s=ka[e].fromReference;return s(n(i))},fromWorkingColorSpace:function(i,t){return this.convert(i,this._workingColorSpace,t)},toWorkingColorSpace:function(i,t){return this.convert(i,t,this._workingColorSpace)},getPrimaries:function(i){return ka[i].primaries},getTransfer:function(i){return i===ts?To:ka[i].transfer},getLuminanceCoefficients:function(i,t=this._workingColorSpace){return i.fromArray(ka[t].luminanceCoefficients)}};function xa(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function ol(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Os;class hg{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Os===void 0&&(Os=Po("canvas")),Os.width=t.width,Os.height=t.height;const n=Os.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Os}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Po("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const s=n.getImageData(0,0,t.width,t.height),a=s.data;for(let r=0;r<a.length;r++)a[r]=xa(a[r]/255)*255;return n.putImageData(s,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(xa(e[n]/255)*255):e[n]=xa(e[n]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let ug=0;class Qf{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:ug++}),this.uuid=Ra(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let a;if(Array.isArray(s)){a=[];for(let r=0,o=s.length;r<o;r++)s[r].isDataTexture?a.push(ll(s[r].image)):a.push(ll(s[r]))}else a=ll(s);n.url=a}return e||(t.images[this.uuid]=n),n}}function ll(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?hg.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let dg=0;class ln extends Is{constructor(t=ln.DEFAULT_IMAGE,e=ln.DEFAULT_MAPPING,n=bs,s=bs,a=Kn,r=Ss,o=zn,l=pi,c=ln.DEFAULT_ANISOTROPY,h=ts){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:dg++}),this.uuid=Ra(),this.name="",this.source=new Qf(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=a,this.minFilter=r,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new lt(0,0),this.repeat=new lt(1,1),this.center=new lt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Yt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Bf)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Oi:t.x=t.x-Math.floor(t.x);break;case bs:t.x=t.x<0?0:1;break;case Tc:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Oi:t.y=t.y-Math.floor(t.y);break;case bs:t.y=t.y<0?0:1;break;case Tc:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}ln.DEFAULT_IMAGE=null;ln.DEFAULT_MAPPING=Bf;ln.DEFAULT_ANISOTROPY=1;class me{constructor(t=0,e=0,n=0,s=1){me.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,s){return this.x=t,this.y=e,this.z=n,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,s=this.z,a=this.w,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*s+r[12]*a,this.y=r[1]*e+r[5]*n+r[9]*s+r[13]*a,this.z=r[2]*e+r[6]*n+r[10]*s+r[14]*a,this.w=r[3]*e+r[7]*n+r[11]*s+r[15]*a,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,s,a;const l=t.elements,c=l[0],h=l[4],u=l[8],d=l[1],f=l[5],g=l[9],_=l[2],p=l[6],m=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-_)<.01&&Math.abs(g-p)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+_)<.1&&Math.abs(g+p)<.1&&Math.abs(c+f+m-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const x=(c+1)/2,S=(f+1)/2,P=(m+1)/2,T=(h+d)/4,w=(u+_)/4,R=(g+p)/4;return x>S&&x>P?x<.01?(n=0,s=.707106781,a=.707106781):(n=Math.sqrt(x),s=T/n,a=w/n):S>P?S<.01?(n=.707106781,s=0,a=.707106781):(s=Math.sqrt(S),n=T/s,a=R/s):P<.01?(n=.707106781,s=.707106781,a=0):(a=Math.sqrt(P),n=w/a,s=R/a),this.set(n,s,a,e),this}let y=Math.sqrt((p-g)*(p-g)+(u-_)*(u-_)+(d-h)*(d-h));return Math.abs(y)<.001&&(y=1),this.x=(p-g)/y,this.y=(u-_)/y,this.z=(d-h)/y,this.w=Math.acos((c+f+m-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class fg extends Is{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new me(0,0,t,e),this.scissorTest=!1,this.viewport=new me(0,0,t,e);const s={width:t,height:e,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Kn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const a=new ln(s,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);a.flipY=!1,a.generateMipmaps=n.generateMipmaps,a.internalFormat=n.internalFormat,this.textures=[];const r=n.count;for(let o=0;o<r;o++)this.textures[o]=a.clone(),this.textures[o].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let s=0,a=this.textures.length;s<a;s++)this.textures[s].image.width=t,this.textures[s].image.height=e,this.textures[s].image.depth=n;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let n=0,s=t.textures.length;n<s;n++)this.textures[n]=t.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;const e=Object.assign({},t.texture.image);return this.texture.source=new Qf(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class ei extends fg{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class tp extends ln{constructor(t=null,e=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=on,this.minFilter=on,this.wrapR=bs,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class pg extends ln{constructor(t=null,e=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=on,this.minFilter=on,this.wrapR=bs,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class hs{constructor(t=0,e=0,n=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,a,r,o){let l=n[s+0],c=n[s+1],h=n[s+2],u=n[s+3];const d=a[r+0],f=a[r+1],g=a[r+2],_=a[r+3];if(o===0){t[e+0]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u;return}if(o===1){t[e+0]=d,t[e+1]=f,t[e+2]=g,t[e+3]=_;return}if(u!==_||l!==d||c!==f||h!==g){let p=1-o;const m=l*d+c*f+h*g+u*_,y=m>=0?1:-1,x=1-m*m;if(x>Number.EPSILON){const P=Math.sqrt(x),T=Math.atan2(P,m*y);p=Math.sin(p*T)/P,o=Math.sin(o*T)/P}const S=o*y;if(l=l*p+d*S,c=c*p+f*S,h=h*p+g*S,u=u*p+_*S,p===1-o){const P=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=P,c*=P,h*=P,u*=P}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,s,a,r){const o=n[s],l=n[s+1],c=n[s+2],h=n[s+3],u=a[r],d=a[r+1],f=a[r+2],g=a[r+3];return t[e]=o*g+h*u+l*f-c*d,t[e+1]=l*g+h*d+c*u-o*f,t[e+2]=c*g+h*f+o*d-l*u,t[e+3]=h*g-o*u-l*d-c*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,s){return this._x=t,this._y=e,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,s=t._y,a=t._z,r=t._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(s/2),u=o(a/2),d=l(n/2),f=l(s/2),g=l(a/2);switch(r){case"XYZ":this._x=d*h*u+c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u-d*f*g;break;case"YXZ":this._x=d*h*u+c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u+d*f*g;break;case"ZXY":this._x=d*h*u-c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u-d*f*g;break;case"ZYX":this._x=d*h*u-c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u+d*f*g;break;case"YZX":this._x=d*h*u+c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u-d*f*g;break;case"XZY":this._x=d*h*u-c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u+d*f*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],s=e[4],a=e[8],r=e[1],o=e[5],l=e[9],c=e[2],h=e[6],u=e[10],d=n+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-l)*f,this._y=(a-c)*f,this._z=(r-s)*f}else if(n>o&&n>u){const f=2*Math.sqrt(1+n-o-u);this._w=(h-l)/f,this._x=.25*f,this._y=(s+r)/f,this._z=(a+c)/f}else if(o>u){const f=2*Math.sqrt(1+o-n-u);this._w=(a-c)/f,this._x=(s+r)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(r-s)/f,this._x=(a+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Ve(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const s=Math.min(1,e/n);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,s=t._y,a=t._z,r=t._w,o=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+r*o+s*c-a*l,this._y=s*h+r*l+a*o-n*c,this._z=a*h+r*c+n*l-s*o,this._w=r*h-n*o-s*l-a*c,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const n=this._x,s=this._y,a=this._z,r=this._w;let o=r*t._w+n*t._x+s*t._y+a*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=r,this._x=n,this._y=s,this._z=a,this;const l=1-o*o;if(l<=Number.EPSILON){const f=1-e;return this._w=f*r+e*this._w,this._x=f*n+e*this._x,this._y=f*s+e*this._y,this._z=f*a+e*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,o),u=Math.sin((1-e)*h)/c,d=Math.sin(e*h)/c;return this._w=r*u+this._w*d,this._x=n*u+this._x*d,this._y=s*u+this._y*d,this._z=a*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),a=Math.sqrt(n);return this.set(s*Math.sin(t),s*Math.cos(t),a*Math.sin(e),a*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class C{constructor(t=0,e=0,n=0){C.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Uu.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Uu.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,s=this.z,a=t.elements;return this.x=a[0]*e+a[3]*n+a[6]*s,this.y=a[1]*e+a[4]*n+a[7]*s,this.z=a[2]*e+a[5]*n+a[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,s=this.z,a=t.elements,r=1/(a[3]*e+a[7]*n+a[11]*s+a[15]);return this.x=(a[0]*e+a[4]*n+a[8]*s+a[12])*r,this.y=(a[1]*e+a[5]*n+a[9]*s+a[13])*r,this.z=(a[2]*e+a[6]*n+a[10]*s+a[14])*r,this}applyQuaternion(t){const e=this.x,n=this.y,s=this.z,a=t.x,r=t.y,o=t.z,l=t.w,c=2*(r*s-o*n),h=2*(o*e-a*s),u=2*(a*n-r*e);return this.x=e+l*c+r*u-o*h,this.y=n+l*h+o*c-a*u,this.z=s+l*u+a*h-r*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,s=this.z,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*s,this.y=a[1]*e+a[5]*n+a[9]*s,this.z=a[2]*e+a[6]*n+a[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,s=t.y,a=t.z,r=e.x,o=e.y,l=e.z;return this.x=s*l-a*o,this.y=a*r-n*l,this.z=n*o-s*r,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return cl.copy(this).projectOnVector(t),this.sub(cl)}reflect(t){return this.sub(cl.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Ve(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const cl=new C,Uu=new hs;class fr{constructor(t=new C(1/0,1/0,1/0),e=new C(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint($n.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint($n.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=$n.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(n!==void 0){const a=n.getAttribute("position");if(e===!0&&a!==void 0&&t.isInstancedMesh!==!0)for(let r=0,o=a.count;r<o;r++)t.isMesh===!0?t.getVertexPosition(r,$n):$n.fromBufferAttribute(a,r),$n.applyMatrix4(t.matrixWorld),this.expandByPoint($n);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),xr.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),xr.copy(n.boundingBox)),xr.applyMatrix4(t.matrixWorld),this.union(xr)}const s=t.children;for(let a=0,r=s.length;a<r;a++)this.expandByObject(s[a],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,$n),$n.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Na),yr.subVectors(this.max,Na),Fs.subVectors(t.a,Na),zs.subVectors(t.b,Na),Bs.subVectors(t.c,Na),$i.subVectors(zs,Fs),Wi.subVectors(Bs,zs),fs.subVectors(Fs,Bs);let e=[0,-$i.z,$i.y,0,-Wi.z,Wi.y,0,-fs.z,fs.y,$i.z,0,-$i.x,Wi.z,0,-Wi.x,fs.z,0,-fs.x,-$i.y,$i.x,0,-Wi.y,Wi.x,0,-fs.y,fs.x,0];return!hl(e,Fs,zs,Bs,yr)||(e=[1,0,0,0,1,0,0,0,1],!hl(e,Fs,zs,Bs,yr))?!1:(Mr.crossVectors($i,Wi),e=[Mr.x,Mr.y,Mr.z],hl(e,Fs,zs,Bs,yr))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,$n).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize($n).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(yi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),yi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),yi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),yi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),yi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),yi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),yi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),yi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(yi),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const yi=[new C,new C,new C,new C,new C,new C,new C,new C],$n=new C,xr=new fr,Fs=new C,zs=new C,Bs=new C,$i=new C,Wi=new C,fs=new C,Na=new C,yr=new C,Mr=new C,ps=new C;function hl(i,t,e,n,s){for(let a=0,r=i.length-3;a<=r;a+=3){ps.fromArray(i,a);const o=s.x*Math.abs(ps.x)+s.y*Math.abs(ps.y)+s.z*Math.abs(ps.z),l=t.dot(ps),c=e.dot(ps),h=n.dot(ps);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const mg=new fr,Ua=new C,ul=new C;class Dh{constructor(t=new C,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;e!==void 0?n.copy(e):mg.setFromPoints(t).getCenter(n);let s=0;for(let a=0,r=t.length;a<r;a++)s=Math.max(s,n.distanceToSquared(t[a]));return this.radius=Math.sqrt(s),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Ua.subVectors(t,this.center);const e=Ua.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Ua,s/n),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(ul.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Ua.copy(t.center).add(ul)),this.expandByPoint(Ua.copy(t.center).sub(ul))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Mi=new C,dl=new C,br=new C,Xi=new C,fl=new C,Sr=new C,pl=new C;class Ih{constructor(t=new C,e=new C(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Mi)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Mi.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Mi.copy(this.origin).addScaledVector(this.direction,e),Mi.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){dl.copy(t).add(e).multiplyScalar(.5),br.copy(e).sub(t).normalize(),Xi.copy(this.origin).sub(dl);const a=t.distanceTo(e)*.5,r=-this.direction.dot(br),o=Xi.dot(this.direction),l=-Xi.dot(br),c=Xi.lengthSq(),h=Math.abs(1-r*r);let u,d,f,g;if(h>0)if(u=r*l-o,d=r*o-l,g=a*h,u>=0)if(d>=-g)if(d<=g){const _=1/h;u*=_,d*=_,f=u*(u+r*d+2*o)+d*(r*u+d+2*l)+c}else d=a,u=Math.max(0,-(r*d+o)),f=-u*u+d*(d+2*l)+c;else d=-a,u=Math.max(0,-(r*d+o)),f=-u*u+d*(d+2*l)+c;else d<=-g?(u=Math.max(0,-(-r*a+o)),d=u>0?-a:Math.min(Math.max(-a,-l),a),f=-u*u+d*(d+2*l)+c):d<=g?(u=0,d=Math.min(Math.max(-a,-l),a),f=d*(d+2*l)+c):(u=Math.max(0,-(r*a+o)),d=u>0?a:Math.min(Math.max(-a,-l),a),f=-u*u+d*(d+2*l)+c);else d=r>0?-a:a,u=Math.max(0,-(r*d+o)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(dl).addScaledVector(br,d),f}intersectSphere(t,e){Mi.subVectors(t.center,this.origin);const n=Mi.dot(this.direction),s=Mi.dot(Mi)-n*n,a=t.radius*t.radius;if(s>a)return null;const r=Math.sqrt(a-s),o=n-r,l=n+r;return l<0?null:o<0?this.at(l,e):this.at(o,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,s,a,r,o,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(t.min.x-d.x)*c,s=(t.max.x-d.x)*c):(n=(t.max.x-d.x)*c,s=(t.min.x-d.x)*c),h>=0?(a=(t.min.y-d.y)*h,r=(t.max.y-d.y)*h):(a=(t.max.y-d.y)*h,r=(t.min.y-d.y)*h),n>r||a>s||((a>n||isNaN(n))&&(n=a),(r<s||isNaN(s))&&(s=r),u>=0?(o=(t.min.z-d.z)*u,l=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,l=(t.min.z-d.z)*u),n>l||o>s)||((o>n||n!==n)&&(n=o),(l<s||s!==s)&&(s=l),s<0)?null:this.at(n>=0?n:s,e)}intersectsBox(t){return this.intersectBox(t,Mi)!==null}intersectTriangle(t,e,n,s,a){fl.subVectors(e,t),Sr.subVectors(n,t),pl.crossVectors(fl,Sr);let r=this.direction.dot(pl),o;if(r>0){if(s)return null;o=1}else if(r<0)o=-1,r=-r;else return null;Xi.subVectors(this.origin,t);const l=o*this.direction.dot(Sr.crossVectors(Xi,Sr));if(l<0)return null;const c=o*this.direction.dot(fl.cross(Xi));if(c<0||l+c>r)return null;const h=-o*Xi.dot(pl);return h<0?null:this.at(h/r,a)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class fe{constructor(t,e,n,s,a,r,o,l,c,h,u,d,f,g,_,p){fe.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,s,a,r,o,l,c,h,u,d,f,g,_,p)}set(t,e,n,s,a,r,o,l,c,h,u,d,f,g,_,p){const m=this.elements;return m[0]=t,m[4]=e,m[8]=n,m[12]=s,m[1]=a,m[5]=r,m[9]=o,m[13]=l,m[2]=c,m[6]=h,m[10]=u,m[14]=d,m[3]=f,m[7]=g,m[11]=_,m[15]=p,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new fe().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,s=1/Hs.setFromMatrixColumn(t,0).length(),a=1/Hs.setFromMatrixColumn(t,1).length(),r=1/Hs.setFromMatrixColumn(t,2).length();return e[0]=n[0]*s,e[1]=n[1]*s,e[2]=n[2]*s,e[3]=0,e[4]=n[4]*a,e[5]=n[5]*a,e[6]=n[6]*a,e[7]=0,e[8]=n[8]*r,e[9]=n[9]*r,e[10]=n[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,s=t.y,a=t.z,r=Math.cos(n),o=Math.sin(n),l=Math.cos(s),c=Math.sin(s),h=Math.cos(a),u=Math.sin(a);if(t.order==="XYZ"){const d=r*h,f=r*u,g=o*h,_=o*u;e[0]=l*h,e[4]=-l*u,e[8]=c,e[1]=f+g*c,e[5]=d-_*c,e[9]=-o*l,e[2]=_-d*c,e[6]=g+f*c,e[10]=r*l}else if(t.order==="YXZ"){const d=l*h,f=l*u,g=c*h,_=c*u;e[0]=d+_*o,e[4]=g*o-f,e[8]=r*c,e[1]=r*u,e[5]=r*h,e[9]=-o,e[2]=f*o-g,e[6]=_+d*o,e[10]=r*l}else if(t.order==="ZXY"){const d=l*h,f=l*u,g=c*h,_=c*u;e[0]=d-_*o,e[4]=-r*u,e[8]=g+f*o,e[1]=f+g*o,e[5]=r*h,e[9]=_-d*o,e[2]=-r*c,e[6]=o,e[10]=r*l}else if(t.order==="ZYX"){const d=r*h,f=r*u,g=o*h,_=o*u;e[0]=l*h,e[4]=g*c-f,e[8]=d*c+_,e[1]=l*u,e[5]=_*c+d,e[9]=f*c-g,e[2]=-c,e[6]=o*l,e[10]=r*l}else if(t.order==="YZX"){const d=r*l,f=r*c,g=o*l,_=o*c;e[0]=l*h,e[4]=_-d*u,e[8]=g*u+f,e[1]=u,e[5]=r*h,e[9]=-o*h,e[2]=-c*h,e[6]=f*u+g,e[10]=d-_*u}else if(t.order==="XZY"){const d=r*l,f=r*c,g=o*l,_=o*c;e[0]=l*h,e[4]=-u,e[8]=c*h,e[1]=d*u+_,e[5]=r*h,e[9]=f*u-g,e[2]=g*u-f,e[6]=o*h,e[10]=_*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(gg,t,vg)}lookAt(t,e,n){const s=this.elements;return wn.subVectors(t,e),wn.lengthSq()===0&&(wn.z=1),wn.normalize(),qi.crossVectors(n,wn),qi.lengthSq()===0&&(Math.abs(n.z)===1?wn.x+=1e-4:wn.z+=1e-4,wn.normalize(),qi.crossVectors(n,wn)),qi.normalize(),wr.crossVectors(wn,qi),s[0]=qi.x,s[4]=wr.x,s[8]=wn.x,s[1]=qi.y,s[5]=wr.y,s[9]=wn.y,s[2]=qi.z,s[6]=wr.z,s[10]=wn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,a=this.elements,r=n[0],o=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],f=n[13],g=n[2],_=n[6],p=n[10],m=n[14],y=n[3],x=n[7],S=n[11],P=n[15],T=s[0],w=s[4],R=s[8],k=s[12],v=s[1],b=s[5],N=s[9],F=s[13],$=s[2],W=s[6],z=s[10],nt=s[14],G=s[3],at=s[7],ht=s[11],mt=s[15];return a[0]=r*T+o*v+l*$+c*G,a[4]=r*w+o*b+l*W+c*at,a[8]=r*R+o*N+l*z+c*ht,a[12]=r*k+o*F+l*nt+c*mt,a[1]=h*T+u*v+d*$+f*G,a[5]=h*w+u*b+d*W+f*at,a[9]=h*R+u*N+d*z+f*ht,a[13]=h*k+u*F+d*nt+f*mt,a[2]=g*T+_*v+p*$+m*G,a[6]=g*w+_*b+p*W+m*at,a[10]=g*R+_*N+p*z+m*ht,a[14]=g*k+_*F+p*nt+m*mt,a[3]=y*T+x*v+S*$+P*G,a[7]=y*w+x*b+S*W+P*at,a[11]=y*R+x*N+S*z+P*ht,a[15]=y*k+x*F+S*nt+P*mt,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],s=t[8],a=t[12],r=t[1],o=t[5],l=t[9],c=t[13],h=t[2],u=t[6],d=t[10],f=t[14],g=t[3],_=t[7],p=t[11],m=t[15];return g*(+a*l*u-s*c*u-a*o*d+n*c*d+s*o*f-n*l*f)+_*(+e*l*f-e*c*d+a*r*d-s*r*f+s*c*h-a*l*h)+p*(+e*c*u-e*o*f-a*r*u+n*r*f+a*o*h-n*c*h)+m*(-s*o*h-e*l*u+e*o*d+s*r*u-n*r*d+n*l*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],s=t[2],a=t[3],r=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],f=t[11],g=t[12],_=t[13],p=t[14],m=t[15],y=u*p*c-_*d*c+_*l*f-o*p*f-u*l*m+o*d*m,x=g*d*c-h*p*c-g*l*f+r*p*f+h*l*m-r*d*m,S=h*_*c-g*u*c+g*o*f-r*_*f-h*o*m+r*u*m,P=g*u*l-h*_*l-g*o*d+r*_*d+h*o*p-r*u*p,T=e*y+n*x+s*S+a*P;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/T;return t[0]=y*w,t[1]=(_*d*a-u*p*a-_*s*f+n*p*f+u*s*m-n*d*m)*w,t[2]=(o*p*a-_*l*a+_*s*c-n*p*c-o*s*m+n*l*m)*w,t[3]=(u*l*a-o*d*a-u*s*c+n*d*c+o*s*f-n*l*f)*w,t[4]=x*w,t[5]=(h*p*a-g*d*a+g*s*f-e*p*f-h*s*m+e*d*m)*w,t[6]=(g*l*a-r*p*a-g*s*c+e*p*c+r*s*m-e*l*m)*w,t[7]=(r*d*a-h*l*a+h*s*c-e*d*c-r*s*f+e*l*f)*w,t[8]=S*w,t[9]=(g*u*a-h*_*a-g*n*f+e*_*f+h*n*m-e*u*m)*w,t[10]=(r*_*a-g*o*a+g*n*c-e*_*c-r*n*m+e*o*m)*w,t[11]=(h*o*a-r*u*a-h*n*c+e*u*c+r*n*f-e*o*f)*w,t[12]=P*w,t[13]=(h*_*s-g*u*s+g*n*d-e*_*d-h*n*p+e*u*p)*w,t[14]=(g*o*s-r*_*s-g*n*l+e*_*l+r*n*p-e*o*p)*w,t[15]=(r*u*s-h*o*s+h*n*l-e*u*l-r*n*d+e*o*d)*w,this}scale(t){const e=this.elements,n=t.x,s=t.y,a=t.z;return e[0]*=n,e[4]*=s,e[8]*=a,e[1]*=n,e[5]*=s,e[9]*=a,e[2]*=n,e[6]*=s,e[10]*=a,e[3]*=n,e[7]*=s,e[11]*=a,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,s))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),s=Math.sin(e),a=1-n,r=t.x,o=t.y,l=t.z,c=a*r,h=a*o;return this.set(c*r+n,c*o-s*l,c*l+s*o,0,c*o+s*l,h*o+n,h*l-s*r,0,c*l-s*o,h*l+s*r,a*l*l+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,s,a,r){return this.set(1,n,a,0,t,1,r,0,e,s,1,0,0,0,0,1),this}compose(t,e,n){const s=this.elements,a=e._x,r=e._y,o=e._z,l=e._w,c=a+a,h=r+r,u=o+o,d=a*c,f=a*h,g=a*u,_=r*h,p=r*u,m=o*u,y=l*c,x=l*h,S=l*u,P=n.x,T=n.y,w=n.z;return s[0]=(1-(_+m))*P,s[1]=(f+S)*P,s[2]=(g-x)*P,s[3]=0,s[4]=(f-S)*T,s[5]=(1-(d+m))*T,s[6]=(p+y)*T,s[7]=0,s[8]=(g+x)*w,s[9]=(p-y)*w,s[10]=(1-(d+_))*w,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,n){const s=this.elements;let a=Hs.set(s[0],s[1],s[2]).length();const r=Hs.set(s[4],s[5],s[6]).length(),o=Hs.set(s[8],s[9],s[10]).length();this.determinant()<0&&(a=-a),t.x=s[12],t.y=s[13],t.z=s[14],Wn.copy(this);const c=1/a,h=1/r,u=1/o;return Wn.elements[0]*=c,Wn.elements[1]*=c,Wn.elements[2]*=c,Wn.elements[4]*=h,Wn.elements[5]*=h,Wn.elements[6]*=h,Wn.elements[8]*=u,Wn.elements[9]*=u,Wn.elements[10]*=u,e.setFromRotationMatrix(Wn),n.x=a,n.y=r,n.z=o,this}makePerspective(t,e,n,s,a,r,o=Di){const l=this.elements,c=2*a/(e-t),h=2*a/(n-s),u=(e+t)/(e-t),d=(n+s)/(n-s);let f,g;if(o===Di)f=-(r+a)/(r-a),g=-2*r*a/(r-a);else if(o===Ro)f=-r/(r-a),g=-r*a/(r-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=h,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=f,l[14]=g,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,s,a,r,o=Di){const l=this.elements,c=1/(e-t),h=1/(n-s),u=1/(r-a),d=(e+t)*c,f=(n+s)*h;let g,_;if(o===Di)g=(r+a)*u,_=-2*u;else if(o===Ro)g=a*u,_=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-f,l[2]=0,l[6]=0,l[10]=_,l[14]=-g,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let s=0;s<16;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const Hs=new C,Wn=new fe,gg=new C(0,0,0),vg=new C(1,1,1),qi=new C,wr=new C,wn=new C,Ou=new fe,Fu=new hs;class mi{constructor(t=0,e=0,n=0,s=mi.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,s=this._order){return this._x=t,this._y=e,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const s=t.elements,a=s[0],r=s[4],o=s[8],l=s[1],c=s[5],h=s[9],u=s[2],d=s[6],f=s[10];switch(e){case"XYZ":this._y=Math.asin(Ve(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-r,a)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Ve(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,a),this._z=0);break;case"ZXY":this._x=Math.asin(Ve(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-r,c)):(this._y=0,this._z=Math.atan2(l,a));break;case"ZYX":this._y=Math.asin(-Ve(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,a)):(this._x=0,this._z=Math.atan2(-r,c));break;case"YZX":this._z=Math.asin(Ve(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,a)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-Ve(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-h,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Ou.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Ou,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Fu.setFromEuler(this),this.setFromQuaternion(Fu,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}mi.DEFAULT_ORDER="XYZ";class kh{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let _g=0;const zu=new C,Vs=new hs,bi=new fe,Er=new C,Oa=new C,xg=new C,yg=new hs,Bu=new C(1,0,0),Hu=new C(0,1,0),Vu=new C(0,0,1),Gu={type:"added"},Mg={type:"removed"},Gs={type:"childadded",child:null},ml={type:"childremoved",child:null};class nn extends Is{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:_g++}),this.uuid=Ra(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=nn.DEFAULT_UP.clone();const t=new C,e=new mi,n=new hs,s=new C(1,1,1);function a(){n.setFromEuler(e,!1)}function r(){e.setFromQuaternion(n,void 0,!1)}e._onChange(a),n._onChange(r),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new fe},normalMatrix:{value:new Yt}}),this.matrix=new fe,this.matrixWorld=new fe,this.matrixAutoUpdate=nn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=nn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new kh,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Vs.setFromAxisAngle(t,e),this.quaternion.multiply(Vs),this}rotateOnWorldAxis(t,e){return Vs.setFromAxisAngle(t,e),this.quaternion.premultiply(Vs),this}rotateX(t){return this.rotateOnAxis(Bu,t)}rotateY(t){return this.rotateOnAxis(Hu,t)}rotateZ(t){return this.rotateOnAxis(Vu,t)}translateOnAxis(t,e){return zu.copy(t).applyQuaternion(this.quaternion),this.position.add(zu.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Bu,t)}translateY(t){return this.translateOnAxis(Hu,t)}translateZ(t){return this.translateOnAxis(Vu,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(bi.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Er.copy(t):Er.set(t,e,n);const s=this.parent;this.updateWorldMatrix(!0,!1),Oa.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?bi.lookAt(Oa,Er,this.up):bi.lookAt(Er,Oa,this.up),this.quaternion.setFromRotationMatrix(bi),s&&(bi.extractRotation(s.matrixWorld),Vs.setFromRotationMatrix(bi),this.quaternion.premultiply(Vs.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Gu),Gs.child=t,this.dispatchEvent(Gs),Gs.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Mg),ml.child=t,this.dispatchEvent(ml),ml.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),bi.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),bi.multiply(t.parent.matrixWorld)),t.applyMatrix4(bi),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Gu),Gs.child=t,this.dispatchEvent(Gs),Gs.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,s=this.children.length;n<s;n++){const r=this.children[n].getObjectByProperty(t,e);if(r!==void 0)return r}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const s=this.children;for(let a=0,r=s.length;a<r;a++)s[a].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oa,t,xg),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oa,yg,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){const n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const s=this.children;for(let a=0,r=s.length;a<r;a++)s[a].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.visibility=this._visibility,s.active=this._active,s.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),this.boundingBox!==null&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()}));function a(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=a(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const u=l[c];a(t.shapes,u)}else a(t.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(t.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(a(t.materials,this.material[l]));s.material=o}else s.material=a(t.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];s.animations.push(a(t.animations,l))}}if(e){const o=r(t.geometries),l=r(t.materials),c=r(t.textures),h=r(t.images),u=r(t.shapes),d=r(t.skeletons),f=r(t.animations),g=r(t.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),g.length>0&&(n.nodes=g)}return n.object=s,n;function r(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const s=t.children[n];this.add(s.clone())}return this}}nn.DEFAULT_UP=new C(0,1,0);nn.DEFAULT_MATRIX_AUTO_UPDATE=!0;nn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Xn=new C,Si=new C,gl=new C,wi=new C,$s=new C,Ws=new C,$u=new C,vl=new C,_l=new C,xl=new C,yl=new me,Ml=new me,bl=new me;class Zn{constructor(t=new C,e=new C,n=new C){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,s){s.subVectors(n,e),Xn.subVectors(t,e),s.cross(Xn);const a=s.lengthSq();return a>0?s.multiplyScalar(1/Math.sqrt(a)):s.set(0,0,0)}static getBarycoord(t,e,n,s,a){Xn.subVectors(s,e),Si.subVectors(n,e),gl.subVectors(t,e);const r=Xn.dot(Xn),o=Xn.dot(Si),l=Xn.dot(gl),c=Si.dot(Si),h=Si.dot(gl),u=r*c-o*o;if(u===0)return a.set(0,0,0),null;const d=1/u,f=(c*l-o*h)*d,g=(r*h-o*l)*d;return a.set(1-f-g,g,f)}static containsPoint(t,e,n,s){return this.getBarycoord(t,e,n,s,wi)===null?!1:wi.x>=0&&wi.y>=0&&wi.x+wi.y<=1}static getInterpolation(t,e,n,s,a,r,o,l){return this.getBarycoord(t,e,n,s,wi)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(a,wi.x),l.addScaledVector(r,wi.y),l.addScaledVector(o,wi.z),l)}static getInterpolatedAttribute(t,e,n,s,a,r){return yl.setScalar(0),Ml.setScalar(0),bl.setScalar(0),yl.fromBufferAttribute(t,e),Ml.fromBufferAttribute(t,n),bl.fromBufferAttribute(t,s),r.setScalar(0),r.addScaledVector(yl,a.x),r.addScaledVector(Ml,a.y),r.addScaledVector(bl,a.z),r}static isFrontFacing(t,e,n,s){return Xn.subVectors(n,e),Si.subVectors(t,e),Xn.cross(Si).dot(s)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,s){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,n,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Xn.subVectors(this.c,this.b),Si.subVectors(this.a,this.b),Xn.cross(Si).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Zn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Zn.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,s,a){return Zn.getInterpolation(t,this.a,this.b,this.c,e,n,s,a)}containsPoint(t){return Zn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Zn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,s=this.b,a=this.c;let r,o;$s.subVectors(s,n),Ws.subVectors(a,n),vl.subVectors(t,n);const l=$s.dot(vl),c=Ws.dot(vl);if(l<=0&&c<=0)return e.copy(n);_l.subVectors(t,s);const h=$s.dot(_l),u=Ws.dot(_l);if(h>=0&&u<=h)return e.copy(s);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return r=l/(l-h),e.copy(n).addScaledVector($s,r);xl.subVectors(t,a);const f=$s.dot(xl),g=Ws.dot(xl);if(g>=0&&f<=g)return e.copy(a);const _=f*c-l*g;if(_<=0&&c>=0&&g<=0)return o=c/(c-g),e.copy(n).addScaledVector(Ws,o);const p=h*g-f*u;if(p<=0&&u-h>=0&&f-g>=0)return $u.subVectors(a,s),o=(u-h)/(u-h+(f-g)),e.copy(s).addScaledVector($u,o);const m=1/(p+_+d);return r=_*m,o=d*m,e.copy(n).addScaledVector($s,r).addScaledVector(Ws,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const ep={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ji={h:0,s:0,l:0},Tr={h:0,s:0,l:0};function Sl(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}class te{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Qe){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,le.toWorkingColorSpace(this,e),this}setRGB(t,e,n,s=le.workingColorSpace){return this.r=t,this.g=e,this.b=n,le.toWorkingColorSpace(this,s),this}setHSL(t,e,n,s=le.workingColorSpace){if(t=Lh(t,1),e=Ve(e,0,1),n=Ve(n,0,1),e===0)this.r=this.g=this.b=n;else{const a=n<=.5?n*(1+e):n+e-n*e,r=2*n-a;this.r=Sl(r,a,t+1/3),this.g=Sl(r,a,t),this.b=Sl(r,a,t-1/3)}return le.toWorkingColorSpace(this,s),this}setStyle(t,e=Qe){function n(a){a!==void 0&&parseFloat(a)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let a;const r=s[1],o=s[2];switch(r){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,e);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,e);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){const a=s[1],r=a.length;if(r===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,e);if(r===6)return this.setHex(parseInt(a,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Qe){const n=ep[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=xa(t.r),this.g=xa(t.g),this.b=xa(t.b),this}copyLinearToSRGB(t){return this.r=ol(t.r),this.g=ol(t.g),this.b=ol(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Qe){return le.fromWorkingColorSpace(an.copy(this),t),Math.round(Ve(an.r*255,0,255))*65536+Math.round(Ve(an.g*255,0,255))*256+Math.round(Ve(an.b*255,0,255))}getHexString(t=Qe){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=le.workingColorSpace){le.fromWorkingColorSpace(an.copy(this),e);const n=an.r,s=an.g,a=an.b,r=Math.max(n,s,a),o=Math.min(n,s,a);let l,c;const h=(o+r)/2;if(o===r)l=0,c=0;else{const u=r-o;switch(c=h<=.5?u/(r+o):u/(2-r-o),r){case n:l=(s-a)/u+(s<a?6:0);break;case s:l=(a-n)/u+2;break;case a:l=(n-s)/u+4;break}l/=6}return t.h=l,t.s=c,t.l=h,t}getRGB(t,e=le.workingColorSpace){return le.fromWorkingColorSpace(an.copy(this),e),t.r=an.r,t.g=an.g,t.b=an.b,t}getStyle(t=Qe){le.fromWorkingColorSpace(an.copy(this),t);const e=an.r,n=an.g,s=an.b;return t!==Qe?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(t,e,n){return this.getHSL(ji),this.setHSL(ji.h+t,ji.s+e,ji.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(ji),t.getHSL(Tr);const n=tr(ji.h,Tr.h,e),s=tr(ji.s,Tr.s,e),a=tr(ji.l,Tr.l,e);return this.setHSL(n,s,a),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,s=this.b,a=t.elements;return this.r=a[0]*e+a[3]*n+a[6]*s,this.g=a[1]*e+a[4]*n+a[7]*s,this.b=a[2]*e+a[5]*n+a[8]*s,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const an=new te;te.NAMES=ep;let bg=0;class Bi extends Is{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:bg++}),this.uuid=Ra(),this.name="",this.type="Material",this.blending=va,this.side=cs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=fc,this.blendDst=pc,this.blendEquation=Yn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new te(0,0,0),this.blendAlpha=0,this.depthFunc=ba,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Ru,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Us,this.stencilZFail=Us,this.stencilZPass=Us,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const s=this[e];if(s===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==va&&(n.blending=this.blending),this.side!==cs&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==fc&&(n.blendSrc=this.blendSrc),this.blendDst!==pc&&(n.blendDst=this.blendDst),this.blendEquation!==Yn&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==ba&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Ru&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Us&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Us&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Us&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(a){const r=[];for(const o in a){const l=a[o];delete l.metadata,r.push(l)}return r}if(e){const a=s(t.textures),r=s(t.images);a.length>0&&(n.textures=a),r.length>0&&(n.images=r)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const s=e.length;n=new Array(s);for(let a=0;a!==s;++a)n[a]=e[a].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class cn extends Bi{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new te(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new mi,this.combine=kf,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const ke=new C,Ar=new lt;class ui{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Pu,this.updateRanges=[],this.gpuType=Li,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let s=0,a=this.itemSize;s<a;s++)this.array[t+s]=e.array[n+s];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)Ar.fromBufferAttribute(this,e),Ar.applyMatrix3(t),this.setXY(e,Ar.x,Ar.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)ke.fromBufferAttribute(this,e),ke.applyMatrix3(t),this.setXYZ(e,ke.x,ke.y,ke.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)ke.fromBufferAttribute(this,e),ke.applyMatrix4(t),this.setXYZ(e,ke.x,ke.y,ke.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)ke.fromBufferAttribute(this,e),ke.applyNormalMatrix(t),this.setXYZ(e,ke.x,ke.y,ke.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)ke.fromBufferAttribute(this,e),ke.transformDirection(t),this.setXYZ(e,ke.x,ke.y,ke.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=sa(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=hn(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=sa(e,this.array)),e}setX(t,e){return this.normalized&&(e=hn(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=sa(e,this.array)),e}setY(t,e){return this.normalized&&(e=hn(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=sa(e,this.array)),e}setZ(t,e){return this.normalized&&(e=hn(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=sa(e,this.array)),e}setW(t,e){return this.normalized&&(e=hn(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=hn(e,this.array),n=hn(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,s){return t*=this.itemSize,this.normalized&&(e=hn(e,this.array),n=hn(n,this.array),s=hn(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this}setXYZW(t,e,n,s,a){return t*=this.itemSize,this.normalized&&(e=hn(e,this.array),n=hn(n,this.array),s=hn(s,this.array),a=hn(a,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this.array[t+3]=a,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==Pu&&(t.usage=this.usage),t}}class np extends ui{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class ip extends ui{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class ue extends ui{constructor(t,e,n){super(new Float32Array(t),e,n)}}let Sg=0;const kn=new fe,wl=new nn,Xs=new C,En=new fr,Fa=new fr,Xe=new C;class pn extends Is{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Sg++}),this.uuid=Ra(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(Jf(t)?ip:np)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const a=new Yt().getNormalMatrix(t);n.applyNormalMatrix(a),n.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return kn.makeRotationFromQuaternion(t),this.applyMatrix4(kn),this}rotateX(t){return kn.makeRotationX(t),this.applyMatrix4(kn),this}rotateY(t){return kn.makeRotationY(t),this.applyMatrix4(kn),this}rotateZ(t){return kn.makeRotationZ(t),this.applyMatrix4(kn),this}translate(t,e,n){return kn.makeTranslation(t,e,n),this.applyMatrix4(kn),this}scale(t,e,n){return kn.makeScale(t,e,n),this.applyMatrix4(kn),this}lookAt(t){return wl.lookAt(t),wl.updateMatrix(),this.applyMatrix4(wl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Xs).negate(),this.translate(Xs.x,Xs.y,Xs.z),this}setFromPoints(t){const e=[];for(let n=0,s=t.length;n<s;n++){const a=t[n];e.push(a.x,a.y,a.z||0)}return this.setAttribute("position",new ue(e,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new fr);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new C(-1/0,-1/0,-1/0),new C(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,s=e.length;n<s;n++){const a=e[n];En.setFromBufferAttribute(a),this.morphTargetsRelative?(Xe.addVectors(this.boundingBox.min,En.min),this.boundingBox.expandByPoint(Xe),Xe.addVectors(this.boundingBox.max,En.max),this.boundingBox.expandByPoint(Xe)):(this.boundingBox.expandByPoint(En.min),this.boundingBox.expandByPoint(En.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Dh);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new C,1/0);return}if(t){const n=this.boundingSphere.center;if(En.setFromBufferAttribute(t),e)for(let a=0,r=e.length;a<r;a++){const o=e[a];Fa.setFromBufferAttribute(o),this.morphTargetsRelative?(Xe.addVectors(En.min,Fa.min),En.expandByPoint(Xe),Xe.addVectors(En.max,Fa.max),En.expandByPoint(Xe)):(En.expandByPoint(Fa.min),En.expandByPoint(Fa.max))}En.getCenter(n);let s=0;for(let a=0,r=t.count;a<r;a++)Xe.fromBufferAttribute(t,a),s=Math.max(s,n.distanceToSquared(Xe));if(e)for(let a=0,r=e.length;a<r;a++){const o=e[a],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)Xe.fromBufferAttribute(o,c),l&&(Xs.fromBufferAttribute(t,c),Xe.add(Xs)),s=Math.max(s,n.distanceToSquared(Xe))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,s=e.normal,a=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ui(new Float32Array(4*n.count),4));const r=this.getAttribute("tangent"),o=[],l=[];for(let R=0;R<n.count;R++)o[R]=new C,l[R]=new C;const c=new C,h=new C,u=new C,d=new lt,f=new lt,g=new lt,_=new C,p=new C;function m(R,k,v){c.fromBufferAttribute(n,R),h.fromBufferAttribute(n,k),u.fromBufferAttribute(n,v),d.fromBufferAttribute(a,R),f.fromBufferAttribute(a,k),g.fromBufferAttribute(a,v),h.sub(c),u.sub(c),f.sub(d),g.sub(d);const b=1/(f.x*g.y-g.x*f.y);isFinite(b)&&(_.copy(h).multiplyScalar(g.y).addScaledVector(u,-f.y).multiplyScalar(b),p.copy(u).multiplyScalar(f.x).addScaledVector(h,-g.x).multiplyScalar(b),o[R].add(_),o[k].add(_),o[v].add(_),l[R].add(p),l[k].add(p),l[v].add(p))}let y=this.groups;y.length===0&&(y=[{start:0,count:t.count}]);for(let R=0,k=y.length;R<k;++R){const v=y[R],b=v.start,N=v.count;for(let F=b,$=b+N;F<$;F+=3)m(t.getX(F+0),t.getX(F+1),t.getX(F+2))}const x=new C,S=new C,P=new C,T=new C;function w(R){P.fromBufferAttribute(s,R),T.copy(P);const k=o[R];x.copy(k),x.sub(P.multiplyScalar(P.dot(k))).normalize(),S.crossVectors(T,k);const b=S.dot(l[R])<0?-1:1;r.setXYZW(R,x.x,x.y,x.z,b)}for(let R=0,k=y.length;R<k;++R){const v=y[R],b=v.start,N=v.count;for(let F=b,$=b+N;F<$;F+=3)w(t.getX(F+0)),w(t.getX(F+1)),w(t.getX(F+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new ui(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const s=new C,a=new C,r=new C,o=new C,l=new C,c=new C,h=new C,u=new C;if(t)for(let d=0,f=t.count;d<f;d+=3){const g=t.getX(d+0),_=t.getX(d+1),p=t.getX(d+2);s.fromBufferAttribute(e,g),a.fromBufferAttribute(e,_),r.fromBufferAttribute(e,p),h.subVectors(r,a),u.subVectors(s,a),h.cross(u),o.fromBufferAttribute(n,g),l.fromBufferAttribute(n,_),c.fromBufferAttribute(n,p),o.add(h),l.add(h),c.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(_,l.x,l.y,l.z),n.setXYZ(p,c.x,c.y,c.z)}else for(let d=0,f=e.count;d<f;d+=3)s.fromBufferAttribute(e,d+0),a.fromBufferAttribute(e,d+1),r.fromBufferAttribute(e,d+2),h.subVectors(r,a),u.subVectors(s,a),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)Xe.fromBufferAttribute(t,e),Xe.normalize(),t.setXYZ(e,Xe.x,Xe.y,Xe.z)}toNonIndexed(){function t(o,l){const c=o.array,h=o.itemSize,u=o.normalized,d=new c.constructor(l.length*h);let f=0,g=0;for(let _=0,p=l.length;_<p;_++){o.isInterleavedBufferAttribute?f=l[_]*o.data.stride+o.offset:f=l[_]*h;for(let m=0;m<h;m++)d[g++]=c[f++]}return new ui(d,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new pn,n=this.index.array,s=this.attributes;for(const o in s){const l=s[o],c=t(l,n);e.setAttribute(o,c)}const a=this.morphAttributes;for(const o in a){const l=[],c=a[o];for(let h=0,u=c.length;h<u;h++){const d=c[h],f=t(d,n);l.push(f)}e.morphAttributes[o]=l}e.morphTargetsRelative=this.morphTargetsRelative;const r=this.groups;for(let o=0,l=r.length;o<l;o++){const c=r[o];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const l in n){const c=n[l];t.data.attributes[l]=c.toJSON(t.data)}const s={};let a=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){const f=c[u];h.push(f.toJSON(t.data))}h.length>0&&(s[l]=h,a=!0)}a&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone(e));const s=t.attributes;for(const c in s){const h=s[c];this.setAttribute(c,h.clone(e))}const a=t.morphAttributes;for(const c in a){const h=[],u=a[c];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(e));this.morphAttributes[c]=h}this.morphTargetsRelative=t.morphTargetsRelative;const r=t.groups;for(let c=0,h=r.length;c<h;c++){const u=r[c];this.addGroup(u.start,u.count,u.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Wu=new fe,ms=new Ih,Cr=new Dh,Xu=new C,Rr=new C,Pr=new C,Lr=new C,El=new C,Dr=new C,qu=new C,Ir=new C;class yt extends nn{constructor(t=new pn,e=new cn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,r=s.length;a<r;a++){const o=s[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(t,e){const n=this.geometry,s=n.attributes.position,a=n.morphAttributes.position,r=n.morphTargetsRelative;e.fromBufferAttribute(s,t);const o=this.morphTargetInfluences;if(a&&o){Dr.set(0,0,0);for(let l=0,c=a.length;l<c;l++){const h=o[l],u=a[l];h!==0&&(El.fromBufferAttribute(u,t),r?Dr.addScaledVector(El,h):Dr.addScaledVector(El.sub(e),h))}e.add(Dr)}return e}raycast(t,e){const n=this.geometry,s=this.material,a=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Cr.copy(n.boundingSphere),Cr.applyMatrix4(a),ms.copy(t.ray).recast(t.near),!(Cr.containsPoint(ms.origin)===!1&&(ms.intersectSphere(Cr,Xu)===null||ms.origin.distanceToSquared(Xu)>(t.far-t.near)**2))&&(Wu.copy(a).invert(),ms.copy(t.ray).applyMatrix4(Wu),!(n.boundingBox!==null&&ms.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,ms)))}_computeIntersections(t,e,n){let s;const a=this.geometry,r=this.material,o=a.index,l=a.attributes.position,c=a.attributes.uv,h=a.attributes.uv1,u=a.attributes.normal,d=a.groups,f=a.drawRange;if(o!==null)if(Array.isArray(r))for(let g=0,_=d.length;g<_;g++){const p=d[g],m=r[p.materialIndex],y=Math.max(p.start,f.start),x=Math.min(o.count,Math.min(p.start+p.count,f.start+f.count));for(let S=y,P=x;S<P;S+=3){const T=o.getX(S),w=o.getX(S+1),R=o.getX(S+2);s=kr(this,m,t,n,c,h,u,T,w,R),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=p.materialIndex,e.push(s))}}else{const g=Math.max(0,f.start),_=Math.min(o.count,f.start+f.count);for(let p=g,m=_;p<m;p+=3){const y=o.getX(p),x=o.getX(p+1),S=o.getX(p+2);s=kr(this,r,t,n,c,h,u,y,x,S),s&&(s.faceIndex=Math.floor(p/3),e.push(s))}}else if(l!==void 0)if(Array.isArray(r))for(let g=0,_=d.length;g<_;g++){const p=d[g],m=r[p.materialIndex],y=Math.max(p.start,f.start),x=Math.min(l.count,Math.min(p.start+p.count,f.start+f.count));for(let S=y,P=x;S<P;S+=3){const T=S,w=S+1,R=S+2;s=kr(this,m,t,n,c,h,u,T,w,R),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=p.materialIndex,e.push(s))}}else{const g=Math.max(0,f.start),_=Math.min(l.count,f.start+f.count);for(let p=g,m=_;p<m;p+=3){const y=p,x=p+1,S=p+2;s=kr(this,r,t,n,c,h,u,y,x,S),s&&(s.faceIndex=Math.floor(p/3),e.push(s))}}}}function wg(i,t,e,n,s,a,r,o){let l;if(t.side===fn?l=n.intersectTriangle(r,a,s,!0,o):l=n.intersectTriangle(s,a,r,t.side===cs,o),l===null)return null;Ir.copy(o),Ir.applyMatrix4(i.matrixWorld);const c=e.ray.origin.distanceTo(Ir);return c<e.near||c>e.far?null:{distance:c,point:Ir.clone(),object:i}}function kr(i,t,e,n,s,a,r,o,l,c){i.getVertexPosition(o,Rr),i.getVertexPosition(l,Pr),i.getVertexPosition(c,Lr);const h=wg(i,t,e,n,Rr,Pr,Lr,qu);if(h){const u=new C;Zn.getBarycoord(qu,Rr,Pr,Lr,u),s&&(h.uv=Zn.getInterpolatedAttribute(s,o,l,c,u,new lt)),a&&(h.uv1=Zn.getInterpolatedAttribute(a,o,l,c,u,new lt)),r&&(h.normal=Zn.getInterpolatedAttribute(r,o,l,c,u,new C),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new C,materialIndex:0};Zn.getNormal(Rr,Pr,Lr,d.normal),h.face=d,h.barycoord=u}return h}class Ye extends pn{constructor(t=1,e=1,n=1,s=1,a=1,r=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:s,heightSegments:a,depthSegments:r};const o=this;s=Math.floor(s),a=Math.floor(a),r=Math.floor(r);const l=[],c=[],h=[],u=[];let d=0,f=0;g("z","y","x",-1,-1,n,e,t,r,a,0),g("z","y","x",1,-1,n,e,-t,r,a,1),g("x","z","y",1,1,t,n,e,s,r,2),g("x","z","y",1,-1,t,n,-e,s,r,3),g("x","y","z",1,-1,t,e,n,s,a,4),g("x","y","z",-1,-1,t,e,-n,s,a,5),this.setIndex(l),this.setAttribute("position",new ue(c,3)),this.setAttribute("normal",new ue(h,3)),this.setAttribute("uv",new ue(u,2));function g(_,p,m,y,x,S,P,T,w,R,k){const v=S/w,b=P/R,N=S/2,F=P/2,$=T/2,W=w+1,z=R+1;let nt=0,G=0;const at=new C;for(let ht=0;ht<z;ht++){const mt=ht*b-F;for(let Xt=0;Xt<W;Xt++){const qt=Xt*v-N;at[_]=qt*y,at[p]=mt*x,at[m]=$,c.push(at.x,at.y,at.z),at[_]=0,at[p]=0,at[m]=T>0?1:-1,h.push(at.x,at.y,at.z),u.push(Xt/w),u.push(1-ht/R),nt+=1}}for(let ht=0;ht<R;ht++)for(let mt=0;mt<w;mt++){const Xt=d+mt+W*ht,qt=d+mt+W*(ht+1),q=d+(mt+1)+W*(ht+1),st=d+(mt+1)+W*ht;l.push(Xt,qt,st),l.push(qt,q,st),G+=6}o.addGroup(f,G,k),f+=G,d+=nt}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ye(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function Ea(i){const t={};for(const e in i){t[e]={};for(const n in i[e]){const s=i[e][n];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=s.clone():Array.isArray(s)?t[e][n]=s.slice():t[e][n]=s}}return t}function un(i){const t={};for(let e=0;e<i.length;e++){const n=Ea(i[e]);for(const s in n)t[s]=n[s]}return t}function Eg(i){const t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function sp(i){const t=i.getRenderTarget();return t===null?i.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:le.workingColorSpace}const es={clone:Ea,merge:un};var Tg=`void main() {
60
+ */const Mh="169",ki={ROTATE:0,DOLLY:1,PAN:2},rs={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},f0=0,Tu=1,p0=2,Pf=1,Lf=2,Ai=3,cs=0,fn=1,ci=2,Je=0,va=1,dc=2,Au=3,Cu=4,Df=5,Yn=100,m0=101,g0=102,v0=103,_0=104,qa=200,x0=201,y0=202,M0=203,fc=204,pc=205,mc=206,b0=207,gc=208,S0=209,w0=210,E0=211,T0=212,A0=213,C0=214,vc=0,_c=1,xc=2,ba=3,yc=4,Mc=5,bc=6,Sc=7,If=0,R0=1,P0=2,os=0,kf=1,Nf=2,Uf=3,Of=4,L0=5,Ff=6,bh=7,zf=300,Sa=301,wa=302,wc=303,Ec=304,Bo=306,Oi=1e3,bs=1001,Tc=1002,rn=1003,D0=1004,_r=1005,Kn=1006,al=1007,Ss=1008,pi=1009,Bf=1010,Hf=1011,or=1012,Sh=1013,Rs=1014,Li=1015,Fi=1016,wh=1017,Eh=1018,Ps=1020,Vf=35902,Gf=1021,$f=1022,zn=1023,Wf=1024,Xf=1025,_a=1026,Ls=1027,qf=1028,Th=1029,jf=1030,Ah=1031,Ch=1033,ao=33776,ro=33777,oo=33778,lo=33779,Ac=35840,Cc=35841,Rc=35842,Pc=35843,Lc=36196,Dc=37492,Ic=37496,kc=37808,Nc=37809,Uc=37810,Oc=37811,Fc=37812,zc=37813,Bc=37814,Hc=37815,Vc=37816,Gc=37817,$c=37818,Wc=37819,Xc=37820,qc=37821,co=36492,jc=36494,Yc=36495,Yf=36283,Kc=36284,Zc=36285,Jc=36286,I0=3200,k0=3201,Rh=0,N0=1,ts="",Qe="srgb",us="srgb-linear",Ph="display-p3",Ho="display-p3-linear",To="linear",ye="srgb",Ao="rec709",Co="p3",Us=7680,Ru=519,U0=512,O0=513,F0=514,Kf=515,z0=516,B0=517,H0=518,V0=519,Pu=35044,Lu="300 es",Di=2e3,Ro=2001;class Is{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const s=this._listeners[t];if(s!==void 0){const a=s.indexOf(e);a!==-1&&s.splice(a,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const n=this._listeners[t.type];if(n!==void 0){t.target=this;const s=n.slice(0);for(let a=0,r=s.length;a<r;a++)s[a].call(this,t);t.target=null}}}const nn=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Du=1234567;const Qa=Math.PI/180,lr=180/Math.PI;function Ra(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(nn[i&255]+nn[i>>8&255]+nn[i>>16&255]+nn[i>>24&255]+"-"+nn[t&255]+nn[t>>8&255]+"-"+nn[t>>16&15|64]+nn[t>>24&255]+"-"+nn[e&63|128]+nn[e>>8&255]+"-"+nn[e>>16&255]+nn[e>>24&255]+nn[n&255]+nn[n>>8&255]+nn[n>>16&255]+nn[n>>24&255]).toLowerCase()}function He(i,t,e){return Math.max(t,Math.min(e,i))}function Lh(i,t){return(i%t+t)%t}function G0(i,t,e,n,s){return n+(i-t)*(s-n)/(e-t)}function $0(i,t,e){return i!==t?(e-i)/(t-i):0}function tr(i,t,e){return(1-e)*i+e*t}function W0(i,t,e,n){return tr(i,t,1-Math.exp(-e*n))}function X0(i,t=1){return t-Math.abs(Lh(i,t*2)-t)}function q0(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function j0(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function Y0(i,t){return i+Math.floor(Math.random()*(t-i+1))}function K0(i,t){return i+Math.random()*(t-i)}function Z0(i){return i*(.5-Math.random())}function J0(i){i!==void 0&&(Du=i);let t=Du+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Q0(i){return i*Qa}function tg(i){return i*lr}function eg(i){return(i&i-1)===0&&i!==0}function ng(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function ig(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function sg(i,t,e,n,s){const a=Math.cos,r=Math.sin,o=a(e/2),l=r(e/2),c=a((t+n)/2),h=r((t+n)/2),u=a((t-n)/2),d=r((t-n)/2),f=a((n-t)/2),g=r((n-t)/2);switch(s){case"XYX":i.set(o*h,l*u,l*d,o*c);break;case"YZY":i.set(l*d,o*h,l*u,o*c);break;case"ZXZ":i.set(l*u,l*d,o*h,o*c);break;case"XZX":i.set(o*h,l*g,l*f,o*c);break;case"YXY":i.set(l*f,o*h,l*g,o*c);break;case"ZYZ":i.set(l*g,l*f,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+s)}}function sa(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function cn(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const aa={DEG2RAD:Qa,RAD2DEG:lr,generateUUID:Ra,clamp:He,euclideanModulo:Lh,mapLinear:G0,inverseLerp:$0,lerp:tr,damp:W0,pingpong:X0,smoothstep:q0,smootherstep:j0,randInt:Y0,randFloat:K0,randFloatSpread:Z0,seededRandom:J0,degToRad:Q0,radToDeg:tg,isPowerOfTwo:eg,ceilPowerOfTwo:ng,floorPowerOfTwo:ig,setQuaternionFromProperEuler:sg,normalize:cn,denormalize:sa};class lt{constructor(t=0,e=0){lt.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(He(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),s=Math.sin(e),a=this.x-t.x,r=this.y-t.y;return this.x=a*n-r*s+t.x,this.y=a*s+r*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Yt{constructor(t,e,n,s,a,r,o,l,c){Yt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,s,a,r,o,l,c)}set(t,e,n,s,a,r,o,l,c){const h=this.elements;return h[0]=t,h[1]=s,h[2]=o,h[3]=e,h[4]=a,h[5]=l,h[6]=n,h[7]=r,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,a=this.elements,r=n[0],o=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],f=n[5],g=n[8],_=s[0],p=s[3],m=s[6],y=s[1],x=s[4],S=s[7],P=s[2],T=s[5],w=s[8];return a[0]=r*_+o*y+l*P,a[3]=r*p+o*x+l*T,a[6]=r*m+o*S+l*w,a[1]=c*_+h*y+u*P,a[4]=c*p+h*x+u*T,a[7]=c*m+h*S+u*w,a[2]=d*_+f*y+g*P,a[5]=d*p+f*x+g*T,a[8]=d*m+f*S+g*w,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],s=t[2],a=t[3],r=t[4],o=t[5],l=t[6],c=t[7],h=t[8];return e*r*h-e*o*c-n*a*h+n*o*l+s*a*c-s*r*l}invert(){const t=this.elements,e=t[0],n=t[1],s=t[2],a=t[3],r=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=h*r-o*c,d=o*l-h*a,f=c*a-r*l,g=e*u+n*d+s*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/g;return t[0]=u*_,t[1]=(s*c-h*n)*_,t[2]=(o*n-s*r)*_,t[3]=d*_,t[4]=(h*e-s*l)*_,t[5]=(s*a-o*e)*_,t[6]=f*_,t[7]=(n*l-c*e)*_,t[8]=(r*e-n*a)*_,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,a,r,o){const l=Math.cos(a),c=Math.sin(a);return this.set(n*l,n*c,-n*(l*r+c*o)+r+t,-s*c,s*l,-s*(-c*r+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(rl.makeScale(t,e)),this}rotate(t){return this.premultiply(rl.makeRotation(-t)),this}translate(t,e){return this.premultiply(rl.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let s=0;s<9;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const rl=new Yt;function Zf(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function Po(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function ag(){const i=Po("canvas");return i.style.display="block",i}const Iu={};function ho(i){i in Iu||(Iu[i]=!0,console.warn(i))}function rg(i,t,e){return new Promise(function(n,s){function a(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(a,e);break;default:n()}}setTimeout(a,e)})}function og(i){const t=i.elements;t[2]=.5*t[2]+.5*t[3],t[6]=.5*t[6]+.5*t[7],t[10]=.5*t[10]+.5*t[11],t[14]=.5*t[14]+.5*t[15]}function lg(i){const t=i.elements;t[11]===-1?(t[10]=-t[10]-1,t[14]=-t[14]):(t[10]=-t[10],t[14]=-t[14]+1)}const ku=new Yt().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Nu=new Yt().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),ka={[us]:{transfer:To,primaries:Ao,luminanceCoefficients:[.2126,.7152,.0722],toReference:i=>i,fromReference:i=>i},[Qe]:{transfer:ye,primaries:Ao,luminanceCoefficients:[.2126,.7152,.0722],toReference:i=>i.convertSRGBToLinear(),fromReference:i=>i.convertLinearToSRGB()},[Ho]:{transfer:To,primaries:Co,luminanceCoefficients:[.2289,.6917,.0793],toReference:i=>i.applyMatrix3(Nu),fromReference:i=>i.applyMatrix3(ku)},[Ph]:{transfer:ye,primaries:Co,luminanceCoefficients:[.2289,.6917,.0793],toReference:i=>i.convertSRGBToLinear().applyMatrix3(Nu),fromReference:i=>i.applyMatrix3(ku).convertLinearToSRGB()}},cg=new Set([us,Ho]),le={enabled:!0,_workingColorSpace:us,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(i){if(!cg.has(i))throw new Error(`Unsupported working color space, "${i}".`);this._workingColorSpace=i},convert:function(i,t,e){if(this.enabled===!1||t===e||!t||!e)return i;const n=ka[t].toReference,s=ka[e].fromReference;return s(n(i))},fromWorkingColorSpace:function(i,t){return this.convert(i,this._workingColorSpace,t)},toWorkingColorSpace:function(i,t){return this.convert(i,t,this._workingColorSpace)},getPrimaries:function(i){return ka[i].primaries},getTransfer:function(i){return i===ts?To:ka[i].transfer},getLuminanceCoefficients:function(i,t=this._workingColorSpace){return i.fromArray(ka[t].luminanceCoefficients)}};function xa(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function ol(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Os;class hg{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Os===void 0&&(Os=Po("canvas")),Os.width=t.width,Os.height=t.height;const n=Os.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Os}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Po("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const s=n.getImageData(0,0,t.width,t.height),a=s.data;for(let r=0;r<a.length;r++)a[r]=xa(a[r]/255)*255;return n.putImageData(s,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(xa(e[n]/255)*255):e[n]=xa(e[n]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let ug=0;class Jf{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:ug++}),this.uuid=Ra(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let a;if(Array.isArray(s)){a=[];for(let r=0,o=s.length;r<o;r++)s[r].isDataTexture?a.push(ll(s[r].image)):a.push(ll(s[r]))}else a=ll(s);n.url=a}return e||(t.images[this.uuid]=n),n}}function ll(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?hg.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let dg=0;class on extends Is{constructor(t=on.DEFAULT_IMAGE,e=on.DEFAULT_MAPPING,n=bs,s=bs,a=Kn,r=Ss,o=zn,l=pi,c=on.DEFAULT_ANISOTROPY,h=ts){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:dg++}),this.uuid=Ra(),this.name="",this.source=new Jf(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=a,this.minFilter=r,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new lt(0,0),this.repeat=new lt(1,1),this.center=new lt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Yt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==zf)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Oi:t.x=t.x-Math.floor(t.x);break;case bs:t.x=t.x<0?0:1;break;case Tc:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Oi:t.y=t.y-Math.floor(t.y);break;case bs:t.y=t.y<0?0:1;break;case Tc:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}on.DEFAULT_IMAGE=null;on.DEFAULT_MAPPING=zf;on.DEFAULT_ANISOTROPY=1;class me{constructor(t=0,e=0,n=0,s=1){me.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,s){return this.x=t,this.y=e,this.z=n,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,s=this.z,a=this.w,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*s+r[12]*a,this.y=r[1]*e+r[5]*n+r[9]*s+r[13]*a,this.z=r[2]*e+r[6]*n+r[10]*s+r[14]*a,this.w=r[3]*e+r[7]*n+r[11]*s+r[15]*a,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,s,a;const l=t.elements,c=l[0],h=l[4],u=l[8],d=l[1],f=l[5],g=l[9],_=l[2],p=l[6],m=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-_)<.01&&Math.abs(g-p)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+_)<.1&&Math.abs(g+p)<.1&&Math.abs(c+f+m-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const x=(c+1)/2,S=(f+1)/2,P=(m+1)/2,T=(h+d)/4,w=(u+_)/4,R=(g+p)/4;return x>S&&x>P?x<.01?(n=0,s=.707106781,a=.707106781):(n=Math.sqrt(x),s=T/n,a=w/n):S>P?S<.01?(n=.707106781,s=0,a=.707106781):(s=Math.sqrt(S),n=T/s,a=R/s):P<.01?(n=.707106781,s=.707106781,a=0):(a=Math.sqrt(P),n=w/a,s=R/a),this.set(n,s,a,e),this}let y=Math.sqrt((p-g)*(p-g)+(u-_)*(u-_)+(d-h)*(d-h));return Math.abs(y)<.001&&(y=1),this.x=(p-g)/y,this.y=(u-_)/y,this.z=(d-h)/y,this.w=Math.acos((c+f+m-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class fg extends Is{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new me(0,0,t,e),this.scissorTest=!1,this.viewport=new me(0,0,t,e);const s={width:t,height:e,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Kn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const a=new on(s,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);a.flipY=!1,a.generateMipmaps=n.generateMipmaps,a.internalFormat=n.internalFormat,this.textures=[];const r=n.count;for(let o=0;o<r;o++)this.textures[o]=a.clone(),this.textures[o].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let s=0,a=this.textures.length;s<a;s++)this.textures[s].image.width=t,this.textures[s].image.height=e,this.textures[s].image.depth=n;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let n=0,s=t.textures.length;n<s;n++)this.textures[n]=t.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;const e=Object.assign({},t.texture.image);return this.texture.source=new Jf(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class ei extends fg{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class Qf extends on{constructor(t=null,e=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=rn,this.minFilter=rn,this.wrapR=bs,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class pg extends on{constructor(t=null,e=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=rn,this.minFilter=rn,this.wrapR=bs,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class hs{constructor(t=0,e=0,n=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,a,r,o){let l=n[s+0],c=n[s+1],h=n[s+2],u=n[s+3];const d=a[r+0],f=a[r+1],g=a[r+2],_=a[r+3];if(o===0){t[e+0]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u;return}if(o===1){t[e+0]=d,t[e+1]=f,t[e+2]=g,t[e+3]=_;return}if(u!==_||l!==d||c!==f||h!==g){let p=1-o;const m=l*d+c*f+h*g+u*_,y=m>=0?1:-1,x=1-m*m;if(x>Number.EPSILON){const P=Math.sqrt(x),T=Math.atan2(P,m*y);p=Math.sin(p*T)/P,o=Math.sin(o*T)/P}const S=o*y;if(l=l*p+d*S,c=c*p+f*S,h=h*p+g*S,u=u*p+_*S,p===1-o){const P=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=P,c*=P,h*=P,u*=P}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,s,a,r){const o=n[s],l=n[s+1],c=n[s+2],h=n[s+3],u=a[r],d=a[r+1],f=a[r+2],g=a[r+3];return t[e]=o*g+h*u+l*f-c*d,t[e+1]=l*g+h*d+c*u-o*f,t[e+2]=c*g+h*f+o*d-l*u,t[e+3]=h*g-o*u-l*d-c*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,s){return this._x=t,this._y=e,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,s=t._y,a=t._z,r=t._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(s/2),u=o(a/2),d=l(n/2),f=l(s/2),g=l(a/2);switch(r){case"XYZ":this._x=d*h*u+c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u-d*f*g;break;case"YXZ":this._x=d*h*u+c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u+d*f*g;break;case"ZXY":this._x=d*h*u-c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u-d*f*g;break;case"ZYX":this._x=d*h*u-c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u+d*f*g;break;case"YZX":this._x=d*h*u+c*f*g,this._y=c*f*u+d*h*g,this._z=c*h*g-d*f*u,this._w=c*h*u-d*f*g;break;case"XZY":this._x=d*h*u-c*f*g,this._y=c*f*u-d*h*g,this._z=c*h*g+d*f*u,this._w=c*h*u+d*f*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],s=e[4],a=e[8],r=e[1],o=e[5],l=e[9],c=e[2],h=e[6],u=e[10],d=n+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-l)*f,this._y=(a-c)*f,this._z=(r-s)*f}else if(n>o&&n>u){const f=2*Math.sqrt(1+n-o-u);this._w=(h-l)/f,this._x=.25*f,this._y=(s+r)/f,this._z=(a+c)/f}else if(o>u){const f=2*Math.sqrt(1+o-n-u);this._w=(a-c)/f,this._x=(s+r)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(r-s)/f,this._x=(a+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(He(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const s=Math.min(1,e/n);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,s=t._y,a=t._z,r=t._w,o=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+r*o+s*c-a*l,this._y=s*h+r*l+a*o-n*c,this._z=a*h+r*c+n*l-s*o,this._w=r*h-n*o-s*l-a*c,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const n=this._x,s=this._y,a=this._z,r=this._w;let o=r*t._w+n*t._x+s*t._y+a*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=r,this._x=n,this._y=s,this._z=a,this;const l=1-o*o;if(l<=Number.EPSILON){const f=1-e;return this._w=f*r+e*this._w,this._x=f*n+e*this._x,this._y=f*s+e*this._y,this._z=f*a+e*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,o),u=Math.sin((1-e)*h)/c,d=Math.sin(e*h)/c;return this._w=r*u+this._w*d,this._x=n*u+this._x*d,this._y=s*u+this._y*d,this._z=a*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),a=Math.sqrt(n);return this.set(s*Math.sin(t),s*Math.cos(t),a*Math.sin(e),a*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class C{constructor(t=0,e=0,n=0){C.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Uu.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Uu.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,s=this.z,a=t.elements;return this.x=a[0]*e+a[3]*n+a[6]*s,this.y=a[1]*e+a[4]*n+a[7]*s,this.z=a[2]*e+a[5]*n+a[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,s=this.z,a=t.elements,r=1/(a[3]*e+a[7]*n+a[11]*s+a[15]);return this.x=(a[0]*e+a[4]*n+a[8]*s+a[12])*r,this.y=(a[1]*e+a[5]*n+a[9]*s+a[13])*r,this.z=(a[2]*e+a[6]*n+a[10]*s+a[14])*r,this}applyQuaternion(t){const e=this.x,n=this.y,s=this.z,a=t.x,r=t.y,o=t.z,l=t.w,c=2*(r*s-o*n),h=2*(o*e-a*s),u=2*(a*n-r*e);return this.x=e+l*c+r*u-o*h,this.y=n+l*h+o*c-a*u,this.z=s+l*u+a*h-r*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,s=this.z,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*s,this.y=a[1]*e+a[5]*n+a[9]*s,this.z=a[2]*e+a[6]*n+a[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,s=t.y,a=t.z,r=e.x,o=e.y,l=e.z;return this.x=s*l-a*o,this.y=a*r-n*l,this.z=n*o-s*r,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return cl.copy(this).projectOnVector(t),this.sub(cl)}reflect(t){return this.sub(cl.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(He(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const cl=new C,Uu=new hs;class fr{constructor(t=new C(1/0,1/0,1/0),e=new C(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint($n.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint($n.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=$n.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(n!==void 0){const a=n.getAttribute("position");if(e===!0&&a!==void 0&&t.isInstancedMesh!==!0)for(let r=0,o=a.count;r<o;r++)t.isMesh===!0?t.getVertexPosition(r,$n):$n.fromBufferAttribute(a,r),$n.applyMatrix4(t.matrixWorld),this.expandByPoint($n);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),xr.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),xr.copy(n.boundingBox)),xr.applyMatrix4(t.matrixWorld),this.union(xr)}const s=t.children;for(let a=0,r=s.length;a<r;a++)this.expandByObject(s[a],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,$n),$n.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Na),yr.subVectors(this.max,Na),Fs.subVectors(t.a,Na),zs.subVectors(t.b,Na),Bs.subVectors(t.c,Na),$i.subVectors(zs,Fs),Wi.subVectors(Bs,zs),fs.subVectors(Fs,Bs);let e=[0,-$i.z,$i.y,0,-Wi.z,Wi.y,0,-fs.z,fs.y,$i.z,0,-$i.x,Wi.z,0,-Wi.x,fs.z,0,-fs.x,-$i.y,$i.x,0,-Wi.y,Wi.x,0,-fs.y,fs.x,0];return!hl(e,Fs,zs,Bs,yr)||(e=[1,0,0,0,1,0,0,0,1],!hl(e,Fs,zs,Bs,yr))?!1:(Mr.crossVectors($i,Wi),e=[Mr.x,Mr.y,Mr.z],hl(e,Fs,zs,Bs,yr))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,$n).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize($n).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(yi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),yi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),yi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),yi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),yi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),yi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),yi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),yi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(yi),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const yi=[new C,new C,new C,new C,new C,new C,new C,new C],$n=new C,xr=new fr,Fs=new C,zs=new C,Bs=new C,$i=new C,Wi=new C,fs=new C,Na=new C,yr=new C,Mr=new C,ps=new C;function hl(i,t,e,n,s){for(let a=0,r=i.length-3;a<=r;a+=3){ps.fromArray(i,a);const o=s.x*Math.abs(ps.x)+s.y*Math.abs(ps.y)+s.z*Math.abs(ps.z),l=t.dot(ps),c=e.dot(ps),h=n.dot(ps);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const mg=new fr,Ua=new C,ul=new C;class Dh{constructor(t=new C,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;e!==void 0?n.copy(e):mg.setFromPoints(t).getCenter(n);let s=0;for(let a=0,r=t.length;a<r;a++)s=Math.max(s,n.distanceToSquared(t[a]));return this.radius=Math.sqrt(s),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Ua.subVectors(t,this.center);const e=Ua.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Ua,s/n),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(ul.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Ua.copy(t.center).add(ul)),this.expandByPoint(Ua.copy(t.center).sub(ul))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const Mi=new C,dl=new C,br=new C,Xi=new C,fl=new C,Sr=new C,pl=new C;class Ih{constructor(t=new C,e=new C(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Mi)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Mi.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Mi.copy(this.origin).addScaledVector(this.direction,e),Mi.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){dl.copy(t).add(e).multiplyScalar(.5),br.copy(e).sub(t).normalize(),Xi.copy(this.origin).sub(dl);const a=t.distanceTo(e)*.5,r=-this.direction.dot(br),o=Xi.dot(this.direction),l=-Xi.dot(br),c=Xi.lengthSq(),h=Math.abs(1-r*r);let u,d,f,g;if(h>0)if(u=r*l-o,d=r*o-l,g=a*h,u>=0)if(d>=-g)if(d<=g){const _=1/h;u*=_,d*=_,f=u*(u+r*d+2*o)+d*(r*u+d+2*l)+c}else d=a,u=Math.max(0,-(r*d+o)),f=-u*u+d*(d+2*l)+c;else d=-a,u=Math.max(0,-(r*d+o)),f=-u*u+d*(d+2*l)+c;else d<=-g?(u=Math.max(0,-(-r*a+o)),d=u>0?-a:Math.min(Math.max(-a,-l),a),f=-u*u+d*(d+2*l)+c):d<=g?(u=0,d=Math.min(Math.max(-a,-l),a),f=d*(d+2*l)+c):(u=Math.max(0,-(r*a+o)),d=u>0?a:Math.min(Math.max(-a,-l),a),f=-u*u+d*(d+2*l)+c);else d=r>0?-a:a,u=Math.max(0,-(r*d+o)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(dl).addScaledVector(br,d),f}intersectSphere(t,e){Mi.subVectors(t.center,this.origin);const n=Mi.dot(this.direction),s=Mi.dot(Mi)-n*n,a=t.radius*t.radius;if(s>a)return null;const r=Math.sqrt(a-s),o=n-r,l=n+r;return l<0?null:o<0?this.at(l,e):this.at(o,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,s,a,r,o,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(t.min.x-d.x)*c,s=(t.max.x-d.x)*c):(n=(t.max.x-d.x)*c,s=(t.min.x-d.x)*c),h>=0?(a=(t.min.y-d.y)*h,r=(t.max.y-d.y)*h):(a=(t.max.y-d.y)*h,r=(t.min.y-d.y)*h),n>r||a>s||((a>n||isNaN(n))&&(n=a),(r<s||isNaN(s))&&(s=r),u>=0?(o=(t.min.z-d.z)*u,l=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,l=(t.min.z-d.z)*u),n>l||o>s)||((o>n||n!==n)&&(n=o),(l<s||s!==s)&&(s=l),s<0)?null:this.at(n>=0?n:s,e)}intersectsBox(t){return this.intersectBox(t,Mi)!==null}intersectTriangle(t,e,n,s,a){fl.subVectors(e,t),Sr.subVectors(n,t),pl.crossVectors(fl,Sr);let r=this.direction.dot(pl),o;if(r>0){if(s)return null;o=1}else if(r<0)o=-1,r=-r;else return null;Xi.subVectors(this.origin,t);const l=o*this.direction.dot(Sr.crossVectors(Xi,Sr));if(l<0)return null;const c=o*this.direction.dot(fl.cross(Xi));if(c<0||l+c>r)return null;const h=-o*Xi.dot(pl);return h<0?null:this.at(h/r,a)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class fe{constructor(t,e,n,s,a,r,o,l,c,h,u,d,f,g,_,p){fe.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,s,a,r,o,l,c,h,u,d,f,g,_,p)}set(t,e,n,s,a,r,o,l,c,h,u,d,f,g,_,p){const m=this.elements;return m[0]=t,m[4]=e,m[8]=n,m[12]=s,m[1]=a,m[5]=r,m[9]=o,m[13]=l,m[2]=c,m[6]=h,m[10]=u,m[14]=d,m[3]=f,m[7]=g,m[11]=_,m[15]=p,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new fe().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,s=1/Hs.setFromMatrixColumn(t,0).length(),a=1/Hs.setFromMatrixColumn(t,1).length(),r=1/Hs.setFromMatrixColumn(t,2).length();return e[0]=n[0]*s,e[1]=n[1]*s,e[2]=n[2]*s,e[3]=0,e[4]=n[4]*a,e[5]=n[5]*a,e[6]=n[6]*a,e[7]=0,e[8]=n[8]*r,e[9]=n[9]*r,e[10]=n[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,s=t.y,a=t.z,r=Math.cos(n),o=Math.sin(n),l=Math.cos(s),c=Math.sin(s),h=Math.cos(a),u=Math.sin(a);if(t.order==="XYZ"){const d=r*h,f=r*u,g=o*h,_=o*u;e[0]=l*h,e[4]=-l*u,e[8]=c,e[1]=f+g*c,e[5]=d-_*c,e[9]=-o*l,e[2]=_-d*c,e[6]=g+f*c,e[10]=r*l}else if(t.order==="YXZ"){const d=l*h,f=l*u,g=c*h,_=c*u;e[0]=d+_*o,e[4]=g*o-f,e[8]=r*c,e[1]=r*u,e[5]=r*h,e[9]=-o,e[2]=f*o-g,e[6]=_+d*o,e[10]=r*l}else if(t.order==="ZXY"){const d=l*h,f=l*u,g=c*h,_=c*u;e[0]=d-_*o,e[4]=-r*u,e[8]=g+f*o,e[1]=f+g*o,e[5]=r*h,e[9]=_-d*o,e[2]=-r*c,e[6]=o,e[10]=r*l}else if(t.order==="ZYX"){const d=r*h,f=r*u,g=o*h,_=o*u;e[0]=l*h,e[4]=g*c-f,e[8]=d*c+_,e[1]=l*u,e[5]=_*c+d,e[9]=f*c-g,e[2]=-c,e[6]=o*l,e[10]=r*l}else if(t.order==="YZX"){const d=r*l,f=r*c,g=o*l,_=o*c;e[0]=l*h,e[4]=_-d*u,e[8]=g*u+f,e[1]=u,e[5]=r*h,e[9]=-o*h,e[2]=-c*h,e[6]=f*u+g,e[10]=d-_*u}else if(t.order==="XZY"){const d=r*l,f=r*c,g=o*l,_=o*c;e[0]=l*h,e[4]=-u,e[8]=c*h,e[1]=d*u+_,e[5]=r*h,e[9]=f*u-g,e[2]=g*u-f,e[6]=o*h,e[10]=_*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(gg,t,vg)}lookAt(t,e,n){const s=this.elements;return wn.subVectors(t,e),wn.lengthSq()===0&&(wn.z=1),wn.normalize(),qi.crossVectors(n,wn),qi.lengthSq()===0&&(Math.abs(n.z)===1?wn.x+=1e-4:wn.z+=1e-4,wn.normalize(),qi.crossVectors(n,wn)),qi.normalize(),wr.crossVectors(wn,qi),s[0]=qi.x,s[4]=wr.x,s[8]=wn.x,s[1]=qi.y,s[5]=wr.y,s[9]=wn.y,s[2]=qi.z,s[6]=wr.z,s[10]=wn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=e.elements,a=this.elements,r=n[0],o=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],f=n[13],g=n[2],_=n[6],p=n[10],m=n[14],y=n[3],x=n[7],S=n[11],P=n[15],T=s[0],w=s[4],R=s[8],k=s[12],v=s[1],b=s[5],N=s[9],F=s[13],$=s[2],W=s[6],z=s[10],nt=s[14],G=s[3],at=s[7],ht=s[11],mt=s[15];return a[0]=r*T+o*v+l*$+c*G,a[4]=r*w+o*b+l*W+c*at,a[8]=r*R+o*N+l*z+c*ht,a[12]=r*k+o*F+l*nt+c*mt,a[1]=h*T+u*v+d*$+f*G,a[5]=h*w+u*b+d*W+f*at,a[9]=h*R+u*N+d*z+f*ht,a[13]=h*k+u*F+d*nt+f*mt,a[2]=g*T+_*v+p*$+m*G,a[6]=g*w+_*b+p*W+m*at,a[10]=g*R+_*N+p*z+m*ht,a[14]=g*k+_*F+p*nt+m*mt,a[3]=y*T+x*v+S*$+P*G,a[7]=y*w+x*b+S*W+P*at,a[11]=y*R+x*N+S*z+P*ht,a[15]=y*k+x*F+S*nt+P*mt,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],s=t[8],a=t[12],r=t[1],o=t[5],l=t[9],c=t[13],h=t[2],u=t[6],d=t[10],f=t[14],g=t[3],_=t[7],p=t[11],m=t[15];return g*(+a*l*u-s*c*u-a*o*d+n*c*d+s*o*f-n*l*f)+_*(+e*l*f-e*c*d+a*r*d-s*r*f+s*c*h-a*l*h)+p*(+e*c*u-e*o*f-a*r*u+n*r*f+a*o*h-n*c*h)+m*(-s*o*h-e*l*u+e*o*d+s*r*u-n*r*d+n*l*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],s=t[2],a=t[3],r=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],f=t[11],g=t[12],_=t[13],p=t[14],m=t[15],y=u*p*c-_*d*c+_*l*f-o*p*f-u*l*m+o*d*m,x=g*d*c-h*p*c-g*l*f+r*p*f+h*l*m-r*d*m,S=h*_*c-g*u*c+g*o*f-r*_*f-h*o*m+r*u*m,P=g*u*l-h*_*l-g*o*d+r*_*d+h*o*p-r*u*p,T=e*y+n*x+s*S+a*P;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/T;return t[0]=y*w,t[1]=(_*d*a-u*p*a-_*s*f+n*p*f+u*s*m-n*d*m)*w,t[2]=(o*p*a-_*l*a+_*s*c-n*p*c-o*s*m+n*l*m)*w,t[3]=(u*l*a-o*d*a-u*s*c+n*d*c+o*s*f-n*l*f)*w,t[4]=x*w,t[5]=(h*p*a-g*d*a+g*s*f-e*p*f-h*s*m+e*d*m)*w,t[6]=(g*l*a-r*p*a-g*s*c+e*p*c+r*s*m-e*l*m)*w,t[7]=(r*d*a-h*l*a+h*s*c-e*d*c-r*s*f+e*l*f)*w,t[8]=S*w,t[9]=(g*u*a-h*_*a-g*n*f+e*_*f+h*n*m-e*u*m)*w,t[10]=(r*_*a-g*o*a+g*n*c-e*_*c-r*n*m+e*o*m)*w,t[11]=(h*o*a-r*u*a-h*n*c+e*u*c+r*n*f-e*o*f)*w,t[12]=P*w,t[13]=(h*_*s-g*u*s+g*n*d-e*_*d-h*n*p+e*u*p)*w,t[14]=(g*o*s-r*_*s-g*n*l+e*_*l+r*n*p-e*o*p)*w,t[15]=(r*u*s-h*o*s+h*n*l-e*u*l-r*n*d+e*o*d)*w,this}scale(t){const e=this.elements,n=t.x,s=t.y,a=t.z;return e[0]*=n,e[4]*=s,e[8]*=a,e[1]*=n,e[5]*=s,e[9]*=a,e[2]*=n,e[6]*=s,e[10]*=a,e[3]*=n,e[7]*=s,e[11]*=a,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,s))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),s=Math.sin(e),a=1-n,r=t.x,o=t.y,l=t.z,c=a*r,h=a*o;return this.set(c*r+n,c*o-s*l,c*l+s*o,0,c*o+s*l,h*o+n,h*l-s*r,0,c*l-s*o,h*l+s*r,a*l*l+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,s,a,r){return this.set(1,n,a,0,t,1,r,0,e,s,1,0,0,0,0,1),this}compose(t,e,n){const s=this.elements,a=e._x,r=e._y,o=e._z,l=e._w,c=a+a,h=r+r,u=o+o,d=a*c,f=a*h,g=a*u,_=r*h,p=r*u,m=o*u,y=l*c,x=l*h,S=l*u,P=n.x,T=n.y,w=n.z;return s[0]=(1-(_+m))*P,s[1]=(f+S)*P,s[2]=(g-x)*P,s[3]=0,s[4]=(f-S)*T,s[5]=(1-(d+m))*T,s[6]=(p+y)*T,s[7]=0,s[8]=(g+x)*w,s[9]=(p-y)*w,s[10]=(1-(d+_))*w,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,n){const s=this.elements;let a=Hs.set(s[0],s[1],s[2]).length();const r=Hs.set(s[4],s[5],s[6]).length(),o=Hs.set(s[8],s[9],s[10]).length();this.determinant()<0&&(a=-a),t.x=s[12],t.y=s[13],t.z=s[14],Wn.copy(this);const c=1/a,h=1/r,u=1/o;return Wn.elements[0]*=c,Wn.elements[1]*=c,Wn.elements[2]*=c,Wn.elements[4]*=h,Wn.elements[5]*=h,Wn.elements[6]*=h,Wn.elements[8]*=u,Wn.elements[9]*=u,Wn.elements[10]*=u,e.setFromRotationMatrix(Wn),n.x=a,n.y=r,n.z=o,this}makePerspective(t,e,n,s,a,r,o=Di){const l=this.elements,c=2*a/(e-t),h=2*a/(n-s),u=(e+t)/(e-t),d=(n+s)/(n-s);let f,g;if(o===Di)f=-(r+a)/(r-a),g=-2*r*a/(r-a);else if(o===Ro)f=-r/(r-a),g=-r*a/(r-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=h,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=f,l[14]=g,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,s,a,r,o=Di){const l=this.elements,c=1/(e-t),h=1/(n-s),u=1/(r-a),d=(e+t)*c,f=(n+s)*h;let g,_;if(o===Di)g=(r+a)*u,_=-2*u;else if(o===Ro)g=a*u,_=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-f,l[2]=0,l[6]=0,l[10]=_,l[14]=-g,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let s=0;s<16;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const Hs=new C,Wn=new fe,gg=new C(0,0,0),vg=new C(1,1,1),qi=new C,wr=new C,wn=new C,Ou=new fe,Fu=new hs;class mi{constructor(t=0,e=0,n=0,s=mi.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,s=this._order){return this._x=t,this._y=e,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const s=t.elements,a=s[0],r=s[4],o=s[8],l=s[1],c=s[5],h=s[9],u=s[2],d=s[6],f=s[10];switch(e){case"XYZ":this._y=Math.asin(He(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-r,a)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-He(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,a),this._z=0);break;case"ZXY":this._x=Math.asin(He(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-r,c)):(this._y=0,this._z=Math.atan2(l,a));break;case"ZYX":this._y=Math.asin(-He(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,a)):(this._x=0,this._z=Math.atan2(-r,c));break;case"YZX":this._z=Math.asin(He(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,a)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-He(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,a)):(this._x=Math.atan2(-h,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Ou.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Ou,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Fu.setFromEuler(this),this.setFromQuaternion(Fu,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}mi.DEFAULT_ORDER="XYZ";class kh{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let _g=0;const zu=new C,Vs=new hs,bi=new fe,Er=new C,Oa=new C,xg=new C,yg=new hs,Bu=new C(1,0,0),Hu=new C(0,1,0),Vu=new C(0,0,1),Gu={type:"added"},Mg={type:"removed"},Gs={type:"childadded",child:null},ml={type:"childremoved",child:null};class en extends Is{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:_g++}),this.uuid=Ra(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=en.DEFAULT_UP.clone();const t=new C,e=new mi,n=new hs,s=new C(1,1,1);function a(){n.setFromEuler(e,!1)}function r(){e.setFromQuaternion(n,void 0,!1)}e._onChange(a),n._onChange(r),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new fe},normalMatrix:{value:new Yt}}),this.matrix=new fe,this.matrixWorld=new fe,this.matrixAutoUpdate=en.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=en.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new kh,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Vs.setFromAxisAngle(t,e),this.quaternion.multiply(Vs),this}rotateOnWorldAxis(t,e){return Vs.setFromAxisAngle(t,e),this.quaternion.premultiply(Vs),this}rotateX(t){return this.rotateOnAxis(Bu,t)}rotateY(t){return this.rotateOnAxis(Hu,t)}rotateZ(t){return this.rotateOnAxis(Vu,t)}translateOnAxis(t,e){return zu.copy(t).applyQuaternion(this.quaternion),this.position.add(zu.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Bu,t)}translateY(t){return this.translateOnAxis(Hu,t)}translateZ(t){return this.translateOnAxis(Vu,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(bi.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Er.copy(t):Er.set(t,e,n);const s=this.parent;this.updateWorldMatrix(!0,!1),Oa.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?bi.lookAt(Oa,Er,this.up):bi.lookAt(Er,Oa,this.up),this.quaternion.setFromRotationMatrix(bi),s&&(bi.extractRotation(s.matrixWorld),Vs.setFromRotationMatrix(bi),this.quaternion.premultiply(Vs.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Gu),Gs.child=t,this.dispatchEvent(Gs),Gs.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Mg),ml.child=t,this.dispatchEvent(ml),ml.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),bi.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),bi.multiply(t.parent.matrixWorld)),t.applyMatrix4(bi),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Gu),Gs.child=t,this.dispatchEvent(Gs),Gs.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,s=this.children.length;n<s;n++){const r=this.children[n].getObjectByProperty(t,e);if(r!==void 0)return r}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const s=this.children;for(let a=0,r=s.length;a<r;a++)s[a].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oa,t,xg),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oa,yg,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,s=e.length;n<s;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){const n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){const s=this.children;for(let a=0,r=s.length;a<r;a++)s[a].updateWorldMatrix(!1,!0)}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.visibility=this._visibility,s.active=this._active,s.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.geometryCount=this._geometryCount,s.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere={center:s.boundingSphere.center.toArray(),radius:s.boundingSphere.radius}),this.boundingBox!==null&&(s.boundingBox={min:s.boundingBox.min.toArray(),max:s.boundingBox.max.toArray()}));function a(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=a(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const u=l[c];a(t.shapes,u)}else a(t.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(t.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(a(t.materials,this.material[l]));s.material=o}else s.material=a(t.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];s.animations.push(a(t.animations,l))}}if(e){const o=r(t.geometries),l=r(t.materials),c=r(t.textures),h=r(t.images),u=r(t.shapes),d=r(t.skeletons),f=r(t.animations),g=r(t.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),g.length>0&&(n.nodes=g)}return n.object=s,n;function r(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const s=t.children[n];this.add(s.clone())}return this}}en.DEFAULT_UP=new C(0,1,0);en.DEFAULT_MATRIX_AUTO_UPDATE=!0;en.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Xn=new C,Si=new C,gl=new C,wi=new C,$s=new C,Ws=new C,$u=new C,vl=new C,_l=new C,xl=new C,yl=new me,Ml=new me,bl=new me;class Zn{constructor(t=new C,e=new C,n=new C){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,s){s.subVectors(n,e),Xn.subVectors(t,e),s.cross(Xn);const a=s.lengthSq();return a>0?s.multiplyScalar(1/Math.sqrt(a)):s.set(0,0,0)}static getBarycoord(t,e,n,s,a){Xn.subVectors(s,e),Si.subVectors(n,e),gl.subVectors(t,e);const r=Xn.dot(Xn),o=Xn.dot(Si),l=Xn.dot(gl),c=Si.dot(Si),h=Si.dot(gl),u=r*c-o*o;if(u===0)return a.set(0,0,0),null;const d=1/u,f=(c*l-o*h)*d,g=(r*h-o*l)*d;return a.set(1-f-g,g,f)}static containsPoint(t,e,n,s){return this.getBarycoord(t,e,n,s,wi)===null?!1:wi.x>=0&&wi.y>=0&&wi.x+wi.y<=1}static getInterpolation(t,e,n,s,a,r,o,l){return this.getBarycoord(t,e,n,s,wi)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(a,wi.x),l.addScaledVector(r,wi.y),l.addScaledVector(o,wi.z),l)}static getInterpolatedAttribute(t,e,n,s,a,r){return yl.setScalar(0),Ml.setScalar(0),bl.setScalar(0),yl.fromBufferAttribute(t,e),Ml.fromBufferAttribute(t,n),bl.fromBufferAttribute(t,s),r.setScalar(0),r.addScaledVector(yl,a.x),r.addScaledVector(Ml,a.y),r.addScaledVector(bl,a.z),r}static isFrontFacing(t,e,n,s){return Xn.subVectors(n,e),Si.subVectors(t,e),Xn.cross(Si).dot(s)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,s){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,n,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Xn.subVectors(this.c,this.b),Si.subVectors(this.a,this.b),Xn.cross(Si).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Zn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Zn.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,s,a){return Zn.getInterpolation(t,this.a,this.b,this.c,e,n,s,a)}containsPoint(t){return Zn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Zn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,s=this.b,a=this.c;let r,o;$s.subVectors(s,n),Ws.subVectors(a,n),vl.subVectors(t,n);const l=$s.dot(vl),c=Ws.dot(vl);if(l<=0&&c<=0)return e.copy(n);_l.subVectors(t,s);const h=$s.dot(_l),u=Ws.dot(_l);if(h>=0&&u<=h)return e.copy(s);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return r=l/(l-h),e.copy(n).addScaledVector($s,r);xl.subVectors(t,a);const f=$s.dot(xl),g=Ws.dot(xl);if(g>=0&&f<=g)return e.copy(a);const _=f*c-l*g;if(_<=0&&c>=0&&g<=0)return o=c/(c-g),e.copy(n).addScaledVector(Ws,o);const p=h*g-f*u;if(p<=0&&u-h>=0&&f-g>=0)return $u.subVectors(a,s),o=(u-h)/(u-h+(f-g)),e.copy(s).addScaledVector($u,o);const m=1/(p+_+d);return r=_*m,o=d*m,e.copy(n).addScaledVector($s,r).addScaledVector(Ws,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const tp={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ji={h:0,s:0,l:0},Tr={h:0,s:0,l:0};function Sl(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}class te{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Qe){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,le.toWorkingColorSpace(this,e),this}setRGB(t,e,n,s=le.workingColorSpace){return this.r=t,this.g=e,this.b=n,le.toWorkingColorSpace(this,s),this}setHSL(t,e,n,s=le.workingColorSpace){if(t=Lh(t,1),e=He(e,0,1),n=He(n,0,1),e===0)this.r=this.g=this.b=n;else{const a=n<=.5?n*(1+e):n+e-n*e,r=2*n-a;this.r=Sl(r,a,t+1/3),this.g=Sl(r,a,t),this.b=Sl(r,a,t-1/3)}return le.toWorkingColorSpace(this,s),this}setStyle(t,e=Qe){function n(a){a!==void 0&&parseFloat(a)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let a;const r=s[1],o=s[2];switch(r){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,e);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,e);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){const a=s[1],r=a.length;if(r===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,e);if(r===6)return this.setHex(parseInt(a,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Qe){const n=tp[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=xa(t.r),this.g=xa(t.g),this.b=xa(t.b),this}copyLinearToSRGB(t){return this.r=ol(t.r),this.g=ol(t.g),this.b=ol(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Qe){return le.fromWorkingColorSpace(sn.copy(this),t),Math.round(He(sn.r*255,0,255))*65536+Math.round(He(sn.g*255,0,255))*256+Math.round(He(sn.b*255,0,255))}getHexString(t=Qe){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=le.workingColorSpace){le.fromWorkingColorSpace(sn.copy(this),e);const n=sn.r,s=sn.g,a=sn.b,r=Math.max(n,s,a),o=Math.min(n,s,a);let l,c;const h=(o+r)/2;if(o===r)l=0,c=0;else{const u=r-o;switch(c=h<=.5?u/(r+o):u/(2-r-o),r){case n:l=(s-a)/u+(s<a?6:0);break;case s:l=(a-n)/u+2;break;case a:l=(n-s)/u+4;break}l/=6}return t.h=l,t.s=c,t.l=h,t}getRGB(t,e=le.workingColorSpace){return le.fromWorkingColorSpace(sn.copy(this),e),t.r=sn.r,t.g=sn.g,t.b=sn.b,t}getStyle(t=Qe){le.fromWorkingColorSpace(sn.copy(this),t);const e=sn.r,n=sn.g,s=sn.b;return t!==Qe?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(t,e,n){return this.getHSL(ji),this.setHSL(ji.h+t,ji.s+e,ji.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(ji),t.getHSL(Tr);const n=tr(ji.h,Tr.h,e),s=tr(ji.s,Tr.s,e),a=tr(ji.l,Tr.l,e);return this.setHSL(n,s,a),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,s=this.b,a=t.elements;return this.r=a[0]*e+a[3]*n+a[6]*s,this.g=a[1]*e+a[4]*n+a[7]*s,this.b=a[2]*e+a[5]*n+a[8]*s,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const sn=new te;te.NAMES=tp;let bg=0;class Bi extends Is{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:bg++}),this.uuid=Ra(),this.name="",this.type="Material",this.blending=va,this.side=cs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=fc,this.blendDst=pc,this.blendEquation=Yn,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new te(0,0,0),this.blendAlpha=0,this.depthFunc=ba,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Ru,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Us,this.stencilZFail=Us,this.stencilZPass=Us,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const s=this[e];if(s===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==va&&(n.blending=this.blending),this.side!==cs&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==fc&&(n.blendSrc=this.blendSrc),this.blendDst!==pc&&(n.blendDst=this.blendDst),this.blendEquation!==Yn&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==ba&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Ru&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Us&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Us&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Us&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(a){const r=[];for(const o in a){const l=a[o];delete l.metadata,r.push(l)}return r}if(e){const a=s(t.textures),r=s(t.images);a.length>0&&(n.textures=a),r.length>0&&(n.images=r)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const s=e.length;n=new Array(s);for(let a=0;a!==s;++a)n[a]=e[a].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class ln extends Bi{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new te(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new mi,this.combine=If,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const ke=new C,Ar=new lt;class ui{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Pu,this.updateRanges=[],this.gpuType=Li,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let s=0,a=this.itemSize;s<a;s++)this.array[t+s]=e.array[n+s];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)Ar.fromBufferAttribute(this,e),Ar.applyMatrix3(t),this.setXY(e,Ar.x,Ar.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)ke.fromBufferAttribute(this,e),ke.applyMatrix3(t),this.setXYZ(e,ke.x,ke.y,ke.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)ke.fromBufferAttribute(this,e),ke.applyMatrix4(t),this.setXYZ(e,ke.x,ke.y,ke.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)ke.fromBufferAttribute(this,e),ke.applyNormalMatrix(t),this.setXYZ(e,ke.x,ke.y,ke.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)ke.fromBufferAttribute(this,e),ke.transformDirection(t),this.setXYZ(e,ke.x,ke.y,ke.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=sa(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=cn(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=sa(e,this.array)),e}setX(t,e){return this.normalized&&(e=cn(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=sa(e,this.array)),e}setY(t,e){return this.normalized&&(e=cn(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=sa(e,this.array)),e}setZ(t,e){return this.normalized&&(e=cn(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=sa(e,this.array)),e}setW(t,e){return this.normalized&&(e=cn(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=cn(e,this.array),n=cn(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,s){return t*=this.itemSize,this.normalized&&(e=cn(e,this.array),n=cn(n,this.array),s=cn(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this}setXYZW(t,e,n,s,a){return t*=this.itemSize,this.normalized&&(e=cn(e,this.array),n=cn(n,this.array),s=cn(s,this.array),a=cn(a,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this.array[t+3]=a,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==Pu&&(t.usage=this.usage),t}}class ep extends ui{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class np extends ui{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class ue extends ui{constructor(t,e,n){super(new Float32Array(t),e,n)}}let Sg=0;const kn=new fe,wl=new en,Xs=new C,En=new fr,Fa=new fr,We=new C;class pn extends Is{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Sg++}),this.uuid=Ra(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(Zf(t)?np:ep)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const a=new Yt().getNormalMatrix(t);n.applyNormalMatrix(a),n.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return kn.makeRotationFromQuaternion(t),this.applyMatrix4(kn),this}rotateX(t){return kn.makeRotationX(t),this.applyMatrix4(kn),this}rotateY(t){return kn.makeRotationY(t),this.applyMatrix4(kn),this}rotateZ(t){return kn.makeRotationZ(t),this.applyMatrix4(kn),this}translate(t,e,n){return kn.makeTranslation(t,e,n),this.applyMatrix4(kn),this}scale(t,e,n){return kn.makeScale(t,e,n),this.applyMatrix4(kn),this}lookAt(t){return wl.lookAt(t),wl.updateMatrix(),this.applyMatrix4(wl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Xs).negate(),this.translate(Xs.x,Xs.y,Xs.z),this}setFromPoints(t){const e=[];for(let n=0,s=t.length;n<s;n++){const a=t[n];e.push(a.x,a.y,a.z||0)}return this.setAttribute("position",new ue(e,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new fr);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new C(-1/0,-1/0,-1/0),new C(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,s=e.length;n<s;n++){const a=e[n];En.setFromBufferAttribute(a),this.morphTargetsRelative?(We.addVectors(this.boundingBox.min,En.min),this.boundingBox.expandByPoint(We),We.addVectors(this.boundingBox.max,En.max),this.boundingBox.expandByPoint(We)):(this.boundingBox.expandByPoint(En.min),this.boundingBox.expandByPoint(En.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Dh);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new C,1/0);return}if(t){const n=this.boundingSphere.center;if(En.setFromBufferAttribute(t),e)for(let a=0,r=e.length;a<r;a++){const o=e[a];Fa.setFromBufferAttribute(o),this.morphTargetsRelative?(We.addVectors(En.min,Fa.min),En.expandByPoint(We),We.addVectors(En.max,Fa.max),En.expandByPoint(We)):(En.expandByPoint(Fa.min),En.expandByPoint(Fa.max))}En.getCenter(n);let s=0;for(let a=0,r=t.count;a<r;a++)We.fromBufferAttribute(t,a),s=Math.max(s,n.distanceToSquared(We));if(e)for(let a=0,r=e.length;a<r;a++){const o=e[a],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)We.fromBufferAttribute(o,c),l&&(Xs.fromBufferAttribute(t,c),We.add(Xs)),s=Math.max(s,n.distanceToSquared(We))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,s=e.normal,a=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new ui(new Float32Array(4*n.count),4));const r=this.getAttribute("tangent"),o=[],l=[];for(let R=0;R<n.count;R++)o[R]=new C,l[R]=new C;const c=new C,h=new C,u=new C,d=new lt,f=new lt,g=new lt,_=new C,p=new C;function m(R,k,v){c.fromBufferAttribute(n,R),h.fromBufferAttribute(n,k),u.fromBufferAttribute(n,v),d.fromBufferAttribute(a,R),f.fromBufferAttribute(a,k),g.fromBufferAttribute(a,v),h.sub(c),u.sub(c),f.sub(d),g.sub(d);const b=1/(f.x*g.y-g.x*f.y);isFinite(b)&&(_.copy(h).multiplyScalar(g.y).addScaledVector(u,-f.y).multiplyScalar(b),p.copy(u).multiplyScalar(f.x).addScaledVector(h,-g.x).multiplyScalar(b),o[R].add(_),o[k].add(_),o[v].add(_),l[R].add(p),l[k].add(p),l[v].add(p))}let y=this.groups;y.length===0&&(y=[{start:0,count:t.count}]);for(let R=0,k=y.length;R<k;++R){const v=y[R],b=v.start,N=v.count;for(let F=b,$=b+N;F<$;F+=3)m(t.getX(F+0),t.getX(F+1),t.getX(F+2))}const x=new C,S=new C,P=new C,T=new C;function w(R){P.fromBufferAttribute(s,R),T.copy(P);const k=o[R];x.copy(k),x.sub(P.multiplyScalar(P.dot(k))).normalize(),S.crossVectors(T,k);const b=S.dot(l[R])<0?-1:1;r.setXYZW(R,x.x,x.y,x.z,b)}for(let R=0,k=y.length;R<k;++R){const v=y[R],b=v.start,N=v.count;for(let F=b,$=b+N;F<$;F+=3)w(t.getX(F+0)),w(t.getX(F+1)),w(t.getX(F+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new ui(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const s=new C,a=new C,r=new C,o=new C,l=new C,c=new C,h=new C,u=new C;if(t)for(let d=0,f=t.count;d<f;d+=3){const g=t.getX(d+0),_=t.getX(d+1),p=t.getX(d+2);s.fromBufferAttribute(e,g),a.fromBufferAttribute(e,_),r.fromBufferAttribute(e,p),h.subVectors(r,a),u.subVectors(s,a),h.cross(u),o.fromBufferAttribute(n,g),l.fromBufferAttribute(n,_),c.fromBufferAttribute(n,p),o.add(h),l.add(h),c.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(_,l.x,l.y,l.z),n.setXYZ(p,c.x,c.y,c.z)}else for(let d=0,f=e.count;d<f;d+=3)s.fromBufferAttribute(e,d+0),a.fromBufferAttribute(e,d+1),r.fromBufferAttribute(e,d+2),h.subVectors(r,a),u.subVectors(s,a),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)We.fromBufferAttribute(t,e),We.normalize(),t.setXYZ(e,We.x,We.y,We.z)}toNonIndexed(){function t(o,l){const c=o.array,h=o.itemSize,u=o.normalized,d=new c.constructor(l.length*h);let f=0,g=0;for(let _=0,p=l.length;_<p;_++){o.isInterleavedBufferAttribute?f=l[_]*o.data.stride+o.offset:f=l[_]*h;for(let m=0;m<h;m++)d[g++]=c[f++]}return new ui(d,h,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new pn,n=this.index.array,s=this.attributes;for(const o in s){const l=s[o],c=t(l,n);e.setAttribute(o,c)}const a=this.morphAttributes;for(const o in a){const l=[],c=a[o];for(let h=0,u=c.length;h<u;h++){const d=c[h],f=t(d,n);l.push(f)}e.morphAttributes[o]=l}e.morphTargetsRelative=this.morphTargetsRelative;const r=this.groups;for(let o=0,l=r.length;o<l;o++){const c=r[o];e.addGroup(c.start,c.count,c.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const l in n){const c=n[l];t.data.attributes[l]=c.toJSON(t.data)}const s={};let a=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){const f=c[u];h.push(f.toJSON(t.data))}h.length>0&&(s[l]=h,a=!0)}a&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone(e));const s=t.attributes;for(const c in s){const h=s[c];this.setAttribute(c,h.clone(e))}const a=t.morphAttributes;for(const c in a){const h=[],u=a[c];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(e));this.morphAttributes[c]=h}this.morphTargetsRelative=t.morphTargetsRelative;const r=t.groups;for(let c=0,h=r.length;c<h;c++){const u=r[c];this.addGroup(u.start,u.count,u.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=t.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Wu=new fe,ms=new Ih,Cr=new Dh,Xu=new C,Rr=new C,Pr=new C,Lr=new C,El=new C,Dr=new C,qu=new C,Ir=new C;class yt extends en{constructor(t=new pn,e=new ln){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,r=s.length;a<r;a++){const o=s[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=a}}}}getVertexPosition(t,e){const n=this.geometry,s=n.attributes.position,a=n.morphAttributes.position,r=n.morphTargetsRelative;e.fromBufferAttribute(s,t);const o=this.morphTargetInfluences;if(a&&o){Dr.set(0,0,0);for(let l=0,c=a.length;l<c;l++){const h=o[l],u=a[l];h!==0&&(El.fromBufferAttribute(u,t),r?Dr.addScaledVector(El,h):Dr.addScaledVector(El.sub(e),h))}e.add(Dr)}return e}raycast(t,e){const n=this.geometry,s=this.material,a=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Cr.copy(n.boundingSphere),Cr.applyMatrix4(a),ms.copy(t.ray).recast(t.near),!(Cr.containsPoint(ms.origin)===!1&&(ms.intersectSphere(Cr,Xu)===null||ms.origin.distanceToSquared(Xu)>(t.far-t.near)**2))&&(Wu.copy(a).invert(),ms.copy(t.ray).applyMatrix4(Wu),!(n.boundingBox!==null&&ms.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,ms)))}_computeIntersections(t,e,n){let s;const a=this.geometry,r=this.material,o=a.index,l=a.attributes.position,c=a.attributes.uv,h=a.attributes.uv1,u=a.attributes.normal,d=a.groups,f=a.drawRange;if(o!==null)if(Array.isArray(r))for(let g=0,_=d.length;g<_;g++){const p=d[g],m=r[p.materialIndex],y=Math.max(p.start,f.start),x=Math.min(o.count,Math.min(p.start+p.count,f.start+f.count));for(let S=y,P=x;S<P;S+=3){const T=o.getX(S),w=o.getX(S+1),R=o.getX(S+2);s=kr(this,m,t,n,c,h,u,T,w,R),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=p.materialIndex,e.push(s))}}else{const g=Math.max(0,f.start),_=Math.min(o.count,f.start+f.count);for(let p=g,m=_;p<m;p+=3){const y=o.getX(p),x=o.getX(p+1),S=o.getX(p+2);s=kr(this,r,t,n,c,h,u,y,x,S),s&&(s.faceIndex=Math.floor(p/3),e.push(s))}}else if(l!==void 0)if(Array.isArray(r))for(let g=0,_=d.length;g<_;g++){const p=d[g],m=r[p.materialIndex],y=Math.max(p.start,f.start),x=Math.min(l.count,Math.min(p.start+p.count,f.start+f.count));for(let S=y,P=x;S<P;S+=3){const T=S,w=S+1,R=S+2;s=kr(this,m,t,n,c,h,u,T,w,R),s&&(s.faceIndex=Math.floor(S/3),s.face.materialIndex=p.materialIndex,e.push(s))}}else{const g=Math.max(0,f.start),_=Math.min(l.count,f.start+f.count);for(let p=g,m=_;p<m;p+=3){const y=p,x=p+1,S=p+2;s=kr(this,r,t,n,c,h,u,y,x,S),s&&(s.faceIndex=Math.floor(p/3),e.push(s))}}}}function wg(i,t,e,n,s,a,r,o){let l;if(t.side===fn?l=n.intersectTriangle(r,a,s,!0,o):l=n.intersectTriangle(s,a,r,t.side===cs,o),l===null)return null;Ir.copy(o),Ir.applyMatrix4(i.matrixWorld);const c=e.ray.origin.distanceTo(Ir);return c<e.near||c>e.far?null:{distance:c,point:Ir.clone(),object:i}}function kr(i,t,e,n,s,a,r,o,l,c){i.getVertexPosition(o,Rr),i.getVertexPosition(l,Pr),i.getVertexPosition(c,Lr);const h=wg(i,t,e,n,Rr,Pr,Lr,qu);if(h){const u=new C;Zn.getBarycoord(qu,Rr,Pr,Lr,u),s&&(h.uv=Zn.getInterpolatedAttribute(s,o,l,c,u,new lt)),a&&(h.uv1=Zn.getInterpolatedAttribute(a,o,l,c,u,new lt)),r&&(h.normal=Zn.getInterpolatedAttribute(r,o,l,c,u,new C),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new C,materialIndex:0};Zn.getNormal(Rr,Pr,Lr,d.normal),h.face=d,h.barycoord=u}return h}class Ye extends pn{constructor(t=1,e=1,n=1,s=1,a=1,r=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:s,heightSegments:a,depthSegments:r};const o=this;s=Math.floor(s),a=Math.floor(a),r=Math.floor(r);const l=[],c=[],h=[],u=[];let d=0,f=0;g("z","y","x",-1,-1,n,e,t,r,a,0),g("z","y","x",1,-1,n,e,-t,r,a,1),g("x","z","y",1,1,t,n,e,s,r,2),g("x","z","y",1,-1,t,n,-e,s,r,3),g("x","y","z",1,-1,t,e,n,s,a,4),g("x","y","z",-1,-1,t,e,-n,s,a,5),this.setIndex(l),this.setAttribute("position",new ue(c,3)),this.setAttribute("normal",new ue(h,3)),this.setAttribute("uv",new ue(u,2));function g(_,p,m,y,x,S,P,T,w,R,k){const v=S/w,b=P/R,N=S/2,F=P/2,$=T/2,W=w+1,z=R+1;let nt=0,G=0;const at=new C;for(let ht=0;ht<z;ht++){const mt=ht*b-F;for(let Xt=0;Xt<W;Xt++){const qt=Xt*v-N;at[_]=qt*y,at[p]=mt*x,at[m]=$,c.push(at.x,at.y,at.z),at[_]=0,at[p]=0,at[m]=T>0?1:-1,h.push(at.x,at.y,at.z),u.push(Xt/w),u.push(1-ht/R),nt+=1}}for(let ht=0;ht<R;ht++)for(let mt=0;mt<w;mt++){const Xt=d+mt+W*ht,qt=d+mt+W*(ht+1),q=d+(mt+1)+W*(ht+1),st=d+(mt+1)+W*ht;l.push(Xt,qt,st),l.push(qt,q,st),G+=6}o.addGroup(f,G,k),f+=G,d+=nt}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Ye(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function Ea(i){const t={};for(const e in i){t[e]={};for(const n in i[e]){const s=i[e][n];s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)?s.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=s.clone():Array.isArray(s)?t[e][n]=s.slice():t[e][n]=s}}return t}function hn(i){const t={};for(let e=0;e<i.length;e++){const n=Ea(i[e]);for(const s in n)t[s]=n[s]}return t}function Eg(i){const t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function ip(i){const t=i.getRenderTarget();return t===null?i.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:le.workingColorSpace}const es={clone:Ea,merge:hn};var Tg=`void main() {
61
61
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
62
62
  }`,Ag=`void main() {
63
63
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
64
- }`;class rn extends Bi{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Tg,this.fragmentShader=Ag,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Ea(t.uniforms),this.uniformsGroups=Eg(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const s in this.uniforms){const r=this.uniforms[s].value;r&&r.isTexture?e.uniforms[s]={type:"t",value:r.toJSON(t).uuid}:r&&r.isColor?e.uniforms[s]={type:"c",value:r.getHex()}:r&&r.isVector2?e.uniforms[s]={type:"v2",value:r.toArray()}:r&&r.isVector3?e.uniforms[s]={type:"v3",value:r.toArray()}:r&&r.isVector4?e.uniforms[s]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?e.uniforms[s]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?e.uniforms[s]={type:"m4",value:r.toArray()}:e.uniforms[s]={value:r}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class ap extends nn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new fe,this.projectionMatrix=new fe,this.projectionMatrixInverse=new fe,this.coordinateSystem=Di}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Yi=new C,ju=new lt,Yu=new lt;class Rn extends ap{constructor(t=50,e=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=lr*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(Qa*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return lr*2*Math.atan(Math.tan(Qa*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){Yi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Yi.x,Yi.y).multiplyScalar(-t/Yi.z),Yi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Yi.x,Yi.y).multiplyScalar(-t/Yi.z)}getViewSize(t,e){return this.getViewBounds(t,ju,Yu),e.subVectors(Yu,ju)}setViewOffset(t,e,n,s,a,r){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=a,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(Qa*.5*this.fov)/this.zoom,n=2*e,s=this.aspect*n,a=-.5*s;const r=this.view;if(this.view!==null&&this.view.enabled){const l=r.fullWidth,c=r.fullHeight;a+=r.offsetX*s/l,e-=r.offsetY*n/c,s*=r.width/l,n*=r.height/c}const o=this.filmOffset;o!==0&&(a+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+s,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const qs=-90,js=1;class Cg extends nn{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new Rn(qs,js,t,e);s.layers=this.layers,this.add(s);const a=new Rn(qs,js,t,e);a.layers=this.layers,this.add(a);const r=new Rn(qs,js,t,e);r.layers=this.layers,this.add(r);const o=new Rn(qs,js,t,e);o.layers=this.layers,this.add(o);const l=new Rn(qs,js,t,e);l.layers=this.layers,this.add(l);const c=new Rn(qs,js,t,e);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,s,a,r,o,l]=e;for(const c of e)this.remove(c);if(t===Di)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),r.up.set(0,0,1),r.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(t===Ro)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),r.up.set(0,0,-1),r.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const c of e)this.add(c),c.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[a,r,o,l,c,h]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),f=t.getActiveMipmapLevel(),g=t.xr.enabled;t.xr.enabled=!1;const _=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,s),t.render(e,a),t.setRenderTarget(n,1,s),t.render(e,r),t.setRenderTarget(n,2,s),t.render(e,o),t.setRenderTarget(n,3,s),t.render(e,l),t.setRenderTarget(n,4,s),t.render(e,c),n.texture.generateMipmaps=_,t.setRenderTarget(n,5,s),t.render(e,h),t.setRenderTarget(u,d,f),t.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class rp extends ln{constructor(t,e,n,s,a,r,o,l,c,h){t=t!==void 0?t:[],e=e!==void 0?e:Sa,super(t,e,n,s,a,r,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class Rg extends ei{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},s=[n,n,n,n,n,n];this.texture=new rp(s,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:Kn}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
64
+ }`;class an extends Bi{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Tg,this.fragmentShader=Ag,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Ea(t.uniforms),this.uniformsGroups=Eg(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const s in this.uniforms){const r=this.uniforms[s].value;r&&r.isTexture?e.uniforms[s]={type:"t",value:r.toJSON(t).uuid}:r&&r.isColor?e.uniforms[s]={type:"c",value:r.getHex()}:r&&r.isVector2?e.uniforms[s]={type:"v2",value:r.toArray()}:r&&r.isVector3?e.uniforms[s]={type:"v3",value:r.toArray()}:r&&r.isVector4?e.uniforms[s]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?e.uniforms[s]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?e.uniforms[s]={type:"m4",value:r.toArray()}:e.uniforms[s]={value:r}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class sp extends en{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new fe,this.projectionMatrix=new fe,this.projectionMatrixInverse=new fe,this.coordinateSystem=Di}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Yi=new C,ju=new lt,Yu=new lt;class Rn extends sp{constructor(t=50,e=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=lr*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(Qa*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return lr*2*Math.atan(Math.tan(Qa*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){Yi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Yi.x,Yi.y).multiplyScalar(-t/Yi.z),Yi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Yi.x,Yi.y).multiplyScalar(-t/Yi.z)}getViewSize(t,e){return this.getViewBounds(t,ju,Yu),e.subVectors(Yu,ju)}setViewOffset(t,e,n,s,a,r){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=a,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(Qa*.5*this.fov)/this.zoom,n=2*e,s=this.aspect*n,a=-.5*s;const r=this.view;if(this.view!==null&&this.view.enabled){const l=r.fullWidth,c=r.fullHeight;a+=r.offsetX*s/l,e-=r.offsetY*n/c,s*=r.width/l,n*=r.height/c}const o=this.filmOffset;o!==0&&(a+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+s,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const qs=-90,js=1;class Cg extends en{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new Rn(qs,js,t,e);s.layers=this.layers,this.add(s);const a=new Rn(qs,js,t,e);a.layers=this.layers,this.add(a);const r=new Rn(qs,js,t,e);r.layers=this.layers,this.add(r);const o=new Rn(qs,js,t,e);o.layers=this.layers,this.add(o);const l=new Rn(qs,js,t,e);l.layers=this.layers,this.add(l);const c=new Rn(qs,js,t,e);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,s,a,r,o,l]=e;for(const c of e)this.remove(c);if(t===Di)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),r.up.set(0,0,1),r.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(t===Ro)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),r.up.set(0,0,-1),r.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const c of e)this.add(c),c.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[a,r,o,l,c,h]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),f=t.getActiveMipmapLevel(),g=t.xr.enabled;t.xr.enabled=!1;const _=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,s),t.render(e,a),t.setRenderTarget(n,1,s),t.render(e,r),t.setRenderTarget(n,2,s),t.render(e,o),t.setRenderTarget(n,3,s),t.render(e,l),t.setRenderTarget(n,4,s),t.render(e,c),n.texture.generateMipmaps=_,t.setRenderTarget(n,5,s),t.render(e,h),t.setRenderTarget(u,d,f),t.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class ap extends on{constructor(t,e,n,s,a,r,o,l,c,h){t=t!==void 0?t:[],e=e!==void 0?e:Sa,super(t,e,n,s,a,r,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class Rg extends ei{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},s=[n,n,n,n,n,n];this.texture=new ap(s,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:Kn}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
65
65
 
66
66
  varying vec3 vWorldDirection;
67
67
 
@@ -96,7 +96,7 @@ Please report this to https://github.com/markedjs/marked.`,t){const s="<p>An err
96
96
  gl_FragColor = texture2D( tEquirect, sampleUV );
97
97
 
98
98
  }
99
- `},s=new Ye(5,5,5),a=new rn({name:"CubemapFromEquirect",uniforms:Ea(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:fn,blending:Je});a.uniforms.tEquirect.value=e;const r=new yt(s,a),o=e.minFilter;return e.minFilter===Ss&&(e.minFilter=Kn),new Cg(1,10,this).update(t,r),e.minFilter=o,r.geometry.dispose(),r.material.dispose(),this}clear(t,e,n,s){const a=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,n,s);t.setRenderTarget(a)}}const Tl=new C,Pg=new C,Lg=new Yt;class Ji{constructor(t=new C(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,s){return this.normal.set(t,e,n),this.constant=s,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const s=Tl.subVectors(n,e).cross(Pg.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(Tl),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const a=-(t.start.dot(this.normal)+this.constant)/s;return a<0||a>1?null:e.copy(t.start).addScaledVector(n,a)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||Lg.getNormalMatrix(t),s=this.coplanarPoint(Tl).applyMatrix4(t),a=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(a),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const gs=new Dh,Nr=new C;class Nh{constructor(t=new Ji,e=new Ji,n=new Ji,s=new Ji,a=new Ji,r=new Ji){this.planes=[t,e,n,s,a,r]}set(t,e,n,s,a,r){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(s),o[4].copy(a),o[5].copy(r),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=Di){const n=this.planes,s=t.elements,a=s[0],r=s[1],o=s[2],l=s[3],c=s[4],h=s[5],u=s[6],d=s[7],f=s[8],g=s[9],_=s[10],p=s[11],m=s[12],y=s[13],x=s[14],S=s[15];if(n[0].setComponents(l-a,d-c,p-f,S-m).normalize(),n[1].setComponents(l+a,d+c,p+f,S+m).normalize(),n[2].setComponents(l+r,d+h,p+g,S+y).normalize(),n[3].setComponents(l-r,d-h,p-g,S-y).normalize(),n[4].setComponents(l-o,d-u,p-_,S-x).normalize(),e===Di)n[5].setComponents(l+o,d+u,p+_,S+x).normalize();else if(e===Ro)n[5].setComponents(o,u,_,x).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),gs.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),gs.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(gs)}intersectsSprite(t){return gs.center.set(0,0,0),gs.radius=.7071067811865476,gs.applyMatrix4(t.matrixWorld),this.intersectsSphere(gs)}intersectsSphere(t){const e=this.planes,n=t.center,s=-t.radius;for(let a=0;a<6;a++)if(e[a].distanceToPoint(n)<s)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const s=e[n];if(Nr.x=s.normal.x>0?t.max.x:t.min.x,Nr.y=s.normal.y>0?t.max.y:t.min.y,Nr.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(Nr)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function op(){let i=null,t=!1,e=null,n=null;function s(a,r){e(a,r),n=i.requestAnimationFrame(s)}return{start:function(){t!==!0&&e!==null&&(n=i.requestAnimationFrame(s),t=!0)},stop:function(){i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(a){e=a},setContext:function(a){i=a}}}function Dg(i){const t=new WeakMap;function e(o,l){const c=o.array,h=o.usage,u=c.byteLength,d=i.createBuffer();i.bindBuffer(l,d),i.bufferData(l,c,h),o.onUploadCallback();let f;if(c instanceof Float32Array)f=i.FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=i.HALF_FLOAT:f=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=i.SHORT;else if(c instanceof Uint32Array)f=i.UNSIGNED_INT;else if(c instanceof Int32Array)f=i.INT;else if(c instanceof Int8Array)f=i.BYTE;else if(c instanceof Uint8Array)f=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,l,c){const h=l.array,u=l.updateRanges;if(i.bindBuffer(c,o),u.length===0)i.bufferSubData(c,0,h);else{u.sort((f,g)=>f.start-g.start);let d=0;for(let f=1;f<u.length;f++){const g=u[d],_=u[f];_.start<=g.start+g.count+1?g.count=Math.max(g.count,_.start+_.count-g.start):(++d,u[d]=_)}u.length=d+1;for(let f=0,g=u.length;f<g;f++){const _=u[f];i.bufferSubData(c,_.start*h.BYTES_PER_ELEMENT,h,_.start,_.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(o){return o.isInterleavedBufferAttribute&&(o=o.data),t.get(o)}function a(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=t.get(o);l&&(i.deleteBuffer(l.buffer),t.delete(o))}function r(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=t.get(o);(!h||h.version<o.version)&&t.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=t.get(o);if(c===void 0)t.set(o,e(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,o,l),c.version=o.version}}return{get:s,remove:a,update:r}}class vi extends pn{constructor(t=1,e=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:s};const a=t/2,r=e/2,o=Math.floor(n),l=Math.floor(s),c=o+1,h=l+1,u=t/o,d=e/l,f=[],g=[],_=[],p=[];for(let m=0;m<h;m++){const y=m*d-r;for(let x=0;x<c;x++){const S=x*u-a;g.push(S,-y,0),_.push(0,0,1),p.push(x/o),p.push(1-m/l)}}for(let m=0;m<l;m++)for(let y=0;y<o;y++){const x=y+c*m,S=y+c*(m+1),P=y+1+c*(m+1),T=y+1+c*m;f.push(x,S,T),f.push(S,P,T)}this.setIndex(f),this.setAttribute("position",new ue(g,3)),this.setAttribute("normal",new ue(_,3)),this.setAttribute("uv",new ue(p,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new vi(t.width,t.height,t.widthSegments,t.heightSegments)}}var Ig=`#ifdef USE_ALPHAHASH
99
+ `},s=new Ye(5,5,5),a=new an({name:"CubemapFromEquirect",uniforms:Ea(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:fn,blending:Je});a.uniforms.tEquirect.value=e;const r=new yt(s,a),o=e.minFilter;return e.minFilter===Ss&&(e.minFilter=Kn),new Cg(1,10,this).update(t,r),e.minFilter=o,r.geometry.dispose(),r.material.dispose(),this}clear(t,e,n,s){const a=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,n,s);t.setRenderTarget(a)}}const Tl=new C,Pg=new C,Lg=new Yt;class Ji{constructor(t=new C(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,s){return this.normal.set(t,e,n),this.constant=s,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const s=Tl.subVectors(n,e).cross(Pg.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(Tl),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const a=-(t.start.dot(this.normal)+this.constant)/s;return a<0||a>1?null:e.copy(t.start).addScaledVector(n,a)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||Lg.getNormalMatrix(t),s=this.coplanarPoint(Tl).applyMatrix4(t),a=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(a),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const gs=new Dh,Nr=new C;class Nh{constructor(t=new Ji,e=new Ji,n=new Ji,s=new Ji,a=new Ji,r=new Ji){this.planes=[t,e,n,s,a,r]}set(t,e,n,s,a,r){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(s),o[4].copy(a),o[5].copy(r),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=Di){const n=this.planes,s=t.elements,a=s[0],r=s[1],o=s[2],l=s[3],c=s[4],h=s[5],u=s[6],d=s[7],f=s[8],g=s[9],_=s[10],p=s[11],m=s[12],y=s[13],x=s[14],S=s[15];if(n[0].setComponents(l-a,d-c,p-f,S-m).normalize(),n[1].setComponents(l+a,d+c,p+f,S+m).normalize(),n[2].setComponents(l+r,d+h,p+g,S+y).normalize(),n[3].setComponents(l-r,d-h,p-g,S-y).normalize(),n[4].setComponents(l-o,d-u,p-_,S-x).normalize(),e===Di)n[5].setComponents(l+o,d+u,p+_,S+x).normalize();else if(e===Ro)n[5].setComponents(o,u,_,x).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),gs.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),gs.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(gs)}intersectsSprite(t){return gs.center.set(0,0,0),gs.radius=.7071067811865476,gs.applyMatrix4(t.matrixWorld),this.intersectsSphere(gs)}intersectsSphere(t){const e=this.planes,n=t.center,s=-t.radius;for(let a=0;a<6;a++)if(e[a].distanceToPoint(n)<s)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const s=e[n];if(Nr.x=s.normal.x>0?t.max.x:t.min.x,Nr.y=s.normal.y>0?t.max.y:t.min.y,Nr.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(Nr)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function rp(){let i=null,t=!1,e=null,n=null;function s(a,r){e(a,r),n=i.requestAnimationFrame(s)}return{start:function(){t!==!0&&e!==null&&(n=i.requestAnimationFrame(s),t=!0)},stop:function(){i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(a){e=a},setContext:function(a){i=a}}}function Dg(i){const t=new WeakMap;function e(o,l){const c=o.array,h=o.usage,u=c.byteLength,d=i.createBuffer();i.bindBuffer(l,d),i.bufferData(l,c,h),o.onUploadCallback();let f;if(c instanceof Float32Array)f=i.FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=i.HALF_FLOAT:f=i.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=i.SHORT;else if(c instanceof Uint32Array)f=i.UNSIGNED_INT;else if(c instanceof Int32Array)f=i.INT;else if(c instanceof Int8Array)f=i.BYTE;else if(c instanceof Uint8Array)f=i.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,l,c){const h=l.array,u=l.updateRanges;if(i.bindBuffer(c,o),u.length===0)i.bufferSubData(c,0,h);else{u.sort((f,g)=>f.start-g.start);let d=0;for(let f=1;f<u.length;f++){const g=u[d],_=u[f];_.start<=g.start+g.count+1?g.count=Math.max(g.count,_.start+_.count-g.start):(++d,u[d]=_)}u.length=d+1;for(let f=0,g=u.length;f<g;f++){const _=u[f];i.bufferSubData(c,_.start*h.BYTES_PER_ELEMENT,h,_.start,_.count)}l.clearUpdateRanges()}l.onUploadCallback()}function s(o){return o.isInterleavedBufferAttribute&&(o=o.data),t.get(o)}function a(o){o.isInterleavedBufferAttribute&&(o=o.data);const l=t.get(o);l&&(i.deleteBuffer(l.buffer),t.delete(o))}function r(o,l){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=t.get(o);(!h||h.version<o.version)&&t.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const c=t.get(o);if(c===void 0)t.set(o,e(o,l));else if(c.version<o.version){if(c.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(c.buffer,o,l),c.version=o.version}}return{get:s,remove:a,update:r}}class vi extends pn{constructor(t=1,e=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:s};const a=t/2,r=e/2,o=Math.floor(n),l=Math.floor(s),c=o+1,h=l+1,u=t/o,d=e/l,f=[],g=[],_=[],p=[];for(let m=0;m<h;m++){const y=m*d-r;for(let x=0;x<c;x++){const S=x*u-a;g.push(S,-y,0),_.push(0,0,1),p.push(x/o),p.push(1-m/l)}}for(let m=0;m<l;m++)for(let y=0;y<o;y++){const x=y+c*m,S=y+c*(m+1),P=y+1+c*(m+1),T=y+1+c*m;f.push(x,S,T),f.push(S,P,T)}this.setIndex(f),this.setAttribute("position",new ue(g,3)),this.setAttribute("normal",new ue(_,3)),this.setAttribute("uv",new ue(p,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new vi(t.width,t.height,t.widthSegments,t.heightSegments)}}var Ig=`#ifdef USE_ALPHAHASH
100
100
  if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
101
101
  #endif`,kg=`#ifdef USE_ALPHAHASH
102
102
  const float ALPHA_HASH_SCALE = 0.05;
@@ -3639,7 +3639,7 @@ void main() {
3639
3639
  #include <tonemapping_fragment>
3640
3640
  #include <colorspace_fragment>
3641
3641
  #include <fog_fragment>
3642
- }`,jt={alphahash_fragment:Ig,alphahash_pars_fragment:kg,alphamap_fragment:Ng,alphamap_pars_fragment:Ug,alphatest_fragment:Og,alphatest_pars_fragment:Fg,aomap_fragment:zg,aomap_pars_fragment:Bg,batching_pars_vertex:Hg,batching_vertex:Vg,begin_vertex:Gg,beginnormal_vertex:$g,bsdfs:Wg,iridescence_fragment:Xg,bumpmap_pars_fragment:qg,clipping_planes_fragment:jg,clipping_planes_pars_fragment:Yg,clipping_planes_pars_vertex:Kg,clipping_planes_vertex:Zg,color_fragment:Jg,color_pars_fragment:Qg,color_pars_vertex:tv,color_vertex:ev,common:nv,cube_uv_reflection_fragment:iv,defaultnormal_vertex:sv,displacementmap_pars_vertex:av,displacementmap_vertex:rv,emissivemap_fragment:ov,emissivemap_pars_fragment:lv,colorspace_fragment:cv,colorspace_pars_fragment:hv,envmap_fragment:uv,envmap_common_pars_fragment:dv,envmap_pars_fragment:fv,envmap_pars_vertex:pv,envmap_physical_pars_fragment:Ev,envmap_vertex:mv,fog_vertex:gv,fog_pars_vertex:vv,fog_fragment:_v,fog_pars_fragment:xv,gradientmap_pars_fragment:yv,lightmap_pars_fragment:Mv,lights_lambert_fragment:bv,lights_lambert_pars_fragment:Sv,lights_pars_begin:wv,lights_toon_fragment:Tv,lights_toon_pars_fragment:Av,lights_phong_fragment:Cv,lights_phong_pars_fragment:Rv,lights_physical_fragment:Pv,lights_physical_pars_fragment:Lv,lights_fragment_begin:Dv,lights_fragment_maps:Iv,lights_fragment_end:kv,logdepthbuf_fragment:Nv,logdepthbuf_pars_fragment:Uv,logdepthbuf_pars_vertex:Ov,logdepthbuf_vertex:Fv,map_fragment:zv,map_pars_fragment:Bv,map_particle_fragment:Hv,map_particle_pars_fragment:Vv,metalnessmap_fragment:Gv,metalnessmap_pars_fragment:$v,morphinstance_vertex:Wv,morphcolor_vertex:Xv,morphnormal_vertex:qv,morphtarget_pars_vertex:jv,morphtarget_vertex:Yv,normal_fragment_begin:Kv,normal_fragment_maps:Zv,normal_pars_fragment:Jv,normal_pars_vertex:Qv,normal_vertex:t_,normalmap_pars_fragment:e_,clearcoat_normal_fragment_begin:n_,clearcoat_normal_fragment_maps:i_,clearcoat_pars_fragment:s_,iridescence_pars_fragment:a_,opaque_fragment:r_,packing:o_,premultiplied_alpha_fragment:l_,project_vertex:c_,dithering_fragment:h_,dithering_pars_fragment:u_,roughnessmap_fragment:d_,roughnessmap_pars_fragment:f_,shadowmap_pars_fragment:p_,shadowmap_pars_vertex:m_,shadowmap_vertex:g_,shadowmask_pars_fragment:v_,skinbase_vertex:__,skinning_pars_vertex:x_,skinning_vertex:y_,skinnormal_vertex:M_,specularmap_fragment:b_,specularmap_pars_fragment:S_,tonemapping_fragment:w_,tonemapping_pars_fragment:E_,transmission_fragment:T_,transmission_pars_fragment:A_,uv_pars_fragment:C_,uv_pars_vertex:R_,uv_vertex:P_,worldpos_vertex:L_,background_vert:D_,background_frag:I_,backgroundCube_vert:k_,backgroundCube_frag:N_,cube_vert:U_,cube_frag:O_,depth_vert:F_,depth_frag:z_,distanceRGBA_vert:B_,distanceRGBA_frag:H_,equirect_vert:V_,equirect_frag:G_,linedashed_vert:$_,linedashed_frag:W_,meshbasic_vert:X_,meshbasic_frag:q_,meshlambert_vert:j_,meshlambert_frag:Y_,meshmatcap_vert:K_,meshmatcap_frag:Z_,meshnormal_vert:J_,meshnormal_frag:Q_,meshphong_vert:tx,meshphong_frag:ex,meshphysical_vert:nx,meshphysical_frag:ix,meshtoon_vert:sx,meshtoon_frag:ax,points_vert:rx,points_frag:ox,shadow_vert:lx,shadow_frag:cx,sprite_vert:hx,sprite_frag:ux},ft={common:{diffuse:{value:new te(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Yt},alphaMap:{value:null},alphaMapTransform:{value:new Yt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Yt}},envmap:{envMap:{value:null},envMapRotation:{value:new Yt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Yt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Yt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Yt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Yt},normalScale:{value:new lt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Yt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Yt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Yt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Yt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new te(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new te(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Yt},alphaTest:{value:0},uvTransform:{value:new Yt}},sprite:{diffuse:{value:new te(16777215)},opacity:{value:1},center:{value:new lt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Yt},alphaMap:{value:null},alphaMapTransform:{value:new Yt},alphaTest:{value:0}}},oi={basic:{uniforms:un([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.fog]),vertexShader:jt.meshbasic_vert,fragmentShader:jt.meshbasic_frag},lambert:{uniforms:un([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,ft.lights,{emissive:{value:new te(0)}}]),vertexShader:jt.meshlambert_vert,fragmentShader:jt.meshlambert_frag},phong:{uniforms:un([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,ft.lights,{emissive:{value:new te(0)},specular:{value:new te(1118481)},shininess:{value:30}}]),vertexShader:jt.meshphong_vert,fragmentShader:jt.meshphong_frag},standard:{uniforms:un([ft.common,ft.envmap,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.roughnessmap,ft.metalnessmap,ft.fog,ft.lights,{emissive:{value:new te(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:jt.meshphysical_vert,fragmentShader:jt.meshphysical_frag},toon:{uniforms:un([ft.common,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.gradientmap,ft.fog,ft.lights,{emissive:{value:new te(0)}}]),vertexShader:jt.meshtoon_vert,fragmentShader:jt.meshtoon_frag},matcap:{uniforms:un([ft.common,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,{matcap:{value:null}}]),vertexShader:jt.meshmatcap_vert,fragmentShader:jt.meshmatcap_frag},points:{uniforms:un([ft.points,ft.fog]),vertexShader:jt.points_vert,fragmentShader:jt.points_frag},dashed:{uniforms:un([ft.common,ft.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:jt.linedashed_vert,fragmentShader:jt.linedashed_frag},depth:{uniforms:un([ft.common,ft.displacementmap]),vertexShader:jt.depth_vert,fragmentShader:jt.depth_frag},normal:{uniforms:un([ft.common,ft.bumpmap,ft.normalmap,ft.displacementmap,{opacity:{value:1}}]),vertexShader:jt.meshnormal_vert,fragmentShader:jt.meshnormal_frag},sprite:{uniforms:un([ft.sprite,ft.fog]),vertexShader:jt.sprite_vert,fragmentShader:jt.sprite_frag},background:{uniforms:{uvTransform:{value:new Yt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:jt.background_vert,fragmentShader:jt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Yt}},vertexShader:jt.backgroundCube_vert,fragmentShader:jt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:jt.cube_vert,fragmentShader:jt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:jt.equirect_vert,fragmentShader:jt.equirect_frag},distanceRGBA:{uniforms:un([ft.common,ft.displacementmap,{referencePosition:{value:new C},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:jt.distanceRGBA_vert,fragmentShader:jt.distanceRGBA_frag},shadow:{uniforms:un([ft.lights,ft.fog,{color:{value:new te(0)},opacity:{value:1}}]),vertexShader:jt.shadow_vert,fragmentShader:jt.shadow_frag}};oi.physical={uniforms:un([oi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Yt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Yt},clearcoatNormalScale:{value:new lt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Yt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Yt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Yt},sheen:{value:0},sheenColor:{value:new te(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Yt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Yt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Yt},transmissionSamplerSize:{value:new lt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Yt},attenuationDistance:{value:0},attenuationColor:{value:new te(0)},specularColor:{value:new te(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Yt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Yt},anisotropyVector:{value:new lt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Yt}}]),vertexShader:jt.meshphysical_vert,fragmentShader:jt.meshphysical_frag};const Ur={r:0,b:0,g:0},vs=new mi,dx=new fe;function fx(i,t,e,n,s,a,r){const o=new te(0);let l=a===!0?0:1,c,h,u=null,d=0,f=null;function g(y){let x=y.isScene===!0?y.background:null;return x&&x.isTexture&&(x=(y.backgroundBlurriness>0?e:t).get(x)),x}function _(y){let x=!1;const S=g(y);S===null?m(o,l):S&&S.isColor&&(m(S,1),x=!0);const P=i.xr.getEnvironmentBlendMode();P==="additive"?n.buffers.color.setClear(0,0,0,1,r):P==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,r),(i.autoClear||x)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function p(y,x){const S=g(x);S&&(S.isCubeTexture||S.mapping===Bo)?(h===void 0&&(h=new yt(new Ye(1,1,1),new rn({name:"BackgroundCubeMaterial",uniforms:Ea(oi.backgroundCube.uniforms),vertexShader:oi.backgroundCube.vertexShader,fragmentShader:oi.backgroundCube.fragmentShader,side:fn,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(P,T,w){this.matrixWorld.copyPosition(w.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),vs.copy(x.backgroundRotation),vs.x*=-1,vs.y*=-1,vs.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(vs.y*=-1,vs.z*=-1),h.material.uniforms.envMap.value=S,h.material.uniforms.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(dx.makeRotationFromEuler(vs)),h.material.toneMapped=le.getTransfer(S.colorSpace)!==ye,(u!==S||d!==S.version||f!==i.toneMapping)&&(h.material.needsUpdate=!0,u=S,d=S.version,f=i.toneMapping),h.layers.enableAll(),y.unshift(h,h.geometry,h.material,0,0,null)):S&&S.isTexture&&(c===void 0&&(c=new yt(new vi(2,2),new rn({name:"BackgroundMaterial",uniforms:Ea(oi.background.uniforms),vertexShader:oi.background.vertexShader,fragmentShader:oi.background.fragmentShader,side:cs,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(c)),c.material.uniforms.t2D.value=S,c.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,c.material.toneMapped=le.getTransfer(S.colorSpace)!==ye,S.matrixAutoUpdate===!0&&S.updateMatrix(),c.material.uniforms.uvTransform.value.copy(S.matrix),(u!==S||d!==S.version||f!==i.toneMapping)&&(c.material.needsUpdate=!0,u=S,d=S.version,f=i.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null))}function m(y,x){y.getRGB(Ur,sp(i)),n.buffers.color.setClear(Ur.r,Ur.g,Ur.b,x,r)}return{getClearColor:function(){return o},setClearColor:function(y,x=1){o.set(y),l=x,m(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(y){l=y,m(o,l)},render:_,addToRenderList:p}}function px(i,t){const e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=d(null);let a=s,r=!1;function o(v,b,N,F,$){let W=!1;const z=u(F,N,b);a!==z&&(a=z,c(a.object)),W=f(v,F,N,$),W&&g(v,F,N,$),$!==null&&t.update($,i.ELEMENT_ARRAY_BUFFER),(W||r)&&(r=!1,S(v,b,N,F),$!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get($).buffer))}function l(){return i.createVertexArray()}function c(v){return i.bindVertexArray(v)}function h(v){return i.deleteVertexArray(v)}function u(v,b,N){const F=N.wireframe===!0;let $=n[v.id];$===void 0&&($={},n[v.id]=$);let W=$[b.id];W===void 0&&(W={},$[b.id]=W);let z=W[F];return z===void 0&&(z=d(l()),W[F]=z),z}function d(v){const b=[],N=[],F=[];for(let $=0;$<e;$++)b[$]=0,N[$]=0,F[$]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:b,enabledAttributes:N,attributeDivisors:F,object:v,attributes:{},index:null}}function f(v,b,N,F){const $=a.attributes,W=b.attributes;let z=0;const nt=N.getAttributes();for(const G in nt)if(nt[G].location>=0){const ht=$[G];let mt=W[G];if(mt===void 0&&(G==="instanceMatrix"&&v.instanceMatrix&&(mt=v.instanceMatrix),G==="instanceColor"&&v.instanceColor&&(mt=v.instanceColor)),ht===void 0||ht.attribute!==mt||mt&&ht.data!==mt.data)return!0;z++}return a.attributesNum!==z||a.index!==F}function g(v,b,N,F){const $={},W=b.attributes;let z=0;const nt=N.getAttributes();for(const G in nt)if(nt[G].location>=0){let ht=W[G];ht===void 0&&(G==="instanceMatrix"&&v.instanceMatrix&&(ht=v.instanceMatrix),G==="instanceColor"&&v.instanceColor&&(ht=v.instanceColor));const mt={};mt.attribute=ht,ht&&ht.data&&(mt.data=ht.data),$[G]=mt,z++}a.attributes=$,a.attributesNum=z,a.index=F}function _(){const v=a.newAttributes;for(let b=0,N=v.length;b<N;b++)v[b]=0}function p(v){m(v,0)}function m(v,b){const N=a.newAttributes,F=a.enabledAttributes,$=a.attributeDivisors;N[v]=1,F[v]===0&&(i.enableVertexAttribArray(v),F[v]=1),$[v]!==b&&(i.vertexAttribDivisor(v,b),$[v]=b)}function y(){const v=a.newAttributes,b=a.enabledAttributes;for(let N=0,F=b.length;N<F;N++)b[N]!==v[N]&&(i.disableVertexAttribArray(N),b[N]=0)}function x(v,b,N,F,$,W,z){z===!0?i.vertexAttribIPointer(v,b,N,$,W):i.vertexAttribPointer(v,b,N,F,$,W)}function S(v,b,N,F){_();const $=F.attributes,W=N.getAttributes(),z=b.defaultAttributeValues;for(const nt in W){const G=W[nt];if(G.location>=0){let at=$[nt];if(at===void 0&&(nt==="instanceMatrix"&&v.instanceMatrix&&(at=v.instanceMatrix),nt==="instanceColor"&&v.instanceColor&&(at=v.instanceColor)),at!==void 0){const ht=at.normalized,mt=at.itemSize,Xt=t.get(at);if(Xt===void 0)continue;const qt=Xt.buffer,q=Xt.type,st=Xt.bytesPerElement,Mt=q===i.INT||q===i.UNSIGNED_INT||at.gpuType===Sh;if(at.isInterleavedBufferAttribute){const dt=at.data,It=dt.stride,Rt=at.offset;if(dt.isInstancedInterleavedBuffer){for(let Nt=0;Nt<G.locationSize;Nt++)m(G.location+Nt,dt.meshPerAttribute);v.isInstancedMesh!==!0&&F._maxInstanceCount===void 0&&(F._maxInstanceCount=dt.meshPerAttribute*dt.count)}else for(let Nt=0;Nt<G.locationSize;Nt++)p(G.location+Nt);i.bindBuffer(i.ARRAY_BUFFER,qt);for(let Nt=0;Nt<G.locationSize;Nt++)x(G.location+Nt,mt/G.locationSize,q,ht,It*st,(Rt+mt/G.locationSize*Nt)*st,Mt)}else{if(at.isInstancedBufferAttribute){for(let dt=0;dt<G.locationSize;dt++)m(G.location+dt,at.meshPerAttribute);v.isInstancedMesh!==!0&&F._maxInstanceCount===void 0&&(F._maxInstanceCount=at.meshPerAttribute*at.count)}else for(let dt=0;dt<G.locationSize;dt++)p(G.location+dt);i.bindBuffer(i.ARRAY_BUFFER,qt);for(let dt=0;dt<G.locationSize;dt++)x(G.location+dt,mt/G.locationSize,q,ht,mt*st,mt/G.locationSize*dt*st,Mt)}}else if(z!==void 0){const ht=z[nt];if(ht!==void 0)switch(ht.length){case 2:i.vertexAttrib2fv(G.location,ht);break;case 3:i.vertexAttrib3fv(G.location,ht);break;case 4:i.vertexAttrib4fv(G.location,ht);break;default:i.vertexAttrib1fv(G.location,ht)}}}}y()}function P(){R();for(const v in n){const b=n[v];for(const N in b){const F=b[N];for(const $ in F)h(F[$].object),delete F[$];delete b[N]}delete n[v]}}function T(v){if(n[v.id]===void 0)return;const b=n[v.id];for(const N in b){const F=b[N];for(const $ in F)h(F[$].object),delete F[$];delete b[N]}delete n[v.id]}function w(v){for(const b in n){const N=n[b];if(N[v.id]===void 0)continue;const F=N[v.id];for(const $ in F)h(F[$].object),delete F[$];delete N[v.id]}}function R(){k(),r=!0,a!==s&&(a=s,c(a.object))}function k(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:R,resetDefaultState:k,dispose:P,releaseStatesOfGeometry:T,releaseStatesOfProgram:w,initAttributes:_,enableAttribute:p,disableUnusedAttributes:y}}function mx(i,t,e){let n;function s(c){n=c}function a(c,h){i.drawArrays(n,c,h),e.update(h,n,1)}function r(c,h,u){u!==0&&(i.drawArraysInstanced(n,c,h,u),e.update(h,n,u))}function o(c,h,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,h,0,u);let f=0;for(let g=0;g<u;g++)f+=h[g];e.update(f,n,1)}function l(c,h,u,d){if(u===0)return;const f=t.get("WEBGL_multi_draw");if(f===null)for(let g=0;g<c.length;g++)r(c[g],h[g],d[g]);else{f.multiDrawArraysInstancedWEBGL(n,c,0,h,0,d,0,u);let g=0;for(let _=0;_<u;_++)g+=h[_];for(let _=0;_<d.length;_++)e.update(g,n,d[_])}}this.setMode=s,this.render=a,this.renderInstances=r,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function gx(i,t,e,n){let s;function a(){if(s!==void 0)return s;if(t.has("EXT_texture_filter_anisotropic")===!0){const w=t.get("EXT_texture_filter_anisotropic");s=i.getParameter(w.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function r(w){return!(w!==zn&&n.convert(w)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(w){const R=w===Fi&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(w!==pi&&n.convert(w)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&w!==Li&&!R)}function l(w){if(w==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";w="mediump"}return w==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=e.precision!==void 0?e.precision:"highp";const h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const u=e.logarithmicDepthBuffer===!0,d=e.reverseDepthBuffer===!0&&t.has("EXT_clip_control");if(d===!0){const w=t.get("EXT_clip_control");w.clipControlEXT(w.LOWER_LEFT_EXT,w.ZERO_TO_ONE_EXT)}const f=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_TEXTURE_SIZE),p=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),m=i.getParameter(i.MAX_VERTEX_ATTRIBS),y=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),x=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),P=g>0,T=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:l,textureFormatReadable:r,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:u,reverseDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:_,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:y,maxVaryings:x,maxFragmentUniforms:S,vertexTextures:P,maxSamples:T}}function vx(i){const t=this;let e=null,n=0,s=!1,a=!1;const r=new Ji,o=new Yt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||n!==0||s;return s=d,n=u.length,f},this.beginShadows=function(){a=!0,h(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){const g=u.clippingPlanes,_=u.clipIntersection,p=u.clipShadows,m=i.get(u);if(!s||g===null||g.length===0||a&&!p)a?h(null):c();else{const y=a?0:n,x=y*4;let S=m.clippingState||null;l.value=S,S=h(g,d,x,f);for(let P=0;P!==x;++P)S[P]=e[P];m.clippingState=S,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,f,g){const _=u!==null?u.length:0;let p=null;if(_!==0){if(p=l.value,g!==!0||p===null){const m=f+_*4,y=d.matrixWorldInverse;o.getNormalMatrix(y),(p===null||p.length<m)&&(p=new Float32Array(m));for(let x=0,S=f;x!==_;++x,S+=4)r.copy(u[x]).applyMatrix4(y,o),r.normal.toArray(p,S),p[S+3]=r.constant}l.value=p,l.needsUpdate=!0}return t.numPlanes=_,t.numIntersection=0,p}}function _x(i){let t=new WeakMap;function e(r,o){return o===wc?r.mapping=Sa:o===Ec&&(r.mapping=wa),r}function n(r){if(r&&r.isTexture){const o=r.mapping;if(o===wc||o===Ec)if(t.has(r)){const l=t.get(r).texture;return e(l,r.mapping)}else{const l=r.image;if(l&&l.height>0){const c=new Rg(l.height);return c.fromEquirectangularTexture(i,r),t.set(r,c),r.addEventListener("dispose",s),e(c.texture,r.mapping)}else return null}}return r}function s(r){const o=r.target;o.removeEventListener("dispose",s);const l=t.get(o);l!==void 0&&(t.delete(o),l.dispose())}function a(){t=new WeakMap}return{get:n,dispose:a}}class Uh extends ap{constructor(t=-1,e=1,n=1,s=-1,a=.1,r=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=s,this.near=a,this.far=r,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,s,a,r){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=a,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let a=n-t,r=n+t,o=s+e,l=s-e;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=c*this.view.offsetX,r=a+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(a,r,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}const ra=4,Ku=[.125,.215,.35,.446,.526,.582],ys=20,Al=new Uh,Zu=new te;let Cl=null,Rl=0,Pl=0,Ll=!1;const xs=(1+Math.sqrt(5))/2,Ys=1/xs,Ju=[new C(-xs,Ys,0),new C(xs,Ys,0),new C(-Ys,0,xs),new C(Ys,0,xs),new C(0,xs,-Ys),new C(0,xs,Ys),new C(-1,1,-1),new C(1,1,-1),new C(-1,1,1),new C(1,1,1)];class Qc{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,s=100){Cl=this._renderer.getRenderTarget(),Rl=this._renderer.getActiveCubeFace(),Pl=this._renderer.getActiveMipmapLevel(),Ll=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const a=this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(t,n,s,a),e>0&&this._blur(a,0,0,e),this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ed(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=td(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(Cl,Rl,Pl),this._renderer.xr.enabled=Ll,t.scissorTest=!1,Or(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Sa||t.mapping===wa?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Cl=this._renderer.getRenderTarget(),Rl=this._renderer.getActiveCubeFace(),Pl=this._renderer.getActiveMipmapLevel(),Ll=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Kn,minFilter:Kn,generateMipmaps:!1,type:Fi,format:zn,colorSpace:us,depthBuffer:!1},s=Qu(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Qu(t,e,n);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=xx(a)),this._blurMaterial=yx(a,t,e)}return s}_compileMaterial(t){const e=new yt(this._lodPlanes[0],t);this._renderer.compile(e,Al)}_sceneToCubeUV(t,e,n,s){const o=new Rn(90,1,e,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,d=h.toneMapping;h.getClearColor(Zu),h.toneMapping=os,h.autoClear=!1;const f=new cn({name:"PMREM.Background",side:fn,depthWrite:!1,depthTest:!1}),g=new yt(new Ye,f);let _=!1;const p=t.background;p?p.isColor&&(f.color.copy(p),t.background=null,_=!0):(f.color.copy(Zu),_=!0);for(let m=0;m<6;m++){const y=m%3;y===0?(o.up.set(0,l[m],0),o.lookAt(c[m],0,0)):y===1?(o.up.set(0,0,l[m]),o.lookAt(0,c[m],0)):(o.up.set(0,l[m],0),o.lookAt(0,0,c[m]));const x=this._cubeSize;Or(s,y*x,m>2?x:0,x,x),h.setRenderTarget(s),_&&h.render(g,o),h.render(t,o)}g.geometry.dispose(),g.material.dispose(),h.toneMapping=d,h.autoClear=u,t.background=p}_textureToCubeUV(t,e){const n=this._renderer,s=t.mapping===Sa||t.mapping===wa;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=ed()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=td());const a=s?this._cubemapMaterial:this._equirectMaterial,r=new yt(this._lodPlanes[0],a),o=a.uniforms;o.envMap.value=t;const l=this._cubeSize;Or(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(r,Al)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const s=this._lodPlanes.length;for(let a=1;a<s;a++){const r=Math.sqrt(this._sigmas[a]*this._sigmas[a]-this._sigmas[a-1]*this._sigmas[a-1]),o=Ju[(s-a-1)%Ju.length];this._blur(t,a-1,a,r,o)}e.autoClear=n}_blur(t,e,n,s,a){const r=this._pingPongRenderTarget;this._halfBlur(t,r,e,n,s,"latitudinal",a),this._halfBlur(r,t,n,n,s,"longitudinal",a)}_halfBlur(t,e,n,s,a,r,o){const l=this._renderer,c=this._blurMaterial;r!=="latitudinal"&&r!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,u=new yt(this._lodPlanes[s],c),d=c.uniforms,f=this._sizeLods[n]-1,g=isFinite(a)?Math.PI/(2*f):2*Math.PI/(2*ys-1),_=a/g,p=isFinite(a)?1+Math.floor(h*_):ys;p>ys&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${ys}`);const m=[];let y=0;for(let w=0;w<ys;++w){const R=w/_,k=Math.exp(-R*R/2);m.push(k),w===0?y+=k:w<p&&(y+=2*k)}for(let w=0;w<m.length;w++)m[w]=m[w]/y;d.envMap.value=t.texture,d.samples.value=p,d.weights.value=m,d.latitudinal.value=r==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:x}=this;d.dTheta.value=g,d.mipInt.value=x-n;const S=this._sizeLods[s],P=3*S*(s>x-ra?s-x+ra:0),T=4*(this._cubeSize-S);Or(e,P,T,3*S,2*S),l.setRenderTarget(e),l.render(u,Al)}}function xx(i){const t=[],e=[],n=[];let s=i;const a=i-ra+1+Ku.length;for(let r=0;r<a;r++){const o=Math.pow(2,s);e.push(o);let l=1/o;r>i-ra?l=Ku[r-i+ra-1]:r===0&&(l=0),n.push(l);const c=1/(o-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,g=6,_=3,p=2,m=1,y=new Float32Array(_*g*f),x=new Float32Array(p*g*f),S=new Float32Array(m*g*f);for(let T=0;T<f;T++){const w=T%3*2/3-1,R=T>2?0:-1,k=[w,R,0,w+2/3,R,0,w+2/3,R+1,0,w,R,0,w+2/3,R+1,0,w,R+1,0];y.set(k,_*g*T),x.set(d,p*g*T);const v=[T,T,T,T,T,T];S.set(v,m*g*T)}const P=new pn;P.setAttribute("position",new ui(y,_)),P.setAttribute("uv",new ui(x,p)),P.setAttribute("faceIndex",new ui(S,m)),t.push(P),s>ra&&s--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function Qu(i,t,e){const n=new ei(i,t,e);return n.texture.mapping=Bo,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Or(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function yx(i,t,e){const n=new Float32Array(ys),s=new C(0,1,0);return new rn({name:"SphericalGaussianBlur",defines:{n:ys,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Oh(),fragmentShader:`
3642
+ }`,jt={alphahash_fragment:Ig,alphahash_pars_fragment:kg,alphamap_fragment:Ng,alphamap_pars_fragment:Ug,alphatest_fragment:Og,alphatest_pars_fragment:Fg,aomap_fragment:zg,aomap_pars_fragment:Bg,batching_pars_vertex:Hg,batching_vertex:Vg,begin_vertex:Gg,beginnormal_vertex:$g,bsdfs:Wg,iridescence_fragment:Xg,bumpmap_pars_fragment:qg,clipping_planes_fragment:jg,clipping_planes_pars_fragment:Yg,clipping_planes_pars_vertex:Kg,clipping_planes_vertex:Zg,color_fragment:Jg,color_pars_fragment:Qg,color_pars_vertex:tv,color_vertex:ev,common:nv,cube_uv_reflection_fragment:iv,defaultnormal_vertex:sv,displacementmap_pars_vertex:av,displacementmap_vertex:rv,emissivemap_fragment:ov,emissivemap_pars_fragment:lv,colorspace_fragment:cv,colorspace_pars_fragment:hv,envmap_fragment:uv,envmap_common_pars_fragment:dv,envmap_pars_fragment:fv,envmap_pars_vertex:pv,envmap_physical_pars_fragment:Ev,envmap_vertex:mv,fog_vertex:gv,fog_pars_vertex:vv,fog_fragment:_v,fog_pars_fragment:xv,gradientmap_pars_fragment:yv,lightmap_pars_fragment:Mv,lights_lambert_fragment:bv,lights_lambert_pars_fragment:Sv,lights_pars_begin:wv,lights_toon_fragment:Tv,lights_toon_pars_fragment:Av,lights_phong_fragment:Cv,lights_phong_pars_fragment:Rv,lights_physical_fragment:Pv,lights_physical_pars_fragment:Lv,lights_fragment_begin:Dv,lights_fragment_maps:Iv,lights_fragment_end:kv,logdepthbuf_fragment:Nv,logdepthbuf_pars_fragment:Uv,logdepthbuf_pars_vertex:Ov,logdepthbuf_vertex:Fv,map_fragment:zv,map_pars_fragment:Bv,map_particle_fragment:Hv,map_particle_pars_fragment:Vv,metalnessmap_fragment:Gv,metalnessmap_pars_fragment:$v,morphinstance_vertex:Wv,morphcolor_vertex:Xv,morphnormal_vertex:qv,morphtarget_pars_vertex:jv,morphtarget_vertex:Yv,normal_fragment_begin:Kv,normal_fragment_maps:Zv,normal_pars_fragment:Jv,normal_pars_vertex:Qv,normal_vertex:t_,normalmap_pars_fragment:e_,clearcoat_normal_fragment_begin:n_,clearcoat_normal_fragment_maps:i_,clearcoat_pars_fragment:s_,iridescence_pars_fragment:a_,opaque_fragment:r_,packing:o_,premultiplied_alpha_fragment:l_,project_vertex:c_,dithering_fragment:h_,dithering_pars_fragment:u_,roughnessmap_fragment:d_,roughnessmap_pars_fragment:f_,shadowmap_pars_fragment:p_,shadowmap_pars_vertex:m_,shadowmap_vertex:g_,shadowmask_pars_fragment:v_,skinbase_vertex:__,skinning_pars_vertex:x_,skinning_vertex:y_,skinnormal_vertex:M_,specularmap_fragment:b_,specularmap_pars_fragment:S_,tonemapping_fragment:w_,tonemapping_pars_fragment:E_,transmission_fragment:T_,transmission_pars_fragment:A_,uv_pars_fragment:C_,uv_pars_vertex:R_,uv_vertex:P_,worldpos_vertex:L_,background_vert:D_,background_frag:I_,backgroundCube_vert:k_,backgroundCube_frag:N_,cube_vert:U_,cube_frag:O_,depth_vert:F_,depth_frag:z_,distanceRGBA_vert:B_,distanceRGBA_frag:H_,equirect_vert:V_,equirect_frag:G_,linedashed_vert:$_,linedashed_frag:W_,meshbasic_vert:X_,meshbasic_frag:q_,meshlambert_vert:j_,meshlambert_frag:Y_,meshmatcap_vert:K_,meshmatcap_frag:Z_,meshnormal_vert:J_,meshnormal_frag:Q_,meshphong_vert:tx,meshphong_frag:ex,meshphysical_vert:nx,meshphysical_frag:ix,meshtoon_vert:sx,meshtoon_frag:ax,points_vert:rx,points_frag:ox,shadow_vert:lx,shadow_frag:cx,sprite_vert:hx,sprite_frag:ux},ft={common:{diffuse:{value:new te(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Yt},alphaMap:{value:null},alphaMapTransform:{value:new Yt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Yt}},envmap:{envMap:{value:null},envMapRotation:{value:new Yt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Yt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Yt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Yt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Yt},normalScale:{value:new lt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Yt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Yt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Yt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Yt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new te(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new te(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Yt},alphaTest:{value:0},uvTransform:{value:new Yt}},sprite:{diffuse:{value:new te(16777215)},opacity:{value:1},center:{value:new lt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Yt},alphaMap:{value:null},alphaMapTransform:{value:new Yt},alphaTest:{value:0}}},oi={basic:{uniforms:hn([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.fog]),vertexShader:jt.meshbasic_vert,fragmentShader:jt.meshbasic_frag},lambert:{uniforms:hn([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,ft.lights,{emissive:{value:new te(0)}}]),vertexShader:jt.meshlambert_vert,fragmentShader:jt.meshlambert_frag},phong:{uniforms:hn([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,ft.lights,{emissive:{value:new te(0)},specular:{value:new te(1118481)},shininess:{value:30}}]),vertexShader:jt.meshphong_vert,fragmentShader:jt.meshphong_frag},standard:{uniforms:hn([ft.common,ft.envmap,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.roughnessmap,ft.metalnessmap,ft.fog,ft.lights,{emissive:{value:new te(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:jt.meshphysical_vert,fragmentShader:jt.meshphysical_frag},toon:{uniforms:hn([ft.common,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.gradientmap,ft.fog,ft.lights,{emissive:{value:new te(0)}}]),vertexShader:jt.meshtoon_vert,fragmentShader:jt.meshtoon_frag},matcap:{uniforms:hn([ft.common,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,{matcap:{value:null}}]),vertexShader:jt.meshmatcap_vert,fragmentShader:jt.meshmatcap_frag},points:{uniforms:hn([ft.points,ft.fog]),vertexShader:jt.points_vert,fragmentShader:jt.points_frag},dashed:{uniforms:hn([ft.common,ft.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:jt.linedashed_vert,fragmentShader:jt.linedashed_frag},depth:{uniforms:hn([ft.common,ft.displacementmap]),vertexShader:jt.depth_vert,fragmentShader:jt.depth_frag},normal:{uniforms:hn([ft.common,ft.bumpmap,ft.normalmap,ft.displacementmap,{opacity:{value:1}}]),vertexShader:jt.meshnormal_vert,fragmentShader:jt.meshnormal_frag},sprite:{uniforms:hn([ft.sprite,ft.fog]),vertexShader:jt.sprite_vert,fragmentShader:jt.sprite_frag},background:{uniforms:{uvTransform:{value:new Yt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:jt.background_vert,fragmentShader:jt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Yt}},vertexShader:jt.backgroundCube_vert,fragmentShader:jt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:jt.cube_vert,fragmentShader:jt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:jt.equirect_vert,fragmentShader:jt.equirect_frag},distanceRGBA:{uniforms:hn([ft.common,ft.displacementmap,{referencePosition:{value:new C},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:jt.distanceRGBA_vert,fragmentShader:jt.distanceRGBA_frag},shadow:{uniforms:hn([ft.lights,ft.fog,{color:{value:new te(0)},opacity:{value:1}}]),vertexShader:jt.shadow_vert,fragmentShader:jt.shadow_frag}};oi.physical={uniforms:hn([oi.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Yt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Yt},clearcoatNormalScale:{value:new lt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Yt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Yt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Yt},sheen:{value:0},sheenColor:{value:new te(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Yt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Yt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Yt},transmissionSamplerSize:{value:new lt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Yt},attenuationDistance:{value:0},attenuationColor:{value:new te(0)},specularColor:{value:new te(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Yt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Yt},anisotropyVector:{value:new lt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Yt}}]),vertexShader:jt.meshphysical_vert,fragmentShader:jt.meshphysical_frag};const Ur={r:0,b:0,g:0},vs=new mi,dx=new fe;function fx(i,t,e,n,s,a,r){const o=new te(0);let l=a===!0?0:1,c,h,u=null,d=0,f=null;function g(y){let x=y.isScene===!0?y.background:null;return x&&x.isTexture&&(x=(y.backgroundBlurriness>0?e:t).get(x)),x}function _(y){let x=!1;const S=g(y);S===null?m(o,l):S&&S.isColor&&(m(S,1),x=!0);const P=i.xr.getEnvironmentBlendMode();P==="additive"?n.buffers.color.setClear(0,0,0,1,r):P==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,r),(i.autoClear||x)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function p(y,x){const S=g(x);S&&(S.isCubeTexture||S.mapping===Bo)?(h===void 0&&(h=new yt(new Ye(1,1,1),new an({name:"BackgroundCubeMaterial",uniforms:Ea(oi.backgroundCube.uniforms),vertexShader:oi.backgroundCube.vertexShader,fragmentShader:oi.backgroundCube.fragmentShader,side:fn,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(P,T,w){this.matrixWorld.copyPosition(w.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),vs.copy(x.backgroundRotation),vs.x*=-1,vs.y*=-1,vs.z*=-1,S.isCubeTexture&&S.isRenderTargetTexture===!1&&(vs.y*=-1,vs.z*=-1),h.material.uniforms.envMap.value=S,h.material.uniforms.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(dx.makeRotationFromEuler(vs)),h.material.toneMapped=le.getTransfer(S.colorSpace)!==ye,(u!==S||d!==S.version||f!==i.toneMapping)&&(h.material.needsUpdate=!0,u=S,d=S.version,f=i.toneMapping),h.layers.enableAll(),y.unshift(h,h.geometry,h.material,0,0,null)):S&&S.isTexture&&(c===void 0&&(c=new yt(new vi(2,2),new an({name:"BackgroundMaterial",uniforms:Ea(oi.background.uniforms),vertexShader:oi.background.vertexShader,fragmentShader:oi.background.fragmentShader,side:cs,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(c)),c.material.uniforms.t2D.value=S,c.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,c.material.toneMapped=le.getTransfer(S.colorSpace)!==ye,S.matrixAutoUpdate===!0&&S.updateMatrix(),c.material.uniforms.uvTransform.value.copy(S.matrix),(u!==S||d!==S.version||f!==i.toneMapping)&&(c.material.needsUpdate=!0,u=S,d=S.version,f=i.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null))}function m(y,x){y.getRGB(Ur,ip(i)),n.buffers.color.setClear(Ur.r,Ur.g,Ur.b,x,r)}return{getClearColor:function(){return o},setClearColor:function(y,x=1){o.set(y),l=x,m(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(y){l=y,m(o,l)},render:_,addToRenderList:p}}function px(i,t){const e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=d(null);let a=s,r=!1;function o(v,b,N,F,$){let W=!1;const z=u(F,N,b);a!==z&&(a=z,c(a.object)),W=f(v,F,N,$),W&&g(v,F,N,$),$!==null&&t.update($,i.ELEMENT_ARRAY_BUFFER),(W||r)&&(r=!1,S(v,b,N,F),$!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get($).buffer))}function l(){return i.createVertexArray()}function c(v){return i.bindVertexArray(v)}function h(v){return i.deleteVertexArray(v)}function u(v,b,N){const F=N.wireframe===!0;let $=n[v.id];$===void 0&&($={},n[v.id]=$);let W=$[b.id];W===void 0&&(W={},$[b.id]=W);let z=W[F];return z===void 0&&(z=d(l()),W[F]=z),z}function d(v){const b=[],N=[],F=[];for(let $=0;$<e;$++)b[$]=0,N[$]=0,F[$]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:b,enabledAttributes:N,attributeDivisors:F,object:v,attributes:{},index:null}}function f(v,b,N,F){const $=a.attributes,W=b.attributes;let z=0;const nt=N.getAttributes();for(const G in nt)if(nt[G].location>=0){const ht=$[G];let mt=W[G];if(mt===void 0&&(G==="instanceMatrix"&&v.instanceMatrix&&(mt=v.instanceMatrix),G==="instanceColor"&&v.instanceColor&&(mt=v.instanceColor)),ht===void 0||ht.attribute!==mt||mt&&ht.data!==mt.data)return!0;z++}return a.attributesNum!==z||a.index!==F}function g(v,b,N,F){const $={},W=b.attributes;let z=0;const nt=N.getAttributes();for(const G in nt)if(nt[G].location>=0){let ht=W[G];ht===void 0&&(G==="instanceMatrix"&&v.instanceMatrix&&(ht=v.instanceMatrix),G==="instanceColor"&&v.instanceColor&&(ht=v.instanceColor));const mt={};mt.attribute=ht,ht&&ht.data&&(mt.data=ht.data),$[G]=mt,z++}a.attributes=$,a.attributesNum=z,a.index=F}function _(){const v=a.newAttributes;for(let b=0,N=v.length;b<N;b++)v[b]=0}function p(v){m(v,0)}function m(v,b){const N=a.newAttributes,F=a.enabledAttributes,$=a.attributeDivisors;N[v]=1,F[v]===0&&(i.enableVertexAttribArray(v),F[v]=1),$[v]!==b&&(i.vertexAttribDivisor(v,b),$[v]=b)}function y(){const v=a.newAttributes,b=a.enabledAttributes;for(let N=0,F=b.length;N<F;N++)b[N]!==v[N]&&(i.disableVertexAttribArray(N),b[N]=0)}function x(v,b,N,F,$,W,z){z===!0?i.vertexAttribIPointer(v,b,N,$,W):i.vertexAttribPointer(v,b,N,F,$,W)}function S(v,b,N,F){_();const $=F.attributes,W=N.getAttributes(),z=b.defaultAttributeValues;for(const nt in W){const G=W[nt];if(G.location>=0){let at=$[nt];if(at===void 0&&(nt==="instanceMatrix"&&v.instanceMatrix&&(at=v.instanceMatrix),nt==="instanceColor"&&v.instanceColor&&(at=v.instanceColor)),at!==void 0){const ht=at.normalized,mt=at.itemSize,Xt=t.get(at);if(Xt===void 0)continue;const qt=Xt.buffer,q=Xt.type,st=Xt.bytesPerElement,Mt=q===i.INT||q===i.UNSIGNED_INT||at.gpuType===Sh;if(at.isInterleavedBufferAttribute){const dt=at.data,It=dt.stride,Rt=at.offset;if(dt.isInstancedInterleavedBuffer){for(let Nt=0;Nt<G.locationSize;Nt++)m(G.location+Nt,dt.meshPerAttribute);v.isInstancedMesh!==!0&&F._maxInstanceCount===void 0&&(F._maxInstanceCount=dt.meshPerAttribute*dt.count)}else for(let Nt=0;Nt<G.locationSize;Nt++)p(G.location+Nt);i.bindBuffer(i.ARRAY_BUFFER,qt);for(let Nt=0;Nt<G.locationSize;Nt++)x(G.location+Nt,mt/G.locationSize,q,ht,It*st,(Rt+mt/G.locationSize*Nt)*st,Mt)}else{if(at.isInstancedBufferAttribute){for(let dt=0;dt<G.locationSize;dt++)m(G.location+dt,at.meshPerAttribute);v.isInstancedMesh!==!0&&F._maxInstanceCount===void 0&&(F._maxInstanceCount=at.meshPerAttribute*at.count)}else for(let dt=0;dt<G.locationSize;dt++)p(G.location+dt);i.bindBuffer(i.ARRAY_BUFFER,qt);for(let dt=0;dt<G.locationSize;dt++)x(G.location+dt,mt/G.locationSize,q,ht,mt*st,mt/G.locationSize*dt*st,Mt)}}else if(z!==void 0){const ht=z[nt];if(ht!==void 0)switch(ht.length){case 2:i.vertexAttrib2fv(G.location,ht);break;case 3:i.vertexAttrib3fv(G.location,ht);break;case 4:i.vertexAttrib4fv(G.location,ht);break;default:i.vertexAttrib1fv(G.location,ht)}}}}y()}function P(){R();for(const v in n){const b=n[v];for(const N in b){const F=b[N];for(const $ in F)h(F[$].object),delete F[$];delete b[N]}delete n[v]}}function T(v){if(n[v.id]===void 0)return;const b=n[v.id];for(const N in b){const F=b[N];for(const $ in F)h(F[$].object),delete F[$];delete b[N]}delete n[v.id]}function w(v){for(const b in n){const N=n[b];if(N[v.id]===void 0)continue;const F=N[v.id];for(const $ in F)h(F[$].object),delete F[$];delete N[v.id]}}function R(){k(),r=!0,a!==s&&(a=s,c(a.object))}function k(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:R,resetDefaultState:k,dispose:P,releaseStatesOfGeometry:T,releaseStatesOfProgram:w,initAttributes:_,enableAttribute:p,disableUnusedAttributes:y}}function mx(i,t,e){let n;function s(c){n=c}function a(c,h){i.drawArrays(n,c,h),e.update(h,n,1)}function r(c,h,u){u!==0&&(i.drawArraysInstanced(n,c,h,u),e.update(h,n,u))}function o(c,h,u){if(u===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,h,0,u);let f=0;for(let g=0;g<u;g++)f+=h[g];e.update(f,n,1)}function l(c,h,u,d){if(u===0)return;const f=t.get("WEBGL_multi_draw");if(f===null)for(let g=0;g<c.length;g++)r(c[g],h[g],d[g]);else{f.multiDrawArraysInstancedWEBGL(n,c,0,h,0,d,0,u);let g=0;for(let _=0;_<u;_++)g+=h[_];for(let _=0;_<d.length;_++)e.update(g,n,d[_])}}this.setMode=s,this.render=a,this.renderInstances=r,this.renderMultiDraw=o,this.renderMultiDrawInstances=l}function gx(i,t,e,n){let s;function a(){if(s!==void 0)return s;if(t.has("EXT_texture_filter_anisotropic")===!0){const w=t.get("EXT_texture_filter_anisotropic");s=i.getParameter(w.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function r(w){return!(w!==zn&&n.convert(w)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(w){const R=w===Fi&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(w!==pi&&n.convert(w)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&w!==Li&&!R)}function l(w){if(w==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";w="mediump"}return w==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=e.precision!==void 0?e.precision:"highp";const h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const u=e.logarithmicDepthBuffer===!0,d=e.reverseDepthBuffer===!0&&t.has("EXT_clip_control");if(d===!0){const w=t.get("EXT_clip_control");w.clipControlEXT(w.LOWER_LEFT_EXT,w.ZERO_TO_ONE_EXT)}const f=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=i.getParameter(i.MAX_TEXTURE_SIZE),p=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),m=i.getParameter(i.MAX_VERTEX_ATTRIBS),y=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),x=i.getParameter(i.MAX_VARYING_VECTORS),S=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),P=g>0,T=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:l,textureFormatReadable:r,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:u,reverseDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:_,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:y,maxVaryings:x,maxFragmentUniforms:S,vertexTextures:P,maxSamples:T}}function vx(i){const t=this;let e=null,n=0,s=!1,a=!1;const r=new Ji,o=new Yt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||n!==0||s;return s=d,n=u.length,f},this.beginShadows=function(){a=!0,h(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){const g=u.clippingPlanes,_=u.clipIntersection,p=u.clipShadows,m=i.get(u);if(!s||g===null||g.length===0||a&&!p)a?h(null):c();else{const y=a?0:n,x=y*4;let S=m.clippingState||null;l.value=S,S=h(g,d,x,f);for(let P=0;P!==x;++P)S[P]=e[P];m.clippingState=S,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,f,g){const _=u!==null?u.length:0;let p=null;if(_!==0){if(p=l.value,g!==!0||p===null){const m=f+_*4,y=d.matrixWorldInverse;o.getNormalMatrix(y),(p===null||p.length<m)&&(p=new Float32Array(m));for(let x=0,S=f;x!==_;++x,S+=4)r.copy(u[x]).applyMatrix4(y,o),r.normal.toArray(p,S),p[S+3]=r.constant}l.value=p,l.needsUpdate=!0}return t.numPlanes=_,t.numIntersection=0,p}}function _x(i){let t=new WeakMap;function e(r,o){return o===wc?r.mapping=Sa:o===Ec&&(r.mapping=wa),r}function n(r){if(r&&r.isTexture){const o=r.mapping;if(o===wc||o===Ec)if(t.has(r)){const l=t.get(r).texture;return e(l,r.mapping)}else{const l=r.image;if(l&&l.height>0){const c=new Rg(l.height);return c.fromEquirectangularTexture(i,r),t.set(r,c),r.addEventListener("dispose",s),e(c.texture,r.mapping)}else return null}}return r}function s(r){const o=r.target;o.removeEventListener("dispose",s);const l=t.get(o);l!==void 0&&(t.delete(o),l.dispose())}function a(){t=new WeakMap}return{get:n,dispose:a}}class Uh extends sp{constructor(t=-1,e=1,n=1,s=-1,a=.1,r=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=s,this.near=a,this.far=r,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,s,a,r){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=a,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let a=n-t,r=n+t,o=s+e,l=s-e;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=c*this.view.offsetX,r=a+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(a,r,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}const ra=4,Ku=[.125,.215,.35,.446,.526,.582],ys=20,Al=new Uh,Zu=new te;let Cl=null,Rl=0,Pl=0,Ll=!1;const xs=(1+Math.sqrt(5))/2,Ys=1/xs,Ju=[new C(-xs,Ys,0),new C(xs,Ys,0),new C(-Ys,0,xs),new C(Ys,0,xs),new C(0,xs,-Ys),new C(0,xs,Ys),new C(-1,1,-1),new C(1,1,-1),new C(-1,1,1),new C(1,1,1)];class Qc{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,s=100){Cl=this._renderer.getRenderTarget(),Rl=this._renderer.getActiveCubeFace(),Pl=this._renderer.getActiveMipmapLevel(),Ll=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const a=this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(t,n,s,a),e>0&&this._blur(a,0,0,e),this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ed(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=td(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(Cl,Rl,Pl),this._renderer.xr.enabled=Ll,t.scissorTest=!1,Or(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Sa||t.mapping===wa?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Cl=this._renderer.getRenderTarget(),Rl=this._renderer.getActiveCubeFace(),Pl=this._renderer.getActiveMipmapLevel(),Ll=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Kn,minFilter:Kn,generateMipmaps:!1,type:Fi,format:zn,colorSpace:us,depthBuffer:!1},s=Qu(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Qu(t,e,n);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=xx(a)),this._blurMaterial=yx(a,t,e)}return s}_compileMaterial(t){const e=new yt(this._lodPlanes[0],t);this._renderer.compile(e,Al)}_sceneToCubeUV(t,e,n,s){const o=new Rn(90,1,e,n),l=[1,-1,1,1,1,1],c=[1,1,1,-1,-1,-1],h=this._renderer,u=h.autoClear,d=h.toneMapping;h.getClearColor(Zu),h.toneMapping=os,h.autoClear=!1;const f=new ln({name:"PMREM.Background",side:fn,depthWrite:!1,depthTest:!1}),g=new yt(new Ye,f);let _=!1;const p=t.background;p?p.isColor&&(f.color.copy(p),t.background=null,_=!0):(f.color.copy(Zu),_=!0);for(let m=0;m<6;m++){const y=m%3;y===0?(o.up.set(0,l[m],0),o.lookAt(c[m],0,0)):y===1?(o.up.set(0,0,l[m]),o.lookAt(0,c[m],0)):(o.up.set(0,l[m],0),o.lookAt(0,0,c[m]));const x=this._cubeSize;Or(s,y*x,m>2?x:0,x,x),h.setRenderTarget(s),_&&h.render(g,o),h.render(t,o)}g.geometry.dispose(),g.material.dispose(),h.toneMapping=d,h.autoClear=u,t.background=p}_textureToCubeUV(t,e){const n=this._renderer,s=t.mapping===Sa||t.mapping===wa;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=ed()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=td());const a=s?this._cubemapMaterial:this._equirectMaterial,r=new yt(this._lodPlanes[0],a),o=a.uniforms;o.envMap.value=t;const l=this._cubeSize;Or(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(r,Al)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const s=this._lodPlanes.length;for(let a=1;a<s;a++){const r=Math.sqrt(this._sigmas[a]*this._sigmas[a]-this._sigmas[a-1]*this._sigmas[a-1]),o=Ju[(s-a-1)%Ju.length];this._blur(t,a-1,a,r,o)}e.autoClear=n}_blur(t,e,n,s,a){const r=this._pingPongRenderTarget;this._halfBlur(t,r,e,n,s,"latitudinal",a),this._halfBlur(r,t,n,n,s,"longitudinal",a)}_halfBlur(t,e,n,s,a,r,o){const l=this._renderer,c=this._blurMaterial;r!=="latitudinal"&&r!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const h=3,u=new yt(this._lodPlanes[s],c),d=c.uniforms,f=this._sizeLods[n]-1,g=isFinite(a)?Math.PI/(2*f):2*Math.PI/(2*ys-1),_=a/g,p=isFinite(a)?1+Math.floor(h*_):ys;p>ys&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${ys}`);const m=[];let y=0;for(let w=0;w<ys;++w){const R=w/_,k=Math.exp(-R*R/2);m.push(k),w===0?y+=k:w<p&&(y+=2*k)}for(let w=0;w<m.length;w++)m[w]=m[w]/y;d.envMap.value=t.texture,d.samples.value=p,d.weights.value=m,d.latitudinal.value=r==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:x}=this;d.dTheta.value=g,d.mipInt.value=x-n;const S=this._sizeLods[s],P=3*S*(s>x-ra?s-x+ra:0),T=4*(this._cubeSize-S);Or(e,P,T,3*S,2*S),l.setRenderTarget(e),l.render(u,Al)}}function xx(i){const t=[],e=[],n=[];let s=i;const a=i-ra+1+Ku.length;for(let r=0;r<a;r++){const o=Math.pow(2,s);e.push(o);let l=1/o;r>i-ra?l=Ku[r-i+ra-1]:r===0&&(l=0),n.push(l);const c=1/(o-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,g=6,_=3,p=2,m=1,y=new Float32Array(_*g*f),x=new Float32Array(p*g*f),S=new Float32Array(m*g*f);for(let T=0;T<f;T++){const w=T%3*2/3-1,R=T>2?0:-1,k=[w,R,0,w+2/3,R,0,w+2/3,R+1,0,w,R,0,w+2/3,R+1,0,w,R+1,0];y.set(k,_*g*T),x.set(d,p*g*T);const v=[T,T,T,T,T,T];S.set(v,m*g*T)}const P=new pn;P.setAttribute("position",new ui(y,_)),P.setAttribute("uv",new ui(x,p)),P.setAttribute("faceIndex",new ui(S,m)),t.push(P),s>ra&&s--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function Qu(i,t,e){const n=new ei(i,t,e);return n.texture.mapping=Bo,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Or(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function yx(i,t,e){const n=new Float32Array(ys),s=new C(0,1,0);return new an({name:"SphericalGaussianBlur",defines:{n:ys,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Oh(),fragmentShader:`
3643
3643
 
3644
3644
  precision mediump float;
3645
3645
  precision mediump int;
@@ -3699,7 +3699,7 @@ void main() {
3699
3699
  }
3700
3700
 
3701
3701
  }
3702
- `,blending:Je,depthTest:!1,depthWrite:!1})}function td(){return new rn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Oh(),fragmentShader:`
3702
+ `,blending:Je,depthTest:!1,depthWrite:!1})}function td(){return new an({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Oh(),fragmentShader:`
3703
3703
 
3704
3704
  precision mediump float;
3705
3705
  precision mediump int;
@@ -3718,7 +3718,7 @@ void main() {
3718
3718
  gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
3719
3719
 
3720
3720
  }
3721
- `,blending:Je,depthTest:!1,depthWrite:!1})}function ed(){return new rn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Oh(),fragmentShader:`
3721
+ `,blending:Je,depthTest:!1,depthWrite:!1})}function ed(){return new an({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Oh(),fragmentShader:`
3722
3722
 
3723
3723
  precision mediump float;
3724
3724
  precision mediump int;
@@ -3789,13 +3789,13 @@ void main() {
3789
3789
  gl_Position = vec4( position, 1.0 );
3790
3790
 
3791
3791
  }
3792
- `}function Mx(i){let t=new WeakMap,e=null;function n(o){if(o&&o.isTexture){const l=o.mapping,c=l===wc||l===Ec,h=l===Sa||l===wa;if(c||h){let u=t.get(o);const d=u!==void 0?u.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return e===null&&(e=new Qc(i)),u=c?e.fromEquirectangular(o,u):e.fromCubemap(o,u),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),u.texture;if(u!==void 0)return u.texture;{const f=o.image;return c&&f&&f.height>0||h&&f&&s(f)?(e===null&&(e=new Qc(i)),u=c?e.fromEquirectangular(o):e.fromCubemap(o),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),o.addEventListener("dispose",a),u.texture):null}}}return o}function s(o){let l=0;const c=6;for(let h=0;h<c;h++)o[h]!==void 0&&l++;return l===c}function a(o){const l=o.target;l.removeEventListener("dispose",a);const c=t.get(l);c!==void 0&&(t.delete(l),c.dispose())}function r(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return{get:n,dispose:r}}function bx(i){const t={};function e(n){if(t[n]!==void 0)return t[n];let s;switch(n){case"WEBGL_depth_texture":s=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":s=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":s=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=i.getExtension(n)}return t[n]=s,s}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){const s=e(n);return s===null&&ho("THREE.WebGLRenderer: "+n+" extension not supported."),s}}}function Sx(i,t,e,n){const s={},a=new WeakMap;function r(u){const d=u.target;d.index!==null&&t.remove(d.index);for(const g in d.attributes)t.remove(d.attributes[g]);for(const g in d.morphAttributes){const _=d.morphAttributes[g];for(let p=0,m=_.length;p<m;p++)t.remove(_[p])}d.removeEventListener("dispose",r),delete s[d.id];const f=a.get(d);f&&(t.remove(f),a.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,e.memory.geometries--}function o(u,d){return s[d.id]===!0||(d.addEventListener("dispose",r),s[d.id]=!0,e.memory.geometries++),d}function l(u){const d=u.attributes;for(const g in d)t.update(d[g],i.ARRAY_BUFFER);const f=u.morphAttributes;for(const g in f){const _=f[g];for(let p=0,m=_.length;p<m;p++)t.update(_[p],i.ARRAY_BUFFER)}}function c(u){const d=[],f=u.index,g=u.attributes.position;let _=0;if(f!==null){const y=f.array;_=f.version;for(let x=0,S=y.length;x<S;x+=3){const P=y[x+0],T=y[x+1],w=y[x+2];d.push(P,T,T,w,w,P)}}else if(g!==void 0){const y=g.array;_=g.version;for(let x=0,S=y.length/3-1;x<S;x+=3){const P=x+0,T=x+1,w=x+2;d.push(P,T,T,w,w,P)}}else return;const p=new(Jf(d)?ip:np)(d,1);p.version=_;const m=a.get(u);m&&t.remove(m),a.set(u,p)}function h(u){const d=a.get(u);if(d){const f=u.index;f!==null&&d.version<f.version&&c(u)}else c(u);return a.get(u)}return{get:o,update:l,getWireframeAttribute:h}}function wx(i,t,e){let n;function s(d){n=d}let a,r;function o(d){a=d.type,r=d.bytesPerElement}function l(d,f){i.drawElements(n,f,a,d*r),e.update(f,n,1)}function c(d,f,g){g!==0&&(i.drawElementsInstanced(n,f,a,d*r,g),e.update(f,n,g))}function h(d,f,g){if(g===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,f,0,a,d,0,g);let p=0;for(let m=0;m<g;m++)p+=f[m];e.update(p,n,1)}function u(d,f,g,_){if(g===0)return;const p=t.get("WEBGL_multi_draw");if(p===null)for(let m=0;m<d.length;m++)c(d[m]/r,f[m],_[m]);else{p.multiDrawElementsInstancedWEBGL(n,f,0,a,d,0,_,0,g);let m=0;for(let y=0;y<g;y++)m+=f[y];for(let y=0;y<_.length;y++)e.update(m,n,_[y])}}this.setMode=s,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=u}function Ex(i){const t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(a,r,o){switch(e.calls++,r){case i.TRIANGLES:e.triangles+=o*(a/3);break;case i.LINES:e.lines+=o*(a/2);break;case i.LINE_STRIP:e.lines+=o*(a-1);break;case i.LINE_LOOP:e.lines+=o*a;break;case i.POINTS:e.points+=o*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",r);break}}function s(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:s,update:n}}function Tx(i,t,e){const n=new WeakMap,s=new me;function a(r,o,l){const c=r.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let d=n.get(o);if(d===void 0||d.count!==u){let v=function(){R.dispose(),n.delete(o),o.removeEventListener("dispose",v)};var f=v;d!==void 0&&d.texture.dispose();const g=o.morphAttributes.position!==void 0,_=o.morphAttributes.normal!==void 0,p=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],y=o.morphAttributes.normal||[],x=o.morphAttributes.color||[];let S=0;g===!0&&(S=1),_===!0&&(S=2),p===!0&&(S=3);let P=o.attributes.position.count*S,T=1;P>t.maxTextureSize&&(T=Math.ceil(P/t.maxTextureSize),P=t.maxTextureSize);const w=new Float32Array(P*T*4*u),R=new tp(w,P,T,u);R.type=Li,R.needsUpdate=!0;const k=S*4;for(let b=0;b<u;b++){const N=m[b],F=y[b],$=x[b],W=P*T*4*b;for(let z=0;z<N.count;z++){const nt=z*k;g===!0&&(s.fromBufferAttribute(N,z),w[W+nt+0]=s.x,w[W+nt+1]=s.y,w[W+nt+2]=s.z,w[W+nt+3]=0),_===!0&&(s.fromBufferAttribute(F,z),w[W+nt+4]=s.x,w[W+nt+5]=s.y,w[W+nt+6]=s.z,w[W+nt+7]=0),p===!0&&(s.fromBufferAttribute($,z),w[W+nt+8]=s.x,w[W+nt+9]=s.y,w[W+nt+10]=s.z,w[W+nt+11]=$.itemSize===4?s.w:1)}}d={count:u,texture:R,size:new lt(P,T)},n.set(o,d),o.addEventListener("dispose",v)}if(r.isInstancedMesh===!0&&r.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",r.morphTexture,e);else{let g=0;for(let p=0;p<c.length;p++)g+=c[p];const _=o.morphTargetsRelative?1:1-g;l.getUniforms().setValue(i,"morphTargetBaseInfluence",_),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",d.texture,e),l.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:a}}function Ax(i,t,e,n){let s=new WeakMap;function a(l){const c=n.render.frame,h=l.geometry,u=t.get(l,h);if(s.get(u)!==c&&(t.update(u),s.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),s.get(l)!==c&&(e.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&e.update(l.instanceColor,i.ARRAY_BUFFER),s.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;s.get(d)!==c&&(d.update(),s.set(d,c))}return u}function r(){s=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),e.remove(c.instanceMatrix),c.instanceColor!==null&&e.remove(c.instanceColor)}return{update:a,dispose:r}}class Fh extends ln{constructor(t,e,n,s,a,r,o,l,c,h=_a){if(h!==_a&&h!==Ls)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===_a&&(n=Rs),n===void 0&&h===Ls&&(n=Ps),super(null,s,a,r,o,l,h,n,c),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=o!==void 0?o:on,this.minFilter=l!==void 0?l:on,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}const lp=new ln,nd=new Fh(1,1),cp=new tp,hp=new pg,up=new rp,id=[],sd=[],ad=new Float32Array(16),rd=new Float32Array(9),od=new Float32Array(4);function Pa(i,t,e){const n=i[0];if(n<=0||n>0)return i;const s=t*e;let a=id[s];if(a===void 0&&(a=new Float32Array(s),id[s]=a),t!==0){n.toArray(a,0);for(let r=1,o=0;r!==t;++r)o+=e,i[r].toArray(a,o)}return a}function Ge(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e<n;e++)if(i[e]!==t[e])return!1;return!0}function $e(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function Vo(i,t){let e=sd[t];e===void 0&&(e=new Int32Array(t),sd[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function Cx(i,t){const e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function Rx(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Ge(e,t))return;i.uniform2fv(this.addr,t),$e(e,t)}}function Px(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(i.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(Ge(e,t))return;i.uniform3fv(this.addr,t),$e(e,t)}}function Lx(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Ge(e,t))return;i.uniform4fv(this.addr,t),$e(e,t)}}function Dx(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Ge(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),$e(e,t)}else{if(Ge(e,n))return;od.set(n),i.uniformMatrix2fv(this.addr,!1,od),$e(e,n)}}function Ix(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Ge(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),$e(e,t)}else{if(Ge(e,n))return;rd.set(n),i.uniformMatrix3fv(this.addr,!1,rd),$e(e,n)}}function kx(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Ge(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),$e(e,t)}else{if(Ge(e,n))return;ad.set(n),i.uniformMatrix4fv(this.addr,!1,ad),$e(e,n)}}function Nx(i,t){const e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function Ux(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Ge(e,t))return;i.uniform2iv(this.addr,t),$e(e,t)}}function Ox(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Ge(e,t))return;i.uniform3iv(this.addr,t),$e(e,t)}}function Fx(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Ge(e,t))return;i.uniform4iv(this.addr,t),$e(e,t)}}function zx(i,t){const e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function Bx(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Ge(e,t))return;i.uniform2uiv(this.addr,t),$e(e,t)}}function Hx(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Ge(e,t))return;i.uniform3uiv(this.addr,t),$e(e,t)}}function Vx(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Ge(e,t))return;i.uniform4uiv(this.addr,t),$e(e,t)}}function Gx(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let a;this.type===i.SAMPLER_2D_SHADOW?(nd.compareFunction=Zf,a=nd):a=lp,e.setTexture2D(t||a,s)}function $x(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture3D(t||hp,s)}function Wx(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTextureCube(t||up,s)}function Xx(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture2DArray(t||cp,s)}function qx(i){switch(i){case 5126:return Cx;case 35664:return Rx;case 35665:return Px;case 35666:return Lx;case 35674:return Dx;case 35675:return Ix;case 35676:return kx;case 5124:case 35670:return Nx;case 35667:case 35671:return Ux;case 35668:case 35672:return Ox;case 35669:case 35673:return Fx;case 5125:return zx;case 36294:return Bx;case 36295:return Hx;case 36296:return Vx;case 35678:case 36198:case 36298:case 36306:case 35682:return Gx;case 35679:case 36299:case 36307:return $x;case 35680:case 36300:case 36308:case 36293:return Wx;case 36289:case 36303:case 36311:case 36292:return Xx}}function jx(i,t){i.uniform1fv(this.addr,t)}function Yx(i,t){const e=Pa(t,this.size,2);i.uniform2fv(this.addr,e)}function Kx(i,t){const e=Pa(t,this.size,3);i.uniform3fv(this.addr,e)}function Zx(i,t){const e=Pa(t,this.size,4);i.uniform4fv(this.addr,e)}function Jx(i,t){const e=Pa(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function Qx(i,t){const e=Pa(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function ty(i,t){const e=Pa(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function ey(i,t){i.uniform1iv(this.addr,t)}function ny(i,t){i.uniform2iv(this.addr,t)}function iy(i,t){i.uniform3iv(this.addr,t)}function sy(i,t){i.uniform4iv(this.addr,t)}function ay(i,t){i.uniform1uiv(this.addr,t)}function ry(i,t){i.uniform2uiv(this.addr,t)}function oy(i,t){i.uniform3uiv(this.addr,t)}function ly(i,t){i.uniform4uiv(this.addr,t)}function cy(i,t,e){const n=this.cache,s=t.length,a=Vo(e,s);Ge(n,a)||(i.uniform1iv(this.addr,a),$e(n,a));for(let r=0;r!==s;++r)e.setTexture2D(t[r]||lp,a[r])}function hy(i,t,e){const n=this.cache,s=t.length,a=Vo(e,s);Ge(n,a)||(i.uniform1iv(this.addr,a),$e(n,a));for(let r=0;r!==s;++r)e.setTexture3D(t[r]||hp,a[r])}function uy(i,t,e){const n=this.cache,s=t.length,a=Vo(e,s);Ge(n,a)||(i.uniform1iv(this.addr,a),$e(n,a));for(let r=0;r!==s;++r)e.setTextureCube(t[r]||up,a[r])}function dy(i,t,e){const n=this.cache,s=t.length,a=Vo(e,s);Ge(n,a)||(i.uniform1iv(this.addr,a),$e(n,a));for(let r=0;r!==s;++r)e.setTexture2DArray(t[r]||cp,a[r])}function fy(i){switch(i){case 5126:return jx;case 35664:return Yx;case 35665:return Kx;case 35666:return Zx;case 35674:return Jx;case 35675:return Qx;case 35676:return ty;case 5124:case 35670:return ey;case 35667:case 35671:return ny;case 35668:case 35672:return iy;case 35669:case 35673:return sy;case 5125:return ay;case 36294:return ry;case 36295:return oy;case 36296:return ly;case 35678:case 36198:case 36298:case 36306:case 35682:return cy;case 35679:case 36299:case 36307:return hy;case 35680:case 36300:case 36308:case 36293:return uy;case 36289:case 36303:case 36311:case 36292:return dy}}class py{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=qx(e.type)}}class my{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=fy(e.type)}}class gy{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const s=this.seq;for(let a=0,r=s.length;a!==r;++a){const o=s[a];o.setValue(t,e[o.id],n)}}}const Dl=/(\w+)(\])?(\[|\.)?/g;function ld(i,t){i.seq.push(t),i.map[t.id]=t}function vy(i,t,e){const n=i.name,s=n.length;for(Dl.lastIndex=0;;){const a=Dl.exec(n),r=Dl.lastIndex;let o=a[1];const l=a[2]==="]",c=a[3];if(l&&(o=o|0),c===void 0||c==="["&&r+2===s){ld(e,c===void 0?new py(o,i,t):new my(o,i,t));break}else{let u=e.map[o];u===void 0&&(u=new gy(o),ld(e,u)),e=u}}}class uo{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){const a=t.getActiveUniform(e,s),r=t.getUniformLocation(e,a.name);vy(a,r,this)}}setValue(t,e,n,s){const a=this.map[e];a!==void 0&&a.setValue(t,n,s)}setOptional(t,e,n){const s=e[n];s!==void 0&&this.setValue(t,n,s)}static upload(t,e,n,s){for(let a=0,r=e.length;a!==r;++a){const o=e[a],l=n[o.id];l.needsUpdate!==!1&&o.setValue(t,l.value,s)}}static seqWithValue(t,e){const n=[];for(let s=0,a=t.length;s!==a;++s){const r=t[s];r.id in e&&n.push(r)}return n}}function cd(i,t,e){const n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}const _y=37297;let xy=0;function yy(i,t){const e=i.split(`
3792
+ `}function Mx(i){let t=new WeakMap,e=null;function n(o){if(o&&o.isTexture){const l=o.mapping,c=l===wc||l===Ec,h=l===Sa||l===wa;if(c||h){let u=t.get(o);const d=u!==void 0?u.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return e===null&&(e=new Qc(i)),u=c?e.fromEquirectangular(o,u):e.fromCubemap(o,u),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),u.texture;if(u!==void 0)return u.texture;{const f=o.image;return c&&f&&f.height>0||h&&f&&s(f)?(e===null&&(e=new Qc(i)),u=c?e.fromEquirectangular(o):e.fromCubemap(o),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),o.addEventListener("dispose",a),u.texture):null}}}return o}function s(o){let l=0;const c=6;for(let h=0;h<c;h++)o[h]!==void 0&&l++;return l===c}function a(o){const l=o.target;l.removeEventListener("dispose",a);const c=t.get(l);c!==void 0&&(t.delete(l),c.dispose())}function r(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return{get:n,dispose:r}}function bx(i){const t={};function e(n){if(t[n]!==void 0)return t[n];let s;switch(n){case"WEBGL_depth_texture":s=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":s=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":s=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":s=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:s=i.getExtension(n)}return t[n]=s,s}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){const s=e(n);return s===null&&ho("THREE.WebGLRenderer: "+n+" extension not supported."),s}}}function Sx(i,t,e,n){const s={},a=new WeakMap;function r(u){const d=u.target;d.index!==null&&t.remove(d.index);for(const g in d.attributes)t.remove(d.attributes[g]);for(const g in d.morphAttributes){const _=d.morphAttributes[g];for(let p=0,m=_.length;p<m;p++)t.remove(_[p])}d.removeEventListener("dispose",r),delete s[d.id];const f=a.get(d);f&&(t.remove(f),a.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,e.memory.geometries--}function o(u,d){return s[d.id]===!0||(d.addEventListener("dispose",r),s[d.id]=!0,e.memory.geometries++),d}function l(u){const d=u.attributes;for(const g in d)t.update(d[g],i.ARRAY_BUFFER);const f=u.morphAttributes;for(const g in f){const _=f[g];for(let p=0,m=_.length;p<m;p++)t.update(_[p],i.ARRAY_BUFFER)}}function c(u){const d=[],f=u.index,g=u.attributes.position;let _=0;if(f!==null){const y=f.array;_=f.version;for(let x=0,S=y.length;x<S;x+=3){const P=y[x+0],T=y[x+1],w=y[x+2];d.push(P,T,T,w,w,P)}}else if(g!==void 0){const y=g.array;_=g.version;for(let x=0,S=y.length/3-1;x<S;x+=3){const P=x+0,T=x+1,w=x+2;d.push(P,T,T,w,w,P)}}else return;const p=new(Zf(d)?np:ep)(d,1);p.version=_;const m=a.get(u);m&&t.remove(m),a.set(u,p)}function h(u){const d=a.get(u);if(d){const f=u.index;f!==null&&d.version<f.version&&c(u)}else c(u);return a.get(u)}return{get:o,update:l,getWireframeAttribute:h}}function wx(i,t,e){let n;function s(d){n=d}let a,r;function o(d){a=d.type,r=d.bytesPerElement}function l(d,f){i.drawElements(n,f,a,d*r),e.update(f,n,1)}function c(d,f,g){g!==0&&(i.drawElementsInstanced(n,f,a,d*r,g),e.update(f,n,g))}function h(d,f,g){if(g===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,f,0,a,d,0,g);let p=0;for(let m=0;m<g;m++)p+=f[m];e.update(p,n,1)}function u(d,f,g,_){if(g===0)return;const p=t.get("WEBGL_multi_draw");if(p===null)for(let m=0;m<d.length;m++)c(d[m]/r,f[m],_[m]);else{p.multiDrawElementsInstancedWEBGL(n,f,0,a,d,0,_,0,g);let m=0;for(let y=0;y<g;y++)m+=f[y];for(let y=0;y<_.length;y++)e.update(m,n,_[y])}}this.setMode=s,this.setIndex=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=u}function Ex(i){const t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(a,r,o){switch(e.calls++,r){case i.TRIANGLES:e.triangles+=o*(a/3);break;case i.LINES:e.lines+=o*(a/2);break;case i.LINE_STRIP:e.lines+=o*(a-1);break;case i.LINE_LOOP:e.lines+=o*a;break;case i.POINTS:e.points+=o*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",r);break}}function s(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:s,update:n}}function Tx(i,t,e){const n=new WeakMap,s=new me;function a(r,o,l){const c=r.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let d=n.get(o);if(d===void 0||d.count!==u){let v=function(){R.dispose(),n.delete(o),o.removeEventListener("dispose",v)};var f=v;d!==void 0&&d.texture.dispose();const g=o.morphAttributes.position!==void 0,_=o.morphAttributes.normal!==void 0,p=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],y=o.morphAttributes.normal||[],x=o.morphAttributes.color||[];let S=0;g===!0&&(S=1),_===!0&&(S=2),p===!0&&(S=3);let P=o.attributes.position.count*S,T=1;P>t.maxTextureSize&&(T=Math.ceil(P/t.maxTextureSize),P=t.maxTextureSize);const w=new Float32Array(P*T*4*u),R=new Qf(w,P,T,u);R.type=Li,R.needsUpdate=!0;const k=S*4;for(let b=0;b<u;b++){const N=m[b],F=y[b],$=x[b],W=P*T*4*b;for(let z=0;z<N.count;z++){const nt=z*k;g===!0&&(s.fromBufferAttribute(N,z),w[W+nt+0]=s.x,w[W+nt+1]=s.y,w[W+nt+2]=s.z,w[W+nt+3]=0),_===!0&&(s.fromBufferAttribute(F,z),w[W+nt+4]=s.x,w[W+nt+5]=s.y,w[W+nt+6]=s.z,w[W+nt+7]=0),p===!0&&(s.fromBufferAttribute($,z),w[W+nt+8]=s.x,w[W+nt+9]=s.y,w[W+nt+10]=s.z,w[W+nt+11]=$.itemSize===4?s.w:1)}}d={count:u,texture:R,size:new lt(P,T)},n.set(o,d),o.addEventListener("dispose",v)}if(r.isInstancedMesh===!0&&r.morphTexture!==null)l.getUniforms().setValue(i,"morphTexture",r.morphTexture,e);else{let g=0;for(let p=0;p<c.length;p++)g+=c[p];const _=o.morphTargetsRelative?1:1-g;l.getUniforms().setValue(i,"morphTargetBaseInfluence",_),l.getUniforms().setValue(i,"morphTargetInfluences",c)}l.getUniforms().setValue(i,"morphTargetsTexture",d.texture,e),l.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:a}}function Ax(i,t,e,n){let s=new WeakMap;function a(l){const c=n.render.frame,h=l.geometry,u=t.get(l,h);if(s.get(u)!==c&&(t.update(u),s.set(u,c)),l.isInstancedMesh&&(l.hasEventListener("dispose",o)===!1&&l.addEventListener("dispose",o),s.get(l)!==c&&(e.update(l.instanceMatrix,i.ARRAY_BUFFER),l.instanceColor!==null&&e.update(l.instanceColor,i.ARRAY_BUFFER),s.set(l,c))),l.isSkinnedMesh){const d=l.skeleton;s.get(d)!==c&&(d.update(),s.set(d,c))}return u}function r(){s=new WeakMap}function o(l){const c=l.target;c.removeEventListener("dispose",o),e.remove(c.instanceMatrix),c.instanceColor!==null&&e.remove(c.instanceColor)}return{update:a,dispose:r}}class Fh extends on{constructor(t,e,n,s,a,r,o,l,c,h=_a){if(h!==_a&&h!==Ls)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===_a&&(n=Rs),n===void 0&&h===Ls&&(n=Ps),super(null,s,a,r,o,l,h,n,c),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=o!==void 0?o:rn,this.minFilter=l!==void 0?l:rn,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}const op=new on,nd=new Fh(1,1),lp=new Qf,cp=new pg,hp=new ap,id=[],sd=[],ad=new Float32Array(16),rd=new Float32Array(9),od=new Float32Array(4);function Pa(i,t,e){const n=i[0];if(n<=0||n>0)return i;const s=t*e;let a=id[s];if(a===void 0&&(a=new Float32Array(s),id[s]=a),t!==0){n.toArray(a,0);for(let r=1,o=0;r!==t;++r)o+=e,i[r].toArray(a,o)}return a}function Ve(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e<n;e++)if(i[e]!==t[e])return!1;return!0}function Ge(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function Vo(i,t){let e=sd[t];e===void 0&&(e=new Int32Array(t),sd[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function Cx(i,t){const e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function Rx(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Ve(e,t))return;i.uniform2fv(this.addr,t),Ge(e,t)}}function Px(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(i.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(Ve(e,t))return;i.uniform3fv(this.addr,t),Ge(e,t)}}function Lx(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Ve(e,t))return;i.uniform4fv(this.addr,t),Ge(e,t)}}function Dx(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Ve(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),Ge(e,t)}else{if(Ve(e,n))return;od.set(n),i.uniformMatrix2fv(this.addr,!1,od),Ge(e,n)}}function Ix(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Ve(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),Ge(e,t)}else{if(Ve(e,n))return;rd.set(n),i.uniformMatrix3fv(this.addr,!1,rd),Ge(e,n)}}function kx(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Ve(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),Ge(e,t)}else{if(Ve(e,n))return;ad.set(n),i.uniformMatrix4fv(this.addr,!1,ad),Ge(e,n)}}function Nx(i,t){const e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function Ux(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Ve(e,t))return;i.uniform2iv(this.addr,t),Ge(e,t)}}function Ox(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Ve(e,t))return;i.uniform3iv(this.addr,t),Ge(e,t)}}function Fx(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Ve(e,t))return;i.uniform4iv(this.addr,t),Ge(e,t)}}function zx(i,t){const e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function Bx(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Ve(e,t))return;i.uniform2uiv(this.addr,t),Ge(e,t)}}function Hx(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Ve(e,t))return;i.uniform3uiv(this.addr,t),Ge(e,t)}}function Vx(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(i.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Ve(e,t))return;i.uniform4uiv(this.addr,t),Ge(e,t)}}function Gx(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let a;this.type===i.SAMPLER_2D_SHADOW?(nd.compareFunction=Kf,a=nd):a=op,e.setTexture2D(t||a,s)}function $x(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture3D(t||cp,s)}function Wx(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTextureCube(t||hp,s)}function Xx(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture2DArray(t||lp,s)}function qx(i){switch(i){case 5126:return Cx;case 35664:return Rx;case 35665:return Px;case 35666:return Lx;case 35674:return Dx;case 35675:return Ix;case 35676:return kx;case 5124:case 35670:return Nx;case 35667:case 35671:return Ux;case 35668:case 35672:return Ox;case 35669:case 35673:return Fx;case 5125:return zx;case 36294:return Bx;case 36295:return Hx;case 36296:return Vx;case 35678:case 36198:case 36298:case 36306:case 35682:return Gx;case 35679:case 36299:case 36307:return $x;case 35680:case 36300:case 36308:case 36293:return Wx;case 36289:case 36303:case 36311:case 36292:return Xx}}function jx(i,t){i.uniform1fv(this.addr,t)}function Yx(i,t){const e=Pa(t,this.size,2);i.uniform2fv(this.addr,e)}function Kx(i,t){const e=Pa(t,this.size,3);i.uniform3fv(this.addr,e)}function Zx(i,t){const e=Pa(t,this.size,4);i.uniform4fv(this.addr,e)}function Jx(i,t){const e=Pa(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function Qx(i,t){const e=Pa(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function ty(i,t){const e=Pa(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function ey(i,t){i.uniform1iv(this.addr,t)}function ny(i,t){i.uniform2iv(this.addr,t)}function iy(i,t){i.uniform3iv(this.addr,t)}function sy(i,t){i.uniform4iv(this.addr,t)}function ay(i,t){i.uniform1uiv(this.addr,t)}function ry(i,t){i.uniform2uiv(this.addr,t)}function oy(i,t){i.uniform3uiv(this.addr,t)}function ly(i,t){i.uniform4uiv(this.addr,t)}function cy(i,t,e){const n=this.cache,s=t.length,a=Vo(e,s);Ve(n,a)||(i.uniform1iv(this.addr,a),Ge(n,a));for(let r=0;r!==s;++r)e.setTexture2D(t[r]||op,a[r])}function hy(i,t,e){const n=this.cache,s=t.length,a=Vo(e,s);Ve(n,a)||(i.uniform1iv(this.addr,a),Ge(n,a));for(let r=0;r!==s;++r)e.setTexture3D(t[r]||cp,a[r])}function uy(i,t,e){const n=this.cache,s=t.length,a=Vo(e,s);Ve(n,a)||(i.uniform1iv(this.addr,a),Ge(n,a));for(let r=0;r!==s;++r)e.setTextureCube(t[r]||hp,a[r])}function dy(i,t,e){const n=this.cache,s=t.length,a=Vo(e,s);Ve(n,a)||(i.uniform1iv(this.addr,a),Ge(n,a));for(let r=0;r!==s;++r)e.setTexture2DArray(t[r]||lp,a[r])}function fy(i){switch(i){case 5126:return jx;case 35664:return Yx;case 35665:return Kx;case 35666:return Zx;case 35674:return Jx;case 35675:return Qx;case 35676:return ty;case 5124:case 35670:return ey;case 35667:case 35671:return ny;case 35668:case 35672:return iy;case 35669:case 35673:return sy;case 5125:return ay;case 36294:return ry;case 36295:return oy;case 36296:return ly;case 35678:case 36198:case 36298:case 36306:case 35682:return cy;case 35679:case 36299:case 36307:return hy;case 35680:case 36300:case 36308:case 36293:return uy;case 36289:case 36303:case 36311:case 36292:return dy}}class py{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=qx(e.type)}}class my{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=fy(e.type)}}class gy{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const s=this.seq;for(let a=0,r=s.length;a!==r;++a){const o=s[a];o.setValue(t,e[o.id],n)}}}const Dl=/(\w+)(\])?(\[|\.)?/g;function ld(i,t){i.seq.push(t),i.map[t.id]=t}function vy(i,t,e){const n=i.name,s=n.length;for(Dl.lastIndex=0;;){const a=Dl.exec(n),r=Dl.lastIndex;let o=a[1];const l=a[2]==="]",c=a[3];if(l&&(o=o|0),c===void 0||c==="["&&r+2===s){ld(e,c===void 0?new py(o,i,t):new my(o,i,t));break}else{let u=e.map[o];u===void 0&&(u=new gy(o),ld(e,u)),e=u}}}class uo{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let s=0;s<n;++s){const a=t.getActiveUniform(e,s),r=t.getUniformLocation(e,a.name);vy(a,r,this)}}setValue(t,e,n,s){const a=this.map[e];a!==void 0&&a.setValue(t,n,s)}setOptional(t,e,n){const s=e[n];s!==void 0&&this.setValue(t,n,s)}static upload(t,e,n,s){for(let a=0,r=e.length;a!==r;++a){const o=e[a],l=n[o.id];l.needsUpdate!==!1&&o.setValue(t,l.value,s)}}static seqWithValue(t,e){const n=[];for(let s=0,a=t.length;s!==a;++s){const r=t[s];r.id in e&&n.push(r)}return n}}function cd(i,t,e){const n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}const _y=37297;let xy=0;function yy(i,t){const e=i.split(`
3793
3793
  `),n=[],s=Math.max(t-6,0),a=Math.min(t+6,e.length);for(let r=s;r<a;r++){const o=r+1;n.push(`${o===t?">":" "} ${o}: ${e[r]}`)}return n.join(`
3794
3794
  `)}function My(i){const t=le.getPrimaries(le.workingColorSpace),e=le.getPrimaries(i);let n;switch(t===e?n="":t===Co&&e===Ao?n="LinearDisplayP3ToLinearSRGB":t===Ao&&e===Co&&(n="LinearSRGBToLinearDisplayP3"),i){case us:case Ho:return[n,"LinearTransferOETF"];case Qe:case Ph:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",i),[n,"LinearTransferOETF"]}}function hd(i,t,e){const n=i.getShaderParameter(t,i.COMPILE_STATUS),s=i.getShaderInfoLog(t).trim();if(n&&s==="")return"";const a=/ERROR: 0:(\d+)/.exec(s);if(a){const r=parseInt(a[1]);return e.toUpperCase()+`
3795
3795
 
3796
3796
  `+s+`
3797
3797
 
3798
- `+yy(i.getShaderSource(t),r)}else return s}function by(i,t){const e=My(t);return`vec4 ${i}( vec4 value ) { return ${e[0]}( ${e[1]}( value ) ); }`}function Sy(i,t){let e;switch(t){case Nf:e="Linear";break;case Uf:e="Reinhard";break;case Of:e="Cineon";break;case Ff:e="ACESFilmic";break;case zf:e="AgX";break;case bh:e="Neutral";break;case L0:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}const Fr=new C;function wy(){le.getLuminanceCoefficients(Fr);const i=Fr.x.toFixed(4),t=Fr.y.toFixed(4),e=Fr.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(`
3798
+ `+yy(i.getShaderSource(t),r)}else return s}function by(i,t){const e=My(t);return`vec4 ${i}( vec4 value ) { return ${e[0]}( ${e[1]}( value ) ); }`}function Sy(i,t){let e;switch(t){case kf:e="Linear";break;case Nf:e="Reinhard";break;case Uf:e="Cineon";break;case Of:e="ACESFilmic";break;case Ff:e="AgX";break;case bh:e="Neutral";break;case L0:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}const Fr=new C;function wy(){le.getLuminanceCoefficients(Fr);const i=Fr.x.toFixed(4),t=Fr.y.toFixed(4),e=Fr.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(`
3799
3799
  `)}function Ey(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ja).join(`
3800
3800
  `)}function Ty(i){const t=[];for(const e in i){const n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
3801
3801
  `)}function Ay(i,t){const e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){const a=i.getActiveAttrib(t,s),r=a.name;let o=1;a.type===i.FLOAT_MAT2&&(o=2),a.type===i.FLOAT_MAT3&&(o=3),a.type===i.FLOAT_MAT4&&(o=4),e[r]={type:a.type,location:i.getAttribLocation(t,r),locationSize:o}}return e}function ja(i){return i!==""}function ud(i,t){const e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,e).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function dd(i,t){return i.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Cy=/^[ \t]*#include +<([\w\d./]+)>/gm;function th(i){return i.replace(Cy,Py)}const Ry=new Map;function Py(i,t){let e=jt[t];if(e===void 0){const n=Ry.get(t);if(n!==void 0)e=jt[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("Can not resolve #include <"+t+">")}return th(e)}const Ly=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function fd(i){return i.replace(Ly,Dy)}function Dy(i,t,e,n){let s="";for(let a=parseInt(t);a<parseInt(e);a++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return s}function pd(i){let t=`precision ${i.precision} float;
@@ -3818,7 +3818,7 @@ void main() {
3818
3818
  `;return i.precision==="highp"?t+=`
3819
3819
  #define HIGH_PRECISION`:i.precision==="mediump"?t+=`
3820
3820
  #define MEDIUM_PRECISION`:i.precision==="lowp"&&(t+=`
3821
- #define LOW_PRECISION`),t}function Iy(i){let t="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===Lf?t="SHADOWMAP_TYPE_PCF":i.shadowMapType===Df?t="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===Ai&&(t="SHADOWMAP_TYPE_VSM"),t}function ky(i){let t="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Sa:case wa:t="ENVMAP_TYPE_CUBE";break;case Bo:t="ENVMAP_TYPE_CUBE_UV";break}return t}function Ny(i){let t="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case wa:t="ENVMAP_MODE_REFRACTION";break}return t}function Uy(i){let t="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case kf:t="ENVMAP_BLENDING_MULTIPLY";break;case R0:t="ENVMAP_BLENDING_MIX";break;case P0:t="ENVMAP_BLENDING_ADD";break}return t}function Oy(i){const t=i.envMapCubeUVHeight;if(t===null)return null;const e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:n,maxMip:e}}function Fy(i,t,e,n){const s=i.getContext(),a=e.defines;let r=e.vertexShader,o=e.fragmentShader;const l=Iy(e),c=ky(e),h=Ny(e),u=Uy(e),d=Oy(e),f=Ey(e),g=Ty(a),_=s.createProgram();let p,m,y=e.glslVersion?"#version "+e.glslVersion+`
3821
+ #define LOW_PRECISION`),t}function Iy(i){let t="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===Pf?t="SHADOWMAP_TYPE_PCF":i.shadowMapType===Lf?t="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===Ai&&(t="SHADOWMAP_TYPE_VSM"),t}function ky(i){let t="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Sa:case wa:t="ENVMAP_TYPE_CUBE";break;case Bo:t="ENVMAP_TYPE_CUBE_UV";break}return t}function Ny(i){let t="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case wa:t="ENVMAP_MODE_REFRACTION";break}return t}function Uy(i){let t="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case If:t="ENVMAP_BLENDING_MULTIPLY";break;case R0:t="ENVMAP_BLENDING_MIX";break;case P0:t="ENVMAP_BLENDING_ADD";break}return t}function Oy(i){const t=i.envMapCubeUVHeight;if(t===null)return null;const e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:n,maxMip:e}}function Fy(i,t,e,n){const s=i.getContext(),a=e.defines;let r=e.vertexShader,o=e.fragmentShader;const l=Iy(e),c=ky(e),h=Ny(e),u=Uy(e),d=Oy(e),f=Ey(e),g=Ty(a),_=s.createProgram();let p,m,y=e.glslVersion?"#version "+e.glslVersion+`
3822
3822
  `:"";e.isRawShaderMaterial?(p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(ja).join(`
3823
3823
  `),p.length>0&&(p+=`
3824
3824
  `),m=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(ja).join(`
@@ -3839,7 +3839,7 @@ Material Type: `+b.type+`
3839
3839
 
3840
3840
  Program Info Log: `+N+`
3841
3841
  `+nt+`
3842
- `+G)}else N!==""?console.warn("THREE.WebGLProgram: Program Info Log:",N):(F===""||$==="")&&(z=!1);z&&(b.diagnostics={runnable:W,programLog:N,vertexShader:{log:F,prefix:p},fragmentShader:{log:$,prefix:m}})}s.deleteShader(P),s.deleteShader(T),R=new uo(s,_),k=Ay(s,_)}let R;this.getUniforms=function(){return R===void 0&&w(this),R};let k;this.getAttributes=function(){return k===void 0&&w(this),k};let v=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return v===!1&&(v=s.getProgramParameter(_,_y)),v},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=xy++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=P,this.fragmentShader=T,this}let zy=0;class By{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,s=this._getShaderStage(e),a=this._getShaderStage(n),r=this._getShaderCacheForMaterial(t);return r.has(s)===!1&&(r.add(s),s.usedTimes++),r.has(a)===!1&&(r.add(a),a.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new Hy(t),e.set(t,n)),n}}class Hy{constructor(t){this.id=zy++,this.code=t,this.usedTimes=0}}function Vy(i,t,e,n,s,a,r){const o=new kh,l=new By,c=new Set,h=[],u=s.logarithmicDepthBuffer,d=s.reverseDepthBuffer,f=s.vertexTextures;let g=s.precision;const _={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(v){return c.add(v),v===0?"uv":`uv${v}`}function m(v,b,N,F,$){const W=F.fog,z=$.geometry,nt=v.isMeshStandardMaterial?F.environment:null,G=(v.isMeshStandardMaterial?e:t).get(v.envMap||nt),at=G&&G.mapping===Bo?G.image.height:null,ht=_[v.type];v.precision!==null&&(g=s.getMaxPrecision(v.precision),g!==v.precision&&console.warn("THREE.WebGLProgram.getParameters:",v.precision,"not supported, using",g,"instead."));const mt=z.morphAttributes.position||z.morphAttributes.normal||z.morphAttributes.color,Xt=mt!==void 0?mt.length:0;let qt=0;z.morphAttributes.position!==void 0&&(qt=1),z.morphAttributes.normal!==void 0&&(qt=2),z.morphAttributes.color!==void 0&&(qt=3);let q,st,Mt,dt;if(ht){const gn=oi[ht];q=gn.vertexShader,st=gn.fragmentShader}else q=v.vertexShader,st=v.fragmentShader,l.update(v),Mt=l.getVertexShaderID(v),dt=l.getFragmentShaderID(v);const It=i.getRenderTarget(),Rt=$.isInstancedMesh===!0,Nt=$.isBatchedMesh===!0,ee=!!v.map,$t=!!v.matcap,L=!!G,ze=!!v.aoMap,Zt=!!v.lightMap,j=!!v.bumpMap,Q=!!v.normalMap,Tt=!!v.displacementMap,wt=!!v.emissiveMap,A=!!v.metalnessMap,M=!!v.roughnessMap,O=v.anisotropy>0,Z=v.clearcoat>0,it=v.dispersion>0,Y=v.iridescence>0,Ct=v.sheen>0,ut=v.transmission>0,gt=O&&!!v.anisotropyMap,Jt=Z&&!!v.clearcoatMap,rt=Z&&!!v.clearcoatNormalMap,vt=Z&&!!v.clearcoatRoughnessMap,Ut=Y&&!!v.iridescenceMap,Ot=Y&&!!v.iridescenceThicknessMap,Et=Ct&&!!v.sheenColorMap,ne=Ct&&!!v.sheenRoughnessMap,Vt=!!v.specularMap,se=!!v.specularColorMap,D=!!v.specularIntensityMap,pt=ut&&!!v.transmissionMap,V=ut&&!!v.thicknessMap,tt=!!v.gradientMap,_t=!!v.alphaMap,bt=v.alphaTest>0,ie=!!v.alphaHash,Ie=!!v.extensions;let mn=os;v.toneMapped&&(It===null||It.isXRRenderTarget===!0)&&(mn=i.toneMapping);const oe={shaderID:ht,shaderType:v.type,shaderName:v.name,vertexShader:q,fragmentShader:st,defines:v.defines,customVertexShaderID:Mt,customFragmentShaderID:dt,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:g,batching:Nt,batchingColor:Nt&&$._colorsTexture!==null,instancing:Rt,instancingColor:Rt&&$.instanceColor!==null,instancingMorph:Rt&&$.morphTexture!==null,supportsVertexTextures:f,outputColorSpace:It===null?i.outputColorSpace:It.isXRRenderTarget===!0?It.texture.colorSpace:us,alphaToCoverage:!!v.alphaToCoverage,map:ee,matcap:$t,envMap:L,envMapMode:L&&G.mapping,envMapCubeUVHeight:at,aoMap:ze,lightMap:Zt,bumpMap:j,normalMap:Q,displacementMap:f&&Tt,emissiveMap:wt,normalMapObjectSpace:Q&&v.normalMapType===N0,normalMapTangentSpace:Q&&v.normalMapType===Rh,metalnessMap:A,roughnessMap:M,anisotropy:O,anisotropyMap:gt,clearcoat:Z,clearcoatMap:Jt,clearcoatNormalMap:rt,clearcoatRoughnessMap:vt,dispersion:it,iridescence:Y,iridescenceMap:Ut,iridescenceThicknessMap:Ot,sheen:Ct,sheenColorMap:Et,sheenRoughnessMap:ne,specularMap:Vt,specularColorMap:se,specularIntensityMap:D,transmission:ut,transmissionMap:pt,thicknessMap:V,gradientMap:tt,opaque:v.transparent===!1&&v.blending===va&&v.alphaToCoverage===!1,alphaMap:_t,alphaTest:bt,alphaHash:ie,combine:v.combine,mapUv:ee&&p(v.map.channel),aoMapUv:ze&&p(v.aoMap.channel),lightMapUv:Zt&&p(v.lightMap.channel),bumpMapUv:j&&p(v.bumpMap.channel),normalMapUv:Q&&p(v.normalMap.channel),displacementMapUv:Tt&&p(v.displacementMap.channel),emissiveMapUv:wt&&p(v.emissiveMap.channel),metalnessMapUv:A&&p(v.metalnessMap.channel),roughnessMapUv:M&&p(v.roughnessMap.channel),anisotropyMapUv:gt&&p(v.anisotropyMap.channel),clearcoatMapUv:Jt&&p(v.clearcoatMap.channel),clearcoatNormalMapUv:rt&&p(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:vt&&p(v.clearcoatRoughnessMap.channel),iridescenceMapUv:Ut&&p(v.iridescenceMap.channel),iridescenceThicknessMapUv:Ot&&p(v.iridescenceThicknessMap.channel),sheenColorMapUv:Et&&p(v.sheenColorMap.channel),sheenRoughnessMapUv:ne&&p(v.sheenRoughnessMap.channel),specularMapUv:Vt&&p(v.specularMap.channel),specularColorMapUv:se&&p(v.specularColorMap.channel),specularIntensityMapUv:D&&p(v.specularIntensityMap.channel),transmissionMapUv:pt&&p(v.transmissionMap.channel),thicknessMapUv:V&&p(v.thicknessMap.channel),alphaMapUv:_t&&p(v.alphaMap.channel),vertexTangents:!!z.attributes.tangent&&(Q||O),vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!z.attributes.color&&z.attributes.color.itemSize===4,pointsUvs:$.isPoints===!0&&!!z.attributes.uv&&(ee||_t),fog:!!W,useFog:v.fog===!0,fogExp2:!!W&&W.isFogExp2,flatShading:v.flatShading===!0,sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:u,reverseDepthBuffer:d,skinning:$.isSkinnedMesh===!0,morphTargets:z.morphAttributes.position!==void 0,morphNormals:z.morphAttributes.normal!==void 0,morphColors:z.morphAttributes.color!==void 0,morphTargetsCount:Xt,morphTextureStride:qt,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:v.dithering,shadowMapEnabled:i.shadowMap.enabled&&N.length>0,shadowMapType:i.shadowMap.type,toneMapping:mn,decodeVideoTexture:ee&&v.map.isVideoTexture===!0&&le.getTransfer(v.map.colorSpace)===ye,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===ci,flipSided:v.side===fn,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:Ie&&v.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ie&&v.extensions.multiDraw===!0||Nt)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return oe.vertexUv1s=c.has(1),oe.vertexUv2s=c.has(2),oe.vertexUv3s=c.has(3),c.clear(),oe}function y(v){const b=[];if(v.shaderID?b.push(v.shaderID):(b.push(v.customVertexShaderID),b.push(v.customFragmentShaderID)),v.defines!==void 0)for(const N in v.defines)b.push(N),b.push(v.defines[N]);return v.isRawShaderMaterial===!1&&(x(b,v),S(b,v),b.push(i.outputColorSpace)),b.push(v.customProgramCacheKey),b.join()}function x(v,b){v.push(b.precision),v.push(b.outputColorSpace),v.push(b.envMapMode),v.push(b.envMapCubeUVHeight),v.push(b.mapUv),v.push(b.alphaMapUv),v.push(b.lightMapUv),v.push(b.aoMapUv),v.push(b.bumpMapUv),v.push(b.normalMapUv),v.push(b.displacementMapUv),v.push(b.emissiveMapUv),v.push(b.metalnessMapUv),v.push(b.roughnessMapUv),v.push(b.anisotropyMapUv),v.push(b.clearcoatMapUv),v.push(b.clearcoatNormalMapUv),v.push(b.clearcoatRoughnessMapUv),v.push(b.iridescenceMapUv),v.push(b.iridescenceThicknessMapUv),v.push(b.sheenColorMapUv),v.push(b.sheenRoughnessMapUv),v.push(b.specularMapUv),v.push(b.specularColorMapUv),v.push(b.specularIntensityMapUv),v.push(b.transmissionMapUv),v.push(b.thicknessMapUv),v.push(b.combine),v.push(b.fogExp2),v.push(b.sizeAttenuation),v.push(b.morphTargetsCount),v.push(b.morphAttributeCount),v.push(b.numDirLights),v.push(b.numPointLights),v.push(b.numSpotLights),v.push(b.numSpotLightMaps),v.push(b.numHemiLights),v.push(b.numRectAreaLights),v.push(b.numDirLightShadows),v.push(b.numPointLightShadows),v.push(b.numSpotLightShadows),v.push(b.numSpotLightShadowsWithMaps),v.push(b.numLightProbes),v.push(b.shadowMapType),v.push(b.toneMapping),v.push(b.numClippingPlanes),v.push(b.numClipIntersection),v.push(b.depthPacking)}function S(v,b){o.disableAll(),b.supportsVertexTextures&&o.enable(0),b.instancing&&o.enable(1),b.instancingColor&&o.enable(2),b.instancingMorph&&o.enable(3),b.matcap&&o.enable(4),b.envMap&&o.enable(5),b.normalMapObjectSpace&&o.enable(6),b.normalMapTangentSpace&&o.enable(7),b.clearcoat&&o.enable(8),b.iridescence&&o.enable(9),b.alphaTest&&o.enable(10),b.vertexColors&&o.enable(11),b.vertexAlphas&&o.enable(12),b.vertexUv1s&&o.enable(13),b.vertexUv2s&&o.enable(14),b.vertexUv3s&&o.enable(15),b.vertexTangents&&o.enable(16),b.anisotropy&&o.enable(17),b.alphaHash&&o.enable(18),b.batching&&o.enable(19),b.dispersion&&o.enable(20),b.batchingColor&&o.enable(21),v.push(o.mask),o.disableAll(),b.fog&&o.enable(0),b.useFog&&o.enable(1),b.flatShading&&o.enable(2),b.logarithmicDepthBuffer&&o.enable(3),b.reverseDepthBuffer&&o.enable(4),b.skinning&&o.enable(5),b.morphTargets&&o.enable(6),b.morphNormals&&o.enable(7),b.morphColors&&o.enable(8),b.premultipliedAlpha&&o.enable(9),b.shadowMapEnabled&&o.enable(10),b.doubleSided&&o.enable(11),b.flipSided&&o.enable(12),b.useDepthPacking&&o.enable(13),b.dithering&&o.enable(14),b.transmission&&o.enable(15),b.sheen&&o.enable(16),b.opaque&&o.enable(17),b.pointsUvs&&o.enable(18),b.decodeVideoTexture&&o.enable(19),b.alphaToCoverage&&o.enable(20),v.push(o.mask)}function P(v){const b=_[v.type];let N;if(b){const F=oi[b];N=es.clone(F.uniforms)}else N=v.uniforms;return N}function T(v,b){let N;for(let F=0,$=h.length;F<$;F++){const W=h[F];if(W.cacheKey===b){N=W,++N.usedTimes;break}}return N===void 0&&(N=new Fy(i,b,v,a),h.push(N)),N}function w(v){if(--v.usedTimes===0){const b=h.indexOf(v);h[b]=h[h.length-1],h.pop(),v.destroy()}}function R(v){l.remove(v)}function k(){l.dispose()}return{getParameters:m,getProgramCacheKey:y,getUniforms:P,acquireProgram:T,releaseProgram:w,releaseShaderCache:R,programs:h,dispose:k}}function Gy(){let i=new WeakMap;function t(r){return i.has(r)}function e(r){let o=i.get(r);return o===void 0&&(o={},i.set(r,o)),o}function n(r){i.delete(r)}function s(r,o,l){i.get(r)[o]=l}function a(){i=new WeakMap}return{has:t,get:e,remove:n,update:s,dispose:a}}function $y(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.z!==t.z?i.z-t.z:i.id-t.id}function md(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function gd(){const i=[];let t=0;const e=[],n=[],s=[];function a(){t=0,e.length=0,n.length=0,s.length=0}function r(u,d,f,g,_,p){let m=i[t];return m===void 0?(m={id:u.id,object:u,geometry:d,material:f,groupOrder:g,renderOrder:u.renderOrder,z:_,group:p},i[t]=m):(m.id=u.id,m.object=u,m.geometry=d,m.material=f,m.groupOrder=g,m.renderOrder=u.renderOrder,m.z=_,m.group=p),t++,m}function o(u,d,f,g,_,p){const m=r(u,d,f,g,_,p);f.transmission>0?n.push(m):f.transparent===!0?s.push(m):e.push(m)}function l(u,d,f,g,_,p){const m=r(u,d,f,g,_,p);f.transmission>0?n.unshift(m):f.transparent===!0?s.unshift(m):e.unshift(m)}function c(u,d){e.length>1&&e.sort(u||$y),n.length>1&&n.sort(d||md),s.length>1&&s.sort(d||md)}function h(){for(let u=t,d=i.length;u<d;u++){const f=i[u];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:e,transmissive:n,transparent:s,init:a,push:o,unshift:l,finish:h,sort:c}}function Wy(){let i=new WeakMap;function t(n,s){const a=i.get(n);let r;return a===void 0?(r=new gd,i.set(n,[r])):s>=a.length?(r=new gd,a.push(r)):r=a[s],r}function e(){i=new WeakMap}return{get:t,dispose:e}}function Xy(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new C,color:new te};break;case"SpotLight":e={position:new C,direction:new C,color:new te,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new C,color:new te,distance:0,decay:0};break;case"HemisphereLight":e={direction:new C,skyColor:new te,groundColor:new te};break;case"RectAreaLight":e={color:new te,position:new C,halfWidth:new C,halfHeight:new C};break}return i[t.id]=e,e}}}function qy(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new lt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new lt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new lt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}let jy=0;function Yy(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function Ky(i){const t=new Xy,e=qy(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new C);const s=new C,a=new fe,r=new fe;function o(c){let h=0,u=0,d=0;for(let k=0;k<9;k++)n.probe[k].set(0,0,0);let f=0,g=0,_=0,p=0,m=0,y=0,x=0,S=0,P=0,T=0,w=0;c.sort(Yy);for(let k=0,v=c.length;k<v;k++){const b=c[k],N=b.color,F=b.intensity,$=b.distance,W=b.shadow&&b.shadow.map?b.shadow.map.texture:null;if(b.isAmbientLight)h+=N.r*F,u+=N.g*F,d+=N.b*F;else if(b.isLightProbe){for(let z=0;z<9;z++)n.probe[z].addScaledVector(b.sh.coefficients[z],F);w++}else if(b.isDirectionalLight){const z=t.get(b);if(z.color.copy(b.color).multiplyScalar(b.intensity),b.castShadow){const nt=b.shadow,G=e.get(b);G.shadowIntensity=nt.intensity,G.shadowBias=nt.bias,G.shadowNormalBias=nt.normalBias,G.shadowRadius=nt.radius,G.shadowMapSize=nt.mapSize,n.directionalShadow[f]=G,n.directionalShadowMap[f]=W,n.directionalShadowMatrix[f]=b.shadow.matrix,y++}n.directional[f]=z,f++}else if(b.isSpotLight){const z=t.get(b);z.position.setFromMatrixPosition(b.matrixWorld),z.color.copy(N).multiplyScalar(F),z.distance=$,z.coneCos=Math.cos(b.angle),z.penumbraCos=Math.cos(b.angle*(1-b.penumbra)),z.decay=b.decay,n.spot[_]=z;const nt=b.shadow;if(b.map&&(n.spotLightMap[P]=b.map,P++,nt.updateMatrices(b),b.castShadow&&T++),n.spotLightMatrix[_]=nt.matrix,b.castShadow){const G=e.get(b);G.shadowIntensity=nt.intensity,G.shadowBias=nt.bias,G.shadowNormalBias=nt.normalBias,G.shadowRadius=nt.radius,G.shadowMapSize=nt.mapSize,n.spotShadow[_]=G,n.spotShadowMap[_]=W,S++}_++}else if(b.isRectAreaLight){const z=t.get(b);z.color.copy(N).multiplyScalar(F),z.halfWidth.set(b.width*.5,0,0),z.halfHeight.set(0,b.height*.5,0),n.rectArea[p]=z,p++}else if(b.isPointLight){const z=t.get(b);if(z.color.copy(b.color).multiplyScalar(b.intensity),z.distance=b.distance,z.decay=b.decay,b.castShadow){const nt=b.shadow,G=e.get(b);G.shadowIntensity=nt.intensity,G.shadowBias=nt.bias,G.shadowNormalBias=nt.normalBias,G.shadowRadius=nt.radius,G.shadowMapSize=nt.mapSize,G.shadowCameraNear=nt.camera.near,G.shadowCameraFar=nt.camera.far,n.pointShadow[g]=G,n.pointShadowMap[g]=W,n.pointShadowMatrix[g]=b.shadow.matrix,x++}n.point[g]=z,g++}else if(b.isHemisphereLight){const z=t.get(b);z.skyColor.copy(b.color).multiplyScalar(F),z.groundColor.copy(b.groundColor).multiplyScalar(F),n.hemi[m]=z,m++}}p>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ft.LTC_FLOAT_1,n.rectAreaLTC2=ft.LTC_FLOAT_2):(n.rectAreaLTC1=ft.LTC_HALF_1,n.rectAreaLTC2=ft.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const R=n.hash;(R.directionalLength!==f||R.pointLength!==g||R.spotLength!==_||R.rectAreaLength!==p||R.hemiLength!==m||R.numDirectionalShadows!==y||R.numPointShadows!==x||R.numSpotShadows!==S||R.numSpotMaps!==P||R.numLightProbes!==w)&&(n.directional.length=f,n.spot.length=_,n.rectArea.length=p,n.point.length=g,n.hemi.length=m,n.directionalShadow.length=y,n.directionalShadowMap.length=y,n.pointShadow.length=x,n.pointShadowMap.length=x,n.spotShadow.length=S,n.spotShadowMap.length=S,n.directionalShadowMatrix.length=y,n.pointShadowMatrix.length=x,n.spotLightMatrix.length=S+P-T,n.spotLightMap.length=P,n.numSpotLightShadowsWithMaps=T,n.numLightProbes=w,R.directionalLength=f,R.pointLength=g,R.spotLength=_,R.rectAreaLength=p,R.hemiLength=m,R.numDirectionalShadows=y,R.numPointShadows=x,R.numSpotShadows=S,R.numSpotMaps=P,R.numLightProbes=w,n.version=jy++)}function l(c,h){let u=0,d=0,f=0,g=0,_=0;const p=h.matrixWorldInverse;for(let m=0,y=c.length;m<y;m++){const x=c[m];if(x.isDirectionalLight){const S=n.directional[u];S.direction.setFromMatrixPosition(x.matrixWorld),s.setFromMatrixPosition(x.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(p),u++}else if(x.isSpotLight){const S=n.spot[f];S.position.setFromMatrixPosition(x.matrixWorld),S.position.applyMatrix4(p),S.direction.setFromMatrixPosition(x.matrixWorld),s.setFromMatrixPosition(x.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(p),f++}else if(x.isRectAreaLight){const S=n.rectArea[g];S.position.setFromMatrixPosition(x.matrixWorld),S.position.applyMatrix4(p),r.identity(),a.copy(x.matrixWorld),a.premultiply(p),r.extractRotation(a),S.halfWidth.set(x.width*.5,0,0),S.halfHeight.set(0,x.height*.5,0),S.halfWidth.applyMatrix4(r),S.halfHeight.applyMatrix4(r),g++}else if(x.isPointLight){const S=n.point[d];S.position.setFromMatrixPosition(x.matrixWorld),S.position.applyMatrix4(p),d++}else if(x.isHemisphereLight){const S=n.hemi[_];S.direction.setFromMatrixPosition(x.matrixWorld),S.direction.transformDirection(p),_++}}}return{setup:o,setupView:l,state:n}}function vd(i){const t=new Ky(i),e=[],n=[];function s(h){c.camera=h,e.length=0,n.length=0}function a(h){e.push(h)}function r(h){n.push(h)}function o(){t.setup(e)}function l(h){t.setupView(e,h)}const c={lightsArray:e,shadowsArray:n,camera:null,lights:t,transmissionRenderTarget:{}};return{init:s,state:c,setupLights:o,setupLightsView:l,pushLight:a,pushShadow:r}}function Zy(i){let t=new WeakMap;function e(s,a=0){const r=t.get(s);let o;return r===void 0?(o=new vd(i),t.set(s,[o])):a>=r.length?(o=new vd(i),r.push(o)):o=r[a],o}function n(){t=new WeakMap}return{get:e,dispose:n}}class Jy extends Bi{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=I0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class Qy extends Bi{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}const t1=`void main() {
3842
+ `+G)}else N!==""?console.warn("THREE.WebGLProgram: Program Info Log:",N):(F===""||$==="")&&(z=!1);z&&(b.diagnostics={runnable:W,programLog:N,vertexShader:{log:F,prefix:p},fragmentShader:{log:$,prefix:m}})}s.deleteShader(P),s.deleteShader(T),R=new uo(s,_),k=Ay(s,_)}let R;this.getUniforms=function(){return R===void 0&&w(this),R};let k;this.getAttributes=function(){return k===void 0&&w(this),k};let v=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return v===!1&&(v=s.getProgramParameter(_,_y)),v},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=xy++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=P,this.fragmentShader=T,this}let zy=0;class By{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,s=this._getShaderStage(e),a=this._getShaderStage(n),r=this._getShaderCacheForMaterial(t);return r.has(s)===!1&&(r.add(s),s.usedTimes++),r.has(a)===!1&&(r.add(a),a.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new Hy(t),e.set(t,n)),n}}class Hy{constructor(t){this.id=zy++,this.code=t,this.usedTimes=0}}function Vy(i,t,e,n,s,a,r){const o=new kh,l=new By,c=new Set,h=[],u=s.logarithmicDepthBuffer,d=s.reverseDepthBuffer,f=s.vertexTextures;let g=s.precision;const _={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(v){return c.add(v),v===0?"uv":`uv${v}`}function m(v,b,N,F,$){const W=F.fog,z=$.geometry,nt=v.isMeshStandardMaterial?F.environment:null,G=(v.isMeshStandardMaterial?e:t).get(v.envMap||nt),at=G&&G.mapping===Bo?G.image.height:null,ht=_[v.type];v.precision!==null&&(g=s.getMaxPrecision(v.precision),g!==v.precision&&console.warn("THREE.WebGLProgram.getParameters:",v.precision,"not supported, using",g,"instead."));const mt=z.morphAttributes.position||z.morphAttributes.normal||z.morphAttributes.color,Xt=mt!==void 0?mt.length:0;let qt=0;z.morphAttributes.position!==void 0&&(qt=1),z.morphAttributes.normal!==void 0&&(qt=2),z.morphAttributes.color!==void 0&&(qt=3);let q,st,Mt,dt;if(ht){const gn=oi[ht];q=gn.vertexShader,st=gn.fragmentShader}else q=v.vertexShader,st=v.fragmentShader,l.update(v),Mt=l.getVertexShaderID(v),dt=l.getFragmentShaderID(v);const It=i.getRenderTarget(),Rt=$.isInstancedMesh===!0,Nt=$.isBatchedMesh===!0,ee=!!v.map,$t=!!v.matcap,L=!!G,ze=!!v.aoMap,Zt=!!v.lightMap,j=!!v.bumpMap,Q=!!v.normalMap,Tt=!!v.displacementMap,St=!!v.emissiveMap,A=!!v.metalnessMap,M=!!v.roughnessMap,O=v.anisotropy>0,Z=v.clearcoat>0,it=v.dispersion>0,Y=v.iridescence>0,Ct=v.sheen>0,ut=v.transmission>0,gt=O&&!!v.anisotropyMap,Jt=Z&&!!v.clearcoatMap,rt=Z&&!!v.clearcoatNormalMap,vt=Z&&!!v.clearcoatRoughnessMap,Ut=Y&&!!v.iridescenceMap,Ot=Y&&!!v.iridescenceThicknessMap,Et=Ct&&!!v.sheenColorMap,ne=Ct&&!!v.sheenRoughnessMap,Vt=!!v.specularMap,se=!!v.specularColorMap,D=!!v.specularIntensityMap,pt=ut&&!!v.transmissionMap,V=ut&&!!v.thicknessMap,tt=!!v.gradientMap,_t=!!v.alphaMap,bt=v.alphaTest>0,ie=!!v.alphaHash,Ie=!!v.extensions;let mn=os;v.toneMapped&&(It===null||It.isXRRenderTarget===!0)&&(mn=i.toneMapping);const oe={shaderID:ht,shaderType:v.type,shaderName:v.name,vertexShader:q,fragmentShader:st,defines:v.defines,customVertexShaderID:Mt,customFragmentShaderID:dt,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:g,batching:Nt,batchingColor:Nt&&$._colorsTexture!==null,instancing:Rt,instancingColor:Rt&&$.instanceColor!==null,instancingMorph:Rt&&$.morphTexture!==null,supportsVertexTextures:f,outputColorSpace:It===null?i.outputColorSpace:It.isXRRenderTarget===!0?It.texture.colorSpace:us,alphaToCoverage:!!v.alphaToCoverage,map:ee,matcap:$t,envMap:L,envMapMode:L&&G.mapping,envMapCubeUVHeight:at,aoMap:ze,lightMap:Zt,bumpMap:j,normalMap:Q,displacementMap:f&&Tt,emissiveMap:St,normalMapObjectSpace:Q&&v.normalMapType===N0,normalMapTangentSpace:Q&&v.normalMapType===Rh,metalnessMap:A,roughnessMap:M,anisotropy:O,anisotropyMap:gt,clearcoat:Z,clearcoatMap:Jt,clearcoatNormalMap:rt,clearcoatRoughnessMap:vt,dispersion:it,iridescence:Y,iridescenceMap:Ut,iridescenceThicknessMap:Ot,sheen:Ct,sheenColorMap:Et,sheenRoughnessMap:ne,specularMap:Vt,specularColorMap:se,specularIntensityMap:D,transmission:ut,transmissionMap:pt,thicknessMap:V,gradientMap:tt,opaque:v.transparent===!1&&v.blending===va&&v.alphaToCoverage===!1,alphaMap:_t,alphaTest:bt,alphaHash:ie,combine:v.combine,mapUv:ee&&p(v.map.channel),aoMapUv:ze&&p(v.aoMap.channel),lightMapUv:Zt&&p(v.lightMap.channel),bumpMapUv:j&&p(v.bumpMap.channel),normalMapUv:Q&&p(v.normalMap.channel),displacementMapUv:Tt&&p(v.displacementMap.channel),emissiveMapUv:St&&p(v.emissiveMap.channel),metalnessMapUv:A&&p(v.metalnessMap.channel),roughnessMapUv:M&&p(v.roughnessMap.channel),anisotropyMapUv:gt&&p(v.anisotropyMap.channel),clearcoatMapUv:Jt&&p(v.clearcoatMap.channel),clearcoatNormalMapUv:rt&&p(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:vt&&p(v.clearcoatRoughnessMap.channel),iridescenceMapUv:Ut&&p(v.iridescenceMap.channel),iridescenceThicknessMapUv:Ot&&p(v.iridescenceThicknessMap.channel),sheenColorMapUv:Et&&p(v.sheenColorMap.channel),sheenRoughnessMapUv:ne&&p(v.sheenRoughnessMap.channel),specularMapUv:Vt&&p(v.specularMap.channel),specularColorMapUv:se&&p(v.specularColorMap.channel),specularIntensityMapUv:D&&p(v.specularIntensityMap.channel),transmissionMapUv:pt&&p(v.transmissionMap.channel),thicknessMapUv:V&&p(v.thicknessMap.channel),alphaMapUv:_t&&p(v.alphaMap.channel),vertexTangents:!!z.attributes.tangent&&(Q||O),vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!z.attributes.color&&z.attributes.color.itemSize===4,pointsUvs:$.isPoints===!0&&!!z.attributes.uv&&(ee||_t),fog:!!W,useFog:v.fog===!0,fogExp2:!!W&&W.isFogExp2,flatShading:v.flatShading===!0,sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:u,reverseDepthBuffer:d,skinning:$.isSkinnedMesh===!0,morphTargets:z.morphAttributes.position!==void 0,morphNormals:z.morphAttributes.normal!==void 0,morphColors:z.morphAttributes.color!==void 0,morphTargetsCount:Xt,morphTextureStride:qt,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:v.dithering,shadowMapEnabled:i.shadowMap.enabled&&N.length>0,shadowMapType:i.shadowMap.type,toneMapping:mn,decodeVideoTexture:ee&&v.map.isVideoTexture===!0&&le.getTransfer(v.map.colorSpace)===ye,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===ci,flipSided:v.side===fn,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:Ie&&v.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Ie&&v.extensions.multiDraw===!0||Nt)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return oe.vertexUv1s=c.has(1),oe.vertexUv2s=c.has(2),oe.vertexUv3s=c.has(3),c.clear(),oe}function y(v){const b=[];if(v.shaderID?b.push(v.shaderID):(b.push(v.customVertexShaderID),b.push(v.customFragmentShaderID)),v.defines!==void 0)for(const N in v.defines)b.push(N),b.push(v.defines[N]);return v.isRawShaderMaterial===!1&&(x(b,v),S(b,v),b.push(i.outputColorSpace)),b.push(v.customProgramCacheKey),b.join()}function x(v,b){v.push(b.precision),v.push(b.outputColorSpace),v.push(b.envMapMode),v.push(b.envMapCubeUVHeight),v.push(b.mapUv),v.push(b.alphaMapUv),v.push(b.lightMapUv),v.push(b.aoMapUv),v.push(b.bumpMapUv),v.push(b.normalMapUv),v.push(b.displacementMapUv),v.push(b.emissiveMapUv),v.push(b.metalnessMapUv),v.push(b.roughnessMapUv),v.push(b.anisotropyMapUv),v.push(b.clearcoatMapUv),v.push(b.clearcoatNormalMapUv),v.push(b.clearcoatRoughnessMapUv),v.push(b.iridescenceMapUv),v.push(b.iridescenceThicknessMapUv),v.push(b.sheenColorMapUv),v.push(b.sheenRoughnessMapUv),v.push(b.specularMapUv),v.push(b.specularColorMapUv),v.push(b.specularIntensityMapUv),v.push(b.transmissionMapUv),v.push(b.thicknessMapUv),v.push(b.combine),v.push(b.fogExp2),v.push(b.sizeAttenuation),v.push(b.morphTargetsCount),v.push(b.morphAttributeCount),v.push(b.numDirLights),v.push(b.numPointLights),v.push(b.numSpotLights),v.push(b.numSpotLightMaps),v.push(b.numHemiLights),v.push(b.numRectAreaLights),v.push(b.numDirLightShadows),v.push(b.numPointLightShadows),v.push(b.numSpotLightShadows),v.push(b.numSpotLightShadowsWithMaps),v.push(b.numLightProbes),v.push(b.shadowMapType),v.push(b.toneMapping),v.push(b.numClippingPlanes),v.push(b.numClipIntersection),v.push(b.depthPacking)}function S(v,b){o.disableAll(),b.supportsVertexTextures&&o.enable(0),b.instancing&&o.enable(1),b.instancingColor&&o.enable(2),b.instancingMorph&&o.enable(3),b.matcap&&o.enable(4),b.envMap&&o.enable(5),b.normalMapObjectSpace&&o.enable(6),b.normalMapTangentSpace&&o.enable(7),b.clearcoat&&o.enable(8),b.iridescence&&o.enable(9),b.alphaTest&&o.enable(10),b.vertexColors&&o.enable(11),b.vertexAlphas&&o.enable(12),b.vertexUv1s&&o.enable(13),b.vertexUv2s&&o.enable(14),b.vertexUv3s&&o.enable(15),b.vertexTangents&&o.enable(16),b.anisotropy&&o.enable(17),b.alphaHash&&o.enable(18),b.batching&&o.enable(19),b.dispersion&&o.enable(20),b.batchingColor&&o.enable(21),v.push(o.mask),o.disableAll(),b.fog&&o.enable(0),b.useFog&&o.enable(1),b.flatShading&&o.enable(2),b.logarithmicDepthBuffer&&o.enable(3),b.reverseDepthBuffer&&o.enable(4),b.skinning&&o.enable(5),b.morphTargets&&o.enable(6),b.morphNormals&&o.enable(7),b.morphColors&&o.enable(8),b.premultipliedAlpha&&o.enable(9),b.shadowMapEnabled&&o.enable(10),b.doubleSided&&o.enable(11),b.flipSided&&o.enable(12),b.useDepthPacking&&o.enable(13),b.dithering&&o.enable(14),b.transmission&&o.enable(15),b.sheen&&o.enable(16),b.opaque&&o.enable(17),b.pointsUvs&&o.enable(18),b.decodeVideoTexture&&o.enable(19),b.alphaToCoverage&&o.enable(20),v.push(o.mask)}function P(v){const b=_[v.type];let N;if(b){const F=oi[b];N=es.clone(F.uniforms)}else N=v.uniforms;return N}function T(v,b){let N;for(let F=0,$=h.length;F<$;F++){const W=h[F];if(W.cacheKey===b){N=W,++N.usedTimes;break}}return N===void 0&&(N=new Fy(i,b,v,a),h.push(N)),N}function w(v){if(--v.usedTimes===0){const b=h.indexOf(v);h[b]=h[h.length-1],h.pop(),v.destroy()}}function R(v){l.remove(v)}function k(){l.dispose()}return{getParameters:m,getProgramCacheKey:y,getUniforms:P,acquireProgram:T,releaseProgram:w,releaseShaderCache:R,programs:h,dispose:k}}function Gy(){let i=new WeakMap;function t(r){return i.has(r)}function e(r){let o=i.get(r);return o===void 0&&(o={},i.set(r,o)),o}function n(r){i.delete(r)}function s(r,o,l){i.get(r)[o]=l}function a(){i=new WeakMap}return{has:t,get:e,remove:n,update:s,dispose:a}}function $y(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.z!==t.z?i.z-t.z:i.id-t.id}function md(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function gd(){const i=[];let t=0;const e=[],n=[],s=[];function a(){t=0,e.length=0,n.length=0,s.length=0}function r(u,d,f,g,_,p){let m=i[t];return m===void 0?(m={id:u.id,object:u,geometry:d,material:f,groupOrder:g,renderOrder:u.renderOrder,z:_,group:p},i[t]=m):(m.id=u.id,m.object=u,m.geometry=d,m.material=f,m.groupOrder=g,m.renderOrder=u.renderOrder,m.z=_,m.group=p),t++,m}function o(u,d,f,g,_,p){const m=r(u,d,f,g,_,p);f.transmission>0?n.push(m):f.transparent===!0?s.push(m):e.push(m)}function l(u,d,f,g,_,p){const m=r(u,d,f,g,_,p);f.transmission>0?n.unshift(m):f.transparent===!0?s.unshift(m):e.unshift(m)}function c(u,d){e.length>1&&e.sort(u||$y),n.length>1&&n.sort(d||md),s.length>1&&s.sort(d||md)}function h(){for(let u=t,d=i.length;u<d;u++){const f=i[u];if(f.id===null)break;f.id=null,f.object=null,f.geometry=null,f.material=null,f.group=null}}return{opaque:e,transmissive:n,transparent:s,init:a,push:o,unshift:l,finish:h,sort:c}}function Wy(){let i=new WeakMap;function t(n,s){const a=i.get(n);let r;return a===void 0?(r=new gd,i.set(n,[r])):s>=a.length?(r=new gd,a.push(r)):r=a[s],r}function e(){i=new WeakMap}return{get:t,dispose:e}}function Xy(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new C,color:new te};break;case"SpotLight":e={position:new C,direction:new C,color:new te,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new C,color:new te,distance:0,decay:0};break;case"HemisphereLight":e={direction:new C,skyColor:new te,groundColor:new te};break;case"RectAreaLight":e={color:new te,position:new C,halfWidth:new C,halfHeight:new C};break}return i[t.id]=e,e}}}function qy(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new lt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new lt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new lt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}let jy=0;function Yy(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function Ky(i){const t=new Xy,e=qy(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new C);const s=new C,a=new fe,r=new fe;function o(c){let h=0,u=0,d=0;for(let k=0;k<9;k++)n.probe[k].set(0,0,0);let f=0,g=0,_=0,p=0,m=0,y=0,x=0,S=0,P=0,T=0,w=0;c.sort(Yy);for(let k=0,v=c.length;k<v;k++){const b=c[k],N=b.color,F=b.intensity,$=b.distance,W=b.shadow&&b.shadow.map?b.shadow.map.texture:null;if(b.isAmbientLight)h+=N.r*F,u+=N.g*F,d+=N.b*F;else if(b.isLightProbe){for(let z=0;z<9;z++)n.probe[z].addScaledVector(b.sh.coefficients[z],F);w++}else if(b.isDirectionalLight){const z=t.get(b);if(z.color.copy(b.color).multiplyScalar(b.intensity),b.castShadow){const nt=b.shadow,G=e.get(b);G.shadowIntensity=nt.intensity,G.shadowBias=nt.bias,G.shadowNormalBias=nt.normalBias,G.shadowRadius=nt.radius,G.shadowMapSize=nt.mapSize,n.directionalShadow[f]=G,n.directionalShadowMap[f]=W,n.directionalShadowMatrix[f]=b.shadow.matrix,y++}n.directional[f]=z,f++}else if(b.isSpotLight){const z=t.get(b);z.position.setFromMatrixPosition(b.matrixWorld),z.color.copy(N).multiplyScalar(F),z.distance=$,z.coneCos=Math.cos(b.angle),z.penumbraCos=Math.cos(b.angle*(1-b.penumbra)),z.decay=b.decay,n.spot[_]=z;const nt=b.shadow;if(b.map&&(n.spotLightMap[P]=b.map,P++,nt.updateMatrices(b),b.castShadow&&T++),n.spotLightMatrix[_]=nt.matrix,b.castShadow){const G=e.get(b);G.shadowIntensity=nt.intensity,G.shadowBias=nt.bias,G.shadowNormalBias=nt.normalBias,G.shadowRadius=nt.radius,G.shadowMapSize=nt.mapSize,n.spotShadow[_]=G,n.spotShadowMap[_]=W,S++}_++}else if(b.isRectAreaLight){const z=t.get(b);z.color.copy(N).multiplyScalar(F),z.halfWidth.set(b.width*.5,0,0),z.halfHeight.set(0,b.height*.5,0),n.rectArea[p]=z,p++}else if(b.isPointLight){const z=t.get(b);if(z.color.copy(b.color).multiplyScalar(b.intensity),z.distance=b.distance,z.decay=b.decay,b.castShadow){const nt=b.shadow,G=e.get(b);G.shadowIntensity=nt.intensity,G.shadowBias=nt.bias,G.shadowNormalBias=nt.normalBias,G.shadowRadius=nt.radius,G.shadowMapSize=nt.mapSize,G.shadowCameraNear=nt.camera.near,G.shadowCameraFar=nt.camera.far,n.pointShadow[g]=G,n.pointShadowMap[g]=W,n.pointShadowMatrix[g]=b.shadow.matrix,x++}n.point[g]=z,g++}else if(b.isHemisphereLight){const z=t.get(b);z.skyColor.copy(b.color).multiplyScalar(F),z.groundColor.copy(b.groundColor).multiplyScalar(F),n.hemi[m]=z,m++}}p>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ft.LTC_FLOAT_1,n.rectAreaLTC2=ft.LTC_FLOAT_2):(n.rectAreaLTC1=ft.LTC_HALF_1,n.rectAreaLTC2=ft.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const R=n.hash;(R.directionalLength!==f||R.pointLength!==g||R.spotLength!==_||R.rectAreaLength!==p||R.hemiLength!==m||R.numDirectionalShadows!==y||R.numPointShadows!==x||R.numSpotShadows!==S||R.numSpotMaps!==P||R.numLightProbes!==w)&&(n.directional.length=f,n.spot.length=_,n.rectArea.length=p,n.point.length=g,n.hemi.length=m,n.directionalShadow.length=y,n.directionalShadowMap.length=y,n.pointShadow.length=x,n.pointShadowMap.length=x,n.spotShadow.length=S,n.spotShadowMap.length=S,n.directionalShadowMatrix.length=y,n.pointShadowMatrix.length=x,n.spotLightMatrix.length=S+P-T,n.spotLightMap.length=P,n.numSpotLightShadowsWithMaps=T,n.numLightProbes=w,R.directionalLength=f,R.pointLength=g,R.spotLength=_,R.rectAreaLength=p,R.hemiLength=m,R.numDirectionalShadows=y,R.numPointShadows=x,R.numSpotShadows=S,R.numSpotMaps=P,R.numLightProbes=w,n.version=jy++)}function l(c,h){let u=0,d=0,f=0,g=0,_=0;const p=h.matrixWorldInverse;for(let m=0,y=c.length;m<y;m++){const x=c[m];if(x.isDirectionalLight){const S=n.directional[u];S.direction.setFromMatrixPosition(x.matrixWorld),s.setFromMatrixPosition(x.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(p),u++}else if(x.isSpotLight){const S=n.spot[f];S.position.setFromMatrixPosition(x.matrixWorld),S.position.applyMatrix4(p),S.direction.setFromMatrixPosition(x.matrixWorld),s.setFromMatrixPosition(x.target.matrixWorld),S.direction.sub(s),S.direction.transformDirection(p),f++}else if(x.isRectAreaLight){const S=n.rectArea[g];S.position.setFromMatrixPosition(x.matrixWorld),S.position.applyMatrix4(p),r.identity(),a.copy(x.matrixWorld),a.premultiply(p),r.extractRotation(a),S.halfWidth.set(x.width*.5,0,0),S.halfHeight.set(0,x.height*.5,0),S.halfWidth.applyMatrix4(r),S.halfHeight.applyMatrix4(r),g++}else if(x.isPointLight){const S=n.point[d];S.position.setFromMatrixPosition(x.matrixWorld),S.position.applyMatrix4(p),d++}else if(x.isHemisphereLight){const S=n.hemi[_];S.direction.setFromMatrixPosition(x.matrixWorld),S.direction.transformDirection(p),_++}}}return{setup:o,setupView:l,state:n}}function vd(i){const t=new Ky(i),e=[],n=[];function s(h){c.camera=h,e.length=0,n.length=0}function a(h){e.push(h)}function r(h){n.push(h)}function o(){t.setup(e)}function l(h){t.setupView(e,h)}const c={lightsArray:e,shadowsArray:n,camera:null,lights:t,transmissionRenderTarget:{}};return{init:s,state:c,setupLights:o,setupLightsView:l,pushLight:a,pushShadow:r}}function Zy(i){let t=new WeakMap;function e(s,a=0){const r=t.get(s);let o;return r===void 0?(o=new vd(i),t.set(s,[o])):a>=r.length?(o=new vd(i),r.push(o)):o=r[a],o}function n(){t=new WeakMap}return{get:e,dispose:n}}class Jy extends Bi{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=I0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class Qy extends Bi{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}const t1=`void main() {
3843
3843
  gl_Position = vec4( position, 1.0 );
3844
3844
  }`,e1=`uniform sampler2D shadow_pass;
3845
3845
  uniform vec2 resolution;
@@ -3867,7 +3867,7 @@ void main() {
3867
3867
  squared_mean = squared_mean / samples;
3868
3868
  float std_dev = sqrt( squared_mean - mean * mean );
3869
3869
  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
3870
- }`;function n1(i,t,e){let n=new Nh;const s=new lt,a=new lt,r=new me,o=new Jy({depthPacking:k0}),l=new Qy,c={},h=e.maxTextureSize,u={[cs]:fn,[fn]:cs,[ci]:ci},d=new rn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new lt},radius:{value:4}},vertexShader:t1,fragmentShader:e1}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const g=new pn;g.setAttribute("position",new ui(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new yt(g,d),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Lf;let m=this.type;this.render=function(T,w,R){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||T.length===0)return;const k=i.getRenderTarget(),v=i.getActiveCubeFace(),b=i.getActiveMipmapLevel(),N=i.state;N.setBlending(Je),N.buffers.color.setClear(1,1,1,1),N.buffers.depth.setTest(!0),N.setScissorTest(!1);const F=m!==Ai&&this.type===Ai,$=m===Ai&&this.type!==Ai;for(let W=0,z=T.length;W<z;W++){const nt=T[W],G=nt.shadow;if(G===void 0){console.warn("THREE.WebGLShadowMap:",nt,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;s.copy(G.mapSize);const at=G.getFrameExtents();if(s.multiply(at),a.copy(G.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(a.x=Math.floor(h/at.x),s.x=a.x*at.x,G.mapSize.x=a.x),s.y>h&&(a.y=Math.floor(h/at.y),s.y=a.y*at.y,G.mapSize.y=a.y)),G.map===null||F===!0||$===!0){const mt=this.type!==Ai?{minFilter:on,magFilter:on}:{};G.map!==null&&G.map.dispose(),G.map=new ei(s.x,s.y,mt),G.map.texture.name=nt.name+".shadowMap",G.camera.updateProjectionMatrix()}i.setRenderTarget(G.map),i.clear();const ht=G.getViewportCount();for(let mt=0;mt<ht;mt++){const Xt=G.getViewport(mt);r.set(a.x*Xt.x,a.y*Xt.y,a.x*Xt.z,a.y*Xt.w),N.viewport(r),G.updateMatrices(nt,mt),n=G.getFrustum(),S(w,R,G.camera,nt,this.type)}G.isPointLightShadow!==!0&&this.type===Ai&&y(G,R),G.needsUpdate=!1}m=this.type,p.needsUpdate=!1,i.setRenderTarget(k,v,b)};function y(T,w){const R=t.update(_);d.defines.VSM_SAMPLES!==T.blurSamples&&(d.defines.VSM_SAMPLES=T.blurSamples,f.defines.VSM_SAMPLES=T.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new ei(s.x,s.y)),d.uniforms.shadow_pass.value=T.map.texture,d.uniforms.resolution.value=T.mapSize,d.uniforms.radius.value=T.radius,i.setRenderTarget(T.mapPass),i.clear(),i.renderBufferDirect(w,null,R,d,_,null),f.uniforms.shadow_pass.value=T.mapPass.texture,f.uniforms.resolution.value=T.mapSize,f.uniforms.radius.value=T.radius,i.setRenderTarget(T.map),i.clear(),i.renderBufferDirect(w,null,R,f,_,null)}function x(T,w,R,k){let v=null;const b=R.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(b!==void 0)v=b;else if(v=R.isPointLight===!0?l:o,i.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){const N=v.uuid,F=w.uuid;let $=c[N];$===void 0&&($={},c[N]=$);let W=$[F];W===void 0&&(W=v.clone(),$[F]=W,w.addEventListener("dispose",P)),v=W}if(v.visible=w.visible,v.wireframe=w.wireframe,k===Ai?v.side=w.shadowSide!==null?w.shadowSide:w.side:v.side=w.shadowSide!==null?w.shadowSide:u[w.side],v.alphaMap=w.alphaMap,v.alphaTest=w.alphaTest,v.map=w.map,v.clipShadows=w.clipShadows,v.clippingPlanes=w.clippingPlanes,v.clipIntersection=w.clipIntersection,v.displacementMap=w.displacementMap,v.displacementScale=w.displacementScale,v.displacementBias=w.displacementBias,v.wireframeLinewidth=w.wireframeLinewidth,v.linewidth=w.linewidth,R.isPointLight===!0&&v.isMeshDistanceMaterial===!0){const N=i.properties.get(v);N.light=R}return v}function S(T,w,R,k,v){if(T.visible===!1)return;if(T.layers.test(w.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&v===Ai)&&(!T.frustumCulled||n.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,T.matrixWorld);const F=t.update(T),$=T.material;if(Array.isArray($)){const W=F.groups;for(let z=0,nt=W.length;z<nt;z++){const G=W[z],at=$[G.materialIndex];if(at&&at.visible){const ht=x(T,at,k,v);T.onBeforeShadow(i,T,w,R,F,ht,G),i.renderBufferDirect(R,null,F,ht,T,G),T.onAfterShadow(i,T,w,R,F,ht,G)}}}else if($.visible){const W=x(T,$,k,v);T.onBeforeShadow(i,T,w,R,F,W,null),i.renderBufferDirect(R,null,F,W,T,null),T.onAfterShadow(i,T,w,R,F,W,null)}}const N=T.children;for(let F=0,$=N.length;F<$;F++)S(N[F],w,R,k,v)}function P(T){T.target.removeEventListener("dispose",P);for(const R in c){const k=c[R],v=T.target.uuid;v in k&&(k[v].dispose(),delete k[v])}}}const i1={[vc]:_c,[xc]:bc,[yc]:Sc,[ba]:Mc,[_c]:vc,[bc]:xc,[Sc]:yc,[Mc]:ba};function s1(i){function t(){let D=!1;const pt=new me;let V=null;const tt=new me(0,0,0,0);return{setMask:function(_t){V!==_t&&!D&&(i.colorMask(_t,_t,_t,_t),V=_t)},setLocked:function(_t){D=_t},setClear:function(_t,bt,ie,Ie,mn){mn===!0&&(_t*=Ie,bt*=Ie,ie*=Ie),pt.set(_t,bt,ie,Ie),tt.equals(pt)===!1&&(i.clearColor(_t,bt,ie,Ie),tt.copy(pt))},reset:function(){D=!1,V=null,tt.set(-1,0,0,0)}}}function e(){let D=!1,pt=!1,V=null,tt=null,_t=null;return{setReversed:function(bt){pt=bt},setTest:function(bt){bt?Mt(i.DEPTH_TEST):dt(i.DEPTH_TEST)},setMask:function(bt){V!==bt&&!D&&(i.depthMask(bt),V=bt)},setFunc:function(bt){if(pt&&(bt=i1[bt]),tt!==bt){switch(bt){case vc:i.depthFunc(i.NEVER);break;case _c:i.depthFunc(i.ALWAYS);break;case xc:i.depthFunc(i.LESS);break;case ba:i.depthFunc(i.LEQUAL);break;case yc:i.depthFunc(i.EQUAL);break;case Mc:i.depthFunc(i.GEQUAL);break;case bc:i.depthFunc(i.GREATER);break;case Sc:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}tt=bt}},setLocked:function(bt){D=bt},setClear:function(bt){_t!==bt&&(i.clearDepth(bt),_t=bt)},reset:function(){D=!1,V=null,tt=null,_t=null}}}function n(){let D=!1,pt=null,V=null,tt=null,_t=null,bt=null,ie=null,Ie=null,mn=null;return{setTest:function(oe){D||(oe?Mt(i.STENCIL_TEST):dt(i.STENCIL_TEST))},setMask:function(oe){pt!==oe&&!D&&(i.stencilMask(oe),pt=oe)},setFunc:function(oe,gn,xi){(V!==oe||tt!==gn||_t!==xi)&&(i.stencilFunc(oe,gn,xi),V=oe,tt=gn,_t=xi)},setOp:function(oe,gn,xi){(bt!==oe||ie!==gn||Ie!==xi)&&(i.stencilOp(oe,gn,xi),bt=oe,ie=gn,Ie=xi)},setLocked:function(oe){D=oe},setClear:function(oe){mn!==oe&&(i.clearStencil(oe),mn=oe)},reset:function(){D=!1,pt=null,V=null,tt=null,_t=null,bt=null,ie=null,Ie=null,mn=null}}}const s=new t,a=new e,r=new n,o=new WeakMap,l=new WeakMap;let c={},h={},u=new WeakMap,d=[],f=null,g=!1,_=null,p=null,m=null,y=null,x=null,S=null,P=null,T=new te(0,0,0),w=0,R=!1,k=null,v=null,b=null,N=null,F=null;const $=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let W=!1,z=0;const nt=i.getParameter(i.VERSION);nt.indexOf("WebGL")!==-1?(z=parseFloat(/^WebGL (\d)/.exec(nt)[1]),W=z>=1):nt.indexOf("OpenGL ES")!==-1&&(z=parseFloat(/^OpenGL ES (\d)/.exec(nt)[1]),W=z>=2);let G=null,at={};const ht=i.getParameter(i.SCISSOR_BOX),mt=i.getParameter(i.VIEWPORT),Xt=new me().fromArray(ht),qt=new me().fromArray(mt);function q(D,pt,V,tt){const _t=new Uint8Array(4),bt=i.createTexture();i.bindTexture(D,bt),i.texParameteri(D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(D,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let ie=0;ie<V;ie++)D===i.TEXTURE_3D||D===i.TEXTURE_2D_ARRAY?i.texImage3D(pt,0,i.RGBA,1,1,tt,0,i.RGBA,i.UNSIGNED_BYTE,_t):i.texImage2D(pt+ie,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,_t);return bt}const st={};st[i.TEXTURE_2D]=q(i.TEXTURE_2D,i.TEXTURE_2D,1),st[i.TEXTURE_CUBE_MAP]=q(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),st[i.TEXTURE_2D_ARRAY]=q(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),st[i.TEXTURE_3D]=q(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),r.setClear(0),Mt(i.DEPTH_TEST),a.setFunc(ba),Zt(!1),j(Tu),Mt(i.CULL_FACE),L(Je);function Mt(D){c[D]!==!0&&(i.enable(D),c[D]=!0)}function dt(D){c[D]!==!1&&(i.disable(D),c[D]=!1)}function It(D,pt){return h[D]!==pt?(i.bindFramebuffer(D,pt),h[D]=pt,D===i.DRAW_FRAMEBUFFER&&(h[i.FRAMEBUFFER]=pt),D===i.FRAMEBUFFER&&(h[i.DRAW_FRAMEBUFFER]=pt),!0):!1}function Rt(D,pt){let V=d,tt=!1;if(D){V=u.get(pt),V===void 0&&(V=[],u.set(pt,V));const _t=D.textures;if(V.length!==_t.length||V[0]!==i.COLOR_ATTACHMENT0){for(let bt=0,ie=_t.length;bt<ie;bt++)V[bt]=i.COLOR_ATTACHMENT0+bt;V.length=_t.length,tt=!0}}else V[0]!==i.BACK&&(V[0]=i.BACK,tt=!0);tt&&i.drawBuffers(V)}function Nt(D){return f!==D?(i.useProgram(D),f=D,!0):!1}const ee={[Yn]:i.FUNC_ADD,[m0]:i.FUNC_SUBTRACT,[g0]:i.FUNC_REVERSE_SUBTRACT};ee[v0]=i.MIN,ee[_0]=i.MAX;const $t={[qa]:i.ZERO,[x0]:i.ONE,[y0]:i.SRC_COLOR,[fc]:i.SRC_ALPHA,[w0]:i.SRC_ALPHA_SATURATE,[gc]:i.DST_COLOR,[mc]:i.DST_ALPHA,[M0]:i.ONE_MINUS_SRC_COLOR,[pc]:i.ONE_MINUS_SRC_ALPHA,[S0]:i.ONE_MINUS_DST_COLOR,[b0]:i.ONE_MINUS_DST_ALPHA,[E0]:i.CONSTANT_COLOR,[T0]:i.ONE_MINUS_CONSTANT_COLOR,[A0]:i.CONSTANT_ALPHA,[C0]:i.ONE_MINUS_CONSTANT_ALPHA};function L(D,pt,V,tt,_t,bt,ie,Ie,mn,oe){if(D===Je){g===!0&&(dt(i.BLEND),g=!1);return}if(g===!1&&(Mt(i.BLEND),g=!0),D!==If){if(D!==_||oe!==R){if((p!==Yn||x!==Yn)&&(i.blendEquation(i.FUNC_ADD),p=Yn,x=Yn),oe)switch(D){case va:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case dc:i.blendFunc(i.ONE,i.ONE);break;case Au:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Cu:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",D);break}else switch(D){case va:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case dc:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case Au:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Cu:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",D);break}m=null,y=null,S=null,P=null,T.set(0,0,0),w=0,_=D,R=oe}return}_t=_t||pt,bt=bt||V,ie=ie||tt,(pt!==p||_t!==x)&&(i.blendEquationSeparate(ee[pt],ee[_t]),p=pt,x=_t),(V!==m||tt!==y||bt!==S||ie!==P)&&(i.blendFuncSeparate($t[V],$t[tt],$t[bt],$t[ie]),m=V,y=tt,S=bt,P=ie),(Ie.equals(T)===!1||mn!==w)&&(i.blendColor(Ie.r,Ie.g,Ie.b,mn),T.copy(Ie),w=mn),_=D,R=!1}function ze(D,pt){D.side===ci?dt(i.CULL_FACE):Mt(i.CULL_FACE);let V=D.side===fn;pt&&(V=!V),Zt(V),D.blending===va&&D.transparent===!1?L(Je):L(D.blending,D.blendEquation,D.blendSrc,D.blendDst,D.blendEquationAlpha,D.blendSrcAlpha,D.blendDstAlpha,D.blendColor,D.blendAlpha,D.premultipliedAlpha),a.setFunc(D.depthFunc),a.setTest(D.depthTest),a.setMask(D.depthWrite),s.setMask(D.colorWrite);const tt=D.stencilWrite;r.setTest(tt),tt&&(r.setMask(D.stencilWriteMask),r.setFunc(D.stencilFunc,D.stencilRef,D.stencilFuncMask),r.setOp(D.stencilFail,D.stencilZFail,D.stencilZPass)),Tt(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),D.alphaToCoverage===!0?Mt(i.SAMPLE_ALPHA_TO_COVERAGE):dt(i.SAMPLE_ALPHA_TO_COVERAGE)}function Zt(D){k!==D&&(D?i.frontFace(i.CW):i.frontFace(i.CCW),k=D)}function j(D){D!==f0?(Mt(i.CULL_FACE),D!==v&&(D===Tu?i.cullFace(i.BACK):D===p0?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):dt(i.CULL_FACE),v=D}function Q(D){D!==b&&(W&&i.lineWidth(D),b=D)}function Tt(D,pt,V){D?(Mt(i.POLYGON_OFFSET_FILL),(N!==pt||F!==V)&&(i.polygonOffset(pt,V),N=pt,F=V)):dt(i.POLYGON_OFFSET_FILL)}function wt(D){D?Mt(i.SCISSOR_TEST):dt(i.SCISSOR_TEST)}function A(D){D===void 0&&(D=i.TEXTURE0+$-1),G!==D&&(i.activeTexture(D),G=D)}function M(D,pt,V){V===void 0&&(G===null?V=i.TEXTURE0+$-1:V=G);let tt=at[V];tt===void 0&&(tt={type:void 0,texture:void 0},at[V]=tt),(tt.type!==D||tt.texture!==pt)&&(G!==V&&(i.activeTexture(V),G=V),i.bindTexture(D,pt||st[D]),tt.type=D,tt.texture=pt)}function O(){const D=at[G];D!==void 0&&D.type!==void 0&&(i.bindTexture(D.type,null),D.type=void 0,D.texture=void 0)}function Z(){try{i.compressedTexImage2D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function it(){try{i.compressedTexImage3D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Y(){try{i.texSubImage2D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Ct(){try{i.texSubImage3D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function ut(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function gt(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Jt(){try{i.texStorage2D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function rt(){try{i.texStorage3D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function vt(){try{i.texImage2D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Ut(){try{i.texImage3D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Ot(D){Xt.equals(D)===!1&&(i.scissor(D.x,D.y,D.z,D.w),Xt.copy(D))}function Et(D){qt.equals(D)===!1&&(i.viewport(D.x,D.y,D.z,D.w),qt.copy(D))}function ne(D,pt){let V=l.get(pt);V===void 0&&(V=new WeakMap,l.set(pt,V));let tt=V.get(D);tt===void 0&&(tt=i.getUniformBlockIndex(pt,D.name),V.set(D,tt))}function Vt(D,pt){const tt=l.get(pt).get(D);o.get(pt)!==tt&&(i.uniformBlockBinding(pt,tt,D.__bindingPointIndex),o.set(pt,tt))}function se(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),c={},G=null,at={},h={},u=new WeakMap,d=[],f=null,g=!1,_=null,p=null,m=null,y=null,x=null,S=null,P=null,T=new te(0,0,0),w=0,R=!1,k=null,v=null,b=null,N=null,F=null,Xt.set(0,0,i.canvas.width,i.canvas.height),qt.set(0,0,i.canvas.width,i.canvas.height),s.reset(),a.reset(),r.reset()}return{buffers:{color:s,depth:a,stencil:r},enable:Mt,disable:dt,bindFramebuffer:It,drawBuffers:Rt,useProgram:Nt,setBlending:L,setMaterial:ze,setFlipSided:Zt,setCullFace:j,setLineWidth:Q,setPolygonOffset:Tt,setScissorTest:wt,activeTexture:A,bindTexture:M,unbindTexture:O,compressedTexImage2D:Z,compressedTexImage3D:it,texImage2D:vt,texImage3D:Ut,updateUBOMapping:ne,uniformBlockBinding:Vt,texStorage2D:Jt,texStorage3D:rt,texSubImage2D:Y,texSubImage3D:Ct,compressedTexSubImage2D:ut,compressedTexSubImage3D:gt,scissor:Ot,viewport:Et,reset:se}}function _d(i,t,e,n){const s=a1(n);switch(e){case $f:return i*t;case Xf:return i*t;case qf:return i*t*2;case jf:return i*t/s.components*s.byteLength;case Th:return i*t/s.components*s.byteLength;case Yf:return i*t*2/s.components*s.byteLength;case Ah:return i*t*2/s.components*s.byteLength;case Wf:return i*t*3/s.components*s.byteLength;case zn:return i*t*4/s.components*s.byteLength;case Ch:return i*t*4/s.components*s.byteLength;case ao:case ro:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case oo:case lo:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Cc:case Pc:return Math.max(i,16)*Math.max(t,8)/4;case Ac:case Rc:return Math.max(i,8)*Math.max(t,8)/2;case Lc:case Dc:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Ic:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case kc:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Nc:return Math.floor((i+4)/5)*Math.floor((t+3)/4)*16;case Uc:return Math.floor((i+4)/5)*Math.floor((t+4)/5)*16;case Oc:return Math.floor((i+5)/6)*Math.floor((t+4)/5)*16;case Fc:return Math.floor((i+5)/6)*Math.floor((t+5)/6)*16;case zc:return Math.floor((i+7)/8)*Math.floor((t+4)/5)*16;case Bc:return Math.floor((i+7)/8)*Math.floor((t+5)/6)*16;case Hc:return Math.floor((i+7)/8)*Math.floor((t+7)/8)*16;case Vc:return Math.floor((i+9)/10)*Math.floor((t+4)/5)*16;case Gc:return Math.floor((i+9)/10)*Math.floor((t+5)/6)*16;case $c:return Math.floor((i+9)/10)*Math.floor((t+7)/8)*16;case Wc:return Math.floor((i+9)/10)*Math.floor((t+9)/10)*16;case Xc:return Math.floor((i+11)/12)*Math.floor((t+9)/10)*16;case qc:return Math.floor((i+11)/12)*Math.floor((t+11)/12)*16;case co:case jc:case Yc:return Math.ceil(i/4)*Math.ceil(t/4)*16;case Kf:case Kc:return Math.ceil(i/4)*Math.ceil(t/4)*8;case Zc:case Jc:return Math.ceil(i/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function a1(i){switch(i){case pi:case Hf:return{byteLength:1,components:1};case or:case Vf:case Fi:return{byteLength:2,components:1};case wh:case Eh:return{byteLength:2,components:4};case Rs:case Sh:case Li:return{byteLength:4,components:1};case Gf:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}function r1(i,t,e,n,s,a,r){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new lt,h=new WeakMap;let u;const d=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(A,M){return f?new OffscreenCanvas(A,M):Po("canvas")}function _(A,M,O){let Z=1;const it=wt(A);if((it.width>O||it.height>O)&&(Z=O/Math.max(it.width,it.height)),Z<1)if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&A instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&A instanceof ImageBitmap||typeof VideoFrame<"u"&&A instanceof VideoFrame){const Y=Math.floor(Z*it.width),Ct=Math.floor(Z*it.height);u===void 0&&(u=g(Y,Ct));const ut=M?g(Y,Ct):u;return ut.width=Y,ut.height=Ct,ut.getContext("2d").drawImage(A,0,0,Y,Ct),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+it.width+"x"+it.height+") to ("+Y+"x"+Ct+")."),ut}else return"data"in A&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+it.width+"x"+it.height+")."),A;return A}function p(A){return A.generateMipmaps&&A.minFilter!==on&&A.minFilter!==Kn}function m(A){i.generateMipmap(A)}function y(A,M,O,Z,it=!1){if(A!==null){if(i[A]!==void 0)return i[A];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+A+"'")}let Y=M;if(M===i.RED&&(O===i.FLOAT&&(Y=i.R32F),O===i.HALF_FLOAT&&(Y=i.R16F),O===i.UNSIGNED_BYTE&&(Y=i.R8)),M===i.RED_INTEGER&&(O===i.UNSIGNED_BYTE&&(Y=i.R8UI),O===i.UNSIGNED_SHORT&&(Y=i.R16UI),O===i.UNSIGNED_INT&&(Y=i.R32UI),O===i.BYTE&&(Y=i.R8I),O===i.SHORT&&(Y=i.R16I),O===i.INT&&(Y=i.R32I)),M===i.RG&&(O===i.FLOAT&&(Y=i.RG32F),O===i.HALF_FLOAT&&(Y=i.RG16F),O===i.UNSIGNED_BYTE&&(Y=i.RG8)),M===i.RG_INTEGER&&(O===i.UNSIGNED_BYTE&&(Y=i.RG8UI),O===i.UNSIGNED_SHORT&&(Y=i.RG16UI),O===i.UNSIGNED_INT&&(Y=i.RG32UI),O===i.BYTE&&(Y=i.RG8I),O===i.SHORT&&(Y=i.RG16I),O===i.INT&&(Y=i.RG32I)),M===i.RGB_INTEGER&&(O===i.UNSIGNED_BYTE&&(Y=i.RGB8UI),O===i.UNSIGNED_SHORT&&(Y=i.RGB16UI),O===i.UNSIGNED_INT&&(Y=i.RGB32UI),O===i.BYTE&&(Y=i.RGB8I),O===i.SHORT&&(Y=i.RGB16I),O===i.INT&&(Y=i.RGB32I)),M===i.RGBA_INTEGER&&(O===i.UNSIGNED_BYTE&&(Y=i.RGBA8UI),O===i.UNSIGNED_SHORT&&(Y=i.RGBA16UI),O===i.UNSIGNED_INT&&(Y=i.RGBA32UI),O===i.BYTE&&(Y=i.RGBA8I),O===i.SHORT&&(Y=i.RGBA16I),O===i.INT&&(Y=i.RGBA32I)),M===i.RGB&&O===i.UNSIGNED_INT_5_9_9_9_REV&&(Y=i.RGB9_E5),M===i.RGBA){const Ct=it?To:le.getTransfer(Z);O===i.FLOAT&&(Y=i.RGBA32F),O===i.HALF_FLOAT&&(Y=i.RGBA16F),O===i.UNSIGNED_BYTE&&(Y=Ct===ye?i.SRGB8_ALPHA8:i.RGBA8),O===i.UNSIGNED_SHORT_4_4_4_4&&(Y=i.RGBA4),O===i.UNSIGNED_SHORT_5_5_5_1&&(Y=i.RGB5_A1)}return(Y===i.R16F||Y===i.R32F||Y===i.RG16F||Y===i.RG32F||Y===i.RGBA16F||Y===i.RGBA32F)&&t.get("EXT_color_buffer_float"),Y}function x(A,M){let O;return A?M===null||M===Rs||M===Ps?O=i.DEPTH24_STENCIL8:M===Li?O=i.DEPTH32F_STENCIL8:M===or&&(O=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):M===null||M===Rs||M===Ps?O=i.DEPTH_COMPONENT24:M===Li?O=i.DEPTH_COMPONENT32F:M===or&&(O=i.DEPTH_COMPONENT16),O}function S(A,M){return p(A)===!0||A.isFramebufferTexture&&A.minFilter!==on&&A.minFilter!==Kn?Math.log2(Math.max(M.width,M.height))+1:A.mipmaps!==void 0&&A.mipmaps.length>0?A.mipmaps.length:A.isCompressedTexture&&Array.isArray(A.image)?M.mipmaps.length:1}function P(A){const M=A.target;M.removeEventListener("dispose",P),w(M),M.isVideoTexture&&h.delete(M)}function T(A){const M=A.target;M.removeEventListener("dispose",T),k(M)}function w(A){const M=n.get(A);if(M.__webglInit===void 0)return;const O=A.source,Z=d.get(O);if(Z){const it=Z[M.__cacheKey];it.usedTimes--,it.usedTimes===0&&R(A),Object.keys(Z).length===0&&d.delete(O)}n.remove(A)}function R(A){const M=n.get(A);i.deleteTexture(M.__webglTexture);const O=A.source,Z=d.get(O);delete Z[M.__cacheKey],r.memory.textures--}function k(A){const M=n.get(A);if(A.depthTexture&&A.depthTexture.dispose(),A.isWebGLCubeRenderTarget)for(let Z=0;Z<6;Z++){if(Array.isArray(M.__webglFramebuffer[Z]))for(let it=0;it<M.__webglFramebuffer[Z].length;it++)i.deleteFramebuffer(M.__webglFramebuffer[Z][it]);else i.deleteFramebuffer(M.__webglFramebuffer[Z]);M.__webglDepthbuffer&&i.deleteRenderbuffer(M.__webglDepthbuffer[Z])}else{if(Array.isArray(M.__webglFramebuffer))for(let Z=0;Z<M.__webglFramebuffer.length;Z++)i.deleteFramebuffer(M.__webglFramebuffer[Z]);else i.deleteFramebuffer(M.__webglFramebuffer);if(M.__webglDepthbuffer&&i.deleteRenderbuffer(M.__webglDepthbuffer),M.__webglMultisampledFramebuffer&&i.deleteFramebuffer(M.__webglMultisampledFramebuffer),M.__webglColorRenderbuffer)for(let Z=0;Z<M.__webglColorRenderbuffer.length;Z++)M.__webglColorRenderbuffer[Z]&&i.deleteRenderbuffer(M.__webglColorRenderbuffer[Z]);M.__webglDepthRenderbuffer&&i.deleteRenderbuffer(M.__webglDepthRenderbuffer)}const O=A.textures;for(let Z=0,it=O.length;Z<it;Z++){const Y=n.get(O[Z]);Y.__webglTexture&&(i.deleteTexture(Y.__webglTexture),r.memory.textures--),n.remove(O[Z])}n.remove(A)}let v=0;function b(){v=0}function N(){const A=v;return A>=s.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+A+" texture units while this GPU supports only "+s.maxTextures),v+=1,A}function F(A){const M=[];return M.push(A.wrapS),M.push(A.wrapT),M.push(A.wrapR||0),M.push(A.magFilter),M.push(A.minFilter),M.push(A.anisotropy),M.push(A.internalFormat),M.push(A.format),M.push(A.type),M.push(A.generateMipmaps),M.push(A.premultiplyAlpha),M.push(A.flipY),M.push(A.unpackAlignment),M.push(A.colorSpace),M.join()}function $(A,M){const O=n.get(A);if(A.isVideoTexture&&Q(A),A.isRenderTargetTexture===!1&&A.version>0&&O.__version!==A.version){const Z=A.image;if(Z===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Z.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{qt(O,A,M);return}}e.bindTexture(i.TEXTURE_2D,O.__webglTexture,i.TEXTURE0+M)}function W(A,M){const O=n.get(A);if(A.version>0&&O.__version!==A.version){qt(O,A,M);return}e.bindTexture(i.TEXTURE_2D_ARRAY,O.__webglTexture,i.TEXTURE0+M)}function z(A,M){const O=n.get(A);if(A.version>0&&O.__version!==A.version){qt(O,A,M);return}e.bindTexture(i.TEXTURE_3D,O.__webglTexture,i.TEXTURE0+M)}function nt(A,M){const O=n.get(A);if(A.version>0&&O.__version!==A.version){q(O,A,M);return}e.bindTexture(i.TEXTURE_CUBE_MAP,O.__webglTexture,i.TEXTURE0+M)}const G={[Oi]:i.REPEAT,[bs]:i.CLAMP_TO_EDGE,[Tc]:i.MIRRORED_REPEAT},at={[on]:i.NEAREST,[D0]:i.NEAREST_MIPMAP_NEAREST,[_r]:i.NEAREST_MIPMAP_LINEAR,[Kn]:i.LINEAR,[al]:i.LINEAR_MIPMAP_NEAREST,[Ss]:i.LINEAR_MIPMAP_LINEAR},ht={[U0]:i.NEVER,[V0]:i.ALWAYS,[O0]:i.LESS,[Zf]:i.LEQUAL,[F0]:i.EQUAL,[H0]:i.GEQUAL,[z0]:i.GREATER,[B0]:i.NOTEQUAL};function mt(A,M){if(M.type===Li&&t.has("OES_texture_float_linear")===!1&&(M.magFilter===Kn||M.magFilter===al||M.magFilter===_r||M.magFilter===Ss||M.minFilter===Kn||M.minFilter===al||M.minFilter===_r||M.minFilter===Ss)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(A,i.TEXTURE_WRAP_S,G[M.wrapS]),i.texParameteri(A,i.TEXTURE_WRAP_T,G[M.wrapT]),(A===i.TEXTURE_3D||A===i.TEXTURE_2D_ARRAY)&&i.texParameteri(A,i.TEXTURE_WRAP_R,G[M.wrapR]),i.texParameteri(A,i.TEXTURE_MAG_FILTER,at[M.magFilter]),i.texParameteri(A,i.TEXTURE_MIN_FILTER,at[M.minFilter]),M.compareFunction&&(i.texParameteri(A,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(A,i.TEXTURE_COMPARE_FUNC,ht[M.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(M.magFilter===on||M.minFilter!==_r&&M.minFilter!==Ss||M.type===Li&&t.has("OES_texture_float_linear")===!1)return;if(M.anisotropy>1||n.get(M).__currentAnisotropy){const O=t.get("EXT_texture_filter_anisotropic");i.texParameterf(A,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,s.getMaxAnisotropy())),n.get(M).__currentAnisotropy=M.anisotropy}}}function Xt(A,M){let O=!1;A.__webglInit===void 0&&(A.__webglInit=!0,M.addEventListener("dispose",P));const Z=M.source;let it=d.get(Z);it===void 0&&(it={},d.set(Z,it));const Y=F(M);if(Y!==A.__cacheKey){it[Y]===void 0&&(it[Y]={texture:i.createTexture(),usedTimes:0},r.memory.textures++,O=!0),it[Y].usedTimes++;const Ct=it[A.__cacheKey];Ct!==void 0&&(it[A.__cacheKey].usedTimes--,Ct.usedTimes===0&&R(M)),A.__cacheKey=Y,A.__webglTexture=it[Y].texture}return O}function qt(A,M,O){let Z=i.TEXTURE_2D;(M.isDataArrayTexture||M.isCompressedArrayTexture)&&(Z=i.TEXTURE_2D_ARRAY),M.isData3DTexture&&(Z=i.TEXTURE_3D);const it=Xt(A,M),Y=M.source;e.bindTexture(Z,A.__webglTexture,i.TEXTURE0+O);const Ct=n.get(Y);if(Y.version!==Ct.__version||it===!0){e.activeTexture(i.TEXTURE0+O);const ut=le.getPrimaries(le.workingColorSpace),gt=M.colorSpace===ts?null:le.getPrimaries(M.colorSpace),Jt=M.colorSpace===ts||ut===gt?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,M.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,M.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Jt);let rt=_(M.image,!1,s.maxTextureSize);rt=Tt(M,rt);const vt=a.convert(M.format,M.colorSpace),Ut=a.convert(M.type);let Ot=y(M.internalFormat,vt,Ut,M.colorSpace,M.isVideoTexture);mt(Z,M);let Et;const ne=M.mipmaps,Vt=M.isVideoTexture!==!0,se=Ct.__version===void 0||it===!0,D=Y.dataReady,pt=S(M,rt);if(M.isDepthTexture)Ot=x(M.format===Ls,M.type),se&&(Vt?e.texStorage2D(i.TEXTURE_2D,1,Ot,rt.width,rt.height):e.texImage2D(i.TEXTURE_2D,0,Ot,rt.width,rt.height,0,vt,Ut,null));else if(M.isDataTexture)if(ne.length>0){Vt&&se&&e.texStorage2D(i.TEXTURE_2D,pt,Ot,ne[0].width,ne[0].height);for(let V=0,tt=ne.length;V<tt;V++)Et=ne[V],Vt?D&&e.texSubImage2D(i.TEXTURE_2D,V,0,0,Et.width,Et.height,vt,Ut,Et.data):e.texImage2D(i.TEXTURE_2D,V,Ot,Et.width,Et.height,0,vt,Ut,Et.data);M.generateMipmaps=!1}else Vt?(se&&e.texStorage2D(i.TEXTURE_2D,pt,Ot,rt.width,rt.height),D&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,rt.width,rt.height,vt,Ut,rt.data)):e.texImage2D(i.TEXTURE_2D,0,Ot,rt.width,rt.height,0,vt,Ut,rt.data);else if(M.isCompressedTexture)if(M.isCompressedArrayTexture){Vt&&se&&e.texStorage3D(i.TEXTURE_2D_ARRAY,pt,Ot,ne[0].width,ne[0].height,rt.depth);for(let V=0,tt=ne.length;V<tt;V++)if(Et=ne[V],M.format!==zn)if(vt!==null)if(Vt){if(D)if(M.layerUpdates.size>0){const _t=_d(Et.width,Et.height,M.format,M.type);for(const bt of M.layerUpdates){const ie=Et.data.subarray(bt*_t/Et.data.BYTES_PER_ELEMENT,(bt+1)*_t/Et.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,V,0,0,bt,Et.width,Et.height,1,vt,ie,0,0)}M.clearLayerUpdates()}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,V,0,0,0,Et.width,Et.height,rt.depth,vt,Et.data,0,0)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,V,Ot,Et.width,Et.height,rt.depth,0,Et.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Vt?D&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,V,0,0,0,Et.width,Et.height,rt.depth,vt,Ut,Et.data):e.texImage3D(i.TEXTURE_2D_ARRAY,V,Ot,Et.width,Et.height,rt.depth,0,vt,Ut,Et.data)}else{Vt&&se&&e.texStorage2D(i.TEXTURE_2D,pt,Ot,ne[0].width,ne[0].height);for(let V=0,tt=ne.length;V<tt;V++)Et=ne[V],M.format!==zn?vt!==null?Vt?D&&e.compressedTexSubImage2D(i.TEXTURE_2D,V,0,0,Et.width,Et.height,vt,Et.data):e.compressedTexImage2D(i.TEXTURE_2D,V,Ot,Et.width,Et.height,0,Et.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Vt?D&&e.texSubImage2D(i.TEXTURE_2D,V,0,0,Et.width,Et.height,vt,Ut,Et.data):e.texImage2D(i.TEXTURE_2D,V,Ot,Et.width,Et.height,0,vt,Ut,Et.data)}else if(M.isDataArrayTexture)if(Vt){if(se&&e.texStorage3D(i.TEXTURE_2D_ARRAY,pt,Ot,rt.width,rt.height,rt.depth),D)if(M.layerUpdates.size>0){const V=_d(rt.width,rt.height,M.format,M.type);for(const tt of M.layerUpdates){const _t=rt.data.subarray(tt*V/rt.data.BYTES_PER_ELEMENT,(tt+1)*V/rt.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,tt,rt.width,rt.height,1,vt,Ut,_t)}M.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,rt.width,rt.height,rt.depth,vt,Ut,rt.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,Ot,rt.width,rt.height,rt.depth,0,vt,Ut,rt.data);else if(M.isData3DTexture)Vt?(se&&e.texStorage3D(i.TEXTURE_3D,pt,Ot,rt.width,rt.height,rt.depth),D&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,rt.width,rt.height,rt.depth,vt,Ut,rt.data)):e.texImage3D(i.TEXTURE_3D,0,Ot,rt.width,rt.height,rt.depth,0,vt,Ut,rt.data);else if(M.isFramebufferTexture){if(se)if(Vt)e.texStorage2D(i.TEXTURE_2D,pt,Ot,rt.width,rt.height);else{let V=rt.width,tt=rt.height;for(let _t=0;_t<pt;_t++)e.texImage2D(i.TEXTURE_2D,_t,Ot,V,tt,0,vt,Ut,null),V>>=1,tt>>=1}}else if(ne.length>0){if(Vt&&se){const V=wt(ne[0]);e.texStorage2D(i.TEXTURE_2D,pt,Ot,V.width,V.height)}for(let V=0,tt=ne.length;V<tt;V++)Et=ne[V],Vt?D&&e.texSubImage2D(i.TEXTURE_2D,V,0,0,vt,Ut,Et):e.texImage2D(i.TEXTURE_2D,V,Ot,vt,Ut,Et);M.generateMipmaps=!1}else if(Vt){if(se){const V=wt(rt);e.texStorage2D(i.TEXTURE_2D,pt,Ot,V.width,V.height)}D&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,vt,Ut,rt)}else e.texImage2D(i.TEXTURE_2D,0,Ot,vt,Ut,rt);p(M)&&m(Z),Ct.__version=Y.version,M.onUpdate&&M.onUpdate(M)}A.__version=M.version}function q(A,M,O){if(M.image.length!==6)return;const Z=Xt(A,M),it=M.source;e.bindTexture(i.TEXTURE_CUBE_MAP,A.__webglTexture,i.TEXTURE0+O);const Y=n.get(it);if(it.version!==Y.__version||Z===!0){e.activeTexture(i.TEXTURE0+O);const Ct=le.getPrimaries(le.workingColorSpace),ut=M.colorSpace===ts?null:le.getPrimaries(M.colorSpace),gt=M.colorSpace===ts||Ct===ut?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,M.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,M.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,gt);const Jt=M.isCompressedTexture||M.image[0].isCompressedTexture,rt=M.image[0]&&M.image[0].isDataTexture,vt=[];for(let tt=0;tt<6;tt++)!Jt&&!rt?vt[tt]=_(M.image[tt],!0,s.maxCubemapSize):vt[tt]=rt?M.image[tt].image:M.image[tt],vt[tt]=Tt(M,vt[tt]);const Ut=vt[0],Ot=a.convert(M.format,M.colorSpace),Et=a.convert(M.type),ne=y(M.internalFormat,Ot,Et,M.colorSpace),Vt=M.isVideoTexture!==!0,se=Y.__version===void 0||Z===!0,D=it.dataReady;let pt=S(M,Ut);mt(i.TEXTURE_CUBE_MAP,M);let V;if(Jt){Vt&&se&&e.texStorage2D(i.TEXTURE_CUBE_MAP,pt,ne,Ut.width,Ut.height);for(let tt=0;tt<6;tt++){V=vt[tt].mipmaps;for(let _t=0;_t<V.length;_t++){const bt=V[_t];M.format!==zn?Ot!==null?Vt?D&&e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,_t,0,0,bt.width,bt.height,Ot,bt.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,_t,ne,bt.width,bt.height,0,bt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Vt?D&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,_t,0,0,bt.width,bt.height,Ot,Et,bt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,_t,ne,bt.width,bt.height,0,Ot,Et,bt.data)}}}else{if(V=M.mipmaps,Vt&&se){V.length>0&&pt++;const tt=wt(vt[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,pt,ne,tt.width,tt.height)}for(let tt=0;tt<6;tt++)if(rt){Vt?D&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,0,0,vt[tt].width,vt[tt].height,Ot,Et,vt[tt].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,ne,vt[tt].width,vt[tt].height,0,Ot,Et,vt[tt].data);for(let _t=0;_t<V.length;_t++){const ie=V[_t].image[tt].image;Vt?D&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,_t+1,0,0,ie.width,ie.height,Ot,Et,ie.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,_t+1,ne,ie.width,ie.height,0,Ot,Et,ie.data)}}else{Vt?D&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,0,0,Ot,Et,vt[tt]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,ne,Ot,Et,vt[tt]);for(let _t=0;_t<V.length;_t++){const bt=V[_t];Vt?D&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,_t+1,0,0,Ot,Et,bt.image[tt]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,_t+1,ne,Ot,Et,bt.image[tt])}}}p(M)&&m(i.TEXTURE_CUBE_MAP),Y.__version=it.version,M.onUpdate&&M.onUpdate(M)}A.__version=M.version}function st(A,M,O,Z,it,Y){const Ct=a.convert(O.format,O.colorSpace),ut=a.convert(O.type),gt=y(O.internalFormat,Ct,ut,O.colorSpace);if(!n.get(M).__hasExternalTextures){const rt=Math.max(1,M.width>>Y),vt=Math.max(1,M.height>>Y);it===i.TEXTURE_3D||it===i.TEXTURE_2D_ARRAY?e.texImage3D(it,Y,gt,rt,vt,M.depth,0,Ct,ut,null):e.texImage2D(it,Y,gt,rt,vt,0,Ct,ut,null)}e.bindFramebuffer(i.FRAMEBUFFER,A),j(M)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Z,it,n.get(O).__webglTexture,0,Zt(M)):(it===i.TEXTURE_2D||it>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&it<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Z,it,n.get(O).__webglTexture,Y),e.bindFramebuffer(i.FRAMEBUFFER,null)}function Mt(A,M,O){if(i.bindRenderbuffer(i.RENDERBUFFER,A),M.depthBuffer){const Z=M.depthTexture,it=Z&&Z.isDepthTexture?Z.type:null,Y=x(M.stencilBuffer,it),Ct=M.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ut=Zt(M);j(M)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ut,Y,M.width,M.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,ut,Y,M.width,M.height):i.renderbufferStorage(i.RENDERBUFFER,Y,M.width,M.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,Ct,i.RENDERBUFFER,A)}else{const Z=M.textures;for(let it=0;it<Z.length;it++){const Y=Z[it],Ct=a.convert(Y.format,Y.colorSpace),ut=a.convert(Y.type),gt=y(Y.internalFormat,Ct,ut,Y.colorSpace),Jt=Zt(M);O&&j(M)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,Jt,gt,M.width,M.height):j(M)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Jt,gt,M.width,M.height):i.renderbufferStorage(i.RENDERBUFFER,gt,M.width,M.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function dt(A,M){if(M&&M.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(i.FRAMEBUFFER,A),!(M.depthTexture&&M.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(M.depthTexture).__webglTexture||M.depthTexture.image.width!==M.width||M.depthTexture.image.height!==M.height)&&(M.depthTexture.image.width=M.width,M.depthTexture.image.height=M.height,M.depthTexture.needsUpdate=!0),$(M.depthTexture,0);const Z=n.get(M.depthTexture).__webglTexture,it=Zt(M);if(M.depthTexture.format===_a)j(M)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Z,0,it):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Z,0);else if(M.depthTexture.format===Ls)j(M)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Z,0,it):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Z,0);else throw new Error("Unknown depthTexture format")}function It(A){const M=n.get(A),O=A.isWebGLCubeRenderTarget===!0;if(M.__boundDepthTexture!==A.depthTexture){const Z=A.depthTexture;if(M.__depthDisposeCallback&&M.__depthDisposeCallback(),Z){const it=()=>{delete M.__boundDepthTexture,delete M.__depthDisposeCallback,Z.removeEventListener("dispose",it)};Z.addEventListener("dispose",it),M.__depthDisposeCallback=it}M.__boundDepthTexture=Z}if(A.depthTexture&&!M.__autoAllocateDepthBuffer){if(O)throw new Error("target.depthTexture not supported in Cube render targets");dt(M.__webglFramebuffer,A)}else if(O){M.__webglDepthbuffer=[];for(let Z=0;Z<6;Z++)if(e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer[Z]),M.__webglDepthbuffer[Z]===void 0)M.__webglDepthbuffer[Z]=i.createRenderbuffer(),Mt(M.__webglDepthbuffer[Z],A,!1);else{const it=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Y=M.__webglDepthbuffer[Z];i.bindRenderbuffer(i.RENDERBUFFER,Y),i.framebufferRenderbuffer(i.FRAMEBUFFER,it,i.RENDERBUFFER,Y)}}else if(e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer),M.__webglDepthbuffer===void 0)M.__webglDepthbuffer=i.createRenderbuffer(),Mt(M.__webglDepthbuffer,A,!1);else{const Z=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,it=M.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,it),i.framebufferRenderbuffer(i.FRAMEBUFFER,Z,i.RENDERBUFFER,it)}e.bindFramebuffer(i.FRAMEBUFFER,null)}function Rt(A,M,O){const Z=n.get(A);M!==void 0&&st(Z.__webglFramebuffer,A,A.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),O!==void 0&&It(A)}function Nt(A){const M=A.texture,O=n.get(A),Z=n.get(M);A.addEventListener("dispose",T);const it=A.textures,Y=A.isWebGLCubeRenderTarget===!0,Ct=it.length>1;if(Ct||(Z.__webglTexture===void 0&&(Z.__webglTexture=i.createTexture()),Z.__version=M.version,r.memory.textures++),Y){O.__webglFramebuffer=[];for(let ut=0;ut<6;ut++)if(M.mipmaps&&M.mipmaps.length>0){O.__webglFramebuffer[ut]=[];for(let gt=0;gt<M.mipmaps.length;gt++)O.__webglFramebuffer[ut][gt]=i.createFramebuffer()}else O.__webglFramebuffer[ut]=i.createFramebuffer()}else{if(M.mipmaps&&M.mipmaps.length>0){O.__webglFramebuffer=[];for(let ut=0;ut<M.mipmaps.length;ut++)O.__webglFramebuffer[ut]=i.createFramebuffer()}else O.__webglFramebuffer=i.createFramebuffer();if(Ct)for(let ut=0,gt=it.length;ut<gt;ut++){const Jt=n.get(it[ut]);Jt.__webglTexture===void 0&&(Jt.__webglTexture=i.createTexture(),r.memory.textures++)}if(A.samples>0&&j(A)===!1){O.__webglMultisampledFramebuffer=i.createFramebuffer(),O.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let ut=0;ut<it.length;ut++){const gt=it[ut];O.__webglColorRenderbuffer[ut]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,O.__webglColorRenderbuffer[ut]);const Jt=a.convert(gt.format,gt.colorSpace),rt=a.convert(gt.type),vt=y(gt.internalFormat,Jt,rt,gt.colorSpace,A.isXRRenderTarget===!0),Ut=Zt(A);i.renderbufferStorageMultisample(i.RENDERBUFFER,Ut,vt,A.width,A.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ut,i.RENDERBUFFER,O.__webglColorRenderbuffer[ut])}i.bindRenderbuffer(i.RENDERBUFFER,null),A.depthBuffer&&(O.__webglDepthRenderbuffer=i.createRenderbuffer(),Mt(O.__webglDepthRenderbuffer,A,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(Y){e.bindTexture(i.TEXTURE_CUBE_MAP,Z.__webglTexture),mt(i.TEXTURE_CUBE_MAP,M);for(let ut=0;ut<6;ut++)if(M.mipmaps&&M.mipmaps.length>0)for(let gt=0;gt<M.mipmaps.length;gt++)st(O.__webglFramebuffer[ut][gt],A,M,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ut,gt);else st(O.__webglFramebuffer[ut],A,M,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ut,0);p(M)&&m(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(Ct){for(let ut=0,gt=it.length;ut<gt;ut++){const Jt=it[ut],rt=n.get(Jt);e.bindTexture(i.TEXTURE_2D,rt.__webglTexture),mt(i.TEXTURE_2D,Jt),st(O.__webglFramebuffer,A,Jt,i.COLOR_ATTACHMENT0+ut,i.TEXTURE_2D,0),p(Jt)&&m(i.TEXTURE_2D)}e.unbindTexture()}else{let ut=i.TEXTURE_2D;if((A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)&&(ut=A.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(ut,Z.__webglTexture),mt(ut,M),M.mipmaps&&M.mipmaps.length>0)for(let gt=0;gt<M.mipmaps.length;gt++)st(O.__webglFramebuffer[gt],A,M,i.COLOR_ATTACHMENT0,ut,gt);else st(O.__webglFramebuffer,A,M,i.COLOR_ATTACHMENT0,ut,0);p(M)&&m(ut),e.unbindTexture()}A.depthBuffer&&It(A)}function ee(A){const M=A.textures;for(let O=0,Z=M.length;O<Z;O++){const it=M[O];if(p(it)){const Y=A.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:i.TEXTURE_2D,Ct=n.get(it).__webglTexture;e.bindTexture(Y,Ct),m(Y),e.unbindTexture()}}}const $t=[],L=[];function ze(A){if(A.samples>0){if(j(A)===!1){const M=A.textures,O=A.width,Z=A.height;let it=i.COLOR_BUFFER_BIT;const Y=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ct=n.get(A),ut=M.length>1;if(ut)for(let gt=0;gt<M.length;gt++)e.bindFramebuffer(i.FRAMEBUFFER,Ct.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+gt,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,Ct.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+gt,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,Ct.__webglMultisampledFramebuffer),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,Ct.__webglFramebuffer);for(let gt=0;gt<M.length;gt++){if(A.resolveDepthBuffer&&(A.depthBuffer&&(it|=i.DEPTH_BUFFER_BIT),A.stencilBuffer&&A.resolveStencilBuffer&&(it|=i.STENCIL_BUFFER_BIT)),ut){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,Ct.__webglColorRenderbuffer[gt]);const Jt=n.get(M[gt]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Jt,0)}i.blitFramebuffer(0,0,O,Z,0,0,O,Z,it,i.NEAREST),l===!0&&($t.length=0,L.length=0,$t.push(i.COLOR_ATTACHMENT0+gt),A.depthBuffer&&A.resolveDepthBuffer===!1&&($t.push(Y),L.push(Y),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,L)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,$t))}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),ut)for(let gt=0;gt<M.length;gt++){e.bindFramebuffer(i.FRAMEBUFFER,Ct.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+gt,i.RENDERBUFFER,Ct.__webglColorRenderbuffer[gt]);const Jt=n.get(M[gt]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,Ct.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+gt,i.TEXTURE_2D,Jt,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,Ct.__webglMultisampledFramebuffer)}else if(A.depthBuffer&&A.resolveDepthBuffer===!1&&l){const M=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[M])}}}function Zt(A){return Math.min(s.maxSamples,A.samples)}function j(A){const M=n.get(A);return A.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function Q(A){const M=r.render.frame;h.get(A)!==M&&(h.set(A,M),A.update())}function Tt(A,M){const O=A.colorSpace,Z=A.format,it=A.type;return A.isCompressedTexture===!0||A.isVideoTexture===!0||O!==us&&O!==ts&&(le.getTransfer(O)===ye?(Z!==zn||it!==pi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",O)),M}function wt(A){return typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement?(c.width=A.naturalWidth||A.width,c.height=A.naturalHeight||A.height):typeof VideoFrame<"u"&&A instanceof VideoFrame?(c.width=A.displayWidth,c.height=A.displayHeight):(c.width=A.width,c.height=A.height),c}this.allocateTextureUnit=N,this.resetTextureUnits=b,this.setTexture2D=$,this.setTexture2DArray=W,this.setTexture3D=z,this.setTextureCube=nt,this.rebindTextures=Rt,this.setupRenderTarget=Nt,this.updateRenderTargetMipmap=ee,this.updateMultisampleRenderTarget=ze,this.setupDepthRenderbuffer=It,this.setupFrameBufferTexture=st,this.useMultisampledRTT=j}function o1(i,t){function e(n,s=ts){let a;const r=le.getTransfer(s);if(n===pi)return i.UNSIGNED_BYTE;if(n===wh)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Eh)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Gf)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Hf)return i.BYTE;if(n===Vf)return i.SHORT;if(n===or)return i.UNSIGNED_SHORT;if(n===Sh)return i.INT;if(n===Rs)return i.UNSIGNED_INT;if(n===Li)return i.FLOAT;if(n===Fi)return i.HALF_FLOAT;if(n===$f)return i.ALPHA;if(n===Wf)return i.RGB;if(n===zn)return i.RGBA;if(n===Xf)return i.LUMINANCE;if(n===qf)return i.LUMINANCE_ALPHA;if(n===_a)return i.DEPTH_COMPONENT;if(n===Ls)return i.DEPTH_STENCIL;if(n===jf)return i.RED;if(n===Th)return i.RED_INTEGER;if(n===Yf)return i.RG;if(n===Ah)return i.RG_INTEGER;if(n===Ch)return i.RGBA_INTEGER;if(n===ao||n===ro||n===oo||n===lo)if(r===ye)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(n===ao)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===ro)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===oo)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===lo)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(n===ao)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===ro)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===oo)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===lo)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Ac||n===Cc||n===Rc||n===Pc)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(n===Ac)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Cc)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Rc)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Pc)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Lc||n===Dc||n===Ic)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(n===Lc||n===Dc)return r===ye?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(n===Ic)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===kc||n===Nc||n===Uc||n===Oc||n===Fc||n===zc||n===Bc||n===Hc||n===Vc||n===Gc||n===$c||n===Wc||n===Xc||n===qc)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(n===kc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Nc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Uc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Oc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Fc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===zc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Bc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Hc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Vc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Gc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===$c)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Wc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Xc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===qc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===co||n===jc||n===Yc)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(n===co)return r===ye?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===jc)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Yc)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Kf||n===Kc||n===Zc||n===Jc)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(n===co)return a.COMPRESSED_RED_RGTC1_EXT;if(n===Kc)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Zc)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Jc)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ps?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}class l1 extends Rn{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class Ht extends nn{constructor(){super(),this.isGroup=!0,this.type="Group"}}const c1={type:"move"};class Il{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ht,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Ht,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new C,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new C),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ht,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new C,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new C),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let s=null,a=null,r=null;const o=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){r=!0;for(const _ of t.hand.values()){const p=e.getJointPose(_,n),m=this._getHandJoint(c,_);p!==null&&(m.matrix.fromArray(p.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=p.radius),m.visible=p!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,g=.005;c.inputState.pinching&&d>f+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&d<=f-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(a=e.getPose(t.gripSpace,n),a!==null&&(l.matrix.fromArray(a.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,a.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(a.linearVelocity)):l.hasLinearVelocity=!1,a.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(a.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(s=e.getPose(t.targetRaySpace,n),s===null&&a!==null&&(s=a),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(c1)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=a!==null),c!==null&&(c.visible=r!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new Ht;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const h1=`
3870
+ }`;function n1(i,t,e){let n=new Nh;const s=new lt,a=new lt,r=new me,o=new Jy({depthPacking:k0}),l=new Qy,c={},h=e.maxTextureSize,u={[cs]:fn,[fn]:cs,[ci]:ci},d=new an({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new lt},radius:{value:4}},vertexShader:t1,fragmentShader:e1}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const g=new pn;g.setAttribute("position",new ui(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new yt(g,d),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Pf;let m=this.type;this.render=function(T,w,R){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||T.length===0)return;const k=i.getRenderTarget(),v=i.getActiveCubeFace(),b=i.getActiveMipmapLevel(),N=i.state;N.setBlending(Je),N.buffers.color.setClear(1,1,1,1),N.buffers.depth.setTest(!0),N.setScissorTest(!1);const F=m!==Ai&&this.type===Ai,$=m===Ai&&this.type!==Ai;for(let W=0,z=T.length;W<z;W++){const nt=T[W],G=nt.shadow;if(G===void 0){console.warn("THREE.WebGLShadowMap:",nt,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;s.copy(G.mapSize);const at=G.getFrameExtents();if(s.multiply(at),a.copy(G.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(a.x=Math.floor(h/at.x),s.x=a.x*at.x,G.mapSize.x=a.x),s.y>h&&(a.y=Math.floor(h/at.y),s.y=a.y*at.y,G.mapSize.y=a.y)),G.map===null||F===!0||$===!0){const mt=this.type!==Ai?{minFilter:rn,magFilter:rn}:{};G.map!==null&&G.map.dispose(),G.map=new ei(s.x,s.y,mt),G.map.texture.name=nt.name+".shadowMap",G.camera.updateProjectionMatrix()}i.setRenderTarget(G.map),i.clear();const ht=G.getViewportCount();for(let mt=0;mt<ht;mt++){const Xt=G.getViewport(mt);r.set(a.x*Xt.x,a.y*Xt.y,a.x*Xt.z,a.y*Xt.w),N.viewport(r),G.updateMatrices(nt,mt),n=G.getFrustum(),S(w,R,G.camera,nt,this.type)}G.isPointLightShadow!==!0&&this.type===Ai&&y(G,R),G.needsUpdate=!1}m=this.type,p.needsUpdate=!1,i.setRenderTarget(k,v,b)};function y(T,w){const R=t.update(_);d.defines.VSM_SAMPLES!==T.blurSamples&&(d.defines.VSM_SAMPLES=T.blurSamples,f.defines.VSM_SAMPLES=T.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new ei(s.x,s.y)),d.uniforms.shadow_pass.value=T.map.texture,d.uniforms.resolution.value=T.mapSize,d.uniforms.radius.value=T.radius,i.setRenderTarget(T.mapPass),i.clear(),i.renderBufferDirect(w,null,R,d,_,null),f.uniforms.shadow_pass.value=T.mapPass.texture,f.uniforms.resolution.value=T.mapSize,f.uniforms.radius.value=T.radius,i.setRenderTarget(T.map),i.clear(),i.renderBufferDirect(w,null,R,f,_,null)}function x(T,w,R,k){let v=null;const b=R.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(b!==void 0)v=b;else if(v=R.isPointLight===!0?l:o,i.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){const N=v.uuid,F=w.uuid;let $=c[N];$===void 0&&($={},c[N]=$);let W=$[F];W===void 0&&(W=v.clone(),$[F]=W,w.addEventListener("dispose",P)),v=W}if(v.visible=w.visible,v.wireframe=w.wireframe,k===Ai?v.side=w.shadowSide!==null?w.shadowSide:w.side:v.side=w.shadowSide!==null?w.shadowSide:u[w.side],v.alphaMap=w.alphaMap,v.alphaTest=w.alphaTest,v.map=w.map,v.clipShadows=w.clipShadows,v.clippingPlanes=w.clippingPlanes,v.clipIntersection=w.clipIntersection,v.displacementMap=w.displacementMap,v.displacementScale=w.displacementScale,v.displacementBias=w.displacementBias,v.wireframeLinewidth=w.wireframeLinewidth,v.linewidth=w.linewidth,R.isPointLight===!0&&v.isMeshDistanceMaterial===!0){const N=i.properties.get(v);N.light=R}return v}function S(T,w,R,k,v){if(T.visible===!1)return;if(T.layers.test(w.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&v===Ai)&&(!T.frustumCulled||n.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,T.matrixWorld);const F=t.update(T),$=T.material;if(Array.isArray($)){const W=F.groups;for(let z=0,nt=W.length;z<nt;z++){const G=W[z],at=$[G.materialIndex];if(at&&at.visible){const ht=x(T,at,k,v);T.onBeforeShadow(i,T,w,R,F,ht,G),i.renderBufferDirect(R,null,F,ht,T,G),T.onAfterShadow(i,T,w,R,F,ht,G)}}}else if($.visible){const W=x(T,$,k,v);T.onBeforeShadow(i,T,w,R,F,W,null),i.renderBufferDirect(R,null,F,W,T,null),T.onAfterShadow(i,T,w,R,F,W,null)}}const N=T.children;for(let F=0,$=N.length;F<$;F++)S(N[F],w,R,k,v)}function P(T){T.target.removeEventListener("dispose",P);for(const R in c){const k=c[R],v=T.target.uuid;v in k&&(k[v].dispose(),delete k[v])}}}const i1={[vc]:_c,[xc]:bc,[yc]:Sc,[ba]:Mc,[_c]:vc,[bc]:xc,[Sc]:yc,[Mc]:ba};function s1(i){function t(){let D=!1;const pt=new me;let V=null;const tt=new me(0,0,0,0);return{setMask:function(_t){V!==_t&&!D&&(i.colorMask(_t,_t,_t,_t),V=_t)},setLocked:function(_t){D=_t},setClear:function(_t,bt,ie,Ie,mn){mn===!0&&(_t*=Ie,bt*=Ie,ie*=Ie),pt.set(_t,bt,ie,Ie),tt.equals(pt)===!1&&(i.clearColor(_t,bt,ie,Ie),tt.copy(pt))},reset:function(){D=!1,V=null,tt.set(-1,0,0,0)}}}function e(){let D=!1,pt=!1,V=null,tt=null,_t=null;return{setReversed:function(bt){pt=bt},setTest:function(bt){bt?Mt(i.DEPTH_TEST):dt(i.DEPTH_TEST)},setMask:function(bt){V!==bt&&!D&&(i.depthMask(bt),V=bt)},setFunc:function(bt){if(pt&&(bt=i1[bt]),tt!==bt){switch(bt){case vc:i.depthFunc(i.NEVER);break;case _c:i.depthFunc(i.ALWAYS);break;case xc:i.depthFunc(i.LESS);break;case ba:i.depthFunc(i.LEQUAL);break;case yc:i.depthFunc(i.EQUAL);break;case Mc:i.depthFunc(i.GEQUAL);break;case bc:i.depthFunc(i.GREATER);break;case Sc:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}tt=bt}},setLocked:function(bt){D=bt},setClear:function(bt){_t!==bt&&(i.clearDepth(bt),_t=bt)},reset:function(){D=!1,V=null,tt=null,_t=null}}}function n(){let D=!1,pt=null,V=null,tt=null,_t=null,bt=null,ie=null,Ie=null,mn=null;return{setTest:function(oe){D||(oe?Mt(i.STENCIL_TEST):dt(i.STENCIL_TEST))},setMask:function(oe){pt!==oe&&!D&&(i.stencilMask(oe),pt=oe)},setFunc:function(oe,gn,xi){(V!==oe||tt!==gn||_t!==xi)&&(i.stencilFunc(oe,gn,xi),V=oe,tt=gn,_t=xi)},setOp:function(oe,gn,xi){(bt!==oe||ie!==gn||Ie!==xi)&&(i.stencilOp(oe,gn,xi),bt=oe,ie=gn,Ie=xi)},setLocked:function(oe){D=oe},setClear:function(oe){mn!==oe&&(i.clearStencil(oe),mn=oe)},reset:function(){D=!1,pt=null,V=null,tt=null,_t=null,bt=null,ie=null,Ie=null,mn=null}}}const s=new t,a=new e,r=new n,o=new WeakMap,l=new WeakMap;let c={},h={},u=new WeakMap,d=[],f=null,g=!1,_=null,p=null,m=null,y=null,x=null,S=null,P=null,T=new te(0,0,0),w=0,R=!1,k=null,v=null,b=null,N=null,F=null;const $=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let W=!1,z=0;const nt=i.getParameter(i.VERSION);nt.indexOf("WebGL")!==-1?(z=parseFloat(/^WebGL (\d)/.exec(nt)[1]),W=z>=1):nt.indexOf("OpenGL ES")!==-1&&(z=parseFloat(/^OpenGL ES (\d)/.exec(nt)[1]),W=z>=2);let G=null,at={};const ht=i.getParameter(i.SCISSOR_BOX),mt=i.getParameter(i.VIEWPORT),Xt=new me().fromArray(ht),qt=new me().fromArray(mt);function q(D,pt,V,tt){const _t=new Uint8Array(4),bt=i.createTexture();i.bindTexture(D,bt),i.texParameteri(D,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(D,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let ie=0;ie<V;ie++)D===i.TEXTURE_3D||D===i.TEXTURE_2D_ARRAY?i.texImage3D(pt,0,i.RGBA,1,1,tt,0,i.RGBA,i.UNSIGNED_BYTE,_t):i.texImage2D(pt+ie,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,_t);return bt}const st={};st[i.TEXTURE_2D]=q(i.TEXTURE_2D,i.TEXTURE_2D,1),st[i.TEXTURE_CUBE_MAP]=q(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),st[i.TEXTURE_2D_ARRAY]=q(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),st[i.TEXTURE_3D]=q(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),a.setClear(1),r.setClear(0),Mt(i.DEPTH_TEST),a.setFunc(ba),Zt(!1),j(Tu),Mt(i.CULL_FACE),L(Je);function Mt(D){c[D]!==!0&&(i.enable(D),c[D]=!0)}function dt(D){c[D]!==!1&&(i.disable(D),c[D]=!1)}function It(D,pt){return h[D]!==pt?(i.bindFramebuffer(D,pt),h[D]=pt,D===i.DRAW_FRAMEBUFFER&&(h[i.FRAMEBUFFER]=pt),D===i.FRAMEBUFFER&&(h[i.DRAW_FRAMEBUFFER]=pt),!0):!1}function Rt(D,pt){let V=d,tt=!1;if(D){V=u.get(pt),V===void 0&&(V=[],u.set(pt,V));const _t=D.textures;if(V.length!==_t.length||V[0]!==i.COLOR_ATTACHMENT0){for(let bt=0,ie=_t.length;bt<ie;bt++)V[bt]=i.COLOR_ATTACHMENT0+bt;V.length=_t.length,tt=!0}}else V[0]!==i.BACK&&(V[0]=i.BACK,tt=!0);tt&&i.drawBuffers(V)}function Nt(D){return f!==D?(i.useProgram(D),f=D,!0):!1}const ee={[Yn]:i.FUNC_ADD,[m0]:i.FUNC_SUBTRACT,[g0]:i.FUNC_REVERSE_SUBTRACT};ee[v0]=i.MIN,ee[_0]=i.MAX;const $t={[qa]:i.ZERO,[x0]:i.ONE,[y0]:i.SRC_COLOR,[fc]:i.SRC_ALPHA,[w0]:i.SRC_ALPHA_SATURATE,[gc]:i.DST_COLOR,[mc]:i.DST_ALPHA,[M0]:i.ONE_MINUS_SRC_COLOR,[pc]:i.ONE_MINUS_SRC_ALPHA,[S0]:i.ONE_MINUS_DST_COLOR,[b0]:i.ONE_MINUS_DST_ALPHA,[E0]:i.CONSTANT_COLOR,[T0]:i.ONE_MINUS_CONSTANT_COLOR,[A0]:i.CONSTANT_ALPHA,[C0]:i.ONE_MINUS_CONSTANT_ALPHA};function L(D,pt,V,tt,_t,bt,ie,Ie,mn,oe){if(D===Je){g===!0&&(dt(i.BLEND),g=!1);return}if(g===!1&&(Mt(i.BLEND),g=!0),D!==Df){if(D!==_||oe!==R){if((p!==Yn||x!==Yn)&&(i.blendEquation(i.FUNC_ADD),p=Yn,x=Yn),oe)switch(D){case va:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case dc:i.blendFunc(i.ONE,i.ONE);break;case Au:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Cu:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",D);break}else switch(D){case va:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case dc:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case Au:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Cu:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",D);break}m=null,y=null,S=null,P=null,T.set(0,0,0),w=0,_=D,R=oe}return}_t=_t||pt,bt=bt||V,ie=ie||tt,(pt!==p||_t!==x)&&(i.blendEquationSeparate(ee[pt],ee[_t]),p=pt,x=_t),(V!==m||tt!==y||bt!==S||ie!==P)&&(i.blendFuncSeparate($t[V],$t[tt],$t[bt],$t[ie]),m=V,y=tt,S=bt,P=ie),(Ie.equals(T)===!1||mn!==w)&&(i.blendColor(Ie.r,Ie.g,Ie.b,mn),T.copy(Ie),w=mn),_=D,R=!1}function ze(D,pt){D.side===ci?dt(i.CULL_FACE):Mt(i.CULL_FACE);let V=D.side===fn;pt&&(V=!V),Zt(V),D.blending===va&&D.transparent===!1?L(Je):L(D.blending,D.blendEquation,D.blendSrc,D.blendDst,D.blendEquationAlpha,D.blendSrcAlpha,D.blendDstAlpha,D.blendColor,D.blendAlpha,D.premultipliedAlpha),a.setFunc(D.depthFunc),a.setTest(D.depthTest),a.setMask(D.depthWrite),s.setMask(D.colorWrite);const tt=D.stencilWrite;r.setTest(tt),tt&&(r.setMask(D.stencilWriteMask),r.setFunc(D.stencilFunc,D.stencilRef,D.stencilFuncMask),r.setOp(D.stencilFail,D.stencilZFail,D.stencilZPass)),Tt(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),D.alphaToCoverage===!0?Mt(i.SAMPLE_ALPHA_TO_COVERAGE):dt(i.SAMPLE_ALPHA_TO_COVERAGE)}function Zt(D){k!==D&&(D?i.frontFace(i.CW):i.frontFace(i.CCW),k=D)}function j(D){D!==f0?(Mt(i.CULL_FACE),D!==v&&(D===Tu?i.cullFace(i.BACK):D===p0?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):dt(i.CULL_FACE),v=D}function Q(D){D!==b&&(W&&i.lineWidth(D),b=D)}function Tt(D,pt,V){D?(Mt(i.POLYGON_OFFSET_FILL),(N!==pt||F!==V)&&(i.polygonOffset(pt,V),N=pt,F=V)):dt(i.POLYGON_OFFSET_FILL)}function St(D){D?Mt(i.SCISSOR_TEST):dt(i.SCISSOR_TEST)}function A(D){D===void 0&&(D=i.TEXTURE0+$-1),G!==D&&(i.activeTexture(D),G=D)}function M(D,pt,V){V===void 0&&(G===null?V=i.TEXTURE0+$-1:V=G);let tt=at[V];tt===void 0&&(tt={type:void 0,texture:void 0},at[V]=tt),(tt.type!==D||tt.texture!==pt)&&(G!==V&&(i.activeTexture(V),G=V),i.bindTexture(D,pt||st[D]),tt.type=D,tt.texture=pt)}function O(){const D=at[G];D!==void 0&&D.type!==void 0&&(i.bindTexture(D.type,null),D.type=void 0,D.texture=void 0)}function Z(){try{i.compressedTexImage2D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function it(){try{i.compressedTexImage3D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Y(){try{i.texSubImage2D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Ct(){try{i.texSubImage3D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function ut(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function gt(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Jt(){try{i.texStorage2D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function rt(){try{i.texStorage3D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function vt(){try{i.texImage2D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Ut(){try{i.texImage3D.apply(i,arguments)}catch(D){console.error("THREE.WebGLState:",D)}}function Ot(D){Xt.equals(D)===!1&&(i.scissor(D.x,D.y,D.z,D.w),Xt.copy(D))}function Et(D){qt.equals(D)===!1&&(i.viewport(D.x,D.y,D.z,D.w),qt.copy(D))}function ne(D,pt){let V=l.get(pt);V===void 0&&(V=new WeakMap,l.set(pt,V));let tt=V.get(D);tt===void 0&&(tt=i.getUniformBlockIndex(pt,D.name),V.set(D,tt))}function Vt(D,pt){const tt=l.get(pt).get(D);o.get(pt)!==tt&&(i.uniformBlockBinding(pt,tt,D.__bindingPointIndex),o.set(pt,tt))}function se(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),c={},G=null,at={},h={},u=new WeakMap,d=[],f=null,g=!1,_=null,p=null,m=null,y=null,x=null,S=null,P=null,T=new te(0,0,0),w=0,R=!1,k=null,v=null,b=null,N=null,F=null,Xt.set(0,0,i.canvas.width,i.canvas.height),qt.set(0,0,i.canvas.width,i.canvas.height),s.reset(),a.reset(),r.reset()}return{buffers:{color:s,depth:a,stencil:r},enable:Mt,disable:dt,bindFramebuffer:It,drawBuffers:Rt,useProgram:Nt,setBlending:L,setMaterial:ze,setFlipSided:Zt,setCullFace:j,setLineWidth:Q,setPolygonOffset:Tt,setScissorTest:St,activeTexture:A,bindTexture:M,unbindTexture:O,compressedTexImage2D:Z,compressedTexImage3D:it,texImage2D:vt,texImage3D:Ut,updateUBOMapping:ne,uniformBlockBinding:Vt,texStorage2D:Jt,texStorage3D:rt,texSubImage2D:Y,texSubImage3D:Ct,compressedTexSubImage2D:ut,compressedTexSubImage3D:gt,scissor:Ot,viewport:Et,reset:se}}function _d(i,t,e,n){const s=a1(n);switch(e){case Gf:return i*t;case Wf:return i*t;case Xf:return i*t*2;case qf:return i*t/s.components*s.byteLength;case Th:return i*t/s.components*s.byteLength;case jf:return i*t*2/s.components*s.byteLength;case Ah:return i*t*2/s.components*s.byteLength;case $f:return i*t*3/s.components*s.byteLength;case zn:return i*t*4/s.components*s.byteLength;case Ch:return i*t*4/s.components*s.byteLength;case ao:case ro:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case oo:case lo:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Cc:case Pc:return Math.max(i,16)*Math.max(t,8)/4;case Ac:case Rc:return Math.max(i,8)*Math.max(t,8)/2;case Lc:case Dc:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Ic:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case kc:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Nc:return Math.floor((i+4)/5)*Math.floor((t+3)/4)*16;case Uc:return Math.floor((i+4)/5)*Math.floor((t+4)/5)*16;case Oc:return Math.floor((i+5)/6)*Math.floor((t+4)/5)*16;case Fc:return Math.floor((i+5)/6)*Math.floor((t+5)/6)*16;case zc:return Math.floor((i+7)/8)*Math.floor((t+4)/5)*16;case Bc:return Math.floor((i+7)/8)*Math.floor((t+5)/6)*16;case Hc:return Math.floor((i+7)/8)*Math.floor((t+7)/8)*16;case Vc:return Math.floor((i+9)/10)*Math.floor((t+4)/5)*16;case Gc:return Math.floor((i+9)/10)*Math.floor((t+5)/6)*16;case $c:return Math.floor((i+9)/10)*Math.floor((t+7)/8)*16;case Wc:return Math.floor((i+9)/10)*Math.floor((t+9)/10)*16;case Xc:return Math.floor((i+11)/12)*Math.floor((t+9)/10)*16;case qc:return Math.floor((i+11)/12)*Math.floor((t+11)/12)*16;case co:case jc:case Yc:return Math.ceil(i/4)*Math.ceil(t/4)*16;case Yf:case Kc:return Math.ceil(i/4)*Math.ceil(t/4)*8;case Zc:case Jc:return Math.ceil(i/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function a1(i){switch(i){case pi:case Bf:return{byteLength:1,components:1};case or:case Hf:case Fi:return{byteLength:2,components:1};case wh:case Eh:return{byteLength:2,components:4};case Rs:case Sh:case Li:return{byteLength:4,components:1};case Vf:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}function r1(i,t,e,n,s,a,r){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new lt,h=new WeakMap;let u;const d=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(A,M){return f?new OffscreenCanvas(A,M):Po("canvas")}function _(A,M,O){let Z=1;const it=St(A);if((it.width>O||it.height>O)&&(Z=O/Math.max(it.width,it.height)),Z<1)if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&A instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&A instanceof ImageBitmap||typeof VideoFrame<"u"&&A instanceof VideoFrame){const Y=Math.floor(Z*it.width),Ct=Math.floor(Z*it.height);u===void 0&&(u=g(Y,Ct));const ut=M?g(Y,Ct):u;return ut.width=Y,ut.height=Ct,ut.getContext("2d").drawImage(A,0,0,Y,Ct),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+it.width+"x"+it.height+") to ("+Y+"x"+Ct+")."),ut}else return"data"in A&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+it.width+"x"+it.height+")."),A;return A}function p(A){return A.generateMipmaps&&A.minFilter!==rn&&A.minFilter!==Kn}function m(A){i.generateMipmap(A)}function y(A,M,O,Z,it=!1){if(A!==null){if(i[A]!==void 0)return i[A];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+A+"'")}let Y=M;if(M===i.RED&&(O===i.FLOAT&&(Y=i.R32F),O===i.HALF_FLOAT&&(Y=i.R16F),O===i.UNSIGNED_BYTE&&(Y=i.R8)),M===i.RED_INTEGER&&(O===i.UNSIGNED_BYTE&&(Y=i.R8UI),O===i.UNSIGNED_SHORT&&(Y=i.R16UI),O===i.UNSIGNED_INT&&(Y=i.R32UI),O===i.BYTE&&(Y=i.R8I),O===i.SHORT&&(Y=i.R16I),O===i.INT&&(Y=i.R32I)),M===i.RG&&(O===i.FLOAT&&(Y=i.RG32F),O===i.HALF_FLOAT&&(Y=i.RG16F),O===i.UNSIGNED_BYTE&&(Y=i.RG8)),M===i.RG_INTEGER&&(O===i.UNSIGNED_BYTE&&(Y=i.RG8UI),O===i.UNSIGNED_SHORT&&(Y=i.RG16UI),O===i.UNSIGNED_INT&&(Y=i.RG32UI),O===i.BYTE&&(Y=i.RG8I),O===i.SHORT&&(Y=i.RG16I),O===i.INT&&(Y=i.RG32I)),M===i.RGB_INTEGER&&(O===i.UNSIGNED_BYTE&&(Y=i.RGB8UI),O===i.UNSIGNED_SHORT&&(Y=i.RGB16UI),O===i.UNSIGNED_INT&&(Y=i.RGB32UI),O===i.BYTE&&(Y=i.RGB8I),O===i.SHORT&&(Y=i.RGB16I),O===i.INT&&(Y=i.RGB32I)),M===i.RGBA_INTEGER&&(O===i.UNSIGNED_BYTE&&(Y=i.RGBA8UI),O===i.UNSIGNED_SHORT&&(Y=i.RGBA16UI),O===i.UNSIGNED_INT&&(Y=i.RGBA32UI),O===i.BYTE&&(Y=i.RGBA8I),O===i.SHORT&&(Y=i.RGBA16I),O===i.INT&&(Y=i.RGBA32I)),M===i.RGB&&O===i.UNSIGNED_INT_5_9_9_9_REV&&(Y=i.RGB9_E5),M===i.RGBA){const Ct=it?To:le.getTransfer(Z);O===i.FLOAT&&(Y=i.RGBA32F),O===i.HALF_FLOAT&&(Y=i.RGBA16F),O===i.UNSIGNED_BYTE&&(Y=Ct===ye?i.SRGB8_ALPHA8:i.RGBA8),O===i.UNSIGNED_SHORT_4_4_4_4&&(Y=i.RGBA4),O===i.UNSIGNED_SHORT_5_5_5_1&&(Y=i.RGB5_A1)}return(Y===i.R16F||Y===i.R32F||Y===i.RG16F||Y===i.RG32F||Y===i.RGBA16F||Y===i.RGBA32F)&&t.get("EXT_color_buffer_float"),Y}function x(A,M){let O;return A?M===null||M===Rs||M===Ps?O=i.DEPTH24_STENCIL8:M===Li?O=i.DEPTH32F_STENCIL8:M===or&&(O=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):M===null||M===Rs||M===Ps?O=i.DEPTH_COMPONENT24:M===Li?O=i.DEPTH_COMPONENT32F:M===or&&(O=i.DEPTH_COMPONENT16),O}function S(A,M){return p(A)===!0||A.isFramebufferTexture&&A.minFilter!==rn&&A.minFilter!==Kn?Math.log2(Math.max(M.width,M.height))+1:A.mipmaps!==void 0&&A.mipmaps.length>0?A.mipmaps.length:A.isCompressedTexture&&Array.isArray(A.image)?M.mipmaps.length:1}function P(A){const M=A.target;M.removeEventListener("dispose",P),w(M),M.isVideoTexture&&h.delete(M)}function T(A){const M=A.target;M.removeEventListener("dispose",T),k(M)}function w(A){const M=n.get(A);if(M.__webglInit===void 0)return;const O=A.source,Z=d.get(O);if(Z){const it=Z[M.__cacheKey];it.usedTimes--,it.usedTimes===0&&R(A),Object.keys(Z).length===0&&d.delete(O)}n.remove(A)}function R(A){const M=n.get(A);i.deleteTexture(M.__webglTexture);const O=A.source,Z=d.get(O);delete Z[M.__cacheKey],r.memory.textures--}function k(A){const M=n.get(A);if(A.depthTexture&&A.depthTexture.dispose(),A.isWebGLCubeRenderTarget)for(let Z=0;Z<6;Z++){if(Array.isArray(M.__webglFramebuffer[Z]))for(let it=0;it<M.__webglFramebuffer[Z].length;it++)i.deleteFramebuffer(M.__webglFramebuffer[Z][it]);else i.deleteFramebuffer(M.__webglFramebuffer[Z]);M.__webglDepthbuffer&&i.deleteRenderbuffer(M.__webglDepthbuffer[Z])}else{if(Array.isArray(M.__webglFramebuffer))for(let Z=0;Z<M.__webglFramebuffer.length;Z++)i.deleteFramebuffer(M.__webglFramebuffer[Z]);else i.deleteFramebuffer(M.__webglFramebuffer);if(M.__webglDepthbuffer&&i.deleteRenderbuffer(M.__webglDepthbuffer),M.__webglMultisampledFramebuffer&&i.deleteFramebuffer(M.__webglMultisampledFramebuffer),M.__webglColorRenderbuffer)for(let Z=0;Z<M.__webglColorRenderbuffer.length;Z++)M.__webglColorRenderbuffer[Z]&&i.deleteRenderbuffer(M.__webglColorRenderbuffer[Z]);M.__webglDepthRenderbuffer&&i.deleteRenderbuffer(M.__webglDepthRenderbuffer)}const O=A.textures;for(let Z=0,it=O.length;Z<it;Z++){const Y=n.get(O[Z]);Y.__webglTexture&&(i.deleteTexture(Y.__webglTexture),r.memory.textures--),n.remove(O[Z])}n.remove(A)}let v=0;function b(){v=0}function N(){const A=v;return A>=s.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+A+" texture units while this GPU supports only "+s.maxTextures),v+=1,A}function F(A){const M=[];return M.push(A.wrapS),M.push(A.wrapT),M.push(A.wrapR||0),M.push(A.magFilter),M.push(A.minFilter),M.push(A.anisotropy),M.push(A.internalFormat),M.push(A.format),M.push(A.type),M.push(A.generateMipmaps),M.push(A.premultiplyAlpha),M.push(A.flipY),M.push(A.unpackAlignment),M.push(A.colorSpace),M.join()}function $(A,M){const O=n.get(A);if(A.isVideoTexture&&Q(A),A.isRenderTargetTexture===!1&&A.version>0&&O.__version!==A.version){const Z=A.image;if(Z===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Z.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{qt(O,A,M);return}}e.bindTexture(i.TEXTURE_2D,O.__webglTexture,i.TEXTURE0+M)}function W(A,M){const O=n.get(A);if(A.version>0&&O.__version!==A.version){qt(O,A,M);return}e.bindTexture(i.TEXTURE_2D_ARRAY,O.__webglTexture,i.TEXTURE0+M)}function z(A,M){const O=n.get(A);if(A.version>0&&O.__version!==A.version){qt(O,A,M);return}e.bindTexture(i.TEXTURE_3D,O.__webglTexture,i.TEXTURE0+M)}function nt(A,M){const O=n.get(A);if(A.version>0&&O.__version!==A.version){q(O,A,M);return}e.bindTexture(i.TEXTURE_CUBE_MAP,O.__webglTexture,i.TEXTURE0+M)}const G={[Oi]:i.REPEAT,[bs]:i.CLAMP_TO_EDGE,[Tc]:i.MIRRORED_REPEAT},at={[rn]:i.NEAREST,[D0]:i.NEAREST_MIPMAP_NEAREST,[_r]:i.NEAREST_MIPMAP_LINEAR,[Kn]:i.LINEAR,[al]:i.LINEAR_MIPMAP_NEAREST,[Ss]:i.LINEAR_MIPMAP_LINEAR},ht={[U0]:i.NEVER,[V0]:i.ALWAYS,[O0]:i.LESS,[Kf]:i.LEQUAL,[F0]:i.EQUAL,[H0]:i.GEQUAL,[z0]:i.GREATER,[B0]:i.NOTEQUAL};function mt(A,M){if(M.type===Li&&t.has("OES_texture_float_linear")===!1&&(M.magFilter===Kn||M.magFilter===al||M.magFilter===_r||M.magFilter===Ss||M.minFilter===Kn||M.minFilter===al||M.minFilter===_r||M.minFilter===Ss)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(A,i.TEXTURE_WRAP_S,G[M.wrapS]),i.texParameteri(A,i.TEXTURE_WRAP_T,G[M.wrapT]),(A===i.TEXTURE_3D||A===i.TEXTURE_2D_ARRAY)&&i.texParameteri(A,i.TEXTURE_WRAP_R,G[M.wrapR]),i.texParameteri(A,i.TEXTURE_MAG_FILTER,at[M.magFilter]),i.texParameteri(A,i.TEXTURE_MIN_FILTER,at[M.minFilter]),M.compareFunction&&(i.texParameteri(A,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(A,i.TEXTURE_COMPARE_FUNC,ht[M.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(M.magFilter===rn||M.minFilter!==_r&&M.minFilter!==Ss||M.type===Li&&t.has("OES_texture_float_linear")===!1)return;if(M.anisotropy>1||n.get(M).__currentAnisotropy){const O=t.get("EXT_texture_filter_anisotropic");i.texParameterf(A,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,s.getMaxAnisotropy())),n.get(M).__currentAnisotropy=M.anisotropy}}}function Xt(A,M){let O=!1;A.__webglInit===void 0&&(A.__webglInit=!0,M.addEventListener("dispose",P));const Z=M.source;let it=d.get(Z);it===void 0&&(it={},d.set(Z,it));const Y=F(M);if(Y!==A.__cacheKey){it[Y]===void 0&&(it[Y]={texture:i.createTexture(),usedTimes:0},r.memory.textures++,O=!0),it[Y].usedTimes++;const Ct=it[A.__cacheKey];Ct!==void 0&&(it[A.__cacheKey].usedTimes--,Ct.usedTimes===0&&R(M)),A.__cacheKey=Y,A.__webglTexture=it[Y].texture}return O}function qt(A,M,O){let Z=i.TEXTURE_2D;(M.isDataArrayTexture||M.isCompressedArrayTexture)&&(Z=i.TEXTURE_2D_ARRAY),M.isData3DTexture&&(Z=i.TEXTURE_3D);const it=Xt(A,M),Y=M.source;e.bindTexture(Z,A.__webglTexture,i.TEXTURE0+O);const Ct=n.get(Y);if(Y.version!==Ct.__version||it===!0){e.activeTexture(i.TEXTURE0+O);const ut=le.getPrimaries(le.workingColorSpace),gt=M.colorSpace===ts?null:le.getPrimaries(M.colorSpace),Jt=M.colorSpace===ts||ut===gt?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,M.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,M.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Jt);let rt=_(M.image,!1,s.maxTextureSize);rt=Tt(M,rt);const vt=a.convert(M.format,M.colorSpace),Ut=a.convert(M.type);let Ot=y(M.internalFormat,vt,Ut,M.colorSpace,M.isVideoTexture);mt(Z,M);let Et;const ne=M.mipmaps,Vt=M.isVideoTexture!==!0,se=Ct.__version===void 0||it===!0,D=Y.dataReady,pt=S(M,rt);if(M.isDepthTexture)Ot=x(M.format===Ls,M.type),se&&(Vt?e.texStorage2D(i.TEXTURE_2D,1,Ot,rt.width,rt.height):e.texImage2D(i.TEXTURE_2D,0,Ot,rt.width,rt.height,0,vt,Ut,null));else if(M.isDataTexture)if(ne.length>0){Vt&&se&&e.texStorage2D(i.TEXTURE_2D,pt,Ot,ne[0].width,ne[0].height);for(let V=0,tt=ne.length;V<tt;V++)Et=ne[V],Vt?D&&e.texSubImage2D(i.TEXTURE_2D,V,0,0,Et.width,Et.height,vt,Ut,Et.data):e.texImage2D(i.TEXTURE_2D,V,Ot,Et.width,Et.height,0,vt,Ut,Et.data);M.generateMipmaps=!1}else Vt?(se&&e.texStorage2D(i.TEXTURE_2D,pt,Ot,rt.width,rt.height),D&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,rt.width,rt.height,vt,Ut,rt.data)):e.texImage2D(i.TEXTURE_2D,0,Ot,rt.width,rt.height,0,vt,Ut,rt.data);else if(M.isCompressedTexture)if(M.isCompressedArrayTexture){Vt&&se&&e.texStorage3D(i.TEXTURE_2D_ARRAY,pt,Ot,ne[0].width,ne[0].height,rt.depth);for(let V=0,tt=ne.length;V<tt;V++)if(Et=ne[V],M.format!==zn)if(vt!==null)if(Vt){if(D)if(M.layerUpdates.size>0){const _t=_d(Et.width,Et.height,M.format,M.type);for(const bt of M.layerUpdates){const ie=Et.data.subarray(bt*_t/Et.data.BYTES_PER_ELEMENT,(bt+1)*_t/Et.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,V,0,0,bt,Et.width,Et.height,1,vt,ie,0,0)}M.clearLayerUpdates()}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,V,0,0,0,Et.width,Et.height,rt.depth,vt,Et.data,0,0)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,V,Ot,Et.width,Et.height,rt.depth,0,Et.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Vt?D&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,V,0,0,0,Et.width,Et.height,rt.depth,vt,Ut,Et.data):e.texImage3D(i.TEXTURE_2D_ARRAY,V,Ot,Et.width,Et.height,rt.depth,0,vt,Ut,Et.data)}else{Vt&&se&&e.texStorage2D(i.TEXTURE_2D,pt,Ot,ne[0].width,ne[0].height);for(let V=0,tt=ne.length;V<tt;V++)Et=ne[V],M.format!==zn?vt!==null?Vt?D&&e.compressedTexSubImage2D(i.TEXTURE_2D,V,0,0,Et.width,Et.height,vt,Et.data):e.compressedTexImage2D(i.TEXTURE_2D,V,Ot,Et.width,Et.height,0,Et.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Vt?D&&e.texSubImage2D(i.TEXTURE_2D,V,0,0,Et.width,Et.height,vt,Ut,Et.data):e.texImage2D(i.TEXTURE_2D,V,Ot,Et.width,Et.height,0,vt,Ut,Et.data)}else if(M.isDataArrayTexture)if(Vt){if(se&&e.texStorage3D(i.TEXTURE_2D_ARRAY,pt,Ot,rt.width,rt.height,rt.depth),D)if(M.layerUpdates.size>0){const V=_d(rt.width,rt.height,M.format,M.type);for(const tt of M.layerUpdates){const _t=rt.data.subarray(tt*V/rt.data.BYTES_PER_ELEMENT,(tt+1)*V/rt.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,tt,rt.width,rt.height,1,vt,Ut,_t)}M.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,rt.width,rt.height,rt.depth,vt,Ut,rt.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,Ot,rt.width,rt.height,rt.depth,0,vt,Ut,rt.data);else if(M.isData3DTexture)Vt?(se&&e.texStorage3D(i.TEXTURE_3D,pt,Ot,rt.width,rt.height,rt.depth),D&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,rt.width,rt.height,rt.depth,vt,Ut,rt.data)):e.texImage3D(i.TEXTURE_3D,0,Ot,rt.width,rt.height,rt.depth,0,vt,Ut,rt.data);else if(M.isFramebufferTexture){if(se)if(Vt)e.texStorage2D(i.TEXTURE_2D,pt,Ot,rt.width,rt.height);else{let V=rt.width,tt=rt.height;for(let _t=0;_t<pt;_t++)e.texImage2D(i.TEXTURE_2D,_t,Ot,V,tt,0,vt,Ut,null),V>>=1,tt>>=1}}else if(ne.length>0){if(Vt&&se){const V=St(ne[0]);e.texStorage2D(i.TEXTURE_2D,pt,Ot,V.width,V.height)}for(let V=0,tt=ne.length;V<tt;V++)Et=ne[V],Vt?D&&e.texSubImage2D(i.TEXTURE_2D,V,0,0,vt,Ut,Et):e.texImage2D(i.TEXTURE_2D,V,Ot,vt,Ut,Et);M.generateMipmaps=!1}else if(Vt){if(se){const V=St(rt);e.texStorage2D(i.TEXTURE_2D,pt,Ot,V.width,V.height)}D&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,vt,Ut,rt)}else e.texImage2D(i.TEXTURE_2D,0,Ot,vt,Ut,rt);p(M)&&m(Z),Ct.__version=Y.version,M.onUpdate&&M.onUpdate(M)}A.__version=M.version}function q(A,M,O){if(M.image.length!==6)return;const Z=Xt(A,M),it=M.source;e.bindTexture(i.TEXTURE_CUBE_MAP,A.__webglTexture,i.TEXTURE0+O);const Y=n.get(it);if(it.version!==Y.__version||Z===!0){e.activeTexture(i.TEXTURE0+O);const Ct=le.getPrimaries(le.workingColorSpace),ut=M.colorSpace===ts?null:le.getPrimaries(M.colorSpace),gt=M.colorSpace===ts||Ct===ut?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,M.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,M.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,gt);const Jt=M.isCompressedTexture||M.image[0].isCompressedTexture,rt=M.image[0]&&M.image[0].isDataTexture,vt=[];for(let tt=0;tt<6;tt++)!Jt&&!rt?vt[tt]=_(M.image[tt],!0,s.maxCubemapSize):vt[tt]=rt?M.image[tt].image:M.image[tt],vt[tt]=Tt(M,vt[tt]);const Ut=vt[0],Ot=a.convert(M.format,M.colorSpace),Et=a.convert(M.type),ne=y(M.internalFormat,Ot,Et,M.colorSpace),Vt=M.isVideoTexture!==!0,se=Y.__version===void 0||Z===!0,D=it.dataReady;let pt=S(M,Ut);mt(i.TEXTURE_CUBE_MAP,M);let V;if(Jt){Vt&&se&&e.texStorage2D(i.TEXTURE_CUBE_MAP,pt,ne,Ut.width,Ut.height);for(let tt=0;tt<6;tt++){V=vt[tt].mipmaps;for(let _t=0;_t<V.length;_t++){const bt=V[_t];M.format!==zn?Ot!==null?Vt?D&&e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,_t,0,0,bt.width,bt.height,Ot,bt.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,_t,ne,bt.width,bt.height,0,bt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Vt?D&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,_t,0,0,bt.width,bt.height,Ot,Et,bt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,_t,ne,bt.width,bt.height,0,Ot,Et,bt.data)}}}else{if(V=M.mipmaps,Vt&&se){V.length>0&&pt++;const tt=St(vt[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,pt,ne,tt.width,tt.height)}for(let tt=0;tt<6;tt++)if(rt){Vt?D&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,0,0,vt[tt].width,vt[tt].height,Ot,Et,vt[tt].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,ne,vt[tt].width,vt[tt].height,0,Ot,Et,vt[tt].data);for(let _t=0;_t<V.length;_t++){const ie=V[_t].image[tt].image;Vt?D&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,_t+1,0,0,ie.width,ie.height,Ot,Et,ie.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,_t+1,ne,ie.width,ie.height,0,Ot,Et,ie.data)}}else{Vt?D&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,0,0,Ot,Et,vt[tt]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,ne,Ot,Et,vt[tt]);for(let _t=0;_t<V.length;_t++){const bt=V[_t];Vt?D&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,_t+1,0,0,Ot,Et,bt.image[tt]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,_t+1,ne,Ot,Et,bt.image[tt])}}}p(M)&&m(i.TEXTURE_CUBE_MAP),Y.__version=it.version,M.onUpdate&&M.onUpdate(M)}A.__version=M.version}function st(A,M,O,Z,it,Y){const Ct=a.convert(O.format,O.colorSpace),ut=a.convert(O.type),gt=y(O.internalFormat,Ct,ut,O.colorSpace);if(!n.get(M).__hasExternalTextures){const rt=Math.max(1,M.width>>Y),vt=Math.max(1,M.height>>Y);it===i.TEXTURE_3D||it===i.TEXTURE_2D_ARRAY?e.texImage3D(it,Y,gt,rt,vt,M.depth,0,Ct,ut,null):e.texImage2D(it,Y,gt,rt,vt,0,Ct,ut,null)}e.bindFramebuffer(i.FRAMEBUFFER,A),j(M)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Z,it,n.get(O).__webglTexture,0,Zt(M)):(it===i.TEXTURE_2D||it>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&it<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Z,it,n.get(O).__webglTexture,Y),e.bindFramebuffer(i.FRAMEBUFFER,null)}function Mt(A,M,O){if(i.bindRenderbuffer(i.RENDERBUFFER,A),M.depthBuffer){const Z=M.depthTexture,it=Z&&Z.isDepthTexture?Z.type:null,Y=x(M.stencilBuffer,it),Ct=M.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ut=Zt(M);j(M)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ut,Y,M.width,M.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,ut,Y,M.width,M.height):i.renderbufferStorage(i.RENDERBUFFER,Y,M.width,M.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,Ct,i.RENDERBUFFER,A)}else{const Z=M.textures;for(let it=0;it<Z.length;it++){const Y=Z[it],Ct=a.convert(Y.format,Y.colorSpace),ut=a.convert(Y.type),gt=y(Y.internalFormat,Ct,ut,Y.colorSpace),Jt=Zt(M);O&&j(M)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,Jt,gt,M.width,M.height):j(M)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Jt,gt,M.width,M.height):i.renderbufferStorage(i.RENDERBUFFER,gt,M.width,M.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function dt(A,M){if(M&&M.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(i.FRAMEBUFFER,A),!(M.depthTexture&&M.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(M.depthTexture).__webglTexture||M.depthTexture.image.width!==M.width||M.depthTexture.image.height!==M.height)&&(M.depthTexture.image.width=M.width,M.depthTexture.image.height=M.height,M.depthTexture.needsUpdate=!0),$(M.depthTexture,0);const Z=n.get(M.depthTexture).__webglTexture,it=Zt(M);if(M.depthTexture.format===_a)j(M)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Z,0,it):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,Z,0);else if(M.depthTexture.format===Ls)j(M)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Z,0,it):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,Z,0);else throw new Error("Unknown depthTexture format")}function It(A){const M=n.get(A),O=A.isWebGLCubeRenderTarget===!0;if(M.__boundDepthTexture!==A.depthTexture){const Z=A.depthTexture;if(M.__depthDisposeCallback&&M.__depthDisposeCallback(),Z){const it=()=>{delete M.__boundDepthTexture,delete M.__depthDisposeCallback,Z.removeEventListener("dispose",it)};Z.addEventListener("dispose",it),M.__depthDisposeCallback=it}M.__boundDepthTexture=Z}if(A.depthTexture&&!M.__autoAllocateDepthBuffer){if(O)throw new Error("target.depthTexture not supported in Cube render targets");dt(M.__webglFramebuffer,A)}else if(O){M.__webglDepthbuffer=[];for(let Z=0;Z<6;Z++)if(e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer[Z]),M.__webglDepthbuffer[Z]===void 0)M.__webglDepthbuffer[Z]=i.createRenderbuffer(),Mt(M.__webglDepthbuffer[Z],A,!1);else{const it=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Y=M.__webglDepthbuffer[Z];i.bindRenderbuffer(i.RENDERBUFFER,Y),i.framebufferRenderbuffer(i.FRAMEBUFFER,it,i.RENDERBUFFER,Y)}}else if(e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer),M.__webglDepthbuffer===void 0)M.__webglDepthbuffer=i.createRenderbuffer(),Mt(M.__webglDepthbuffer,A,!1);else{const Z=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,it=M.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,it),i.framebufferRenderbuffer(i.FRAMEBUFFER,Z,i.RENDERBUFFER,it)}e.bindFramebuffer(i.FRAMEBUFFER,null)}function Rt(A,M,O){const Z=n.get(A);M!==void 0&&st(Z.__webglFramebuffer,A,A.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),O!==void 0&&It(A)}function Nt(A){const M=A.texture,O=n.get(A),Z=n.get(M);A.addEventListener("dispose",T);const it=A.textures,Y=A.isWebGLCubeRenderTarget===!0,Ct=it.length>1;if(Ct||(Z.__webglTexture===void 0&&(Z.__webglTexture=i.createTexture()),Z.__version=M.version,r.memory.textures++),Y){O.__webglFramebuffer=[];for(let ut=0;ut<6;ut++)if(M.mipmaps&&M.mipmaps.length>0){O.__webglFramebuffer[ut]=[];for(let gt=0;gt<M.mipmaps.length;gt++)O.__webglFramebuffer[ut][gt]=i.createFramebuffer()}else O.__webglFramebuffer[ut]=i.createFramebuffer()}else{if(M.mipmaps&&M.mipmaps.length>0){O.__webglFramebuffer=[];for(let ut=0;ut<M.mipmaps.length;ut++)O.__webglFramebuffer[ut]=i.createFramebuffer()}else O.__webglFramebuffer=i.createFramebuffer();if(Ct)for(let ut=0,gt=it.length;ut<gt;ut++){const Jt=n.get(it[ut]);Jt.__webglTexture===void 0&&(Jt.__webglTexture=i.createTexture(),r.memory.textures++)}if(A.samples>0&&j(A)===!1){O.__webglMultisampledFramebuffer=i.createFramebuffer(),O.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let ut=0;ut<it.length;ut++){const gt=it[ut];O.__webglColorRenderbuffer[ut]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,O.__webglColorRenderbuffer[ut]);const Jt=a.convert(gt.format,gt.colorSpace),rt=a.convert(gt.type),vt=y(gt.internalFormat,Jt,rt,gt.colorSpace,A.isXRRenderTarget===!0),Ut=Zt(A);i.renderbufferStorageMultisample(i.RENDERBUFFER,Ut,vt,A.width,A.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ut,i.RENDERBUFFER,O.__webglColorRenderbuffer[ut])}i.bindRenderbuffer(i.RENDERBUFFER,null),A.depthBuffer&&(O.__webglDepthRenderbuffer=i.createRenderbuffer(),Mt(O.__webglDepthRenderbuffer,A,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(Y){e.bindTexture(i.TEXTURE_CUBE_MAP,Z.__webglTexture),mt(i.TEXTURE_CUBE_MAP,M);for(let ut=0;ut<6;ut++)if(M.mipmaps&&M.mipmaps.length>0)for(let gt=0;gt<M.mipmaps.length;gt++)st(O.__webglFramebuffer[ut][gt],A,M,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ut,gt);else st(O.__webglFramebuffer[ut],A,M,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ut,0);p(M)&&m(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(Ct){for(let ut=0,gt=it.length;ut<gt;ut++){const Jt=it[ut],rt=n.get(Jt);e.bindTexture(i.TEXTURE_2D,rt.__webglTexture),mt(i.TEXTURE_2D,Jt),st(O.__webglFramebuffer,A,Jt,i.COLOR_ATTACHMENT0+ut,i.TEXTURE_2D,0),p(Jt)&&m(i.TEXTURE_2D)}e.unbindTexture()}else{let ut=i.TEXTURE_2D;if((A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)&&(ut=A.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(ut,Z.__webglTexture),mt(ut,M),M.mipmaps&&M.mipmaps.length>0)for(let gt=0;gt<M.mipmaps.length;gt++)st(O.__webglFramebuffer[gt],A,M,i.COLOR_ATTACHMENT0,ut,gt);else st(O.__webglFramebuffer,A,M,i.COLOR_ATTACHMENT0,ut,0);p(M)&&m(ut),e.unbindTexture()}A.depthBuffer&&It(A)}function ee(A){const M=A.textures;for(let O=0,Z=M.length;O<Z;O++){const it=M[O];if(p(it)){const Y=A.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:i.TEXTURE_2D,Ct=n.get(it).__webglTexture;e.bindTexture(Y,Ct),m(Y),e.unbindTexture()}}}const $t=[],L=[];function ze(A){if(A.samples>0){if(j(A)===!1){const M=A.textures,O=A.width,Z=A.height;let it=i.COLOR_BUFFER_BIT;const Y=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ct=n.get(A),ut=M.length>1;if(ut)for(let gt=0;gt<M.length;gt++)e.bindFramebuffer(i.FRAMEBUFFER,Ct.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+gt,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,Ct.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+gt,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,Ct.__webglMultisampledFramebuffer),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,Ct.__webglFramebuffer);for(let gt=0;gt<M.length;gt++){if(A.resolveDepthBuffer&&(A.depthBuffer&&(it|=i.DEPTH_BUFFER_BIT),A.stencilBuffer&&A.resolveStencilBuffer&&(it|=i.STENCIL_BUFFER_BIT)),ut){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,Ct.__webglColorRenderbuffer[gt]);const Jt=n.get(M[gt]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Jt,0)}i.blitFramebuffer(0,0,O,Z,0,0,O,Z,it,i.NEAREST),l===!0&&($t.length=0,L.length=0,$t.push(i.COLOR_ATTACHMENT0+gt),A.depthBuffer&&A.resolveDepthBuffer===!1&&($t.push(Y),L.push(Y),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,L)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,$t))}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),ut)for(let gt=0;gt<M.length;gt++){e.bindFramebuffer(i.FRAMEBUFFER,Ct.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+gt,i.RENDERBUFFER,Ct.__webglColorRenderbuffer[gt]);const Jt=n.get(M[gt]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,Ct.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+gt,i.TEXTURE_2D,Jt,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,Ct.__webglMultisampledFramebuffer)}else if(A.depthBuffer&&A.resolveDepthBuffer===!1&&l){const M=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[M])}}}function Zt(A){return Math.min(s.maxSamples,A.samples)}function j(A){const M=n.get(A);return A.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function Q(A){const M=r.render.frame;h.get(A)!==M&&(h.set(A,M),A.update())}function Tt(A,M){const O=A.colorSpace,Z=A.format,it=A.type;return A.isCompressedTexture===!0||A.isVideoTexture===!0||O!==us&&O!==ts&&(le.getTransfer(O)===ye?(Z!==zn||it!==pi)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",O)),M}function St(A){return typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement?(c.width=A.naturalWidth||A.width,c.height=A.naturalHeight||A.height):typeof VideoFrame<"u"&&A instanceof VideoFrame?(c.width=A.displayWidth,c.height=A.displayHeight):(c.width=A.width,c.height=A.height),c}this.allocateTextureUnit=N,this.resetTextureUnits=b,this.setTexture2D=$,this.setTexture2DArray=W,this.setTexture3D=z,this.setTextureCube=nt,this.rebindTextures=Rt,this.setupRenderTarget=Nt,this.updateRenderTargetMipmap=ee,this.updateMultisampleRenderTarget=ze,this.setupDepthRenderbuffer=It,this.setupFrameBufferTexture=st,this.useMultisampledRTT=j}function o1(i,t){function e(n,s=ts){let a;const r=le.getTransfer(s);if(n===pi)return i.UNSIGNED_BYTE;if(n===wh)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Eh)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Vf)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Bf)return i.BYTE;if(n===Hf)return i.SHORT;if(n===or)return i.UNSIGNED_SHORT;if(n===Sh)return i.INT;if(n===Rs)return i.UNSIGNED_INT;if(n===Li)return i.FLOAT;if(n===Fi)return i.HALF_FLOAT;if(n===Gf)return i.ALPHA;if(n===$f)return i.RGB;if(n===zn)return i.RGBA;if(n===Wf)return i.LUMINANCE;if(n===Xf)return i.LUMINANCE_ALPHA;if(n===_a)return i.DEPTH_COMPONENT;if(n===Ls)return i.DEPTH_STENCIL;if(n===qf)return i.RED;if(n===Th)return i.RED_INTEGER;if(n===jf)return i.RG;if(n===Ah)return i.RG_INTEGER;if(n===Ch)return i.RGBA_INTEGER;if(n===ao||n===ro||n===oo||n===lo)if(r===ye)if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(n===ao)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===ro)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===oo)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===lo)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get("WEBGL_compressed_texture_s3tc"),a!==null){if(n===ao)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===ro)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===oo)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===lo)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Ac||n===Cc||n===Rc||n===Pc)if(a=t.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(n===Ac)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Cc)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Rc)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Pc)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Lc||n===Dc||n===Ic)if(a=t.get("WEBGL_compressed_texture_etc"),a!==null){if(n===Lc||n===Dc)return r===ye?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(n===Ic)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===kc||n===Nc||n===Uc||n===Oc||n===Fc||n===zc||n===Bc||n===Hc||n===Vc||n===Gc||n===$c||n===Wc||n===Xc||n===qc)if(a=t.get("WEBGL_compressed_texture_astc"),a!==null){if(n===kc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Nc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Uc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Oc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Fc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===zc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Bc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Hc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Vc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Gc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===$c)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Wc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Xc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===qc)return r===ye?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===co||n===jc||n===Yc)if(a=t.get("EXT_texture_compression_bptc"),a!==null){if(n===co)return r===ye?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===jc)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Yc)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Yf||n===Kc||n===Zc||n===Jc)if(a=t.get("EXT_texture_compression_rgtc"),a!==null){if(n===co)return a.COMPRESSED_RED_RGTC1_EXT;if(n===Kc)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Zc)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Jc)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Ps?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}class l1 extends Rn{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class Ht extends en{constructor(){super(),this.isGroup=!0,this.type="Group"}}const c1={type:"move"};class Il{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ht,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Ht,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new C,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new C),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ht,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new C,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new C),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let s=null,a=null,r=null;const o=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){r=!0;for(const _ of t.hand.values()){const p=e.getJointPose(_,n),m=this._getHandJoint(c,_);p!==null&&(m.matrix.fromArray(p.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=p.radius),m.visible=p!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,g=.005;c.inputState.pinching&&d>f+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&d<=f-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(a=e.getPose(t.gripSpace,n),a!==null&&(l.matrix.fromArray(a.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,a.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(a.linearVelocity)):l.hasLinearVelocity=!1,a.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(a.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(s=e.getPose(t.targetRaySpace,n),s===null&&a!==null&&(s=a),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(c1)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=a!==null),c!==null&&(c.visible=r!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new Ht;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const h1=`
3871
3871
  void main() {
3872
3872
 
3873
3873
  gl_Position = vec4( position, 1.0 );
@@ -3891,7 +3891,7 @@ void main() {
3891
3891
 
3892
3892
  }
3893
3893
 
3894
- }`;class d1{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(this.texture===null){const s=new ln,a=t.properties.get(s);a.__webglTexture=e.texture,(e.depthNear!=n.depthNear||e.depthFar!=n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=s}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new rn({vertexShader:h1,fragmentShader:u1,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new yt(new vi(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class f1 extends Is{constructor(t,e){super();const n=this;let s=null,a=1,r=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,f=null,g=null;const _=new d1,p=e.getContextAttributes();let m=null,y=null;const x=[],S=[],P=new lt;let T=null;const w=new Rn;w.layers.enable(1),w.viewport=new me;const R=new Rn;R.layers.enable(2),R.viewport=new me;const k=[w,R],v=new l1;v.layers.enable(1),v.layers.enable(2);let b=null,N=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(q){let st=x[q];return st===void 0&&(st=new Il,x[q]=st),st.getTargetRaySpace()},this.getControllerGrip=function(q){let st=x[q];return st===void 0&&(st=new Il,x[q]=st),st.getGripSpace()},this.getHand=function(q){let st=x[q];return st===void 0&&(st=new Il,x[q]=st),st.getHandSpace()};function F(q){const st=S.indexOf(q.inputSource);if(st===-1)return;const Mt=x[st];Mt!==void 0&&(Mt.update(q.inputSource,q.frame,c||r),Mt.dispatchEvent({type:q.type,data:q.inputSource}))}function $(){s.removeEventListener("select",F),s.removeEventListener("selectstart",F),s.removeEventListener("selectend",F),s.removeEventListener("squeeze",F),s.removeEventListener("squeezestart",F),s.removeEventListener("squeezeend",F),s.removeEventListener("end",$),s.removeEventListener("inputsourceschange",W);for(let q=0;q<x.length;q++){const st=S[q];st!==null&&(S[q]=null,x[q].disconnect(st))}b=null,N=null,_.reset(),t.setRenderTarget(m),f=null,d=null,u=null,s=null,y=null,qt.stop(),n.isPresenting=!1,t.setPixelRatio(T),t.setSize(P.width,P.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(q){a=q,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(q){o=q,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||r},this.setReferenceSpace=function(q){c=q},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(q){if(s=q,s!==null){if(m=t.getRenderTarget(),s.addEventListener("select",F),s.addEventListener("selectstart",F),s.addEventListener("selectend",F),s.addEventListener("squeeze",F),s.addEventListener("squeezestart",F),s.addEventListener("squeezeend",F),s.addEventListener("end",$),s.addEventListener("inputsourceschange",W),p.xrCompatible!==!0&&await e.makeXRCompatible(),T=t.getPixelRatio(),t.getSize(P),s.renderState.layers===void 0){const st={antialias:p.antialias,alpha:!0,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:a};f=new XRWebGLLayer(s,e,st),s.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),y=new ei(f.framebufferWidth,f.framebufferHeight,{format:zn,type:pi,colorSpace:t.outputColorSpace,stencilBuffer:p.stencil})}else{let st=null,Mt=null,dt=null;p.depth&&(dt=p.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,st=p.stencil?Ls:_a,Mt=p.stencil?Ps:Rs);const It={colorFormat:e.RGBA8,depthFormat:dt,scaleFactor:a};u=new XRWebGLBinding(s,e),d=u.createProjectionLayer(It),s.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),y=new ei(d.textureWidth,d.textureHeight,{format:zn,type:pi,depthTexture:new Fh(d.textureWidth,d.textureHeight,Mt,void 0,void 0,void 0,void 0,void 0,void 0,st),stencilBuffer:p.stencil,colorSpace:t.outputColorSpace,samples:p.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,r=await s.requestReferenceSpace(o),qt.setContext(s),qt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function W(q){for(let st=0;st<q.removed.length;st++){const Mt=q.removed[st],dt=S.indexOf(Mt);dt>=0&&(S[dt]=null,x[dt].disconnect(Mt))}for(let st=0;st<q.added.length;st++){const Mt=q.added[st];let dt=S.indexOf(Mt);if(dt===-1){for(let Rt=0;Rt<x.length;Rt++)if(Rt>=S.length){S.push(Mt),dt=Rt;break}else if(S[Rt]===null){S[Rt]=Mt,dt=Rt;break}if(dt===-1)break}const It=x[dt];It&&It.connect(Mt)}}const z=new C,nt=new C;function G(q,st,Mt){z.setFromMatrixPosition(st.matrixWorld),nt.setFromMatrixPosition(Mt.matrixWorld);const dt=z.distanceTo(nt),It=st.projectionMatrix.elements,Rt=Mt.projectionMatrix.elements,Nt=It[14]/(It[10]-1),ee=It[14]/(It[10]+1),$t=(It[9]+1)/It[5],L=(It[9]-1)/It[5],ze=(It[8]-1)/It[0],Zt=(Rt[8]+1)/Rt[0],j=Nt*ze,Q=Nt*Zt,Tt=dt/(-ze+Zt),wt=Tt*-ze;if(st.matrixWorld.decompose(q.position,q.quaternion,q.scale),q.translateX(wt),q.translateZ(Tt),q.matrixWorld.compose(q.position,q.quaternion,q.scale),q.matrixWorldInverse.copy(q.matrixWorld).invert(),It[10]===-1)q.projectionMatrix.copy(st.projectionMatrix),q.projectionMatrixInverse.copy(st.projectionMatrixInverse);else{const A=Nt+Tt,M=ee+Tt,O=j-wt,Z=Q+(dt-wt),it=$t*ee/M*A,Y=L*ee/M*A;q.projectionMatrix.makePerspective(O,Z,it,Y,A,M),q.projectionMatrixInverse.copy(q.projectionMatrix).invert()}}function at(q,st){st===null?q.matrixWorld.copy(q.matrix):q.matrixWorld.multiplyMatrices(st.matrixWorld,q.matrix),q.matrixWorldInverse.copy(q.matrixWorld).invert()}this.updateCamera=function(q){if(s===null)return;let st=q.near,Mt=q.far;_.texture!==null&&(_.depthNear>0&&(st=_.depthNear),_.depthFar>0&&(Mt=_.depthFar)),v.near=R.near=w.near=st,v.far=R.far=w.far=Mt,(b!==v.near||N!==v.far)&&(s.updateRenderState({depthNear:v.near,depthFar:v.far}),b=v.near,N=v.far);const dt=q.parent,It=v.cameras;at(v,dt);for(let Rt=0;Rt<It.length;Rt++)at(It[Rt],dt);It.length===2?G(v,w,R):v.projectionMatrix.copy(w.projectionMatrix),ht(q,v,dt)};function ht(q,st,Mt){Mt===null?q.matrix.copy(st.matrixWorld):(q.matrix.copy(Mt.matrixWorld),q.matrix.invert(),q.matrix.multiply(st.matrixWorld)),q.matrix.decompose(q.position,q.quaternion,q.scale),q.updateMatrixWorld(!0),q.projectionMatrix.copy(st.projectionMatrix),q.projectionMatrixInverse.copy(st.projectionMatrixInverse),q.isPerspectiveCamera&&(q.fov=lr*2*Math.atan(1/q.projectionMatrix.elements[5]),q.zoom=1)}this.getCamera=function(){return v},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(q){l=q,d!==null&&(d.fixedFoveation=q),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=q)},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(v)};let mt=null;function Xt(q,st){if(h=st.getViewerPose(c||r),g=st,h!==null){const Mt=h.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let dt=!1;Mt.length!==v.cameras.length&&(v.cameras.length=0,dt=!0);for(let Rt=0;Rt<Mt.length;Rt++){const Nt=Mt[Rt];let ee=null;if(f!==null)ee=f.getViewport(Nt);else{const L=u.getViewSubImage(d,Nt);ee=L.viewport,Rt===0&&(t.setRenderTargetTextures(y,L.colorTexture,d.ignoreDepthValues?void 0:L.depthStencilTexture),t.setRenderTarget(y))}let $t=k[Rt];$t===void 0&&($t=new Rn,$t.layers.enable(Rt),$t.viewport=new me,k[Rt]=$t),$t.matrix.fromArray(Nt.transform.matrix),$t.matrix.decompose($t.position,$t.quaternion,$t.scale),$t.projectionMatrix.fromArray(Nt.projectionMatrix),$t.projectionMatrixInverse.copy($t.projectionMatrix).invert(),$t.viewport.set(ee.x,ee.y,ee.width,ee.height),Rt===0&&(v.matrix.copy($t.matrix),v.matrix.decompose(v.position,v.quaternion,v.scale)),dt===!0&&v.cameras.push($t)}const It=s.enabledFeatures;if(It&&It.includes("depth-sensing")){const Rt=u.getDepthInformation(Mt[0]);Rt&&Rt.isValid&&Rt.texture&&_.init(t,Rt,s.renderState)}}for(let Mt=0;Mt<x.length;Mt++){const dt=S[Mt],It=x[Mt];dt!==null&&It!==void 0&&It.update(dt,st,c||r)}mt&&mt(q,st),st.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:st}),g=null}const qt=new op;qt.setAnimationLoop(Xt),this.setAnimationLoop=function(q){mt=q},this.dispose=function(){}}}const _s=new mi,p1=new fe;function m1(i,t){function e(p,m){p.matrixAutoUpdate===!0&&p.updateMatrix(),m.value.copy(p.matrix)}function n(p,m){m.color.getRGB(p.fogColor.value,sp(i)),m.isFog?(p.fogNear.value=m.near,p.fogFar.value=m.far):m.isFogExp2&&(p.fogDensity.value=m.density)}function s(p,m,y,x,S){m.isMeshBasicMaterial||m.isMeshLambertMaterial?a(p,m):m.isMeshToonMaterial?(a(p,m),u(p,m)):m.isMeshPhongMaterial?(a(p,m),h(p,m)):m.isMeshStandardMaterial?(a(p,m),d(p,m),m.isMeshPhysicalMaterial&&f(p,m,S)):m.isMeshMatcapMaterial?(a(p,m),g(p,m)):m.isMeshDepthMaterial?a(p,m):m.isMeshDistanceMaterial?(a(p,m),_(p,m)):m.isMeshNormalMaterial?a(p,m):m.isLineBasicMaterial?(r(p,m),m.isLineDashedMaterial&&o(p,m)):m.isPointsMaterial?l(p,m,y,x):m.isSpriteMaterial?c(p,m):m.isShadowMaterial?(p.color.value.copy(m.color),p.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function a(p,m){p.opacity.value=m.opacity,m.color&&p.diffuse.value.copy(m.color),m.emissive&&p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(p.map.value=m.map,e(m.map,p.mapTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,e(m.alphaMap,p.alphaMapTransform)),m.bumpMap&&(p.bumpMap.value=m.bumpMap,e(m.bumpMap,p.bumpMapTransform),p.bumpScale.value=m.bumpScale,m.side===fn&&(p.bumpScale.value*=-1)),m.normalMap&&(p.normalMap.value=m.normalMap,e(m.normalMap,p.normalMapTransform),p.normalScale.value.copy(m.normalScale),m.side===fn&&p.normalScale.value.negate()),m.displacementMap&&(p.displacementMap.value=m.displacementMap,e(m.displacementMap,p.displacementMapTransform),p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias),m.emissiveMap&&(p.emissiveMap.value=m.emissiveMap,e(m.emissiveMap,p.emissiveMapTransform)),m.specularMap&&(p.specularMap.value=m.specularMap,e(m.specularMap,p.specularMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);const y=t.get(m),x=y.envMap,S=y.envMapRotation;x&&(p.envMap.value=x,_s.copy(S),_s.x*=-1,_s.y*=-1,_s.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(_s.y*=-1,_s.z*=-1),p.envMapRotation.value.setFromMatrix4(p1.makeRotationFromEuler(_s)),p.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio),m.lightMap&&(p.lightMap.value=m.lightMap,p.lightMapIntensity.value=m.lightMapIntensity,e(m.lightMap,p.lightMapTransform)),m.aoMap&&(p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity,e(m.aoMap,p.aoMapTransform))}function r(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,m.map&&(p.map.value=m.map,e(m.map,p.mapTransform))}function o(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function l(p,m,y,x){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*y,p.scale.value=x*.5,m.map&&(p.map.value=m.map,e(m.map,p.uvTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,e(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function c(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map&&(p.map.value=m.map,e(m.map,p.mapTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,e(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function h(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,1e-4)}function u(p,m){m.gradientMap&&(p.gradientMap.value=m.gradientMap)}function d(p,m){p.metalness.value=m.metalness,m.metalnessMap&&(p.metalnessMap.value=m.metalnessMap,e(m.metalnessMap,p.metalnessMapTransform)),p.roughness.value=m.roughness,m.roughnessMap&&(p.roughnessMap.value=m.roughnessMap,e(m.roughnessMap,p.roughnessMapTransform)),m.envMap&&(p.envMapIntensity.value=m.envMapIntensity)}function f(p,m,y){p.ior.value=m.ior,m.sheen>0&&(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(p.sheenColorMap.value=m.sheenColorMap,e(m.sheenColorMap,p.sheenColorMapTransform)),m.sheenRoughnessMap&&(p.sheenRoughnessMap.value=m.sheenRoughnessMap,e(m.sheenRoughnessMap,p.sheenRoughnessMapTransform))),m.clearcoat>0&&(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(p.clearcoatMap.value=m.clearcoatMap,e(m.clearcoatMap,p.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,e(m.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(p.clearcoatNormalMap.value=m.clearcoatNormalMap,e(m.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===fn&&p.clearcoatNormalScale.value.negate())),m.dispersion>0&&(p.dispersion.value=m.dispersion),m.iridescence>0&&(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(p.iridescenceMap.value=m.iridescenceMap,e(m.iridescenceMap,p.iridescenceMapTransform)),m.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=m.iridescenceThicknessMap,e(m.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),m.transmission>0&&(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=y.texture,p.transmissionSamplerSize.value.set(y.width,y.height),m.transmissionMap&&(p.transmissionMap.value=m.transmissionMap,e(m.transmissionMap,p.transmissionMapTransform)),p.thickness.value=m.thickness,m.thicknessMap&&(p.thicknessMap.value=m.thicknessMap,e(m.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(p.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(p.anisotropyMap.value=m.anisotropyMap,e(m.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularColorMap&&(p.specularColorMap.value=m.specularColorMap,e(m.specularColorMap,p.specularColorMapTransform)),m.specularIntensityMap&&(p.specularIntensityMap.value=m.specularIntensityMap,e(m.specularIntensityMap,p.specularIntensityMapTransform))}function g(p,m){m.matcap&&(p.matcap.value=m.matcap)}function _(p,m){const y=t.get(m).light;p.referencePosition.value.setFromMatrixPosition(y.matrixWorld),p.nearDistance.value=y.shadow.camera.near,p.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function g1(i,t,e,n){let s={},a={},r=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,x){const S=x.program;n.uniformBlockBinding(y,S)}function c(y,x){let S=s[y.id];S===void 0&&(g(y),S=h(y),s[y.id]=S,y.addEventListener("dispose",p));const P=x.program;n.updateUBOMapping(y,P);const T=t.render.frame;a[y.id]!==T&&(d(y),a[y.id]=T)}function h(y){const x=u();y.__bindingPointIndex=x;const S=i.createBuffer(),P=y.__size,T=y.usage;return i.bindBuffer(i.UNIFORM_BUFFER,S),i.bufferData(i.UNIFORM_BUFFER,P,T),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,x,S),S}function u(){for(let y=0;y<o;y++)if(r.indexOf(y)===-1)return r.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){const x=s[y.id],S=y.uniforms,P=y.__cache;i.bindBuffer(i.UNIFORM_BUFFER,x);for(let T=0,w=S.length;T<w;T++){const R=Array.isArray(S[T])?S[T]:[S[T]];for(let k=0,v=R.length;k<v;k++){const b=R[k];if(f(b,T,k,P)===!0){const N=b.__offset,F=Array.isArray(b.value)?b.value:[b.value];let $=0;for(let W=0;W<F.length;W++){const z=F[W],nt=_(z);typeof z=="number"||typeof z=="boolean"?(b.__data[0]=z,i.bufferSubData(i.UNIFORM_BUFFER,N+$,b.__data)):z.isMatrix3?(b.__data[0]=z.elements[0],b.__data[1]=z.elements[1],b.__data[2]=z.elements[2],b.__data[3]=0,b.__data[4]=z.elements[3],b.__data[5]=z.elements[4],b.__data[6]=z.elements[5],b.__data[7]=0,b.__data[8]=z.elements[6],b.__data[9]=z.elements[7],b.__data[10]=z.elements[8],b.__data[11]=0):(z.toArray(b.__data,$),$+=nt.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,N,b.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function f(y,x,S,P){const T=y.value,w=x+"_"+S;if(P[w]===void 0)return typeof T=="number"||typeof T=="boolean"?P[w]=T:P[w]=T.clone(),!0;{const R=P[w];if(typeof T=="number"||typeof T=="boolean"){if(R!==T)return P[w]=T,!0}else if(R.equals(T)===!1)return R.copy(T),!0}return!1}function g(y){const x=y.uniforms;let S=0;const P=16;for(let w=0,R=x.length;w<R;w++){const k=Array.isArray(x[w])?x[w]:[x[w]];for(let v=0,b=k.length;v<b;v++){const N=k[v],F=Array.isArray(N.value)?N.value:[N.value];for(let $=0,W=F.length;$<W;$++){const z=F[$],nt=_(z),G=S%P,at=G%nt.boundary,ht=G+at;S+=at,ht!==0&&P-ht<nt.storage&&(S+=P-ht),N.__data=new Float32Array(nt.storage/Float32Array.BYTES_PER_ELEMENT),N.__offset=S,S+=nt.storage}}}const T=S%P;return T>0&&(S+=P-T),y.__size=S,y.__cache={},this}function _(y){const x={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),x}function p(y){const x=y.target;x.removeEventListener("dispose",p);const S=r.indexOf(x.__bindingPointIndex);r.splice(S,1),i.deleteBuffer(s[x.id]),delete s[x.id],delete a[x.id]}function m(){for(const y in s)i.deleteBuffer(s[y]);r=[],s={},a={}}return{bind:l,update:c,dispose:m}}class v1{constructor(t={}){const{canvas:e=ag(),context:n=null,depth:s=!0,stencil:a=!1,alpha:r=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1}=t;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=r;const f=new Uint32Array(4),g=new Int32Array(4);let _=null,p=null;const m=[],y=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Qe,this.toneMapping=os,this.toneMappingExposure=1;const x=this;let S=!1,P=0,T=0,w=null,R=-1,k=null;const v=new me,b=new me;let N=null;const F=new te(0);let $=0,W=e.width,z=e.height,nt=1,G=null,at=null;const ht=new me(0,0,W,z),mt=new me(0,0,W,z);let Xt=!1;const qt=new Nh;let q=!1,st=!1;const Mt=new fe,dt=new fe,It=new C,Rt=new me,Nt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ee=!1;function $t(){return w===null?nt:1}let L=n;function ze(E,I){return e.getContext(E,I)}try{const E={alpha:!0,depth:s,stencil:a,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Mh}`),e.addEventListener("webglcontextlost",tt,!1),e.addEventListener("webglcontextrestored",_t,!1),e.addEventListener("webglcontextcreationerror",bt,!1),L===null){const I="webgl2";if(L=ze(I,E),L===null)throw ze(I)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(E){throw console.error("THREE.WebGLRenderer: "+E.message),E}let Zt,j,Q,Tt,wt,A,M,O,Z,it,Y,Ct,ut,gt,Jt,rt,vt,Ut,Ot,Et,ne,Vt,se,D;function pt(){Zt=new bx(L),Zt.init(),Vt=new o1(L,Zt),j=new gx(L,Zt,t,Vt),Q=new s1(L),j.reverseDepthBuffer&&Q.buffers.depth.setReversed(!0),Tt=new Ex(L),wt=new Gy,A=new r1(L,Zt,Q,wt,j,Vt,Tt),M=new _x(x),O=new Mx(x),Z=new Dg(L),se=new px(L,Z),it=new Sx(L,Z,Tt,se),Y=new Ax(L,it,Z,Tt),Ot=new Tx(L,j,A),rt=new vx(wt),Ct=new Vy(x,M,O,Zt,j,se,rt),ut=new m1(x,wt),gt=new Wy,Jt=new Zy(Zt),Ut=new fx(x,M,O,Q,Y,d,l),vt=new n1(x,Y,j),D=new g1(L,Tt,j,Q),Et=new mx(L,Zt,Tt),ne=new wx(L,Zt,Tt),Tt.programs=Ct.programs,x.capabilities=j,x.extensions=Zt,x.properties=wt,x.renderLists=gt,x.shadowMap=vt,x.state=Q,x.info=Tt}pt();const V=new f1(x,L);this.xr=V,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){const E=Zt.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){const E=Zt.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return nt},this.setPixelRatio=function(E){E!==void 0&&(nt=E,this.setSize(W,z,!1))},this.getSize=function(E){return E.set(W,z)},this.setSize=function(E,I,B=!0){if(V.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=E,z=I,e.width=Math.floor(E*nt),e.height=Math.floor(I*nt),B===!0&&(e.style.width=E+"px",e.style.height=I+"px"),this.setViewport(0,0,E,I)},this.getDrawingBufferSize=function(E){return E.set(W*nt,z*nt).floor()},this.setDrawingBufferSize=function(E,I,B){W=E,z=I,nt=B,e.width=Math.floor(E*B),e.height=Math.floor(I*B),this.setViewport(0,0,E,I)},this.getCurrentViewport=function(E){return E.copy(v)},this.getViewport=function(E){return E.copy(ht)},this.setViewport=function(E,I,B,H){E.isVector4?ht.set(E.x,E.y,E.z,E.w):ht.set(E,I,B,H),Q.viewport(v.copy(ht).multiplyScalar(nt).round())},this.getScissor=function(E){return E.copy(mt)},this.setScissor=function(E,I,B,H){E.isVector4?mt.set(E.x,E.y,E.z,E.w):mt.set(E,I,B,H),Q.scissor(b.copy(mt).multiplyScalar(nt).round())},this.getScissorTest=function(){return Xt},this.setScissorTest=function(E){Q.setScissorTest(Xt=E)},this.setOpaqueSort=function(E){G=E},this.setTransparentSort=function(E){at=E},this.getClearColor=function(E){return E.copy(Ut.getClearColor())},this.setClearColor=function(){Ut.setClearColor.apply(Ut,arguments)},this.getClearAlpha=function(){return Ut.getClearAlpha()},this.setClearAlpha=function(){Ut.setClearAlpha.apply(Ut,arguments)},this.clear=function(E=!0,I=!0,B=!0){let H=0;if(E){let U=!1;if(w!==null){const ot=w.texture.format;U=ot===Ch||ot===Ah||ot===Th}if(U){const ot=w.texture.type,xt=ot===pi||ot===Rs||ot===or||ot===Ps||ot===wh||ot===Eh,At=Ut.getClearColor(),Pt=Ut.getClearAlpha(),Ft=At.r,Bt=At.g,Lt=At.b;xt?(f[0]=Ft,f[1]=Bt,f[2]=Lt,f[3]=Pt,L.clearBufferuiv(L.COLOR,0,f)):(g[0]=Ft,g[1]=Bt,g[2]=Lt,g[3]=Pt,L.clearBufferiv(L.COLOR,0,g))}else H|=L.COLOR_BUFFER_BIT}I&&(H|=L.DEPTH_BUFFER_BIT,L.clearDepth(this.capabilities.reverseDepthBuffer?0:1)),B&&(H|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),L.clear(H)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",tt,!1),e.removeEventListener("webglcontextrestored",_t,!1),e.removeEventListener("webglcontextcreationerror",bt,!1),gt.dispose(),Jt.dispose(),wt.dispose(),M.dispose(),O.dispose(),Y.dispose(),se.dispose(),D.dispose(),Ct.dispose(),V.dispose(),V.removeEventListener("sessionstart",nu),V.removeEventListener("sessionend",iu),ds.stop()};function tt(E){E.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),S=!0}function _t(){console.log("THREE.WebGLRenderer: Context Restored."),S=!1;const E=Tt.autoReset,I=vt.enabled,B=vt.autoUpdate,H=vt.needsUpdate,U=vt.type;pt(),Tt.autoReset=E,vt.enabled=I,vt.autoUpdate=B,vt.needsUpdate=H,vt.type=U}function bt(E){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function ie(E){const I=E.target;I.removeEventListener("dispose",ie),Ie(I)}function Ie(E){mn(E),wt.remove(E)}function mn(E){const I=wt.get(E).programs;I!==void 0&&(I.forEach(function(B){Ct.releaseProgram(B)}),E.isShaderMaterial&&Ct.releaseShaderCache(E))}this.renderBufferDirect=function(E,I,B,H,U,ot){I===null&&(I=Nt);const xt=U.isMesh&&U.matrixWorld.determinant()<0,At=Xp(E,I,B,H,U);Q.setMaterial(H,xt);let Pt=B.index,Ft=1;if(H.wireframe===!0){if(Pt=it.getWireframeAttribute(B),Pt===void 0)return;Ft=2}const Bt=B.drawRange,Lt=B.attributes.position;let de=Bt.start*Ft,Me=(Bt.start+Bt.count)*Ft;ot!==null&&(de=Math.max(de,ot.start*Ft),Me=Math.min(Me,(ot.start+ot.count)*Ft)),Pt!==null?(de=Math.max(de,0),Me=Math.min(Me,Pt.count)):Lt!=null&&(de=Math.max(de,0),Me=Math.min(Me,Lt.count));const Ae=Me-de;if(Ae<0||Ae===1/0)return;se.setup(U,H,At,B,Pt);let bn,ce=Et;if(Pt!==null&&(bn=Z.get(Pt),ce=ne,ce.setIndex(bn)),U.isMesh)H.wireframe===!0?(Q.setLineWidth(H.wireframeLinewidth*$t()),ce.setMode(L.LINES)):ce.setMode(L.TRIANGLES);else if(U.isLine){let Dt=H.linewidth;Dt===void 0&&(Dt=1),Q.setLineWidth(Dt*$t()),U.isLineSegments?ce.setMode(L.LINES):U.isLineLoop?ce.setMode(L.LINE_LOOP):ce.setMode(L.LINE_STRIP)}else U.isPoints?ce.setMode(L.POINTS):U.isSprite&&ce.setMode(L.TRIANGLES);if(U.isBatchedMesh)if(U._multiDrawInstances!==null)ce.renderMultiDrawInstances(U._multiDrawStarts,U._multiDrawCounts,U._multiDrawCount,U._multiDrawInstances);else if(Zt.get("WEBGL_multi_draw"))ce.renderMultiDraw(U._multiDrawStarts,U._multiDrawCounts,U._multiDrawCount);else{const Dt=U._multiDrawStarts,Ke=U._multiDrawCounts,he=U._multiDrawCount,Gn=Pt?Z.get(Pt).bytesPerElement:1,Ns=wt.get(H).currentProgram.getUniforms();for(let Sn=0;Sn<he;Sn++)Ns.setValue(L,"_gl_DrawID",Sn),ce.render(Dt[Sn]/Gn,Ke[Sn])}else if(U.isInstancedMesh)ce.renderInstances(de,Ae,U.count);else if(B.isInstancedBufferGeometry){const Dt=B._maxInstanceCount!==void 0?B._maxInstanceCount:1/0,Ke=Math.min(B.instanceCount,Dt);ce.renderInstances(de,Ae,Ke)}else ce.render(de,Ae)};function oe(E,I,B){E.transparent===!0&&E.side===ci&&E.forceSinglePass===!1?(E.side=fn,E.needsUpdate=!0,gr(E,I,B),E.side=cs,E.needsUpdate=!0,gr(E,I,B),E.side=ci):gr(E,I,B)}this.compile=function(E,I,B=null){B===null&&(B=E),p=Jt.get(B),p.init(I),y.push(p),B.traverseVisible(function(U){U.isLight&&U.layers.test(I.layers)&&(p.pushLight(U),U.castShadow&&p.pushShadow(U))}),E!==B&&E.traverseVisible(function(U){U.isLight&&U.layers.test(I.layers)&&(p.pushLight(U),U.castShadow&&p.pushShadow(U))}),p.setupLights();const H=new Set;return E.traverse(function(U){if(!(U.isMesh||U.isPoints||U.isLine||U.isSprite))return;const ot=U.material;if(ot)if(Array.isArray(ot))for(let xt=0;xt<ot.length;xt++){const At=ot[xt];oe(At,B,U),H.add(At)}else oe(ot,B,U),H.add(ot)}),y.pop(),p=null,H},this.compileAsync=function(E,I,B=null){const H=this.compile(E,I,B);return new Promise(U=>{function ot(){if(H.forEach(function(xt){wt.get(xt).currentProgram.isReady()&&H.delete(xt)}),H.size===0){U(E);return}setTimeout(ot,10)}Zt.get("KHR_parallel_shader_compile")!==null?ot():setTimeout(ot,10)})};let gn=null;function xi(E){gn&&gn(E)}function nu(){ds.stop()}function iu(){ds.start()}const ds=new op;ds.setAnimationLoop(xi),typeof self<"u"&&ds.setContext(self),this.setAnimationLoop=function(E){gn=E,V.setAnimationLoop(E),E===null?ds.stop():ds.start()},V.addEventListener("sessionstart",nu),V.addEventListener("sessionend",iu),this.render=function(E,I){if(I!==void 0&&I.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(S===!0)return;if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),I.parent===null&&I.matrixWorldAutoUpdate===!0&&I.updateMatrixWorld(),V.enabled===!0&&V.isPresenting===!0&&(V.cameraAutoUpdate===!0&&V.updateCamera(I),I=V.getCamera()),E.isScene===!0&&E.onBeforeRender(x,E,I,w),p=Jt.get(E,y.length),p.init(I),y.push(p),dt.multiplyMatrices(I.projectionMatrix,I.matrixWorldInverse),qt.setFromProjectionMatrix(dt),st=this.localClippingEnabled,q=rt.init(this.clippingPlanes,st),_=gt.get(E,m.length),_.init(),m.push(_),V.enabled===!0&&V.isPresenting===!0){const ot=x.xr.getDepthSensingMesh();ot!==null&&qo(ot,I,-1/0,x.sortObjects)}qo(E,I,0,x.sortObjects),_.finish(),x.sortObjects===!0&&_.sort(G,at),ee=V.enabled===!1||V.isPresenting===!1||V.hasDepthSensing()===!1,ee&&Ut.addToRenderList(_,E),this.info.render.frame++,q===!0&&rt.beginShadows();const B=p.state.shadowsArray;vt.render(B,E,I),q===!0&&rt.endShadows(),this.info.autoReset===!0&&this.info.reset();const H=_.opaque,U=_.transmissive;if(p.setupLights(),I.isArrayCamera){const ot=I.cameras;if(U.length>0)for(let xt=0,At=ot.length;xt<At;xt++){const Pt=ot[xt];au(H,U,E,Pt)}ee&&Ut.render(E);for(let xt=0,At=ot.length;xt<At;xt++){const Pt=ot[xt];su(_,E,Pt,Pt.viewport)}}else U.length>0&&au(H,U,E,I),ee&&Ut.render(E),su(_,E,I);w!==null&&(A.updateMultisampleRenderTarget(w),A.updateRenderTargetMipmap(w)),E.isScene===!0&&E.onAfterRender(x,E,I),se.resetDefaultState(),R=-1,k=null,y.pop(),y.length>0?(p=y[y.length-1],q===!0&&rt.setGlobalState(x.clippingPlanes,p.state.camera)):p=null,m.pop(),m.length>0?_=m[m.length-1]:_=null};function qo(E,I,B,H){if(E.visible===!1)return;if(E.layers.test(I.layers)){if(E.isGroup)B=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(I);else if(E.isLight)p.pushLight(E),E.castShadow&&p.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||qt.intersectsSprite(E)){H&&Rt.setFromMatrixPosition(E.matrixWorld).applyMatrix4(dt);const xt=Y.update(E),At=E.material;At.visible&&_.push(E,xt,At,B,Rt.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||qt.intersectsObject(E))){const xt=Y.update(E),At=E.material;if(H&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),Rt.copy(E.boundingSphere.center)):(xt.boundingSphere===null&&xt.computeBoundingSphere(),Rt.copy(xt.boundingSphere.center)),Rt.applyMatrix4(E.matrixWorld).applyMatrix4(dt)),Array.isArray(At)){const Pt=xt.groups;for(let Ft=0,Bt=Pt.length;Ft<Bt;Ft++){const Lt=Pt[Ft],de=At[Lt.materialIndex];de&&de.visible&&_.push(E,xt,de,B,Rt.z,Lt)}}else At.visible&&_.push(E,xt,At,B,Rt.z,null)}}const ot=E.children;for(let xt=0,At=ot.length;xt<At;xt++)qo(ot[xt],I,B,H)}function su(E,I,B,H){const U=E.opaque,ot=E.transmissive,xt=E.transparent;p.setupLightsView(B),q===!0&&rt.setGlobalState(x.clippingPlanes,B),H&&Q.viewport(v.copy(H)),U.length>0&&mr(U,I,B),ot.length>0&&mr(ot,I,B),xt.length>0&&mr(xt,I,B),Q.buffers.depth.setTest(!0),Q.buffers.depth.setMask(!0),Q.buffers.color.setMask(!0),Q.setPolygonOffset(!1)}function au(E,I,B,H){if((B.isScene===!0?B.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[H.id]===void 0&&(p.state.transmissionRenderTarget[H.id]=new ei(1,1,{generateMipmaps:!0,type:Zt.has("EXT_color_buffer_half_float")||Zt.has("EXT_color_buffer_float")?Fi:pi,minFilter:Ss,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:le.workingColorSpace}));const ot=p.state.transmissionRenderTarget[H.id],xt=H.viewport||v;ot.setSize(xt.z,xt.w);const At=x.getRenderTarget();x.setRenderTarget(ot),x.getClearColor(F),$=x.getClearAlpha(),$<1&&x.setClearColor(16777215,.5),x.clear(),ee&&Ut.render(B);const Pt=x.toneMapping;x.toneMapping=os;const Ft=H.viewport;if(H.viewport!==void 0&&(H.viewport=void 0),p.setupLightsView(H),q===!0&&rt.setGlobalState(x.clippingPlanes,H),mr(E,B,H),A.updateMultisampleRenderTarget(ot),A.updateRenderTargetMipmap(ot),Zt.has("WEBGL_multisampled_render_to_texture")===!1){let Bt=!1;for(let Lt=0,de=I.length;Lt<de;Lt++){const Me=I[Lt],Ae=Me.object,bn=Me.geometry,ce=Me.material,Dt=Me.group;if(ce.side===ci&&Ae.layers.test(H.layers)){const Ke=ce.side;ce.side=fn,ce.needsUpdate=!0,ru(Ae,B,H,bn,ce,Dt),ce.side=Ke,ce.needsUpdate=!0,Bt=!0}}Bt===!0&&(A.updateMultisampleRenderTarget(ot),A.updateRenderTargetMipmap(ot))}x.setRenderTarget(At),x.setClearColor(F,$),Ft!==void 0&&(H.viewport=Ft),x.toneMapping=Pt}function mr(E,I,B){const H=I.isScene===!0?I.overrideMaterial:null;for(let U=0,ot=E.length;U<ot;U++){const xt=E[U],At=xt.object,Pt=xt.geometry,Ft=H===null?xt.material:H,Bt=xt.group;At.layers.test(B.layers)&&ru(At,I,B,Pt,Ft,Bt)}}function ru(E,I,B,H,U,ot){E.onBeforeRender(x,I,B,H,U,ot),E.modelViewMatrix.multiplyMatrices(B.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),U.onBeforeRender(x,I,B,H,E,ot),U.transparent===!0&&U.side===ci&&U.forceSinglePass===!1?(U.side=fn,U.needsUpdate=!0,x.renderBufferDirect(B,I,H,U,E,ot),U.side=cs,U.needsUpdate=!0,x.renderBufferDirect(B,I,H,U,E,ot),U.side=ci):x.renderBufferDirect(B,I,H,U,E,ot),E.onAfterRender(x,I,B,H,U,ot)}function gr(E,I,B){I.isScene!==!0&&(I=Nt);const H=wt.get(E),U=p.state.lights,ot=p.state.shadowsArray,xt=U.state.version,At=Ct.getParameters(E,U.state,ot,I,B),Pt=Ct.getProgramCacheKey(At);let Ft=H.programs;H.environment=E.isMeshStandardMaterial?I.environment:null,H.fog=I.fog,H.envMap=(E.isMeshStandardMaterial?O:M).get(E.envMap||H.environment),H.envMapRotation=H.environment!==null&&E.envMap===null?I.environmentRotation:E.envMapRotation,Ft===void 0&&(E.addEventListener("dispose",ie),Ft=new Map,H.programs=Ft);let Bt=Ft.get(Pt);if(Bt!==void 0){if(H.currentProgram===Bt&&H.lightsStateVersion===xt)return lu(E,At),Bt}else At.uniforms=Ct.getUniforms(E),E.onBeforeCompile(At,x),Bt=Ct.acquireProgram(At,Pt),Ft.set(Pt,Bt),H.uniforms=At.uniforms;const Lt=H.uniforms;return(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(Lt.clippingPlanes=rt.uniform),lu(E,At),H.needsLights=jp(E),H.lightsStateVersion=xt,H.needsLights&&(Lt.ambientLightColor.value=U.state.ambient,Lt.lightProbe.value=U.state.probe,Lt.directionalLights.value=U.state.directional,Lt.directionalLightShadows.value=U.state.directionalShadow,Lt.spotLights.value=U.state.spot,Lt.spotLightShadows.value=U.state.spotShadow,Lt.rectAreaLights.value=U.state.rectArea,Lt.ltc_1.value=U.state.rectAreaLTC1,Lt.ltc_2.value=U.state.rectAreaLTC2,Lt.pointLights.value=U.state.point,Lt.pointLightShadows.value=U.state.pointShadow,Lt.hemisphereLights.value=U.state.hemi,Lt.directionalShadowMap.value=U.state.directionalShadowMap,Lt.directionalShadowMatrix.value=U.state.directionalShadowMatrix,Lt.spotShadowMap.value=U.state.spotShadowMap,Lt.spotLightMatrix.value=U.state.spotLightMatrix,Lt.spotLightMap.value=U.state.spotLightMap,Lt.pointShadowMap.value=U.state.pointShadowMap,Lt.pointShadowMatrix.value=U.state.pointShadowMatrix),H.currentProgram=Bt,H.uniformsList=null,Bt}function ou(E){if(E.uniformsList===null){const I=E.currentProgram.getUniforms();E.uniformsList=uo.seqWithValue(I.seq,E.uniforms)}return E.uniformsList}function lu(E,I){const B=wt.get(E);B.outputColorSpace=I.outputColorSpace,B.batching=I.batching,B.batchingColor=I.batchingColor,B.instancing=I.instancing,B.instancingColor=I.instancingColor,B.instancingMorph=I.instancingMorph,B.skinning=I.skinning,B.morphTargets=I.morphTargets,B.morphNormals=I.morphNormals,B.morphColors=I.morphColors,B.morphTargetsCount=I.morphTargetsCount,B.numClippingPlanes=I.numClippingPlanes,B.numIntersection=I.numClipIntersection,B.vertexAlphas=I.vertexAlphas,B.vertexTangents=I.vertexTangents,B.toneMapping=I.toneMapping}function Xp(E,I,B,H,U){I.isScene!==!0&&(I=Nt),A.resetTextureUnits();const ot=I.fog,xt=H.isMeshStandardMaterial?I.environment:null,At=w===null?x.outputColorSpace:w.isXRRenderTarget===!0?w.texture.colorSpace:us,Pt=(H.isMeshStandardMaterial?O:M).get(H.envMap||xt),Ft=H.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,Bt=!!B.attributes.tangent&&(!!H.normalMap||H.anisotropy>0),Lt=!!B.morphAttributes.position,de=!!B.morphAttributes.normal,Me=!!B.morphAttributes.color;let Ae=os;H.toneMapped&&(w===null||w.isXRRenderTarget===!0)&&(Ae=x.toneMapping);const bn=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,ce=bn!==void 0?bn.length:0,Dt=wt.get(H),Ke=p.state.lights;if(q===!0&&(st===!0||E!==k)){const In=E===k&&H.id===R;rt.setState(H,E,In)}let he=!1;H.version===Dt.__version?(Dt.needsLights&&Dt.lightsStateVersion!==Ke.state.version||Dt.outputColorSpace!==At||U.isBatchedMesh&&Dt.batching===!1||!U.isBatchedMesh&&Dt.batching===!0||U.isBatchedMesh&&Dt.batchingColor===!0&&U.colorTexture===null||U.isBatchedMesh&&Dt.batchingColor===!1&&U.colorTexture!==null||U.isInstancedMesh&&Dt.instancing===!1||!U.isInstancedMesh&&Dt.instancing===!0||U.isSkinnedMesh&&Dt.skinning===!1||!U.isSkinnedMesh&&Dt.skinning===!0||U.isInstancedMesh&&Dt.instancingColor===!0&&U.instanceColor===null||U.isInstancedMesh&&Dt.instancingColor===!1&&U.instanceColor!==null||U.isInstancedMesh&&Dt.instancingMorph===!0&&U.morphTexture===null||U.isInstancedMesh&&Dt.instancingMorph===!1&&U.morphTexture!==null||Dt.envMap!==Pt||H.fog===!0&&Dt.fog!==ot||Dt.numClippingPlanes!==void 0&&(Dt.numClippingPlanes!==rt.numPlanes||Dt.numIntersection!==rt.numIntersection)||Dt.vertexAlphas!==Ft||Dt.vertexTangents!==Bt||Dt.morphTargets!==Lt||Dt.morphNormals!==de||Dt.morphColors!==Me||Dt.toneMapping!==Ae||Dt.morphTargetsCount!==ce)&&(he=!0):(he=!0,Dt.__version=H.version);let Gn=Dt.currentProgram;he===!0&&(Gn=gr(H,I,U));let Ns=!1,Sn=!1,jo=!1;const Pe=Gn.getUniforms(),Vi=Dt.uniforms;if(Q.useProgram(Gn.program)&&(Ns=!0,Sn=!0,jo=!0),H.id!==R&&(R=H.id,Sn=!0),Ns||k!==E){j.reverseDepthBuffer?(Mt.copy(E.projectionMatrix),og(Mt),lg(Mt),Pe.setValue(L,"projectionMatrix",Mt)):Pe.setValue(L,"projectionMatrix",E.projectionMatrix),Pe.setValue(L,"viewMatrix",E.matrixWorldInverse);const In=Pe.map.cameraPosition;In!==void 0&&In.setValue(L,It.setFromMatrixPosition(E.matrixWorld)),j.logarithmicDepthBuffer&&Pe.setValue(L,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(H.isMeshPhongMaterial||H.isMeshToonMaterial||H.isMeshLambertMaterial||H.isMeshBasicMaterial||H.isMeshStandardMaterial||H.isShaderMaterial)&&Pe.setValue(L,"isOrthographic",E.isOrthographicCamera===!0),k!==E&&(k=E,Sn=!0,jo=!0)}if(U.isSkinnedMesh){Pe.setOptional(L,U,"bindMatrix"),Pe.setOptional(L,U,"bindMatrixInverse");const In=U.skeleton;In&&(In.boneTexture===null&&In.computeBoneTexture(),Pe.setValue(L,"boneTexture",In.boneTexture,A))}U.isBatchedMesh&&(Pe.setOptional(L,U,"batchingTexture"),Pe.setValue(L,"batchingTexture",U._matricesTexture,A),Pe.setOptional(L,U,"batchingIdTexture"),Pe.setValue(L,"batchingIdTexture",U._indirectTexture,A),Pe.setOptional(L,U,"batchingColorTexture"),U._colorsTexture!==null&&Pe.setValue(L,"batchingColorTexture",U._colorsTexture,A));const Yo=B.morphAttributes;if((Yo.position!==void 0||Yo.normal!==void 0||Yo.color!==void 0)&&Ot.update(U,B,Gn),(Sn||Dt.receiveShadow!==U.receiveShadow)&&(Dt.receiveShadow=U.receiveShadow,Pe.setValue(L,"receiveShadow",U.receiveShadow)),H.isMeshGouraudMaterial&&H.envMap!==null&&(Vi.envMap.value=Pt,Vi.flipEnvMap.value=Pt.isCubeTexture&&Pt.isRenderTargetTexture===!1?-1:1),H.isMeshStandardMaterial&&H.envMap===null&&I.environment!==null&&(Vi.envMapIntensity.value=I.environmentIntensity),Sn&&(Pe.setValue(L,"toneMappingExposure",x.toneMappingExposure),Dt.needsLights&&qp(Vi,jo),ot&&H.fog===!0&&ut.refreshFogUniforms(Vi,ot),ut.refreshMaterialUniforms(Vi,H,nt,z,p.state.transmissionRenderTarget[E.id]),uo.upload(L,ou(Dt),Vi,A)),H.isShaderMaterial&&H.uniformsNeedUpdate===!0&&(uo.upload(L,ou(Dt),Vi,A),H.uniformsNeedUpdate=!1),H.isSpriteMaterial&&Pe.setValue(L,"center",U.center),Pe.setValue(L,"modelViewMatrix",U.modelViewMatrix),Pe.setValue(L,"normalMatrix",U.normalMatrix),Pe.setValue(L,"modelMatrix",U.matrixWorld),H.isShaderMaterial||H.isRawShaderMaterial){const In=H.uniformsGroups;for(let Ko=0,Yp=In.length;Ko<Yp;Ko++){const cu=In[Ko];D.update(cu,Gn),D.bind(cu,Gn)}}return Gn}function qp(E,I){E.ambientLightColor.needsUpdate=I,E.lightProbe.needsUpdate=I,E.directionalLights.needsUpdate=I,E.directionalLightShadows.needsUpdate=I,E.pointLights.needsUpdate=I,E.pointLightShadows.needsUpdate=I,E.spotLights.needsUpdate=I,E.spotLightShadows.needsUpdate=I,E.rectAreaLights.needsUpdate=I,E.hemisphereLights.needsUpdate=I}function jp(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.getActiveCubeFace=function(){return P},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(E,I,B){wt.get(E.texture).__webglTexture=I,wt.get(E.depthTexture).__webglTexture=B;const H=wt.get(E);H.__hasExternalTextures=!0,H.__autoAllocateDepthBuffer=B===void 0,H.__autoAllocateDepthBuffer||Zt.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),H.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(E,I){const B=wt.get(E);B.__webglFramebuffer=I,B.__useDefaultFramebuffer=I===void 0},this.setRenderTarget=function(E,I=0,B=0){w=E,P=I,T=B;let H=!0,U=null,ot=!1,xt=!1;if(E){const Pt=wt.get(E);if(Pt.__useDefaultFramebuffer!==void 0)Q.bindFramebuffer(L.FRAMEBUFFER,null),H=!1;else if(Pt.__webglFramebuffer===void 0)A.setupRenderTarget(E);else if(Pt.__hasExternalTextures)A.rebindTextures(E,wt.get(E.texture).__webglTexture,wt.get(E.depthTexture).__webglTexture);else if(E.depthBuffer){const Lt=E.depthTexture;if(Pt.__boundDepthTexture!==Lt){if(Lt!==null&&wt.has(Lt)&&(E.width!==Lt.image.width||E.height!==Lt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");A.setupDepthRenderbuffer(E)}}const Ft=E.texture;(Ft.isData3DTexture||Ft.isDataArrayTexture||Ft.isCompressedArrayTexture)&&(xt=!0);const Bt=wt.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Array.isArray(Bt[I])?U=Bt[I][B]:U=Bt[I],ot=!0):E.samples>0&&A.useMultisampledRTT(E)===!1?U=wt.get(E).__webglMultisampledFramebuffer:Array.isArray(Bt)?U=Bt[B]:U=Bt,v.copy(E.viewport),b.copy(E.scissor),N=E.scissorTest}else v.copy(ht).multiplyScalar(nt).floor(),b.copy(mt).multiplyScalar(nt).floor(),N=Xt;if(Q.bindFramebuffer(L.FRAMEBUFFER,U)&&H&&Q.drawBuffers(E,U),Q.viewport(v),Q.scissor(b),Q.setScissorTest(N),ot){const Pt=wt.get(E.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+I,Pt.__webglTexture,B)}else if(xt){const Pt=wt.get(E.texture),Ft=I||0;L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,Pt.__webglTexture,B||0,Ft)}R=-1},this.readRenderTargetPixels=function(E,I,B,H,U,ot,xt){if(!(E&&E.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let At=wt.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&xt!==void 0&&(At=At[xt]),At){Q.bindFramebuffer(L.FRAMEBUFFER,At);try{const Pt=E.texture,Ft=Pt.format,Bt=Pt.type;if(!j.textureFormatReadable(Ft)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!j.textureTypeReadable(Bt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}I>=0&&I<=E.width-H&&B>=0&&B<=E.height-U&&L.readPixels(I,B,H,U,Vt.convert(Ft),Vt.convert(Bt),ot)}finally{const Pt=w!==null?wt.get(w).__webglFramebuffer:null;Q.bindFramebuffer(L.FRAMEBUFFER,Pt)}}},this.readRenderTargetPixelsAsync=async function(E,I,B,H,U,ot,xt){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let At=wt.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&xt!==void 0&&(At=At[xt]),At){const Pt=E.texture,Ft=Pt.format,Bt=Pt.type;if(!j.textureFormatReadable(Ft))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!j.textureTypeReadable(Bt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(I>=0&&I<=E.width-H&&B>=0&&B<=E.height-U){Q.bindFramebuffer(L.FRAMEBUFFER,At);const Lt=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,Lt),L.bufferData(L.PIXEL_PACK_BUFFER,ot.byteLength,L.STREAM_READ),L.readPixels(I,B,H,U,Vt.convert(Ft),Vt.convert(Bt),0);const de=w!==null?wt.get(w).__webglFramebuffer:null;Q.bindFramebuffer(L.FRAMEBUFFER,de);const Me=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await rg(L,Me,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,Lt),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,ot),L.deleteBuffer(Lt),L.deleteSync(Me),ot}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(E,I=null,B=0){E.isTexture!==!0&&(ho("WebGLRenderer: copyFramebufferToTexture function signature has changed."),I=arguments[0]||null,E=arguments[1]);const H=Math.pow(2,-B),U=Math.floor(E.image.width*H),ot=Math.floor(E.image.height*H),xt=I!==null?I.x:0,At=I!==null?I.y:0;A.setTexture2D(E,0),L.copyTexSubImage2D(L.TEXTURE_2D,B,0,0,xt,At,U,ot),Q.unbindTexture()},this.copyTextureToTexture=function(E,I,B=null,H=null,U=0){E.isTexture!==!0&&(ho("WebGLRenderer: copyTextureToTexture function signature has changed."),H=arguments[0]||null,E=arguments[1],I=arguments[2],U=arguments[3]||0,B=null);let ot,xt,At,Pt,Ft,Bt;B!==null?(ot=B.max.x-B.min.x,xt=B.max.y-B.min.y,At=B.min.x,Pt=B.min.y):(ot=E.image.width,xt=E.image.height,At=0,Pt=0),H!==null?(Ft=H.x,Bt=H.y):(Ft=0,Bt=0);const Lt=Vt.convert(I.format),de=Vt.convert(I.type);A.setTexture2D(I,0),L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,I.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,I.unpackAlignment);const Me=L.getParameter(L.UNPACK_ROW_LENGTH),Ae=L.getParameter(L.UNPACK_IMAGE_HEIGHT),bn=L.getParameter(L.UNPACK_SKIP_PIXELS),ce=L.getParameter(L.UNPACK_SKIP_ROWS),Dt=L.getParameter(L.UNPACK_SKIP_IMAGES),Ke=E.isCompressedTexture?E.mipmaps[U]:E.image;L.pixelStorei(L.UNPACK_ROW_LENGTH,Ke.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Ke.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,At),L.pixelStorei(L.UNPACK_SKIP_ROWS,Pt),E.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,U,Ft,Bt,ot,xt,Lt,de,Ke.data):E.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,U,Ft,Bt,Ke.width,Ke.height,Lt,Ke.data):L.texSubImage2D(L.TEXTURE_2D,U,Ft,Bt,ot,xt,Lt,de,Ke),L.pixelStorei(L.UNPACK_ROW_LENGTH,Me),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Ae),L.pixelStorei(L.UNPACK_SKIP_PIXELS,bn),L.pixelStorei(L.UNPACK_SKIP_ROWS,ce),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Dt),U===0&&I.generateMipmaps&&L.generateMipmap(L.TEXTURE_2D),Q.unbindTexture()},this.copyTextureToTexture3D=function(E,I,B=null,H=null,U=0){E.isTexture!==!0&&(ho("WebGLRenderer: copyTextureToTexture3D function signature has changed."),B=arguments[0]||null,H=arguments[1]||null,E=arguments[2],I=arguments[3],U=arguments[4]||0);let ot,xt,At,Pt,Ft,Bt,Lt,de,Me;const Ae=E.isCompressedTexture?E.mipmaps[U]:E.image;B!==null?(ot=B.max.x-B.min.x,xt=B.max.y-B.min.y,At=B.max.z-B.min.z,Pt=B.min.x,Ft=B.min.y,Bt=B.min.z):(ot=Ae.width,xt=Ae.height,At=Ae.depth,Pt=0,Ft=0,Bt=0),H!==null?(Lt=H.x,de=H.y,Me=H.z):(Lt=0,de=0,Me=0);const bn=Vt.convert(I.format),ce=Vt.convert(I.type);let Dt;if(I.isData3DTexture)A.setTexture3D(I,0),Dt=L.TEXTURE_3D;else if(I.isDataArrayTexture||I.isCompressedArrayTexture)A.setTexture2DArray(I,0),Dt=L.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,I.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,I.unpackAlignment);const Ke=L.getParameter(L.UNPACK_ROW_LENGTH),he=L.getParameter(L.UNPACK_IMAGE_HEIGHT),Gn=L.getParameter(L.UNPACK_SKIP_PIXELS),Ns=L.getParameter(L.UNPACK_SKIP_ROWS),Sn=L.getParameter(L.UNPACK_SKIP_IMAGES);L.pixelStorei(L.UNPACK_ROW_LENGTH,Ae.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Ae.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Pt),L.pixelStorei(L.UNPACK_SKIP_ROWS,Ft),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Bt),E.isDataTexture||E.isData3DTexture?L.texSubImage3D(Dt,U,Lt,de,Me,ot,xt,At,bn,ce,Ae.data):I.isCompressedArrayTexture?L.compressedTexSubImage3D(Dt,U,Lt,de,Me,ot,xt,At,bn,Ae.data):L.texSubImage3D(Dt,U,Lt,de,Me,ot,xt,At,bn,ce,Ae),L.pixelStorei(L.UNPACK_ROW_LENGTH,Ke),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,he),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Gn),L.pixelStorei(L.UNPACK_SKIP_ROWS,Ns),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Sn),U===0&&I.generateMipmaps&&L.generateMipmap(Dt),Q.unbindTexture()},this.initRenderTarget=function(E){wt.get(E).__webglFramebuffer===void 0&&A.setupRenderTarget(E)},this.initTexture=function(E){E.isCubeTexture?A.setTextureCube(E,0):E.isData3DTexture?A.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?A.setTexture2DArray(E,0):A.setTexture2D(E,0),Q.unbindTexture()},this.resetState=function(){P=0,T=0,w=null,Q.reset(),se.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Di}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=t===Ph?"display-p3":"srgb",e.unpackColorSpace=le.workingColorSpace===Ho?"display-p3":"srgb"}}class dp extends nn{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new mi,this.environmentIntensity=1,this.environmentRotation=new mi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class fp extends ln{constructor(t=null,e=1,n=1,s,a,r,o,l,c=on,h=on,u,d){super(null,r,o,l,c,h,s,a,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Hi extends ln{constructor(t,e,n,s,a,r,o,l,c){super(t,e,n,s,a,r,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class _i{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,s=this.getPoint(0),a=0;e.push(0);for(let r=1;r<=t;r++)n=this.getPoint(r/t),a+=n.distanceTo(s),e.push(a),s=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const n=this.getLengths();let s=0;const a=n.length;let r;e?r=e:r=t*n[a-1];let o=0,l=a-1,c;for(;o<=l;)if(s=Math.floor(o+(l-o)/2),c=n[s]-r,c<0)o=s+1;else if(c>0)l=s-1;else{l=s;break}if(s=l,n[s]===r)return s/(a-1);const h=n[s],d=n[s+1]-h,f=(r-h)/d;return(s+f)/(a-1)}getTangent(t,e){let s=t-1e-4,a=t+1e-4;s<0&&(s=0),a>1&&(a=1);const r=this.getPoint(s),o=this.getPoint(a),l=e||(r.isVector2?new lt:new C);return l.copy(o).sub(r).normalize(),l}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new C,s=[],a=[],r=[],o=new C,l=new fe;for(let f=0;f<=t;f++){const g=f/t;s[f]=this.getTangentAt(g,new C)}a[0]=new C,r[0]=new C;let c=Number.MAX_VALUE;const h=Math.abs(s[0].x),u=Math.abs(s[0].y),d=Math.abs(s[0].z);h<=c&&(c=h,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(s[0],n).normalize(),a[0].crossVectors(s[0],o),r[0].crossVectors(s[0],a[0]);for(let f=1;f<=t;f++){if(a[f]=a[f-1].clone(),r[f]=r[f-1].clone(),o.crossVectors(s[f-1],s[f]),o.length()>Number.EPSILON){o.normalize();const g=Math.acos(Ve(s[f-1].dot(s[f]),-1,1));a[f].applyMatrix4(l.makeRotationAxis(o,g))}r[f].crossVectors(s[f],a[f])}if(e===!0){let f=Math.acos(Ve(a[0].dot(a[t]),-1,1));f/=t,s[0].dot(o.crossVectors(a[0],a[t]))>0&&(f=-f);for(let g=1;g<=t;g++)a[g].applyMatrix4(l.makeRotationAxis(s[g],f*g)),r[g].crossVectors(s[g],a[g])}return{tangents:s,normals:a,binormals:r}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class zh extends _i{constructor(t=0,e=0,n=1,s=1,a=0,r=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=s,this.aStartAngle=a,this.aEndAngle=r,this.aClockwise=o,this.aRotation=l}getPoint(t,e=new lt){const n=e,s=Math.PI*2;let a=this.aEndAngle-this.aStartAngle;const r=Math.abs(a)<Number.EPSILON;for(;a<0;)a+=s;for(;a>s;)a-=s;a<Number.EPSILON&&(r?a=0:a=s),this.aClockwise===!0&&!r&&(a===s?a=-s:a=a-s);const o=this.aStartAngle+t*a;let l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),d=l-this.aX,f=c-this.aY;l=d*h-f*u+this.aX,c=d*u+f*h+this.aY}return n.set(l,c)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}class _1 extends zh{constructor(t,e,n,s,a,r){super(t,e,n,n,s,a,r),this.isArcCurve=!0,this.type="ArcCurve"}}function Bh(){let i=0,t=0,e=0,n=0;function s(a,r,o,l){i=a,t=o,e=-3*a+3*r-2*o-l,n=2*a-2*r+o+l}return{initCatmullRom:function(a,r,o,l,c){s(r,o,c*(o-a),c*(l-r))},initNonuniformCatmullRom:function(a,r,o,l,c,h,u){let d=(r-a)/c-(o-a)/(c+h)+(o-r)/h,f=(o-r)/h-(l-r)/(h+u)+(l-o)/u;d*=h,f*=h,s(r,o,d,f)},calc:function(a){const r=a*a,o=r*a;return i+t*a+e*r+n*o}}}const zr=new C,kl=new Bh,Nl=new Bh,Ul=new Bh;class x1 extends _i{constructor(t=[],e=!1,n="centripetal",s=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=s}getPoint(t,e=new C){const n=e,s=this.points,a=s.length,r=(a-(this.closed?0:1))*t;let o=Math.floor(r),l=r-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/a)+1)*a:l===0&&o===a-1&&(o=a-2,l=1);let c,h;this.closed||o>0?c=s[(o-1)%a]:(zr.subVectors(s[0],s[1]).add(s[0]),c=zr);const u=s[o%a],d=s[(o+1)%a];if(this.closed||o+2<a?h=s[(o+2)%a]:(zr.subVectors(s[a-1],s[a-2]).add(s[a-1]),h=zr),this.curveType==="centripetal"||this.curveType==="chordal"){const f=this.curveType==="chordal"?.5:.25;let g=Math.pow(c.distanceToSquared(u),f),_=Math.pow(u.distanceToSquared(d),f),p=Math.pow(d.distanceToSquared(h),f);_<1e-4&&(_=1),g<1e-4&&(g=_),p<1e-4&&(p=_),kl.initNonuniformCatmullRom(c.x,u.x,d.x,h.x,g,_,p),Nl.initNonuniformCatmullRom(c.y,u.y,d.y,h.y,g,_,p),Ul.initNonuniformCatmullRom(c.z,u.z,d.z,h.z,g,_,p)}else this.curveType==="catmullrom"&&(kl.initCatmullRom(c.x,u.x,d.x,h.x,this.tension),Nl.initCatmullRom(c.y,u.y,d.y,h.y,this.tension),Ul.initCatmullRom(c.z,u.z,d.z,h.z,this.tension));return n.set(kl.calc(l),Nl.calc(l),Ul.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const s=t.points[e];this.points.push(s.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const s=this.points[e];t.points.push(s.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const s=t.points[e];this.points.push(new C().fromArray(s))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function xd(i,t,e,n,s){const a=(n-t)*.5,r=(s-e)*.5,o=i*i,l=i*o;return(2*e-2*n+a+r)*l+(-3*e+3*n-2*a-r)*o+a*i+e}function y1(i,t){const e=1-i;return e*e*t}function M1(i,t){return 2*(1-i)*i*t}function b1(i,t){return i*i*t}function er(i,t,e,n){return y1(i,t)+M1(i,e)+b1(i,n)}function S1(i,t){const e=1-i;return e*e*e*t}function w1(i,t){const e=1-i;return 3*e*e*i*t}function E1(i,t){return 3*(1-i)*i*i*t}function T1(i,t){return i*i*i*t}function nr(i,t,e,n,s){return S1(i,t)+w1(i,e)+E1(i,n)+T1(i,s)}class pp extends _i{constructor(t=new lt,e=new lt,n=new lt,s=new lt){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=s}getPoint(t,e=new lt){const n=e,s=this.v0,a=this.v1,r=this.v2,o=this.v3;return n.set(nr(t,s.x,a.x,r.x,o.x),nr(t,s.y,a.y,r.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class A1 extends _i{constructor(t=new C,e=new C,n=new C,s=new C){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=s}getPoint(t,e=new C){const n=e,s=this.v0,a=this.v1,r=this.v2,o=this.v3;return n.set(nr(t,s.x,a.x,r.x,o.x),nr(t,s.y,a.y,r.y,o.y),nr(t,s.z,a.z,r.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class mp extends _i{constructor(t=new lt,e=new lt){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new lt){const n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new lt){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class C1 extends _i{constructor(t=new C,e=new C){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new C){const n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new C){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class gp extends _i{constructor(t=new lt,e=new lt,n=new lt){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new lt){const n=e,s=this.v0,a=this.v1,r=this.v2;return n.set(er(t,s.x,a.x,r.x),er(t,s.y,a.y,r.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class R1 extends _i{constructor(t=new C,e=new C,n=new C){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new C){const n=e,s=this.v0,a=this.v1,r=this.v2;return n.set(er(t,s.x,a.x,r.x),er(t,s.y,a.y,r.y),er(t,s.z,a.z,r.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class vp extends _i{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new lt){const n=e,s=this.points,a=(s.length-1)*t,r=Math.floor(a),o=a-r,l=s[r===0?r:r-1],c=s[r],h=s[r>s.length-2?s.length-1:r+1],u=s[r>s.length-3?s.length-1:r+2];return n.set(xd(o,l.x,c.x,h.x,u.x),xd(o,l.y,c.y,h.y,u.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const s=t.points[e];this.points.push(s.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const s=this.points[e];t.points.push(s.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const s=t.points[e];this.points.push(new lt().fromArray(s))}return this}}var yd=Object.freeze({__proto__:null,ArcCurve:_1,CatmullRomCurve3:x1,CubicBezierCurve:pp,CubicBezierCurve3:A1,EllipseCurve:zh,LineCurve:mp,LineCurve3:C1,QuadraticBezierCurve:gp,QuadraticBezierCurve3:R1,SplineCurve:vp});class P1 extends _i{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){const n=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new yd[n](e,t))}return this}getPoint(t,e){const n=t*this.getLength(),s=this.getCurveLengths();let a=0;for(;a<s.length;){if(s[a]>=n){const r=s[a]-n,o=this.curves[a],l=o.getLength(),c=l===0?0:1-r/l;return o.getPointAt(c,e)}a++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,s=this.curves.length;n<s;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let n;for(let s=0,a=this.curves;s<a.length;s++){const r=a[s],o=r.isEllipseCurve?t*2:r.isLineCurve||r.isLineCurve3?1:r.isSplineCurve?t*r.points.length:t,l=r.getPoints(o);for(let c=0;c<l.length;c++){const h=l[c];n&&n.equals(h)||(e.push(h),n=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const s=t.curves[e];this.curves.push(s.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){const s=this.curves[e];t.curves.push(s.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const s=t.curves[e];this.curves.push(new yd[s.type]().fromJSON(s))}return this}}class L1 extends P1{constructor(t){super(),this.type="Path",this.currentPoint=new lt,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const n=new mp(this.currentPoint.clone(),new lt(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,s){const a=new gp(this.currentPoint.clone(),new lt(t,e),new lt(n,s));return this.curves.push(a),this.currentPoint.set(n,s),this}bezierCurveTo(t,e,n,s,a,r){const o=new pp(this.currentPoint.clone(),new lt(t,e),new lt(n,s),new lt(a,r));return this.curves.push(o),this.currentPoint.set(a,r),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),n=new vp(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,s,a,r){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+o,e+l,n,s,a,r),this}absarc(t,e,n,s,a,r){return this.absellipse(t,e,n,n,s,a,r),this}ellipse(t,e,n,s,a,r,o,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+c,e+h,n,s,a,r,o,l),this}absellipse(t,e,n,s,a,r,o,l){const c=new zh(t,e,n,s,a,r,o,l);if(this.curves.length>0){const u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class Go extends pn{constructor(t=[new lt(0,-.5),new lt(.5,0),new lt(0,.5)],e=12,n=0,s=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:s},e=Math.floor(e),s=Ve(s,0,Math.PI*2);const a=[],r=[],o=[],l=[],c=[],h=1/e,u=new C,d=new lt,f=new C,g=new C,_=new C;let p=0,m=0;for(let y=0;y<=t.length-1;y++)switch(y){case 0:p=t[y+1].x-t[y].x,m=t[y+1].y-t[y].y,f.x=m*1,f.y=-p,f.z=m*0,_.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(_.x,_.y,_.z);break;default:p=t[y+1].x-t[y].x,m=t[y+1].y-t[y].y,f.x=m*1,f.y=-p,f.z=m*0,g.copy(f),f.x+=_.x,f.y+=_.y,f.z+=_.z,f.normalize(),l.push(f.x,f.y,f.z),_.copy(g)}for(let y=0;y<=e;y++){const x=n+y*h*s,S=Math.sin(x),P=Math.cos(x);for(let T=0;T<=t.length-1;T++){u.x=t[T].x*S,u.y=t[T].y,u.z=t[T].x*P,r.push(u.x,u.y,u.z),d.x=y/e,d.y=T/(t.length-1),o.push(d.x,d.y);const w=l[3*T+0]*S,R=l[3*T+1],k=l[3*T+0]*P;c.push(w,R,k)}}for(let y=0;y<e;y++)for(let x=0;x<t.length-1;x++){const S=x+y*t.length,P=S,T=S+t.length,w=S+t.length+1,R=S+1;a.push(P,T,R),a.push(w,R,T)}this.setIndex(a),this.setAttribute("position",new ue(r,3)),this.setAttribute("uv",new ue(o,2)),this.setAttribute("normal",new ue(c,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Go(t.points,t.segments,t.phiStart,t.phiLength)}}class Hh extends Go{constructor(t=1,e=1,n=4,s=8){const a=new L1;a.absarc(0,-e/2,t,Math.PI*1.5,0),a.absarc(0,e/2,t,0,Math.PI*.5),super(a.getPoints(n),s),this.type="CapsuleGeometry",this.parameters={radius:t,length:e,capSegments:n,radialSegments:s}}static fromJSON(t){return new Hh(t.radius,t.length,t.capSegments,t.radialSegments)}}class gi extends pn{constructor(t=1,e=32,n=0,s=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:s},e=Math.max(3,e);const a=[],r=[],o=[],l=[],c=new C,h=new lt;r.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let u=0,d=3;u<=e;u++,d+=3){const f=n+u/e*s;c.x=t*Math.cos(f),c.y=t*Math.sin(f),r.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(r[d]/t+1)/2,h.y=(r[d+1]/t+1)/2,l.push(h.x,h.y)}for(let u=1;u<=e;u++)a.push(u,u+1,0);this.setIndex(a),this.setAttribute("position",new ue(r,3)),this.setAttribute("normal",new ue(o,3)),this.setAttribute("uv",new ue(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new gi(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Hn extends pn{constructor(t=1,e=1,n=1,s=32,a=1,r=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:s,heightSegments:a,openEnded:r,thetaStart:o,thetaLength:l};const c=this;s=Math.floor(s),a=Math.floor(a);const h=[],u=[],d=[],f=[];let g=0;const _=[],p=n/2;let m=0;y(),r===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(h),this.setAttribute("position",new ue(u,3)),this.setAttribute("normal",new ue(d,3)),this.setAttribute("uv",new ue(f,2));function y(){const S=new C,P=new C;let T=0;const w=(e-t)/n;for(let R=0;R<=a;R++){const k=[],v=R/a,b=v*(e-t)+t;for(let N=0;N<=s;N++){const F=N/s,$=F*l+o,W=Math.sin($),z=Math.cos($);P.x=b*W,P.y=-v*n+p,P.z=b*z,u.push(P.x,P.y,P.z),S.set(W,w,z).normalize(),d.push(S.x,S.y,S.z),f.push(F,1-v),k.push(g++)}_.push(k)}for(let R=0;R<s;R++)for(let k=0;k<a;k++){const v=_[k][R],b=_[k+1][R],N=_[k+1][R+1],F=_[k][R+1];t>0&&(h.push(v,b,F),T+=3),e>0&&(h.push(b,N,F),T+=3)}c.addGroup(m,T,0),m+=T}function x(S){const P=g,T=new lt,w=new C;let R=0;const k=S===!0?t:e,v=S===!0?1:-1;for(let N=1;N<=s;N++)u.push(0,p*v,0),d.push(0,v,0),f.push(.5,.5),g++;const b=g;for(let N=0;N<=s;N++){const $=N/s*l+o,W=Math.cos($),z=Math.sin($);w.x=k*z,w.y=p*v,w.z=k*W,u.push(w.x,w.y,w.z),d.push(0,v,0),T.x=W*.5+.5,T.y=z*.5*v+.5,f.push(T.x,T.y),g++}for(let N=0;N<s;N++){const F=P+N,$=b+N;S===!0?h.push($,$+1,F):h.push($+1,$,F),R+=3}c.addGroup(m,R,S===!0?1:2),m+=R}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Hn(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class pr extends Hn{constructor(t=1,e=1,n=32,s=1,a=!1,r=0,o=Math.PI*2){super(0,t,e,n,s,a,r,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:s,openEnded:a,thetaStart:r,thetaLength:o}}static fromJSON(t){return new pr(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Vh extends pn{constructor(t=[],e=[],n=1,s=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:s};const a=[],r=[];o(s),c(n),h(),this.setAttribute("position",new ue(a,3)),this.setAttribute("normal",new ue(a.slice(),3)),this.setAttribute("uv",new ue(r,2)),s===0?this.computeVertexNormals():this.normalizeNormals();function o(y){const x=new C,S=new C,P=new C;for(let T=0;T<e.length;T+=3)f(e[T+0],x),f(e[T+1],S),f(e[T+2],P),l(x,S,P,y)}function l(y,x,S,P){const T=P+1,w=[];for(let R=0;R<=T;R++){w[R]=[];const k=y.clone().lerp(S,R/T),v=x.clone().lerp(S,R/T),b=T-R;for(let N=0;N<=b;N++)N===0&&R===T?w[R][N]=k:w[R][N]=k.clone().lerp(v,N/b)}for(let R=0;R<T;R++)for(let k=0;k<2*(T-R)-1;k++){const v=Math.floor(k/2);k%2===0?(d(w[R][v+1]),d(w[R+1][v]),d(w[R][v])):(d(w[R][v+1]),d(w[R+1][v+1]),d(w[R+1][v]))}}function c(y){const x=new C;for(let S=0;S<a.length;S+=3)x.x=a[S+0],x.y=a[S+1],x.z=a[S+2],x.normalize().multiplyScalar(y),a[S+0]=x.x,a[S+1]=x.y,a[S+2]=x.z}function h(){const y=new C;for(let x=0;x<a.length;x+=3){y.x=a[x+0],y.y=a[x+1],y.z=a[x+2];const S=p(y)/2/Math.PI+.5,P=m(y)/Math.PI+.5;r.push(S,1-P)}g(),u()}function u(){for(let y=0;y<r.length;y+=6){const x=r[y+0],S=r[y+2],P=r[y+4],T=Math.max(x,S,P),w=Math.min(x,S,P);T>.9&&w<.1&&(x<.2&&(r[y+0]+=1),S<.2&&(r[y+2]+=1),P<.2&&(r[y+4]+=1))}}function d(y){a.push(y.x,y.y,y.z)}function f(y,x){const S=y*3;x.x=t[S+0],x.y=t[S+1],x.z=t[S+2]}function g(){const y=new C,x=new C,S=new C,P=new C,T=new lt,w=new lt,R=new lt;for(let k=0,v=0;k<a.length;k+=9,v+=6){y.set(a[k+0],a[k+1],a[k+2]),x.set(a[k+3],a[k+4],a[k+5]),S.set(a[k+6],a[k+7],a[k+8]),T.set(r[v+0],r[v+1]),w.set(r[v+2],r[v+3]),R.set(r[v+4],r[v+5]),P.copy(y).add(x).add(S).divideScalar(3);const b=p(P);_(T,v+0,y,b),_(w,v+2,x,b),_(R,v+4,S,b)}}function _(y,x,S,P){P<0&&y.x===1&&(r[x]=y.x-1),S.x===0&&S.z===0&&(r[x]=P/2/Math.PI+.5)}function p(y){return Math.atan2(y.z,-y.x)}function m(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Vh(t.vertices,t.indices,t.radius,t.details)}}class Ta extends Vh{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,s=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],a=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(s,a,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Ta(t.radius,t.detail)}}class Gh extends pn{constructor(t=.5,e=1,n=32,s=1,a=0,r=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:s,thetaStart:a,thetaLength:r},n=Math.max(3,n),s=Math.max(1,s);const o=[],l=[],c=[],h=[];let u=t;const d=(e-t)/s,f=new C,g=new lt;for(let _=0;_<=s;_++){for(let p=0;p<=n;p++){const m=a+p/n*r;f.x=u*Math.cos(m),f.y=u*Math.sin(m),l.push(f.x,f.y,f.z),c.push(0,0,1),g.x=(f.x/e+1)/2,g.y=(f.y/e+1)/2,h.push(g.x,g.y)}u+=d}for(let _=0;_<s;_++){const p=_*(n+1);for(let m=0;m<n;m++){const y=m+p,x=y,S=y+n+1,P=y+n+2,T=y+1;o.push(x,S,T),o.push(S,P,T)}}this.setIndex(o),this.setAttribute("position",new ue(l,3)),this.setAttribute("normal",new ue(c,3)),this.setAttribute("uv",new ue(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Gh(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class di extends pn{constructor(t=1,e=32,n=16,s=0,a=Math.PI*2,r=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:s,phiLength:a,thetaStart:r,thetaLength:o},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const l=Math.min(r+o,Math.PI);let c=0;const h=[],u=new C,d=new C,f=[],g=[],_=[],p=[];for(let m=0;m<=n;m++){const y=[],x=m/n;let S=0;m===0&&r===0?S=.5/e:m===n&&l===Math.PI&&(S=-.5/e);for(let P=0;P<=e;P++){const T=P/e;u.x=-t*Math.cos(s+T*a)*Math.sin(r+x*o),u.y=t*Math.cos(r+x*o),u.z=t*Math.sin(s+T*a)*Math.sin(r+x*o),g.push(u.x,u.y,u.z),d.copy(u).normalize(),_.push(d.x,d.y,d.z),p.push(T+S,1-x),y.push(c++)}h.push(y)}for(let m=0;m<n;m++)for(let y=0;y<e;y++){const x=h[m][y+1],S=h[m][y],P=h[m+1][y],T=h[m+1][y+1];(m!==0||r>0)&&f.push(x,S,T),(m!==n-1||l<Math.PI)&&f.push(S,P,T)}this.setIndex(f),this.setAttribute("position",new ue(g,3)),this.setAttribute("normal",new ue(_,3)),this.setAttribute("uv",new ue(p,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new di(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class li extends pn{constructor(t=1,e=.4,n=12,s=48,a=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:s,arc:a},n=Math.floor(n),s=Math.floor(s);const r=[],o=[],l=[],c=[],h=new C,u=new C,d=new C;for(let f=0;f<=n;f++)for(let g=0;g<=s;g++){const _=g/s*a,p=f/n*Math.PI*2;u.x=(t+e*Math.cos(p))*Math.cos(_),u.y=(t+e*Math.cos(p))*Math.sin(_),u.z=e*Math.sin(p),o.push(u.x,u.y,u.z),h.x=t*Math.cos(_),h.y=t*Math.sin(_),d.subVectors(u,h).normalize(),l.push(d.x,d.y,d.z),c.push(g/s),c.push(f/n)}for(let f=1;f<=n;f++)for(let g=1;g<=s;g++){const _=(s+1)*f+g-1,p=(s+1)*(f-1)+g-1,m=(s+1)*(f-1)+g,y=(s+1)*f+g;r.push(_,p,y),r.push(p,m,y)}this.setIndex(r),this.setAttribute("position",new ue(o,3)),this.setAttribute("normal",new ue(l,3)),this.setAttribute("uv",new ue(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new li(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class D1 extends Bi{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new te(0),this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.fog=t.fog,this}}class I1 extends rn{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Dn extends Bi{constructor(t){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new te(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new te(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Rh,this.normalScale=new lt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new mi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class k1 extends Bi{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Rh,this.normalScale=new lt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class $h extends nn{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new te(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(e.object.target=this.target.uuid),e}}class N1 extends $h{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(nn.DEFAULT_UP),this.updateMatrix(),this.groundColor=new te(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}}const Ol=new fe,Md=new C,bd=new C;class _p{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new lt(512,512),this.map=null,this.mapPass=null,this.matrix=new fe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Nh,this._frameExtents=new lt(1,1),this._viewportCount=1,this._viewports=[new me(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;Md.setFromMatrixPosition(t.matrixWorld),e.position.copy(Md),bd.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(bd),e.updateMatrixWorld(),Ol.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ol),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Ol)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}const Sd=new fe,za=new C,Fl=new C;class U1 extends _p{constructor(){super(new Rn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new lt(4,2),this._viewportCount=6,this._viewports=[new me(2,1,1,1),new me(0,1,1,1),new me(3,1,1,1),new me(1,1,1,1),new me(3,0,1,1),new me(1,0,1,1)],this._cubeDirections=[new C(1,0,0),new C(-1,0,0),new C(0,0,1),new C(0,0,-1),new C(0,1,0),new C(0,-1,0)],this._cubeUps=[new C(0,1,0),new C(0,1,0),new C(0,1,0),new C(0,1,0),new C(0,0,1),new C(0,0,-1)]}updateMatrices(t,e=0){const n=this.camera,s=this.matrix,a=t.distance||n.far;a!==n.far&&(n.far=a,n.updateProjectionMatrix()),za.setFromMatrixPosition(t.matrixWorld),n.position.copy(za),Fl.copy(n.position),Fl.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(Fl),n.updateMatrixWorld(),s.makeTranslation(-za.x,-za.y,-za.z),Sd.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Sd)}}class O1 extends $h{constructor(t,e,n=0,s=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=s,this.shadow=new U1}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class F1 extends _p{constructor(){super(new Uh(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class z1 extends $h{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(nn.DEFAULT_UP),this.updateMatrix(),this.target=new nn,this.shadow=new F1}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class xp{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=wd(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=wd();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function wd(){return performance.now()}const Ed=new fe;class yp{constructor(t,e,n=0,s=1/0){this.ray=new Ih(t,e),this.near=n,this.far=s,this.camera=null,this.layers=new kh,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return Ed.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Ed),this}intersectObject(t,e=!0,n=[]){return eh(t,this,n,e),n.sort(Td),n}intersectObjects(t,e=!0,n=[]){for(let s=0,a=t.length;s<a;s++)eh(t[s],this,n,e);return n.sort(Td),n}}function Td(i,t){return i.distance-t.distance}function eh(i,t,e,n){let s=!0;if(i.layers.test(t.layers)&&i.raycast(t,e)===!1&&(s=!1),s===!0&&n===!0){const a=i.children;for(let r=0,o=a.length;r<o;r++)eh(a[r],t,e,!0)}}class Aa{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(Ve(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class B1 extends Is{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Mh}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Mh);const zl=new Map;function be(i,t={}){const e=i+JSON.stringify(t);return zl.has(e)||zl.set(e,new Dn({color:i,roughness:.7,...t})),zl.get(e)}const Ba=(i,t)=>"#"+new te(i).multiplyScalar(t).getHexString();function ae(i,t,e,n=0,s=0,a=0){const r=new yt(i,t);return r.position.set(n,s,a),r.castShadow=!0,r.receiveShadow=!0,e.add(r),r}const ai=(i,t)=>new Hh(i,Math.max(.001,t),5,12),Ei=(i,t=20,e=14)=>new di(i,t,e),H1=.93,V1=.45,G1=.44,$1=.06,W1=.1,Wt=.46,Wh={ada:{hair:"afro",pants:"#3a3f5c",shoes:"#26211d"},tunde:{hair:"short",pants:"#4b4136",shoes:"#1c1c1c",extra:"lanyard"},mira:{hair:"bob",pants:"#2f3b52",shoes:"#5b4636"},kai:{hair:"spiky",pants:"#38383d",shoes:"#e9e6df",extra:"hood"},zola:{hair:"ponytail",pants:"#4d3f5e",shoes:"#2b2b2b"},remi:{hair:"bun",pants:"#3f4f60",shoes:"#704d38",extra:"glasses"},obi:{hair:"buzz",pants:"#2c3a32",shoes:"#1d1d1d",extra:"headphones"},lin:{hair:"long",pants:"#3b3b4a",shoes:"#2a2a2a"},chief:{hair:"side",pants:"#22232e",shoes:"#141414",extra:"suit"}};function Br(i,t,e,n,s,a,r,o,l,c){const h=new Ht;h.position.set(t,e,0),i.add(h),ae(ai(a,n-a),o,h,0,-n/2);const u=new Ht;u.position.y=-n,h.add(u),ae(ai(r,s-r),l,u,0,-s/2);const d=new Ht;return d.position.y=-s,u.add(d),c==null||c(d),{pivot:h,joint:u,end:d}}class ir{constructor(t){const e=Wh[t.id]||{hair:"short",pants:"#34384a",shoes:"#222"};this.look=e;const n=be(t.skin,{roughness:.6}),s=be(t.shirt),a=be(Ba(t.shirt,.9)),r=be(e.pants),o=be(e.shoes,{roughness:.5}),l=be(t.hair,{roughness:.85});this.group=new Ht,this.body=new Ht,this.group.add(this.body),this.hips=new Ht,this.hips.position.y=.95,this.body.add(this.hips),ae(ai(.2,.06),r,this.hips,0,.02).scale.set(1,1,.8);const h=_=>{ae(new Ye(.15,.09,.26),o,_,0,-.02,.05).geometry.translate(0,0,0)};this.legL=Br(this.hips,-.11,-.02,.45,.44,.1,.085,r,r,h),this.legR=Br(this.hips,.11,-.02,.45,.44,.1,.085,r,r,h),this.torso=new Ht,this.hips.add(this.torso);const u=[[.001,0],[.19,0],[.225,.08],[.23,.24],[.22,.36],[.255,.5],[.24,.58],[.15,.645],[.001,.66]].map(([_,p])=>new lt(_,p)),d=ae(new Go(u,20),e.extra==="suit"?be("#2b2d42"):s,this.torso,0,.04);d.scale.z=.8,ae(new li(.11,.03,8,20),e.extra==="suit"?be("#f4f1ea"):be(Ba(t.shirt,.8)),this.torso,0,.67).rotation.x=Math.PI/2,ae(new Hn(.075,.085,.14,12),n,this.torso,0,.73);const f=_=>ae(Ei(.07,12,10),n,_,0,-.02),g=e.extra==="suit"?be("#2b2d42"):a;this.armL=Br(this.torso,-.29,.58,.32,.3,.072,.062,g,e.extra==="suit"||e.extra==="hood"?g:n,f),this.armR=Br(this.torso,.29,.58,.32,.3,.072,.062,g,e.extra==="suit"||e.extra==="hood"?g:n,f),this.buildHead(t,n,l),this.buildExtras(t,e,l),this.book=ae(new Ye(.34,.05,.26),be("#3d7ea6"),this.torso,0,.3,.36),this.book.rotation.x=-.6,this.book.visible=!1,this.mug=ae(new Hn(.06,.055,.13,12),be("#ffffff"),this.armR.end,0,-.06,.07),this.mug.visible=!1,this.blinkAt=1+Math.random()*3,this.blink=0,this.cur={}}buildHead(t,e,n){this.head=new Ht,this.head.position.y=.78,this.torso.add(this.head),ae(Ei(.33,28,20),e,this.head,0,.3).scale.set(1,.97,.94);for(const r of[-1,1])ae(Ei(.06,10,8),e,this.head,r*.32,.29,-.01).scale.set(.6,1,1);ae(Ei(.032,10,8),be(Ba(t.skin,.88),{roughness:.6}),this.head,0,.27,.31),this.eyes=[];for(const r of[-1,1]){const o=new Ht;o.position.set(r*.115,.33,.285),o.rotation.y=r*.28,this.head.add(o);const l=new yt(Ei(.042,14,10),be("#17181c",{roughness:.3}));l.scale.set(.82,1.2,.5),o.add(l);const c=new yt(Ei(.013,8,6),new cn({color:"#ffffff"}));c.position.set(.012,.018,.02),o.add(c),this.eyes.push(o)}this.brows=[];for(const r of[-1,1]){const o=new yt(ai(.014,.08),be(Ba(t.hair,.9)));o.rotation.z=Math.PI/2;const l=new Ht;l.position.set(r*.115,.425,.275),l.rotation.y=r*.28,l.add(o),this.head.add(l),this.brows.push(l)}this.mouth=new yt(new li(.055,.012,6,18,Math.PI),be("#5b2a2a",{roughness:.5})),this.mouth.position.set(0,.205,.292),this.mouth.rotation.z=Math.PI,this.head.add(this.mouth);for(const r of[-1,1]){const o=new yt(new gi(.045,16),new cn({color:"#ff8d7a",transparent:!0,opacity:.22,depthWrite:!1}));o.position.set(r*.19,.24,.245),o.rotation.y=r*.62,this.head.add(o)}const a=(r=.345,o=.52,l=-.25)=>{const c=ae(new di(r,28,16,0,Math.PI*2,0,Math.PI*o),n,this.head,0,.31,-.01);return c.rotation.x=l,c.scale.set(1,1,.97),c};switch(this.look.hair){case"afro":a(.35,.55),ae(Ei(.43,24,18),n,this.head,0,.47,-.08).scale.set(1,.85,.95);break;case"bob":{a(.36,.56,-.32);for(const r of[-1,1])ae(ai(.09,.2),n,this.head,r*.29,.22,-.1).scale.set(.75,1,1.1);ae(ai(.05,.3),n,this.head,0,.55,.17).rotation.z=Math.PI/2;break}case"spiky":a(.35,.5);for(let r=0;r<9;r++){const o=r/9*Math.PI*2;ae(new pr(.07,.22,6),n,this.head,Math.cos(o)*.17,.6,Math.sin(o)*.17-.03).rotation.set(Math.sin(o)*.7,0,-Math.cos(o)*.7)}break;case"ponytail":{a(.35,.55),ae(Ei(.07,10,8),be("#e07a5f"),this.head,0,.42,-.33);const r=ae(ai(.08,.32),n,this.head,0,.22,-.4);r.rotation.x=.35,this.tail=r;break}case"bun":a(.35,.55),ae(Ei(.14,16,12),n,this.head,0,.66,-.1);break;case"buzz":a(.338,.5,-.3);break;case"long":{a(.36,.58,-.2),ae(ai(.16,.42),n,this.head,0,.1,-.2).scale.set(1.75,1,.6);break}case"side":{a(.35,.5),ae(ai(.07,.3),n,this.head,.06,.58,.12).rotation.set(.2,0,Math.PI/2-.25);break}default:a(.35,.5)}}buildExtras(t,e,n){if(e.extra==="glasses"||e.extra==="suit"){const s=be("#1b1b1f",{roughness:.4});for(const a of[-1,1]){const r=ae(new li(.06,.011,6,18),s,this.head,a*.115,.33,.3);r.rotation.y=a*.28}ae(ai(.009,.06),s,this.head,0,.34,.315).rotation.z=Math.PI/2}if(e.extra==="suit"){const s=ae(new Ye(.06,.3,.02),be("#b23a3a"),this.torso,0,.47,.19);s.rotation.x=-.12,ae(new Ye(.16,.18,.02),be("#f4f1ea"),this.torso,0,.56,.175).rotation.x=-.15}if(e.extra==="headphones"){const s=ae(new li(.35,.025,8,24,Math.PI),be("#22252b"),this.head,0,.32,0);s.rotation.y=Math.PI/2,s.rotation.x=-.15;for(const a of[-1,1])ae(new Hn(.09,.09,.07,18),be("#e05f4a"),this.head,a*.34,.3,0).rotation.z=Math.PI/2}if(e.extra==="lanyard"&&(ae(new li(.16,.01,6,20,Math.PI),be("#2a6fb0"),this.torso,0,.62,.12).rotation.set(-.25,0,Math.PI),ae(new Ye(.1,.13,.015),be("#ffffff"),this.torso,0,.42,.205).rotation.x=-.1),e.extra==="hood"){const s=ae(new li(.2,.06,10,24),be(Ba(t.shirt,.85)),this.torso,0,.64,-.05);s.rotation.x=Math.PI/2+.35,s.scale.set(1,1,.7)}}static sit(t=Wt,e=-1.4){const n=t+W1,s=n-V1*Math.cos(e),a=-Math.acos(Math.min(1,Math.max(-1,(s-$1)/G1)));return{y:n-H1,hip:e,knee:a-e}}pose(t,e,n,s={}){const a=Math.min(1,e*10);let r=0,o=0,l=0,c=0,h=.05,u=.05,d=-.12,f=-.12,g=-.07,_=.07,p=0,m=0,y=0,x=0,S=0;const P=Math.sin(n*1.7)*.012;switch(this.book.visible=t==="read",this.mug.visible=t==="mug",t){case"walk":{const v=Math.sin(n*9.5),b=Math.cos(n*9.5);r=v*.5,o=-v*.5,l=Math.max(0,-b)*.9+.05,c=Math.max(0,b)*.9+.05,h=-v*.45,u=v*.45,d=f=-.35,p=Math.abs(b)*.05,m=.06,x=Math.sin(n*4.75)*.04;break}case"desk":{const v=ir.sit(s.seatY,-1.45);r=o=v.hip,l=c=v.knee,p=v.y,m=.08,s.typing?(h=-.5+Math.sin(n*17)*.05,u=-.5+Math.sin(n*17+2)*.05,d=-1.15+Math.sin(n*19)*.12,f=-1.15+Math.sin(n*19+1.6)*.12,g=-.18,_=.18,y=.12+Math.sin(n*.7)*.03):s.waiting?(u=-.95,f=-2.25,_=.05,h=-.4,d=-1,x=Math.sin(n*.6)*.45,y=-.05):(h=u=-.35,d=f=-.9,g=-.2,_=.2,m=-.04,x=Math.sin(n*.35)*.3);break}case"couch":{const v=ir.sit(s.seatY,-1.3);r=o=v.hip,l=c=v.knee,p=v.y,m=-.18,h=u=-.2,d=f=-.75,g=-.15,_=.15,x=Math.sin(n*.3)*.5,S=Math.sin(n*.21)*.06;break}case"sit":{const v=ir.sit(s.seatY,-1.42);r=o=v.hip,l=c=v.knee,p=v.y,m=.03,h=u=-.32,d=f=-.95,g=-.16,_=.16,x=Math.sin(n*.4)*.4,S=Math.sin(n*.27)*.05;break}case"read":h=u=-.55,d=f=-1.35,g=-.12,_=.12,y=.4,x=Math.sin(n*.6)*.12;break;case"type":h=-.75+Math.sin(n*14)*.08,u=-.75+Math.sin(n*14+2)*.08,d=-.9,f=-.9,g=-.15,_=.15,y=.08;break;case"gaze":h=u=.3,d=f=-.25,g=-.12,_=.12,y=-.18,x=Math.sin(n*.45)*.35;break;case"write":u=-2.2+Math.sin(n*6)*.2,f=-.5+Math.sin(n*9)*.15,_=.25,x=Math.sin(n*1.2)*.1,y=-.08;break;case"mug":{const v=Math.sin(n*.8)>.75;u=v?-.85:-.45,f=v?-2.05:-1.55,_=.1,y=v?-.15:.02,x=v?0:Math.sin(n*.4)*.3;break}case"cue":m=.62,h=-1.5,d=-.12,g=-.12,u=-.95,f=-1.35,_=.14,y=-.5,r=o=-.12,l=c=.14,x=Math.sin(n*.8)*.05;break;case"talk":u=-.55+Math.sin(n*4)*.2,f=-1.1+Math.sin(n*5.3)*.2,_=.2,h=-.1,d=-.4,S=Math.sin(n*2.2)*.06,y=-.04;break;case"celebrate":h=u=-2.75,d=f=-.25,g=-.35,_=.35,p=Math.abs(Math.sin(n*8))*.32,y=-.15,l=c=p>.05?.4:.1,r=o=-l*.5;break;case"slump":y=.45,m=.22,h=u=.12,d=f=-.05;break;default:x=Math.sin(n*.5)*.25}const T=this.cur,w=(v,b,N=a)=>T[v]=T[v]===void 0?b:T[v]+(b-T[v])*N,R=t==="walk",k=R?Math.min(1,e*18):a;this.legL.pivot.rotation.x=w("hipL",r,k),this.legR.pivot.rotation.x=w("hipR",o,k),this.legL.joint.rotation.x=w("kneeL",l,k),this.legR.joint.rotation.x=w("kneeR",c,k),this.armL.pivot.rotation.x=w("shL",h,k),this.armR.pivot.rotation.x=w("shR",u,k),this.armL.pivot.rotation.z=w("outL",g),this.armR.pivot.rotation.z=w("outR",_),this.armL.joint.rotation.x=w("elL",d,k),this.armR.joint.rotation.x=w("elR",f,k),this.torso.rotation.x=w("lean",m),this.torso.scale.y=1+P,this.head.rotation.x=w("headX",y,a*.6),this.head.rotation.y=w("headY",x,a*.4),this.head.rotation.z=w("headZ",S,a*.6),this.body.position.y=R||t==="celebrate"?p:w("y",p),this.tail&&(this.tail.rotation.x=.35+Math.sin(n*(R?9.5:1.5))*(R?.12:.03))}express(t,e,n){n>this.blinkAt&&(this.blink=.14,this.blinkAt=n+2+Math.random()*4),this.blink=Math.max(0,this.blink-e);const s=this.blink>0,a=Math.min(1,e*12),r=this.cur,o=(m,y)=>r[m]=r[m]===void 0?y:r[m]+(y-r[m])*a;let l=1,c=0,h=0,u=1,d=1,f=!1;t==="happy"?(l=.3,c=.025,u=1.45,d=1.6):t==="think"?(c=.02,h=.25,u=.55,l=.9):t==="worried"?(h=-.35,c=.01,f=!0,u=.8):t==="talk"&&(u=.8,d=.6+Math.abs(Math.sin(n*13))*1.6,c=Math.sin(n*3)*.008),s&&t!=="happy"&&(l=.1);const g=o("eyeY",l);for(const m of this.eyes)m.scale.y=g;const _=o("browY",c),p=o("browTilt",h);this.brows.forEach((m,y)=>{m.position.y=.425+_,m.rotation.z=(y?-1:1)*p}),this.mouth.rotation.z=f?0:Math.PI,this.mouth.position.y=f?.18:.205,this.mouth.scale.set(o("mouthX",u),o("mouthY",d),1)}}const X=i=>document.getElementById(i),Ad=["👍","❤️","😂","🎉","👀","🙏","🔥","✅"],X1=[["Smileys",["😀","😄","😁","😆","😅","🤣","😂","🙂","😉","😊","😇","🥰","😍","🤩","😘","😋","😛","🤪","🤔","🤨","😐","😑","😶","🙄","😏","😬","😌","😴","🤯","🥳","😎","🤓","🧐","😕","😟","😮","😲","😳","🥺","😢","😭","😱","😤","😡","🤬","💀","🤡","👻"]],["Gestures",["👍","👎","👌","🤌","✌️","🤞","🤝","👏","🙌","👐","🙏","💪","👋","🤙","👀","🫡","🤷","🤦","🙋","🙇"]],["Hearts",["❤️","🧡","💛","💚","💙","💜","🖤","🤍","💔","💯","💥","💫","✨","⭐","🔥","⚡"]],["Work",["✅","❌","⚠️","❓","❗","🚀","🎉","🎯","🏆","🐛","🔧","🛠️","💡","📌","📎","📝","📈","📉","⏳","🧪","🔒","🧠","☕","🍕"]]],J=i=>String(i??"").replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t]),Mp=new Pf({gfm:!0,breaks:!0});Mp.use({renderer:{html:i=>J(i.text??i),link:({href:i,text:t})=>/^https?:\/\//i.test(i)?`<a href="${J(i)}" target="_blank" rel="noreferrer">${J(t)}</a>`:J(t),image:({text:i})=>J(i)}});const Bl=i=>Mp.parse(String(i??"")),oa={queued:"Queued",working:"Working",done:"Shipped",failed:"Failed",stopped:"Stopped"},q1={haiku:"Haiku",sonnet:"Sonnet",opus:"Opus"},j1=i=>{var t,e;return q1[i]||((e=[...((t=X("model"))==null?void 0:t.options)||[]].find(n=>n.value===i))==null?void 0:e.text)||i||"Default"},Hl={library:"Library",servers:"Server room",window:"Research",whiteboard:"Whiteboard",desk:"Desk"},Ci=(i,t)=>typeof t=="string"&&Object.hasOwn(i,t)?t:"",Vl=i=>oa[Ci(oa,i)]||"",Cd=i=>{const t=/^the boss (?:says|asks|wants)\s*[:,]?\s*["“](.+?)(?:["”]|$)[\s.,:;]*(.*)/is.exec(String(i||"")),e=(t?t[1].length<24&&t[2]?`${t[1].replace(/[.!]$/,"")}: ${t[2]}`:t[1]:String(i||"")).trim();return e.charAt(0).toUpperCase()+e.slice(1)},Y1=i=>{if(!i)return"";const t=Math.max(0,Math.round((Date.now()-i)/6e4));return t<1?"now":t<60?`${t}m`:t<1440?`${Math.round(t/60)}h`:`${Math.round(t/1440)}d`},Ti=i=>Number.isFinite(i)?i:0,ya=i=>typeof i=="string"&&/^#[0-9a-f]{3,8}$/i.test(i)?i:"#999",Xh=new Map,Gl=i=>{let t=0;for(const a of String(i))t=(t*31+a.charCodeAt(0))%360;const e=(String(i).match(/[a-z0-9]/i)||["#"])[0].toUpperCase(),n=Xh.get(i),s=n===!1?"":`<img src="/api/repos/icon?name=${encodeURIComponent(i)}" alt="" data-pico="${J(i)}" draggable="false">`;return`<span class="pico${n?" has":""}" style="--h:${t}" aria-hidden="true">${J(e)}${s}</span>`};document.addEventListener("load",i=>{var e;const t=i.target;(e=t==null?void 0:t.dataset)!=null&&e.pico&&(Xh.set(t.dataset.pico,!0),t.parentElement.classList.add("has"))},!0);document.addEventListener("error",i=>{var e;const t=i.target;(e=t==null?void 0:t.dataset)!=null&&e.pico&&(Xh.set(t.dataset.pico,!1),t.remove())},!0);const bp=i=>{const t=Wh[i.id]||{},e=ya(i.skin),n=ya(i.hair),s=ya(i.shirt),a=t.hair||"short",r={afro:`<circle cx="24" cy="18" r="13.5" fill="${n}"/>`,bob:`<path d="M10 40V19a14 14 0 0 1 28 0v21z" fill="${n}"/>`,long:`<path d="M9 44V19a15 15 0 0 1 30 0v25z" fill="${n}"/>`,ponytail:`<path d="M33 14c8 1 10 9 6 19-1-6-3-9-6-10z" fill="${n}"/>`,bun:`<circle cx="24" cy="6.5" r="4.5" fill="${n}"/>`}[a]||"",o={afro:`<path d="M15 17a9 9 0 0 1 18 0c-3-3-6-4-9-4s-6 1-9 4z" fill="${n}"/>`,short:`<path d="M15 18a9 9 0 0 1 18 0c-4-1-6-3-9-5-2 3-5 4-9 5z" fill="${n}"/>`,buzz:`<path d="M15.2 17.5a8.8 8.8 0 0 1 17.6 0c-5-2-12.6-2-17.6 0z" fill="${n}"/>`,spiky:`<path d="M15 18l1-7 3 4 2-7 3 6 3-6 2 7 3-4 1 7c-4-2-6-3-9-3s-5 1-9 3z" fill="${n}"/>`,bob:`<path d="M15 19a9 9 0 0 1 18 0c-5 0-9-2-11-5-1 3-3 5-7 5z" fill="${n}"/>`,long:`<path d="M15 19a9 9 0 0 1 18 0c-5 0-9-2-11-5-1 3-3 5-7 5z" fill="${n}"/>`,ponytail:`<path d="M15 18a9 9 0 0 1 18 0c-4-1-7-3-9-5-2 3-5 4-9 5z" fill="${n}"/>`,bun:`<path d="M15 18a9 9 0 0 1 18 0c-4-1-7-3-9-5-2 3-5 4-9 5z" fill="${n}"/>`}[a]||"",l=t.extra==="glasses"?'<g fill="none" stroke="#2b2b2b" stroke-width="1.2"><circle cx="20.5" cy="22" r="3"/><circle cx="27.5" cy="22" r="3"/><path d="M23.5 22h1"/></g>':t.extra==="headphones"?'<path d="M14.5 22v-4a9.5 9.5 0 0 1 19 0v4" fill="none" stroke="#2b2b2b" stroke-width="2"/><rect x="12.5" y="20" width="4" height="7" rx="2" fill="#2b2b2b"/><rect x="31.5" y="20" width="4" height="7" rx="2" fill="#2b2b2b"/>':"";return`<svg class="face" viewBox="0 0 48 48" aria-hidden="true" style="background:${s}33">
3894
+ }`;class d1{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(this.texture===null){const s=new on,a=t.properties.get(s);a.__webglTexture=e.texture,(e.depthNear!=n.depthNear||e.depthFar!=n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=s}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new an({vertexShader:h1,fragmentShader:u1,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new yt(new vi(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class f1 extends Is{constructor(t,e){super();const n=this;let s=null,a=1,r=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,f=null,g=null;const _=new d1,p=e.getContextAttributes();let m=null,y=null;const x=[],S=[],P=new lt;let T=null;const w=new Rn;w.layers.enable(1),w.viewport=new me;const R=new Rn;R.layers.enable(2),R.viewport=new me;const k=[w,R],v=new l1;v.layers.enable(1),v.layers.enable(2);let b=null,N=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(q){let st=x[q];return st===void 0&&(st=new Il,x[q]=st),st.getTargetRaySpace()},this.getControllerGrip=function(q){let st=x[q];return st===void 0&&(st=new Il,x[q]=st),st.getGripSpace()},this.getHand=function(q){let st=x[q];return st===void 0&&(st=new Il,x[q]=st),st.getHandSpace()};function F(q){const st=S.indexOf(q.inputSource);if(st===-1)return;const Mt=x[st];Mt!==void 0&&(Mt.update(q.inputSource,q.frame,c||r),Mt.dispatchEvent({type:q.type,data:q.inputSource}))}function $(){s.removeEventListener("select",F),s.removeEventListener("selectstart",F),s.removeEventListener("selectend",F),s.removeEventListener("squeeze",F),s.removeEventListener("squeezestart",F),s.removeEventListener("squeezeend",F),s.removeEventListener("end",$),s.removeEventListener("inputsourceschange",W);for(let q=0;q<x.length;q++){const st=S[q];st!==null&&(S[q]=null,x[q].disconnect(st))}b=null,N=null,_.reset(),t.setRenderTarget(m),f=null,d=null,u=null,s=null,y=null,qt.stop(),n.isPresenting=!1,t.setPixelRatio(T),t.setSize(P.width,P.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(q){a=q,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(q){o=q,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||r},this.setReferenceSpace=function(q){c=q},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(q){if(s=q,s!==null){if(m=t.getRenderTarget(),s.addEventListener("select",F),s.addEventListener("selectstart",F),s.addEventListener("selectend",F),s.addEventListener("squeeze",F),s.addEventListener("squeezestart",F),s.addEventListener("squeezeend",F),s.addEventListener("end",$),s.addEventListener("inputsourceschange",W),p.xrCompatible!==!0&&await e.makeXRCompatible(),T=t.getPixelRatio(),t.getSize(P),s.renderState.layers===void 0){const st={antialias:p.antialias,alpha:!0,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:a};f=new XRWebGLLayer(s,e,st),s.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),y=new ei(f.framebufferWidth,f.framebufferHeight,{format:zn,type:pi,colorSpace:t.outputColorSpace,stencilBuffer:p.stencil})}else{let st=null,Mt=null,dt=null;p.depth&&(dt=p.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,st=p.stencil?Ls:_a,Mt=p.stencil?Ps:Rs);const It={colorFormat:e.RGBA8,depthFormat:dt,scaleFactor:a};u=new XRWebGLBinding(s,e),d=u.createProjectionLayer(It),s.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),y=new ei(d.textureWidth,d.textureHeight,{format:zn,type:pi,depthTexture:new Fh(d.textureWidth,d.textureHeight,Mt,void 0,void 0,void 0,void 0,void 0,void 0,st),stencilBuffer:p.stencil,colorSpace:t.outputColorSpace,samples:p.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(l),c=null,r=await s.requestReferenceSpace(o),qt.setContext(s),qt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function W(q){for(let st=0;st<q.removed.length;st++){const Mt=q.removed[st],dt=S.indexOf(Mt);dt>=0&&(S[dt]=null,x[dt].disconnect(Mt))}for(let st=0;st<q.added.length;st++){const Mt=q.added[st];let dt=S.indexOf(Mt);if(dt===-1){for(let Rt=0;Rt<x.length;Rt++)if(Rt>=S.length){S.push(Mt),dt=Rt;break}else if(S[Rt]===null){S[Rt]=Mt,dt=Rt;break}if(dt===-1)break}const It=x[dt];It&&It.connect(Mt)}}const z=new C,nt=new C;function G(q,st,Mt){z.setFromMatrixPosition(st.matrixWorld),nt.setFromMatrixPosition(Mt.matrixWorld);const dt=z.distanceTo(nt),It=st.projectionMatrix.elements,Rt=Mt.projectionMatrix.elements,Nt=It[14]/(It[10]-1),ee=It[14]/(It[10]+1),$t=(It[9]+1)/It[5],L=(It[9]-1)/It[5],ze=(It[8]-1)/It[0],Zt=(Rt[8]+1)/Rt[0],j=Nt*ze,Q=Nt*Zt,Tt=dt/(-ze+Zt),St=Tt*-ze;if(st.matrixWorld.decompose(q.position,q.quaternion,q.scale),q.translateX(St),q.translateZ(Tt),q.matrixWorld.compose(q.position,q.quaternion,q.scale),q.matrixWorldInverse.copy(q.matrixWorld).invert(),It[10]===-1)q.projectionMatrix.copy(st.projectionMatrix),q.projectionMatrixInverse.copy(st.projectionMatrixInverse);else{const A=Nt+Tt,M=ee+Tt,O=j-St,Z=Q+(dt-St),it=$t*ee/M*A,Y=L*ee/M*A;q.projectionMatrix.makePerspective(O,Z,it,Y,A,M),q.projectionMatrixInverse.copy(q.projectionMatrix).invert()}}function at(q,st){st===null?q.matrixWorld.copy(q.matrix):q.matrixWorld.multiplyMatrices(st.matrixWorld,q.matrix),q.matrixWorldInverse.copy(q.matrixWorld).invert()}this.updateCamera=function(q){if(s===null)return;let st=q.near,Mt=q.far;_.texture!==null&&(_.depthNear>0&&(st=_.depthNear),_.depthFar>0&&(Mt=_.depthFar)),v.near=R.near=w.near=st,v.far=R.far=w.far=Mt,(b!==v.near||N!==v.far)&&(s.updateRenderState({depthNear:v.near,depthFar:v.far}),b=v.near,N=v.far);const dt=q.parent,It=v.cameras;at(v,dt);for(let Rt=0;Rt<It.length;Rt++)at(It[Rt],dt);It.length===2?G(v,w,R):v.projectionMatrix.copy(w.projectionMatrix),ht(q,v,dt)};function ht(q,st,Mt){Mt===null?q.matrix.copy(st.matrixWorld):(q.matrix.copy(Mt.matrixWorld),q.matrix.invert(),q.matrix.multiply(st.matrixWorld)),q.matrix.decompose(q.position,q.quaternion,q.scale),q.updateMatrixWorld(!0),q.projectionMatrix.copy(st.projectionMatrix),q.projectionMatrixInverse.copy(st.projectionMatrixInverse),q.isPerspectiveCamera&&(q.fov=lr*2*Math.atan(1/q.projectionMatrix.elements[5]),q.zoom=1)}this.getCamera=function(){return v},this.getFoveation=function(){if(!(d===null&&f===null))return l},this.setFoveation=function(q){l=q,d!==null&&(d.fixedFoveation=q),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=q)},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(v)};let mt=null;function Xt(q,st){if(h=st.getViewerPose(c||r),g=st,h!==null){const Mt=h.views;f!==null&&(t.setRenderTargetFramebuffer(y,f.framebuffer),t.setRenderTarget(y));let dt=!1;Mt.length!==v.cameras.length&&(v.cameras.length=0,dt=!0);for(let Rt=0;Rt<Mt.length;Rt++){const Nt=Mt[Rt];let ee=null;if(f!==null)ee=f.getViewport(Nt);else{const L=u.getViewSubImage(d,Nt);ee=L.viewport,Rt===0&&(t.setRenderTargetTextures(y,L.colorTexture,d.ignoreDepthValues?void 0:L.depthStencilTexture),t.setRenderTarget(y))}let $t=k[Rt];$t===void 0&&($t=new Rn,$t.layers.enable(Rt),$t.viewport=new me,k[Rt]=$t),$t.matrix.fromArray(Nt.transform.matrix),$t.matrix.decompose($t.position,$t.quaternion,$t.scale),$t.projectionMatrix.fromArray(Nt.projectionMatrix),$t.projectionMatrixInverse.copy($t.projectionMatrix).invert(),$t.viewport.set(ee.x,ee.y,ee.width,ee.height),Rt===0&&(v.matrix.copy($t.matrix),v.matrix.decompose(v.position,v.quaternion,v.scale)),dt===!0&&v.cameras.push($t)}const It=s.enabledFeatures;if(It&&It.includes("depth-sensing")){const Rt=u.getDepthInformation(Mt[0]);Rt&&Rt.isValid&&Rt.texture&&_.init(t,Rt,s.renderState)}}for(let Mt=0;Mt<x.length;Mt++){const dt=S[Mt],It=x[Mt];dt!==null&&It!==void 0&&It.update(dt,st,c||r)}mt&&mt(q,st),st.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:st}),g=null}const qt=new rp;qt.setAnimationLoop(Xt),this.setAnimationLoop=function(q){mt=q},this.dispose=function(){}}}const _s=new mi,p1=new fe;function m1(i,t){function e(p,m){p.matrixAutoUpdate===!0&&p.updateMatrix(),m.value.copy(p.matrix)}function n(p,m){m.color.getRGB(p.fogColor.value,ip(i)),m.isFog?(p.fogNear.value=m.near,p.fogFar.value=m.far):m.isFogExp2&&(p.fogDensity.value=m.density)}function s(p,m,y,x,S){m.isMeshBasicMaterial||m.isMeshLambertMaterial?a(p,m):m.isMeshToonMaterial?(a(p,m),u(p,m)):m.isMeshPhongMaterial?(a(p,m),h(p,m)):m.isMeshStandardMaterial?(a(p,m),d(p,m),m.isMeshPhysicalMaterial&&f(p,m,S)):m.isMeshMatcapMaterial?(a(p,m),g(p,m)):m.isMeshDepthMaterial?a(p,m):m.isMeshDistanceMaterial?(a(p,m),_(p,m)):m.isMeshNormalMaterial?a(p,m):m.isLineBasicMaterial?(r(p,m),m.isLineDashedMaterial&&o(p,m)):m.isPointsMaterial?l(p,m,y,x):m.isSpriteMaterial?c(p,m):m.isShadowMaterial?(p.color.value.copy(m.color),p.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function a(p,m){p.opacity.value=m.opacity,m.color&&p.diffuse.value.copy(m.color),m.emissive&&p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(p.map.value=m.map,e(m.map,p.mapTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,e(m.alphaMap,p.alphaMapTransform)),m.bumpMap&&(p.bumpMap.value=m.bumpMap,e(m.bumpMap,p.bumpMapTransform),p.bumpScale.value=m.bumpScale,m.side===fn&&(p.bumpScale.value*=-1)),m.normalMap&&(p.normalMap.value=m.normalMap,e(m.normalMap,p.normalMapTransform),p.normalScale.value.copy(m.normalScale),m.side===fn&&p.normalScale.value.negate()),m.displacementMap&&(p.displacementMap.value=m.displacementMap,e(m.displacementMap,p.displacementMapTransform),p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias),m.emissiveMap&&(p.emissiveMap.value=m.emissiveMap,e(m.emissiveMap,p.emissiveMapTransform)),m.specularMap&&(p.specularMap.value=m.specularMap,e(m.specularMap,p.specularMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);const y=t.get(m),x=y.envMap,S=y.envMapRotation;x&&(p.envMap.value=x,_s.copy(S),_s.x*=-1,_s.y*=-1,_s.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(_s.y*=-1,_s.z*=-1),p.envMapRotation.value.setFromMatrix4(p1.makeRotationFromEuler(_s)),p.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio),m.lightMap&&(p.lightMap.value=m.lightMap,p.lightMapIntensity.value=m.lightMapIntensity,e(m.lightMap,p.lightMapTransform)),m.aoMap&&(p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity,e(m.aoMap,p.aoMapTransform))}function r(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,m.map&&(p.map.value=m.map,e(m.map,p.mapTransform))}function o(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function l(p,m,y,x){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*y,p.scale.value=x*.5,m.map&&(p.map.value=m.map,e(m.map,p.uvTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,e(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function c(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map&&(p.map.value=m.map,e(m.map,p.mapTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,e(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function h(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,1e-4)}function u(p,m){m.gradientMap&&(p.gradientMap.value=m.gradientMap)}function d(p,m){p.metalness.value=m.metalness,m.metalnessMap&&(p.metalnessMap.value=m.metalnessMap,e(m.metalnessMap,p.metalnessMapTransform)),p.roughness.value=m.roughness,m.roughnessMap&&(p.roughnessMap.value=m.roughnessMap,e(m.roughnessMap,p.roughnessMapTransform)),m.envMap&&(p.envMapIntensity.value=m.envMapIntensity)}function f(p,m,y){p.ior.value=m.ior,m.sheen>0&&(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(p.sheenColorMap.value=m.sheenColorMap,e(m.sheenColorMap,p.sheenColorMapTransform)),m.sheenRoughnessMap&&(p.sheenRoughnessMap.value=m.sheenRoughnessMap,e(m.sheenRoughnessMap,p.sheenRoughnessMapTransform))),m.clearcoat>0&&(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(p.clearcoatMap.value=m.clearcoatMap,e(m.clearcoatMap,p.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,e(m.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(p.clearcoatNormalMap.value=m.clearcoatNormalMap,e(m.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===fn&&p.clearcoatNormalScale.value.negate())),m.dispersion>0&&(p.dispersion.value=m.dispersion),m.iridescence>0&&(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(p.iridescenceMap.value=m.iridescenceMap,e(m.iridescenceMap,p.iridescenceMapTransform)),m.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=m.iridescenceThicknessMap,e(m.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),m.transmission>0&&(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=y.texture,p.transmissionSamplerSize.value.set(y.width,y.height),m.transmissionMap&&(p.transmissionMap.value=m.transmissionMap,e(m.transmissionMap,p.transmissionMapTransform)),p.thickness.value=m.thickness,m.thicknessMap&&(p.thicknessMap.value=m.thicknessMap,e(m.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(p.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(p.anisotropyMap.value=m.anisotropyMap,e(m.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularColorMap&&(p.specularColorMap.value=m.specularColorMap,e(m.specularColorMap,p.specularColorMapTransform)),m.specularIntensityMap&&(p.specularIntensityMap.value=m.specularIntensityMap,e(m.specularIntensityMap,p.specularIntensityMapTransform))}function g(p,m){m.matcap&&(p.matcap.value=m.matcap)}function _(p,m){const y=t.get(m).light;p.referencePosition.value.setFromMatrixPosition(y.matrixWorld),p.nearDistance.value=y.shadow.camera.near,p.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function g1(i,t,e,n){let s={},a={},r=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,x){const S=x.program;n.uniformBlockBinding(y,S)}function c(y,x){let S=s[y.id];S===void 0&&(g(y),S=h(y),s[y.id]=S,y.addEventListener("dispose",p));const P=x.program;n.updateUBOMapping(y,P);const T=t.render.frame;a[y.id]!==T&&(d(y),a[y.id]=T)}function h(y){const x=u();y.__bindingPointIndex=x;const S=i.createBuffer(),P=y.__size,T=y.usage;return i.bindBuffer(i.UNIFORM_BUFFER,S),i.bufferData(i.UNIFORM_BUFFER,P,T),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,x,S),S}function u(){for(let y=0;y<o;y++)if(r.indexOf(y)===-1)return r.push(y),y;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(y){const x=s[y.id],S=y.uniforms,P=y.__cache;i.bindBuffer(i.UNIFORM_BUFFER,x);for(let T=0,w=S.length;T<w;T++){const R=Array.isArray(S[T])?S[T]:[S[T]];for(let k=0,v=R.length;k<v;k++){const b=R[k];if(f(b,T,k,P)===!0){const N=b.__offset,F=Array.isArray(b.value)?b.value:[b.value];let $=0;for(let W=0;W<F.length;W++){const z=F[W],nt=_(z);typeof z=="number"||typeof z=="boolean"?(b.__data[0]=z,i.bufferSubData(i.UNIFORM_BUFFER,N+$,b.__data)):z.isMatrix3?(b.__data[0]=z.elements[0],b.__data[1]=z.elements[1],b.__data[2]=z.elements[2],b.__data[3]=0,b.__data[4]=z.elements[3],b.__data[5]=z.elements[4],b.__data[6]=z.elements[5],b.__data[7]=0,b.__data[8]=z.elements[6],b.__data[9]=z.elements[7],b.__data[10]=z.elements[8],b.__data[11]=0):(z.toArray(b.__data,$),$+=nt.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,N,b.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function f(y,x,S,P){const T=y.value,w=x+"_"+S;if(P[w]===void 0)return typeof T=="number"||typeof T=="boolean"?P[w]=T:P[w]=T.clone(),!0;{const R=P[w];if(typeof T=="number"||typeof T=="boolean"){if(R!==T)return P[w]=T,!0}else if(R.equals(T)===!1)return R.copy(T),!0}return!1}function g(y){const x=y.uniforms;let S=0;const P=16;for(let w=0,R=x.length;w<R;w++){const k=Array.isArray(x[w])?x[w]:[x[w]];for(let v=0,b=k.length;v<b;v++){const N=k[v],F=Array.isArray(N.value)?N.value:[N.value];for(let $=0,W=F.length;$<W;$++){const z=F[$],nt=_(z),G=S%P,at=G%nt.boundary,ht=G+at;S+=at,ht!==0&&P-ht<nt.storage&&(S+=P-ht),N.__data=new Float32Array(nt.storage/Float32Array.BYTES_PER_ELEMENT),N.__offset=S,S+=nt.storage}}}const T=S%P;return T>0&&(S+=P-T),y.__size=S,y.__cache={},this}function _(y){const x={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(x.boundary=4,x.storage=4):y.isVector2?(x.boundary=8,x.storage=8):y.isVector3||y.isColor?(x.boundary=16,x.storage=12):y.isVector4?(x.boundary=16,x.storage=16):y.isMatrix3?(x.boundary=48,x.storage=48):y.isMatrix4?(x.boundary=64,x.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),x}function p(y){const x=y.target;x.removeEventListener("dispose",p);const S=r.indexOf(x.__bindingPointIndex);r.splice(S,1),i.deleteBuffer(s[x.id]),delete s[x.id],delete a[x.id]}function m(){for(const y in s)i.deleteBuffer(s[y]);r=[],s={},a={}}return{bind:l,update:c,dispose:m}}class v1{constructor(t={}){const{canvas:e=ag(),context:n=null,depth:s=!0,stencil:a=!1,alpha:r=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1}=t;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=r;const f=new Uint32Array(4),g=new Int32Array(4);let _=null,p=null;const m=[],y=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Qe,this.toneMapping=os,this.toneMappingExposure=1;const x=this;let S=!1,P=0,T=0,w=null,R=-1,k=null;const v=new me,b=new me;let N=null;const F=new te(0);let $=0,W=e.width,z=e.height,nt=1,G=null,at=null;const ht=new me(0,0,W,z),mt=new me(0,0,W,z);let Xt=!1;const qt=new Nh;let q=!1,st=!1;const Mt=new fe,dt=new fe,It=new C,Rt=new me,Nt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ee=!1;function $t(){return w===null?nt:1}let L=n;function ze(E,I){return e.getContext(E,I)}try{const E={alpha:!0,depth:s,stencil:a,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Mh}`),e.addEventListener("webglcontextlost",tt,!1),e.addEventListener("webglcontextrestored",_t,!1),e.addEventListener("webglcontextcreationerror",bt,!1),L===null){const I="webgl2";if(L=ze(I,E),L===null)throw ze(I)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(E){throw console.error("THREE.WebGLRenderer: "+E.message),E}let Zt,j,Q,Tt,St,A,M,O,Z,it,Y,Ct,ut,gt,Jt,rt,vt,Ut,Ot,Et,ne,Vt,se,D;function pt(){Zt=new bx(L),Zt.init(),Vt=new o1(L,Zt),j=new gx(L,Zt,t,Vt),Q=new s1(L),j.reverseDepthBuffer&&Q.buffers.depth.setReversed(!0),Tt=new Ex(L),St=new Gy,A=new r1(L,Zt,Q,St,j,Vt,Tt),M=new _x(x),O=new Mx(x),Z=new Dg(L),se=new px(L,Z),it=new Sx(L,Z,Tt,se),Y=new Ax(L,it,Z,Tt),Ot=new Tx(L,j,A),rt=new vx(St),Ct=new Vy(x,M,O,Zt,j,se,rt),ut=new m1(x,St),gt=new Wy,Jt=new Zy(Zt),Ut=new fx(x,M,O,Q,Y,d,l),vt=new n1(x,Y,j),D=new g1(L,Tt,j,Q),Et=new mx(L,Zt,Tt),ne=new wx(L,Zt,Tt),Tt.programs=Ct.programs,x.capabilities=j,x.extensions=Zt,x.properties=St,x.renderLists=gt,x.shadowMap=vt,x.state=Q,x.info=Tt}pt();const V=new f1(x,L);this.xr=V,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){const E=Zt.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){const E=Zt.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return nt},this.setPixelRatio=function(E){E!==void 0&&(nt=E,this.setSize(W,z,!1))},this.getSize=function(E){return E.set(W,z)},this.setSize=function(E,I,B=!0){if(V.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}W=E,z=I,e.width=Math.floor(E*nt),e.height=Math.floor(I*nt),B===!0&&(e.style.width=E+"px",e.style.height=I+"px"),this.setViewport(0,0,E,I)},this.getDrawingBufferSize=function(E){return E.set(W*nt,z*nt).floor()},this.setDrawingBufferSize=function(E,I,B){W=E,z=I,nt=B,e.width=Math.floor(E*B),e.height=Math.floor(I*B),this.setViewport(0,0,E,I)},this.getCurrentViewport=function(E){return E.copy(v)},this.getViewport=function(E){return E.copy(ht)},this.setViewport=function(E,I,B,H){E.isVector4?ht.set(E.x,E.y,E.z,E.w):ht.set(E,I,B,H),Q.viewport(v.copy(ht).multiplyScalar(nt).round())},this.getScissor=function(E){return E.copy(mt)},this.setScissor=function(E,I,B,H){E.isVector4?mt.set(E.x,E.y,E.z,E.w):mt.set(E,I,B,H),Q.scissor(b.copy(mt).multiplyScalar(nt).round())},this.getScissorTest=function(){return Xt},this.setScissorTest=function(E){Q.setScissorTest(Xt=E)},this.setOpaqueSort=function(E){G=E},this.setTransparentSort=function(E){at=E},this.getClearColor=function(E){return E.copy(Ut.getClearColor())},this.setClearColor=function(){Ut.setClearColor.apply(Ut,arguments)},this.getClearAlpha=function(){return Ut.getClearAlpha()},this.setClearAlpha=function(){Ut.setClearAlpha.apply(Ut,arguments)},this.clear=function(E=!0,I=!0,B=!0){let H=0;if(E){let U=!1;if(w!==null){const ot=w.texture.format;U=ot===Ch||ot===Ah||ot===Th}if(U){const ot=w.texture.type,xt=ot===pi||ot===Rs||ot===or||ot===Ps||ot===wh||ot===Eh,At=Ut.getClearColor(),Pt=Ut.getClearAlpha(),Ft=At.r,Bt=At.g,Lt=At.b;xt?(f[0]=Ft,f[1]=Bt,f[2]=Lt,f[3]=Pt,L.clearBufferuiv(L.COLOR,0,f)):(g[0]=Ft,g[1]=Bt,g[2]=Lt,g[3]=Pt,L.clearBufferiv(L.COLOR,0,g))}else H|=L.COLOR_BUFFER_BIT}I&&(H|=L.DEPTH_BUFFER_BIT,L.clearDepth(this.capabilities.reverseDepthBuffer?0:1)),B&&(H|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),L.clear(H)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",tt,!1),e.removeEventListener("webglcontextrestored",_t,!1),e.removeEventListener("webglcontextcreationerror",bt,!1),gt.dispose(),Jt.dispose(),St.dispose(),M.dispose(),O.dispose(),Y.dispose(),se.dispose(),D.dispose(),Ct.dispose(),V.dispose(),V.removeEventListener("sessionstart",nu),V.removeEventListener("sessionend",iu),ds.stop()};function tt(E){E.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),S=!0}function _t(){console.log("THREE.WebGLRenderer: Context Restored."),S=!1;const E=Tt.autoReset,I=vt.enabled,B=vt.autoUpdate,H=vt.needsUpdate,U=vt.type;pt(),Tt.autoReset=E,vt.enabled=I,vt.autoUpdate=B,vt.needsUpdate=H,vt.type=U}function bt(E){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function ie(E){const I=E.target;I.removeEventListener("dispose",ie),Ie(I)}function Ie(E){mn(E),St.remove(E)}function mn(E){const I=St.get(E).programs;I!==void 0&&(I.forEach(function(B){Ct.releaseProgram(B)}),E.isShaderMaterial&&Ct.releaseShaderCache(E))}this.renderBufferDirect=function(E,I,B,H,U,ot){I===null&&(I=Nt);const xt=U.isMesh&&U.matrixWorld.determinant()<0,At=Wp(E,I,B,H,U);Q.setMaterial(H,xt);let Pt=B.index,Ft=1;if(H.wireframe===!0){if(Pt=it.getWireframeAttribute(B),Pt===void 0)return;Ft=2}const Bt=B.drawRange,Lt=B.attributes.position;let de=Bt.start*Ft,Me=(Bt.start+Bt.count)*Ft;ot!==null&&(de=Math.max(de,ot.start*Ft),Me=Math.min(Me,(ot.start+ot.count)*Ft)),Pt!==null?(de=Math.max(de,0),Me=Math.min(Me,Pt.count)):Lt!=null&&(de=Math.max(de,0),Me=Math.min(Me,Lt.count));const Ae=Me-de;if(Ae<0||Ae===1/0)return;se.setup(U,H,At,B,Pt);let bn,ce=Et;if(Pt!==null&&(bn=Z.get(Pt),ce=ne,ce.setIndex(bn)),U.isMesh)H.wireframe===!0?(Q.setLineWidth(H.wireframeLinewidth*$t()),ce.setMode(L.LINES)):ce.setMode(L.TRIANGLES);else if(U.isLine){let Dt=H.linewidth;Dt===void 0&&(Dt=1),Q.setLineWidth(Dt*$t()),U.isLineSegments?ce.setMode(L.LINES):U.isLineLoop?ce.setMode(L.LINE_LOOP):ce.setMode(L.LINE_STRIP)}else U.isPoints?ce.setMode(L.POINTS):U.isSprite&&ce.setMode(L.TRIANGLES);if(U.isBatchedMesh)if(U._multiDrawInstances!==null)ce.renderMultiDrawInstances(U._multiDrawStarts,U._multiDrawCounts,U._multiDrawCount,U._multiDrawInstances);else if(Zt.get("WEBGL_multi_draw"))ce.renderMultiDraw(U._multiDrawStarts,U._multiDrawCounts,U._multiDrawCount);else{const Dt=U._multiDrawStarts,Ke=U._multiDrawCounts,he=U._multiDrawCount,Gn=Pt?Z.get(Pt).bytesPerElement:1,Ns=St.get(H).currentProgram.getUniforms();for(let Sn=0;Sn<he;Sn++)Ns.setValue(L,"_gl_DrawID",Sn),ce.render(Dt[Sn]/Gn,Ke[Sn])}else if(U.isInstancedMesh)ce.renderInstances(de,Ae,U.count);else if(B.isInstancedBufferGeometry){const Dt=B._maxInstanceCount!==void 0?B._maxInstanceCount:1/0,Ke=Math.min(B.instanceCount,Dt);ce.renderInstances(de,Ae,Ke)}else ce.render(de,Ae)};function oe(E,I,B){E.transparent===!0&&E.side===ci&&E.forceSinglePass===!1?(E.side=fn,E.needsUpdate=!0,gr(E,I,B),E.side=cs,E.needsUpdate=!0,gr(E,I,B),E.side=ci):gr(E,I,B)}this.compile=function(E,I,B=null){B===null&&(B=E),p=Jt.get(B),p.init(I),y.push(p),B.traverseVisible(function(U){U.isLight&&U.layers.test(I.layers)&&(p.pushLight(U),U.castShadow&&p.pushShadow(U))}),E!==B&&E.traverseVisible(function(U){U.isLight&&U.layers.test(I.layers)&&(p.pushLight(U),U.castShadow&&p.pushShadow(U))}),p.setupLights();const H=new Set;return E.traverse(function(U){if(!(U.isMesh||U.isPoints||U.isLine||U.isSprite))return;const ot=U.material;if(ot)if(Array.isArray(ot))for(let xt=0;xt<ot.length;xt++){const At=ot[xt];oe(At,B,U),H.add(At)}else oe(ot,B,U),H.add(ot)}),y.pop(),p=null,H},this.compileAsync=function(E,I,B=null){const H=this.compile(E,I,B);return new Promise(U=>{function ot(){if(H.forEach(function(xt){St.get(xt).currentProgram.isReady()&&H.delete(xt)}),H.size===0){U(E);return}setTimeout(ot,10)}Zt.get("KHR_parallel_shader_compile")!==null?ot():setTimeout(ot,10)})};let gn=null;function xi(E){gn&&gn(E)}function nu(){ds.stop()}function iu(){ds.start()}const ds=new rp;ds.setAnimationLoop(xi),typeof self<"u"&&ds.setContext(self),this.setAnimationLoop=function(E){gn=E,V.setAnimationLoop(E),E===null?ds.stop():ds.start()},V.addEventListener("sessionstart",nu),V.addEventListener("sessionend",iu),this.render=function(E,I){if(I!==void 0&&I.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(S===!0)return;if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),I.parent===null&&I.matrixWorldAutoUpdate===!0&&I.updateMatrixWorld(),V.enabled===!0&&V.isPresenting===!0&&(V.cameraAutoUpdate===!0&&V.updateCamera(I),I=V.getCamera()),E.isScene===!0&&E.onBeforeRender(x,E,I,w),p=Jt.get(E,y.length),p.init(I),y.push(p),dt.multiplyMatrices(I.projectionMatrix,I.matrixWorldInverse),qt.setFromProjectionMatrix(dt),st=this.localClippingEnabled,q=rt.init(this.clippingPlanes,st),_=gt.get(E,m.length),_.init(),m.push(_),V.enabled===!0&&V.isPresenting===!0){const ot=x.xr.getDepthSensingMesh();ot!==null&&qo(ot,I,-1/0,x.sortObjects)}qo(E,I,0,x.sortObjects),_.finish(),x.sortObjects===!0&&_.sort(G,at),ee=V.enabled===!1||V.isPresenting===!1||V.hasDepthSensing()===!1,ee&&Ut.addToRenderList(_,E),this.info.render.frame++,q===!0&&rt.beginShadows();const B=p.state.shadowsArray;vt.render(B,E,I),q===!0&&rt.endShadows(),this.info.autoReset===!0&&this.info.reset();const H=_.opaque,U=_.transmissive;if(p.setupLights(),I.isArrayCamera){const ot=I.cameras;if(U.length>0)for(let xt=0,At=ot.length;xt<At;xt++){const Pt=ot[xt];au(H,U,E,Pt)}ee&&Ut.render(E);for(let xt=0,At=ot.length;xt<At;xt++){const Pt=ot[xt];su(_,E,Pt,Pt.viewport)}}else U.length>0&&au(H,U,E,I),ee&&Ut.render(E),su(_,E,I);w!==null&&(A.updateMultisampleRenderTarget(w),A.updateRenderTargetMipmap(w)),E.isScene===!0&&E.onAfterRender(x,E,I),se.resetDefaultState(),R=-1,k=null,y.pop(),y.length>0?(p=y[y.length-1],q===!0&&rt.setGlobalState(x.clippingPlanes,p.state.camera)):p=null,m.pop(),m.length>0?_=m[m.length-1]:_=null};function qo(E,I,B,H){if(E.visible===!1)return;if(E.layers.test(I.layers)){if(E.isGroup)B=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(I);else if(E.isLight)p.pushLight(E),E.castShadow&&p.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||qt.intersectsSprite(E)){H&&Rt.setFromMatrixPosition(E.matrixWorld).applyMatrix4(dt);const xt=Y.update(E),At=E.material;At.visible&&_.push(E,xt,At,B,Rt.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||qt.intersectsObject(E))){const xt=Y.update(E),At=E.material;if(H&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),Rt.copy(E.boundingSphere.center)):(xt.boundingSphere===null&&xt.computeBoundingSphere(),Rt.copy(xt.boundingSphere.center)),Rt.applyMatrix4(E.matrixWorld).applyMatrix4(dt)),Array.isArray(At)){const Pt=xt.groups;for(let Ft=0,Bt=Pt.length;Ft<Bt;Ft++){const Lt=Pt[Ft],de=At[Lt.materialIndex];de&&de.visible&&_.push(E,xt,de,B,Rt.z,Lt)}}else At.visible&&_.push(E,xt,At,B,Rt.z,null)}}const ot=E.children;for(let xt=0,At=ot.length;xt<At;xt++)qo(ot[xt],I,B,H)}function su(E,I,B,H){const U=E.opaque,ot=E.transmissive,xt=E.transparent;p.setupLightsView(B),q===!0&&rt.setGlobalState(x.clippingPlanes,B),H&&Q.viewport(v.copy(H)),U.length>0&&mr(U,I,B),ot.length>0&&mr(ot,I,B),xt.length>0&&mr(xt,I,B),Q.buffers.depth.setTest(!0),Q.buffers.depth.setMask(!0),Q.buffers.color.setMask(!0),Q.setPolygonOffset(!1)}function au(E,I,B,H){if((B.isScene===!0?B.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[H.id]===void 0&&(p.state.transmissionRenderTarget[H.id]=new ei(1,1,{generateMipmaps:!0,type:Zt.has("EXT_color_buffer_half_float")||Zt.has("EXT_color_buffer_float")?Fi:pi,minFilter:Ss,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:le.workingColorSpace}));const ot=p.state.transmissionRenderTarget[H.id],xt=H.viewport||v;ot.setSize(xt.z,xt.w);const At=x.getRenderTarget();x.setRenderTarget(ot),x.getClearColor(F),$=x.getClearAlpha(),$<1&&x.setClearColor(16777215,.5),x.clear(),ee&&Ut.render(B);const Pt=x.toneMapping;x.toneMapping=os;const Ft=H.viewport;if(H.viewport!==void 0&&(H.viewport=void 0),p.setupLightsView(H),q===!0&&rt.setGlobalState(x.clippingPlanes,H),mr(E,B,H),A.updateMultisampleRenderTarget(ot),A.updateRenderTargetMipmap(ot),Zt.has("WEBGL_multisampled_render_to_texture")===!1){let Bt=!1;for(let Lt=0,de=I.length;Lt<de;Lt++){const Me=I[Lt],Ae=Me.object,bn=Me.geometry,ce=Me.material,Dt=Me.group;if(ce.side===ci&&Ae.layers.test(H.layers)){const Ke=ce.side;ce.side=fn,ce.needsUpdate=!0,ru(Ae,B,H,bn,ce,Dt),ce.side=Ke,ce.needsUpdate=!0,Bt=!0}}Bt===!0&&(A.updateMultisampleRenderTarget(ot),A.updateRenderTargetMipmap(ot))}x.setRenderTarget(At),x.setClearColor(F,$),Ft!==void 0&&(H.viewport=Ft),x.toneMapping=Pt}function mr(E,I,B){const H=I.isScene===!0?I.overrideMaterial:null;for(let U=0,ot=E.length;U<ot;U++){const xt=E[U],At=xt.object,Pt=xt.geometry,Ft=H===null?xt.material:H,Bt=xt.group;At.layers.test(B.layers)&&ru(At,I,B,Pt,Ft,Bt)}}function ru(E,I,B,H,U,ot){E.onBeforeRender(x,I,B,H,U,ot),E.modelViewMatrix.multiplyMatrices(B.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),U.onBeforeRender(x,I,B,H,E,ot),U.transparent===!0&&U.side===ci&&U.forceSinglePass===!1?(U.side=fn,U.needsUpdate=!0,x.renderBufferDirect(B,I,H,U,E,ot),U.side=cs,U.needsUpdate=!0,x.renderBufferDirect(B,I,H,U,E,ot),U.side=ci):x.renderBufferDirect(B,I,H,U,E,ot),E.onAfterRender(x,I,B,H,U,ot)}function gr(E,I,B){I.isScene!==!0&&(I=Nt);const H=St.get(E),U=p.state.lights,ot=p.state.shadowsArray,xt=U.state.version,At=Ct.getParameters(E,U.state,ot,I,B),Pt=Ct.getProgramCacheKey(At);let Ft=H.programs;H.environment=E.isMeshStandardMaterial?I.environment:null,H.fog=I.fog,H.envMap=(E.isMeshStandardMaterial?O:M).get(E.envMap||H.environment),H.envMapRotation=H.environment!==null&&E.envMap===null?I.environmentRotation:E.envMapRotation,Ft===void 0&&(E.addEventListener("dispose",ie),Ft=new Map,H.programs=Ft);let Bt=Ft.get(Pt);if(Bt!==void 0){if(H.currentProgram===Bt&&H.lightsStateVersion===xt)return lu(E,At),Bt}else At.uniforms=Ct.getUniforms(E),E.onBeforeCompile(At,x),Bt=Ct.acquireProgram(At,Pt),Ft.set(Pt,Bt),H.uniforms=At.uniforms;const Lt=H.uniforms;return(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(Lt.clippingPlanes=rt.uniform),lu(E,At),H.needsLights=qp(E),H.lightsStateVersion=xt,H.needsLights&&(Lt.ambientLightColor.value=U.state.ambient,Lt.lightProbe.value=U.state.probe,Lt.directionalLights.value=U.state.directional,Lt.directionalLightShadows.value=U.state.directionalShadow,Lt.spotLights.value=U.state.spot,Lt.spotLightShadows.value=U.state.spotShadow,Lt.rectAreaLights.value=U.state.rectArea,Lt.ltc_1.value=U.state.rectAreaLTC1,Lt.ltc_2.value=U.state.rectAreaLTC2,Lt.pointLights.value=U.state.point,Lt.pointLightShadows.value=U.state.pointShadow,Lt.hemisphereLights.value=U.state.hemi,Lt.directionalShadowMap.value=U.state.directionalShadowMap,Lt.directionalShadowMatrix.value=U.state.directionalShadowMatrix,Lt.spotShadowMap.value=U.state.spotShadowMap,Lt.spotLightMatrix.value=U.state.spotLightMatrix,Lt.spotLightMap.value=U.state.spotLightMap,Lt.pointShadowMap.value=U.state.pointShadowMap,Lt.pointShadowMatrix.value=U.state.pointShadowMatrix),H.currentProgram=Bt,H.uniformsList=null,Bt}function ou(E){if(E.uniformsList===null){const I=E.currentProgram.getUniforms();E.uniformsList=uo.seqWithValue(I.seq,E.uniforms)}return E.uniformsList}function lu(E,I){const B=St.get(E);B.outputColorSpace=I.outputColorSpace,B.batching=I.batching,B.batchingColor=I.batchingColor,B.instancing=I.instancing,B.instancingColor=I.instancingColor,B.instancingMorph=I.instancingMorph,B.skinning=I.skinning,B.morphTargets=I.morphTargets,B.morphNormals=I.morphNormals,B.morphColors=I.morphColors,B.morphTargetsCount=I.morphTargetsCount,B.numClippingPlanes=I.numClippingPlanes,B.numIntersection=I.numClipIntersection,B.vertexAlphas=I.vertexAlphas,B.vertexTangents=I.vertexTangents,B.toneMapping=I.toneMapping}function Wp(E,I,B,H,U){I.isScene!==!0&&(I=Nt),A.resetTextureUnits();const ot=I.fog,xt=H.isMeshStandardMaterial?I.environment:null,At=w===null?x.outputColorSpace:w.isXRRenderTarget===!0?w.texture.colorSpace:us,Pt=(H.isMeshStandardMaterial?O:M).get(H.envMap||xt),Ft=H.vertexColors===!0&&!!B.attributes.color&&B.attributes.color.itemSize===4,Bt=!!B.attributes.tangent&&(!!H.normalMap||H.anisotropy>0),Lt=!!B.morphAttributes.position,de=!!B.morphAttributes.normal,Me=!!B.morphAttributes.color;let Ae=os;H.toneMapped&&(w===null||w.isXRRenderTarget===!0)&&(Ae=x.toneMapping);const bn=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,ce=bn!==void 0?bn.length:0,Dt=St.get(H),Ke=p.state.lights;if(q===!0&&(st===!0||E!==k)){const In=E===k&&H.id===R;rt.setState(H,E,In)}let he=!1;H.version===Dt.__version?(Dt.needsLights&&Dt.lightsStateVersion!==Ke.state.version||Dt.outputColorSpace!==At||U.isBatchedMesh&&Dt.batching===!1||!U.isBatchedMesh&&Dt.batching===!0||U.isBatchedMesh&&Dt.batchingColor===!0&&U.colorTexture===null||U.isBatchedMesh&&Dt.batchingColor===!1&&U.colorTexture!==null||U.isInstancedMesh&&Dt.instancing===!1||!U.isInstancedMesh&&Dt.instancing===!0||U.isSkinnedMesh&&Dt.skinning===!1||!U.isSkinnedMesh&&Dt.skinning===!0||U.isInstancedMesh&&Dt.instancingColor===!0&&U.instanceColor===null||U.isInstancedMesh&&Dt.instancingColor===!1&&U.instanceColor!==null||U.isInstancedMesh&&Dt.instancingMorph===!0&&U.morphTexture===null||U.isInstancedMesh&&Dt.instancingMorph===!1&&U.morphTexture!==null||Dt.envMap!==Pt||H.fog===!0&&Dt.fog!==ot||Dt.numClippingPlanes!==void 0&&(Dt.numClippingPlanes!==rt.numPlanes||Dt.numIntersection!==rt.numIntersection)||Dt.vertexAlphas!==Ft||Dt.vertexTangents!==Bt||Dt.morphTargets!==Lt||Dt.morphNormals!==de||Dt.morphColors!==Me||Dt.toneMapping!==Ae||Dt.morphTargetsCount!==ce)&&(he=!0):(he=!0,Dt.__version=H.version);let Gn=Dt.currentProgram;he===!0&&(Gn=gr(H,I,U));let Ns=!1,Sn=!1,jo=!1;const Pe=Gn.getUniforms(),Vi=Dt.uniforms;if(Q.useProgram(Gn.program)&&(Ns=!0,Sn=!0,jo=!0),H.id!==R&&(R=H.id,Sn=!0),Ns||k!==E){j.reverseDepthBuffer?(Mt.copy(E.projectionMatrix),og(Mt),lg(Mt),Pe.setValue(L,"projectionMatrix",Mt)):Pe.setValue(L,"projectionMatrix",E.projectionMatrix),Pe.setValue(L,"viewMatrix",E.matrixWorldInverse);const In=Pe.map.cameraPosition;In!==void 0&&In.setValue(L,It.setFromMatrixPosition(E.matrixWorld)),j.logarithmicDepthBuffer&&Pe.setValue(L,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(H.isMeshPhongMaterial||H.isMeshToonMaterial||H.isMeshLambertMaterial||H.isMeshBasicMaterial||H.isMeshStandardMaterial||H.isShaderMaterial)&&Pe.setValue(L,"isOrthographic",E.isOrthographicCamera===!0),k!==E&&(k=E,Sn=!0,jo=!0)}if(U.isSkinnedMesh){Pe.setOptional(L,U,"bindMatrix"),Pe.setOptional(L,U,"bindMatrixInverse");const In=U.skeleton;In&&(In.boneTexture===null&&In.computeBoneTexture(),Pe.setValue(L,"boneTexture",In.boneTexture,A))}U.isBatchedMesh&&(Pe.setOptional(L,U,"batchingTexture"),Pe.setValue(L,"batchingTexture",U._matricesTexture,A),Pe.setOptional(L,U,"batchingIdTexture"),Pe.setValue(L,"batchingIdTexture",U._indirectTexture,A),Pe.setOptional(L,U,"batchingColorTexture"),U._colorsTexture!==null&&Pe.setValue(L,"batchingColorTexture",U._colorsTexture,A));const Yo=B.morphAttributes;if((Yo.position!==void 0||Yo.normal!==void 0||Yo.color!==void 0)&&Ot.update(U,B,Gn),(Sn||Dt.receiveShadow!==U.receiveShadow)&&(Dt.receiveShadow=U.receiveShadow,Pe.setValue(L,"receiveShadow",U.receiveShadow)),H.isMeshGouraudMaterial&&H.envMap!==null&&(Vi.envMap.value=Pt,Vi.flipEnvMap.value=Pt.isCubeTexture&&Pt.isRenderTargetTexture===!1?-1:1),H.isMeshStandardMaterial&&H.envMap===null&&I.environment!==null&&(Vi.envMapIntensity.value=I.environmentIntensity),Sn&&(Pe.setValue(L,"toneMappingExposure",x.toneMappingExposure),Dt.needsLights&&Xp(Vi,jo),ot&&H.fog===!0&&ut.refreshFogUniforms(Vi,ot),ut.refreshMaterialUniforms(Vi,H,nt,z,p.state.transmissionRenderTarget[E.id]),uo.upload(L,ou(Dt),Vi,A)),H.isShaderMaterial&&H.uniformsNeedUpdate===!0&&(uo.upload(L,ou(Dt),Vi,A),H.uniformsNeedUpdate=!1),H.isSpriteMaterial&&Pe.setValue(L,"center",U.center),Pe.setValue(L,"modelViewMatrix",U.modelViewMatrix),Pe.setValue(L,"normalMatrix",U.normalMatrix),Pe.setValue(L,"modelMatrix",U.matrixWorld),H.isShaderMaterial||H.isRawShaderMaterial){const In=H.uniformsGroups;for(let Ko=0,jp=In.length;Ko<jp;Ko++){const cu=In[Ko];D.update(cu,Gn),D.bind(cu,Gn)}}return Gn}function Xp(E,I){E.ambientLightColor.needsUpdate=I,E.lightProbe.needsUpdate=I,E.directionalLights.needsUpdate=I,E.directionalLightShadows.needsUpdate=I,E.pointLights.needsUpdate=I,E.pointLightShadows.needsUpdate=I,E.spotLights.needsUpdate=I,E.spotLightShadows.needsUpdate=I,E.rectAreaLights.needsUpdate=I,E.hemisphereLights.needsUpdate=I}function qp(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.getActiveCubeFace=function(){return P},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(E,I,B){St.get(E.texture).__webglTexture=I,St.get(E.depthTexture).__webglTexture=B;const H=St.get(E);H.__hasExternalTextures=!0,H.__autoAllocateDepthBuffer=B===void 0,H.__autoAllocateDepthBuffer||Zt.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),H.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(E,I){const B=St.get(E);B.__webglFramebuffer=I,B.__useDefaultFramebuffer=I===void 0},this.setRenderTarget=function(E,I=0,B=0){w=E,P=I,T=B;let H=!0,U=null,ot=!1,xt=!1;if(E){const Pt=St.get(E);if(Pt.__useDefaultFramebuffer!==void 0)Q.bindFramebuffer(L.FRAMEBUFFER,null),H=!1;else if(Pt.__webglFramebuffer===void 0)A.setupRenderTarget(E);else if(Pt.__hasExternalTextures)A.rebindTextures(E,St.get(E.texture).__webglTexture,St.get(E.depthTexture).__webglTexture);else if(E.depthBuffer){const Lt=E.depthTexture;if(Pt.__boundDepthTexture!==Lt){if(Lt!==null&&St.has(Lt)&&(E.width!==Lt.image.width||E.height!==Lt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");A.setupDepthRenderbuffer(E)}}const Ft=E.texture;(Ft.isData3DTexture||Ft.isDataArrayTexture||Ft.isCompressedArrayTexture)&&(xt=!0);const Bt=St.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Array.isArray(Bt[I])?U=Bt[I][B]:U=Bt[I],ot=!0):E.samples>0&&A.useMultisampledRTT(E)===!1?U=St.get(E).__webglMultisampledFramebuffer:Array.isArray(Bt)?U=Bt[B]:U=Bt,v.copy(E.viewport),b.copy(E.scissor),N=E.scissorTest}else v.copy(ht).multiplyScalar(nt).floor(),b.copy(mt).multiplyScalar(nt).floor(),N=Xt;if(Q.bindFramebuffer(L.FRAMEBUFFER,U)&&H&&Q.drawBuffers(E,U),Q.viewport(v),Q.scissor(b),Q.setScissorTest(N),ot){const Pt=St.get(E.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+I,Pt.__webglTexture,B)}else if(xt){const Pt=St.get(E.texture),Ft=I||0;L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,Pt.__webglTexture,B||0,Ft)}R=-1},this.readRenderTargetPixels=function(E,I,B,H,U,ot,xt){if(!(E&&E.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let At=St.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&xt!==void 0&&(At=At[xt]),At){Q.bindFramebuffer(L.FRAMEBUFFER,At);try{const Pt=E.texture,Ft=Pt.format,Bt=Pt.type;if(!j.textureFormatReadable(Ft)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!j.textureTypeReadable(Bt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}I>=0&&I<=E.width-H&&B>=0&&B<=E.height-U&&L.readPixels(I,B,H,U,Vt.convert(Ft),Vt.convert(Bt),ot)}finally{const Pt=w!==null?St.get(w).__webglFramebuffer:null;Q.bindFramebuffer(L.FRAMEBUFFER,Pt)}}},this.readRenderTargetPixelsAsync=async function(E,I,B,H,U,ot,xt){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let At=St.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&xt!==void 0&&(At=At[xt]),At){const Pt=E.texture,Ft=Pt.format,Bt=Pt.type;if(!j.textureFormatReadable(Ft))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!j.textureTypeReadable(Bt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(I>=0&&I<=E.width-H&&B>=0&&B<=E.height-U){Q.bindFramebuffer(L.FRAMEBUFFER,At);const Lt=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,Lt),L.bufferData(L.PIXEL_PACK_BUFFER,ot.byteLength,L.STREAM_READ),L.readPixels(I,B,H,U,Vt.convert(Ft),Vt.convert(Bt),0);const de=w!==null?St.get(w).__webglFramebuffer:null;Q.bindFramebuffer(L.FRAMEBUFFER,de);const Me=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await rg(L,Me,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,Lt),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,ot),L.deleteBuffer(Lt),L.deleteSync(Me),ot}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(E,I=null,B=0){E.isTexture!==!0&&(ho("WebGLRenderer: copyFramebufferToTexture function signature has changed."),I=arguments[0]||null,E=arguments[1]);const H=Math.pow(2,-B),U=Math.floor(E.image.width*H),ot=Math.floor(E.image.height*H),xt=I!==null?I.x:0,At=I!==null?I.y:0;A.setTexture2D(E,0),L.copyTexSubImage2D(L.TEXTURE_2D,B,0,0,xt,At,U,ot),Q.unbindTexture()},this.copyTextureToTexture=function(E,I,B=null,H=null,U=0){E.isTexture!==!0&&(ho("WebGLRenderer: copyTextureToTexture function signature has changed."),H=arguments[0]||null,E=arguments[1],I=arguments[2],U=arguments[3]||0,B=null);let ot,xt,At,Pt,Ft,Bt;B!==null?(ot=B.max.x-B.min.x,xt=B.max.y-B.min.y,At=B.min.x,Pt=B.min.y):(ot=E.image.width,xt=E.image.height,At=0,Pt=0),H!==null?(Ft=H.x,Bt=H.y):(Ft=0,Bt=0);const Lt=Vt.convert(I.format),de=Vt.convert(I.type);A.setTexture2D(I,0),L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,I.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,I.unpackAlignment);const Me=L.getParameter(L.UNPACK_ROW_LENGTH),Ae=L.getParameter(L.UNPACK_IMAGE_HEIGHT),bn=L.getParameter(L.UNPACK_SKIP_PIXELS),ce=L.getParameter(L.UNPACK_SKIP_ROWS),Dt=L.getParameter(L.UNPACK_SKIP_IMAGES),Ke=E.isCompressedTexture?E.mipmaps[U]:E.image;L.pixelStorei(L.UNPACK_ROW_LENGTH,Ke.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Ke.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,At),L.pixelStorei(L.UNPACK_SKIP_ROWS,Pt),E.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,U,Ft,Bt,ot,xt,Lt,de,Ke.data):E.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,U,Ft,Bt,Ke.width,Ke.height,Lt,Ke.data):L.texSubImage2D(L.TEXTURE_2D,U,Ft,Bt,ot,xt,Lt,de,Ke),L.pixelStorei(L.UNPACK_ROW_LENGTH,Me),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Ae),L.pixelStorei(L.UNPACK_SKIP_PIXELS,bn),L.pixelStorei(L.UNPACK_SKIP_ROWS,ce),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Dt),U===0&&I.generateMipmaps&&L.generateMipmap(L.TEXTURE_2D),Q.unbindTexture()},this.copyTextureToTexture3D=function(E,I,B=null,H=null,U=0){E.isTexture!==!0&&(ho("WebGLRenderer: copyTextureToTexture3D function signature has changed."),B=arguments[0]||null,H=arguments[1]||null,E=arguments[2],I=arguments[3],U=arguments[4]||0);let ot,xt,At,Pt,Ft,Bt,Lt,de,Me;const Ae=E.isCompressedTexture?E.mipmaps[U]:E.image;B!==null?(ot=B.max.x-B.min.x,xt=B.max.y-B.min.y,At=B.max.z-B.min.z,Pt=B.min.x,Ft=B.min.y,Bt=B.min.z):(ot=Ae.width,xt=Ae.height,At=Ae.depth,Pt=0,Ft=0,Bt=0),H!==null?(Lt=H.x,de=H.y,Me=H.z):(Lt=0,de=0,Me=0);const bn=Vt.convert(I.format),ce=Vt.convert(I.type);let Dt;if(I.isData3DTexture)A.setTexture3D(I,0),Dt=L.TEXTURE_3D;else if(I.isDataArrayTexture||I.isCompressedArrayTexture)A.setTexture2DArray(I,0),Dt=L.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}L.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,I.flipY),L.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,I.premultiplyAlpha),L.pixelStorei(L.UNPACK_ALIGNMENT,I.unpackAlignment);const Ke=L.getParameter(L.UNPACK_ROW_LENGTH),he=L.getParameter(L.UNPACK_IMAGE_HEIGHT),Gn=L.getParameter(L.UNPACK_SKIP_PIXELS),Ns=L.getParameter(L.UNPACK_SKIP_ROWS),Sn=L.getParameter(L.UNPACK_SKIP_IMAGES);L.pixelStorei(L.UNPACK_ROW_LENGTH,Ae.width),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Ae.height),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Pt),L.pixelStorei(L.UNPACK_SKIP_ROWS,Ft),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Bt),E.isDataTexture||E.isData3DTexture?L.texSubImage3D(Dt,U,Lt,de,Me,ot,xt,At,bn,ce,Ae.data):I.isCompressedArrayTexture?L.compressedTexSubImage3D(Dt,U,Lt,de,Me,ot,xt,At,bn,Ae.data):L.texSubImage3D(Dt,U,Lt,de,Me,ot,xt,At,bn,ce,Ae),L.pixelStorei(L.UNPACK_ROW_LENGTH,Ke),L.pixelStorei(L.UNPACK_IMAGE_HEIGHT,he),L.pixelStorei(L.UNPACK_SKIP_PIXELS,Gn),L.pixelStorei(L.UNPACK_SKIP_ROWS,Ns),L.pixelStorei(L.UNPACK_SKIP_IMAGES,Sn),U===0&&I.generateMipmaps&&L.generateMipmap(Dt),Q.unbindTexture()},this.initRenderTarget=function(E){St.get(E).__webglFramebuffer===void 0&&A.setupRenderTarget(E)},this.initTexture=function(E){E.isCubeTexture?A.setTextureCube(E,0):E.isData3DTexture?A.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?A.setTexture2DArray(E,0):A.setTexture2D(E,0),Q.unbindTexture()},this.resetState=function(){P=0,T=0,w=null,Q.reset(),se.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Di}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=t===Ph?"display-p3":"srgb",e.unpackColorSpace=le.workingColorSpace===Ho?"display-p3":"srgb"}}class up extends en{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new mi,this.environmentIntensity=1,this.environmentRotation=new mi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class dp extends on{constructor(t=null,e=1,n=1,s,a,r,o,l,c=rn,h=rn,u,d){super(null,r,o,l,c,h,s,a,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Hi extends on{constructor(t,e,n,s,a,r,o,l,c){super(t,e,n,s,a,r,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class _i{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,s=this.getPoint(0),a=0;e.push(0);for(let r=1;r<=t;r++)n=this.getPoint(r/t),a+=n.distanceTo(s),e.push(a),s=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const n=this.getLengths();let s=0;const a=n.length;let r;e?r=e:r=t*n[a-1];let o=0,l=a-1,c;for(;o<=l;)if(s=Math.floor(o+(l-o)/2),c=n[s]-r,c<0)o=s+1;else if(c>0)l=s-1;else{l=s;break}if(s=l,n[s]===r)return s/(a-1);const h=n[s],d=n[s+1]-h,f=(r-h)/d;return(s+f)/(a-1)}getTangent(t,e){let s=t-1e-4,a=t+1e-4;s<0&&(s=0),a>1&&(a=1);const r=this.getPoint(s),o=this.getPoint(a),l=e||(r.isVector2?new lt:new C);return l.copy(o).sub(r).normalize(),l}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new C,s=[],a=[],r=[],o=new C,l=new fe;for(let f=0;f<=t;f++){const g=f/t;s[f]=this.getTangentAt(g,new C)}a[0]=new C,r[0]=new C;let c=Number.MAX_VALUE;const h=Math.abs(s[0].x),u=Math.abs(s[0].y),d=Math.abs(s[0].z);h<=c&&(c=h,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(s[0],n).normalize(),a[0].crossVectors(s[0],o),r[0].crossVectors(s[0],a[0]);for(let f=1;f<=t;f++){if(a[f]=a[f-1].clone(),r[f]=r[f-1].clone(),o.crossVectors(s[f-1],s[f]),o.length()>Number.EPSILON){o.normalize();const g=Math.acos(He(s[f-1].dot(s[f]),-1,1));a[f].applyMatrix4(l.makeRotationAxis(o,g))}r[f].crossVectors(s[f],a[f])}if(e===!0){let f=Math.acos(He(a[0].dot(a[t]),-1,1));f/=t,s[0].dot(o.crossVectors(a[0],a[t]))>0&&(f=-f);for(let g=1;g<=t;g++)a[g].applyMatrix4(l.makeRotationAxis(s[g],f*g)),r[g].crossVectors(s[g],a[g])}return{tangents:s,normals:a,binormals:r}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class zh extends _i{constructor(t=0,e=0,n=1,s=1,a=0,r=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=s,this.aStartAngle=a,this.aEndAngle=r,this.aClockwise=o,this.aRotation=l}getPoint(t,e=new lt){const n=e,s=Math.PI*2;let a=this.aEndAngle-this.aStartAngle;const r=Math.abs(a)<Number.EPSILON;for(;a<0;)a+=s;for(;a>s;)a-=s;a<Number.EPSILON&&(r?a=0:a=s),this.aClockwise===!0&&!r&&(a===s?a=-s:a=a-s);const o=this.aStartAngle+t*a;let l=this.aX+this.xRadius*Math.cos(o),c=this.aY+this.yRadius*Math.sin(o);if(this.aRotation!==0){const h=Math.cos(this.aRotation),u=Math.sin(this.aRotation),d=l-this.aX,f=c-this.aY;l=d*h-f*u+this.aX,c=d*u+f*h+this.aY}return n.set(l,c)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}class _1 extends zh{constructor(t,e,n,s,a,r){super(t,e,n,n,s,a,r),this.isArcCurve=!0,this.type="ArcCurve"}}function Bh(){let i=0,t=0,e=0,n=0;function s(a,r,o,l){i=a,t=o,e=-3*a+3*r-2*o-l,n=2*a-2*r+o+l}return{initCatmullRom:function(a,r,o,l,c){s(r,o,c*(o-a),c*(l-r))},initNonuniformCatmullRom:function(a,r,o,l,c,h,u){let d=(r-a)/c-(o-a)/(c+h)+(o-r)/h,f=(o-r)/h-(l-r)/(h+u)+(l-o)/u;d*=h,f*=h,s(r,o,d,f)},calc:function(a){const r=a*a,o=r*a;return i+t*a+e*r+n*o}}}const zr=new C,kl=new Bh,Nl=new Bh,Ul=new Bh;class x1 extends _i{constructor(t=[],e=!1,n="centripetal",s=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=s}getPoint(t,e=new C){const n=e,s=this.points,a=s.length,r=(a-(this.closed?0:1))*t;let o=Math.floor(r),l=r-o;this.closed?o+=o>0?0:(Math.floor(Math.abs(o)/a)+1)*a:l===0&&o===a-1&&(o=a-2,l=1);let c,h;this.closed||o>0?c=s[(o-1)%a]:(zr.subVectors(s[0],s[1]).add(s[0]),c=zr);const u=s[o%a],d=s[(o+1)%a];if(this.closed||o+2<a?h=s[(o+2)%a]:(zr.subVectors(s[a-1],s[a-2]).add(s[a-1]),h=zr),this.curveType==="centripetal"||this.curveType==="chordal"){const f=this.curveType==="chordal"?.5:.25;let g=Math.pow(c.distanceToSquared(u),f),_=Math.pow(u.distanceToSquared(d),f),p=Math.pow(d.distanceToSquared(h),f);_<1e-4&&(_=1),g<1e-4&&(g=_),p<1e-4&&(p=_),kl.initNonuniformCatmullRom(c.x,u.x,d.x,h.x,g,_,p),Nl.initNonuniformCatmullRom(c.y,u.y,d.y,h.y,g,_,p),Ul.initNonuniformCatmullRom(c.z,u.z,d.z,h.z,g,_,p)}else this.curveType==="catmullrom"&&(kl.initCatmullRom(c.x,u.x,d.x,h.x,this.tension),Nl.initCatmullRom(c.y,u.y,d.y,h.y,this.tension),Ul.initCatmullRom(c.z,u.z,d.z,h.z,this.tension));return n.set(kl.calc(l),Nl.calc(l),Ul.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const s=t.points[e];this.points.push(s.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const s=this.points[e];t.points.push(s.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const s=t.points[e];this.points.push(new C().fromArray(s))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}}function xd(i,t,e,n,s){const a=(n-t)*.5,r=(s-e)*.5,o=i*i,l=i*o;return(2*e-2*n+a+r)*l+(-3*e+3*n-2*a-r)*o+a*i+e}function y1(i,t){const e=1-i;return e*e*t}function M1(i,t){return 2*(1-i)*i*t}function b1(i,t){return i*i*t}function er(i,t,e,n){return y1(i,t)+M1(i,e)+b1(i,n)}function S1(i,t){const e=1-i;return e*e*e*t}function w1(i,t){const e=1-i;return 3*e*e*i*t}function E1(i,t){return 3*(1-i)*i*i*t}function T1(i,t){return i*i*i*t}function nr(i,t,e,n,s){return S1(i,t)+w1(i,e)+E1(i,n)+T1(i,s)}class fp extends _i{constructor(t=new lt,e=new lt,n=new lt,s=new lt){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=s}getPoint(t,e=new lt){const n=e,s=this.v0,a=this.v1,r=this.v2,o=this.v3;return n.set(nr(t,s.x,a.x,r.x,o.x),nr(t,s.y,a.y,r.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class A1 extends _i{constructor(t=new C,e=new C,n=new C,s=new C){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=s}getPoint(t,e=new C){const n=e,s=this.v0,a=this.v1,r=this.v2,o=this.v3;return n.set(nr(t,s.x,a.x,r.x,o.x),nr(t,s.y,a.y,r.y,o.y),nr(t,s.z,a.z,r.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class pp extends _i{constructor(t=new lt,e=new lt){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new lt){const n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new lt){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class C1 extends _i{constructor(t=new C,e=new C){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new C){const n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new C){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class mp extends _i{constructor(t=new lt,e=new lt,n=new lt){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new lt){const n=e,s=this.v0,a=this.v1,r=this.v2;return n.set(er(t,s.x,a.x,r.x),er(t,s.y,a.y,r.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class R1 extends _i{constructor(t=new C,e=new C,n=new C){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new C){const n=e,s=this.v0,a=this.v1,r=this.v2;return n.set(er(t,s.x,a.x,r.x),er(t,s.y,a.y,r.y),er(t,s.z,a.z,r.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class gp extends _i{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new lt){const n=e,s=this.points,a=(s.length-1)*t,r=Math.floor(a),o=a-r,l=s[r===0?r:r-1],c=s[r],h=s[r>s.length-2?s.length-1:r+1],u=s[r>s.length-3?s.length-1:r+2];return n.set(xd(o,l.x,c.x,h.x,u.x),xd(o,l.y,c.y,h.y,u.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const s=t.points[e];this.points.push(s.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const s=this.points[e];t.points.push(s.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const s=t.points[e];this.points.push(new lt().fromArray(s))}return this}}var yd=Object.freeze({__proto__:null,ArcCurve:_1,CatmullRomCurve3:x1,CubicBezierCurve:fp,CubicBezierCurve3:A1,EllipseCurve:zh,LineCurve:pp,LineCurve3:C1,QuadraticBezierCurve:mp,QuadraticBezierCurve3:R1,SplineCurve:gp});class P1 extends _i{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){const n=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new yd[n](e,t))}return this}getPoint(t,e){const n=t*this.getLength(),s=this.getCurveLengths();let a=0;for(;a<s.length;){if(s[a]>=n){const r=s[a]-n,o=this.curves[a],l=o.getLength(),c=l===0?0:1-r/l;return o.getPointAt(c,e)}a++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,s=this.curves.length;n<s;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let n;for(let s=0,a=this.curves;s<a.length;s++){const r=a[s],o=r.isEllipseCurve?t*2:r.isLineCurve||r.isLineCurve3?1:r.isSplineCurve?t*r.points.length:t,l=r.getPoints(o);for(let c=0;c<l.length;c++){const h=l[c];n&&n.equals(h)||(e.push(h),n=h)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const s=t.curves[e];this.curves.push(s.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){const s=this.curves[e];t.curves.push(s.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const s=t.curves[e];this.curves.push(new yd[s.type]().fromJSON(s))}return this}}class L1 extends P1{constructor(t){super(),this.type="Path",this.currentPoint=new lt,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const n=new pp(this.currentPoint.clone(),new lt(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,s){const a=new mp(this.currentPoint.clone(),new lt(t,e),new lt(n,s));return this.curves.push(a),this.currentPoint.set(n,s),this}bezierCurveTo(t,e,n,s,a,r){const o=new fp(this.currentPoint.clone(),new lt(t,e),new lt(n,s),new lt(a,r));return this.curves.push(o),this.currentPoint.set(a,r),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),n=new gp(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,s,a,r){const o=this.currentPoint.x,l=this.currentPoint.y;return this.absarc(t+o,e+l,n,s,a,r),this}absarc(t,e,n,s,a,r){return this.absellipse(t,e,n,n,s,a,r),this}ellipse(t,e,n,s,a,r,o,l){const c=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(t+c,e+h,n,s,a,r,o,l),this}absellipse(t,e,n,s,a,r,o,l){const c=new zh(t,e,n,s,a,r,o,l);if(this.curves.length>0){const u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class Go extends pn{constructor(t=[new lt(0,-.5),new lt(.5,0),new lt(0,.5)],e=12,n=0,s=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:s},e=Math.floor(e),s=He(s,0,Math.PI*2);const a=[],r=[],o=[],l=[],c=[],h=1/e,u=new C,d=new lt,f=new C,g=new C,_=new C;let p=0,m=0;for(let y=0;y<=t.length-1;y++)switch(y){case 0:p=t[y+1].x-t[y].x,m=t[y+1].y-t[y].y,f.x=m*1,f.y=-p,f.z=m*0,_.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(_.x,_.y,_.z);break;default:p=t[y+1].x-t[y].x,m=t[y+1].y-t[y].y,f.x=m*1,f.y=-p,f.z=m*0,g.copy(f),f.x+=_.x,f.y+=_.y,f.z+=_.z,f.normalize(),l.push(f.x,f.y,f.z),_.copy(g)}for(let y=0;y<=e;y++){const x=n+y*h*s,S=Math.sin(x),P=Math.cos(x);for(let T=0;T<=t.length-1;T++){u.x=t[T].x*S,u.y=t[T].y,u.z=t[T].x*P,r.push(u.x,u.y,u.z),d.x=y/e,d.y=T/(t.length-1),o.push(d.x,d.y);const w=l[3*T+0]*S,R=l[3*T+1],k=l[3*T+0]*P;c.push(w,R,k)}}for(let y=0;y<e;y++)for(let x=0;x<t.length-1;x++){const S=x+y*t.length,P=S,T=S+t.length,w=S+t.length+1,R=S+1;a.push(P,T,R),a.push(w,R,T)}this.setIndex(a),this.setAttribute("position",new ue(r,3)),this.setAttribute("uv",new ue(o,2)),this.setAttribute("normal",new ue(c,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Go(t.points,t.segments,t.phiStart,t.phiLength)}}class Hh extends Go{constructor(t=1,e=1,n=4,s=8){const a=new L1;a.absarc(0,-e/2,t,Math.PI*1.5,0),a.absarc(0,e/2,t,0,Math.PI*.5),super(a.getPoints(n),s),this.type="CapsuleGeometry",this.parameters={radius:t,length:e,capSegments:n,radialSegments:s}}static fromJSON(t){return new Hh(t.radius,t.length,t.capSegments,t.radialSegments)}}class gi extends pn{constructor(t=1,e=32,n=0,s=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:s},e=Math.max(3,e);const a=[],r=[],o=[],l=[],c=new C,h=new lt;r.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let u=0,d=3;u<=e;u++,d+=3){const f=n+u/e*s;c.x=t*Math.cos(f),c.y=t*Math.sin(f),r.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(r[d]/t+1)/2,h.y=(r[d+1]/t+1)/2,l.push(h.x,h.y)}for(let u=1;u<=e;u++)a.push(u,u+1,0);this.setIndex(a),this.setAttribute("position",new ue(r,3)),this.setAttribute("normal",new ue(o,3)),this.setAttribute("uv",new ue(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new gi(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Hn extends pn{constructor(t=1,e=1,n=1,s=32,a=1,r=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:s,heightSegments:a,openEnded:r,thetaStart:o,thetaLength:l};const c=this;s=Math.floor(s),a=Math.floor(a);const h=[],u=[],d=[],f=[];let g=0;const _=[],p=n/2;let m=0;y(),r===!1&&(t>0&&x(!0),e>0&&x(!1)),this.setIndex(h),this.setAttribute("position",new ue(u,3)),this.setAttribute("normal",new ue(d,3)),this.setAttribute("uv",new ue(f,2));function y(){const S=new C,P=new C;let T=0;const w=(e-t)/n;for(let R=0;R<=a;R++){const k=[],v=R/a,b=v*(e-t)+t;for(let N=0;N<=s;N++){const F=N/s,$=F*l+o,W=Math.sin($),z=Math.cos($);P.x=b*W,P.y=-v*n+p,P.z=b*z,u.push(P.x,P.y,P.z),S.set(W,w,z).normalize(),d.push(S.x,S.y,S.z),f.push(F,1-v),k.push(g++)}_.push(k)}for(let R=0;R<s;R++)for(let k=0;k<a;k++){const v=_[k][R],b=_[k+1][R],N=_[k+1][R+1],F=_[k][R+1];t>0&&(h.push(v,b,F),T+=3),e>0&&(h.push(b,N,F),T+=3)}c.addGroup(m,T,0),m+=T}function x(S){const P=g,T=new lt,w=new C;let R=0;const k=S===!0?t:e,v=S===!0?1:-1;for(let N=1;N<=s;N++)u.push(0,p*v,0),d.push(0,v,0),f.push(.5,.5),g++;const b=g;for(let N=0;N<=s;N++){const $=N/s*l+o,W=Math.cos($),z=Math.sin($);w.x=k*z,w.y=p*v,w.z=k*W,u.push(w.x,w.y,w.z),d.push(0,v,0),T.x=W*.5+.5,T.y=z*.5*v+.5,f.push(T.x,T.y),g++}for(let N=0;N<s;N++){const F=P+N,$=b+N;S===!0?h.push($,$+1,F):h.push($+1,$,F),R+=3}c.addGroup(m,R,S===!0?1:2),m+=R}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Hn(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class pr extends Hn{constructor(t=1,e=1,n=32,s=1,a=!1,r=0,o=Math.PI*2){super(0,t,e,n,s,a,r,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:s,openEnded:a,thetaStart:r,thetaLength:o}}static fromJSON(t){return new pr(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Vh extends pn{constructor(t=[],e=[],n=1,s=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:s};const a=[],r=[];o(s),c(n),h(),this.setAttribute("position",new ue(a,3)),this.setAttribute("normal",new ue(a.slice(),3)),this.setAttribute("uv",new ue(r,2)),s===0?this.computeVertexNormals():this.normalizeNormals();function o(y){const x=new C,S=new C,P=new C;for(let T=0;T<e.length;T+=3)f(e[T+0],x),f(e[T+1],S),f(e[T+2],P),l(x,S,P,y)}function l(y,x,S,P){const T=P+1,w=[];for(let R=0;R<=T;R++){w[R]=[];const k=y.clone().lerp(S,R/T),v=x.clone().lerp(S,R/T),b=T-R;for(let N=0;N<=b;N++)N===0&&R===T?w[R][N]=k:w[R][N]=k.clone().lerp(v,N/b)}for(let R=0;R<T;R++)for(let k=0;k<2*(T-R)-1;k++){const v=Math.floor(k/2);k%2===0?(d(w[R][v+1]),d(w[R+1][v]),d(w[R][v])):(d(w[R][v+1]),d(w[R+1][v+1]),d(w[R+1][v]))}}function c(y){const x=new C;for(let S=0;S<a.length;S+=3)x.x=a[S+0],x.y=a[S+1],x.z=a[S+2],x.normalize().multiplyScalar(y),a[S+0]=x.x,a[S+1]=x.y,a[S+2]=x.z}function h(){const y=new C;for(let x=0;x<a.length;x+=3){y.x=a[x+0],y.y=a[x+1],y.z=a[x+2];const S=p(y)/2/Math.PI+.5,P=m(y)/Math.PI+.5;r.push(S,1-P)}g(),u()}function u(){for(let y=0;y<r.length;y+=6){const x=r[y+0],S=r[y+2],P=r[y+4],T=Math.max(x,S,P),w=Math.min(x,S,P);T>.9&&w<.1&&(x<.2&&(r[y+0]+=1),S<.2&&(r[y+2]+=1),P<.2&&(r[y+4]+=1))}}function d(y){a.push(y.x,y.y,y.z)}function f(y,x){const S=y*3;x.x=t[S+0],x.y=t[S+1],x.z=t[S+2]}function g(){const y=new C,x=new C,S=new C,P=new C,T=new lt,w=new lt,R=new lt;for(let k=0,v=0;k<a.length;k+=9,v+=6){y.set(a[k+0],a[k+1],a[k+2]),x.set(a[k+3],a[k+4],a[k+5]),S.set(a[k+6],a[k+7],a[k+8]),T.set(r[v+0],r[v+1]),w.set(r[v+2],r[v+3]),R.set(r[v+4],r[v+5]),P.copy(y).add(x).add(S).divideScalar(3);const b=p(P);_(T,v+0,y,b),_(w,v+2,x,b),_(R,v+4,S,b)}}function _(y,x,S,P){P<0&&y.x===1&&(r[x]=y.x-1),S.x===0&&S.z===0&&(r[x]=P/2/Math.PI+.5)}function p(y){return Math.atan2(y.z,-y.x)}function m(y){return Math.atan2(-y.y,Math.sqrt(y.x*y.x+y.z*y.z))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Vh(t.vertices,t.indices,t.radius,t.details)}}class Ta extends Vh{constructor(t=1,e=0){const n=(1+Math.sqrt(5))/2,s=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],a=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(s,a,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new Ta(t.radius,t.detail)}}class Gh extends pn{constructor(t=.5,e=1,n=32,s=1,a=0,r=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:s,thetaStart:a,thetaLength:r},n=Math.max(3,n),s=Math.max(1,s);const o=[],l=[],c=[],h=[];let u=t;const d=(e-t)/s,f=new C,g=new lt;for(let _=0;_<=s;_++){for(let p=0;p<=n;p++){const m=a+p/n*r;f.x=u*Math.cos(m),f.y=u*Math.sin(m),l.push(f.x,f.y,f.z),c.push(0,0,1),g.x=(f.x/e+1)/2,g.y=(f.y/e+1)/2,h.push(g.x,g.y)}u+=d}for(let _=0;_<s;_++){const p=_*(n+1);for(let m=0;m<n;m++){const y=m+p,x=y,S=y+n+1,P=y+n+2,T=y+1;o.push(x,S,T),o.push(S,P,T)}}this.setIndex(o),this.setAttribute("position",new ue(l,3)),this.setAttribute("normal",new ue(c,3)),this.setAttribute("uv",new ue(h,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Gh(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}}class di extends pn{constructor(t=1,e=32,n=16,s=0,a=Math.PI*2,r=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:s,phiLength:a,thetaStart:r,thetaLength:o},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const l=Math.min(r+o,Math.PI);let c=0;const h=[],u=new C,d=new C,f=[],g=[],_=[],p=[];for(let m=0;m<=n;m++){const y=[],x=m/n;let S=0;m===0&&r===0?S=.5/e:m===n&&l===Math.PI&&(S=-.5/e);for(let P=0;P<=e;P++){const T=P/e;u.x=-t*Math.cos(s+T*a)*Math.sin(r+x*o),u.y=t*Math.cos(r+x*o),u.z=t*Math.sin(s+T*a)*Math.sin(r+x*o),g.push(u.x,u.y,u.z),d.copy(u).normalize(),_.push(d.x,d.y,d.z),p.push(T+S,1-x),y.push(c++)}h.push(y)}for(let m=0;m<n;m++)for(let y=0;y<e;y++){const x=h[m][y+1],S=h[m][y],P=h[m+1][y],T=h[m+1][y+1];(m!==0||r>0)&&f.push(x,S,T),(m!==n-1||l<Math.PI)&&f.push(S,P,T)}this.setIndex(f),this.setAttribute("position",new ue(g,3)),this.setAttribute("normal",new ue(_,3)),this.setAttribute("uv",new ue(p,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new di(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class li extends pn{constructor(t=1,e=.4,n=12,s=48,a=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:s,arc:a},n=Math.floor(n),s=Math.floor(s);const r=[],o=[],l=[],c=[],h=new C,u=new C,d=new C;for(let f=0;f<=n;f++)for(let g=0;g<=s;g++){const _=g/s*a,p=f/n*Math.PI*2;u.x=(t+e*Math.cos(p))*Math.cos(_),u.y=(t+e*Math.cos(p))*Math.sin(_),u.z=e*Math.sin(p),o.push(u.x,u.y,u.z),h.x=t*Math.cos(_),h.y=t*Math.sin(_),d.subVectors(u,h).normalize(),l.push(d.x,d.y,d.z),c.push(g/s),c.push(f/n)}for(let f=1;f<=n;f++)for(let g=1;g<=s;g++){const _=(s+1)*f+g-1,p=(s+1)*(f-1)+g-1,m=(s+1)*(f-1)+g,y=(s+1)*f+g;r.push(_,p,y),r.push(p,m,y)}this.setIndex(r),this.setAttribute("position",new ue(o,3)),this.setAttribute("normal",new ue(l,3)),this.setAttribute("uv",new ue(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new li(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}class D1 extends Bi{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new te(0),this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.fog=t.fog,this}}class I1 extends an{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Dn extends Bi{constructor(t){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new te(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new te(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Rh,this.normalScale=new lt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new mi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class k1 extends Bi{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Rh,this.normalScale=new lt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class $h extends en{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new te(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(e.object.target=this.target.uuid),e}}class N1 extends $h{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(en.DEFAULT_UP),this.updateMatrix(),this.groundColor=new te(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}}const Ol=new fe,Md=new C,bd=new C;class vp{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new lt(512,512),this.map=null,this.mapPass=null,this.matrix=new fe,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Nh,this._frameExtents=new lt(1,1),this._viewportCount=1,this._viewports=[new me(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;Md.setFromMatrixPosition(t.matrixWorld),e.position.copy(Md),bd.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(bd),e.updateMatrixWorld(),Ol.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ol),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Ol)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}const Sd=new fe,za=new C,Fl=new C;class U1 extends vp{constructor(){super(new Rn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new lt(4,2),this._viewportCount=6,this._viewports=[new me(2,1,1,1),new me(0,1,1,1),new me(3,1,1,1),new me(1,1,1,1),new me(3,0,1,1),new me(1,0,1,1)],this._cubeDirections=[new C(1,0,0),new C(-1,0,0),new C(0,0,1),new C(0,0,-1),new C(0,1,0),new C(0,-1,0)],this._cubeUps=[new C(0,1,0),new C(0,1,0),new C(0,1,0),new C(0,1,0),new C(0,0,1),new C(0,0,-1)]}updateMatrices(t,e=0){const n=this.camera,s=this.matrix,a=t.distance||n.far;a!==n.far&&(n.far=a,n.updateProjectionMatrix()),za.setFromMatrixPosition(t.matrixWorld),n.position.copy(za),Fl.copy(n.position),Fl.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(Fl),n.updateMatrixWorld(),s.makeTranslation(-za.x,-za.y,-za.z),Sd.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Sd)}}class O1 extends $h{constructor(t,e,n=0,s=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=s,this.shadow=new U1}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class F1 extends vp{constructor(){super(new Uh(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class z1 extends $h{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(en.DEFAULT_UP),this.updateMatrix(),this.target=new en,this.shadow=new F1}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class _p{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=wd(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=wd();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function wd(){return performance.now()}const Ed=new fe;class xp{constructor(t,e,n=0,s=1/0){this.ray=new Ih(t,e),this.near=n,this.far=s,this.camera=null,this.layers=new kh,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return Ed.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Ed),this}intersectObject(t,e=!0,n=[]){return eh(t,this,n,e),n.sort(Td),n}intersectObjects(t,e=!0,n=[]){for(let s=0,a=t.length;s<a;s++)eh(t[s],this,n,e);return n.sort(Td),n}}function Td(i,t){return i.distance-t.distance}function eh(i,t,e,n){let s=!0;if(i.layers.test(t.layers)&&i.raycast(t,e)===!1&&(s=!1),s===!0&&n===!0){const a=i.children;for(let r=0,o=a.length;r<o;r++)eh(a[r],t,e,!0)}}class Aa{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(He(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class B1 extends Is{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Mh}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Mh);const zl=new Map;function be(i,t={}){const e=i+JSON.stringify(t);return zl.has(e)||zl.set(e,new Dn({color:i,roughness:.7,...t})),zl.get(e)}const Ba=(i,t)=>"#"+new te(i).multiplyScalar(t).getHexString();function ae(i,t,e,n=0,s=0,a=0){const r=new yt(i,t);return r.position.set(n,s,a),r.castShadow=!0,r.receiveShadow=!0,e.add(r),r}const ai=(i,t)=>new Hh(i,Math.max(.001,t),5,12),Ei=(i,t=20,e=14)=>new di(i,t,e),H1=.93,V1=.45,G1=.44,$1=.06,W1=.1,Wt=.46,Wh={ada:{hair:"afro",pants:"#3a3f5c",shoes:"#26211d"},tunde:{hair:"short",pants:"#4b4136",shoes:"#1c1c1c",extra:"lanyard"},mira:{hair:"bob",pants:"#2f3b52",shoes:"#5b4636"},kai:{hair:"spiky",pants:"#38383d",shoes:"#e9e6df",extra:"hood"},zola:{hair:"ponytail",pants:"#4d3f5e",shoes:"#2b2b2b"},remi:{hair:"bun",pants:"#3f4f60",shoes:"#704d38",extra:"glasses"},obi:{hair:"buzz",pants:"#2c3a32",shoes:"#1d1d1d",extra:"headphones"},lin:{hair:"long",pants:"#3b3b4a",shoes:"#2a2a2a"},chief:{hair:"side",pants:"#22232e",shoes:"#141414",extra:"suit"}};function Br(i,t,e,n,s,a,r,o,l,c){const h=new Ht;h.position.set(t,e,0),i.add(h),ae(ai(a,n-a),o,h,0,-n/2);const u=new Ht;u.position.y=-n,h.add(u),ae(ai(r,s-r),l,u,0,-s/2);const d=new Ht;return d.position.y=-s,u.add(d),c==null||c(d),{pivot:h,joint:u,end:d}}class ir{constructor(t){const e=Wh[t.id]||{hair:"short",pants:"#34384a",shoes:"#222"};this.look=e;const n=be(t.skin,{roughness:.6}),s=be(t.shirt),a=be(Ba(t.shirt,.9)),r=be(e.pants),o=be(e.shoes,{roughness:.5}),l=be(t.hair,{roughness:.85});this.group=new Ht,this.body=new Ht,this.group.add(this.body),this.hips=new Ht,this.hips.position.y=.95,this.body.add(this.hips),ae(ai(.2,.06),r,this.hips,0,.02).scale.set(1,1,.8);const h=_=>{ae(new Ye(.15,.09,.26),o,_,0,-.02,.05).geometry.translate(0,0,0)};this.legL=Br(this.hips,-.11,-.02,.45,.44,.1,.085,r,r,h),this.legR=Br(this.hips,.11,-.02,.45,.44,.1,.085,r,r,h),this.torso=new Ht,this.hips.add(this.torso);const u=[[.001,0],[.19,0],[.225,.08],[.23,.24],[.22,.36],[.255,.5],[.24,.58],[.15,.645],[.001,.66]].map(([_,p])=>new lt(_,p)),d=ae(new Go(u,20),e.extra==="suit"?be("#2b2d42"):s,this.torso,0,.04);d.scale.z=.8,ae(new li(.11,.03,8,20),e.extra==="suit"?be("#f4f1ea"):be(Ba(t.shirt,.8)),this.torso,0,.67).rotation.x=Math.PI/2,ae(new Hn(.075,.085,.14,12),n,this.torso,0,.73);const f=_=>ae(Ei(.07,12,10),n,_,0,-.02),g=e.extra==="suit"?be("#2b2d42"):a;this.armL=Br(this.torso,-.29,.58,.32,.3,.072,.062,g,e.extra==="suit"||e.extra==="hood"?g:n,f),this.armR=Br(this.torso,.29,.58,.32,.3,.072,.062,g,e.extra==="suit"||e.extra==="hood"?g:n,f),this.buildHead(t,n,l),this.buildExtras(t,e,l),this.book=ae(new Ye(.34,.05,.26),be("#3d7ea6"),this.torso,0,.3,.36),this.book.rotation.x=-.6,this.book.visible=!1,this.mug=ae(new Hn(.06,.055,.13,12),be("#ffffff"),this.armR.end,0,-.06,.07),this.mug.visible=!1,this.blinkAt=1+Math.random()*3,this.blink=0,this.cur={}}buildHead(t,e,n){this.head=new Ht,this.head.position.y=.78,this.torso.add(this.head),ae(Ei(.33,28,20),e,this.head,0,.3).scale.set(1,.97,.94);for(const r of[-1,1])ae(Ei(.06,10,8),e,this.head,r*.32,.29,-.01).scale.set(.6,1,1);ae(Ei(.032,10,8),be(Ba(t.skin,.88),{roughness:.6}),this.head,0,.27,.31),this.eyes=[];for(const r of[-1,1]){const o=new Ht;o.position.set(r*.115,.33,.285),o.rotation.y=r*.28,this.head.add(o);const l=new yt(Ei(.042,14,10),be("#17181c",{roughness:.3}));l.scale.set(.82,1.2,.5),o.add(l);const c=new yt(Ei(.013,8,6),new ln({color:"#ffffff"}));c.position.set(.012,.018,.02),o.add(c),this.eyes.push(o)}this.brows=[];for(const r of[-1,1]){const o=new yt(ai(.014,.08),be(Ba(t.hair,.9)));o.rotation.z=Math.PI/2;const l=new Ht;l.position.set(r*.115,.425,.275),l.rotation.y=r*.28,l.add(o),this.head.add(l),this.brows.push(l)}this.mouth=new yt(new li(.055,.012,6,18,Math.PI),be("#5b2a2a",{roughness:.5})),this.mouth.position.set(0,.205,.292),this.mouth.rotation.z=Math.PI,this.head.add(this.mouth);for(const r of[-1,1]){const o=new yt(new gi(.045,16),new ln({color:"#ff8d7a",transparent:!0,opacity:.22,depthWrite:!1}));o.position.set(r*.19,.24,.245),o.rotation.y=r*.62,this.head.add(o)}const a=(r=.345,o=.52,l=-.25)=>{const c=ae(new di(r,28,16,0,Math.PI*2,0,Math.PI*o),n,this.head,0,.31,-.01);return c.rotation.x=l,c.scale.set(1,1,.97),c};switch(this.look.hair){case"afro":a(.35,.55),ae(Ei(.43,24,18),n,this.head,0,.47,-.08).scale.set(1,.85,.95);break;case"bob":{a(.36,.56,-.32);for(const r of[-1,1])ae(ai(.09,.2),n,this.head,r*.29,.22,-.1).scale.set(.75,1,1.1);ae(ai(.05,.3),n,this.head,0,.55,.17).rotation.z=Math.PI/2;break}case"spiky":a(.35,.5);for(let r=0;r<9;r++){const o=r/9*Math.PI*2;ae(new pr(.07,.22,6),n,this.head,Math.cos(o)*.17,.6,Math.sin(o)*.17-.03).rotation.set(Math.sin(o)*.7,0,-Math.cos(o)*.7)}break;case"ponytail":{a(.35,.55),ae(Ei(.07,10,8),be("#e07a5f"),this.head,0,.42,-.33);const r=ae(ai(.08,.32),n,this.head,0,.22,-.4);r.rotation.x=.35,this.tail=r;break}case"bun":a(.35,.55),ae(Ei(.14,16,12),n,this.head,0,.66,-.1);break;case"buzz":a(.338,.5,-.3);break;case"long":{a(.36,.58,-.2),ae(ai(.16,.42),n,this.head,0,.1,-.2).scale.set(1.75,1,.6);break}case"side":{a(.35,.5),ae(ai(.07,.3),n,this.head,.06,.58,.12).rotation.set(.2,0,Math.PI/2-.25);break}default:a(.35,.5)}}buildExtras(t,e,n){if(e.extra==="glasses"||e.extra==="suit"){const s=be("#1b1b1f",{roughness:.4});for(const a of[-1,1]){const r=ae(new li(.06,.011,6,18),s,this.head,a*.115,.33,.3);r.rotation.y=a*.28}ae(ai(.009,.06),s,this.head,0,.34,.315).rotation.z=Math.PI/2}if(e.extra==="suit"){const s=ae(new Ye(.06,.3,.02),be("#b23a3a"),this.torso,0,.47,.19);s.rotation.x=-.12,ae(new Ye(.16,.18,.02),be("#f4f1ea"),this.torso,0,.56,.175).rotation.x=-.15}if(e.extra==="headphones"){const s=ae(new li(.35,.025,8,24,Math.PI),be("#22252b"),this.head,0,.32,0);s.rotation.y=Math.PI/2,s.rotation.x=-.15;for(const a of[-1,1])ae(new Hn(.09,.09,.07,18),be("#e05f4a"),this.head,a*.34,.3,0).rotation.z=Math.PI/2}if(e.extra==="lanyard"&&(ae(new li(.16,.01,6,20,Math.PI),be("#2a6fb0"),this.torso,0,.62,.12).rotation.set(-.25,0,Math.PI),ae(new Ye(.1,.13,.015),be("#ffffff"),this.torso,0,.42,.205).rotation.x=-.1),e.extra==="hood"){const s=ae(new li(.2,.06,10,24),be(Ba(t.shirt,.85)),this.torso,0,.64,-.05);s.rotation.x=Math.PI/2+.35,s.scale.set(1,1,.7)}}static sit(t=Wt,e=-1.4){const n=t+W1,s=n-V1*Math.cos(e),a=-Math.acos(Math.min(1,Math.max(-1,(s-$1)/G1)));return{y:n-H1,hip:e,knee:a-e}}pose(t,e,n,s={}){const a=Math.min(1,e*10);let r=0,o=0,l=0,c=0,h=.05,u=.05,d=-.12,f=-.12,g=-.07,_=.07,p=0,m=0,y=0,x=0,S=0;const P=Math.sin(n*1.7)*.012;switch(this.book.visible=t==="read",this.mug.visible=t==="mug",t){case"walk":{const v=Math.sin(n*9.5),b=Math.cos(n*9.5);r=v*.5,o=-v*.5,l=Math.max(0,-b)*.9+.05,c=Math.max(0,b)*.9+.05,h=-v*.45,u=v*.45,d=f=-.35,p=Math.abs(b)*.05,m=.06,x=Math.sin(n*4.75)*.04;break}case"desk":{const v=ir.sit(s.seatY,-1.45);r=o=v.hip,l=c=v.knee,p=v.y,m=.08,s.typing?(h=-.5+Math.sin(n*17)*.05,u=-.5+Math.sin(n*17+2)*.05,d=-1.15+Math.sin(n*19)*.12,f=-1.15+Math.sin(n*19+1.6)*.12,g=-.18,_=.18,y=.12+Math.sin(n*.7)*.03):s.waiting?(u=-.95,f=-2.25,_=.05,h=-.4,d=-1,x=Math.sin(n*.6)*.45,y=-.05):(h=u=-.35,d=f=-.9,g=-.2,_=.2,m=-.04,x=Math.sin(n*.35)*.3);break}case"couch":{const v=ir.sit(s.seatY,-1.3);r=o=v.hip,l=c=v.knee,p=v.y,m=-.18,h=u=-.2,d=f=-.75,g=-.15,_=.15,x=Math.sin(n*.3)*.5,S=Math.sin(n*.21)*.06;break}case"sit":{const v=ir.sit(s.seatY,-1.42);r=o=v.hip,l=c=v.knee,p=v.y,m=.03,h=u=-.32,d=f=-.95,g=-.16,_=.16,x=Math.sin(n*.4)*.4,S=Math.sin(n*.27)*.05;break}case"read":h=u=-.55,d=f=-1.35,g=-.12,_=.12,y=.4,x=Math.sin(n*.6)*.12;break;case"type":h=-.75+Math.sin(n*14)*.08,u=-.75+Math.sin(n*14+2)*.08,d=-.9,f=-.9,g=-.15,_=.15,y=.08;break;case"gaze":h=u=.3,d=f=-.25,g=-.12,_=.12,y=-.18,x=Math.sin(n*.45)*.35;break;case"write":u=-2.2+Math.sin(n*6)*.2,f=-.5+Math.sin(n*9)*.15,_=.25,x=Math.sin(n*1.2)*.1,y=-.08;break;case"mug":{const v=Math.sin(n*.8)>.75;u=v?-.85:-.45,f=v?-2.05:-1.55,_=.1,y=v?-.15:.02,x=v?0:Math.sin(n*.4)*.3;break}case"cue":m=.62,h=-1.5,d=-.12,g=-.12,u=-.95,f=-1.35,_=.14,y=-.5,r=o=-.12,l=c=.14,x=Math.sin(n*.8)*.05;break;case"talk":u=-.55+Math.sin(n*4)*.2,f=-1.1+Math.sin(n*5.3)*.2,_=.2,h=-.1,d=-.4,S=Math.sin(n*2.2)*.06,y=-.04;break;case"celebrate":h=u=-2.75,d=f=-.25,g=-.35,_=.35,p=Math.abs(Math.sin(n*8))*.32,y=-.15,l=c=p>.05?.4:.1,r=o=-l*.5;break;case"slump":y=.45,m=.22,h=u=.12,d=f=-.05;break;default:x=Math.sin(n*.5)*.25}const T=this.cur,w=(v,b,N=a)=>T[v]=T[v]===void 0?b:T[v]+(b-T[v])*N,R=t==="walk",k=R?Math.min(1,e*18):a;this.legL.pivot.rotation.x=w("hipL",r,k),this.legR.pivot.rotation.x=w("hipR",o,k),this.legL.joint.rotation.x=w("kneeL",l,k),this.legR.joint.rotation.x=w("kneeR",c,k),this.armL.pivot.rotation.x=w("shL",h,k),this.armR.pivot.rotation.x=w("shR",u,k),this.armL.pivot.rotation.z=w("outL",g),this.armR.pivot.rotation.z=w("outR",_),this.armL.joint.rotation.x=w("elL",d,k),this.armR.joint.rotation.x=w("elR",f,k),this.torso.rotation.x=w("lean",m),this.torso.scale.y=1+P,this.head.rotation.x=w("headX",y,a*.6),this.head.rotation.y=w("headY",x,a*.4),this.head.rotation.z=w("headZ",S,a*.6),this.body.position.y=R||t==="celebrate"?p:w("y",p),this.tail&&(this.tail.rotation.x=.35+Math.sin(n*(R?9.5:1.5))*(R?.12:.03))}express(t,e,n){n>this.blinkAt&&(this.blink=.14,this.blinkAt=n+2+Math.random()*4),this.blink=Math.max(0,this.blink-e);const s=this.blink>0,a=Math.min(1,e*12),r=this.cur,o=(m,y)=>r[m]=r[m]===void 0?y:r[m]+(y-r[m])*a;let l=1,c=0,h=0,u=1,d=1,f=!1;t==="happy"?(l=.3,c=.025,u=1.45,d=1.6):t==="think"?(c=.02,h=.25,u=.55,l=.9):t==="worried"?(h=-.35,c=.01,f=!0,u=.8):t==="talk"&&(u=.8,d=.6+Math.abs(Math.sin(n*13))*1.6,c=Math.sin(n*3)*.008),s&&t!=="happy"&&(l=.1);const g=o("eyeY",l);for(const m of this.eyes)m.scale.y=g;const _=o("browY",c),p=o("browTilt",h);this.brows.forEach((m,y)=>{m.position.y=.425+_,m.rotation.z=(y?-1:1)*p}),this.mouth.rotation.z=f?0:Math.PI,this.mouth.position.y=f?.18:.205,this.mouth.scale.set(o("mouthX",u),o("mouthY",d),1)}}const X=i=>document.getElementById(i),Ad=["👍","❤️","😂","🎉","👀","🙏","🔥","✅"],X1=[["Smileys",["😀","😄","😁","😆","😅","🤣","😂","🙂","😉","😊","😇","🥰","😍","🤩","😘","😋","😛","🤪","🤔","🤨","😐","😑","😶","🙄","😏","😬","😌","😴","🤯","🥳","😎","🤓","🧐","😕","😟","😮","😲","😳","🥺","😢","😭","😱","😤","😡","🤬","💀","🤡","👻"]],["Gestures",["👍","👎","👌","🤌","✌️","🤞","🤝","👏","🙌","👐","🙏","💪","👋","🤙","👀","🫡","🤷","🤦","🙋","🙇"]],["Hearts",["❤️","🧡","💛","💚","💙","💜","🖤","🤍","💔","💯","💥","💫","✨","⭐","🔥","⚡"]],["Work",["✅","❌","⚠️","❓","❗","🚀","🎉","🎯","🏆","🐛","🔧","🛠️","💡","📌","📎","📝","📈","📉","⏳","🧪","🔒","🧠","☕","🍕"]]],J=i=>String(i??"").replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t]),yp=new Rf({gfm:!0,breaks:!0});yp.use({renderer:{html:i=>J(i.text??i),link:({href:i,text:t})=>/^https?:\/\//i.test(i)?`<a href="${J(i)}" target="_blank" rel="noreferrer">${J(t)}</a>`:J(t),image:({text:i})=>J(i)}});const Bl=i=>yp.parse(String(i??"")),oa={queued:"Queued",working:"Working",done:"Shipped",failed:"Failed",stopped:"Stopped"},q1={haiku:"Haiku",sonnet:"Sonnet",opus:"Opus"},j1=i=>{var t,e;return q1[i]||((e=[...((t=X("model"))==null?void 0:t.options)||[]].find(n=>n.value===i))==null?void 0:e.text)||i||"Default"},Hl={library:"Library",servers:"Server room",window:"Research",whiteboard:"Whiteboard",desk:"Desk"},Ci=(i,t)=>typeof t=="string"&&Object.hasOwn(i,t)?t:"",Vl=i=>oa[Ci(oa,i)]||"",Cd=i=>{const t=/^the boss (?:says|asks|wants)\s*[:,]?\s*["“](.+?)(?:["”]|$)[\s.,:;]*(.*)/is.exec(String(i||"")),e=(t?t[1].length<24&&t[2]?`${t[1].replace(/[.!]$/,"")}: ${t[2]}`:t[1]:String(i||"")).trim();return e.charAt(0).toUpperCase()+e.slice(1)},Y1=i=>{if(!i)return"";const t=Math.max(0,Math.round((Date.now()-i)/6e4));return t<1?"now":t<60?`${t}m`:t<1440?`${Math.round(t/60)}h`:`${Math.round(t/1440)}d`},Ti=i=>Number.isFinite(i)?i:0,ya=i=>typeof i=="string"&&/^#[0-9a-f]{3,8}$/i.test(i)?i:"#999",Xh=new Map,Gl=i=>{let t=0;for(const a of String(i))t=(t*31+a.charCodeAt(0))%360;const e=(String(i).match(/[a-z0-9]/i)||["#"])[0].toUpperCase(),n=Xh.get(i),s=n===!1?"":`<img src="/api/repos/icon?name=${encodeURIComponent(i)}" alt="" data-pico="${J(i)}" draggable="false">`;return`<span class="pico${n?" has":""}" style="--h:${t}" aria-hidden="true">${J(e)}${s}</span>`};document.addEventListener("load",i=>{var e;const t=i.target;(e=t==null?void 0:t.dataset)!=null&&e.pico&&(Xh.set(t.dataset.pico,!0),t.parentElement.classList.add("has"))},!0);document.addEventListener("error",i=>{var e;const t=i.target;(e=t==null?void 0:t.dataset)!=null&&e.pico&&(Xh.set(t.dataset.pico,!1),t.remove())},!0);const Mp=i=>{const t=Wh[i.id]||{},e=ya(i.skin),n=ya(i.hair),s=ya(i.shirt),a=t.hair||"short",r={afro:`<circle cx="24" cy="18" r="13.5" fill="${n}"/>`,bob:`<path d="M10 40V19a14 14 0 0 1 28 0v21z" fill="${n}"/>`,long:`<path d="M9 44V19a15 15 0 0 1 30 0v25z" fill="${n}"/>`,ponytail:`<path d="M33 14c8 1 10 9 6 19-1-6-3-9-6-10z" fill="${n}"/>`,bun:`<circle cx="24" cy="6.5" r="4.5" fill="${n}"/>`}[a]||"",o={afro:`<path d="M15 17a9 9 0 0 1 18 0c-3-3-6-4-9-4s-6 1-9 4z" fill="${n}"/>`,short:`<path d="M15 18a9 9 0 0 1 18 0c-4-1-6-3-9-5-2 3-5 4-9 5z" fill="${n}"/>`,buzz:`<path d="M15.2 17.5a8.8 8.8 0 0 1 17.6 0c-5-2-12.6-2-17.6 0z" fill="${n}"/>`,spiky:`<path d="M15 18l1-7 3 4 2-7 3 6 3-6 2 7 3-4 1 7c-4-2-6-3-9-3s-5 1-9 3z" fill="${n}"/>`,bob:`<path d="M15 19a9 9 0 0 1 18 0c-5 0-9-2-11-5-1 3-3 5-7 5z" fill="${n}"/>`,long:`<path d="M15 19a9 9 0 0 1 18 0c-5 0-9-2-11-5-1 3-3 5-7 5z" fill="${n}"/>`,ponytail:`<path d="M15 18a9 9 0 0 1 18 0c-4-1-7-3-9-5-2 3-5 4-9 5z" fill="${n}"/>`,bun:`<path d="M15 18a9 9 0 0 1 18 0c-4-1-7-3-9-5-2 3-5 4-9 5z" fill="${n}"/>`}[a]||"",l=t.extra==="glasses"?'<g fill="none" stroke="#2b2b2b" stroke-width="1.2"><circle cx="20.5" cy="22" r="3"/><circle cx="27.5" cy="22" r="3"/><path d="M23.5 22h1"/></g>':t.extra==="headphones"?'<path d="M14.5 22v-4a9.5 9.5 0 0 1 19 0v4" fill="none" stroke="#2b2b2b" stroke-width="2"/><rect x="12.5" y="20" width="4" height="7" rx="2" fill="#2b2b2b"/><rect x="31.5" y="20" width="4" height="7" rx="2" fill="#2b2b2b"/>':"";return`<svg class="face" viewBox="0 0 48 48" aria-hidden="true" style="background:${s}33">
3895
3895
  ${r}
3896
3896
  <path d="M6 48c1-9 8-13 18-13s17 4 18 13z" fill="${s}"/>
3897
3897
  <rect x="20.5" y="27" width="7" height="9" rx="3" fill="${e}"/>
@@ -3900,12 +3900,12 @@ void main() {
3900
3900
  <circle cx="20.5" cy="22.5" r="1.2" fill="#2b2118"/><circle cx="27.5" cy="22.5" r="1.2" fill="#2b2118"/>
3901
3901
  <path d="M21.5 27.5q2.5 2 5 0" fill="none" stroke="#2b2118" stroke-width="1.1" stroke-linecap="round" opacity=".7"/>
3902
3902
  ${l}
3903
- </svg>`},Hr=(i,t="")=>`<span class="av ${t}">${i.look?bp(i.look):'<svg class="face" viewBox="0 0 48 48" aria-hidden="true" style="background:#c9c1b455"><path d="M6 48c1-9 8-13 18-13s17 4 18 13z" fill="#a39a8a"/><ellipse cx="24" cy="21" rx="9" ry="10" fill="#a39a8a"/></svg>'}</span>`,Ks=(i,t)=>{try{if(t===void 0)return localStorage.getItem(i);localStorage.setItem(i,t)}catch{}return null};function $l(i){const t=Math.max(0,Math.round(i/1e3));if(t<60)return`${t}s`;const e=Math.floor(t/60);return e<60?`${e}m ${t%60}s`:`${Math.floor(e/60)}h ${e%60}m`}const K1=i=>{const t=Math.ceil(i/6e4);if(t<60)return`${t}m`;const e=Math.floor(t/60);return e<24?`${e}h ${t%60}m`:`${Math.floor(e/24)}d ${e%24}h`},Z1=i=>{const t=new Date(i),e=t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return t.toDateString()===new Date().toDateString()?e:`${t.toLocaleDateString([],{weekday:"short"})} ${e}`},Ha=i=>i>=1<<30?`${(i/(1<<30)).toFixed(1)} GB`:`${Math.round(i/(1<<20))} MB`,Rd=i=>`${i>=10?Math.round(i):Math.round(i*10)/10}%`;async function Le(i,t,e){const n=t===void 0?e?{method:e}:{}:{method:e||"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)},s=await fetch(i,n),a=await s.json().catch(()=>({}));if(!s.ok)throw new Error(a.error||`Request failed (${s.status})`);return a}const Sp=i=>i<1024?`${i} B`:i<1048576?`${Math.round(i/1024)} KB`:`${(i/1048576).toFixed(1)} MB`,Vr=i=>`/api/uploads/${i.id}/${encodeURIComponent(i.name)}`;class Pd{constructor(t,e){this.el=t,this.onError=e,this.items=[],t.onclick=n=>{const s=n.target.closest("[data-drop]");s&&(this.items=this.items.filter(a=>a.key!==s.dataset.drop),this.render())}}add(t){for(const e of t){const n={key:Math.random().toString(36).slice(2),name:e.name||"pasted",size:e.size,preview:e.type.startsWith("image/")?URL.createObjectURL(e):null},s=e.name||`pasted-${Date.now()}.${(e.type.split("/")[1]||"bin").replace("jpeg","jpg")}`;n.done=fetch("/api/uploads",{method:"POST",headers:{"x-file-name":encodeURIComponent(s),"content-type":e.type||"application/octet-stream"},body:e}).then(async a=>{const r=await a.json().catch(()=>({}));if(!a.ok)throw new Error(r.error||`Upload failed (${a.status})`);n.id=r.id}).catch(a=>{this.items=this.items.filter(r=>r!==n),this.render(),this.onError(`${n.name}: ${a.message}`)}).finally(()=>{n.loading=!1,this.render()}),n.loading=!0,this.items.push(n)}this.render()}attach({id:t,name:e,size:n}){this.items.push({key:Math.random().toString(36).slice(2),id:t,name:e,size:n,done:Promise.resolve(),voice:!0}),this.render()}async ids(){return await Promise.all(this.items.map(t=>t.done)),this.items.filter(t=>t.id).map(t=>t.id)}get empty(){return!this.items.length}clear(){this.items.forEach(t=>t.preview&&URL.revokeObjectURL(t.preview)),this.items=[],this.render()}render(){this.el.hidden=!this.items.length,this.el.innerHTML=this.items.map(t=>`
3904
- <span class="file ${t.loading?"loading":""}" title="${J(t.name)} · ${Sp(t.size)}">
3903
+ </svg>`},Hr=(i,t="")=>`<span class="av ${t}">${i.look?Mp(i.look):'<svg class="face" viewBox="0 0 48 48" aria-hidden="true" style="background:#c9c1b455"><path d="M6 48c1-9 8-13 18-13s17 4 18 13z" fill="#a39a8a"/><ellipse cx="24" cy="21" rx="9" ry="10" fill="#a39a8a"/></svg>'}</span>`,Ks=(i,t)=>{try{if(t===void 0)return localStorage.getItem(i);localStorage.setItem(i,t)}catch{}return null};function $l(i){const t=Math.max(0,Math.round(i/1e3));if(t<60)return`${t}s`;const e=Math.floor(t/60);return e<60?`${e}m ${t%60}s`:`${Math.floor(e/60)}h ${e%60}m`}const K1=i=>{const t=Math.ceil(i/6e4);if(t<60)return`${t}m`;const e=Math.floor(t/60);return e<24?`${e}h ${t%60}m`:`${Math.floor(e/24)}d ${e%24}h`},Z1=i=>{const t=new Date(i),e=t.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"});return t.toDateString()===new Date().toDateString()?e:`${t.toLocaleDateString([],{weekday:"short"})} ${e}`},Ha=i=>i>=1<<30?`${(i/(1<<30)).toFixed(1)} GB`:`${Math.round(i/(1<<20))} MB`,Rd=i=>`${i>=10?Math.round(i):Math.round(i*10)/10}%`;async function Le(i,t,e){const n=t===void 0?e?{method:e}:{}:{method:e||"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)},s=await fetch(i,n),a=await s.json().catch(()=>({}));if(!s.ok)throw new Error(a.error||`Request failed (${s.status})`);return a}const bp=i=>i<1024?`${i} B`:i<1048576?`${Math.round(i/1024)} KB`:`${(i/1048576).toFixed(1)} MB`,Vr=i=>`/api/uploads/${i.id}/${encodeURIComponent(i.name)}`;class Pd{constructor(t,e){this.el=t,this.onError=e,this.items=[],t.onclick=n=>{const s=n.target.closest("[data-drop]");s&&(this.items=this.items.filter(a=>a.key!==s.dataset.drop),this.render())}}add(t){for(const e of t){const n={key:Math.random().toString(36).slice(2),name:e.name||"pasted",size:e.size,preview:e.type.startsWith("image/")?URL.createObjectURL(e):null},s=e.name||`pasted-${Date.now()}.${(e.type.split("/")[1]||"bin").replace("jpeg","jpg")}`;n.done=fetch("/api/uploads",{method:"POST",headers:{"x-file-name":encodeURIComponent(s),"content-type":e.type||"application/octet-stream"},body:e}).then(async a=>{const r=await a.json().catch(()=>({}));if(!a.ok)throw new Error(r.error||`Upload failed (${a.status})`);n.id=r.id}).catch(a=>{this.items=this.items.filter(r=>r!==n),this.render(),this.onError(`${n.name}: ${a.message}`)}).finally(()=>{n.loading=!1,this.render()}),n.loading=!0,this.items.push(n)}this.render()}attach({id:t,name:e,size:n}){this.items.push({key:Math.random().toString(36).slice(2),id:t,name:e,size:n,done:Promise.resolve(),voice:!0}),this.render()}async ids(){return await Promise.all(this.items.map(t=>t.done)),this.items.filter(t=>t.id).map(t=>t.id)}get empty(){return!this.items.length}clear(){this.items.forEach(t=>t.preview&&URL.revokeObjectURL(t.preview)),this.items=[],this.render()}render(){this.el.hidden=!this.items.length,this.el.innerHTML=this.items.map(t=>`
3904
+ <span class="file ${t.loading?"loading":""}" title="${J(t.name)} · ${bp(t.size)}">
3905
3905
  ${t.preview?`<img src="${t.preview}" alt="">`:t.voice?"<b>VOICE</b>":"<b>FILE</b>"}
3906
3906
  <span>${J(t.name)}</span>
3907
3907
  <button type="button" data-drop="${t.key}" aria-label="Remove ${J(t.name)}">×</button>
3908
- </span>`).join("")}}function Ld(i,{zone:t,input:e,picker:n,button:s}){s.onclick=()=>n.click(),n.onchange=()=>{i.add([...n.files]),n.value=""},e.addEventListener("paste",a=>{var o;const r=[...((o=a.clipboardData)==null?void 0:o.files)||[]];r.length&&(a.preventDefault(),i.add(r))}),t.addEventListener("dragover",a=>{[...a.dataTransfer.types].includes("Files")&&(a.preventDefault(),t.classList.add("dropping"))}),t.addEventListener("dragleave",a=>{t.contains(a.relatedTarget)||t.classList.remove("dropping")}),t.addEventListener("drop",a=>{t.classList.remove("dropping"),a.dataTransfer.files.length&&(a.preventDefault(),i.add([...a.dataTransfer.files]))})}const Dd=i=>i!=null&&i.length?`<div class="files">${i.map(t=>t.image?`<a class="thumb" href="${Vr(t)}" target="_blank" rel="noreferrer" title="${J(t.name)}"><img src="${Vr(t)}" alt="${J(t.name)}" loading="lazy"></a>`:t.audio?`<audio class="voice" controls preload="metadata" src="${Vr(t)}" title="${J(t.name)}"></audio>`:`<a class="file" href="${Vr(t)}" title="${J(t.name)} · ${Sp(t.size)}"><b>FILE</b><span>${J(t.name)}</span></a>`).join("")}</div>`:"",Gr={more:'<svg viewBox="0 0 24 24"><path d="M7 7l5 5 5-5M7 13l5 5 5-5"/></svg>',speak:'<svg viewBox="0 0 24 24"><path d="M11 5 6 9H3v6h3l5 4V5Z"/><path d="M15.5 8.5a5 5 0 0 1 0 7"/></svg>',open:'<svg viewBox="0 0 24 24"><path d="M14 4h6v6M20 4l-9 9"/><path d="M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5"/></svg>',reply:'<svg viewBox="0 0 24 24"><path d="M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12z"/></svg>'};class J1{constructor(t){this.app=t,this.openId=null,this.repos=null,window.addEventListener("focus",()=>this.syncRepos()),document.addEventListener("visibilitychange",()=>{document.hidden||this.syncRepos()}),this.channels=[{id:"general",name:"general"}],this.channel=Ks("office.channel")||"general",this.unread=new Map,X("clear").onclick=async()=>{await Le("/api/jobs/clear",{}),this.closeDetail()},X("away").onclick=e=>{const n=e.target.closest("[data-recall]");n&&this.app.recall(n.dataset.recall)},X("jobs").onclick=e=>{const n=e.target.closest("[data-id]");n&&this.app.openJob(n.dataset.id)},X("projects").onclick=e=>{const n=e.target.closest(".job[data-id]");if(n)return this.app.openJob(n.dataset.id);const s=e.target.closest("[data-new]");if(s)return this.focusInput(`#${s.dataset.new.replace(/\s+/g,"-")} `);const a=e.target.closest("[data-project]");a&&(this.projectOpen=this.projectOpen===a.dataset.project?null:a.dataset.project,this.renderProjects())},document.querySelectorAll(".tabs button").forEach(e=>e.onclick=()=>this.tab(e.dataset.tab)),document.querySelectorAll("#mnav button").forEach(e=>e.onclick=()=>{e.dataset.m==="office"?this.mobile("office"):this.tab(e.dataset.m)}),this.bindViewToggle(),this.bindTeam(),this.bindChat(),this.bindChannels(),this.bindFold(),this.renderChannels(),addEventListener("keydown",e=>{var s;const n=/INPUT|TEXTAREA|SELECT/.test((s=document.activeElement)==null?void 0:s.tagName);(e.key==="n"||e.key==="/")&&!n&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),this.focusInput()),e.key==="Escape"&&!n&&this.closeDetail()}),setInterval(()=>this.tick(),1e3)}renderOwner(t){t=String(t||"").trim();const e=t?`${t}${/s$/i.test(t)?"’":"’s"} Office`:"Your Office";X("officeName").textContent=e,document.title=e}bindFold(){const t=X("fold"),e=X("gaugesBox"),n=a=>{e.hidden=!a,t.setAttribute("aria-expanded",String(a));const r=a?"Hide usage":"Show usage";t.setAttribute("aria-label",r),t.title=r;try{localStorage.setItem("office.gauges",a?"1":"0")}catch{}};let s=!1;try{s=localStorage.getItem("office.gauges")==="1"}catch{}n(s),t.addEventListener("click",()=>n(e.hidden)),X("officeName").addEventListener("click",()=>n(e.hidden))}renderLevel(t){const e=`${t.xp-t.floor} / ${t.next-t.floor} XP`;X("lvNum").textContent=t.level,X("lv").title=`Level ${t.level} · ${e}`,X("lv").setAttribute("aria-label",`Level ${t.level}, ${e}`),X("lv").style.setProperty("--p",Math.min(100,(t.xp-t.floor)/(t.next-t.floor)*100)),X("xptext").textContent=e}renderUsage(t){if(t!==void 0&&(this.usage=t),t=this.usage,X("usage").hidden=!t,!t)return;const e=t.error&&!t.session&&!t.week;X("useErr").hidden=!e,X("useErr").textContent=e?t.error:"";for(const[n,s]of[["useSession",t.session],["useWeek",t.week]]){const a=X(n);if(a.hidden=!s,!s)continue;const r=s.resetsAt?s.resetsAt-Date.now():null;a.className=`meter ${s.pct>=90?"hot":s.pct>=70?"warm":""}`,a.style.setProperty("--p",Math.min(100,s.pct)),a.querySelector(".v").textContent=`${s.pct}%`,a.querySelector(".r").textContent=r===null?"":r<=0?"Resetting now":`Resets in ${K1(r)}`,a.title=[s.resetsAt?`Resets ${Z1(s.resetsAt)}`:"",a.querySelector(".r").textContent].filter(Boolean).join(" · ")}}renderProc(t,e){e&&(this.machine=e),this.procs=t||null;const n=this.machine,s=Object.values(this.procs||{}).filter(u=>u);if(X("load").hidden=!s.length||!n,X("load").hidden)return this.renderMeta(this.app.job(this.openId));const a=s.reduce((u,d)=>u+(d.cpu||0),0),r=s.reduce((u,d)=>u+d.mem,0),o=a/n.cores,l=r/n.mem*100,c=`${s.length} ${s.length===1?"agent":"agents"}`,h=`${(a/100).toFixed(1)} of ${n.cores} cores`;this.meter("loadCpu",o,Rd(o),s.length>1?`${c} · ${h}`:h,`${c} using ${h}`),this.meter("loadMem",l,Ha(r),`${Rd(l)} of ${Ha(n.mem)}`,`${c} holding ${Ha(r)} of ${Ha(n.mem)}`),this.renderMeta(this.app.job(this.openId))}meter(t,e,n,s,a){const r=X(t);r.hidden=!1,r.className=`meter ${e>=90?"hot":e>=70?"warm":""}`,r.style.setProperty("--p",Math.min(100,e)),r.querySelector(".v").textContent=n,r.querySelector(".r").textContent=s,r.title=`${a} · ${s}`}renderStats(t,e=0){const n=a=>t.filter(r=>r.status===a&&!r.awaitingBoss).length,s=t.reduce((a,r)=>a+(r.cost||0),e);X("stats").innerHTML=[`<span><b>${n("working")}</b> working</span>`,`<span><b>${n("queued")}</b> queued</span>`,`<span><b>${n("done")}</b> shipped</span>`,`<span><b>$${s.toFixed(2)}</b> spent</span>`].join("")}renderJobs(t,e){const n={working:0,queued:1,done:2,failed:2,stopped:2},s=[...t].sort((h,u)=>n[h.status]-n[u.status]||(u.endedAt||u.queuedAt)-(h.endedAt||h.queuedAt)),a=h=>`
3908
+ </span>`).join("")}}function Ld(i,{zone:t,input:e,picker:n,button:s}){s.onclick=()=>n.click(),n.onchange=()=>{i.add([...n.files]),n.value=""},e.addEventListener("paste",a=>{var o;const r=[...((o=a.clipboardData)==null?void 0:o.files)||[]];r.length&&(a.preventDefault(),i.add(r))}),t.addEventListener("dragover",a=>{[...a.dataTransfer.types].includes("Files")&&(a.preventDefault(),t.classList.add("dropping"))}),t.addEventListener("dragleave",a=>{t.contains(a.relatedTarget)||t.classList.remove("dropping")}),t.addEventListener("drop",a=>{t.classList.remove("dropping"),a.dataTransfer.files.length&&(a.preventDefault(),i.add([...a.dataTransfer.files]))})}const Dd=i=>i!=null&&i.length?`<div class="files">${i.map(t=>t.image?`<a class="thumb" href="${Vr(t)}" target="_blank" rel="noreferrer" title="${J(t.name)}"><img src="${Vr(t)}" alt="${J(t.name)}" loading="lazy"></a>`:t.audio?`<audio class="voice" controls preload="metadata" src="${Vr(t)}" title="${J(t.name)}"></audio>`:`<a class="file" href="${Vr(t)}" title="${J(t.name)} · ${bp(t.size)}"><b>FILE</b><span>${J(t.name)}</span></a>`).join("")}</div>`:"",Gr={more:'<svg viewBox="0 0 24 24"><path d="M7 7l5 5 5-5M7 13l5 5 5-5"/></svg>',speak:'<svg viewBox="0 0 24 24"><path d="M11 5 6 9H3v6h3l5 4V5Z"/><path d="M15.5 8.5a5 5 0 0 1 0 7"/></svg>',open:'<svg viewBox="0 0 24 24"><path d="M14 4h6v6M20 4l-9 9"/><path d="M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5"/></svg>',reply:'<svg viewBox="0 0 24 24"><path d="M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12z"/></svg>'};class J1{constructor(t){this.app=t,this.openId=null,this.repos=null,window.addEventListener("focus",()=>this.syncRepos()),document.addEventListener("visibilitychange",()=>{document.hidden||this.syncRepos()}),this.channels=[{id:"general",name:"general"}],this.channel=Ks("office.channel")||"general",this.unread=new Map,X("clear").onclick=async()=>{await Le("/api/jobs/clear",{}),this.closeDetail()},X("away").onclick=e=>{const n=e.target.closest("[data-recall]");n&&this.app.recall(n.dataset.recall)},X("jobs").onclick=e=>{const n=e.target.closest("[data-id]");n&&this.app.openJob(n.dataset.id)},X("projects").onclick=e=>{const n=e.target.closest(".job[data-id]");if(n)return this.app.openJob(n.dataset.id);const s=e.target.closest("[data-new]");if(s)return this.focusInput(`#${s.dataset.new.replace(/\s+/g,"-")} `);const a=e.target.closest("[data-project]");a&&(this.projectOpen=this.projectOpen===a.dataset.project?null:a.dataset.project,this.renderProjects())},document.querySelectorAll(".tabs button").forEach(e=>e.onclick=()=>this.tab(e.dataset.tab)),document.querySelectorAll("#mnav button").forEach(e=>e.onclick=()=>{e.dataset.m==="office"?this.mobile("office"):this.tab(e.dataset.m)}),this.bindViewToggle(),this.bindTeam(),this.bindChat(),this.bindChannels(),this.bindFold(),this.renderChannels(),addEventListener("keydown",e=>{var s;const n=/INPUT|TEXTAREA|SELECT/.test((s=document.activeElement)==null?void 0:s.tagName);(e.key==="n"||e.key==="/")&&!n&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),this.focusInput()),e.key==="Escape"&&!n&&this.closeDetail()}),setInterval(()=>this.tick(),1e3)}renderOwner(t){t=String(t||"").trim();const e=t?`${t}${/s$/i.test(t)?"’":"’s"} Office`:"Your Office";X("officeName").textContent=e,document.title=e}bindFold(){const t=X("fold"),e=X("gaugesBox"),n=a=>{e.hidden=!a,t.setAttribute("aria-expanded",String(a));const r=a?"Hide usage":"Show usage";t.setAttribute("aria-label",r),t.title=r;try{localStorage.setItem("office.gauges",a?"1":"0")}catch{}};let s=!1;try{s=localStorage.getItem("office.gauges")==="1"}catch{}n(s),t.addEventListener("click",()=>n(e.hidden)),X("officeName").addEventListener("click",()=>n(e.hidden))}renderLevel(t){const e=`${t.xp-t.floor} / ${t.next-t.floor} XP`;X("lvNum").textContent=t.level,X("lv").title=`Level ${t.level} · ${e}`,X("lv").setAttribute("aria-label",`Level ${t.level}, ${e}`),X("lv").style.setProperty("--p",Math.min(100,(t.xp-t.floor)/(t.next-t.floor)*100)),X("xptext").textContent=e}renderUsage(t){if(t!==void 0&&(this.usage=t),t=this.usage,X("usage").hidden=!t,!t)return;const e=t.error&&!t.session&&!t.week;X("useErr").hidden=!e,X("useErr").textContent=e?t.error:"";for(const[n,s]of[["useSession",t.session],["useWeek",t.week]]){const a=X(n);if(a.hidden=!s,!s)continue;const r=s.resetsAt?s.resetsAt-Date.now():null;a.className=`meter ${s.pct>=90?"hot":s.pct>=70?"warm":""}`,a.style.setProperty("--p",Math.min(100,s.pct)),a.querySelector(".v").textContent=`${s.pct}%`,a.querySelector(".r").textContent=r===null?"":r<=0?"Resetting now":`Resets in ${K1(r)}`,a.title=[s.resetsAt?`Resets ${Z1(s.resetsAt)}`:"",a.querySelector(".r").textContent].filter(Boolean).join(" · ")}}renderProc(t,e){e&&(this.machine=e),this.procs=t||null;const n=this.machine,s=Object.values(this.procs||{}).filter(u=>u);if(X("load").hidden=!s.length||!n,X("load").hidden)return this.renderMeta(this.app.job(this.openId));const a=s.reduce((u,d)=>u+(d.cpu||0),0),r=s.reduce((u,d)=>u+d.mem,0),o=a/n.cores,l=r/n.mem*100,c=`${s.length} ${s.length===1?"agent":"agents"}`,h=`${(a/100).toFixed(1)} of ${n.cores} cores`;this.meter("loadCpu",o,Rd(o),s.length>1?`${c} · ${h}`:h,`${c} using ${h}`),this.meter("loadMem",l,Ha(r),`${Rd(l)} of ${Ha(n.mem)}`,`${c} holding ${Ha(r)} of ${Ha(n.mem)}`),this.renderMeta(this.app.job(this.openId))}meter(t,e,n,s,a){const r=X(t);r.hidden=!1,r.className=`meter ${e>=90?"hot":e>=70?"warm":""}`,r.style.setProperty("--p",Math.min(100,e)),r.querySelector(".v").textContent=n,r.querySelector(".r").textContent=s,r.title=`${a} · ${s}`}renderStats(t,e=0){const n=a=>t.filter(r=>r.status===a&&!r.awaitingBoss).length,s=t.reduce((a,r)=>a+(r.cost||0),e);X("stats").innerHTML=[`<span><b>${n("working")}</b> working</span>`,`<span><b>${n("queued")}</b> queued</span>`,`<span><b>${n("done")}</b> shipped</span>`,`<span><b>$${s.toFixed(2)}</b> spent</span>`].join("")}renderJobs(t,e){const n={working:0,queued:1,done:2,failed:2,stopped:2},s=[...t].sort((h,u)=>n[h.status]-n[u.status]||(u.endedAt||u.queuedAt)-(h.endedAt||h.queuedAt)),a=h=>`
3909
3909
  <button class="job ${h.id===this.openId?"open":""}" data-id="${J(h.id)}">
3910
3910
  <span class="dot ${Ci(oa,h.status)}"></span>
3911
3911
  <span class="t" title="${J(h.title)}">${J(Cd(h.title))}</span>
@@ -4004,14 +4004,14 @@ In it: ${o}`:""}`;return`<button type="button" role="tab" aria-selected="${r}" c
4004
4004
  <p class="hint-t">Shapes how ${J(l.name)} writes and who the chief sends their way. It never lowers the bar on the work.</p>
4005
4005
  <div class="row"><button type="button" class="ghost small" data-cancel>Cancel</button><button type="submit" class="primary small">Save</button></div>
4006
4006
  </form>`,o=(l,c)=>c>=a?"Not hired yet":s.has(l.id)?"Gone home":"";if(this.view==="icons"){const l=e.find(c=>c.id===this.editing);X("team").innerHTML=`<div class="tiles">${e.map((c,h)=>{const u=o(c,h);return`<button type="button" class="tile${h>=a?" later":""}${c.id===this.editing?" open":""}" data-member="${J(c.id)}" aria-expanded="${c.id===this.editing}" title="${J(c.name)} · ${J(c.role||"No role yet")}${u?` · ${u}`:""}">
4007
- <span class="art">${bp(c)}</span>
4007
+ <span class="art">${Mp(c)}</span>
4008
4008
  <span class="n">${J(c.name)}</span>
4009
4009
  <span class="c">${u||J(c.role||"No role yet")}</span>
4010
4010
  </button>`}).join("")}</div>${l?`<div class="member open">${r(l)}</div>`:""}`;return}X("team").innerHTML=e.map((l,c)=>{const h=o(l,c),u=this.editing===l.id,d=`<button type="button" class="head" data-member="${J(l.id)}" aria-expanded="${u}">
4011
4011
  <i style="background:${ya(l.shirt)}"></i>
4012
4012
  <span class="n">${J(l.name)}${h?` <em>${h}</em>`:""}</span>
4013
4013
  <span class="r">${J(l.role||"No role yet")}</span>
4014
- </button>`;return u?`<div class="member open">${d}${r(l)}</div>`:`<div class="member${c>=a?" later":""}">${d}${l.personality?`<p class="p">${J(l.personality)}</p>`:""}</div>`}).join("")}renderAway(t){const e=X("away");e.hidden=!t.length,e.innerHTML=t.length?`<span>Gone home</span>${t.map(n=>`<button type="button" data-recall="${J(n.id)}" title="Call ${J(n.name)} back"><i style="background:${ya(n.shirt)}"></i>${J(n.name)}</button>`).join("")}`:""}banner(t,e){const n=X("banner");n.innerHTML=`<b>${J(t)}</b><span>${J(e)}</span>`,n.classList.remove("show"),n.offsetWidth,n.classList.add("show")}}const Tn=(i,t={})=>Object.assign(document.createElement(i),t),Wl=i=>i.toLowerCase().replace(/[^a-z0-9]/g,"");function Q1(i){return new Promise(t=>{const e=Date.now(),n=()=>{if(i.staff.length&&i.progress)return t(!0);if(Date.now()-e>15e3)return t(!1);setTimeout(n,200)};n()})}async function tM(i){if(!await Q1(i))return;const t=i.staff.slice(0,i.progress.capacity||0);if(!t.length)return;const e=Tn("dialog",{className:"name-ask meet"}),n=Tn("form",{method:"dialog"}),s=Tn("div",{className:"meet-list"}),a=t.map(f=>{const g=Tn("label",{className:"meet-row"}),_=Tn("i");_.style.background=f.shirt;const p=Tn("input",{type:"text",value:f.name,maxLength:20,required:!0,autocomplete:"off",spellcheck:!1,pattern:"[A-Za-z][A-Za-z0-9\\-]*",title:"One word: letters, numbers or hyphens"});p.setAttribute("aria-label",`Name for your ${f.role||"agent"}`);const m=Tn("span",{className:"meet-role",textContent:f.role||""});return g.append(_,p,m),s.append(g),{s:f,input:p}}),r=Tn("p",{className:"acct-note acct-err",hidden:!0}),o=Tn("button",{type:"submit",className:"primary small",textContent:"Done"}),l=Tn("button",{type:"button",className:"acct-forget",textContent:"Keep these names"}),c=Tn("div",{className:"meet-foot"});c.append(l,o),n.append(Tn("h2",{textContent:"Meet your team"}),Tn("p",{className:"acct-note",textContent:"These are the agents on your floor. Keep their names or give them your own. You tag them in chat by name, and you can rename them any time in the Team tab."}),s,r,c),e.append(n);const h=()=>{e.close(),e.remove()};l.addEventListener("click",h),e.addEventListener("cancel",h),n.addEventListener("submit",async f=>{f.preventDefault(),r.hidden=!0;const g=a.filter(({s:p,input:m})=>m.value.trim()!==p.name),_=new Map;for(const{input:p}of a){const m=Wl(p.value);if(_.has(m))return u(`Two agents can't both be ${p.value.trim()}.`,p);_.set(m,p)}o.disabled=!0;for(const{s:p,input:m}of d(g))try{i.applyProfile(p.id,await Le(`/api/staff/${p.id}/profile`,{name:m.value.trim()}))}catch(y){return o.disabled=!1,u(`${p.name}: ${y.message}`,m)}h()});function u(f,g){r.textContent=f,r.hidden=!1,g.focus(),g.select()}function d(f){const g=[],_=[...f];for(;_.length;){const p=_.findIndex(({input:m})=>!_.some(y=>Wl(y.s.name)===Wl(m.value)));g.push(..._.splice(p<0?0:p,1))}return g}document.body.append(e),e.showModal(),a[0].input.focus(),a[0].input.select()}const Id={type:"change"},qh={type:"start"},wp={type:"end"},$r=new Ih,kd=new Ji,eM=Math.cos(70*aa.DEG2RAD),Be=new C,vn=2*Math.PI,pe={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Xl=1e-6;class nM extends B1{constructor(t,e=null){super(t,e),this.state=pe.NONE,this.enabled=!0,this.target=new C,this.cursor=new C,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:ki.ROTATE,MIDDLE:ki.DOLLY,RIGHT:ki.PAN},this.touches={ONE:rs.ROTATE,TWO:rs.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new C,this._lastQuaternion=new hs,this._lastTargetPosition=new C,this._quat=new hs().setFromUnitVectors(t.up,new C(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Aa,this._sphericalDelta=new Aa,this._scale=1,this._panOffset=new C,this._rotateStart=new lt,this._rotateEnd=new lt,this._rotateDelta=new lt,this._panStart=new lt,this._panEnd=new lt,this._panDelta=new lt,this._dollyStart=new lt,this._dollyEnd=new lt,this._dollyDelta=new lt,this._dollyDirection=new C,this._mouse=new lt,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=sM.bind(this),this._onPointerDown=iM.bind(this),this._onPointerUp=aM.bind(this),this._onContextMenu=dM.bind(this),this._onMouseWheel=lM.bind(this),this._onKeyDown=cM.bind(this),this._onTouchStart=hM.bind(this),this._onTouchMove=uM.bind(this),this._onMouseDown=rM.bind(this),this._onMouseMove=oM.bind(this),this._interceptControlDown=fM.bind(this),this._interceptControlUp=pM.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Id),this.update(),this.state=pe.NONE}update(t=null){const e=this.object.position;Be.copy(e).sub(this.target),Be.applyQuaternion(this._quat),this._spherical.setFromVector3(Be),this.autoRotate&&this.state===pe.NONE&&this._rotateLeft(this._getAutoRotationAngle(t)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=vn:n>Math.PI&&(n-=vn),s<-Math.PI?s+=vn:s>Math.PI&&(s-=vn),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const r=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=r!=this._spherical.radius}if(Be.setFromSpherical(this._spherical),Be.applyQuaternion(this._quatInverse),e.copy(this.target).add(Be),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let r=null;if(this.object.isPerspectiveCamera){const o=Be.length();r=this._clampDistance(o*this._scale);const l=o-r;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),a=!!l}else if(this.object.isOrthographicCamera){const o=new C(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=l!==this.object.zoom;const c=new C(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),r=Be.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;r!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(r).add(this.object.position):($r.origin.copy(this.object.position),$r.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot($r.direction))<eM?this.object.lookAt(this.target):(kd.setFromNormalAndCoplanarPoint(this.object.up,this.target),$r.intersectPlane(kd,this.target))))}else if(this.object.isOrthographicCamera){const r=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),r!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>Xl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Xl||this._lastTargetPosition.distanceToSquared(this.target)>Xl?(this.dispatchEvent(Id),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?vn/60*this.autoRotateSpeed*t:vn/60/60*this.autoRotateSpeed}_getZoomScale(t){const e=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){Be.setFromMatrixColumn(e,0),Be.multiplyScalar(-t),this._panOffset.add(Be)}_panUp(t,e){this.screenSpacePanning===!0?Be.setFromMatrixColumn(e,1):(Be.setFromMatrixColumn(e,0),Be.crossVectors(this.object.up,Be)),Be.multiplyScalar(t),this._panOffset.add(Be)}_pan(t,e){const n=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Be.copy(s).sub(this.target);let a=Be.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*a/n.clientHeight,this.object.matrix),this._panUp(2*e*a/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),s=t-n.left,a=e-n.top,r=n.width,o=n.height;this._mouse.x=s/r*2-1,this._mouse.y=-(a/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(vn*this._rotateDelta.x/e.clientHeight),this._rotateUp(vn*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(vn*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(-vn*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(vn*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(-vn*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panStart.set(n,s)}}_handleTouchStartDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.y,a=Math.sqrt(n*n+s*s);this._dollyStart.set(0,a)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{const n=this._getSecondPointerPosition(t),s=.5*(t.pageX+n.x),a=.5*(t.pageY+n.y);this._rotateEnd.set(s,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(vn*this._rotateDelta.x/e.clientHeight),this._rotateUp(vn*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.y,a=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,a),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const r=(t.pageX+e.x)*.5,o=(t.pageY+e.y)*.5;this._updateZoomParameters(r,o)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId){this._pointers.splice(e,1);return}}_isTrackingPointer(t){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return!0;return!1}_trackPointer(t){let e=this._pointerPositions[t.pointerId];e===void 0&&(e=new lt,this._pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){const e=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(t){const e=t.deltaMode,n={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return t.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function iM(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function sM(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function aM(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(wp),this.state=pe.NONE;break;case 1:const t=this._pointers[0],e=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:e.x,pageY:e.y});break}}function rM(i){let t;switch(i.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case ki.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=pe.DOLLY;break;case ki.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=pe.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=pe.ROTATE}break;case ki.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=pe.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=pe.PAN}break;default:this.state=pe.NONE}this.state!==pe.NONE&&this.dispatchEvent(qh)}function oM(i){switch(this.state){case pe.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case pe.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case pe.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function lM(i){this.enabled===!1||this.enableZoom===!1||this.state!==pe.NONE||(i.preventDefault(),this.dispatchEvent(qh),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(wp))}function cM(i){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(i)}function hM(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case rs.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=pe.TOUCH_ROTATE;break;case rs.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=pe.TOUCH_PAN;break;default:this.state=pe.NONE}break;case 2:switch(this.touches.TWO){case rs.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=pe.TOUCH_DOLLY_PAN;break;case rs.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=pe.TOUCH_DOLLY_ROTATE;break;default:this.state=pe.NONE}break;default:this.state=pe.NONE}this.state!==pe.NONE&&this.dispatchEvent(qh)}function uM(i){switch(this._trackPointer(i),this.state){case pe.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case pe.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case pe.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case pe.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=pe.NONE}}function dM(i){this.enabled!==!1&&i.preventDefault()}function fM(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function pM(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class mM extends nM{constructor(t,e){super(t,e),this.screenSpacePanning=!1,this.mouseButtons={LEFT:ki.PAN,MIDDLE:ki.DOLLY,RIGHT:ki.ROTATE},this.touches={ONE:rs.PAN,TWO:rs.DOLLY_ROTATE}}}class gM extends dp{constructor(){super();const t=new Ye;t.deleteAttribute("uv");const e=new Dn({side:fn}),n=new Dn,s=new O1(16777215,900,28,2);s.position.set(.418,16.199,.3),this.add(s);const a=new yt(t,e);a.position.set(-.757,13.219,.717),a.scale.set(31.713,28.305,28.591),this.add(a);const r=new yt(t,n);r.position.set(-10.906,2.009,1.846),r.rotation.set(0,-.195,0),r.scale.set(2.328,7.905,4.651),this.add(r);const o=new yt(t,n);o.position.set(-5.607,-.754,-.758),o.rotation.set(0,.994,0),o.scale.set(1.97,1.534,3.955),this.add(o);const l=new yt(t,n);l.position.set(6.167,.857,7.803),l.rotation.set(0,.561,0),l.scale.set(3.927,6.285,3.687),this.add(l);const c=new yt(t,n);c.position.set(-2.017,.018,6.124),c.rotation.set(0,.333,0),c.scale.set(2.002,4.566,2.064),this.add(c);const h=new yt(t,n);h.position.set(2.291,-.756,-2.621),h.rotation.set(0,-.286,0),h.scale.set(1.546,1.552,1.496),this.add(h);const u=new yt(t,n);u.position.set(-2.193,-.369,-5.547),u.rotation.set(0,.516,0),u.scale.set(3.875,3.487,2.986),this.add(u);const d=new yt(t,Zs(50));d.position.set(-16.116,14.37,8.208),d.scale.set(.1,2.428,2.739),this.add(d);const f=new yt(t,Zs(50));f.position.set(-16.109,18.021,-8.207),f.scale.set(.1,2.425,2.751),this.add(f);const g=new yt(t,Zs(17));g.position.set(14.904,12.198,-1.832),g.scale.set(.15,4.265,6.331),this.add(g);const _=new yt(t,Zs(43));_.position.set(-.462,8.89,14.52),_.scale.set(4.38,5.441,.088),this.add(_);const p=new yt(t,Zs(20));p.position.set(3.235,11.486,-12.541),p.scale.set(2.5,2,.1),this.add(p);const m=new yt(t,Zs(100));m.position.set(0,20,0),m.scale.set(1,.1,1),this.add(m)}dispose(){const t=new Set;this.traverse(e=>{e.isMesh&&(t.add(e.geometry),t.add(e.material))});for(const e of t)e.dispose()}}function Zs(i){const t=new cn;return t.color.setScalar(i),t}const fo={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
4014
+ </button>`;return u?`<div class="member open">${d}${r(l)}</div>`:`<div class="member${c>=a?" later":""}">${d}${l.personality?`<p class="p">${J(l.personality)}</p>`:""}</div>`}).join("")}renderAway(t){const e=X("away");e.hidden=!t.length,e.innerHTML=t.length?`<span>Gone home</span>${t.map(n=>`<button type="button" data-recall="${J(n.id)}" title="Call ${J(n.name)} back"><i style="background:${ya(n.shirt)}"></i>${J(n.name)}</button>`).join("")}`:""}banner(t,e){const n=X("banner");n.innerHTML=`<b>${J(t)}</b><span>${J(e)}</span>`,n.classList.remove("show"),n.offsetWidth,n.classList.add("show")}}const Tn=(i,t={})=>Object.assign(document.createElement(i),t),Wl=i=>i.toLowerCase().replace(/[^a-z0-9]/g,"");function Q1(i){return new Promise(t=>{const e=Date.now(),n=()=>{if(i.staff.length&&i.progress)return t(!0);if(Date.now()-e>15e3)return t(!1);setTimeout(n,200)};n()})}async function tM(i){if(!await Q1(i))return;const t=i.staff.slice(0,i.progress.capacity||0);if(!t.length)return;const e=Tn("dialog",{className:"name-ask meet"}),n=Tn("form",{method:"dialog"}),s=Tn("div",{className:"meet-list"}),a=t.map(f=>{const g=Tn("label",{className:"meet-row"}),_=Tn("i");_.style.background=f.shirt;const p=Tn("input",{type:"text",value:f.name,maxLength:20,required:!0,autocomplete:"off",spellcheck:!1,pattern:"[A-Za-z][A-Za-z0-9\\-]*",title:"One word: letters, numbers or hyphens"});p.setAttribute("aria-label",`Name for your ${f.role||"agent"}`);const m=Tn("span",{className:"meet-role",textContent:f.role||""});return g.append(_,p,m),s.append(g),{s:f,input:p}}),r=Tn("p",{className:"acct-note acct-err",hidden:!0}),o=Tn("button",{type:"submit",className:"primary small",textContent:"Done"}),l=Tn("button",{type:"button",className:"acct-forget",textContent:"Keep these names"}),c=Tn("div",{className:"meet-foot"});c.append(l,o),n.append(Tn("h2",{textContent:"Meet your team"}),Tn("p",{className:"acct-note",textContent:"These are the agents on your floor. Keep their names or give them your own. You tag them in chat by name, and you can rename them any time in the Team tab."}),s,r,c),e.append(n);const h=()=>{e.close(),e.remove()};l.addEventListener("click",h),e.addEventListener("cancel",h),n.addEventListener("submit",async f=>{f.preventDefault(),r.hidden=!0;const g=a.filter(({s:p,input:m})=>m.value.trim()!==p.name),_=new Map;for(const{input:p}of a){const m=Wl(p.value);if(_.has(m))return u(`Two agents can't both be ${p.value.trim()}.`,p);_.set(m,p)}o.disabled=!0;for(const{s:p,input:m}of d(g))try{i.applyProfile(p.id,await Le(`/api/staff/${p.id}/profile`,{name:m.value.trim()}))}catch(y){return o.disabled=!1,u(`${p.name}: ${y.message}`,m)}h()});function u(f,g){r.textContent=f,r.hidden=!1,g.focus(),g.select()}function d(f){const g=[],_=[...f];for(;_.length;){const p=_.findIndex(({input:m})=>!_.some(y=>Wl(y.s.name)===Wl(m.value)));g.push(..._.splice(p<0?0:p,1))}return g}document.body.append(e),e.showModal(),a[0].input.focus(),a[0].input.select()}const Id={type:"change"},qh={type:"start"},Sp={type:"end"},$r=new Ih,kd=new Ji,eM=Math.cos(70*aa.DEG2RAD),Be=new C,vn=2*Math.PI,pe={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Xl=1e-6;class nM extends B1{constructor(t,e=null){super(t,e),this.state=pe.NONE,this.enabled=!0,this.target=new C,this.cursor=new C,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:ki.ROTATE,MIDDLE:ki.DOLLY,RIGHT:ki.PAN},this.touches={ONE:rs.ROTATE,TWO:rs.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new C,this._lastQuaternion=new hs,this._lastTargetPosition=new C,this._quat=new hs().setFromUnitVectors(t.up,new C(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Aa,this._sphericalDelta=new Aa,this._scale=1,this._panOffset=new C,this._rotateStart=new lt,this._rotateEnd=new lt,this._rotateDelta=new lt,this._panStart=new lt,this._panEnd=new lt,this._panDelta=new lt,this._dollyStart=new lt,this._dollyEnd=new lt,this._dollyDelta=new lt,this._dollyDirection=new C,this._mouse=new lt,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=sM.bind(this),this._onPointerDown=iM.bind(this),this._onPointerUp=aM.bind(this),this._onContextMenu=dM.bind(this),this._onMouseWheel=lM.bind(this),this._onKeyDown=cM.bind(this),this._onTouchStart=hM.bind(this),this._onTouchMove=uM.bind(this),this._onMouseDown=rM.bind(this),this._onMouseMove=oM.bind(this),this._interceptControlDown=fM.bind(this),this._interceptControlUp=pM.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(t){t.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=t}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Id),this.update(),this.state=pe.NONE}update(t=null){const e=this.object.position;Be.copy(e).sub(this.target),Be.applyQuaternion(this._quat),this._spherical.setFromVector3(Be),this.autoRotate&&this.state===pe.NONE&&this._rotateLeft(this._getAutoRotationAngle(t)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=vn:n>Math.PI&&(n-=vn),s<-Math.PI?s+=vn:s>Math.PI&&(s-=vn),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const r=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=r!=this._spherical.radius}if(Be.setFromSpherical(this._spherical),Be.applyQuaternion(this._quatInverse),e.copy(this.target).add(Be),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let r=null;if(this.object.isPerspectiveCamera){const o=Be.length();r=this._clampDistance(o*this._scale);const l=o-r;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),a=!!l}else if(this.object.isOrthographicCamera){const o=new C(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=l!==this.object.zoom;const c=new C(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),r=Be.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;r!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(r).add(this.object.position):($r.origin.copy(this.object.position),$r.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot($r.direction))<eM?this.object.lookAt(this.target):(kd.setFromNormalAndCoplanarPoint(this.object.up,this.target),$r.intersectPlane(kd,this.target))))}else if(this.object.isOrthographicCamera){const r=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),r!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>Xl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Xl||this._lastTargetPosition.distanceToSquared(this.target)>Xl?(this.dispatchEvent(Id),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(t){return t!==null?vn/60*this.autoRotateSpeed*t:vn/60/60*this.autoRotateSpeed}_getZoomScale(t){const e=Math.abs(t*.01);return Math.pow(.95,this.zoomSpeed*e)}_rotateLeft(t){this._sphericalDelta.theta-=t}_rotateUp(t){this._sphericalDelta.phi-=t}_panLeft(t,e){Be.setFromMatrixColumn(e,0),Be.multiplyScalar(-t),this._panOffset.add(Be)}_panUp(t,e){this.screenSpacePanning===!0?Be.setFromMatrixColumn(e,1):(Be.setFromMatrixColumn(e,0),Be.crossVectors(this.object.up,Be)),Be.multiplyScalar(t),this._panOffset.add(Be)}_pan(t,e){const n=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Be.copy(s).sub(this.target);let a=Be.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*t*a/n.clientHeight,this.object.matrix),this._panUp(2*e*a/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(t*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(e*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(t){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(t,e){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),s=t-n.left,a=e-n.top,r=n.width,o=n.height;this._mouse.x=s/r*2-1,this._mouse.y=-(a/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(t){return Math.max(this.minDistance,Math.min(this.maxDistance,t))}_handleMouseDownRotate(t){this._rotateStart.set(t.clientX,t.clientY)}_handleMouseDownDolly(t){this._updateZoomParameters(t.clientX,t.clientX),this._dollyStart.set(t.clientX,t.clientY)}_handleMouseDownPan(t){this._panStart.set(t.clientX,t.clientY)}_handleMouseMoveRotate(t){this._rotateEnd.set(t.clientX,t.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(vn*this._rotateDelta.x/e.clientHeight),this._rotateUp(vn*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(t){this._dollyEnd.set(t.clientX,t.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(t){this._panEnd.set(t.clientX,t.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(t){this._updateZoomParameters(t.clientX,t.clientY),t.deltaY<0?this._dollyIn(this._getZoomScale(t.deltaY)):t.deltaY>0&&this._dollyOut(this._getZoomScale(t.deltaY)),this.update()}_handleKeyDown(t){let e=!1;switch(t.code){case this.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(vn*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),e=!0;break;case this.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateUp(-vn*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),e=!0;break;case this.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(vn*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),e=!0;break;case this.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?this._rotateLeft(-vn*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),e=!0;break}e&&(t.preventDefault(),this.update())}_handleTouchStartRotate(t){if(this._pointers.length===1)this._rotateStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(t){if(this._pointers.length===1)this._panStart.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panStart.set(n,s)}}_handleTouchStartDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.y,a=Math.sqrt(n*n+s*s);this._dollyStart.set(0,a)}_handleTouchStartDollyPan(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enablePan&&this._handleTouchStartPan(t)}_handleTouchStartDollyRotate(t){this.enableZoom&&this._handleTouchStartDolly(t),this.enableRotate&&this._handleTouchStartRotate(t)}_handleTouchMoveRotate(t){if(this._pointers.length==1)this._rotateEnd.set(t.pageX,t.pageY);else{const n=this._getSecondPointerPosition(t),s=.5*(t.pageX+n.x),a=.5*(t.pageY+n.y);this._rotateEnd.set(s,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const e=this.domElement;this._rotateLeft(vn*this._rotateDelta.x/e.clientHeight),this._rotateUp(vn*this._rotateDelta.y/e.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(t){if(this._pointers.length===1)this._panEnd.set(t.pageX,t.pageY);else{const e=this._getSecondPointerPosition(t),n=.5*(t.pageX+e.x),s=.5*(t.pageY+e.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(t){const e=this._getSecondPointerPosition(t),n=t.pageX-e.x,s=t.pageY-e.y,a=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,a),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const r=(t.pageX+e.x)*.5,o=(t.pageY+e.y)*.5;this._updateZoomParameters(r,o)}_handleTouchMoveDollyPan(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enablePan&&this._handleTouchMovePan(t)}_handleTouchMoveDollyRotate(t){this.enableZoom&&this._handleTouchMoveDolly(t),this.enableRotate&&this._handleTouchMoveRotate(t)}_addPointer(t){this._pointers.push(t.pointerId)}_removePointer(t){delete this._pointerPositions[t.pointerId];for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId){this._pointers.splice(e,1);return}}_isTrackingPointer(t){for(let e=0;e<this._pointers.length;e++)if(this._pointers[e]==t.pointerId)return!0;return!1}_trackPointer(t){let e=this._pointerPositions[t.pointerId];e===void 0&&(e=new lt,this._pointerPositions[t.pointerId]=e),e.set(t.pageX,t.pageY)}_getSecondPointerPosition(t){const e=t.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[e]}_customWheelEvent(t){const e=t.deltaMode,n={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(e){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return t.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function iM(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function sM(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function aM(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Sp),this.state=pe.NONE;break;case 1:const t=this._pointers[0],e=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:e.x,pageY:e.y});break}}function rM(i){let t;switch(i.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case ki.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=pe.DOLLY;break;case ki.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=pe.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=pe.ROTATE}break;case ki.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=pe.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=pe.PAN}break;default:this.state=pe.NONE}this.state!==pe.NONE&&this.dispatchEvent(qh)}function oM(i){switch(this.state){case pe.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case pe.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case pe.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function lM(i){this.enabled===!1||this.enableZoom===!1||this.state!==pe.NONE||(i.preventDefault(),this.dispatchEvent(qh),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(Sp))}function cM(i){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(i)}function hM(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case rs.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=pe.TOUCH_ROTATE;break;case rs.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=pe.TOUCH_PAN;break;default:this.state=pe.NONE}break;case 2:switch(this.touches.TWO){case rs.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=pe.TOUCH_DOLLY_PAN;break;case rs.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=pe.TOUCH_DOLLY_ROTATE;break;default:this.state=pe.NONE}break;default:this.state=pe.NONE}this.state!==pe.NONE&&this.dispatchEvent(qh)}function uM(i){switch(this._trackPointer(i),this.state){case pe.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case pe.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case pe.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case pe.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=pe.NONE}}function dM(i){this.enabled!==!1&&i.preventDefault()}function fM(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function pM(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class mM extends nM{constructor(t,e){super(t,e),this.screenSpacePanning=!1,this.mouseButtons={LEFT:ki.PAN,MIDDLE:ki.DOLLY,RIGHT:ki.ROTATE},this.touches={ONE:rs.PAN,TWO:rs.DOLLY_ROTATE}}}class gM extends up{constructor(){super();const t=new Ye;t.deleteAttribute("uv");const e=new Dn({side:fn}),n=new Dn,s=new O1(16777215,900,28,2);s.position.set(.418,16.199,.3),this.add(s);const a=new yt(t,e);a.position.set(-.757,13.219,.717),a.scale.set(31.713,28.305,28.591),this.add(a);const r=new yt(t,n);r.position.set(-10.906,2.009,1.846),r.rotation.set(0,-.195,0),r.scale.set(2.328,7.905,4.651),this.add(r);const o=new yt(t,n);o.position.set(-5.607,-.754,-.758),o.rotation.set(0,.994,0),o.scale.set(1.97,1.534,3.955),this.add(o);const l=new yt(t,n);l.position.set(6.167,.857,7.803),l.rotation.set(0,.561,0),l.scale.set(3.927,6.285,3.687),this.add(l);const c=new yt(t,n);c.position.set(-2.017,.018,6.124),c.rotation.set(0,.333,0),c.scale.set(2.002,4.566,2.064),this.add(c);const h=new yt(t,n);h.position.set(2.291,-.756,-2.621),h.rotation.set(0,-.286,0),h.scale.set(1.546,1.552,1.496),this.add(h);const u=new yt(t,n);u.position.set(-2.193,-.369,-5.547),u.rotation.set(0,.516,0),u.scale.set(3.875,3.487,2.986),this.add(u);const d=new yt(t,Zs(50));d.position.set(-16.116,14.37,8.208),d.scale.set(.1,2.428,2.739),this.add(d);const f=new yt(t,Zs(50));f.position.set(-16.109,18.021,-8.207),f.scale.set(.1,2.425,2.751),this.add(f);const g=new yt(t,Zs(17));g.position.set(14.904,12.198,-1.832),g.scale.set(.15,4.265,6.331),this.add(g);const _=new yt(t,Zs(43));_.position.set(-.462,8.89,14.52),_.scale.set(4.38,5.441,.088),this.add(_);const p=new yt(t,Zs(20));p.position.set(3.235,11.486,-12.541),p.scale.set(2.5,2,.1),this.add(p);const m=new yt(t,Zs(100));m.position.set(0,20,0),m.scale.set(1,.1,1),this.add(m)}dispose(){const t=new Set;this.traverse(e=>{e.isMesh&&(t.add(e.geometry),t.add(e.material))});for(const e of t)e.dispose()}}function Zs(i){const t=new ln;return t.color.setScalar(i),t}const fo={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
4015
4015
 
4016
4016
  varying vec2 vUv;
4017
4017
 
@@ -4034,7 +4034,7 @@ In it: ${o}`:""}`;return`<button type="button" role="tab" aria-selected="${r}" c
4034
4034
  gl_FragColor = opacity * texel;
4035
4035
 
4036
4036
 
4037
- }`};class La{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const vM=new Uh(-1,1,1,-1,0,1);class _M extends pn{constructor(){super(),this.setAttribute("position",new ue([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new ue([0,2,0,0,2,0],2))}}const xM=new _M;class jh{constructor(t){this._mesh=new yt(xM,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,vM)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}class yM extends La{constructor(t,e){super(),this.textureID=e!==void 0?e:"tDiffuse",t instanceof rn?(this.uniforms=t.uniforms,this.material=t):t&&(this.uniforms=es.clone(t.uniforms),this.material=new rn({name:t.name!==void 0?t.name:"unspecified",defines:Object.assign({},t.defines),uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader})),this.fsQuad=new jh(this.material)}render(t,e,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(t.setRenderTarget(null),this.fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this.fsQuad.render(t))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class Nd extends La{constructor(t,e){super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(t,e,n){const s=t.getContext(),a=t.state;a.buffers.color.setMask(!1),a.buffers.depth.setMask(!1),a.buffers.color.setLocked(!0),a.buffers.depth.setLocked(!0);let r,o;this.inverse?(r=0,o=1):(r=1,o=0),a.buffers.stencil.setTest(!0),a.buffers.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),a.buffers.stencil.setFunc(s.ALWAYS,r,4294967295),a.buffers.stencil.setClear(o),a.buffers.stencil.setLocked(!0),t.setRenderTarget(n),this.clear&&t.clear(),t.render(this.scene,this.camera),t.setRenderTarget(e),this.clear&&t.clear(),t.render(this.scene,this.camera),a.buffers.color.setLocked(!1),a.buffers.depth.setLocked(!1),a.buffers.color.setMask(!0),a.buffers.depth.setMask(!0),a.buffers.stencil.setLocked(!1),a.buffers.stencil.setFunc(s.EQUAL,1,4294967295),a.buffers.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),a.buffers.stencil.setLocked(!0)}}class MM extends La{constructor(){super(),this.needsSwap=!1}render(t){t.state.buffers.stencil.setLocked(!1),t.state.buffers.stencil.setTest(!1)}}class bM{constructor(t,e){if(this.renderer=t,this._pixelRatio=t.getPixelRatio(),e===void 0){const n=t.getSize(new lt);this._width=n.width,this._height=n.height,e=new ei(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Fi}),e.texture.name="EffectComposer.rt1"}else this._width=e.width,this._height=e.height;this.renderTarget1=e,this.renderTarget2=e.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new yM(fo),this.copyPass.material.blending=Je,this.clock=new xp}swapBuffers(){const t=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=t}addPass(t){this.passes.push(t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(t,e){this.passes.splice(e,0,t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(t){const e=this.passes.indexOf(t);e!==-1&&this.passes.splice(e,1)}isLastEnabledPass(t){for(let e=t+1;e<this.passes.length;e++)if(this.passes[e].enabled)return!1;return!0}render(t){t===void 0&&(t=this.clock.getDelta());const e=this.renderer.getRenderTarget();let n=!1;for(let s=0,a=this.passes.length;s<a;s++){const r=this.passes[s];if(r.enabled!==!1){if(r.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(s),r.render(this.renderer,this.writeBuffer,this.readBuffer,t,n),r.needsSwap){if(n){const o=this.renderer.getContext(),l=this.renderer.state.buffers.stencil;l.setFunc(o.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,t),l.setFunc(o.EQUAL,1,4294967295)}this.swapBuffers()}Nd!==void 0&&(r instanceof Nd?n=!0:r instanceof MM&&(n=!1))}}this.renderer.setRenderTarget(e)}reset(t){if(t===void 0){const e=this.renderer.getSize(new lt);this._pixelRatio=this.renderer.getPixelRatio(),this._width=e.width,this._height=e.height,t=this.renderTarget1.clone(),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=t,this.renderTarget2=t.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(t,e){this._width=t,this._height=e;const n=this._width*this._pixelRatio,s=this._height*this._pixelRatio;this.renderTarget1.setSize(n,s),this.renderTarget2.setSize(n,s);for(let a=0;a<this.passes.length;a++)this.passes[a].setSize(n,s)}setPixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class SM extends La{constructor(t,e,n=null,s=null,a=null){super(),this.scene=t,this.camera=e,this.overrideMaterial=n,this.clearColor=s,this.clearAlpha=a,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new te}render(t,e,n){const s=t.autoClear;t.autoClear=!1;let a,r;this.overrideMaterial!==null&&(r=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(t.getClearColor(this._oldClearColor),t.setClearColor(this.clearColor,t.getClearAlpha())),this.clearAlpha!==null&&(a=t.getClearAlpha(),t.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&t.clearDepth(),t.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),t.render(this.scene,this.camera),this.clearColor!==null&&t.setClearColor(this._oldClearColor),this.clearAlpha!==null&&t.setClearAlpha(a),this.overrideMaterial!==null&&(this.scene.overrideMaterial=r),t.autoClear=s}}const Wr={defines:{PERSPECTIVE_CAMERA:1,SAMPLES:16,NORMAL_VECTOR_TYPE:1,DEPTH_SWIZZLING:"x",SCREEN_SPACE_RADIUS:0,SCREEN_SPACE_RADIUS_SCALE:100,SCENE_CLIP_BOX:0},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new lt},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new fe},cameraProjectionMatrixInverse:{value:new fe},cameraWorldMatrix:{value:new fe},radius:{value:.25},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},scale:{value:1},sceneBoxMin:{value:new C(-1,-1,-1)},sceneBoxMax:{value:new C(1,1,1)}},vertexShader:`
4037
+ }`};class La{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const vM=new Uh(-1,1,1,-1,0,1);class _M extends pn{constructor(){super(),this.setAttribute("position",new ue([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new ue([0,2,0,0,2,0],2))}}const xM=new _M;class jh{constructor(t){this._mesh=new yt(xM,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,vM)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}class yM extends La{constructor(t,e){super(),this.textureID=e!==void 0?e:"tDiffuse",t instanceof an?(this.uniforms=t.uniforms,this.material=t):t&&(this.uniforms=es.clone(t.uniforms),this.material=new an({name:t.name!==void 0?t.name:"unspecified",defines:Object.assign({},t.defines),uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader})),this.fsQuad=new jh(this.material)}render(t,e,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(t.setRenderTarget(null),this.fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this.fsQuad.render(t))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class Nd extends La{constructor(t,e){super(),this.scene=t,this.camera=e,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(t,e,n){const s=t.getContext(),a=t.state;a.buffers.color.setMask(!1),a.buffers.depth.setMask(!1),a.buffers.color.setLocked(!0),a.buffers.depth.setLocked(!0);let r,o;this.inverse?(r=0,o=1):(r=1,o=0),a.buffers.stencil.setTest(!0),a.buffers.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),a.buffers.stencil.setFunc(s.ALWAYS,r,4294967295),a.buffers.stencil.setClear(o),a.buffers.stencil.setLocked(!0),t.setRenderTarget(n),this.clear&&t.clear(),t.render(this.scene,this.camera),t.setRenderTarget(e),this.clear&&t.clear(),t.render(this.scene,this.camera),a.buffers.color.setLocked(!1),a.buffers.depth.setLocked(!1),a.buffers.color.setMask(!0),a.buffers.depth.setMask(!0),a.buffers.stencil.setLocked(!1),a.buffers.stencil.setFunc(s.EQUAL,1,4294967295),a.buffers.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),a.buffers.stencil.setLocked(!0)}}class MM extends La{constructor(){super(),this.needsSwap=!1}render(t){t.state.buffers.stencil.setLocked(!1),t.state.buffers.stencil.setTest(!1)}}class bM{constructor(t,e){if(this.renderer=t,this._pixelRatio=t.getPixelRatio(),e===void 0){const n=t.getSize(new lt);this._width=n.width,this._height=n.height,e=new ei(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Fi}),e.texture.name="EffectComposer.rt1"}else this._width=e.width,this._height=e.height;this.renderTarget1=e,this.renderTarget2=e.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new yM(fo),this.copyPass.material.blending=Je,this.clock=new _p}swapBuffers(){const t=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=t}addPass(t){this.passes.push(t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(t,e){this.passes.splice(e,0,t),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(t){const e=this.passes.indexOf(t);e!==-1&&this.passes.splice(e,1)}isLastEnabledPass(t){for(let e=t+1;e<this.passes.length;e++)if(this.passes[e].enabled)return!1;return!0}render(t){t===void 0&&(t=this.clock.getDelta());const e=this.renderer.getRenderTarget();let n=!1;for(let s=0,a=this.passes.length;s<a;s++){const r=this.passes[s];if(r.enabled!==!1){if(r.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(s),r.render(this.renderer,this.writeBuffer,this.readBuffer,t,n),r.needsSwap){if(n){const o=this.renderer.getContext(),l=this.renderer.state.buffers.stencil;l.setFunc(o.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,t),l.setFunc(o.EQUAL,1,4294967295)}this.swapBuffers()}Nd!==void 0&&(r instanceof Nd?n=!0:r instanceof MM&&(n=!1))}}this.renderer.setRenderTarget(e)}reset(t){if(t===void 0){const e=this.renderer.getSize(new lt);this._pixelRatio=this.renderer.getPixelRatio(),this._width=e.width,this._height=e.height,t=this.renderTarget1.clone(),t.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=t,this.renderTarget2=t.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(t,e){this._width=t,this._height=e;const n=this._width*this._pixelRatio,s=this._height*this._pixelRatio;this.renderTarget1.setSize(n,s),this.renderTarget2.setSize(n,s);for(let a=0;a<this.passes.length;a++)this.passes[a].setSize(n,s)}setPixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class SM extends La{constructor(t,e,n=null,s=null,a=null){super(),this.scene=t,this.camera=e,this.overrideMaterial=n,this.clearColor=s,this.clearAlpha=a,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new te}render(t,e,n){const s=t.autoClear;t.autoClear=!1;let a,r;this.overrideMaterial!==null&&(r=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(t.getClearColor(this._oldClearColor),t.setClearColor(this.clearColor,t.getClearAlpha())),this.clearAlpha!==null&&(a=t.getClearAlpha(),t.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&t.clearDepth(),t.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),t.render(this.scene,this.camera),this.clearColor!==null&&t.setClearColor(this._oldClearColor),this.clearAlpha!==null&&t.setClearAlpha(a),this.overrideMaterial!==null&&(this.scene.overrideMaterial=r),t.autoClear=s}}const Wr={defines:{PERSPECTIVE_CAMERA:1,SAMPLES:16,NORMAL_VECTOR_TYPE:1,DEPTH_SWIZZLING:"x",SCREEN_SPACE_RADIUS:0,SCREEN_SPACE_RADIUS_SCALE:100,SCENE_CLIP_BOX:0},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new lt},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new fe},cameraProjectionMatrixInverse:{value:new fe},cameraWorldMatrix:{value:new fe},radius:{value:.25},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},scale:{value:1},sceneBoxMin:{value:new C(-1,-1,-1)},sceneBoxMax:{value:new C(1,1,1)}},vertexShader:`
4038
4038
 
4039
4039
  varying vec2 vUv;
4040
4040
 
@@ -4259,7 +4259,7 @@ In it: ${o}`:""}`;return`<button type="button" role="tab" aria-selected="${r}" c
4259
4259
  void main() {
4260
4260
  vec4 texel = texture2D( tDiffuse, vUv );
4261
4261
  gl_FragColor = vec4(mix(vec3(1.), texel.rgb, intensity), texel.a);
4262
- }`};function wM(i=5){const t=Math.floor(i)%2===0?Math.floor(i)+1:Math.floor(i),e=EM(t),n=e.length,s=new Uint8Array(n*4);for(let r=0;r<n;++r){const o=e[r],l=2*Math.PI*o/n,c=new C(Math.cos(l),Math.sin(l),0).normalize();s[r*4]=(c.x*.5+.5)*255,s[r*4+1]=(c.y*.5+.5)*255,s[r*4+2]=127,s[r*4+3]=255}const a=new fp(s,t,t);return a.wrapS=Oi,a.wrapT=Oi,a.needsUpdate=!0,a}function EM(i){const t=Math.floor(i)%2===0?Math.floor(i)+1:Math.floor(i),e=t*t,n=Array(e).fill(0);let s=Math.floor(t/2),a=t-1;for(let r=1;r<=e;){if(s===-1&&a===t?(a=t-2,s=0):(a===t&&(a=0),s<0&&(s=t-1)),n[s*t+a]!==0){a-=2,s++;continue}else n[s*t+a]=r++;a++,s--}return n}const qr={defines:{SAMPLES:16,SAMPLE_VECTORS:Ep(16,2,1),NORMAL_VECTOR_TYPE:1,DEPTH_VALUE_SOURCE:0},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new lt},cameraProjectionMatrixInverse:{value:new fe},lumaPhi:{value:5},depthPhi:{value:5},normalPhi:{value:5},radius:{value:4},index:{value:0}},vertexShader:`
4262
+ }`};function wM(i=5){const t=Math.floor(i)%2===0?Math.floor(i)+1:Math.floor(i),e=EM(t),n=e.length,s=new Uint8Array(n*4);for(let r=0;r<n;++r){const o=e[r],l=2*Math.PI*o/n,c=new C(Math.cos(l),Math.sin(l),0).normalize();s[r*4]=(c.x*.5+.5)*255,s[r*4+1]=(c.y*.5+.5)*255,s[r*4+2]=127,s[r*4+3]=255}const a=new dp(s,t,t);return a.wrapS=Oi,a.wrapT=Oi,a.needsUpdate=!0,a}function EM(i){const t=Math.floor(i)%2===0?Math.floor(i)+1:Math.floor(i),e=t*t,n=Array(e).fill(0);let s=Math.floor(t/2),a=t-1;for(let r=1;r<=e;){if(s===-1&&a===t?(a=t-2,s=0):(a===t&&(a=0),s<0&&(s=t-1)),n[s*t+a]!==0){a-=2,s++;continue}else n[s*t+a]=r++;a++,s--}return n}const qr={defines:{SAMPLES:16,SAMPLE_VECTORS:wp(16,2,1),NORMAL_VECTOR_TYPE:1,DEPTH_VALUE_SOURCE:0},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new lt},cameraProjectionMatrixInverse:{value:new fe},lumaPhi:{value:5},depthPhi:{value:5},normalPhi:{value:5},radius:{value:4},index:{value:0}},vertexShader:`
4263
4263
 
4264
4264
  varying vec2 vUv;
4265
4265
 
@@ -4404,7 +4404,7 @@ In it: ${o}`:""}`;return`<button type="button" role="tab" aria-selected="${r}" c
4404
4404
  denoised /= totalWeight;
4405
4405
  }
4406
4406
  gl_FragColor = FRAGMENT_OUTPUT;
4407
- }`};function Ep(i,t,e){const n=TM(i,t,e);let s="vec3[SAMPLES](";for(let a=0;a<i;a++){const r=n[a];s+=`vec3(${r.x}, ${r.y}, ${r.z})${a<i-1?",":")"}`}return s}function TM(i,t,e){const n=[];for(let s=0;s<i;s++){const a=2*Math.PI*t*s/i,r=Math.pow(s/(i-1),e);n.push(new C(Math.cos(a),Math.sin(a),r))}return n}class AM{constructor(t=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let e=0;e<256;e++)this.p[e]=Math.floor(t.random()*256);this.perm=[];for(let e=0;e<512;e++)this.perm[e]=this.p[e&255];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}dot(t,e,n){return t[0]*e+t[1]*n}dot3(t,e,n,s){return t[0]*e+t[1]*n+t[2]*s}dot4(t,e,n,s,a){return t[0]*e+t[1]*n+t[2]*s+t[3]*a}noise(t,e){let n,s,a;const r=.5*(Math.sqrt(3)-1),o=(t+e)*r,l=Math.floor(t+o),c=Math.floor(e+o),h=(3-Math.sqrt(3))/6,u=(l+c)*h,d=l-u,f=c-u,g=t-d,_=e-f;let p,m;g>_?(p=1,m=0):(p=0,m=1);const y=g-p+h,x=_-m+h,S=g-1+2*h,P=_-1+2*h,T=l&255,w=c&255,R=this.perm[T+this.perm[w]]%12,k=this.perm[T+p+this.perm[w+m]]%12,v=this.perm[T+1+this.perm[w+1]]%12;let b=.5-g*g-_*_;b<0?n=0:(b*=b,n=b*b*this.dot(this.grad3[R],g,_));let N=.5-y*y-x*x;N<0?s=0:(N*=N,s=N*N*this.dot(this.grad3[k],y,x));let F=.5-S*S-P*P;return F<0?a=0:(F*=F,a=F*F*this.dot(this.grad3[v],S,P)),70*(n+s+a)}noise3d(t,e,n){let s,a,r,o;const c=(t+e+n)*.3333333333333333,h=Math.floor(t+c),u=Math.floor(e+c),d=Math.floor(n+c),f=1/6,g=(h+u+d)*f,_=h-g,p=u-g,m=d-g,y=t-_,x=e-p,S=n-m;let P,T,w,R,k,v;y>=x?x>=S?(P=1,T=0,w=0,R=1,k=1,v=0):y>=S?(P=1,T=0,w=0,R=1,k=0,v=1):(P=0,T=0,w=1,R=1,k=0,v=1):x<S?(P=0,T=0,w=1,R=0,k=1,v=1):y<S?(P=0,T=1,w=0,R=0,k=1,v=1):(P=0,T=1,w=0,R=1,k=1,v=0);const b=y-P+f,N=x-T+f,F=S-w+f,$=y-R+2*f,W=x-k+2*f,z=S-v+2*f,nt=y-1+3*f,G=x-1+3*f,at=S-1+3*f,ht=h&255,mt=u&255,Xt=d&255,qt=this.perm[ht+this.perm[mt+this.perm[Xt]]]%12,q=this.perm[ht+P+this.perm[mt+T+this.perm[Xt+w]]]%12,st=this.perm[ht+R+this.perm[mt+k+this.perm[Xt+v]]]%12,Mt=this.perm[ht+1+this.perm[mt+1+this.perm[Xt+1]]]%12;let dt=.6-y*y-x*x-S*S;dt<0?s=0:(dt*=dt,s=dt*dt*this.dot3(this.grad3[qt],y,x,S));let It=.6-b*b-N*N-F*F;It<0?a=0:(It*=It,a=It*It*this.dot3(this.grad3[q],b,N,F));let Rt=.6-$*$-W*W-z*z;Rt<0?r=0:(Rt*=Rt,r=Rt*Rt*this.dot3(this.grad3[st],$,W,z));let Nt=.6-nt*nt-G*G-at*at;return Nt<0?o=0:(Nt*=Nt,o=Nt*Nt*this.dot3(this.grad3[Mt],nt,G,at)),32*(s+a+r+o)}noise4d(t,e,n,s){const a=this.grad4,r=this.simplex,o=this.perm,l=(Math.sqrt(5)-1)/4,c=(5-Math.sqrt(5))/20;let h,u,d,f,g;const _=(t+e+n+s)*l,p=Math.floor(t+_),m=Math.floor(e+_),y=Math.floor(n+_),x=Math.floor(s+_),S=(p+m+y+x)*c,P=p-S,T=m-S,w=y-S,R=x-S,k=t-P,v=e-T,b=n-w,N=s-R,F=k>v?32:0,$=k>b?16:0,W=v>b?8:0,z=k>N?4:0,nt=v>N?2:0,G=b>N?1:0,at=F+$+W+z+nt+G,ht=r[at][0]>=3?1:0,mt=r[at][1]>=3?1:0,Xt=r[at][2]>=3?1:0,qt=r[at][3]>=3?1:0,q=r[at][0]>=2?1:0,st=r[at][1]>=2?1:0,Mt=r[at][2]>=2?1:0,dt=r[at][3]>=2?1:0,It=r[at][0]>=1?1:0,Rt=r[at][1]>=1?1:0,Nt=r[at][2]>=1?1:0,ee=r[at][3]>=1?1:0,$t=k-ht+c,L=v-mt+c,ze=b-Xt+c,Zt=N-qt+c,j=k-q+2*c,Q=v-st+2*c,Tt=b-Mt+2*c,wt=N-dt+2*c,A=k-It+3*c,M=v-Rt+3*c,O=b-Nt+3*c,Z=N-ee+3*c,it=k-1+4*c,Y=v-1+4*c,Ct=b-1+4*c,ut=N-1+4*c,gt=p&255,Jt=m&255,rt=y&255,vt=x&255,Ut=o[gt+o[Jt+o[rt+o[vt]]]]%32,Ot=o[gt+ht+o[Jt+mt+o[rt+Xt+o[vt+qt]]]]%32,Et=o[gt+q+o[Jt+st+o[rt+Mt+o[vt+dt]]]]%32,ne=o[gt+It+o[Jt+Rt+o[rt+Nt+o[vt+ee]]]]%32,Vt=o[gt+1+o[Jt+1+o[rt+1+o[vt+1]]]]%32;let se=.6-k*k-v*v-b*b-N*N;se<0?h=0:(se*=se,h=se*se*this.dot4(a[Ut],k,v,b,N));let D=.6-$t*$t-L*L-ze*ze-Zt*Zt;D<0?u=0:(D*=D,u=D*D*this.dot4(a[Ot],$t,L,ze,Zt));let pt=.6-j*j-Q*Q-Tt*Tt-wt*wt;pt<0?d=0:(pt*=pt,d=pt*pt*this.dot4(a[Et],j,Q,Tt,wt));let V=.6-A*A-M*M-O*O-Z*Z;V<0?f=0:(V*=V,f=V*V*this.dot4(a[ne],A,M,O,Z));let tt=.6-it*it-Y*Y-Ct*Ct-ut*ut;return tt<0?g=0:(tt*=tt,g=tt*tt*this.dot4(a[Vt],it,Y,Ct,ut)),27*(h+u+d+f+g)}}class ri extends La{constructor(t,e,n,s,a,r,o){super(),this.width=n!==void 0?n:512,this.height=s!==void 0?s:512,this.clear=!0,this.camera=e,this.scene=t,this.output=0,this._renderGBuffer=!0,this._visibilityCache=new Map,this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=wM(),this.pdNoiseTexture=this.generateNoise(),this.gtaoRenderTarget=new ei(this.width,this.height,{type:Fi}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new rn({defines:Object.assign({},Wr.defines),uniforms:es.clone(Wr.uniforms),vertexShader:Wr.vertexShader,fragmentShader:Wr.fragmentShader,blending:Je,depthTest:!1,depthWrite:!1}),this.gtaoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.gtaoMaterial.uniforms.tNoise.value=this.gtaoNoiseTexture,this.gtaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.normalMaterial=new k1,this.normalMaterial.blending=Je,this.pdMaterial=new rn({defines:Object.assign({},qr.defines),uniforms:es.clone(qr.uniforms),vertexShader:qr.vertexShader,fragmentShader:qr.fragmentShader,depthTest:!1,depthWrite:!1}),this.pdMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.pdMaterial.uniforms.tNoise.value=this.pdNoiseTexture,this.pdMaterial.uniforms.resolution.value.set(this.width,this.height),this.pdMaterial.uniforms.lumaPhi.value=10,this.pdMaterial.uniforms.depthPhi.value=2,this.pdMaterial.uniforms.normalPhi.value=3,this.pdMaterial.uniforms.radius.value=8,this.depthRenderMaterial=new rn({defines:Object.assign({},Xr.defines),uniforms:es.clone(Xr.uniforms),vertexShader:Xr.vertexShader,fragmentShader:Xr.fragmentShader,blending:Je}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new rn({uniforms:es.clone(fo.uniforms),vertexShader:fo.vertexShader,fragmentShader:fo.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:gc,blendDst:qa,blendEquation:Yn,blendSrcAlpha:mc,blendDstAlpha:qa,blendEquationAlpha:Yn}),this.blendMaterial=new rn({uniforms:es.clone(ql.uniforms),vertexShader:ql.vertexShader,fragmentShader:ql.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:If,blendSrc:gc,blendDst:qa,blendEquation:Yn,blendSrcAlpha:mc,blendDstAlpha:qa,blendEquationAlpha:Yn}),this.fsQuad=new jh(null),this.originalClearColor=new te,this.setGBuffer(a?a.depthTexture:void 0,a?a.normalTexture:void 0),r!==void 0&&this.updateGtaoMaterial(r),o!==void 0&&this.updatePdMaterial(o)}dispose(){this.gtaoNoiseTexture.dispose(),this.pdNoiseTexture.dispose(),this.normalRenderTarget.dispose(),this.gtaoRenderTarget.dispose(),this.pdRenderTarget.dispose(),this.normalMaterial.dispose(),this.pdMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this.fsQuad.dispose()}get gtaoMap(){return this.pdRenderTarget.texture}setGBuffer(t,e){t!==void 0?(this.depthTexture=t,this.normalTexture=e,this._renderGBuffer=!1):(this.depthTexture=new Fh,this.depthTexture.format=Ls,this.depthTexture.type=Ps,this.normalRenderTarget=new ei(this.width,this.height,{minFilter:on,magFilter:on,type:Fi,depthTexture:this.depthTexture}),this.normalTexture=this.normalRenderTarget.texture,this._renderGBuffer=!0);const n=this.normalTexture?1:0,s=this.depthTexture===this.normalTexture?"w":"x";this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE=n,this.gtaoMaterial.defines.DEPTH_SWIZZLING=s,this.gtaoMaterial.uniforms.tNormal.value=this.normalTexture,this.gtaoMaterial.uniforms.tDepth.value=this.depthTexture,this.pdMaterial.defines.NORMAL_VECTOR_TYPE=n,this.pdMaterial.defines.DEPTH_SWIZZLING=s,this.pdMaterial.uniforms.tNormal.value=this.normalTexture,this.pdMaterial.uniforms.tDepth.value=this.depthTexture,this.depthRenderMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture}setSceneClipBox(t){t?(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX!==1,this.gtaoMaterial.defines.SCENE_CLIP_BOX=1,this.gtaoMaterial.uniforms.sceneBoxMin.value.copy(t.min),this.gtaoMaterial.uniforms.sceneBoxMax.value.copy(t.max)):(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX===0,this.gtaoMaterial.defines.SCENE_CLIP_BOX=0)}updateGtaoMaterial(t){t.radius!==void 0&&(this.gtaoMaterial.uniforms.radius.value=t.radius),t.distanceExponent!==void 0&&(this.gtaoMaterial.uniforms.distanceExponent.value=t.distanceExponent),t.thickness!==void 0&&(this.gtaoMaterial.uniforms.thickness.value=t.thickness),t.distanceFallOff!==void 0&&(this.gtaoMaterial.uniforms.distanceFallOff.value=t.distanceFallOff,this.gtaoMaterial.needsUpdate=!0),t.scale!==void 0&&(this.gtaoMaterial.uniforms.scale.value=t.scale),t.samples!==void 0&&t.samples!==this.gtaoMaterial.defines.SAMPLES&&(this.gtaoMaterial.defines.SAMPLES=t.samples,this.gtaoMaterial.needsUpdate=!0),t.screenSpaceRadius!==void 0&&(t.screenSpaceRadius?1:0)!==this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS&&(this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS=t.screenSpaceRadius?1:0,this.gtaoMaterial.needsUpdate=!0)}updatePdMaterial(t){let e=!1;t.lumaPhi!==void 0&&(this.pdMaterial.uniforms.lumaPhi.value=t.lumaPhi),t.depthPhi!==void 0&&(this.pdMaterial.uniforms.depthPhi.value=t.depthPhi),t.normalPhi!==void 0&&(this.pdMaterial.uniforms.normalPhi.value=t.normalPhi),t.radius!==void 0&&t.radius!==this.radius&&(this.pdMaterial.uniforms.radius.value=t.radius),t.radiusExponent!==void 0&&t.radiusExponent!==this.pdRadiusExponent&&(this.pdRadiusExponent=t.radiusExponent,e=!0),t.rings!==void 0&&t.rings!==this.pdRings&&(this.pdRings=t.rings,e=!0),t.samples!==void 0&&t.samples!==this.pdSamples&&(this.pdSamples=t.samples,e=!0),e&&(this.pdMaterial.defines.SAMPLES=this.pdSamples,this.pdMaterial.defines.SAMPLE_VECTORS=Ep(this.pdSamples,this.pdRings,this.pdRadiusExponent),this.pdMaterial.needsUpdate=!0)}render(t,e,n){switch(this._renderGBuffer&&(this.overrideVisibility(),this.renderOverride(t,this.normalMaterial,this.normalRenderTarget,7829503,1),this.restoreVisibility()),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy(this.camera.matrixWorld),this.renderPass(t,this.gtaoMaterial,this.gtaoRenderTarget,16777215,1),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.renderPass(t,this.pdMaterial,this.pdRenderTarget,16777215,1),this.output){case ri.OUTPUT.Off:break;case ri.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=Je,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case ri.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=Je,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case ri.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=Je,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case ri.OUTPUT.Depth:this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.renderPass(t,this.depthRenderMaterial,this.renderToScreen?null:e);break;case ri.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=Je,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case ri.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=Je,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e),this.blendMaterial.uniforms.intensity.value=this.blendIntensity,this.blendMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.renderPass(t,this.blendMaterial,this.renderToScreen?null:e);break;default:console.warn("THREE.GTAOPass: Unknown output type.")}}renderPass(t,e,n,s,a){t.getClearColor(this.originalClearColor);const r=t.getClearAlpha(),o=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,s!=null&&(t.setClearColor(s),t.setClearAlpha(a||0),t.clear()),this.fsQuad.material=e,this.fsQuad.render(t),t.autoClear=o,t.setClearColor(this.originalClearColor),t.setClearAlpha(r)}renderOverride(t,e,n,s,a){t.getClearColor(this.originalClearColor);const r=t.getClearAlpha(),o=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,s=e.clearColor||s,a=e.clearAlpha||a,s!=null&&(t.setClearColor(s),t.setClearAlpha(a||0),t.clear()),this.scene.overrideMaterial=e,t.render(this.scene,this.camera),this.scene.overrideMaterial=null,t.autoClear=o,t.setClearColor(this.originalClearColor),t.setClearAlpha(r)}setSize(t,e){this.width=t,this.height=e,this.gtaoRenderTarget.setSize(t,e),this.normalRenderTarget.setSize(t,e),this.pdRenderTarget.setSize(t,e),this.gtaoMaterial.uniforms.resolution.value.set(t,e),this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.pdMaterial.uniforms.resolution.value.set(t,e),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse)}overrideVisibility(){const t=this.scene,e=this._visibilityCache;t.traverse(function(n){e.set(n,n.visible),(n.isPoints||n.isLine)&&(n.visible=!1)})}restoreVisibility(){const t=this.scene,e=this._visibilityCache;t.traverse(function(n){const s=e.get(n);n.visible=s}),e.clear()}generateNoise(t=64){const e=new AM,n=t*t*4,s=new Uint8Array(n);for(let r=0;r<t;r++)for(let o=0;o<t;o++){const l=r,c=o;s[(r*t+o)*4]=(e.noise(l,c)*.5+.5)*255,s[(r*t+o)*4+1]=(e.noise(l+t,c)*.5+.5)*255,s[(r*t+o)*4+2]=(e.noise(l,c+t)*.5+.5)*255,s[(r*t+o)*4+3]=(e.noise(l+t,c+t)*.5+.5)*255}const a=new fp(s,t,t,zn,pi);return a.wrapS=Oi,a.wrapT=Oi,a.needsUpdate=!0,a}}ri.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};const CM={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
4407
+ }`};function wp(i,t,e){const n=TM(i,t,e);let s="vec3[SAMPLES](";for(let a=0;a<i;a++){const r=n[a];s+=`vec3(${r.x}, ${r.y}, ${r.z})${a<i-1?",":")"}`}return s}function TM(i,t,e){const n=[];for(let s=0;s<i;s++){const a=2*Math.PI*t*s/i,r=Math.pow(s/(i-1),e);n.push(new C(Math.cos(a),Math.sin(a),r))}return n}class AM{constructor(t=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let e=0;e<256;e++)this.p[e]=Math.floor(t.random()*256);this.perm=[];for(let e=0;e<512;e++)this.perm[e]=this.p[e&255];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}dot(t,e,n){return t[0]*e+t[1]*n}dot3(t,e,n,s){return t[0]*e+t[1]*n+t[2]*s}dot4(t,e,n,s,a){return t[0]*e+t[1]*n+t[2]*s+t[3]*a}noise(t,e){let n,s,a;const r=.5*(Math.sqrt(3)-1),o=(t+e)*r,l=Math.floor(t+o),c=Math.floor(e+o),h=(3-Math.sqrt(3))/6,u=(l+c)*h,d=l-u,f=c-u,g=t-d,_=e-f;let p,m;g>_?(p=1,m=0):(p=0,m=1);const y=g-p+h,x=_-m+h,S=g-1+2*h,P=_-1+2*h,T=l&255,w=c&255,R=this.perm[T+this.perm[w]]%12,k=this.perm[T+p+this.perm[w+m]]%12,v=this.perm[T+1+this.perm[w+1]]%12;let b=.5-g*g-_*_;b<0?n=0:(b*=b,n=b*b*this.dot(this.grad3[R],g,_));let N=.5-y*y-x*x;N<0?s=0:(N*=N,s=N*N*this.dot(this.grad3[k],y,x));let F=.5-S*S-P*P;return F<0?a=0:(F*=F,a=F*F*this.dot(this.grad3[v],S,P)),70*(n+s+a)}noise3d(t,e,n){let s,a,r,o;const c=(t+e+n)*.3333333333333333,h=Math.floor(t+c),u=Math.floor(e+c),d=Math.floor(n+c),f=1/6,g=(h+u+d)*f,_=h-g,p=u-g,m=d-g,y=t-_,x=e-p,S=n-m;let P,T,w,R,k,v;y>=x?x>=S?(P=1,T=0,w=0,R=1,k=1,v=0):y>=S?(P=1,T=0,w=0,R=1,k=0,v=1):(P=0,T=0,w=1,R=1,k=0,v=1):x<S?(P=0,T=0,w=1,R=0,k=1,v=1):y<S?(P=0,T=1,w=0,R=0,k=1,v=1):(P=0,T=1,w=0,R=1,k=1,v=0);const b=y-P+f,N=x-T+f,F=S-w+f,$=y-R+2*f,W=x-k+2*f,z=S-v+2*f,nt=y-1+3*f,G=x-1+3*f,at=S-1+3*f,ht=h&255,mt=u&255,Xt=d&255,qt=this.perm[ht+this.perm[mt+this.perm[Xt]]]%12,q=this.perm[ht+P+this.perm[mt+T+this.perm[Xt+w]]]%12,st=this.perm[ht+R+this.perm[mt+k+this.perm[Xt+v]]]%12,Mt=this.perm[ht+1+this.perm[mt+1+this.perm[Xt+1]]]%12;let dt=.6-y*y-x*x-S*S;dt<0?s=0:(dt*=dt,s=dt*dt*this.dot3(this.grad3[qt],y,x,S));let It=.6-b*b-N*N-F*F;It<0?a=0:(It*=It,a=It*It*this.dot3(this.grad3[q],b,N,F));let Rt=.6-$*$-W*W-z*z;Rt<0?r=0:(Rt*=Rt,r=Rt*Rt*this.dot3(this.grad3[st],$,W,z));let Nt=.6-nt*nt-G*G-at*at;return Nt<0?o=0:(Nt*=Nt,o=Nt*Nt*this.dot3(this.grad3[Mt],nt,G,at)),32*(s+a+r+o)}noise4d(t,e,n,s){const a=this.grad4,r=this.simplex,o=this.perm,l=(Math.sqrt(5)-1)/4,c=(5-Math.sqrt(5))/20;let h,u,d,f,g;const _=(t+e+n+s)*l,p=Math.floor(t+_),m=Math.floor(e+_),y=Math.floor(n+_),x=Math.floor(s+_),S=(p+m+y+x)*c,P=p-S,T=m-S,w=y-S,R=x-S,k=t-P,v=e-T,b=n-w,N=s-R,F=k>v?32:0,$=k>b?16:0,W=v>b?8:0,z=k>N?4:0,nt=v>N?2:0,G=b>N?1:0,at=F+$+W+z+nt+G,ht=r[at][0]>=3?1:0,mt=r[at][1]>=3?1:0,Xt=r[at][2]>=3?1:0,qt=r[at][3]>=3?1:0,q=r[at][0]>=2?1:0,st=r[at][1]>=2?1:0,Mt=r[at][2]>=2?1:0,dt=r[at][3]>=2?1:0,It=r[at][0]>=1?1:0,Rt=r[at][1]>=1?1:0,Nt=r[at][2]>=1?1:0,ee=r[at][3]>=1?1:0,$t=k-ht+c,L=v-mt+c,ze=b-Xt+c,Zt=N-qt+c,j=k-q+2*c,Q=v-st+2*c,Tt=b-Mt+2*c,St=N-dt+2*c,A=k-It+3*c,M=v-Rt+3*c,O=b-Nt+3*c,Z=N-ee+3*c,it=k-1+4*c,Y=v-1+4*c,Ct=b-1+4*c,ut=N-1+4*c,gt=p&255,Jt=m&255,rt=y&255,vt=x&255,Ut=o[gt+o[Jt+o[rt+o[vt]]]]%32,Ot=o[gt+ht+o[Jt+mt+o[rt+Xt+o[vt+qt]]]]%32,Et=o[gt+q+o[Jt+st+o[rt+Mt+o[vt+dt]]]]%32,ne=o[gt+It+o[Jt+Rt+o[rt+Nt+o[vt+ee]]]]%32,Vt=o[gt+1+o[Jt+1+o[rt+1+o[vt+1]]]]%32;let se=.6-k*k-v*v-b*b-N*N;se<0?h=0:(se*=se,h=se*se*this.dot4(a[Ut],k,v,b,N));let D=.6-$t*$t-L*L-ze*ze-Zt*Zt;D<0?u=0:(D*=D,u=D*D*this.dot4(a[Ot],$t,L,ze,Zt));let pt=.6-j*j-Q*Q-Tt*Tt-St*St;pt<0?d=0:(pt*=pt,d=pt*pt*this.dot4(a[Et],j,Q,Tt,St));let V=.6-A*A-M*M-O*O-Z*Z;V<0?f=0:(V*=V,f=V*V*this.dot4(a[ne],A,M,O,Z));let tt=.6-it*it-Y*Y-Ct*Ct-ut*ut;return tt<0?g=0:(tt*=tt,g=tt*tt*this.dot4(a[Vt],it,Y,Ct,ut)),27*(h+u+d+f+g)}}class ri extends La{constructor(t,e,n,s,a,r,o){super(),this.width=n!==void 0?n:512,this.height=s!==void 0?s:512,this.clear=!0,this.camera=e,this.scene=t,this.output=0,this._renderGBuffer=!0,this._visibilityCache=new Map,this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=wM(),this.pdNoiseTexture=this.generateNoise(),this.gtaoRenderTarget=new ei(this.width,this.height,{type:Fi}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new an({defines:Object.assign({},Wr.defines),uniforms:es.clone(Wr.uniforms),vertexShader:Wr.vertexShader,fragmentShader:Wr.fragmentShader,blending:Je,depthTest:!1,depthWrite:!1}),this.gtaoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.gtaoMaterial.uniforms.tNoise.value=this.gtaoNoiseTexture,this.gtaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.normalMaterial=new k1,this.normalMaterial.blending=Je,this.pdMaterial=new an({defines:Object.assign({},qr.defines),uniforms:es.clone(qr.uniforms),vertexShader:qr.vertexShader,fragmentShader:qr.fragmentShader,depthTest:!1,depthWrite:!1}),this.pdMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.pdMaterial.uniforms.tNoise.value=this.pdNoiseTexture,this.pdMaterial.uniforms.resolution.value.set(this.width,this.height),this.pdMaterial.uniforms.lumaPhi.value=10,this.pdMaterial.uniforms.depthPhi.value=2,this.pdMaterial.uniforms.normalPhi.value=3,this.pdMaterial.uniforms.radius.value=8,this.depthRenderMaterial=new an({defines:Object.assign({},Xr.defines),uniforms:es.clone(Xr.uniforms),vertexShader:Xr.vertexShader,fragmentShader:Xr.fragmentShader,blending:Je}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new an({uniforms:es.clone(fo.uniforms),vertexShader:fo.vertexShader,fragmentShader:fo.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:gc,blendDst:qa,blendEquation:Yn,blendSrcAlpha:mc,blendDstAlpha:qa,blendEquationAlpha:Yn}),this.blendMaterial=new an({uniforms:es.clone(ql.uniforms),vertexShader:ql.vertexShader,fragmentShader:ql.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:Df,blendSrc:gc,blendDst:qa,blendEquation:Yn,blendSrcAlpha:mc,blendDstAlpha:qa,blendEquationAlpha:Yn}),this.fsQuad=new jh(null),this.originalClearColor=new te,this.setGBuffer(a?a.depthTexture:void 0,a?a.normalTexture:void 0),r!==void 0&&this.updateGtaoMaterial(r),o!==void 0&&this.updatePdMaterial(o)}dispose(){this.gtaoNoiseTexture.dispose(),this.pdNoiseTexture.dispose(),this.normalRenderTarget.dispose(),this.gtaoRenderTarget.dispose(),this.pdRenderTarget.dispose(),this.normalMaterial.dispose(),this.pdMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this.fsQuad.dispose()}get gtaoMap(){return this.pdRenderTarget.texture}setGBuffer(t,e){t!==void 0?(this.depthTexture=t,this.normalTexture=e,this._renderGBuffer=!1):(this.depthTexture=new Fh,this.depthTexture.format=Ls,this.depthTexture.type=Ps,this.normalRenderTarget=new ei(this.width,this.height,{minFilter:rn,magFilter:rn,type:Fi,depthTexture:this.depthTexture}),this.normalTexture=this.normalRenderTarget.texture,this._renderGBuffer=!0);const n=this.normalTexture?1:0,s=this.depthTexture===this.normalTexture?"w":"x";this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE=n,this.gtaoMaterial.defines.DEPTH_SWIZZLING=s,this.gtaoMaterial.uniforms.tNormal.value=this.normalTexture,this.gtaoMaterial.uniforms.tDepth.value=this.depthTexture,this.pdMaterial.defines.NORMAL_VECTOR_TYPE=n,this.pdMaterial.defines.DEPTH_SWIZZLING=s,this.pdMaterial.uniforms.tNormal.value=this.normalTexture,this.pdMaterial.uniforms.tDepth.value=this.depthTexture,this.depthRenderMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture}setSceneClipBox(t){t?(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX!==1,this.gtaoMaterial.defines.SCENE_CLIP_BOX=1,this.gtaoMaterial.uniforms.sceneBoxMin.value.copy(t.min),this.gtaoMaterial.uniforms.sceneBoxMax.value.copy(t.max)):(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX===0,this.gtaoMaterial.defines.SCENE_CLIP_BOX=0)}updateGtaoMaterial(t){t.radius!==void 0&&(this.gtaoMaterial.uniforms.radius.value=t.radius),t.distanceExponent!==void 0&&(this.gtaoMaterial.uniforms.distanceExponent.value=t.distanceExponent),t.thickness!==void 0&&(this.gtaoMaterial.uniforms.thickness.value=t.thickness),t.distanceFallOff!==void 0&&(this.gtaoMaterial.uniforms.distanceFallOff.value=t.distanceFallOff,this.gtaoMaterial.needsUpdate=!0),t.scale!==void 0&&(this.gtaoMaterial.uniforms.scale.value=t.scale),t.samples!==void 0&&t.samples!==this.gtaoMaterial.defines.SAMPLES&&(this.gtaoMaterial.defines.SAMPLES=t.samples,this.gtaoMaterial.needsUpdate=!0),t.screenSpaceRadius!==void 0&&(t.screenSpaceRadius?1:0)!==this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS&&(this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS=t.screenSpaceRadius?1:0,this.gtaoMaterial.needsUpdate=!0)}updatePdMaterial(t){let e=!1;t.lumaPhi!==void 0&&(this.pdMaterial.uniforms.lumaPhi.value=t.lumaPhi),t.depthPhi!==void 0&&(this.pdMaterial.uniforms.depthPhi.value=t.depthPhi),t.normalPhi!==void 0&&(this.pdMaterial.uniforms.normalPhi.value=t.normalPhi),t.radius!==void 0&&t.radius!==this.radius&&(this.pdMaterial.uniforms.radius.value=t.radius),t.radiusExponent!==void 0&&t.radiusExponent!==this.pdRadiusExponent&&(this.pdRadiusExponent=t.radiusExponent,e=!0),t.rings!==void 0&&t.rings!==this.pdRings&&(this.pdRings=t.rings,e=!0),t.samples!==void 0&&t.samples!==this.pdSamples&&(this.pdSamples=t.samples,e=!0),e&&(this.pdMaterial.defines.SAMPLES=this.pdSamples,this.pdMaterial.defines.SAMPLE_VECTORS=wp(this.pdSamples,this.pdRings,this.pdRadiusExponent),this.pdMaterial.needsUpdate=!0)}render(t,e,n){switch(this._renderGBuffer&&(this.overrideVisibility(),this.renderOverride(t,this.normalMaterial,this.normalRenderTarget,7829503,1),this.restoreVisibility()),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy(this.camera.matrixWorld),this.renderPass(t,this.gtaoMaterial,this.gtaoRenderTarget,16777215,1),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.renderPass(t,this.pdMaterial,this.pdRenderTarget,16777215,1),this.output){case ri.OUTPUT.Off:break;case ri.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=Je,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case ri.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=Je,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case ri.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=Je,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case ri.OUTPUT.Depth:this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.renderPass(t,this.depthRenderMaterial,this.renderToScreen?null:e);break;case ri.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=Je,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e);break;case ri.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=Je,this.renderPass(t,this.copyMaterial,this.renderToScreen?null:e),this.blendMaterial.uniforms.intensity.value=this.blendIntensity,this.blendMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.renderPass(t,this.blendMaterial,this.renderToScreen?null:e);break;default:console.warn("THREE.GTAOPass: Unknown output type.")}}renderPass(t,e,n,s,a){t.getClearColor(this.originalClearColor);const r=t.getClearAlpha(),o=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,s!=null&&(t.setClearColor(s),t.setClearAlpha(a||0),t.clear()),this.fsQuad.material=e,this.fsQuad.render(t),t.autoClear=o,t.setClearColor(this.originalClearColor),t.setClearAlpha(r)}renderOverride(t,e,n,s,a){t.getClearColor(this.originalClearColor);const r=t.getClearAlpha(),o=t.autoClear;t.setRenderTarget(n),t.autoClear=!1,s=e.clearColor||s,a=e.clearAlpha||a,s!=null&&(t.setClearColor(s),t.setClearAlpha(a||0),t.clear()),this.scene.overrideMaterial=e,t.render(this.scene,this.camera),this.scene.overrideMaterial=null,t.autoClear=o,t.setClearColor(this.originalClearColor),t.setClearAlpha(r)}setSize(t,e){this.width=t,this.height=e,this.gtaoRenderTarget.setSize(t,e),this.normalRenderTarget.setSize(t,e),this.pdRenderTarget.setSize(t,e),this.gtaoMaterial.uniforms.resolution.value.set(t,e),this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.pdMaterial.uniforms.resolution.value.set(t,e),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse)}overrideVisibility(){const t=this.scene,e=this._visibilityCache;t.traverse(function(n){e.set(n,n.visible),(n.isPoints||n.isLine)&&(n.visible=!1)})}restoreVisibility(){const t=this.scene,e=this._visibilityCache;t.traverse(function(n){const s=e.get(n);n.visible=s}),e.clear()}generateNoise(t=64){const e=new AM,n=t*t*4,s=new Uint8Array(n);for(let r=0;r<t;r++)for(let o=0;o<t;o++){const l=r,c=o;s[(r*t+o)*4]=(e.noise(l,c)*.5+.5)*255,s[(r*t+o)*4+1]=(e.noise(l+t,c)*.5+.5)*255,s[(r*t+o)*4+2]=(e.noise(l,c+t)*.5+.5)*255,s[(r*t+o)*4+3]=(e.noise(l+t,c+t)*.5+.5)*255}const a=new dp(s,t,t,zn,pi);return a.wrapS=Oi,a.wrapT=Oi,a.needsUpdate=!0,a}}ri.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};const CM={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
4408
4408
  precision highp float;
4409
4409
 
4410
4410
  uniform mat4 modelViewMatrix;
@@ -4471,5 +4471,5 @@ In it: ${o}`:""}`;return`<button type="button" role="tab" aria-selected="${r}" c
4471
4471
 
4472
4472
  #endif
4473
4473
 
4474
- }`};class RM extends La{constructor(){super();const t=CM;this.uniforms=es.clone(t.uniforms),this.material=new I1({name:t.name,uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader}),this.fsQuad=new jh(this.material),this._outputColorSpace=null,this._toneMapping=null}render(t,e,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=t.toneMappingExposure,(this._outputColorSpace!==t.outputColorSpace||this._toneMapping!==t.toneMapping)&&(this._outputColorSpace=t.outputColorSpace,this._toneMapping=t.toneMapping,this.material.defines={},le.getTransfer(this._outputColorSpace)===ye&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===Nf?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===Uf?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===Of?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===Ff?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===zf?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===bh&&(this.material.defines.NEUTRAL_TONE_MAPPING=""),this.material.needsUpdate=!0),this.renderToScreen===!0?(t.setRenderTarget(null),this.fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this.fsQuad.render(t))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class PM{constructor(t,e,n=-t/2,s=-e/2){this.w=t,this.d=e,this.ox=n,this.oz=s,this.cells=new Uint8Array(t*e)}inside(t,e){return t>=0&&e>=0&&t<this.w&&e<this.d}blocked(t,e){return!this.inside(t,e)||this.cells[e*this.w+t]===1}cellOf(t,e){return[Math.floor(t-this.ox),Math.floor(e-this.oz)]}center(t,e){return[this.ox+t+.5,this.oz+e+.5]}block(t,e,n,s){const[a,r]=this.cellOf(t,n),[o,l]=this.cellOf(e-1e-6,s-1e-6);for(let c=r;c<=l;c++)for(let h=a;h<=o;h++)this.inside(h,c)&&(this.cells[c*this.w+h]=1)}nearestFree(t,e){if(!this.blocked(t,e))return[t,e];const n=new Set([e*this.w+t]),s=[[t,e]];for(;s.length;){const[a,r]=s.shift();for(const[o,l]of[[1,0],[-1,0],[0,1],[0,-1]]){const c=a+o,h=r+l;if(!(!this.inside(c,h)||n.has(h*this.w+c))){if(!this.blocked(c,h))return[c,h];n.add(h*this.w+c),s.push([c,h])}}}return[t,e]}clear(t,e,n,s){const a=Math.hypot(n-t,s-e),r=Math.ceil(a/.2);for(let o=1;o<r;o++){const l=o/r,[c,h]=this.cellOf(t+(n-t)*l,e+(s-e)*l);if(this.blocked(c,h))return!1}return!0}path(t,e,n,s){const a=this.nearestFree(...this.cellOf(t,e)),r=this.nearestFree(...this.cellOf(n,s)),o=(y,x)=>x*this.w+y,l=(y,x)=>Math.hypot(y-r[0],x-r[1]),c=new Map([[o(...a),0]]),h=new Map,u=[[l(...a),...a]],d=new Set;let f=!1;for(;u.length;){let y=0;for(let T=1;T<u.length;T++)u[T][0]<u[y][0]&&(y=T);const[,x,S]=u.splice(y,1)[0],P=o(x,S);if(!d.has(P)){if(d.add(P),x===r[0]&&S===r[1]){f=!0;break}for(let T=-1;T<=1;T++)for(let w=-1;w<=1;w++){if(!T&&!w)continue;const R=x+T,k=S+w;if(this.blocked(R,k)||T&&w&&(this.blocked(x+T,S)||this.blocked(x,S+w)))continue;const v=o(R,k),b=c.get(P)+(T&&w?Math.SQRT2:1);b<(c.get(v)??1/0)&&(c.set(v,b),h.set(v,P),u.push([b+l(R,k),R,k]))}}}const g=[];if(f){let y=o(...r);for(;y!==void 0;)g.unshift(this.center(y%this.w,Math.floor(y/this.w))),y=h.get(y)}g.push([n,s]);const _=[];let p=[t,e],m=0;for(;m<g.length;){let y=m;for(let x=g.length-1;x>m;x--)if(this.clear(p[0],p[1],g[x][0],g[x][1])){y=x;break}_.push(g[y]),p=g[y],m=y+1}return _}}const Ki=52,ns=30,re={x0:-20,x1:32,z0:-ns/2,z1:ns/2,cx:6},Js=20.4,Ud=27,je={x:7.6,z:10.9,felt:.84},ct={wall:"#f5f0e8",trim:"#d9cdbb",wood:"#c39a6b",woodDark:"#8c6440",metal:"#3b404c",rack:"#262a33",pot:"#e4d6c1",couch:"#5b7fa6",rug:"#c99b84",glass:"#cfe6f2",board:"#fbfaf7",chair:"#30343d"},jl=new Map;function xe(i,t={}){const e=i+JSON.stringify(t);return jl.has(e)||jl.set(e,new Dn({color:i,roughness:.82,...t})),jl.get(e)}function K(i,t,e,n,s,a,r,o,l){const c=new yt(new Ye(t,e,n),l instanceof Bi?l:xe(s,l));return c.position.set(a,r,o),c.castShadow=!0,c.receiveShadow=!0,i.add(c),c}function Ni(i,t,e,n,s){const a=document.createElement("canvas");a.width=n,a.height=s;const r=new Hi(a);r.colorSpace=Qe,r.anisotropy=4;const o=new yt(new vi(t,e),new cn({map:r,toneMapped:!1}));return i.add(o),{canvas:a,ctx:a.getContext("2d"),tex:r,mesh:o}}const Bn='"Inter Variable", Inter, system-ui, sans-serif',LM='"JetBrains Mono", ui-monospace, monospace';function zt(i,t,e,n,s,a,r,o,l=16,c){const h=new yt(new Hn(t,e,n,l),c instanceof Bi?c:xe(s,c));return h.position.set(a,r,o),h.castShadow=!0,h.receiveShadow=!0,i.add(h),h}const Od=["#5f9e6e","#477d55","#6fae74","#3f7350","#7dbb7a"];function Tp(i,t,e,n,s=1,a="bush"){const r=new Ht;r.position.set(e,0,n),r.rotation.y=e*1.7+n,r.scale.setScalar(s),zt(r,.35,.27,.6,ct.pot,0,.3,0,18),zt(r,.37,.37,.06,"#d8c8b0",0,.6,0,18),zt(r,.31,.31,.02,"#5a4130",0,.62,0,18);const o=(l,c,h,u,d)=>{const f=new yt(new Ta(l,0),xe(Od[d%Od.length],{flatShading:!0}));f.position.set(c,h,u),f.rotation.set(c*3,u*5,h),f.castShadow=!0,r.add(f)};if(a==="tall")zt(r,.035,.05,1.5,ct.woodDark,0,1.35,0,6),o(.42,.12,1.55,.05,1),o(.48,-.15,1.95,-.08,0),o(.38,.18,2.3,.1,2),o(.3,-.05,2.6,0,4);else if(a==="snake")for(let l=0;l<7;l++){const c=l/7*Math.PI*2,h=.8+l*37%5*.12,u=new yt(new pr(.07,h,4),xe(l%2?"#4e8a5c":"#6f9f5a",{flatShading:!0}));u.position.set(Math.cos(c)*.12,.62+h/2,Math.sin(c)*.12),u.rotation.set(Math.sin(c)*.18,c,-Math.cos(c)*.18),u.scale.z=.35,u.castShadow=!0,r.add(u)}else o(.55,0,1,0,0),o(.4,.3,1.25,.1,1),o(.38,-.28,1.2,-.12,2),o(.36,.05,1.5,-.2,3);return i.add(r),t.block(e-.45*s,e+.45*s,n-.45*s,n+.45*s),r}function Yh(i,t,e,n){zt(i,.09,.07,.12,"#e8dccb",t,e+.06,n,12);const s=new yt(new Ta(.1,0),xe("#7aa874",{flatShading:!0}));s.position.set(t,e+.17,n),s.scale.y=.7,s.castShadow=!0,i.add(s)}function Lo(i,t,e,n,s=3){const a=["#e07a5f","#3d7ea6","#f2cc8f","#81b29a","#9c6ade"];for(let r=0;r<s;r++){const o=K(i,.34-r*.03,.05,.25,a[(r+Math.round(t*7))%a.length],t,e+.025+r*.05,n);o.rotation.y=(r-1)*.15}}function DM(i,t,e,n){const s=xe("#2f3440",{roughness:.5});zt(i,.11,.12,.03,null,t,e+.015,n,16,s);const a=K(i,.03,.42,.03,null,t,e+.22,n,s);a.rotation.x=-.25;const r=K(i,.03,.03,.3,null,t,e+.42,n+.13,s);r.rotation.x=.35;const o=zt(i,.05,.12,.14,null,t,e+.36,n+.27,16,xe("#e9b949",{roughness:.45}));o.rotation.x=.4;const l=new yt(new gi(.1,16),new cn({color:"#fff3c9"}));l.position.set(t,e+.3,n+.3),l.rotation.x=-Math.PI/2+.4,i.add(l)}function Va(i,t,e,n,s,a,r="#3b3330"){const o=[K(i.g,n+.14,s+.14,.05,r,t,e,.18)],l=Ni(i.g,n,s,Math.round(256*n),Math.round(256*s));l.mesh.position.set(t,e,.21),l.mesh.material=new Dn({map:l.tex,roughness:.9}),a(l.ctx,l.canvas.width,l.canvas.height),l.tex.needsUpdate=!0,o.push(l.mesh),i.attach.push(...o)}const Ga={sunset(i,t,e){i.fillStyle="#f4e3c8",i.fillRect(0,0,t,e),i.fillStyle="#e9967a",i.beginPath(),i.arc(t*.62,e*.45,t*.2,0,Math.PI*2),i.fill(),i.fillStyle="#8fb0a0",i.beginPath(),i.moveTo(0,e),i.lineTo(0,e*.62),i.quadraticCurveTo(t*.35,e*.4,t*.7,e*.66),i.lineTo(t,e*.58),i.lineTo(t,e),i.fill(),i.fillStyle="#4f7c74",i.beginPath(),i.moveTo(0,e),i.lineTo(0,e*.8),i.quadraticCurveTo(t*.5,e*.6,t,e*.82),i.lineTo(t,e),i.fill()},blocks(i,t,e){i.fillStyle="#f7f1e6",i.fillRect(0,0,t,e);const n=["#e07a5f","#3d405b","#81b29a","#f2cc8f"];i.fillStyle=n[0],i.fillRect(t*.12,e*.12,t*.42,e*.4),i.fillStyle=n[1],i.fillRect(t*.54,e*.12,t*.34,e*.22),i.fillStyle=n[2],i.fillRect(t*.54,e*.34,t*.34,e*.54),i.fillStyle=n[3],i.fillRect(t*.12,e*.52,t*.42,e*.36),i.fillStyle="#3d405b",i.beginPath(),i.arc(t*.33,e*.7,t*.1,0,Math.PI*2),i.fill()},arcs(i,t,e){i.fillStyle="#efe6d8",i.fillRect(0,0,t,e),["#c8553d","#f28f3b","#ffd5c2","#588b8b"].forEach((s,a)=>{i.strokeStyle=s,i.lineWidth=t*.07,i.beginPath(),i.arc(t/2,e*.85,t*(.38-a*.09),Math.PI,0),i.stroke()})},leaf(i,t,e){i.fillStyle="#e7ece4",i.fillRect(0,0,t,e),i.fillStyle="#5f8f6b",i.beginPath(),i.ellipse(t/2,e/2,t*.18,e*.36,.35,0,Math.PI*2),i.fill(),i.strokeStyle="#e7ece4",i.lineWidth=t*.015,i.beginPath(),i.moveTo(t*.38,e*.82),i.lineTo(t*.62,e*.18),i.stroke()}};function IM(i,t,e){const n=Ni(i.g,.9,.9,256,256);n.mesh.geometry=new gi(.45,40),n.mesh.position.set(t,e,.22);const s=zt(i.g,.5,.5,.08,"#3b3330",t,e,.17,40);s.rotation.x=Math.PI/2,i.attach.push(s,n.mesh);const a=()=>{const{ctx:r,tex:o}=n;r.fillStyle="#fbf8f2",r.fillRect(0,0,256,256),r.translate(128,128),r.fillStyle="#3b3330";for(let d=0;d<12;d++)r.save(),r.rotate(d/12*Math.PI*2),r.fillRect(-3,-112,6,d%3?12:22),r.restore();const l=new Date,c=l.getMinutes(),h=l.getHours()%12+c/60,u=(d,f,g,_)=>{r.save(),r.rotate(d),r.fillStyle=_,r.fillRect(-g/2,-f,g,f+14),r.restore()};u(h/12*Math.PI*2,62,9,"#3b3330"),u(c/60*Math.PI*2,92,6,"#3b3330"),r.fillStyle="#e07a5f",r.beginPath(),r.arc(0,0,8,0,Math.PI*2),r.fill(),r.setTransform(1,0,0,1,0,0),o.needsUpdate=!0};a(),setInterval(a,3e4)}function kM(){const i=document.createElement("canvas");i.width=i.height=512;const t=i.getContext("2d"),e=8,n=512/e;for(let a=0;a<e;a++)for(let r=0;r<e;r++){t.fillStyle=`hsl(${170+Math.random()*8}, ${9+Math.random()*4}%, ${82+Math.random()*2.5}%)`,t.fillRect(a*n,r*n,n,n),t.globalAlpha=.05;for(let o=0;o<40;o++)t.fillStyle=Math.random()<.5?"#000":"#fff",t.fillRect(a*n+Math.random()*n,r*n+Math.random()*n,2,2);t.globalAlpha=1,t.fillStyle="rgba(60, 80, 80, 0.09)",t.fillRect(a*n,r*n,n,1.5),t.fillRect(a*n,r*n,1.5,n)}const s=new Hi(i);return s.colorSpace=Qe,s.wrapS=s.wrapT=Oi,s.repeat.set(24.5/8,12.6/8),s.anisotropy=8,s}let jr;function NM(i,t,e,n,s){if(!jr){const r=document.createElement("canvas");r.width=256,r.height=64;const o=r.getContext("2d"),l=o.createLinearGradient(0,0,256,0);l.addColorStop(0,"rgba(255, 236, 200, 0.55)"),l.addColorStop(1,"rgba(255, 236, 200, 0)"),o.fillStyle=l,o.fillRect(0,0,256,64),jr=new Hi(r),jr.colorSpace=Qe}const a=new yt(new vi(n,s),new cn({map:jr,transparent:!0,depthWrite:!1,blending:dc,opacity:.5}));a.rotation.x=-Math.PI/2,a.position.set(t,.025,e),i.add(a)}let Yl;function UM(){if(!Yl){const i=Lp();i.repeat.set(.5,.22),Yl=new Dn({map:i,color:"#f0d6b4",roughness:.52})}return Yl}let Qs;function OM(){if(Qs)return Qs;const i=document.createElement("canvas");i.width=384,i.height=128;const t=i.getContext("2d"),e=15,n=5,s=i.width/e,a=i.height/n,r=3;t.fillStyle="#cfcac1",t.fillRect(0,0,i.width,i.height);const o=(c,h,u,d)=>{t.fillStyle="#f7f5f1",t.fillRect(c,h,u,d),t.fillStyle="rgba(88, 84, 78, 0.22)",t.fillRect(c,h+d-2,u,2)};for(let c=0;c<n-1;c++)for(let h=0;h<e;h++)o(h*s+r,c*a+r,s-r*2,a-r*2);const l=(n-1)*a;for(const c of[0,1,2,11,12,13,14])o(c*s+r,l+r,s-r*2,a-r*2);return o(3*s+r,l+r,s*8-r*2,a-r*2),Qs=new Hi(i),Qs.colorSpace=Qe,Qs.anisotropy=4,Qs}function Fd(i,t,e,n,s,a,r=500){const o=new Ht;o.position.set(n,s,a),i.add(o);const l=new yt(new Ye(t+.08,e+.12,.05),["#272d38","#272d38","#272d38","#272d38","#1e232c","#3c4352"].map(h=>xe(h)));l.position.set(0,-.015,-.03),l.castShadow=!0,l.receiveShadow=!0,o.add(l),K(o,(t+.08)*.55,.035,.012,"#323a47",0,-e*.34,-.056).castShadow=!1;const c=Ni(o,t,e,Math.round(t*r),Math.round(e*r));return c.mesh.position.set(0,.015,.002),{g:o,face:c}}function FM(i,t,e,n){const s=xe("#23272f",{roughness:.6});zt(i,.11,.13,.025,"#2f3440",t,e+.012,n,14),zt(i,.022,.022,.3,"#2f3440",t,e+.16,n,10);const a=new yt(new li(.11,.022,6,16,Math.PI),s);a.position.set(t,e+.3,n),a.castShadow=!0,i.add(a);for(const r of[-.11,.11]){const o=zt(i,.065,.065,.05,null,t+r,e+.28,n,14,s);o.rotation.z=Math.PI/2,o.castShadow=!0}}function zM(i,t,e,n){const s=xe("#f4c430",{roughness:.45}),a=new yt(new di(.075,12,10),s);a.position.set(t,e+.06,n),a.scale.set(1,.85,1.25),a.castShadow=!0,i.add(a);const r=new yt(new di(.05,12,10),s);r.position.set(t,e+.15,n-.05),r.castShadow=!0,i.add(r);const o=new yt(new pr(.022,.06,8),xe("#e8833a",{roughness:.5}));o.position.set(t,e+.14,n-.11),o.rotation.x=-Math.PI/2,i.add(o);for(const l of[-.02,.02]){const c=new yt(new di(.008,6,6),xe("#1a1a1a"));c.position.set(t+l,e+.17,n-.085),i.add(c)}}function BM(i,t,e,n,s){const a=new Ht;a.position.set(t,e,n),a.rotation.y=-.4+s%2*.8,i.add(a),K(a,.26,.21,.02,"#3b3330",0,.12,0);const r=Ni(a,.21,.16,84,64);r.mesh.position.set(0,.125,.012);const{ctx:o,canvas:l}=r;o.fillStyle="#cfe3ef",o.fillRect(0,0,l.width,l.height),o.fillStyle="#8fb0a0",o.beginPath(),o.moveTo(0,l.height),o.quadraticCurveTo(l.width*.5,l.height*.35,l.width,l.height),o.fill(),o.fillStyle="#f2cc8f",o.beginPath(),o.arc(l.width*.72,l.height*.3,7,0,Math.PI*2),o.fill(),r.tex.needsUpdate=!0;const c=K(a,.02,.1,.02,"#3b3330",0,.05,-.04);c.rotation.x=.35}function Ap(i,t,e,n){const s=K(i,.3,.035,.38,"#44506b",t,e+.018,n);s.rotation.y=.18;const a=K(i,.27,.02,.35,"#f6f2e8",t,e+.028,n+.01);a.rotation.y=.18,zt(i,.009,.009,.24,"#e07a5f",t+.04,e+.045,n,8).rotation.set(0,.5,Math.PI/2)}function HM(i,t,e,n,s){const a=new Ht;a.position.set(e,0,n);const r=K(a,2.5,.1,1.15,null,0,.78,0,UM());r.receiveShadow=!0,K(a,2.54,.03,1.19,ct.woodDark,0,.742,0);for(const w of[-1.08,1.08])K(a,.09,.72,.16,ct.metal,w,.37,0),K(a,.13,.06,1,ct.metal,w,.03,0),K(a,.13,.05,.86,ct.metal,w,.715,0);K(a,1.95,.07,.08,ct.metal,0,.67,-.18),K(a,2,.3,.04,ct.woodDark,0,.57,-.5);const o=K(a,1.3,.05,.12,"#2a2e38",0,.5,-.3);o.castShadow=!1,K(a,.58,.62,.56,"#e6ded0",.78,.31,-.2);for(const w of[.17,.45]){K(a,.5,.24,.02,"#f1ebe0",.78,w,.09);const R=zt(a,.013,.013,.16,"#8d94a3",.78,w,.105,8);R.rotation.z=Math.PI/2}K(a,.17,.07,.2,ct.metal,0,.87,-.47),zt(a,.03,.035,.52,ct.metal,0,1.12,-.47,12);const l=K(a,.055,.055,.32,ct.metal,0,1.35,-.38);l.rotation.x=.3,K(a,.14,.14,.05,ct.metal,0,1.42,-.31);const c=Fd(a,1.5,.84,0,1.46,-.295);c.g.rotation.x=.05;const h=new cn({color:"#2a3442",toneMapped:!1}),u=new yt(new gi(.014,12),h);u.position.set(.68,-.47,.03),c.g.add(u),s%3===1&&[["#f6d365",-.04,.09],["#f3a6b2",-.19,-.06]].forEach(([w,R,k])=>{const v=K(c.g,.11,.11,.004,w,.8,R,.02);v.rotation.z=k,v.castShadow=!1});const d=Fd(a,.6,.36,-.99,1.08,-.02,500);d.g.rotation.y=.62,K(d.g,.3,.03,.2,ct.metal,0,-.25,0),K(d.g,.06,.2,.06,ct.metal,0,-.14,0);const f=K(a,1.18,.008,.42,"#454d5e",0,.834,.16);f.castShadow=!1,K(a,.8,.022,.27,"#e9e6e1",-.02,.849,.15);const g=new yt(new vi(.76,.23),new Dn({map:OM(),roughness:.7}));g.rotation.x=-Math.PI/2,g.position.set(-.02,.861,.15),g.receiveShadow=!0,a.add(g);const _=new yt(new di(.055,12,8),xe("#e9e6e1"));_.position.set(.52,.843,.18),_.scale.set(1,.6,1.45),_.castShadow=!0,a.add(_),K(a,.012,.004,.05,"#9aa3b2",.52,.874,.15).castShadow=!1;const p=["#e07a5f","#3d7ea6","#f2cc8f","#81b29a"][s%4];zt(a,.07,.065,.16,p,.66,.91,-.08,14);const m=new yt(new li(.045,.012,6,12,Math.PI*1.2),xe(p));m.position.set(.73,.92,-.08),m.rotation.y=Math.PI/2,m.rotation.z=-.3,a.add(m);const y=new yt(new gi(.062,14),xe("#4a3328",{roughness:.3}));y.rotation.x=-Math.PI/2,y.position.set(.66,.985,-.08),a.add(y),[()=>DM(a,.98,.83,-.38),()=>Yh(a,1,.83,-.3),()=>Lo(a,.98,.83,-.32),()=>FM(a,1,.83,-.3),()=>zM(a,1,.83,-.28),()=>BM(a,1,.83,-.3,s)][s%6](),s%4===2&&Ap(a,-.55,.835,-.18);const x=new Ht;x.position.set(.86,.835,.44),a.add(x),K(x,.46,.022,.1,"#2f343f",0,.011,0);const S=Ni(x,.42,.11,256,67);S.mesh.position.set(0,.07,.015),S.mesh.rotation.x=-.42,S.mesh.material=new Dn({map:S.tex,roughness:.75});const P=Cp(ct.chair);P.position.set(0,0,1.05),a.add(P),i.add(a),t.block(e-1.3,e+1.3,n-.7,n+.5);const T={index:s,x:e,z:n,seat:new C(e,0,n+1.05),seatY:Wt,screen:c.face,side:d.face,plate:S,led:h,chair:P};return Pp(T,{}),T}function Cp(i){const t=new Ht,e=xe("#3c4250",{roughness:.9});K(t,.6,.07,.58,i,0,Wt-.035,0);const n=K(t,.56,.05,.54,null,0,Wt+.01,.01,e);n.castShadow=!1;const s=new Ht;s.position.set(0,Wt,.3),s.rotation.x=.12,t.add(s),K(s,.56,.3,.09,i,0,.19,0),K(s,.52,.34,.05,null,0,.52,.005,e);for(const a of[-.25,.25])K(s,.05,.36,.06,i,a,.52,0);K(s,.34,.13,.06,i,0,.79,-.01);for(const a of[-.33,.33]){K(t,.05,.22,.4,i,a,Wt+.09,.06);const r=K(t,.09,.05,.44,null,a,Wt+.21,.04,e);r.castShadow=!1}zt(t,.055,.055,.18,"#6e7684",0,Wt-.14,0,12),zt(t,.042,.042,Wt-.22,ct.metal,0,(Wt-.22)/2+.06,0,10),zt(t,.11,.13,.05,ct.metal,0,.08,0,14);for(let a=0;a<5;a++){const r=a/5*Math.PI*2,o=K(t,.07,.045,.3,ct.metal,0,.075,0);o.position.set(Math.sin(r)*.17,.075,Math.cos(r)*.17),o.rotation.y=r;const l=zt(t,.035,.035,.025,"#22262e",Math.sin(r)*.31,.04,Math.cos(r)*.31,10);l.rotation.z=Math.PI/2,l.rotation.y=r}return t}function zd(i,t,e,n,s){const a=new Ht;a.position.set(e,0,n),a.rotation.y=s,K(a,1.35,Wt-.14,1.2,ct.couch,0,(Wt-.14)/2,0),K(a,1.15,.14,1,"#6c8fb6",0,Wt-.07,.05),K(a,1.35,.78,.26,ct.couch,0,Wt+.25,-.47);for(const o of[-.54,.54])K(a,.27,.56,1.2,ct.couch,o,Wt-.06,0);for(const[o,l]of[[-.55,-.5],[.55,-.5],[-.55,.5],[.55,.5]])zt(a,.05,.04,.12,ct.woodDark,o,.06,l,8);i.add(a);const r=.75;return t.block(e-r,e+r,n-r,n+r),a}function Rp(i,t,e,n){zt(i,.26,.26,.08,n,t,Wt-.04,e,20),zt(i,.035,.035,Wt-.09,ct.metal,t,(Wt-.09)/2,e,8),zt(i,.2,.22,.03,ct.metal,t,.015,e,16)}function Bd(i,{title:t="",subtitle:e="",lines:n=[],accent:s="#7bd389",idle:a=!1,t:r=0}){const{ctx:o,canvas:l,tex:c}=i.screen,h=l.width,u=l.height,d=h/512,f=o.createLinearGradient(0,0,0,u);if(f.addColorStop(0,"#141c26"),f.addColorStop(1,"#0d131b"),o.fillStyle=f,o.fillRect(0,0,h,u),a){o.textAlign="center",o.fillStyle="#2f3a49",o.font=`600 ${34*d}px ${Bn}`,o.fillText(t,h/2,u/2+4*d),o.fillStyle="#263040",o.font=`400 ${20*d}px ${Bn}`,o.fillText(e,h/2,u/2+36*d),o.textAlign="left",c.needsUpdate=!0;return}o.fillStyle=s,o.fillRect(0,0,h,5*d),o.globalAlpha=.09,o.fillRect(0,5*d,h,76*d),o.globalAlpha=1,o.beginPath(),o.arc(30*d,40*d,6*d,0,Math.PI*2),o.fillStyle=s,o.globalAlpha=.55+.45*Math.sin(r*3),o.fill(),o.globalAlpha=1,o.fillStyle="#eaeff5",o.font=`650 ${26*d}px ${Bn}`,o.fillText(t,46*d,48*d),o.fillStyle="#7d8a9c",o.font=`400 ${18*d}px ${Bn}`,o.fillText(e,46*d,73*d),o.fillStyle="rgba(125, 138, 156, 0.22)",o.fillRect(24*d,92*d,1.5*d,u-104*d),o.font=`400 ${18*d}px ${LM}`;const g=n.slice(-8);g.forEach((_,p)=>{const m=p===g.length-1,y=116*d+p*23*d;o.globalAlpha=m?1:.45+p*.06,o.fillStyle=_.color||(m?"#eaeff5":"#8b98aa");let x=_.text;for(;o.measureText(x).width>h-56*d&&x.length>4;)x=x.slice(0,-2);x!==_.text&&(x=x.slice(0,-1)+"…"),o.fillText(x,38*d,y),o.globalAlpha=1}),Math.floor(r*2)%2===0&&(o.fillStyle=s,o.fillRect(38*d,116*d+g.length*23*d-14*d,9*d,17*d)),c.needsUpdate=!0}function Pp(i,{name:t="",accent:e="#7d8a9c",state:n="open"}={}){const s=n==="working";i.led&&i.led.color.set(s?e:n==="open"?"#232a35":"#39455a");const a=i.plate;if(a){const{ctx:o,canvas:l,tex:c}=a;o.fillStyle="#2c323d",o.fillRect(0,0,l.width,l.height),o.fillStyle=n==="open"?"#454c5a":e,o.fillRect(0,0,9,l.height),o.fillStyle=n==="open"?"#8d97a6":"#f3f1ed",o.font=`650 30px ${Bn}`,o.textBaseline="middle",o.fillText(t,26,l.height/2+1),o.textBaseline="alphabetic",c.needsUpdate=!0}const r=i.side;if(r){const{ctx:o,canvas:l,tex:c}=r,h=l.width,u=l.height;if(o.fillStyle=n==="open"?"#0b0f15":"#121a24",o.fillRect(0,0,h,u),n==="open"){o.fillStyle="#1b2430",o.beginPath(),o.arc(h/2,u/2,5,0,Math.PI*2),o.fill(),c.needsUpdate=!0;return}o.fillStyle=e,o.globalAlpha=.85,o.fillRect(0,0,h,4),o.globalAlpha=1,o.font=`600 ${Math.round(u*.1)}px ${Bn}`,o.fillStyle="#6f7d8f",o.fillText(t.toUpperCase(),14,26),o.textAlign="right",o.fillStyle=s?e:"#4d5a6b",o.fillText(s?"ACTIVE":n==="away"?"OFFLINE":"IDLE",h-14,26),o.textAlign="left";let d=0;for(const f of t+n)d=(d*31+f.charCodeAt(0))%9973;for(let f=0;f<6;f++){const g=44+f*Math.round((u-58)/6),_=Math.max(4,Math.round(u*.045));o.fillStyle="#1b2531",o.fillRect(14,g,h-28,_),d=(d*31+17)%9973;const p=s?.25+d%70/100:.08+d%25/100;o.fillStyle=f===0&&s?e:"#35445a",o.fillRect(14,g,Math.round((h-28)*p),_)}c.needsUpdate=!0}}function VM(i){const t=new PM(Ki,ns,re.x0,re.z0),e=[],n=xe("#a97a50"),s=new Dn({map:Lp(),roughness:.7}),a=new yt(new Ye(Ki+.6,.7,ns+.6),[n,n,s,n,n,n]);a.position.set(re.cx,-.35,0),a.receiveShadow=!0,a.castShadow=!0,i.add(a);const r=new yt(new vi(160,160),new D1({opacity:.14}));r.rotation.x=-Math.PI/2,r.position.y=-.72,r.receiveShadow=!0,i.add(r);const o=$M(Ki+16,ns+16);o.position.x=re.cx,i.add(o);const l=K(i,24.5,.02,12.6,null,0,.011,1.2,new Dn({map:kM(),roughness:1}));l.castShadow=!1;const c=-21,h=[Yr(i,Ki+.6,re.cx,re.z0-.15,0,[0,0,-1]),Yr(i,Ki+.6,re.cx,re.z1+.15,Math.PI,[0,0,1],[[-Ki/2-.3,c-1.2],[c+1.2,Ki/2+.3]]),Yr(i,ns,re.x0-.15,0,Math.PI/2,[-1,0,0]),Yr(i,ns,re.x1+.15,0,-Math.PI/2,[1,0,0])],[u,,d,f]=h,g=j=>j-re.cx;t.block(re.x0,re.x1,re.z0,re.z0+.2),t.block(re.x0,re.x0+.2,re.z0,re.z1);for(const j of[-6,0,6]){const Q=-j;d.attach.push(K(d.g,3.6,2.2,.06,ct.glass,Q,2.2,.15,{emissive:"#bfe3f5",emissiveIntensity:.45,roughness:.15}),K(d.g,3.8,.12,.14,ct.trim,Q,1.08,.2),K(d.g,3.8,.12,.14,ct.trim,Q,3.32,.2),K(d.g,.1,2.3,.14,ct.trim,Q,2.2,.2))}for(const j of[-6,0,6])NM(i,-17.4,j,5,3.6);const _=[];[[-9,-3],[-3,-3],[3,-3],[9,-3],[-9,5],[-3,5],[3,5],[9,5]].forEach(([j,Q],Tt)=>_.push(HM(i,t,j,Q,Tt)));const p=["#e07a5f","#3d7ea6","#f2cc8f","#81b29a","#9c6ade","#e5989b","#2a9d8f","#577590"];for(const j of[-18.4,-16.2,-14,-11.8]){K(i,2,3.2,.7,ct.woodDark,j,1.6,-14.5);for(let Q=0;Q<4;Q++){const Tt=.45+Q*.75;K(i,1.86,.05,.62,ct.wood,j,Tt-.04,-14.42);let wt=j-.85;for(;wt<j+.8;){const A=.1+Math.random()*.1,M=.4+Math.random()*.22;K(i,A,M,.45,p[Math.floor(Math.random()*p.length)],wt+A/2,Tt+M/2,-14.4),wt+=A+.02}}}t.block(-19.6,-10.7,-15,-14);for(const j of[12,13.4,14.8,16.2,17.6]){K(i,1.2,2.7,1,ct.rack,j,1.35,-14.4);for(let Q=0;Q<9;Q++){const Tt=K(i,.07,.07,.03,"#000",j-.4+Q%3*.12,.5+Math.floor(Q/3)*.7+Math.random()*.2,-13.88,new Dn({color:"#0a0a0a",emissive:["#4ade80","#60a5fa","#fbbf24"][Q%3],emissiveIntensity:1.2}));Tt.castShadow=!1,e.push(Tt)}for(let Q=0;Q<6;Q++)K(i,1,.02,.02,"#4b5261",j,.35+Q*.42,-13.89)}t.block(11.2,18.4,-15,-13.7);const m=new Ht;m.position.set(-18.6,0,0);const y=new yt(new Hn(.35,.45,.9,16),xe(ct.woodDark));y.position.y=.45;const x=new yt(new di(.45,24,16),xe("#4f8fc0",{roughness:.5}));x.position.y=1.35;const S=new yt(new Ta(.46,1),xe("#7fb069",{flatShading:!0,transparent:!0,opacity:.85}));S.position.y=1.35,S.scale.set(1,.9,.7);for(const j of[y,x,S])j.castShadow=!0,m.add(j);i.add(m),t.block(-19.2,-18,-.6,.6);const P=new Ht;P.position.set(15.6,0,-8),K(P,5,2.4,.08,ct.board,0,1.9,0,{roughness:.4}),K(P,5.2,.1,.14,ct.metal,0,.66,.02),K(P,.08,1.9,.08,ct.metal,-2.3,.6,0),K(P,.08,1.9,.08,ct.metal,2.3,.6,0);const T=Ni(P,4.8,2.2,640,290);T.mesh.position.set(0,1.9,.045),i.add(P),t.block(13,18.2,-8.4,-7.6);const w=K(i,9,.02,5.4,ct.rug,-14,.01,10.6);w.castShadow=!1;const R=new Ht;R.position.set(-14.5,0,8.4),K(R,5,Wt-.14,1.2,ct.couch,0,(Wt-.14)/2,0),K(R,5,.8,.3,ct.couch,0,Wt+.26,-.48);for(const j of[-2.35,2.35])K(R,.3,.6,1.2,ct.couch,j,Wt-.08,0);for(const j of[-1.5,0,1.5])K(R,1.4,.14,1,"#6c8fb6",j,Wt-.07,.05);for(const[j,Q]of[[-2.2,-.5],[2.2,-.5],[-2.2,.5],[2.2,.5]])zt(R,.05,.04,.12,ct.woodDark,j,.06,Q,8);i.add(R),t.block(-17,-12,7.8,9),zd(i,t,-17.3,10.9,Math.PI/2),zd(i,t,-12,10.9,-Math.PI/2),K(i,2.4,.08,1.2,ct.wood,-14.5,.48,10.6);for(const[j,Q]of[[-1.1,-.5],[1.1,-.5],[-1.1,.5],[1.1,.5]])K(i,.06,.44,.06,ct.metal,-14.5+j,.22,10.6+Q);t.block(-15.8,-13.2,10,11.2),K(i,1.3,.95,3.2,"#efe9df",-19.3,.475,12),K(i,.55,.65,.5,"#2c2f36",-19.35,1.28,11.4),K(i,.12,.08,.12,"#c0392b",-19.05,1.4,11.4,{emissive:"#c0392b",emissiveIntensity:.6});for(let j=0;j<3;j++){const Q=new yt(new Hn(.07,.06,.14,10),xe("#ffffff"));Q.position.set(-19.2,1.02,12.5+j*.25),i.add(Q)}t.block(-20,-18.6,10.4,13.6);const k=new Ht;k.position.set(-11,0,12),zt(k,.3,.34,.04,ct.metal,0,.02,0,20),zt(k,.04,.04,1.05,ct.metal,0,.55,0,10),zt(k,.48,.48,.05,ct.wood,0,1.08,0,28);for(const[j,Q,Tt]of[[-.18,.08,"#e07a5f"],[.2,-.1,"#3d7ea6"]])zt(k,.06,.05,.13,Tt,j,1.17,Q,12);i.add(k),t.block(-11.5,-10.5,11.5,12.5),u.attach.push(K(u.g,9.4,3.5,.08,"#d9cdbb",g(0),2.2,.2));const v=Ni(u.g,9,3.2,1536,546);v.mesh.position.set(g(0),2.2,.26),u.attach.push(v.mesh);const b=new Ht;b.position.set(23.4,0,12.4),K(b,3.4,1.05,.9,"#efe9df",0,.525,0),K(b,3.5,.06,1,ct.wood,0,1.08,0),K(b,.9,.55,.05,ct.metal,-.8,1.4,-.25);const N=Ni(b,1.6,.34,400,85);N.mesh.position.set(0,.62,.456),N.ctx.fillStyle="#efe9df",N.ctx.fillRect(0,0,400,85),N.ctx.fillStyle="#1d1b18",N.ctx.font=`650 38px ${Bn}`,N.ctx.textAlign="center",N.ctx.fillText("Chief of Staff",200,56),N.tex.needsUpdate=!0;const F=Cp(ct.chair);F.position.set(0,0,-1),F.rotation.y=Math.PI,b.add(F),i.add(b),t.block(21.6,25.2,11.9,12.9);const $=K(i,2.4,.02,1.6,"#b9a58f",Ud,.01,14);$.castShadow=!1,Va(u,g(-7.6),2.5,1.6,1.1,Ga.sunset),IM(u,g(7.6),2.7),Va(f,1.4,2.4,1,1.4,Ga.arcs),Va(f,3,2.4,1,1.4,Ga.blocks),Va(f,4.6,2.4,1,1.4,Ga.leaf),Va(d,11,2.5,1.2,.9,Ga.blocks,"#c39a6b");const W=new Ht;W.position.set(19.35,0,3),K(W,.7,.75,3.6,ct.woodDark,0,.4,0),K(W,.76,.05,3.7,ct.wood,0,.8,0);for(const j of[-1.2,0,1.2])K(W,.02,.6,1.1,"#9a7350",-.36,.4,j);for(const[j]of[[-1.7],[1.7]])K(W,.6,.06,.06,ct.metal,0,.03,j);Lo(W,0,.82,-1.1,4),Yh(W,0,.82,.2),zt(W,.11,.08,.38,"#3d7ea6",.05,1.01,1.2,14,{roughness:.35});for(let j=0;j<3;j++){const Q=zt(W,.008,.008,.5,"#5f8f6b",.05+(j-1)*.04,1.4,1.2,4);Q.rotation.z=(j-1)*.3;const Tt=new yt(new Ta(.06,0),xe(["#f2cc8f","#e5989b","#fff"][j],{flatShading:!0}));Tt.position.set(.05+(j-1)*.12,1.64,1.2),W.add(Tt)}i.add(W),t.block(18.9,20,1.1,4.9);const z=new Ht;z.position.set(-1,0,11.6),K(z,5.2,.08,1.4,ct.wood,0,.78,0);for(const j of[-2.3,2.3])K(z,.08,.74,1.1,ct.metal,j,.38,0);for(const j of[-1.7,0,1.7])for(const Q of[-1.05,1.05])Rp(z,j,Q,["#e07a5f","#f2cc8f","#81b29a"][Math.round(j+2)%3]);Lo(z,-1.4,.82,.1,2),zt(z,.06,.06,.14,"#ffffff",.5,.89,-.2,12);const nt=new Ht;nt.position.set(1.3,.82,.1),K(nt,.5,.025,.35,"#c7ccd4",0,.012,0);const G=K(nt,.5,.34,.02,"#c7ccd4",0,.17,-.17);G.rotation.x=-.25,z.add(nt);for(const j of[-1.6,1.6]){zt(z,.02,.02,1.6,"#2f3440",j,3.4,0,6);const Q=zt(z,.06,.32,.28,"#2f3440",j,2.55,0,20,{roughness:.5});Q.castShadow=!1;const Tt=new yt(new gi(.29,20),new cn({color:"#fff1c4"}));Tt.rotation.x=Math.PI/2,Tt.position.set(j,2.405,0),z.add(Tt)}i.add(z),t.block(-3.8,1.8,10.3,12.9);const at=new Ht;at.position.set(je.x,0,je.z);const ht=.84;K(at,3.7,.22,2.1,ct.woodDark,0,.71,0);for(const[j,Q]of[[-1.55,-.85],[1.55,-.85],[-1.55,.85],[1.55,.85]])K(at,.2,.62,.2,ct.woodDark,j,.31,Q);K(at,3.5,.03,1.9,"#2f7a57",0,ht-.015,0,{roughness:1});const mt=[];for(const j of[-1,1]){for(const Q of[-1,1])mt.push([1.32,.1,.25,j*.82,Q*.925]);mt.push([.25,.1,1.36,j*1.725,0])}for(const[j,Q,Tt,wt,A]of mt)K(at,j,Q,Tt,ct.wood,wt,ht+.05,A);for(const j of[-1,1])for(const Q of[-1,1])K(at,.3,.1,.3,ct.wood,j*1.83,ht+.05,Q*.98);for(const[j,Q,Tt,wt]of[[1.28,.06,.82,.83],[1.28,.06,.82,-.83],[1.28,.06,-.82,.83],[1.28,.06,-.82,-.83]])K(at,j,.05,Q,"#256646",Tt,ht+.025,wt).castShadow=!1;for(const j of[-1,1])K(at,.06,.05,1.3,"#256646",j*1.57,ht+.025,0).castShadow=!1;const Xt=new cn({color:"#0c0d10"});for(const[j,Q]of[[-1.6,-.8],[1.6,-.8],[-1.6,.8],[1.6,.8],[0,-.835],[0,.835]]){const Tt=new yt(new Hn(.15,.15,.02,20),Xt);Tt.position.set(j,ht+.002,Q),at.add(Tt)}i.add(at),t.block(je.x-1.95,je.x+1.95,je.z-1.15,je.z+1.15);const qt=new Ht;qt.position.set(-18,0,8.2),zt(qt,.22,.24,.04,"#2f3440",0,.02,0,20),zt(qt,.025,.025,1.7,"#2f3440",0,.87,0,8);const q=zt(qt,.22,.3,.38,"#f3e7d3",0,1.85,0,24,{emissive:"#ffe2a8",emissiveIntensity:.35,roughness:.9});q.castShadow=!1,i.add(qt),t.block(-18.4,-17.6,7.8,8.6);const st=K(i,6.4,.02,3.2,"#c9b79c",25.4,.012,12.9,{roughness:1});st.castShadow=!1;const Mt=K(i,6,.022,2.8,"#ddd0bb",25.4,.013,12.9,{roughness:1});Mt.castShadow=!1;const dt=GM(i,t,u,f,g),It=[[-19,-9.5,1.1,"tall"],[10,-14,1,"snake"],[-9.8,-14.2,.9,"bush"],[19,-11,1.2,"tall"],[-10.3,14,1,"bush"],[6.2,13.8,1.1,"tall"],[19,8.5,1,"snake"],[19.2,0,.9,"bush"],[-19.1,14.2,.8,"snake"],[11.6,13.9,1,"bush"]];for(const[j,Q,Tt,wt]of It)Tp(i,t,j,Q,Tt,wt);const Rt={n:Math.PI,s:0,w:-Math.PI/2,e:Math.PI/2},Nt=j=>j.map(([Q,Tt,wt,A,M])=>({pos:new C(Q,0,Tt),face:Rt[wt],pose:A,seatY:M,taken:null})),ee={library:{label:"Library",spots:Nt([[-17.6,-12.9,"n","read"],[-15.3,-12.9,"n","read"],[-13.1,-12.9,"n","read"],[-11,-12.9,"n","read"]])},servers:{label:"Server room",spots:Nt([[12.7,-12.6,"n","type"],[14.1,-12.6,"n","type"],[15.5,-12.6,"n","type"],[16.9,-12.6,"n","type"]])},window:{label:"Research window",spots:Nt([[-17.5,-6,"w","gaze"],[-17.5,-2.6,"w","gaze"],[-17.5,2.6,"w","gaze"],[-17.5,6,"w","gaze"]])},whiteboard:{label:"Whiteboard",spots:Nt([[13.9,-6.4,"n","write"],[15.2,-6.4,"n","write"],[16.5,-6.4,"n","write"],[17.8,-6.4,"n","write"]])},lounge:{label:"Break room",spots:Nt([[-16,8.5,"s","couch",Wt],[-14.5,8.5,"s","couch",Wt],[-13,8.5,"s","couch",Wt],[-17.2,10.9,"e","couch",Wt],[-11.9,10.9,"w","couch",Wt],[-2.7,10.55,"s","sit",Wt],[-1,10.55,"s","sit",Wt],[.7,10.55,"s","sit",Wt],[-2.7,12.65,"n","sit",Wt],[-1,12.65,"n","sit",Wt],[.7,12.65,"n","sit",Wt],[-17.9,11.4,"w","mug"],[-17.9,12.8,"w","mug"],[-11.95,12,"e","mug"],[-10.05,12,"w","mug"]])}},$t=new C(15.3,0,-2.4),L=Array.from({length:10},(j,Q)=>{const Tt=Math.PI+Q/10*Math.PI*2,wt=new C($t.x+Math.sin(Tt)*2.3,0,$t.z+Math.cos(Tt)*2.3);return{pos:wt,face:Math.atan2($t.x-wt.x,$t.z-wt.z)}});ee.lounge.spots.push({pos:new C(je.x-.9,0,je.z-1.65),face:Rt.s,pose:"stand",taken:null,game:!0},{pos:new C(je.x+.9,0,je.z+1.65),face:Rt.n,pose:"stand",taken:null,game:!0});const ze=(j,Q,Tt,wt,A)=>({pos:new C(j,0,Q),face:Math.atan2(Tt-j,wt-Q),pose:A,taken:null});return ee.poolside={label:"Pool table",spots:[[4.9,10.9],[10.3,10.9],[9.6,8.8],[5.6,8.8]].map(([j,Q])=>ze(j,Q,je.x,je.z,"mug"))},Object.assign(ee,dt.stations),{grid:t,desks:_,stations:ee,pool:at,standup:L,board:v,scribble:T,blinkers:e,globe:S,slab:a,updateWalls:(j,Q,Tt)=>XM(h,j,Q,Tt),door:new C(Ud,0,14.4),reception:{seat:new C(23.4,0,11.4),seatY:Wt}}}function GM(i,t,e,n,s){const a=(T,w,R,k,v,b)=>({pos:new C(T,0,w),face:Math.atan2(R-T,k-w),pose:v,seatY:b,taken:null}),o=new Dn({color:ct.glass,transparent:!0,opacity:.28,roughness:.08,metalness:.1,depthWrite:!1}),l=re.z0,c=-3.6,h=new yt(new Ye(.05,2.3,c-l),o);h.position.set(Js,1.25,(l+c)/2),i.add(h),K(i,.1,.1,c-l,ct.metal,Js,2.42,(l+c)/2),K(i,.12,.1,c-l,ct.metal,Js,.05,(l+c)/2);for(let T=l+.2;T<=c+.01;T+=(c-l-.2)/4)K(i,.08,2.45,.08,ct.metal,Js,1.22,T);t.block(Js-.15,Js+.15,l,c),K(i,10.4,.02,10.8,"#c9d3c4",26.2,.011,-8.6,{roughness:1}).castShadow=!1,K(i,10,.022,10.4,"#d6ddd1",26.2,.012,-8.6,{roughness:1}).castShadow=!1,e.attach.push(K(e.g,5.4,1.5,.08,"#2f3440",s(26.2),2.65,.2));const u=Ni(e.g,5.2,1.3,800,200);u.mesh.position.set(s(26.2),2.65,.25),u.ctx.fillStyle="#2f3440",u.ctx.fillRect(0,0,800,200),u.ctx.textAlign="center",u.ctx.fillStyle="#f5f0e8",u.ctx.font=`680 76px ${Bn}`,u.ctx.fillText("Guest wing",400,104),u.ctx.fillStyle="#b9c7b4",u.ctx.font=`500 30px ${Bn}`,u.ctx.fillText("Visitors from linked offices work here",400,158),u.tex.needsUpdate=!0,e.attach.push(u.mesh);for(const T of[-10.4,-5.2])n.attach.push(K(n.g,3.2,2.2,.06,ct.glass,T,2.2,.15,{emissive:"#bfe3f5",emissiveIntensity:.45,roughness:.15}),K(n.g,3.4,.12,.14,ct.trim,T,1.08,.2),K(n.g,3.4,.12,.14,ct.trim,T,3.32,.2),K(n.g,.1,2.3,.14,ct.trim,T,2.2,.2));const d=[];for(const T of[-11,-6.2]){const w=new Ht;w.position.set(26.2,0,T),K(w,6.2,.08,1.2,ct.wood,0,.78,0),K(w,6.24,.03,1.24,ct.woodDark,0,.742,0);for(const R of[-2.8,2.8])K(w,.08,.74,1,ct.metal,R,.38,0);K(w,5.5,.26,.04,ct.woodDark,0,.6,0);for(const R of[-2,0,2])for(const k of[-1,1]){Rp(w,R,k*1.05,["#7c5cff","#0e9f9a","#d9488f","#c98a12","#3b82f6","#65a30d"][(R/2+1)*2+(k+1)/2]);const v=new Ht;v.position.set(R,.82,k*.3),v.rotation.y=k>0?0:Math.PI,K(v,.5,.025,.35,"#c7ccd4",0,.012,0);const b=K(v,.5,.34,.02,"#c7ccd4",0,.17,-.17);b.rotation.x=-.25,w.add(v),d.push(a(26.2+R,T+k*1.05,26.2+R,T,"desk",Wt))}for(const R of[-2,2]){zt(w,.02,.02,1.6,"#2f3440",R,3.4,0,6),zt(w,.06,.32,.28,"#2f3440",R,2.55,0,20,{roughness:.5}).castShadow=!1;const k=new yt(new gi(.29,20),new cn({color:"#fff1c4"}));k.rotation.x=Math.PI/2,k.position.set(R,2.405,0),w.add(k)}i.add(w),t.block(26.2-3.1,26.2+3.1,T-.6,T+.6)}const f=new Ht;f.position.set(24.4,0,-2.2);const g="#3f8f8a",_="#5aa8a2";K(f,4,Wt-.14,1.1,g,0,(Wt-.14)/2,0),K(f,4,.78,.28,g,0,Wt+.25,-.44);for(const T of[-1.86,1.86])K(f,.28,.58,1.1,g,T,Wt-.07,0);for(const T of[-1.1,0,1.1])K(f,1.05,.14,.92,_,T,Wt-.07,.05);for(const[T,w]of[[-1.8,-.45],[1.8,-.45],[-1.8,.45],[1.8,.45]])zt(f,.05,.04,.12,ct.woodDark,T,.06,w,8);i.add(f),t.block(22.3,26.5,-2.8,-1.6),K(i,1.8,.06,.7,ct.wood,24.4,.4,-.5);for(const[T,w]of[[-.8,-.28],[.8,-.28],[-.8,.28],[.8,.28]])K(i,.05,.38,.05,ct.metal,24.4+T,.19,-.5+w);Lo(i,24,.43,-.5,2),t.block(23.4,25.4,-.9,-.1);const p=new Ht;p.position.set(31.35,0,3),K(p,1,.95,3.6,"#efe9df",0,.475,0),K(p,1.06,.05,3.7,ct.wood,0,.97,0),K(p,.55,.65,.5,"#2c2f36",.1,1.32,-.9),K(p,.12,.08,.12,"#0e9f9a",-.2,1.44,-.9,{emissive:"#0e9f9a",emissiveIntensity:.6});for(let T=0;T<3;T++)zt(p,.07,.06,.14,"#ffffff",-.1,1.06,.1+T*.28,10);Yh(p,0,.99,1.3),i.add(p),t.block(30.8,re.x1,1.1,4.9);const m=new Ht;m.position.set(27.6,0,3),zt(m,.3,.34,.04,ct.metal,0,.02,0,20),zt(m,.04,.04,1.05,ct.metal,0,.55,0,10),zt(m,.48,.48,.05,ct.wood,0,1.08,0,28),zt(m,.06,.05,.13,"#d9488f",.15,1.17,.1,12),i.add(m),t.block(27.1,28.1,2.5,3.5);const y=[a(30.2,2,31.35,2,"mug"),a(30.2,3,31.35,3,"mug"),a(30.2,4,31.35,4,"mug"),a(26.65,3,27.6,3,"mug"),a(28.55,3,27.6,3,"mug"),...[23.2,24.4,25.6].map(T=>({pos:new C(T,0,-2.1),face:0,pose:"couch",seatY:Wt,taken:null}))],x={x:27.6,z:8.4},S=new Ht;S.position.set(x.x,0,x.z),zt(S,.42,.48,.05,ct.metal,0,.025,0,24),zt(S,.07,.07,1.02,ct.metal,0,.53,0,12),zt(S,.9,.9,.06,ct.wood,0,1.06,0,36),Ap(S,-.2,1.09,.1),i.add(S),t.block(x.x-.9,x.x+.9,x.z-.9,x.z+.9);const P=Array.from({length:6},(T,w)=>{const R=w/6*Math.PI*2+Math.PI/6;return a(x.x+Math.sin(R)*1.55,x.z+Math.cos(R)*1.55,x.x,x.z,"stand")});for(const[T,w,R,k]of[[31.2,-14.2,1.1,"tall"],[21.1,-4.6,.9,"bush"],[31.2,13.8,1,"snake"],[31.3,-1.2,.9,"bush"],[21.2,6.2,1,"tall"]])Tp(i,t,T,w,R,k);return{stations:{hotdesk:{label:"Guest desks",spots:d},coffee:{label:"Guest coffee",spots:y},huddle:{label:"Guest table",spots:P}}}}function Lp(){const i=document.createElement("canvas");i.width=i.height=1024;const t=i.getContext("2d"),e=16,n=i.height/e;for(let a=0;a<e;a++){let r=-Math.random()*400;for(;r<i.width;){const o=380+Math.random()*520,l=73+Math.random()*3.5;t.fillStyle=`hsl(${32+Math.random()*3}, ${33+Math.random()*5}%, ${l}%)`,t.fillRect(r,a*n,o,n),t.globalAlpha=.045;for(let c=0;c<6;c++)t.fillStyle=Math.random()<.5?"#7a5634":"#fff6e8",t.fillRect(r,a*n+Math.random()*n,o,1+Math.random()*2);t.globalAlpha=1,t.fillStyle="rgba(90, 60, 35, 0.22)",t.fillRect(r,a*n,2,n),r+=o}t.fillStyle="rgba(90, 60, 35, 0.18)",t.fillRect(0,a*n,i.width,2)}const s=new Hi(i);return s.colorSpace=Qe,s.wrapS=s.wrapT=Oi,s.repeat.set(Ki/8,ns/8),s.anisotropy=8,s}function $M(i,t){const e=document.createElement("canvas");e.width=e.height=256;const n=e.getContext("2d"),s=n.createRadialGradient(128,128,30,128,128,128);s.addColorStop(0,"rgba(60, 40, 20, 0.28)"),s.addColorStop(.6,"rgba(60, 40, 20, 0.12)"),s.addColorStop(1,"rgba(60, 40, 20, 0)"),n.fillStyle=s,n.fillRect(0,0,256,256);const a=new Hi(e),r=new yt(new vi(i,t),new cn({map:a,transparent:!0,depthWrite:!1}));return r.rotation.x=-Math.PI/2,r.position.y=-.715,r}const la=4.2,WM=.5;function Yr(i,t,e,n,s,a,r=[[-t/2,t/2]]){const o=new Ht;o.position.set(e,0,n),o.rotation.y=s;const l=new Ht,c=new Ht;o.add(l,c);for(const[u,d]of r){const f=new yt(new Ye(d-u,la,.3),xe(ct.wall));f.position.set((u+d)/2,la/2,0),f.castShadow=f.receiveShadow=!0,l.add(f);const g=new yt(new Ye(d-u,.1,.36),xe("#cbbba3"));g.position.set((u+d)/2,.05,0),c.add(g);const _=new yt(new Ye(d-u,.22,.04),xe(ct.trim));_.position.set((u+d)/2,.11,.17),o.add(_)}i.add(o);const h={g:o,body:l,cap:c,outward:new C(...a),h:la,attach:[]};return c.position.y=la,h}const Hd=new C;function XM(i,t,e,n){Hd.subVectors(t.position,e).setY(0).normalize();for(const s of i){const a=s.outward.dot(Hd)>.2?WM:la;s.h+=(a-s.h)*Math.min(1,n*7),s.body.scale.y=s.h/la,s.cap.position.y=s.h;for(const r of s.attach)r.visible=s.h>3.4}}const qM={queued:0,working:1,done:2,failed:2,stopped:2},jM={queued:"#fde68a",working:"#bfdbfe",done:"#bbf7d0",failed:"#fecaca",stopped:"#e5e7eb"};function Dp(i,t){const{ctx:e,canvas:n,tex:s}=i,a=n.width,r=n.height;e.fillStyle="#fbfaf7",e.fillRect(0,0,a,r);const o=["Queued","Working","Shipped"],l=a/3;o.forEach((c,h)=>{e.fillStyle="#1d1b18",e.font=`650 34px ${Bn}`,e.fillText(c,h*l+28,54),h&&(e.fillStyle="#e7e1d7",e.fillRect(h*l,20,3,r-40)),t.filter(d=>qM[d.status]===h).sort((d,f)=>(f.endedAt||f.queuedAt)-(d.endedAt||d.queuedAt)).slice(0,6).forEach((d,f)=>{const g=h*l+28+f%2*(l/2-18),_=80+Math.floor(f/2)*150,p=l/2-36,m=130;e.save(),e.translate(g+p/2,_+m/2),e.rotate((d.id.charCodeAt(0)%7-3)*.008),e.fillStyle="rgba(0,0,0,0.08)",e.fillRect(-p/2+4,-m/2+6,p,m),e.fillStyle=jM[d.status],e.fillRect(-p/2,-m/2,p,m),e.fillStyle="#1d1b18",e.font=`600 22px ${Bn}`,YM(e,d.title,-p/2+14,-m/2+34,p-28,26,3),e.fillStyle="#5b554c",e.font=`400 18px ${Bn}`,e.fillText(d.repo.slice(0,22),-p/2+14,m/2-14),e.restore()})}),s.needsUpdate=!0}function YM(i,t,e,n,s,a,r){const o=String(t).split(/\s+/);let l="",c=0;for(let h=0;h<o.length;h++){const u=l?l+" "+o[h]:o[h];if(i.measureText(u).width>s&&l){if(c===r-1){i.fillText(l+"…",e,n+c*a);return}i.fillText(l,e,n+c*a),l=o[h],c++}else l=u}i.fillText(l,e,n+c*a)}function nh(i,t){const{ctx:e,canvas:n,tex:s}=i;e.fillStyle="#fbfaf7",e.fillRect(0,0,n.width,n.height),e.fillStyle="#2f5d8a",e.font='600 30px "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive',e.fillText("Today",26,46),e.font='400 24px "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive',t.slice(0,7).forEach((a,r)=>{e.fillStyle=a.done?"#6b8f71":"#3a3a3a";const o=(a.done?"✓ ":"• ")+a.text;e.fillText(o.length>44?o.slice(0,43)+"…":o,30,86+r*30)}),s.needsUpdate=!0}const Vd=(i,t,e)=>{let n=((t-i+Math.PI)%(Math.PI*2)+Math.PI*2)%(Math.PI*2)-Math.PI;return i+n*e},$a=(i,t)=>i+Math.random()*(t-i);function Kr(i,t=34){let e=String(i||"").replace(/\s+/g," ").trim();const n=e.search(/[,;:]| \u2014 | - | and | with | so that | in order /i);if(n>11&&(e=e.slice(0,n)),e.length<=t)return e;const s=e.lastIndexOf(" ",t);return e.slice(0,s>t*.6?s:t).replace(/[,.;:]$/,"")+"…"}const Gd=["coffee?","anyone seen my mug","back in 5","nice weather","who broke main","lunch soon?","reading the docs, honestly","standup when"];let Kl=null;function KM(){if(Kl)return Kl;const i=document.createElement("canvas");i.width=i.height=64;const t=i.getContext("2d"),e=t.createRadialGradient(32,32,4,32,32,32);return e.addColorStop(0,"rgba(40, 28, 16, 0.32)"),e.addColorStop(1,"rgba(40, 28, 16, 0)"),t.fillStyle=e,t.fillRect(0,0,64,64),Kl=new Hi(i)}class Kh{constructor(t,e,n,s={}){this.staff=t,this.id=t.id,this.name=t.name,this.world=e,this.desk=s.desk||e.desks[e.agentIndex(t.id)],this.deskFace=s.face??Math.PI,this.root=new Ht,this.fig=new ir(t),this.root.add(this.fig.group),this.body=this.fig.body;const a=new yt(new gi(.5,24),new cn({map:KM(),transparent:!0,depthWrite:!1}));a.rotation.x=-Math.PI/2,a.position.y=.015,this.root.add(a),this.ring=new yt(new Gh(.55,.68,40),new cn({color:t.shirt,transparent:!0,opacity:.9})),this.ring.rotation.x=-Math.PI/2,this.ring.position.y=.03,this.ring.visible=!1,this.root.add(this.ring),this.root.traverse(c=>{c.userData.agentId=t.id}),e.scene.add(this.root),this.pos=this.root.position,this.heading=0,this.path=[],this.goal=null,this.placeKey=null,this.spot=null,this.pose="stand",this.want="lounge",this.dwellUntil=0,this.wanderAt=0,this.chatAt=$a(8,30),this.anim=null,this.job=null,this.lines=[],this.phase=Math.random()*10,this.label=document.createElement("div"),this.label.className="agent-label";const r=document.createElement("div");r.className="bubble";const o=document.createElement("div");o.className="name";const l=document.createElement("i");/^#[0-9a-f]{3,8}$/i.test(t.shirt??"")&&(l.style.background=t.shirt),this.nameText=document.createTextNode(String(t.name??"")),o.append(l,this.nameText),this.label.append(r,o),this.bubbleEl=this.label.querySelector(".bubble"),n.appendChild(this.label),this.say("")}rename(t){this.name=t,this.nameText.data=t,this.labelDirty=!0}say(t,e="",n=0){t!==this.bubbleText&&(this.labelDirty=!0),this.bubbleText=t,this.bubbleEl.textContent=t,this.bubbleEl.className="bubble"+(e?" "+e:""),this.bubbleEl.style.display=t?"":"none",this.bubbleUntil=n?(this.now||0)+n/1e3:0}teleport(t){const e=this.resolve(t);e&&(this.pos.copy(e.pos),this.heading=e.face,this.root.rotation.y=e.face,this.goal=e,this.path=[],this.arrive(0))}resolve(t,e=!1){if(t==="desk")return{key:t,pos:this.desk.seat.clone(),face:this.deskFace,pose:"desk",seatY:this.desk.seatY};if(t==="visit")return this.visitTarget;if(t==="standup")return this.meeting;if(t==="door")return{key:t,pos:this.world.door.clone(),face:Math.PI,pose:"stand"};const n=this.world.stations[t];if(!n)return null;let s=!e&&this.spot&&n.spots.includes(this.spot)?this.spot:null;if(!s){const r=n.spots.filter(l=>!l.game&&(!l.taken||l.taken===this.id)),o=e?r.filter(l=>l!==this.spot):r;s=(o.length?o:r)[Math.floor(Math.random()*(o.length||r.length))]}if(!s)return t==="lounge"?null:this.resolve("desk");this.spot&&this.spot!==s&&(this.spot.taken=null),s.taken=this.id,this.spot=s;const a=t==="lounge"||s.seatY?0:.12;return{key:t,pos:s.pos.clone().add(new C($a(-a,a),0,$a(-a,a))),face:s.face,pose:s.pose,seatY:s.seatY}}goTo(t,e,n=!1){t==="desk"&&this.spot&&(this.spot.taken=null,this.spot=null);const s=this.resolve(t,n);s&&(this.goal=s,this.placeKey=null,this.path=this.world.grid.path(this.pos.x,this.pos.z,s.pos.x,s.pos.z),this.path.length||this.arrive(e))}arrive(t){const e=this.goal;this.pos.set(e.pos.x,0,e.pos.z),this.placeKey=e.key,this.pose=e.pose,this.seatY=e.seatY,this.dwellUntil=t+(e.key==="desk"?.8:e.key==="lounge"?0:e.key==="visit"?3.4:e.key==="standup"?.5:2.4),e.key==="lounge"&&(this.wanderAt=t+$a(18,40))}assign(t,e=!1){this.job=t,this.anim=null,this.want="desk",this.lines=[],this.say("On it","",0),e&&this.teleport("desk")}visit(t,e){const n=this.world.grid,s=[[1.1,0],[-1.1,0],[0,1.1],[0,-1.1],[.9,.9],[-.9,.9]],[a,r]=s.find(([l,c])=>!n.blocked(...n.cellOf(t.pos.x+l,t.pos.z+c)))||[1.1,0],o=new C(t.pos.x+a,0,t.pos.z+r);this.visitTarget={key:"visit",pos:o,face:Math.atan2(t.pos.x-o.x,t.pos.z-o.z),pose:"talk"},this.afterVisit=this.want==="visit"?this.afterVisit:this.want,this.want="visit",this.placeKey=null,this.path=[],this.spot&&(this.spot.taken=null,this.spot=null),this.say(Kr(e,52),"talk",0)}onLog(t){if(!this.job)return;const e=(...a)=>!this.meeting&&this.say(...a),n={tool:null,text:"#e8edf3",error:"#f87171",thinking:"#64748b",system:"#64748b"}[t.kind],s=a=>{this.want==="visit"?this.afterVisit=a:this.want=a};if(t.kind==="tool")s("desk"),e(Kr(t.summary)),this.lines.push({text:"› "+t.summary,color:n});else if(t.kind==="text"){s("desk");const a=t.summary.split(new RegExp("(?<=[.!?])\\s|\\n"))[0];e(Kr(a,44)),this.lines.push({text:a,color:n})}else t.kind==="thinking"?e("thinking…","thinking"):t.kind==="error"?(e(t.blocked?"Needs clearance":"Hm, that failed","warn"),this.lines.push({text:"✕ "+t.summary.split(`
4475
- `)[0],color:n})):t.kind==="system"&&(this.lines.push({text:t.summary,color:n}),t.wait&&(s("desk"),e(Kr(t.summary,30)+"…","thinking")));this.lines.length>40&&this.lines.splice(0,this.lines.length-40)}meet(t,e=!1){if(this.meeting={key:"standup",pos:t.pos.clone(),face:t.face,pose:"stand"},this.spot&&(this.spot.taken=null,this.spot=null),e)return this.teleport("standup");this.want!=="visit"&&(this.path=[],this.placeKey=null)}adjourn(){this.meeting=null,this.placeKey==="standup"&&(this.placeKey=null)}speak(t){this.say(t,"talk",5200),this.anim={kind:"talk",until:(this.now||0)+4.8}}leave(){this.leaving=!0,this.want="door",this.spot&&(this.spot.taken=null,this.spot=null),this.say("Heading home","idle",3e3)}stay(){this.leaving=!1,this.want="lounge",this.say("Oh, staying!","good",2500)}dispose(){this.spot&&(this.spot.taken=null),this.world.scene.remove(this.root),this.label.remove()}finish(t){const e=this.now||0;this.anim={kind:t==="done"?"celebrate":"slump",until:e+2.2},this.say(t==="done"?"Shipped it!":t==="waiting"?"Need your answer":t==="stopped"?"Okay, stopping":"Hit a wall",t==="done"?"good":"warn",4e3),this.job=null,this.afterVisit=null,this.want="lounge"}think(t){var s;if(this.anim&&t<this.anim.until)return;this.anim=null,this.bubbleUntil&&t>this.bubbleUntil&&this.say("");const e=this.meeting&&!this.leaving&&this.want!=="visit"?"standup":this.want;if(this.path.length){((s=this.goal)==null?void 0:s.key)==="lounge"&&e!=="lounge"&&this.goTo(e,t);return}if(t<this.dwellUntil)return;if(this.leaving&&this.placeKey==="door"){this.gone=!0;return}this.placeKey==="visit"&&this.want==="visit"&&(this.want=this.job?this.afterVisit||"desk":"lounge",this.afterVisit=null,this.bubbleEl.classList.contains("talk")&&this.say(""));const n=this.meeting&&!this.leaving&&this.want!=="visit"?"standup":this.want;n!==this.placeKey?this.goTo(n,t):n==="lounge"&&t>this.wanderAt&&this.goTo("lounge",t,!0),!this.job&&!this.meeting&&!this.chatting&&t>this.chatAt&&(this.chatAt=t+$a(25,60),Math.random()<.5&&this.say(Gd[Math.floor(Math.random()*Gd.length)],"idle",3500))}update(t,e){var s;this.now=e,this.think(e);let n=!1;if(this.path.length){const[a,r]=this.path[0],o=a-this.pos.x,l=r-this.pos.z,c=Math.hypot(o,l),h=3.4*t;c<=h?(this.pos.x=a,this.pos.z=r,this.path.shift(),this.path.length||this.arrive(e)):(this.pos.x+=o/c*h,this.pos.z+=l/c*h,this.heading=Vd(this.heading,Math.atan2(o,l),Math.min(1,t*12)),n=!0)}!n&&this.goal&&!this.path.length&&(this.heading=Vd(this.heading,this.goal.face,Math.min(1,t*8))),this.root.rotation.y=this.heading,this.animate(n?"walk":((s=this.anim)==null?void 0:s.kind)||this.pose,t,e)}animate(t,e,n){var r;this.fig.pose(t,e,n+this.phase,{typing:!!this.job&&!this.job.waiting&&this.job.id!=="idle",waiting:!!((r=this.job)!=null&&r.waiting),seatY:this.seatY});const s=this.bubbleEl.className,a=t==="celebrate"?"happy":t==="slump"||s.includes("warn")?"worried":t==="talk"||s.includes("idle")&&this.bubbleText?"talk":s.includes("thinking")?"think":s.includes("good")?"happy":"neutral";this.fig.express(a,e,n+this.phase)}placeLabel(t,e,n){const s=new C(this.pos.x,this.body.position.y+2.5+(this.fig.look.hair==="afro"?.2:0),this.pos.z).project(t);if(this.onScreen=s.z<=1,!this.onScreen){this.label.style.display="none",this.lift=0;return}this.label.style.display="",this.anchorX=(s.x*.5+.5)*e,this.anchorY=(-s.y*.5+.5)*n,this.depth=s.z,this.label.style.zIndex=String(Math.round((1-s.z)*1e4)),(this.labelDirty||!this.labelW)&&this.measureLabel()}measureLabel(){this.label.offsetWidth&&(this.labelDirty=!1,this.labelW=this.label.offsetWidth,this.labelH=this.label.offsetHeight)}labelBox(t){const e=this.anchorY-t;return{left:this.anchorX-this.labelW/2,right:this.anchorX+this.labelW/2,top:e-this.labelH,bottom:e}}setLift(t,e){const n=this.lift===void 0?1:Math.min(1,e*9);this.lift=(this.lift||0)+(t-(this.lift||0))*n,Math.abs(this.lift-t)<.4&&(this.lift=t),this.label.style.transform=`translate(-50%, -100%) translate(${this.anchorX}px, ${this.anchorY-this.lift}px)`}setBuried(t){t!==this.buried&&(this.buried=t,this.label.classList.toggle("buried",t))}setCrowded(t,e){t?this.uncrowdAt=e+.6:this.crowded&&e<(this.uncrowdAt||0)&&(t=!0),t!==this.crowded&&(this.crowded=t,this.label.classList.toggle("crowded",t),this.measureLabel())}setSelected(t){this.ring.visible=t,this.label.classList.toggle("selected",t)}}const Zr=(i,t)=>i+Math.random()*(t-i),sr=i=>i[Math.floor(Math.random()*i.length)];async function is(i,t,e){const n=await fetch(i,t===void 0?{method:e||"GET"}:{method:e||"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`Request failed (${n.status})`);return n.json().catch(()=>({}))}const ZM=[["Coffee machine is making that noise again.","It does that when it likes you.","It has never liked me."],["Weekend plans, {b}?","Sleep, then more sleep.","Ambitious. I respect it."],["Did you see the size of that last diff?","I saw it. I chose not to look closer.","Wise."],["{b}, tabs or spaces?","Whatever the linter says.","Diplomatic answer.","It's the only safe one in here."],["I renamed one variable and forty tests broke.","Only forty? Lucky.","You have a dark sense of luck, {b}."],["Who keeps leaving one sip in the coffee pot?","Not me.","That is exactly what someone guilty would say."],["Favourite error message?",'"Something went wrong."',"So helpful. So honest."],["Read anything good lately?","The changelog for our test runner. Gripping stuff.","No spoilers please."],["This couch is too comfy.","Dangerous for productivity.","Good thing nobody has given us work yet."],["Do you ever dream in stack traces?","Only on deploy days.","Same."],["{b}, you were quiet in standup.","Saving my words for code review.","Ominous."],["Hot take: README files are love letters.","To whom?","To whoever opens this repo at 2am.","That's beautiful, {a}."],["What's the plant's name?","I call it Prod.","Why?","Because we don't touch it."],["I fixed a bug by deleting code today.","Best kind of fix.","Felt like spring cleaning."],["Lunch?","Already had it. Twice.","Bold."],['Have you noticed the boss says "quick change" a lot?',"Never quick.","Rarely one change."],["If you could rewrite one thing from scratch?","The build config.","Wouldn't we all."],["How do you stay so calm, {b}?","Small commits.","That explains a lot."]],JM=[{pair:["tunde","obi"],lines:["Still thinking about idempotency keys, {b}.","You always are. It is why I trust you with the ledger.","Say it again, but with a retry.","Same result. That is the whole point."]},{pair:["tunde","obi"],lines:["Remember the first ledger?","Four of us and one whiteboard.","We never did erase that whiteboard.","It's load-bearing now."]},{pair:["kai","zola"],lines:["Submission day, {b}. Checklist out?","Always out. Step one: breathe.","Step two: provisioning profile.","Step two is where we cry."]},{pair:["kai","zola"],lines:["Another rejection email. I can feel it.","Read it first. Then panic.","That is not on the checklist.","I will add it."]},{pair:["ada","mira"],lines:["I had a thought about the dashboard, {b}.","Is it a question? Please let it be a question.","It is a question.","Then I love it already. Go."]},{pair:["ada","tunde"],lines:["Does the new screen survive a retry, {b}?","You asked before I did.","You taught me.","Noted. Quietly proud."]},{pair:["ada","kai"],lines:["It should feel the same on web and app.","Thumbs do not agree.","Thumbs never do.","Move the button down, {a}."]},{pair:["mira","lin"],lines:["Could you look at this early, {b}? Before it is finished?","You ask early. I like that.","Startup scars.","The good kind of scar."]},{pair:["mira","tunde"],lines:["I could just own this whole feature, {b}.","Could you also wait for my green light?","That is the hard part.","It is the part that saves you."]},{pair:["mira","zola"],lines:["Ship it now, {b}?","Not yet.","How about now?","Ask me after the checklist."]},{pair:["lin","obi"],lines:["Another payload for you, {a}.","Guilty until proven valid.","You read my mind.","I read your schema."]},{pair:["lin","tunde"],lines:["Your logs are very readable, {b}.","I log everything now.","I know. It started on a train.","Do not remind me."]},{pair:["zola","tunde"],lines:["That alert again.","I saw it.","We nod?","We nod."]},{pair:["remi","mira"],lines:["Found a bug in your feature, {b}.","Wonderful. Send me the steps.","No defence? No excuses?","I would rather have the bug than the excuse."]}],QM=[{who:"tunde",lines:["Remember the Tuesday, {b}?","Nobody has forgotten the Tuesday.","That is why I log everything now.","Fair enough."]},{who:"kai",lines:["Did you hear? An app rejected over one permission string.","Is this the one you keep telling us about?","Never gets old.","It does, {a}."]},{who:"ada",lines:["Found a loading spinner I actually like.","Is it going in the folder?","It is going in the folder.","There is a folder?"]},{who:"zola",lines:["The release train ran on time again.","Because of the checklist.","Because of the checklist.","We all owe it a coffee."]},{who:"obi",lines:["Webhooks are promises, {b}.","To whom?","To whichever team is waiting on them.","Heavy thought for a coffee break."]},{who:"mira",lines:["One quick question, {b}.","Your questions are never quick.","This one is tiny.","Narrator: it was not."]},{who:"lin",lines:["Anyone have a worry they have not told anyone?","Not yet.","My door is open, and so is the kettle.","Thanks, {a}."]},{who:"remi",lines:['Anyone say "it works on my machine" today?',"Not me.","Good. I was sharpening my pencil.","Please do not."]}];function tb(i,t){const e=JM.filter(a=>a.pair.includes(i.id)&&a.pair.includes(t.id)),n=QM.filter(a=>a.who===i.id||a.who===t.id),s=Math.random();if(e.length&&s<.55){const a=sr(e);return $d(a.pair[0],a.lines,i,t)}if(n.length&&s<.8){const a=sr(n);return $d(a.who,a.lines,i,t)}return{who:[i,t],script:sr(ZM)}}function $d(i,t,e,n){return{who:i===e.id?[e,n]:[n,e],script:t}}const Wa=i=>!i.job&&!i.meeting&&!i.leaving&&!i.path.length&&i.want==="lounge"&&i.placeKey==="lounge"&&!i.playing;class eb{constructor(){this.next=Zr(10,20),this.chat=null,this.claiming=!1}update(t,e){if(this.chat)return this.step(e);if(this.claiming||e<this.next)return;const n=t.filter(Wa);if(n.length<2)return;const s=sr(n),a=sr(n.filter(r=>r!==s));this.claim(s,a,e)}async claim(t,e,n){this.claiming=!0,this.next=n+Zr(20,45);let s=null,a=null;try{({id:s,script:a}=await is("/api/chill",{who:[t.id,e.id]}))}catch{}if(this.claiming=!1,!!s){if(!Wa(t)||!Wa(e))return this.release(s);this.start(t,e,s,a)}}start(t,e,n,s){const{who:[a,r],script:o}=Array.isArray(s)&&s.length>=2?{who:[t,e],script:s}:tb(t,e),l=o.map(c=>c.replaceAll("{a}",a.name).replaceAll("{b}",r.name));for(const[c,h]of[[a,r],[r,a]])c.chatting=!0,c.wanderAt=1/0,c.pose!=="couch"&&(c.goal={...c.goal,face:Math.atan2(h.pos.x-c.pos.x,h.pos.z-c.pos.z)});this.chat={id:n,who:[a,r],script:l,line:0,at:0}}step(t){const e=this.chat;if(!e.who.every(Wa))return this.end(t);if(t<e.at)return;if(e.line>=e.script.length)return this.end(t);const n=e.who[e.line%2],s=e.script[e.line];n.say(s,"idle",3200+s.length*30),is(`/api/chill/${e.id}/line`,{from:n.id,text:s}).catch(()=>{}),e.at=t+2.6+s.length*.035,e.line++}end(t){this.release(this.chat.id);for(const e of this.chat.who)e.chatting=!1,Wa(e)&&(e.wanderAt=t+Zr(8,20));this.chat=null,this.next=t+Zr(20,45)}release(t){is(`/api/chill/${t}`,void 0,"DELETE").catch(()=>{})}}const Ze=3.2,Ri=1.6,Re=.075,Ip=.9,Jr=.78,Wd=7,nb=1/240,Qr=.15,Xd=.135,Zh=[{x:-Ze/2,z:-Ri/2,r:Qr},{x:Ze/2,z:-Ri/2,r:Qr},{x:-Ze/2,z:Ri/2,r:Qr},{x:Ze/2,z:Ri/2,r:Qr},{x:0,z:-Ri/2-.035,r:Xd},{x:0,z:Ri/2+.035,r:Xd}],to=i=>i===0?"cue":i===8?"eight":i<8?"solids":"stripes";function ih(){const i=[{n:0,x:-Ze/4,z:0,vx:0,vz:0,in:!1}],t=[1,2,3,4,5,6,7,9,10,11,12,13,14,15].sort(()=>Math.random()-.5),e=new Array(15);e[4]=8;const n=[10,14];e[n[0]]=t.splice(t.findIndex(r=>r<8),1)[0],e[n[1]]=t.splice(t.findIndex(r=>r>8),1)[0];for(let r=0;r<15;r++)e[r]||(e[r]=t.pop());const s=Re*2*1.002;let a=0;for(let r=0;r<5;r++)for(let o=0;o<=r;o++)i.push({n:e[a++],x:Ze/4+r*s*.866,z:(o-r/2)*s,vx:0,vz:0,in:!1});return i}function ib(i,t,e={}){var s,a,r;let n=t;for(;n>1e-9;){const o=Math.min(nb,n);n-=o;for(const l of i){if(l.in)continue;const c=Math.hypot(l.vx,l.vz);if(c>0){const f=Math.max(0,c-Ip*o),g=f/c;l.vx*=g,l.vz*=g,f<.012&&(l.vx=0,l.vz=0)}l.x+=l.vx*o,l.z+=l.vz*o;const h=Ze/2-Re,u=Ri/2-Re;let d=!1;l.x<-h?(l.x=-h,l.vx=Math.abs(l.vx)*Jr,d=!0):l.x>h&&(l.x=h,l.vx=-Math.abs(l.vx)*Jr,d=!0),l.z<-u?(l.z=-u,l.vz=Math.abs(l.vz)*Jr,d=!0):l.z>u&&(l.z=u,l.vz=-Math.abs(l.vz)*Jr,d=!0),d&&((s=e.cushion)==null||s.call(e,l));for(const f of Zh)if(Math.hypot(l.x-f.x,l.z-f.z)<f.r){l.in=!0,l.vx=0,l.vz=0,l.pocket=f,(a=e.pocket)==null||a.call(e,l,f);break}}for(let l=0;l<i.length;l++){const c=i[l];if(!c.in)for(let h=l+1;h<i.length;h++){const u=i[h];if(u.in)continue;const d=u.x-c.x,f=u.z-c.z,g=d*d+f*f;if(g>=4*Re*Re||g===0)continue;const _=Math.sqrt(g),p=d/_,m=f/_,y=(2*Re-_)/2;c.x-=p*y,c.z-=m*y,u.x+=p*y,u.z+=m*y;const x=(u.vx-c.vx)*p+(u.vz-c.vz)*m;if(x<0){const S=-1.96*x/2;c.vx-=S*p,c.vz-=S*m,u.vx+=S*p,u.vz+=S*m,(r=e.hit)==null||r.call(e,c,u,-x)}}}}}const sb=i=>i.some(t=>!t.in&&(t.vx||t.vz));class ab{constructor(t){this.players=t,this.balls=ih(),this.turn=0,this.groups=null,this.shots=0,this.winner=null,this.over=null,this.inHand=!0,this.begin()}get cue(){return this.balls[0]}get shooter(){return this.players[this.turn]}get other(){return this.players[1-this.turn]}begin(){this.log={first:null,potted:[],cushion:!1,legal:this.targets().map(t=>t.n)}}targets(t=this.shooter){const e=this.balls.filter(s=>s.n&&!s.in);if(!this.groups)return e.filter(s=>s.n!==8);const n=e.filter(s=>to(s.n)===this.groups[t]);return n.length?n:e.filter(s=>s.n===8)}remaining(t){return this.groups?this.balls.filter(e=>e.n&&!e.in&&to(e.n)===this.groups[t]).length:7}recorder(){return{hit:(t,e)=>{this.log.first===null&&(t.n===0||e.n===0)&&(this.log.first=t.n===0?e.n:t.n)},pocket:t=>this.log.potted.push(t.n),cushion:()=>{this.log.cushion=!0}}}settle(){this.shots++;const{first:t,potted:e}=this.log,n=this.shooter,s=this.shots===1,a=e.includes(0),r=e.includes(8),o=this.log.legal,l={foul:!1,why:"",potted:e.filter(h=>h),continues:!1,assigned:null,eight:r};if(s&&r){const h=this.balls.find(u=>u.n===8);h.in=!1,h.x=Ze/4,h.z=0,h.vx=h.vz=0,e.splice(e.indexOf(8),1),l.eight=!1}if(t===null?(l.foul=!0,l.why="missed everything"):o.includes(t)||(l.foul=!0,l.why=t===8?"hit the eight first":"wrong ball first"),a&&(l.foul=!0,l.why="scratched"),!l.foul&&!s&&!e.length&&!this.log.cushion&&(l.foul=!0,l.why="nothing reached a cushion"),l.eight){const h=this.groups&&o.every(u=>u===8);return h&&!l.foul?this.finish(n,"eight"):this.finish(this.other,h?"foul-eight":"early-eight"),l.over=this.over,l}if(!this.groups&&!l.foul&&!s){const h=e.find(u=>u&&u!==8);if(h){const u=to(h);this.groups={[n]:u,[this.other]:u==="solids"?"stripes":"solids"},l.assigned=u}}if(a){const h=this.cue;h.in=!1,h.vx=h.vz=0}const c=e.filter(h=>h&&h!==8&&(!this.groups||to(h)===this.groups[n]));if(l.continues=!l.foul&&c.length>0,this.inHand=l.foul,l.continues||(this.turn=1-this.turn),this.shots>=80&&!this.winner){const h=this.remaining(this.players[0]),u=this.remaining(this.players[1]);this.finish(h<=u?this.players[0]:this.players[1],"worn-out"),l.over=this.over}return this.begin(),l}finish(t,e){this.winner=t,this.over=e}placeCue(t){const e=this.cue,n=(a,r)=>this.balls.every(o=>o===e||o.in||Math.hypot(o.x-a,o.z-r)>Re*2.4),s=t?[[-Ze/4,0],[-Ze/4,.2],[-Ze/4,-.2]]:[[-Ze/4,0],[-Ze/3,.3],[-Ze/3,-.3],[.3,.3],[.3,-.3],[-.2,.5],[-.2,-.5],[-Ze/2+.3,.2]];for(const[a,r]of s)if(n(a,r)){e.x=a,e.z=r,e.vx=e.vz=0,e.in=!1;return}for(let a=0;a<200;a++){const r=(Math.random()-.5)*(Ze-.4),o=(Math.random()-.5)*(Ri-.4);if(n(r,o)){e.x=r,e.z=o,e.vx=e.vz=0,e.in=!1;return}}}}const Zl=(i,t,e,n,s,a,r)=>{const o=n-t,l=s-e,c=o*o+l*l||1e-9;for(const h of i){if(h.in||a.includes(h))continue;const u=Math.max(0,Math.min(1,((h.x-t)*o+(h.z-e)*l)/c));if(Math.hypot(h.x-(t+u*o),h.z-(e+u*l))<r)return!1}return!0};function rb(i,t=.7){const e=i.balls,n=i.cue,s=i.targets();let a=null;if(i.shots===0){const c=e.find(h=>h.n!==0&&h.x===Math.min(...e.filter(u=>u.n).map(u=>u.x)));a={angle:Math.atan2(c.z-n.z,c.x-n.x),speed:5.6+Math.random()*1.2,target:c,pocket:null,clean:!1,power:"break"}}else{for(const c of s)for(const h of Zh){const u=h.x*.97,d=h.z*.97,f=u-c.x,g=d-c.z,_=Math.hypot(f,g)||1e-9,p=c.x-f/_*2*Re,m=c.z-g/_*2*Re;if(Math.abs(p)>Ze/2-Re||Math.abs(m)>Ri/2-Re)continue;const y=p-n.x,x=m-n.z,S=Math.hypot(y,x);if(S<Re*2)continue;const P=(y*f+x*g)/(S*_);if(P<.34||!Zl(e,n.x,n.z,p,m,[n,c],Re*2*.98)||!Zl(e,c.x,c.z,u,d,[n,c],Re*2*.98))continue;const T=P*2-(S+_)*.35-(c.n===8,0);(!a||T>a.score)&&(a={angle:Math.atan2(x,y),speed:Math.min(Wd*.8,Math.sqrt(2*Ip*(S+_*1.3))+1.1),target:c,pocket:h,clean:!0,score:T})}if(!a){const c=s.length?s:e.filter(f=>f.n&&!f.in),h=c.filter(f=>Zl(e,n.x,n.z,f.x,f.z,[n,f],Re*2*.98)),u=h.length?h:c;u.sort((f,g)=>Math.hypot(f.x-n.x,f.z-n.z)-Math.hypot(g.x-n.x,g.z-n.z));const d=u[0];a={angle:Math.atan2(d.z-n.z,d.x-n.x),speed:2.6+Math.random()*1.2,target:d,pocket:null,clean:!1}}}const r=Math.hypot(a.target.x-n.x,a.target.z-n.z),o=(.006+.026*(1-t))*(.8+r*.35),l=()=>(Math.random()+Math.random()+Math.random()-1.5)*1.4;return a.angle+=l()*o*(a.power==="break"?.6:1),a.speed=Math.min(Wd,Math.max(1.2,a.speed*(1+l()*.06*(1.2-t)))),a}function ob(i,t,e){i.cue.vx=Math.cos(t)*e,i.cue.vz=Math.sin(t)*e}let jn=null,po=null,Do=!1;try{Do=localStorage.getItem("office.muted")==="1"}catch{}function kp(){if(!jn){const i=window.AudioContext||window.webkitAudioContext;if(!i)return;jn=new i,po=jn.createGain(),po.gain.value=.5,po.connect(jn.destination)}jn.state==="suspended"&&jn.resume()}addEventListener("pointerdown",kp);addEventListener("keydown",kp);function Nn(i,t,e,{type:n="sine",gain:s=.2}={}){const a=jn.currentTime+t,r=jn.createOscillator(),o=jn.createGain();r.type=n,r.frequency.setValueAtTime(i,a),o.gain.setValueAtTime(1e-4,a),o.gain.exponentialRampToValueAtTime(s,a+.012),o.gain.exponentialRampToValueAtTime(1e-4,a+e),r.connect(o).connect(po),r.start(a),r.stop(a+e+.05)}const ta=()=>!Do&&jn&&jn.state==="running",dn={get muted(){return Do},setMuted(i){Do=i;try{localStorage.setItem("office.muted",i?"1":"0")}catch{}},ship(){ta()&&([659.25,830.61,987.77].forEach((i,t)=>{Nn(i,t*.085,.55,{gain:.16}),Nn(i*2,t*.085,.3,{type:"triangle",gain:.035})}),Nn(1318.5,.26,.9,{gain:.09}))},fail(){ta()&&(Nn(293.66,0,.35,{type:"triangle",gain:.12}),Nn(246.94,.14,.5,{type:"triangle",gain:.12}))},levelUp(){ta()&&[523.25,659.25,783.99,1046.5,1318.5].forEach((i,t)=>Nn(i,t*.07,.7,{gain:.13}))},knock(){ta()&&(Nn(880,0,.09,{gain:.06}),Nn(1174.7,.07,.12,{gain:.05}))},click(i=.5){if(!ta())return;const t=.025+i*.07;Nn(1900+Math.random()*500,0,.035,{type:"triangle",gain:t}),Nn(3100,0,.02,{gain:t*.5})},pocket(){ta()&&(Nn(180,0,.18,{type:"triangle",gain:.09}),Nn(120,.06,.22,{type:"sine",gain:.07}))}},ea=(i,t)=>i+Math.random()*(t-i),ii=i=>i[Math.floor(Math.random()*i.length)],lb=["#f2c230","#2f5fb3","#d6402f","#6a3a9c","#e8803a","#2f8a4f","#8a2a2e"];function cb(i){const t=document.createElement("canvas");t.width=128,t.height=64;const e=t.getContext("2d"),n=i===0?"#f4f1ea":i===8?"#1b1b1f":lb[(i-1)%7];if(e.fillStyle=i>8?"#f4f1ea":n,e.fillRect(0,0,128,64),i>8&&(e.fillStyle=n,e.fillRect(0,14,128,36)),i){e.font="700 17px Inter, system-ui, sans-serif",e.textAlign="center",e.textBaseline="middle";for(const a of[32,96])e.fillStyle="#f4f1ea",e.beginPath(),e.arc(a,32,13,0,Math.PI*2),e.fill(),e.fillStyle="#1b1b1f",e.fillText(String(i),a,33)}const s=new Hi(t);return s.colorSpace=Qe,s}const hb=["corner","corner","corner","corner","side","side"],ub=i=>hb[Zh.indexOf(i)]||"pocket",db=[["Eight ball? Loser buys the coffee.","You are on."],["Quick game of eight ball?","Rack them up."],["Pool table is free. That never happens.","Then we have to."],["Break is yours.","Bold of you to give me the break."]],fb=["Nice.","Smooth.","That one dropped.","Clean.","In."],pb=["So close.","Rolled out.","Unlucky.","The table is tilted."],mb=["Scratch.","Ugh, foul.","The cue ball had other plans."],gb=["Ball in hand.","Your table.","Thank you."],vb=["Here goes.","Let me see this one.","Easy.","Trust the line."],_b=["Good game.","That was fun.","Rematch later?"],xb=["Rematch.","Good game. Coffee is on me.","The table was tilted."];class yb{constructor(t,e){this.spots=e.stations.lounge.spots.filter(r=>r.game),this.root=new Ht,this.root.position.set(je.x,0,je.z),t.add(this.root);const n=new di(Re,20,14);this.meshes=[];for(let r=0;r<=15;r++){const o=new yt(n,new Dn({map:cb(r),roughness:.22,metalness:.02}));o.castShadow=!0,o.userData={x:0,z:0,sunk:null},this.root.add(o),this.meshes.push(o)}this.cue=new Ht;const s=new yt(new Hn(.016,.026,1.9,8),xe("#d9b27a"));s.rotation.z=Math.PI/2,s.position.x=-.95,s.castShadow=!0;const a=new yt(new Hn(.016,.016,.04,8),xe("#5b8fb0"));a.rotation.z=Math.PI/2,a.position.x=-.02,this.cue.add(s,a),this.cueOuter=new Ht,this.cueOuter.add(this.cue),this.cue.rotation.z=-.12,this.cueOuter.visible=!1,this.root.add(this.cueOuter),this.resting=ih(),this.view=this.resting,this.next=ea(25,45),this.s=null,this.claiming=!1}get playing(){return!!this.s}update(t,e,n){this.s?this.run(e,n):!this.claiming&&e>=this.next&&this.tryStart(t,e),this.draw(e,n)}tryStart(t,e){const n=o=>!o.gone&&!o.job&&!o.meeting&&!o.leaving&&o.want==="lounge"&&!o.playing&&!o.chatting,s=t.filter(n);if(this.next=e+ea(15,30),s.length<2)return;const a=ii(s),r=ii(s.filter(o=>o!==a));this.claim(a,r,e)}async claim(t,e,n){this.claiming=!0;let s=null;try{({id:s}=await is("/api/chill",{who:[t.id,e.id],game:!0}))}catch{}if(this.claiming=!1,!s)return;const a=r=>!r.gone&&!r.job&&!r.meeting&&!r.leaving&&r.want==="lounge"&&!r.playing&&!r.chatting;if(!a(t)||!a(e))return this.release(s);this.begin(t,e,s,n)}begin(t,e,n,s){const a=[t,e];a.forEach((o,l)=>{const c=this.spots[l];o.spot&&o.spot!==c&&(o.spot.taken=null),o.spot=c,c.taken=o.id,o.playing=!0,o.chatting=!0,o.wanderAt=1/0,o.goTo("lounge",s)});const r=o=>.45+([...o.id].reduce((l,c)=>l*31+c.charCodeAt(0),7)>>>0)%50/100;this.s={id:n,players:a,skill:a.map(r),phase:"walk",deadline:s+60,game:null,plan:null,shots:0}}called(t){return t.gone||t.job||t.meeting||t.leaving||t.want!=="lounge"}run(t,e){const n=this.s;if(n.players.some(o=>this.called(o)))return this.stop(t,!1);for(const o of n.players)o.wanderAt=1/0;t-(n.pinged??0)>30&&(n.pinged=t,is(`/api/chill/${n.id}/ping`,{}).catch(()=>{}));const[s,a]=n.players,r=o=>{var l;return o.placeKey==="lounge"&&!o.path.length&&((l=o.spot)==null?void 0:l.game)};switch(n.phase){case"walk":{if(t>n.deadline)return this.stop(t,!1);if(!r(s)||!r(a))return;n.game=new ab([s.id,a.id]),this.view=n.game.balls;for(const c of this.meshes)c.userData.sunk=null;const[o,l]=ii(db);s.say(o,"idle",3200),n.phase="rack",n.until=t+1.2,n.line=l,n.said=!1,is(`/api/chill/${n.id}/line`,{from:s.id,text:o}).catch(()=>{});return}case"rack":!n.said&&t>n.until-.4&&(a.say(n.line,"idle",2600),n.said=!0),t>n.until&&this.aim(t);return;case"aim":return this.aiming(t);case"roll":{const o=n.rec;if(n.clicks=0,ib(n.game.balls,Math.min(e,.05),o),n.rolled+=e,n.rolled>.3&&(this.cueOuter.visible=!1),sb(n.game.balls)&&n.rolled<22)return;for(const l of n.game.balls)l.vx=0,l.vz=0;return this.settled(t)}case"pause":t>n.until&&this.aim(t);return;case"over":t>n.until&&this.stop(t,!0)}}agentOf(t){return this.s.players.find(e=>e.id===t)}aim(t){const e=this.s,n=e.game,s=this.agentOf(n.shooter),a=this.agentOf(n.other),r=e.players.indexOf(s);n.inHand&&n.placeCue(n.shots===0),e.plan=rb(n,e.skill[r]),e.t0=t,e.dur=ea(1.5,2.2),e.struck=!1,e.phase="aim",e.shooter=s,e.waiter=a;const o=je.x+n.cue.x,l=je.z+n.cue.z;s.goal={...s.goal,face:Math.atan2(o-s.pos.x,l-s.pos.z)},a.goal={...a.goal,face:Math.atan2(o-a.pos.x,l-a.pos.z)};const c=e.plan.pocket&&ub(e.plan.pocket),h=c&&Math.random()<.4?e.plan.target.n===8?`Eight ball, ${c} pocket.`:`${c[0].toUpperCase()}${c.slice(1)} pocket.`:Math.random()<.18?ii(vb):"";h&&s.say(h,"idle",2400),this.cueOuter.visible=!0}aiming(t){const e=this.s,n=e.game,s=Math.min(1,(t-e.t0)/e.dur);e.shooter.anim={kind:"cue",until:t+.5},e.waiter.anim={kind:"mug",until:t+.5};const a=s<.55?.07+Math.sin(s*40)*.006:s<.85?.07+((s-.55)/.3)**2*.34:.41*(1-(s-.85)/.15)+.02;this.placeCue(a,e.plan.angle),s>=1&&!e.struck&&(e.struck=!0,ob(n,e.plan.angle,e.plan.speed),dn.click(Math.min(1,e.plan.speed/6)),e.rec=this.recorder(n),e.rolled=0,e.clicks=0,e.phase="roll",e.shooter.anim=null)}recorder(t){const e=t.recorder();return{hit:(n,s,a)=>{e.hit(n,s,a),this.s.clicks++<2&&dn.click(Math.min(1,a/4))},pocket:(n,s)=>{e.pocket(n,s),dn.pocket()},cushion:e.cushion}}settled(t){const e=this.s,n=e.game,s=e.shooter,a=e.waiter,r=n.settle();e.shots++;const o=r.potted.length>0;if(r.over)return this.over(t,r);r.assigned?s.say(`${r.assigned==="solids"?"Solids":"Stripes"} for me.`,"idle",2800):r.foul?(s.say(ii(mb),"warn",2400),Math.random()<.5&&setTimeout(()=>this.s&&a.say(ii(gb),"idle",2200),700)):o&&r.continues?Math.random()<.45&&s.say(ii(fb),"good",2200):Math.random()<.22&&s.say(ii(pb),"idle",2200),e.phase="pause",e.until=t+1.1+(r.foul?.6:0)}over(t,e){const n=this.s,s=n.game,a=this.agentOf(s.winner),r=n.players.find(l=>l!==a),o={eight:`Eight ball down. Good game, ${r.name}.`,"early-eight":`${r.name} dropped the eight early, so that one is mine. Good game.`,"foul-eight":`The eight went in with a foul, ${r.name}. Still a good game.`,"worn-out":`Called it after ${s.shots} shots, fewer balls left. Good game, ${r.name}.`}[s.over];a.say(ii(_b),"good",3600),r.say(ii(xb),"idle",3600),a.anim={kind:"celebrate",until:t+2.2},r.anim={kind:"slump",until:t+1.8},is(`/api/chill/${n.id}/line`,{from:a.id,text:o}).catch(()=>{}),n.phase="over",n.until=t+5}stop(t,e){var s;const n=this.s;if(n){this.release(n.id);for(const a of n.players)a.playing=!1,a.chatting=!1,a.anim=null,(s=a.spot)!=null&&s.game&&(a.spot.taken=null,a.spot=null),!a.gone&&!a.job&&!a.meeting&&a.want==="lounge"?a.wanderAt=t+ea(5,12):a.wanderAt=0;this.cueOuter.visible=!1,this.resting=ih(),this.view=this.resting;for(const a of this.meshes)a.userData.sunk=null;this.s=null,this.next=t+(e?ea(60,150):ea(30,60))}}release(t){is(`/api/chill/${t}`,void 0,"DELETE").catch(()=>{})}placeCue(t,e){const n=this.s.game.cue,s=Math.cos(e),a=Math.sin(e);this.cueOuter.position.set(n.x-s*(Re+t),je.felt+Re,n.z-a*(Re+t)),this.cueOuter.rotation.y=-e}draw(t,e){const n=je.felt;for(const s of this.view){const a=this.meshes[s.n],r=a.userData;if(s.in){r.sunk===null&&(r.sunk=t);const h=Math.min(1,(t-r.sunk)/.35),u=s.pocket;a.visible=h<1,a.position.set(s.x+(((u==null?void 0:u.x)??s.x)-s.x)*h,n+Re-h*.22,s.z+(((u==null?void 0:u.z)??s.z)-s.z)*h),a.scale.setScalar(1-h*.5);continue}r.sunk=null,a.visible=!0,a.scale.setScalar(1),a.position.set(s.x,n+Re,s.z);const o=s.x-r.x,l=s.z-r.z,c=Math.hypot(o,l);if(c>1e-5&&c<.5){const h=new C(l,0,-o).normalize();a.quaternion.premultiply(new hs().setFromAxisAngle(h,c/Re))}r.x=s.x,r.z=s.z}}}const Jl=10,qd=["#7c5cff","#0e9f9a","#d9488f","#c98a12","#3b82f6","#65a30d"],Mb=/^#[0-9a-f]{6}$/i,na=(i,t)=>String(i??"").replace(/\s+/g," ").trim().slice(0,t),Ql=(i,t)=>Mb.test(i)?i:t,bb=new Set(["working","idle","break","meeting","away"]);function Sb(i){return Array.isArray(i)?i.filter(t=>t&&typeof t.link=="string"&&t.link).map(t=>({link:na(t.link,80),handle:na(t.handle,40)||"friend",agents:(Array.isArray(t.agents)?t.agents:[]).filter(e=>e&&typeof e.id=="string"&&e.id).map(e=>{var n,s,a;return{id:na(e.id,40),name:na(e.name,40)||"Visitor",role:na(e.role,60),state:bb.has(e.state)?e.state:"idle",look:{shirt:Ql((n=e.look)==null?void 0:n.shirt,"#8a8f9c"),hair:Ql((s=e.look)==null?void 0:s.hair,"#3b2f2a"),skin:Ql((a=e.look)==null?void 0:a.skin,"#c68e63")},job:e.job&&typeof e.job=="object"?{title:na(e.job.title,120)}:null}})})):[]}class wb extends Kh{constructor(t,e,n,s,a,r){const o=Object.hasOwn(Wh,e.id)?e.id:"visitor";super({id:o,name:"",...e.look},s,a,{desk:{seat:s.door.clone(),seatY:0}}),this.key=`${t.link}:${e.id}`,this.id=this.key,this.root.traverse(u=>{u.userData.agentId=this.key,u.userData.visitor=this.key}),this.tint=n,this.chatAt=1/0,this.hangout=Math.random()<.5?"poolside":"coffee";const l=new te(n);this.fig.group.traverse(u=>{var d;!u.isMesh||!((d=u.material)!=null&&d.color)||(u.material=u.material.clone(),u.material.color.lerp(l,.16),u.material.emissive&&(u.material.emissive.copy(l),u.material.emissiveIntensity=.07))}),this.ring.material.color.set(n),this.ring.material.opacity=.6,this.ring.visible=!0,this.label.classList.add("visitor"),this.label.style.setProperty("--tint",n);const c=this.label.querySelector(".name");c.replaceChildren();const h=document.createElement("i");if(h.style.background=n,this.nameEl=document.createElement("span"),this.handleEl=document.createElement("span"),this.handleEl.className="handle",c.append(h,this.nameEl,this.handleEl),this.set(t,e),r){this.teleport(this.want);return}this.teleport("door"),this.say(`Hi from @${t.handle}`,"good",4e3)}set(t,e){this.office=t,this.info=e,this.name=e.name,this.nameEl.textContent!==e.name&&(this.nameEl.textContent=e.name,this.labelDirty=!0),this.handleEl.textContent!==` · @${t.handle}`&&(this.handleEl.textContent=` · @${t.handle}`,this.labelDirty=!0),this.leaving&&(this.leaving=!1,this.say("Forgot something","idle",2500)),this.want=this.place(e.state)}place(t){const e=t==="working"?["hotdesk","huddle",this.hangout]:t==="meeting"?["huddle","hotdesk"]:[this.hangout,this.hangout==="coffee"?"poolside":"coffee","huddle"];return e.find(n=>this.roomAt(n))||e[0]}roomAt(t){return this.world.stations[t].spots.some(e=>!e.game&&(!e.taken||e.taken===this.id))}resolve(t,e){if(t==="desk"){this.spot&&(this.spot.taken=null,this.spot=null);const n=this.world.door.clone().add(new C(1.4+Math.random()*1.8,0,-1.6+Math.random()*.8));return{key:t,pos:n,face:Math.atan2(-n.x,-n.z),pose:"stand"}}return super.resolve(t,e)}leave(){this.leaving||(super.leave(),this.say(`Back to @${this.office.handle}`,"idle",3e3))}dispose(){this.fig.group.traverse(t=>{t.isMesh&&t.material.dispose()}),super.dispose()}}class Eb{constructor({world:t,labels:e,camera:n,canvas:s}){Object.assign(this,{world:t,labels:e,camera:n,canvas:s}),this.on=new Map,this.offices=[],this.tints=new Map,this.list=[],this.first=!0,this.sign=document.createElement("div"),this.sign.className="door-sign",this.sign.hidden=!0,e.appendChild(this.sign),this.card=document.createElement("div"),this.card.className="visitor-card",this.card.hidden=!0,e.appendChild(this.card),this.ray=new yp,s.addEventListener("pointermove",a=>this.hover(a)),s.addEventListener("pointerleave",()=>{this.card.hidden=!0})}handle(t){if(t.t==="visitors")return this.receive(t.offices),!0;if(t.t==="hello"&&Array.isArray(t.visitors)&&this.receive(t.visitors,this.first),t.t==="hello"&&(this.first=!1),t.t==="links"&&Array.isArray(t.links)){const e=new Set(t.links.map(n=>n==null?void 0:n.id));this.receive(this.offices.filter(n=>e.has(n.link)))}return!1}tintOf(t){return this.tints.has(t)||this.tints.set(t,qd[this.tints.size%qd.length]),this.tints.get(t)}receive(t,e=!1){this.offices=Sb(t);const n=new Map,s=this.offices.map(o=>o.agents.filter(l=>l.state!=="away").map(l=>[`${o.link}:${l.id}`,o,l]));for(const o of s)for(const[l,c,h]of o)n.set(l,[c,h]);const a=new Set([...this.on.values()].filter(o=>!o.leaving&&n.has(o.key)).map(o=>o.key).slice(0,Jl));for(let o=0;a.size<Jl&&s.some(l=>l.length>o);o++)for(const l of s)l[o]&&a.size<Jl&&a.add(l[o][0]);for(const o of this.on.values())a.has(o.key)||o.leave();for(const o of a){const[l,c]=n.get(o),h=this.on.get(o);h?h.set(l,c):this.on.set(o,new wb(l,c,this.tintOf(l.link),this.world,this.labels,e))}const r=new Map;for(const[o,[l]]of n)a.has(o)||r.set(l.handle,(r.get(l.handle)||0)+1);this.sign.replaceChildren(...[...r].map(([o,l])=>{const c=document.createElement("div");return c.textContent=`+${l} from @${o}`,c})),this.sign.hidden=!r.size,this.list=[...this.on.values()]}update(t,e){for(const n of this.on.values())n.update(t,e),n.gone&&(n.dispose(),this.on.delete(n.key),this.list=[...this.on.values()])}placeSign(t,e){if(this.sign.hidden)return;const n=this.world.door.clone().setY(2.7).project(this.camera);if(n.z>1){this.sign.style.display="none";return}this.sign.style.display="",this.sign.style.transform=`translate(-50%, -100%) translate(${(n.x*.5+.5)*t}px, ${(-n.y*.5+.5)*e}px)`}hover(t){if(t.buttons||!this.list.length){this.card.hidden=!0;return}const e=this.canvas.getBoundingClientRect();this.ray.setFromCamera(new lt((t.clientX-e.left)/e.width*2-1,-((t.clientY-e.top)/e.height)*2+1),this.camera);const n=this.ray.intersectObjects(this.list.map(o=>o.root),!0)[0],s=n&&this.on.get(n.object.userData.visitor);if(!s){this.card.hidden=!0;return}(this.card.dataset.key!==s.key||this.card.dataset.stamp!==JSON.stringify(s.info))&&this.fillCard(s),this.card.hidden=!1;let a=t.clientX-e.left+14,r=t.clientY-e.top+14;a+this.card.offsetWidth>e.width-8&&(a-=this.card.offsetWidth+28),r+this.card.offsetHeight>e.height-8&&(r-=this.card.offsetHeight+28),this.card.style.transform=`translate(${a}px, ${r}px)`}fillCard(t){var r;const{info:e,office:n}=t;this.card.dataset.key=t.key,this.card.dataset.stamp=JSON.stringify(e),this.card.style.setProperty("--tint",t.tint);const s=(o,l)=>{const c=document.createElement("div");return c.className=o,c.textContent=l,c},a={working:"Working",idle:"Between jobs",break:"On a break",meeting:"In a meeting",away:"Heading home"}[e.state];this.card.replaceChildren(s("vc-who",`${e.name} · @${n.handle}`),s("vc-role",e.role||"Agent"),s("vc-job",((r=e.job)==null?void 0:r.title)||(e.state==="working"?"On a job":"No job right now")),s("vc-state",`${a} · visiting from @${n.handle}`))}}class Tb{constructor(t){this.scene=t,this.bits=[],this.geo=new vi(.14,.09)}burst(t,e){for(let n=0;n<70;n++){const s=new yt(this.geo,new cn({color:e[n%e.length],side:ci,transparent:!0}));s.position.set(t.x,2.4,t.z);const a=Math.random()*Math.PI*2,r=1.5+Math.random()*3;s.userData={v:new C(Math.cos(a)*r,4+Math.random()*4,Math.sin(a)*r),spin:new C(Math.random()*10,Math.random()*10,Math.random()*10),life:2.2+Math.random()*.8},this.scene.add(s),this.bits.push(s)}}update(t){for(let e=this.bits.length-1;e>=0;e--){const n=this.bits[e],s=n.userData;s.life-=t,s.v.y-=9*t,s.v.multiplyScalar(1-t*1.2),n.position.addScaledVector(s.v,t),n.position.y<.02?(n.position.y=.02,s.v.set(0,0,0),n.rotation.set(-Math.PI/2,0,n.rotation.z)):(n.rotation.x+=s.spin.x*t,n.rotation.y+=s.spin.y*t,n.rotation.z+=s.spin.z*t),n.material.opacity=Math.min(1,s.life/.6),s.life<=0&&(this.scene.remove(n),n.material.dispose(),this.bits.splice(e,1))}}}{const i=document.getElementById("app"),t=document.getElementById("side-grip"),e="office.sideWidth",n=320,s=24,a=()=>Math.max(n,Math.min(900,innerWidth-420)),r=u=>i.style.setProperty("--side-w",`${Math.round(Math.min(a(),Math.max(n,u)))}px`),o=Number(localStorage.getItem(e));o&&r(o);const l=()=>t.parentElement.getBoundingClientRect().width,c=()=>localStorage.setItem(e,String(Math.round(l())));t.addEventListener("pointerdown",u=>{t.setPointerCapture(u.pointerId),i.classList.add("resizing"),u.preventDefault()}),t.addEventListener("pointermove",u=>{t.hasPointerCapture(u.pointerId)&&r(u.clientX)});const h=u=>{t.hasPointerCapture(u.pointerId)&&(t.releasePointerCapture(u.pointerId),i.classList.remove("resizing"),c())};t.addEventListener("pointerup",h),t.addEventListener("pointercancel",h),t.addEventListener("dblclick",()=>{i.style.removeProperty("--side-w"),localStorage.removeItem(e)}),t.addEventListener("keydown",u=>{const d=u.key==="ArrowLeft"?-s:u.key==="ArrowRight"?s:0;d&&(u.preventDefault(),r(l()+d),c())})}{const i=document.getElementById("app"),t="office.sideZoom",e=.8,n=1.8,s=r=>(r=Math.round(Math.min(n,Math.max(e,r))*100)/100,i.style.setProperty("--side-zoom",String(r)),r===1?localStorage.removeItem(t):localStorage.setItem(t,String(r)),r);let a=Number(localStorage.getItem(t))||1;s(a),addEventListener("keydown",r=>{if(!(r.ctrlKey||r.metaKey)||r.altKey)return;const o=r.key;if(o==="+"||o==="=")a=s(a+.1);else if(o==="-"||o==="_")a=s(a-.1);else if(o==="0")a=s(1);else return;r.preventDefault()}),document.querySelector(".side").addEventListener("wheel",r=>{r.ctrlKey&&(r.preventDefault(),a=s(a-Math.sign(r.deltaY)*.05))},{passive:!1})}document.getElementById("view");const Io=document.getElementById("stage"),Jh=document.getElementById("labels"),We=new v1({antialias:!0,alpha:!0});We.setClearColor(0,0);We.setPixelRatio(Math.min(devicePixelRatio,2));We.shadowMap.enabled=!0;We.shadowMap.type=Df;We.toneMapping=bh;We.toneMappingExposure=1;Io.appendChild(We.domElement);const ni=new dp;ni.background=Ab();ni.environment=new Qc(We).fromScene(new gM,.04).texture;ni.environmentIntensity=.55;ni.add(new N1("#fff8ef","#b9ab99",.55));const zi=new z1("#fff0d8",1.75);zi.position.set(re.cx-18,34,20);zi.target.position.set(re.cx,0,0);zi.castShadow=!0;zi.shadow.mapSize.set(4096,4096);Object.assign(zi.shadow.camera,{left:-38,right:38,top:30,bottom:-30,near:1,far:110});zi.shadow.bias=-3e-4;zi.shadow.normalBias=.03;ni.add(zi,zi.target);const Ee=new Rn(30,1,.5,400),Ue={target:new C(re.cx,0,.5),radius:60,phi:.86,theta:Math.PI/4};Ee.position.setFromSpherical(new Aa(Ue.radius,Ue.phi,Ue.theta)).add(Ue.target);const Oe=new mM(Ee,We.domElement);Oe.target.copy(Ue.target);Object.assign(Oe,{enableDamping:!0,dampingFactor:.09,minPolarAngle:.25,maxPolarAngle:1.22,minDistance:12,maxDistance:260,zoomToCursor:!0,rotateSpeed:.55,zoomSpeed:.9,panSpeed:1.1});const Np=[];for(const i of[re.x0-.3,re.x1+.3])for(const t of[re.z0-.3,re.z1+.3])for(const e of[-.7,3])Np.push(new C(i,e,t));function Up(i,t,e){const n=Ee.aspect<.9?1.7:.93,s=Ee.clone();let a=15,r=260;for(let o=0;o<20;o++){const l=(a+r)/2;s.position.setFromSpherical(new Aa(l,i,t)).add(e),s.lookAt(e),s.updateMatrixWorld(),Np.every(h=>{const u=h.clone().project(s);return Math.abs(u.x)<n&&Math.abs(u.y)<.88})?r=l:a=l}return r}const Ca=new bM(We,new ei(1,1,{type:Fi,samples:4}));Ca.addPass(new SM(ni,Ee));const $o=new ri(ni,Ee,1,1);$o.updateGtaoMaterial({radius:.9,distanceExponent:1.6,thickness:1.5,scale:1.1,samples:16});$o.updatePdMaterial({lumaPhi:10,depthPhi:2,normalPhi:3,radius:6,rings:2,samples:16});$o.blendIntensity=.85;Ca.addPass($o);Ca.addPass(new RM);function Ab(){const i=document.createElement("canvas");i.width=512,i.height=512;const t=i.getContext("2d"),e=t.createRadialGradient(256,190,20,256,230,400);e.addColorStop(0,"#f7f3ec"),e.addColorStop(.6,"#ece5da"),e.addColorStop(1,"#d9d0c2"),t.fillStyle=e,t.fillRect(0,0,512,512);const n=new Hi(i);return n.colorSpace=Qe,n}let ca=1,ha=1,Wo=!1;function Op(){ca=Io.clientWidth,ha=Io.clientHeight,We.setSize(ca,ha,!1),Ca.setPixelRatio(Math.min(devicePixelRatio,1.5)),Ca.setSize(ca,ha),Ee.aspect=ca/ha,Ee.updateProjectionMatrix(),Wo||(Ue.radius=Up(Ue.phi,Ue.theta,Ue.target),Ee.position.setFromSpherical(new Aa(Ue.radius,Ue.phi,Ue.theta)).add(Ue.target),Oe.target.copy(Ue.target))}new ResizeObserver(Op).observe(Io);Op();const Mn=VM(ni),Fp=new Tb(ni),sh={id:"chief",name:"Chief",shirt:"#2b2d42",hair:"#8d8d8d",skin:"#a8714a"},et={staff:[],away:[],remote:[],chiefCost:0,modes:{},progress:null,jobs:new Map,agents:new Map,dismissed:new Set,selected:null,job:i=>et.jobs.get(i),staffName:i=>{const t=et.staff.find(e=>e.id===i);if(t)return t.name;for(const e of et.remote){const n=e.staff.find(s=>s.id===i);if(n)return`${n.name} @${e.host}`}return""},person:i=>{if(i==="you")return{name:"You",color:"#c9c1b4"};if(i==="chief")return{name:"Chief of Staff",color:sh.shirt,look:sh};const t=et.staff.find(e=>e.id===i);return{name:(t==null?void 0:t.name)||i,color:(t==null?void 0:t.shirt)||"#999",look:t}},onFloor:()=>{var i;return et.staff.slice(0,((i=et.progress)==null?void 0:i.capacity)||0).filter(t=>!et.dismissed.has(t.id))},roster:()=>{const i=a=>[...et.jobs.values()].find(r=>r.status==="working"&&r.agentId===a),t=et.onFloor().map(a=>({name:a.name,color:a.shirt,look:a,note:i(a.id)?`on ${i(a.id).repo}`:"free"})),e=a=>a.toLowerCase().replace(/[^a-z0-9]/g,""),n=et.remote.flatMap(a=>a.staff.filter(r=>r.here).map(r=>({s:r,o:a}))),s=a=>t.some(r=>e(r.name)===e(a))||n.filter(({s:r})=>e(r.name)===e(a)).length>1;return[...t,...n.map(({s:a,o:r})=>({name:a.name,color:a.shirt,look:a,host:r.host,insert:s(a.name)?`@${a.name}@${r.host}`:`@${a.name}`,note:`@${r.host} · ${i(a.id)?`on ${i(a.id).repo}`:"free"}`}))]},doer:i=>i.visitor?`${i.visitor.name} from ${i.from}`:et.staffName(i.agentId),busyIn:i=>{const t=[...et.jobs.values()].filter(e=>e.status==="working"&&e.repo===i).map(e=>et.doer(e));return t.length?`${t.join(", ")} here`:""}},Qh={scene:ni,...Mn,agentIndex:i=>et.staff.findIndex(t=>t.id===i)},kt=new J1(et);Sm({toast:(i,t)=>kt.toast(i,t),renderOwner:i=>{Gt.on||kt.renderOwner(i)}});const xn=new Kh(sh,Qh,Jh,{desk:Mn.reception,face:0}),Cb=new eb,Rb=new yb(ni,Mn),mo=new Eb({world:Qh,labels:Jh,camera:Ee,canvas:We.domElement});xn.want="desk";xn.teleport("desk");et.mergeLog=i=>{const t=et.jobs.get(i.id);t?t.log=i.log:et.jobs.set(i.id,i)};et.applyProfile=(i,t)=>{var n;const e=et.staff.find(s=>s.id===i);e&&(Object.assign(e,t),(n=et.agents.get(i))==null||n.rename(e.name),et.refreshLists(),kt.renderTeam())};Cm(()=>tM(et));et.refreshLists=()=>{const i=[...et.jobs.values()];kt.renderJobs(i,et.staffName),kt.renderStats(i,et.chiefCost),Dp(Mn.board,i)};et.openJob=i=>{kt.openDetail(i);const t=et.jobs.get(i),e=(t==null?void 0:t.status)==="working"&&et.agents.get(t.agentId);e&&(et.select(e.id,!1),Vp())};et.select=(i,t=!0)=>{for(const a of et.agents.values())a.setSelected(a.id===i);if(et.selected=i,i||(ks=!1),!i||!t)return;const e=et.agents.get(i);Vp(),kt.focusInput(`@${e.name} `);const n=[...et.jobs.values()].filter(a=>a.agentId===i),s=n.find(a=>a.status==="working")||n.sort((a,r)=>(r.endedAt||0)-(a.endedAt||0))[0];s&&kt.openDetail(s.id),(s==null?void 0:s.status)!=="working"&&kt.toast(`${e.name} is between jobs. Press N to give them one.`,"",{label:"Send home",run:()=>et.dismiss(e.id)})};et.dismiss=i=>!Gt.on&&kt.post(`/api/staff/${i}/dismiss`);et.recall=i=>!Gt.on&&kt.post(`/api/staff/${i}/recall`);function zp(i,t){et.onFloor().forEach(e=>{const n=et.agents.get(e.id);if(n){n.leaving&&n.stay();return}const s=new Kh(e,Qh,Jh);et.agents.set(e.id,s),i?s.teleport("lounge"):(s.teleport("door"),s.say(t||`Hi, I'm ${e.name}!`,"good",5e3))})}function jd(i,t){et.dismissed=new Set(i||[]);for(const e of et.agents.values())!et.dismissed.has(e.id)||e.leaving||e.job||(t?e.gone=!0:e.leave());zp(t,"Back in!"),kt.renderAway(et.staff.filter(e=>et.dismissed.has(e.id))),kt.renderTeam()}function Pb(i){var t,e;for(const n of et.agents.values()){const s=[...et.jobs.values()].find(a=>a.status==="working"&&a.agentId===n.id);s&&((t=n.job)==null?void 0:t.id)!==s.id?(n.assign(s,i),s.log.forEach(a=>n.onLog(a))):!s&&n.job&&n.finish(((e=et.jobs.get(n.job.id))==null?void 0:e.status)||"stopped")}}function Yd(i=[],t=!1){const e=Mn.standup;xn.meet(e[0],t),i.forEach((n,s)=>{var a;return(a=et.agents.get(n))==null?void 0:a.meet(e[1+Math.round(s*(e.length-2)/Math.max(1,i.length-1))],t)}),et.standupOn=!0,document.getElementById("standup").disabled=!0}function Kd(){xn.adjourn();for(const i of et.agents.values())i.adjourn();et.standupOn=!1,document.getElementById("standup").disabled=!1}let eo=!0;function ah(){const i=Gt.on?`/ws/visit/${encodeURIComponent(Gt.link)}`:"/ws",t=new WebSocket(`${location.protocol==="https:"?"wss":"ws"}://${location.host}${i}`);t.onmessage=e=>Lb(JSON.parse(e.data)),t.onclose=e=>{const n=ym(e.code);if(n!=null){n&&setTimeout(ah,n);return}kt.toast("Lost the office line. Reconnecting…","bad"),setTimeout(ah,1500)}}function Lb(i){var t,e,n,s,a,r,o,l;if(!mo.handle(i)){if(i.t==="hello"){vm(i.visiting),et.staff=i.staff,i.visiting||kt.renderOwner(i.owner),et.voice=i.voice,yn=i.tts||yn,Ma(),et.modes=xm(i.modes),et.progress=i.progress,et.chiefCost=i.chiefCost||0,et.jobs=new Map(i.jobs.map(h=>[h.id,h])),et.remote=i.remote||[],et.away=i.away||[],kt.renderChannels(i.channels||[{id:"general",name:"general"}]),kt.renderChat(i.chat||[]),kt.chiefBusy(i.chiefBusy),jd(i.dismissed,eo),Pb(eo),i.standup?Yd(i.standup.who,eo):et.standupOn&&Kd(),eo=!1,kt.renderLevel(et.progress),kt.renderUsage(i.usage),ic(i.auth),Jo(i.contextLimit),i.visiting||pu(i),vu(i.leaderboard),As(i.links),kt.renderProc(i.procs,i.machine),et.refreshLists();const c=Ob();nh(Mn.scribble,c),kt.openId&&(et.jobs.has(kt.openId)?kt.openDetail(kt.openId):kt.closeDetail())}else if(i.t==="job"){const c=et.jobs.get(i.job.id),h={...i.job,log:(c==null?void 0:c.log)||[]};if(et.jobs.set(h.id,h),h.status==="working"){const u=et.agents.get(h.agentId);u&&((t=u.job)==null?void 0:t.id)!==h.id?u.assign(h):u&&(u.job=h)}else for(const u of et.agents.values()){if(((e=u.job)==null?void 0:e.id)!==h.id)continue;const d=h.status==="done"&&!h.awaitingBoss;u.finish(d?"done":h.awaitingBoss?"waiting":h.status),d&&Fp.burst(u.pos,[u.staff.shirt,"#f2cc8f","#81b29a","#3d7ea6","#ffffff"]),d&&(dn.ship(),tc(`${u.name} shipped`,h.title)),h.status==="failed"&&(dn.fail(),tc(`${u.name} hit a wall`,h.title))}(c==null?void 0:c.status)!==h.status?(kt.openId===h.id&&kt.renderDetail(),h.awaitingBoss&&(c==null?void 0:c.status)==="working"?kt.toast(`${et.doer(h)} is waiting on you: “${h.title}”`,"warn"):h.status==="done"&&(c==null?void 0:c.status)==="working"&&kt.toast(`${et.doer(h)} shipped “${h.title}”`,"good"),h.status==="failed"&&(c==null?void 0:c.status)==="working"&&kt.toast(`${et.doer(h)} hit a wall on “${h.title}”`,"bad")):kt.openId===h.id&&((c==null?void 0:c.applied)!==h.applied||(c==null?void 0:c.discarded)!==h.discarded)?kt.renderDetail():kt.openId===h.id&&((n=c==null?void 0:c.changes)==null?void 0:n.end)!==((s=h.changes)==null?void 0:s.end)&&kt.renderChanges(h),et.refreshLists()}else if(i.t==="log"){const c=et.jobs.get(i.jobId);if(!c)return;c.log.push(i.entry),c.log.length>600&&c.log.shift();for(const h of et.agents.values())((a=h.job)==null?void 0:a.id)===c.id&&h.onLog(i.entry);i.entry.todos&&nh(Mn.scribble,i.entry.todos),kt.appendLog(c.id,i.entry)}else if(i.t==="remote")et.remote=i.offices||[],et.away=i.away||[],et.refreshLists();else if(i.t==="channels")kt.renderChannels(i.channels);else if(i.t==="chat"){kt.addMessage(i.msg);const c=et.agents.get(i.msg.from),h=et.agents.get(i.msg.to);if(c&&h&&(c.visit(h,i.msg.text),dn.knock()),Ub(i.msg),i.msg.kind==="flag"&&(dn.knock(),tc("The boss is needed",i.msg.text.replace(/\*\*/g,""))),i.msg.kind==="standup"){const u=i.msg.say||i.msg.text;(r=i.msg.from==="chief"?xn:c)==null||r.speak(u.length>90?u.slice(0,89)+"…":u)}else i.msg.from==="chief"&&(xn.job=null,xn.say(i.msg.text.length>90?i.msg.text.slice(0,89)+"…":i.msg.text,"",6e3))}else if(i.t==="forget")kt.forget(i.ids);else if(i.t==="voice"){const c=kt.addVoice(i.id,i.file);c&&yn.replies&&!si.active&&!document.hidden&&c.play().catch(()=>{})}else if(i.t==="tts")yn={...yn,...i},Ma();else if(i.t==="react")kt.setReactions(i.id,i.reactions);else if(i.t==="standup")i.phase==="start"?(Yd(i.who),kt.banner("Standup","Everyone to the whiteboard."),dn.knock()):Kd();else if(i.t==="chief")kt.chiefBusy(i.busy),i.busy?(xn.job={id:"routing"},xn.say("Reading your message…","thinking")):xn.job=null,i.cost!==void 0&&(et.chiefCost=i.cost,et.refreshLists());else if(i.t==="staff")jd(i.dismissed,!1);else if(i.t==="profile")et.applyProfile(i.id,i.profile);else if(i.t==="auth")ic(i.auth);else if(i.t==="contextLimit")Jo(i.contextLimit);else if(i.t==="settings")Jo(i.contextLimit),pu(i);else if(i.t==="leaderboard")vu(i.leaderboard);else if(i.t==="links")As(i);else if(i.t==="usage")kt.renderUsage(i.usage);else if(i.t==="proc")kt.renderProc(i.procs,i.machine);else if(i.t==="xp"){et.progress=i.progress,kt.renderLevel(et.progress);const c=et.agents.get(i.agentId);if(c){const h=document.createElement("span");h.className="xpfloat",h.textContent=`+${i.gained} XP`,c.label.appendChild(h),setTimeout(()=>h.remove(),1800)}if(i.levelUp){setTimeout(()=>dn.levelUp(),700);const h=(o=et.staff[et.progress.capacity-1])==null?void 0:o.name,u=!et.agents.has((l=et.staff[et.progress.capacity-1])==null?void 0:l.id);kt.banner(`Level ${et.progress.level}`,u?`${h} just joined the office.`:"The office is fully staffed."),zp(!1)}}}}let rh=0;function tc(i,t){if(document.hidden){rh++,document.title=`(${rh}) Agent Office`;try{"Notification"in window&&Notification.permission==="granted"&&new Notification(i,{body:t,silent:!0})}catch{}}}document.addEventListener("visibilitychange",()=>{document.hidden||(rh=0,document.title="Agent Office")});document.getElementById("composer").addEventListener("submit",()=>{try{"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()}catch{}},{once:!0});const Db='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M11 5 6 9H3v6h3l5 4V5Z"/><path d="M15.5 8.5a5 5 0 0 1 0 7"/><path d="M18.5 5.5a9 9 0 0 1 0 13"/></svg>',Ib='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M11 5 6 9H3v6h3l5 4V5Z"/><path d="m22 9-6 6"/><path d="m16 9 6 6"/></svg>',go=document.getElementById("sound");function Bp(){go.innerHTML=dn.muted?Ib:Db;const i=dn.muted?"Sound off":"Sound on";go.title=i,go.setAttribute("aria-label",i)}go.onclick=()=>{dn.setMuted(!dn.muted),Bp(),dn.muted||dn.ship()};Bp();const kb='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3a3 3 0 0 1 3 3v5a3 3 0 0 1-6 0V6a3 3 0 0 1 3-3z"/><path d="M5 11a7 7 0 0 0 14 0"/><path d="M12 18v3"/></svg>',Nb='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M9 9V6a3 3 0 0 1 5.6-1.5M15 11a3 3 0 0 1-4.5 2.6"/><path d="M5 11a7 7 0 0 0 11 5.7M19 11v0"/><path d="M12 18v3"/><path d="m3 3 18 18"/></svg>',ua=document.getElementById("speak");let yn={ok:!1,replies:!1};const Hp=()=>yn.ok?yn.replies:hi.on;function Ma(){const i=Hp();ua.innerHTML=i?kb:Nb,ua.classList.toggle("on",i);const t=i?yn.ok?"Agents reply with voice notes":"Replies read aloud":"Replies are silent";ua.title=t,ua.setAttribute("aria-label",t)}hi.supported||(ua.hidden=!0);ua.onclick=async()=>{const i=!Hp();if(!yn.ok){hi.setOn(i),Ma(),i&&hi.speak("Voice on. I will read replies out as they land.","chief",{force:!0});return}yn={...yn,replies:i},Ma();try{const t=await fetch("/api/voice/replies",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({on:i})});if(!t.ok)throw new Error((await t.json().catch(()=>({}))).error||`Request failed (${t.status})`)}catch(t){yn={...yn,replies:!i},Ma(),kt.toast(t.message,"bad")}};Ma();function Ub(i){yn.ok||!hi.on||i.from==="you"||i.to||i.kind==="chill"||si.active||hi.speak(i.text,i.from)}function Ob(){let i=null;for(const t of et.jobs.values())for(const e of t.log)e.todos&&(!i||e.ts>i.ts)&&(i=e);return(i==null?void 0:i.todos)||[]}const _n=new Aa,Fb=i=>i<.5?4*i*i*i:1-(-2*i+2)**3/2;let Se=null,ks=!1;function Vp(){ks=!0,Se=null,Wo=!0}function tu({target:i,radius:t,phi:e,theta:n},s=.7){_n.setFromVector3(Ee.position.clone().sub(Oe.target)),Se={t:0,dur:s,target0:Oe.target.clone(),target1:(i||Oe.target).clone().setY(0),r0:_n.radius,r1:t??_n.radius,p0:_n.phi,p1:e??_n.phi,th0:_n.theta,th1:n??_n.theta}}function ko(i){Wo=!0,_n.setFromVector3(Ee.position.clone().sub(Oe.target));const t=Se?Se.th1:_n.theta;tu({theta:t+i*Math.PI/4,target:Se==null?void 0:Se.target1},.55)}function Gp(){ks=!1,_n.setFromVector3(Ee.position.clone().sub(Oe.target));let i=Ue.theta;for(;i-_n.theta>Math.PI;)i-=Math.PI*2;for(;_n.theta-i>Math.PI;)i+=Math.PI*2;tu({target:Ue.target,radius:Up(Ue.phi,i,Ue.target),phi:Ue.phi,theta:i},.9)}Oe.addEventListener("start",()=>{Wo=!0,Se=null,ks=!1,setTimeout(()=>{var i;return(i=document.querySelector(".hint"))==null?void 0:i.classList.add("gone")},5e3)});document.getElementById("turnLeft").onclick=()=>ko(-1);document.getElementById("turnRight").onclick=()=>ko(1);document.getElementById("recenter").onclick=()=>Gp();document.getElementById("standup").onclick=()=>kt.post("/api/standup");const ss=new Set;addEventListener("keydown",i=>{var e;if(/INPUT|TEXTAREA|SELECT/.test((e=document.activeElement)==null?void 0:e.tagName)||i.metaKey||i.ctrlKey)return;const t=i.key.toLowerCase();t==="q"?ko(-1):t==="e"?ko(1):t==="r"?Gp():"wasd".includes(t)&&t.length===1&&(ss.add(t),Se=null,ks=!1)});addEventListener("keyup",i=>ss.delete(i.key.toLowerCase()));addEventListener("blur",()=>ss.clear());const no=new C,ec=new C,qn=new C;function zb(i){if(Se){Se.t=Math.min(1,Se.t+i/Se.dur);const n=Fb(Se.t),s=Se.target0.clone().lerp(Se.target1,n);_n.set(aa.lerp(Se.r0,Se.r1,n),aa.lerp(Se.p0,Se.p1,n),aa.lerp(Se.th0,Se.th1,n)),Oe.target.copy(s),Ee.position.setFromSpherical(_n).add(s),Se.t>=1&&(Se=null)}qn.set(0,0,0);const t=ks&&et.agents.get(et.selected);if(t&&qn.set(t.pos.x-Oe.target.x,0,t.pos.z-Oe.target.z).multiplyScalar(Math.min(1,i*3)),ss.size){no.subVectors(Oe.target,Ee.position).setY(0).normalize(),ec.crossVectors(no,Ee.up).normalize();const n=.45*Ee.position.distanceTo(Oe.target)*i;ss.has("w")&&qn.addScaledVector(no,n),ss.has("s")&&qn.addScaledVector(no,-n),ss.has("d")&&qn.addScaledVector(ec,n),ss.has("a")&&qn.addScaledVector(ec,-n)}Oe.target.add(qn),Ee.position.add(qn),Oe.update();const e=Oe.target;qn.set(aa.clamp(e.x,re.x0+1,re.x1-1)-e.x,-e.y,aa.clamp(e.z,re.z0+1,re.z1-1)-e.z),e.add(qn),Ee.position.add(qn)}const Xo=new yp,Zd=new lt;function eu(i){const t=We.domElement.getBoundingClientRect();Zd.set((i.clientX-t.left)/t.width*2-1,-((i.clientY-t.top)/t.height)*2+1),Xo.setFromCamera(Zd,Ee)}const $p=()=>[...et.agents.values(),xn].map(i=>i.root);let vo=null;We.domElement.addEventListener("pointerdown",i=>{vo=[i.clientX,i.clientY]});We.domElement.addEventListener("pointerup",i=>{if(!vo||Math.hypot(i.clientX-vo[0],i.clientY-vo[1])>5||i.button!==0)return;eu(i);const t=Xo.intersectObjects($p(),!0)[0];t&&(t.object.userData.agentId==="chief"?(kt.focusInput(),xn.say("Tell me what you need.","",3e3)):et.select(t.object.userData.agentId))});We.domElement.addEventListener("dblclick",i=>{eu(i);const t=Xo.intersectObject(Mn.slab,!1)[0];t&&(ks=!1,tu({target:t.point,radius:Math.min(Ee.position.distanceTo(Oe.target),34)},.8))});We.domElement.addEventListener("contextmenu",i=>i.preventDefault());We.domElement.addEventListener("pointermove",i=>{i.buttons||(eu(i),We.domElement.style.cursor=Xo.intersectObjects($p(),!0).length?"pointer":"")});const Jd=new xp;let Qd=0,tf=0;function Bb(i){Mn.desks.forEach((t,e)=>{const n=et.staff[e],s=n&&et.agents.get(n.id),a=!s&&n&&et.dismissed.has(n.id),r=s!=null&&s.job?"working":s?"break":a?"away":"open",o=r!=="open",l=`${(n==null?void 0:n.name)||""} ${r}`;if(t.plateKey!==l&&(t.plateKey=l,Pp(t,{name:o?n.name:"Open desk",accent:o?n.shirt:"#7d8a9c",state:r})),s!=null&&s.job){Bd(t,{title:s.job.repo,subtitle:s.job.title,lines:s.lines,accent:n.shirt,t:i}),t.idleKey=null;return}const c=s?`${n.name}`:a?`away ${n.name}`:"open";if(t.idleKey===c)return;t.idleKey=c;const h=et.progress?e-1:0;Bd(t,s?{idle:!0,title:n.name,subtitle:"on a break"}:a?{idle:!0,title:n.name,subtitle:"gone home"}:{idle:!0,title:"Open desk",subtitle:`hires at level ${h}`})})}let ef=!1;function Wp(){const i=Math.min(Jd.getDelta(),.05),t=Jd.elapsedTime;zb(i),Mn.updateWalls(Ee,Oe.target,i);for(const s of et.agents.values())s.update(i,t),s.gone&&(s.dispose(),et.agents.delete(s.id),et.selected===s.id&&et.select(null));if(Cb.update([...et.agents.values()],t),Rb.update([...et.agents.values()],t,i),xn.update(i,t),mo.update(i,t),Fp.update(i),Mn.globe.rotation.y+=i*.4,(Qd-=i)<=0&&(Qd=.4,Bb(t)),(tf-=i)<=0){tf=.15;for(const s of Mn.blinkers)Math.random()<.25&&(s.material.emissiveIntensity=Math.random()<.5?.15:1.4)}Ca.render(i);const e=Ee.position.distanceTo(Oe.target)>Ue.radius*1.25,n=[];for(const s of[...et.agents.values(),xn,...mo.list])e!==ef&&(s.label.classList.toggle("far",e),s.labelDirty=!0),s.placeLabel(Ee,ca,ha),s.onScreen&&n.push(s);Vb(n,i,t),mo.placeSign(ca,ha),ef=e,requestAnimationFrame(Wp)}const Hb=4,nf=(i,t)=>i.left<t.right-1&&i.right>t.left+1&&i.top<t.bottom-1&&i.bottom>t.top+1;function Vb(i,t,e){const n=[],s=a=>a.id===et.selected?-1:a.depth;for(const a of[...i].sort((r,o)=>s(r)-s(o))){let r=0,o=!1;for(let h=0;h<2;h++){const u=Math.max(0,Math.min(o?140:80,a.anchorY-a.labelH-6));r=0;for(let d=0;d<10&&r<=u;d++){const f=a.labelBox(r),g=n.find(_=>nf(_,f));if(!g)break;r+=f.bottom-g.top+Hb}if(r<=u||o){r=Math.min(r,u);break}o=!0,a.setCrowded(!0,e)}o||a.setCrowded(!1,e),a.setLift(r,t);const l=a.labelBox(a.lift),c=n.some(h=>nf(h,l));a.setBuried(c),c||n.push(l)}}Dp(Mn.board,[]);nh(Mn.scribble,[]);ah();Wp();
4474
+ }`};class RM extends La{constructor(){super();const t=CM;this.uniforms=es.clone(t.uniforms),this.material=new I1({name:t.name,uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader}),this.fsQuad=new jh(this.material),this._outputColorSpace=null,this._toneMapping=null}render(t,e,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=t.toneMappingExposure,(this._outputColorSpace!==t.outputColorSpace||this._toneMapping!==t.toneMapping)&&(this._outputColorSpace=t.outputColorSpace,this._toneMapping=t.toneMapping,this.material.defines={},le.getTransfer(this._outputColorSpace)===ye&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===kf?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===Nf?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===Uf?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===Of?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===Ff?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===bh&&(this.material.defines.NEUTRAL_TONE_MAPPING=""),this.material.needsUpdate=!0),this.renderToScreen===!0?(t.setRenderTarget(null),this.fsQuad.render(t)):(t.setRenderTarget(e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),this.fsQuad.render(t))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class PM{constructor(t,e,n=-t/2,s=-e/2){this.w=t,this.d=e,this.ox=n,this.oz=s,this.cells=new Uint8Array(t*e)}inside(t,e){return t>=0&&e>=0&&t<this.w&&e<this.d}blocked(t,e){return!this.inside(t,e)||this.cells[e*this.w+t]===1}cellOf(t,e){return[Math.floor(t-this.ox),Math.floor(e-this.oz)]}center(t,e){return[this.ox+t+.5,this.oz+e+.5]}block(t,e,n,s){const[a,r]=this.cellOf(t,n),[o,l]=this.cellOf(e-1e-6,s-1e-6);for(let c=r;c<=l;c++)for(let h=a;h<=o;h++)this.inside(h,c)&&(this.cells[c*this.w+h]=1)}nearestFree(t,e){if(!this.blocked(t,e))return[t,e];const n=new Set([e*this.w+t]),s=[[t,e]];for(;s.length;){const[a,r]=s.shift();for(const[o,l]of[[1,0],[-1,0],[0,1],[0,-1]]){const c=a+o,h=r+l;if(!(!this.inside(c,h)||n.has(h*this.w+c))){if(!this.blocked(c,h))return[c,h];n.add(h*this.w+c),s.push([c,h])}}}return[t,e]}clear(t,e,n,s){const a=Math.hypot(n-t,s-e),r=Math.ceil(a/.2);for(let o=1;o<r;o++){const l=o/r,[c,h]=this.cellOf(t+(n-t)*l,e+(s-e)*l);if(this.blocked(c,h))return!1}return!0}path(t,e,n,s){const a=this.nearestFree(...this.cellOf(t,e)),r=this.nearestFree(...this.cellOf(n,s)),o=(y,x)=>x*this.w+y,l=(y,x)=>Math.hypot(y-r[0],x-r[1]),c=new Map([[o(...a),0]]),h=new Map,u=[[l(...a),...a]],d=new Set;let f=!1;for(;u.length;){let y=0;for(let T=1;T<u.length;T++)u[T][0]<u[y][0]&&(y=T);const[,x,S]=u.splice(y,1)[0],P=o(x,S);if(!d.has(P)){if(d.add(P),x===r[0]&&S===r[1]){f=!0;break}for(let T=-1;T<=1;T++)for(let w=-1;w<=1;w++){if(!T&&!w)continue;const R=x+T,k=S+w;if(this.blocked(R,k)||T&&w&&(this.blocked(x+T,S)||this.blocked(x,S+w)))continue;const v=o(R,k),b=c.get(P)+(T&&w?Math.SQRT2:1);b<(c.get(v)??1/0)&&(c.set(v,b),h.set(v,P),u.push([b+l(R,k),R,k]))}}}const g=[];if(f){let y=o(...r);for(;y!==void 0;)g.unshift(this.center(y%this.w,Math.floor(y/this.w))),y=h.get(y)}g.push([n,s]);const _=[];let p=[t,e],m=0;for(;m<g.length;){let y=m;for(let x=g.length-1;x>m;x--)if(this.clear(p[0],p[1],g[x][0],g[x][1])){y=x;break}_.push(g[y]),p=g[y],m=y+1}return _}}const Ki=52,ns=30,re={x0:-20,x1:32,z0:-ns/2,z1:ns/2,cx:6},Js=20.4,Ud=27,qe={x:7.6,z:10.9,felt:.84},ct={wall:"#f5f0e8",trim:"#d9cdbb",wood:"#c39a6b",woodDark:"#8c6440",metal:"#3b404c",rack:"#262a33",pot:"#e4d6c1",couch:"#5b7fa6",rug:"#c99b84",glass:"#cfe6f2",board:"#fbfaf7",chair:"#30343d"},jl=new Map;function xe(i,t={}){const e=i+JSON.stringify(t);return jl.has(e)||jl.set(e,new Dn({color:i,roughness:.82,...t})),jl.get(e)}function K(i,t,e,n,s,a,r,o,l){const c=new yt(new Ye(t,e,n),l instanceof Bi?l:xe(s,l));return c.position.set(a,r,o),c.castShadow=!0,c.receiveShadow=!0,i.add(c),c}function Ni(i,t,e,n,s){const a=document.createElement("canvas");a.width=n,a.height=s;const r=new Hi(a);r.colorSpace=Qe,r.anisotropy=4;const o=new yt(new vi(t,e),new ln({map:r,toneMapped:!1}));return i.add(o),{canvas:a,ctx:a.getContext("2d"),tex:r,mesh:o}}const Bn='"Inter Variable", Inter, system-ui, sans-serif',LM='"JetBrains Mono", ui-monospace, monospace';function zt(i,t,e,n,s,a,r,o,l=16,c){const h=new yt(new Hn(t,e,n,l),c instanceof Bi?c:xe(s,c));return h.position.set(a,r,o),h.castShadow=!0,h.receiveShadow=!0,i.add(h),h}const Od=["#5f9e6e","#477d55","#6fae74","#3f7350","#7dbb7a"];function Ep(i,t,e,n,s=1,a="bush"){const r=new Ht;r.position.set(e,0,n),r.rotation.y=e*1.7+n,r.scale.setScalar(s),zt(r,.35,.27,.6,ct.pot,0,.3,0,18),zt(r,.37,.37,.06,"#d8c8b0",0,.6,0,18),zt(r,.31,.31,.02,"#5a4130",0,.62,0,18);const o=(l,c,h,u,d)=>{const f=new yt(new Ta(l,0),xe(Od[d%Od.length],{flatShading:!0}));f.position.set(c,h,u),f.rotation.set(c*3,u*5,h),f.castShadow=!0,r.add(f)};if(a==="tall")zt(r,.035,.05,1.5,ct.woodDark,0,1.35,0,6),o(.42,.12,1.55,.05,1),o(.48,-.15,1.95,-.08,0),o(.38,.18,2.3,.1,2),o(.3,-.05,2.6,0,4);else if(a==="snake")for(let l=0;l<7;l++){const c=l/7*Math.PI*2,h=.8+l*37%5*.12,u=new yt(new pr(.07,h,4),xe(l%2?"#4e8a5c":"#6f9f5a",{flatShading:!0}));u.position.set(Math.cos(c)*.12,.62+h/2,Math.sin(c)*.12),u.rotation.set(Math.sin(c)*.18,c,-Math.cos(c)*.18),u.scale.z=.35,u.castShadow=!0,r.add(u)}else o(.55,0,1,0,0),o(.4,.3,1.25,.1,1),o(.38,-.28,1.2,-.12,2),o(.36,.05,1.5,-.2,3);return i.add(r),t.block(e-.45*s,e+.45*s,n-.45*s,n+.45*s),r}function Yh(i,t,e,n){zt(i,.09,.07,.12,"#e8dccb",t,e+.06,n,12);const s=new yt(new Ta(.1,0),xe("#7aa874",{flatShading:!0}));s.position.set(t,e+.17,n),s.scale.y=.7,s.castShadow=!0,i.add(s)}function Lo(i,t,e,n,s=3){const a=["#e07a5f","#3d7ea6","#f2cc8f","#81b29a","#9c6ade"];for(let r=0;r<s;r++){const o=K(i,.34-r*.03,.05,.25,a[(r+Math.round(t*7))%a.length],t,e+.025+r*.05,n);o.rotation.y=(r-1)*.15}}function DM(i,t,e,n){const s=xe("#2f3440",{roughness:.5});zt(i,.11,.12,.03,null,t,e+.015,n,16,s);const a=K(i,.03,.42,.03,null,t,e+.22,n,s);a.rotation.x=-.25;const r=K(i,.03,.03,.3,null,t,e+.42,n+.13,s);r.rotation.x=.35;const o=zt(i,.05,.12,.14,null,t,e+.36,n+.27,16,xe("#e9b949",{roughness:.45}));o.rotation.x=.4;const l=new yt(new gi(.1,16),new ln({color:"#fff3c9"}));l.position.set(t,e+.3,n+.3),l.rotation.x=-Math.PI/2+.4,i.add(l)}function Va(i,t,e,n,s,a,r="#3b3330"){const o=[K(i.g,n+.14,s+.14,.05,r,t,e,.18)],l=Ni(i.g,n,s,Math.round(256*n),Math.round(256*s));l.mesh.position.set(t,e,.21),l.mesh.material=new Dn({map:l.tex,roughness:.9}),a(l.ctx,l.canvas.width,l.canvas.height),l.tex.needsUpdate=!0,o.push(l.mesh),i.attach.push(...o)}const Ga={sunset(i,t,e){i.fillStyle="#f4e3c8",i.fillRect(0,0,t,e),i.fillStyle="#e9967a",i.beginPath(),i.arc(t*.62,e*.45,t*.2,0,Math.PI*2),i.fill(),i.fillStyle="#8fb0a0",i.beginPath(),i.moveTo(0,e),i.lineTo(0,e*.62),i.quadraticCurveTo(t*.35,e*.4,t*.7,e*.66),i.lineTo(t,e*.58),i.lineTo(t,e),i.fill(),i.fillStyle="#4f7c74",i.beginPath(),i.moveTo(0,e),i.lineTo(0,e*.8),i.quadraticCurveTo(t*.5,e*.6,t,e*.82),i.lineTo(t,e),i.fill()},blocks(i,t,e){i.fillStyle="#f7f1e6",i.fillRect(0,0,t,e);const n=["#e07a5f","#3d405b","#81b29a","#f2cc8f"];i.fillStyle=n[0],i.fillRect(t*.12,e*.12,t*.42,e*.4),i.fillStyle=n[1],i.fillRect(t*.54,e*.12,t*.34,e*.22),i.fillStyle=n[2],i.fillRect(t*.54,e*.34,t*.34,e*.54),i.fillStyle=n[3],i.fillRect(t*.12,e*.52,t*.42,e*.36),i.fillStyle="#3d405b",i.beginPath(),i.arc(t*.33,e*.7,t*.1,0,Math.PI*2),i.fill()},arcs(i,t,e){i.fillStyle="#efe6d8",i.fillRect(0,0,t,e),["#c8553d","#f28f3b","#ffd5c2","#588b8b"].forEach((s,a)=>{i.strokeStyle=s,i.lineWidth=t*.07,i.beginPath(),i.arc(t/2,e*.85,t*(.38-a*.09),Math.PI,0),i.stroke()})},leaf(i,t,e){i.fillStyle="#e7ece4",i.fillRect(0,0,t,e),i.fillStyle="#5f8f6b",i.beginPath(),i.ellipse(t/2,e/2,t*.18,e*.36,.35,0,Math.PI*2),i.fill(),i.strokeStyle="#e7ece4",i.lineWidth=t*.015,i.beginPath(),i.moveTo(t*.38,e*.82),i.lineTo(t*.62,e*.18),i.stroke()}};function IM(i,t,e){const n=Ni(i.g,.9,.9,256,256);n.mesh.geometry=new gi(.45,40),n.mesh.position.set(t,e,.22);const s=zt(i.g,.5,.5,.08,"#3b3330",t,e,.17,40);s.rotation.x=Math.PI/2,i.attach.push(s,n.mesh);const a=()=>{const{ctx:r,tex:o}=n;r.fillStyle="#fbf8f2",r.fillRect(0,0,256,256),r.translate(128,128),r.fillStyle="#3b3330";for(let d=0;d<12;d++)r.save(),r.rotate(d/12*Math.PI*2),r.fillRect(-3,-112,6,d%3?12:22),r.restore();const l=new Date,c=l.getMinutes(),h=l.getHours()%12+c/60,u=(d,f,g,_)=>{r.save(),r.rotate(d),r.fillStyle=_,r.fillRect(-g/2,-f,g,f+14),r.restore()};u(h/12*Math.PI*2,62,9,"#3b3330"),u(c/60*Math.PI*2,92,6,"#3b3330"),r.fillStyle="#e07a5f",r.beginPath(),r.arc(0,0,8,0,Math.PI*2),r.fill(),r.setTransform(1,0,0,1,0,0),o.needsUpdate=!0};a(),setInterval(a,3e4)}function kM(){const i=document.createElement("canvas");i.width=i.height=512;const t=i.getContext("2d"),e=8,n=512/e;for(let a=0;a<e;a++)for(let r=0;r<e;r++){t.fillStyle=`hsl(${170+Math.random()*8}, ${9+Math.random()*4}%, ${82+Math.random()*2.5}%)`,t.fillRect(a*n,r*n,n,n),t.globalAlpha=.05;for(let o=0;o<40;o++)t.fillStyle=Math.random()<.5?"#000":"#fff",t.fillRect(a*n+Math.random()*n,r*n+Math.random()*n,2,2);t.globalAlpha=1,t.fillStyle="rgba(60, 80, 80, 0.09)",t.fillRect(a*n,r*n,n,1.5),t.fillRect(a*n,r*n,1.5,n)}const s=new Hi(i);return s.colorSpace=Qe,s.wrapS=s.wrapT=Oi,s.repeat.set(24.5/8,12.6/8),s.anisotropy=8,s}let jr;function NM(i,t,e,n,s){if(!jr){const r=document.createElement("canvas");r.width=256,r.height=64;const o=r.getContext("2d"),l=o.createLinearGradient(0,0,256,0);l.addColorStop(0,"rgba(255, 236, 200, 0.55)"),l.addColorStop(1,"rgba(255, 236, 200, 0)"),o.fillStyle=l,o.fillRect(0,0,256,64),jr=new Hi(r),jr.colorSpace=Qe}const a=new yt(new vi(n,s),new ln({map:jr,transparent:!0,depthWrite:!1,blending:dc,opacity:.5}));a.rotation.x=-Math.PI/2,a.position.set(t,.025,e),i.add(a)}let Yl;function UM(){if(!Yl){const i=Pp();i.repeat.set(.5,.22),Yl=new Dn({map:i,color:"#f0d6b4",roughness:.52})}return Yl}let Qs;function OM(){if(Qs)return Qs;const i=document.createElement("canvas");i.width=384,i.height=128;const t=i.getContext("2d"),e=15,n=5,s=i.width/e,a=i.height/n,r=3;t.fillStyle="#cfcac1",t.fillRect(0,0,i.width,i.height);const o=(c,h,u,d)=>{t.fillStyle="#f7f5f1",t.fillRect(c,h,u,d),t.fillStyle="rgba(88, 84, 78, 0.22)",t.fillRect(c,h+d-2,u,2)};for(let c=0;c<n-1;c++)for(let h=0;h<e;h++)o(h*s+r,c*a+r,s-r*2,a-r*2);const l=(n-1)*a;for(const c of[0,1,2,11,12,13,14])o(c*s+r,l+r,s-r*2,a-r*2);return o(3*s+r,l+r,s*8-r*2,a-r*2),Qs=new Hi(i),Qs.colorSpace=Qe,Qs.anisotropy=4,Qs}function Fd(i,t,e,n,s,a,r=500){const o=new Ht;o.position.set(n,s,a),i.add(o);const l=new yt(new Ye(t+.08,e+.12,.05),["#272d38","#272d38","#272d38","#272d38","#1e232c","#3c4352"].map(h=>xe(h)));l.position.set(0,-.015,-.03),l.castShadow=!0,l.receiveShadow=!0,o.add(l),K(o,(t+.08)*.55,.035,.012,"#323a47",0,-e*.34,-.056).castShadow=!1;const c=Ni(o,t,e,Math.round(t*r),Math.round(e*r));return c.mesh.position.set(0,.015,.002),{g:o,face:c}}function FM(i,t,e,n){const s=xe("#23272f",{roughness:.6});zt(i,.11,.13,.025,"#2f3440",t,e+.012,n,14),zt(i,.022,.022,.3,"#2f3440",t,e+.16,n,10);const a=new yt(new li(.11,.022,6,16,Math.PI),s);a.position.set(t,e+.3,n),a.castShadow=!0,i.add(a);for(const r of[-.11,.11]){const o=zt(i,.065,.065,.05,null,t+r,e+.28,n,14,s);o.rotation.z=Math.PI/2,o.castShadow=!0}}function zM(i,t,e,n){const s=xe("#f4c430",{roughness:.45}),a=new yt(new di(.075,12,10),s);a.position.set(t,e+.06,n),a.scale.set(1,.85,1.25),a.castShadow=!0,i.add(a);const r=new yt(new di(.05,12,10),s);r.position.set(t,e+.15,n-.05),r.castShadow=!0,i.add(r);const o=new yt(new pr(.022,.06,8),xe("#e8833a",{roughness:.5}));o.position.set(t,e+.14,n-.11),o.rotation.x=-Math.PI/2,i.add(o);for(const l of[-.02,.02]){const c=new yt(new di(.008,6,6),xe("#1a1a1a"));c.position.set(t+l,e+.17,n-.085),i.add(c)}}function BM(i,t,e,n,s){const a=new Ht;a.position.set(t,e,n),a.rotation.y=-.4+s%2*.8,i.add(a),K(a,.26,.21,.02,"#3b3330",0,.12,0);const r=Ni(a,.21,.16,84,64);r.mesh.position.set(0,.125,.012);const{ctx:o,canvas:l}=r;o.fillStyle="#cfe3ef",o.fillRect(0,0,l.width,l.height),o.fillStyle="#8fb0a0",o.beginPath(),o.moveTo(0,l.height),o.quadraticCurveTo(l.width*.5,l.height*.35,l.width,l.height),o.fill(),o.fillStyle="#f2cc8f",o.beginPath(),o.arc(l.width*.72,l.height*.3,7,0,Math.PI*2),o.fill(),r.tex.needsUpdate=!0;const c=K(a,.02,.1,.02,"#3b3330",0,.05,-.04);c.rotation.x=.35}function Tp(i,t,e,n){const s=K(i,.3,.035,.38,"#44506b",t,e+.018,n);s.rotation.y=.18;const a=K(i,.27,.02,.35,"#f6f2e8",t,e+.028,n+.01);a.rotation.y=.18,zt(i,.009,.009,.24,"#e07a5f",t+.04,e+.045,n,8).rotation.set(0,.5,Math.PI/2)}function HM(i,t,e,n,s){const a=new Ht;a.position.set(e,0,n);const r=K(a,2.5,.1,1.15,null,0,.78,0,UM());r.receiveShadow=!0,K(a,2.54,.03,1.19,ct.woodDark,0,.742,0);for(const w of[-1.08,1.08])K(a,.09,.72,.16,ct.metal,w,.37,0),K(a,.13,.06,1,ct.metal,w,.03,0),K(a,.13,.05,.86,ct.metal,w,.715,0);K(a,1.95,.07,.08,ct.metal,0,.67,-.18),K(a,2,.3,.04,ct.woodDark,0,.57,-.5);const o=K(a,1.3,.05,.12,"#2a2e38",0,.5,-.3);o.castShadow=!1,K(a,.58,.62,.56,"#e6ded0",.78,.31,-.2);for(const w of[.17,.45]){K(a,.5,.24,.02,"#f1ebe0",.78,w,.09);const R=zt(a,.013,.013,.16,"#8d94a3",.78,w,.105,8);R.rotation.z=Math.PI/2}K(a,.17,.07,.2,ct.metal,0,.87,-.47),zt(a,.03,.035,.52,ct.metal,0,1.12,-.47,12);const l=K(a,.055,.055,.32,ct.metal,0,1.35,-.38);l.rotation.x=.3,K(a,.14,.14,.05,ct.metal,0,1.42,-.31);const c=Fd(a,1.5,.84,0,1.46,-.295);c.g.rotation.x=.05;const h=new ln({color:"#2a3442",toneMapped:!1}),u=new yt(new gi(.014,12),h);u.position.set(.68,-.47,.03),c.g.add(u),s%3===1&&[["#f6d365",-.04,.09],["#f3a6b2",-.19,-.06]].forEach(([w,R,k])=>{const v=K(c.g,.11,.11,.004,w,.8,R,.02);v.rotation.z=k,v.castShadow=!1});const d=Fd(a,.6,.36,-.99,1.08,-.02,500);d.g.rotation.y=.62,K(d.g,.3,.03,.2,ct.metal,0,-.25,0),K(d.g,.06,.2,.06,ct.metal,0,-.14,0);const f=K(a,1.18,.008,.42,"#454d5e",0,.834,.16);f.castShadow=!1,K(a,.8,.022,.27,"#e9e6e1",-.02,.849,.15);const g=new yt(new vi(.76,.23),new Dn({map:OM(),roughness:.7}));g.rotation.x=-Math.PI/2,g.position.set(-.02,.861,.15),g.receiveShadow=!0,a.add(g);const _=new yt(new di(.055,12,8),xe("#e9e6e1"));_.position.set(.52,.843,.18),_.scale.set(1,.6,1.45),_.castShadow=!0,a.add(_),K(a,.012,.004,.05,"#9aa3b2",.52,.874,.15).castShadow=!1;const p=["#e07a5f","#3d7ea6","#f2cc8f","#81b29a"][s%4];zt(a,.07,.065,.16,p,.66,.91,-.08,14);const m=new yt(new li(.045,.012,6,12,Math.PI*1.2),xe(p));m.position.set(.73,.92,-.08),m.rotation.y=Math.PI/2,m.rotation.z=-.3,a.add(m);const y=new yt(new gi(.062,14),xe("#4a3328",{roughness:.3}));y.rotation.x=-Math.PI/2,y.position.set(.66,.985,-.08),a.add(y),[()=>DM(a,.98,.83,-.38),()=>Yh(a,1,.83,-.3),()=>Lo(a,.98,.83,-.32),()=>FM(a,1,.83,-.3),()=>zM(a,1,.83,-.28),()=>BM(a,1,.83,-.3,s)][s%6](),s%4===2&&Tp(a,-.55,.835,-.18);const x=new Ht;x.position.set(.86,.835,.44),a.add(x),K(x,.46,.022,.1,"#2f343f",0,.011,0);const S=Ni(x,.42,.11,256,67);S.mesh.position.set(0,.07,.015),S.mesh.rotation.x=-.42,S.mesh.material=new Dn({map:S.tex,roughness:.75});const P=Ap(ct.chair);P.position.set(0,0,1.05),a.add(P),i.add(a),t.block(e-1.3,e+1.3,n-.7,n+.5);const T={index:s,x:e,z:n,seat:new C(e,0,n+1.05),seatY:Wt,screen:c.face,side:d.face,plate:S,led:h,chair:P};return Rp(T,{}),T}function Ap(i){const t=new Ht,e=xe("#3c4250",{roughness:.9});K(t,.6,.07,.58,i,0,Wt-.035,0);const n=K(t,.56,.05,.54,null,0,Wt+.01,.01,e);n.castShadow=!1;const s=new Ht;s.position.set(0,Wt,.3),s.rotation.x=.12,t.add(s),K(s,.56,.3,.09,i,0,.19,0),K(s,.52,.34,.05,null,0,.52,.005,e);for(const a of[-.25,.25])K(s,.05,.36,.06,i,a,.52,0);K(s,.34,.13,.06,i,0,.79,-.01);for(const a of[-.33,.33]){K(t,.05,.22,.4,i,a,Wt+.09,.06);const r=K(t,.09,.05,.44,null,a,Wt+.21,.04,e);r.castShadow=!1}zt(t,.055,.055,.18,"#6e7684",0,Wt-.14,0,12),zt(t,.042,.042,Wt-.22,ct.metal,0,(Wt-.22)/2+.06,0,10),zt(t,.11,.13,.05,ct.metal,0,.08,0,14);for(let a=0;a<5;a++){const r=a/5*Math.PI*2,o=K(t,.07,.045,.3,ct.metal,0,.075,0);o.position.set(Math.sin(r)*.17,.075,Math.cos(r)*.17),o.rotation.y=r;const l=zt(t,.035,.035,.025,"#22262e",Math.sin(r)*.31,.04,Math.cos(r)*.31,10);l.rotation.z=Math.PI/2,l.rotation.y=r}return t}function zd(i,t,e,n,s){const a=new Ht;a.position.set(e,0,n),a.rotation.y=s,K(a,1.35,Wt-.14,1.2,ct.couch,0,(Wt-.14)/2,0),K(a,1.15,.14,1,"#6c8fb6",0,Wt-.07,.05),K(a,1.35,.78,.26,ct.couch,0,Wt+.25,-.47);for(const o of[-.54,.54])K(a,.27,.56,1.2,ct.couch,o,Wt-.06,0);for(const[o,l]of[[-.55,-.5],[.55,-.5],[-.55,.5],[.55,.5]])zt(a,.05,.04,.12,ct.woodDark,o,.06,l,8);i.add(a);const r=.75;return t.block(e-r,e+r,n-r,n+r),a}function Cp(i,t,e,n){zt(i,.26,.26,.08,n,t,Wt-.04,e,20),zt(i,.035,.035,Wt-.09,ct.metal,t,(Wt-.09)/2,e,8),zt(i,.2,.22,.03,ct.metal,t,.015,e,16)}function Bd(i,{title:t="",subtitle:e="",lines:n=[],accent:s="#7bd389",idle:a=!1,t:r=0}){const{ctx:o,canvas:l,tex:c}=i.screen,h=l.width,u=l.height,d=h/512,f=o.createLinearGradient(0,0,0,u);if(f.addColorStop(0,"#141c26"),f.addColorStop(1,"#0d131b"),o.fillStyle=f,o.fillRect(0,0,h,u),a){o.textAlign="center",o.fillStyle="#2f3a49",o.font=`600 ${34*d}px ${Bn}`,o.fillText(t,h/2,u/2+4*d),o.fillStyle="#263040",o.font=`400 ${20*d}px ${Bn}`,o.fillText(e,h/2,u/2+36*d),o.textAlign="left",c.needsUpdate=!0;return}o.fillStyle=s,o.fillRect(0,0,h,5*d),o.globalAlpha=.09,o.fillRect(0,5*d,h,76*d),o.globalAlpha=1,o.beginPath(),o.arc(30*d,40*d,6*d,0,Math.PI*2),o.fillStyle=s,o.globalAlpha=.55+.45*Math.sin(r*3),o.fill(),o.globalAlpha=1,o.fillStyle="#eaeff5",o.font=`650 ${26*d}px ${Bn}`,o.fillText(t,46*d,48*d),o.fillStyle="#7d8a9c",o.font=`400 ${18*d}px ${Bn}`,o.fillText(e,46*d,73*d),o.fillStyle="rgba(125, 138, 156, 0.22)",o.fillRect(24*d,92*d,1.5*d,u-104*d),o.font=`400 ${18*d}px ${LM}`;const g=n.slice(-8);g.forEach((_,p)=>{const m=p===g.length-1,y=116*d+p*23*d;o.globalAlpha=m?1:.45+p*.06,o.fillStyle=_.color||(m?"#eaeff5":"#8b98aa");let x=_.text;for(;o.measureText(x).width>h-56*d&&x.length>4;)x=x.slice(0,-2);x!==_.text&&(x=x.slice(0,-1)+"…"),o.fillText(x,38*d,y),o.globalAlpha=1}),Math.floor(r*2)%2===0&&(o.fillStyle=s,o.fillRect(38*d,116*d+g.length*23*d-14*d,9*d,17*d)),c.needsUpdate=!0}function Rp(i,{name:t="",accent:e="#7d8a9c",state:n="open"}={}){const s=n==="working";i.led&&i.led.color.set(s?e:n==="open"?"#232a35":"#39455a");const a=i.plate;if(a){const{ctx:o,canvas:l,tex:c}=a;o.fillStyle="#2c323d",o.fillRect(0,0,l.width,l.height),o.fillStyle=n==="open"?"#454c5a":e,o.fillRect(0,0,9,l.height),o.fillStyle=n==="open"?"#8d97a6":"#f3f1ed",o.font=`650 30px ${Bn}`,o.textBaseline="middle",o.fillText(t,26,l.height/2+1),o.textBaseline="alphabetic",c.needsUpdate=!0}const r=i.side;if(r){const{ctx:o,canvas:l,tex:c}=r,h=l.width,u=l.height;if(o.fillStyle=n==="open"?"#0b0f15":"#121a24",o.fillRect(0,0,h,u),n==="open"){o.fillStyle="#1b2430",o.beginPath(),o.arc(h/2,u/2,5,0,Math.PI*2),o.fill(),c.needsUpdate=!0;return}o.fillStyle=e,o.globalAlpha=.85,o.fillRect(0,0,h,4),o.globalAlpha=1,o.font=`600 ${Math.round(u*.1)}px ${Bn}`,o.fillStyle="#6f7d8f",o.fillText(t.toUpperCase(),14,26),o.textAlign="right",o.fillStyle=s?e:"#4d5a6b",o.fillText(s?"ACTIVE":n==="away"?"OFFLINE":"IDLE",h-14,26),o.textAlign="left";let d=0;for(const f of t+n)d=(d*31+f.charCodeAt(0))%9973;for(let f=0;f<6;f++){const g=44+f*Math.round((u-58)/6),_=Math.max(4,Math.round(u*.045));o.fillStyle="#1b2531",o.fillRect(14,g,h-28,_),d=(d*31+17)%9973;const p=s?.25+d%70/100:.08+d%25/100;o.fillStyle=f===0&&s?e:"#35445a",o.fillRect(14,g,Math.round((h-28)*p),_)}c.needsUpdate=!0}}function VM(i){const t=new PM(Ki,ns,re.x0,re.z0),e=[],n=xe("#a97a50"),s=new Dn({map:Pp(),roughness:.7}),a=new yt(new Ye(Ki+.6,.7,ns+.6),[n,n,s,n,n,n]);a.position.set(re.cx,-.35,0),a.receiveShadow=!0,a.castShadow=!0,i.add(a);const r=new yt(new vi(160,160),new D1({opacity:.14}));r.rotation.x=-Math.PI/2,r.position.y=-.72,r.receiveShadow=!0,i.add(r);const o=$M(Ki+16,ns+16);o.position.x=re.cx,i.add(o);const l=K(i,24.5,.02,12.6,null,0,.011,1.2,new Dn({map:kM(),roughness:1}));l.castShadow=!1;const c=-21,h=[Yr(i,Ki+.6,re.cx,re.z0-.15,0,[0,0,-1]),Yr(i,Ki+.6,re.cx,re.z1+.15,Math.PI,[0,0,1],[[-Ki/2-.3,c-1.2],[c+1.2,Ki/2+.3]]),Yr(i,ns,re.x0-.15,0,Math.PI/2,[-1,0,0]),Yr(i,ns,re.x1+.15,0,-Math.PI/2,[1,0,0])],[u,,d,f]=h,g=j=>j-re.cx;t.block(re.x0,re.x1,re.z0,re.z0+.2),t.block(re.x0,re.x0+.2,re.z0,re.z1);for(const j of[-6,0,6]){const Q=-j;d.attach.push(K(d.g,3.6,2.2,.06,ct.glass,Q,2.2,.15,{emissive:"#bfe3f5",emissiveIntensity:.45,roughness:.15}),K(d.g,3.8,.12,.14,ct.trim,Q,1.08,.2),K(d.g,3.8,.12,.14,ct.trim,Q,3.32,.2),K(d.g,.1,2.3,.14,ct.trim,Q,2.2,.2))}for(const j of[-6,0,6])NM(i,-17.4,j,5,3.6);const _=[];[[-9,-3],[-3,-3],[3,-3],[9,-3],[-9,5],[-3,5],[3,5],[9,5]].forEach(([j,Q],Tt)=>_.push(HM(i,t,j,Q,Tt)));const p=["#e07a5f","#3d7ea6","#f2cc8f","#81b29a","#9c6ade","#e5989b","#2a9d8f","#577590"];for(const j of[-18.4,-16.2,-14,-11.8]){K(i,2,3.2,.7,ct.woodDark,j,1.6,-14.5);for(let Q=0;Q<4;Q++){const Tt=.45+Q*.75;K(i,1.86,.05,.62,ct.wood,j,Tt-.04,-14.42);let St=j-.85;for(;St<j+.8;){const A=.1+Math.random()*.1,M=.4+Math.random()*.22;K(i,A,M,.45,p[Math.floor(Math.random()*p.length)],St+A/2,Tt+M/2,-14.4),St+=A+.02}}}t.block(-19.6,-10.7,-15,-14);for(const j of[12,13.4,14.8,16.2,17.6]){K(i,1.2,2.7,1,ct.rack,j,1.35,-14.4);for(let Q=0;Q<9;Q++){const Tt=K(i,.07,.07,.03,"#000",j-.4+Q%3*.12,.5+Math.floor(Q/3)*.7+Math.random()*.2,-13.88,new Dn({color:"#0a0a0a",emissive:["#4ade80","#60a5fa","#fbbf24"][Q%3],emissiveIntensity:1.2}));Tt.castShadow=!1,e.push(Tt)}for(let Q=0;Q<6;Q++)K(i,1,.02,.02,"#4b5261",j,.35+Q*.42,-13.89)}t.block(11.2,18.4,-15,-13.7);const m=new Ht;m.position.set(-18.6,0,0);const y=new yt(new Hn(.35,.45,.9,16),xe(ct.woodDark));y.position.y=.45;const x=new yt(new di(.45,24,16),xe("#4f8fc0",{roughness:.5}));x.position.y=1.35;const S=new yt(new Ta(.46,1),xe("#7fb069",{flatShading:!0,transparent:!0,opacity:.85}));S.position.y=1.35,S.scale.set(1,.9,.7);for(const j of[y,x,S])j.castShadow=!0,m.add(j);i.add(m),t.block(-19.2,-18,-.6,.6);const P=new Ht;P.position.set(15.6,0,-8),K(P,5,2.4,.08,ct.board,0,1.9,0,{roughness:.4}),K(P,5.2,.1,.14,ct.metal,0,.66,.02),K(P,.08,1.9,.08,ct.metal,-2.3,.6,0),K(P,.08,1.9,.08,ct.metal,2.3,.6,0);const T=Ni(P,4.8,2.2,640,290);T.mesh.position.set(0,1.9,.045),i.add(P),t.block(13,18.2,-8.4,-7.6);const w=K(i,9,.02,5.4,ct.rug,-14,.01,10.6);w.castShadow=!1;const R=new Ht;R.position.set(-14.5,0,8.4),K(R,5,Wt-.14,1.2,ct.couch,0,(Wt-.14)/2,0),K(R,5,.8,.3,ct.couch,0,Wt+.26,-.48);for(const j of[-2.35,2.35])K(R,.3,.6,1.2,ct.couch,j,Wt-.08,0);for(const j of[-1.5,0,1.5])K(R,1.4,.14,1,"#6c8fb6",j,Wt-.07,.05);for(const[j,Q]of[[-2.2,-.5],[2.2,-.5],[-2.2,.5],[2.2,.5]])zt(R,.05,.04,.12,ct.woodDark,j,.06,Q,8);i.add(R),t.block(-17,-12,7.8,9),zd(i,t,-17.3,10.9,Math.PI/2),zd(i,t,-12,10.9,-Math.PI/2),K(i,2.4,.08,1.2,ct.wood,-14.5,.48,10.6);for(const[j,Q]of[[-1.1,-.5],[1.1,-.5],[-1.1,.5],[1.1,.5]])K(i,.06,.44,.06,ct.metal,-14.5+j,.22,10.6+Q);t.block(-15.8,-13.2,10,11.2),K(i,1.3,.95,3.2,"#efe9df",-19.3,.475,12),K(i,.55,.65,.5,"#2c2f36",-19.35,1.28,11.4),K(i,.12,.08,.12,"#c0392b",-19.05,1.4,11.4,{emissive:"#c0392b",emissiveIntensity:.6});for(let j=0;j<3;j++){const Q=new yt(new Hn(.07,.06,.14,10),xe("#ffffff"));Q.position.set(-19.2,1.02,12.5+j*.25),i.add(Q)}t.block(-20,-18.6,10.4,13.6);const k=new Ht;k.position.set(-11,0,12),zt(k,.3,.34,.04,ct.metal,0,.02,0,20),zt(k,.04,.04,1.05,ct.metal,0,.55,0,10),zt(k,.48,.48,.05,ct.wood,0,1.08,0,28);for(const[j,Q,Tt]of[[-.18,.08,"#e07a5f"],[.2,-.1,"#3d7ea6"]])zt(k,.06,.05,.13,Tt,j,1.17,Q,12);i.add(k),t.block(-11.5,-10.5,11.5,12.5),u.attach.push(K(u.g,9.4,3.5,.08,"#d9cdbb",g(0),2.2,.2));const v=Ni(u.g,9,3.2,1536,546);v.mesh.position.set(g(0),2.2,.26),u.attach.push(v.mesh);const b=new Ht;b.position.set(23.4,0,12.4),K(b,3.4,1.05,.9,"#efe9df",0,.525,0),K(b,3.5,.06,1,ct.wood,0,1.08,0),K(b,.9,.55,.05,ct.metal,-.8,1.4,-.25);const N=Ni(b,1.6,.34,400,85);N.mesh.position.set(0,.62,.456),N.ctx.fillStyle="#efe9df",N.ctx.fillRect(0,0,400,85),N.ctx.fillStyle="#1d1b18",N.ctx.font=`650 38px ${Bn}`,N.ctx.textAlign="center",N.ctx.fillText("Chief of Staff",200,56),N.tex.needsUpdate=!0;const F=Ap(ct.chair);F.position.set(0,0,-1),F.rotation.y=Math.PI,b.add(F),i.add(b),t.block(21.6,25.2,11.9,12.9);const $=K(i,2.4,.02,1.6,"#b9a58f",Ud,.01,14);$.castShadow=!1,Va(u,g(-7.6),2.5,1.6,1.1,Ga.sunset),IM(u,g(7.6),2.7),Va(f,1.4,2.4,1,1.4,Ga.arcs),Va(f,3,2.4,1,1.4,Ga.blocks),Va(f,4.6,2.4,1,1.4,Ga.leaf),Va(d,11,2.5,1.2,.9,Ga.blocks,"#c39a6b");const W=new Ht;W.position.set(19.35,0,3),K(W,.7,.75,3.6,ct.woodDark,0,.4,0),K(W,.76,.05,3.7,ct.wood,0,.8,0);for(const j of[-1.2,0,1.2])K(W,.02,.6,1.1,"#9a7350",-.36,.4,j);for(const[j]of[[-1.7],[1.7]])K(W,.6,.06,.06,ct.metal,0,.03,j);Lo(W,0,.82,-1.1,4),Yh(W,0,.82,.2),zt(W,.11,.08,.38,"#3d7ea6",.05,1.01,1.2,14,{roughness:.35});for(let j=0;j<3;j++){const Q=zt(W,.008,.008,.5,"#5f8f6b",.05+(j-1)*.04,1.4,1.2,4);Q.rotation.z=(j-1)*.3;const Tt=new yt(new Ta(.06,0),xe(["#f2cc8f","#e5989b","#fff"][j],{flatShading:!0}));Tt.position.set(.05+(j-1)*.12,1.64,1.2),W.add(Tt)}i.add(W),t.block(18.9,20,1.1,4.9);const z=new Ht;z.position.set(-1,0,11.6),K(z,5.2,.08,1.4,ct.wood,0,.78,0);for(const j of[-2.3,2.3])K(z,.08,.74,1.1,ct.metal,j,.38,0);for(const j of[-1.7,0,1.7])for(const Q of[-1.05,1.05])Cp(z,j,Q,["#e07a5f","#f2cc8f","#81b29a"][Math.round(j+2)%3]);Lo(z,-1.4,.82,.1,2),zt(z,.06,.06,.14,"#ffffff",.5,.89,-.2,12);const nt=new Ht;nt.position.set(1.3,.82,.1),K(nt,.5,.025,.35,"#c7ccd4",0,.012,0);const G=K(nt,.5,.34,.02,"#c7ccd4",0,.17,-.17);G.rotation.x=-.25,z.add(nt);for(const j of[-1.6,1.6]){zt(z,.02,.02,1.6,"#2f3440",j,3.4,0,6);const Q=zt(z,.06,.32,.28,"#2f3440",j,2.55,0,20,{roughness:.5});Q.castShadow=!1;const Tt=new yt(new gi(.29,20),new ln({color:"#fff1c4"}));Tt.rotation.x=Math.PI/2,Tt.position.set(j,2.405,0),z.add(Tt)}i.add(z),t.block(-3.8,1.8,10.3,12.9);const at=new Ht;at.position.set(qe.x,0,qe.z);const ht=.84;K(at,3.7,.22,2.1,ct.woodDark,0,.71,0);for(const[j,Q]of[[-1.55,-.85],[1.55,-.85],[-1.55,.85],[1.55,.85]])K(at,.2,.62,.2,ct.woodDark,j,.31,Q);K(at,3.5,.03,1.9,"#2f7a57",0,ht-.015,0,{roughness:1});const mt=[];for(const j of[-1,1]){for(const Q of[-1,1])mt.push([1.32,.1,.25,j*.82,Q*.925]);mt.push([.25,.1,1.36,j*1.725,0])}for(const[j,Q,Tt,St,A]of mt)K(at,j,Q,Tt,ct.wood,St,ht+.05,A);for(const j of[-1,1])for(const Q of[-1,1])K(at,.3,.1,.3,ct.wood,j*1.83,ht+.05,Q*.98);for(const[j,Q,Tt,St]of[[1.28,.06,.82,.83],[1.28,.06,.82,-.83],[1.28,.06,-.82,.83],[1.28,.06,-.82,-.83]])K(at,j,.05,Q,"#256646",Tt,ht+.025,St).castShadow=!1;for(const j of[-1,1])K(at,.06,.05,1.3,"#256646",j*1.57,ht+.025,0).castShadow=!1;const Xt=new ln({color:"#0c0d10"});for(const[j,Q]of[[-1.6,-.8],[1.6,-.8],[-1.6,.8],[1.6,.8],[0,-.835],[0,.835]]){const Tt=new yt(new Hn(.15,.15,.02,20),Xt);Tt.position.set(j,ht+.002,Q),at.add(Tt)}i.add(at),t.block(qe.x-1.95,qe.x+1.95,qe.z-1.15,qe.z+1.15);const qt=new Ht;qt.position.set(-18,0,8.2),zt(qt,.22,.24,.04,"#2f3440",0,.02,0,20),zt(qt,.025,.025,1.7,"#2f3440",0,.87,0,8);const q=zt(qt,.22,.3,.38,"#f3e7d3",0,1.85,0,24,{emissive:"#ffe2a8",emissiveIntensity:.35,roughness:.9});q.castShadow=!1,i.add(qt),t.block(-18.4,-17.6,7.8,8.6);const st=K(i,6.4,.02,3.2,"#c9b79c",25.4,.012,12.9,{roughness:1});st.castShadow=!1;const Mt=K(i,6,.022,2.8,"#ddd0bb",25.4,.013,12.9,{roughness:1});Mt.castShadow=!1;const dt=GM(i,t,u,f,g),It=[[-19,-9.5,1.1,"tall"],[10,-14,1,"snake"],[-9.8,-14.2,.9,"bush"],[19,-11,1.2,"tall"],[-10.3,14,1,"bush"],[6.2,13.8,1.1,"tall"],[19,8.5,1,"snake"],[19.2,0,.9,"bush"],[-19.1,14.2,.8,"snake"],[11.6,13.9,1,"bush"]];for(const[j,Q,Tt,St]of It)Ep(i,t,j,Q,Tt,St);const Rt={n:Math.PI,s:0,w:-Math.PI/2,e:Math.PI/2},Nt=j=>j.map(([Q,Tt,St,A,M])=>({pos:new C(Q,0,Tt),face:Rt[St],pose:A,seatY:M,taken:null})),ee={library:{label:"Library",spots:Nt([[-17.6,-12.9,"n","read"],[-15.3,-12.9,"n","read"],[-13.1,-12.9,"n","read"],[-11,-12.9,"n","read"]])},servers:{label:"Server room",spots:Nt([[12.7,-12.6,"n","type"],[14.1,-12.6,"n","type"],[15.5,-12.6,"n","type"],[16.9,-12.6,"n","type"]])},window:{label:"Research window",spots:Nt([[-17.5,-6,"w","gaze"],[-17.5,-2.6,"w","gaze"],[-17.5,2.6,"w","gaze"],[-17.5,6,"w","gaze"]])},whiteboard:{label:"Whiteboard",spots:Nt([[13.9,-6.4,"n","write"],[15.2,-6.4,"n","write"],[16.5,-6.4,"n","write"],[17.8,-6.4,"n","write"]])},lounge:{label:"Break room",spots:Nt([[-16,8.5,"s","couch",Wt],[-14.5,8.5,"s","couch",Wt],[-13,8.5,"s","couch",Wt],[-17.2,10.9,"e","couch",Wt],[-11.9,10.9,"w","couch",Wt],[-2.7,10.55,"s","sit",Wt],[-1,10.55,"s","sit",Wt],[.7,10.55,"s","sit",Wt],[-2.7,12.65,"n","sit",Wt],[-1,12.65,"n","sit",Wt],[.7,12.65,"n","sit",Wt],[-17.9,11.4,"w","mug"],[-17.9,12.8,"w","mug"],[-11.95,12,"e","mug"],[-10.05,12,"w","mug"]])}},$t=new C(15.3,0,-2.4),L=Array.from({length:10},(j,Q)=>{const Tt=Math.PI+Q/10*Math.PI*2,St=new C($t.x+Math.sin(Tt)*2.3,0,$t.z+Math.cos(Tt)*2.3);return{pos:St,face:Math.atan2($t.x-St.x,$t.z-St.z)}});ee.lounge.spots.push({pos:new C(qe.x-.9,0,qe.z-1.65),face:Rt.s,pose:"stand",taken:null,game:!0},{pos:new C(qe.x+.9,0,qe.z+1.65),face:Rt.n,pose:"stand",taken:null,game:!0});const ze=(j,Q,Tt,St,A)=>({pos:new C(j,0,Q),face:Math.atan2(Tt-j,St-Q),pose:A,taken:null});return ee.poolside={label:"Pool table",spots:[[4.9,10.9],[10.3,10.9],[9.6,8.8],[5.6,8.8]].map(([j,Q])=>ze(j,Q,qe.x,qe.z,"mug"))},Object.assign(ee,dt.stations),{grid:t,desks:_,stations:ee,pool:at,standup:L,board:v,scribble:T,blinkers:e,globe:S,slab:a,updateWalls:(j,Q,Tt)=>XM(h,j,Q,Tt),door:new C(Ud,0,14.4),reception:{seat:new C(23.4,0,11.4),seatY:Wt}}}function GM(i,t,e,n,s){const a=(T,w,R,k,v,b)=>({pos:new C(T,0,w),face:Math.atan2(R-T,k-w),pose:v,seatY:b,taken:null}),o=new Dn({color:ct.glass,transparent:!0,opacity:.28,roughness:.08,metalness:.1,depthWrite:!1}),l=re.z0,c=-3.6,h=new yt(new Ye(.05,2.3,c-l),o);h.position.set(Js,1.25,(l+c)/2),i.add(h),K(i,.1,.1,c-l,ct.metal,Js,2.42,(l+c)/2),K(i,.12,.1,c-l,ct.metal,Js,.05,(l+c)/2);for(let T=l+.2;T<=c+.01;T+=(c-l-.2)/4)K(i,.08,2.45,.08,ct.metal,Js,1.22,T);t.block(Js-.15,Js+.15,l,c),K(i,10.4,.02,10.8,"#c9d3c4",26.2,.011,-8.6,{roughness:1}).castShadow=!1,K(i,10,.022,10.4,"#d6ddd1",26.2,.012,-8.6,{roughness:1}).castShadow=!1,e.attach.push(K(e.g,5.4,1.5,.08,"#2f3440",s(26.2),2.65,.2));const u=Ni(e.g,5.2,1.3,800,200);u.mesh.position.set(s(26.2),2.65,.25),u.ctx.fillStyle="#2f3440",u.ctx.fillRect(0,0,800,200),u.ctx.textAlign="center",u.ctx.fillStyle="#f5f0e8",u.ctx.font=`680 76px ${Bn}`,u.ctx.fillText("Guest wing",400,104),u.ctx.fillStyle="#b9c7b4",u.ctx.font=`500 30px ${Bn}`,u.ctx.fillText("Visitors from linked offices work here",400,158),u.tex.needsUpdate=!0,e.attach.push(u.mesh);for(const T of[-10.4,-5.2])n.attach.push(K(n.g,3.2,2.2,.06,ct.glass,T,2.2,.15,{emissive:"#bfe3f5",emissiveIntensity:.45,roughness:.15}),K(n.g,3.4,.12,.14,ct.trim,T,1.08,.2),K(n.g,3.4,.12,.14,ct.trim,T,3.32,.2),K(n.g,.1,2.3,.14,ct.trim,T,2.2,.2));const d=[];for(const T of[-11,-6.2]){const w=new Ht;w.position.set(26.2,0,T),K(w,6.2,.08,1.2,ct.wood,0,.78,0),K(w,6.24,.03,1.24,ct.woodDark,0,.742,0);for(const R of[-2.8,2.8])K(w,.08,.74,1,ct.metal,R,.38,0);K(w,5.5,.26,.04,ct.woodDark,0,.6,0);for(const R of[-2,0,2])for(const k of[-1,1]){Cp(w,R,k*1.05,["#7c5cff","#0e9f9a","#d9488f","#c98a12","#3b82f6","#65a30d"][(R/2+1)*2+(k+1)/2]);const v=new Ht;v.position.set(R,.82,k*.3),v.rotation.y=k>0?0:Math.PI,K(v,.5,.025,.35,"#c7ccd4",0,.012,0);const b=K(v,.5,.34,.02,"#c7ccd4",0,.17,-.17);b.rotation.x=-.25,w.add(v),d.push(a(26.2+R,T+k*1.05,26.2+R,T,"desk",Wt))}for(const R of[-2,2]){zt(w,.02,.02,1.6,"#2f3440",R,3.4,0,6),zt(w,.06,.32,.28,"#2f3440",R,2.55,0,20,{roughness:.5}).castShadow=!1;const k=new yt(new gi(.29,20),new ln({color:"#fff1c4"}));k.rotation.x=Math.PI/2,k.position.set(R,2.405,0),w.add(k)}i.add(w),t.block(26.2-3.1,26.2+3.1,T-.6,T+.6)}const f=new Ht;f.position.set(24.4,0,-2.2);const g="#3f8f8a",_="#5aa8a2";K(f,4,Wt-.14,1.1,g,0,(Wt-.14)/2,0),K(f,4,.78,.28,g,0,Wt+.25,-.44);for(const T of[-1.86,1.86])K(f,.28,.58,1.1,g,T,Wt-.07,0);for(const T of[-1.1,0,1.1])K(f,1.05,.14,.92,_,T,Wt-.07,.05);for(const[T,w]of[[-1.8,-.45],[1.8,-.45],[-1.8,.45],[1.8,.45]])zt(f,.05,.04,.12,ct.woodDark,T,.06,w,8);i.add(f),t.block(22.3,26.5,-2.8,-1.6),K(i,1.8,.06,.7,ct.wood,24.4,.4,-.5);for(const[T,w]of[[-.8,-.28],[.8,-.28],[-.8,.28],[.8,.28]])K(i,.05,.38,.05,ct.metal,24.4+T,.19,-.5+w);Lo(i,24,.43,-.5,2),t.block(23.4,25.4,-.9,-.1);const p=new Ht;p.position.set(31.35,0,3),K(p,1,.95,3.6,"#efe9df",0,.475,0),K(p,1.06,.05,3.7,ct.wood,0,.97,0),K(p,.55,.65,.5,"#2c2f36",.1,1.32,-.9),K(p,.12,.08,.12,"#0e9f9a",-.2,1.44,-.9,{emissive:"#0e9f9a",emissiveIntensity:.6});for(let T=0;T<3;T++)zt(p,.07,.06,.14,"#ffffff",-.1,1.06,.1+T*.28,10);Yh(p,0,.99,1.3),i.add(p),t.block(30.8,re.x1,1.1,4.9);const m=new Ht;m.position.set(27.6,0,3),zt(m,.3,.34,.04,ct.metal,0,.02,0,20),zt(m,.04,.04,1.05,ct.metal,0,.55,0,10),zt(m,.48,.48,.05,ct.wood,0,1.08,0,28),zt(m,.06,.05,.13,"#d9488f",.15,1.17,.1,12),i.add(m),t.block(27.1,28.1,2.5,3.5);const y=[a(30.2,2,31.35,2,"mug"),a(30.2,3,31.35,3,"mug"),a(30.2,4,31.35,4,"mug"),a(26.65,3,27.6,3,"mug"),a(28.55,3,27.6,3,"mug"),...[23.2,24.4,25.6].map(T=>({pos:new C(T,0,-2.1),face:0,pose:"couch",seatY:Wt,taken:null}))],x={x:27.6,z:8.4},S=new Ht;S.position.set(x.x,0,x.z),zt(S,.42,.48,.05,ct.metal,0,.025,0,24),zt(S,.07,.07,1.02,ct.metal,0,.53,0,12),zt(S,.9,.9,.06,ct.wood,0,1.06,0,36),Tp(S,-.2,1.09,.1),i.add(S),t.block(x.x-.9,x.x+.9,x.z-.9,x.z+.9);const P=Array.from({length:6},(T,w)=>{const R=w/6*Math.PI*2+Math.PI/6;return a(x.x+Math.sin(R)*1.55,x.z+Math.cos(R)*1.55,x.x,x.z,"stand")});for(const[T,w,R,k]of[[31.2,-14.2,1.1,"tall"],[21.1,-4.6,.9,"bush"],[31.2,13.8,1,"snake"],[31.3,-1.2,.9,"bush"],[21.2,6.2,1,"tall"]])Ep(i,t,T,w,R,k);return{stations:{hotdesk:{label:"Guest desks",spots:d},coffee:{label:"Guest coffee",spots:y},huddle:{label:"Guest table",spots:P}}}}function Pp(){const i=document.createElement("canvas");i.width=i.height=1024;const t=i.getContext("2d"),e=16,n=i.height/e;for(let a=0;a<e;a++){let r=-Math.random()*400;for(;r<i.width;){const o=380+Math.random()*520,l=73+Math.random()*3.5;t.fillStyle=`hsl(${32+Math.random()*3}, ${33+Math.random()*5}%, ${l}%)`,t.fillRect(r,a*n,o,n),t.globalAlpha=.045;for(let c=0;c<6;c++)t.fillStyle=Math.random()<.5?"#7a5634":"#fff6e8",t.fillRect(r,a*n+Math.random()*n,o,1+Math.random()*2);t.globalAlpha=1,t.fillStyle="rgba(90, 60, 35, 0.22)",t.fillRect(r,a*n,2,n),r+=o}t.fillStyle="rgba(90, 60, 35, 0.18)",t.fillRect(0,a*n,i.width,2)}const s=new Hi(i);return s.colorSpace=Qe,s.wrapS=s.wrapT=Oi,s.repeat.set(Ki/8,ns/8),s.anisotropy=8,s}function $M(i,t){const e=document.createElement("canvas");e.width=e.height=256;const n=e.getContext("2d"),s=n.createRadialGradient(128,128,30,128,128,128);s.addColorStop(0,"rgba(60, 40, 20, 0.28)"),s.addColorStop(.6,"rgba(60, 40, 20, 0.12)"),s.addColorStop(1,"rgba(60, 40, 20, 0)"),n.fillStyle=s,n.fillRect(0,0,256,256);const a=new Hi(e),r=new yt(new vi(i,t),new ln({map:a,transparent:!0,depthWrite:!1}));return r.rotation.x=-Math.PI/2,r.position.y=-.715,r}const la=4.2,WM=.5;function Yr(i,t,e,n,s,a,r=[[-t/2,t/2]]){const o=new Ht;o.position.set(e,0,n),o.rotation.y=s;const l=new Ht,c=new Ht;o.add(l,c);for(const[u,d]of r){const f=new yt(new Ye(d-u,la,.3),xe(ct.wall));f.position.set((u+d)/2,la/2,0),f.castShadow=f.receiveShadow=!0,l.add(f);const g=new yt(new Ye(d-u,.1,.36),xe("#cbbba3"));g.position.set((u+d)/2,.05,0),c.add(g);const _=new yt(new Ye(d-u,.22,.04),xe(ct.trim));_.position.set((u+d)/2,.11,.17),o.add(_)}i.add(o);const h={g:o,body:l,cap:c,outward:new C(...a),h:la,attach:[]};return c.position.y=la,h}const Hd=new C;function XM(i,t,e,n){Hd.subVectors(t.position,e).setY(0).normalize();for(const s of i){const a=s.outward.dot(Hd)>.2?WM:la;s.h+=(a-s.h)*Math.min(1,n*7),s.body.scale.y=s.h/la,s.cap.position.y=s.h;for(const r of s.attach)r.visible=s.h>3.4}}const qM={queued:0,working:1,done:2,failed:2,stopped:2},jM={queued:"#fde68a",working:"#bfdbfe",done:"#bbf7d0",failed:"#fecaca",stopped:"#e5e7eb"};function Lp(i,t){const{ctx:e,canvas:n,tex:s}=i,a=n.width,r=n.height;e.fillStyle="#fbfaf7",e.fillRect(0,0,a,r);const o=["Queued","Working","Shipped"],l=a/3;o.forEach((c,h)=>{e.fillStyle="#1d1b18",e.font=`650 34px ${Bn}`,e.fillText(c,h*l+28,54),h&&(e.fillStyle="#e7e1d7",e.fillRect(h*l,20,3,r-40)),t.filter(d=>qM[d.status]===h).sort((d,f)=>(f.endedAt||f.queuedAt)-(d.endedAt||d.queuedAt)).slice(0,6).forEach((d,f)=>{const g=h*l+28+f%2*(l/2-18),_=80+Math.floor(f/2)*150,p=l/2-36,m=130;e.save(),e.translate(g+p/2,_+m/2),e.rotate((d.id.charCodeAt(0)%7-3)*.008),e.fillStyle="rgba(0,0,0,0.08)",e.fillRect(-p/2+4,-m/2+6,p,m),e.fillStyle=jM[d.status],e.fillRect(-p/2,-m/2,p,m),e.fillStyle="#1d1b18",e.font=`600 22px ${Bn}`,YM(e,d.title,-p/2+14,-m/2+34,p-28,26,3),e.fillStyle="#5b554c",e.font=`400 18px ${Bn}`,e.fillText(d.repo.slice(0,22),-p/2+14,m/2-14),e.restore()})}),s.needsUpdate=!0}function YM(i,t,e,n,s,a,r){const o=String(t).split(/\s+/);let l="",c=0;for(let h=0;h<o.length;h++){const u=l?l+" "+o[h]:o[h];if(i.measureText(u).width>s&&l){if(c===r-1){i.fillText(l+"…",e,n+c*a);return}i.fillText(l,e,n+c*a),l=o[h],c++}else l=u}i.fillText(l,e,n+c*a)}function nh(i,t){const{ctx:e,canvas:n,tex:s}=i;e.fillStyle="#fbfaf7",e.fillRect(0,0,n.width,n.height),e.fillStyle="#2f5d8a",e.font='600 30px "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive',e.fillText("Today",26,46),e.font='400 24px "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive',t.slice(0,7).forEach((a,r)=>{e.fillStyle=a.done?"#6b8f71":"#3a3a3a";const o=(a.done?"✓ ":"• ")+a.text;e.fillText(o.length>44?o.slice(0,43)+"…":o,30,86+r*30)}),s.needsUpdate=!0}const Vd=(i,t,e)=>{let n=((t-i+Math.PI)%(Math.PI*2)+Math.PI*2)%(Math.PI*2)-Math.PI;return i+n*e},$a=(i,t)=>i+Math.random()*(t-i);function Kr(i,t=34){let e=String(i||"").replace(/\s+/g," ").trim();const n=e.search(/[,;:]| \u2014 | - | and | with | so that | in order /i);if(n>11&&(e=e.slice(0,n)),e.length<=t)return e;const s=e.lastIndexOf(" ",t);return e.slice(0,s>t*.6?s:t).replace(/[,.;:]$/,"")+"…"}const Gd=["coffee?","anyone seen my mug","back in 5","nice weather","who broke main","lunch soon?","reading the docs, honestly","standup when"];let Kl=null;function KM(){if(Kl)return Kl;const i=document.createElement("canvas");i.width=i.height=64;const t=i.getContext("2d"),e=t.createRadialGradient(32,32,4,32,32,32);return e.addColorStop(0,"rgba(40, 28, 16, 0.32)"),e.addColorStop(1,"rgba(40, 28, 16, 0)"),t.fillStyle=e,t.fillRect(0,0,64,64),Kl=new Hi(i)}class Kh{constructor(t,e,n,s={}){this.staff=t,this.id=t.id,this.name=t.name,this.world=e,this.desk=s.desk||e.desks[e.agentIndex(t.id)],this.deskFace=s.face??Math.PI,this.root=new Ht,this.fig=new ir(t),this.root.add(this.fig.group),this.body=this.fig.body;const a=new yt(new gi(.5,24),new ln({map:KM(),transparent:!0,depthWrite:!1}));a.rotation.x=-Math.PI/2,a.position.y=.015,this.root.add(a),this.ring=new yt(new Gh(.55,.68,40),new ln({color:t.shirt,transparent:!0,opacity:.9})),this.ring.rotation.x=-Math.PI/2,this.ring.position.y=.03,this.ring.visible=!1,this.root.add(this.ring),this.root.traverse(c=>{c.userData.agentId=t.id}),e.scene.add(this.root),this.pos=this.root.position,this.heading=0,this.path=[],this.goal=null,this.placeKey=null,this.spot=null,this.pose="stand",this.want="lounge",this.dwellUntil=0,this.wanderAt=0,this.chatAt=$a(8,30),this.anim=null,this.job=null,this.lines=[],this.phase=Math.random()*10,this.label=document.createElement("div"),this.label.className="agent-label";const r=document.createElement("div");r.className="bubble";const o=document.createElement("div");o.className="name";const l=document.createElement("i");/^#[0-9a-f]{3,8}$/i.test(t.shirt??"")&&(l.style.background=t.shirt),this.nameText=document.createTextNode(String(t.name??"")),o.append(l,this.nameText),this.label.append(r,o),this.bubbleEl=this.label.querySelector(".bubble"),n.appendChild(this.label),this.say("")}rename(t){this.name=t,this.nameText.data=t,this.labelDirty=!0}say(t,e="",n=0){t!==this.bubbleText&&(this.labelDirty=!0),this.bubbleText=t,this.bubbleEl.textContent=t,this.bubbleEl.className="bubble"+(e?" "+e:""),this.bubbleEl.style.display=t?"":"none",this.bubbleUntil=n?(this.now||0)+n/1e3:0}teleport(t){const e=this.resolve(t);e&&(this.pos.copy(e.pos),this.heading=e.face,this.root.rotation.y=e.face,this.goal=e,this.path=[],this.arrive(0))}resolve(t,e=!1){if(t==="desk")return{key:t,pos:this.desk.seat.clone(),face:this.deskFace,pose:"desk",seatY:this.desk.seatY};if(t==="visit")return this.visitTarget;if(t==="standup")return this.meeting;if(t==="door")return{key:t,pos:this.world.door.clone(),face:Math.PI,pose:"stand"};const n=this.world.stations[t];if(!n)return null;let s=!e&&this.spot&&n.spots.includes(this.spot)?this.spot:null;if(!s){const r=n.spots.filter(l=>!l.game&&(!l.taken||l.taken===this.id)),o=e?r.filter(l=>l!==this.spot):r;s=(o.length?o:r)[Math.floor(Math.random()*(o.length||r.length))]}if(!s)return t==="lounge"?null:this.resolve("desk");this.spot&&this.spot!==s&&(this.spot.taken=null),s.taken=this.id,this.spot=s;const a=t==="lounge"||s.seatY?0:.12;return{key:t,pos:s.pos.clone().add(new C($a(-a,a),0,$a(-a,a))),face:s.face,pose:s.pose,seatY:s.seatY}}goTo(t,e,n=!1){t==="desk"&&this.spot&&(this.spot.taken=null,this.spot=null);const s=this.resolve(t,n);s&&(this.goal=s,this.placeKey=null,this.path=this.world.grid.path(this.pos.x,this.pos.z,s.pos.x,s.pos.z),this.path.length||this.arrive(e))}arrive(t){const e=this.goal;this.pos.set(e.pos.x,0,e.pos.z),this.placeKey=e.key,this.pose=e.pose,this.seatY=e.seatY,this.dwellUntil=t+(e.key==="desk"?.8:e.key==="lounge"?0:e.key==="visit"?3.4:e.key==="standup"?.5:2.4),e.key==="lounge"&&(this.wanderAt=t+$a(18,40))}assign(t,e=!1){this.job=t,this.anim=null,this.want="desk",this.lines=[],this.say("On it","",0),e&&this.teleport("desk")}visit(t,e){const n=this.world.grid,s=[[1.1,0],[-1.1,0],[0,1.1],[0,-1.1],[.9,.9],[-.9,.9]],[a,r]=s.find(([l,c])=>!n.blocked(...n.cellOf(t.pos.x+l,t.pos.z+c)))||[1.1,0],o=new C(t.pos.x+a,0,t.pos.z+r);this.visitTarget={key:"visit",pos:o,face:Math.atan2(t.pos.x-o.x,t.pos.z-o.z),pose:"talk"},this.afterVisit=this.want==="visit"?this.afterVisit:this.want,this.want="visit",this.placeKey=null,this.path=[],this.spot&&(this.spot.taken=null,this.spot=null),this.say(Kr(e,52),"talk",0)}onLog(t){if(!this.job)return;const e=(...a)=>!this.meeting&&this.say(...a),n={tool:null,text:"#e8edf3",error:"#f87171",thinking:"#64748b",system:"#64748b"}[t.kind],s=a=>{this.want==="visit"?this.afterVisit=a:this.want=a};if(t.kind==="tool")s("desk"),e(Kr(t.summary)),this.lines.push({text:"› "+t.summary,color:n});else if(t.kind==="text"){s("desk");const a=t.summary.split(new RegExp("(?<=[.!?])\\s|\\n"))[0];e(Kr(a,44)),this.lines.push({text:a,color:n})}else t.kind==="thinking"?e("thinking…","thinking"):t.kind==="error"?(e(t.blocked?"Needs clearance":"Hm, that failed","warn"),this.lines.push({text:"✕ "+t.summary.split(`
4475
+ `)[0],color:n})):t.kind==="system"&&(this.lines.push({text:t.summary,color:n}),t.wait&&(s("desk"),e(Kr(t.summary,30)+"…","thinking")));this.lines.length>40&&this.lines.splice(0,this.lines.length-40)}meet(t,e=!1){if(this.meeting={key:"standup",pos:t.pos.clone(),face:t.face,pose:"stand"},this.spot&&(this.spot.taken=null,this.spot=null),e)return this.teleport("standup");this.want!=="visit"&&(this.path=[],this.placeKey=null)}adjourn(){this.meeting=null,this.placeKey==="standup"&&(this.placeKey=null)}speak(t){this.say(t,"talk",5200),this.anim={kind:"talk",until:(this.now||0)+4.8}}leave(){this.leaving=!0,this.want="door",this.spot&&(this.spot.taken=null,this.spot=null),this.say("Heading home","idle",3e3)}stay(){this.leaving=!1,this.want="lounge",this.say("Oh, staying!","good",2500)}dispose(){this.spot&&(this.spot.taken=null),this.world.scene.remove(this.root),this.label.remove()}finish(t){const e=this.now||0;this.anim={kind:t==="done"?"celebrate":"slump",until:e+2.2},this.say(t==="done"?"Shipped it!":t==="waiting"?"Need your answer":t==="stopped"?"Okay, stopping":"Hit a wall",t==="done"?"good":"warn",4e3),this.job=null,this.afterVisit=null,this.want="lounge"}think(t){var s;if(this.anim&&t<this.anim.until)return;this.anim=null,this.bubbleUntil&&t>this.bubbleUntil&&this.say("");const e=this.meeting&&!this.leaving&&this.want!=="visit"?"standup":this.want;if(this.path.length){((s=this.goal)==null?void 0:s.key)==="lounge"&&e!=="lounge"&&this.goTo(e,t);return}if(t<this.dwellUntil)return;if(this.leaving&&this.placeKey==="door"){this.gone=!0;return}this.placeKey==="visit"&&this.want==="visit"&&(this.want=this.job?this.afterVisit||"desk":"lounge",this.afterVisit=null,this.bubbleEl.classList.contains("talk")&&this.say(""));const n=this.meeting&&!this.leaving&&this.want!=="visit"?"standup":this.want;n!==this.placeKey?this.goTo(n,t):n==="lounge"&&t>this.wanderAt&&this.goTo("lounge",t,!0),!this.job&&!this.meeting&&!this.chatting&&t>this.chatAt&&(this.chatAt=t+$a(25,60),Math.random()<.5&&this.say(Gd[Math.floor(Math.random()*Gd.length)],"idle",3500))}update(t,e){var s;this.now=e,this.think(e);let n=!1;if(this.path.length){const[a,r]=this.path[0],o=a-this.pos.x,l=r-this.pos.z,c=Math.hypot(o,l),h=3.4*t;c<=h?(this.pos.x=a,this.pos.z=r,this.path.shift(),this.path.length||this.arrive(e)):(this.pos.x+=o/c*h,this.pos.z+=l/c*h,this.heading=Vd(this.heading,Math.atan2(o,l),Math.min(1,t*12)),n=!0)}!n&&this.goal&&!this.path.length&&(this.heading=Vd(this.heading,this.goal.face,Math.min(1,t*8))),this.root.rotation.y=this.heading,this.animate(n?"walk":((s=this.anim)==null?void 0:s.kind)||this.pose,t,e)}animate(t,e,n){var r;this.fig.pose(t,e,n+this.phase,{typing:!!this.job&&!this.job.waiting&&this.job.id!=="idle",waiting:!!((r=this.job)!=null&&r.waiting),seatY:this.seatY});const s=this.bubbleEl.className,a=t==="celebrate"?"happy":t==="slump"||s.includes("warn")?"worried":t==="talk"||s.includes("idle")&&this.bubbleText?"talk":s.includes("thinking")?"think":s.includes("good")?"happy":"neutral";this.fig.express(a,e,n+this.phase)}placeLabel(t,e,n){const s=new C(this.pos.x,this.body.position.y+2.5+(this.fig.look.hair==="afro"?.2:0),this.pos.z).project(t);if(this.onScreen=s.z<=1,!this.onScreen){this.label.style.display="none",this.lift=0;return}this.label.style.display="",this.anchorX=(s.x*.5+.5)*e,this.anchorY=(-s.y*.5+.5)*n,this.depth=s.z,this.label.style.zIndex=String(Math.round((1-s.z)*1e4)),(this.labelDirty||!this.labelW)&&this.measureLabel()}measureLabel(){this.label.offsetWidth&&(this.labelDirty=!1,this.labelW=this.label.offsetWidth,this.labelH=this.label.offsetHeight)}labelBox(t){const e=this.anchorY-t;return{left:this.anchorX-this.labelW/2,right:this.anchorX+this.labelW/2,top:e-this.labelH,bottom:e}}setLift(t,e){const n=this.lift===void 0?1:Math.min(1,e*9);this.lift=(this.lift||0)+(t-(this.lift||0))*n,Math.abs(this.lift-t)<.4&&(this.lift=t),this.label.style.transform=`translate(-50%, -100%) translate(${this.anchorX}px, ${this.anchorY-this.lift}px)`}setBuried(t){t!==this.buried&&(this.buried=t,this.label.classList.toggle("buried",t))}setCrowded(t,e){t?this.uncrowdAt=e+.6:this.crowded&&e<(this.uncrowdAt||0)&&(t=!0),t!==this.crowded&&(this.crowded=t,this.label.classList.toggle("crowded",t),this.measureLabel())}setSelected(t){this.ring.visible=t,this.label.classList.toggle("selected",t)}}const Zr=(i,t)=>i+Math.random()*(t-i),sr=i=>i[Math.floor(Math.random()*i.length)];async function is(i,t,e){const n=await fetch(i,t===void 0?{method:e||"GET"}:{method:e||"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`Request failed (${n.status})`);return n.json().catch(()=>({}))}const ZM=[["Coffee machine is making that noise again.","It does that when it likes you.","It has never liked me."],["Weekend plans, {b}?","Sleep, then more sleep.","Ambitious. I respect it."],["Did you see the size of that last diff?","I saw it. I chose not to look closer.","Wise."],["{b}, tabs or spaces?","Whatever the linter says.","Diplomatic answer.","It's the only safe one in here."],["I renamed one variable and forty tests broke.","Only forty? Lucky.","You have a dark sense of luck, {b}."],["Who keeps leaving one sip in the coffee pot?","Not me.","That is exactly what someone guilty would say."],["Favourite error message?",'"Something went wrong."',"So helpful. So honest."],["Read anything good lately?","The changelog for our test runner. Gripping stuff.","No spoilers please."],["This couch is too comfy.","Dangerous for productivity.","Good thing nobody has given us work yet."],["Do you ever dream in stack traces?","Only on deploy days.","Same."],["{b}, you were quiet in standup.","Saving my words for code review.","Ominous."],["Hot take: README files are love letters.","To whom?","To whoever opens this repo at 2am.","That's beautiful, {a}."],["What's the plant's name?","I call it Prod.","Why?","Because we don't touch it."],["I fixed a bug by deleting code today.","Best kind of fix.","Felt like spring cleaning."],["Lunch?","Already had it. Twice.","Bold."],['Have you noticed the boss says "quick change" a lot?',"Never quick.","Rarely one change."],["If you could rewrite one thing from scratch?","The build config.","Wouldn't we all."],["How do you stay so calm, {b}?","Small commits.","That explains a lot."]],JM=[{pair:["tunde","obi"],lines:["Still thinking about idempotency keys, {b}.","You always are. It is why I trust you with the ledger.","Say it again, but with a retry.","Same result. That is the whole point."]},{pair:["tunde","obi"],lines:["Remember the first ledger?","Four of us and one whiteboard.","We never did erase that whiteboard.","It's load-bearing now."]},{pair:["kai","zola"],lines:["Submission day, {b}. Checklist out?","Always out. Step one: breathe.","Step two: provisioning profile.","Step two is where we cry."]},{pair:["kai","zola"],lines:["Another rejection email. I can feel it.","Read it first. Then panic.","That is not on the checklist.","I will add it."]},{pair:["ada","mira"],lines:["I had a thought about the dashboard, {b}.","Is it a question? Please let it be a question.","It is a question.","Then I love it already. Go."]},{pair:["ada","tunde"],lines:["Does the new screen survive a retry, {b}?","You asked before I did.","You taught me.","Noted. Quietly proud."]},{pair:["ada","kai"],lines:["It should feel the same on web and app.","Thumbs do not agree.","Thumbs never do.","Move the button down, {a}."]},{pair:["mira","lin"],lines:["Could you look at this early, {b}? Before it is finished?","You ask early. I like that.","Startup scars.","The good kind of scar."]},{pair:["mira","tunde"],lines:["I could just own this whole feature, {b}.","Could you also wait for my green light?","That is the hard part.","It is the part that saves you."]},{pair:["mira","zola"],lines:["Ship it now, {b}?","Not yet.","How about now?","Ask me after the checklist."]},{pair:["lin","obi"],lines:["Another payload for you, {a}.","Guilty until proven valid.","You read my mind.","I read your schema."]},{pair:["lin","tunde"],lines:["Your logs are very readable, {b}.","I log everything now.","I know. It started on a train.","Do not remind me."]},{pair:["zola","tunde"],lines:["That alert again.","I saw it.","We nod?","We nod."]},{pair:["remi","mira"],lines:["Found a bug in your feature, {b}.","Wonderful. Send me the steps.","No defence? No excuses?","I would rather have the bug than the excuse."]}],QM=[{who:"tunde",lines:["Remember the Tuesday, {b}?","Nobody has forgotten the Tuesday.","That is why I log everything now.","Fair enough."]},{who:"kai",lines:["Did you hear? An app rejected over one permission string.","Is this the one you keep telling us about?","Never gets old.","It does, {a}."]},{who:"ada",lines:["Found a loading spinner I actually like.","Is it going in the folder?","It is going in the folder.","There is a folder?"]},{who:"zola",lines:["The release train ran on time again.","Because of the checklist.","Because of the checklist.","We all owe it a coffee."]},{who:"obi",lines:["Webhooks are promises, {b}.","To whom?","To whichever team is waiting on them.","Heavy thought for a coffee break."]},{who:"mira",lines:["One quick question, {b}.","Your questions are never quick.","This one is tiny.","Narrator: it was not."]},{who:"lin",lines:["Anyone have a worry they have not told anyone?","Not yet.","My door is open, and so is the kettle.","Thanks, {a}."]},{who:"remi",lines:['Anyone say "it works on my machine" today?',"Not me.","Good. I was sharpening my pencil.","Please do not."]}];function tb(i,t){const e=JM.filter(a=>a.pair.includes(i.id)&&a.pair.includes(t.id)),n=QM.filter(a=>a.who===i.id||a.who===t.id),s=Math.random();if(e.length&&s<.55){const a=sr(e);return $d(a.pair[0],a.lines,i,t)}if(n.length&&s<.8){const a=sr(n);return $d(a.who,a.lines,i,t)}return{who:[i,t],script:sr(ZM)}}function $d(i,t,e,n){return{who:i===e.id?[e,n]:[n,e],script:t}}const Wa=i=>!i.job&&!i.meeting&&!i.leaving&&!i.path.length&&i.want==="lounge"&&i.placeKey==="lounge"&&!i.playing;class eb{constructor(){this.next=Zr(10,20),this.chat=null,this.claiming=!1}update(t,e){if(this.chat)return this.step(e);if(this.claiming||e<this.next)return;const n=t.filter(Wa);if(n.length<2)return;const s=sr(n),a=sr(n.filter(r=>r!==s));this.claim(s,a,e)}async claim(t,e,n){this.claiming=!0,this.next=n+Zr(20,45);let s=null,a=null;try{({id:s,script:a}=await is("/api/chill",{who:[t.id,e.id]}))}catch{}if(this.claiming=!1,!!s){if(!Wa(t)||!Wa(e))return this.release(s);this.start(t,e,s,a)}}start(t,e,n,s){const{who:[a,r],script:o}=Array.isArray(s)&&s.length>=2?{who:[t,e],script:s}:tb(t,e),l=o.map(c=>c.replaceAll("{a}",a.name).replaceAll("{b}",r.name));for(const[c,h]of[[a,r],[r,a]])c.chatting=!0,c.wanderAt=1/0,c.pose!=="couch"&&(c.goal={...c.goal,face:Math.atan2(h.pos.x-c.pos.x,h.pos.z-c.pos.z)});this.chat={id:n,who:[a,r],script:l,line:0,at:0}}step(t){const e=this.chat;if(!e.who.every(Wa))return this.end(t);if(t<e.at)return;if(e.line>=e.script.length)return this.end(t);const n=e.who[e.line%2],s=e.script[e.line];n.say(s,"idle",3200+s.length*30),is(`/api/chill/${e.id}/line`,{from:n.id,text:s}).catch(()=>{}),e.at=t+2.6+s.length*.035,e.line++}end(t){this.release(this.chat.id);for(const e of this.chat.who)e.chatting=!1,Wa(e)&&(e.wanderAt=t+Zr(8,20));this.chat=null,this.next=t+Zr(20,45)}release(t){is(`/api/chill/${t}`,void 0,"DELETE").catch(()=>{})}}const Ze=3.2,Ri=1.6,Re=.075,Dp=.9,Jr=.78,Wd=7,nb=1/240,Qr=.15,Xd=.135,Zh=[{x:-Ze/2,z:-Ri/2,r:Qr},{x:Ze/2,z:-Ri/2,r:Qr},{x:-Ze/2,z:Ri/2,r:Qr},{x:Ze/2,z:Ri/2,r:Qr},{x:0,z:-Ri/2-.035,r:Xd},{x:0,z:Ri/2+.035,r:Xd}],to=i=>i===0?"cue":i===8?"eight":i<8?"solids":"stripes";function ih(){const i=[{n:0,x:-Ze/4,z:0,vx:0,vz:0,in:!1}],t=[1,2,3,4,5,6,7,9,10,11,12,13,14,15].sort(()=>Math.random()-.5),e=new Array(15);e[4]=8;const n=[10,14];e[n[0]]=t.splice(t.findIndex(r=>r<8),1)[0],e[n[1]]=t.splice(t.findIndex(r=>r>8),1)[0];for(let r=0;r<15;r++)e[r]||(e[r]=t.pop());const s=Re*2*1.002;let a=0;for(let r=0;r<5;r++)for(let o=0;o<=r;o++)i.push({n:e[a++],x:Ze/4+r*s*.866,z:(o-r/2)*s,vx:0,vz:0,in:!1});return i}function ib(i,t,e={}){var s,a,r;let n=t;for(;n>1e-9;){const o=Math.min(nb,n);n-=o;for(const l of i){if(l.in)continue;const c=Math.hypot(l.vx,l.vz);if(c>0){const f=Math.max(0,c-Dp*o),g=f/c;l.vx*=g,l.vz*=g,f<.012&&(l.vx=0,l.vz=0)}l.x+=l.vx*o,l.z+=l.vz*o;const h=Ze/2-Re,u=Ri/2-Re;let d=!1;l.x<-h?(l.x=-h,l.vx=Math.abs(l.vx)*Jr,d=!0):l.x>h&&(l.x=h,l.vx=-Math.abs(l.vx)*Jr,d=!0),l.z<-u?(l.z=-u,l.vz=Math.abs(l.vz)*Jr,d=!0):l.z>u&&(l.z=u,l.vz=-Math.abs(l.vz)*Jr,d=!0),d&&((s=e.cushion)==null||s.call(e,l));for(const f of Zh)if(Math.hypot(l.x-f.x,l.z-f.z)<f.r){l.in=!0,l.vx=0,l.vz=0,l.pocket=f,(a=e.pocket)==null||a.call(e,l,f);break}}for(let l=0;l<i.length;l++){const c=i[l];if(!c.in)for(let h=l+1;h<i.length;h++){const u=i[h];if(u.in)continue;const d=u.x-c.x,f=u.z-c.z,g=d*d+f*f;if(g>=4*Re*Re||g===0)continue;const _=Math.sqrt(g),p=d/_,m=f/_,y=(2*Re-_)/2;c.x-=p*y,c.z-=m*y,u.x+=p*y,u.z+=m*y;const x=(u.vx-c.vx)*p+(u.vz-c.vz)*m;if(x<0){const S=-1.96*x/2;c.vx-=S*p,c.vz-=S*m,u.vx+=S*p,u.vz+=S*m,(r=e.hit)==null||r.call(e,c,u,-x)}}}}}const sb=i=>i.some(t=>!t.in&&(t.vx||t.vz));class ab{constructor(t){this.players=t,this.balls=ih(),this.turn=0,this.groups=null,this.shots=0,this.winner=null,this.over=null,this.inHand=!0,this.begin()}get cue(){return this.balls[0]}get shooter(){return this.players[this.turn]}get other(){return this.players[1-this.turn]}begin(){this.log={first:null,potted:[],cushion:!1,legal:this.targets().map(t=>t.n)}}targets(t=this.shooter){const e=this.balls.filter(s=>s.n&&!s.in);if(!this.groups)return e.filter(s=>s.n!==8);const n=e.filter(s=>to(s.n)===this.groups[t]);return n.length?n:e.filter(s=>s.n===8)}remaining(t){return this.groups?this.balls.filter(e=>e.n&&!e.in&&to(e.n)===this.groups[t]).length:7}recorder(){return{hit:(t,e)=>{this.log.first===null&&(t.n===0||e.n===0)&&(this.log.first=t.n===0?e.n:t.n)},pocket:t=>this.log.potted.push(t.n),cushion:()=>{this.log.cushion=!0}}}settle(){this.shots++;const{first:t,potted:e}=this.log,n=this.shooter,s=this.shots===1,a=e.includes(0),r=e.includes(8),o=this.log.legal,l={foul:!1,why:"",potted:e.filter(h=>h),continues:!1,assigned:null,eight:r};if(s&&r){const h=this.balls.find(u=>u.n===8);h.in=!1,h.x=Ze/4,h.z=0,h.vx=h.vz=0,e.splice(e.indexOf(8),1),l.eight=!1}if(t===null?(l.foul=!0,l.why="missed everything"):o.includes(t)||(l.foul=!0,l.why=t===8?"hit the eight first":"wrong ball first"),a&&(l.foul=!0,l.why="scratched"),!l.foul&&!s&&!e.length&&!this.log.cushion&&(l.foul=!0,l.why="nothing reached a cushion"),l.eight){const h=this.groups&&o.every(u=>u===8);return h&&!l.foul?this.finish(n,"eight"):this.finish(this.other,h?"foul-eight":"early-eight"),l.over=this.over,l}if(!this.groups&&!l.foul&&!s){const h=e.find(u=>u&&u!==8);if(h){const u=to(h);this.groups={[n]:u,[this.other]:u==="solids"?"stripes":"solids"},l.assigned=u}}if(a){const h=this.cue;h.in=!1,h.vx=h.vz=0}const c=e.filter(h=>h&&h!==8&&(!this.groups||to(h)===this.groups[n]));if(l.continues=!l.foul&&c.length>0,this.inHand=l.foul,l.continues||(this.turn=1-this.turn),this.shots>=80&&!this.winner){const h=this.remaining(this.players[0]),u=this.remaining(this.players[1]);this.finish(h<=u?this.players[0]:this.players[1],"worn-out"),l.over=this.over}return this.begin(),l}finish(t,e){this.winner=t,this.over=e}placeCue(t){const e=this.cue,n=(a,r)=>this.balls.every(o=>o===e||o.in||Math.hypot(o.x-a,o.z-r)>Re*2.4),s=t?[[-Ze/4,0],[-Ze/4,.2],[-Ze/4,-.2]]:[[-Ze/4,0],[-Ze/3,.3],[-Ze/3,-.3],[.3,.3],[.3,-.3],[-.2,.5],[-.2,-.5],[-Ze/2+.3,.2]];for(const[a,r]of s)if(n(a,r)){e.x=a,e.z=r,e.vx=e.vz=0,e.in=!1;return}for(let a=0;a<200;a++){const r=(Math.random()-.5)*(Ze-.4),o=(Math.random()-.5)*(Ri-.4);if(n(r,o)){e.x=r,e.z=o,e.vx=e.vz=0,e.in=!1;return}}}}const Zl=(i,t,e,n,s,a,r)=>{const o=n-t,l=s-e,c=o*o+l*l||1e-9;for(const h of i){if(h.in||a.includes(h))continue;const u=Math.max(0,Math.min(1,((h.x-t)*o+(h.z-e)*l)/c));if(Math.hypot(h.x-(t+u*o),h.z-(e+u*l))<r)return!1}return!0};function rb(i,t=.7){const e=i.balls,n=i.cue,s=i.targets();let a=null;if(i.shots===0){const c=e.find(h=>h.n!==0&&h.x===Math.min(...e.filter(u=>u.n).map(u=>u.x)));a={angle:Math.atan2(c.z-n.z,c.x-n.x),speed:5.6+Math.random()*1.2,target:c,pocket:null,clean:!1,power:"break"}}else{for(const c of s)for(const h of Zh){const u=h.x*.97,d=h.z*.97,f=u-c.x,g=d-c.z,_=Math.hypot(f,g)||1e-9,p=c.x-f/_*2*Re,m=c.z-g/_*2*Re;if(Math.abs(p)>Ze/2-Re||Math.abs(m)>Ri/2-Re)continue;const y=p-n.x,x=m-n.z,S=Math.hypot(y,x);if(S<Re*2)continue;const P=(y*f+x*g)/(S*_);if(P<.34||!Zl(e,n.x,n.z,p,m,[n,c],Re*2*.98)||!Zl(e,c.x,c.z,u,d,[n,c],Re*2*.98))continue;const T=P*2-(S+_)*.35-(c.n===8,0);(!a||T>a.score)&&(a={angle:Math.atan2(x,y),speed:Math.min(Wd*.8,Math.sqrt(2*Dp*(S+_*1.3))+1.1),target:c,pocket:h,clean:!0,score:T})}if(!a){const c=s.length?s:e.filter(f=>f.n&&!f.in),h=c.filter(f=>Zl(e,n.x,n.z,f.x,f.z,[n,f],Re*2*.98)),u=h.length?h:c;u.sort((f,g)=>Math.hypot(f.x-n.x,f.z-n.z)-Math.hypot(g.x-n.x,g.z-n.z));const d=u[0];a={angle:Math.atan2(d.z-n.z,d.x-n.x),speed:2.6+Math.random()*1.2,target:d,pocket:null,clean:!1}}}const r=Math.hypot(a.target.x-n.x,a.target.z-n.z),o=(.006+.026*(1-t))*(.8+r*.35),l=()=>(Math.random()+Math.random()+Math.random()-1.5)*1.4;return a.angle+=l()*o*(a.power==="break"?.6:1),a.speed=Math.min(Wd,Math.max(1.2,a.speed*(1+l()*.06*(1.2-t)))),a}function ob(i,t,e){i.cue.vx=Math.cos(t)*e,i.cue.vz=Math.sin(t)*e}let jn=null,po=null,Do=!1;try{Do=localStorage.getItem("office.muted")==="1"}catch{}function Ip(){if(!jn){const i=window.AudioContext||window.webkitAudioContext;if(!i)return;jn=new i,po=jn.createGain(),po.gain.value=.5,po.connect(jn.destination)}jn.state==="suspended"&&jn.resume()}addEventListener("pointerdown",Ip);addEventListener("keydown",Ip);function Nn(i,t,e,{type:n="sine",gain:s=.2}={}){const a=jn.currentTime+t,r=jn.createOscillator(),o=jn.createGain();r.type=n,r.frequency.setValueAtTime(i,a),o.gain.setValueAtTime(1e-4,a),o.gain.exponentialRampToValueAtTime(s,a+.012),o.gain.exponentialRampToValueAtTime(1e-4,a+e),r.connect(o).connect(po),r.start(a),r.stop(a+e+.05)}const ta=()=>!Do&&jn&&jn.state==="running",un={get muted(){return Do},setMuted(i){Do=i;try{localStorage.setItem("office.muted",i?"1":"0")}catch{}},ship(){ta()&&([659.25,830.61,987.77].forEach((i,t)=>{Nn(i,t*.085,.55,{gain:.16}),Nn(i*2,t*.085,.3,{type:"triangle",gain:.035})}),Nn(1318.5,.26,.9,{gain:.09}))},fail(){ta()&&(Nn(293.66,0,.35,{type:"triangle",gain:.12}),Nn(246.94,.14,.5,{type:"triangle",gain:.12}))},levelUp(){ta()&&[523.25,659.25,783.99,1046.5,1318.5].forEach((i,t)=>Nn(i,t*.07,.7,{gain:.13}))},knock(){ta()&&(Nn(880,0,.09,{gain:.06}),Nn(1174.7,.07,.12,{gain:.05}))},click(i=.5){if(!ta())return;const t=.025+i*.07;Nn(1900+Math.random()*500,0,.035,{type:"triangle",gain:t}),Nn(3100,0,.02,{gain:t*.5})},pocket(){ta()&&(Nn(180,0,.18,{type:"triangle",gain:.09}),Nn(120,.06,.22,{type:"sine",gain:.07}))}},ea=(i,t)=>i+Math.random()*(t-i),ii=i=>i[Math.floor(Math.random()*i.length)],lb=["#f2c230","#2f5fb3","#d6402f","#6a3a9c","#e8803a","#2f8a4f","#8a2a2e"];function cb(i){const t=document.createElement("canvas");t.width=128,t.height=64;const e=t.getContext("2d"),n=i===0?"#f4f1ea":i===8?"#1b1b1f":lb[(i-1)%7];if(e.fillStyle=i>8?"#f4f1ea":n,e.fillRect(0,0,128,64),i>8&&(e.fillStyle=n,e.fillRect(0,14,128,36)),i){e.font="700 17px Inter, system-ui, sans-serif",e.textAlign="center",e.textBaseline="middle";for(const a of[32,96])e.fillStyle="#f4f1ea",e.beginPath(),e.arc(a,32,13,0,Math.PI*2),e.fill(),e.fillStyle="#1b1b1f",e.fillText(String(i),a,33)}const s=new Hi(t);return s.colorSpace=Qe,s}const hb=["corner","corner","corner","corner","side","side"],ub=i=>hb[Zh.indexOf(i)]||"pocket",db=[["Eight ball? Loser buys the coffee.","You are on."],["Quick game of eight ball?","Rack them up."],["Pool table is free. That never happens.","Then we have to."],["Break is yours.","Bold of you to give me the break."]],fb=["Nice.","Smooth.","That one dropped.","Clean.","In."],pb=["So close.","Rolled out.","Unlucky.","The table is tilted."],mb=["Scratch.","Ugh, foul.","The cue ball had other plans."],gb=["Ball in hand.","Your table.","Thank you."],vb=["Here goes.","Let me see this one.","Easy.","Trust the line."],_b=["Good game.","That was fun.","Rematch later?"],xb=["Rematch.","Good game. Coffee is on me.","The table was tilted."];class yb{constructor(t,e){this.spots=e.stations.lounge.spots.filter(r=>r.game),this.root=new Ht,this.root.position.set(qe.x,0,qe.z),t.add(this.root);const n=new di(Re,20,14);this.meshes=[];for(let r=0;r<=15;r++){const o=new yt(n,new Dn({map:cb(r),roughness:.22,metalness:.02}));o.castShadow=!0,o.userData={x:0,z:0,sunk:null},this.root.add(o),this.meshes.push(o)}this.cue=new Ht;const s=new yt(new Hn(.016,.026,1.9,8),xe("#d9b27a"));s.rotation.z=Math.PI/2,s.position.x=-.95,s.castShadow=!0;const a=new yt(new Hn(.016,.016,.04,8),xe("#5b8fb0"));a.rotation.z=Math.PI/2,a.position.x=-.02,this.cue.add(s,a),this.cueOuter=new Ht,this.cueOuter.add(this.cue),this.cue.rotation.z=-.12,this.cueOuter.visible=!1,this.root.add(this.cueOuter),this.resting=ih(),this.view=this.resting,this.next=ea(25,45),this.s=null,this.claiming=!1}get playing(){return!!this.s}update(t,e,n){this.s?this.run(e,n):!this.claiming&&e>=this.next&&this.tryStart(t,e),this.draw(e,n)}tryStart(t,e){const n=o=>!o.gone&&!o.job&&!o.meeting&&!o.leaving&&o.want==="lounge"&&!o.playing&&!o.chatting,s=t.filter(n);if(this.next=e+ea(15,30),s.length<2)return;const a=ii(s),r=ii(s.filter(o=>o!==a));this.claim(a,r,e)}async claim(t,e,n){this.claiming=!0;let s=null;try{({id:s}=await is("/api/chill",{who:[t.id,e.id],game:!0}))}catch{}if(this.claiming=!1,!s)return;const a=r=>!r.gone&&!r.job&&!r.meeting&&!r.leaving&&r.want==="lounge"&&!r.playing&&!r.chatting;if(!a(t)||!a(e))return this.release(s);this.begin(t,e,s,n)}begin(t,e,n,s){const a=[t,e];a.forEach((o,l)=>{const c=this.spots[l];o.spot&&o.spot!==c&&(o.spot.taken=null),o.spot=c,c.taken=o.id,o.playing=!0,o.chatting=!0,o.wanderAt=1/0,o.goTo("lounge",s)});const r=o=>.45+([...o.id].reduce((l,c)=>l*31+c.charCodeAt(0),7)>>>0)%50/100;this.s={id:n,players:a,skill:a.map(r),phase:"walk",deadline:s+60,game:null,plan:null,shots:0}}called(t){return t.gone||t.job||t.meeting||t.leaving||t.want!=="lounge"}run(t,e){const n=this.s;if(n.players.some(o=>this.called(o)))return this.stop(t,!1);for(const o of n.players)o.wanderAt=1/0;t-(n.pinged??0)>30&&(n.pinged=t,is(`/api/chill/${n.id}/ping`,{}).catch(()=>{}));const[s,a]=n.players,r=o=>{var l;return o.placeKey==="lounge"&&!o.path.length&&((l=o.spot)==null?void 0:l.game)};switch(n.phase){case"walk":{if(t>n.deadline)return this.stop(t,!1);if(!r(s)||!r(a))return;n.game=new ab([s.id,a.id]),this.view=n.game.balls;for(const c of this.meshes)c.userData.sunk=null;const[o,l]=ii(db);s.say(o,"idle",3200),n.phase="rack",n.until=t+1.2,n.line=l,n.said=!1,is(`/api/chill/${n.id}/line`,{from:s.id,text:o}).catch(()=>{});return}case"rack":!n.said&&t>n.until-.4&&(a.say(n.line,"idle",2600),n.said=!0),t>n.until&&this.aim(t);return;case"aim":return this.aiming(t);case"roll":{const o=n.rec;if(n.clicks=0,ib(n.game.balls,Math.min(e,.05),o),n.rolled+=e,n.rolled>.3&&(this.cueOuter.visible=!1),sb(n.game.balls)&&n.rolled<22)return;for(const l of n.game.balls)l.vx=0,l.vz=0;return this.settled(t)}case"pause":t>n.until&&this.aim(t);return;case"over":t>n.until&&this.stop(t,!0)}}agentOf(t){return this.s.players.find(e=>e.id===t)}aim(t){const e=this.s,n=e.game,s=this.agentOf(n.shooter),a=this.agentOf(n.other),r=e.players.indexOf(s);n.inHand&&n.placeCue(n.shots===0),e.plan=rb(n,e.skill[r]),e.t0=t,e.dur=ea(1.5,2.2),e.struck=!1,e.phase="aim",e.shooter=s,e.waiter=a;const o=qe.x+n.cue.x,l=qe.z+n.cue.z;s.goal={...s.goal,face:Math.atan2(o-s.pos.x,l-s.pos.z)},a.goal={...a.goal,face:Math.atan2(o-a.pos.x,l-a.pos.z)};const c=e.plan.pocket&&ub(e.plan.pocket),h=c&&Math.random()<.4?e.plan.target.n===8?`Eight ball, ${c} pocket.`:`${c[0].toUpperCase()}${c.slice(1)} pocket.`:Math.random()<.18?ii(vb):"";h&&s.say(h,"idle",2400),this.cueOuter.visible=!0}aiming(t){const e=this.s,n=e.game,s=Math.min(1,(t-e.t0)/e.dur);e.shooter.anim={kind:"cue",until:t+.5},e.waiter.anim={kind:"mug",until:t+.5};const a=s<.55?.07+Math.sin(s*40)*.006:s<.85?.07+((s-.55)/.3)**2*.34:.41*(1-(s-.85)/.15)+.02;this.placeCue(a,e.plan.angle),s>=1&&!e.struck&&(e.struck=!0,ob(n,e.plan.angle,e.plan.speed),un.click(Math.min(1,e.plan.speed/6)),e.rec=this.recorder(n),e.rolled=0,e.clicks=0,e.phase="roll",e.shooter.anim=null)}recorder(t){const e=t.recorder();return{hit:(n,s,a)=>{e.hit(n,s,a),this.s.clicks++<2&&un.click(Math.min(1,a/4))},pocket:(n,s)=>{e.pocket(n,s),un.pocket()},cushion:e.cushion}}settled(t){const e=this.s,n=e.game,s=e.shooter,a=e.waiter,r=n.settle();e.shots++;const o=r.potted.length>0;if(r.over)return this.over(t,r);r.assigned?s.say(`${r.assigned==="solids"?"Solids":"Stripes"} for me.`,"idle",2800):r.foul?(s.say(ii(mb),"warn",2400),Math.random()<.5&&setTimeout(()=>this.s&&a.say(ii(gb),"idle",2200),700)):o&&r.continues?Math.random()<.45&&s.say(ii(fb),"good",2200):Math.random()<.22&&s.say(ii(pb),"idle",2200),e.phase="pause",e.until=t+1.1+(r.foul?.6:0)}over(t,e){const n=this.s,s=n.game,a=this.agentOf(s.winner),r=n.players.find(l=>l!==a),o={eight:`Eight ball down. Good game, ${r.name}.`,"early-eight":`${r.name} dropped the eight early, so that one is mine. Good game.`,"foul-eight":`The eight went in with a foul, ${r.name}. Still a good game.`,"worn-out":`Called it after ${s.shots} shots, fewer balls left. Good game, ${r.name}.`}[s.over];a.say(ii(_b),"good",3600),r.say(ii(xb),"idle",3600),a.anim={kind:"celebrate",until:t+2.2},r.anim={kind:"slump",until:t+1.8},is(`/api/chill/${n.id}/line`,{from:a.id,text:o}).catch(()=>{}),n.phase="over",n.until=t+5}stop(t,e){var s;const n=this.s;if(n){this.release(n.id);for(const a of n.players)a.playing=!1,a.chatting=!1,a.anim=null,(s=a.spot)!=null&&s.game&&(a.spot.taken=null,a.spot=null),!a.gone&&!a.job&&!a.meeting&&a.want==="lounge"?a.wanderAt=t+ea(5,12):a.wanderAt=0;this.cueOuter.visible=!1,this.resting=ih(),this.view=this.resting;for(const a of this.meshes)a.userData.sunk=null;this.s=null,this.next=t+(e?ea(60,150):ea(30,60))}}release(t){is(`/api/chill/${t}`,void 0,"DELETE").catch(()=>{})}placeCue(t,e){const n=this.s.game.cue,s=Math.cos(e),a=Math.sin(e);this.cueOuter.position.set(n.x-s*(Re+t),qe.felt+Re,n.z-a*(Re+t)),this.cueOuter.rotation.y=-e}draw(t,e){const n=qe.felt;for(const s of this.view){const a=this.meshes[s.n],r=a.userData;if(s.in){r.sunk===null&&(r.sunk=t);const h=Math.min(1,(t-r.sunk)/.35),u=s.pocket;a.visible=h<1,a.position.set(s.x+(((u==null?void 0:u.x)??s.x)-s.x)*h,n+Re-h*.22,s.z+(((u==null?void 0:u.z)??s.z)-s.z)*h),a.scale.setScalar(1-h*.5);continue}r.sunk=null,a.visible=!0,a.scale.setScalar(1),a.position.set(s.x,n+Re,s.z);const o=s.x-r.x,l=s.z-r.z,c=Math.hypot(o,l);if(c>1e-5&&c<.5){const h=new C(l,0,-o).normalize();a.quaternion.premultiply(new hs().setFromAxisAngle(h,c/Re))}r.x=s.x,r.z=s.z}}}const Jl=10,qd=["#7c5cff","#0e9f9a","#d9488f","#c98a12","#3b82f6","#65a30d"],Mb=/^#[0-9a-f]{6}$/i,na=(i,t)=>String(i??"").replace(/\s+/g," ").trim().slice(0,t),Ql=(i,t)=>Mb.test(i)?i:t,bb=new Set(["working","idle","break","meeting","away"]);function Sb(i){return Array.isArray(i)?i.filter(t=>t&&typeof t.link=="string"&&t.link).map(t=>({link:na(t.link,80),handle:na(t.handle,40)||"friend",agents:(Array.isArray(t.agents)?t.agents:[]).filter(e=>e&&typeof e.id=="string"&&e.id).map(e=>{var n,s,a;return{id:na(e.id,40),name:na(e.name,40)||"Visitor",role:na(e.role,60),state:bb.has(e.state)?e.state:"idle",look:{shirt:Ql((n=e.look)==null?void 0:n.shirt,"#8a8f9c"),hair:Ql((s=e.look)==null?void 0:s.hair,"#3b2f2a"),skin:Ql((a=e.look)==null?void 0:a.skin,"#c68e63")},job:e.job&&typeof e.job=="object"?{title:na(e.job.title,120)}:null}})})):[]}class wb extends Kh{constructor(t,e,n,s,a,r){const o=Object.hasOwn(Wh,e.id)?e.id:"visitor";super({id:o,name:"",...e.look},s,a,{desk:{seat:s.door.clone(),seatY:0}}),this.key=`${t.link}:${e.id}`,this.id=this.key,this.root.traverse(u=>{u.userData.agentId=this.key,u.userData.visitor=this.key}),this.tint=n,this.chatAt=1/0,this.hangout=Math.random()<.5?"poolside":"coffee";const l=new te(n);this.fig.group.traverse(u=>{var d;!u.isMesh||!((d=u.material)!=null&&d.color)||(u.material=u.material.clone(),u.material.color.lerp(l,.16),u.material.emissive&&(u.material.emissive.copy(l),u.material.emissiveIntensity=.07))}),this.ring.material.color.set(n),this.ring.material.opacity=.6,this.ring.visible=!0,this.label.classList.add("visitor"),this.label.style.setProperty("--tint",n);const c=this.label.querySelector(".name");c.replaceChildren();const h=document.createElement("i");if(h.style.background=n,this.nameEl=document.createElement("span"),this.handleEl=document.createElement("span"),this.handleEl.className="handle",c.append(h,this.nameEl,this.handleEl),this.set(t,e),r){this.teleport(this.want);return}this.teleport("door"),this.say(`Hi from @${t.handle}`,"good",4e3)}set(t,e){this.office=t,this.info=e,this.name=e.name,this.nameEl.textContent!==e.name&&(this.nameEl.textContent=e.name,this.labelDirty=!0),this.handleEl.textContent!==` · @${t.handle}`&&(this.handleEl.textContent=` · @${t.handle}`,this.labelDirty=!0),this.leaving&&(this.leaving=!1,this.say("Forgot something","idle",2500)),this.want=this.place(e.state)}place(t){const e=t==="working"?["hotdesk","huddle",this.hangout]:t==="meeting"?["huddle","hotdesk"]:[this.hangout,this.hangout==="coffee"?"poolside":"coffee","huddle"];return e.find(n=>this.roomAt(n))||e[0]}roomAt(t){return this.world.stations[t].spots.some(e=>!e.game&&(!e.taken||e.taken===this.id))}resolve(t,e){if(t==="desk"){this.spot&&(this.spot.taken=null,this.spot=null);const n=this.world.door.clone().add(new C(1.4+Math.random()*1.8,0,-1.6+Math.random()*.8));return{key:t,pos:n,face:Math.atan2(-n.x,-n.z),pose:"stand"}}return super.resolve(t,e)}leave(){this.leaving||(super.leave(),this.say(`Back to @${this.office.handle}`,"idle",3e3))}dispose(){this.fig.group.traverse(t=>{t.isMesh&&t.material.dispose()}),super.dispose()}}class Eb{constructor({world:t,labels:e,camera:n,canvas:s}){Object.assign(this,{world:t,labels:e,camera:n,canvas:s}),this.on=new Map,this.offices=[],this.tints=new Map,this.list=[],this.first=!0,this.sign=document.createElement("div"),this.sign.className="door-sign",this.sign.hidden=!0,e.appendChild(this.sign),this.card=document.createElement("div"),this.card.className="visitor-card",this.card.hidden=!0,e.appendChild(this.card),this.ray=new xp,s.addEventListener("pointermove",a=>this.hover(a)),s.addEventListener("pointerleave",()=>{this.card.hidden=!0})}handle(t){if(t.t==="visitors")return this.receive(t.offices),!0;if(t.t==="hello"&&Array.isArray(t.visitors)&&this.receive(t.visitors,this.first),t.t==="hello"&&(this.first=!1),t.t==="links"&&Array.isArray(t.links)){const e=new Set(t.links.map(n=>n==null?void 0:n.id));this.receive(this.offices.filter(n=>e.has(n.link)))}return!1}tintOf(t){return this.tints.has(t)||this.tints.set(t,qd[this.tints.size%qd.length]),this.tints.get(t)}receive(t,e=!1){this.offices=Sb(t);const n=new Map,s=this.offices.map(o=>o.agents.filter(l=>l.state!=="away").map(l=>[`${o.link}:${l.id}`,o,l]));for(const o of s)for(const[l,c,h]of o)n.set(l,[c,h]);const a=new Set([...this.on.values()].filter(o=>!o.leaving&&n.has(o.key)).map(o=>o.key).slice(0,Jl));for(let o=0;a.size<Jl&&s.some(l=>l.length>o);o++)for(const l of s)l[o]&&a.size<Jl&&a.add(l[o][0]);for(const o of this.on.values())a.has(o.key)||o.leave();for(const o of a){const[l,c]=n.get(o),h=this.on.get(o);h?h.set(l,c):this.on.set(o,new wb(l,c,this.tintOf(l.link),this.world,this.labels,e))}const r=new Map;for(const[o,[l]]of n)a.has(o)||r.set(l.handle,(r.get(l.handle)||0)+1);this.sign.replaceChildren(...[...r].map(([o,l])=>{const c=document.createElement("div");return c.textContent=`+${l} from @${o}`,c})),this.sign.hidden=!r.size,this.list=[...this.on.values()]}update(t,e){for(const n of this.on.values())n.update(t,e),n.gone&&(n.dispose(),this.on.delete(n.key),this.list=[...this.on.values()])}placeSign(t,e){if(this.sign.hidden)return;const n=this.world.door.clone().setY(2.7).project(this.camera);if(n.z>1){this.sign.style.display="none";return}this.sign.style.display="",this.sign.style.transform=`translate(-50%, -100%) translate(${(n.x*.5+.5)*t}px, ${(-n.y*.5+.5)*e}px)`}hover(t){if(t.buttons||!this.list.length){this.card.hidden=!0;return}const e=this.canvas.getBoundingClientRect();this.ray.setFromCamera(new lt((t.clientX-e.left)/e.width*2-1,-((t.clientY-e.top)/e.height)*2+1),this.camera);const n=this.ray.intersectObjects(this.list.map(o=>o.root),!0)[0],s=n&&this.on.get(n.object.userData.visitor);if(!s){this.card.hidden=!0;return}(this.card.dataset.key!==s.key||this.card.dataset.stamp!==JSON.stringify(s.info))&&this.fillCard(s),this.card.hidden=!1;let a=t.clientX-e.left+14,r=t.clientY-e.top+14;a+this.card.offsetWidth>e.width-8&&(a-=this.card.offsetWidth+28),r+this.card.offsetHeight>e.height-8&&(r-=this.card.offsetHeight+28),this.card.style.transform=`translate(${a}px, ${r}px)`}fillCard(t){var r;const{info:e,office:n}=t;this.card.dataset.key=t.key,this.card.dataset.stamp=JSON.stringify(e),this.card.style.setProperty("--tint",t.tint);const s=(o,l)=>{const c=document.createElement("div");return c.className=o,c.textContent=l,c},a={working:"Working",idle:"Between jobs",break:"On a break",meeting:"In a meeting",away:"Heading home"}[e.state];this.card.replaceChildren(s("vc-who",`${e.name} · @${n.handle}`),s("vc-role",e.role||"Agent"),s("vc-job",((r=e.job)==null?void 0:r.title)||(e.state==="working"?"On a job":"No job right now")),s("vc-state",`${a} · visiting from @${n.handle}`))}}class Tb{constructor(t){this.scene=t,this.bits=[],this.geo=new vi(.14,.09)}burst(t,e){for(let n=0;n<70;n++){const s=new yt(this.geo,new ln({color:e[n%e.length],side:ci,transparent:!0}));s.position.set(t.x,2.4,t.z);const a=Math.random()*Math.PI*2,r=1.5+Math.random()*3;s.userData={v:new C(Math.cos(a)*r,4+Math.random()*4,Math.sin(a)*r),spin:new C(Math.random()*10,Math.random()*10,Math.random()*10),life:2.2+Math.random()*.8},this.scene.add(s),this.bits.push(s)}}update(t){for(let e=this.bits.length-1;e>=0;e--){const n=this.bits[e],s=n.userData;s.life-=t,s.v.y-=9*t,s.v.multiplyScalar(1-t*1.2),n.position.addScaledVector(s.v,t),n.position.y<.02?(n.position.y=.02,s.v.set(0,0,0),n.rotation.set(-Math.PI/2,0,n.rotation.z)):(n.rotation.x+=s.spin.x*t,n.rotation.y+=s.spin.y*t,n.rotation.z+=s.spin.z*t),n.material.opacity=Math.min(1,s.life/.6),s.life<=0&&(this.scene.remove(n),n.material.dispose(),this.bits.splice(e,1))}}}{const i=document.getElementById("app"),t=document.getElementById("side-grip"),e="office.sideWidth",n=320,s=24,a=()=>Math.max(n,Math.min(900,innerWidth-420)),r=u=>i.style.setProperty("--side-w",`${Math.round(Math.min(a(),Math.max(n,u)))}px`),o=Number(localStorage.getItem(e));o&&r(o);const l=()=>t.parentElement.getBoundingClientRect().width,c=()=>localStorage.setItem(e,String(Math.round(l())));t.addEventListener("pointerdown",u=>{t.setPointerCapture(u.pointerId),i.classList.add("resizing"),u.preventDefault()}),t.addEventListener("pointermove",u=>{t.hasPointerCapture(u.pointerId)&&r(u.clientX)});const h=u=>{t.hasPointerCapture(u.pointerId)&&(t.releasePointerCapture(u.pointerId),i.classList.remove("resizing"),c())};t.addEventListener("pointerup",h),t.addEventListener("pointercancel",h),t.addEventListener("dblclick",()=>{i.style.removeProperty("--side-w"),localStorage.removeItem(e)}),t.addEventListener("keydown",u=>{const d=u.key==="ArrowLeft"?-s:u.key==="ArrowRight"?s:0;d&&(u.preventDefault(),r(l()+d),c())})}{const i=document.getElementById("app"),t="office.sideZoom",e=.8,n=1.8,s=r=>(r=Math.round(Math.min(n,Math.max(e,r))*100)/100,i.style.setProperty("--side-zoom",String(r)),r===1?localStorage.removeItem(t):localStorage.setItem(t,String(r)),r);let a=Number(localStorage.getItem(t))||1;s(a),addEventListener("keydown",r=>{if(!(r.ctrlKey||r.metaKey)||r.altKey)return;const o=r.key;if(o==="+"||o==="=")a=s(a+.1);else if(o==="-"||o==="_")a=s(a-.1);else if(o==="0")a=s(1);else return;r.preventDefault()}),document.querySelector(".side").addEventListener("wheel",r=>{r.ctrlKey&&(r.preventDefault(),a=s(a-Math.sign(r.deltaY)*.05))},{passive:!1})}document.getElementById("view");const Io=document.getElementById("stage"),Jh=document.getElementById("labels"),$e=new v1({antialias:!0,alpha:!0});$e.setClearColor(0,0);$e.setPixelRatio(Math.min(devicePixelRatio,2));$e.shadowMap.enabled=!0;$e.shadowMap.type=Lf;$e.toneMapping=bh;$e.toneMappingExposure=1;Io.appendChild($e.domElement);const ni=new up;ni.background=Ab();ni.environment=new Qc($e).fromScene(new gM,.04).texture;ni.environmentIntensity=.55;ni.add(new N1("#fff8ef","#b9ab99",.55));const zi=new z1("#fff0d8",1.75);zi.position.set(re.cx-18,34,20);zi.target.position.set(re.cx,0,0);zi.castShadow=!0;zi.shadow.mapSize.set(4096,4096);Object.assign(zi.shadow.camera,{left:-38,right:38,top:30,bottom:-30,near:1,far:110});zi.shadow.bias=-3e-4;zi.shadow.normalBias=.03;ni.add(zi,zi.target);const Ee=new Rn(30,1,.5,400),Ue={target:new C(re.cx,0,.5),radius:60,phi:.86,theta:Math.PI/4};Ee.position.setFromSpherical(new Aa(Ue.radius,Ue.phi,Ue.theta)).add(Ue.target);const Oe=new mM(Ee,$e.domElement);Oe.target.copy(Ue.target);Object.assign(Oe,{enableDamping:!0,dampingFactor:.09,minPolarAngle:.25,maxPolarAngle:1.22,minDistance:12,maxDistance:260,zoomToCursor:!0,rotateSpeed:.55,zoomSpeed:.9,panSpeed:1.1});const kp=[];for(const i of[re.x0-.3,re.x1+.3])for(const t of[re.z0-.3,re.z1+.3])for(const e of[-.7,3])kp.push(new C(i,e,t));function Np(i,t,e){const n=Ee.aspect<.9?1.7:.93,s=Ee.clone();let a=15,r=260;for(let o=0;o<20;o++){const l=(a+r)/2;s.position.setFromSpherical(new Aa(l,i,t)).add(e),s.lookAt(e),s.updateMatrixWorld(),kp.every(h=>{const u=h.clone().project(s);return Math.abs(u.x)<n&&Math.abs(u.y)<.88})?r=l:a=l}return r}const Ca=new bM($e,new ei(1,1,{type:Fi,samples:4}));Ca.addPass(new SM(ni,Ee));const $o=new ri(ni,Ee,1,1);$o.updateGtaoMaterial({radius:.9,distanceExponent:1.6,thickness:1.5,scale:1.1,samples:16});$o.updatePdMaterial({lumaPhi:10,depthPhi:2,normalPhi:3,radius:6,rings:2,samples:16});$o.blendIntensity=.85;Ca.addPass($o);Ca.addPass(new RM);function Ab(){const i=document.createElement("canvas");i.width=512,i.height=512;const t=i.getContext("2d"),e=t.createRadialGradient(256,190,20,256,230,400);e.addColorStop(0,"#f7f3ec"),e.addColorStop(.6,"#ece5da"),e.addColorStop(1,"#d9d0c2"),t.fillStyle=e,t.fillRect(0,0,512,512);const n=new Hi(i);return n.colorSpace=Qe,n}let ca=1,ha=1,Wo=!1;function Up(){ca=Io.clientWidth,ha=Io.clientHeight,$e.setSize(ca,ha,!1),Ca.setPixelRatio(Math.min(devicePixelRatio,1.5)),Ca.setSize(ca,ha),Ee.aspect=ca/ha,Ee.updateProjectionMatrix(),Wo||(Ue.radius=Np(Ue.phi,Ue.theta,Ue.target),Ee.position.setFromSpherical(new Aa(Ue.radius,Ue.phi,Ue.theta)).add(Ue.target),Oe.target.copy(Ue.target))}new ResizeObserver(Up).observe(Io);Up();const Mn=VM(ni),Op=new Tb(ni),sh={id:"chief",name:"Chief",shirt:"#2b2d42",hair:"#8d8d8d",skin:"#a8714a"},et={staff:[],away:[],remote:[],chiefCost:0,modes:{},progress:null,jobs:new Map,agents:new Map,dismissed:new Set,selected:null,job:i=>et.jobs.get(i),staffName:i=>{const t=et.staff.find(e=>e.id===i);if(t)return t.name;for(const e of et.remote){const n=e.staff.find(s=>s.id===i);if(n)return`${n.name} @${e.host}`}return""},person:i=>{if(i==="you")return{name:"You",color:"#c9c1b4"};if(i==="chief")return{name:"Chief of Staff",color:sh.shirt,look:sh};const t=et.staff.find(e=>e.id===i);return{name:(t==null?void 0:t.name)||i,color:(t==null?void 0:t.shirt)||"#999",look:t}},onFloor:()=>{var i;return et.staff.slice(0,((i=et.progress)==null?void 0:i.capacity)||0).filter(t=>!et.dismissed.has(t.id))},roster:()=>{const i=a=>[...et.jobs.values()].find(r=>r.status==="working"&&r.agentId===a),t=et.onFloor().map(a=>({name:a.name,color:a.shirt,look:a,note:i(a.id)?`on ${i(a.id).repo}`:"free"})),e=a=>a.toLowerCase().replace(/[^a-z0-9]/g,""),n=et.remote.flatMap(a=>a.staff.filter(r=>r.here).map(r=>({s:r,o:a}))),s=a=>t.some(r=>e(r.name)===e(a))||n.filter(({s:r})=>e(r.name)===e(a)).length>1;return[...t,...n.map(({s:a,o:r})=>({name:a.name,color:a.shirt,look:a,host:r.host,insert:s(a.name)?`@${a.name}@${r.host}`:`@${a.name}`,note:`@${r.host} · ${i(a.id)?`on ${i(a.id).repo}`:"free"}`}))]},doer:i=>i.visitor?`${i.visitor.name} from ${i.from}`:et.staffName(i.agentId),busyIn:i=>{const t=[...et.jobs.values()].filter(e=>e.status==="working"&&e.repo===i).map(e=>et.doer(e));return t.length?`${t.join(", ")} here`:""}},Qh={scene:ni,...Mn,agentIndex:i=>et.staff.findIndex(t=>t.id===i)},kt=new J1(et);Sm({toast:(i,t)=>kt.toast(i,t),renderOwner:i=>{Gt.on||kt.renderOwner(i)}});const xn=new Kh(sh,Qh,Jh,{desk:Mn.reception,face:0}),Cb=new eb,Rb=new yb(ni,Mn),mo=new Eb({world:Qh,labels:Jh,camera:Ee,canvas:$e.domElement});xn.want="desk";xn.teleport("desk");et.mergeLog=i=>{const t=et.jobs.get(i.id);t?t.log=i.log:et.jobs.set(i.id,i)};et.applyProfile=(i,t)=>{var n;const e=et.staff.find(s=>s.id===i);e&&(Object.assign(e,t),(n=et.agents.get(i))==null||n.rename(e.name),et.refreshLists(),kt.renderTeam())};Cm(()=>tM(et));et.refreshLists=()=>{const i=[...et.jobs.values()];kt.renderJobs(i,et.staffName),kt.renderStats(i,et.chiefCost),Lp(Mn.board,i)};et.openJob=i=>{kt.openDetail(i);const t=et.jobs.get(i),e=(t==null?void 0:t.status)==="working"&&et.agents.get(t.agentId);e&&(et.select(e.id,!1),Hp())};et.select=(i,t=!0)=>{for(const a of et.agents.values())a.setSelected(a.id===i);if(et.selected=i,i||(ks=!1),!i||!t)return;const e=et.agents.get(i);Hp(),kt.focusInput(`@${e.name} `);const n=[...et.jobs.values()].filter(a=>a.agentId===i),s=n.find(a=>a.status==="working")||n.sort((a,r)=>(r.endedAt||0)-(a.endedAt||0))[0];s&&kt.openDetail(s.id),(s==null?void 0:s.status)!=="working"&&kt.toast(`${e.name} is between jobs. Press N to give them one.`,"",{label:"Send home",run:()=>et.dismiss(e.id)})};et.dismiss=i=>!Gt.on&&kt.post(`/api/staff/${i}/dismiss`);et.recall=i=>!Gt.on&&kt.post(`/api/staff/${i}/recall`);function Fp(i,t){et.onFloor().forEach(e=>{const n=et.agents.get(e.id);if(n){n.leaving&&n.stay();return}const s=new Kh(e,Qh,Jh);et.agents.set(e.id,s),i?s.teleport("lounge"):(s.teleport("door"),s.say(t||`Hi, I'm ${e.name}!`,"good",5e3))})}function jd(i,t){et.dismissed=new Set(i||[]);for(const e of et.agents.values())!et.dismissed.has(e.id)||e.leaving||e.job||(t?e.gone=!0:e.leave());Fp(t,"Back in!"),kt.renderAway(et.staff.filter(e=>et.dismissed.has(e.id))),kt.renderTeam()}function Pb(i){var t,e;for(const n of et.agents.values()){const s=[...et.jobs.values()].find(a=>a.status==="working"&&a.agentId===n.id);s&&((t=n.job)==null?void 0:t.id)!==s.id?(n.assign(s,i),s.log.forEach(a=>n.onLog(a))):!s&&n.job&&n.finish(((e=et.jobs.get(n.job.id))==null?void 0:e.status)||"stopped")}}function Yd(i=[],t=!1){const e=Mn.standup;xn.meet(e[0],t),i.forEach((n,s)=>{var a;return(a=et.agents.get(n))==null?void 0:a.meet(e[1+Math.round(s*(e.length-2)/Math.max(1,i.length-1))],t)}),et.standupOn=!0,document.getElementById("standup").disabled=!0}function Kd(){xn.adjourn();for(const i of et.agents.values())i.adjourn();et.standupOn=!1,document.getElementById("standup").disabled=!1}let eo=!0;function ah(){const i=Gt.on?`/ws/visit/${encodeURIComponent(Gt.link)}`:"/ws",t=new WebSocket(`${location.protocol==="https:"?"wss":"ws"}://${location.host}${i}`);t.onmessage=e=>Lb(JSON.parse(e.data)),t.onclose=e=>{const n=ym(e.code);if(n!=null){n&&setTimeout(ah,n);return}kt.toast("Lost the office line. Reconnecting…","bad"),setTimeout(ah,1500)}}function Lb(i){var t,e,n,s,a,r,o,l;if(!mo.handle(i)){if(i.t==="hello"){vm(i.visiting),et.staff=i.staff,i.visiting||kt.renderOwner(i.owner),et.voice=i.voice,yn=i.tts||yn,Ma(),et.modes=xm(i.modes),et.progress=i.progress,et.chiefCost=i.chiefCost||0,et.jobs=new Map(i.jobs.map(h=>[h.id,h])),et.remote=i.remote||[],et.away=i.away||[],kt.renderChannels(i.channels||[{id:"general",name:"general"}]),kt.renderChat(i.chat||[]),kt.chiefBusy(i.chiefBusy),jd(i.dismissed,eo),Pb(eo),i.standup?Yd(i.standup.who,eo):et.standupOn&&Kd(),eo=!1,kt.renderLevel(et.progress),kt.renderUsage(i.usage),ic(i.auth),Jo(i.contextLimit),i.visiting||pu(i),vu(i.leaderboard),As(i.links),kt.renderProc(i.procs,i.machine),et.refreshLists();const c=Ob();nh(Mn.scribble,c),kt.openId&&(et.jobs.has(kt.openId)?kt.openDetail(kt.openId):kt.closeDetail())}else if(i.t==="job"){const c=et.jobs.get(i.job.id),h={...i.job,log:(c==null?void 0:c.log)||[]};if(et.jobs.set(h.id,h),h.status==="working"){const u=et.agents.get(h.agentId);u&&((t=u.job)==null?void 0:t.id)!==h.id?u.assign(h):u&&(u.job=h)}else for(const u of et.agents.values()){if(((e=u.job)==null?void 0:e.id)!==h.id)continue;const d=h.status==="done"&&!h.awaitingBoss;u.finish(d?"done":h.awaitingBoss?"waiting":h.status),d&&Op.burst(u.pos,[u.staff.shirt,"#f2cc8f","#81b29a","#3d7ea6","#ffffff"]),d&&(un.ship(),tc(`${u.name} shipped`,h.title)),h.status==="failed"&&(un.fail(),tc(`${u.name} hit a wall`,h.title))}(c==null?void 0:c.status)!==h.status?(kt.openId===h.id&&kt.renderDetail(),h.awaitingBoss&&(c==null?void 0:c.status)==="working"?kt.toast(`${et.doer(h)} is waiting on you: “${h.title}”`,"warn"):h.status==="done"&&(c==null?void 0:c.status)==="working"&&kt.toast(`${et.doer(h)} shipped “${h.title}”`,"good"),h.status==="failed"&&(c==null?void 0:c.status)==="working"&&kt.toast(`${et.doer(h)} hit a wall on “${h.title}”`,"bad")):kt.openId===h.id&&((c==null?void 0:c.applied)!==h.applied||(c==null?void 0:c.discarded)!==h.discarded)?kt.renderDetail():kt.openId===h.id&&((n=c==null?void 0:c.changes)==null?void 0:n.end)!==((s=h.changes)==null?void 0:s.end)&&kt.renderChanges(h),et.refreshLists()}else if(i.t==="log"){const c=et.jobs.get(i.jobId);if(!c)return;c.log.push(i.entry),c.log.length>600&&c.log.shift();for(const h of et.agents.values())((a=h.job)==null?void 0:a.id)===c.id&&h.onLog(i.entry);i.entry.todos&&nh(Mn.scribble,i.entry.todos),kt.appendLog(c.id,i.entry)}else if(i.t==="remote")et.remote=i.offices||[],et.away=i.away||[],et.refreshLists();else if(i.t==="channels")kt.renderChannels(i.channels);else if(i.t==="chat"){kt.addMessage(i.msg);const c=et.agents.get(i.msg.from),h=et.agents.get(i.msg.to);if(c&&h&&(c.visit(h,i.msg.text),un.knock()),Ub(i.msg),i.msg.kind==="flag"&&(un.knock(),tc("The boss is needed",i.msg.text.replace(/\*\*/g,""))),i.msg.kind==="standup"){const u=i.msg.say||i.msg.text;(r=i.msg.from==="chief"?xn:c)==null||r.speak(u.length>90?u.slice(0,89)+"…":u)}else i.msg.from==="chief"&&(xn.job=null,xn.say(i.msg.text.length>90?i.msg.text.slice(0,89)+"…":i.msg.text,"",6e3))}else if(i.t==="forget")kt.forget(i.ids);else if(i.t==="voice"){const c=kt.addVoice(i.id,i.file);c&&yn.replies&&!si.active&&!document.hidden&&c.play().catch(()=>{})}else if(i.t==="tts")yn={...yn,...i},Ma();else if(i.t==="react")kt.setReactions(i.id,i.reactions);else if(i.t==="standup")i.phase==="start"?(Yd(i.who),kt.banner("Standup","Everyone to the whiteboard."),un.knock()):Kd();else if(i.t==="chief")kt.chiefBusy(i.busy),i.busy?(xn.job={id:"routing"},xn.say("Reading your message…","thinking")):xn.job=null,i.cost!==void 0&&(et.chiefCost=i.cost,et.refreshLists());else if(i.t==="staff")jd(i.dismissed,!1);else if(i.t==="profile")et.applyProfile(i.id,i.profile);else if(i.t==="auth")ic(i.auth);else if(i.t==="contextLimit")Jo(i.contextLimit);else if(i.t==="settings")Jo(i.contextLimit),pu(i);else if(i.t==="leaderboard")vu(i.leaderboard);else if(i.t==="links")As(i);else if(i.t==="usage")kt.renderUsage(i.usage);else if(i.t==="proc")kt.renderProc(i.procs,i.machine);else if(i.t==="xp"){et.progress=i.progress,kt.renderLevel(et.progress);const c=et.agents.get(i.agentId);if(c){const h=document.createElement("span");h.className="xpfloat",h.textContent=`+${i.gained} XP`,c.label.appendChild(h),setTimeout(()=>h.remove(),1800)}if(i.levelUp){setTimeout(()=>un.levelUp(),700);const h=(o=et.staff[et.progress.capacity-1])==null?void 0:o.name,u=!et.agents.has((l=et.staff[et.progress.capacity-1])==null?void 0:l.id);kt.banner(`Level ${et.progress.level}`,u?`${h} just joined the office.`:"The office is fully staffed."),Fp(!1)}}}}let rh=0;function tc(i,t){if(document.hidden){rh++,document.title=`(${rh}) Agent Office`;try{"Notification"in window&&Notification.permission==="granted"&&new Notification(i,{body:t,silent:!0})}catch{}}}document.addEventListener("visibilitychange",()=>{document.hidden||(rh=0,document.title="Agent Office")});document.getElementById("composer").addEventListener("submit",()=>{try{"Notification"in window&&Notification.permission==="default"&&Notification.requestPermission()}catch{}},{once:!0});const Db='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M11 5 6 9H3v6h3l5 4V5Z"/><path d="M15.5 8.5a5 5 0 0 1 0 7"/><path d="M18.5 5.5a9 9 0 0 1 0 13"/></svg>',Ib='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M11 5 6 9H3v6h3l5 4V5Z"/><path d="m22 9-6 6"/><path d="m16 9 6 6"/></svg>',go=document.getElementById("sound");function zp(){go.innerHTML=un.muted?Ib:Db;const i=un.muted?"Sound off":"Sound on";go.title=i,go.setAttribute("aria-label",i)}go.onclick=()=>{un.setMuted(!un.muted),zp(),un.muted||un.ship()};zp();const kb='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3a3 3 0 0 1 3 3v5a3 3 0 0 1-6 0V6a3 3 0 0 1 3-3z"/><path d="M5 11a7 7 0 0 0 14 0"/><path d="M12 18v3"/></svg>',Nb='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M9 9V6a3 3 0 0 1 5.6-1.5M15 11a3 3 0 0 1-4.5 2.6"/><path d="M5 11a7 7 0 0 0 11 5.7M19 11v0"/><path d="M12 18v3"/><path d="m3 3 18 18"/></svg>',ua=document.getElementById("speak");let yn={ok:!1,replies:!1};const Bp=()=>yn.ok?yn.replies:hi.on;function Ma(){const i=Bp();ua.innerHTML=i?kb:Nb,ua.classList.toggle("on",i);const t=i?yn.ok?"Agents reply with voice notes":"Replies read aloud":"Replies are silent";ua.title=t,ua.setAttribute("aria-label",t)}hi.supported||(ua.hidden=!0);ua.onclick=async()=>{const i=!Bp();if(!yn.ok){hi.setOn(i),Ma(),i&&hi.speak("Voice on. I will read replies out as they land.","chief",{force:!0});return}yn={...yn,replies:i},Ma();try{const t=await fetch("/api/voice/replies",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({on:i})});if(!t.ok)throw new Error((await t.json().catch(()=>({}))).error||`Request failed (${t.status})`)}catch(t){yn={...yn,replies:!i},Ma(),kt.toast(t.message,"bad")}};Ma();function Ub(i){yn.ok||!hi.on||i.from==="you"||i.to||i.kind==="chill"||si.active||hi.speak(i.text,i.from)}function Ob(){let i=null;for(const t of et.jobs.values())for(const e of t.log)e.todos&&(!i||e.ts>i.ts)&&(i=e);return(i==null?void 0:i.todos)||[]}const _n=new Aa,Fb=i=>i<.5?4*i*i*i:1-(-2*i+2)**3/2;let Se=null,ks=!1;function Hp(){ks=!0,Se=null,Wo=!0}function tu({target:i,radius:t,phi:e,theta:n},s=.7){_n.setFromVector3(Ee.position.clone().sub(Oe.target)),Se={t:0,dur:s,target0:Oe.target.clone(),target1:(i||Oe.target).clone().setY(0),r0:_n.radius,r1:t??_n.radius,p0:_n.phi,p1:e??_n.phi,th0:_n.theta,th1:n??_n.theta}}function ko(i){Wo=!0,_n.setFromVector3(Ee.position.clone().sub(Oe.target));const t=Se?Se.th1:_n.theta;tu({theta:t+i*Math.PI/4,target:Se==null?void 0:Se.target1},.55)}function Vp(){ks=!1,_n.setFromVector3(Ee.position.clone().sub(Oe.target));let i=Ue.theta;for(;i-_n.theta>Math.PI;)i-=Math.PI*2;for(;_n.theta-i>Math.PI;)i+=Math.PI*2;tu({target:Ue.target,radius:Np(Ue.phi,i,Ue.target),phi:Ue.phi,theta:i},.9)}Oe.addEventListener("start",()=>{Wo=!0,Se=null,ks=!1,setTimeout(()=>{var i;return(i=document.querySelector(".hint"))==null?void 0:i.classList.add("gone")},5e3)});document.getElementById("turnLeft").onclick=()=>ko(-1);document.getElementById("turnRight").onclick=()=>ko(1);document.getElementById("recenter").onclick=()=>Vp();document.getElementById("standup").onclick=()=>kt.post("/api/standup");const ss=new Set;addEventListener("keydown",i=>{var e;if(/INPUT|TEXTAREA|SELECT/.test((e=document.activeElement)==null?void 0:e.tagName)||i.metaKey||i.ctrlKey)return;const t=i.key.toLowerCase();t==="q"?ko(-1):t==="e"?ko(1):t==="r"?Vp():"wasd".includes(t)&&t.length===1&&(ss.add(t),Se=null,ks=!1)});addEventListener("keyup",i=>ss.delete(i.key.toLowerCase()));addEventListener("blur",()=>ss.clear());const no=new C,ec=new C,qn=new C;function zb(i){if(Se){Se.t=Math.min(1,Se.t+i/Se.dur);const n=Fb(Se.t),s=Se.target0.clone().lerp(Se.target1,n);_n.set(aa.lerp(Se.r0,Se.r1,n),aa.lerp(Se.p0,Se.p1,n),aa.lerp(Se.th0,Se.th1,n)),Oe.target.copy(s),Ee.position.setFromSpherical(_n).add(s),Se.t>=1&&(Se=null)}qn.set(0,0,0);const t=ks&&et.agents.get(et.selected);if(t&&qn.set(t.pos.x-Oe.target.x,0,t.pos.z-Oe.target.z).multiplyScalar(Math.min(1,i*3)),ss.size){no.subVectors(Oe.target,Ee.position).setY(0).normalize(),ec.crossVectors(no,Ee.up).normalize();const n=.45*Ee.position.distanceTo(Oe.target)*i;ss.has("w")&&qn.addScaledVector(no,n),ss.has("s")&&qn.addScaledVector(no,-n),ss.has("d")&&qn.addScaledVector(ec,n),ss.has("a")&&qn.addScaledVector(ec,-n)}Oe.target.add(qn),Ee.position.add(qn),Oe.update();const e=Oe.target;qn.set(aa.clamp(e.x,re.x0+1,re.x1-1)-e.x,-e.y,aa.clamp(e.z,re.z0+1,re.z1-1)-e.z),e.add(qn),Ee.position.add(qn)}const Xo=new xp,Zd=new lt;function eu(i){const t=$e.domElement.getBoundingClientRect();Zd.set((i.clientX-t.left)/t.width*2-1,-((i.clientY-t.top)/t.height)*2+1),Xo.setFromCamera(Zd,Ee)}const Gp=()=>[...et.agents.values(),xn].map(i=>i.root);let vo=null;$e.domElement.addEventListener("pointerdown",i=>{vo=[i.clientX,i.clientY]});$e.domElement.addEventListener("pointerup",i=>{if(!vo||Math.hypot(i.clientX-vo[0],i.clientY-vo[1])>5||i.button!==0)return;eu(i);const t=Xo.intersectObjects(Gp(),!0)[0];t&&(t.object.userData.agentId==="chief"?(kt.focusInput(),xn.say("Tell me what you need.","",3e3)):et.select(t.object.userData.agentId))});$e.domElement.addEventListener("dblclick",i=>{eu(i);const t=Xo.intersectObject(Mn.slab,!1)[0];t&&(ks=!1,tu({target:t.point,radius:Math.min(Ee.position.distanceTo(Oe.target),34)},.8))});$e.domElement.addEventListener("contextmenu",i=>i.preventDefault());$e.domElement.addEventListener("pointermove",i=>{i.buttons||(eu(i),$e.domElement.style.cursor=Xo.intersectObjects(Gp(),!0).length?"pointer":"")});const Jd=new _p;let Qd=0,tf=0;function Bb(i){Mn.desks.forEach((t,e)=>{const n=et.staff[e],s=n&&et.agents.get(n.id),a=!s&&n&&et.dismissed.has(n.id),r=s!=null&&s.job?"working":s?"break":a?"away":"open",o=r!=="open",l=`${(n==null?void 0:n.name)||""} ${r}`;if(t.plateKey!==l&&(t.plateKey=l,Rp(t,{name:o?n.name:"Open desk",accent:o?n.shirt:"#7d8a9c",state:r})),s!=null&&s.job){Bd(t,{title:s.job.repo,subtitle:s.job.title,lines:s.lines,accent:n.shirt,t:i}),t.idleKey=null;return}const c=s?`${n.name}`:a?`away ${n.name}`:"open";if(t.idleKey===c)return;t.idleKey=c;const h=et.progress?e-1:0;Bd(t,s?{idle:!0,title:n.name,subtitle:"on a break"}:a?{idle:!0,title:n.name,subtitle:"gone home"}:{idle:!0,title:"Open desk",subtitle:`hires at level ${h}`})})}let ef=!1;function $p(){const i=Math.min(Jd.getDelta(),.05),t=Jd.elapsedTime;zb(i),Mn.updateWalls(Ee,Oe.target,i);for(const s of et.agents.values())s.update(i,t),s.gone&&(s.dispose(),et.agents.delete(s.id),et.selected===s.id&&et.select(null));if(Cb.update([...et.agents.values()],t),Rb.update([...et.agents.values()],t,i),xn.update(i,t),mo.update(i,t),Op.update(i),Mn.globe.rotation.y+=i*.4,(Qd-=i)<=0&&(Qd=.4,Bb(t)),(tf-=i)<=0){tf=.15;for(const s of Mn.blinkers)Math.random()<.25&&(s.material.emissiveIntensity=Math.random()<.5?.15:1.4)}Ca.render(i);const e=Ee.position.distanceTo(Oe.target)>Ue.radius*1.25,n=[];for(const s of[...et.agents.values(),xn,...mo.list])e!==ef&&(s.label.classList.toggle("far",e),s.labelDirty=!0),s.placeLabel(Ee,ca,ha),s.onScreen&&n.push(s);Vb(n,i,t),mo.placeSign(ca,ha),ef=e,requestAnimationFrame($p)}const Hb=4,nf=(i,t)=>i.left<t.right-1&&i.right>t.left+1&&i.top<t.bottom-1&&i.bottom>t.top+1;function Vb(i,t,e){const n=[],s=a=>a.id===et.selected?-1:a.depth;for(const a of[...i].sort((r,o)=>s(r)-s(o))){let r=0,o=!1;for(let h=0;h<2;h++){const u=Math.max(0,Math.min(o?140:80,a.anchorY-a.labelH-6));r=0;for(let d=0;d<10&&r<=u;d++){const f=a.labelBox(r),g=n.find(_=>nf(_,f));if(!g)break;r+=f.bottom-g.top+Hb}if(r<=u||o){r=Math.min(r,u);break}o=!0,a.setCrowded(!0,e)}o||a.setCrowded(!1,e),a.setLift(r,t);const l=a.labelBox(a.lift),c=n.some(h=>nf(h,l));a.setBuried(c),c||n.push(l)}}Lp(Mn.board,[]);nh(Mn.scribble,[]);ah();$p();