diff --git "a/assets/index-BGsg45ec.js" "b/assets/index-BGsg45ec.js" new file mode 100644--- /dev/null +++ "b/assets/index-BGsg45ec.js" @@ -0,0 +1,536 @@ +var Ma=Object.defineProperty;var Sa=(t,e,n)=>e in t?Ma(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Ri=(t,e,n)=>Sa(t,typeof e!="symbol"?e+"":e,n);import{E as Ia,V as Ra,a as Ca,c as Na,r as La,b as Pr,d as Pa,e as Ci,f as Oa,g as Da,h as Fa,s as za,i as Ba,j as Ua}from"./live2d-zip-loader-ZcjvsZqp.js";import{f as qn,g as X,h as Ue,i as Dt,t as ja,d as Fe,j as Va,k as Ha,l as ti,w as je,m as dn,c as ie,o as ee,p as gn,q as Ga,s as rt,v as pn,x as Xt,y as Be,b as Te,a as O,z as Ct,A as At,B as ni,C as it,D as me,e as H,M as gt,T as kt,E as ri,F as Yn,G as Jo,Z as Fn,H as Ft,I as $a,V as se,S as Ni,Q as zn,O as $t,J as Pe,P as _t,K as qa,L as es,N as hn,U as ii,W as ze,X as ts,Y as ns,_ as oi,$ as yn,a0 as Ya,a1 as si,a2 as Ka,a3 as rs,a4 as yt,a5 as ai,a6 as Et,a7 as Wa,a8 as is,a9 as Ot,aa as os,ab as Xa,ac as Qa,ad as Za,ae as Ja,af as ss,ag as Kn,ah as el,ai as tl,aj as nl,ak as Pt,al as rl,am as il,an as ol,ao as sl,ap as tr,aq as Bn,ar as Or,as as Nt,at as as,au as Dr,av as Ht,aw as Li,ax as Lt,ay as Gt,az as nr,aA as al,aB as ll,aC as ul,aD as cl,aE as ls,aF as us,aG as Un,aH as cs,aI as li,aJ as jn,aK as fs,aL as fl,n as Fr,aM as dl,aN as zr,aO as ds,aP as pl,aQ as un,aR as ps,aS as ct,aT as xt,aU as mn,aV as hl,aW as ml,aX as gl,aY as yl,aZ as xl,a_ as ui,a$ as vl,b0 as bl,b1 as wl,b2 as rr,b3 as Tl,b4 as hs,b5 as kl,b6 as Al,b7 as _l,b8 as El,b9 as Ml,ba as ir,bb as Sl,bc as Il,bd as Rl,be as Pi,bf as Oi,bg as Di,bh as Fi,bi as Cl,bj as Nl,bk as Ll,bl as Pl,bm as Ol,bn as Wn,bo as Dl,bp as ms,bq as Fl,br as zl,bs as Bl,bt as Ul,bu as gs,bv as Vn,bw as ys,bx as ci,by as fi,bz as jl,bA as or,bB as Vl,bC as Hl}from"./index-Ckx1uYwx.js";import{u as Gl,g as $l}from"./index-GillZCtH.js";import{u as sr}from"./queue-LF_zCIza.js";import{u as ql,a as Yl,b as Kl,l as Wl,_ as xs}from"./queues-J7yDZv_k.js";import{r as Xl,a as Ql,b as Zl,c as Jl,l as eu,u as di}from"./providers-CUoH-bBv.js";import{_ as tu,a as nu,r as rn}from"./Model.vue_vue_type_script_setup_true_lang-CyW07Gj2.js";import{_ as pi}from"./TransitionVertical.vue_vue_type_script_setup_true_lang-I4AokXMb.js";import{_ as zi}from"./Collapsable.vue_vue_type_script_setup_true_lang-BxZutolL.js";import{H as ru}from"./HeaderLink-BYfFL6Od.js";import{u as vs}from"./consciousness-V6fneqCL.js";import{d as Bi}from"./index-DRlqiHyy.js";import{b as Ui}from"./route-block-B_A1xBdJ.js";async function*iu(t,e){const n=t.getReader();try{for(;;){const{done:r,value:i}=await n.read();if(r)return;yield e(i)}}finally{n.releaseLock()}}function ou(t){const e=new Uint8Array(t.frequencyBinCount);t.getByteFrequencyData(e);const n=[];for(let i=0;i<700;i+=80)n.push(e[i]);return e.map(i=>i**1.2).map(i=>i*1.2).reduce((i,o)=>i+o,0)/e.length/100}function su(t){const e=new Uint8Array(t.frequencyBinCount);t.getByteFrequencyData(e);const n=[];for(let u=0;u<700;u+=80)n.push(e[u]);const r=e.map(u=>u**1.5),i=Math.min(...r),s=Math.max(...r)-i;let a;return s===0?a=r.map(()=>0):a=r.map(u=>(u-i)/s),a.reduce((u,c)=>u+c,0)/e.length}function au(t,e="linear"){switch(e){case"linear":return ou(t);case"minmax":return su(t)}}const bs=qn("AudioContext",()=>({audioContext:new AudioContext,calculateVolume:au})),lu=qn("SpeakingStore",()=>{const n=X(0),r=X(!1),i=Ue(()=>r.value?(30+70*n.value)/100:30);return{mouthOpenSize:n,nowSpeaking:r,nowSpeakingAvatarBorderOpacity:i}});function An(t,e,n){return e+n<0||e+n>=t.length-1?"":t[e+n]}function uu(t){let e="literal",n="";return{async consume(r){var i,o,s;for(let a=0;a"?(l+=An(r,a,1),u="literal",a++):l==="<"?u="special":l===">"&&(u="literal"),e==="literal"&&u==="special"?n!==""&&(await((i=t.onLiteral)==null?void 0:i.call(t,n)),n=""):e==="special"&&u==="literal"&&n!==""&&(n+=l,await((o=t.onSpecial)==null?void 0:o.call(t,n)),n=""),e==="literal"&&u==="literal"?(await((s=t.onLiteral)==null?void 0:s.call(t,l)),n=""):e==="special"&&u==="literal"?n="":n+=l,e=u}},async end(){var r,i;n!==""&&(e==="literal"?await((r=t.onLiteral)==null?void 0:r.call(t,n)):n.endsWith("|>")&&await((i=t.onSpecial)==null?void 0:i.call(t,n)))}}}function cu(t,e){return{role:"system",content:[t,Ia.map(n=>`- ${n}`).join(` +`),e].join(` + +`)}}var fu=async t=>{var e;return(t.fetch??globalThis.fetch)(Xl("chat/completions",t.baseURL),{body:Zl({...t,tools:(e=t.tools)==null?void 0:e.map(n=>({function:n.function,type:"function"}))}),headers:Ql({"Content-Type":"application/json",...t.headers},t.apiKey),method:"POST",signal:t.abortSignal}).then(Jl)},du=({finishReason:t,maxSteps:e,stepsLength:n,toolCallsLength:r})=>{if(n===0)return"initial";if(n0&&t==="tool_calls")return"tool-result";if(!["error","length"].includes(t))return"continue"}return"done"},pu=t=>typeof t=="string"||Array.isArray(t)&&t.every(e=>!!(typeof e=="object"&&"type"in e&&["audio","image","text"].includes(e.type)))?t:JSON.stringify(t),hu=async({abortSignal:t,messages:e,toolCall:n,tools:r})=>{const i=r==null?void 0:r.find(a=>a.function.name===n.function.name);if(!i){const a=r==null?void 0:r.map(u=>u.function.name),l=a==null||a.length===0?"No tools are available.":`Available tools: ${a.join(", ")}.`;throw new Error(`Model tried to call unavailable tool '${n.function.name}. ${l}.`)}const o=JSON.parse(n.function.arguments),s=pu(await i.execute(o,{abortSignal:t,messages:e,toolCallId:n.id}));return{parsedArgs:o,result:s,toolName:n.function.name}},ar=class extends Error{constructor(e,n){super(e);Ri(this,"response");this.name="XSAIError",this.response=n}},ji="data:",mu=t=>{if(!t||!t.startsWith(ji))return[void 0,!1];const e=t.slice(ji.length),n=e.startsWith(" ")?e.slice(1):e;if(n==="[DONE]")return[void 0,!0];if(n.startsWith("{")&&n.includes('"error":'))throw new Error(`Error from server: ${n}`);return[JSON.parse(n),!1]},gu=async t=>{let e,n,r;const i=new ReadableStream({start(p){e=p}}),o=new ReadableStream({start(p){n=p}}),s=new ReadableStream({start(p){r=p}}),a=t.maxSteps??1,l=new TextDecoder,u=[],c=async p=>{var I,A,R;const d={choices:[],finishReason:"error",messages:structuredClone(p.messages),stepType:"initial",toolCalls:[],toolResults:[]},b={};let x="",v=!0;const T=(P,h)=>{if(P.endedToolCallIDs.has(h))return;const M=d.choices[P.index].message.tool_calls[h];try{M.function.parsed_arguments=JSON.parse(M.function.arguments)}catch(y){P.toolCallErrors[h]=y}P.endedToolCallIDs.add(h),P.currentToolID=null};if(await fu({...p,stream:!0}).then(async P=>P.body.pipeThrough(new TransformStream({transform:async(h,M)=>{const y=l.decode(h,{stream:!0});x+=y;const g=x.split(` +`);x=g.pop()??"";for(const m of g)try{const[k,_]=mu(m);if(_)break;k&&M.enqueue(k)}catch(k){M.error(k)}}})).pipeTo(new WritableStream({abort:h=>{e.error(h),n.error(h),r.error(h)},write:async h=>{var K,E,te;(K=p.onChunk)==null||K.call(p,h),e.enqueue(h);const M=h.choices[0];if(!M)throw new ar("no choice found");M.delta.tool_calls&&(v=!1);const{delta:y,finish_reason:g,index:m,...k}=M,_=(E=d.choices)[m]??(E[m]={finish_reason:g,index:m,message:{role:"assistant"}});if(g!==void 0){if(d.finishReason=g,_.finish_reason=g,g==="length")throw new ar("length exceeded");if(g==="content_filter")throw new ar("content filter")}Object.assign(_,k);const{content:F,refusal:j,tool_calls:D,...z}=y,Q=_.message;Object.assign(Q,z),j!==void 0&&(Q.refusal=(Q.refusal||"")+j),F!==void 0&&(Q.content=(Q.content||"")+F,v&&(r==null||r.enqueue(F)));for(const{function:ge,id:C,type:de}of D||[]){Q.tool_calls??(Q.tool_calls={});const ke=(te=Q.tool_calls)[C]??(te[C]={function:{arguments:"",name:ge.name,parsed_arguments:{}},id:C,type:de});ke.function.arguments+=ge.arguments}const Z=b[m]??(b[m]={calledToolCallIDs:new Set,currentToolID:null,endedToolCallIDs:new Set,index:m,toolCallErrors:{},toolCallResults:{}});g&&Z.currentToolID!==null&&T(Z,Z.currentToolID);for(const ge of y.tool_calls||[])Z.currentToolID!==null&&Z.currentToolID!==ge.id&&T(Z,Z.currentToolID),Z.calledToolCallIDs.add(ge.id),Z.currentToolID=ge.id}}))),d.messages.push({content:((I=d.choices[0])==null?void 0:I.message.content)??"",refusal:(A=d.choices[0])==null?void 0:A.message.refusal,role:"assistant"}),await Promise.allSettled(d.choices.map(async P=>{const h=b[P.index];return Promise.allSettled([...h.endedToolCallIDs].map(async M=>{const y=P.message.tool_calls[M];if(d.toolCalls.push({args:y.function.arguments,toolCallId:M,toolCallType:"function",toolName:y.function.name}),!h.toolCallResults[M])try{const{result:g}=await hu({abortSignal:p.abortSignal,messages:p.messages,toolCall:y,tools:p.tools});h.toolCallResults[M]=g,d.messages.push({content:g,role:"tool",tool_call_id:M}),d.toolResults.push({args:y.function.parsed_arguments,result:g,toolCallId:M,toolName:y.function.name})}catch(g){h.toolCallErrors[M]=g}}))})),d.stepType=du({finishReason:d.finishReason,maxSteps:a,stepsLength:u.length,toolCallsLength:d.toolCalls.length}),u.push(d),n.enqueue(d),(R=p.onStepFinish)==null||R.call(p,d),!v)return async()=>c({...p,messages:d.messages})};return(async()=>{var d;let p=await c(t);for(;typeof p=="function"&&u.length{e.error(p),n.error(p),r.error(p)}),Promise.resolve({chunkStream:i,stepStream:o,textStream:s})};const yu=qn("llm",()=>{async function t(n,r,i,o){const s=o==null?void 0:o.headers;return await gu({...r.chat(n),messages:i,streamOptions:{usage:!0},headers:s})}async function e(n,r){if(n==="")return[];try{return await eu({baseURL:n.endsWith("/")?n:`${n}/`,apiKey:r})}catch(i){if(String(i).includes("Failed to construct 'URL': Invalid URL"))return[];throw i}}return{models:e,stream:t}}),Mt=qn("chat",()=>{const{stream:t}=yu(),{t:e}=Dt(),n=X(!1),r=X([]),i=X([]),o=X([]),s=X([]),a=X([]),l=X([]),u=X([]),c=X([]);function f(h){r.value.push(h)}function p(h){i.value.push(h)}function d(h){o.value.push(h)}function b(h){s.value.push(h)}function x(h){a.value.push(h)}function v(h){l.value.push(h)}function T(h){u.value.push(h)}function I(h){c.value.push(h)}const A=X([cu(e("prompt.prefix"),e("prompt.suffix"))]),R=X({role:"assistant",content:""});async function P(h,M){var y;try{if(n.value=!0,!h)return;for(const D of r.value)await D(h);R.value={role:"assistant",content:""},A.value.push({role:"user",content:h}),A.value.push(R.value);const g=A.value.slice(0,A.value.length-1).map(D=>ja(D));for(const D of i.value)await D(h);for(const D of o.value)await D(h);const m=(y=M.providerConfig)==null?void 0:y.headers,k=m==null?void 0:m.filter(D=>D.key&&D.value).reduce((D,z)=>(D[z.key]=z.value,D),{}),_=await t(M.model,M.chatProvider,g,{headers:k});for(const D of s.value)await D(h);let F="";const j=uu({onLiteral:async D=>{for(const z of a.value)await z(D);R.value.content+=D},onSpecial:async D=>{for(const z of l.value)await z(D)}});for await(const D of iu(_.textStream,async z=>z))F+=D,await j.consume(D);await j.end();for(const D of u.value)await D();for(const D of c.value)await D(F);console.debug("LLM output:",F)}finally{n.value=!1}}return{sending:n,messages:A,streamingMessage:R,send:P,onBeforeMessageComposed:f,onAfterMessageComposed:p,onBeforeSend:d,onAfterSend:b,onTokenLiteral:x,onTokenSpecial:v,onStreamEnd:T,onAssistantResponseEnd:I}}),ws=Fe({__name:"Screen",setup(t){const e=X(),n=Va(Ga),{width:r,height:i}=Ha(),o=ti(e,{immediate:!0,windowResize:!0,reset:!0}),s=Ue(()=>n.between("sm","md").value||n.smaller("sm").value),a=Ue(()=>n.between("md","lg").value),l=Ue(()=>n.greaterOrEqual("lg").value),u=Ue(()=>l.value?o.width.value:s.value||a.value?r.value-16:o.width.value),c=X(0);return je([r,i,e],()=>{var p,d;const f=(d=(p=e.value)==null?void 0:p.parentElement)==null?void 0:d.getBoundingClientRect();l.value||s.value||a.value?c.value=(f==null?void 0:f.height)||0:c.value=600}),je([o.width,o.height],()=>{l.value||s.value||a.value?c.value=o.height.value:c.value=600}),dn(async()=>{e.value&&o.update()}),(f,p)=>(ee(),ie("div",{ref_key:"containerRef",ref:e,"h-full":"","w-full":""},[gn(f.$slots,"default",{width:u.value,height:c.value})],512))}}),xu={absolute:"",bottom:"3",right:"3"},vu={flex:"~ row","cursor-pointer":""},bu=["checked","aria-checked"],wu={key:0,"min-w":"50vw",z:"(ee(),Xt(ws,{relative:""},{default:Be(({width:s,height:a})=>[Te(nu,{width:s,height:a},{default:Be(({app:l})=>[Te(tu,{app:l,"mouth-open-size":t.mouthOpenSize,width:s,height:a,paused:t.paused},null,8,["app","mouth-open-size","width","height","paused"])]),_:2},1032,["width","height"]),O("div",xu,[O("div",vu,[O("label",{class:Ct([n.value?"bg-zinc-300 dark:bg-zinc-200":"bg-zinc-100 dark:bg-zinc-700"]),transition:"all ease-in-out duration-500",text:"lg zinc-500 dark:zinc-400","m-1":"","h-fit":"","w-fit":"","cursor-pointer":"","appearance-none":"","gap-1":"","rounded-lg":"","rounded-md":"","border-none":"","p-2":"","outline-none":""},[At(O("input",{"onUpdate:modelValue":o[0]||(o[0]=l=>n.value=l),checked:n.value,"aria-checked":n.value,name:"showLive2DViewerInspector",type:"checkbox",hidden:"","appearance-none":"","outline-none":""},null,8,bu),[[ni,n.value]]),o[8]||(o[8]=O("div",{"select-none":""},[O("div",{"i-solar:bug-bold-duotone":""})],-1))],2)]),Te(pi,null,{default:Be(()=>[n.value?(ee(),ie("div",wu,[O("div",Tu,[O("div",ku,[O("span",null,me(H(e)("stage.viewers.debug-menu.emotions")),1)]),O("div",Au,[O("button",{"rounded-lg":"",bg:"zinc-100/70 dark:zinc-800/50","px-2":"","py-1":"","backdrop-blur-sm":"",onClick:o[1]||(o[1]=l=>r.value={group:"Surprise",index:0})},me(H(e)("stage.viewers.debug-menu.emotions-btn.surprised")),1),O("button",{"rounded-lg":"",bg:"zinc-100/70 dark:zinc-800/50","px-2":"","py-1":"","backdrop-blur-sm":"",onClick:o[2]||(o[2]=l=>r.value={group:"Sad",index:0})},me(H(e)("stage.viewers.debug-menu.emotions-btn.sad")),1),O("button",{"rounded-lg":"",bg:"zinc-100/70 dark:zinc-800/50","px-2":"","py-1":"","backdrop-blur-sm":"",onClick:o[3]||(o[3]=l=>r.value={group:"Angry",index:0})},me(H(e)("stage.viewers.debug-menu.emotions-btn.angry")),1),O("button",{"rounded-lg":"",bg:"zinc-100/70 dark:zinc-800/50","px-2":"","py-1":"","backdrop-blur-sm":"",onClick:o[4]||(o[4]=l=>r.value={group:"Happy",index:0})},me(H(e)("stage.viewers.debug-menu.emotions-btn.happy")),1),O("button",{"rounded-lg":"",bg:"zinc-100/70 dark:zinc-800/50","px-2":"","py-1":"","backdrop-blur-sm":"",onClick:o[5]||(o[5]=l=>r.value={group:"Awkward",index:0})},me(H(e)("stage.viewers.debug-menu.emotions-btn.awkward")),1),O("button",{"rounded-lg":"",bg:"zinc-100/70 dark:zinc-800/50","px-2":"","py-1":"","backdrop-blur-sm":"",onClick:o[6]||(o[6]=l=>r.value={group:"Question",index:0})},me(H(e)("stage.viewers.debug-menu.emotions-btn.question")),1),O("button",{"rounded-lg":"",bg:"zinc-100/70 dark:zinc-800/50","px-2":"","py-1":"","backdrop-blur-sm":"",onClick:o[7]||(o[7]=l=>r.value={group:"Think",index:0})},me(H(e)("stage.viewers.debug-menu.emotions-btn.think")),1)])])])):it("",!0)]),_:1})])]),_:1}))}});var Eu=Object.defineProperty,Mu=(t,e,n)=>e in t?Eu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Su=(t,e,n)=>Mu(t,e+"",n);function Iu(t){return el()?(tl(t),!0):!1}function Ts(t){return typeof t=="function"?t():H(t)}const Ru=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Cu=Object.prototype.toString,Nu=t=>Cu.call(t)==="[object Object]",Lu=()=>{},Pu=Ru?window:void 0;function Ou(t){var e;const n=Ts(t);return(e=n==null?void 0:n.$el)!=null?e:n}function lr(...t){let e,n,r,i;if(typeof t[0]=="string"||Array.isArray(t[0])?([n,r,i]=t,e=Pu):[e,n,r,i]=t,!e)return Lu;Array.isArray(n)||(n=[n]),Array.isArray(r)||(r=[r]);const o=[],s=()=>{o.forEach(c=>c()),o.length=0},a=(c,f,p,d)=>(c.addEventListener(f,p,d),()=>c.removeEventListener(f,p,d)),l=je(()=>[Ou(e),Ts(i)],([c,f])=>{if(s(),!c)return;const p=Nu(f)?{...f}:f;o.push(...n.flatMap(d=>r.map(b=>a(c,d,b,p))))},{immediate:!0,flush:"post"}),u=()=>{l(),s()};return Iu(u),u}function ks(t,e,n,r){const i=class extends yn{constructor(o={}){const s=Object.entries(t);super({uniforms:s.reduce((a,[l,u])=>{const c=si.clone({[l]:{value:u}});return{...a,...c}},{}),vertexShader:e,fragmentShader:n}),Su(this,"key",""),s.forEach(([a])=>Object.defineProperty(this,a,{get:()=>this.uniforms[a].value,set:l=>this.uniforms[a].value=l})),Object.assign(this,o)}};return i.key=Ot.generateUUID(),i}ks({color:new ze("white"),scale:new Pe(1,1),imageBounds:new Pe(1,1),resolution:1024,map:null,zoom:1,radius:0,grayscale:0,opacity:1},` + varying vec2 vUv; + varying vec2 vPos; + void main() { + gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.); + vUv = uv; + vPos = position.xy; + } + `,` + // mostly from https://gist.github.com/statico/df64c5d167362ecf7b34fca0b1459a44 + varying vec2 vUv; + varying vec2 vPos; + uniform vec2 scale; + uniform vec2 imageBounds; + uniform float resolution; + uniform vec3 color; + uniform sampler2D map; + uniform float radius; + uniform float zoom; + uniform float grayscale; + uniform float opacity; + const vec3 luma = vec3(.299, 0.587, 0.114); + vec4 toGrayscale(vec4 color, float intensity) { + return vec4(mix(color.rgb, vec3(dot(color.rgb, luma)), intensity), color.a); + } + vec2 aspect(vec2 size) { + return size / min(size.x, size.y); + } + + const float PI = 3.14159265; + + // from https://iquilezles.org/articles/distfunctions + float udRoundBox( vec2 p, vec2 b, float r ) { + return length(max(abs(p)-b+r,0.0))-r; + } + + void main() { + vec2 s = aspect(scale); + vec2 i = aspect(imageBounds); + float rs = s.x / s.y; + float ri = i.x / i.y; + vec2 new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, i.y * s.x / i.x); + vec2 offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new; + vec2 uv = vUv * s / new + offset; + vec2 zUv = (uv - vec2(0.5, 0.5)) / zoom + vec2(0.5, 0.5); + + vec2 res = vec2(scale * resolution); + vec2 halfRes = 0.5 * res; + float b = udRoundBox(vUv.xy * res - halfRes, halfRes, resolution * radius); + vec3 a = mix(vec3(1.0,0.0,0.0), vec3(0.0,0.0,0.0), smoothstep(0.0, 1.0, b)); + gl_FragColor = toGrayscale(texture2D(map, zUv) * vec4(color, opacity * a), grayscale); + + #include + #include + } + `);const hi=parseInt(nl.replace(/\D+/g,""));var Du=Object.defineProperty,Fu=(t,e,n)=>e in t?Du(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,zu=(t,e,n)=>(Fu(t,e+"",n),n);async function Vi(t){const e=await t.arrayBuffer(),n=btoa(String.fromCharCode(...new Uint8Array(e)));return`data:${t.type||""};base64,${n}`}let _n,ur,Bt,En;function cr(t,e=1/0,n=null){ur||(ur=new os(2,2,1,1)),Bt||(Bt=new yn({uniforms:{blitTexture:new ul(t)},vertexShader:` + varying vec2 vUv; + void main(){ + vUv = uv; + gl_Position = vec4(position.xy * 1.0,0.,.999999); + } + `,fragmentShader:` + uniform sampler2D blitTexture; + varying vec2 vUv; + + void main(){ + gl_FragColor = vec4(vUv.xy, 0, 1); + + #ifdef IS_SRGB + gl_FragColor = LinearTosRGB( texture2D( blitTexture, vUv) ); + #else + gl_FragColor = texture2D( blitTexture, vUv); + #endif + } + `})),Bt.uniforms.blitTexture.value=t,Bt.defines.IS_SRGB="colorSpace"in t?t.colorSpace==="srgb":t.encoding===3001,Bt.needsUpdate=!0,En||(En=new Pt(ur,Bt),En.frustrumCulled=!1);const r=new _t,i=new Dr;i.add(En),n||(n=_n=new cl({antialias:!1})),n.setSize(Math.min(t.image.width,e),Math.min(t.image.height,e)),n.clear(),n.render(i,r);const o=new Bn(n.domElement);return o.minFilter=t.minFilter,o.magFilter=t.magFilter,o.wrapS=t.wrapS,o.wrapT=t.wrapT,o.name=t.name,_n&&(_n.dispose(),_n=null),o}const Hi={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class As{constructor(){this.pluginCallbacks=[],this.register(function(e){return new Ku(e)}),this.register(function(e){return new Wu(e)}),this.register(function(e){return new Zu(e)}),this.register(function(e){return new Ju(e)}),this.register(function(e){return new ec(e)}),this.register(function(e){return new tc(e)}),this.register(function(e){return new Xu(e)}),this.register(function(e){return new Qu(e)}),this.register(function(e){return new nc(e)}),this.register(function(e){return new rc(e)}),this.register(function(e){return new ic(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,n,r,i){const o=new Yu,s=[];for(let a=0,l=this.pluginCallbacks.length;at.times[t.times.length-1]){if(Math.abs(t.times[t.times.length-1]-e)<.001)return t.times.length-1;r[r.length-1]=e,r.set(t.times,0),i.set(t.values,0),i.set(o.evaluate(e),t.values.length),s=r.length-1}else for(let a=0;ae){r.set(t.times.slice(0,a+1),0),r[a+1]=e,r.set(t.times.slice(a+1),a+2),i.set(t.values.slice(0,(a+1)*n),0),i.set(o.evaluate(e),(a+1)*n),i.set(t.values.slice((a+1)*n),(a+2)*n),s=a+1;break}}return t.times=r,t.values=i,s},mergeMorphTargetTracks:function(t,e){const n=[],r={},i=t.tracks;for(let o=0;o4?s=t.array[i*t.itemSize+o]:(o===0?s=t.getX(i):o===1?s=t.getY(i):o===2?s=t.getZ(i):o===3&&(s=t.getW(i)),t.normalized===!0&&(s=Ot.normalize(s,t.array))),r.min[o]=Math.min(r.min[o],s),r.max[o]=Math.max(r.max[o],s)}return r}function _s(t){return Math.ceil(t/4)*4}function dr(t,e=0){const n=_s(t.byteLength);if(n!==t.byteLength){const r=new Uint8Array(n);if(r.set(new Uint8Array(t)),e!==0)for(let i=t.byteLength;i"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function Ki(t,e){if(t.toBlob!==void 0)return new Promise(r=>t.toBlob(r,e));let n;return e==="image/jpeg"?n=.92:e==="image/webp"&&(n=.8),t.convertToBlob({type:e,quality:n})}class Yu{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,n,r={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},r),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);const i=this,o=i.buffers,s=i.json;r=i.options;const a=i.extensionsUsed,l=i.extensionsRequired,u=new Blob(o,{type:"application/octet-stream"}),c=Object.keys(a),f=Object.keys(l);c.length>0&&(s.extensionsUsed=c),f.length>0&&(s.extensionsRequired=f),s.buffers&&s.buffers.length>0&&(s.buffers[0].byteLength=u.size),r.binary===!0?u.arrayBuffer().then(p=>{const d=dr(p),b=new DataView(new ArrayBuffer(qi));b.setUint32(0,d.byteLength,!0),b.setUint32(4,Hu,!0);const x=dr(Gu(JSON.stringify(s)),32),v=new DataView(new ArrayBuffer(qi));v.setUint32(0,x.byteLength,!0),v.setUint32(4,Vu,!0);const T=new ArrayBuffer($i),I=new DataView(T);I.setUint32(0,Uu,!0),I.setUint32(4,ju,!0);const A=$i+v.byteLength+x.byteLength+b.byteLength+d.byteLength;I.setUint32(8,A,!0),new Blob([T,v,x,b,d],{type:"application/octet-stream"}).arrayBuffer().then(n)}):s.buffers&&s.buffers.length>0?Vi(u).then(p=>{s.buffers[0].uri=p,n(s)}):n(s)}serializeUserData(e,n){if(Object.keys(e.userData).length===0)return;const r=this.options,i=this.extensionsUsed;try{const o=JSON.parse(JSON.stringify(e.userData));if(r.includeCustomExtensions&&o.gltfExtensions){n.extensions===void 0&&(n.extensions={});for(const s in o.gltfExtensions)n.extensions[s]=o.gltfExtensions[s],i[s]=!0;delete o.gltfExtensions}Object.keys(o).length>0&&(n.extras=o)}catch(o){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+o.message)}}getUID(e,n=!1){if(this.uids.has(e)===!1){const r=new Map;r.set(!0,this.uid++),r.set(!1,this.uid++),this.uids.set(e,r)}return this.uids.get(e).get(n)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const n=new se;for(let r=0,i=e.count;r5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const n=this.cache;if(n.attributesNormalized.has(e))return n.attributesNormalized.get(e);const r=e.clone(),i=new se;for(let o=0,s=r.count;o4?b=e.array[p*e.itemSize+d]:(d===0?b=e.getX(p):d===1?b=e.getY(p):d===2?b=e.getZ(p):d===3&&(b=e.getW(p)),e.normalized===!0&&(b=Ot.normalize(b,e.array))),n===he.FLOAT?u.setFloat32(c,b,!0):n===he.INT?u.setInt32(c,b,!0):n===he.UNSIGNED_INT?u.setUint32(c,b,!0):n===he.SHORT?u.setInt16(c,b,!0):n===he.UNSIGNED_SHORT?u.setUint16(c,b,!0):n===he.BYTE?u.setInt8(c,b):n===he.UNSIGNED_BYTE&&u.setUint8(c,b),c+=a}const f={buffer:this.processBuffer(u.buffer),byteOffset:this.byteOffset,byteLength:l};return o!==void 0&&(f.target=o),o===he.ARRAY_BUFFER&&(f.byteStride=e.itemSize*a),this.byteOffset+=l,s.bufferViews.push(f),{id:s.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const n=this,r=n.json;return r.bufferViews||(r.bufferViews=[]),e.arrayBuffer().then(i=>{const o=dr(i),s={buffer:n.processBuffer(o),byteOffset:n.byteOffset,byteLength:o.byteLength};return n.byteOffset+=o.byteLength,r.bufferViews.push(s)-1})}processAccessor(e,n,r,i){const o=this.json,s={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"};let a;if(e.array.constructor===Float32Array)a=he.FLOAT;else if(e.array.constructor===Int32Array)a=he.INT;else if(e.array.constructor===Uint32Array)a=he.UNSIGNED_INT;else if(e.array.constructor===Int16Array)a=he.SHORT;else if(e.array.constructor===Uint16Array)a=he.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)a=he.BYTE;else if(e.array.constructor===Uint8Array)a=he.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(r===void 0&&(r=0),i===void 0&&(i=e.count),i===0)return null;const l=qu(e,r,i);let u;n!==void 0&&(u=e===n.index?he.ELEMENT_ARRAY_BUFFER:he.ARRAY_BUFFER);const c=this.processBufferView(e,a,r,i,u),f={bufferView:c.id,byteOffset:c.byteOffset,componentType:a,count:i,max:l.max,min:l.min,type:s[e.itemSize]};return e.normalized===!0&&(f.normalized=!0),o.accessors||(o.accessors=[]),o.accessors.push(f)-1}processImage(e,n,r,i="image/png"){if(e!==null){const o=this,s=o.cache,a=o.json,l=o.options,u=o.pending;s.images.has(e)||s.images.set(e,{});const c=s.images.get(e),f=i+":flipY/"+r.toString();if(c[f]!==void 0)return c[f];a.images||(a.images=[]);const p={mimeType:i},d=Yi();d.width=Math.min(e.width,l.maxTextureSize),d.height=Math.min(e.height,l.maxTextureSize);const b=d.getContext("2d");if(r===!0&&(b.translate(0,d.height),b.scale(1,-1)),e.data!==void 0){n!==Or&&console.error("GLTFExporter: Only RGBAFormat is supported.",n),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const v=new Uint8ClampedArray(e.height*e.width*4);for(let T=0;To.processBufferViewImage(v)).then(v=>{p.bufferView=v})):d.toDataURL!==void 0?p.uri=d.toDataURL(i):u.push(Ki(d,i).then(Vi).then(v=>{p.uri=v}));const x=a.images.push(p)-1;return c[f]=x,x}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const n=this.json;n.samplers||(n.samplers=[]);const r={magFilter:Ze[e.magFilter],minFilter:Ze[e.minFilter],wrapS:Ze[e.wrapS],wrapT:Ze[e.wrapT]};return n.samplers.push(r)-1}processTexture(e){const n=this.options,r=this.cache,i=this.json;if(r.textures.has(e))return r.textures.get(e);i.textures||(i.textures=[]),e instanceof tr&&(e=cr(e,n.maxTextureSize));let o=e.userData.mimeType;o==="image/webp"&&(o="image/png");const s={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,o)};e.name&&(s.name=e.name),this._invokeAll(function(l){l.writeTexture&&l.writeTexture(e,s)});const a=i.textures.push(s)-1;return r.textures.set(e,a),a}processMaterial(e){const n=this.cache,r=this.json;if(n.materials.has(e))return n.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;r.materials||(r.materials=[]);const i={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const o=e.color.toArray().concat([e.opacity]);if(ln(o,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=o),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const a=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),l={index:this.processTexture(a),channel:a.channel};this.applyTextureTransform(l,a),i.pbrMetallicRoughness.metallicRoughnessTexture=l}if(e.map){const a={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(a,e.map),i.pbrMetallicRoughness.baseColorTexture=a}if(e.emissive){const a=e.emissive;if(Math.max(a.r,a.g,a.b)>0&&(i.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const l={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(l,e.emissiveMap),i.emissiveTexture=l}}if(e.normalMap){const a={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(a.scale=e.normalScale.x),this.applyTextureTransform(a,e.normalMap),i.normalTexture=a}if(e.aoMap){const a={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(a.strength=e.aoMapIntensity),this.applyTextureTransform(a,e.aoMap),i.occlusionTexture=a}e.transparent?i.alphaMode="BLEND":e.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===Kn&&(i.doubleSided=!0),e.name!==""&&(i.name=e.name),this.serializeUserData(e,i),this._invokeAll(function(a){a.writeMaterial&&a.writeMaterial(e,i)});const s=r.materials.push(i)-1;return n.materials.set(e,s),s}processMesh(e){const n=this.cache,r=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let A=0,R=e.material.length;A=152?{uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3"}:{uv:"TEXCOORD_0",uv2:"TEXCOORD_1"},color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},d=s.getAttribute("normal");d!==void 0&&!this.isNormalizedNormalAttribute(d)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),s.setAttribute("normal",this.createNormalizedNormalAttribute(d)));let b=null;for(let A in s.attributes){if(A.slice(0,5)==="morph")continue;const R=s.attributes[A];if(A=p[A]||A.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(A)||(A="_"+A),n.attributes.has(this.getUID(R))){u[A]=n.attributes.get(this.getUID(R));continue}b=null;const P=R.array;A==="JOINTS_0"&&!(P instanceof Uint16Array)&&!(P instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),b=new Nt(new Uint16Array(P),R.itemSize,R.normalized));const h=this.processAccessor(b||R,s);h!==null&&(A.startsWith("_")||this.detectMeshQuantization(A,R),u[A]=h,n.attributes.set(this.getUID(R),h))}if(d!==void 0&&s.setAttribute("normal",d),Object.keys(u).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const A=[],R=[],P={};if(e.morphTargetDictionary!==void 0)for(const h in e.morphTargetDictionary)P[e.morphTargetDictionary[h]]=h;for(let h=0;h0&&(l.extras={},l.extras.targetNames=R)}const x=Array.isArray(e.material);if(x&&s.groups.length===0)return null;const v=x?e.material:[e.material],T=x?s.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let A=0,R=T.length;A0&&(P.targets=f),s.index!==null){let M=this.getUID(s.index);(T[A].start!==void 0||T[A].count!==void 0)&&(M+=":"+T[A].start+":"+T[A].count),n.attributes.has(M)?P.indices=n.attributes.get(M):(P.indices=this.processAccessor(s.index,s,T[A].start,T[A].count),n.attributes.set(M,P.indices)),P.indices===null&&delete P.indices}const h=this.processMaterial(v[T[A].materialIndex]);h!==null&&(P.material=h),c.push(P)}l.primitives=c,r.meshes||(r.meshes=[]),this._invokeAll(function(A){A.writeMesh&&A.writeMesh(e,l)});const I=r.meshes.push(l)-1;return n.meshes.set(o,I),I}detectMeshQuantization(e,n){if(this.extensionsUsed[fr])return;let r;switch(n.array.constructor){case Int8Array:r="byte";break;case Uint8Array:r="unsigned byte";break;case Int16Array:r="short";break;case Uint16Array:r="unsigned short";break;default:return}n.normalized&&(r+=" normalized");const i=e.split("_",1)[0];Hi[i]&&Hi[i].includes(r)&&(this.extensionsUsed[fr]=!0,this.extensionsRequired[fr]=!0)}processCamera(e){const n=this.json;n.cameras||(n.cameras=[]);const r=e.isOrthographicCamera,i={type:r?"orthographic":"perspective"};return r?i.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:Ot.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(i.name=e.type),n.cameras.push(i)-1}processAnimation(e,n){const r=this.json,i=this.nodeMap;r.animations||(r.animations=[]),e=As.Utils.mergeMorphTargetTracks(e.clone(),n);const o=e.tracks,s=[],a=[];for(let l=0;l0){const a=[];for(let l=0,u=e.children.length;l0&&(o.children=a)}this._invokeAll(function(a){a.writeNode&&a.writeNode(e,o)});const s=n.nodes.push(o)-1;return i.set(e,s),s}processScene(e){const n=this.json,r=this.options;n.scenes||(n.scenes=[],n.scene=0);const i={};e.name!==""&&(i.name=e.name),n.scenes.push(i);const o=[];for(let s=0,a=e.children.length;s0&&(i.nodes=o),this.serializeUserData(e,i)}processObjects(e){const n=new Dr;n.name="AuxScene";for(let r=0;r0&&this.processObjects(r);for(let i=0;i0&&(s.range=e.distance)):e.isSpotLight&&(s.type="spot",e.distance>0&&(s.range=e.distance),s.spot={},s.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,s.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),o[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},o[this.name]=!0);const a=i.extensions[this.name].lights;a.push(s),n.extensions=n.extensions||{},n.extensions[this.name]={light:a.length-1}}}let Wu=class{constructor(t){this.writer=t,this.name="KHR_materials_unlit"}writeMaterial(t,e){if(!t.isMeshBasicMaterial)return;const n=this.writer.extensionsUsed;e.extensions=e.extensions||{},e.extensions[this.name]={},n[this.name]=!0,e.pbrMetallicRoughness.metallicFactor=0,e.pbrMetallicRoughness.roughnessFactor=.9}},Xu=class{constructor(t){this.writer=t,this.name="KHR_materials_clearcoat"}writeMaterial(t,e){if(!t.isMeshPhysicalMaterial||t.clearcoat===0)return;const n=this.writer,r=n.extensionsUsed,i={};if(i.clearcoatFactor=t.clearcoat,t.clearcoatMap){const o={index:n.processTexture(t.clearcoatMap),texCoord:t.clearcoatMap.channel};n.applyTextureTransform(o,t.clearcoatMap),i.clearcoatTexture=o}if(i.clearcoatRoughnessFactor=t.clearcoatRoughness,t.clearcoatRoughnessMap){const o={index:n.processTexture(t.clearcoatRoughnessMap),texCoord:t.clearcoatRoughnessMap.channel};n.applyTextureTransform(o,t.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=o}if(t.clearcoatNormalMap){const o={index:n.processTexture(t.clearcoatNormalMap),texCoord:t.clearcoatNormalMap.channel};n.applyTextureTransform(o,t.clearcoatNormalMap),i.clearcoatNormalTexture=o}e.extensions=e.extensions||{},e.extensions[this.name]=i,r[this.name]=!0}},Qu=class{constructor(t){this.writer=t,this.name="KHR_materials_iridescence"}writeMaterial(t,e){if(!t.isMeshPhysicalMaterial||t.iridescence===0)return;const n=this.writer,r=n.extensionsUsed,i={};if(i.iridescenceFactor=t.iridescence,t.iridescenceMap){const o={index:n.processTexture(t.iridescenceMap),texCoord:t.iridescenceMap.channel};n.applyTextureTransform(o,t.iridescenceMap),i.iridescenceTexture=o}if(i.iridescenceIor=t.iridescenceIOR,i.iridescenceThicknessMinimum=t.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=t.iridescenceThicknessRange[1],t.iridescenceThicknessMap){const o={index:n.processTexture(t.iridescenceThicknessMap),texCoord:t.iridescenceThicknessMap.channel};n.applyTextureTransform(o,t.iridescenceThicknessMap),i.iridescenceThicknessTexture=o}e.extensions=e.extensions||{},e.extensions[this.name]=i,r[this.name]=!0}},Zu=class{constructor(t){this.writer=t,this.name="KHR_materials_transmission"}writeMaterial(t,e){if(!t.isMeshPhysicalMaterial||t.transmission===0)return;const n=this.writer,r=n.extensionsUsed,i={};if(i.transmissionFactor=t.transmission,t.transmissionMap){const o={index:n.processTexture(t.transmissionMap),texCoord:t.transmissionMap.channel};n.applyTextureTransform(o,t.transmissionMap),i.transmissionTexture=o}e.extensions=e.extensions||{},e.extensions[this.name]=i,r[this.name]=!0}},Ju=class{constructor(t){this.writer=t,this.name="KHR_materials_volume"}writeMaterial(t,e){if(!t.isMeshPhysicalMaterial||t.transmission===0)return;const n=this.writer,r=n.extensionsUsed,i={};if(i.thicknessFactor=t.thickness,t.thicknessMap){const o={index:n.processTexture(t.thicknessMap),texCoord:t.thicknessMap.channel};n.applyTextureTransform(o,t.thicknessMap),i.thicknessTexture=o}i.attenuationDistance=t.attenuationDistance,i.attenuationColor=t.attenuationColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=i,r[this.name]=!0}},ec=class{constructor(t){this.writer=t,this.name="KHR_materials_ior"}writeMaterial(t,e){if(!t.isMeshPhysicalMaterial||t.ior===1.5)return;const n=this.writer.extensionsUsed,r={};r.ior=t.ior,e.extensions=e.extensions||{},e.extensions[this.name]=r,n[this.name]=!0}},tc=class{constructor(t){this.writer=t,this.name="KHR_materials_specular"}writeMaterial(t,e){if(!t.isMeshPhysicalMaterial||t.specularIntensity===1&&t.specularColor.equals(Bu)&&!t.specularIntensityMap&&!t.specularColorTexture)return;const n=this.writer,r=n.extensionsUsed,i={};if(t.specularIntensityMap){const o={index:n.processTexture(t.specularIntensityMap),texCoord:t.specularIntensityMap.channel};n.applyTextureTransform(o,t.specularIntensityMap),i.specularTexture=o}if(t.specularColorMap){const o={index:n.processTexture(t.specularColorMap),texCoord:t.specularColorMap.channel};n.applyTextureTransform(o,t.specularColorMap),i.specularColorTexture=o}i.specularFactor=t.specularIntensity,i.specularColorFactor=t.specularColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=i,r[this.name]=!0}},nc=class{constructor(t){this.writer=t,this.name="KHR_materials_sheen"}writeMaterial(t,e){if(!t.isMeshPhysicalMaterial||t.sheen==0)return;const n=this.writer,r=n.extensionsUsed,i={};if(t.sheenRoughnessMap){const o={index:n.processTexture(t.sheenRoughnessMap),texCoord:t.sheenRoughnessMap.channel};n.applyTextureTransform(o,t.sheenRoughnessMap),i.sheenRoughnessTexture=o}if(t.sheenColorMap){const o={index:n.processTexture(t.sheenColorMap),texCoord:t.sheenColorMap.channel};n.applyTextureTransform(o,t.sheenColorMap),i.sheenColorTexture=o}i.sheenRoughnessFactor=t.sheenRoughness,i.sheenColorFactor=t.sheenColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=i,r[this.name]=!0}},rc=class{constructor(t){this.writer=t,this.name="KHR_materials_anisotropy"}writeMaterial(t,e){if(!t.isMeshPhysicalMaterial||t.anisotropy==0)return;const n=this.writer,r=n.extensionsUsed,i={};if(t.anisotropyMap){const o={index:n.processTexture(t.anisotropyMap)};n.applyTextureTransform(o,t.anisotropyMap),i.anisotropyTexture=o}i.anisotropyStrength=t.anisotropy,i.anisotropyRotation=t.anisotropyRotation,e.extensions=e.extensions||{},e.extensions[this.name]=i,r[this.name]=!0}},ic=class{constructor(t){this.writer=t,this.name="KHR_materials_emissive_strength"}writeMaterial(t,e){if(!t.isMeshStandardMaterial||t.emissiveIntensity===1)return;const n=this.writer.extensionsUsed,r={};r.emissiveStrength=t.emissiveIntensity,e.extensions=e.extensions||{},e.extensions[this.name]=r,n[this.name]=!0}};var xn=Uint8Array,Es=Uint16Array,oc=Uint32Array,sc=new xn([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ac=new xn([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ms=function(t,e){for(var n=new Es(31),r=0;r<31;++r)n[r]=e+=1<>>1|(Ne&21845)<<1;bt=(bt&52428)>>>2|(bt&13107)<<2,bt=(bt&61680)>>>4|(bt&3855)<<4,cc[Ne]=((bt&65280)>>>8|(bt&255)<<8)>>>1}var Xn=new xn(288);for(var Ne=0;Ne<144;++Ne)Xn[Ne]=8;for(var Ne=144;Ne<256;++Ne)Xn[Ne]=9;for(var Ne=256;Ne<280;++Ne)Xn[Ne]=7;for(var Ne=280;Ne<288;++Ne)Xn[Ne]=8;var fc=new xn(32);for(var Ne=0;Ne<32;++Ne)fc[Ne]=5;var dc=new xn(0),pc=typeof TextDecoder<"u"&&new TextDecoder,hc=0;try{pc.decode(dc,{stream:!0}),hc=1}catch{}var mc=Object.defineProperty,gc=(t,e,n)=>e in t?mc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,yc=(t,e,n)=>(gc(t,e+"",n),n);const Is=class extends Pt{constructor(t,e={}){super(t),this.isReflector=!0,this.type="Reflector",this.camera=new _t;const n=this,r=e.color!==void 0?new ze(e.color):new ze(8355711),i=e.textureWidth||512,o=e.textureHeight||512,s=e.clipBias||0,a=e.shader||Is.ReflectorShader,l=e.multisample!==void 0?e.multisample:4,u=new es,c=new se,f=new se,p=new se,d=new yt,b=new se(0,0,-1),x=new Et,v=new se,T=new se,I=new Et,A=new yt,R=this.camera,P=new il(i,o,{samples:l,type:ol}),h=new yn({uniforms:si.clone(a.uniforms),fragmentShader:a.fragmentShader,vertexShader:a.vertexShader});h.uniforms.tDiffuse.value=P.texture,h.uniforms.color.value=r,h.uniforms.textureMatrix.value=A,this.material=h,this.onBeforeRender=function(M,y,g){if(f.setFromMatrixPosition(n.matrixWorld),p.setFromMatrixPosition(g.matrixWorld),d.extractRotation(n.matrixWorld),c.set(0,0,1),c.applyMatrix4(d),v.subVectors(f,p),v.dot(c)>0)return;v.reflect(c).negate(),v.add(f),d.extractRotation(g.matrixWorld),b.set(0,0,-1),b.applyMatrix4(d),b.add(p),T.subVectors(f,b),T.reflect(c).negate(),T.add(f),R.position.copy(v),R.up.set(0,1,0),R.up.applyMatrix4(d),R.up.reflect(c),R.lookAt(T),R.far=g.far,R.updateMatrixWorld(),R.projectionMatrix.copy(g.projectionMatrix),A.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),A.multiply(R.projectionMatrix),A.multiply(R.matrixWorldInverse),A.multiply(n.matrixWorld),u.setFromNormalAndCoplanarPoint(c,f),u.applyMatrix4(R.matrixWorldInverse),x.set(u.normal.x,u.normal.y,u.normal.z,u.constant);const m=R.projectionMatrix;I.x=(Math.sign(x.x)+m.elements[8])/m.elements[0],I.y=(Math.sign(x.y)+m.elements[9])/m.elements[5],I.z=-1,I.w=(1+m.elements[10])/m.elements[14],x.multiplyScalar(2/x.dot(I)),m.elements[2]=x.x,m.elements[6]=x.y,m.elements[10]=x.z+1-s,m.elements[14]=x.w,n.visible=!1;const k=M.getRenderTarget(),_=M.xr.enabled,F=M.shadowMap.autoUpdate,j=M.toneMapping;let D=!1;"outputColorSpace"in M?D=M.outputColorSpace==="srgb":D=M.outputEncoding===3001,M.xr.enabled=!1,M.shadowMap.autoUpdate=!1,"outputColorSpace"in M?M.outputColorSpace="srgb-linear":M.outputEncoding=3e3,M.toneMapping=sl,M.setRenderTarget(P),M.state.buffers.depth.setMask(!0),M.autoClear===!1&&M.clear(),M.render(y,R),M.xr.enabled=_,M.shadowMap.autoUpdate=F,M.toneMapping=j,"outputColorSpace"in M?M.outputColorSpace=D?"srgb":"srgb-linear":M.outputEncoding=D?3001:3e3,M.setRenderTarget(k);const z=g.viewport;z!==void 0&&M.state.viewport(z),n.visible=!0},this.getRenderTarget=function(){return P},this.dispose=function(){P.dispose(),n.material.dispose()}}};let Br=Is;yc(Br,"ReflectorShader",{uniforms:{color:{value:null},tDiffuse:{value:null},textureMatrix:{value:null}},vertexShader:` + uniform mat4 textureMatrix; + varying vec4 vUv; + + #include + #include + + void main() { + + vUv = textureMatrix * vec4( position, 1.0 ); + + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + + #include + + }`,fragmentShader:` + uniform vec3 color; + uniform sampler2D tDiffuse; + varying vec4 vUv; + + #include + + float blendOverlay( float base, float blend ) { + + return( base < 0.5 ? ( 2.0 * base * blend ) : ( 1.0 - 2.0 * ( 1.0 - base ) * ( 1.0 - blend ) ) ); + + } + + vec3 blendOverlay( vec3 base, vec3 blend ) { + + return vec3( blendOverlay( base.r, blend.r ), blendOverlay( base.g, blend.g ), blendOverlay( base.b, blend.b ) ); + + } + + void main() { + + #include + + vec4 base = texture2DProj( tDiffuse, vUv ); + gl_FragColor = vec4( blendOverlay( base.rgb, color ), 1.0 ); + + #include + #include <${hi>=154?"colorspace_fragment":"encodings_fragment"}> + + }`});var xc=Object.defineProperty,vc=(t,e,n)=>e in t?xc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Rs=(t,e,n)=>(vc(t,typeof e!="symbol"?e+"":e,n),n);const Qn=new ts,bc=new Float32Array([-1,-1,0,0,0,1,-1,0,1,0,1,1,0,1,1,-1,1,0,0,1]),Cs=new ns(bc,5);Qn.setIndex([0,1,2,0,2,3]);Qn.setAttribute("position",new oi(Cs,3,0,!1));Qn.setAttribute("uv",new oi(Cs,2,3,!1));const Ur=class extends Pt{constructor(){super(Ur.Geometry,new Ht({opacity:0,transparent:!0})),this.isLensflare=!0,this.type="Lensflare",this.frustumCulled=!1,this.renderOrder=1/0;const t=new se,e=new se,n=new Li(new Uint8Array(16*16*3),16,16,Or);n.minFilter=Lt,n.magFilter=Lt,n.wrapS=Gt,n.wrapT=Gt;const r=new Li(new Uint8Array(16*16*3),16,16,Or);r.minFilter=Lt,r.magFilter=Lt,r.wrapS=Gt,r.wrapT=Gt;const i=Ur.Geometry,o=new nr({uniforms:{scale:{value:null},screenPosition:{value:null}},vertexShader:` + + precision highp float; + + uniform vec3 screenPosition; + uniform vec2 scale; + + attribute vec3 position; + + void main() { + + gl_Position = vec4( position.xy * scale + screenPosition.xy, screenPosition.z, 1.0 ); + + }`,fragmentShader:` + + precision highp float; + + void main() { + + gl_FragColor = vec4( 1.0, 0.0, 1.0, 1.0 ); + + }`,depthTest:!0,depthWrite:!1,transparent:!1}),s=new nr({uniforms:{map:{value:n},scale:{value:null},screenPosition:{value:null}},vertexShader:` + + precision highp float; + + uniform vec3 screenPosition; + uniform vec2 scale; + + attribute vec3 position; + attribute vec2 uv; + + varying vec2 vUV; + + void main() { + + vUV = uv; + + gl_Position = vec4( position.xy * scale + screenPosition.xy, screenPosition.z, 1.0 ); + + }`,fragmentShader:` + + precision highp float; + + uniform sampler2D map; + + varying vec2 vUV; + + void main() { + + gl_FragColor = texture2D( map, vUV ); + + }`,depthTest:!1,depthWrite:!1,transparent:!1}),a=new Pt(i,o),l=[],u=Ns.Shader,c=new nr({uniforms:{map:{value:null},occlusionMap:{value:r},color:{value:new ze(16777215)},scale:{value:new Pe},screenPosition:{value:new se}},vertexShader:u.vertexShader,fragmentShader:u.fragmentShader,blending:al,transparent:!0,depthWrite:!1}),f=new Pt(i,c);this.addElement=function(v){l.push(v)};const p=new Pe,d=new Pe,b=new ll,x=new Et;this.onBeforeRender=function(v,T,I){v.getCurrentViewport(x);const A=x.w/x.z,R=x.z/2,P=x.w/2;let h=16/x.w;if(p.set(h*A,h),b.min.set(x.x,x.y),b.max.set(x.x+(x.z-16),x.y+(x.w-16)),e.setFromMatrixPosition(this.matrixWorld),e.applyMatrix4(I.matrixWorldInverse),!(e.z>0)&&(t.copy(e).applyMatrix4(I.projectionMatrix),d.x=x.x+t.x*R+R-8,d.y=x.y+t.y*P+P-8,b.containsPoint(d))){v.copyFramebufferToTexture(d,n);let M=o.uniforms;M.scale.value=p,M.screenPosition.value=t,v.renderBufferDirect(I,null,i,o,a,null),v.copyFramebufferToTexture(d,r),M=s.uniforms,M.scale.value=p,M.screenPosition.value=t,v.renderBufferDirect(I,null,i,s,a,null);const y=-t.x*2,g=-t.y*2;for(let m=0,k=l.length;me in t?Tc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Ls=(t,e,n)=>(kc(t,typeof e!="symbol"?e+"":e,n),n);const On={uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new se},up:{value:new se(0,1,0)}},vertexShader:` + uniform vec3 sunPosition; + uniform float rayleigh; + uniform float turbidity; + uniform float mieCoefficient; + uniform vec3 up; + + varying vec3 vWorldPosition; + varying vec3 vSunDirection; + varying float vSunfade; + varying vec3 vBetaR; + varying vec3 vBetaM; + varying float vSunE; + + // constants for atmospheric scattering + const float e = 2.71828182845904523536028747135266249775724709369995957; + const float pi = 3.141592653589793238462643383279502884197169; + + // wavelength of used primaries, according to preetham + const vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 ); + // this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function: + // (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn)) + const vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 ); + + // mie stuff + // K coefficient for the primaries + const float v = 4.0; + const vec3 K = vec3( 0.686, 0.678, 0.666 ); + // MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K + const vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 ); + + // earth shadow hack + // cutoffAngle = pi / 1.95; + const float cutoffAngle = 1.6110731556870734; + const float steepness = 1.5; + const float EE = 1000.0; + + float sunIntensity( float zenithAngleCos ) { + zenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 ); + return EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) ); + } + + vec3 totalMie( float T ) { + float c = ( 0.2 * T ) * 10E-18; + return 0.434 * c * MieConst; + } + + void main() { + + vec4 worldPosition = modelMatrix * vec4( position, 1.0 ); + vWorldPosition = worldPosition.xyz; + + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + gl_Position.z = gl_Position.w; // set z to camera.far + + vSunDirection = normalize( sunPosition ); + + vSunE = sunIntensity( dot( vSunDirection, up ) ); + + vSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 ); + + float rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) ); + + // extinction (absorbtion + out scattering) + // rayleigh coefficients + vBetaR = totalRayleigh * rayleighCoefficient; + + // mie coefficients + vBetaM = totalMie( turbidity ) * mieCoefficient; + + } + `,fragmentShader:` + varying vec3 vWorldPosition; + varying vec3 vSunDirection; + varying float vSunfade; + varying vec3 vBetaR; + varying vec3 vBetaM; + varying float vSunE; + + uniform float mieDirectionalG; + uniform vec3 up; + + const vec3 cameraPos = vec3( 0.0, 0.0, 0.0 ); + + // constants for atmospheric scattering + const float pi = 3.141592653589793238462643383279502884197169; + + const float n = 1.0003; // refractive index of air + const float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius) + + // optical length at zenith for molecules + const float rayleighZenithLength = 8.4E3; + const float mieZenithLength = 1.25E3; + // 66 arc seconds -> degrees, and the cosine of that + const float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324; + + // 3.0 / ( 16.0 * pi ) + const float THREE_OVER_SIXTEENPI = 0.05968310365946075; + // 1.0 / ( 4.0 * pi ) + const float ONE_OVER_FOURPI = 0.07957747154594767; + + float rayleighPhase( float cosTheta ) { + return THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) ); + } + + float hgPhase( float cosTheta, float g ) { + float g2 = pow( g, 2.0 ); + float inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 ); + return ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse ); + } + + void main() { + + vec3 direction = normalize( vWorldPosition - cameraPos ); + + // optical length + // cutoff angle at 90 to avoid singularity in next formula. + float zenithAngle = acos( max( 0.0, dot( up, direction ) ) ); + float inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) ); + float sR = rayleighZenithLength * inverse; + float sM = mieZenithLength * inverse; + + // combined extinction factor + vec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) ); + + // in scattering + float cosTheta = dot( direction, vSunDirection ); + + float rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 ); + vec3 betaRTheta = vBetaR * rPhase; + + float mPhase = hgPhase( cosTheta, mieDirectionalG ); + vec3 betaMTheta = vBetaM * mPhase; + + vec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) ); + Lin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) ); + + // nightsky + float theta = acos( direction.y ); // elevation --> y-axis, [-pi/2, pi/2] + float phi = atan( direction.z, direction.x ); // azimuth --> x-axis [-pi/2, pi/2] + vec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 ); + vec3 L0 = vec3( 0.1 ) * Fex; + + // composition + solar disc + float sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta ); + L0 += ( vSunE * 19000.0 * Fex ) * sundisk; + + vec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 ); + + vec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) ); + + gl_FragColor = vec4( retColor, 1.0 ); + + #include + #include <${hi>=154?"colorspace_fragment":"encodings_fragment"}> + + } + `},Ps=new yn({name:"SkyShader",fragmentShader:On.fragmentShader,vertexShader:On.vertexShader,uniforms:si.clone(On.uniforms),side:Ya,depthWrite:!1});class Os extends Pt{constructor(){super(new rl(1,1,1),Ps)}}Ls(Os,"SkyShader",On);Ls(Os,"material",Ps);new Ka;new se;new rs(0,0,0,"YXZ");new se;var Ac=Object.defineProperty,_c=(t,e,n)=>e in t?Ac(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,re=(t,e,n)=>(_c(t,typeof e!="symbol"?e+"":e,n),n);const Mn=new qa,Wi=new es,Ec=Math.cos(70*(Math.PI/180)),Xi=(t,e)=>(t%e+e)%e;class Mc extends $a{constructor(e,n){super(),re(this,"object"),re(this,"domElement"),re(this,"enabled",!0),re(this,"target",new se),re(this,"minDistance",0),re(this,"maxDistance",1/0),re(this,"minZoom",0),re(this,"maxZoom",1/0),re(this,"minPolarAngle",0),re(this,"maxPolarAngle",Math.PI),re(this,"minAzimuthAngle",-1/0),re(this,"maxAzimuthAngle",1/0),re(this,"enableDamping",!1),re(this,"dampingFactor",.05),re(this,"enableZoom",!0),re(this,"zoomSpeed",1),re(this,"enableRotate",!0),re(this,"rotateSpeed",1),re(this,"enablePan",!0),re(this,"panSpeed",1),re(this,"screenSpacePanning",!0),re(this,"keyPanSpeed",7),re(this,"zoomToCursor",!1),re(this,"autoRotate",!1),re(this,"autoRotateSpeed",2),re(this,"reverseOrbit",!1),re(this,"reverseHorizontalOrbit",!1),re(this,"reverseVerticalOrbit",!1),re(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),re(this,"mouseButtons",{LEFT:gt.ROTATE,MIDDLE:gt.DOLLY,RIGHT:gt.PAN}),re(this,"touches",{ONE:kt.ROTATE,TWO:kt.DOLLY_PAN}),re(this,"target0"),re(this,"position0"),re(this,"zoom0"),re(this,"_domElementKeyEvents",null),re(this,"getPolarAngle"),re(this,"getAzimuthalAngle"),re(this,"setPolarAngle"),re(this,"setAzimuthalAngle"),re(this,"getDistance"),re(this,"getZoomScale"),re(this,"listenToKeyEvents"),re(this,"stopListenToKeyEvents"),re(this,"saveState"),re(this,"reset"),re(this,"update"),re(this,"connect"),re(this,"dispose"),re(this,"dollyIn"),re(this,"dollyOut"),re(this,"getScale"),re(this,"setScale"),this.object=e,this.domElement=n,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>c.phi,this.getAzimuthalAngle=()=>c.theta,this.setPolarAngle=L=>{let q=Xi(L,2*Math.PI),J=c.phi;J<0&&(J+=2*Math.PI),q<0&&(q+=2*Math.PI);let Ee=Math.abs(q-J);2*Math.PI-Ee{let q=Xi(L,2*Math.PI),J=c.theta;J<0&&(J+=2*Math.PI),q<0&&(q+=2*Math.PI);let Ee=Math.abs(q-J);2*Math.PI-Eer.object.position.distanceTo(r.target),this.listenToKeyEvents=L=>{L.addEventListener("keydown",oe),this._domElementKeyEvents=L},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",oe),this._domElementKeyEvents=null},this.saveState=()=>{r.target0.copy(r.target),r.position0.copy(r.object.position),r.zoom0=r.object.zoom},this.reset=()=>{r.target.copy(r.target0),r.object.position.copy(r.position0),r.object.zoom=r.zoom0,r.object.updateProjectionMatrix(),r.dispatchEvent(i),r.update(),l=a.NONE},this.update=(()=>{const L=new se,q=new se(0,1,0),J=new zn().setFromUnitVectors(e.up,q),Ee=J.clone().invert(),Xe=new se,st=new zn,Tn=2*Math.PI;return function(){const Ii=r.object.position;J.setFromUnitVectors(e.up,q),Ee.copy(J).invert(),L.copy(Ii).sub(r.target),L.applyQuaternion(J),c.setFromVector3(L),r.autoRotate&&l===a.NONE&&j(_()),r.enableDamping?(c.theta+=f.theta*r.dampingFactor,c.phi+=f.phi*r.dampingFactor):(c.theta+=f.theta,c.phi+=f.phi);let pt=r.minAzimuthAngle,ht=r.maxAzimuthAngle;isFinite(pt)&&isFinite(ht)&&(pt<-Math.PI?pt+=Tn:pt>Math.PI&&(pt-=Tn),ht<-Math.PI?ht+=Tn:ht>Math.PI&&(ht-=Tn),pt<=ht?c.theta=Math.max(pt,Math.min(ht,c.theta)):c.theta=c.theta>(pt+ht)/2?Math.max(pt,c.theta):Math.min(ht,c.theta)),c.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,c.phi)),c.makeSafe(),r.enableDamping===!0?r.target.addScaledVector(d,r.dampingFactor):r.target.add(d),r.zoomToCursor&&g||r.object.isOrthographicCamera?c.radius=C(c.radius):c.radius=C(c.radius*p),L.setFromSpherical(c),L.applyQuaternion(Ee),Ii.copy(r.target).add(L),r.object.matrixAutoUpdate||r.object.updateMatrix(),r.object.lookAt(r.target),r.enableDamping===!0?(f.theta*=1-r.dampingFactor,f.phi*=1-r.dampingFactor,d.multiplyScalar(1-r.dampingFactor)):(f.set(0,0,0),d.set(0,0,0));let en=!1;if(r.zoomToCursor&&g){let tn=null;if(r.object instanceof _t&&r.object.isPerspectiveCamera){const nn=L.length();tn=C(nn*p);const kn=nn-tn;r.object.position.addScaledVector(M,kn),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const nn=new se(y.x,y.y,0);nn.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/p)),r.object.updateProjectionMatrix(),en=!0;const kn=new se(y.x,y.y,0);kn.unproject(r.object),r.object.position.sub(kn).add(nn),r.object.updateMatrixWorld(),tn=L.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;tn!==null&&(r.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(tn).add(r.object.position):(Mn.origin.copy(r.object.position),Mn.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(Mn.direction))u||8*(1-st.dot(r.object.quaternion))>u?(r.dispatchEvent(i),Xe.copy(r.object.position),st.copy(r.object.quaternion),en=!1,!0):!1}})(),this.connect=L=>{r.domElement=L,r.domElement.style.touchAction="none",r.domElement.addEventListener("contextmenu",He),r.domElement.addEventListener("pointerdown",Me),r.domElement.addEventListener("pointercancel",et),r.domElement.addEventListener("wheel",W)},this.dispose=()=>{var L,q,J,Ee,Xe,st;r.domElement&&(r.domElement.style.touchAction="auto"),(L=r.domElement)==null||L.removeEventListener("contextmenu",He),(q=r.domElement)==null||q.removeEventListener("pointerdown",Me),(J=r.domElement)==null||J.removeEventListener("pointercancel",et),(Ee=r.domElement)==null||Ee.removeEventListener("wheel",W),(Xe=r.domElement)==null||Xe.ownerDocument.removeEventListener("pointermove",Ve),(st=r.domElement)==null||st.ownerDocument.removeEventListener("pointerup",et),r._domElementKeyEvents!==null&&r._domElementKeyEvents.removeEventListener("keydown",oe)};const r=this,i={type:"change"},o={type:"start"},s={type:"end"},a={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let l=a.NONE;const u=1e-6,c=new Ni,f=new Ni;let p=1;const d=new se,b=new Pe,x=new Pe,v=new Pe,T=new Pe,I=new Pe,A=new Pe,R=new Pe,P=new Pe,h=new Pe,M=new se,y=new Pe;let g=!1;const m=[],k={};function _(){return 2*Math.PI/60/60*r.autoRotateSpeed}function F(){return Math.pow(.95,r.zoomSpeed)}function j(L){r.reverseOrbit||r.reverseHorizontalOrbit?f.theta+=L:f.theta-=L}function D(L){r.reverseOrbit||r.reverseVerticalOrbit?f.phi+=L:f.phi-=L}const z=(()=>{const L=new se;return function(q,J){L.setFromMatrixColumn(J,0),L.multiplyScalar(-q),d.add(L)}})(),Q=(()=>{const L=new se;return function(q,J){r.screenSpacePanning===!0?L.setFromMatrixColumn(J,1):(L.setFromMatrixColumn(J,0),L.crossVectors(r.object.up,L)),L.multiplyScalar(q),d.add(L)}})(),Z=(()=>{const L=new se;return function(q,J){const Ee=r.domElement;if(Ee&&r.object instanceof _t&&r.object.isPerspectiveCamera){const Xe=r.object.position;L.copy(Xe).sub(r.target);let st=L.length();st*=Math.tan(r.object.fov/2*Math.PI/180),z(2*q*st/Ee.clientHeight,r.object.matrix),Q(2*J*st/Ee.clientHeight,r.object.matrix)}else Ee&&r.object instanceof $t&&r.object.isOrthographicCamera?(z(q*(r.object.right-r.object.left)/r.object.zoom/Ee.clientWidth,r.object.matrix),Q(J*(r.object.top-r.object.bottom)/r.object.zoom/Ee.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function K(L){r.object instanceof _t&&r.object.isPerspectiveCamera||r.object instanceof $t&&r.object.isOrthographicCamera?p=L:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function E(L){K(p/L)}function te(L){K(p*L)}function ge(L){if(!r.zoomToCursor||!r.domElement)return;g=!0;const q=r.domElement.getBoundingClientRect(),J=L.clientX-q.left,Ee=L.clientY-q.top,Xe=q.width,st=q.height;y.x=J/Xe*2-1,y.y=-(Ee/st)*2+1,M.set(y.x,y.y,1).unproject(r.object).sub(r.object.position).normalize()}function C(L){return Math.max(r.minDistance,Math.min(r.maxDistance,L))}function de(L){b.set(L.clientX,L.clientY)}function ke(L){ge(L),R.set(L.clientX,L.clientY)}function ye(L){T.set(L.clientX,L.clientY)}function De(L){x.set(L.clientX,L.clientY),v.subVectors(x,b).multiplyScalar(r.rotateSpeed);const q=r.domElement;q&&(j(2*Math.PI*v.x/q.clientHeight),D(2*Math.PI*v.y/q.clientHeight)),b.copy(x),r.update()}function G(L){P.set(L.clientX,L.clientY),h.subVectors(P,R),h.y>0?E(F()):h.y<0&&te(F()),R.copy(P),r.update()}function w(L){I.set(L.clientX,L.clientY),A.subVectors(I,T).multiplyScalar(r.panSpeed),Z(A.x,A.y),T.copy(I),r.update()}function S(L){ge(L),L.deltaY<0?te(F()):L.deltaY>0&&E(F()),r.update()}function N(L){let q=!1;switch(L.code){case r.keys.UP:Z(0,r.keyPanSpeed),q=!0;break;case r.keys.BOTTOM:Z(0,-r.keyPanSpeed),q=!0;break;case r.keys.LEFT:Z(r.keyPanSpeed,0),q=!0;break;case r.keys.RIGHT:Z(-r.keyPanSpeed,0),q=!0;break}q&&(L.preventDefault(),r.update())}function V(){if(m.length==1)b.set(m[0].pageX,m[0].pageY);else{const L=.5*(m[0].pageX+m[1].pageX),q=.5*(m[0].pageY+m[1].pageY);b.set(L,q)}}function B(){if(m.length==1)T.set(m[0].pageX,m[0].pageY);else{const L=.5*(m[0].pageX+m[1].pageX),q=.5*(m[0].pageY+m[1].pageY);T.set(L,q)}}function Y(){const L=m[0].pageX-m[1].pageX,q=m[0].pageY-m[1].pageY,J=Math.sqrt(L*L+q*q);R.set(0,J)}function ne(){r.enableZoom&&Y(),r.enablePan&&B()}function xe(){r.enableZoom&&Y(),r.enableRotate&&V()}function Ae(L){if(m.length==1)x.set(L.pageX,L.pageY);else{const J=dt(L),Ee=.5*(L.pageX+J.x),Xe=.5*(L.pageY+J.y);x.set(Ee,Xe)}v.subVectors(x,b).multiplyScalar(r.rotateSpeed);const q=r.domElement;q&&(j(2*Math.PI*v.x/q.clientHeight),D(2*Math.PI*v.y/q.clientHeight)),b.copy(x)}function fe(L){if(m.length==1)I.set(L.pageX,L.pageY);else{const q=dt(L),J=.5*(L.pageX+q.x),Ee=.5*(L.pageY+q.y);I.set(J,Ee)}A.subVectors(I,T).multiplyScalar(r.panSpeed),Z(A.x,A.y),T.copy(I)}function ve(L){const q=dt(L),J=L.pageX-q.x,Ee=L.pageY-q.y,Xe=Math.sqrt(J*J+Ee*Ee);P.set(0,Xe),h.set(0,Math.pow(P.y/R.y,r.zoomSpeed)),E(h.y),R.copy(P)}function Ie(L){r.enableZoom&&ve(L),r.enablePan&&fe(L)}function we(L){r.enableZoom&&ve(L),r.enableRotate&&Ae(L)}function Me(L){var q,J;r.enabled!==!1&&(m.length===0&&((q=r.domElement)==null||q.ownerDocument.addEventListener("pointermove",Ve),(J=r.domElement)==null||J.ownerDocument.addEventListener("pointerup",et)),ft(L),L.pointerType==="touch"?ue(L):Jt(L))}function Ve(L){r.enabled!==!1&&(L.pointerType==="touch"?be(L):U(L))}function et(L){var q,J,Ee;ot(L),m.length===0&&((q=r.domElement)==null||q.releasePointerCapture(L.pointerId),(J=r.domElement)==null||J.ownerDocument.removeEventListener("pointermove",Ve),(Ee=r.domElement)==null||Ee.ownerDocument.removeEventListener("pointerup",et)),r.dispatchEvent(s),l=a.NONE}function Jt(L){let q;switch(L.button){case 0:q=r.mouseButtons.LEFT;break;case 1:q=r.mouseButtons.MIDDLE;break;case 2:q=r.mouseButtons.RIGHT;break;default:q=-1}switch(q){case gt.DOLLY:if(r.enableZoom===!1)return;ke(L),l=a.DOLLY;break;case gt.ROTATE:if(L.ctrlKey||L.metaKey||L.shiftKey){if(r.enablePan===!1)return;ye(L),l=a.PAN}else{if(r.enableRotate===!1)return;de(L),l=a.ROTATE}break;case gt.PAN:if(L.ctrlKey||L.metaKey||L.shiftKey){if(r.enableRotate===!1)return;de(L),l=a.ROTATE}else{if(r.enablePan===!1)return;ye(L),l=a.PAN}break;default:l=a.NONE}l!==a.NONE&&r.dispatchEvent(o)}function U(L){if(r.enabled!==!1)switch(l){case a.ROTATE:if(r.enableRotate===!1)return;De(L);break;case a.DOLLY:if(r.enableZoom===!1)return;G(L);break;case a.PAN:if(r.enablePan===!1)return;w(L);break}}function W(L){r.enabled===!1||r.enableZoom===!1||l!==a.NONE&&l!==a.ROTATE||(L.preventDefault(),r.dispatchEvent(o),S(L),r.dispatchEvent(s))}function oe(L){r.enabled===!1||r.enablePan===!1||N(L)}function ue(L){switch(vt(L),m.length){case 1:switch(r.touches.ONE){case kt.ROTATE:if(r.enableRotate===!1)return;V(),l=a.TOUCH_ROTATE;break;case kt.PAN:if(r.enablePan===!1)return;B(),l=a.TOUCH_PAN;break;default:l=a.NONE}break;case 2:switch(r.touches.TWO){case kt.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;ne(),l=a.TOUCH_DOLLY_PAN;break;case kt.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;xe(),l=a.TOUCH_DOLLY_ROTATE;break;default:l=a.NONE}break;default:l=a.NONE}l!==a.NONE&&r.dispatchEvent(o)}function be(L){switch(vt(L),l){case a.TOUCH_ROTATE:if(r.enableRotate===!1)return;Ae(L),r.update();break;case a.TOUCH_PAN:if(r.enablePan===!1)return;fe(L),r.update();break;case a.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;Ie(L),r.update();break;case a.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;we(L),r.update();break;default:l=a.NONE}}function He(L){r.enabled!==!1&&L.preventDefault()}function ft(L){m.push(L)}function ot(L){delete k[L.pointerId];for(let q=0;q{te(L),r.update()},this.dollyOut=(L=F())=>{E(L),r.update()},this.getScale=()=>p,this.setScale=L=>{K(L),r.update()},this.getZoomScale=()=>F(),n!==void 0&&this.connect(n),this.update()}}new yt;new se;new rs;new se;var Sc=Object.defineProperty,Ic=(t,e,n)=>e in t?Sc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,mi=(t,e,n)=>(Ic(t,typeof e!="symbol"?e+"":e,n),n);class Ds{constructor(e){mi(this,"data"),this.data=e}generateShapes(e,n=100,r){const i=[],o={letterSpacing:0,lineHeight:1,...r},s=Rc(e,n,this.data,o);for(let a=0,l=s.length;a + #include + #include + uniform float thickness; + uniform bool screenspace; + uniform vec2 size; + void main() { + #if defined (USE_SKINNING) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + vec4 tNormal = vec4(normal, 0.0); + vec4 tPosition = vec4(transformed, 1.0); + #ifdef USE_INSTANCING + tNormal = instanceMatrix * tNormal; + tPosition = instanceMatrix * tPosition; + #endif + if (screenspace) { + vec3 newPosition = tPosition.xyz + tNormal.xyz * thickness; + gl_Position = projectionMatrix * modelViewMatrix * vec4(newPosition, 1.0); + } else { + vec4 clipPosition = projectionMatrix * modelViewMatrix * tPosition; + vec4 clipNormal = projectionMatrix * modelViewMatrix * tNormal; + vec2 offset = normalize(clipNormal.xy) * thickness / size * clipPosition.w * 2.0; + clipPosition.xy += offset; + gl_Position = clipPosition; + } + }`,`uniform vec3 color; + uniform float opacity; + void main(){ + gl_FragColor = vec4(color, opacity); + #include + #include + }`);const Nc=["args","material-uniforms-color-value"];Br.ReflectorShader;new se;new se;new se;var pr;/Mac/.test((pr=globalThis==null?void 0:globalThis.navigator)===null||pr===void 0?void 0:pr.platform);const Lc=["target","auto-rotate","auto-rotate-speed","enable-damping","damping-factor","enable-pan","key-pan-speed","keys","max-azimuth-angle","min-azimuth-angle","max-polar-angle","min-polar-angle","min-distance","max-distance","min-zoom","max-zoom","touches","enable-zoom","zoom-speed","enable-rotate","rotate-speed","mouse-buttons","args"],Pc=Fe({__name:"OrbitControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},target:{default:()=>[0,0,0]},enableDamping:{type:Boolean,default:!0},dampingFactor:{default:.05},autoRotate:{type:Boolean,default:!1},autoRotateSpeed:{default:2},enablePan:{type:Boolean,default:!0},keyPanSpeed:{default:7},keys:{},maxAzimuthAngle:{default:Number.POSITIVE_INFINITY},minAzimuthAngle:{default:Number.NEGATIVE_INFINITY},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:Number.POSITIVE_INFINITY},minZoom:{default:0},maxZoom:{default:Number.POSITIVE_INFINITY},touches:{default:()=>({ONE:kt.ROTATE,TWO:kt.DOLLY_PAN})},enableZoom:{type:Boolean,default:!0},zoomSpeed:{default:1},enableRotate:{type:Boolean,default:!0},rotateSpeed:{default:1},mouseButtons:{default:()=>({LEFT:gt.ROTATE,MIDDLE:gt.DOLLY,RIGHT:gt.PAN})}},emits:["change","start","end"],setup(t,{expose:e,emit:n}){const r=t,i=n,{makeDefault:o,autoRotate:s,autoRotateSpeed:a,enableDamping:l,dampingFactor:u,enablePan:c,keyPanSpeed:f,maxAzimuthAngle:p,minAzimuthAngle:d,maxPolarAngle:b,minPolarAngle:x,minDistance:v,maxDistance:T,minZoom:I,maxZoom:A,enableZoom:R,zoomSpeed:P,enableRotate:h,touches:M,rotateSpeed:y,target:g,mouseButtons:m}=ri(r),{camera:k,renderer:_,extend:F,controls:j,invalidate:D}=Yn(),z=Jo(null);F({OrbitControls:Mc}),je(z,K=>{Q(),K&&o.value?j.value=K:j.value=null});function Q(){lr(z.value,"change",()=>{i("change",z.value),D()}),lr(z.value,"start",()=>i("start",z.value)),lr(z.value,"end",()=>i("end",z.value))}const{onBeforeRender:Z}=Fn();return Z(({invalidate:K})=>{z.value&&(l.value||s.value)&&(z.value.update(),s.value&&K())}),Ft(()=>{z.value&&z.value.dispose()}),e({instance:z}),(K,E)=>(K.camera||H(k))&&(K.domElement||H(_))?(ee(),ie("TresOrbitControls",{key:0,ref_key:"controlsRef",ref:z,target:H(g),"auto-rotate":H(s),"auto-rotate-speed":H(a),"enable-damping":H(l),"damping-factor":H(u),"enable-pan":H(c),"key-pan-speed":H(f),keys:K.keys,"max-azimuth-angle":H(p),"min-azimuth-angle":H(d),"max-polar-angle":H(b),"min-polar-angle":H(x),"min-distance":H(v),"max-distance":H(T),"min-zoom":H(I),"max-zoom":H(A),touches:H(M),"enable-zoom":H(R),"zoom-speed":H(P),"enable-rotate":H(h),"rotate-speed":H(y),"mouse-buttons":H(m),args:[K.camera||H(k),K.domElement||H(_).domElement]},null,8,Lc)):it("",!0)}});function Sn(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Qi={exports:{}},Zi;function Oc(){return Zi||(Zi=1,function(t,e){(function(n){t.exports=n()})(function(){return function n(r,i,o){function s(u,c){if(!i[u]){if(!r[u]){var f=typeof Sn=="function"&&Sn;if(!c&&f)return f(u,!0);if(a)return a(u,!0);throw new Error("Cannot find module '"+u+"'")}c=i[u]={exports:{}},r[u][0].call(c.exports,function(p){var d=r[u][1][p];return s(d||p)},c,c.exports,n,r,i,o)}return i[u].exports}for(var a=typeof Sn=="function"&&Sn,l=0;l>16),D((65280&m)>>8),D(255&m);return k==2?D(255&(m=M(y.charAt(g))<<2|M(y.charAt(g+1))>>4)):k==1&&(D((m=M(y.charAt(g))<<10|M(y.charAt(g+1))<<4|M(y.charAt(g+2))>>2)>>8&255),D(255&m)),_},b.fromByteArray=function(y){var g,m,k,_,F=y.length%3,j="";function D(z){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(z)}for(g=0,k=y.length-F;g>18&63)+D(_>>12&63)+D(_>>6&63)+D(63&_);switch(F){case 1:j=(j+=D((m=y[y.length-1])>>2))+D(m<<4&63)+"==";break;case 2:j=(j=(j+=D((m=(y[y.length-2]<<8)+y[y.length-1])>>10))+D(m>>4&63))+D(m<<2&63)+"="}return j}})(i===void 0?this.base64js={}:i)}).call(this,n("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},n("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:11}],3:[function(n,r,i){(function(o,s,v,l,u,c,f,p,d){var b=n("base64-js"),x=n("ieee754");function v(w,S,N){if(!(this instanceof v))return new v(w,S,N);var V,B,Y,ne,xe=typeof w;if(S==="base64"&&xe=="string")for(w=(ne=w).trim?ne.trim():ne.replace(/^\s+|\s+$/g,"");w.length%4!=0;)w+="=";if(xe=="number")V=Z(w);else if(xe=="string")V=v.byteLength(w,S);else{if(xe!="object")throw new Error("First argument needs to be a number, array or string.");V=Z(w.length)}if(v._useTypedArrays?B=v._augment(new Uint8Array(V)):((B=this).length=V,B._isBuffer=!0),v._useTypedArrays&&typeof w.byteLength=="number")B._set(w);else if(K(ne=w)||v.isBuffer(ne)||ne&&typeof ne=="object"&&typeof ne.length=="number")for(Y=0;Y>8,ne=ne%256,xe.push(ne),xe.push(Y);return xe}(S),w,N,V)}function A(w,S,N){var V="";N=Math.min(w.length,N);for(var B=S;B>>0)):(S+1>>0),B}function h(w,S,N,V){if(V||(G(typeof N=="boolean","missing or invalid endian"),G(S!=null,"missing offset"),G(S+1>>8*(V?Y:1-Y)}function k(w,S,N,V,B){if(B||(G(S!=null,"missing value"),G(typeof V=="boolean","missing or invalid endian"),G(N!=null,"missing offset"),G(N+3>>8*(V?Y:3-Y)&255}function _(w,S,N,V,B){B||(G(S!=null,"missing value"),G(typeof V=="boolean","missing or invalid endian"),G(N!=null,"missing offset"),G(N+1this.length&&(V=this.length);var B=(V=w.length-S=this.length))return this[w]},v.prototype.readUInt16LE=function(w,S){return R(this,w,!0,S)},v.prototype.readUInt16BE=function(w,S){return R(this,w,!1,S)},v.prototype.readUInt32LE=function(w,S){return P(this,w,!0,S)},v.prototype.readUInt32BE=function(w,S){return P(this,w,!1,S)},v.prototype.readInt8=function(w,S){if(S||(G(w!=null,"missing offset"),G(w=this.length))return 128&this[w]?-1*(255-this[w]+1):this[w]},v.prototype.readInt16LE=function(w,S){return h(this,w,!0,S)},v.prototype.readInt16BE=function(w,S){return h(this,w,!1,S)},v.prototype.readInt32LE=function(w,S){return M(this,w,!0,S)},v.prototype.readInt32BE=function(w,S){return M(this,w,!1,S)},v.prototype.readFloatLE=function(w,S){return y(this,w,!0,S)},v.prototype.readFloatBE=function(w,S){return y(this,w,!1,S)},v.prototype.readDoubleLE=function(w,S){return g(this,w,!0,S)},v.prototype.readDoubleBE=function(w,S){return g(this,w,!1,S)},v.prototype.writeUInt8=function(w,S,N){N||(G(w!=null,"missing value"),G(S!=null,"missing offset"),G(S=this.length||(this[S]=w)},v.prototype.writeUInt16LE=function(w,S,N){m(this,w,S,!0,N)},v.prototype.writeUInt16BE=function(w,S,N){m(this,w,S,!1,N)},v.prototype.writeUInt32LE=function(w,S,N){k(this,w,S,!0,N)},v.prototype.writeUInt32BE=function(w,S,N){k(this,w,S,!1,N)},v.prototype.writeInt8=function(w,S,N){N||(G(w!=null,"missing value"),G(S!=null,"missing offset"),G(S=this.length||(0<=w?this.writeUInt8(w,S,N):this.writeUInt8(255+w+1,S,N))},v.prototype.writeInt16LE=function(w,S,N){_(this,w,S,!0,N)},v.prototype.writeInt16BE=function(w,S,N){_(this,w,S,!1,N)},v.prototype.writeInt32LE=function(w,S,N){F(this,w,S,!0,N)},v.prototype.writeInt32BE=function(w,S,N){F(this,w,S,!1,N)},v.prototype.writeFloatLE=function(w,S,N){j(this,w,S,!0,N)},v.prototype.writeFloatBE=function(w,S,N){j(this,w,S,!1,N)},v.prototype.writeDoubleLE=function(w,S,N){D(this,w,S,!0,N)},v.prototype.writeDoubleBE=function(w,S,N){D(this,w,S,!1,N)},v.prototype.fill=function(w,S,N){if(S=S||0,N=N||this.length,G(typeof(w=typeof(w=w||0)=="string"?w.charCodeAt(0):w)=="number"&&!isNaN(w),"value is not a number"),G(S<=N,"end < start"),N!==S&&this.length!==0){G(0<=S&&S"},v.prototype.toArrayBuffer=function(){if(typeof Uint8Array>"u")throw new Error("Buffer.toArrayBuffer not supported in this browser");if(v._useTypedArrays)return new v(this).buffer;for(var w=new Uint8Array(this.length),S=0,N=w.length;S=S.length||B>=w.length);B++)S[B+N]=w[B];return B}function de(w){try{return decodeURIComponent(w)}catch{return"�"}}function ke(w,S){G(typeof w=="number","cannot write a non-number as a number"),G(0<=w,"specified a negative value for writing an unsigned value"),G(w<=S,"value is larger than maximum value for type"),G(Math.floor(w)===w,"value has a fractional component")}function ye(w,S,N){G(typeof w=="number","cannot write a non-number as a number"),G(w<=S,"value larger than maximum allowed value"),G(N<=w,"value smaller than minimum allowed value"),G(Math.floor(w)===w,"value has a fractional component")}function De(w,S,N){G(typeof w=="number","cannot write a non-number as a number"),G(w<=S,"value larger than maximum allowed value"),G(N<=w,"value smaller than minimum allowed value")}function G(w,S){if(!w)throw new Error(S||"Failed assertion")}v._augment=function(w){return w._isBuffer=!0,w._get=w.get,w._set=w.set,w.get=z.get,w.set=z.set,w.write=z.write,w.toString=z.toString,w.toLocaleString=z.toString,w.toJSON=z.toJSON,w.copy=z.copy,w.slice=z.slice,w.readUInt8=z.readUInt8,w.readUInt16LE=z.readUInt16LE,w.readUInt16BE=z.readUInt16BE,w.readUInt32LE=z.readUInt32LE,w.readUInt32BE=z.readUInt32BE,w.readInt8=z.readInt8,w.readInt16LE=z.readInt16LE,w.readInt16BE=z.readInt16BE,w.readInt32LE=z.readInt32LE,w.readInt32BE=z.readInt32BE,w.readFloatLE=z.readFloatLE,w.readFloatBE=z.readFloatBE,w.readDoubleLE=z.readDoubleLE,w.readDoubleBE=z.readDoubleBE,w.writeUInt8=z.writeUInt8,w.writeUInt16LE=z.writeUInt16LE,w.writeUInt16BE=z.writeUInt16BE,w.writeUInt32LE=z.writeUInt32LE,w.writeUInt32BE=z.writeUInt32BE,w.writeInt8=z.writeInt8,w.writeInt16LE=z.writeInt16LE,w.writeInt16BE=z.writeInt16BE,w.writeInt32LE=z.writeInt32LE,w.writeInt32BE=z.writeInt32BE,w.writeFloatLE=z.writeFloatLE,w.writeFloatBE=z.writeFloatBE,w.writeDoubleLE=z.writeDoubleLE,w.writeDoubleBE=z.writeDoubleBE,w.fill=z.fill,w.inspect=z.inspect,w.toArrayBuffer=z.toArrayBuffer,w}}).call(this,n("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},n("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/buffer/index.js","/node_modules/gulp-browserify/node_modules/buffer")},{"base64-js":2,buffer:3,ieee754:10,lYpoI2:11}],4:[function(n,r,i){(function(o,s,b,l,u,c,f,p,d){var b=n("buffer").Buffer,x=4,v=new b(x);v.fill(0),r.exports={hash:function(T,I,A,R){for(var P=I(function(m,k){m.length%x!=0&&(_=m.length+(x-m.length%x),m=b.concat([m,v],_));for(var _,F=[],j=k?m.readInt32BE:m.readInt32LE,D=0;DA?Q=z(Q):Q.length>5]|=128<>>9<<4)]=M;for(var y=1732584193,g=-271733879,m=-1732584194,k=271733878,_=0;_>>32-m,y)}function T(h,M,y,g,m,k,_){return v(M&y|~M&g,h,M,m,k,_)}function I(h,M,y,g,m,k,_){return v(M&g|y&~g,h,M,m,k,_)}function A(h,M,y,g,m,k,_){return v(M^y^g,h,M,m,k,_)}function R(h,M,y,g,m,k,_){return v(y^(M|~g),h,M,m,k,_)}function P(h,M){var y=(65535&h)+(65535&M);return(h>>16)+(M>>16)+(y>>16)<<16|65535&y}r.exports=function(h){return b.hash(h,x,16)}}).call(this,n("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},n("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],7:[function(n,r,i){(function(o,s,a,l,u,c,f,p,d){r.exports=function(b){for(var x,v=new Array(b),T=0;T>>((3&T)<<3)&255;return v}}).call(this,n("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},n("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],8:[function(n,r,i){(function(o,s,a,l,u,c,f,p,d){var b=n("./helpers");function x(I,A){I[A>>5]|=128<<24-A%32,I[15+(A+64>>9<<4)]=A;for(var R,P,h,M=Array(80),y=1732584193,g=-271733879,m=-1732584194,k=271733878,_=-1009589776,F=0;F>16)+(A>>16)+(R>>16)<<16|65535&R}function T(I,A){return I<>>32-A}r.exports=function(I){return b.hash(I,x,20,!0)}}).call(this,n("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},n("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],9:[function(n,r,i){(function(o,s,a,l,u,c,f,p,d){function b(A,R){var P=(65535&A)+(65535&R);return(A>>16)+(R>>16)+(P>>16)<<16|65535&P}function x(A,R){var P,h=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),M=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),y=new Array(64);A[R>>5]|=128<<24-R%32,A[15+(R+64>>9<<4)]=R;for(var g,m,k=0;k>>R|A<<32-R},I=function(A,R){return A>>>R};r.exports=function(A){return v.hash(A,x,32,!0)}}).call(this,n("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},n("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],10:[function(n,r,i){(function(o,s,a,l,u,c,f,p,d){i.read=function(b,x,v,T,k){var A,R,P=8*k-T-1,h=(1<>1,y=-7,g=v?k-1:0,m=v?-1:1,k=b[x+g];for(g+=m,A=k&(1<<-y)-1,k>>=-y,y+=P;0>=-y,y+=T;0>1,g=I===23?Math.pow(2,-24)-Math.pow(2,-77):0,m=T?0:_-1,k=T?1:-1,_=x<0||x===0&&1/x<0?1:0;for(x=Math.abs(x),isNaN(x)||x===1/0?(P=isNaN(x)?1:0,R=M):(R=Math.floor(Math.log(x)/Math.LN2),x*(T=Math.pow(2,-R))<1&&(R--,T*=2),2<=(x+=1<=R+y?g/T:g*Math.pow(2,1-y))*T&&(R++,T/=2),M<=R+y?(P=0,R=M):1<=R+y?(P=(x*T-1)*Math.pow(2,I),R+=y):(P=x*Math.pow(2,y-1)*Math.pow(2,I),R=0));8<=I;b[v+m]=255&P,m+=k,P/=256,I-=8);for(R=R<>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"]),to}var ro,io;function zs(){return io||(io=1,ro=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT"]),ro}var hr,oo;function Fc(){if(oo)return hr;oo=1;var t=Fs();return hr=t.slice().concat(["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uvec2","uvec3","uvec4","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","coherent","restrict","readonly","writeonly","resource","atomic_uint","noperspective","patch","sample","subroutine","common","partition","active","filter","image1D","image2D","image3D","imageCube","iimage1D","iimage2D","iimage3D","iimageCube","uimage1D","uimage2D","uimage3D","uimageCube","image1DArray","image2DArray","iimage1DArray","iimage2DArray","uimage1DArray","uimage2DArray","image1DShadow","image2DShadow","image1DArrayShadow","image2DArrayShadow","imageBuffer","iimageBuffer","uimageBuffer","sampler1DArray","sampler1DArrayShadow","isampler1D","isampler1DArray","usampler1D","usampler1DArray","isampler2DRect","usampler2DRect","samplerBuffer","isamplerBuffer","usamplerBuffer","sampler2DMS","isampler2DMS","usampler2DMS","sampler2DMSArray","isampler2DMSArray","usampler2DMSArray"]),hr}var mr,so;function zc(){if(so)return mr;so=1;var t=zs();return t=t.slice().filter(function(e){return!/^(gl\_|texture)/.test(e)}),mr=t.concat(["gl_VertexID","gl_InstanceID","gl_Position","gl_PointSize","gl_FragCoord","gl_FrontFacing","gl_FragDepth","gl_PointCoord","gl_MaxVertexAttribs","gl_MaxVertexUniformVectors","gl_MaxVertexOutputVectors","gl_MaxFragmentInputVectors","gl_MaxVertexTextureImageUnits","gl_MaxCombinedTextureImageUnits","gl_MaxTextureImageUnits","gl_MaxFragmentUniformVectors","gl_MaxDrawBuffers","gl_MinProgramTexelOffset","gl_MaxProgramTexelOffset","gl_DepthRangeParameters","gl_DepthRange","trunc","round","roundEven","isnan","isinf","floatBitsToInt","floatBitsToUint","intBitsToFloat","uintBitsToFloat","packSnorm2x16","unpackSnorm2x16","packUnorm2x16","unpackUnorm2x16","packHalf2x16","unpackHalf2x16","outerProduct","transpose","determinant","inverse","texture","textureSize","textureProj","textureLod","textureOffset","texelFetch","texelFetchOffset","textureProjOffset","textureLodOffset","textureProjLod","textureProjLodOffset","textureGrad","textureGradOffset","textureProjGrad","textureProjGradOffset"]),mr}var gr,ao;function Bc(){if(ao)return gr;ao=1,gr=R;var t=Fs(),e=Dc(),n=zs(),r=Fc(),i=zc(),o=999,s=9999,a=0,l=1,u=2,c=3,f=4,p=5,d=6,b=7,x=8,v=9,T=10,I=11,A=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"];function R(P){var h=0,M=0,y=o,g,m,k=[],_=[],F=1,j=0,D=0,z=!1,Q=!1,Z="",K;P=P||{};var E=n,te=t;P.version==="300 es"&&(E=i,te=r);for(var ge={},C={},h=0;h0)continue;we=fe.slice(0,1).join("")}return de(we),D+=we.length,k=k.slice(we.length),k.length}while(!0)}function Y(){return/[^a-fA-F0-9]/.test(g)?(de(k.join("")),y=o,h):(k.push(g),m=g,h+1)}function ne(){return g==="."||/[eE]/.test(g)?(k.push(g),y=p,m=g,h+1):g==="x"&&k.length===1&&k[0]==="0"?(y=I,k.push(g),m=g,h+1):/[^\d]/.test(g)?(de(k.join("")),y=o,h):(k.push(g),m=g,h+1)}function xe(){return g==="f"&&(k.push(g),m=g,h+=1),/[eE]/.test(g)||(g==="-"||g==="+")&&/[eE]/.test(m)?(k.push(g),m=g,h+1):/[^\d]/.test(g)?(de(k.join("")),y=o,h):(k.push(g),m=g,h+1)}function Ae(){if(/[^\d\w_]/.test(g)){var fe=k.join("");return C[fe]?y=x:ge[fe]?y=b:y=d,de(k.join("")),y=o,h}return k.push(g),m=g,h+1}}return gr}var yr,lo;function Uc(){if(lo)return yr;lo=1;var t=Bc();yr=e;function e(n,r){var i=t(r),o=[];return o=o.concat(i(n)),o=o.concat(i(null)),o}return yr}Uc();function jc(t,e){if(typeof t!="object"||t===null)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Vc(t){var e=jc(t,"string");return typeof e=="symbol"?e:String(e)}function Se(t,e,n){return e=Vc(e),e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var le={position:"csm_Position",positionRaw:"csm_PositionRaw",pointSize:"csm_PointSize",fragColor:"csm_FragColor",diffuseColor:"csm_DiffuseColor",normal:"csm_Normal",roughness:"csm_Roughness",metalness:"csm_Metalness",emissive:"csm_Emissive",ao:"csm_AO",bump:"csm_Bump",depthAlpha:"csm_DepthAlpha"},Ge,Ut;Ge={},Se(Ge,"".concat(le.normal),{"#include ":` + vec3 objectNormal = `.concat(le.normal,`; + #ifdef USE_TANGENT + vec3 objectTangent = vec3( tangent.xyz ); + #endif + `)}),Se(Ge,"".concat(le.position),{"#include ":` + vec3 transformed = `.concat(le.position,`; + `)}),Se(Ge,"".concat(le.positionRaw),{"#include ":` + vec4 csm_internal_positionUnprojected = `.concat(le.positionRaw,`; + mat4x4 csm_internal_unprojectMatrix = projectionMatrix * modelViewMatrix; + #ifdef USE_INSTANCING + csm_internal_unprojectMatrix = csm_internal_unprojectMatrix * instanceMatrix; + #endif + csm_internal_positionUnprojected = inverse(csm_internal_unprojectMatrix) * csm_internal_positionUnprojected; + vec3 transformed = csm_internal_positionUnprojected.xyz; + `)}),Se(Ge,"".concat(le.pointSize),{"gl_PointSize = size;":` + gl_PointSize = `.concat(le.pointSize,`; + `)}),Se(Ge,"".concat(le.diffuseColor),{"#include ":` + #include + diffuseColor = `.concat(le.diffuseColor,`; + `)}),Se(Ge,"".concat(le.fragColor),{"#include ":` + #include + gl_FragColor = `.concat(le.fragColor,`; + `)}),Se(Ge,"".concat(le.emissive),{"vec3 totalEmissiveRadiance = emissive;":` + vec3 totalEmissiveRadiance = `.concat(le.emissive,`; + `)}),Se(Ge,"".concat(le.roughness),{"#include ":` + #include + roughnessFactor = `.concat(le.roughness,`; + `)}),Se(Ge,"".concat(le.metalness),{"#include ":` + #include + metalnessFactor = `.concat(le.metalness,`; + `)}),Se(Ge,"".concat(le.ao),{"#include ":` + #include + reflectedLight.indirectDiffuse *= 1. - `.concat(le.ao,`; + `)}),Se(Ge,"".concat(le.bump),{"#include ":` + #include + + vec3 csm_internal_orthogonal = `.concat(le.bump," - (dot(").concat(le.bump,`, normal) * normal); + vec3 csm_internal_projectedbump = mat3(csm_internal_vModelViewMatrix) * csm_internal_orthogonal; + normal = normalize(normal - csm_internal_projectedbump); + `)}),Se(Ge,"".concat(le.depthAlpha),{"gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );":` + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity * `.concat(le.depthAlpha,` ); + `),"gl_FragColor = packDepthToRGBA( fragCoordZ );":` + gl_FragColor = packDepthToRGBA( fragCoordZ ); + gl_FragColor.a *= `.concat(le.depthAlpha,`; + `)});Ut={},Se(Ut,"".concat(le.position),{"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );":` + gl_Position = projectionMatrix * modelViewMatrix * vec4( `.concat(le.position,`, 1.0 ); + `)}),Se(Ut,"".concat(le.positionRaw),{"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );":` + gl_Position = `.concat(le.position,`; + `)}),Se(Ut,"".concat(le.diffuseColor),{"gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );":` + gl_FragColor = `.concat(le.diffuseColor,`; + `)}),Se(Ut,"".concat(le.fragColor),{"gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );":` + gl_FragColor = `.concat(le.fragColor,`; + `)});var $e;$e={},Se($e,"".concat(le.position),"*"),Se($e,"".concat(le.positionRaw),"*"),Se($e,"".concat(le.normal),"*"),Se($e,"".concat(le.pointSize),["PointsMaterial"]),Se($e,"".concat(le.diffuseColor),"*"),Se($e,"".concat(le.fragColor),"*"),Se($e,"".concat(le.emissive),["MeshStandardMaterial","MeshPhysicalMaterial"]),Se($e,"".concat(le.roughness),["MeshStandardMaterial","MeshPhysicalMaterial"]),Se($e,"".concat(le.metalness),["MeshStandardMaterial","MeshPhysicalMaterial"]),Se($e,"".concat(le.ao),["MeshStandardMaterial","MeshPhysicalMaterial","MeshBasicMaterial","MeshLambertMaterial","MeshPhongMaterial","MeshToonMaterial"]),Se($e,"".concat(le.bump),["MeshLambertMaterial","MeshMatcapMaterial","MeshNormalMaterial","MeshPhongMaterial","MeshPhysicalMaterial","MeshStandardMaterial","MeshToonMaterial","ShadowMaterial"]),Se($e,"".concat(le.depthAlpha),"*");var Hc=`void main() { + gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); +}`,Gc=`#include + +void main() { + vec2 center = vec2(0., 1.); + float rotation = 0.0; + + + + float size = 0.03; + + vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); + vec2 scale; + scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); + scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); + + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale * size; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + + gl_Position = projectionMatrix * mvPosition; +}`;const vn=new se(0,0,0),gi=new se(0,0,0),$c=new se(0,0,0);function uo(t,e,n){const r=vn.setFromMatrixPosition(t.matrixWorld);r.project(e);const i=n.width/2,o=n.height/2;return[(Number.isNaN(r.x)?0:r.x)*i+i,-(r.y*o)+o,r.z]}function qc(t,e){const n=vn.setFromMatrixPosition(t.matrixWorld),r=gi.setFromMatrixPosition(e.matrixWorld),i=n.sub(r),o=e.getWorldDirection($c);return i.angleTo(o)>Math.PI/2}function Yc(t,e,n,r){const i=vn.setFromMatrixPosition(t.matrixWorld),o=i.clone();o.project(e),n.setFromCamera(new Pe(o.x,o.y),e);const s=n.intersectObjects(r,!0);if(s.length>0){const a=s[0].distance;return i.distanceTo(n.ray.origin)Math.abs(t)<1e-10?0:t;function Bs(t,e,n=""){let r="matrix3d(";for(let i=0;i!==16;i++)r+=jr(e[i]*t.elements[i])+(i!==15?",":")");return n+r}const Xc=(t=>e=>Bs(e,t))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),Qc=(t=>(e,n)=>Bs(e,t(n),"translate(-50%,-50%)"))(t=>[1/t,1/t,1/t,1,-1/t,-1/t,-1/t,-1,1/t,1/t,1/t,1,1,1,1,1]),Zc=["geometry","material"];new os;var Vr={exports:{}},Jc=Vr.exports,co;function ef(){return co||(co=1,function(t,e){(function(n,r){t.exports=r()})(Jc,function(){var n=function(){function r(d){return s.appendChild(d.dom),d}function i(d){for(var b=0;bl+1e3&&(c.update(1e3*u/(d-l),100),l=d,u=0,p)){var b=performance.memory;p.update(b.usedJSHeapSize/1048576,b.jsHeapSizeLimit/1048576)}return d},update:function(){a=this.end()},domElement:s,setMode:i}};return n.Panel=function(r,i,o){var s=1/0,a=0,l=Math.round,u=l(window.devicePixelRatio||1),c=80*u,f=48*u,p=3*u,d=2*u,b=3*u,x=15*u,v=74*u,T=30*u,I=document.createElement("canvas");I.width=c,I.height=f,I.style.cssText="width:80px;height:48px";var A=I.getContext("2d");return A.font="bold "+9*u+"px Helvetica,Arial,sans-serif",A.textBaseline="top",A.fillStyle=o,A.fillRect(0,0,c,f),A.fillStyle=i,A.fillText(r,p,d),A.fillRect(b,x,v,T),A.fillStyle=o,A.globalAlpha=.9,A.fillRect(b,x,v,T),{dom:I,update:function(R,P){s=Math.min(s,R),a=Math.max(a,R),A.fillStyle=o,A.globalAlpha=1,A.fillRect(0,0,c,x),A.fillStyle=i,A.fillText(l(R)+" "+r+" ("+l(s)+"-"+l(a)+")",p,d),A.drawImage(I,b+u,x,v-u,T,b,x,v-u,T),A.fillRect(b+v-u,x,u,T),A.fillStyle=o,A.globalAlpha=.9,A.fillRect(b+v-u,x,u,l((1-R/P)*T))}}},n})}(Vr)),Vr.exports}ef();const tf={key:0,args:[0,1,64]},nf={key:1,args:[.5,1,64]},rf={key:2},of=["tone-mapped","map","side","color"];new ze(16777215);const jt=Fe({__name:"Range",props:{modelValue:null,min:{default:0},max:{default:100},step:{default:1},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","mousedown"],setup(t,{emit:e}){const n=t,r=e,i=X(null);function o(b,x,v){return Math.min(Math.max(b,x),v)}function s(b){const x=b.toString();return x.includes("e-")?Number.parseInt(x.split("e-")[1],10):x.includes(".")?x.split(".")[1].length:0}function a(b,x){const v=s(x),T=10**(v+3);return Number.parseFloat((b*T/T).toFixed(v))}const l=Ue(()=>a(o(n.modelValue,n.min,n.max),n.step)),u=Ue(()=>{const b=(l.value-n.min)/(n.max-n.min)*100;return{width:`${b}%`,backgroundSize:`${b}% 100%`}});function c(b){if(!i.value)return l.value;const x=i.value.getBoundingClientRect(),T=(b.clientX-x.left)/x.width,I=n.max-n.min,A=n.min+I*T,R=Math.round(A/n.step)*n.step;return Math.min(Math.max(R,n.min),n.max)}function f(b){if(n.disabled)return;const x=c(b);r("update:modelValue",x)}function p(b){if(n.disabled)return;b.preventDefault();const x=c(b);r("update:modelValue",x),window.addEventListener("mousemove",f),window.addEventListener("mouseup",d)}function d(b){window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",d)}return Ft(()=>{window.removeEventListener("mousemove",f),window.removeEventListener("mouseup",d)}),(b,x)=>(ee(),ie("span",{ref_key:"sliderRef",ref:i,class:Ct(["range-slider disabled:pointer-events-none disabled:cursor-default disabled:opacity-50",{disabled:t.disabled}]),bg:"[#e6e1fc] dark:[#676085]","touch-action-none":"",relative:"","inline-block":"","w-full":"","cursor-ew-resize":"","rounded-sm":"",onMousedown:p},[O("span",{style:Fr(u.value),bg:"[#cabeff] dark:[#4e34b9]",relative:"",block:"","rounded-sm":"",h:"[14px]"},null,4),O("span",{role:"slider",class:"slider-thumb",style:Fr({left:`${(l.value-t.min)/(t.max-t.min)*100}%`}),absolute:"","rounded-sm":"",w:"[1px]",h:"[14px]",bg:"zinc-100 dark:zinc-400",top:"50%",transform:"translate-x-[50%] translate-y-[-50%]"},null,4)],34))}});function fo(t,e){if(e===dl)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),t;if(e===zr||e===ds){let n=t.getIndex();if(n===null){const s=[],a=t.getAttribute("position");if(a!==void 0){for(let l=0;l=2.0 are supported."));return}const u=new Bf(o,{path:n||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(let c=0;c=0&&a[f]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+f+'".')}}u.setExtensions(s),u.setPlugins(a),u.parse(r,i)}parseAsync(e,n){const r=this;return new Promise(function(i,o){r.parse(e,n,i,o)})}}function af(){let t={};return{get:function(e){return t[e]},add:function(e,n){t[e]=n},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const pe={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class lf{constructor(e){this.parser=e,this.name=pe.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,n=this.parser.json.nodes||[];for(let r=0,i=n.length;r=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return n.loadTextureImage(e,o.source,s)}}class Tf{constructor(e){this.parser=e,this.name=pe.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const n=this.name,r=this.parser,i=r.json,o=i.textures[e];if(!o.extensions||!o.extensions[n])return null;const s=o.extensions[n],a=i.images[s.source];let l=r.textureLoader;if(a.uri){const u=r.options.manager.getHandler(a.uri);u!==null&&(l=u)}return this.detectSupport().then(function(u){if(u)return r.loadTextureImage(e,s.source,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class kf{constructor(e){this.parser=e,this.name=pe.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const n=this.name,r=this.parser,i=r.json,o=i.textures[e];if(!o.extensions||!o.extensions[n])return null;const s=o.extensions[n],a=i.images[s.source];let l=r.textureLoader;if(a.uri){const u=r.options.manager.getHandler(a.uri);u!==null&&(l=u)}return this.detectSupport().then(function(u){if(u)return r.loadTextureImage(e,s.source,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return r.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class Af{constructor(e){this.name=pe.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const n=this.parser.json,r=n.bufferViews[e];if(r.extensions&&r.extensions[this.name]){const i=r.extensions[this.name],o=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return o.then(function(a){const l=i.byteOffset||0,u=i.byteLength||0,c=i.count,f=i.byteStride,p=new Uint8Array(a,l,u);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(c,f,p,i.mode,i.filter).then(function(d){return d.buffer}):s.ready.then(function(){const d=new ArrayBuffer(c*f);return s.decodeGltfBuffer(new Uint8Array(d),c,f,p,i.mode,i.filter),d})})}else return null}}class _f{constructor(e){this.name=pe.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const n=this.parser.json,r=n.nodes[e];if(!r.extensions||!r.extensions[this.name]||r.mesh===void 0)return null;const i=n.meshes[r.mesh];for(const u of i.primitives)if(u.mode!==tt.TRIANGLES&&u.mode!==tt.TRIANGLE_STRIP&&u.mode!==tt.TRIANGLE_FAN&&u.mode!==void 0)return null;const s=r.extensions[this.name].attributes,a=[],l={};for(const u in s)a.push(this.parser.getDependency("accessor",s[u]).then(c=>(l[u]=c,l[u])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(u=>{const c=u.pop(),f=c.isGroup?c.children:[c],p=u[0].count,d=[];for(const b of f){const x=new yt,v=new se,T=new zn,I=new se(1,1,1),A=new yl(b.geometry,b.material,p);for(let R=0;R0||t.search(/^data\:image\/jpeg/)===0?"image/jpeg":t.search(/\.webp($|\?)/i)>0||t.search(/^data\:image\/webp/)===0?"image/webp":t.search(/\.ktx2($|\?)/i)>0||t.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const zf=new yt;class Bf{constructor(e={},n={}){this.json=e,this.extensions={},this.plugins={},this.options=n,this.cache=new af,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let r=!1,i=-1,o=!1,s=-1;if(typeof navigator<"u"){const a=navigator.userAgent;r=/^((?!chrome|android).)*safari/i.test(a)===!0;const l=a.match(/Version\/(\d+)/);i=r&&l?parseInt(l[1],10):-1,o=a.indexOf("Firefox")>-1,s=o?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||r&&i<17||o&&s<98?this.textureLoader=new vl(this.options.manager):this.textureLoader=new bl(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new ps(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,n){const r=this,i=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])}).then(function(s){const a={scene:s[0][i.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:i.asset,parser:r,userData:{}};return It(o,a,i),mt(a,i),Promise.all(r._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(const l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(n)}_markDefs(){const e=this.json.nodes||[],n=this.json.skins||[],r=this.json.meshes||[];for(let i=0,o=n.length;i{const l=this.associations.get(s);l!=null&&this.associations.set(a,l);for(const[u,c]of s.children.entries())o(c,a.children[u])};return o(r,i),i.name+="_instance_"+e.uses[n]++,i}_invokeOne(e){const n=Object.values(this.plugins);n.push(this);for(let r=0;r=2&&v.setY(g,h[M*l+1]),l>=3&&v.setZ(g,h[M*l+2]),l>=4&&v.setW(g,h[M*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}v.normalized=b}return v})}loadTexture(e){const n=this.json,r=this.options,o=n.textures[e].source,s=n.images[o];let a=this.textureLoader;if(s.uri){const l=r.manager.getHandler(s.uri);l!==null&&(a=l)}return this.loadTextureImage(e,o,a)}loadTextureImage(e,n,r){const i=this,o=this.json,s=o.textures[e],a=o.images[n],l=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[l])return this.textureCache[l];const u=this.loadImageSource(n,r).then(function(c){c.flipY=!1,c.name=s.name||a.name||"",c.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(c.name=a.uri);const p=(o.samplers||{})[s.sampler]||{};return c.magFilter=ho[p.magFilter]||Un,c.minFilter=ho[p.minFilter]||li,c.wrapS=mo[p.wrapS]||jn,c.wrapT=mo[p.wrapT]||jn,c.generateMipmaps=!c.isCompressedTexture&&c.minFilter!==Lt&&c.minFilter!==Un,i.associations.set(c,{textures:e}),c}).catch(function(){return null});return this.textureCache[l]=u,u}loadImageSource(e,n){const r=this,i=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(f=>f.clone());const s=i.images[e],a=self.URL||self.webkitURL;let l=s.uri||"",u=!1;if(s.bufferView!==void 0)l=r.getDependency("bufferView",s.bufferView).then(function(f){u=!0;const p=new Blob([f],{type:s.mimeType});return l=a.createObjectURL(p),l});else if(s.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(l).then(function(f){return new Promise(function(p,d){let b=p;n.isImageBitmapLoader===!0&&(b=function(x){const v=new Bn(x);v.needsUpdate=!0,p(v)}),n.load(un.resolveURL(f,o.path),b,void 0,d)})}).then(function(f){return u===!0&&a.revokeObjectURL(l),mt(f,s),f.userData.mimeType=s.mimeType||Ff(s.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),f});return this.sourceCache[e]=c,c}assignTexture(e,n,r,i){const o=this;return this.getDependency("texture",r.index).then(function(s){if(!s)return null;if(r.texCoord!==void 0&&r.texCoord>0&&(s=s.clone(),s.channel=r.texCoord),o.extensions[pe.KHR_TEXTURE_TRANSFORM]){const a=r.extensions!==void 0?r.extensions[pe.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=o.associations.get(s);s=o.extensions[pe.KHR_TEXTURE_TRANSFORM].extendTexture(s,a),o.associations.set(s,l)}}return i!==void 0&&(s.colorSpace=i),e[n]=s,s})}assignFinalMaterial(e){const n=e.geometry;let r=e.material;const i=n.attributes.tangent===void 0,o=n.attributes.color!==void 0,s=n.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+r.uuid;let l=this.cache.get(a);l||(l=new wl,rr.prototype.copy.call(l,r),l.color.copy(r.color),l.map=r.map,l.sizeAttenuation=!1,this.cache.add(a,l)),r=l}else if(e.isLine){const a="LineBasicMaterial:"+r.uuid;let l=this.cache.get(a);l||(l=new Tl,rr.prototype.copy.call(l,r),l.color.copy(r.color),l.map=r.map,this.cache.add(a,l)),r=l}if(i||o||s){let a="ClonedMaterial:"+r.uuid+":";i&&(a+="derivative-tangents:"),o&&(a+="vertex-colors:"),s&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=r.clone(),o&&(l.vertexColors=!0),s&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(r))),r=l}e.material=r}getMaterialType(){return hs}loadMaterial(e){const n=this,r=this.json,i=this.extensions,o=r.materials[e];let s;const a={},l=o.extensions||{},u=[];if(l[pe.KHR_MATERIALS_UNLIT]){const f=i[pe.KHR_MATERIALS_UNLIT];s=f.getMaterialType(),u.push(f.extendParams(a,o,n))}else{const f=o.pbrMetallicRoughness||{};if(a.color=new ze(1,1,1),a.opacity=1,Array.isArray(f.baseColorFactor)){const p=f.baseColorFactor;a.color.setRGB(p[0],p[1],p[2],xt),a.opacity=p[3]}f.baseColorTexture!==void 0&&u.push(n.assignTexture(a,"map",f.baseColorTexture,mn)),a.metalness=f.metallicFactor!==void 0?f.metallicFactor:1,a.roughness=f.roughnessFactor!==void 0?f.roughnessFactor:1,f.metallicRoughnessTexture!==void 0&&(u.push(n.assignTexture(a,"metalnessMap",f.metallicRoughnessTexture)),u.push(n.assignTexture(a,"roughnessMap",f.metallicRoughnessTexture))),s=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),u.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,a)})))}o.doubleSided===!0&&(a.side=Kn);const c=o.alphaMode||vr.OPAQUE;if(c===vr.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,c===vr.MASK&&(a.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&s!==Ht&&(u.push(n.assignTexture(a,"normalMap",o.normalTexture)),a.normalScale=new Pe(1,1),o.normalTexture.scale!==void 0)){const f=o.normalTexture.scale;a.normalScale.set(f,f)}if(o.occlusionTexture!==void 0&&s!==Ht&&(u.push(n.assignTexture(a,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&s!==Ht){const f=o.emissiveFactor;a.emissive=new ze().setRGB(f[0],f[1],f[2],xt)}return o.emissiveTexture!==void 0&&s!==Ht&&u.push(n.assignTexture(a,"emissiveMap",o.emissiveTexture,mn)),Promise.all(u).then(function(){const f=new s(a);return o.name&&(f.name=o.name),mt(f,o),n.associations.set(f,{materials:e}),o.extensions&&It(i,f,o),f})}createUniqueName(e){const n=hn.sanitizeNodeName(e||"");return n in this.nodeNamesUsed?n+"_"+ ++this.nodeNamesUsed[n]:(this.nodeNamesUsed[n]=0,n)}loadGeometries(e){const n=this,r=this.extensions,i=this.primitiveCache;function o(a){return r[pe.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,n).then(function(l){return go(l,a,n)})}const s=[];for(let a=0,l=e.length;a0&&Of(T,o),T.name=n.createUniqueName(o.name||"mesh_"+e),mt(T,o),v.extensions&&It(i,T,v),n.assignFinalMaterial(T),f.push(T)}for(let d=0,b=f.length;d1?c=new ir:u.length===1?c=u[0]:c=new ui,c!==u[0])for(let f=0,p=u.length;f{const f=new Map;for(const[p,d]of i.associations)(p instanceof rr||p instanceof Bn)&&f.set(p,d);return c.traverse(p=>{const d=i.associations.get(p);d!=null&&f.set(p,d)}),f};return i.associations=u(o),o})}_createAnimationTracks(e,n,r,i,o){const s=[],a=e.name?e.name:e.uuid,l=[];wt[o.path]===wt.weights?e.traverse(function(p){p.morphTargetInfluences&&l.push(p.name?p.name:p.uuid)}):l.push(a);let u;switch(wt[o.path]){case wt.weights:u=Oi;break;case wt.rotation:u=Di;break;case wt.position:case wt.scale:u=Pi;break;default:switch(r.itemSize){case 1:u=Oi;break;case 2:case 3:default:u=Pi;break}break}const c=i.interpolation!==void 0?Nf[i.interpolation]:ii,f=this._getArrayFromAccessor(r);for(let p=0,d=l.length;pnew Ra(t)),Rt.register(t=>new Ca(t)),Rt)}async function jf(t){const r=(await Vs().loadAsync(t)).userData;if(!r.vrmAnimations){console.warn("No VRM animations found in the .vrma file");return}if(r.vrmAnimations.length===0){console.warn("No VRM animations found in the .vrma file");return}return r.vrmAnimations[0]}async function Vf(t,e){if(!t){console.warn("No VRM found");return}if(e)return Na(e,t)}function Hf(){const t=X(!1),e=X(0),n=X(0),r=.2,i=1,o=6,s=X(Math.random()*(o-i)+i);function a(l,u){if(l!=null&&l.expressionManager&&(n.value+=u,!t.value&&n.value>=s.value&&(t.value=!0,e.value=0),t.value)){e.value+=u/r;const c=Math.sin(Math.PI*e.value);l.expressionManager.setValue("blink",c),e.value>=1&&(t.value=!1,n.value=0,l.expressionManager.setValue("blink",0),s.value=Math.random()*(o-i)+i)}}return{update:a}}function Gf(){let t=-1,e,n=0;function r(){e?e.set(rn(-.25,.25),rn(-.2,.15),-.65):e=new se(rn(-.25,.25),rn(-.2,.15),-.65)}function i(o,s){var a;!(o!=null&&o.expressionManager)||!o.lookAt||(n>=t?(r(),n=0,t=La()/1e3):e||r(),o.lookAt.target||(o.lookAt.target=new ui),o.lookAt.target.position.lerp(e,rn(.2,.5)),(a=o.lookAt)==null||a.update(s),n+=s)}return{update:i}}async function $f(t,e){const i=(await Vs().loadAsync(t,s=>{var a;return(a=e==null?void 0:e.onProgress)==null?void 0:a.call(e,s)})).userData;if(!i.vrm)return;const o=i.vrm;if(Pr.removeUnnecessaryVertices(o.scene),Pr.combineSkeletons(o.scene),o.scene.traverse(s=>{s.frustumCulled=!1}),o.lookAt){const s=new Pa(o.lookAt);s.name="lookAtQuaternionProxy",o.scene.add(s)}return e!=null&&e.scene&&e.scene.add(o.scene),e!=null&&e.position&&o.scene.position.set(...e.position),o}function qf(t){const e=X(null),n=X(!1),r=X(0),i=X(new Map),o=X(new Map),s=X(),a=(T,I,A)=>T+(I-T)*A,l=T=>T<.5?4*T*T*T:1-(-2*T+2)**3/2,u=new Map([["happy",{expression:[{name:"happy",value:1,duration:.3},{name:"aa",value:.3}],blendDuration:.3}],["sad",{expression:[{name:"sad",value:1},{name:"oh",value:.2}],blendDuration:.3}],["angry",{expression:[{name:"angry",value:1},{name:"ee",value:.4}],blendDuration:.2}],["surprised",{expression:[{name:"Surprised",value:1},{name:"oh",value:.6}],blendDuration:.1}],["neutral",{expression:[{name:"neutral",value:1}],blendDuration:.5}]]),c=()=>{s.value&&(clearTimeout(s.value),s.value=void 0)},f=T=>{var A;if(c(),!u.has(T)){console.warn(`Emotion ${T} not found`);return}const I=u.get(T);if(e.value=T,n.value=!0,r.value=0,t.expressionManager){const R=Object.keys(t.expressionManager.expressionMap);for(const P of R)t.expressionManager.setValue(P,0)}i.value.clear(),o.value.clear();for(const R of I.expression||[]){const P=((A=t.expressionManager)==null?void 0:A.getValue(R.name))||0;i.value.set(R.name,P),o.value.set(R.name,R.value)}};return{currentEmotion:e,isTransitioning:n,setEmotion:f,setEmotionWithResetAfter:(T,I)=>{c(),f(T),s.value=setTimeout(()=>{f("neutral"),s.value=void 0},I)},update:T=>{var R;if(!n.value||!e.value)return;const A=u.get(e.value).blendDuration||.3;r.value+=T/A,r.value>=1&&(r.value=1,n.value=!1);for(const[P,h]of o.value){const M=i.value.get(P)||0,y=a(M,h,l(r.value));(R=t.expressionManager)==null||R.setValue(P,y)}},addEmotionState:(T,I)=>{u.set(T,I)},removeEmotionState:T=>{u.delete(T)},dispose:()=>{c()}}}const Yf=Fe({__name:"Model",props:{model:null,idleAnimation:null,loadAnimations:null,position:null,paused:{type:Boolean}},emits:["loadModelProgress","error"],setup(t,{expose:e,emit:n}){const r=t,i=n;let o;const s=X(),a=X(),{scene:l}=Yn(),{onBeforeRender:u}=Fn(),c=Hf(),f=Gf(),p=X();je(()=>r.position,([x,v,T])=>{s.value&&s.value.scene.position.set(x,v,T)}),dn(async()=>{if(l.value)try{const x=await $f(r.model,{scene:l.value,lookAt:!0,position:r.position,onProgress:I=>i("loadModelProgress",Number.parseFloat((100*(I.loaded/I.total)).toFixed(2)))});if(!x){console.warn("No VRM model loaded");return}const v=await jf(r.idleAnimation),T=await Vf(x,v);if(!T){console.warn("No VRM animation loaded");return}a.value=new Ll(x.scene),a.value.clipAction(T).play(),p.value=qf(x),s.value=x,o=u(({delta:I})=>{var A,R,P;(A=a.value)==null||A.update(I),(R=s.value)==null||R.update(I),c.update(s.value,I),f.update(s.value,I),(P=p.value)==null||P.update(I)}).off}catch(x){i("error",x)}}),Ft(()=>{o==null||o(),s.value&&(s.value.scene.removeFromParent(),Pr.deepDispose(s.value.scene))}),e({setExpression(x){var v;(v=p.value)==null||v.setEmotionWithResetAfter(x,1e3)}});const{pause:d,resume:b}=Fn();return je(()=>r.paused,x=>{x?d():b()}),(x,v)=>gn(x.$slots,"default")}}),Kf=["position"],Wf={absolute:"",bottom:"3",right:"3"},Xf={flex:"~ row","cursor-pointer":""},Qf=["checked","aria-checked"],Zf={key:0,"min-w":"50vw",z:"{var x;(x=p.value)==null||x.setExpression(b)}}),(b,x)=>(ee(),Xt(ws,{relative:""},{default:Be(({height:v,width:T})=>[Te(H(Pl),{alpha:!0,antialias:!0,width:T,height:v},{default:Be(()=>[Te(H(Pc)),O("TresPerspectiveCamera",{position:[s.value,a.value,l.value]},null,8,Kf),x[14]||(x[14]=O("TresDirectionalLight",{color:16777215,intensity:1.2,position:[1,1,1]},null,-1)),x[15]||(x[15]=O("TresAmbientLight",{color:16777215,intensity:1.5},null,-1)),Te(Yf,{ref_key:"modelRef",ref:p,model:r.model,"idle-animation":r.idleAnimation,position:[u.value,c.value,f.value],paused:r.paused,onLoadModelProgress:x[0]||(x[0]=I=>i("loadModelProgress",I)),onError:x[1]||(x[1]=I=>i("error",I))},null,8,["model","idle-animation","position","paused"])]),_:2},1032,["width","height"]),O("div",Wf,[O("div",Xf,[O("label",{class:Ct([o.value?"bg-zinc-300 dark:bg-zinc-200":"bg-zinc-100 dark:bg-zinc-700"]),transition:"all ease-in-out duration-500",text:"lg zinc-500 dark:zinc-400","m-1":"","h-fit":"","w-fit":"","cursor-pointer":"","appearance-none":"","gap-1":"","rounded-lg":"","rounded-md":"","border-none":"","p-2":"","outline-none":""},[At(O("input",{"onUpdate:modelValue":x[2]||(x[2]=I=>o.value=I),checked:o.value,"aria-checked":o.value,name:"showLive2DViewerInspector",type:"checkbox",hidden:"","appearance-none":"","outline-none":""},null,8,Qf),[[ni,o.value]]),x[16]||(x[16]=O("div",{"select-none":""},[O("div",{"i-solar:bug-bold-duotone":""})],-1))],2)]),Te(pi,null,{default:Be(()=>[o.value?(ee(),ie("div",Zf,[O("div",Jf,[O("div",ed,[O("span",null,me(H(d)("stage.viewers.debug-menu.vrm.model.title")),1)]),Te(zi,{"h-fit":"","w-full":"",flex:"~ col",border:"~ gray/25 rounded-lg",divide:"y dashed gray/25","of-clip":"","shadow-sm":""},{label:Be(()=>[O("span",td,me(H(d)("stage.viewers.debug-menu.vrm.camera")),1)]),default:Be(()=>[O("div",nd,[x[17]||(x[17]=O("div",{text:"zinc-400 dark:zinc-500"},[O("span",null,"X")],-1)),O("label",rd,[Te(jt,{modelValue:s.value,"onUpdate:modelValue":x[3]||(x[3]=I=>s.value=I),min:-10,max:10,step:.01},null,8,["modelValue"])]),O("div",id,[O("span",null,me(s.value),1)]),x[18]||(x[18]=O("div",{text:"zinc-400 dark:zinc-500"},[O("span",null,"Y")],-1)),O("label",od,[Te(jt,{modelValue:a.value,"onUpdate:modelValue":x[4]||(x[4]=I=>a.value=I),min:-10,max:10,step:.01},null,8,["modelValue"])]),O("div",sd,[O("span",null,me(a.value),1)]),x[19]||(x[19]=O("div",{text:"zinc-400 dark:zinc-500"},[O("span",null,"Z")],-1)),O("label",ad,[Te(jt,{modelValue:l.value,"onUpdate:modelValue":x[5]||(x[5]=I=>l.value=I),min:-10,max:10,step:.01},null,8,["modelValue"])]),O("div",ld,[O("span",null,me(l.value),1)])])]),_:1}),Te(zi,{"h-fit":"","w-full":"",flex:"~ col",border:"~ gray/25 rounded-lg",divide:"y dashed gray/25","of-clip":"","shadow-sm":""},{label:Be(()=>[O("span",ud,me(H(d)("stage.viewers.debug-menu.vrm.model.title")),1)]),default:Be(()=>[O("div",cd,[x[20]||(x[20]=O("div",{text:"zinc-400 dark:zinc-500"},[O("span",null,"X")],-1)),O("label",fd,[Te(jt,{modelValue:u.value,"onUpdate:modelValue":x[6]||(x[6]=I=>u.value=I),min:-10,max:10,step:.01},null,8,["modelValue"])]),O("div",dd,[O("span",null,me(u.value),1)]),x[21]||(x[21]=O("div",{text:"zinc-400 dark:zinc-500"},[O("span",null,"Y")],-1)),O("label",pd,[Te(jt,{modelValue:c.value,"onUpdate:modelValue":x[7]||(x[7]=I=>c.value=I),min:-10,max:10,step:.01},null,8,["modelValue"])]),O("div",hd,[O("span",null,me(c.value),1)]),x[22]||(x[22]=O("div",{text:"zinc-400 dark:zinc-500"},[O("span",null,"Z")],-1)),O("label",md,[Te(jt,{modelValue:f.value,"onUpdate:modelValue":x[8]||(x[8]=I=>f.value=I),min:-10,max:10,step:.01},null,8,["modelValue"])]),O("div",gd,[O("span",null,me(f.value),1)])])]),_:1}),O("div",yd,[O("span",null,me(H(d)("stage.viewers.debug-menu.emotions")),1)]),O("div",xd,[O("button",{"rounded-lg":"",bg:"zinc-100/70 dark:zinc-800/50","px-2":"","py-1":"","backdrop-blur-sm":"",onClick:x[9]||(x[9]=I=>{var A;return(A=p.value)==null?void 0:A.setExpression("neutral")})},me(H(d)("stage.viewers.debug-menu.emotions-btn.neutral")),1),O("button",{"rounded-lg":"",bg:"zinc-100/70 dark:zinc-800/50","px-2":"","py-1":"","backdrop-blur-sm":"",onClick:x[10]||(x[10]=I=>{var A;return(A=p.value)==null?void 0:A.setExpression("surprised")})},me(H(d)("stage.viewers.debug-menu.emotions-btn.surprised")),1),O("button",{"rounded-lg":"",bg:"zinc-100/70 dark:zinc-800/50","px-2":"","py-1":"","backdrop-blur-sm":"",onClick:x[11]||(x[11]=I=>{var A;return(A=p.value)==null?void 0:A.setExpression("sad")})},me(H(d)("stage.viewers.debug-menu.emotions-btn.sad")),1),O("button",{"rounded-lg":"",bg:"zinc-100/70 dark:zinc-800/50","px-2":"","py-1":"","backdrop-blur-sm":"",onClick:x[12]||(x[12]=I=>{var A;return(A=p.value)==null?void 0:A.setExpression("angry")})},me(H(d)("stage.viewers.debug-menu.emotions-btn.angry")),1),O("button",{"rounded-lg":"",bg:"zinc-100/70 dark:zinc-800/50","px-2":"","py-1":"","backdrop-blur-sm":"",onClick:x[13]||(x[13]=I=>{var A;return(A=p.value)==null?void 0:A.setExpression("happy")})},me(H(d)("stage.viewers.debug-menu.emotions-btn.happy")),1)])])])):it("",!0)]),_:1})])]),_:1}))}}),bd=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class bn{constructor(e,n,r){this.normal=n,this.property=e,r&&(this.space=r)}}bn.prototype.normal={};bn.prototype.property={};bn.prototype.space=void 0;function Hs(t,e){const n={},r={};for(const i of t)Object.assign(n,i.property),Object.assign(r,i.normal);return new bn(n,r,e)}function $r(t){return t.toLowerCase()}class Ke{constructor(e,n){this.attribute=n,this.property=e}}Ke.prototype.attribute="";Ke.prototype.booleanish=!1;Ke.prototype.boolean=!1;Ke.prototype.commaOrSpaceSeparated=!1;Ke.prototype.commaSeparated=!1;Ke.prototype.defined=!1;Ke.prototype.mustUseProperty=!1;Ke.prototype.number=!1;Ke.prototype.overloadedBoolean=!1;Ke.prototype.property="";Ke.prototype.spaceSeparated=!1;Ke.prototype.space=void 0;let wd=0;const ce=zt(),Le=zt(),Gs=zt(),$=zt(),Re=zt(),Yt=zt(),Qe=zt();function zt(){return 2**++wd}const qr=Object.freeze(Object.defineProperty({__proto__:null,boolean:ce,booleanish:Le,commaOrSpaceSeparated:Qe,commaSeparated:Yt,number:$,overloadedBoolean:Gs,spaceSeparated:Re},Symbol.toStringTag,{value:"Module"})),wr=Object.keys(qr);class yi extends Ke{constructor(e,n,r,i){let o=-1;if(super(e,n),yo(this,"space",i),typeof r=="number")for(;++o4&&n.slice(0,4)==="data"&&_d.test(e)){if(e.charAt(4)==="-"){const o=e.slice(5).replace(xo,Sd);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=e.slice(4);if(!xo.test(o)){let s=o.replace(Ad,Md);s.charAt(0)!=="-"&&(s="-"+s),e="data"+s}}i=yi}return new i(r,e)}function Md(t){return"-"+t.toLowerCase()}function Sd(t){return t.charAt(1).toUpperCase()}const Id=Hs([$s,Td,Ks,Ws,Xs],"html"),Qs=Hs([$s,kd,Ks,Ws,Xs],"svg"),vo={}.hasOwnProperty;function Rd(t,e){const n=e||{};function r(i,...o){let s=r.invalid;const a=r.handlers;if(i&&vo.call(i,t)){const l=String(i[t]);s=vo.call(a,l)?a[l]:r.unknown}if(s)return s.call(this,i,...o)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}const Cd=/["&'<>`]/g,Nd=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Ld=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,Pd=/[|\\{}()[\]^$+*?.]/g,bo=new WeakMap;function Od(t,e){if(t=t.replace(e.subset?Dd(e.subset):Cd,r),e.subset||e.escapeOnly)return t;return t.replace(Nd,n).replace(Ld,r);function n(i,o,s){return e.format((i.charCodeAt(0)-55296)*1024+i.charCodeAt(1)-56320+65536,s.charCodeAt(o+2),e)}function r(i,o,s){return e.format(i.charCodeAt(0),s.charCodeAt(o+1),e)}}function Dd(t){let e=bo.get(t);return e||(e=Fd(t),bo.set(t,e)),e}function Fd(t){const e=[];let n=-1;for(;++n",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"},Hd=["cent","copy","divide","gt","lt","not","para","times"],Zs={}.hasOwnProperty,Yr={};let In;for(In in Tr)Zs.call(Tr,In)&&(Yr[Tr[In]]=In);const Gd=/[^\dA-Za-z]/;function $d(t,e,n,r){const i=String.fromCharCode(t);if(Zs.call(Yr,i)){const o=Yr[i],s="&"+o;return n&&Vd.includes(o)&&!Hd.includes(o)&&(!r||e&&e!==61&&Gd.test(String.fromCharCode(e)))?s:s+";"}return""}function qd(t,e,n){let r=Bd(t,e,n.omitOptionalSemicolons),i;if((n.useNamedReferences||n.useShortestReferences)&&(i=$d(t,e,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!i)&&n.useShortestReferences){const o=jd(t,e,n.omitOptionalSemicolons);o.length|^->||--!>|"],Wd=["<",">"];function Xd(t,e,n,r){return r.settings.bogusComments?"":"";function i(o){return Kt(o,Object.assign({},r.settings.characterReferences,{subset:Wd}))}}function Qd(t,e,n,r){return""}function wo(t,e){const n=String(t);if(typeof e!="string")throw new TypeError("Expected character");let r=0,i=n.indexOf(e);for(;i!==-1;)r++,i=n.indexOf(e,i+e.length);return r}function Zd(t,e){const n=e||{};return(t[t.length-1]===""?[...t,""]:t).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function Jd(t){return t.join(" ").trim()}const ep=/[ \t\n\f\r]/g;function xi(t){return typeof t=="object"?t.type==="text"?To(t.value):!1:To(t)}function To(t){return t.replace(ep,"")===""}const Oe=ea(1),Js=ea(-1),tp=[];function ea(t){return e;function e(n,r,i){const o=n?n.children:tp;let s=(r||0)+t,a=o[s];if(!i)for(;a&&xi(a);)s+=t,a=o[s];return a}}const np={}.hasOwnProperty;function ta(t){return e;function e(n,r,i){return np.call(t,n.tagName)&&t[n.tagName](n,r,i)}}const vi=ta({body:ip,caption:kr,colgroup:kr,dd:lp,dt:ap,head:kr,html:rp,li:sp,optgroup:up,option:cp,p:op,rp:ko,rt:ko,tbody:dp,td:Ao,tfoot:pp,th:Ao,thead:fp,tr:hp});function kr(t,e,n){const r=Oe(n,e,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&xi(r.value.charAt(0)))}function rp(t,e,n){const r=Oe(n,e);return!r||r.type!=="comment"}function ip(t,e,n){const r=Oe(n,e);return!r||r.type!=="comment"}function op(t,e,n){const r=Oe(n,e);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function sp(t,e,n){const r=Oe(n,e);return!r||r.type==="element"&&r.tagName==="li"}function ap(t,e,n){const r=Oe(n,e);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function lp(t,e,n){const r=Oe(n,e);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function ko(t,e,n){const r=Oe(n,e);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function up(t,e,n){const r=Oe(n,e);return!r||r.type==="element"&&r.tagName==="optgroup"}function cp(t,e,n){const r=Oe(n,e);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function fp(t,e,n){const r=Oe(n,e);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function dp(t,e,n){const r=Oe(n,e);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function pp(t,e,n){return!Oe(n,e)}function hp(t,e,n){const r=Oe(n,e);return!r||r.type==="element"&&r.tagName==="tr"}function Ao(t,e,n){const r=Oe(n,e);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const mp=ta({body:xp,colgroup:vp,head:yp,html:gp,tbody:bp});function gp(t){const e=Oe(t,-1);return!e||e.type!=="comment"}function yp(t){const e=new Set;for(const r of t.children)if(r.type==="element"&&(r.tagName==="base"||r.tagName==="title")){if(e.has(r.tagName))return!1;e.add(r.tagName)}const n=t.children[0];return!n||n.type==="element"}function xp(t){const e=Oe(t,-1,!0);return!e||e.type!=="comment"&&!(e.type==="text"&&xi(e.value.charAt(0)))&&!(e.type==="element"&&(e.tagName==="meta"||e.tagName==="link"||e.tagName==="script"||e.tagName==="style"||e.tagName==="template"))}function vp(t,e,n){const r=Js(n,e),i=Oe(t,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&vi(r,n.children.indexOf(r),n)?!1:!!(i&&i.type==="element"&&i.tagName==="col")}function bp(t,e,n){const r=Js(n,e),i=Oe(t,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&vi(r,n.children.indexOf(r),n)?!1:!!(i&&i.type==="element"&&i.tagName==="tr")}const Rn={name:[[` +\f\r &/=>`.split(""),` +\f\r "&'/=>\``.split("")],[`\0 +\f\r "&'/<=>`.split(""),`\0 +\f\r "&'/<=>\``.split("")]],unquoted:[[` +\f\r &>`.split(""),`\0 +\f\r "&'<=>\``.split("")],[`\0 +\f\r "&'<=>\``.split(""),`\0 +\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function wp(t,e,n,r){const i=r.schema,o=i.space==="svg"?!1:r.settings.omitOptionalTags;let s=i.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(t.tagName.toLowerCase());const a=[];let l;i.space==="html"&&t.tagName==="svg"&&(r.schema=Qs);const u=Tp(r,t.properties),c=r.all(i.space==="html"&&t.tagName==="template"?t.content:t);return r.schema=i,c&&(s=!1),(u||!o||!mp(t,e,n))&&(a.push("<",t.tagName,u?" "+u:""),s&&(i.space==="svg"||r.settings.closeSelfClosing)&&(l=u.charAt(u.length-1),(!r.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&a.push(" "),a.push("/")),a.push(">")),a.push(c),!s&&(!o||!vi(t,e,n))&&a.push(""),a.join("")}function Tp(t,e){const n=[];let r=-1,i;if(e){for(i in e)if(e[i]!==null&&e[i]!==void 0){const o=kp(t,i,e[i]);o&&n.push(o)}}for(;++rwo(n,t.alternative)&&(s=t.alternative),a=s+Kt(n,Object.assign({},t.settings.characterReferences,{subset:(s==="'"?Rn.single:Rn.double)[i][o],attribute:!0}))+s),l+(a&&"="+a))}const Ap=["<","&"];function na(t,e,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?t.value:Kt(t.value,Object.assign({},r.settings.characterReferences,{subset:Ap}))}function _p(t,e,n,r){return r.settings.allowDangerousHtml?t.value:na(t,e,n,r)}function Ep(t,e,n,r){return r.all(t)}const Mp=Rd("type",{invalid:Sp,unknown:Ip,handlers:{comment:Xd,doctype:Qd,element:wp,raw:_p,root:Ep,text:na}});function Sp(t){throw new Error("Expected node, not `"+t+"`")}function Ip(t){const e=t;throw new Error("Cannot compile unknown node `"+e.type+"`")}const Rp={},Cp={},Np=[];function Lp(t,e){const n=e||Rp,r=n.quote||'"',i=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:Pp,all:Op,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||bd,characterReferences:n.characterReferences||Cp,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?Qs:Id,quote:r,alternative:i}.one(Array.isArray(t)?{type:"root",children:t}:t,void 0,void 0)}function Pp(t,e,n){return Mp(t,e,n,this)}function Op(t){const e=[],n=t&&t.children||Np;let r=-1;for(;++ri?0:i+e:e=e>i?i:e,n=n>0?n:0,r.length<1e4)s=Array.from(r),s.unshift(e,n),t.splice(...s);else for(n&&t.splice(e,n);o0?(ut(t,t.length,0,e),t):e}const Mo={}.hasOwnProperty;function Up(t){const e={};let n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Wt(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const lt=St(/[A-Za-z]/),Je=St(/[\dA-Za-z]/),Hp=St(/[#-'*+\--9=?A-Z^-~]/);function Kr(t){return t!==null&&(t<32||t===127)}const Wr=St(/\d/),Gp=St(/[\dA-Fa-f]/),$p=St(/[!-/:-@[-`{-~]/);function ae(t){return t!==null&&t<-2}function Ye(t){return t!==null&&(t<0||t===32)}function _e(t){return t===-2||t===-1||t===32}const qp=St(new RegExp("\\p{P}|\\p{S}","u")),Yp=St(/\s/);function St(t){return e;function e(n){return n!==null&&n>-1&&t.test(String.fromCharCode(n))}}function Zt(t){const e=[];let n=-1,r=0,i=0;for(;++n55295&&o<57344){const a=t.charCodeAt(n+1);o<56320&&a>56319&&a<57344?(s=String.fromCharCode(o,a),i=1):s="�"}else s=String.fromCharCode(o);s&&(e.push(t.slice(r,n),encodeURIComponent(s)),r=n+i+1,s=""),i&&(n+=i,i=0)}return e.join("")+t.slice(r)}function Ce(t,e,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let o=0;return s;function s(l){return _e(l)?(t.enter(n),a(l)):e(l)}function a(l){return _e(l)&&o++s))return;const M=e.events.length;let y=M,g,m;for(;y--;)if(e.events[y][0]==="exit"&&e.events[y][1].type==="chunkFlow"){if(g){m=e.events[y][1].end;break}g=!0}for(T(r),h=M;hA;){const P=n[R];e.containerState=P[1],P[0].exit.call(e,t)}n.length=A}function I(){i.write([null]),o=void 0,i=void 0,e.containerState._closeFlow=void 0}}function Zp(t,e,n){return Ce(t,t.attempt(this.parser.constructs.document,e,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Io(t){if(t===null||Ye(t)||Yp(t))return 1;if(qp(t))return 2}function wi(t,e,n){const r=[];let i=-1;for(;++i1&&t[n][1].end.offset-t[n][1].start.offset>1?2:1;const f={...t[r][1].end},p={...t[n][1].start};Ro(f,-l),Ro(p,l),s={type:l>1?"strongSequence":"emphasisSequence",start:f,end:{...t[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...t[n][1].start},end:p},o={type:l>1?"strongText":"emphasisText",start:{...t[r][1].end},end:{...t[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...s.start},end:{...a.end}},t[r][1].end={...s.start},t[n][1].start={...a.end},u=[],t[r][1].end.offset-t[r][1].start.offset&&(u=nt(u,[["enter",t[r][1],e],["exit",t[r][1],e]])),u=nt(u,[["enter",i,e],["enter",s,e],["exit",s,e],["enter",o,e]]),u=nt(u,wi(e.parser.constructs.insideSpan.null,t.slice(r+1,n),e)),u=nt(u,[["exit",o,e],["enter",a,e],["exit",a,e],["exit",i,e]]),t[n][1].end.offset-t[n][1].start.offset?(c=2,u=nt(u,[["enter",t[n][1],e],["exit",t[n][1],e]])):c=0,ut(t,r-1,n-r+3,u),n=r+u.length-c-2;break}}for(n=-1;++n0&&_e(h)?Ce(t,I,"linePrefix",o+1)(h):I(h)}function I(h){return h===null||ae(h)?t.check(Co,x,R)(h):(t.enter("codeFlowValue"),A(h))}function A(h){return h===null||ae(h)?(t.exit("codeFlowValue"),I(h)):(t.consume(h),A)}function R(h){return t.exit("codeFenced"),e(h)}function P(h,M,y){let g=0;return m;function m(D){return h.enter("lineEnding"),h.consume(D),h.exit("lineEnding"),k}function k(D){return h.enter("codeFencedFence"),_e(D)?Ce(h,_,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):_(D)}function _(D){return D===a?(h.enter("codeFencedFenceSequence"),F(D)):y(D)}function F(D){return D===a?(g++,h.consume(D),F):g>=s?(h.exit("codeFencedFenceSequence"),_e(D)?Ce(h,j,"whitespace")(D):j(D)):y(D)}function j(D){return D===null||ae(D)?(h.exit("codeFencedFence"),M(D)):y(D)}}}function ch(t,e,n){const r=this;return i;function i(s){return s===null?n(s):(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),o)}function o(s){return r.parser.lazy[r.now().line]?n(s):e(s)}}const Ar={name:"codeIndented",tokenize:dh},fh={partial:!0,tokenize:ph};function dh(t,e,n){const r=this;return i;function i(u){return t.enter("codeIndented"),Ce(t,o,"linePrefix",5)(u)}function o(u){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?s(u):n(u)}function s(u){return u===null?l(u):ae(u)?t.attempt(fh,s,l)(u):(t.enter("codeFlowValue"),a(u))}function a(u){return u===null||ae(u)?(t.exit("codeFlowValue"),s(u)):(t.consume(u),a)}function l(u){return t.exit("codeIndented"),e(u)}}function ph(t,e,n){const r=this;return i;function i(s){return r.parser.lazy[r.now().line]?n(s):ae(s)?(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),i):Ce(t,o,"linePrefix",5)(s)}function o(s){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?e(s):ae(s)?i(s):n(s)}}const hh={name:"codeText",previous:gh,resolve:mh,tokenize:yh};function mh(t){let e=t.length-4,n=3,r,i;if((t[n][1].type==="lineEnding"||t[n][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(r=n;++r=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return ethis.left.length)return this.right.slice(this.right.length-r+this.left.length,this.right.length-e+this.left.length).reverse();const i=this.left.slice(e);return i.push(...this.right.slice(this.right.length-r+this.left.length).reverse()),i}splice(e,n,r){const i=n||0;this.setCursor(Math.trunc(e));const o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&sn(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),sn(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),sn(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e=4?e(s):t.interrupt(r.parser.constructs.flow,n,e)(s)}}function ua(t,e,n,r,i,o,s,a,l){const u=l||Number.POSITIVE_INFINITY;let c=0;return f;function f(T){return T===60?(t.enter(r),t.enter(i),t.enter(o),t.consume(T),t.exit(o),p):T===null||T===32||T===41||Kr(T)?n(T):(t.enter(r),t.enter(s),t.enter(a),t.enter("chunkString",{contentType:"string"}),x(T))}function p(T){return T===62?(t.enter(o),t.consume(T),t.exit(o),t.exit(i),t.exit(r),e):(t.enter(a),t.enter("chunkString",{contentType:"string"}),d(T))}function d(T){return T===62?(t.exit("chunkString"),t.exit(a),p(T)):T===null||T===60||ae(T)?n(T):(t.consume(T),T===92?b:d)}function b(T){return T===60||T===62||T===92?(t.consume(T),d):d(T)}function x(T){return!c&&(T===null||T===41||Ye(T))?(t.exit("chunkString"),t.exit(a),t.exit(s),t.exit(r),e(T)):c999||d===null||d===91||d===93&&!l||d===94&&!a&&"_hiddenFootnoteSupport"in s.parser.constructs?n(d):d===93?(t.exit(o),t.enter(i),t.consume(d),t.exit(i),t.exit(r),e):ae(d)?(t.enter("lineEnding"),t.consume(d),t.exit("lineEnding"),c):(t.enter("chunkString",{contentType:"string"}),f(d))}function f(d){return d===null||d===91||d===93||ae(d)||a++>999?(t.exit("chunkString"),c(d)):(t.consume(d),l||(l=!_e(d)),d===92?p:f)}function p(d){return d===91||d===92||d===93?(t.consume(d),a++,f):f(d)}}function fa(t,e,n,r,i,o){let s;return a;function a(p){return p===34||p===39||p===40?(t.enter(r),t.enter(i),t.consume(p),t.exit(i),s=p===40?41:p,l):n(p)}function l(p){return p===s?(t.enter(i),t.consume(p),t.exit(i),t.exit(r),e):(t.enter(o),u(p))}function u(p){return p===s?(t.exit(o),l(s)):p===null?n(p):ae(p)?(t.enter("lineEnding"),t.consume(p),t.exit("lineEnding"),Ce(t,u,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),c(p))}function c(p){return p===s||p===null||ae(p)?(t.exit("chunkString"),u(p)):(t.consume(p),p===92?f:c)}function f(p){return p===s||p===92?(t.consume(p),c):c(p)}}function cn(t,e){let n;return r;function r(i){return ae(i)?(t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),n=!0,r):_e(i)?Ce(t,r,n?"linePrefix":"lineSuffix")(i):e(i)}}const _h={name:"definition",tokenize:Mh},Eh={partial:!0,tokenize:Sh};function Mh(t,e,n){const r=this;let i;return o;function o(d){return t.enter("definition"),s(d)}function s(d){return ca.call(r,t,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(d)}function a(d){return i=Wt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),d===58?(t.enter("definitionMarker"),t.consume(d),t.exit("definitionMarker"),l):n(d)}function l(d){return Ye(d)?cn(t,u)(d):u(d)}function u(d){return ua(t,c,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(d)}function c(d){return t.attempt(Eh,f,f)(d)}function f(d){return _e(d)?Ce(t,p,"whitespace")(d):p(d)}function p(d){return d===null||ae(d)?(t.exit("definition"),r.parser.defined.push(i),e(d)):n(d)}}function Sh(t,e,n){return r;function r(a){return Ye(a)?cn(t,i)(a):n(a)}function i(a){return fa(t,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function o(a){return _e(a)?Ce(t,s,"whitespace")(a):s(a)}function s(a){return a===null||ae(a)?e(a):n(a)}}const Ih={name:"hardBreakEscape",tokenize:Rh};function Rh(t,e,n){return r;function r(o){return t.enter("hardBreakEscape"),t.consume(o),i}function i(o){return ae(o)?(t.exit("hardBreakEscape"),e(o)):n(o)}}const Ch={name:"headingAtx",resolve:Nh,tokenize:Lh};function Nh(t,e){let n=t.length-2,r=3,i,o;return t[r][1].type==="whitespace"&&(r+=2),n-2>r&&t[n][1].type==="whitespace"&&(n-=2),t[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&t[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:t[r][1].start,end:t[n][1].end},o={type:"chunkText",start:t[r][1].start,end:t[n][1].end,contentType:"text"},ut(t,r,n-r+1,[["enter",i,e],["enter",o,e],["exit",o,e],["exit",i,e]])),t}function Lh(t,e,n){let r=0;return i;function i(c){return t.enter("atxHeading"),o(c)}function o(c){return t.enter("atxHeadingSequence"),s(c)}function s(c){return c===35&&r++<6?(t.consume(c),s):c===null||Ye(c)?(t.exit("atxHeadingSequence"),a(c)):n(c)}function a(c){return c===35?(t.enter("atxHeadingSequence"),l(c)):c===null||ae(c)?(t.exit("atxHeading"),e(c)):_e(c)?Ce(t,a,"whitespace")(c):(t.enter("atxHeadingText"),u(c))}function l(c){return c===35?(t.consume(c),l):(t.exit("atxHeadingSequence"),a(c))}function u(c){return c===null||c===35||Ye(c)?(t.exit("atxHeadingText"),a(c)):(t.consume(c),u)}}const Ph=["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","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Lo=["pre","script","style","textarea"],Oh={concrete:!0,name:"htmlFlow",resolveTo:zh,tokenize:Bh},Dh={partial:!0,tokenize:jh},Fh={partial:!0,tokenize:Uh};function zh(t){let e=t.length;for(;e--&&!(t[e][0]==="enter"&&t[e][1].type==="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t}function Bh(t,e,n){const r=this;let i,o,s,a,l;return u;function u(C){return c(C)}function c(C){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(C),f}function f(C){return C===33?(t.consume(C),p):C===47?(t.consume(C),o=!0,x):C===63?(t.consume(C),i=3,r.interrupt?e:E):lt(C)?(t.consume(C),s=String.fromCharCode(C),v):n(C)}function p(C){return C===45?(t.consume(C),i=2,d):C===91?(t.consume(C),i=5,a=0,b):lt(C)?(t.consume(C),i=4,r.interrupt?e:E):n(C)}function d(C){return C===45?(t.consume(C),r.interrupt?e:E):n(C)}function b(C){const de="CDATA[";return C===de.charCodeAt(a++)?(t.consume(C),a===de.length?r.interrupt?e:_:b):n(C)}function x(C){return lt(C)?(t.consume(C),s=String.fromCharCode(C),v):n(C)}function v(C){if(C===null||C===47||C===62||Ye(C)){const de=C===47,ke=s.toLowerCase();return!de&&!o&&Lo.includes(ke)?(i=1,r.interrupt?e(C):_(C)):Ph.includes(s.toLowerCase())?(i=6,de?(t.consume(C),T):r.interrupt?e(C):_(C)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(C):o?I(C):A(C))}return C===45||Je(C)?(t.consume(C),s+=String.fromCharCode(C),v):n(C)}function T(C){return C===62?(t.consume(C),r.interrupt?e:_):n(C)}function I(C){return _e(C)?(t.consume(C),I):m(C)}function A(C){return C===47?(t.consume(C),m):C===58||C===95||lt(C)?(t.consume(C),R):_e(C)?(t.consume(C),A):m(C)}function R(C){return C===45||C===46||C===58||C===95||Je(C)?(t.consume(C),R):P(C)}function P(C){return C===61?(t.consume(C),h):_e(C)?(t.consume(C),P):A(C)}function h(C){return C===null||C===60||C===61||C===62||C===96?n(C):C===34||C===39?(t.consume(C),l=C,M):_e(C)?(t.consume(C),h):y(C)}function M(C){return C===l?(t.consume(C),l=null,g):C===null||ae(C)?n(C):(t.consume(C),M)}function y(C){return C===null||C===34||C===39||C===47||C===60||C===61||C===62||C===96||Ye(C)?P(C):(t.consume(C),y)}function g(C){return C===47||C===62||_e(C)?A(C):n(C)}function m(C){return C===62?(t.consume(C),k):n(C)}function k(C){return C===null||ae(C)?_(C):_e(C)?(t.consume(C),k):n(C)}function _(C){return C===45&&i===2?(t.consume(C),z):C===60&&i===1?(t.consume(C),Q):C===62&&i===4?(t.consume(C),te):C===63&&i===3?(t.consume(C),E):C===93&&i===5?(t.consume(C),K):ae(C)&&(i===6||i===7)?(t.exit("htmlFlowData"),t.check(Dh,ge,F)(C)):C===null||ae(C)?(t.exit("htmlFlowData"),F(C)):(t.consume(C),_)}function F(C){return t.check(Fh,j,ge)(C)}function j(C){return t.enter("lineEnding"),t.consume(C),t.exit("lineEnding"),D}function D(C){return C===null||ae(C)?F(C):(t.enter("htmlFlowData"),_(C))}function z(C){return C===45?(t.consume(C),E):_(C)}function Q(C){return C===47?(t.consume(C),s="",Z):_(C)}function Z(C){if(C===62){const de=s.toLowerCase();return Lo.includes(de)?(t.consume(C),te):_(C)}return lt(C)&&s.length<8?(t.consume(C),s+=String.fromCharCode(C),Z):_(C)}function K(C){return C===93?(t.consume(C),E):_(C)}function E(C){return C===62?(t.consume(C),te):C===45&&i===2?(t.consume(C),E):_(C)}function te(C){return C===null||ae(C)?(t.exit("htmlFlowData"),ge(C)):(t.consume(C),te)}function ge(C){return t.exit("htmlFlow"),e(C)}}function Uh(t,e,n){const r=this;return i;function i(s){return ae(s)?(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),o):n(s)}function o(s){return r.parser.lazy[r.now().line]?n(s):e(s)}}function jh(t,e,n){return r;function r(i){return t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),t.attempt(Zn,e,n)}}const Vh={name:"htmlText",tokenize:Hh};function Hh(t,e,n){const r=this;let i,o,s;return a;function a(E){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(E),l}function l(E){return E===33?(t.consume(E),u):E===47?(t.consume(E),P):E===63?(t.consume(E),A):lt(E)?(t.consume(E),y):n(E)}function u(E){return E===45?(t.consume(E),c):E===91?(t.consume(E),o=0,b):lt(E)?(t.consume(E),I):n(E)}function c(E){return E===45?(t.consume(E),d):n(E)}function f(E){return E===null?n(E):E===45?(t.consume(E),p):ae(E)?(s=f,Q(E)):(t.consume(E),f)}function p(E){return E===45?(t.consume(E),d):f(E)}function d(E){return E===62?z(E):E===45?p(E):f(E)}function b(E){const te="CDATA[";return E===te.charCodeAt(o++)?(t.consume(E),o===te.length?x:b):n(E)}function x(E){return E===null?n(E):E===93?(t.consume(E),v):ae(E)?(s=x,Q(E)):(t.consume(E),x)}function v(E){return E===93?(t.consume(E),T):x(E)}function T(E){return E===62?z(E):E===93?(t.consume(E),T):x(E)}function I(E){return E===null||E===62?z(E):ae(E)?(s=I,Q(E)):(t.consume(E),I)}function A(E){return E===null?n(E):E===63?(t.consume(E),R):ae(E)?(s=A,Q(E)):(t.consume(E),A)}function R(E){return E===62?z(E):A(E)}function P(E){return lt(E)?(t.consume(E),h):n(E)}function h(E){return E===45||Je(E)?(t.consume(E),h):M(E)}function M(E){return ae(E)?(s=M,Q(E)):_e(E)?(t.consume(E),M):z(E)}function y(E){return E===45||Je(E)?(t.consume(E),y):E===47||E===62||Ye(E)?g(E):n(E)}function g(E){return E===47?(t.consume(E),z):E===58||E===95||lt(E)?(t.consume(E),m):ae(E)?(s=g,Q(E)):_e(E)?(t.consume(E),g):z(E)}function m(E){return E===45||E===46||E===58||E===95||Je(E)?(t.consume(E),m):k(E)}function k(E){return E===61?(t.consume(E),_):ae(E)?(s=k,Q(E)):_e(E)?(t.consume(E),k):g(E)}function _(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(t.consume(E),i=E,F):ae(E)?(s=_,Q(E)):_e(E)?(t.consume(E),_):(t.consume(E),j)}function F(E){return E===i?(t.consume(E),i=void 0,D):E===null?n(E):ae(E)?(s=F,Q(E)):(t.consume(E),F)}function j(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||Ye(E)?g(E):(t.consume(E),j)}function D(E){return E===47||E===62||Ye(E)?g(E):n(E)}function z(E){return E===62?(t.consume(E),t.exit("htmlTextData"),t.exit("htmlText"),e):n(E)}function Q(E){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(E),t.exit("lineEnding"),Z}function Z(E){return _e(E)?Ce(t,K,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):K(E)}function K(E){return t.enter("htmlTextData"),s(E)}}const Ti={name:"labelEnd",resolveAll:Yh,resolveTo:Kh,tokenize:Wh},Gh={tokenize:Xh},$h={tokenize:Qh},qh={tokenize:Zh};function Yh(t){let e=-1;const n=[];for(;++e=3&&(u===null||ae(u))?(t.exit("thematicBreak"),e(u)):n(u)}function l(u){return u===i?(t.consume(u),r++,l):(t.exit("thematicBreakSequence"),_e(u)?Ce(t,a,"whitespace")(u):a(u))}}const qe={continuation:{tokenize:lm},exit:cm,name:"list",tokenize:am},om={partial:!0,tokenize:fm},sm={partial:!0,tokenize:um};function am(t,e,n){const r=this,i=r.events[r.events.length-1];let o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,s=0;return a;function a(d){const b=r.containerState.type||(d===42||d===43||d===45?"listUnordered":"listOrdered");if(b==="listUnordered"?!r.containerState.marker||d===r.containerState.marker:Wr(d)){if(r.containerState.type||(r.containerState.type=b,t.enter(b,{_container:!0})),b==="listUnordered")return t.enter("listItemPrefix"),d===42||d===45?t.check(Dn,n,u)(d):u(d);if(!r.interrupt||d===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),l(d)}return n(d)}function l(d){return Wr(d)&&++s<10?(t.consume(d),l):(!r.interrupt||s<2)&&(r.containerState.marker?d===r.containerState.marker:d===41||d===46)?(t.exit("listItemValue"),u(d)):n(d)}function u(d){return t.enter("listItemMarker"),t.consume(d),t.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||d,t.check(Zn,r.interrupt?n:c,t.attempt(om,p,f))}function c(d){return r.containerState.initialBlankLine=!0,o++,p(d)}function f(d){return _e(d)?(t.enter("listItemPrefixWhitespace"),t.consume(d),t.exit("listItemPrefixWhitespace"),p):n(d)}function p(d){return r.containerState.size=o+r.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(d)}}function lm(t,e,n){const r=this;return r.containerState._closeFlow=void 0,t.check(Zn,i,o);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ce(t,e,"listItemIndent",r.containerState.size+1)(a)}function o(a){return r.containerState.furtherBlankLines||!_e(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,s(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,t.attempt(sm,e,s)(a))}function s(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ce(t,t.attempt(qe,e,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function um(t,e,n){const r=this;return Ce(t,i,"listItemIndent",r.containerState.size+1);function i(o){const s=r.events[r.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===r.containerState.size?e(o):n(o)}}function cm(t){t.exit(this.containerState.type)}function fm(t,e,n){const r=this;return Ce(t,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){const s=r.events[r.events.length-1];return!_e(o)&&s&&s[1].type==="listItemPrefixWhitespace"?e(o):n(o)}}const Po={name:"setextUnderline",resolveTo:dm,tokenize:pm};function dm(t,e){let n=t.length,r,i,o;for(;n--;)if(t[n][0]==="enter"){if(t[n][1].type==="content"){r=n;break}t[n][1].type==="paragraph"&&(i=n)}else t[n][1].type==="content"&&t.splice(n,1),!o&&t[n][1].type==="definition"&&(o=n);const s={type:"setextHeading",start:{...t[i][1].start},end:{...t[t.length-1][1].end}};return t[i][1].type="setextHeadingText",o?(t.splice(i,0,["enter",s,e]),t.splice(o+1,0,["exit",t[r][1],e]),t[r][1].end={...t[o][1].end}):t[r][1]=s,t.push(["exit",s,e]),t}function pm(t,e,n){const r=this;let i;return o;function o(u){let c=r.events.length,f;for(;c--;)if(r.events[c][1].type!=="lineEnding"&&r.events[c][1].type!=="linePrefix"&&r.events[c][1].type!=="content"){f=r.events[c][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(t.enter("setextHeadingLine"),i=u,s(u)):n(u)}function s(u){return t.enter("setextHeadingLineSequence"),a(u)}function a(u){return u===i?(t.consume(u),a):(t.exit("setextHeadingLineSequence"),_e(u)?Ce(t,l,"lineSuffix")(u):l(u))}function l(u){return u===null||ae(u)?(t.exit("setextHeadingLine"),e(u)):n(u)}}const hm={tokenize:mm};function mm(t){const e=this,n=t.attempt(Zn,r,t.attempt(this.parser.constructs.flowInitial,i,Ce(t,t.attempt(this.parser.constructs.flow,i,t.attempt(bh,i)),"linePrefix")));return n;function r(o){if(o===null){t.consume(o);return}return t.enter("lineEndingBlank"),t.consume(o),t.exit("lineEndingBlank"),e.currentConstruct=void 0,n}function i(o){if(o===null){t.consume(o);return}return t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),e.currentConstruct=void 0,n}}const gm={resolveAll:pa()},ym=da("string"),xm=da("text");function da(t){return{resolveAll:pa(t==="text"?vm:void 0),tokenize:e};function e(n){const r=this,i=this.parser.constructs[t],o=n.attempt(i,s,a);return s;function s(c){return u(c)?o(c):a(c)}function a(c){if(c===null){n.consume(c);return}return n.enter("data"),n.consume(c),l}function l(c){return u(c)?(n.exit("data"),o(c)):(n.consume(c),l)}function u(c){if(c===null)return!0;const f=i[c];let p=-1;if(f)for(;++p-1){const a=s[0];typeof a=="string"?s[0]=a.slice(r):s.shift()}o>0&&s.push(t[i].slice(0,o))}return s}function Nm(t,e){let n=-1;const r=[];let i;for(;++n0){const He=oe.tokenStack[oe.tokenStack.length-1];(He[1]||zo).call(oe,void 0,He[0])}for(W.position={start:Tt(U.length>0?U[0][1].start:{line:1,column:1,offset:0}),end:Tt(U.length>0?U[U.length-2][1].end:{line:1,column:1,offset:0})},be=-1;++be1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(s)}]};t.patch(e,l);const u={type:"element",tagName:"sup",properties:{},children:[l]};return t.patch(e,u),t.applyData(e,u)}function Wm(t,e){const n={type:"element",tagName:"h"+e.depth,properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function Xm(t,e){if(t.options.allowDangerousHtml){const n={type:"raw",value:e.value};return t.patch(e,n),t.applyData(e,n)}}function ga(t,e){const n=e.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(e.label||e.identifier)+"]"),e.type==="imageReference")return[{type:"text",value:"!["+e.alt+r}];const i=t.all(e),o=i[0];o&&o.type==="text"?o.value="["+o.value:i.unshift({type:"text",value:"["});const s=i[i.length-1];return s&&s.type==="text"?s.value+=r:i.push({type:"text",value:r}),i}function Qm(t,e){const n=String(e.identifier).toUpperCase(),r=t.definitionById.get(n);if(!r)return ga(t,e);const i={src:Zt(r.url||""),alt:e.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"img",properties:i,children:[]};return t.patch(e,o),t.applyData(e,o)}function Zm(t,e){const n={src:Zt(e.url)};e.alt!==null&&e.alt!==void 0&&(n.alt=e.alt),e.title!==null&&e.title!==void 0&&(n.title=e.title);const r={type:"element",tagName:"img",properties:n,children:[]};return t.patch(e,r),t.applyData(e,r)}function Jm(t,e){const n={type:"text",value:e.value.replace(/\r?\n|\r/g," ")};t.patch(e,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return t.patch(e,r),t.applyData(e,r)}function eg(t,e){const n=String(e.identifier).toUpperCase(),r=t.definitionById.get(n);if(!r)return ga(t,e);const i={href:Zt(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"a",properties:i,children:t.all(e)};return t.patch(e,o),t.applyData(e,o)}function tg(t,e){const n={href:Zt(e.url)};e.title!==null&&e.title!==void 0&&(n.title=e.title);const r={type:"element",tagName:"a",properties:n,children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function ng(t,e,n){const r=t.all(e),i=n?rg(n):ya(e),o={},s=[];if(typeof e.checked=="boolean"){const c=r[0];let f;c&&c.type==="element"&&c.tagName==="p"?f=c:(f={type:"element",tagName:"p",properties:{},children:[]},r.unshift(f)),f.children.length>0&&f.children.unshift({type:"text",value:" "}),f.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:e.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let a=-1;for(;++a1}function ig(t,e){const n={},r=t.all(e);let i=-1;for(typeof e.start=="number"&&e.start!==1&&(n.start=e.start);++i0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function lg(t){const e=va(t),n=xa(t);if(e&&n)return{start:e,end:n}}function ug(t,e){const n=t.all(e),r=n.shift(),i=[];if(r){const s={type:"element",tagName:"thead",properties:{},children:t.wrap([r],!0)};t.patch(e.children[0],s),i.push(s)}if(n.length>0){const s={type:"element",tagName:"tbody",properties:{},children:t.wrap(n,!0)},a=va(e.children[1]),l=xa(e.children[e.children.length-1]);a&&l&&(s.position={start:a,end:l}),i.push(s)}const o={type:"element",tagName:"table",properties:{},children:t.wrap(i,!0)};return t.patch(e,o),t.applyData(e,o)}function cg(t,e,n){const r=n?n.children:void 0,o=(r?r.indexOf(e):1)===0?"th":"td",s=n&&n.type==="table"?n.align:void 0,a=s?s.length:e.children.length;let l=-1;const u=[];for(;++l0,!0),r[0]),i=r.index+r[0].length,r=n.exec(e);return o.push(jo(e.slice(i),i>0,!1)),o.join("")}function jo(t,e,n){let r=0,i=t.length;if(e){let o=t.codePointAt(r);for(;o===Bo||o===Uo;)r++,o=t.codePointAt(r)}if(n){let o=t.codePointAt(i-1);for(;o===Bo||o===Uo;)i--,o=t.codePointAt(i-1)}return i>r?t.slice(r,i):""}function pg(t,e){const n={type:"text",value:dg(String(e.value))};return t.patch(e,n),t.applyData(e,n)}function hg(t,e){const n={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(e,n),t.applyData(e,n)}const mg={blockquote:Hm,break:Gm,code:$m,delete:qm,emphasis:Ym,footnoteReference:Km,heading:Wm,html:Xm,imageReference:Qm,image:Zm,inlineCode:Jm,linkReference:eg,link:tg,listItem:ng,list:ig,paragraph:og,root:sg,strong:ag,table:ug,tableCell:fg,tableRow:cg,text:pg,thematicBreak:hg,toml:Cn,yaml:Cn,definition:Cn,footnoteDefinition:Cn};function Cn(){}const wa=-1,Jn=0,Hn=1,Gn=2,ki=3,Ai=4,_i=5,Ei=6,Ta=7,ka=8,Vo=typeof self=="object"?self:globalThis,gg=(t,e)=>{const n=(i,o)=>(t.set(o,i),i),r=i=>{if(t.has(i))return t.get(i);const[o,s]=e[i];switch(o){case Jn:case wa:return n(s,i);case Hn:{const a=n([],i);for(const l of s)a.push(r(l));return a}case Gn:{const a=n({},i);for(const[l,u]of s)a[r(l)]=r(u);return a}case ki:return n(new Date(s),i);case Ai:{const{source:a,flags:l}=s;return n(new RegExp(a,l),i)}case _i:{const a=n(new Map,i);for(const[l,u]of s)a.set(r(l),r(u));return a}case Ei:{const a=n(new Set,i);for(const l of s)a.add(r(l));return a}case Ta:{const{name:a,message:l}=s;return n(new Vo[a](l),i)}case ka:return n(BigInt(s),i);case"BigInt":return n(Object(BigInt(s)),i)}return n(new Vo[o](s),i)};return r},Ho=t=>gg(new Map,t)(0),Vt="",{toString:yg}={},{keys:xg}=Object,an=t=>{const e=typeof t;if(e!=="object"||!t)return[Jn,e];const n=yg.call(t).slice(8,-1);switch(n){case"Array":return[Hn,Vt];case"Object":return[Gn,Vt];case"Date":return[ki,Vt];case"RegExp":return[Ai,Vt];case"Map":return[_i,Vt];case"Set":return[Ei,Vt]}return n.includes("Array")?[Hn,n]:n.includes("Error")?[Ta,n]:[Gn,n]},Nn=([t,e])=>t===Jn&&(e==="function"||e==="symbol"),vg=(t,e,n,r)=>{const i=(s,a)=>{const l=r.push(s)-1;return n.set(a,l),l},o=s=>{if(n.has(s))return n.get(s);let[a,l]=an(s);switch(a){case Jn:{let c=s;switch(l){case"bigint":a=ka,c=s.toString();break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+l);c=null;break;case"undefined":return i([wa],s)}return i([a,c],s)}case Hn:{if(l)return i([l,[...s]],s);const c=[],f=i([a,c],s);for(const p of s)c.push(o(p));return f}case Gn:{if(l)switch(l){case"BigInt":return i([l,s.toString()],s);case"Boolean":case"Number":case"String":return i([l,s.valueOf()],s)}if(e&&"toJSON"in s)return o(s.toJSON());const c=[],f=i([a,c],s);for(const p of xg(s))(t||!Nn(an(s[p])))&&c.push([o(p),o(s[p])]);return f}case ki:return i([a,s.toISOString()],s);case Ai:{const{source:c,flags:f}=s;return i([a,{source:c,flags:f}],s)}case _i:{const c=[],f=i([a,c],s);for(const[p,d]of s)(t||!(Nn(an(p))||Nn(an(d))))&&c.push([o(p),o(d)]);return f}case Ei:{const c=[],f=i([a,c],s);for(const p of s)(t||!Nn(an(p)))&&c.push(o(p));return f}}const{message:u}=s;return i([a,{name:l,message:u}],s)};return o},Go=(t,{json:e,lossy:n}={})=>{const r=[];return vg(!(e||n),!!e,new Map,r)(t),r},$n=typeof structuredClone=="function"?(t,e)=>e&&("json"in e||"lossy"in e)?Ho(Go(t,e)):structuredClone(t):(t,e)=>Ho(Go(t,e));function bg(t,e){const n=[{type:"text",value:"↩"}];return e>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(e)}]}),n}function wg(t,e){return"Back to reference "+(t+1)+(e>1?"-"+e:"")}function Tg(t){const e=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",n=t.options.footnoteBackContent||bg,r=t.options.footnoteBackLabel||wg,i=t.options.footnoteLabel||"Footnotes",o=t.options.footnoteLabelTagName||"h2",s=t.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let l=-1;for(;++l0&&b.push({type:"text",value:" "});let I=typeof n=="string"?n:n(l,d);typeof I=="string"&&(I={type:"text",value:I}),b.push({type:"element",tagName:"a",properties:{href:"#"+e+"fnref-"+p+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(l,d),className:["data-footnote-backref"]},children:Array.isArray(I)?I:[I]})}const v=c[c.length-1];if(v&&v.type==="element"&&v.tagName==="p"){const I=v.children[v.children.length-1];I&&I.type==="text"?I.value+=" ":v.children.push({type:"text",value:" "}),v.children.push(...b)}else c.push(...b);const T={type:"element",tagName:"li",properties:{id:e+"fn-"+p},children:t.wrap(c,!0)};t.patch(u,T),a.push(T)}if(a.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...$n(s),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:` +`},{type:"element",tagName:"ol",properties:{},children:t.wrap(a,!0)},{type:"text",value:` +`}]}}const Aa=function(t){if(t==null)return Eg;if(typeof t=="function")return er(t);if(typeof t=="object")return Array.isArray(t)?kg(t):Ag(t);if(typeof t=="string")return _g(t);throw new Error("Expected function, string, or object as test")};function kg(t){const e=[];let n=-1;for(;++n":""))+")"})}return p;function p(){let d=_a,b,x,v;if((!e||o(l,u,c[c.length-1]||void 0))&&(d=Cg(n(l,c)),d[0]===$o))return d;if("children"in l&&l.children){const T=l;if(T.children&&d[0]!==Ig)for(x=(r?T.children.length:-1)+s,v=c.concat(T);x>-1&&x0&&n.push({type:"text",value:` +`}),n}function qo(t){let e=0,n=t.charCodeAt(e);for(;n===9||n===32;)e++,n=t.charCodeAt(e);return t.slice(e)}function Yo(t,e){const n=Pg(t,e),r=n.one(t,void 0),i=Tg(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&o.children.push({type:"text",value:` +`},i),o}function Bg(t,e){return t&&"run"in t?async function(n,r){const i=Yo(n,{file:r,...e});await t.run(i,r)}:function(n,r){return Yo(n,{file:r,...t||e})}}function Ko(t){if(t)throw t}var Er,Wo;function Ug(){if(Wo)return Er;Wo=1;var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):e.call(u)==="[object Array]"},o=function(u){if(!u||e.call(u)!=="[object Object]")return!1;var c=t.call(u,"constructor"),f=u.constructor&&u.constructor.prototype&&t.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!c&&!f)return!1;var p;for(p in u);return typeof p>"u"||t.call(u,p)},s=function(u,c){n&&c.name==="__proto__"?n(u,c.name,{enumerable:!0,configurable:!0,value:c.newValue,writable:!0}):u[c.name]=c.newValue},a=function(u,c){if(c==="__proto__")if(t.call(u,c)){if(r)return r(u,c).value}else return;return u[c]};return Er=function l(){var u,c,f,p,d,b,x=arguments[0],v=1,T=arguments.length,I=!1;for(typeof x=="boolean"&&(I=x,x=arguments[1]||{},v=2),(x==null||typeof x!="object"&&typeof x!="function")&&(x={});vs.length;let l;a&&s.push(i);try{l=t.apply(this,s)}catch(u){const c=u;if(a&&n)throw c;return i(c)}a||(l&&l.then&&typeof l.then=="function"?l.then(o,i):l instanceof Error?i(l):o(l))}function i(s,...a){n||(n=!0,e(s,...a))}function o(s){i(null,s)}}class We extends Error{constructor(e,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",o={},s=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof e=="string"?i=e:!o.cause&&e&&(s=!0,i=e.message,o.cause=e),!o.ruleId&&!o.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?o.ruleId=r:(o.source=r.slice(0,l),o.ruleId=r.slice(l+1))}if(!o.place&&o.ancestors&&o.ancestors){const l=o.ancestors[o.ancestors.length-1];l&&(o.place=l.position)}const a=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file,this.message=i,this.line=a?a.line:void 0,this.name=fn(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=s&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual,this.expected,this.note,this.url}}We.prototype.file="";We.prototype.name="";We.prototype.reason="";We.prototype.message="";We.prototype.stack="";We.prototype.column=void 0;We.prototype.line=void 0;We.prototype.ancestors=void 0;We.prototype.cause=void 0;We.prototype.fatal=void 0;We.prototype.place=void 0;We.prototype.ruleId=void 0;We.prototype.source=void 0;const at={basename:Gg,dirname:$g,extname:qg,join:Yg,sep:"/"};function Gg(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');wn(t);let n=0,r=-1,i=t.length,o;if(e===void 0||e.length===0||e.length>t.length){for(;i--;)if(t.codePointAt(i)===47){if(o){n=i+1;break}}else r<0&&(o=!0,r=i+1);return r<0?"":t.slice(n,r)}if(e===t)return"";let s=-1,a=e.length-1;for(;i--;)if(t.codePointAt(i)===47){if(o){n=i+1;break}}else s<0&&(o=!0,s=i+1),a>-1&&(t.codePointAt(i)===e.codePointAt(a--)?a<0&&(r=i):(a=-1,r=s));return n===r?r=s:r<0&&(r=t.length),t.slice(n,r)}function $g(t){if(wn(t),t.length===0)return".";let e=-1,n=t.length,r;for(;--n;)if(t.codePointAt(n)===47){if(r){e=n;break}}else r||(r=!0);return e<0?t.codePointAt(0)===47?"/":".":e===1&&t.codePointAt(0)===47?"//":t.slice(0,e)}function qg(t){wn(t);let e=t.length,n=-1,r=0,i=-1,o=0,s;for(;e--;){const a=t.codePointAt(e);if(a===47){if(s){r=e+1;break}continue}n<0&&(s=!0,n=e+1),a===46?i<0?i=e:o!==1&&(o=1):i>-1&&(o=-1)}return i<0||n<0||o===0||o===1&&i===n-1&&i===r+1?"":t.slice(i,n)}function Yg(...t){let e=-1,n;for(;++e0&&t.codePointAt(t.length-1)===47&&(n+="/"),e?"/"+n:n}function Wg(t,e){let n="",r=0,i=-1,o=0,s=-1,a,l;for(;++s<=t.length;){if(s2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",r=0):(n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/")),i=s,o=0;continue}}else if(n.length>0){n="",r=0,i=s,o=0;continue}}e&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+t.slice(i+1,s):n=t.slice(i+1,s),r=s-i-1;i=s,o=0}else a===46&&o>-1?o++:o=-1}return n}function wn(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const Xg={cwd:Qg};function Qg(){return"/"}function ei(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function Zg(t){if(typeof t=="string")t=new URL(t);else if(!ei(t)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(t.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return Jg(t)}function Jg(t){if(t.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const e=t.pathname;let n=-1;for(;++n0){let[d,...b]=c;const x=r[p][1];Jr(x)&&Jr(d)&&(d=Mr(!0,x,d)),r[p]=[u,d,...b]}}}}const iy=new Mi().freeze();function Cr(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function Nr(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function Lr(t,e){if(e)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Qo(t){if(!Jr(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function Zo(t,e,n){if(!n)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function Ln(t){return oy(t)?t:new ey(t)}function oy(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function sy(t){return typeof t=="string"||ay(t)}function ay(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}function Si(){const t=iy().use(Vm).use(Bg).use(Dp);return{process:e=>t.processSync(e).toString()}}const ly={relative:""},uy={"h-full":"","w-full":""},cy={key:0,class:"animate-stripe",absolute:"",left:"1/2",bottom:"20%",z:"20","rounded-2xl":"",text:"primary-600","px-2":"","py-2":"",transform:"translate-x--1/2"},fy={bg:"primary-50","rounded-xl":"","px-10":"","py-6":""},dy=["innerHTML"],py=Fe({__name:"Stage",props:{paused:{type:Boolean,default:!1}},setup(t){const e=X(),n=X(),{stageView:r}=rt(pn()),{mouthOpenSize:i}=rt(lu()),{audioContext:o,calculateVolume:s}=bs(),{onBeforeMessageComposed:a,onBeforeSend:l,onTokenLiteral:u,onTokenSpecial:c,onStreamEnd:f,streamingMessage:p,onAssistantResponseEnd:d}=Mt(),{process:b}=Si(),x=di(),v=X(),T=X(!1),I=X(!1),A=sr({handlers:[K=>new Promise(E=>{const te=o.createBufferSource();te.buffer=K.data.audioBuffer,te.connect(o.destination),te.connect(v.value),T.value=!0,te.start(0),te.onended=()=>{T.value=!1,E()}})]}),R=Gl(),{ssmlEnabled:P,activeSpeechProvider:h,activeSpeechModel:M,activeSpeechVoice:y}=rt(R);async function g(K){try{if(!h.value){console.warn("No active speech provider configured");return}if(!y.value){console.warn("No active speech voice configured");return}const E=x.getProviderInstance(h.value);if(!E){console.error("Failed to initialize speech provider");return}const te=x.getProviderConfig(h.value),ge=P.value?R.generateSSML(K.data,y.value):K.data,C=await $l({...E.speech(M.value,te),input:ge,voice:y.value.id}),de=await o.decodeAudioData(C);await A.add({audioBuffer:de,text:K.data})}catch(E){console.error("Speech generation failed:",E)}}const m=sr({handlers:[g]});m.on("add",K=>{console.debug("ttsQueue added",K)});const k=ql(m),{live2dCurrentMotion:_}=rt(pn()),F=sr({handlers:[async K=>{if(r.value==="3d"){const E=Ba[K.data];if(!E)return;await n.value.setExpression(E)}else r.value==="2d"&&(_.value={group:Ua[K.data]})}]}),j=Yl(F);j.onHandlerEvent("emotion",K=>{console.debug("emotion detected",K)});const D=Kl();D.onHandlerEvent("delay",K=>{console.debug("delay detected",K)});function z(){requestAnimationFrame(z),T.value&&(i.value=s(v.value,"linear"))}function Q(){I.value||(z(),o.resume(),I.value=!0)}function Z(){v.value||(v.value=o.createAnalyser())}return a(async()=>{Z(),Q()}),l(async()=>{_.value={group:Ci}}),u(async K=>{await k.add(K)}),c(async K=>{await D.add(K),await j.add(K)}),f(async()=>{await D.add(Wl)}),d(async K=>{}),Ft(()=>{var E,te,ge;I.value=!1;const K=window;(E=K.electron)==null||E.ipcRenderer.removeAllListeners("before-hide"),(te=K.electron)==null||te.ipcRenderer.removeAllListeners("after-show"),(ge=K.electron)==null||ge.ipcRenderer.removeAllListeners("before-quit")}),dn(()=>{var E,te,ge;const K=window;(E=K.electron)==null||E.ipcRenderer.on("before-hide",()=>{_.value={group:Oa}}),(te=K.electron)==null||te.ipcRenderer.on("after-show",()=>{_.value={group:Da}}),(ge=K.electron)==null||ge.ipcRenderer.on("before-quit",()=>{_.value={group:Ci}})}),dn(async()=>{e.value=Fa("duckdb-wasm://?bundles=import-url"),await e.value.execute(za`CREATE TABLE memory_test (vec FLOAT[768]);`)}),(K,E)=>(ee(),ie("div",ly,[O("div",uy,[H(r)==="2d"?(ee(),Xt(_u,{key:0,"mouth-open-size":H(i),"min-w":"50% (ee(),ie("header",vy,[O("div",by,[Te(ru)]),Te(H(Dl),{class:"m-1 block max-h-[10lh] min-h-[1lh] rounded-lg bg-zinc-100 p-2 text-lg text-zinc-500 outline-none dark:bg-zinc-800 dark:text-zinc-400",to:"/settings"},{default:Be(()=>n[0]||(n[0]=[O("div",{"i-solar:settings-minimalistic-bold-duotone":""},null,-1)])),_:1})]))}});function Ea(t,e){const n=ms(e??{},{...Bi.getDefaultRealTimeVADOptions("v5"),preSpeechPadFrames:30,positiveSpeechThreshold:.5,negativeSpeechThreshold:.35,minSpeechFrames:30,auto:!0}),r=X(),i=Fl("microphone");async function o(){if(r.value&&(r.value.destroy(),r.value=void 0,console.warn("existing MicVAD destroyed")),!i.value)return;const s=H(t);if(!s)return;const a=await navigator.mediaDevices.getUserMedia({audio:{deviceId:s}});r.value=await Bi.MicVAD.new({...n,stream:a}),n.auto&&r.value.start()}return je(i,o,{immediate:!0}),je(zl(t),o,{immediate:!0}),Bl(o),Ft(()=>{r.value&&(r.value.destroy(),r.value=void 0)}),{destroy:()=>{r.value&&(r.value.destroy(),r.value=void 0)},start:()=>{r.value&&r.value.start()}}}function Ty(t,e){const n=ms(e,{onLoading:()=>{},onInitiate:()=>{},onProgress:()=>{},onDone:()=>{},onReady:()=>{},onStart:()=>{},onUpdate:()=>{},onComplete:()=>{}}),{post:r,data:i,terminate:o}=Ul(t,{type:"module"}),s=X(null),a=X(""),l=X([]),u=X(!1),c=X(0),f=X("");return je(i,p=>{var d,b,x,v,T,I,A,R;switch(p.status){case"loading":s.value="loading",a.value=p.data,(d=n.onLoading)==null||d.call(n,p.data);break;case"initiate":l.value.push(p),(b=n.onInitiate)==null||b.call(n,p);break;case"progress":l.value=l.value.map(P=>P.file===p.file?{...P,...p}:P),(x=n.onProgress)==null||x.call(n,p);break;case"done":l.value=l.value.filter(P=>P.file!==p.file),(v=n.onDone)==null||v.call(n,p);break;case"ready":s.value="ready",(T=n.onReady)==null||T.call(n);break;case"start":u.value=!0,(I=n.onStart)==null||I.call(n);break;case"update":c.value=p.tps,(A=n.onUpdate)==null||A.call(n,p.tps);break;case"complete":u.value=!1,f.value=p.output[0]||"",console.debug("Whisper result:",f.value),(R=n.onComplete)==null||R.call(n,p.output[0]);break}}),Ft(()=>{o()}),{transcribe:p=>r(p),status:s,loadingMessage:a,loadingProgress:l,transcribing:u,tps:c,result:f,load:()=>r({type:"load"}),terminate:o}}const ky="/assets/worker-KF4IHpL4.js";async function Ay(t,e){const n=new ArrayBuffer(44+t.length*2),r=new DataView(n);Pn(r,0,"RIFF"),r.setUint32(4,36+t.length*2,!0),Pn(r,8,"WAVE"),Pn(r,12,"fmt "),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,1,!0),r.setUint32(24,e,!0),r.setUint32(28,e*2,!0),r.setUint16(32,2,!0),r.setUint16(34,16,!0),Pn(r,36,"data"),r.setUint32(40,t.length*2,!0),_y(r,44,t);const i=new Blob([r],{type:"audio/wav"});return new Promise((o,s)=>{const a=new FileReader;a.onload=()=>{const l=a.result.split(",")[1];o(l)},a.onerror=s,a.readAsDataURL(i)})}function Pn(t,e,n){for(let r=0;r{Vn().then(()=>{i.update(),o.value=i.height.value})}),u(async()=>{Vn().then(()=>{i.update(),o.value=i.height.value})}),(c,f)=>{const p=ys("auto-animate");return ee(),ie("div",Ey,[f[2]||(f[2]=O("div",{"flex-1":""},null,-1)),At((ee(),ie("div",{ref_key:"chatHistoryRef",ref:e,"h-full":"","w-full":"",flex:"~ col","overflow-scroll":""},[f[1]||(f[1]=O("div",{"flex-1":""},null,-1)),(ee(!0),ie(ci,null,fi(H(n),(d,b)=>(ee(),ie("div",{key:b,"mb-2":""},[d.role==="error"?(ee(),ie("div",My,[O("div",Sy,[O("div",Iy,[O("div",Ry,[O("span",Cy,me(H(s)("stage.chat.message.character-name.core-system")),1)]),f[0]||(f[0]=O("div",{"i-solar:danger-triangle-bold-duotone":"","text-violet-500":""},null,-1))]),H(r)?(ee(),ie("div",Ny)):(ee(),ie("div",{key:1,class:"markdown-content text-violet-500",text:"base {if(!k||!k.trim())return;const _=o.getProviderConfig(s.value);await p(k,{chatProvider:o.getProviderInstance(s.value),model:a.value,providerConfig:_})}});async function P(){if(e.value.trim())try{const k=o.getProviderConfig(s.value);await p(e.value,{chatProvider:o.getProviderInstance(s.value),model:a.value,providerConfig:k})}catch(k){b.value.pop(),b.value.push({role:"error",content:k.message})}}const{destroy:h,start:M}=Ea(f,{onSpeechStart:()=>{n.value=!0},onVADMisfire:()=>{n.value=!1},onSpeechEnd:k=>{n.value=!1,g(k)},auto:!1});function y(){A.value!=="loading"&&(I(),M())}async function g(k){await x.resume();const _=await Ay(k,x.sampleRate);T({type:"generate",data:{audio:_,language:"en"}})}async function m(k){const _=k.target,F=l.value.find(j=>j.deviceId===_.value);if(!F){u.value=void 0;return}u.value=F}return je(c,async k=>{k==="false"&&(h(),R())}),d(async()=>{e.value=""}),(k,_)=>(ee(),ie("div",$y,[O("fieldset",qy,[O("label",{class:Ct([r.value==="chat"?"bg-primary-100 dark:bg-primary-900":"bg-white dark:bg-primary-950",r.value==="chat"?"text-primary-500 dark:text-primary-500":""]),flex:"~ row",checked:r.value==="chat","aria-checked":r.value==="chat",border:"solid l-2 t-2 b-2 primary-100 dark:primary-900",bg:"hover:primary-100 dark:hover:primary-900",text:"primary-300 hover:primary-500 dark:primary-300/50 dark:hover:primary-500",transition:"all duration-250 ease-in-out","cursor-pointer":"","items-center":"","gap-1":"","rounded-l-lg":"","px-2":""},[At(O("input",{"onUpdate:modelValue":_[0]||(_[0]=F=>r.value=F),type:"radio",name:"tab",value:"chat",hidden:""},null,512),[[or,r.value]]),_[5]||(_[5]=O("div",{"i-solar:dialog-2-bold-duotone":"",text:"2xl",transform:"translate-y--2"},null,-1)),O("div",Ky,[O("span",Wy,me(H(v)("stage.chat.tabs.chat")),1)])],10,Yy),O("label",{class:Ct([r.value==="custom"?"bg-primary-100 dark:bg-primary-900":"bg-white dark:bg-primary-950",r.value==="custom"?"text-primary-500 dark:text-primary-500":""]),flex:"~ row",checked:r.value==="custom","aria-checked":r.value==="custom",border:"solid t-2 b-2 primary-100 dark:primary-900",bg:"hover:primary-100 dark:hover:primary-900",text:"primary-300 hover:primary-500 dark:primary-300/50 dark:hover:primary-500",transition:"all duration-250 ease-in-out","cursor-pointer":"","items-center":"","gap-1":"","px-2":""},[At(O("input",{"onUpdate:modelValue":_[1]||(_[1]=F=>r.value=F),type:"radio",name:"tab",value:"custom",hidden:""},null,512),[[or,r.value]]),_[6]||(_[6]=O("div",{"i-solar:star-fall-2-bold-duotone":"",text:"2xl",transform:"translate-y--2"},null,-1)),O("div",Qy,[O("span",null,me(H(v)("stage.chat.tabs.custom")),1)])],10,Xy),O("label",{class:Ct([r.value==="clothes"?"bg-primary-100 dark:bg-primary-900":"bg-white dark:bg-primary-950",r.value==="clothes"?"text-primary-500 dark:text-primary-500":""]),flex:"~ row",checked:r.value==="clothes","aria-checked":r.value==="clothes",border:"solid r-2 t-2 b-2 primary-100 dark:primary-900",bg:"hover:primary-100 dark:hover:primary-900",text:"primary-300 hover:primary-500 dark:primary-300/50 dark:hover:primary-500",transition:"all duration-250 ease-in-out","cursor-pointer":"","items-center":"","gap-1":"","rounded-r-lg":"","px-2":""},[At(O("input",{"onUpdate:modelValue":_[2]||(_[2]=F=>r.value=F),type:"radio",name:"tab",value:"clothes",hidden:""},null,512),[[or,r.value]]),_[7]||(_[7]=O("div",{"i-solar:magic-stick-3-bold-duotone":"",text:"2xl",transform:"translate-y--2"},null,-1)),O("div",Jy,[O("span",null,me(H(v)("stage.chat.tabs.clothes")),1)])],10,Zy)]),O("div",e0,[O("div",t0,[Te(Gy,{"h-full":"","flex-1":"","p-4":"",w:"full","max-h":"e.value=F),placeholder:H(v)("stage.message"),text:"primary-300 hover:primary-500 dark:primary-300/50 dark:hover:primary-500 placeholder:primary-300 placeholder:hover:primary-500 placeholder:dark:primary-300/50 placeholder:dark:hover:primary-500",bg:"primary-100 dark:primary-400/20","min-h":"[100px]","max-h":"[300px]","w-full":"","rounded-t-xl":"","p-4":"","font-medium":"","outline-none":"",transition:"all duration-250 ease-in-out placeholder:all placeholder:duration-250 placeholder:ease-in-out",onSubmit:P},null,8,["modelValue","placeholder"])])])]),O("div",r0,[O("button",{bg:"complementary-100 hover:complementary-200 dark:complementary-800 dark:hover:complementary-700",transition:"all duration-250 ease-in-out",text:"complementary-400","mb-6":"",flex:"","cursor-pointer":"","items-center":"","justify-center":"","gap-2":"","rounded-full":"","px-4":"","py-2":"",onClick:y},[Te(Vl,{mode:"out-in"},{default:Be(()=>[H(A)===null?(ee(),ie("div",i0,me(H(v)("stage.operations.load-models")),1)):H(A)==="loading"?(ee(),ie("div",o0,[_[8]||(_[8]=O("div",{"i-svg-spinners:bouncing-ball":"",class:"text-cyan"},null,-1)),O("span",null,me(H(v)("stage.operations.load-models-status.loading")),1)])):H(A)==="ready"?(ee(),ie("div",s0,[_[9]||(_[9]=O("div",{"i-lucide:check":"",class:"text-cyan"},null,-1)),O("span",null,me(H(v)("stage.operations.load-models-status.ready")),1)])):it("",!0)]),_:1})]),O("div",a0,[Te(H(pi),null,{default:Be(()=>[i.value?(ee(),ie("fieldset",l0,[(ee(!0),ie(ci,null,fi(H(l),(F,j)=>(ee(),ie("label",{key:j,class:"[&_div_span]:dark:hover:bg-cyan-300 [&_div_span]:dark:hover:bg-cyan-900"},[O("input",{type:"radio",name:"audioInput",value:F.deviceId,hidden:"",onChange:m},null,40,u0),O("div",c0,[O("div",f0,[F.deviceId===H(f)?(ee(),ie("div",d0)):it("",!0)]),O("span",{"inline-block":"",class:Ct([F.deviceId===H(f)?"cyan-400 dark:text-white":"cyan-400/50 dark:text-white/50"]),transition:"all duration-250 ease-in-out"},me(F.label),3)])]))),128))])):it("",!0)]),_:1}),O("label",p0,[At(O("input",{"onUpdate:modelValue":_[4]||(_[4]=F=>i.value=F),type:"checkbox",hidden:""},null,512),[[ni,i.value]]),_[10]||(_[10]=O("div",{"i-solar:microphone-2-bold-duotone":""},null,-1)),O("div",null,[n.value?(ee(),ie("span",m0,"Listening...")):(ee(),ie("span",h0,me(H(v)("settings.microphone")),1))])])])])]))}}),y0=Wn(g0,[["__scopeId","data-v-808bb58d"]]),x0={py:"1",flex:"~ col",rounded:"lg","overflow-hidden":""},v0={key:0,flex:"",mr:"12"},b0={flex:"~ col",border:"4 solid primary-200/50 dark:primary-500/50",shadow:"md primary-200/50 dark:none","min-w-20":"","rounded-lg":"","px-2":"","py-1":"",h:"unset {Vn().then(()=>{i.update(),o.value=i.height.value})}),l(async()=>{Vn().then(()=>{i.update(),o.value=i.height.value})}),(u,c)=>{const f=ys("auto-animate");return ee(),ie("div",x0,[c[1]||(c[1]=O("div",{"flex-1":""},null,-1)),At((ee(),ie("div",{ref_key:"chatHistoryRef",ref:e,"h-full":"","w-full":"","max-h":"30vh",flex:"~ col","overflow-scroll":""},[c[0]||(c[0]=O("div",{"flex-1":""},null,-1)),(ee(!0),ie(ci,null,fi(H(r),(p,d)=>(ee(),ie("div",{key:d,"mb-2":""},[p.role==="assistant"?(ee(),ie("div",v0,[O("div",b0,[O("div",null,[O("span",w0,me(H(n)("stage.chat.message.character-name.airi")),1)]),p.content?(ee(),ie("div",{key:0,class:"markdown-content",text:"base {n.value=!0},onVADMisfire:()=>{n.value=!1},onSpeechEnd:x=>{n.value=!1,b()},auto:!1});function b(x){alert("Transcription is not implemented yet")}return je(s,async x=>{x==="false"&&p()}),u(async()=>{e.value=""}),dn(()=>{d()}),(x,v)=>(ee(),ie("div",null,[O("div",R0,[Te(I0,{absolute:"","left-0":"","top-0":"",transform:"translate-y-[-100%]","w-full":""}),O("div",C0,[Te(H(xs),{modelValue:e.value,"onUpdate:modelValue":v[0]||(v[0]=T=>e.value=T),placeholder:H(c)("stage.message"),border:"solid 2 primary-100 dark:primary-400/20",text:"primary-300 hover:primary-500 dark:primary-300/50 dark:hover:primary-500 placeholder:primary-300 placeholder:hover:primary-500 placeholder:dark:primary-300/50 placeholder:dark:hover:primary-500",bg:"primary-100 dark:primary-400/20","max-h":"[10lh]","min-h":"[1lh]","w-full":"","resize-none":"","overflow-y-scroll":"","rounded-xl":"","p-2":"","font-medium":"","outline-none":"",transition:"all duration-250 ease-in-out placeholder:all placeholder:duration-250 placeholder:ease-in-out",onSubmit:f},null,8,["modelValue","placeholder"])])])]))}}),L0={class:"relative"},P0={absolute:"","left-0":"","right-0":"","top-0":"","w-full":"","overflow-hidden":""},O0=Fe({__name:"AnimatedWave",props:{height:{default:40},amplitude:{default:14},waveLength:{default:250},fillColor:{default:"oklch(95% 0.10 var(--theme-colors-hue))"},direction:{default:"down"},movementDirection:{default:"left"},animationSpeed:{default:50}},setup(t){const e=t,n=X(e.height),r=X(e.amplitude),i=X(e.waveLength),o=X(e.fillColor),s=X(e.direction),a=X(e.movementDirection);function l(f,p,d,b,x){const v=[],I=Math.ceil(f/b)*b,A=1,R=x==="up"?d:p-d;v.push(`M 0 ${R}`);const P=Math.PI*2/b;for(let M=0;M<=I;M+=A){const y=d*Math.sin(P*M),g=x==="up"?R-y:R+y;v.push(`L ${M} ${g}`)}const h=x==="up"?p:0;return v.push(`L ${I} ${h}`),v.push(`L 0 ${h} Z`),v.join(" ")}const u=Ue(()=>n.value+r.value*2),c=Ue(()=>{const f=` + + `;return`url(data:image/svg+xml;base64,${btoa(f)})`});return je(()=>[e.height,e.amplitude,e.waveLength,e.fillColor,e.direction,e.movementDirection],()=>{n.value=e.height,r.value=e.amplitude,i.value=e.waveLength,o.value=e.fillColor,s.value=e.direction,a.value=e.movementDirection},{immediate:!0}),(f,p)=>(ee(),ie("div",L0,[gn(f.$slots,"default",{},void 0,!0),O("div",P0,[O("div",{class:"wave",style:Fr({background:o.value,height:`${u.value}px`,maskImage:c.value,WebkitMaskImage:c.value,"--wave-translate":`${-i.value}px`,"--animation-duration":`${i.value/t.animationSpeed}s`,"animation-direction":a.value==="left"?"normal":"reverse"})},null,4)])]))}}),D0=Wn(O0,[["__scopeId","data-v-d4cf94d8"]]),F0={relative:"",flex:"~ col","z-2":"","h-100vh":"","w-100vw":"","of-hidden":""},z0={relative:"",flex:"~ 1 row gap-y-0 gap-x-2 (ee(),Xt(xy,null,{default:Be(()=>[Te(D0,{"fill-color":H(e)?"oklch(35% calc(var(--theme-colors-chroma) * 0.6) var(--theme-colors-hue))":"color-mix(in srgb, oklch(95% calc(var(--theme-colors-chroma-50) * 0.5) var(--theme-colors-hue)) 80%, oklch(100% 0 360))"},{default:Be(()=>[O("div",F0,[O("div",null,[Te(wy,{class:"flex",p2:""})]),O("div",z0,[Te(H(hy),{"flex-1":"","min-w":"1/2",paused:n.value},null,8,["paused"]),Te(y0,{class:"flex