diff --git "a/assets/components-DVv6pi81.js" "b/assets/components-DVv6pi81.js" new file mode 100644--- /dev/null +++ "b/assets/components-DVv6pi81.js" @@ -0,0 +1,3773 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/__vite-browser-external-0_TDy7U3.js","assets/index-CLba5Fju.js","assets/index-C6wKJuaN.css","assets/default-node-D--pDlDQ.js","assets/import-url-browser-D6kI1pk-.js","assets/import-url-browser-BPXUaBlv.js","assets/duckdb-mvp-C3i5IjU8.js","assets/import-url-node-CDn8y3R9.js"])))=>i.map(i=>d[i]); +var e=function(exports){function t(e){"@babel/helpers - typeof";return t=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},t(e)}function n(e,n){if(t(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n||`default`);if(t(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(e)}function r(e){var r=n(e,`string`);return t(r)==`symbol`?r:r+``}function i(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}return exports.defineProperty=i,exports}({});import{AdditiveBlending as t,AlwaysStencilFunc as n,AnimationMixer as r,Audio as i,AudioListener as a,AudioLoader as o,BackSide as s,Box2 as c,Box3 as l,BoxGeometry as u,BufferAttribute as d,BufferGeometry as f,CatmullRomCurve3 as p,ClampToEdgeWrapping as m,Color as h,CompressedTexture as g,CubeCamera as _,CubeReflectionMapping as v,CubeTextureLoader as y,CylinderGeometry as b,DataTexture as x,DataTextureLoader as S,DataUtils as C,DepthTexture as w,DoubleSide as T,EdgesGeometry as E,Ee as D,EquirectangularReflectionMapping as O,Euler as k,EventDispatcher as A,ExtrudeGeometry as j,FileLoader as M,Float32BufferAttribute as N,FloatType as ee,Fragment as P,FrontSide as F,Group as I,HalfFloatType as te,InstancedBufferGeometry as ne,InstancedInterleavedBuffer as L,InstancedMesh as re,InterleavedBuffer as R,InterleavedBufferAttribute as ie,InterpolateDiscrete as ae,InterpolateLinear as oe,Ir as se,Line as ce,Line3 as le,LineBasicMaterial as ue,LinearFilter as de,LinearMipmapLinearFilter as fe,LinearMipmapNearestFilter as pe,Loader as me,MOUSE as he,Material as ge,MathUtils as _e,Matrix3 as ve,Matrix4 as ye,Mesh as be,MeshBasicMaterial as xe,MeshDepthMaterial as Se,MeshStandardMaterial as Ce,MirroredRepeatWrapping as we,Mn as Te,NearestFilter as Ee,NearestMipmapLinearFilter as De,NearestMipmapNearestFilter as Oe,NoToneMapping as ke,Object3D as Ae,OctahedronGeometry as je,OrthographicCamera as Me,Path as Ne,PerspectiveCamera as Pe,Plane as Fe,PlaneGeometry as Ie,PropertyBinding as Le,Q as Re,QuadraticBezierCurve3 as ze,Quaternion as Be,REVISION as Ve,RGBAFormat as He,RawShaderMaterial as Ue,Ray as We,Raycaster as Ge,RepeatWrapping as Ke,ReplaceStencilOp as qe,Scene as Je,ShaderChunk as Ye,ShaderMaterial as Xe,Shape as Ze,ShapeGeometry as Qe,ShapePath as $e,ShapeUtils as et,SkinnedMesh as tt,Sphere as nt,SphereGeometry as rt,Spherical as it,TOUCH as at,Texture as ot,TextureLoader as st,TorusGeometry as ct,Transition as lt,Triangle as ut,Uniform as dt,UniformsLib as ft,UniformsUtils as pt,Vector2 as mt,Vector3 as z,Vector4 as ht,Vn as gt,WebGLCubeRenderTarget as _t,WebGLRenderTarget as vt,WebGLRenderer as yt,WireframeGeometry as bt,__commonJSMin as xt,__export as St,__plugin_vue_export_helper_default as Ct,__require as wt,__toDynamicImportESM as Tt,__toESM as Et,__vitePreload as Dt,breakpointsTailwind as Ot,computed as kt,createBaseVNode as B,createBlock as At,createCommentVNode as jt,createElementBlock as V,createTextVNode as Mt,createVNode as Nt,defineComponent as H,defu as Pt,dn as Ft,formatCss as It,formatHex as Lt,getCurrentInstance as Rt,getCurrentScope as zt,guardReactiveProps as Bt,inject as Vt,io as Ht,isReactive as Ut,isRef as Wt,mergeModels as Gt,mergeProps as Kt,nextTick as qt,normalizeClass as Jt,normalizeProps as Yt,normalizeStyle as Xt,oklch as Zt,onBeforeUnmount as Qt,onMounted as $t,onScopeDispose as en,onUnmounted as tn,openBlock as U,pe as nn,reactive as rn,ref as W,render as an,renderList as on,renderSlot as sn,resolveComponent as cn,resolveDirective as ln,shallowReactive as un,shallowRef as dn,so as fn,storeToRefs as pn,toDisplayString as mn,toRaw as hn,toRef as gn,toRefs as _n,toValue$1 as vn,unref as G,useAttrs as yn,useBreakpoints as bn,useDark as xn,useDebounceFn as Sn,useElementBounding as Cn,useI18n as wn,useModel as Tn,useRouter as En,useSettings as Dn,useSlots as On,useWindowSize as kn,vModelCheckbox as An,vModelRadio as jn,vModelSelect as Mn,vModelText as Nn,watch as K,watchDebounced as Pn,watchEffect as Fn,withAsyncContext as In,withCtx as Ln,withDirectives as Rn,withModifiers as zn}from"./index-CLba5Fju.js";import{getImportUrlBundles as Bn}from"./import-url-browser-BPXUaBlv.js";import{generateSpeech as Vn,useAudioContext as Hn,useChatStore as Un,useProvidersStore as Wn,useSpeakingStore as Gn,useSpeechStore as Kn}from"./stores-BmdxfgEv.js";import{Collapsable_default as qn,TransitionVertical_default as Jn}from"./Button-BVmSgTYq.js";import{FieldCheckbox_default as Yn,FieldInput_default as Xn,Input_default as Zn}from"./src-BTAEqhOr.js";import{EMOTION_EmotionMotionName_value as Qn,EMOTION_VRMExpressionName_value as $n,EmotionThinkMotionName as er,chromaticHue as tr,chromaticHueDefault as nr,llmInferenceEndToken as rr,useDelayMessageQueue as ir,useEmotionsMessageQueue as ar,useMessageContentQueue as or}from"./queues-9mJHY5lA.js";import{VRMUtils as sr,clipFromVRMAnimation as cr,lerp as lr,loadVRMAnimation as ur,loadVrm as dr,randFloat as fr,randomSaccadeInterval as pr,useBlink as mr,useIdleEyeSaccades as hr,useMarkdown as gr,useVRMEmote as _r}from"./composables-riq4vJdB.js";import{useQueue as vr}from"./queue-DM4L2HHj.js";var yr,br,xr,Sr,Cr,wr,Tr,Er,Dr,Or,kr,Ar,jr,Mr,Nr,Pr,Fr,Ir,Lr,Rr,zr,Br,Vr,Hr,Ur,Wr,Gr,Kr,qr,Jr,Yr,Xr,Zr,Qr,$r,ei,ti,ni,ri,ii,ai,oi,si,ci,li,ui,di,fi,pi,mi,hi,gi,_i,vi,yi,bi,xi,Si,Ci,wi,Ti,Ei,Di,Oi,ki,Ai,ji,Mi,Ni,Pi,Fi,Ii,Li,Ri,zi,Bi,Vi,Hi,Ui,Wi,Gi,Ki,qi,Ji,Yi,Xi,Zi,Qi,$i,ea,ta,na,ra,ia,aa;let oa,sa,ca,la;var ua=H({__name:`AudioSpectrum`,props:{stream:null,bars:{default:32},minFreq:{default:60},maxFreq:{default:4e3}},setup(e){let t=e,n=W(Array.from({length:t.bars}).fill(0));$t(()=>{r()}),K(()=>t.stream,()=>{r()});function r(){if(!t.stream)return;let e=new(window.AudioContext||window.webkitAudioContext),r=e.createMediaStreamSource(t.stream),i=e.createAnalyser();i.fftSize=2048,r.connect(i);let a=i.frequencyBinCount,o=new Uint8Array(a),s=e.sampleRate,c=s/i.fftSize,l=Math.floor(t.minFreq/c),u=Math.floor(t.maxFreq/c),d=u-l,f=Math.floor(d/t.bars),p=()=>{try{requestAnimationFrame(p),i.getByteFrequencyData(o);let e=Array.from({length:t.bars}).fill(0);for(let n=0;nsn(e.$slots,`default`,{frequencies:n.value})}}),da=ua;const fa={"h-full":``,flex:``,"items-center":``,"gap-1":``},pa=5;var ma=H({__name:`AudioSpectrumVisualizer`,props:{frequencies:null,barsClass:null},setup(e){let t=e;function n(e,t){let n=.1,r=1;return n+(r-n)*(e/t)}function r(e,r){let i=n(r,t.frequencies.length);return Math.min(100,Math.max(10,e*100*pa*i))}return(t,n)=>(U(),V(`div`,fa,[(U(!0),V(P,null,on(e.frequencies,(t,n)=>(U(),V(`div`,{key:n,"h-full":``,flex:``,"flex-1":``,"items-end":``},[B(`div`,{transition:`all 100 ease-in-out`,"mx-auto":``,"my-0":``,"w-full":``,"rounded-full":``,class:Jt(e.barsClass),style:Xt({height:`${r(t,n)}%`})},null,6)]))),128))]))}}),ha=ma;const ga={key:0,class:`mb-2 flex items-center justify-between`},_a={class:`text-sm font-medium`},va={class:`text-sm text-neutral-500`};var ya=H({__name:`LevelMeter`,props:{level:null,min:{default:0},max:{default:100},numBars:{default:20},label:{default:`Level`},unit:{default:`%`},height:{default:24},showHeader:{type:Boolean,default:!0},animationSpeed:{default:75},colorThresholds:{default:()=>[{value:60,color:`bg-green-500`},{value:80,color:`bg-yellow-500`},{value:100,color:`bg-red-500`}]},formatValue:{type:Function}},setup(e){let t=e,n=kt(()=>{let e=Math.max(0,Math.min(100,(t.level-t.min)/(t.max-t.min)*100)),n=Math.floor(e/100*t.numBars);return Array.from({length:t.numBars},(e,r)=>({active:re.value-t.value);for(let e of i)if(n<=e.value)return e.color;return(r=i[i.length-1])?.color||`bg-green-500`}return(t,i)=>(U(),V(`div`,null,[e.showHeader?(U(),V(`div`,ga,[B(`span`,_a,mn(e.label),1),B(`span`,va,mn(e.formatValue?e.formatValue(e.level):`${Math.round(e.level)}${e.unit}`),1)])):jt(``,!0),B(`div`,{class:`flex items-end gap-1 rounded bg-neutral-200/45 p-1 dark:bg-neutral-700`,style:Xt({height:`${e.height}px`})},[(U(!0),V(P,null,on(n.value,(t,n)=>(U(),V(`div`,{key:n,class:Jt([`flex-1 rounded-sm transition-all`,[t.active?r(n,t.level):`bg-neutral-200 dark:bg-neutral-600`,`duration-${e.animationSpeed}`]]),style:Xt({height:t.active?`100%`:`20%`})},null,6))),128))],4)]))}}),ba=ya,xa=H({__name:`Volumed`,props:{perspective:null,transform:null},setup(e){return(t,n)=>(U(),V(`div`,{class:`volumed`,style:Xt({perspective:`${e.perspective}px`,transform:e.transform})},[sn(t.$slots,`default`,{},void 0,!0)],4))}}),Sa=Ct(xa,[[`__scopeId`,`data-v-568551bc`]]),Ca=H({__name:`CursorMomentum`,props:{baseSpeed:{default:.1},friction:{default:.95},momentumFactor:{default:.005}},setup(e,{expose:t}){let n=e,r=W(1),i=W(0),a=0,o=gn(()=>n.friction),s=gn(()=>n.baseSpeed),c=gn(()=>n.momentumFactor);function l(e){a||=e;let t=e-a;a=e,r.value=s.value+(r.value-s.value)*o.value,i.value+=r.value*t,requestAnimationFrame(l)}function u(e){let t=Math.sqrt(e.movementX**2+e.movementY**2);r.value+=t*c.value}return $t(()=>{window.addEventListener(`mousemove`,u),requestAnimationFrame(l)}),tn(()=>{window.removeEventListener(`mousemove`,u)}),t({momentum:r,currentValue:i}),(e,t)=>sn(e.$slots,`default`,{momentum:r.value,currentValue:i.value})}}),wa=Ca,Ta=H({__name:`TestDummyMarkerFlat`,props:{size:null},setup(e){return(t,n)=>(U(),V(`div`,{class:`test-dummy-flat`,style:Xt({width:`${e.size}px`,height:`${e.size}px`})},n[0]||=[B(`div`,{class:`marker`},null,-1)],4))}}),Ea=Ct(Ta,[[`__scopeId`,`data-v-b4ef37ac`]]),Da=H({__name:`TestDummyMarker`,setup(e){return(e,t)=>(U(),At(wa,{"base-speed":.1,friction:.95,"momentum-factor":5e-4},{default:Ln(({currentValue:e})=>[Nt(Sa,{perspective:800,transform:`rotateX(45deg) translateY(3px)`},{default:Ln(()=>[Nt(Ea,{size:24,style:Xt({transform:`rotate(${e}deg)`})},null,8,[`style`])]),_:2},1024)]),_:1}))}}),Oa=Da;const ka={key:0,class:`mb-2 flex items-center justify-between`},Aa={class:`text-sm font-medium`},ja={class:`text-sm text-neutral-500`},Ma={key:1,class:`mt-1 flex gap-3 text-xs text-neutral-500`},Na={class:`flex items-center gap-1`},Pa={class:`flex items-center gap-1`},Fa={class:`flex items-center gap-1`};var Ia=H({__name:`ThresholdMeter`,props:{value:null,threshold:null,min:{default:0},max:{default:1},numBars:{default:20},label:{default:`Value`},unit:{default:`%`},precision:{default:1},height:{default:24},showHeader:{type:Boolean,default:!0},showLegend:{type:Boolean,default:!0},animationSpeed:{default:100},belowThresholdClass:{default:`bg-primary-300 dark:bg-primary-600`},aboveThresholdClass:{default:`bg-green-500`},thresholdBarClass:{default:`bg-white dark:bg-neutral-800`},inactiveBarClass:{default:`bg-neutral-300 dark:bg-neutral-600`},belowLabel:{default:`Below`},aboveLabel:{default:`Above`},thresholdLabel:{default:`Threshold`},formatValue:{type:Function}},setup(e){let t=e,n=kt(()=>{let e=Math.max(0,Math.min(1,(t.value-t.min)/(t.max-t.min))),n=Math.max(0,Math.min(1,(t.threshold-t.min)/(t.max-t.min))),r=Math.floor(e*t.numBars),i=Math.floor(n*t.numBars);return Array.from({length:t.numBars},(e,t)=>({active:t=i,isBelowThreshold:t(U(),V(`div`,null,[e.showHeader?(U(),V(`div`,ka,[B(`span`,Aa,mn(e.label),1),B(`span`,ja,mn(e.formatValue?e.formatValue(e.value):`${(e.value*100).toFixed(e.precision)}${e.unit}`),1)])):jt(``,!0),B(`div`,{class:`flex items-end gap-1 rounded bg-neutral-200/45 p-1 p-1 dark:bg-neutral-700`,style:Xt({height:`${e.height}px`})},[(U(!0),V(P,null,on(n.value,(t,n)=>(U(),V(`div`,{key:`threshold-${n}`,class:Jt([`flex-1 rounded-sm transition-all`,[t.isThreshold?e.thresholdBarClass:t.isAboveThreshold?e.aboveThresholdClass:t.isBelowThreshold?e.belowThresholdClass:e.inactiveBarClass,`duration-${e.animationSpeed}`]]),style:Xt({height:t.active||t.isThreshold?`100%`:`20%`})},null,6))),128))],4),e.showLegend?(U(),V(`div`,Ma,[B(`span`,Na,[B(`div`,{class:Jt(`inline-block h-0.5lh w-1lh rounded-full ${e.belowThresholdClass}`)},null,2),Mt(` `+mn(e.belowLabel),1)]),B(`span`,Pa,[B(`div`,{class:Jt(`inline-block h-0.5lh w-1lh rounded-full border border-neutral-400 ${e.thresholdBarClass}`)},null,2),Mt(` `+mn(e.thresholdLabel),1)]),B(`span`,Fa,[B(`div`,{class:Jt(`inline-block h-0.5lh w-1lh rounded-full ${e.aboveThresholdClass}`)},null,2),Mt(` `+mn(e.aboveLabel),1)])])):jt(``,!0)]))}}),La=Ia;function Ra(e){return{color:e,withAlpha:t=>{let n=Zt(e);if(!n)throw Error(`Invalid color provided for alpha adjustment`);return Ra(Zt({mode:`oklch`,l:n.l,c:n.c,h:n.h,alpha:t}))},toHex:()=>Lt(e),toCSS:()=>It(e)}}function za(e=200,t){let n=t??.18+Math.cos(e*Math.PI/180)*.04,r={50:{lightness:.95,chromaMultiplier:.3,mixWithWhite:.7},100:{lightness:.95,chromaMultiplier:.5,mixWithWhite:.2},200:{lightness:.9,chromaMultiplier:.6},300:{lightness:.85,chromaMultiplier:.75},400:{lightness:.74,chromaMultiplier:.85},500:{lightness:.62,chromaMultiplier:1},600:{lightness:.54,chromaMultiplier:1.15},700:{lightness:.49,chromaMultiplier:1.1},800:{lightness:.42,chromaMultiplier:.85},900:{lightness:.37,chromaMultiplier:.7},950:{lightness:.29,chromaMultiplier:.5}},i=(t,i,a=0)=>{let o=r[t],s=(e+a)%360,c=n*o.chromaMultiplier,l=Zt({mode:`oklch`,l:o.lightness,c,h:s,alpha:i??1});if(o.mixWithWhite){let e=Zt({mode:`oklch`,l:1,c:0,h:0,alpha:i??1});return Ra(Ba(l,e,o.mixWithWhite))}return Ra(l)};return{baseHue:e,chroma:n,getAllShades:(e,t=0)=>{let n={};for(let a of Object.keys(r)){let r=Number.parseInt(a);n[r]=i(r,e,t)}return n},shadeBy:i}}function Ba(e,t,n=.5){let r=Zt(e),i=Zt(t);if(!r||!i)throw Error(`Invalid colors provided for mixing`);return Zt({mode:`oklch`,l:r.l*(1-n)+i.l*n,c:r.c*(1-n)+i.c*n,h:Va(r.h??0,i.h??0,n)})}function Va(e,t,n){let r=t-e;return r>180&&(r-=360),r<-180&&(r+=360),(e+r*n+360)%360}const Ha={key:0,class:`flex items-center justify-between`},Ua={class:`text-sm font-medium`},Wa={class:`text-xs text-neutral-500`},Ga={class:`h-full w-full`},Ka={id:`below-threshold-gradient`,x1:`0%`,y1:`0%`,x2:`0%`,y2:`100%`},qa=[`fill`],Ja=[`y`,`height`,`fill`],Ya=[`y1`,`y2`,`stroke`,`fill`],Xa=[`d`,`fill`],Za=[`d`,`stroke`,`stroke-width`],Qa={key:0,class:`absolute left-2 top-2 flex items-center gap-1.5 border border-primary-200 rounded-md bg-primary-50 px-2 py-1 dark:border-primary-800 dark:bg-primary-900`},$a={class:`text-xs text-primary-700 font-medium dark:text-primary-300`},eo={key:1,class:`flex flex-wrap items-center justify-between text-xs text-neutral-500`},to={class:`flex items-center gap-3`},no={class:`flex items-center gap-1 text-nowrap`},ro={class:`flex items-center gap-1 text-nowrap`},io={key:0,class:`text-nowrap`};var ao=H({__name:`TimeSeriesChart`,props:{history:null,currentValue:null,threshold:{default:null},isActive:{type:Boolean},title:{default:`Time Series`},colorsHue:null,lineColor:null,thresholdColor:null,activeColor:null,inactiveColor:null,subtitle:{default:`Recent data`},activeLabel:{default:`Active`},activeLegendLabel:{default:`Active state`},inactiveLegendLabel:{default:`Inactive state`},thresholdLabel:{default:`Threshold`},height:{default:80},lineWidth:{default:1.5},chartHeight:null,minDataPoints:{default:5},precision:{default:0},unit:{default:`%`},showHeader:{type:Boolean,default:!0},showThreshold:{type:Boolean,default:!0},showArea:{type:Boolean,default:!0},showThresholdAreas:{type:Boolean,default:!0},showCurrentValue:{type:Boolean,default:!0},showActiveIndicator:{type:Boolean,default:!0},showLegend:{type:Boolean,default:!0},formatValue:{type:Function}},setup(e){let t=e,n=kt(()=>t.height),r=W(),i=Vt(tr,nr),a=gn(()=>t.colorsHue||i||nr),o=kt(()=>za(a.value)),s=Cn(r,{windowResize:!0});K([a,r],()=>{r.value&&r.value.style.setProperty(`--chromatic-hue`,a.value.toString())},{immediate:!0});let c=gn(()=>t.lineColor),l=kt(()=>c.value?c.value:o.value.shadeBy(500).toHex()),u=gn(()=>t.thresholdColor),d=kt(()=>{if(!u.value){let e=o.value.shadeBy(500).withAlpha(.1).color;return`oklch(${e.l} ${e.c} ${e.h} / ${e.alpha})`}return u.value}),f=gn(()=>t.activeColor),p=kt(()=>f.value?f.value:o.value.shadeBy(600).toHex()),m=gn(()=>t.inactiveColor),h=kt(()=>m.value?m.value:o.value.shadeBy(400).toHex()),g=Math.random().toString(36).substring(2,9),_=`grid-${g}`,v=`area-gradient-${g}`,y=`threshold-gradient-${g}`,b=kt(()=>t.threshold===null?0:Math.max(0,Math.min(1,t.threshold))),x=kt(()=>t.threshold===null?0:n.value-b.value*n.value),S=kt(()=>{let e=t.history;if(e.length<2)return``;let r=s.width.value,i=n.value,a=`M0,${i-e[0]*i}`;for(let t=1;t{let e=t.history;if(e.length<2)return``;let r=s.width.value,i=n.value,a=`M0,${i} L0,${i-e[0]*i}`;for(let t=1;te.history.length>e.minDataPoints?(U(),V(`div`,{key:0,ref_key:`timeSeriesChartRef`,ref:r,class:`time-series-chart space-y-3`},[e.showHeader?(U(),V(`div`,Ha,[B(`div`,Ua,mn(e.title),1),B(`div`,Wa,mn(e.subtitle),1)])):jt(``,!0),B(`div`,{class:`relative overflow-hidden border border-neutral-200 rounded-lg from-neutral-50 to-neutral-100 bg-gradient-to-b dark:border-neutral-800 dark:from-neutral-800 dark:to-neutral-900`,style:Xt({height:`${n.value}px`})},[(U(),V(`svg`,Ga,[B(`defs`,null,[B(`pattern`,{id:_,width:`20`,height:`10`,patternUnits:`userSpaceOnUse`},i[0]||=[B(`path`,{d:`M 20 0 L 0 0 0 10`,fill:`none`,stroke:`rgb(156 163 175 / 0.1)`,"stroke-width":`0.5`},null,-1)]),B(`linearGradient`,{id:v,x1:`0%`,y1:`0%`,x2:`0%`,y2:`100%`},[B(`stop`,{offset:`0%`,style:Xt(`stop-color:${l.value};stop-opacity:0.3`)},null,4),B(`stop`,{offset:`50%`,style:Xt(`stop-color:${l.value};stop-opacity:0.15`)},null,4),B(`stop`,{offset:`100%`,style:Xt(`stop-color:${l.value};stop-opacity:0.05`)},null,4)]),B(`linearGradient`,{id:y,x1:`0%`,y1:`0%`,x2:`0%`,y2:`100%`},[B(`stop`,{offset:`0%`,style:Xt(`stop-color:${p.value};stop-opacity:0.3`)},null,4),B(`stop`,{offset:`50%`,style:Xt(`stop-color:${p.value};stop-opacity:0.15`)},null,4),B(`stop`,{offset:`100%`,style:Xt(`stop-color:${p.value};stop-opacity:0.05`)},null,4)]),B(`linearGradient`,Ka,[B(`stop`,{offset:`0%`,style:Xt(`stop-color:${d.value};stop-opacity:0.2`)},null,4),B(`stop`,{offset:`50%`,style:Xt(`stop-color:${d.value};stop-opacity:0.1`)},null,4),B(`stop`,{offset:`100%`,style:Xt(`stop-color:${d.value};stop-opacity:0.05`)},null,4)])]),B(`rect`,{width:`100%`,height:`100%`,fill:`url(#${_})`},null,8,qa),e.showThreshold&&e.threshold!==null?(U(),V(`rect`,{key:0,x:`0`,y:x.value,width:`100%`,height:n.value-x.value,fill:d.value,class:`transition-all duration-300`},null,8,Ja)):jt(``,!0),e.showThreshold&&e.threshold!==null?(U(),V(`line`,{key:1,x1:`0`,y1:x.value,x2:`100%`,y2:x.value,stroke:d.value,"stroke-width":`1.5`,"stroke-dasharray":`4,4`,fill:d.value,class:`transition-all duration-300`},null,8,Ya)):jt(``,!0),C.value&&e.showArea?(U(),V(`path`,{key:2,d:C.value,fill:`url(#${v})`,class:`transition-all duration-75`},null,8,Xa)):jt(``,!0),S.value?(U(),V(`path`,{key:3,d:S.value,fill:`none`,stroke:l.value,"stroke-width":e.lineWidth,"stroke-linecap":`round`,"stroke-linejoin":`round`,class:`drop-shadow-sm transition-all duration-75`},null,8,Za)):jt(``,!0)])),e.showCurrentValue?(U(),V(`div`,{key:0,class:Jt([`absolute right-2 top-2 border border-neutral-200 rounded-md bg-white px-2 py-1 shadow-sm transition-all duration-200 dark:border-neutral-700 dark:bg-neutral-800`,e.isActive?`bg-primary-50 dark:bg-primary-900 border-primary-200 dark:border-primary-800`:``])},[B(`div`,{class:Jt([`text-xs font-medium`,e.isActive?`text-primary-700 dark:text-primary-300`:`text-neutral-600 dark:text-neutral-400`])},mn(e.formatValue?e.formatValue(e.currentValue):`${(e.currentValue*100).toFixed(e.precision)}${e.unit}`),3)],2)):jt(``,!0),Nt(lt,{name:`fade`},{default:Ln(()=>[e.isActive&&e.showActiveIndicator?(U(),V(`div`,Qa,[i[1]||=B(`div`,{class:`h-1.5 w-1.5 animate-pulse rounded-full bg-primary-500`},null,-1),B(`span`,$a,mn(e.activeLabel),1)])):jt(``,!0)]),_:1})],4),e.showLegend?(U(),V(`div`,eo,[B(`div`,to,[B(`span`,no,[B(`div`,{class:`h-2 w-2 rounded-full`,style:Xt({backgroundColor:p.value})},null,4),Mt(` `+mn(e.activeLegendLabel),1)]),B(`span`,ro,[B(`div`,{class:`h-2 w-2 rounded-full`,style:Xt({backgroundColor:h.value})},null,4),Mt(` `+mn(e.inactiveLegendLabel),1)])]),e.threshold===null?jt(``,!0):(U(),V(`span`,io,mn(e.thresholdLabel)+`: `+mn((e.threshold*100).toFixed(0))+`%`,1))])):jt(``,!0)],512)):jt(``,!0)}}),oo=Ct(ao,[[`__scopeId`,`data-v-6e84a8be`]]),so;(function(e){e[e.WEBGL_LEGACY=0]=`WEBGL_LEGACY`,e[e.WEBGL=1]=`WEBGL`,e[e.WEBGL2=2]=`WEBGL2`})(so||={});var co;(function(e){e[e.UNKNOWN=0]=`UNKNOWN`,e[e.WEBGL=1]=`WEBGL`,e[e.CANVAS=2]=`CANVAS`})(co||={});var lo;(function(e){e[e.COLOR=16384]=`COLOR`,e[e.DEPTH=256]=`DEPTH`,e[e.STENCIL=1024]=`STENCIL`})(lo||={});var uo;(function(e){e[e.NORMAL=0]=`NORMAL`,e[e.ADD=1]=`ADD`,e[e.MULTIPLY=2]=`MULTIPLY`,e[e.SCREEN=3]=`SCREEN`,e[e.OVERLAY=4]=`OVERLAY`,e[e.DARKEN=5]=`DARKEN`,e[e.LIGHTEN=6]=`LIGHTEN`,e[e.COLOR_DODGE=7]=`COLOR_DODGE`,e[e.COLOR_BURN=8]=`COLOR_BURN`,e[e.HARD_LIGHT=9]=`HARD_LIGHT`,e[e.SOFT_LIGHT=10]=`SOFT_LIGHT`,e[e.DIFFERENCE=11]=`DIFFERENCE`,e[e.EXCLUSION=12]=`EXCLUSION`,e[e.HUE=13]=`HUE`,e[e.SATURATION=14]=`SATURATION`,e[e.COLOR=15]=`COLOR`,e[e.LUMINOSITY=16]=`LUMINOSITY`,e[e.NORMAL_NPM=17]=`NORMAL_NPM`,e[e.ADD_NPM=18]=`ADD_NPM`,e[e.SCREEN_NPM=19]=`SCREEN_NPM`,e[e.NONE=20]=`NONE`,e[e.SRC_OVER=0]=`SRC_OVER`,e[e.SRC_IN=21]=`SRC_IN`,e[e.SRC_OUT=22]=`SRC_OUT`,e[e.SRC_ATOP=23]=`SRC_ATOP`,e[e.DST_OVER=24]=`DST_OVER`,e[e.DST_IN=25]=`DST_IN`,e[e.DST_OUT=26]=`DST_OUT`,e[e.DST_ATOP=27]=`DST_ATOP`,e[e.ERASE=26]=`ERASE`,e[e.SUBTRACT=28]=`SUBTRACT`,e[e.XOR=29]=`XOR`})(uo||={});var fo;(function(e){e[e.POINTS=0]=`POINTS`,e[e.LINES=1]=`LINES`,e[e.LINE_LOOP=2]=`LINE_LOOP`,e[e.LINE_STRIP=3]=`LINE_STRIP`,e[e.TRIANGLES=4]=`TRIANGLES`,e[e.TRIANGLE_STRIP=5]=`TRIANGLE_STRIP`,e[e.TRIANGLE_FAN=6]=`TRIANGLE_FAN`})(fo||={});var po;(function(e){e[e.RGBA=6408]=`RGBA`,e[e.RGB=6407]=`RGB`,e[e.RG=33319]=`RG`,e[e.RED=6403]=`RED`,e[e.RGBA_INTEGER=36249]=`RGBA_INTEGER`,e[e.RGB_INTEGER=36248]=`RGB_INTEGER`,e[e.RG_INTEGER=33320]=`RG_INTEGER`,e[e.RED_INTEGER=36244]=`RED_INTEGER`,e[e.ALPHA=6406]=`ALPHA`,e[e.LUMINANCE=6409]=`LUMINANCE`,e[e.LUMINANCE_ALPHA=6410]=`LUMINANCE_ALPHA`,e[e.DEPTH_COMPONENT=6402]=`DEPTH_COMPONENT`,e[e.DEPTH_STENCIL=34041]=`DEPTH_STENCIL`})(po||={});var mo;(function(e){e[e.TEXTURE_2D=3553]=`TEXTURE_2D`,e[e.TEXTURE_CUBE_MAP=34067]=`TEXTURE_CUBE_MAP`,e[e.TEXTURE_2D_ARRAY=35866]=`TEXTURE_2D_ARRAY`,e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]=`TEXTURE_CUBE_MAP_POSITIVE_X`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]=`TEXTURE_CUBE_MAP_NEGATIVE_X`,e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]=`TEXTURE_CUBE_MAP_POSITIVE_Y`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]=`TEXTURE_CUBE_MAP_NEGATIVE_Y`,e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]=`TEXTURE_CUBE_MAP_POSITIVE_Z`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]=`TEXTURE_CUBE_MAP_NEGATIVE_Z`})(mo||={});var ho;(function(e){e[e.UNSIGNED_BYTE=5121]=`UNSIGNED_BYTE`,e[e.UNSIGNED_SHORT=5123]=`UNSIGNED_SHORT`,e[e.UNSIGNED_SHORT_5_6_5=33635]=`UNSIGNED_SHORT_5_6_5`,e[e.UNSIGNED_SHORT_4_4_4_4=32819]=`UNSIGNED_SHORT_4_4_4_4`,e[e.UNSIGNED_SHORT_5_5_5_1=32820]=`UNSIGNED_SHORT_5_5_5_1`,e[e.UNSIGNED_INT=5125]=`UNSIGNED_INT`,e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]=`UNSIGNED_INT_10F_11F_11F_REV`,e[e.UNSIGNED_INT_2_10_10_10_REV=33640]=`UNSIGNED_INT_2_10_10_10_REV`,e[e.UNSIGNED_INT_24_8=34042]=`UNSIGNED_INT_24_8`,e[e.UNSIGNED_INT_5_9_9_9_REV=35902]=`UNSIGNED_INT_5_9_9_9_REV`,e[e.BYTE=5120]=`BYTE`,e[e.SHORT=5122]=`SHORT`,e[e.INT=5124]=`INT`,e[e.FLOAT=5126]=`FLOAT`,e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]=`FLOAT_32_UNSIGNED_INT_24_8_REV`,e[e.HALF_FLOAT=36193]=`HALF_FLOAT`})(ho||={});var go;(function(e){e[e.FLOAT=0]=`FLOAT`,e[e.INT=1]=`INT`,e[e.UINT=2]=`UINT`})(go||={});var _o;(function(e){e[e.NEAREST=0]=`NEAREST`,e[e.LINEAR=1]=`LINEAR`})(_o||={});var vo;(function(e){e[e.CLAMP=33071]=`CLAMP`,e[e.REPEAT=10497]=`REPEAT`,e[e.MIRRORED_REPEAT=33648]=`MIRRORED_REPEAT`})(vo||={});var yo;(function(e){e[e.OFF=0]=`OFF`,e[e.POW2=1]=`POW2`,e[e.ON=2]=`ON`,e[e.ON_MANUAL=3]=`ON_MANUAL`})(yo||={});var bo;(function(e){e[e.NPM=0]=`NPM`,e[e.UNPACK=1]=`UNPACK`,e[e.PMA=2]=`PMA`,e[e.NO_PREMULTIPLIED_ALPHA=0]=`NO_PREMULTIPLIED_ALPHA`,e[e.PREMULTIPLY_ON_UPLOAD=1]=`PREMULTIPLY_ON_UPLOAD`,e[e.PREMULTIPLY_ALPHA=2]=`PREMULTIPLY_ALPHA`,e[e.PREMULTIPLIED_ALPHA=2]=`PREMULTIPLIED_ALPHA`})(bo||={});var xo;(function(e){e[e.NO=0]=`NO`,e[e.YES=1]=`YES`,e[e.AUTO=2]=`AUTO`,e[e.BLEND=0]=`BLEND`,e[e.CLEAR=1]=`CLEAR`,e[e.BLIT=2]=`BLIT`})(xo||={});var So;(function(e){e[e.AUTO=0]=`AUTO`,e[e.MANUAL=1]=`MANUAL`})(So||={});var Co;(function(e){e.LOW=`lowp`,e.MEDIUM=`mediump`,e.HIGH=`highp`})(Co||={});var wo;(function(e){e[e.NONE=0]=`NONE`,e[e.SCISSOR=1]=`SCISSOR`,e[e.STENCIL=2]=`STENCIL`,e[e.SPRITE=3]=`SPRITE`,e[e.COLOR=4]=`COLOR`})(wo||={});var To;(function(e){e[e.RED=1]=`RED`,e[e.GREEN=2]=`GREEN`,e[e.BLUE=4]=`BLUE`,e[e.ALPHA=8]=`ALPHA`})(To||={});var Eo;(function(e){e[e.NONE=0]=`NONE`,e[e.LOW=2]=`LOW`,e[e.MEDIUM=4]=`MEDIUM`,e[e.HIGH=8]=`HIGH`})(Eo||={});var Do;(function(e){e[e.ELEMENT_ARRAY_BUFFER=34963]=`ELEMENT_ARRAY_BUFFER`,e[e.ARRAY_BUFFER=34962]=`ARRAY_BUFFER`,e[e.UNIFORM_BUFFER=35345]=`UNIFORM_BUFFER`})(Do||={});var Oo={createCanvas:function(e,t){var n=document.createElement(`canvas`);return n.width=e,n.height=t,n},getWebGLRenderingContext:function(){return WebGLRenderingContext},getNavigator:function(){return navigator},getBaseUrl:function(){var e;return(e=document.baseURI)??window.location.href},fetch:function(e,t){return fetch(e,t)}},ko=/iPhone/i,Ao=/iPod/i,jo=/iPad/i,Mo=/\biOS-universal(?:.+)Mac\b/i,No=/\bAndroid(?:.+)Mobile\b/i,Po=/Android/i,Fo=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Io=/Silk/i,Lo=/Windows Phone/i,Ro=/\bWindows(?:.+)ARM\b/i,zo=/BlackBerry/i,Bo=/BB10/i,Vo=/Opera Mini/i,Ho=/\b(CriOS|Chrome)(?:.+)Mobile/i,Uo=/Mobile(?:.+)Firefox\b/i,Wo=function(e){return e!==void 0&&e.platform===`MacIntel`&&typeof e.maxTouchPoints==`number`&&e.maxTouchPoints>1&&typeof MSStream>`u`};function Go(e){return function(t){return t.test(e)}}function Ko(e){var t={userAgent:``,platform:``,maxTouchPoints:0};!e&&typeof navigator<`u`?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof e==`string`?t.userAgent=e:e&&e.userAgent&&(t={userAgent:e.userAgent,platform:e.platform,maxTouchPoints:e.maxTouchPoints||0});var n=t.userAgent,r=n.split(`[FBAN`);r[1]!==void 0&&(n=r[0]),r=n.split(`Twitter`),r[1]!==void 0&&(n=r[0]);var i=Go(n),a={apple:{phone:i(ko)&&!i(Lo),ipod:i(Ao),tablet:!i(ko)&&(i(jo)||Wo(t))&&!i(Lo),universal:i(Mo),device:(i(ko)||i(Ao)||i(jo)||i(Mo)||Wo(t))&&!i(Lo)},amazon:{phone:i(Fo),tablet:!i(Fo)&&i(Io),device:i(Fo)||i(Io)},android:{phone:!i(Lo)&&i(Fo)||!i(Lo)&&i(No),tablet:!i(Lo)&&!i(Fo)&&!i(No)&&(i(Io)||i(Po)),device:!i(Lo)&&(i(Fo)||i(Io)||i(No)||i(Po))||i(/\bokhttp\b/i)},windows:{phone:i(Lo),tablet:i(Ro),device:i(Lo)||i(Ro)},other:{blackberry:i(zo),blackberry10:i(Bo),opera:i(Vo),firefox:i(Uo),chrome:i(Ho),device:i(zo)||i(Bo)||i(Vo)||i(Uo)||i(Ho)},any:!1,phone:!1,tablet:!1};return a.any=a.apple.device||a.android.device||a.windows.device||a.other.device,a.phone=a.apple.phone||a.android.phone||a.windows.phone,a.tablet=a.apple.tablet||a.android.tablet||a.windows.tablet,a}var qo=Ko(globalThis.navigator);function Jo(){return!qo.apple.device}function Yo(e){var t=!0;if(qo.tablet||qo.phone){if(qo.apple.device){var n=navigator.userAgent.match(/OS (\d+)_(\d+)?/);if(n){var r=parseInt(n[1],10);r<11&&(t=!1)}}if(qo.android.device){var n=navigator.userAgent.match(/Android\s([0-9.]*)/);if(n){var r=parseInt(n[1],10);r<7&&(t=!1)}}}return t?e:4}var Xo={ADAPTER:Oo,MIPMAP_TEXTURES:yo.POW2,ANISOTROPIC_LEVEL:0,RESOLUTION:1,FILTER_RESOLUTION:1,FILTER_MULTISAMPLE:Eo.NONE,SPRITE_MAX_TEXTURES:Yo(32),SPRITE_BATCH_SIZE:4096,RENDER_OPTIONS:{view:null,width:800,height:600,autoDensity:!1,backgroundColor:0,backgroundAlpha:1,useContextAlpha:!0,clearBeforeRender:!0,antialias:!1,preserveDrawingBuffer:!1},GC_MODE:So.AUTO,GC_MAX_IDLE:60*60,GC_MAX_CHECK_COUNT:60*10,WRAP_MODE:vo.CLAMP,SCALE_MODE:_o.LINEAR,PRECISION_VERTEX:Co.HIGH,PRECISION_FRAGMENT:qo.apple.device?Co.HIGH:Co.MEDIUM,CAN_UPLOAD_SAME_BUFFER:Jo(),CREATE_IMAGE_BITMAP:!1,ROUND_PIXELS:!1},Zo=xt((exports,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i{t.exports=n,t.exports.default=n;function n(e,t,n){n||=2;var i=t&&t.length,o=i?t[0]*n:e.length,s=r(e,0,o,n,!0),c=[];if(!s||s.next===s.prev)return c;var l,d,f,p,m,h,g;if(i&&(s=u(e,t,s,n)),e.length>80*n){l=f=e[0],d=p=e[1];for(var _=n;_f&&(f=m),h>p&&(p=h);g=Math.max(f-l,p-d),g=g===0?0:32767/g}return a(s,c,n,l,d,g,0),c}function r(e,t,n,r,i){var a,o;if(i===N(e,t,n,r)>0)for(a=t;a=t;a-=r)o=A(a,e[a],e[a+1],o);return o&&S(o,o.next)&&(j(o),o=o.next),o}function i(e,t){if(!e)return e;t||=e;var n=e,r;do if(r=!1,!n.steiner&&(S(n,n.next)||x(n.prev,n,n.next)===0)){if(j(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function a(e,t,n,r,u,d,f){if(e){!f&&d&&h(e,r,u,d);for(var p=e,m,g;e.prev!==e.next;){if(m=e.prev,g=e.next,d?s(e,r,u,d):o(e)){t.push(m.i/n|0),t.push(e.i/n|0),t.push(g.i/n|0),j(e),e=g.next,p=g.next;continue}if(e=g,e===p){f?f===1?(e=c(i(e),t,n),a(e,t,n,r,u,d,2)):f===2&&l(e,t,n,r,u,d):a(i(e),t,n,r,u,d,1);break}}}}function o(e){var t=e.prev,n=e,r=e.next;if(x(t,n,r)>=0)return!1;for(var i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=ia?i>o?i:o:a>o?a:o,p=s>c?s>l?s:l:c>l?c:l,m=r.next;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&y(i,s,a,c,o,l,m.x,m.y)&&x(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function s(e,t,n,r){var i=e.prev,a=e,o=e.next;if(x(i,a,o)>=0)return!1;for(var s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=sc?s>l?s:l:c>l?c:l,g=u>d?u>f?u:f:d>f?d:f,v=_(p,m,t,n,r),b=_(h,g,t,n,r),S=e.prevZ,C=e.nextZ;S&&S.z>=v&&C&&C.z<=b;){if(S.x>=p&&S.x<=h&&S.y>=m&&S.y<=g&&S!==i&&S!==o&&y(s,u,c,d,l,f,S.x,S.y)&&x(S.prev,S,S.next)>=0||(S=S.prevZ,C.x>=p&&C.x<=h&&C.y>=m&&C.y<=g&&C!==i&&C!==o&&y(s,u,c,d,l,f,C.x,C.y)&&x(C.prev,C,C.next)>=0))return!1;C=C.nextZ}for(;S&&S.z>=v;){if(S.x>=p&&S.x<=h&&S.y>=m&&S.y<=g&&S!==i&&S!==o&&y(s,u,c,d,l,f,S.x,S.y)&&x(S.prev,S,S.next)>=0)return!1;S=S.prevZ}for(;C&&C.z<=b;){if(C.x>=p&&C.x<=h&&C.y>=m&&C.y<=g&&C!==i&&C!==o&&y(s,u,c,d,l,f,C.x,C.y)&&x(C.prev,C,C.next)>=0)return!1;C=C.nextZ}return!0}function c(e,t,n){var r=e;do{var a=r.prev,o=r.next.next;!S(a,o)&&C(a,r,r.next,o)&&D(a,o)&&D(o,a)&&(t.push(a.i/n|0),t.push(r.i/n|0),t.push(o.i/n|0),j(r),j(r.next),r=e=o),r=r.next}while(r!==e);return i(r)}function l(e,t,n,r,o,s){var c=e;do{for(var l=c.next.next;l!==c.prev;){if(c.i!==l.i&&b(c,l)){var u=k(c,l);c=i(c,c.next),u=i(u,u.next),a(c,t,n,r,o,s,0),a(u,t,n,r,o,s,0);return}l=l.next}c=c.next}while(c!==e)}function u(e,t,n,i){var a=[],o,s,c,l,u;for(o=0,s=t.length;o=n.next.y&&n.next.y!==n.y){var s=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=r&&s>a&&(a=s,o=n.x=n.x&&n.x>=l&&r!==n.x&&y(io.x||n.x===o.x&&m(o,n)))&&(o=n,d=f)),n=n.next;while(n!==c);return o}function m(e,t){return x(e.prev,e,t.prev)<0&&x(t.next,e,e.next)<0}function h(e,t,n,r){var i=e;do i.z===0&&(i.z=_(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,g(i)}function g(e){var t,n,r,i,a,o,s,c,l=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,r=n,s=0,t=0;t0||c>0&&r;)s!==0&&(c===0||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;n=r}a.nextZ=null,l*=2}while(o>1);return e}function _(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function v(e){var t=e,n=e;do(t.x=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function b(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!E(e,t)&&(D(e,t)&&D(t,e)&&O(e,t)&&(x(e.prev,e,t.prev)||x(e,t.prev,t))||S(e,t)&&x(e.prev,e,e.next)>0&&x(t.prev,t,t.next)>0)}function x(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function S(e,t){return e.x===t.x&&e.y===t.y}function C(e,t,n,r){var i=T(x(e,t,n)),a=T(x(e,t,r)),o=T(x(n,r,e)),s=T(x(n,r,t));return!!(i!==a&&o!==s||i===0&&w(e,n,t)||a===0&&w(e,r,t)||o===0&&w(n,e,r)||s===0&&w(n,t,r))}function w(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function T(e){return e>0?1:e<0?-1:0}function E(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&C(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function D(e,t){return x(e.prev,e,e.next)<0?x(e,t,e.next)>=0&&x(e,e.prev,t)>=0:x(e,t,e.prev)<0||x(e,e.next,t)<0}function O(e,t){var n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function k(e,t){var n=new M(e.i,e.x,e.y),r=new M(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function A(e,t,n,r){var i=new M(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function j(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function M(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}n.deviation=function(e,t,n,r){var i=t&&t.length,a=i?t[0]*n:e.length,o=Math.abs(N(e,0,a,n));if(i)for(var s=0,c=t.length;s0&&(r+=e[i-1].length,n.holes.push(r))}return n}}),$o=xt((exports,t)=>{(function(n){var r=typeof exports==`object`&&exports&&!exports.nodeType&&exports,i=typeof t==`object`&&t&&!t.nodeType&&t,a=typeof global==`object`&&global;(a.global===a||a.window===a||a.self===a)&&(n=a);var o,s=2147483647,c=36,l=1,u=26,d=38,f=700,p=72,m=128,h=`-`,g=/^xn--/,_=/[^\x20-\x7E]/,v=/[\x2E\u3002\uFF0E\uFF61]/g,y={overflow:`Overflow: input needs wider integers to process`,"not-basic":`Illegal input >= 0x80 (not a basic code point)`,"invalid-input":`Invalid input`},b=c-l,x=Math.floor,S=String.fromCharCode,C;function w(e){throw RangeError(y[e])}function T(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function E(e,t){var n=e.split(`@`),r=``;n.length>1&&(r=n[0]+`@`,e=n[1]),e=e.replace(v,`.`);var i=e.split(`.`),a=T(i,t).join(`.`);return r+a}function D(e){for(var t=[],n=0,r=e.length,i,a;n=55296&&i<=56319&&n65535&&(e-=65536,t+=S(e>>>10&1023|55296),e=56320|e&1023),t+=S(e),t}).join(``)}function k(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:c}function A(e,t){return e+22+75*(e<26)-((t!=0)<<5)}function j(e,t,n){var r=0;for(e=n?x(e/f):e>>1,e+=x(e/t);e>b*u>>1;r+=c)e=x(e/b);return x(r+(b+1)*e/(e+d))}function M(e){var t=[],n=e.length,r,i=0,a=m,o=p,d,f,g,_,v,y,b,S,C;for(d=e.lastIndexOf(h),d<0&&(d=0),f=0;f=128&&w(`not-basic`),t.push(e.charCodeAt(f));for(g=d>0?d+1:0;g=n&&w(`invalid-input`),b=k(e.charCodeAt(g++)),(b>=c||b>x((s-i)/v))&&w(`overflow`),i+=b*v,S=y<=o?l:y>=o+u?u:y-o,!(bx(s/C)&&w(`overflow`),v*=C;r=t.length+1,o=j(i-_,r,_==0),x(i/r)>s-a&&w(`overflow`),a+=x(i/r),i%=r,t.splice(i++,0,a)}return O(t)}function N(e){var t,n,r,i,a,o,d,f,g,_,v,y=[],b,C,T,E;for(e=D(e),b=e.length,t=m,n=0,a=p,o=0;o=t&&vx((s-n)/C)&&w(`overflow`),n+=(d-t)*C,t=d,o=0;os&&w(`overflow`),v==t){for(f=n,g=c;_=g<=a?l:g>=a+u?u:g-a,!(f<_);g+=c)E=f-_,T=c-_,y.push(S(A(_+E%T,0))),f=x(E/T);y.push(S(A(f,0))),a=j(n,C,r==i),n=0,++r}++n,++t}return y.join(``)}function ee(e){return E(e,function(e){return g.test(e)?M(e.slice(4).toLowerCase()):e})}function P(e){return E(e,function(e){return _.test(e)?`xn--`+N(e):e})}if(o={version:`1.4.1`,ucs2:{decode:D,encode:O},decode:M,encode:N,toASCII:P,toUnicode:ee},typeof define==`function`&&typeof define.amd==`object`&&define.amd)define(`punycode`,function(){return o});else if(r&&i)if(t.exports==r)i.exports=o;else for(C in o)o.hasOwnProperty(C)&&(r[C]=o[C]);else n.punycode=o})(void 0)}),es=xt((exports,t)=>{Object.defineProperty(exports,`__esModule`,{value:!0});function n(){let e,t,n=n=>{if(n&&(typeof n==`object`||typeof n==`function`)){if(e)return e.get(n)}else if(t)return t.get(n)},r=(n,r)=>{n&&(typeof n==`object`||typeof n==`function`)?(e||=new WeakMap,e.set(n,r)):(t||=new Map,t.set(n,r))},i=n=>{if(n&&(typeof n==`object`||typeof n==`function`)){if(e)return e.has(n)}else if(t)return t.has(n);return!1},a=e=>{if(!i(e))throw TypeError(`Side channel does not contain the given key`)};return{get:n,set:r,has:i,assert:a}}exports.default=n,(typeof exports.default==`object`&&exports.default!==null||typeof exports.default==`function`)&&(Object.assign(exports.default,exports),t.exports=exports.default)}),ts=xt((exports,t)=>{var n=String.prototype.replace,r=/%20/g,i={RFC1738:`RFC1738`,RFC3986:`RFC3986`};t.exports={default:i.RFC3986,formatters:{RFC1738:function(e){return n.call(e,r,`+`)},RFC3986:function(e){return String(e)}},RFC1738:i.RFC1738,RFC3986:i.RFC3986}}),ns=xt((exports,t)=>{var n=ts(),r=Object.prototype.hasOwnProperty,i=Array.isArray,a=function(){for(var e=[],t=0;t<256;++t)e.push(`%`+((t<16?`0`:``)+t.toString(16)).toUpperCase());return e}(),o=function(e){for(;e.length>1;){var t=e.pop(),n=t.obj[t.prop];if(i(n)){for(var r=[],a=0;a=d?s.slice(l,l+d):s,f=[],p=0;p=48&&m<=57||m>=65&&m<=90||m>=97&&m<=122||o===n.RFC1738&&(m===40||m===41)){f[f.length]=u.charAt(p);continue}if(m<128){f[f.length]=a[m];continue}if(m<2048){f[f.length]=a[192|m>>6]+a[128|m&63];continue}if(m<55296||m>=57344){f[f.length]=a[224|m>>12]+a[128|m>>6&63]+a[128|m&63];continue}p+=1,m=65536+((m&1023)<<10|u.charCodeAt(p)&1023),f[f.length]=a[240|m>>18]+a[128|m>>12&63]+a[128|m>>6&63]+a[128|m&63]}c+=f.join(``)}return c},p=function(e){for(var t=[{obj:{o:e},prop:`o`}],n=[],r=0;r{var n=es(),r=ns(),i=ts(),a=Object.prototype.hasOwnProperty,o={brackets:function(e){return e+`[]`},comma:`comma`,indices:function(e,t){return e+`[`+t+`]`},repeat:function(e){return e}},s=Array.isArray,c=Array.prototype.push,l=function(e,t){c.apply(e,s(t)?t:[t])},u=Date.prototype.toISOString,d=i.default,f={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:`indices`,charset:`utf-8`,charsetSentinel:!1,commaRoundTrip:!1,delimiter:`&`,encode:!0,encodeDotInKeys:!1,encoder:r.encode,encodeValuesOnly:!1,filter:void 0,format:d,formatter:i.formatters[d],indices:!1,serializeDate:function(e){return u.call(e)},skipNulls:!1,strictNullHandling:!1},p=function(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`symbol`||typeof e==`bigint`},m={},h=function e(t,i,a,o,c,u,d,h,g,_,v,y,b,x,S,C,w,T){for(var E=t,D=T,O=0,k=!1;(D=D.get(m))!==void 0&&!k;){var A=D.get(t);if(O+=1,A!==void 0){if(A===O)throw RangeError(`Cyclic object value`);k=!0}D.get(m)===void 0&&(O=0)}if(typeof _==`function`?E=_(i,E):E instanceof Date?E=b(E):a===`comma`&&s(E)&&(E=r.maybeMap(E,function(e){return e instanceof Date?b(e):e})),E===null){if(u)return g&&!C?g(i,f.encoder,w,`key`,x):i;E=``}if(p(E)||r.isBuffer(E)){if(g){var j=C?i:g(i,f.encoder,w,`key`,x);return[S(j)+`=`+S(g(E,f.encoder,w,`value`,x))]}return[S(i)+`=`+S(String(E))]}var M=[];if(E===void 0)return M;var N;if(a===`comma`&&s(E))C&&g&&(E=r.maybeMap(E,g)),N=[{value:E.length>0?E.join(`,`)||null:void 0}];else if(s(_))N=_;else{var ee=Object.keys(E);N=v?ee.sort(v):ee}var P=h?String(i).replace(/\./g,`%2E`):String(i),F=o&&s(E)&&E.length===1?P+`[]`:P;if(c&&s(E)&&E.length===0)return F+`[]`;for(var I=0;I0?b+y:``}}),os=xt((exports,t)=>{var n=ns(),r=Object.prototype.hasOwnProperty,i=Array.isArray,a={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:`utf-8`,charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:n.decode,delimiter:`&`,depth:5,duplicates:`combine`,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictNullHandling:!1,throwOnLimitExceeded:!1},o=function(e){return e.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},s=function(e,t,n){if(e&&typeof e==`string`&&t.comma&&e.indexOf(`,`)>-1)return e.split(`,`);if(t.throwOnLimitExceeded&&n>=t.arrayLimit)throw RangeError(`Array limit exceeded. Only `+t.arrayLimit+` element`+(t.arrayLimit===1?``:`s`)+` allowed in an array.`);return e},c=`utf8=%26%2310003%3B`,l=`utf8=%E2%9C%93`,u=function(e,t){var u={__proto__:null},d=t.ignoreQueryPrefix?e.replace(/^\?/,``):e;d=d.replace(/%5B/gi,`[`).replace(/%5D/gi,`]`);var f=t.parameterLimit===1/0?void 0:t.parameterLimit,p=d.split(t.delimiter,t.throwOnLimitExceeded?f+1:f);if(t.throwOnLimitExceeded&&p.length>f)throw RangeError(`Parameter limit exceeded. Only `+f+` parameter`+(f===1?``:`s`)+` allowed.`);var m=-1,h,g=t.charset;if(t.charsetSentinel)for(h=0;h-1&&(x=i(x)?[x]:x);var S=r.call(u,b);S&&t.duplicates===`combine`?u[b]=n.combine(u[b],x):(!S||t.duplicates===`last`)&&(u[b]=x)}return u},d=function(e,t,r,i){var a=0;if(e.length>0&&e[e.length-1]===`[]`){var o=e.slice(0,-1).join(``);a=Array.isArray(t)&&t[o]?t[o].length:0}for(var c=i?t:s(t,r,a),l=e.length-1;l>=0;--l){var u,d=e[l];if(d===`[]`&&r.parseArrays)u=r.allowEmptyArrays&&(c===``||r.strictNullHandling&&c===null)?[]:n.combine([],c);else{u=r.plainObjects?{__proto__:null}:{};var f=d.charAt(0)===`[`&&d.charAt(d.length-1)===`]`?d.slice(1,-1):d,p=r.decodeDotInKeys?f.replace(/%2E/g,`.`):f,m=parseInt(p,10);!r.parseArrays&&p===``?u={0:c}:!isNaN(m)&&d!==p&&String(m)===p&&m>=0&&r.parseArrays&&m<=r.arrayLimit?(u=[],u[m]=c):p!==`__proto__`&&(u[p]=c)}c=u}return c},f=function(e,t,n,i){if(e){var a=n.allowDots?e.replace(/\.([^.[]+)/g,`[$1]`):e,o=/(\[[^[\]]*])/,s=/(\[[^[\]]*])/g,c=n.depth>0&&o.exec(a),l=c?a.slice(0,c.index):a,u=[];if(l){if(!n.plainObjects&&r.call(Object.prototype,l)&&!n.allowPrototypes)return;u.push(l)}for(var f=0;n.depth>0&&(c=s.exec(a))!==null&&f{var n=rs(),r=os(),i=ts();t.exports={formats:i,parse:r,stringify:n}}),cs=xt(exports=>{var t=$o();function n(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var r=/^([a-z0-9.+-]+:)/i,i=/:[0-9]*$/,a=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,o=[`<`,`>`,`"`,"`",` `,`\r`,` +`,` `],s=[`{`,`}`,`|`,`\\`,`^`,"`"].concat(o),c=[`'`].concat(s),l=[`%`,`/`,`?`,`;`,`#`].concat(c),u=[`/`,`?`,`#`],d=255,f=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,m={javascript:!0,"javascript:":!0},h={javascript:!0,"javascript:":!0},g={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},_=ss();function v(e,t,r){if(e&&typeof e==`object`&&e instanceof n)return e;var i=new n;return i.parse(e,t,r),i}n.prototype.parse=function(e,n,i){if(typeof e!=`string`)throw TypeError(`Parameter 'url' must be a string, not `+typeof e);var o=e.indexOf(`?`),s=o!==-1&&o127?ee+=`x`:ee+=N[P];if(!ee.match(f)){var I=j.slice(0,E),te=j.slice(E+1),ne=N.match(p);ne&&(I.push(ne[1]),te.unshift(ne[2])),te.length&&(b=`/`+te.join(`.`)+b),this.hostname=I.join(`.`);break}}}this.hostname.length>d?this.hostname=``:this.hostname=this.hostname.toLowerCase(),A||(this.hostname=t.toASCII(this.hostname));var L=this.port?`:`+this.port:``,re=this.hostname||``;this.host=re+L,this.href+=this.host,A&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),b[0]!==`/`&&(b=`/`+b))}if(!m[C])for(var E=0,M=c.length;E0?r.host.split(`@`):!1;w&&(r.auth=w.shift(),r.hostname=w.shift(),r.host=r.hostname)}return r.search=e.search,r.query=e.query,(r.pathname!==null||r.search!==null)&&(r.path=(r.pathname?r.pathname:``)+(r.search?r.search:``)),r.href=r.format(),r}if(!S.length)return r.pathname=null,r.search?r.path=`/`+r.search:r.path=null,r.href=r.format(),r;for(var T=S.slice(-1)[0],E=(r.host||e.host||S.length>1)&&(T===`.`||T===`..`)||T===``,D=0,O=S.length;O>=0;O--)T=S[O],T===`.`?S.splice(O,1):T===`..`?(S.splice(O,1),D++):D&&(S.splice(O,1),D--);if(!b&&!x)for(;D--;)S.unshift(`..`);b&&S[0]!==``&&(!S[0]||S[0].charAt(0)!==`/`)&&S.unshift(``),E&&S.join(`/`).substr(-1)!==`/`&&S.push(``);var k=S[0]===``||S[0]&&S[0].charAt(0)===`/`;if(C){r.hostname=k?``:S.length?S.shift():``,r.host=r.hostname;var w=r.host&&r.host.indexOf(`@`)>0?r.host.split(`@`):!1;w&&(r.auth=w.shift(),r.hostname=w.shift(),r.host=r.hostname)}return b||=r.host&&S.length,b&&!k&&S.unshift(``),S.length>0?r.pathname=S.join(`/`):(r.pathname=null,r.path=null),(r.pathname!==null||r.search!==null)&&(r.path=(r.pathname?r.pathname:``)+(r.search?r.search:``)),r.auth=e.auth||r.auth,r.slashes=r.slashes||e.slashes,r.href=r.format(),r},n.prototype.parseHost=function(){var e=this.host,t=i.exec(e);t&&(t=t[0],t!==`:`&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)},exports.parse=v,exports.resolve=b,exports.resolveObject=x,exports.format=y,exports.Url=n}),ls=Et(Zo(),1),us=Et(Qo(),1),ds=Et(cs(),1),fs={parse:ds.parse,format:ds.format,resolve:ds.resolve};Xo.RETINA_PREFIX=/@([0-9\.]+)x/,Xo.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT=!1;var ps=!1,ms=`6.5.10`;function hs(e){var t;if(!ps){if(Xo.ADAPTER.getNavigator().userAgent.toLowerCase().indexOf(`chrome`)>-1){var n=[` + %c %c %c PixiJS `+ms+` - ✰ `+e+` ✰ %c %c http://www.pixijs.com/ %c %c ♥%c♥%c♥ + +`,`background: #ff66a5; padding:5px 0;`,`background: #ff66a5; padding:5px 0;`,`color: #ff66a5; background: #030307; padding:5px 0;`,`background: #ff66a5; padding:5px 0;`,`background: #ffc3dc; padding:5px 0;`,`background: #ff66a5; padding:5px 0;`,`color: #ff2424; background: #fff; padding:5px 0;`,`color: #ff2424; background: #fff; padding:5px 0;`,`color: #ff2424; background: #fff; padding:5px 0;`];(t=globalThis.console).log.apply(t,n)}else globalThis.console&&globalThis.console.log(`PixiJS `+ms+` - `+e+` - http://www.pixijs.com/`);ps=!0}}var gs;function _s(){return gs===void 0&&(gs=function(){var e={stencil:!0,failIfMajorPerformanceCaveat:Xo.FAIL_IF_MAJOR_PERFORMANCE_CAVEAT};try{if(!Xo.ADAPTER.getWebGLRenderingContext())return!1;var t=Xo.ADAPTER.createCanvas(),n=t.getContext(`webgl`,e)||t.getContext(`experimental-webgl`,e),r=!!(n&&n.getContextAttributes().stencil);if(n){var i=n.getExtension(`WEBGL_lose_context`);i&&i.loseContext()}return n=null,r}catch{return!1}}()),gs}function vs(e,t){return t===void 0&&(t=[]),t[0]=(e>>16&255)/255,t[1]=(e>>8&255)/255,t[2]=(e&255)/255,t}function ys(e){var t=e.toString(16);return t=`000000`.substring(0,6-t.length)+t,`#`+t}function bs(e){return(e[0]*255<<16)+(e[1]*255<<8)+(e[2]*255|0)}function xs(){for(var e=[],t=[],n=0;n<32;n++)e[n]=n,t[n]=n;e[uo.NORMAL_NPM]=uo.NORMAL,e[uo.ADD_NPM]=uo.ADD,e[uo.SCREEN_NPM]=uo.SCREEN,t[uo.NORMAL]=uo.NORMAL_NPM,t[uo.ADD]=uo.ADD_NPM,t[uo.SCREEN]=uo.SCREEN_NPM;var r=[];return r.push(t),r.push(e),r}var Ss=xs();function Cs(e,t){if(t===1)return(t*255<<24)+e;if(t===0)return 0;var n=e>>16&255,r=e>>8&255,i=e&255;return n=n*t+.5|0,r=r*t+.5|0,i=i*t+.5|0,(t*255<<24)+(n<<16)+(r<<8)+i}function ws(e){if(e.BYTES_PER_ELEMENT===4)return e instanceof Float32Array?`Float32Array`:e instanceof Uint32Array?`Uint32Array`:`Int32Array`;if(e.BYTES_PER_ELEMENT===2){if(e instanceof Uint16Array)return`Uint16Array`}else if(e.BYTES_PER_ELEMENT===1&&e instanceof Uint8Array)return`Uint8Array`;return null}function Ts(e){return e+=e===0?1:0,--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e+1}function Es(e){return!(e&e-1)&&!!e}function Ds(e){var t=(e>65535?1:0)<<4;e>>>=t;var n=(e>255?1:0)<<3;return e>>>=n,t|=n,n=(e>15?1:0)<<2,e>>>=n,t|=n,n=(e>3?1:0)<<1,e>>>=n,t|=n,t|e>>1}function Os(e,t,n){var r=e.length,i;if(!(t>=r||n===0)){n=t+n>r?r-t:n;var a=r-n;for(i=t;i8)throw Error(`max arguments reached`);var c=this,l=c.name,u=c.items;this._aliasCount++;for(var d=0,f=u.length;d0&&this.items.length>1&&(this._aliasCount=0,this.items=this.items.slice(0))},e.prototype.add=function(e){return e[this._name]&&(this.ensureNonAliasedItems(),this.remove(e),this.items.push(e)),this},e.prototype.remove=function(e){var t=this.items.indexOf(e);return t!==-1&&(this.ensureNonAliasedItems(),this.items.splice(t,1)),this},e.prototype.contains=function(e){return this.items.indexOf(e)!==-1},e.prototype.removeAll=function(){return this.ensureNonAliasedItems(),this.items.length=0,this},e.prototype.destroy=function(){this.removeAll(),this.items=null,this._name=null},Object.defineProperty(e.prototype,`empty`,{get:function(){return this.items.length===0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,`name`,{get:function(){return this._name},enumerable:!1,configurable:!0}),e}();Object.defineProperties(Ws.prototype,{dispatch:{value:Ws.prototype.emit},run:{value:Ws.prototype.emit}}),Xo.TARGET_FPMS=.06;var Gs;(function(e){e[e.INTERACTION=50]=`INTERACTION`,e[e.HIGH=25]=`HIGH`,e[e.NORMAL=0]=`NORMAL`,e[e.LOW=-25]=`LOW`,e[e.UTILITY=-50]=`UTILITY`})(Gs||={});var Ks=function(){function e(e,t,n,r){t===void 0&&(t=null),n===void 0&&(n=0),r===void 0&&(r=!1),this.next=null,this.previous=null,this._destroyed=!1,this.fn=e,this.context=t,this.priority=n,this.once=r}return e.prototype.match=function(e,t){return t===void 0&&(t=null),this.fn===e&&this.context===t},e.prototype.emit=function(e){this.fn&&(this.context?this.fn.call(this.context,e):this.fn(e));var t=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),t},e.prototype.connect=function(e){this.previous=e,e.next&&(e.next.previous=this),this.next=e.next,e.next=this},e.prototype.destroy=function(e){e===void 0&&(e=!1),this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);var t=this.next;return this.next=e?null:t,this.previous=null,t},e}(),qs=function(){function e(){var e=this;this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Ks(null,null,1/0),this.deltaMS=1/Xo.TARGET_FPMS,this.elapsedMS=1/Xo.TARGET_FPMS,this._tick=function(t){e._requestId=null,e.started&&(e.update(t),e.started&&e._requestId===null&&e._head.next&&(e._requestId=requestAnimationFrame(e._tick)))}}return e.prototype._requestIfNeeded=function(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))},e.prototype._cancelIfNeeded=function(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)},e.prototype._startIfPossible=function(){this.started?this._requestIfNeeded():this.autoStart&&this.start()},e.prototype.add=function(e,t,n){return n===void 0&&(n=Gs.NORMAL),this._addListener(new Ks(e,t,n))},e.prototype.addOnce=function(e,t,n){return n===void 0&&(n=Gs.NORMAL),this._addListener(new Ks(e,t,n,!0))},e.prototype._addListener=function(e){var t=this._head.next,n=this._head;if(!t)e.connect(n);else{for(;t;){if(e.priority>t.priority){e.connect(n);break}n=t,t=t.next}e.previous||e.connect(n)}return this._startIfPossible(),this},e.prototype.remove=function(e,t){for(var n=this._head.next;n;)n=n.match(e,t)?n.destroy():n.next;return this._head.next||this._cancelIfNeeded(),this},Object.defineProperty(e.prototype,`count`,{get:function(){if(!this._head)return 0;for(var e=0,t=this._head;t=t.next;)e++;return e},enumerable:!1,configurable:!0}),e.prototype.start=function(){this.started||(this.started=!0,this._requestIfNeeded())},e.prototype.stop=function(){this.started&&(this.started=!1,this._cancelIfNeeded())},e.prototype.destroy=function(){if(!this._protected){this.stop();for(var e=this._head.next;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}},e.prototype.update=function(e){e===void 0&&(e=performance.now());var t;if(e>this.lastTime){if(t=this.elapsedMS=e-this.lastTime,t>this._maxElapsedMS&&(t=this._maxElapsedMS),t*=this.speed,this._minElapsedMS){var n=e-this._lastFrame|0;if(n=this.x&&e=this.y&&te.right?e.right:this.right;if(r<=n)return!1;var i=this.ye.bottom?e.bottom:this.bottom;return a>i}var o=this.left,s=this.right,c=this.top,l=this.bottom;if(s<=o||l<=c)return!1;var u=ec[0].set(e.left,e.top),d=ec[1].set(e.left,e.bottom),f=ec[2].set(e.right,e.top),p=ec[3].set(e.right,e.bottom);if(f.x<=u.x||d.y<=u.y)return!1;var m=Math.sign(t.a*t.d-t.b*t.c);if(m===0||(t.apply(u,u),t.apply(d,d),t.apply(f,f),t.apply(p,p),Math.max(u.x,d.x,f.x,p.x)<=o||Math.min(u.x,d.x,f.x,p.x)>=s||Math.max(u.y,d.y,f.y,p.y)<=c||Math.min(u.y,d.y,f.y,p.y)>=l))return!1;var h=m*(d.y-u.y),g=m*(u.x-d.x),_=h*o+g*c,v=h*s+g*c,y=h*o+g*l,b=h*s+g*l;if(Math.max(_,v,y,b)<=h*u.x+g*u.y||Math.min(_,v,y,b)>=h*p.x+g*p.y)return!1;var x=m*(u.y-f.y),S=m*(f.x-u.x),C=x*o+S*c,w=x*s+S*c,T=x*o+S*l,E=x*s+S*l;return!(Math.max(C,w,T,E)<=x*u.x+S*u.y||Math.min(C,w,T,E)>=x*p.x+S*p.y)},e.prototype.pad=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=e),this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this},e.prototype.fit=function(e){var t=Math.max(this.x,e.x),n=Math.min(this.x+this.width,e.x+e.width),r=Math.max(this.y,e.y),i=Math.min(this.y+this.height,e.y+e.height);return this.x=t,this.width=Math.max(n-t,0),this.y=r,this.height=Math.max(i-r,0),this},e.prototype.ceil=function(e,t){e===void 0&&(e=1),t===void 0&&(t=.001);var n=Math.ceil((this.x+this.width-t)*e)/e,r=Math.ceil((this.y+this.height-t)*e)/e;return this.x=Math.floor((this.x+t)*e)/e,this.y=Math.floor((this.y+t)*e)/e,this.width=n-this.x,this.height=r-this.y,this},e.prototype.enlarge=function(e){var t=Math.min(this.x,e.x),n=Math.max(this.x+this.width,e.x+e.width),r=Math.min(this.y,e.y),i=Math.max(this.y+this.height,e.y+e.height);return this.x=t,this.width=n-t,this.y=r,this.height=i-r,this},e.prototype.toString=function(){return`[@pixi/math:Rectangle x=`+this.x+` y=`+this.y+` width=`+this.width+` height=`+this.height+`]`},e}(),nc=function(){function e(e,t,n){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0),this.x=e,this.y=t,this.radius=n,this.type=Qs.CIRC}return e.prototype.clone=function(){return new e(this.x,this.y,this.radius)},e.prototype.contains=function(e,t){if(this.radius<=0)return!1;var n=this.radius*this.radius,r=this.x-e,i=this.y-t;return r*=r,i*=i,r+i<=n},e.prototype.getBounds=function(){return new tc(this.x-this.radius,this.y-this.radius,this.radius*2,this.radius*2)},e.prototype.toString=function(){return`[@pixi/math:Circle x=`+this.x+` y=`+this.y+` radius=`+this.radius+`]`},e}(),rc=function(){function e(e,t,n,r){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=0),this.x=e,this.y=t,this.width=n,this.height=r,this.type=Qs.ELIP}return e.prototype.clone=function(){return new e(this.x,this.y,this.width,this.height)},e.prototype.contains=function(e,t){if(this.width<=0||this.height<=0)return!1;var n=(e-this.x)/this.width,r=(t-this.y)/this.height;return n*=n,r*=r,n+r<=1},e.prototype.getBounds=function(){return new tc(this.x-this.width,this.y-this.height,this.width,this.height)},e.prototype.toString=function(){return`[@pixi/math:Ellipse x=`+this.x+` y=`+this.y+` width=`+this.width+` height=`+this.height+`]`},e}(),ic=function(){function e(){for(var e=arguments,t=[],n=0;nt!=l>t&&e<(c-o)*((t-s)/(l-s))+o;u&&(n=!n)}return n},e.prototype.toString=function(){return`[@pixi/math:Polygon`+(`closeStroke=`+this.closeStroke)+(`points=`+this.points.reduce(function(e,t){return e+`, `+t},``)+`]`)},e}(),ac=function(){function e(e,t,n,r,i){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=0),i===void 0&&(i=20),this.x=e,this.y=t,this.width=n,this.height=r,this.radius=i,this.type=Qs.RREC}return e.prototype.clone=function(){return new e(this.x,this.y,this.width,this.height,this.radius)},e.prototype.contains=function(e,t){if(this.width<=0||this.height<=0)return!1;if(e>=this.x&&e<=this.x+this.width&&t>=this.y&&t<=this.y+this.height){var n=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(t>=this.y+n&&t<=this.y+this.height-n||e>=this.x+n&&e<=this.x+this.width-n)return!0;var r=e-(this.x+n),i=t-(this.y+n),a=n*n;if(r*r+i*i<=a||(r=e-(this.x+this.width-n),r*r+i*i<=a)||(i=t-(this.y+this.height-n),r*r+i*i<=a)||(r=e-(this.x+n),r*r+i*i<=a))return!0}return!1},e.prototype.toString=function(){return`[@pixi/math:RoundedRectangle x=`+this.x+` y=`+this.y+(`width=`+this.width+` height=`+this.height+` radius=`+this.radius+`]`)},e}(),oc=function(){function e(e,t,n,r){n===void 0&&(n=0),r===void 0&&(r=0),this._x=n,this._y=r,this.cb=e,this.scope=t}return e.prototype.clone=function(t,n){return t===void 0&&(t=this.cb),n===void 0&&(n=this.scope),new e(t,n,this._x,this._y)},e.prototype.set=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=e),(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this.cb.call(this.scope)),this},e.prototype.copyFrom=function(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this.cb.call(this.scope)),this},e.prototype.copyTo=function(e){return e.set(this._x,this._y),e},e.prototype.equals=function(e){return e.x===this._x&&e.y===this._y},e.prototype.toString=function(){return`[@pixi/math:ObservablePoint x=0 y=0 scope=`+this.scope+`]`},Object.defineProperty(e.prototype,`x`,{get:function(){return this._x},set:function(e){this._x!==e&&(this._x=e,this.cb.call(this.scope))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,`y`,{get:function(){return this._y},set:function(e){this._y!==e&&(this._y=e,this.cb.call(this.scope))},enumerable:!1,configurable:!0}),e}(),sc=function(){function e(e,t,n,r,i,a){e===void 0&&(e=1),t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=1),i===void 0&&(i=0),a===void 0&&(a=0),this.array=null,this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a}return e.prototype.fromArray=function(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]},e.prototype.set=function(e,t,n,r,i,a){return this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a,this},e.prototype.toArray=function(e,t){this.array||=new Float32Array(9);var n=t||this.array;return e?(n[0]=this.a,n[1]=this.b,n[2]=0,n[3]=this.c,n[4]=this.d,n[5]=0,n[6]=this.tx,n[7]=this.ty,n[8]=1):(n[0]=this.a,n[1]=this.c,n[2]=this.tx,n[3]=this.b,n[4]=this.d,n[5]=this.ty,n[6]=0,n[7]=0,n[8]=1),n},e.prototype.apply=function(e,t){t||=new $s;var n=e.x,r=e.y;return t.x=this.a*n+this.c*r+this.tx,t.y=this.b*n+this.d*r+this.ty,t},e.prototype.applyInverse=function(e,t){t||=new $s;var n=1/(this.a*this.d+this.c*-this.b),r=e.x,i=e.y;return t.x=this.d*n*r+-this.c*n*i+(this.ty*this.c-this.tx*this.d)*n,t.y=this.a*n*i+-this.b*n*r+(-this.ty*this.a+this.tx*this.b)*n,t},e.prototype.translate=function(e,t){return this.tx+=e,this.ty+=t,this},e.prototype.scale=function(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this},e.prototype.rotate=function(e){var t=Math.cos(e),n=Math.sin(e),r=this.a,i=this.c,a=this.tx;return this.a=r*t-this.b*n,this.b=r*n+this.b*t,this.c=i*t-this.d*n,this.d=i*n+this.d*t,this.tx=a*t-this.ty*n,this.ty=a*n+this.ty*t,this},e.prototype.append=function(e){var t=this.a,n=this.b,r=this.c,i=this.d;return this.a=e.a*t+e.b*r,this.b=e.a*n+e.b*i,this.c=e.c*t+e.d*r,this.d=e.c*n+e.d*i,this.tx=e.tx*t+e.ty*r+this.tx,this.ty=e.tx*n+e.ty*i+this.ty,this},e.prototype.setTransform=function(e,t,n,r,i,a,o,s,c){return this.a=Math.cos(o+c)*i,this.b=Math.sin(o+c)*i,this.c=-Math.sin(o-s)*a,this.d=Math.cos(o-s)*a,this.tx=e-(n*this.a+r*this.c),this.ty=t-(n*this.b+r*this.d),this},e.prototype.prepend=function(e){var t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){var n=this.a,r=this.c;this.a=n*e.a+this.b*e.c,this.b=n*e.b+this.b*e.d,this.c=r*e.a+this.d*e.c,this.d=r*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this},e.prototype.decompose=function(e){var t=this.a,n=this.b,r=this.c,i=this.d,a=e.pivot,o=-Math.atan2(-r,i),s=Math.atan2(n,t),c=Math.abs(o+s);return c<1e-5||Math.abs(Ys-c)<1e-5?(e.rotation=s,e.skew.x=e.skew.y=0):(e.rotation=0,e.skew.x=o,e.skew.y=s),e.scale.x=Math.sqrt(t*t+n*n),e.scale.y=Math.sqrt(r*r+i*i),e.position.x=this.tx+(a.x*t+a.y*r),e.position.y=this.ty+(a.x*n+a.y*i),e},e.prototype.invert=function(){var e=this.a,t=this.b,n=this.c,r=this.d,i=this.tx,a=e*r-t*n;return this.a=r/a,this.b=-t/a,this.c=-n/a,this.d=e/a,this.tx=(n*this.ty-r*i)/a,this.ty=-(e*this.ty-t*i)/a,this},e.prototype.identity=function(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this},e.prototype.clone=function(){var t=new e;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t},e.prototype.copyTo=function(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e},e.prototype.copyFrom=function(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this},e.prototype.toString=function(){return`[@pixi/math:Matrix a=`+this.a+` b=`+this.b+` c=`+this.c+` d=`+this.d+` tx=`+this.tx+` ty=`+this.ty+`]`},Object.defineProperty(e,`IDENTITY`,{get:function(){return new e},enumerable:!1,configurable:!0}),Object.defineProperty(e,`TEMP_MATRIX`,{get:function(){return new e},enumerable:!1,configurable:!0}),e}(),cc=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],lc=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],uc=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],dc=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],fc=[],pc=[],mc=Math.sign;function hc(){for(var e=0;e<16;e++){var t=[];fc.push(t);for(var n=0;n<16;n++)for(var r=mc(cc[e]*cc[n]+uc[e]*lc[n]),i=mc(lc[e]*cc[n]+dc[e]*lc[n]),a=mc(cc[e]*uc[n]+uc[e]*dc[n]),o=mc(lc[e]*uc[n]+dc[e]*dc[n]),s=0;s<16;s++)if(cc[s]===r&&lc[s]===i&&uc[s]===a&&dc[s]===o){t.push(s);break}}for(var e=0;e<16;e++){var c=new sc;c.set(cc[e],lc[e],uc[e],dc[e],0,0),pc.push(c)}}hc();var gc={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:function(e){return cc[e]},uY:function(e){return lc[e]},vX:function(e){return uc[e]},vY:function(e){return dc[e]},inv:function(e){return e&8?e&15:-e&7},add:function(e,t){return fc[e][t]},sub:function(e,t){return fc[e][gc.inv(t)]},rotate180:function(e){return e^4},isVertical:function(e){return(e&3)==2},byDirection:function(e,t){return Math.abs(e)*2<=Math.abs(t)?t>=0?gc.S:gc.N:Math.abs(t)*2<=Math.abs(e)?e>0?gc.E:gc.W:t>0?e>0?gc.SE:gc.SW:e>0?gc.NE:gc.NW},matrixAppendRotationInv:function(e,t,n,r){n===void 0&&(n=0),r===void 0&&(r=0);var i=pc[gc.inv(t)];i.tx=n,i.ty=r,e.append(i)}},_c=function(){function e(){this.worldTransform=new sc,this.localTransform=new sc,this.position=new oc(this.onChange,this,0,0),this.scale=new oc(this.onChange,this,1,1),this.pivot=new oc(this.onChange,this,0,0),this.skew=new oc(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}return e.prototype.onChange=function(){this._localID++},e.prototype.updateSkew=function(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++},e.prototype.toString=function(){return`[@pixi/math:Transform `+(`position=(`+this.position.x+`, `+this.position.y+`) `)+(`rotation=`+this.rotation+` `)+(`scale=(`+this.scale.x+`, `+this.scale.y+`) `)+(`skew=(`+this.skew.x+`, `+this.skew.y+`) `)+`]`},e.prototype.updateLocalTransform=function(){var e=this.localTransform;this._localID!==this._currentLocalID&&(e.a=this._cx*this.scale.x,e.b=this._sx*this.scale.x,e.c=this._cy*this.scale.y,e.d=this._sy*this.scale.y,e.tx=this.position.x-(this.pivot.x*e.a+this.pivot.y*e.c),e.ty=this.position.y-(this.pivot.x*e.b+this.pivot.y*e.d),this._currentLocalID=this._localID,this._parentID=-1)},e.prototype.updateTransform=function(e){var t=this.localTransform;if(this._localID!==this._currentLocalID&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==e._worldID){var n=e.worldTransform,r=this.worldTransform;r.a=t.a*n.a+t.b*n.c,r.b=t.a*n.b+t.b*n.d,r.c=t.c*n.a+t.d*n.c,r.d=t.c*n.b+t.d*n.d,r.tx=t.tx*n.a+t.ty*n.c+n.tx,r.ty=t.tx*n.b+t.ty*n.d+n.ty,this._parentID=e._worldID,this._worldID++}},e.prototype.setFromMatrix=function(e){e.decompose(this),this._localID++},Object.defineProperty(e.prototype,`rotation`,{get:function(){return this._rotation},set:function(e){this._rotation!==e&&(this._rotation=e,this.updateSkew())},enumerable:!1,configurable:!0}),e.IDENTITY=new e,e}();Xo.PREFER_ENV=qo.any?so.WEBGL:so.WEBGL2,Xo.STRICT_TEXTURE_CACHE=!1;var vc=[];function yc(e,t){if(!e)return null;var n=``;if(typeof e==`string`){var r=/\.(\w{3,4})(?:$|\?|#)/i.exec(e);r&&(n=r[1].toLowerCase())}for(var i=vc.length-1;i>=0;--i){var a=vc[i];if(a.test&&a.test(e,n))return new a(e,t)}throw Error(`Unrecognized source type to auto-detect Resource`)} +/*! ***************************************************************************** + +Copyright (c) Microsoft Corporation. + + + +Permission to use, copy, modify, and/or distribute this software for any + +purpose with or without fee is hereby granted. + + + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + +PERFORMANCE OF THIS SOFTWARE. + +***************************************************************************** */ +var bc=function(e,t){return bc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},bc(e,t)};function xc(e,t){bc(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Sc=function(){return Sc=Object.assign||function(e){for(var t=arguments,n,r=1,i=arguments.length;r0&&l>0,r.textureCacheIds=[],r.destroyed=!1,r.resource=null,r._batchEnabled=0,r._batchLocation=0,r.parentTextureArray=null,r.setResource(t),r}return Object.defineProperty(t.prototype,`realWidth`,{get:function(){return Math.round(this.width*this.resolution)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`realHeight`,{get:function(){return Math.round(this.height*this.resolution)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`mipmap`,{get:function(){return this._mipmap},set:function(e){this._mipmap!==e&&(this._mipmap=e,this.dirtyStyleId++)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`scaleMode`,{get:function(){return this._scaleMode},set:function(e){this._scaleMode!==e&&(this._scaleMode=e,this.dirtyStyleId++)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`wrapMode`,{get:function(){return this._wrapMode},set:function(e){this._wrapMode!==e&&(this._wrapMode=e,this.dirtyStyleId++)},enumerable:!1,configurable:!0}),t.prototype.setStyle=function(e,t){var n;return e!==void 0&&e!==this.scaleMode&&(this.scaleMode=e,n=!0),t!==void 0&&t!==this.mipmap&&(this.mipmap=t,n=!0),n&&this.dirtyStyleId++,this},t.prototype.setSize=function(e,t,n){return n||=this.resolution,this.setRealSize(e*n,t*n,n)},t.prototype.setRealSize=function(e,t,n){return this.resolution=n||this.resolution,this.width=Math.round(e)/this.resolution,this.height=Math.round(t)/this.resolution,this._refreshPOT(),this.update(),this},t.prototype._refreshPOT=function(){this.isPowerOfTwo=Es(this.realWidth)&&Es(this.realHeight)},t.prototype.setResolution=function(e){var t=this.resolution;return t===e?this:(this.resolution=e,this.valid&&(this.width=Math.round(this.width*t)/e,this.height=Math.round(this.height*t)/e,this.emit(`update`,this)),this._refreshPOT(),this)},t.prototype.setResource=function(e){if(this.resource===e)return this;if(this.resource)throw Error(`Resource can be set only once`);return e.bind(this),this.resource=e,this},t.prototype.update=function(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit(`update`,this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit(`loaded`,this),this.emit(`update`,this))},t.prototype.onError=function(e){this.emit(`error`,this,e)},t.prototype.destroy=function(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete Fs[this.cacheId],delete Ps[this.cacheId],this.cacheId=null),this.dispose(),t.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0},t.prototype.dispose=function(){this.emit(`dispose`,this)},t.prototype.castToBaseTexture=function(){return this},t.from=function(e,n,r){r===void 0&&(r=Xo.STRICT_TEXTURE_CACHE);var i=typeof e==`string`,a=null;if(i)a=e;else{if(!e._pixiId){var o=n&&n.pixiIdPrefix||`pixiid`;e._pixiId=o+`_`+As()}a=e._pixiId}var s=Fs[a];if(i&&r&&!s)throw Error(`The cacheId "`+a+`" does not exist in BaseTextureCache.`);return s||(s=new t(e,n),s.cacheId=a,t.addToCache(s,a)),s},t.fromBuffer=function(e,n,r,i){e||=new Float32Array(n*r*4);var a=new Tc(e,{width:n,height:r}),o=e instanceof Float32Array?ho.FLOAT:ho.UNSIGNED_BYTE;return new t(a,Object.assign({},Ec,i||{width:n,height:r,type:o}))},t.addToCache=function(e,t){t&&(e.textureCacheIds.indexOf(t)===-1&&e.textureCacheIds.push(t),Fs[t]&&console.warn(`BaseTexture added to the cache with an id [`+t+`] that already had an entry`),Fs[t]=e)},t.removeFromCache=function(e){if(typeof e==`string`){var t=Fs[e];if(t){var n=t.textureCacheIds.indexOf(e);return n>-1&&t.textureCacheIds.splice(n,1),delete Fs[e],t}}else if(e&&e.textureCacheIds){for(var r=0;r0)if(e.resource)this.addResourceAt(e.resource,t);else throw Error(`CubeResource does not support copying of renderTexture.`);else e.target=mo.TEXTURE_CUBE_MAP_POSITIVE_X+t,e.parentTextureArray=this.baseTexture,this.items[t]=e;return e.valid&&!this.valid&&this.resize(e.realWidth,e.realHeight),this.items[t]=e,this},t.prototype.upload=function(e,n,r){for(var i=this.itemDirtyIds,a=0;a)?\s*()]*-->)?\s*\]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i,t}(Ac),Fc=function(e){xc(t,e);function t(n,r){var i=this;if(r||={},!(n instanceof HTMLVideoElement)){var a=document.createElement(`video`);a.setAttribute(`preload`,`auto`),a.setAttribute(`webkit-playsinline`,``),a.setAttribute(`playsinline`,``),typeof n==`string`&&(n=[n]);var o=n[0].src||n[0];Ac.crossOrigin(a,o,r.crossorigin);for(var s=0;s2},t.prototype._onPlayStart=function(){this.valid||this._onCanPlay(),this.autoUpdate&&!this._isConnectedToTicker&&(qs.shared.add(this.update,this),this._isConnectedToTicker=!0)},t.prototype._onPlayStop=function(){this._isConnectedToTicker&&(qs.shared.remove(this.update,this),this._isConnectedToTicker=!1)},t.prototype._onCanPlay=function(){var e=this.source;e.removeEventListener(`canplay`,this._onCanPlay),e.removeEventListener(`canplaythrough`,this._onCanPlay);var t=this.valid;this.resize(e.videoWidth,e.videoHeight),!t&&this._resolve&&(this._resolve(this),this._resolve=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&e.play()},t.prototype.dispose=function(){this._isConnectedToTicker&&(qs.shared.remove(this.update,this),this._isConnectedToTicker=!1);var t=this.source;t&&(t.removeEventListener(`error`,this._onError,!0),t.pause(),t.src=``,t.load()),e.prototype.dispose.call(this)},Object.defineProperty(t.prototype,`autoUpdate`,{get:function(){return this._autoUpdate},set:function(e){e!==this._autoUpdate&&(this._autoUpdate=e,!this._autoUpdate&&this._isConnectedToTicker?(qs.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._isSourcePlaying()&&(qs.shared.add(this.update,this),this._isConnectedToTicker=!0))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`updateFPS`,{get:function(){return this._updateFPS},set:function(e){e!==this._updateFPS&&(this._updateFPS=e)},enumerable:!1,configurable:!0}),t.test=function(e,n){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement||t.TYPES.indexOf(n)>-1},t.TYPES=[`mp4`,`m4v`,`webm`,`ogg`,`ogv`,`h264`,`avi`,`mov`],t.MIME_TYPES={ogv:`video/ogg`,mov:`video/quicktime`,m4v:`video/mp4`},t}(Ac),Ic=function(e){xc(t,e);function t(t){return e.call(this,t)||this}return t.test=function(e){return!!globalThis.createImageBitmap&&typeof ImageBitmap<`u`&&e instanceof ImageBitmap},t}(Ac);vc.push(Nc,Ic,jc,Fc,Pc,Tc,Mc,kc);var Lc={__proto__:null,Resource:wc,BaseImageResource:Ac,INSTALLED:vc,autoDetectResource:yc,AbstractMultiResource:Oc,ArrayResource:kc,BufferResource:Tc,CanvasResource:jc,CubeResource:Mc,ImageResource:Nc,SVGResource:Pc,VideoResource:Fc,ImageBitmapResource:Ic},Rc=function(e){xc(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.upload=function(e,t,n){var r=e.gl;r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.alphaMode===bo.UNPACK);var i=t.realWidth,a=t.realHeight;return n.width===i&&n.height===a?r.texSubImage2D(t.target,0,0,0,i,a,t.format,n.type,this.data):(n.width=i,n.height=a,r.texImage2D(t.target,0,n.internalFormat,i,a,0,t.format,n.type,this.data)),!0},t}(Tc),zc=function(){function e(e,t){this.width=Math.round(e||100),this.height=Math.round(t||100),this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new Ws(`disposeFramebuffer`),this.multisample=Eo.NONE}return Object.defineProperty(e.prototype,`colorTexture`,{get:function(){return this.colorTextures[0]},enumerable:!1,configurable:!0}),e.prototype.addColorTexture=function(e,t){return e===void 0&&(e=0),this.colorTextures[e]=t||new Dc(null,{scaleMode:_o.NEAREST,resolution:1,mipmap:yo.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this},e.prototype.addDepthTexture=function(e){return this.depthTexture=e||new Dc(new Rc(null,{width:this.width,height:this.height}),{scaleMode:_o.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:yo.OFF,format:po.DEPTH_COMPONENT,type:ho.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this},e.prototype.enableDepth=function(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this},e.prototype.enableStencil=function(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this},e.prototype.resize=function(e,t){if(e=Math.round(e),t=Math.round(t),!(e===this.width&&t===this.height)){this.width=e,this.height=t,this.dirtyId++,this.dirtySize++;for(var n=0;n-1&&t.textureCacheIds.splice(n,1),delete Ps[e],t}}else if(e&&e.textureCacheIds){for(var r=0;rthis.baseTexture.width,o=n+i>this.baseTexture.height;if(a||o){var s=a&&o?`and`:`or`,c=`X: `+t+` + `+r+` = `+(t+r)+` > `+this.baseTexture.width,l=`Y: `+n+` + `+i+` = `+(n+i)+` > `+this.baseTexture.height;throw Error(`Texture Error: frame does not fit inside the base Texture dimensions: `+(c+` `+s+` `+l))}this.valid=r&&i&&this.baseTexture.valid,!this.trim&&!this.rotate&&(this.orig=e),this.valid&&this.updateUvs()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`rotate`,{get:function(){return this._rotate},set:function(e){this._rotate=e,this.valid&&this.updateUvs()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`width`,{get:function(){return this.orig.width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`height`,{get:function(){return this.orig.height},enumerable:!1,configurable:!0}),t.prototype.castToBaseTexture=function(){return this.baseTexture},Object.defineProperty(t,`EMPTY`,{get:function(){return t._EMPTY||(t._EMPTY=new t(new Dc),Uc(t._EMPTY),Uc(t._EMPTY.baseTexture)),t._EMPTY},enumerable:!1,configurable:!0}),Object.defineProperty(t,`WHITE`,{get:function(){if(!t._WHITE){var e=Xo.ADAPTER.createCanvas(16,16),n=e.getContext(`2d`);e.width=16,e.height=16,n.fillStyle=`white`,n.fillRect(0,0,16,16),t._WHITE=new t(Dc.from(e)),Uc(t._WHITE),Uc(t._WHITE.baseTexture)}return t._WHITE},enumerable:!1,configurable:!0}),t}(ls.default),Gc=function(e){xc(t,e);function t(t,n){var r=e.call(this,t,n)||this;return r.valid=!0,r.filterFrame=null,r.filterPoolKey=null,r.updateUvs(),r}return Object.defineProperty(t.prototype,`framebuffer`,{get:function(){return this.baseTexture.framebuffer},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`multisample`,{get:function(){return this.framebuffer.multisample},set:function(e){this.framebuffer.multisample=e},enumerable:!1,configurable:!0}),t.prototype.resize=function(e,t,n){n===void 0&&(n=!0);var r=this.baseTexture.resolution,i=Math.round(e*r)/r,a=Math.round(t*r)/r;this.valid=i>0&&a>0,this._frame.width=this.orig.width=i,this._frame.height=this.orig.height=a,n&&this.baseTexture.resize(i,a),this.updateUvs()},t.prototype.setResolution=function(e){var t=this.baseTexture;t.resolution!==e&&(t.setResolution(e),this.resize(t.width,t.height,!1))},t.create=function(e){for(var n=arguments,r=[],i=1;i>>0,r>1&&(i+=r*4294967296)):i=r>1?-r:-1,this.texturePool[i]||(this.texturePool[i]=[]);var a=this.texturePool[i].pop();return a||=this.createTexture(e,t,r),a.filterPoolKey=i,a.setResolution(n),a},e.prototype.getFilterTexture=function(e,t,n){var r=this.getOptimalTexture(e.width,e.height,t||e.resolution,n||Eo.NONE);return r.filterFrame=e.filterFrame,r},e.prototype.returnTexture=function(e){var t=e.filterPoolKey;e.filterFrame=null,this.texturePool[t].push(e)},e.prototype.returnFilterTexture=function(e){this.returnTexture(e)},e.prototype.clear=function(e){if(e=e!==!1,e)for(var t in this.texturePool){var n=this.texturePool[t];if(n)for(var r=0;r0&&e.height>0,this.texturePool){if(!(Number(t)<0))continue;var n=this.texturePool[t];if(n)for(var r=0;r1){for(var l=0;l1&&(u=this.getOptimalFilterTexture(l.width,l.height,t.resolution),u.filterFrame=l.filterFrame),n[d].apply(this,l,u,xo.CLEAR,t);var f=l;l=u,u=f}n[d].apply(this,l,c.renderTexture,xo.BLEND,t),d>1&&t.multisample>1&&this.returnFilterTexture(t.renderTexture),this.returnFilterTexture(l),this.returnFilterTexture(u)}t.clear(),this.statePool.push(t)},e.prototype.bindAndClear=function(e,t){t===void 0&&(t=xo.CLEAR);var n=this.renderer,r=n.renderTexture,i=n.state;if(e===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.projection.transform=this.activeState.transform:this.renderer.projection.transform=null,e&&e.filterFrame){var a=this.tempRect;a.x=0,a.y=0,a.width=e.filterFrame.width,a.height=e.filterFrame.height,r.bind(e,e.filterFrame,a)}else e===this.defaultFilterStack[this.defaultFilterStack.length-1].renderTexture?this.renderer.renderTexture.bind(e,this.activeState.bindingSourceFrame,this.activeState.bindingDestinationFrame):r.bind(e);var o=i.stateId&1||this.forceClear;(t===xo.CLEAR||t===xo.BLIT&&o)&&this.renderer.framebuffer.clear(0,0,0,0)},e.prototype.applyFilter=function(e,t,n,r){var i=this.renderer;i.state.set(e.state),this.bindAndClear(n,r),e.uniforms.uSampler=t,e.uniforms.filterGlobals=this.globalUniforms,i.shader.bind(e),e.legacy=!!e.program.attributeData.aTextureCoord,e.legacy?(this.quadUv.map(t._frame,t.filterFrame),i.geometry.bind(this.quadUv),i.geometry.draw(fo.TRIANGLES)):(i.geometry.bind(this.quad),i.geometry.draw(fo.TRIANGLE_STRIP))},e.prototype.calculateSpriteMatrix=function(e,t){var n=this.activeState,r=n.sourceFrame,i=n.destinationFrame,a=t._texture.orig,o=e.set(i.width,0,0,i.height,r.x,r.y),s=t.worldTransform.copyTo(sc.TEMP_MATRIX);return s.invert(),o.prepend(s),o.scale(1/a.width,1/a.height),o.translate(t.anchor.x,t.anchor.y),o},e.prototype.destroy=function(){this.renderer=null,this.texturePool.clear(!1)},e.prototype.getOptimalFilterTexture=function(e,t,n,r){return n===void 0&&(n=1),r===void 0&&(r=Eo.NONE),this.texturePool.getOptimalTexture(e,t,n,r)},e.prototype.getFilterTexture=function(e,t,n){if(typeof e==`number`){var r=e;e=t,t=r}e||=this.activeState.renderTexture;var i=this.texturePool.getOptimalTexture(e.width,e.height,t||e.resolution,n||Eo.NONE);return i.filterFrame=e.filterFrame,i},e.prototype.returnFilterTexture=function(e){this.texturePool.returnTexture(e)},e.prototype.emptyPool=function(){this.texturePool.clear(!0)},e.prototype.resize=function(){this.texturePool.setScreenSize(this.renderer.view)},e.prototype.transformAABB=function(e,t){var n=sl[0],r=sl[1],i=sl[2],a=sl[3];n.set(t.left,t.top),r.set(t.left,t.bottom),i.set(t.right,t.top),a.set(t.right,t.bottom),e.apply(n,n),e.apply(r,r),e.apply(i,i),e.apply(a,a);var o=Math.min(n.x,r.x,i.x,a.x),s=Math.min(n.y,r.y,i.y,a.y),c=Math.max(n.x,r.x,i.x,a.x),l=Math.max(n.y,r.y,i.y,a.y);t.x=o,t.y=s,t.width=c-o,t.height=l-s},e.prototype.roundFrame=function(e,t,n,r,i){if(!(e.width<=0||e.height<=0||n.width<=0||n.height<=0)){if(i){var a=i.a,o=i.b,s=i.c,c=i.d;if((Math.abs(o)>1e-4||Math.abs(s)>1e-4)&&(Math.abs(a)>1e-4||Math.abs(c)>1e-4))return}i=i?cl.copyFrom(i):cl.identity(),i.translate(-n.x,-n.y).scale(r.width/n.width,r.height/n.height).translate(r.x,r.y),this.transformAABB(i,e),e.ceil(t),this.transformAABB(i.invert(),e)}},e}(),ul=function(){function e(e){this.renderer=e}return e.prototype.flush=function(){},e.prototype.destroy=function(){this.renderer=null},e.prototype.start=function(){},e.prototype.stop=function(){this.flush()},e.prototype.render=function(e){},e}(),dl=function(){function e(e){this.renderer=e,this.emptyRenderer=new ul(e),this.currentRenderer=this.emptyRenderer}return e.prototype.setObjectRenderer=function(e){this.currentRenderer!==e&&(this.currentRenderer.stop(),this.currentRenderer=e,this.currentRenderer.start())},e.prototype.flush=function(){this.setObjectRenderer(this.emptyRenderer)},e.prototype.reset=function(){this.setObjectRenderer(this.emptyRenderer)},e.prototype.copyBoundTextures=function(e,t){for(var n=this.renderer.texture.boundTextures,r=t-1;r>=0;--r)e[r]=n[r]||null,e[r]&&(e[r]._batchLocation=r)},e.prototype.boundArray=function(e,t,n,r){for(var i=e.elements,a=e.ids,o=e.count,s=0,c=0;c=0&&u=so.WEBGL2&&(n=e.getContext(`webgl2`,t)),n)this.webGLVersion=2;else if(this.webGLVersion=1,n=e.getContext(`webgl`,t)||e.getContext(`experimental-webgl`,t),!n)throw Error(`This browser does not support WebGL. Try using the canvas renderer`);return this.gl=n,this.getExtensions(),this.gl},e.prototype.getExtensions=function(){var e=this.gl,t={loseContext:e.getExtension(`WEBGL_lose_context`),anisotropicFiltering:e.getExtension(`EXT_texture_filter_anisotropic`),floatTextureLinear:e.getExtension(`OES_texture_float_linear`),s3tc:e.getExtension(`WEBGL_compressed_texture_s3tc`),s3tc_sRGB:e.getExtension(`WEBGL_compressed_texture_s3tc_srgb`),etc:e.getExtension(`WEBGL_compressed_texture_etc`),etc1:e.getExtension(`WEBGL_compressed_texture_etc1`),pvrtc:e.getExtension(`WEBGL_compressed_texture_pvrtc`)||e.getExtension(`WEBKIT_WEBGL_compressed_texture_pvrtc`),atc:e.getExtension(`WEBGL_compressed_texture_atc`),astc:e.getExtension(`WEBGL_compressed_texture_astc`)};this.webGLVersion===1?Object.assign(this.extensions,t,{drawBuffers:e.getExtension(`WEBGL_draw_buffers`),depthTexture:e.getExtension(`WEBGL_depth_texture`),vertexArrayObject:e.getExtension(`OES_vertex_array_object`)||e.getExtension(`MOZ_OES_vertex_array_object`)||e.getExtension(`WEBKIT_OES_vertex_array_object`),uint32ElementIndex:e.getExtension(`OES_element_index_uint`),floatTexture:e.getExtension(`OES_texture_float`),floatTextureLinear:e.getExtension(`OES_texture_float_linear`),textureHalfFloat:e.getExtension(`OES_texture_half_float`),textureHalfFloatLinear:e.getExtension(`OES_texture_half_float_linear`)}):this.webGLVersion===2&&Object.assign(this.extensions,t,{colorBufferFloat:e.getExtension(`EXT_color_buffer_float`)})},e.prototype.handleContextLost=function(e){var t=this;e.preventDefault(),setTimeout(function(){t.gl.isContextLost()&&t.extensions.loseContext&&t.extensions.loseContext.restoreContext()},0)},e.prototype.handleContextRestored=function(){this.renderer.runners.contextChange.emit(this.gl)},e.prototype.destroy=function(){var e=this.renderer.view;this.renderer=null,e.removeEventListener(`webglcontextlost`,this.handleContextLost),e.removeEventListener(`webglcontextrestored`,this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext&&this.extensions.loseContext.loseContext()},e.prototype.postrender=function(){this.renderer.renderingToScreen&&this.gl.flush()},e.prototype.validateContext=function(e){var t=e.getContextAttributes(),n=`WebGL2RenderingContext`in globalThis&&e instanceof globalThis.WebGL2RenderingContext;n&&(this.webGLVersion=2),t&&!t.stencil&&console.warn(`Provided WebGL context does not have a stencil buffer, masks may not render correctly`);var r=n||!!e.getExtension(`OES_element_index_uint`);this.supports.uint32Indices=r,r||console.warn(`Provided WebGL context does not support 32 index buffer, complex graphics may not render correctly`)},e}(),ml=function(){function e(e){this.framebuffer=e,this.stencil=null,this.dirtyId=-1,this.dirtyFormat=-1,this.dirtySize=-1,this.multisample=Eo.NONE,this.msaaBuffer=null,this.blitFramebuffer=null,this.mipLevel=0}return e}(),hl=new tc,gl=function(){function e(e){this.renderer=e,this.managedFramebuffers=[],this.unknownFramebuffer=new zc(10,10),this.msaaSamples=null}return e.prototype.contextChange=function(){this.disposeAll(!0);var e=this.gl=this.renderer.gl;if(this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.current=this.unknownFramebuffer,this.viewport=new tc,this.hasMRT=!0,this.writeDepthTexture=!0,this.renderer.context.webGLVersion===1){var t=this.renderer.context.extensions.drawBuffers,n=this.renderer.context.extensions.depthTexture;Xo.PREFER_ENV===so.WEBGL_LEGACY&&(t=null,n=null),t?e.drawBuffers=function(e){return t.drawBuffersWEBGL(e)}:(this.hasMRT=!1,e.drawBuffers=function(){}),n||(this.writeDepthTexture=!1)}else this.msaaSamples=e.getInternalformatParameter(e.RENDERBUFFER,e.RGBA8,e.SAMPLES)},e.prototype.bind=function(e,t,n){n===void 0&&(n=0);var r=this.gl;if(e){var i=e.glFramebuffers[this.CONTEXT_UID]||this.initFramebuffer(e);this.current!==e&&(this.current=e,r.bindFramebuffer(r.FRAMEBUFFER,i.framebuffer)),i.mipLevel!==n&&(e.dirtyId++,e.dirtyFormat++,i.mipLevel=n),i.dirtyId!==e.dirtyId&&(i.dirtyId=e.dirtyId,i.dirtyFormat===e.dirtyFormat?i.dirtySize!==e.dirtySize&&(i.dirtySize=e.dirtySize,this.resizeFramebuffer(e)):(i.dirtyFormat=e.dirtyFormat,i.dirtySize=e.dirtySize,this.updateFramebuffer(e,n)));for(var a=0;a>n,c=t.height>>n,l=s/t.width;this.setViewport(t.x*l,t.y*l,s,c)}else{var s=e.width>>n,c=e.height>>n;this.setViewport(0,0,s,c)}}else this.current&&(this.current=null,r.bindFramebuffer(r.FRAMEBUFFER,null)),t?this.setViewport(t.x,t.y,t.width,t.height):this.setViewport(0,0,this.renderer.width,this.renderer.height)},e.prototype.setViewport=function(e,t,n,r){var i=this.viewport;e=Math.round(e),t=Math.round(t),n=Math.round(n),r=Math.round(r),(i.width!==n||i.height!==r||i.x!==e||i.y!==t)&&(i.x=e,i.y=t,i.width=n,i.height=r,this.gl.viewport(e,t,n,r))},Object.defineProperty(e.prototype,`size`,{get:function(){return this.current?{x:0,y:0,width:this.current.width,height:this.current.height}:{x:0,y:0,width:this.renderer.width,height:this.renderer.height}},enumerable:!1,configurable:!0}),e.prototype.clear=function(e,t,n,r,i){i===void 0&&(i=lo.COLOR|lo.DEPTH);var a=this.gl;a.clearColor(e,t,n,r),a.clear(i)},e.prototype.initFramebuffer=function(e){var t=this.gl,n=new ml(t.createFramebuffer());return n.multisample=this.detectSamples(e.multisample),e.glFramebuffers[this.CONTEXT_UID]=n,this.managedFramebuffers.push(e),e.disposeRunner.add(this),n},e.prototype.resizeFramebuffer=function(e){var t=this.gl,n=e.glFramebuffers[this.CONTEXT_UID];n.msaaBuffer&&(t.bindRenderbuffer(t.RENDERBUFFER,n.msaaBuffer),t.renderbufferStorageMultisample(t.RENDERBUFFER,n.multisample,t.RGBA8,e.width,e.height)),n.stencil&&(t.bindRenderbuffer(t.RENDERBUFFER,n.stencil),n.msaaBuffer?t.renderbufferStorageMultisample(t.RENDERBUFFER,n.multisample,t.DEPTH24_STENCIL8,e.width,e.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,e.width,e.height));var r=e.colorTextures,i=r.length;t.drawBuffers||(i=Math.min(i,1));for(var a=0;a1&&this.canMultisampleFramebuffer(e)?(r.msaaBuffer=r.msaaBuffer||n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,r.msaaBuffer),n.renderbufferStorageMultisample(n.RENDERBUFFER,r.multisample,n.RGBA8,e.width,e.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,r.msaaBuffer)):r.msaaBuffer&&(n.deleteRenderbuffer(r.msaaBuffer),r.msaaBuffer=null,r.blitFramebuffer&&(r.blitFramebuffer.dispose(),r.blitFramebuffer=null));for(var o=[],s=0;s1&&n.drawBuffers(o),e.depthTexture){var u=this.writeDepthTexture;if(u){var d=e.depthTexture;this.renderer.texture.bind(d,0),n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,d._glTextures[this.CONTEXT_UID].texture,t)}}(e.stencil||e.depth)&&!(e.depthTexture&&this.writeDepthTexture)?(r.stencil=r.stencil||n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,r.stencil),r.msaaBuffer?n.renderbufferStorageMultisample(n.RENDERBUFFER,r.multisample,n.DEPTH24_STENCIL8,e.width,e.height):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,e.width,e.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,r.stencil)):r.stencil&&(n.deleteRenderbuffer(r.stencil),r.stencil=null)},e.prototype.canMultisampleFramebuffer=function(e){return this.renderer.context.webGLVersion!==1&&e.colorTextures.length<=1&&!e.depthTexture},e.prototype.detectSamples=function(e){var t=this.msaaSamples,n=Eo.NONE;if(e<=1||t===null)return n;for(var r=0;r=0&&this.managedFramebuffers.splice(i,1),e.disposeRunner.remove(this),t||(r.deleteFramebuffer(n.framebuffer),n.msaaBuffer&&r.deleteRenderbuffer(n.msaaBuffer),n.stencil&&r.deleteRenderbuffer(n.stencil)),n.blitFramebuffer&&n.blitFramebuffer.dispose()}},e.prototype.disposeAll=function(e){var t=this.managedFramebuffers;this.managedFramebuffers=[];for(var n=0;n=so.WEBGL2&&(t=e.getContext(`webgl2`,{})),t||(t=e.getContext(`webgl`,{})||e.getContext(`experimental-webgl`,{}),t?t.getExtension(`WEBGL_draw_buffers`):t=null),El=t}return El}var Ol;function kl(){if(!Ol){Ol=Co.MEDIUM;var e=Dl();if(e&&e.getShaderPrecisionFormat){var t=e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT);Ol=t.precision?Co.HIGH:Co.MEDIUM}}return Ol}function Al(e,t,n){if(e.substring(0,9)!==`precision`){var r=t;return t===Co.HIGH&&n!==Co.HIGH&&(r=Co.MEDIUM),`precision `+r+` float; +`+e}else if(n!==Co.HIGH&&e.substring(0,15)===`precision highp`)return e.replace(`precision highp`,`precision mediump`);return e}var jl={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function Ml(e){return jl[e]}var Nl=null,Pl={FLOAT:`float`,FLOAT_VEC2:`vec2`,FLOAT_VEC3:`vec3`,FLOAT_VEC4:`vec4`,INT:`int`,INT_VEC2:`ivec2`,INT_VEC3:`ivec3`,INT_VEC4:`ivec4`,UNSIGNED_INT:`uint`,UNSIGNED_INT_VEC2:`uvec2`,UNSIGNED_INT_VEC3:`uvec3`,UNSIGNED_INT_VEC4:`uvec4`,BOOL:`bool`,BOOL_VEC2:`bvec2`,BOOL_VEC3:`bvec3`,BOOL_VEC4:`bvec4`,FLOAT_MAT2:`mat2`,FLOAT_MAT3:`mat3`,FLOAT_MAT4:`mat4`,SAMPLER_2D:`sampler2D`,INT_SAMPLER_2D:`sampler2D`,UNSIGNED_INT_SAMPLER_2D:`sampler2D`,SAMPLER_CUBE:`samplerCube`,INT_SAMPLER_CUBE:`samplerCube`,UNSIGNED_INT_SAMPLER_CUBE:`samplerCube`,SAMPLER_2D_ARRAY:`sampler2DArray`,INT_SAMPLER_2D_ARRAY:`sampler2DArray`,UNSIGNED_INT_SAMPLER_2D_ARRAY:`sampler2DArray`};function Fl(e,t){if(!Nl){var n=Object.keys(Pl);Nl={};for(var r=0;r0&&(t+=` +else `),n0?this.maskStack[this.maskStack.length-1]._colorMask:15;n!==t&&this.renderer.gl.colorMask((n&1)!=0,(n&2)!=0,(n&4)!=0,(n&8)!=0)},e.prototype.destroy=function(){this.renderer=null},e}(),pu=function(){function e(e){this.renderer=e,this.maskStack=[],this.glConst=0}return e.prototype.getStackLength=function(){return this.maskStack.length},e.prototype.setMaskStack=function(e){var t=this.renderer.gl,n=this.getStackLength();this.maskStack=e;var r=this.getStackLength();r!==n&&(r===0?t.disable(this.glConst):(t.enable(this.glConst),this._useCurrent()))},e.prototype._useCurrent=function(){},e.prototype.destroy=function(){this.renderer=null,this.maskStack=null},e}(),mu=new sc,hu=[],gu=function(e){xc(t,e);function t(t){var n=e.call(this,t)||this;return n.glConst=Xo.ADAPTER.getWebGLRenderingContext().SCISSOR_TEST,n}return t.prototype.getStackLength=function(){var e=this.maskStack[this.maskStack.length-1];return e?e._scissorCounter:0},t.prototype.calcScissorRect=function(e){var t;if(!e._scissorRectLocal){var n=e._scissorRect,r=e.maskObject,i=this.renderer,a=i.renderTexture,o=r.getBounds(!0,(t=hu.pop())??new tc);this.roundFrameToPixels(o,a.current?a.current.resolution:i.resolution,a.sourceFrame,a.destinationFrame,i.projection.transform),n&&o.fit(n),e._scissorRectLocal=o}},t.isMatrixRotated=function(e){if(!e)return!1;var t=e.a,n=e.b,r=e.c,i=e.d;return(Math.abs(n)>1e-4||Math.abs(r)>1e-4)&&(Math.abs(t)>1e-4||Math.abs(i)>1e-4)},t.prototype.testScissor=function(e){var n=e.maskObject;if(!n.isFastRect||!n.isFastRect()||t.isMatrixRotated(n.worldTransform)||t.isMatrixRotated(this.renderer.projection.transform))return!1;this.calcScissorRect(e);var r=e._scissorRectLocal;return r.width>0&&r.height>0},t.prototype.roundFrameToPixels=function(e,n,r,i,a){t.isMatrixRotated(a)||(a=a?mu.copyFrom(a):mu.identity(),a.translate(-r.x,-r.y).scale(i.width/r.width,i.height/r.height).translate(i.x,i.y),this.renderer.filter.transformAABB(a,e),e.fit(i),e.x=Math.round(e.x*n),e.y=Math.round(e.y*n),e.width=Math.round(e.width*n),e.height=Math.round(e.height*n))},t.prototype.push=function(e){e._scissorRectLocal||this.calcScissorRect(e);var t=this.renderer.gl;e._scissorRect||t.enable(t.SCISSOR_TEST),e._scissorCounter++,e._scissorRect=e._scissorRectLocal,this._useCurrent()},t.prototype.pop=function(e){var t=this.renderer.gl;e&&hu.push(e._scissorRectLocal),this.getStackLength()>0?this._useCurrent():t.disable(t.SCISSOR_TEST)},t.prototype._useCurrent=function(){var e=this.maskStack[this.maskStack.length-1]._scissorRect,t;t=this.renderer.renderTexture.current?e.y:this.renderer.height-e.height-e.y,this.renderer.gl.scissor(e.x,t,e.width,e.height)},t}(pu),_u=function(e){xc(t,e);function t(t){var n=e.call(this,t)||this;return n.glConst=Xo.ADAPTER.getWebGLRenderingContext().STENCIL_TEST,n}return t.prototype.getStackLength=function(){var e=this.maskStack[this.maskStack.length-1];return e?e._stencilCounter:0},t.prototype.push=function(e){var t=e.maskObject,n=this.renderer.gl,r=e._stencilCounter;r===0&&(this.renderer.framebuffer.forceStencil(),n.clearStencil(0),n.clear(n.STENCIL_BUFFER_BIT),n.enable(n.STENCIL_TEST)),e._stencilCounter++;var i=e._colorMask;i!==0&&(e._colorMask=0,n.colorMask(!1,!1,!1,!1)),n.stencilFunc(n.EQUAL,r,4294967295),n.stencilOp(n.KEEP,n.KEEP,n.INCR),t.renderable=!0,t.render(this.renderer),this.renderer.batch.flush(),t.renderable=!1,i!==0&&(e._colorMask=i,n.colorMask((i&1)!=0,(i&2)!=0,(i&4)!=0,(i&8)!=0)),this._useCurrent()},t.prototype.pop=function(e){var t=this.renderer.gl;if(this.getStackLength()===0)t.disable(t.STENCIL_TEST);else{var n=this.maskStack.length===0?null:this.maskStack[this.maskStack.length-1],r=n?n._colorMask:15;r!==0&&(n._colorMask=0,t.colorMask(!1,!1,!1,!1)),t.stencilOp(t.KEEP,t.KEEP,t.DECR),e.renderable=!0,e.render(this.renderer),this.renderer.batch.flush(),e.renderable=!1,r!==0&&(n._colorMask=r,t.colorMask((r&1)!=0,(r&2)!=0,(r&4)!=0,(r&8)!=0)),this._useCurrent()}},t.prototype._useCurrent=function(){var e=this.renderer.gl;e.stencilFunc(e.EQUAL,this.getStackLength(),4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP)},t}(pu),vu=function(){function e(e){this.renderer=e,this.destinationFrame=null,this.sourceFrame=null,this.defaultFrame=null,this.projectionMatrix=new sc,this.transform=null}return e.prototype.update=function(e,t,n,r){this.destinationFrame=e||this.destinationFrame||this.defaultFrame,this.sourceFrame=t||this.sourceFrame||e,this.calculateProjection(this.destinationFrame,this.sourceFrame,n,r),this.transform&&this.projectionMatrix.append(this.transform);var i=this.renderer;i.globalUniforms.uniforms.projectionMatrix=this.projectionMatrix,i.globalUniforms.update(),i.shader.shader&&i.shader.syncUniformGroup(i.shader.shader.uniforms.globals)},e.prototype.calculateProjection=function(e,t,n,r){var i=this.projectionMatrix,a=r?-1:1;i.identity(),i.a=1/t.width*2,i.d=a*(1/t.height*2),i.tx=-1-t.x*i.a,i.ty=-a-t.y*i.d},e.prototype.setTransform=function(e){},e.prototype.destroy=function(){this.renderer=null},e}(),yu=new tc,bu=new tc,xu=function(){function e(e){this.renderer=e,this.clearColor=e._backgroundColorRgba,this.defaultMaskStack=[],this.current=null,this.sourceFrame=new tc,this.destinationFrame=new tc,this.viewportFrame=new tc}return e.prototype.bind=function(e,t,n){e===void 0&&(e=null);var r=this.renderer;this.current=e;var i,a,o;e?(i=e.baseTexture,o=i.resolution,t||(yu.width=e.frame.width,yu.height=e.frame.height,t=yu),n||(bu.x=e.frame.x,bu.y=e.frame.y,bu.width=t.width,bu.height=t.height,n=bu),a=i.framebuffer):(o=r.resolution,t||(yu.width=r.screen.width,yu.height=r.screen.height,t=yu),n||(n=yu,n.width=t.width,n.height=t.height));var s=this.viewportFrame;s.x=n.x*o,s.y=n.y*o,s.width=n.width*o,s.height=n.height*o,e||(s.y=r.view.height-(s.y+s.height)),s.ceil(),this.renderer.framebuffer.bind(a,s),this.renderer.projection.update(n,t,o,!a),e?this.renderer.mask.setMaskStack(i.maskStack):this.renderer.mask.setMaskStack(this.defaultMaskStack),this.sourceFrame.copyFrom(t),this.destinationFrame.copyFrom(n)},e.prototype.clear=function(e,t){this.current?e||=this.current.baseTexture.clearColor:e||=this.clearColor;var n=this.destinationFrame,r=this.current?this.current.baseTexture:this.renderer.screen,i=n.width!==r.width||n.height!==r.height;if(i){var a=this.viewportFrame,o=a.x,s=a.y,c=a.width,l=a.height;o=Math.round(o),s=Math.round(s),c=Math.round(c),l=Math.round(l),this.renderer.gl.enable(this.renderer.gl.SCISSOR_TEST),this.renderer.gl.scissor(o,s,c,l)}this.renderer.framebuffer.clear(e[0],e[1],e[2],e[3],t),i&&this.renderer.scissor.pop()},e.prototype.resize=function(){this.bind(null)},e.prototype.reset=function(){this.bind(null)},e.prototype.destroy=function(){this.renderer=null},e}();function Su(e,t,n,r,i){n.buffer.update(i)}var Cu={float:` + data[offset] = v; + `,vec2:` + data[offset] = v[0]; + data[offset+1] = v[1]; + `,vec3:` + data[offset] = v[0]; + data[offset+1] = v[1]; + data[offset+2] = v[2]; + + `,vec4:` + data[offset] = v[0]; + data[offset+1] = v[1]; + data[offset+2] = v[2]; + data[offset+3] = v[3]; + `,mat2:` + data[offset] = v[0]; + data[offset+1] = v[1]; + + data[offset+4] = v[2]; + data[offset+5] = v[3]; + `,mat3:` + data[offset] = v[0]; + data[offset+1] = v[1]; + data[offset+2] = v[2]; + + data[offset + 4] = v[3]; + data[offset + 5] = v[4]; + data[offset + 6] = v[5]; + + data[offset + 8] = v[6]; + data[offset + 9] = v[7]; + data[offset + 10] = v[8]; + `,mat4:` + for(var i = 0; i < 16; i++) + { + data[offset + i] = v[i]; + } + `},wu={float:4,vec2:8,vec3:12,vec4:16,int:4,ivec2:8,ivec3:12,ivec4:16,uint:4,uvec2:8,uvec3:12,uvec4:16,bool:4,bvec2:8,bvec3:12,bvec4:16,mat2:16*2,mat3:16*3,mat4:16*4};function Tu(e){for(var t=e.map(function(e){return{data:e,offset:0,dataLen:0,dirty:0}}),n=0,r=0,i=0,a=0;a1&&(n=Math.max(n,16)*o.data.size),o.dataLen=n,r%n!==0&&r<16){var s=r%n%16;r+=s,i+=s}r+n>16?(i=Math.ceil(i/16)*16,o.offset=i,i+=n,r=n):(o.offset=i,r+=n,i+=n)}return i=Math.ceil(i/16)*16,{uboElements:t,size:i}}function Eu(e,t){var n=[];for(var r in e)t[r]&&n.push(t[r]);return n.sort(function(e,t){return e.index-t.index}),n}function Du(e,t){if(!e.autoManage)return{size:0,syncFunc:Su};for(var n=Eu(e.uniforms,t),r=Tu(n),i=r.uboElements,a=r.size,o=[` + var v = null; + var v2 = null; + var cv = null; + var t = 0; + var gl = renderer.gl + var index = 0; + var data = buffer.data; + `],s=0;s1){var m=Ml(c.data.type),h=Math.max(wu[c.data.type]/16,1),g=m/h,_=(4-g%4)%4;o.push(` + cv = ud.`+u+`.value; + v = uv.`+u+`; + offset = `+c.offset/4+`; + + t = 0; + + for(var i=0; i < `+c.data.size*h+`; i++) + { + for(var j = 0; j < `+g+`; j++) + { + data[offset++] = v[t++]; + } + offset += `+_+`; + } + + `)}else{var v=Cu[c.data.type];o.push(` + cv = ud.`+u+`.value; + v = uv.`+u+`; + offset = `+c.offset/4+`; + `+v+`; + `)}}return o.push(` + renderer.buffer.update(buffer); + `),{size:a,syncFunc:Function(`ud`,`uv`,`renderer`,`syncData`,`buffer`,o.join(` +`))}}var Ou=function(){function e(){}return e}(),ku=function(){function e(e,t){this.program=e,this.uniformData=t,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}return e.prototype.destroy=function(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null},e}();function Au(e,t){for(var n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),i=0;it?1:-1});for(var o=0;o>=1,n++;this.stateId=e.data}for(var n=0;nthis.checkCountMax&&(this.checkCount=0,this.run())))},e.prototype.run=function(){for(var e=this.renderer.texture,t=e.managedTextures,n=!1,r=0;rthis.maxIdle&&(e.destroyTexture(i,!0),t[r]=null,n=!0)}if(n){for(var a=0,r=0;r=0;r--)this.unload(e.children[r])},e.prototype.destroy=function(){this.renderer=null},e}();function Gu(e){var t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C;return C=`WebGL2RenderingContext`in globalThis&&e instanceof globalThis.WebGL2RenderingContext?(t={},t[ho.UNSIGNED_BYTE]=(n={},n[po.RGBA]=e.RGBA8,n[po.RGB]=e.RGB8,n[po.RG]=e.RG8,n[po.RED]=e.R8,n[po.RGBA_INTEGER]=e.RGBA8UI,n[po.RGB_INTEGER]=e.RGB8UI,n[po.RG_INTEGER]=e.RG8UI,n[po.RED_INTEGER]=e.R8UI,n[po.ALPHA]=e.ALPHA,n[po.LUMINANCE]=e.LUMINANCE,n[po.LUMINANCE_ALPHA]=e.LUMINANCE_ALPHA,n),t[ho.BYTE]=(r={},r[po.RGBA]=e.RGBA8_SNORM,r[po.RGB]=e.RGB8_SNORM,r[po.RG]=e.RG8_SNORM,r[po.RED]=e.R8_SNORM,r[po.RGBA_INTEGER]=e.RGBA8I,r[po.RGB_INTEGER]=e.RGB8I,r[po.RG_INTEGER]=e.RG8I,r[po.RED_INTEGER]=e.R8I,r),t[ho.UNSIGNED_SHORT]=(i={},i[po.RGBA_INTEGER]=e.RGBA16UI,i[po.RGB_INTEGER]=e.RGB16UI,i[po.RG_INTEGER]=e.RG16UI,i[po.RED_INTEGER]=e.R16UI,i[po.DEPTH_COMPONENT]=e.DEPTH_COMPONENT16,i),t[ho.SHORT]=(a={},a[po.RGBA_INTEGER]=e.RGBA16I,a[po.RGB_INTEGER]=e.RGB16I,a[po.RG_INTEGER]=e.RG16I,a[po.RED_INTEGER]=e.R16I,a),t[ho.UNSIGNED_INT]=(o={},o[po.RGBA_INTEGER]=e.RGBA32UI,o[po.RGB_INTEGER]=e.RGB32UI,o[po.RG_INTEGER]=e.RG32UI,o[po.RED_INTEGER]=e.R32UI,o[po.DEPTH_COMPONENT]=e.DEPTH_COMPONENT24,o),t[ho.INT]=(s={},s[po.RGBA_INTEGER]=e.RGBA32I,s[po.RGB_INTEGER]=e.RGB32I,s[po.RG_INTEGER]=e.RG32I,s[po.RED_INTEGER]=e.R32I,s),t[ho.FLOAT]=(c={},c[po.RGBA]=e.RGBA32F,c[po.RGB]=e.RGB32F,c[po.RG]=e.RG32F,c[po.RED]=e.R32F,c[po.DEPTH_COMPONENT]=e.DEPTH_COMPONENT32F,c),t[ho.HALF_FLOAT]=(l={},l[po.RGBA]=e.RGBA16F,l[po.RGB]=e.RGB16F,l[po.RG]=e.RG16F,l[po.RED]=e.R16F,l),t[ho.UNSIGNED_SHORT_5_6_5]=(u={},u[po.RGB]=e.RGB565,u),t[ho.UNSIGNED_SHORT_4_4_4_4]=(d={},d[po.RGBA]=e.RGBA4,d),t[ho.UNSIGNED_SHORT_5_5_5_1]=(f={},f[po.RGBA]=e.RGB5_A1,f),t[ho.UNSIGNED_INT_2_10_10_10_REV]=(p={},p[po.RGBA]=e.RGB10_A2,p[po.RGBA_INTEGER]=e.RGB10_A2UI,p),t[ho.UNSIGNED_INT_10F_11F_11F_REV]=(m={},m[po.RGB]=e.R11F_G11F_B10F,m),t[ho.UNSIGNED_INT_5_9_9_9_REV]=(h={},h[po.RGB]=e.RGB9_E5,h),t[ho.UNSIGNED_INT_24_8]=(g={},g[po.DEPTH_STENCIL]=e.DEPTH24_STENCIL8,g),t[ho.FLOAT_32_UNSIGNED_INT_24_8_REV]=(_={},_[po.DEPTH_STENCIL]=e.DEPTH32F_STENCIL8,_),t):(v={},v[ho.UNSIGNED_BYTE]=(y={},y[po.RGBA]=e.RGBA,y[po.RGB]=e.RGB,y[po.ALPHA]=e.ALPHA,y[po.LUMINANCE]=e.LUMINANCE,y[po.LUMINANCE_ALPHA]=e.LUMINANCE_ALPHA,y),v[ho.UNSIGNED_SHORT_5_6_5]=(b={},b[po.RGB]=e.RGB,b),v[ho.UNSIGNED_SHORT_4_4_4_4]=(x={},x[po.RGBA]=e.RGBA,x),v[ho.UNSIGNED_SHORT_5_5_5_1]=(S={},S[po.RGBA]=e.RGBA,S),v),C}var Ku=function(){function e(e){this.texture=e,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=ho.UNSIGNED_BYTE,this.internalFormat=po.RGBA,this.samplerType=0}return e}(),qu=function(){function e(e){this.renderer=e,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new Dc,this.hasIntegerTextures=!1}return e.prototype.contextChange=function(){var e=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=Gu(e);var t=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=t;for(var n=0;n=0;--a){var o=n[a];if(o){var s=o._glTextures[i];s.samplerType!==go.FLOAT&&this.renderer.texture.unbind(o)}}},e.prototype.initTexture=function(e){var t=new Ku(this.gl.createTexture());return t.dirtyId=-1,e._glTextures[this.CONTEXT_UID]=t,this.managedTextures.push(e),e.on(`dispose`,this.destroyTexture,this),t},e.prototype.initTextureType=function(e,t){var n,r;t.internalFormat=(r=(n=this.internalFormats[e.type])?.[e.format])??e.format,this.webGLVersion===2&&e.type===ho.HALF_FLOAT?t.type=this.gl.HALF_FLOAT:t.type=e.type},e.prototype.updateTexture=function(e){var t=e._glTextures[this.CONTEXT_UID];if(t){var n=this.renderer;if(this.initTextureType(e,t),e.resource&&e.resource.upload(n,e,t))t.samplerType!==go.FLOAT&&(this.hasIntegerTextures=!0);else{var r=e.realWidth,i=e.realHeight,a=n.gl;(t.width!==r||t.height!==i||t.dirtyId<0)&&(t.width=r,t.height=i,a.texImage2D(e.target,0,t.internalFormat,r,i,0,e.format,t.type,null))}e.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(e),t.dirtyId=e.dirtyId}},e.prototype.destroyTexture=function(e,t){var n=this.gl;if(e=e.castToBaseTexture(),e._glTextures[this.CONTEXT_UID]&&(this.unbind(e),n.deleteTexture(e._glTextures[this.CONTEXT_UID].texture),e.off(`dispose`,this.destroyTexture,this),delete e._glTextures[this.CONTEXT_UID],!t)){var r=this.managedTextures.indexOf(e);r!==-1&&Os(this.managedTextures,r,1)}},e.prototype.updateTextureStyle=function(e){var t=e._glTextures[this.CONTEXT_UID];t&&((e.mipmap===yo.POW2||this.webGLVersion!==2)&&!e.isPowerOfTwo?t.mipmap=!1:t.mipmap=e.mipmap>=1,this.webGLVersion!==2&&!e.isPowerOfTwo?t.wrapMode=vo.CLAMP:t.wrapMode=e.wrapMode,e.resource&&e.resource.style(this.renderer,e,t)||this.setStyle(e,t),t.dirtyStyleId=e.dirtyStyleId)},e.prototype.setStyle=function(e,t){var n=this.gl;if(t.mipmap&&e.mipmap!==yo.ON_MANUAL&&n.generateMipmap(e.target),n.texParameteri(e.target,n.TEXTURE_WRAP_S,t.wrapMode),n.texParameteri(e.target,n.TEXTURE_WRAP_T,t.wrapMode),t.mipmap){n.texParameteri(e.target,n.TEXTURE_MIN_FILTER,e.scaleMode===_o.LINEAR?n.LINEAR_MIPMAP_LINEAR:n.NEAREST_MIPMAP_NEAREST);var r=this.renderer.context.extensions.anisotropicFiltering;if(r&&e.anisotropicLevel>0&&e.scaleMode===_o.LINEAR){var i=Math.min(e.anisotropicLevel,n.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT));n.texParameterf(e.target,r.TEXTURE_MAX_ANISOTROPY_EXT,i)}}else n.texParameteri(e.target,n.TEXTURE_MIN_FILTER,e.scaleMode===_o.LINEAR?n.LINEAR:n.NEAREST);n.texParameteri(e.target,n.TEXTURE_MAG_FILTER,e.scaleMode===_o.LINEAR?n.LINEAR:n.NEAREST)},e.prototype.destroy=function(){this.renderer=null},e}(),Ju={__proto__:null,FilterSystem:ll,BatchSystem:dl,ContextSystem:pl,FramebufferSystem:gl,GeometrySystem:vl,MaskSystem:fu,ScissorSystem:gu,StencilSystem:_u,ProjectionSystem:vu,RenderTextureSystem:xu,ShaderSystem:Fu,StateSystem:Uu,TextureGCSystem:Wu,TextureSystem:qu},Yu=new sc,Xu=function(e){xc(t,e);function t(t,n){t===void 0&&(t=co.UNKNOWN);var r=e.call(this)||this;return n=Object.assign({},Xo.RENDER_OPTIONS,n),r.options=n,r.type=t,r.screen=new tc(0,0,n.width,n.height),r.view=n.view||Xo.ADAPTER.createCanvas(),r.resolution=n.resolution||Xo.RESOLUTION,r.useContextAlpha=n.useContextAlpha,r.autoDensity=!!n.autoDensity,r.preserveDrawingBuffer=n.preserveDrawingBuffer,r.clearBeforeRender=n.clearBeforeRender,r._backgroundColor=0,r._backgroundColorRgba=[0,0,0,1],r._backgroundColorString=`#000000`,r.backgroundColor=n.backgroundColor||r._backgroundColor,r.backgroundAlpha=n.backgroundAlpha,n.transparent!==void 0&&(Ms(`6.0.0`,`Option transparent is deprecated, please use backgroundAlpha instead.`),r.useContextAlpha=n.transparent,r.backgroundAlpha=n.transparent?0:1),r._lastObjectRendered=null,r.plugins={},r}return t.prototype.initPlugins=function(e){for(var t in e)this.plugins[t]=new e[t](this)},Object.defineProperty(t.prototype,`width`,{get:function(){return this.view.width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`height`,{get:function(){return this.view.height},enumerable:!1,configurable:!0}),t.prototype.resize=function(e,t){this.view.width=Math.round(e*this.resolution),this.view.height=Math.round(t*this.resolution);var n=this.view.width/this.resolution,r=this.view.height/this.resolution;this.screen.width=n,this.screen.height=r,this.autoDensity&&(this.view.style.width=n+`px`,this.view.style.height=r+`px`),this.emit(`resize`,n,r)},t.prototype.generateTexture=function(e,t,n,r){t===void 0&&(t={}),typeof t==`number`&&(Ms(`6.1.0`,`generateTexture options (scaleMode, resolution, region) are now object options.`),t={scaleMode:t,resolution:n,region:r});var i=t.region,a=Cc(t,[`region`]);r=i||e.getLocalBounds(null,!0),r.width===0&&(r.width=1),r.height===0&&(r.height=1);var o=Gc.create(Sc({width:r.width,height:r.height},a));return Yu.tx=-r.x,Yu.ty=-r.y,this.render(e,{renderTexture:o,clear:!1,transform:Yu,skipUpdateTransform:!!e.parent}),o},t.prototype.destroy=function(e){for(var t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null;e&&this.view.parentNode&&this.view.parentNode.removeChild(this.view);var n=this;n.plugins=null,n.type=co.UNKNOWN,n.view=null,n.screen=null,n._tempDisplayObjectParent=null,n.options=null,this._backgroundColorRgba=null,this._backgroundColorString=null,this._lastObjectRendered=null},Object.defineProperty(t.prototype,`backgroundColor`,{get:function(){return this._backgroundColor},set:function(e){this._backgroundColor=e,this._backgroundColorString=ys(e),vs(e,this._backgroundColorRgba)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`backgroundAlpha`,{get:function(){return this._backgroundColorRgba[3]},set:function(e){this._backgroundColorRgba[3]=e},enumerable:!1,configurable:!0}),t}(ls.default),Zu=function(){function e(e){this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}return e}(),Qu=function(){function e(e){this.renderer=e,this.managedBuffers={},this.boundBufferBases={}}return e.prototype.destroy=function(){this.renderer=null},e.prototype.contextChange=function(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID},e.prototype.bind=function(e){var t=this,n=t.gl,r=t.CONTEXT_UID,i=e._glBuffers[r]||this.createGLBuffer(e);n.bindBuffer(e.type,i.buffer)},e.prototype.bindBufferBase=function(e,t){var n=this,r=n.gl,i=n.CONTEXT_UID;if(this.boundBufferBases[t]!==e){var a=e._glBuffers[i]||this.createGLBuffer(e);this.boundBufferBases[t]=e,r.bindBufferBase(r.UNIFORM_BUFFER,t,a.buffer)}},e.prototype.bindBufferRange=function(e,t,n){var r=this,i=r.gl,a=r.CONTEXT_UID;n||=0;var o=e._glBuffers[a]||this.createGLBuffer(e);i.bindBufferRange(i.UNIFORM_BUFFER,t||0,o.buffer,n*256,256)},e.prototype.update=function(e){var t=this,n=t.gl,r=t.CONTEXT_UID,i=e._glBuffers[r];if(e._updateID!==i.updateID)if(i.updateID=e._updateID,n.bindBuffer(e.type,i.buffer),i.byteLength>=e.data.byteLength)n.bufferSubData(e.type,0,e.data);else{var a=e.static?n.STATIC_DRAW:n.DYNAMIC_DRAW;i.byteLength=e.data.byteLength,n.bufferData(e.type,e.data,a)}},e.prototype.dispose=function(e,t){if(this.managedBuffers[e.id]){delete this.managedBuffers[e.id];var n=e._glBuffers[this.CONTEXT_UID],r=this.gl;e.disposeRunner.remove(this),n&&(t||r.deleteBuffer(n.buffer),delete e._glBuffers[this.CONTEXT_UID])}},e.prototype.disposeAll=function(e){for(var t=Object.keys(this.managedBuffers),n=0;n=Eo.HIGH?this.multisample=Eo.HIGH:t>=Eo.MEDIUM?this.multisample=Eo.MEDIUM:t>=Eo.LOW?this.multisample=Eo.LOW:this.multisample=Eo.NONE},t.prototype.addSystem=function(e,t){var n=new e(this);if(this[t])throw Error(`Whoops! The name "`+t+`" is already in use`);for(var r in this[t]=n,this.runners)this.runners[r].add(n);return this},t.prototype.render=function(e,t){var n,r,i,a;if(t&&(t instanceof Gc?(Ms(`6.0.0`,`Renderer#render arguments changed, use options instead.`),n=t,r=arguments[2],i=arguments[3],a=arguments[4]):(n=t.renderTexture,r=t.clear,i=t.transform,a=t.skipUpdateTransform)),this.renderingToScreen=!n,this.runners.prerender.emit(),this.emit(`prerender`),this.projection.transform=i,!this.context.isLost){if(n||(this._lastObjectRendered=e),!a){var o=e.enableTempParent();e.updateTransform(),e.disableTempParent(o)}this.renderTexture.bind(n),this.batch.currentRenderer.start(),(r===void 0?this.clearBeforeRender:r)&&this.renderTexture.clear(),e.render(this),this.batch.currentRenderer.flush(),n&&n.baseTexture.update(),this.runners.postrender.emit(),this.projection.transform=null,this.emit(`postrender`)}},t.prototype.generateTexture=function(t,n,r,i){n===void 0&&(n={});var a=e.prototype.generateTexture.call(this,t,n,r,i);return this.framebuffer.blit(),a},t.prototype.resize=function(t,n){e.prototype.resize.call(this,t,n),this.runners.resize.emit(this.screen.height,this.screen.width)},t.prototype.reset=function(){return this.runners.reset.emit(),this},t.prototype.clear=function(){this.renderTexture.bind(),this.renderTexture.clear()},t.prototype.destroy=function(t){for(var n in this.runners.destroy.emit(),this.runners)this.runners[n].destroy();e.prototype.destroy.call(this,t),this.gl=null},Object.defineProperty(t.prototype,`extract`,{get:function(){return Ms(`6.0.0`,`Renderer#extract has been deprecated, please use Renderer#plugins.extract instead.`),this.plugins.extract},enumerable:!1,configurable:!0}),t.registerPlugin=function(e,t){Ms(`6.5.0`,`Renderer.registerPlugin() has been deprecated, please use extensions.add() instead.`),Us.add({name:e,type:Vs.RendererPlugin,ref:t})},t.__plugins={},t}(Xu);Us.handleByMap(Vs.RendererPlugin,$u.__plugins);function ed(e){return $u.create(e)}var td=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,nd=td,rd=function(){function e(e){Ms(`6.1.0`,`System class is deprecated, implemement ISystem interface instead.`),this.renderer=e}return e.prototype.destroy=function(){this.renderer=null},e}(),id=function(){function e(){this.texArray=null,this.blend=0,this.type=fo.TRIANGLES,this.start=0,this.size=0,this.data=null}return e}(),ad=function(){function e(){this.elements=[],this.ids=[],this.count=0}return e.prototype.clear=function(){for(var e=0;ethis.size&&this.flush(),this._vertexCount+=e.vertexData.length/2,this._indexCount+=e.indices.length,this._bufferedTextures[this._bufferSize]=e._texture.baseTexture,this._bufferedElements[this._bufferSize++]=e)},t.prototype.buildTexturesAndDrawCalls=function(){var e=this,n=e._bufferedTextures,r=e.MAX_TEXTURES,i=t._textureArrayPool,a=this.renderer.batch,o=this._tempBoundTextures,s=this.renderer.textureGC.count,c=++Dc._globalBatch,l=0,u=i[0],d=0;a.copyBoundTextures(o,r);for(var f=0;f=r&&(a.boundArray(u,o,c,r),this.buildDrawCalls(u,d,f),d=f,u=i[++l],++c),p._batchEnabled=c,p.touched=s,u.elements[u.count++]=p)}u.count>0&&(a.boundArray(u,o,c,r),this.buildDrawCalls(u,d,this._bufferSize),++l,++c);for(var f=0;f0&&(t+=` +else `),nthis.maxX||this.minY>this.maxY},e.prototype.clear=function(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0},e.prototype.getRectangle=function(e){return this.minX>this.maxX||this.minY>this.maxY?tc.EMPTY:(e||=new tc(0,0,1,1),e.x=this.minX,e.y=this.minY,e.width=this.maxX-this.minX,e.height=this.maxY-this.minY,e)},e.prototype.addPoint=function(e){this.minX=Math.min(this.minX,e.x),this.maxX=Math.max(this.maxX,e.x),this.minY=Math.min(this.minY,e.y),this.maxY=Math.max(this.maxY,e.y)},e.prototype.addPointMatrix=function(e,t){var n=e.a,r=e.b,i=e.c,a=e.d,o=e.tx,s=e.ty,c=n*t.x+i*t.y+o,l=r*t.x+a*t.y+s;this.minX=Math.min(this.minX,c),this.maxX=Math.max(this.maxX,c),this.minY=Math.min(this.minY,l),this.maxY=Math.max(this.maxY,l)},e.prototype.addQuad=function(e){var t=this.minX,n=this.minY,r=this.maxX,i=this.maxY,a=e[0],o=e[1];t=ar?a:r,i=o>i?o:i,a=e[2],o=e[3],t=ar?a:r,i=o>i?o:i,a=e[4],o=e[5],t=ar?a:r,i=o>i?o:i,a=e[6],o=e[7],t=ar?a:r,i=o>i?o:i,this.minX=t,this.minY=n,this.maxX=r,this.maxY=i},e.prototype.addFrame=function(e,t,n,r,i){this.addFrameMatrix(e.worldTransform,t,n,r,i)},e.prototype.addFrameMatrix=function(e,t,n,r,i){var a=e.a,o=e.b,s=e.c,c=e.d,l=e.tx,u=e.ty,d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,h=a*t+s*n+l,g=o*t+c*n+u;d=hp?h:p,m=g>m?g:m,h=a*r+s*n+l,g=o*r+c*n+u,d=hp?h:p,m=g>m?g:m,h=a*t+s*i+l,g=o*t+c*i+u,d=hp?h:p,m=g>m?g:m,h=a*r+s*i+l,g=o*r+c*i+u,d=hp?h:p,m=g>m?g:m,this.minX=d,this.minY=f,this.maxX=p,this.maxY=m},e.prototype.addVertexData=function(e,t,n){for(var r=this.minX,i=this.minY,a=this.maxX,o=this.maxY,s=t;sa?c:a,o=l>o?l:o}this.minX=r,this.minY=i,this.maxX=a,this.maxY=o},e.prototype.addVertices=function(e,t,n,r){this.addVerticesMatrix(e.worldTransform,t,n,r)},e.prototype.addVerticesMatrix=function(e,t,n,r,i,a){i===void 0&&(i=0),a===void 0&&(a=i);for(var o=e.a,s=e.b,c=e.c,l=e.d,u=e.tx,d=e.ty,f=this.minX,p=this.minY,m=this.maxX,h=this.maxY,g=n;gr?e.maxX:r,this.maxY=e.maxY>i?e.maxY:i},e.prototype.addBoundsMask=function(e,t){var n=e.minX>t.minX?e.minX:t.minX,r=e.minY>t.minY?e.minY:t.minY,i=e.maxXc?i:c,this.maxY=a>l?a:l}},e.prototype.addBoundsMatrix=function(e,t){this.addFrameMatrix(t,e.minX,e.minY,e.maxX,e.maxY)},e.prototype.addBoundsArea=function(e,t){var n=e.minX>t.x?e.minX:t.x,r=e.minY>t.y?e.minY:t.y,i=e.maxXc?i:c,this.maxY=a>l?a:l}},e.prototype.pad=function(e,t){e===void 0&&(e=0),t===void 0&&(t=e),this.isEmpty()||(this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t)},e.prototype.addFramePad=function(e,t,n,r,i,a){e-=i,t-=a,n+=i,r+=a,this.minX=this.minXn?this.maxX:n,this.minY=this.minYr?this.maxY:r},e}(),bd=function(e,t){return bd=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},bd(e,t)};function xd(e,t){bd(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Sd=function(e){xd(t,e);function t(){var t=e.call(this)||this;return t.tempDisplayObjectParent=null,t.transform=new _c,t.alpha=1,t.visible=!0,t.renderable=!0,t.cullable=!1,t.cullArea=null,t.parent=null,t.worldAlpha=1,t._lastSortedIndex=0,t._zIndex=0,t.filterArea=null,t.filters=null,t._enabledFilters=null,t._bounds=new yd,t._localBounds=null,t._boundsID=0,t._boundsRect=null,t._localBoundsRect=null,t._mask=null,t._maskRefCount=0,t._destroyed=!1,t.isSprite=!1,t.isMask=!1,t}return t.mixin=function(e){for(var n=Object.keys(e),r=0;r1)for(var r=0;rthis.children.length)throw Error(e+`addChildAt: The index `+t+` supplied is out of bounds `+this.children.length);return e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.splice(t,0,e),this._boundsID++,this.onChildrenChange(t),e.emit(`added`,this),this.emit(`childAdded`,e,this,t),e},t.prototype.swapChildren=function(e,t){if(e!==t){var n=this.getChildIndex(e),r=this.getChildIndex(t);this.children[n]=t,this.children[r]=e,this.onChildrenChange(n=this.children.length)throw Error(`The index `+t+` supplied is out of bounds `+this.children.length);var n=this.getChildIndex(e);Os(this.children,n,1),this.children.splice(t,0,e),this.onChildrenChange(t)},t.prototype.getChildAt=function(e){if(e<0||e>=this.children.length)throw Error(`getChildAt: Index (`+e+`) does not exist.`);return this.children[e]},t.prototype.removeChild=function(){for(var e=arguments,t=[],n=0;n1)for(var r=0;r0&&i<=r){a=this.children.splice(n,i);for(var o=0;o1&&this.children.sort(wd),this.sortDirty=!1},t.prototype.updateTransform=function(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(var e=0,t=this.children.length;e0&&n.height>0){var r,i;if(this.cullArea?(r=this.cullArea,i=this.worldTransform):this._render!==t.prototype._render&&(r=this.getBounds(!0)),r&&n.intersects(r,i))this._render(e);else if(this.cullArea)return;for(var a=0,o=this.children.length;anew Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),Ad=class e{constructor(){this._breathParameters=[],this._currentTime=0}static create(){return new e}setParameters(e){this._breathParameters=e}getParameters(){return this._breathParameters}updateParameters(e,t){this._currentTime+=t;let n=this._currentTime*2*3.14159;for(let t=0;t=1&&(r=1,this._blinkingState=Pd.EyeState_Closed,this._stateStartTimeSeconds=this._userTimeSeconds),n=1-r;break;case Pd.EyeState_Closed:r=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closedSeconds,r>=1&&(this._blinkingState=Pd.EyeState_Opening,this._stateStartTimeSeconds=this._userTimeSeconds),n=0;break;case Pd.EyeState_Opening:r=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._openingSeconds,r>=1&&(r=1,this._blinkingState=Pd.EyeState_Interval,this._nextBlinkingTime=this.determinNextBlinkingTiming()),n=r;break;case Pd.EyeState_Interval:this._nextBlinkingTime(e[e.EyeState_First=0]=`EyeState_First`,e[e.EyeState_Interval=1]=`EyeState_Interval`,e[e.EyeState_Closing=2]=`EyeState_Closing`,e[e.EyeState_Closed=3]=`EyeState_Closed`,e[e.EyeState_Opening=4]=`EyeState_Opening`,e))(Pd||{});const Fd=.001,Id=.5;var Ld=class e{static create(t){let n=new e;typeof t.FadeInTime==`number`&&(n._fadeTimeSeconds=t.FadeInTime,n._fadeTimeSeconds<=0&&(n._fadeTimeSeconds=Id));let r=t.Groups,i=r.length;for(let e=0;eFd){if(i>=0)break;i=o,a=e.getPartOpacityByIndex(n),a+=t/this._fadeTimeSeconds,a>1&&(a=1)}}i<0&&(i=0,a=1);for(let t=n;ts&&(r=1-s/(1-a)),t>r&&(t=r),e.setPartOpacityByIndex(n,t)}}}constructor(){this._fadeTimeSeconds=Id,this._lastModel=void 0,this._partGroups=[],this._partGroupCounts=[]}},Rd=class e{constructor(e){this.parameterIndex=0,this.partIndex=0,this.partId=``,this.link=[],e!=null&&this.assignment(e)}assignment(e){return this.partId=e.partId,this.link=e.link.map(e=>e.clone()),this}initialize(e){this.parameterIndex=e.getParameterIndex(this.partId),this.partIndex=e.getPartIndex(this.partId),e.setParameterValueByIndex(this.parameterIndex,1)}clone(){let t=new e;return t.partId=this.partId,t.parameterIndex=this.parameterIndex,t.partIndex=this.partIndex,t.link=this.link.map(e=>e.clone()),t}},zd=class e{constructor(e,t){this.x=e||0,this.y=t||0}add(t){let n=new e(0,0);return n.x=this.x+t.x,n.y=this.y+t.y,n}substract(t){let n=new e(0,0);return n.x=this.x-t.x,n.y=this.y-t.y,n}multiply(t){let n=new e(0,0);return n.x=this.x*t.x,n.y=this.y*t.y,n}multiplyByScaler(t){return this.multiply(new e(t,t))}division(t){let n=new e(0,0);return n.x=this.x/t.x,n.y=this.y/t.y,n}divisionByScalar(t){return this.division(new e(t,t))}getLength(){return Math.sqrt(this.x*this.x+this.y*this.y)}getDistanceWith(e){return Math.sqrt((this.x-e.x)*(this.x-e.x)+(this.y-e.y)*(this.y-e.y))}dot(e){return this.x*e.x+this.y*e.y}normalize(){let e=(this.x*this.x+this.y*this.y)**.5;this.x/=e,this.y/=e}isEqual(e){return this.x==e.x&&this.y==e.y}isNotEqual(e){return!this.isEqual(e)}};const Bd=class{static range(e,t,n){return en&&(e=n),e}static sin(e){return Math.sin(e)}static cos(e){return Math.cos(e)}static abs(e){return Math.abs(e)}static sqrt(e){return Math.sqrt(e)}static cbrt(e){if(e===0)return e;let t=e,n=t<0;n&&(t=-t);let r;return t===1/0?r=1/0:(r=Math.exp(Math.log(t)/3),r=(t/(r*r)+2*r)/3),n?-r:r}static getEasingSine(e){return e<0?0:e>1?1:.5-.5*this.cos(e*Math.PI)}static max(e,t){return e>t?e:t}static min(e,t){return e>t?t:e}static degreesToRadian(e){return e/180*Math.PI}static radianToDegrees(e){return e*180/Math.PI}static directionToRadian(e,t){let n=Math.atan2(t.y,t.x),r=Math.atan2(e.y,e.x),i=n-r;for(;i<-Math.PI;)i+=Math.PI*2;for(;i>Math.PI;)i-=Math.PI*2;return i}static directionToDegrees(e,t){let n=this.directionToRadian(e,t),r=this.radianToDegrees(n);return t.x-e.x>0&&(r=-r),r}static radianToDirection(e){let t=new zd;return t.x=this.sin(e),t.y=this.cos(e),t}static quadraticEquation(e,t,n){return this.abs(e)1&&(e=1),t<0?t=0:t>1&&(t=1),n<0?n=0:n>1&&(n=1),r<0?r=0:r>1&&(r=1),this._modelColor.R=e,this._modelColor.G=t,this._modelColor.B=n,this._modelColor.A=r}getModelColor(){return Object.assign({},this._modelColor)}setIsPremultipliedAlpha(e){this._isPremultipliedAlpha=e}isPremultipliedAlpha(){return this._isPremultipliedAlpha}setIsCulling(e){this._isCulling=e}isCulling(){return this._isCulling}setAnisotropy(e){this._anisortopy=e}getAnisotropy(){return this._anisortopy}getModel(){return this._model}constructor(){this._isCulling=!1,this._isPremultipliedAlpha=!1,this._anisortopy=0,this._modelColor=new Gd,this._mvpMatrix4x4=new Hd,this._mvpMatrix4x4.loadIdentity()}},Wd=(e=>(e[e.CubismBlendMode_Normal=0]=`CubismBlendMode_Normal`,e[e.CubismBlendMode_Additive=1]=`CubismBlendMode_Additive`,e[e.CubismBlendMode_Multiplicative=2]=`CubismBlendMode_Multiplicative`,e))(Wd||{}),Gd=class{constructor(){this.R=1,this.G=1,this.B=1,this.A=1}};let Kd=!1,qd=!1,Jd;const Yd={vertexOffset:0,vertexStep:2};var Xd=class{static startUp(e){if(Kd)return ef(`CubismFramework.startUp() is already done.`),Kd;if(Live2DCubismCore._isStarted)return Kd=!0,!0;if(Live2DCubismCore._isStarted=!0,Jd=e,Jd&&Live2DCubismCore.Logging.csmSetLogFunction(Jd.logFunction),Kd=!0,Kd){let e=Live2DCubismCore.Version.csmGetVersion(),t=(e&4278190080)>>24,n=(e&16711680)>>16,r=e&65535,i=e;ef(`Live2D Cubism Core version: {0}.{1}.{2} ({3})`,(`00`+t).slice(-2),(`00`+n).slice(-2),(`0000`+r).slice(-4),i)}return ef(`CubismFramework.startUp() is complete.`),Kd}static cleanUp(){Kd=!1,qd=!1,Jd=void 0}static initialize(){if(!Kd){tf(`CubismFramework is not started.`);return}if(qd){tf(`CubismFramework.initialize() skipped, already initialized.`);return}qd=!0,ef(`CubismFramework.initialize() is complete.`)}static dispose(){if(!Kd){tf(`CubismFramework is not started.`);return}if(!qd){tf(`CubismFramework.dispose() skipped, not initialized.`);return}Ud.staticRelease(),qd=!1,ef(`CubismFramework.dispose() is complete.`)}static isStarted(){return Kd}static isInitialized(){return qd}static coreLogFunction(e){Live2DCubismCore.Logging.csmGetLogFunction()&&Live2DCubismCore.Logging.csmGetLogFunction()(e)}static getLoggingLevel(){return Jd==null?Zd.LogLevel_Off:Jd.loggingLevel}constructor(){}},Zd=(e=>(e[e.LogLevel_Verbose=0]=`LogLevel_Verbose`,e[e.LogLevel_Debug=1]=`LogLevel_Debug`,e[e.LogLevel_Info=2]=`LogLevel_Info`,e[e.LogLevel_Warning=3]=`LogLevel_Warning`,e[e.LogLevel_Error=4]=`LogLevel_Error`,e[e.LogLevel_Off=5]=`LogLevel_Off`,e))(Zd||{});const Qd=()=>{};function $d(e,...t){rf.print(Zd.LogLevel_Debug,`[CSM][D]`+e+` +`,t)}function ef(e,...t){rf.print(Zd.LogLevel_Info,`[CSM][I]`+e+` +`,t)}function tf(e,...t){rf.print(Zd.LogLevel_Warning,`[CSM][W]`+e+` +`,t)}function nf(e,...t){rf.print(Zd.LogLevel_Error,`[CSM][E]`+e+` +`,t)}var rf=class{static print(e,t,n){if(en[t]);r(i)}static dumpBytes(e,t,n){for(let r=0;r0?this.print(e,` +`):r%8==0&&r>0&&this.print(e,` `),this.print(e,`{0} `,[t[r]&255]);this.print(e,` +`)}constructor(){}},af=class{update(){this._model.update(),this._model.drawables.resetDynamicFlags()}getCanvasWidth(){return this._model==null?0:this._model.canvasinfo.CanvasWidth/this._model.canvasinfo.PixelsPerUnit}getCanvasHeight(){return this._model==null?0:this._model.canvasinfo.CanvasHeight/this._model.canvasinfo.PixelsPerUnit}saveParameters(){let e=this._model.parameters.count,t=this._savedParameters.length;for(let n=0;nt&&(t=this._model.parameters.minimumValues[e]),this._parameterValues[e]=n==1?t:this._parameterValues[e]=this._parameterValues[e]*(1-n)+t*n}setParameterValueById(e,t,n=1){let r=this.getParameterIndex(e);this.setParameterValueByIndex(r,t,n)}addParameterValueByIndex(e,t,n=1){this.setParameterValueByIndex(e,this.getParameterValueByIndex(e)+t*n)}addParameterValueById(e,t,n=1){let r=this.getParameterIndex(e);this.addParameterValueByIndex(r,t,n)}multiplyParameterValueById(e,t,n=1){let r=this.getParameterIndex(e);this.multiplyParameterValueByIndex(r,t,n)}multiplyParameterValueByIndex(e,t,n=1){this.setParameterValueByIndex(e,this.getParameterValueByIndex(e)*(1+(t-1)*n))}getDrawableIds(){return this._drawableIds.slice()}getDrawableIndex(e){let t=this._model.drawables.count;for(let n=0;nt&&(e=t);for(let t=0;t0&&t.getEndTime()(e[e.ExpressionBlendType_Add=0]=`ExpressionBlendType_Add`,e[e.ExpressionBlendType_Multiply=1]=`ExpressionBlendType_Multiply`,e[e.ExpressionBlendType_Overwrite=2]=`ExpressionBlendType_Overwrite`,e))(df||{}),ff;(e=>{e.supportMoreMaskDivisions=!0,e.setOpacityFromMotion=!1})(ff||={});var pf=(e=>(e[e.CubismMotionCurveTarget_Model=0]=`CubismMotionCurveTarget_Model`,e[e.CubismMotionCurveTarget_Parameter=1]=`CubismMotionCurveTarget_Parameter`,e[e.CubismMotionCurveTarget_PartOpacity=2]=`CubismMotionCurveTarget_PartOpacity`,e))(pf||{}),mf=(e=>(e[e.CubismMotionSegmentType_Linear=0]=`CubismMotionSegmentType_Linear`,e[e.CubismMotionSegmentType_Bezier=1]=`CubismMotionSegmentType_Bezier`,e[e.CubismMotionSegmentType_Stepped=2]=`CubismMotionSegmentType_Stepped`,e[e.CubismMotionSegmentType_InverseStepped=3]=`CubismMotionSegmentType_InverseStepped`,e))(mf||{}),hf=class{constructor(e=0,t=0){this.time=e,this.value=t}},gf=class{constructor(){this.basePointIndex=0,this.segmentType=0}},_f=class{constructor(){this.id=``,this.type=0,this.segmentCount=0,this.baseSegmentIndex=0,this.fadeInTime=0,this.fadeOutTime=0}},vf=class{constructor(){this.fireTime=0,this.value=``}},yf=class{constructor(){this.duration=0,this.loop=!1,this.curveCount=0,this.eventCount=0,this.fps=0,this.curves=[],this.segments=[],this.points=[],this.events=[]}},bf=class{constructor(e){this._json=e}release(){this._json=void 0}getMotionDuration(){return this._json.Meta.Duration}isMotionLoop(){return this._json.Meta.Loop||!1}getEvaluationOptionFlag(e){return xf.EvaluationOptionFlag_AreBeziersRistricted==e?!!this._json.Meta.AreBeziersRestricted:!1}getMotionCurveCount(){return this._json.Meta.CurveCount}getMotionFps(){return this._json.Meta.Fps}getMotionTotalSegmentCount(){return this._json.Meta.TotalSegmentCount}getMotionTotalPointCount(){return this._json.Meta.TotalPointCount}getMotionFadeInTime(){return this._json.Meta.FadeInTime}getMotionFadeOutTime(){return this._json.Meta.FadeOutTime}getMotionCurveTarget(e){return this._json.Curves[e].Target}getMotionCurveId(e){return this._json.Curves[e].Id}getMotionCurveFadeInTime(e){return this._json.Curves[e].FadeInTime}getMotionCurveFadeOutTime(e){return this._json.Curves[e].FadeOutTime}getMotionCurveSegmentCount(e){return this._json.Curves[e].Segments.length}getMotionCurveSegment(e,t){return this._json.Curves[e].Segments[t]}getEventCount(){return this._json.Meta.UserDataCount||0}getTotalEventValueSize(){return this._json.Meta.TotalUserDataSize}getEventTime(e){return this._json.UserData[e].Time}getEventValue(e){return this._json.UserData[e].Value}},xf=(e=>(e[e.EvaluationOptionFlag_AreBeziersRistricted=0]=`EvaluationOptionFlag_AreBeziersRistricted`,e))(xf||{});const Sf=`EyeBlink`,Cf=`LipSync`,wf=`Model`,Tf=`Parameter`,Ef=`PartOpacity`,Df=!1;function Of(e,t,n){let r=new hf;return r.time=e.time+(t.time-e.time)*n,r.value=e.value+(t.value-e.value)*n,r}function kf(e,t){let n=(t-e[0].time)/(e[1].time-e[0].time);return n<0&&(n=0),e[0].value+(e[1].value-e[0].value)*n}function Af(e,t){let n=(t-e[0].time)/(e[3].time-e[0].time);n<0&&(n=0);let r=Of(e[0],e[1],n),i=Of(e[1],e[2],n),a=Of(e[2],e[3],n),o=Of(r,i,n),s=Of(i,a,n);return Of(o,s,n).value}function jf(e,t){let n=t,r=e[0].time,i=e[3].time,a=e[1].time,o=e[2].time,s=i-3*o+3*a-r,c=3*o-6*a+3*r,l=3*a-3*r,u=r-n,d=Vd.cardanoAlgorithmForBezier(s,c,l,u),f=Of(e[0],e[1],d),p=Of(e[1],e[2],d),m=Of(e[2],e[3],d),h=Of(f,p,d),g=Of(p,m,d);return Of(h,g,d).value}function Mf(e,t){return e[0].value}function Nf(e,t){return e[1].value}function Pf(e,t,n){let r=e.curves[t],i=-1,a=r.baseSegmentIndex+r.segmentCount,o=0;for(let t=r.baseSegmentIndex;tn){i=t;break}if(i==-1)return e.points[o].value;let s=e.segments[i];return s.evaluate(e.points.slice(s.basePointIndex),n)}var Ff=class e extends cf{constructor(){super(),this._eyeBlinkParameterIds=[],this._lipSyncParameterIds=[],this._sourceFrameRate=30,this._loopDurationSeconds=-1,this._isLoop=!1,this._isLoopFadeIn=!0,this._lastWeight=0}static create(t,n){let r=new e;return r.parse(t),r._sourceFrameRate=r._motionData.fps,r._loopDurationSeconds=r._motionData.duration,r._onFinishedMotion=n,r}doUpdateParameters(e,t,n,r){this._modelCurveIdEyeBlink??=Sf,this._modelCurveIdLipSync??=Cf;let i=t-r.getStartTime();i<0&&(i=0);let a=Number.MAX_VALUE,o=Number.MAX_VALUE,s=64,c=0,l=0;this._eyeBlinkParameterIds.length>s&&$d(`too many eye blink targets : {0}`,this._eyeBlinkParameterIds.length),this._lipSyncParameterIds.length>s&&$d(`too many lip sync targets : {0}`,this._lipSyncParameterIds.length);let u=this._fadeInSeconds<=0?1:Vd.getEasingSine((t-r.getFadeInStartTime())/this._fadeInSeconds),d=this._fadeOutSeconds<=0||r.getEndTime()<0?1:Vd.getEasingSine((r.getEndTime()-t)/this._fadeOutSeconds),f,p,m,h=i;if(this._isLoop)for(;h>this._motionData.duration;)h-=this._motionData.duration;let g=this._motionData.curves;for(p=0;p>t&1)continue;let i=r+(o-r)*n;e.setParameterValueById(this._eyeBlinkParameterIds[t],i)}if(a!=Number.MAX_VALUE)for(let t=0;t>t&1)continue;let i=r+(a-r)*n;e.setParameterValueById(this._lipSyncParameterIds[t],i)}for(;p=this._motionData.duration&&(this._isLoop?(r.setStartTime(t),this._isLoopFadeIn&&r.setFadeInStartTime(t)):(this._onFinishedMotion&&this._onFinishedMotion(this),r.setIsFinished(!0))),this._lastWeight=n}setIsLoop(e){this._isLoop=e}isLoop(){return this._isLoop}setIsLoopFadeIn(e){this._isLoopFadeIn=e}isLoopFadeIn(){return this._isLoopFadeIn}getDuration(){return this._isLoop?-1:this._loopDurationSeconds}getLoopDuration(){return this._loopDurationSeconds}setParameterFadeInTime(e,t){let n=this._motionData.curves;for(let r=0;rnew _f),this._motionData.segments=Array.from({length:t.getMotionTotalSegmentCount()}).map(()=>new gf),this._motionData.events=Array.from({length:this._motionData.eventCount}).map(()=>new vf),this._motionData.points=[];let a=0,o=0;for(let e=0;ee&&this._motionData.events[n].fireTime<=t&&this._firedEventValues.push(this._motionData.events[n].value);return this._firedEventValues}},If=class{constructor(){this._autoDelete=!1,this._available=!0,this._finished=!1,this._started=!1,this._startTimeSeconds=-1,this._fadeInStartTimeSeconds=0,this._endTimeSeconds=-1,this._stateTimeSeconds=0,this._stateWeight=0,this._lastEventCheckSeconds=0,this._motionQueueEntryHandle=this,this._fadeOutSeconds=0,this._isTriggeredFadeOut=!1}release(){this._autoDelete&&this._motion&&this._motion.release()}setFadeOut(e){this._fadeOutSeconds=e,this._isTriggeredFadeOut=!0}startFadeOut(e,t){let n=t+e;this._isTriggeredFadeOut=!0,(this._endTimeSeconds<0||nt!=null&&t._motionQueueEntryHandle==e)}setEventCallback(e,t=null){this._eventCallBack=e,this._eventCustomData=t}doUpdateMotion(e,t){let n=!1,r=0;for(;r(e[e.CubismPhysicsTargetType_Parameter=0]=`CubismPhysicsTargetType_Parameter`,e))(zf||{}),Bf=(e=>(e[e.CubismPhysicsSource_X=0]=`CubismPhysicsSource_X`,e[e.CubismPhysicsSource_Y=1]=`CubismPhysicsSource_Y`,e[e.CubismPhysicsSource_Angle=2]=`CubismPhysicsSource_Angle`,e))(Bf||{}),Vf=class{constructor(){this.initialPosition=new zd(0,0),this.position=new zd(0,0),this.lastPosition=new zd(0,0),this.lastGravity=new zd(0,0),this.force=new zd(0,0),this.velocity=new zd(0,0)}},Hf=class{constructor(){this.normalizationPosition={},this.normalizationAngle={}}},Uf=class{constructor(){this.source={}}},Wf=class{constructor(){this.destination={},this.translationScale=new zd(0,0)}},Gf=class{constructor(){this.settings=[],this.inputs=[],this.outputs=[],this.particles=[],this.gravity=new zd(0,0),this.wind=new zd(0,0)}},Kf=class{constructor(e){this._json=e}release(){this._json=void 0}getGravity(){let e=new zd(0,0);return e.x=this._json.Meta.EffectiveForces.Gravity.X,e.y=this._json.Meta.EffectiveForces.Gravity.Y,e}getWind(){let e=new zd(0,0);return e.x=this._json.Meta.EffectiveForces.Wind.X,e.y=this._json.Meta.EffectiveForces.Wind.Y,e}getSubRigCount(){return this._json.Meta.PhysicsSettingCount}getTotalInputCount(){return this._json.Meta.TotalInputCount}getTotalOutputCount(){return this._json.Meta.TotalOutputCount}getVertexCount(){return this._json.Meta.VertexCount}getNormalizationPositionMinimumValue(e){return this._json.PhysicsSettings[e].Normalization.Position.Minimum}getNormalizationPositionMaximumValue(e){return this._json.PhysicsSettings[e].Normalization.Position.Maximum}getNormalizationPositionDefaultValue(e){return this._json.PhysicsSettings[e].Normalization.Position.Default}getNormalizationAngleMinimumValue(e){return this._json.PhysicsSettings[e].Normalization.Angle.Minimum}getNormalizationAngleMaximumValue(e){return this._json.PhysicsSettings[e].Normalization.Angle.Maximum}getNormalizationAngleDefaultValue(e){return this._json.PhysicsSettings[e].Normalization.Angle.Default}getInputCount(e){return this._json.PhysicsSettings[e].Input.length}getInputWeight(e,t){return this._json.PhysicsSettings[e].Input[t].Weight}getInputReflect(e,t){return this._json.PhysicsSettings[e].Input[t].Reflect}getInputType(e,t){return this._json.PhysicsSettings[e].Input[t].Type}getInputSourceId(e,t){return this._json.PhysicsSettings[e].Input[t].Source.Id}getOutputCount(e){return this._json.PhysicsSettings[e].Output.length}getOutputVertexIndex(e,t){return this._json.PhysicsSettings[e].Output[t].VertexIndex}getOutputAngleScale(e,t){return this._json.PhysicsSettings[e].Output[t].Scale}getOutputWeight(e,t){return this._json.PhysicsSettings[e].Output[t].Weight}getOutputDestinationId(e,t){return this._json.PhysicsSettings[e].Output[t].Destination.Id}getOutputType(e,t){return this._json.PhysicsSettings[e].Output[t].Type}getOutputReflect(e,t){return this._json.PhysicsSettings[e].Output[t].Reflect}getParticleCount(e){return this._json.PhysicsSettings[e].Vertices.length}getParticleMobility(e,t){return this._json.PhysicsSettings[e].Vertices[t].Mobility}getParticleDelay(e,t){return this._json.PhysicsSettings[e].Vertices[t].Delay}getParticleAcceleration(e,t){return this._json.PhysicsSettings[e].Vertices[t].Acceleration}getParticleRadius(e,t){return this._json.PhysicsSettings[e].Vertices[t].Radius}getParticlePosition(e,t){let n=new zd(0,0);return n.x=this._json.PhysicsSettings[e].Vertices[t].Position.X,n.y=this._json.PhysicsSettings[e].Vertices[t].Position.Y,n}};const qf=`X`,Jf=`Y`,Yf=`Angle`,Xf=5,Zf=100,Qf=.001;var $f=class e{static create(t){let n=new e;return n.parse(t),n._physicsRig.gravity.y=0,n}evaluate(e,t){let n,r,i,a,o=new zd,s,c,l,u,d,f,p,m;d=e.getModel().parameters.values,f=e.getModel().parameters.maximumValues,p=e.getModel().parameters.minimumValues,m=e.getModel().parameters.defaultValues;for(let h=0;h=s.particleCount)break;l[t].destinationParameterIndex==-1&&(l[t].destinationParameterIndex=e.getParameterIndex(l[t].destination.id));let r=new zd;r.x=u[n].position.x-u[n-1].position.x,r.y=u[n].position.y-u[n-1].position.y,a=l[t].getValue(r,u,n,l[t].reflect,this._options.gravity);let i=l[t].destinationParameterIndex,o=!Float32Array.prototype.slice&&`subarray`in Float32Array.prototype?JSON.parse(JSON.stringify(d.subarray(i))):d.slice(i);pp(o,p[i],f[i],a,l[t]);for(let e=i,t=0;e=2?t[n-1].position.substract(t[n-2].position):i.multiplyByScaler(-1),a=Vd.directionToRadian(i,e),r&&(a*=-1),a}function sp(e,t){return Math.abs(Math.max(e,t)-Math.min(e,t))}function cp(e,t){let n=Math.min(e,t);return n+sp(e,t)/2}function lp(e,t){return e.x}function up(e,t){return e.y}function dp(e,t){return t}function fp(e,t,n,r,i,a,o,s){let c,l,u,d,f=new zd(0,0),p=new zd(0,0),m=new zd(0,0),h=new zd(0,0);e[0].position=new zd(n.x,n.y),c=Vd.degreesToRadian(r),d=Vd.radianToDirection(c),d.normalize();for(let n=1;nn&&(o>i.valueExceededMaximum&&(i.valueExceededMaximum=o),o=n),s=i.weight/Zf,s>=1||(o=e[0]*(1-s)+o*s),e[0]=o}function mp(e,t,n,r,i,a,o,s){let c=0,l=Vd.max(n,t);le&&(e=u);let d=Vd.min(i,a),f=Vd.max(i,a),p=o,m=cp(u,l),h=e-m;switch(Math.sign(h)){case 1:{let e=f-p,t=l-m;t!=0&&(c=h*(e/t),c+=p);break}case-1:{let e=d-p,t=u-m;t!=0&&(c=h*(e/t),c+=p);break}case 0:c=p;break}return s?c:c*-1}var hp=class{constructor(e=0,t=0,n=0,r=0){this.x=e,this.y=t,this.width=n,this.height=r}getCenterX(){return this.x+.5*this.width}getCenterY(){return this.y+.5*this.height}getRight(){return this.x+this.width}getBottom(){return this.y+this.height}setRect(e){this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height}expand(e,t){this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2}};const gp=4,_p=10;let vp,yp,bp;var xp=class{getChannelFlagAsColor(e){return this._channelColors[e]}getMaskRenderTexture(){let e=0;if(this._maskTexture&&this._maskTexture.texture!=0&&(this._maskTexture.frameNo=this._currentFrameNo,e=this._maskTexture.texture),e==0){let t=this._clippingMaskBufferSize;this._colorBuffer=this.gl.createTexture(),this.gl.bindTexture(this.gl.TEXTURE_2D,this._colorBuffer),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,t,t,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,null),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.bindTexture(this.gl.TEXTURE_2D,null),e=this.gl.createFramebuffer(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,e),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,this._colorBuffer,0),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,bp),this._maskTexture=new Sp(this._currentFrameNo,e)}return e}setGL(e){this.gl=e}calcClippedDrawTotalBounds(e,t){let n=Number.MAX_VALUE,r=Number.MAX_VALUE,i=Number.MIN_VALUE,a=Number.MIN_VALUE,o=t._clippedDrawableIndexList.length;for(let s=0;sf&&(f=t),np&&(p=n)}if(u!=Number.MAX_VALUE)if(ui&&(i=f),p>a&&(a=p),n==Number.MAX_VALUE)t._allClippedDrawRect.x=0,t._allClippedDrawRect.y=0,t._allClippedDrawRect.width=0,t._allClippedDrawRect.height=0,t._isUsing=!1;else{t._isUsing=!0;let e=i-n,o=a-r;t._allClippedDrawRect.x=n,t._allClippedDrawRect.y=r,t._allClippedDrawRect.width=e,t._allClippedDrawRect.height=o}}}constructor(){this._maskRenderTexture=null,this._colorBuffer=null,this._currentFrameNo=0,this._clippingMaskBufferSize=256,this._clippingContextListForMask=[],this._clippingContextListForDraw=[],this._channelColors=[],this._tmpBoundsOnModel=new hp,this._tmpMatrix=new Hd,this._tmpMatrixForMask=new Hd,this._tmpMatrixForDraw=new Hd;let e=new Gd;e.R=1,e.G=0,e.B=0,e.A=0,this._channelColors.push(e),e=new Gd,e.R=0,e.G=1,e.B=0,e.A=0,this._channelColors.push(e),e=new Gd,e.R=0,e.G=0,e.B=1,e.A=0,this._channelColors.push(e),e=new Gd,e.R=0,e.G=0,e.B=0,e.A=1,this._channelColors.push(e)}release(){var e,t,n;let r=this;for(let t=0;t0){this.gl.viewport(0,0,this._clippingMaskBufferSize,this._clippingMaskBufferSize),this._maskRenderTexture=this.getMaskRenderTexture(),t.getMvpMatrix(),t.preDraw(),this.setupLayoutBounds(n),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._maskRenderTexture),this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT);for(let n=0;n(e[e.ShaderNames_SetupMask=0]=`ShaderNames_SetupMask`,e[e.ShaderNames_NormalPremultipliedAlpha=1]=`ShaderNames_NormalPremultipliedAlpha`,e[e.ShaderNames_NormalMaskedPremultipliedAlpha=2]=`ShaderNames_NormalMaskedPremultipliedAlpha`,e[e.ShaderNames_NomralMaskedInvertedPremultipliedAlpha=3]=`ShaderNames_NomralMaskedInvertedPremultipliedAlpha`,e[e.ShaderNames_AddPremultipliedAlpha=4]=`ShaderNames_AddPremultipliedAlpha`,e[e.ShaderNames_AddMaskedPremultipliedAlpha=5]=`ShaderNames_AddMaskedPremultipliedAlpha`,e[e.ShaderNames_AddMaskedPremultipliedAlphaInverted=6]=`ShaderNames_AddMaskedPremultipliedAlphaInverted`,e[e.ShaderNames_MultPremultipliedAlpha=7]=`ShaderNames_MultPremultipliedAlpha`,e[e.ShaderNames_MultMaskedPremultipliedAlpha=8]=`ShaderNames_MultMaskedPremultipliedAlpha`,e[e.ShaderNames_MultMaskedPremultipliedAlphaInverted=9]=`ShaderNames_MultMaskedPremultipliedAlphaInverted`,e))(Tp||{});const Ep=`attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_myPos;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_clipMatrix * a_position; v_myPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}`,Dp=`precision mediump float;varying vec2 v_texCoord;varying vec4 v_myPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;void main(){ float isInside = step(u_baseColor.x, v_myPos.x/v_myPos.w) * step(u_baseColor.y, v_myPos.y/v_myPos.w) * step(v_myPos.x/v_myPos.w, u_baseColor.z) * step(v_myPos.y/v_myPos.w, u_baseColor.w); gl_FragColor = u_channelFlag * texture2D(s_texture0, v_texCoord).a * isInside;}`,Op=`attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;uniform mat4 u_matrix;void main(){ gl_Position = u_matrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}`,kp=`attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform mat4 u_matrix;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_matrix * a_position; v_clipPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}`,Ap=`precision mediump float;varying vec2 v_texCoord;uniform vec4 u_baseColor;uniform sampler2D s_texture0;void main(){ gl_FragColor = texture2D(s_texture0 , v_texCoord) * u_baseColor;}`,jp=`precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;uniform sampler2D s_texture1;void main(){ vec4 col_formask = texture2D(s_texture0 , v_texCoord) * u_baseColor; vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * maskVal; gl_FragColor = col_formask;}`,Mp=`precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_channelFlag;uniform vec4 u_baseColor;void main(){vec4 col_formask = texture2D(s_texture0, v_texCoord) * u_baseColor;vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag;float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a;col_formask = col_formask * (1.0 - maskVal);gl_FragColor = col_formask;}`;var Np=class extends Ud{constructor(){super(),this._clippingContextBufferForMask=null,this._clippingContextBufferForDraw=null,this._clippingManager=new xp,this.firstDraw=!0,this._textures={},this._sortedDrawableIndexList=[],this._bufferData={vertex:null,uv:null,index:null}}initialize(e){e.isUsingMasking()&&(this._clippingManager=new xp,this._clippingManager.initialize(e,e.getDrawableCount(),e.getDrawableMasks(),e.getDrawableMaskCounts()));for(let t=e.getDrawableCount()-1;t>=0;t--)this._sortedDrawableIndexList[t]=0;super.initialize(e)}bindTexture(e,t){this._textures[e]=t}getBindedTextures(){return this._textures}setClippingMaskBufferSize(e){this._clippingManager.release(),this._clippingManager=new xp,this._clippingManager.setClippingMaskBufferSize(e),this._clippingManager.initialize(this.getModel(),this.getModel().getDrawableCount(),this.getModel().getDrawableMasks(),this.getModel().getDrawableMaskCounts())}getClippingMaskBufferSize(){return this._clippingManager.getClippingMaskBufferSize()}release(){var e,t,n;let r=this;this._clippingManager.release(),r._clippingManager=void 0,(e=this.gl)==null||e.deleteBuffer(this._bufferData.vertex),this._bufferData.vertex=null,(t=this.gl)==null||t.deleteBuffer(this._bufferData.uv),this._bufferData.uv=null,(n=this.gl)==null||n.deleteBuffer(this._bufferData.index),this._bufferData.index=null,r._bufferData=void 0,r._textures=void 0}doDrawModel(){this.preDraw(),this._clippingManager!=null&&this._clippingManager.setupClippingContext(this.getModel(),this);let e=this.getModel().getDrawableCount(),t=this.getModel().getDrawableRenderOrders();for(let n=0;n{Np.doStaticRelease()};var Pp=class{constructor(e){this.groups=e.Groups,this.hitAreas=e.HitAreas,this.layout=e.Layout,this.moc=e.FileReferences.Moc,this.expressions=e.FileReferences.Expressions,this.motions=e.FileReferences.Motions,this.textures=e.FileReferences.Textures,this.physics=e.FileReferences.Physics,this.pose=e.FileReferences.Pose}getEyeBlinkParameters(){var e,t;return(t=(e=this.groups)?.find(e=>e.Name===`EyeBlink`))?.Ids}getLipSyncParameters(){var e,t;return(t=(e=this.groups)?.find(e=>e.Name===`LipSync`))?.Ids}};const Fp=`ParamAngleX`,Ip=`ParamAngleY`,Lp=`ParamAngleZ`,Rp=`ParamEyeBallX`,zp=`ParamEyeBallY`,Bp=`ParamBodyAngleX`,Vp=`ParamBreath`,Hp=2,Up=2;var Wp;(e=>{e.LOG_LEVEL_VERBOSE=0,e.LOG_LEVEL_WARNING=1,e.LOG_LEVEL_ERROR=2,e.LOG_LEVEL_NONE=999,e.logLevel=e.LOG_LEVEL_WARNING,e.sound=!0,e.motionSync=!0,e.motionFadingDuration=500,e.idleMotionFadingDuration=2e3,e.expressionFadingDuration=500,e.preserveExpressionOnMotion=!0,e.cubism4=ff})(Wp||={});const Gp={log(e,...t){Wp.logLevel<=Wp.LOG_LEVEL_VERBOSE&&console.log(`[${e}]`,...t)},warn(e,...t){Wp.logLevel<=Wp.LOG_LEVEL_WARNING&&console.warn(`[${e}]`,...t)},error(e,...t){Wp.logLevel<=Wp.LOG_LEVEL_ERROR&&console.error(`[${e}]`,...t)}};function Kp(e,t,n){return en?n:e}function qp(e,t){t.forEach(t=>{Object.getOwnPropertyNames(t.prototype).forEach(n=>{n!==`constructor`&&Object.defineProperty(e.prototype,n,Object.getOwnPropertyDescriptor(t.prototype,n))})})}function Jp(e){let t=e.lastIndexOf(`/`);return t!=-1&&(e=e.slice(0,t)),t=e.lastIndexOf(`/`),t!==-1&&(e=e.slice(t+1)),e}function Yp(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}var Xp=class extends ls.default{constructor(e,t){super(),this.expressions=[],this.reserveExpressionIndex=-1,this.destroyed=!1,this.settings=e,this.tag=`ExpressionManager(${e.name})`}init(){this.defaultExpression=this.createExpression({},void 0),this.currentExpression=this.defaultExpression,this.stopAllExpressions()}loadExpression(e){return kd(this,null,function*(){if(!this.definitions[e]){Gp.warn(this.tag,`Undefined expression at [${e}]`);return}if(this.expressions[e]===null){Gp.warn(this.tag,`Cannot set expression at [${e}] because it's already failed in loading.`);return}if(this.expressions[e])return this.expressions[e];let t=yield this._loadExpression(e);return this.expressions[e]=t,t})}_loadExpression(e){throw Error(`Not implemented.`)}setRandomExpression(){return kd(this,null,function*(){if(this.definitions.length){let e=[];for(let t=0;t-1&&ec&&(a*=c/s,o*=c/s),this.vx+=a,this.vy+=o;let l=Math.sqrt(Od(this.vx,2)+Od(this.vy,2)),u=.5*(Math.sqrt(Od(c,2)+8*c*r)-c);l>u&&(this.vx*=u/l,this.vy*=u/l),this.x+=this.vx,this.y+=this.vy}},tm=class{constructor(e){this.json=e;let t=e.url;if(typeof t!=`string`)throw TypeError("The `url` field in settings JSON must be defined as a string.");this.url=t,this.name=Jp(this.url)}resolveURL(e){return fs.resolve(this.url,e)}replaceFiles(e){this.moc=e(this.moc,`moc`),this.pose!==void 0&&(this.pose=e(this.pose,`pose`)),this.physics!==void 0&&(this.physics=e(this.physics,`physics`));for(let t=0;t(e.push(t),t)),e}validateFiles(e){let t=(t,n)=>{let r=this.resolveURL(t);if(!e.includes(r)){if(n)throw Error(`File "${t}" is defined in settings, but doesn't exist in given files`);return!1}return!0},n=[this.moc,...this.textures];n.forEach(e=>t(e,!0));let r=this.getDefinedFiles();return r.filter(e=>t(e,!1))}},nm=(e=>(e[e.NONE=0]=`NONE`,e[e.IDLE=1]=`IDLE`,e[e.NORMAL=2]=`NORMAL`,e[e.FORCE=3]=`FORCE`,e))(nm||{}),rm=class{constructor(){this.debug=!1,this.currentPriority=0,this.reservePriority=0}reserve(e,t,n){if(n<=0)return Gp.log(this.tag,`Cannot start a motion with MotionPriority.NONE.`),!1;if(e===this.currentGroup&&t===this.currentIndex)return Gp.log(this.tag,`Motion is already playing.`,this.dump(e,t)),!1;if(e===this.reservedGroup&&t===this.reservedIndex||e===this.reservedIdleGroup&&t===this.reservedIdleIndex)return Gp.log(this.tag,`Motion is already reserved.`,this.dump(e,t)),!1;if(n===1){if(this.currentPriority!==0)return Gp.log(this.tag,`Cannot start idle motion because another motion is playing.`,this.dump(e,t)),!1;if(this.reservedIdleGroup!==void 0)return Gp.log(this.tag,`Cannot start idle motion because another idle motion has reserved.`,this.dump(e,t)),!1;this.setReservedIdle(e,t)}else{if(n<3){if(n<=this.currentPriority)return Gp.log(this.tag,`Cannot start motion because another motion is playing as an equivalent or higher priority.`,this.dump(e,t)),!1;if(n<=this.reservePriority)return Gp.log(this.tag,`Cannot start motion because another motion has reserved as an equivalent or higher priority.`,this.dump(e,t)),!1}this.setReserved(e,t,n)}return!0}start(e,t,n,r){if(r===1){if(this.setReservedIdle(void 0,void 0),this.currentPriority!==0)return Gp.log(this.tag,`Cannot start idle motion because another motion is playing.`,this.dump(t,n)),!1}else{if(t!==this.reservedGroup||n!==this.reservedIndex)return Gp.log(this.tag,`Cannot start motion because another motion has taken the place.`,this.dump(t,n)),!1;this.setReserved(void 0,void 0,0)}return e?(this.setCurrent(t,n,r),!0):!1}complete(){this.setCurrent(void 0,void 0,0)}setCurrent(e,t,n){this.currentPriority=n,this.currentGroup=e,this.currentIndex=t}setReserved(e,t,n){this.reservePriority=n,this.reservedGroup=e,this.reservedIndex=t}setReservedIdle(e,t){this.reservedIdleGroup=e,this.reservedIdleIndex=t}isActive(e,t){return e===this.currentGroup&&t===this.currentIndex||e===this.reservedGroup&&t===this.reservedIndex||e===this.reservedIdleGroup&&t===this.reservedIdleIndex}reset(){this.setCurrent(void 0,void 0,0),this.setReserved(void 0,void 0,0),this.setReservedIdle(void 0,void 0)}shouldRequestIdleMotion(){return this.currentGroup===void 0&&this.reservedIdleGroup===void 0}shouldOverrideExpression(){return!Wp.preserveExpressionOnMotion&&this.currentPriority>1}dump(e,t){if(this.debug){let n=[`currentPriority`,`reservePriority`,`currentGroup`,`currentIndex`,`reservedGroup`,`reservedIndex`,`reservedIdleGroup`,`reservedIdleIndex`];return` + group = "${e}", index = ${t} +`+n.map(e=>`[`+e+`] `+this[e]).join(` +`)}return``}};const im=`SoundManager`,am=.5;var om=class{static get volume(){return this._volume}static set volume(e){this._volume=(e>1?1:e<0?0:e)||0,this.audios.forEach(e=>e.volume=this._volume)}static add(e,t,n){let r=new Audio(e);return r.volume=this._volume,r.preload=`auto`,r.addEventListener(`ended`,()=>{this.dispose(r),t?.()}),r.addEventListener(`error`,t=>{this.dispose(r),Gp.warn(im,`Error occurred on "${e}"`,t.error),n?.(t.error)}),this.audios.push(r),r}static play(e){return new Promise((t,n)=>{var r;(r=e.play())==null||r.catch(t=>{e.dispatchEvent(new ErrorEvent(`error`,{error:t})),n(t)}),e.readyState===e.HAVE_ENOUGH_DATA?t():e.addEventListener(`canplaythrough`,t)})}static dispose(e){e.pause(),e.removeAttribute(`src`),Yp(this.audios,e)}static destroy(){for(let e=this.audios.length-1;e>=0;e--)this.dispose(this.audios[e])}};om.audios=[],om._volume=am;var sm=class extends ls.default{constructor(e,t){super(),this.motionGroups={},this.state=new rm,this.playing=!1,this.destroyed=!1,this.settings=e,this.tag=`MotionManager(${e.name})`,this.state.tag=this.tag}init(e){e?.idleMotionGroup&&(this.groups.idle=e.idleMotionGroup),this.setupMotions(e),this.stopAllMotions()}setupMotions(e){for(let e of Object.keys(this.definitions))this.motionGroups[e]=[];let t;switch(e?.motionPreload){case`NONE`:return;case`ALL`:t=Object.keys(this.definitions);break;case`IDLE`:default:t=[this.groups.idle];break}for(let e of t)if(this.definitions[e])for(let t=0;tthis.currentAudio=void 0,()=>this.currentAudio=void 0),this.currentAudio=a}catch(t){Gp.warn(this.tag,`Failed to create audio`,e,t)}}let o=yield this.loadMotion(e,t);if(a){let e=om.play(a).catch(e=>Gp.warn(this.tag,`Failed to play audio`,a.src,e));Wp.motionSync&&(yield e)}return this.state.start(o,e,t,n)?(Gp.log(this.tag,`Start motion:`,this.getMotionName(i)),this.emit(`motionStart`,e,t,a),this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),this.playing=!0,this._startMotion(o),!0):(a&&(om.dispose(a),this.currentAudio=void 0),!1)})}startRandomMotion(e,t){return kd(this,null,function*(){let n=this.definitions[e];if(n?.length){let r=[];for(let t=0;te.index>=0);for(let t of e)this.hitAreas[t.name]=t}hitTest(e,t){return Object.keys(this.hitAreas).filter(n=>this.isHit(n,e,t))}isHit(e,t,n){if(!this.hitAreas[e])return!1;let r=this.hitAreas[e].index,i=this.getDrawableBounds(r,cm);return i.x<=t&&t<=i.x+i.width&&i.y<=n&&n<=i.y+i.height}getDrawableBounds(e,t){let n=this.getDrawableVertices(e),r=n[0],i=n[0],a=n[1],o=n[1];for(let e=0;e{(a.status===200||a.status===0)&&a.response?r(a.response):a.onerror()},a.onerror=()=>{Gp.warn(um,`Failed to load resource as ${a.responseType} (Status ${a.status}): ${t}`),i(new dm(`Network error.`,t,a.status))},a.onabort=()=>i(new dm(`Aborted.`,t,a.status,!0)),a.onloadend=()=>{var t;fm.allXhrSet.delete(a),e&&((t=fm.xhrMap.get(e))==null||t.delete(a))},a}static cancelXHRs(){var e;(e=fm.xhrMap.get(this))==null||e.forEach(e=>{e.abort(),fm.allXhrSet.delete(e)}),fm.xhrMap.delete(this)}static release(){fm.allXhrSet.forEach(e=>e.abort()),fm.allXhrSet.clear(),fm.xhrMap=new WeakMap}};let pm=fm;pm.xhrMap=new WeakMap,pm.allXhrSet=new Set,pm.loader=(e,t)=>new Promise((t,n)=>{let r=fm.createXHR(e.target,e.settings?e.settings.resolveURL(e.url):e.url,e.type,n=>{e.result=n,t()},n);r.send()});function mm(e,t){let n=-1;return r(0);function r(i,a){if(a)return Promise.reject(a);if(i<=n)return Promise.reject(Error(`next() called multiple times`));n=i;let o=e[i];if(!o)return Promise.resolve();try{return Promise.resolve(o(t,r.bind(null,i+1)))}catch(e){return Promise.reject(e)}}}var hm=class{static load(e){return mm(this.middlewares,e).then(()=>e.result)}};hm.middlewares=[pm.loader];function gm(e,t={}){var n;let r={resourceOptions:{crossorigin:t.crossOrigin}};if(Wc.fromURL)return Wc.fromURL(e,r).catch(e=>{if(e instanceof Error)throw e;let t=Error(`Texture loading error`);throw t.event=e,t});r.resourceOptions.autoLoad=!1;let i=Wc.from(e,r);if(i.baseTexture.valid)return Promise.resolve(i);let a=i.baseTexture.resource;return(n=a._live2d_load)??(a._live2d_load=new Promise((e,t)=>{let n=e=>{a.source.removeEventListener(`error`,n);let r=Error(`Texture loading error`);r.event=e,t(r)};a.source.addEventListener(`error`,n),a.load().then(()=>e(i)).catch(n)})),a._live2d_load}const _m=`Live2DFactory`,vm=(e,t)=>kd(void 0,null,function*(){if(typeof e.source==`string`){let t=yield hm.load({url:e.source,type:`json`,target:e.live2dModel});t.url=e.source,e.source=t,e.live2dModel.emit(`settingsJSONLoaded`,t)}return t()}),ym=(e,t)=>kd(void 0,null,function*(){if(e.source instanceof tm)return e.settings=e.source,t();if(typeof e.source==`object`){let n=Tm.findRuntime(e.source);if(n){let r=n.createModelSettings(e.source);return e.settings=r,e.live2dModel.emit(`settingsLoaded`,r),t()}}throw TypeError(`Unknown settings format.`)}),bm=(e,t)=>{if(e.settings){let n=Tm.findRuntime(e.settings);if(n)return n.ready().then(t)}return t()},xm=(e,t)=>kd(void 0,null,function*(){yield t();let n=e.internalModel;if(n){let t=e.settings,r=Tm.findRuntime(t);if(r){let i=[];t.pose&&i.push(hm.load({settings:t,url:t.pose,type:`json`,target:n}).then(t=>{n.pose=r.createPose(n.coreModel,t),e.live2dModel.emit(`poseLoaded`,n.pose)}).catch(t=>{e.live2dModel.emit(`poseLoadError`,t),Gp.warn(_m,`Failed to load pose.`,t)})),t.physics&&i.push(hm.load({settings:t,url:t.physics,type:`json`,target:n}).then(t=>{n.physics=r.createPhysics(n.coreModel,t),e.live2dModel.emit(`physicsLoaded`,n.physics)}).catch(t=>{e.live2dModel.emit(`physicsLoadError`,t),Gp.warn(_m,`Failed to load physics.`,t)})),i.length&&(yield Promise.all(i))}}}),Sm=(e,t)=>kd(void 0,null,function*(){if(e.settings){let n=e.live2dModel,r=e.settings.textures.map(t=>{let n=e.settings.resolveURL(t);return gm(n,{crossOrigin:e.options.crossOrigin})});if(yield t(),e.internalModel)n.internalModel=e.internalModel,n.emit(`modelLoaded`,e.internalModel);else throw TypeError(`Missing internal model.`);n.textures=yield Promise.all(r),n.emit(`textureLoaded`,n.textures)}else throw TypeError(`Missing settings.`)}),Cm=(e,t)=>kd(void 0,null,function*(){let n=e.settings;if(n instanceof tm){let r=Tm.findRuntime(n);if(!r)throw TypeError(`Unknown model settings.`);let i=yield hm.load({settings:n,url:n.moc,type:`arraybuffer`,target:e.live2dModel});if(!r.isValidMoc(i))throw Error(`Invalid moc data`);let a=r.createCoreModel(i);return e.internalModel=r.createInternalModel(a,n,e.options),t()}throw TypeError(`Missing settings.`)}),wm=class{static registerRuntime(e){wm.runtimes.push(e),wm.runtimes.sort((e,t)=>t.version-e.version)}static findRuntime(e){for(let t of wm.runtimes)if(t.test(e))return t}static setupLive2DModel(e,t,n){return kd(this,null,function*(){let r=new Promise(t=>e.once(`textureLoaded`,t)),i=new Promise(t=>e.once(`modelLoaded`,t)),a=Promise.all([r,i]).then(()=>e.emit(`ready`));yield mm(wm.live2DModelMiddlewares,{live2dModel:e,source:t,options:n||{}}),yield a,e.emit(`load`)})}static loadMotion(e,t,n){var r,i;let a=r=>e.emit(`motionLoadError`,t,n,r);try{let o=(r=e.definitions[t])?.[n];if(!o)return Promise.resolve(void 0);e.listeners(`destroy`).includes(wm.releaseTasks)||e.once(`destroy`,wm.releaseTasks);let s=wm.motionTasksMap.get(e);s||(s={},wm.motionTasksMap.set(e,s));let c=s[t];c||(c=[],s[t]=c);let l=e.getMotionFile(o);return(i=c[n])??(c[n]=hm.load({url:l,settings:e.settings,type:e.motionDataType,target:e}).then(r=>{var i;let a=(i=wm.motionTasksMap.get(e))?.[t];a&&delete a[n];let s=e.createMotion(r,t,o);return e.emit(`motionLoaded`,t,n,s),s}).catch(t=>{Gp.warn(e.tag,`Failed to load motion: ${l} +`,t),a(t)})),c[n]}catch(r){Gp.warn(e.tag,`Failed to load motion at "${t}"[${n}] +`,r),a(r)}return Promise.resolve(void 0)}static loadExpression(e,t){var n;let r=n=>e.emit(`expressionLoadError`,t,n);try{let i=e.definitions[t];if(!i)return Promise.resolve(void 0);e.listeners(`destroy`).includes(wm.releaseTasks)||e.once(`destroy`,wm.releaseTasks);let a=wm.expressionTasksMap.get(e);a||(a=[],wm.expressionTasksMap.set(e,a));let o=e.getExpressionFile(i);return(n=a[t])??(a[t]=hm.load({url:o,settings:e.settings,type:`json`,target:e}).then(n=>{let r=wm.expressionTasksMap.get(e);r&&delete r[t];let a=e.createExpression(n,i);return e.emit(`expressionLoaded`,t,a),a}).catch(t=>{Gp.warn(e.tag,`Failed to load expression: ${o} +`,t),r(t)})),a[t]}catch(n){Gp.warn(e.tag,`Failed to load expression at [${t}] +`,n),r(n)}return Promise.resolve(void 0)}static releaseTasks(){this instanceof sm?wm.motionTasksMap.delete(this):wm.expressionTasksMap.delete(this)}};let Tm=wm;Tm.runtimes=[],Tm.urlToJSON=vm,Tm.jsonToSettings=ym,Tm.waitUntilReady=bm,Tm.setupOptionals=xm,Tm.setupEssentials=Sm,Tm.createInternalModel=Cm,Tm.live2DModelMiddlewares=[vm,ym,bm,xm,Sm,Cm],Tm.motionTasksMap=new WeakMap,Tm.expressionTasksMap=new WeakMap,sm.prototype._loadMotion=function(e,t){return Tm.loadMotion(this,e,t)},Xp.prototype._loadExpression=function(e){return Tm.loadExpression(this,e)};var Em=class{constructor(){this._autoInteract=!1}get autoInteract(){return this._autoInteract}set autoInteract(e){e!==this._autoInteract&&(e?this.on(`pointertap`,Dm,this):this.off(`pointertap`,Dm,this),this._autoInteract=e)}registerInteraction(e){e!==this.interactionManager&&(this.unregisterInteraction(),this._autoInteract&&e&&(this.interactionManager=e,e.on(`pointermove`,Om,this)))}unregisterInteraction(){var e;this.interactionManager&&((e=this.interactionManager)==null||e.off(`pointermove`,Om,this),this.interactionManager=void 0)}};function Dm(e){this.tap(e.data.global.x,e.data.global.y)}function Om(e){this.focus(e.data.global.x,e.data.global.y)}var km=class extends _c{};const Am=new $s,jm=new sc;let Mm;var Nm=class extends Td{constructor(e){super(),this.tag=`Live2DModel(uninitialized)`,this.textures=[],this.transform=new km,this.anchor=new oc(this.onAnchorChange,this,0,0),this.glContextID=-1,this.elapsedTime=performance.now(),this.deltaTime=0,this._autoUpdate=!1,this.once(`modelLoaded`,()=>this.init(e))}static from(e,t){let n=new this(t);return Tm.setupLive2DModel(n,e,t).then(()=>n)}static fromSync(e,t){let n=new this(t);return Tm.setupLive2DModel(n,e,t).then(t?.onLoad).catch(t?.onError),n}static registerTicker(e){Mm=e}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){var t;Mm||=(t=window.PIXI)?.Ticker,e?this._destroyed||(Mm?(Mm.shared.add(this.onTickerUpdate,this),this._autoUpdate=!0):Gp.warn(this.tag,`No Ticker registered, please call Live2DModel.registerTicker(Ticker).`)):(Mm?.shared.remove(this.onTickerUpdate,this),this._autoUpdate=!1)}init(e){this.tag=`Live2DModel(${this.internalModel.settings.name})`;let t=Object.assign({autoUpdate:!0,autoInteract:!0},e);t.autoInteract&&(this.interactive=!0),this.autoInteract=t.autoInteract,this.autoUpdate=t.autoUpdate}onAnchorChange(){this.pivot.set(this.anchor.x*this.internalModel.width,this.anchor.y*this.internalModel.height)}motion(e,t,n){return t===void 0?this.internalModel.motionManager.startRandomMotion(e,n):this.internalModel.motionManager.startMotion(e,t,n)}expression(e){return this.internalModel.motionManager.expressionManager?e===void 0?this.internalModel.motionManager.expressionManager.setRandomExpression():this.internalModel.motionManager.expressionManager.setExpression(e):Promise.resolve(!1)}focus(e,t,n=!1){Am.x=e,Am.y=t,this.toModelPosition(Am,Am,!0);let r=Am.x/this.internalModel.originalWidth*2-1,i=Am.y/this.internalModel.originalHeight*2-1,a=Math.atan2(i,r);this.internalModel.focusController.focus(Math.cos(a),-Math.sin(a),n)}tap(e,t){let n=this.hitTest(e,t);n.length&&(Gp.log(this.tag,`Hit`,n),this.emit(`hit`,n))}hitTest(e,t){return Am.x=e,Am.y=t,this.toModelPosition(Am,Am),this.internalModel.hitTest(Am.x,Am.y)}toModelPosition(e,t=e.clone(),n){return n||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.transform.worldTransform.applyInverse(e,t),this.internalModel.localTransform.applyInverse(t,t),t}containsPoint(e){return this.getBounds(!0).contains(e.x,e.y)}_calculateBounds(){this._bounds.addFrame(this.transform,0,0,this.internalModel.width,this.internalModel.height)}onTickerUpdate(){this.update(Mm.shared.deltaMS)}update(e){this.deltaTime+=e,this.elapsedTime+=e}_render(e){this.registerInteraction(e.plugins.interaction),e.batch.reset(),e.geometry.reset(),e.shader.reset(),e.state.reset();let t=!1;this.glContextID!==e.CONTEXT_UID&&(this.glContextID=e.CONTEXT_UID,this.internalModel.updateWebGLContext(e.gl,this.glContextID),t=!0);for(let n=0;nt.destroy(e.baseTexture)),this.internalModel.destroy(),super.destroy(e)}};qp(Nm,[Em]);const Pm=class{static resolveURL(e,t){var n;let r=(n=Pm.filesMap[e])?.[t];if(r===void 0)throw Error(`Cannot find this file from uploaded files: `+t);return r}static upload(e,t){return kd(this,null,function*(){let n={};for(let r of t.getDefinedFiles()){let i=decodeURI(fs.resolve(t.url,r)),a=e.find(e=>e.webkitRelativePath===i);a&&(n[r]=URL.createObjectURL(a))}Pm.filesMap[t._objectURL]=n})}static createSettings(e){return kd(this,null,function*(){let t=e.find(e=>e.name.endsWith(`model.json`)||e.name.endsWith(`model3.json`));if(!t)throw TypeError(`Settings file not found`);let n=yield Pm.readText(t),r=JSON.parse(n);r.url=t.webkitRelativePath;let i=Tm.findRuntime(r);if(!i)throw Error(`Unknown settings JSON`);let a=i.createModelSettings(r);return a._objectURL=URL.createObjectURL(t),a})}static readText(e){return kd(this,null,function*(){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsText(e,`utf8`)})})}};let Fm=Pm;Fm.filesMap={},Fm.factory=(e,t)=>kd(void 0,null,function*(){if(Array.isArray(e.source)&&e.source[0]instanceof File){let t=e.source,n=t.settings;if(!n)n=yield Pm.createSettings(t);else if(!n._objectURL)throw Error(`"_objectURL" must be specified in ModelSettings`);n.validateFiles(t.map(e=>encodeURI(e.webkitRelativePath))),yield Pm.upload(t,n),n.resolveURL=function(e){return Pm.resolveURL(this._objectURL,e)},e.source=n,e.live2dModel.once(`modelLoaded`,e=>{e.once(`destroy`,function(){let e=this.settings._objectURL;if(URL.revokeObjectURL(e),Pm.filesMap[e])for(let t of Object.values(Pm.filesMap[e]))URL.revokeObjectURL(t);delete Pm.filesMap[e]})})}return t()}),Tm.live2DModelMiddlewares.unshift(Fm.factory);const Im=class{static unzip(e,t){return kd(this,null,function*(){let n=yield Im.getFilePaths(e),r=[];for(let e of t.getDefinedFiles()){let i=decodeURI(fs.resolve(t.url,e));n.includes(i)&&r.push(i)}let i=yield Im.getFiles(e,r);for(let e=0;ee.endsWith(`model.json`)||e.endsWith(`model3.json`));if(!n)throw Error(`Settings file not found`);let r=yield Im.readText(e,n);if(!r)throw Error(`Empty settings file: `+n);let i=JSON.parse(r);i.url=n;let a=Tm.findRuntime(i);if(!a)throw Error(`Unknown settings JSON`);return a.createModelSettings(i)})}static zipReader(e,t){return kd(this,null,function*(){throw Error(`Not implemented`)})}static getFilePaths(e){return kd(this,null,function*(){throw Error(`Not implemented`)})}static getFiles(e,t){return kd(this,null,function*(){throw Error(`Not implemented`)})}static readText(e,t){return kd(this,null,function*(){throw Error(`Not implemented`)})}static releaseReader(e){}};let Lm=Im;if(Lm.ZIP_PROTOCOL=`zip://`,Lm.uid=0,Lm.factory=(e,t)=>kd(void 0,null,function*(){let n=e.source,r,i,a;if(typeof n==`string`&&(n.endsWith(`.zip`)||n.startsWith(Im.ZIP_PROTOCOL))?(r=n.startsWith(Im.ZIP_PROTOCOL)?n.slice(Im.ZIP_PROTOCOL.length):n,i=yield hm.load({url:r,type:`blob`,target:e.live2dModel})):Array.isArray(n)&&n.length===1&&n[0]instanceof File&&n[0].name.endsWith(`.zip`)&&(i=n[0],r=URL.createObjectURL(i),a=n.settings),i){if(!i.size)throw Error(`Empty zip file`);let t=yield Im.zipReader(i,r);a||=yield Im.createSettings(t),a._objectURL=Im.ZIP_PROTOCOL+Im.uid+`/`+a.url;let n=yield Im.unzip(t,a);n.settings=a,e.source=n,r.startsWith(`blob:`)&&e.live2dModel.once(`modelLoaded`,e=>{e.once(`destroy`,function(){URL.revokeObjectURL(r)})}),Im.releaseReader(t)}return t()}),Tm.live2DModelMiddlewares.unshift(Lm.factory),!window.Live2DCubismCore)throw Error(`Could not find Cubism 4 runtime. This plugin requires live2dcubismcore.js to be loaded.`);var Rm=class extends Xp{constructor(e,t){var n;super(e,t),this.queueManager=new Lf,this.definitions=(n=e.expressions)??[],this.init()}isFinished(){return this.queueManager.isFinished()}getExpressionIndex(e){return this.definitions.findIndex(t=>t.Name===e)}getExpressionFile(e){return e.File}createExpression(e,t){return uf.create(e)}_setExpression(e){return this.queueManager.startMotion(e,!1,performance.now())}stopAllExpressions(){this.queueManager.stopAllMotions()}updateParameters(e,t){return this.queueManager.doUpdateMotion(e,t)}},zm=class e extends tm{constructor(t){if(super(t),!e.isValidJSON(t))throw TypeError(`Invalid JSON.`);Object.assign(this,new Pp(t))}static isValidJSON(e){var t;return!!e?.FileReferences&&typeof e.FileReferences.Moc==`string`&&(t=e.FileReferences.Textures)?.length>0&&e.FileReferences.Textures.every(e=>typeof e==`string`)}replaceFiles(e){if(super.replaceFiles(e),this.motions)for(let[t,n]of Object.entries(this.motions))for(let r=0;r{this.emit(`motion:`+t)})}isFinished(){return this.queueManager.isFinished()}_startMotion(e,t){return e.setFinishedMotionHandler(t),this.queueManager.stopAllMotions(),this.queueManager.startMotion(e,!1,performance.now())}_stopAllMotions(){this.queueManager.stopAllMotions()}createMotion(e,t,n){let r=Ff.create(e),i=new bf(e),a=(t===this.groups.idle?Wp.idleMotionFadingDuration:Wp.motionFadingDuration)/1e3;return i.getMotionFadeInTime()===void 0&&r.setFadeInTime(n.FadeInTime>0?n.FadeInTime:a),i.getMotionFadeOutTime()===void 0&&r.setFadeOutTime(n.FadeOutTime>0?n.FadeOutTime:a),r.setEffectIds(this.eyeBlinkIds,this.lipSyncIds),r}getMotionFile(e){return e.File}getMotionName(e){return e.File}getSoundFile(e){return e.Sound}updateParameters(e,t){return this.queueManager.doUpdateMotion(e,t)}destroy(){super.destroy(),this.queueManager.release(),this.queueManager=void 0}};const Vm=new Hd;var Hm=class extends lm{constructor(e,t,n){super(),this.lipSync=!0,this.breath=Ad.create(),this.renderer=new Np,this.idParamAngleX=Fp,this.idParamAngleY=Ip,this.idParamAngleZ=Lp,this.idParamEyeBallX=Rp,this.idParamEyeBallY=zp,this.idParamBodyAngleX=Bp,this.idParamBreath=Vp,this.pixelsPerUnit=1,this.centeringTransform=new sc,this.coreModel=e,this.settings=t,this.motionManager=new Bm(t,n),this.init()}init(){var e;super.init(),(e=this.settings.getEyeBlinkParameters())?.length>0&&(this.eyeBlink=Nd.create(this.settings)),this.breath.setParameters([new jd(this.idParamAngleX,0,15,6.5345,.5),new jd(this.idParamAngleY,0,8,3.5345,.5),new jd(this.idParamAngleZ,0,10,5.5345,.5),new jd(this.idParamBodyAngleX,0,4,15.5345,.5),new jd(this.idParamBreath,0,.5,3.2345,.5)]),this.renderer.initialize(this.coreModel),this.renderer.setIsPremultipliedAlpha(!0)}getSize(){return[this.coreModel.getModel().canvasinfo.CanvasWidth,this.coreModel.getModel().canvasinfo.CanvasHeight]}getLayout(){let e={};if(this.settings.layout)for(let t of Object.keys(this.settings.layout)){let n=t.charAt(0).toLowerCase()+t.slice(1);e[n]=this.settings.layout[t]}return e}setupLayout(){super.setupLayout(),this.pixelsPerUnit=this.coreModel.getModel().canvasinfo.PixelsPerUnit,this.centeringTransform.scale(this.pixelsPerUnit,this.pixelsPerUnit).translate(this.originalWidth/2,this.originalHeight/2)}updateWebGLContext(e,t){this.renderer.firstDraw=!0,this.renderer._bufferData={vertex:null,uv:null,index:null},this.renderer.startUp(e),this.renderer._clippingManager._currentFrameNo=t,this.renderer._clippingManager._maskTexture=void 0,wp.getInstance()._shaderSets=[]}bindTexture(e,t){this.renderer.bindTexture(e,t)}getHitAreaDefs(){var e,t;return(t=(e=this.settings.hitAreas)?.map(e=>({id:e.Id,name:e.Name,index:this.coreModel.getDrawableIndex(e.Id)})))??[]}getDrawableIDs(){return this.coreModel.getDrawableIds()}getDrawableIndex(e){return this.coreModel.getDrawableIndex(e)}getDrawableVertices(e){if(typeof e==`string`&&(e=this.coreModel.getDrawableIndex(e),e===-1))throw TypeError(`Unable to find drawable ID: `+e);let t=this.coreModel.getDrawableVertices(e).slice();for(let e=0;e{function n(){try{Km(),e()}catch(e){if(Wm--,Wm<0){let n=Error(`Failed to start up Cubism 4 framework.`);n.cause=e,t(n);return}Gp.log(`Cubism4`,`Startup failed, retrying 10ms later...`),setTimeout(n,10)}}n()}),Um)}function Km(e){e=Object.assign({logFunction:console.log,loggingLevel:Zd.LogLevel_Verbose},e),Xd.startUp(e),Xd.initialize()}Tm.registerRuntime({version:4,ready:Gm,test(e){return e instanceof zm||zm.isValidJSON(e)},isValidMoc(e){if(e.byteLength<4)return!1;let t=new Int8Array(e,0,4);return String.fromCharCode(...t)===`MOC3`},createModelSettings(e){return new zm(e)},createCoreModel(e){let t=sf.create(e);try{let e=t.createModel();return e.__moc=t,e}catch(e){try{t.release()}catch{}throw e}},createInternalModel(e,t,n){let r=new Hm(e,t,n),i=e;return i.__moc&&(r.__moc=i.__moc,delete i.__moc,r.once(`destroy`,qm)),r},createPhysics(e,t){return $f.create(t)},createPose(e,t){return Ld.create(t)}});function qm(){var e;(e=this.__moc)==null||e.release()}var Jm=H({__name:`Canvas`,props:{width:null,height:null,resolution:{default:2}},setup(e,{expose:t}){let n=e,r=W(),i=W(),a=W();async function o(e){Nm.registerTicker(qs),Us.add(Js),i.value=new Dd({width:n.width*n.resolution,height:n.height*n.resolution,backgroundAlpha:0,preserveDrawingBuffer:!0}),a.value=i.value.view,a.value.style.width=`100%`,a.value.style.height=`100%`,a.value.style.objectFit=`cover`,a.value.style.display=`block`,e.appendChild(i.value.view)}function s(){i.value&&i.value.renderer.resize(n.width,n.height)}K([()=>n.width,()=>n.height],()=>s()),K(()=>n.resolution,e=>{i.value&&e&&(i.value.renderer.resolution=e,s())}),$t(async()=>r.value&&await o(r.value)),tn(()=>{var e;return(e=i.value)?.destroy()});async function c(){let e=new Promise(e=>{if(!a.value||!i.value)return e(null);i.value.render(),a.value.toBlob(e)});return e}function l(){return a.value}return t({captureFrame:c,canvasElement:l}),(e,t)=>(U(),V(`div`,{ref_key:`containerRef`,ref:r,"h-full":``,"w-full":``},[sn(e.$slots,`default`,{app:i.value})],512))}}),Ym=Jm,Xm=xt((exports,t)=>{ +/*! +localForage -- Offline Storage, Improved +Version 1.10.0 +https://localforage.github.io/localForage +(c) 2013-2017 Mozilla, Apache License 2.0 +*/ +(function(n){if(typeof exports==`object`&&t!==void 0)t.exports=n();else if(typeof define==`function`&&define.amd)define([],n);else{var r;r=typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:this,r.localforage=n()}})(function(){var e,t,n;return function e(t,n,r){function i(o,s){if(!n[o]){if(!t[o]){var c=typeof wt==`function`&&wt;if(!s&&c)return c(o,!0);if(a)return a(o,!0);var l=Error(`Cannot find module '`+o+`'`);throw l.code=`MODULE_NOT_FOUND`,l}var u=n[o]={exports:{}};t[o][0].call(u.exports,function(e){var n=t[o][1][e];return i(n||e)},u,u.exports,e,t,n,r)}return n[o].exports}for(var a=typeof wt==`function`&&wt,o=0;o`u`&&e(3);var l=Promise;function u(e,t){t&&e.then(function(e){t(null,e)},function(e){t(e)})}function d(e,t,n){typeof t==`function`&&e.then(t),typeof n==`function`&&e.catch(n)}function f(e){return typeof e!=`string`&&(console.warn(e+` used as a key, but it is not a string.`),e=String(e)),e}function p(){if(arguments.length&&typeof arguments[arguments.length-1]==`function`)return arguments[arguments.length-1]}var m=`local-forage-detect-blob-support`,h=void 0,g={},_=Object.prototype.toString,v=`readonly`,y=`readwrite`;function b(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),i=0;i=43)}}).catch(function(){return!1})}function S(e){return typeof h==`boolean`?l.resolve(h):x(e).then(function(e){return h=e,h})}function C(e){var t=g[e.name],n={};n.promise=new l(function(e,t){n.resolve=e,n.reject=t}),t.deferredOperations.push(n),t.dbReady?t.dbReady=t.dbReady.then(function(){return n.promise}):t.dbReady=n.promise}function w(e){var t=g[e.name],n=t.deferredOperations.pop();if(n)return n.resolve(),n.promise}function T(e,t){var n=g[e.name],r=n.deferredOperations.pop();if(r)return r.reject(t),r.promise}function E(e,t){return new l(function(n,r){if(g[e.name]=g[e.name]||F(),e.db)if(t)C(e),e.db.close();else return n(e.db);var i=[e.name];t&&i.push(e.version);var a=o.open.apply(o,i);t&&(a.onupgradeneeded=function(t){var n=a.result;try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore(m)}catch(n){if(n.name===`ConstraintError`)console.warn(`The database "`+e.name+`" has been upgraded from version `+t.oldVersion+` to version `+t.newVersion+`, but the storage "`+e.storeName+`" already exists.`);else throw n}}),a.onerror=function(e){e.preventDefault(),r(a.error)},a.onsuccess=function(){var t=a.result;t.onversionchange=function(e){e.target.close()},n(t),w(e)}})}function D(e){return E(e,!1)}function O(e){return E(e,!0)}function k(e,t){if(!e.db)return!0;var n=!e.db.objectStoreNames.contains(e.storeName),r=e.versione.db.version;if(r&&(e.version!==t&&console.warn(`The database "`+e.name+`" can't be downgraded from version `+e.db.version+` to version `+e.version+`.`),e.version=e.db.version),i||n){if(n){var a=e.db.version+1;a>e.version&&(e.version=a)}return!0}return!1}function A(e){return new l(function(t,n){var r=new FileReader;r.onerror=n,r.onloadend=function(n){var r=btoa(n.target.result||``);t({__local_forage_encoded_blob:!0,data:r,type:e.type})},r.readAsBinaryString(e)})}function j(e){var t=b(atob(e.data));return c([t],{type:e.type})}function M(e){return e&&e.__local_forage_encoded_blob}function N(e){var t=this,n=t._initReady().then(function(){var e=g[t._dbInfo.name];if(e&&e.dbReady)return e.dbReady});return d(n,e,e),n}function ee(e){C(e);for(var t=g[e.name],n=t.forages,r=0;r0&&(!e.db||i.name===`InvalidStateError`||i.name===`NotFoundError`))return l.resolve().then(function(){if(!e.db||i.name===`NotFoundError`&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),O(e)}).then(function(){return ee(e).then(function(){P(e,t,n,r-1)})}).catch(n);n(i)}}function F(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function I(e){var t=this,n={db:null};if(e)for(var r in e)n[r]=e[r];var i=g[n.name];i||(i=F(),g[n.name]=i),i.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=N);var a=[];function o(){return l.resolve()}for(var s=0;s>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l}function ke(e){var t=new Uint8Array(e),n=``,r;for(r=0;r>2],n+=ue[(t[r]&3)<<4|t[r+1]>>4],n+=ue[(t[r+1]&15)<<2|t[r+2]>>6],n+=ue[t[r+2]&63];return t.length%3==2?n=n.substring(0,n.length-1)+`=`:t.length%3==1&&(n=n.substring(0,n.length-2)+`==`),n}function Ae(e,t){var n=``;if(e&&(n=De.call(e)),e&&(n===`[object ArrayBuffer]`||e.buffer&&De.call(e.buffer)===`[object ArrayBuffer]`)){var r,i=pe;e instanceof ArrayBuffer?(r=e,i+=he):(r=e.buffer,n===`[object Int8Array]`?i+=_e:n===`[object Uint8Array]`?i+=ve:n===`[object Uint8ClampedArray]`?i+=ye:n===`[object Int16Array]`?i+=be:n===`[object Uint16Array]`?i+=Se:n===`[object Int32Array]`?i+=xe:n===`[object Uint32Array]`?i+=Ce:n===`[object Float32Array]`?i+=we:n===`[object Float64Array]`?i+=Te:t(Error(`Failed to get type for BinaryArray`))),t(i+ke(r))}else if(n===`[object Blob]`){var a=new FileReader;a.onload=function(){var n=de+e.type+`~`+ke(this.result);t(pe+ge+n)},a.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error(`Couldn't convert value into a JSON string: `,e),t(null,n)}}function je(e){if(e.substring(0,me)!==pe)return JSON.parse(e);var t=e.substring(Ee),n=e.substring(me,Ee),r;if(n===ge&&fe.test(t)){var i=t.match(fe);r=i[1],t=t.substring(i[0].length)}var a=Oe(t);switch(n){case he:return a;case ge:return c([a],{type:r});case _e:return new Int8Array(a);case ve:return new Uint8Array(a);case ye:return new Uint8ClampedArray(a);case be:return new Int16Array(a);case Se:return new Uint16Array(a);case xe:return new Int32Array(a);case Ce:return new Uint32Array(a);case we:return new Float32Array(a);case Te:return new Float64Array(a);default:throw Error(`Unkown type: `+n)}}var Me={serialize:Ae,deserialize:je,stringToBuffer:Oe,bufferToString:ke};function Ne(e,t,n,r){e.executeSql(`CREATE TABLE IF NOT EXISTS `+t.storeName+` (id INTEGER PRIMARY KEY, key unique, value)`,[],n,r)}function Pe(e){var t=this,n={db:null};if(e)for(var r in e)n[r]=typeof e[r]==`string`?e[r]:e[r].toString();var i=new l(function(e,r){try{n.db=openDatabase(n.name,String(n.version),n.description,n.size)}catch(e){return r(e)}n.db.transaction(function(i){Ne(i,n,function(){t._dbInfo=n,e()},function(e,t){r(t)})},r)});return n.serializer=Me,i}function Fe(e,t,n,r,i,a){e.executeSql(n,r,i,function(e,o){o.code===o.SYNTAX_ERR?e.executeSql(`SELECT name FROM sqlite_master WHERE type='table' AND name = ?`,[t.storeName],function(e,s){s.rows.length?a(e,o):Ne(e,t,function(){e.executeSql(n,r,i,a)},a)},a):a(e,o)},a)}function Ie(e,t){var n=this;e=f(e);var r=new l(function(t,r){n.ready().then(function(){var i=n._dbInfo;i.db.transaction(function(n){Fe(n,i,`SELECT * FROM `+i.storeName+` WHERE key = ? LIMIT 1`,[e],function(e,n){var r=n.rows.length?n.rows.item(0).value:null;r&&=i.serializer.deserialize(r),t(r)},function(e,t){r(t)})})}).catch(r)});return u(r,t),r}function Le(e,t){var n=this,r=new l(function(t,r){n.ready().then(function(){var i=n._dbInfo;i.db.transaction(function(n){Fe(n,i,`SELECT * FROM `+i.storeName,[],function(n,r){for(var a=r.rows,o=a.length,s=0;s0){a(Re.apply(i,[e,s,n,r-1]));return}o(t)}})})}).catch(o)});return u(a,n),a}function ze(e,t,n){return Re.apply(this,[e,t,n,1])}function Be(e,t){var n=this;e=f(e);var r=new l(function(t,r){n.ready().then(function(){var i=n._dbInfo;i.db.transaction(function(n){Fe(n,i,`DELETE FROM `+i.storeName+` WHERE key = ?`,[e],function(){t()},function(e,t){r(t)})})}).catch(r)});return u(r,t),r}function Ve(e){var t=this,n=new l(function(e,n){t.ready().then(function(){var r=t._dbInfo;r.db.transaction(function(t){Fe(t,r,`DELETE FROM `+r.storeName,[],function(){e()},function(e,t){n(t)})})}).catch(n)});return u(n,e),n}function He(e){var t=this,n=new l(function(e,n){t.ready().then(function(){var r=t._dbInfo;r.db.transaction(function(t){Fe(t,r,`SELECT COUNT(key) as c FROM `+r.storeName,[],function(t,n){var r=n.rows.item(0).c;e(r)},function(e,t){n(t)})})}).catch(n)});return u(n,e),n}function Ue(e,t){var n=this,r=new l(function(t,r){n.ready().then(function(){var i=n._dbInfo;i.db.transaction(function(n){Fe(n,i,`SELECT key FROM `+i.storeName+` WHERE id = ? LIMIT 1`,[e+1],function(e,n){var r=n.rows.length?n.rows.item(0).key:null;t(r)},function(e,t){r(t)})})}).catch(r)});return u(r,t),r}function We(e){var t=this,n=new l(function(e,n){t.ready().then(function(){var r=t._dbInfo;r.db.transaction(function(t){Fe(t,r,`SELECT key FROM `+r.storeName,[],function(t,n){for(var r=[],i=0;i '__WebKitDatabaseInfoTable__'`,[],function(n,r){for(var i=[],a=0;a0}function Qe(e){var t=this,n={};if(e)for(var r in e)n[r]=e[r];return n.keyPrefix=Ye(e,t._defaultConfig),Ze()?(t._dbInfo=n,n.serializer=Me,l.resolve()):l.reject()}function $e(e){var t=this,n=t.ready().then(function(){for(var e=t._dbInfo.keyPrefix,n=localStorage.length-1;n>=0;n--){var r=localStorage.key(n);r.indexOf(e)===0&&localStorage.removeItem(r)}});return u(n,e),n}function et(e,t){var n=this;e=f(e);var r=n.ready().then(function(){var t=n._dbInfo,r=localStorage.getItem(t.keyPrefix+e);return r&&=t.serializer.deserialize(r),r});return u(r,t),r}function tt(e,t){var n=this,r=n.ready().then(function(){for(var t=n._dbInfo,r=t.keyPrefix,i=r.length,a=localStorage.length,o=1,s=0;s=0;t--){var n=localStorage.key(t);n.indexOf(e)===0&&localStorage.removeItem(n)}}):l.reject(`Invalid arguments`),u(i,t),i}var ct={_driver:`localStorageWrapper`,_initStorage:Qe,_support:Je(),iterate:tt,getItem:et,setItem:ot,removeItem:at,clear:$e,length:it,key:nt,keys:rt,dropInstance:st},lt=function(e,t){return e===t||typeof e==`number`&&typeof t==`number`&&isNaN(e)&&isNaN(t)},ut=function(e,t){for(var n=e.length,r=0;r=0;f--){var p=d[f],m=this.recursiveFindHit(e,p,n,r,c);if(m){if(!p.parent)continue;c=!1,m&&(e.target&&(r=!1),s=!0)}}return i&&(r&&!e.target&&!t.hitArea&&t.containsPoint&&t.containsPoint(o)&&(s=!0),t.interactive&&(s&&!e.target&&(e.target=t),n&&n(e,t,!!s))),s},e.prototype.findHit=function(e,t,n,r){this.recursiveFindHit(e,t,n,r,!1)},e}(),rh={interactive:!1,interactiveChildren:!0,hitArea:null,get buttonMode(){return this.cursor===`pointer`},set buttonMode(e){e?this.cursor=`pointer`:this.cursor===`pointer`&&(this.cursor=null)},cursor:null,get trackedPointers(){return this._trackedPointers===void 0&&(this._trackedPointers={}),this._trackedPointers},_trackedPointers:void 0};Sd.mixin(rh);var ih=1,ah={target:null,data:{global:null}},oh=function(e){$m(t,e);function t(t,n){var r=e.call(this)||this;return n||={},r.renderer=t,r.autoPreventDefault=n.autoPreventDefault===void 0?!0:n.autoPreventDefault,r.interactionFrequency=n.interactionFrequency||10,r.mouse=new Zm,r.mouse.identifier=ih,r.mouse.global.set(-999999),r.activeInteractionData={},r.activeInteractionData[ih]=r.mouse,r.interactionDataPool=[],r.eventData=new eh,r.interactionDOMElement=null,r.moveWhenInside=!1,r.eventsAdded=!1,r.tickerAdded=!1,r.mouseOverRenderer=!(`PointerEvent`in globalThis),r.supportsTouchEvents=`ontouchstart`in globalThis,r.supportsPointerEvents=!!globalThis.PointerEvent,r.onPointerUp=r.onPointerUp.bind(r),r.processPointerUp=r.processPointerUp.bind(r),r.onPointerCancel=r.onPointerCancel.bind(r),r.processPointerCancel=r.processPointerCancel.bind(r),r.onPointerDown=r.onPointerDown.bind(r),r.processPointerDown=r.processPointerDown.bind(r),r.onPointerMove=r.onPointerMove.bind(r),r.processPointerMove=r.processPointerMove.bind(r),r.onPointerOut=r.onPointerOut.bind(r),r.processPointerOverOut=r.processPointerOverOut.bind(r),r.onPointerOver=r.onPointerOver.bind(r),r.cursorStyles={default:`inherit`,pointer:`pointer`},r.currentCursorMode=null,r.cursor=null,r.resolution=1,r.delayedEvents=[],r.search=new nh,r._tempDisplayObject=new Cd,r._eventListenerOptions={capture:!0,passive:!1},r._useSystemTicker=n.useSystemTicker===void 0?!0:n.useSystemTicker,r.setTargetElement(r.renderer.view,r.renderer.resolution),r}return Object.defineProperty(t.prototype,`useSystemTicker`,{get:function(){return this._useSystemTicker},set:function(e){this._useSystemTicker=e,e?this.addTickerListener():this.removeTickerListener()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`lastObjectRendered`,{get:function(){return this.renderer._lastObjectRendered||this._tempDisplayObject},enumerable:!1,configurable:!0}),t.prototype.hitTest=function(e,t){return ah.target=null,ah.data.global=e,t||=this.lastObjectRendered,this.processInteractive(ah,t,null,!0),ah.target},t.prototype.setTargetElement=function(e,t){t===void 0&&(t=1),this.removeTickerListener(),this.removeEvents(),this.interactionDOMElement=e,this.resolution=t,this.addEvents(),this.addTickerListener()},t.prototype.addTickerListener=function(){this.tickerAdded||!this.interactionDOMElement||!this._useSystemTicker||(qs.system.add(this.tickerUpdate,this,Gs.INTERACTION),this.tickerAdded=!0)},t.prototype.removeTickerListener=function(){this.tickerAdded&&(qs.system.remove(this.tickerUpdate,this),this.tickerAdded=!1)},t.prototype.addEvents=function(){if(!(this.eventsAdded||!this.interactionDOMElement)){var e=this.interactionDOMElement.style;globalThis.navigator.msPointerEnabled?(e.msContentZooming=`none`,e.msTouchAction=`none`):this.supportsPointerEvents&&(e.touchAction=`none`),this.supportsPointerEvents?(globalThis.document.addEventListener(`pointermove`,this.onPointerMove,this._eventListenerOptions),this.interactionDOMElement.addEventListener(`pointerdown`,this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.addEventListener(`pointerleave`,this.onPointerOut,this._eventListenerOptions),this.interactionDOMElement.addEventListener(`pointerover`,this.onPointerOver,this._eventListenerOptions),globalThis.addEventListener(`pointercancel`,this.onPointerCancel,this._eventListenerOptions),globalThis.addEventListener(`pointerup`,this.onPointerUp,this._eventListenerOptions)):(globalThis.document.addEventListener(`mousemove`,this.onPointerMove,this._eventListenerOptions),this.interactionDOMElement.addEventListener(`mousedown`,this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.addEventListener(`mouseout`,this.onPointerOut,this._eventListenerOptions),this.interactionDOMElement.addEventListener(`mouseover`,this.onPointerOver,this._eventListenerOptions),globalThis.addEventListener(`mouseup`,this.onPointerUp,this._eventListenerOptions)),this.supportsTouchEvents&&(this.interactionDOMElement.addEventListener(`touchstart`,this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.addEventListener(`touchcancel`,this.onPointerCancel,this._eventListenerOptions),this.interactionDOMElement.addEventListener(`touchend`,this.onPointerUp,this._eventListenerOptions),this.interactionDOMElement.addEventListener(`touchmove`,this.onPointerMove,this._eventListenerOptions)),this.eventsAdded=!0}},t.prototype.removeEvents=function(){if(!(!this.eventsAdded||!this.interactionDOMElement)){var e=this.interactionDOMElement.style;globalThis.navigator.msPointerEnabled?(e.msContentZooming=``,e.msTouchAction=``):this.supportsPointerEvents&&(e.touchAction=``),this.supportsPointerEvents?(globalThis.document.removeEventListener(`pointermove`,this.onPointerMove,this._eventListenerOptions),this.interactionDOMElement.removeEventListener(`pointerdown`,this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.removeEventListener(`pointerleave`,this.onPointerOut,this._eventListenerOptions),this.interactionDOMElement.removeEventListener(`pointerover`,this.onPointerOver,this._eventListenerOptions),globalThis.removeEventListener(`pointercancel`,this.onPointerCancel,this._eventListenerOptions),globalThis.removeEventListener(`pointerup`,this.onPointerUp,this._eventListenerOptions)):(globalThis.document.removeEventListener(`mousemove`,this.onPointerMove,this._eventListenerOptions),this.interactionDOMElement.removeEventListener(`mousedown`,this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.removeEventListener(`mouseout`,this.onPointerOut,this._eventListenerOptions),this.interactionDOMElement.removeEventListener(`mouseover`,this.onPointerOver,this._eventListenerOptions),globalThis.removeEventListener(`mouseup`,this.onPointerUp,this._eventListenerOptions)),this.supportsTouchEvents&&(this.interactionDOMElement.removeEventListener(`touchstart`,this.onPointerDown,this._eventListenerOptions),this.interactionDOMElement.removeEventListener(`touchcancel`,this.onPointerCancel,this._eventListenerOptions),this.interactionDOMElement.removeEventListener(`touchend`,this.onPointerUp,this._eventListenerOptions),this.interactionDOMElement.removeEventListener(`touchmove`,this.onPointerMove,this._eventListenerOptions)),this.interactionDOMElement=null,this.eventsAdded=!1}},t.prototype.tickerUpdate=function(e){this._deltaTime+=e,!(this._deltaTime0&&(a=e.composedPath()[0]);for(var o=a===this.interactionDOMElement?``:`outside`,s=0;s 0.0) { + c.rgb /= c.a; + + vec3 rgb = pow(c.rgb, vec3(1. / gamma)); + rgb = mix(vec3(.5), mix(vec3(dot(vec3(.2125, .7154, .0721), rgb)), rgb, saturation), contrast); + rgb.r *= red; + rgb.g *= green; + rgb.b *= blue; + c.rgb = rgb * brightness; + + c.rgb *= c.a; + } + + gl_FragColor = c * alpha; +} +`,dh=function(e){ch(t,e);function t(t){var n=e.call(this,lh,uh)||this;return n.gamma=1,n.saturation=1,n.contrast=1,n.brightness=1,n.red=1,n.green=1,n.blue=1,n.alpha=1,Object.assign(n,t),n}return t.prototype.apply=function(e,t,n,r){this.uniforms.gamma=Math.max(this.gamma,1e-4),this.uniforms.saturation=this.saturation,this.uniforms.contrast=this.contrast,this.uniforms.brightness=this.brightness,this.uniforms.red=this.red,this.uniforms.green=this.green,this.uniforms.blue=this.blue,this.uniforms.alpha=this.alpha,e.applyFilter(this,t,n,r)},t}(ou),fh=function(e,t){return fh=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},fh(e,t)};function ph(e,t){fh(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var mh=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,hh=` +varying vec2 vTextureCoord; +uniform sampler2D uSampler; + +uniform vec2 uOffset; + +void main(void) +{ + vec4 color = vec4(0.0); + + // Sample top left pixel + color += texture2D(uSampler, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y)); + + // Sample top right pixel + color += texture2D(uSampler, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y)); + + // Sample bottom right pixel + color += texture2D(uSampler, vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y)); + + // Sample bottom left pixel + color += texture2D(uSampler, vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y)); + + // Average + color *= 0.25; + + gl_FragColor = color; +}`,gh=` +varying vec2 vTextureCoord; +uniform sampler2D uSampler; + +uniform vec2 uOffset; +uniform vec4 filterClamp; + +void main(void) +{ + vec4 color = vec4(0.0); + + // Sample top left pixel + color += texture2D(uSampler, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y + uOffset.y), filterClamp.xy, filterClamp.zw)); + + // Sample top right pixel + color += texture2D(uSampler, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y + uOffset.y), filterClamp.xy, filterClamp.zw)); + + // Sample bottom right pixel + color += texture2D(uSampler, clamp(vec2(vTextureCoord.x + uOffset.x, vTextureCoord.y - uOffset.y), filterClamp.xy, filterClamp.zw)); + + // Sample bottom left pixel + color += texture2D(uSampler, clamp(vec2(vTextureCoord.x - uOffset.x, vTextureCoord.y - uOffset.y), filterClamp.xy, filterClamp.zw)); + + // Average + color *= 0.25; + + gl_FragColor = color; +} +`,_h=function(e){ph(t,e);function t(t,n,r){t===void 0&&(t=4),n===void 0&&(n=3),r===void 0&&(r=!1);var i=e.call(this,mh,r?gh:hh)||this;return i._kernels=[],i._blur=4,i._quality=3,i.uniforms.uOffset=new Float32Array(2),i._pixelSize=new $s,i.pixelSize=1,i._clamp=r,Array.isArray(t)?i.kernels=t:(i._blur=t,i.quality=n),i}return t.prototype.apply=function(e,t,n,r){var i=this._pixelSize.x/t._frame.width,a=this._pixelSize.y/t._frame.height,o;if(this._quality===1||this._blur===0)o=this._kernels[0]+.5,this.uniforms.uOffset[0]=o*i,this.uniforms.uOffset[1]=o*a,e.applyFilter(this,t,n,r);else{for(var s=e.getFilterTexture(),c=t,l=s,u=void 0,d=this._quality-1,f=0;f0)for(var r=e,i=e/t,a=1;a0?(this._kernels=e,this._quality=e.length,this._blur=Math.max.apply(Math,e)):(this._kernels=[0],this._quality=1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`clamp`,{get:function(){return this._clamp},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`pixelSize`,{get:function(){return this._pixelSize},set:function(e){typeof e==`number`?(this._pixelSize.x=e,this._pixelSize.y=e):Array.isArray(e)?(this._pixelSize.x=e[0],this._pixelSize.y=e[1]):e instanceof $s?(this._pixelSize.x=e.x,this._pixelSize.y=e.y):(this._pixelSize.x=1,this._pixelSize.y=1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`quality`,{get:function(){return this._quality},set:function(e){this._quality=Math.max(1,Math.round(e)),this._generateKernels()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`blur`,{get:function(){return this._blur},set:function(e){this._blur=e,this._generateKernels()},enumerable:!1,configurable:!0}),t}(ou),vh=function(e,t){return vh=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},vh(e,t)};function yh(e,t){vh(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var bh=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,xh=` +uniform sampler2D uSampler; +varying vec2 vTextureCoord; + +uniform float threshold; + +void main() { + vec4 color = texture2D(uSampler, vTextureCoord); + + // A simple & fast algorithm for getting brightness. + // It's inaccuracy , but good enought for this feature. + float _max = max(max(color.r, color.g), color.b); + float _min = min(min(color.r, color.g), color.b); + float brightness = (_max + _min) * 0.5; + + if(brightness > threshold) { + gl_FragColor = color; + } else { + gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); + } +} +`,Sh=function(e){yh(t,e);function t(t){t===void 0&&(t=.5);var n=e.call(this,bh,xh)||this;return n.threshold=t,n}return Object.defineProperty(t.prototype,`threshold`,{get:function(){return this.uniforms.threshold},set:function(e){this.uniforms.threshold=e},enumerable:!1,configurable:!0}),t}(ou),Ch=`uniform sampler2D uSampler; +varying vec2 vTextureCoord; + +uniform sampler2D bloomTexture; +uniform float bloomScale; +uniform float brightness; + +void main() { + vec4 color = texture2D(uSampler, vTextureCoord); + color.rgb *= brightness; + vec4 bloomColor = vec4(texture2D(bloomTexture, vTextureCoord).rgb, 0.0); + bloomColor.rgb *= bloomScale; + gl_FragColor = color + bloomColor; +} +`,wh=function(e){yh(t,e);function t(n){var r=e.call(this,bh,Ch)||this;r.bloomScale=1,r.brightness=1,r._resolution=Xo.FILTER_RESOLUTION,typeof n==`number`&&(n={threshold:n});var i=Object.assign(t.defaults,n);r.bloomScale=i.bloomScale,r.brightness=i.brightness;var a=i.kernels,o=i.blur,s=i.quality,c=i.pixelSize,l=i.resolution;return r._extractFilter=new Sh(i.threshold),r._extractFilter.resolution=l,r._blurFilter=a?new _h(a):new _h(o,s),r.pixelSize=c,r.resolution=l,r}return t.prototype.apply=function(e,t,n,r,i){var a=e.getFilterTexture();this._extractFilter.apply(e,t,a,1,i);var o=e.getFilterTexture();this._blurFilter.apply(e,a,o,1),this.uniforms.bloomScale=this.bloomScale,this.uniforms.brightness=this.brightness,this.uniforms.bloomTexture=o,e.applyFilter(this,t,n,r),e.returnFilterTexture(o),e.returnFilterTexture(a)},Object.defineProperty(t.prototype,`resolution`,{get:function(){return this._resolution},set:function(e){this._resolution=e,this._extractFilter&&(this._extractFilter.resolution=e),this._blurFilter&&(this._blurFilter.resolution=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`threshold`,{get:function(){return this._extractFilter.threshold},set:function(e){this._extractFilter.threshold=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`kernels`,{get:function(){return this._blurFilter.kernels},set:function(e){this._blurFilter.kernels=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`blur`,{get:function(){return this._blurFilter.blur},set:function(e){this._blurFilter.blur=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`quality`,{get:function(){return this._blurFilter.quality},set:function(e){this._blurFilter.quality=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`pixelSize`,{get:function(){return this._blurFilter.pixelSize},set:function(e){this._blurFilter.pixelSize=e},enumerable:!1,configurable:!0}),t.defaults={threshold:.5,bloomScale:1,brightness:1,kernels:null,blur:8,quality:4,pixelSize:1,resolution:Xo.FILTER_RESOLUTION},t}(ou),Th=function(e,t){return Th=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Th(e,t)};function Eh(e,t){Th(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Dh=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,Oh=`varying vec2 vTextureCoord; + +uniform vec4 filterArea; +uniform float pixelSize; +uniform sampler2D uSampler; + +vec2 mapCoord( vec2 coord ) +{ + coord *= filterArea.xy; + coord += filterArea.zw; + + return coord; +} + +vec2 unmapCoord( vec2 coord ) +{ + coord -= filterArea.zw; + coord /= filterArea.xy; + + return coord; +} + +vec2 pixelate(vec2 coord, vec2 size) +{ + return floor( coord / size ) * size; +} + +vec2 getMod(vec2 coord, vec2 size) +{ + return mod( coord , size) / size; +} + +float character(float n, vec2 p) +{ + p = floor(p*vec2(4.0, -4.0) + 2.5); + + if (clamp(p.x, 0.0, 4.0) == p.x) + { + if (clamp(p.y, 0.0, 4.0) == p.y) + { + if (int(mod(n/exp2(p.x + 5.0*p.y), 2.0)) == 1) return 1.0; + } + } + return 0.0; +} + +void main() +{ + vec2 coord = mapCoord(vTextureCoord); + + // get the rounded color.. + vec2 pixCoord = pixelate(coord, vec2(pixelSize)); + pixCoord = unmapCoord(pixCoord); + + vec4 color = texture2D(uSampler, pixCoord); + + // determine the character to use + float gray = (color.r + color.g + color.b) / 3.0; + + float n = 65536.0; // . + if (gray > 0.2) n = 65600.0; // : + if (gray > 0.3) n = 332772.0; // * + if (gray > 0.4) n = 15255086.0; // o + if (gray > 0.5) n = 23385164.0; // & + if (gray > 0.6) n = 15252014.0; // 8 + if (gray > 0.7) n = 13199452.0; // @ + if (gray > 0.8) n = 11512810.0; // # + + // get the mod.. + vec2 modd = getMod(coord, vec2(pixelSize)); + + gl_FragColor = color * character( n, vec2(-1.0) + modd * 2.0); + +} +`,kh=function(e){Eh(t,e);function t(t){t===void 0&&(t=8);var n=e.call(this,Dh,Oh)||this;return n.size=t,n}return Object.defineProperty(t.prototype,`size`,{get:function(){return this.uniforms.pixelSize},set:function(e){this.uniforms.pixelSize=e},enumerable:!1,configurable:!0}),t}(ou),Ah=function(e,t){return Ah=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Ah(e,t)};function jh(e,t){Ah(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Mh=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,Nh=`precision mediump float; + +varying vec2 vTextureCoord; +uniform sampler2D uSampler; +uniform vec4 filterArea; + +uniform float transformX; +uniform float transformY; +uniform vec3 lightColor; +uniform float lightAlpha; +uniform vec3 shadowColor; +uniform float shadowAlpha; + +void main(void) { + vec2 transform = vec2(1.0 / filterArea) * vec2(transformX, transformY); + vec4 color = texture2D(uSampler, vTextureCoord); + float light = texture2D(uSampler, vTextureCoord - transform).a; + float shadow = texture2D(uSampler, vTextureCoord + transform).a; + + color.rgb = mix(color.rgb, lightColor, clamp((color.a - light) * lightAlpha, 0.0, 1.0)); + color.rgb = mix(color.rgb, shadowColor, clamp((color.a - shadow) * shadowAlpha, 0.0, 1.0)); + gl_FragColor = vec4(color.rgb * color.a, color.a); +} +`,Ph=function(e){jh(t,e);function t(t){var n=e.call(this,Mh,Nh)||this;return n._thickness=2,n._angle=0,n.uniforms.lightColor=new Float32Array(3),n.uniforms.shadowColor=new Float32Array(3),Object.assign(n,{rotation:45,thickness:2,lightColor:16777215,lightAlpha:.7,shadowColor:0,shadowAlpha:.7},t),n.padding=1,n}return t.prototype._updateTransform=function(){this.uniforms.transformX=this._thickness*Math.cos(this._angle),this.uniforms.transformY=this._thickness*Math.sin(this._angle)},Object.defineProperty(t.prototype,`rotation`,{get:function(){return this._angle/Zs},set:function(e){this._angle=e*Zs,this._updateTransform()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`thickness`,{get:function(){return this._thickness},set:function(e){this._thickness=e,this._updateTransform()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`lightColor`,{get:function(){return bs(this.uniforms.lightColor)},set:function(e){vs(e,this.uniforms.lightColor)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`lightAlpha`,{get:function(){return this.uniforms.lightAlpha},set:function(e){this.uniforms.lightAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`shadowColor`,{get:function(){return bs(this.uniforms.shadowColor)},set:function(e){vs(e,this.uniforms.shadowColor)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`shadowAlpha`,{get:function(){return this.uniforms.shadowAlpha},set:function(e){this.uniforms.shadowAlpha=e},enumerable:!1,configurable:!0}),t}(ou),Fh=function(e,t){return Fh=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},Fh(e,t)};function Ih(e,t){Fh(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Lh=`varying vec2 vTextureCoord; + +uniform sampler2D uSampler; +uniform float uAlpha; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha; +} +`,Rh=function(e){Ih(t,e);function t(t){t===void 0&&(t=1);var n=e.call(this,nd,Lh,{uAlpha:1})||this;return n.alpha=t,n}return Object.defineProperty(t.prototype,`alpha`,{get:function(){return this.uniforms.uAlpha},set:function(e){this.uniforms.uAlpha=e},enumerable:!1,configurable:!0}),t}(ou),zh=function(e,t){return zh=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},zh(e,t)};function Bh(e,t){zh(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Vh=` + attribute vec2 aVertexPosition; + + uniform mat3 projectionMatrix; + + uniform float strength; + + varying vec2 vBlurTexCoords[%size%]; + + uniform vec4 inputSize; + uniform vec4 outputFrame; + + vec4 filterVertexPosition( void ) + { + vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy; + + return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0); + } + + vec2 filterTextureCoord( void ) + { + return aVertexPosition * (outputFrame.zw * inputSize.zw); + } + + void main(void) + { + gl_Position = filterVertexPosition(); + + vec2 textureCoord = filterTextureCoord(); + %blur% + }`;function Hh(e,t){var n=Math.ceil(e/2),r=Vh,i=``,a;a=t?`vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);`:`vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);`;for(var o=0;o=n&&(o=e-s-1),c=c.replace(`%value%`,t[o].toString()),i+=c,i+=` +`}return r=r.replace(`%blur%`,i),r=r.replace(`%size%`,e.toString()),r}var Kh=function(e){Bh(t,e);function t(t,n,r,i,a){n===void 0&&(n=8),r===void 0&&(r=4),i===void 0&&(i=Xo.FILTER_RESOLUTION),a===void 0&&(a=5);var o=this,s=Hh(a,t),c=Gh(a);return o=e.call(this,s,c)||this,o.horizontal=t,o.resolution=i,o._quality=0,o.quality=r,o.blur=n,o}return t.prototype.apply=function(e,t,n,r){if(n?this.horizontal?this.uniforms.strength=1/n.width*(n.width/t.width):this.uniforms.strength=1/n.height*(n.height/t.height):this.horizontal?this.uniforms.strength=1/e.renderer.width*(e.renderer.width/t.width):this.uniforms.strength=1/e.renderer.height*(e.renderer.height/t.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)e.applyFilter(this,t,n,r);else{var i=e.getFilterTexture(),a=e.renderer,o=t,s=i;this.state.blend=!1,e.applyFilter(this,o,s,xo.CLEAR);for(var c=1;c 0.0) { + coord *= mix(1.0, smoothstep(0.0, radius / distance, percent), strength * 0.75); + } else { + coord *= mix(1.0, pow(percent, 1.0 + strength * 0.75) * radius / distance, 1.0 - percent); + } + } + coord += center * dimensions.xy; + coord /= filterArea.xy; + vec2 clampedCoord = clamp(coord, filterClamp.xy, filterClamp.zw); + vec4 color = texture2D(uSampler, clampedCoord); + if (coord != clampedCoord) { + color *= max(0.0, 1.0 - length(coord - clampedCoord)); + } + + gl_FragColor = color; +} +`,tg=function(e){Qh(t,e);function t(n){var r=e.call(this,$h,eg)||this;return r.uniforms.dimensions=new Float32Array(2),Object.assign(r,t.defaults,n),r}return t.prototype.apply=function(e,t,n,r){var i=t.filterFrame,a=i.width,o=i.height;this.uniforms.dimensions[0]=a,this.uniforms.dimensions[1]=o,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`radius`,{get:function(){return this.uniforms.radius},set:function(e){this.uniforms.radius=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`strength`,{get:function(){return this.uniforms.strength},set:function(e){this.uniforms.strength=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`center`,{get:function(){return this.uniforms.center},set:function(e){this.uniforms.center=e},enumerable:!1,configurable:!0}),t.defaults={center:[.5,.5],radius:100,strength:1},t}(ou),ng=function(e,t){return ng=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},ng(e,t)};function rg(e,t){ng(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var ig=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,ag=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; +uniform sampler2D colorMap; +uniform float _mix; +uniform float _size; +uniform float _sliceSize; +uniform float _slicePixelSize; +uniform float _sliceInnerSize; +void main() { + vec4 color = texture2D(uSampler, vTextureCoord.xy); + + vec4 adjusted; + if (color.a > 0.0) { + color.rgb /= color.a; + float innerWidth = _size - 1.0; + float zSlice0 = min(floor(color.b * innerWidth), innerWidth); + float zSlice1 = min(zSlice0 + 1.0, innerWidth); + float xOffset = _slicePixelSize * 0.5 + color.r * _sliceInnerSize; + float s0 = xOffset + (zSlice0 * _sliceSize); + float s1 = xOffset + (zSlice1 * _sliceSize); + float yOffset = _sliceSize * 0.5 + color.g * (1.0 - _sliceSize); + vec4 slice0Color = texture2D(colorMap, vec2(s0,yOffset)); + vec4 slice1Color = texture2D(colorMap, vec2(s1,yOffset)); + float zOffset = fract(color.b * innerWidth); + adjusted = mix(slice0Color, slice1Color, zOffset); + + color.rgb *= color.a; + } + gl_FragColor = vec4(mix(color, adjusted, _mix).rgb, color.a); + +}`,og=function(e){rg(t,e);function t(t,n,r){n===void 0&&(n=!1),r===void 0&&(r=1);var i=e.call(this,ig,ag)||this;return i.mix=1,i._size=0,i._sliceSize=0,i._slicePixelSize=0,i._sliceInnerSize=0,i._nearest=!1,i._scaleMode=null,i._colorMap=null,i._scaleMode=null,i.nearest=n,i.mix=r,i.colorMap=t,i}return t.prototype.apply=function(e,t,n,r){this.uniforms._mix=this.mix,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`colorSize`,{get:function(){return this._size},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`colorMap`,{get:function(){return this._colorMap},set:function(e){var t;e&&(e instanceof Wc||(e=Wc.from(e)),(t=e)?.baseTexture&&(e.baseTexture.scaleMode=this._scaleMode,e.baseTexture.mipmap=yo.OFF,this._size=e.height,this._sliceSize=1/this._size,this._slicePixelSize=this._sliceSize/this._size,this._sliceInnerSize=this._slicePixelSize*(this._size-1),this.uniforms._size=this._size,this.uniforms._sliceSize=this._sliceSize,this.uniforms._slicePixelSize=this._slicePixelSize,this.uniforms._sliceInnerSize=this._sliceInnerSize,this.uniforms.colorMap=e),this._colorMap=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`nearest`,{get:function(){return this._nearest},set:function(e){this._nearest=e,this._scaleMode=e?_o.NEAREST:_o.LINEAR;var t=this._colorMap;t&&t.baseTexture&&(t.baseTexture._glTextures={},t.baseTexture.scaleMode=this._scaleMode,t.baseTexture.mipmap=yo.OFF,t._updateID++,t.baseTexture.emit(`update`,t.baseTexture))},enumerable:!1,configurable:!0}),t.prototype.updateColorMap=function(){var e=this._colorMap;e&&e.baseTexture&&(e._updateID++,e.baseTexture.emit(`update`,e.baseTexture),this.colorMap=e)},t.prototype.destroy=function(t){t===void 0&&(t=!1),this._colorMap&&this._colorMap.destroy(t),e.prototype.destroy.call(this)},t}(ou),sg=function(e,t){return sg=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},sg(e,t)};function cg(e,t){sg(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var lg=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,ug=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; +uniform vec3 color; +uniform float alpha; + +void main(void) { + vec4 currentColor = texture2D(uSampler, vTextureCoord); + gl_FragColor = vec4(mix(currentColor.rgb, color.rgb, currentColor.a * alpha), currentColor.a); +} +`,dg=function(e){cg(t,e);function t(t,n){t===void 0&&(t=0),n===void 0&&(n=1);var r=e.call(this,lg,ug)||this;return r._color=0,r._alpha=1,r.uniforms.color=new Float32Array(3),r.color=t,r.alpha=n,r}return Object.defineProperty(t.prototype,`color`,{get:function(){return this._color},set:function(e){var t=this.uniforms.color;typeof e==`number`?(vs(e,t),this._color=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],this._color=bs(t))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`alpha`,{get:function(){return this._alpha},set:function(e){this.uniforms.alpha=e,this._alpha=e},enumerable:!1,configurable:!0}),t}(ou),fg=function(e,t){return fg=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},fg(e,t)};function pg(e,t){fg(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var mg=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,hg=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; +uniform vec3 originalColor; +uniform vec3 newColor; +uniform float epsilon; +void main(void) { + vec4 currentColor = texture2D(uSampler, vTextureCoord); + vec3 colorDiff = originalColor - (currentColor.rgb / max(currentColor.a, 0.0000000001)); + float colorDistance = length(colorDiff); + float doReplace = step(colorDistance, epsilon); + gl_FragColor = vec4(mix(currentColor.rgb, (newColor + colorDiff) * currentColor.a, doReplace), currentColor.a); +} +`,gg=function(e){pg(t,e);function t(t,n,r){t===void 0&&(t=16711680),n===void 0&&(n=0),r===void 0&&(r=.4);var i=e.call(this,mg,hg)||this;return i._originalColor=16711680,i._newColor=0,i.uniforms.originalColor=new Float32Array(3),i.uniforms.newColor=new Float32Array(3),i.originalColor=t,i.newColor=n,i.epsilon=r,i}return Object.defineProperty(t.prototype,`originalColor`,{get:function(){return this._originalColor},set:function(e){var t=this.uniforms.originalColor;typeof e==`number`?(vs(e,t),this._originalColor=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],this._originalColor=bs(t))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`newColor`,{get:function(){return this._newColor},set:function(e){var t=this.uniforms.newColor;typeof e==`number`?(vs(e,t),this._newColor=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],this._newColor=bs(t))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`epsilon`,{get:function(){return this.uniforms.epsilon},set:function(e){this.uniforms.epsilon=e},enumerable:!1,configurable:!0}),t}(ou),_g=function(e,t){return _g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},_g(e,t)};function vg(e,t){_g(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var yg=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,bg=`precision mediump float; + +varying mediump vec2 vTextureCoord; + +uniform sampler2D uSampler; +uniform vec2 texelSize; +uniform float matrix[9]; + +void main(void) +{ + vec4 c11 = texture2D(uSampler, vTextureCoord - texelSize); // top left + vec4 c12 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - texelSize.y)); // top center + vec4 c13 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y - texelSize.y)); // top right + + vec4 c21 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y)); // mid left + vec4 c22 = texture2D(uSampler, vTextureCoord); // mid center + vec4 c23 = texture2D(uSampler, vec2(vTextureCoord.x + texelSize.x, vTextureCoord.y)); // mid right + + vec4 c31 = texture2D(uSampler, vec2(vTextureCoord.x - texelSize.x, vTextureCoord.y + texelSize.y)); // bottom left + vec4 c32 = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + texelSize.y)); // bottom center + vec4 c33 = texture2D(uSampler, vTextureCoord + texelSize); // bottom right + + gl_FragColor = + c11 * matrix[0] + c12 * matrix[1] + c13 * matrix[2] + + c21 * matrix[3] + c22 * matrix[4] + c23 * matrix[5] + + c31 * matrix[6] + c32 * matrix[7] + c33 * matrix[8]; + + gl_FragColor.a = c22.a; +} +`,xg=function(e){vg(t,e);function t(t,n,r){n===void 0&&(n=200),r===void 0&&(r=200);var i=e.call(this,yg,bg)||this;return i.uniforms.texelSize=new Float32Array(2),i.uniforms.matrix=new Float32Array(9),t!==void 0&&(i.matrix=t),i.width=n,i.height=r,i}return Object.defineProperty(t.prototype,`matrix`,{get:function(){return this.uniforms.matrix},set:function(e){var t=this;e.forEach(function(e,n){t.uniforms.matrix[n]=e})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`width`,{get:function(){return 1/this.uniforms.texelSize[0]},set:function(e){this.uniforms.texelSize[0]=1/e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`height`,{get:function(){return 1/this.uniforms.texelSize[1]},set:function(e){this.uniforms.texelSize[1]=1/e},enumerable:!1,configurable:!0}),t}(ou),Sg=function(e,t){return Sg=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Sg(e,t)};function Cg(e,t){Sg(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var wg=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,Tg=`precision mediump float; + +varying vec2 vTextureCoord; + +uniform sampler2D uSampler; + +void main(void) +{ + float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb); + + gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); + + if (lum < 1.00) + { + if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) + { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + } + } + + if (lum < 0.75) + { + if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) + { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + } + } + + if (lum < 0.50) + { + if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) + { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + } + } + + if (lum < 0.3) + { + if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) + { + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + } + } +} +`,Eg=function(e){Cg(t,e);function t(){return e.call(this,wg,Tg)||this}return t}(ou),Dg=function(e,t){return Dg=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Dg(e,t)};function Og(e,t){Dg(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var kg=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,Ag=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; + +uniform vec4 filterArea; +uniform vec2 dimensions; + +const float SQRT_2 = 1.414213; + +const float light = 1.0; + +uniform float curvature; +uniform float lineWidth; +uniform float lineContrast; +uniform bool verticalLine; +uniform float noise; +uniform float noiseSize; + +uniform float vignetting; +uniform float vignettingAlpha; +uniform float vignettingBlur; + +uniform float seed; +uniform float time; + +float rand(vec2 co) { + return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); +} + +void main(void) +{ + vec2 pixelCoord = vTextureCoord.xy * filterArea.xy; + vec2 dir = vec2(vTextureCoord.xy * filterArea.xy / dimensions - vec2(0.5, 0.5)); + + gl_FragColor = texture2D(uSampler, vTextureCoord); + vec3 rgb = gl_FragColor.rgb; + + if (noise > 0.0 && noiseSize > 0.0) + { + pixelCoord.x = floor(pixelCoord.x / noiseSize); + pixelCoord.y = floor(pixelCoord.y / noiseSize); + float _noise = rand(pixelCoord * noiseSize * seed) - 0.5; + rgb += _noise * noise; + } + + if (lineWidth > 0.0) + { + float _c = curvature > 0. ? curvature : 1.; + float k = curvature > 0. ?(length(dir * dir) * 0.25 * _c * _c + 0.935 * _c) : 1.; + vec2 uv = dir * k; + + float v = (verticalLine ? uv.x * dimensions.x : uv.y * dimensions.y) * min(1.0, 2.0 / lineWidth ) / _c; + float j = 1. + cos(v * 1.2 - time) * 0.5 * lineContrast; + rgb *= j; + float segment = verticalLine ? mod((dir.x + .5) * dimensions.x, 4.) : mod((dir.y + .5) * dimensions.y, 4.); + rgb *= 0.99 + ceil(segment) * 0.015; + } + + if (vignetting > 0.0) + { + float outter = SQRT_2 - vignetting * SQRT_2; + float darker = clamp((outter - length(dir) * SQRT_2) / ( 0.00001 + vignettingBlur * SQRT_2), 0.0, 1.0); + rgb *= darker + (1.0 - darker) * (1.0 - vignettingAlpha); + } + + gl_FragColor.rgb = rgb; +} +`,jg=function(e){Og(t,e);function t(n){var r=e.call(this,kg,Ag)||this;return r.time=0,r.seed=0,r.uniforms.dimensions=new Float32Array(2),Object.assign(r,t.defaults,n),r}return t.prototype.apply=function(e,t,n,r){var i=t.filterFrame,a=i.width,o=i.height;this.uniforms.dimensions[0]=a,this.uniforms.dimensions[1]=o,this.uniforms.seed=this.seed,this.uniforms.time=this.time,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`curvature`,{get:function(){return this.uniforms.curvature},set:function(e){this.uniforms.curvature=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`lineWidth`,{get:function(){return this.uniforms.lineWidth},set:function(e){this.uniforms.lineWidth=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`lineContrast`,{get:function(){return this.uniforms.lineContrast},set:function(e){this.uniforms.lineContrast=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`verticalLine`,{get:function(){return this.uniforms.verticalLine},set:function(e){this.uniforms.verticalLine=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`noise`,{get:function(){return this.uniforms.noise},set:function(e){this.uniforms.noise=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`noiseSize`,{get:function(){return this.uniforms.noiseSize},set:function(e){this.uniforms.noiseSize=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`vignetting`,{get:function(){return this.uniforms.vignetting},set:function(e){this.uniforms.vignetting=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`vignettingAlpha`,{get:function(){return this.uniforms.vignettingAlpha},set:function(e){this.uniforms.vignettingAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`vignettingBlur`,{get:function(){return this.uniforms.vignettingBlur},set:function(e){this.uniforms.vignettingBlur=e},enumerable:!1,configurable:!0}),t.defaults={curvature:1,lineWidth:1,lineContrast:.25,verticalLine:!1,noise:0,noiseSize:1,seed:0,vignetting:.3,vignettingAlpha:1,vignettingBlur:.3,time:0},t}(ou),Mg=function(e,t){return Mg=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Mg(e,t)};function Ng(e,t){Mg(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Pg=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,Fg=`precision mediump float; + +varying vec2 vTextureCoord; +varying vec4 vColor; + +uniform vec4 filterArea; +uniform sampler2D uSampler; + +uniform float angle; +uniform float scale; + +float pattern() +{ + float s = sin(angle), c = cos(angle); + vec2 tex = vTextureCoord * filterArea.xy; + vec2 point = vec2( + c * tex.x - s * tex.y, + s * tex.x + c * tex.y + ) * scale; + return (sin(point.x) * sin(point.y)) * 4.0; +} + +void main() +{ + vec4 color = texture2D(uSampler, vTextureCoord); + float average = (color.r + color.g + color.b) / 3.0; + gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a); +} +`,Ig=function(e){Ng(t,e);function t(t,n){t===void 0&&(t=1),n===void 0&&(n=5);var r=e.call(this,Pg,Fg)||this;return r.scale=t,r.angle=n,r}return Object.defineProperty(t.prototype,`scale`,{get:function(){return this.uniforms.scale},set:function(e){this.uniforms.scale=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`angle`,{get:function(){return this.uniforms.angle},set:function(e){this.uniforms.angle=e},enumerable:!1,configurable:!0}),t}(ou),Lg=function(e,t){return Lg=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Lg(e,t)};function Rg(e,t){Lg(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var zg=function(){return zg=Object.assign||function(e){for(var t=arguments,n,r=1,i=arguments.length;r 1.0 || coord.y > 1.0) { + return; + } + + float cx = coord.x - 0.5; + float cy = (coord.y - 0.5) * aspect; + float ny = (-sinDir * cx + cosDir * cy) / aspect + 0.5; + + // displacementMap: repeat + // ny = ny > 1.0 ? ny - 1.0 : (ny < 0.0 ? 1.0 + ny : ny); + + // displacementMap: mirror + ny = ny > 1.0 ? 2.0 - ny : (ny < 0.0 ? -ny : ny); + + vec4 dc = texture2D(displacementMap, vec2(0.5, ny)); + + float displacement = (dc.r - dc.g) * (offset / filterArea.x); + + coord = vTextureCoord + vec2(cosDir * displacement, sinDir * displacement * aspect); + + if (fillMode == CLAMP) { + coord = clamp(coord, filterClamp.xy, filterClamp.zw); + } else { + if( coord.x > filterClamp.z ) { + if (fillMode == TRANSPARENT) { + discard; + } else if (fillMode == LOOP) { + coord.x -= filterClamp.z; + } else if (fillMode == MIRROR) { + coord.x = filterClamp.z * 2.0 - coord.x; + } + } else if( coord.x < filterClamp.x ) { + if (fillMode == TRANSPARENT) { + discard; + } else if (fillMode == LOOP) { + coord.x += filterClamp.z; + } else if (fillMode == MIRROR) { + coord.x *= -filterClamp.z; + } + } + + if( coord.y > filterClamp.w ) { + if (fillMode == TRANSPARENT) { + discard; + } else if (fillMode == LOOP) { + coord.y -= filterClamp.w; + } else if (fillMode == MIRROR) { + coord.y = filterClamp.w * 2.0 - coord.y; + } + } else if( coord.y < filterClamp.y ) { + if (fillMode == TRANSPARENT) { + discard; + } else if (fillMode == LOOP) { + coord.y += filterClamp.w; + } else if (fillMode == MIRROR) { + coord.y *= -filterClamp.w; + } + } + } + + gl_FragColor.r = texture2D(uSampler, coord + red * (1.0 - seed * 0.4) / filterArea.xy).r; + gl_FragColor.g = texture2D(uSampler, coord + green * (1.0 - seed * 0.3) / filterArea.xy).g; + gl_FragColor.b = texture2D(uSampler, coord + blue * (1.0 - seed * 0.2) / filterArea.xy).b; + gl_FragColor.a = texture2D(uSampler, coord).a; +} +`,Qg=function(e){Yg(t,e);function t(n){var r=e.call(this,Xg,Zg)||this;return r.offset=100,r.fillMode=t.TRANSPARENT,r.average=!1,r.seed=0,r.minSize=8,r.sampleSize=512,r._slices=0,r._offsets=new Float32Array(1),r._sizes=new Float32Array(1),r._direction=-1,r.uniforms.dimensions=new Float32Array(2),r._canvas=document.createElement(`canvas`),r._canvas.width=4,r._canvas.height=r.sampleSize,r.texture=Wc.from(r._canvas,{scaleMode:_o.NEAREST}),Object.assign(r,t.defaults,n),r}return t.prototype.apply=function(e,t,n,r){var i=t.filterFrame,a=i.width,o=i.height;this.uniforms.dimensions[0]=a,this.uniforms.dimensions[1]=o,this.uniforms.aspect=o/a,this.uniforms.seed=this.seed,this.uniforms.offset=this.offset,this.uniforms.fillMode=this.fillMode,e.applyFilter(this,t,n,r)},t.prototype._randomizeSizes=function(){var e=this._sizes,t=this._slices-1,n=this.sampleSize,r=Math.min(this.minSize/n,.9/this._slices);if(this.average){for(var i=this._slices,a=1,o=0;o0;n--){var r=Math.random()*n>>0,i=e[n];e[n]=e[r],e[r]=i}},t.prototype._randomizeOffsets=function(){for(var e=0;e0?r:0,c=r<0?-r:0;n.fillStyle=`rgba(`+s+`, `+c+`, 0, 1)`,n.fillRect(0,i>>0,e,o+1>>0),i+=o}t.baseTexture.update(),this.uniforms.displacementMap=t},Object.defineProperty(t.prototype,`sizes`,{get:function(){return this._sizes},set:function(e){for(var t=Math.min(this._slices,e.length),n=0;n>0)+1},Object.defineProperty(t.prototype,`offset`,{get:function(){return this.uniforms.uOffset},set:function(e){this.uniforms.uOffset=e},enumerable:!1,configurable:!0}),t}(ou),h_=function(e,t){return h_=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},h_(e,t)};function g_(e,t){h_(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var __=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,v_=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; + +uniform float epsilon; + +const int MAX_COLORS = %maxColors%; + +uniform vec3 originalColors[MAX_COLORS]; +uniform vec3 targetColors[MAX_COLORS]; + +void main(void) +{ + gl_FragColor = texture2D(uSampler, vTextureCoord); + + float alpha = gl_FragColor.a; + if (alpha < 0.0001) + { + return; + } + + vec3 color = gl_FragColor.rgb / alpha; + + for(int i = 0; i < MAX_COLORS; i++) + { + vec3 origColor = originalColors[i]; + if (origColor.r < 0.0) + { + break; + } + vec3 colorDiff = origColor - color; + if (length(colorDiff) < epsilon) + { + vec3 targetColor = targetColors[i]; + gl_FragColor = vec4((targetColor + colorDiff) * alpha, alpha); + return; + } + } +} +`,y_=function(e){g_(t,e);function t(t,n,r){n===void 0&&(n=.05),r===void 0&&(r=t.length);var i=e.call(this,__,v_.replace(/%maxColors%/g,r.toFixed(0)))||this;return i._replacements=[],i._maxColors=0,i.epsilon=n,i._maxColors=r,i.uniforms.originalColors=new Float32Array(r*3),i.uniforms.targetColors=new Float32Array(r*3),i.replacements=t,i}return Object.defineProperty(t.prototype,`replacements`,{get:function(){return this._replacements},set:function(e){var t=this.uniforms.originalColors,n=this.uniforms.targetColors,r=e.length;if(r>this._maxColors)throw Error(`Length of replacements (`+r+`) exceeds the maximum colors length (`+this._maxColors+`)`);t[r*3]=-1;for(var i=0;i 0.5) then: 1 - 2 * (1 - dst) * (1 - src) + return vec3((dst.x <= 0.5) ? (2.0 * src.x * dst.x) : (1.0 - 2.0 * (1.0 - dst.x) * (1.0 - src.x)), + (dst.y <= 0.5) ? (2.0 * src.y * dst.y) : (1.0 - 2.0 * (1.0 - dst.y) * (1.0 - src.y)), + (dst.z <= 0.5) ? (2.0 * src.z * dst.z) : (1.0 - 2.0 * (1.0 - dst.z) * (1.0 - src.z))); +} + + +void main() +{ + gl_FragColor = texture2D(uSampler, vTextureCoord); + vec3 color = gl_FragColor.rgb; + + if (sepia > 0.0) + { + float gray = (color.x + color.y + color.z) / 3.0; + vec3 grayscale = vec3(gray); + + color = Overlay(SEPIA_RGB, grayscale); + + color = grayscale + sepia * (color - grayscale); + } + + vec2 coord = vTextureCoord * filterArea.xy / dimensions.xy; + + if (vignetting > 0.0) + { + float outter = SQRT_2 - vignetting * SQRT_2; + vec2 dir = vec2(vec2(0.5, 0.5) - coord); + dir.y *= dimensions.y / dimensions.x; + float darker = clamp((outter - length(dir) * SQRT_2) / ( 0.00001 + vignettingBlur * SQRT_2), 0.0, 1.0); + color.rgb *= darker + (1.0 - darker) * (1.0 - vignettingAlpha); + } + + if (scratchDensity > seed && scratch != 0.0) + { + float phase = seed * 256.0; + float s = mod(floor(phase), 2.0); + float dist = 1.0 / scratchDensity; + float d = distance(coord, vec2(seed * dist, abs(s - seed * dist))); + if (d < seed * 0.6 + 0.4) + { + highp float period = scratchDensity * 10.0; + + float xx = coord.x * period + phase; + float aa = abs(mod(xx, 0.5) * 4.0); + float bb = mod(floor(xx / 0.5), 2.0); + float yy = (1.0 - bb) * aa + bb * (2.0 - aa); + + float kk = 2.0 * period; + float dw = scratchWidth / dimensions.x * (0.75 + seed); + float dh = dw * kk; + + float tine = (yy - (2.0 - dh)); + + if (tine > 0.0) { + float _sign = sign(scratch); + + tine = s * tine / period + scratch + 0.1; + tine = clamp(tine + 1.0, 0.5 + _sign * 0.5, 1.5 + _sign * 0.5); + + color.rgb *= tine; + } + } + } + + if (noise > 0.0 && noiseSize > 0.0) + { + vec2 pixelCoord = vTextureCoord.xy * filterArea.xy; + pixelCoord.x = floor(pixelCoord.x / noiseSize); + pixelCoord.y = floor(pixelCoord.y / noiseSize); + // vec2 d = pixelCoord * noiseSize * vec2(1024.0 + seed * 512.0, 1024.0 - seed * 512.0); + // float _noise = snoise(d) * 0.5; + float _noise = rand(pixelCoord * noiseSize * seed) - 0.5; + color += _noise * noise; + } + + gl_FragColor.rgb = color; +} +`,w_=function(e){x_(t,e);function t(n,r){r===void 0&&(r=0);var i=e.call(this,S_,C_)||this;return i.seed=0,i.uniforms.dimensions=new Float32Array(2),typeof n==`number`?(i.seed=n,n=void 0):i.seed=r,Object.assign(i,t.defaults,n),i}return t.prototype.apply=function(e,t,n,r){var i,a;this.uniforms.dimensions[0]=(i=t.filterFrame)?.width,this.uniforms.dimensions[1]=(a=t.filterFrame)?.height,this.uniforms.seed=this.seed,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`sepia`,{get:function(){return this.uniforms.sepia},set:function(e){this.uniforms.sepia=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`noise`,{get:function(){return this.uniforms.noise},set:function(e){this.uniforms.noise=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`noiseSize`,{get:function(){return this.uniforms.noiseSize},set:function(e){this.uniforms.noiseSize=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`scratch`,{get:function(){return this.uniforms.scratch},set:function(e){this.uniforms.scratch=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`scratchDensity`,{get:function(){return this.uniforms.scratchDensity},set:function(e){this.uniforms.scratchDensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`scratchWidth`,{get:function(){return this.uniforms.scratchWidth},set:function(e){this.uniforms.scratchWidth=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`vignetting`,{get:function(){return this.uniforms.vignetting},set:function(e){this.uniforms.vignetting=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`vignettingAlpha`,{get:function(){return this.uniforms.vignettingAlpha},set:function(e){this.uniforms.vignettingAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`vignettingBlur`,{get:function(){return this.uniforms.vignettingBlur},set:function(e){this.uniforms.vignettingBlur=e},enumerable:!1,configurable:!0}),t.defaults={sepia:.3,noise:.3,noiseSize:1,scratch:.5,scratchDensity:.3,scratchWidth:1,vignetting:.3,vignettingAlpha:1,vignettingBlur:.3},t}(ou),T_=function(e,t){return T_=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},T_(e,t)};function E_(e,t){T_(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var D_=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,O_=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; + +uniform vec2 thickness; +uniform vec4 outlineColor; +uniform vec4 filterClamp; + +const float DOUBLE_PI = 3.14159265358979323846264 * 2.; + +void main(void) { + vec4 ownColor = texture2D(uSampler, vTextureCoord); + vec4 curColor; + float maxAlpha = 0.; + vec2 displaced; + for (float angle = 0.; angle <= DOUBLE_PI; angle += \${angleStep}) { + displaced.x = vTextureCoord.x + thickness.x * cos(angle); + displaced.y = vTextureCoord.y + thickness.y * sin(angle); + curColor = texture2D(uSampler, clamp(displaced, filterClamp.xy, filterClamp.zw)); + maxAlpha = max(maxAlpha, curColor.a); + } + float resultAlpha = max(maxAlpha, ownColor.a); + gl_FragColor = vec4((ownColor.rgb + outlineColor.rgb * (1. - ownColor.a)) * resultAlpha, resultAlpha); +} +`,k_=function(e){E_(t,e);function t(n,r,i){n===void 0&&(n=1),r===void 0&&(r=0),i===void 0&&(i=.1);var a=e.call(this,D_,O_.replace(/\$\{angleStep\}/,t.getAngleStep(i)))||this;return a._thickness=1,a.uniforms.thickness=new Float32Array([0,0]),a.uniforms.outlineColor=new Float32Array([0,0,0,1]),Object.assign(a,{thickness:n,color:r,quality:i}),a}return t.getAngleStep=function(e){var n=Math.max(e*t.MAX_SAMPLES,t.MIN_SAMPLES);return(Math.PI*2/n).toFixed(7)},t.prototype.apply=function(e,t,n,r){this.uniforms.thickness[0]=this._thickness/t._frame.width,this.uniforms.thickness[1]=this._thickness/t._frame.height,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`color`,{get:function(){return bs(this.uniforms.outlineColor)},set:function(e){vs(e,this.uniforms.outlineColor)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`thickness`,{get:function(){return this._thickness},set:function(e){this._thickness=e,this.padding=e},enumerable:!1,configurable:!0}),t.MIN_SAMPLES=1,t.MAX_SAMPLES=100,t}(ou),A_=function(e,t){return A_=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},A_(e,t)};function j_(e,t){A_(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var M_=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,N_=`precision mediump float; + +varying vec2 vTextureCoord; + +uniform vec2 size; +uniform sampler2D uSampler; + +uniform vec4 filterArea; + +vec2 mapCoord( vec2 coord ) +{ + coord *= filterArea.xy; + coord += filterArea.zw; + + return coord; +} + +vec2 unmapCoord( vec2 coord ) +{ + coord -= filterArea.zw; + coord /= filterArea.xy; + + return coord; +} + +vec2 pixelate(vec2 coord, vec2 size) +{ + return floor( coord / size ) * size; +} + +void main(void) +{ + vec2 coord = mapCoord(vTextureCoord); + + coord = pixelate(coord, size); + + coord = unmapCoord(coord); + + gl_FragColor = texture2D(uSampler, coord); +} +`,P_=function(e){j_(t,e);function t(t){t===void 0&&(t=10);var n=e.call(this,M_,N_)||this;return n.size=t,n}return Object.defineProperty(t.prototype,`size`,{get:function(){return this.uniforms.size},set:function(e){typeof e==`number`&&(e=[e,e]),this.uniforms.size=e},enumerable:!1,configurable:!0}),t}(ou),F_=function(e,t){return F_=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},F_(e,t)};function I_(e,t){F_(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var L_=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,R_=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; +uniform vec4 filterArea; + +uniform float uRadian; +uniform vec2 uCenter; +uniform float uRadius; +uniform int uKernelSize; + +const int MAX_KERNEL_SIZE = 2048; + +void main(void) +{ + vec4 color = texture2D(uSampler, vTextureCoord); + + if (uKernelSize == 0) + { + gl_FragColor = color; + return; + } + + float aspect = filterArea.y / filterArea.x; + vec2 center = uCenter.xy / filterArea.xy; + float gradient = uRadius / filterArea.x * 0.3; + float radius = uRadius / filterArea.x - gradient * 0.5; + int k = uKernelSize - 1; + + vec2 coord = vTextureCoord; + vec2 dir = vec2(center - coord); + float dist = length(vec2(dir.x, dir.y * aspect)); + + float radianStep = uRadian; + if (radius >= 0.0 && dist > radius) { + float delta = dist - radius; + float gap = gradient; + float scale = 1.0 - abs(delta / gap); + if (scale <= 0.0) { + gl_FragColor = color; + return; + } + radianStep *= scale; + } + radianStep /= float(k); + + float s = sin(radianStep); + float c = cos(radianStep); + mat2 rotationMatrix = mat2(vec2(c, -s), vec2(s, c)); + + for(int i = 0; i < MAX_KERNEL_SIZE - 1; i++) { + if (i == k) { + break; + } + + coord -= center; + coord.y *= aspect; + coord = rotationMatrix * coord; + coord.y /= aspect; + coord += center; + + vec4 sample = texture2D(uSampler, coord); + + // switch to pre-multiplied alpha to correctly blur transparent images + // sample.rgb *= sample.a; + + color += sample; + } + + gl_FragColor = color / float(uKernelSize); +} +`,z_=function(e){I_(t,e);function t(t,n,r,i){t===void 0&&(t=0),n===void 0&&(n=[0,0]),r===void 0&&(r=5),i===void 0&&(i=-1);var a=e.call(this,L_,R_)||this;return a._angle=0,a.angle=t,a.center=n,a.kernelSize=r,a.radius=i,a}return t.prototype.apply=function(e,t,n,r){this.uniforms.uKernelSize=this._angle===0?0:this.kernelSize,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`angle`,{get:function(){return this._angle},set:function(e){this._angle=e,this.uniforms.uRadian=e*Math.PI/180},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`center`,{get:function(){return this.uniforms.uCenter},set:function(e){this.uniforms.uCenter=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`radius`,{get:function(){return this.uniforms.uRadius},set:function(e){(e<0||e===1/0)&&(e=-1),this.uniforms.uRadius=e},enumerable:!1,configurable:!0}),t}(ou),B_=function(e,t){return B_=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},B_(e,t)};function V_(e,t){B_(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var H_=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,U_=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; + +uniform vec4 filterArea; +uniform vec4 filterClamp; +uniform vec2 dimensions; + +uniform bool mirror; +uniform float boundary; +uniform vec2 amplitude; +uniform vec2 waveLength; +uniform vec2 alpha; +uniform float time; + +float rand(vec2 co) { + return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); +} + +void main(void) +{ + vec2 pixelCoord = vTextureCoord.xy * filterArea.xy; + vec2 coord = pixelCoord / dimensions; + + if (coord.y < boundary) { + gl_FragColor = texture2D(uSampler, vTextureCoord); + return; + } + + float k = (coord.y - boundary) / (1. - boundary + 0.0001); + float areaY = boundary * dimensions.y / filterArea.y; + float v = areaY + areaY - vTextureCoord.y; + float y = mirror ? v : vTextureCoord.y; + + float _amplitude = ((amplitude.y - amplitude.x) * k + amplitude.x ) / filterArea.x; + float _waveLength = ((waveLength.y - waveLength.x) * k + waveLength.x) / filterArea.y; + float _alpha = (alpha.y - alpha.x) * k + alpha.x; + + float x = vTextureCoord.x + cos(v * 6.28 / _waveLength - time) * _amplitude; + x = clamp(x, filterClamp.x, filterClamp.z); + + vec4 color = texture2D(uSampler, vec2(x, y)); + + gl_FragColor = color * _alpha; +} +`,W_=function(e){V_(t,e);function t(n){var r=e.call(this,H_,U_)||this;return r.time=0,r.uniforms.amplitude=new Float32Array(2),r.uniforms.waveLength=new Float32Array(2),r.uniforms.alpha=new Float32Array(2),r.uniforms.dimensions=new Float32Array(2),Object.assign(r,t.defaults,n),r}return t.prototype.apply=function(e,t,n,r){var i,a;this.uniforms.dimensions[0]=(i=t.filterFrame)?.width,this.uniforms.dimensions[1]=(a=t.filterFrame)?.height,this.uniforms.time=this.time,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`mirror`,{get:function(){return this.uniforms.mirror},set:function(e){this.uniforms.mirror=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`boundary`,{get:function(){return this.uniforms.boundary},set:function(e){this.uniforms.boundary=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`amplitude`,{get:function(){return this.uniforms.amplitude},set:function(e){this.uniforms.amplitude[0]=e[0],this.uniforms.amplitude[1]=e[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`waveLength`,{get:function(){return this.uniforms.waveLength},set:function(e){this.uniforms.waveLength[0]=e[0],this.uniforms.waveLength[1]=e[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`alpha`,{get:function(){return this.uniforms.alpha},set:function(e){this.uniforms.alpha[0]=e[0],this.uniforms.alpha[1]=e[1]},enumerable:!1,configurable:!0}),t.defaults={mirror:!0,boundary:.5,amplitude:[0,20],waveLength:[30,100],alpha:[1,1],time:0},t}(ou),G_=function(e,t){return G_=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},G_(e,t)};function K_(e,t){G_(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var q_=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,J_=`precision mediump float; + +varying vec2 vTextureCoord; + +uniform sampler2D uSampler; +uniform vec4 filterArea; +uniform vec2 red; +uniform vec2 green; +uniform vec2 blue; + +void main(void) +{ + gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/filterArea.xy).r; + gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/filterArea.xy).g; + gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/filterArea.xy).b; + gl_FragColor.a = texture2D(uSampler, vTextureCoord).a; +} +`,Y_=function(e){K_(t,e);function t(t,n,r){t===void 0&&(t=[-10,0]),n===void 0&&(n=[0,10]),r===void 0&&(r=[0,0]);var i=e.call(this,q_,J_)||this;return i.red=t,i.green=n,i.blue=r,i}return Object.defineProperty(t.prototype,`red`,{get:function(){return this.uniforms.red},set:function(e){this.uniforms.red=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`green`,{get:function(){return this.uniforms.green},set:function(e){this.uniforms.green=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`blue`,{get:function(){return this.uniforms.blue},set:function(e){this.uniforms.blue=e},enumerable:!1,configurable:!0}),t}(ou),X_=function(e,t){return X_=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},X_(e,t)};function Z_(e,t){X_(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Q_=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,$_=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; +uniform vec4 filterArea; +uniform vec4 filterClamp; + +uniform vec2 center; + +uniform float amplitude; +uniform float wavelength; +// uniform float power; +uniform float brightness; +uniform float speed; +uniform float radius; + +uniform float time; + +const float PI = 3.14159; + +void main() +{ + float halfWavelength = wavelength * 0.5 / filterArea.x; + float maxRadius = radius / filterArea.x; + float currentRadius = time * speed / filterArea.x; + + float fade = 1.0; + + if (maxRadius > 0.0) { + if (currentRadius > maxRadius) { + gl_FragColor = texture2D(uSampler, vTextureCoord); + return; + } + fade = 1.0 - pow(currentRadius / maxRadius, 2.0); + } + + vec2 dir = vec2(vTextureCoord - center / filterArea.xy); + dir.y *= filterArea.y / filterArea.x; + float dist = length(dir); + + if (dist <= 0.0 || dist < currentRadius - halfWavelength || dist > currentRadius + halfWavelength) { + gl_FragColor = texture2D(uSampler, vTextureCoord); + return; + } + + vec2 diffUV = normalize(dir); + + float diff = (dist - currentRadius) / halfWavelength; + + float p = 1.0 - pow(abs(diff), 2.0); + + // float powDiff = diff * pow(p, 2.0) * ( amplitude * fade ); + float powDiff = 1.25 * sin(diff * PI) * p * ( amplitude * fade ); + + vec2 offset = diffUV * powDiff / filterArea.xy; + + // Do clamp : + vec2 coord = vTextureCoord + offset; + vec2 clampedCoord = clamp(coord, filterClamp.xy, filterClamp.zw); + vec4 color = texture2D(uSampler, clampedCoord); + if (coord != clampedCoord) { + color *= max(0.0, 1.0 - length(coord - clampedCoord)); + } + + // No clamp : + // gl_FragColor = texture2D(uSampler, vTextureCoord + offset); + + color.rgb *= 1.0 + (brightness - 1.0) * p * fade; + + gl_FragColor = color; +} +`,ev=function(e){Z_(t,e);function t(n,r,i){n===void 0&&(n=[0,0]),i===void 0&&(i=0);var a=e.call(this,Q_,$_)||this;return a.center=n,Object.assign(a,t.defaults,r),a.time=i,a}return t.prototype.apply=function(e,t,n,r){this.uniforms.time=this.time,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`center`,{get:function(){return this.uniforms.center},set:function(e){this.uniforms.center=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`amplitude`,{get:function(){return this.uniforms.amplitude},set:function(e){this.uniforms.amplitude=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`wavelength`,{get:function(){return this.uniforms.wavelength},set:function(e){this.uniforms.wavelength=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`brightness`,{get:function(){return this.uniforms.brightness},set:function(e){this.uniforms.brightness=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`speed`,{get:function(){return this.uniforms.speed},set:function(e){this.uniforms.speed=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`radius`,{get:function(){return this.uniforms.radius},set:function(e){this.uniforms.radius=e},enumerable:!1,configurable:!0}),t.defaults={amplitude:30,wavelength:160,brightness:1,speed:500,radius:-1},t}(ou),tv=function(e,t){return tv=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},tv(e,t)};function nv(e,t){tv(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var rv=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,iv=`varying vec2 vTextureCoord; +uniform sampler2D uSampler; +uniform sampler2D uLightmap; +uniform vec4 filterArea; +uniform vec2 dimensions; +uniform vec4 ambientColor; +void main() { + vec4 diffuseColor = texture2D(uSampler, vTextureCoord); + vec2 lightCoord = (vTextureCoord * filterArea.xy) / dimensions; + vec4 light = texture2D(uLightmap, lightCoord); + vec3 ambient = ambientColor.rgb * ambientColor.a; + vec3 intensity = ambient + light.rgb; + vec3 finalColor = diffuseColor.rgb * intensity; + gl_FragColor = vec4(finalColor, diffuseColor.a); +} +`,av=function(e){nv(t,e);function t(t,n,r){n===void 0&&(n=0),r===void 0&&(r=1);var i=e.call(this,rv,iv)||this;return i._color=0,i.uniforms.dimensions=new Float32Array(2),i.uniforms.ambientColor=new Float32Array([0,0,0,r]),i.texture=t,i.color=n,i}return t.prototype.apply=function(e,t,n,r){var i,a;this.uniforms.dimensions[0]=(i=t.filterFrame)?.width,this.uniforms.dimensions[1]=(a=t.filterFrame)?.height,e.applyFilter(this,t,n,r)},Object.defineProperty(t.prototype,`texture`,{get:function(){return this.uniforms.uLightmap},set:function(e){this.uniforms.uLightmap=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`color`,{get:function(){return this._color},set:function(e){var t=this.uniforms.ambientColor;typeof e==`number`?(vs(e,t),this._color=e):(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],this._color=bs(t))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`alpha`,{get:function(){return this.uniforms.ambientColor[3]},set:function(e){this.uniforms.ambientColor[3]=e},enumerable:!1,configurable:!0}),t}(ou),ov=function(e,t){return ov=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},ov(e,t)};function sv(e,t){ov(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var cv=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,lv=`varying vec2 vTextureCoord; + +uniform sampler2D uSampler; +uniform float blur; +uniform float gradientBlur; +uniform vec2 start; +uniform vec2 end; +uniform vec2 delta; +uniform vec2 texSize; + +float random(vec3 scale, float seed) +{ + return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed); +} + +void main(void) +{ + vec4 color = vec4(0.0); + float total = 0.0; + + float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0); + vec2 normal = normalize(vec2(start.y - end.y, end.x - start.x)); + float radius = smoothstep(0.0, 1.0, abs(dot(vTextureCoord * texSize - start, normal)) / gradientBlur) * blur; + + for (float t = -30.0; t <= 30.0; t++) + { + float percent = (t + offset - 0.5) / 30.0; + float weight = 1.0 - abs(percent); + vec4 sample = texture2D(uSampler, vTextureCoord + delta / texSize * percent * radius); + sample.rgb *= sample.a; + color += sample * weight; + total += weight; + } + + color /= total; + color.rgb /= color.a + 0.00001; + + gl_FragColor = color; +} +`,uv=function(e){sv(t,e);function t(t,n,r,i){t===void 0&&(t=100),n===void 0&&(n=600);var a=e.call(this,cv,lv)||this;return a.uniforms.blur=t,a.uniforms.gradientBlur=n,a.uniforms.start=r||new $s(0,window.innerHeight/2),a.uniforms.end=i||new $s(600,window.innerHeight/2),a.uniforms.delta=new $s(30,30),a.uniforms.texSize=new $s(window.innerWidth,window.innerHeight),a.updateDelta(),a}return t.prototype.updateDelta=function(){this.uniforms.delta.x=0,this.uniforms.delta.y=0},Object.defineProperty(t.prototype,`blur`,{get:function(){return this.uniforms.blur},set:function(e){this.uniforms.blur=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`gradientBlur`,{get:function(){return this.uniforms.gradientBlur},set:function(e){this.uniforms.gradientBlur=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`start`,{get:function(){return this.uniforms.start},set:function(e){this.uniforms.start=e,this.updateDelta()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`end`,{get:function(){return this.uniforms.end},set:function(e){this.uniforms.end=e,this.updateDelta()},enumerable:!1,configurable:!0}),t}(ou),dv=function(e){sv(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.updateDelta=function(){var e=this.uniforms.end.x-this.uniforms.start.x,t=this.uniforms.end.y-this.uniforms.start.y,n=Math.sqrt(e*e+t*t);this.uniforms.delta.x=e/n,this.uniforms.delta.y=t/n},t}(uv),fv=function(e){sv(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.updateDelta=function(){var e=this.uniforms.end.x-this.uniforms.start.x,t=this.uniforms.end.y-this.uniforms.start.y,n=Math.sqrt(e*e+t*t);this.uniforms.delta.x=-t/n,this.uniforms.delta.y=e/n},t}(uv),pv=function(e){sv(t,e);function t(t,n,r,i){t===void 0&&(t=100),n===void 0&&(n=600);var a=e.call(this)||this;return a.tiltShiftXFilter=new dv(t,n,r,i),a.tiltShiftYFilter=new fv(t,n,r,i),a}return t.prototype.apply=function(e,t,n,r){var i=e.getFilterTexture();this.tiltShiftXFilter.apply(e,t,i,1),this.tiltShiftYFilter.apply(e,i,n,r),e.returnFilterTexture(i)},Object.defineProperty(t.prototype,`blur`,{get:function(){return this.tiltShiftXFilter.blur},set:function(e){this.tiltShiftXFilter.blur=this.tiltShiftYFilter.blur=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`gradientBlur`,{get:function(){return this.tiltShiftXFilter.gradientBlur},set:function(e){this.tiltShiftXFilter.gradientBlur=this.tiltShiftYFilter.gradientBlur=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`start`,{get:function(){return this.tiltShiftXFilter.start},set:function(e){this.tiltShiftXFilter.start=this.tiltShiftYFilter.start=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`end`,{get:function(){return this.tiltShiftXFilter.end},set:function(e){this.tiltShiftXFilter.end=this.tiltShiftYFilter.end=e},enumerable:!1,configurable:!0}),t}(ou),mv=function(e,t){return mv=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},mv(e,t)};function hv(e,t){mv(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var gv=`attribute vec2 aVertexPosition; +attribute vec2 aTextureCoord; + +uniform mat3 projectionMatrix; + +varying vec2 vTextureCoord; + +void main(void) +{ + gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0); + vTextureCoord = aTextureCoord; +}`,_v=`varying vec2 vTextureCoord; + +uniform sampler2D uSampler; +uniform float radius; +uniform float angle; +uniform vec2 offset; +uniform vec4 filterArea; + +vec2 mapCoord( vec2 coord ) +{ + coord *= filterArea.xy; + coord += filterArea.zw; + + return coord; +} + +vec2 unmapCoord( vec2 coord ) +{ + coord -= filterArea.zw; + coord /= filterArea.xy; + + return coord; +} + +vec2 twist(vec2 coord) +{ + coord -= offset; + + float dist = length(coord); + + if (dist < radius) + { + float ratioDist = (radius - dist) / radius; + float angleMod = ratioDist * ratioDist * angle; + float s = sin(angleMod); + float c = cos(angleMod); + coord = vec2(coord.x * c - coord.y * s, coord.x * s + coord.y * c); + } + + coord += offset; + + return coord; +} + +void main(void) +{ + + vec2 coord = mapCoord(vTextureCoord); + + coord = twist(coord); + + coord = unmapCoord(coord); + + gl_FragColor = texture2D(uSampler, coord ); + +} +`,vv=function(e){hv(t,e);function t(n){var r=e.call(this,gv,_v)||this;return Object.assign(r,t.defaults,n),r}return Object.defineProperty(t.prototype,`offset`,{get:function(){return this.uniforms.offset},set:function(e){this.uniforms.offset=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`radius`,{get:function(){return this.uniforms.radius},set:function(e){this.uniforms.radius=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`angle`,{get:function(){return this.uniforms.angle},set:function(e){this.uniforms.angle=e},enumerable:!1,configurable:!0}),t.defaults={radius:200,angle:4,padding:20,offset:new $s},t}(ou),yv=function(e,t){return yv=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},yv(e,t)};function bv(e,t){yv(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function xv(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i= 0.0 && dist > radius) { // radius < 0 means it's infinity + delta = dist - radius; + gap = gradient; + } + + if (delta > 0.0) { + float normalCount = gap / filterArea.x; + delta = (normalCount - delta) / normalCount; + countLimit *= delta; + strength *= delta; + if (countLimit < 1.0) + { + gl_FragColor = texture2D(uSampler, vTextureCoord); + return; + } + } + + // randomize the lookup values to hide the fixed number of samples + float offset = rand(vTextureCoord, 0.0); + + float total = 0.0; + vec4 color = vec4(0.0); + + dir *= strength; + + for (float t = 0.0; t < MAX_KERNEL_SIZE; t++) { + float percent = (t + offset) / MAX_KERNEL_SIZE; + float weight = 4.0 * (percent - percent * percent); + vec2 p = vTextureCoord + dir * percent; + vec4 sample = texture2D(uSampler, p); + + // switch to pre-multiplied alpha to correctly blur transparent images + // sample.rgb *= sample.a; + + color += sample * weight; + total += weight; + + if (t > countLimit){ + break; + } + } + + color /= total; + // switch back from pre-multiplied alpha + // color.rgb /= color.a + 0.00001; + + gl_FragColor = color; +} +`,wv=function(e){bv(t,e);function t(n){var r=this,i=Object.assign(t.defaults,n),a=i.maxKernelSize,o=xv(i,[`maxKernelSize`]);return r=e.call(this,Sv,Cv.replace("${maxKernelSize}",a.toFixed(1)))||this,Object.assign(r,o),r}return Object.defineProperty(t.prototype,`center`,{get:function(){return this.uniforms.uCenter},set:function(e){this.uniforms.uCenter=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`strength`,{get:function(){return this.uniforms.uStrength},set:function(e){this.uniforms.uStrength=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`innerRadius`,{get:function(){return this.uniforms.uInnerRadius},set:function(e){this.uniforms.uInnerRadius=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,`radius`,{get:function(){return this.uniforms.uRadius},set:function(e){(e<0||e===1/0)&&(e=-1),this.uniforms.uRadius=e},enumerable:!1,configurable:!0}),t.defaults={strength:.1,center:[0,0],innerRadius:0,radius:-1,maxKernelSize:32},t}(ou);function Tv(){let e=-1,t,n=-1;function r(r,i){(i>=e||i({x:0,y:0})},disableFocusAt:{type:Boolean,default:!1}},emits:[`modelLoaded`],setup(e,{expose:t,emit:n}){let r=e,i=n,a=gn(()=>r.app),o=gn(()=>r.paused),s=gn(()=>r.focusAt),c=W(),l=W(0),u=W(0),d=kt(()=>Math.max(0,Math.min(100,r.mouthOpenSize))),f=xn(),p=bn(Ot),m=kt(()=>p.between(`sm`,`md`).value||p.smaller(`sm`).value),h=Tv(),g=dn(new Hg({alpha:.2,blur:0,distance:20,rotation:45}));function _(){return c.value.internalModel.coreModel}function v(e){if(!e.value)return;let t=2.2;m.value&&(t=2.2);let n=r.height*.95/u.value*t,i=r.width*.95/l.value*t,a=Math.min(n,i);e.value.scale.set(a,a)}let{live2dModelFile:y,loadingLive2dModel:b,live2dCurrentMotion:x,availableLive2dMotions:S,live2dLoadSource:C,live2dModelUrl:w,themeColorsHue:T,themeColorsHueDynamic:E}=pn(Dn()),D=W({group:`Idle`,index:0});async function O(){var e;if(!a.value)return;c.value&&(a.value.stage.removeChild(c.value),c.value.destroy(),c.value=void 0);let t=new Nm;C.value===`file`?await Tm.setupLive2DModel(t,[y.value],{autoInteract:!1}):C.value===`url`&&await Tm.setupLive2DModel(t,w.value,{autoInteract:!1}),c.value=t,a.value.stage.addChild(c.value),l.value=c.value.width,u.value=c.value.height,c.value.x=r.width/2,c.value.y=r.height,c.value.anchor.set(.5,.5),v(c),c.value.on(`hit`,e=>{c.value&&e.includes(`body`)&&c.value.motion(`tap_body`)});let n=c.value.internalModel,o=n.coreModel,s=n.motionManager;o.setParameterValueById(`ParamMouthOpenY`,d.value),S.value=Object.entries(s.definitions).flatMap(([e,t])=>t?t.map((t,n)=>({motionName:e,motionIndex:n,fileName:t.File})):[]).filter(Boolean),s.groups.idle&&(e=s.motionGroups[s.groups.idle])?.forEach(e=>{e._motionData.curves.forEach(e=>{(e.id===`ParamEyeBallX`||e.id===`ParamEyeBallY`)&&(e.id=`_${e.id}`)})});let f=s.update;s.update=function(e,t){return f?.call(this,e,t),s.state.currentGroup===s.groups.idle&&h.update(n,t),!0},s.on(`motionStart`,(e,t)=>{D.value={group:e,index:t}}),y.value&&await Ev.default.setItem(`live2dModel`,y.value),i(`modelLoaded`),b.value=!1}async function k(){if(!a.value)return;Nm.registerTicker(qs),Us.add(Js),Us.add(oh);let e=await Ev.default.getItem(`live2dModel`);if(e){y.value=e,C.value=`file`,b.value=!0;return}if(w.value){C.value=`url`,b.value=!0;return}b.value=!1}async function A(e,t){await c.value.motion(e,t,nm.FORCE)}let j=Sn(()=>{c.value&&(c.value.x=r.width/2,c.value.y=r.height,v(c))},100),M=W(),N=W(0);function ee(){if(c.value){let e=getComputedStyle(M.value).backgroundColor;g.value.color=Number(Lt(e).replace(`#`,`0x`)),c.value.filters=[g.value]}}K([()=>r.width,()=>r.height],()=>j()),K(f,ee,{immediate:!0}),K([c,T],ee);function F(){ee(),N.value=requestAnimationFrame(F)}K(E,()=>{E.value?N.value=requestAnimationFrame(F):(cancelAnimationFrame(N.value),N.value=0)},{immediate:!0}),K(d,e=>_().setParameterValueById(`ParamMouthOpenY`,e)),K(a,k),K(x,e=>A(e.group,e.index)),K(o,e=>{var t,n;return e?(t=a.value)?.stop():(n=a.value)?.start()}),K(s,e=>{c.value&&(r.disableFocusAt||c.value.focus(e.x,e.y))}),Pn(b,e=>{e&&O()},{debounce:1e3}),$t(ee),tn(()=>{var e;cancelAnimationFrame(N.value),c.value&&(e=a.value)?.stage.removeChild(c.value)});function I(){return S.value}return t({setMotion:A,listMotionGroups:I}),(e,t)=>(U(),V(P,null,[B(`div`,{ref_key:`dropShadowColorComputer`,ref:M,hidden:``,bg:`primary-400 dark:primary-500`},null,512),sn(e.$slots,`default`)],64))}}),Ov=Dv;const kv={"z-1":``,"flex-1":``},Av={"text-lg":``,"font-normal":``,class:`menu-icon-item-title`,transition:`all ease-in-out duration-400`},jv={text:`sm neutral-500 dark:neutral-400`,class:`menu-icon-item-description`,transition:`all ease-in-out duration-400`};var Mv=H({__name:`IconItem`,props:{title:null,description:null,icon:null,iconTemplate:{type:Boolean},to:null},setup(e){return(t,n)=>{let r=cn(`RouterLink`);return U(),At(r,{box:`border`,flex:`~ row`,bg:`neutral-50 dark:neutral-900`,border:`neutral-100 dark:neutral-800/25 hover:primary-500/30 dark:hover:primary-400/30 solid 2`,"drop-shadow":`none hover:[0px_4px_4px_rgba(220,220,220,0.4)] active:[0px_0px_0px_rgba(220,220,220,0.25)] dark:hover:none`,class:`menu-icon-item`,transition:`all ease-in-out duration-400`,relative:``,"w-full":``,"items-center":``,"overflow-hidden":``,"rounded-lg":``,"p-5":``,"text-left":``,cursor:`pointer`,to:e.to},{default:Ln(()=>[B(`div`,kv,[B(`div`,Av,mn(e.title),1),B(`div`,jv,[B(`span`,null,mn(e.description),1)])]),typeof e.icon==`string`?(U(),V(`div`,{key:0,class:Jt([`menu-icon-item-icon`,[e.icon]]),transition:`all ease-in-out duration-400`,absolute:``,"right-0":``,"size-24":``,"translate-y-4":``,text:`neutral-400/50 dark:neutral-600/50`},null,2)):jt(``,!0),e.iconTemplate?sn(t.$slots,`icon`,{key:1},void 0,!0):jt(``,!0)]),_:3},8,[`to`])}}}),Nv=Ct(Mv,[[`__scopeId`,`data-v-c0e4998c`]]);const Pv={flex:`~ col`,bg:`neutral-50 dark:neutral-800`,border:`neutral-100 dark:neutral-800/25 hover:primary-500/30 dark:hover:primary-400/30 solid 2`,"drop-shadow":`none hover:[0px_4px_4px_rgba(220,220,220,0.4)] active:[0px_0px_0px_rgba(220,220,220,0.25)] dark:hover:none`,class:`menu-icon-status-item`,transition:`all ease-in-out duration-400`,"w-full":``,"cursor-pointer":``,"of-hidden":``,"rounded-xl":``},Fv={"z-1":``,"flex-1":``},Iv={"text-lg":``,"font-normal":``,class:`menu-icon-status-item-title`,transition:`all ease-in-out duration-400`},Lv={text:`sm neutral-500 dark:neutral-400`,class:`menu-icon-status-item-description`,transition:`all ease-in-out duration-400`},Rv=[`src`],zv={"p-2":``},Bv={key:0,"size-3":``,bg:`green-500 dark:green-600`,"rounded-full":``},Vv={key:1,"size-3":``,bg:`neutral-400 dark:neutral-500`,"rounded-full":``};var Hv=H({__name:`IconStatusItem`,props:{title:null,description:null,icon:null,iconColor:null,iconImage:null,to:null,configured:{type:Boolean}},setup(e){let t=e;return(e,n)=>{let r=cn(`RouterLink`);return U(),V(`div`,Pv,[Nt(r,{flex:`~ row`,class:`menu-icon-status-item-link`,bg:`white dark:neutral-900`,transition:`all ease-in-out duration-400`,relative:``,"h-full":``,"w-full":``,"items-center":``,"overflow-hidden":``,"rounded-lg":``,"p-5":``,"text-left":``,to:t.to},{default:Ln(()=>[B(`div`,Fv,[B(`div`,Iv,mn(t.title),1),B(`div`,Lv,[B(`span`,null,mn(t.description||``),1)])]),t.icon?(U(),V(`div`,{key:0,class:Jt([`menu-icon-status-item-icon`,[t.icon]]),transition:`all ease-in-out duration-400`,absolute:``,"right-0":``,"size-16":``,"translate-y-2":``,text:`neutral-400/50 dark:neutral-600/50`,"grayscale-100":``},null,2)):jt(``,!0),t.iconColor?(U(),V(`div`,{key:1,class:Jt([`menu-icon-status-item-icon-color`,[t.iconColor]]),transition:`all ease-in-out duration-400`,absolute:``,"right-0":``,"size-16":``,"translate-y-2":``,text:`neutral-400/50 dark:neutral-600/50`,"grayscale-100":``},null,2)):jt(``,!0),t.iconImage?(U(),V(`img`,{key:2,src:t.iconImage,class:`menu-icon-status-item-icon-image`,transition:`all ease-in-out duration-400`,absolute:``,"right-0":``,"size-16":``,"translate-y-2":``,"grayscale-100":``},null,8,Rv)):jt(``,!0)]),_:1},8,[`to`]),B(`div`,zv,[t.configured?(U(),V(`div`,Bv)):(U(),V(`div`,Vv))])])}}}),Uv=Ct(Hv,[[`__scopeId`,`data-v-03028e15`]]);const Wv=[`checked`,`name`,`value`],Gv={class:`relative mr-3 mt-0.5 flex-shrink-0`},Kv={class:`w-full flex flex-col gap-2`},qv={class:`flex items-center`},Jv={key:0,class:`relative`},Yv=[`title`],Xv={key:1,class:`mt-2`};var Zv=H({__name:`RadioCardDetail`,props:Gt({id:null,name:null,value:null,title:null,description:null,deprecated:{type:Boolean,default:!1},showExpandCollapse:{type:Boolean,default:!0},expandCollapseThreshold:{default:100},customInputValue:{default:``},customInputPlaceholder:{default:``},showCustomInput:{type:Boolean,default:!1}},{modelValue:{required:!0},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=Tn(e,`modelValue`),n=W(!1);function r(){n.value=!n.value}return(i,a)=>(U(),V(`label`,{key:e.id,class:Jt([`form_radio-card-detail relative flex cursor-pointer items-start rounded-xl p-3 pr-[20px]`,[t.value===e.value?`bg-primary-50 dark:bg-primary-900/20 border-primary-100 dark:border-primary-900 hover:border-primary-500/30 dark:hover:border-primary-400/30`:`bg-white dark:bg-neutral-900/20 border-neutral-100 dark:border-neutral-900 hover:border-primary-500/30 dark:hover:border-primary-400/30`,t.value===e.value?`form_radio-card-detail-active`:``,e.deprecated?`opacity-60`:``]]),transition:`all duration-200 ease-in-out`,border:`2 solid`},[Rn(B(`input`,{"onUpdate:modelValue":a[0]||=e=>t.value=e,checked:t.value===e.value,type:`radio`,name:e.name,value:e.value,class:`absolute opacity-0`},null,8,Wv),[[jn,t.value]]),B(`div`,Gv,[B(`div`,{class:Jt([`size-5 border-2 rounded-full transition-colors duration-200`,[t.value===e.value?`border-primary-500 dark:border-primary-400`:`border-neutral-300 dark:border-neutral-600`]])},[B(`div`,{class:Jt([`absolute left-1/2 top-1/2 size-3 rounded-full transition-opacity duration-200 -translate-x-1/2 -translate-y-1/2`,[t.value===e.value?`opacity-100 bg-primary-500 dark:bg-primary-400`:`opacity-0`]])},null,2)],2)]),B(`div`,Kv,[B(`div`,qv,[B(`span`,{class:Jt([`line-clamp-1 font-normal`,[t.value===e.value?`text-neutral-700 dark:text-neutral-300`:`text-neutral-700 dark:text-neutral-400`]])},mn(e.title),3)]),e.description?(U(),V(`div`,Jv,[Nt(G(Jn),null,{default:Ln(()=>[!n.value||!e.showExpandCollapse?(U(),V(`div`,{key:0,class:Jt([`line-clamp-2 cursor-pointer text-xs`,[t.value===e.value?`text-neutral-600 dark:text-neutral-400`:`text-neutral-500 dark:text-neutral-500`]]),title:e.description,onClick:zn(r,[`prevent`])},mn(e.description),11,Yv)):(U(),V(`div`,{key:1,class:Jt([`cursor-pointer text-xs`,[t.value===e.value?`text-neutral-600 dark:text-neutral-400`:`text-neutral-500 dark:text-neutral-500`]]),onClick:zn(r,[`prevent`])},mn(e.description),3))]),_:1}),e.showExpandCollapse&&e.description.length>e.expandCollapseThreshold?(U(),V(`button`,{key:0,class:`mt-0.5 inline-flex items-center text-xs text-primary-500 dark:text-primary-600`,onClick:zn(r,[`prevent`])},[B(`span`,null,mn(n.value?`Show less`:`Show more`),1),B(`div`,{class:Jt([{"rotate-180":n.value},`transition-transform duration-200`])},a[2]||=[B(`div`,{"i-solar:alt-arrow-down-linear":``,"ml-0.5":``,"text-xs":``},null,-1)],2)])):jt(``,!0)])):jt(``,!0),e.showCustomInput&&t.value===e.value?(U(),V(`div`,Xv,[Nt(G(Zn),{modelValue:t.value,"onUpdate:modelValue":a[1]||=e=>t.value=e,type:`text`,class:`w-full border border-neutral-300 rounded bg-white px-2 py-1 text-sm dark:border-neutral-700 dark:bg-neutral-900`,placeholder:e.customInputPlaceholder},null,8,[`modelValue`,`placeholder`])])):jt(``,!0)])],2))}}),Qv=Ct(Zv,[[`__scopeId`,`data-v-e854843a`]]);const $v={class:`radio-card-detail-many-select`},ey={key:0,class:`relative`,"inline-flex":`~`,"w-full":``,"items-center":``},ty=[`placeholder`],ny={class:`mt-4 space-y-2`},ry={key:0,class:`text-sm text-neutral-500 dark:text-neutral-400`},iy={key:1,class:`flex items-center gap-3 border border-2 border-amber-200 rounded-xl bg-amber-50 p-4 dark:border-amber-800 dark:bg-amber-900/20`},ay={class:`flex flex-col`},oy={class:`font-medium`},sy={class:`text-sm text-amber-600 dark:text-amber-400`},cy={class:`relative`};var ly=H({__name:`RadioCardManySelect`,props:Gt({items:null,searchable:{type:Boolean,default:!0},searchPlaceholder:{default:`Search...`},searchNoResultsTitle:{default:`No results found`},searchNoResultsDescription:{default:`Try a different search term`},searchResultsText:{default:`{count} of {total} results`},customInputPlaceholder:{default:`Enter custom value`},expandButtonText:{default:`Show more`},collapseButtonText:{default:`Show less`},showMore:{type:Boolean,default:!0}},{modelValue:{required:!0},modelModifiers:{}}),emits:Gt([`update:customValue`],[`update:modelValue`]),setup(e,{emit:t}){let n=e,r=t,i=Tn(e,`modelValue`),a=W(``),o=W(!1),s=W(``),c=kt(()=>{if(!a.value)return n.items;let e=a.value.toLowerCase();return n.items.filter(t=>t.name.toLowerCase().includes(e)||t.description&&t.description.toLowerCase().includes(e))});function l(e){s.value=e,r(`update:customValue`,e)}return(t,n)=>(U(),V(`div`,$v,[e.searchable?(U(),V(`div`,ey,[n[4]||=B(`div`,{class:`pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3`},[B(`div`,{"i-solar:magnifer-line-duotone":``,class:`text-neutral-500 dark:text-neutral-400`})],-1),Rn(B(`input`,{"onUpdate:modelValue":n[0]||=e=>a.value=e,type:`search`,class:`w-full rounded-xl p-2.5 pl-10 text-sm outline-none`,border:`focus:primary-100 dark:focus:primary-400/50 2 solid neutral-200 dark:neutral-800`,transition:`all duration-200 ease-in-out`,bg:`white dark:neutral-900`,placeholder:e.searchPlaceholder},null,8,ty),[[Nn,a.value]])])):jt(``,!0),B(`div`,ny,[a.value?(U(),V(`div`,ry,mn(e.searchResultsText.replace(`{count}`,c.value.length.toString()).replace(`{total}`,e.items.length.toString())),1)):jt(``,!0),a.value&&c.value.length===0?(U(),V(`div`,iy,[n[5]||=B(`div`,{"i-solar:info-circle-line-duotone":``,class:`text-2xl text-amber-500 dark:text-amber-400`},null,-1),B(`div`,ay,[B(`span`,oy,mn(e.searchNoResultsTitle),1),B(`span`,sy,mn(e.searchNoResultsDescription.replace(`{query}`,a.value)),1)])])):jt(``,!0),B(`div`,cy,[B(`div`,{class:Jt([`grid auto-cols-[350px] grid-flow-col max-h-[calc(100dvh-7lh)] gap-4 overflow-x-auto pb-4 scrollbar-none`,[o.value?`grid-cols-1 md:grid-cols-2 grid-flow-row auto-cols-auto`:``]]),transition:`all duration-200 ease-in-out`,style:{"scroll-snap-type":`x mandatory`}},[(U(!0),V(P,null,on(c.value,t=>(U(),At(Qv,{id:t.id,key:t.id,modelValue:i.value,"onUpdate:modelValue":n[1]||=e=>i.value=e,value:t.id,title:t.name,description:t.description,deprecated:t.deprecated,"show-expand-collapse":e.showMore,"expand-collapse-threshold":100,"show-custom-input":t.customizable,"custom-input-value":s.value,"custom-input-placeholder":e.customInputPlaceholder,name:`radio-card-detail-many-select`,class:`scroll-snap-align-start`,"onUpdate:customInputValue":n[2]||=e=>l(e)},null,8,[`id`,`modelValue`,`value`,`title`,`description`,`deprecated`,`show-expand-collapse`,`show-custom-input`,`custom-input-value`,`custom-input-placeholder`]))),128))],2),B(`div`,{bg:`neutral-100 dark:[rgba(0,0,0,0.3)]`,"rounded-xl":``,class:Jt([o.value?`w-full`:`mt-4 w-full rounded-lg`])},[B(`button`,{"w-full":``,flex:``,"items-center":``,"justify-center":``,"gap-2":``,"rounded-lg":``,"py-2":``,transition:`all duration-200 ease-in-out`,class:Jt([o.value?`bg-primary-500 hover:bg-primary-600 text-white`:`bg-white dark:bg-neutral-900 hover:bg-neutral-100 dark:hover:bg-neutral-800`]),onClick:n[3]||=e=>o.value=!o.value},[B(`span`,null,mn(o.value?e.collapseButtonText:e.expandButtonText),1),B(`div`,{class:Jt([o.value?`rotate-180`:``,`text-lg`]),"i-solar:alt-arrow-down-linear":``,transition:`transform duration-200 ease-in-out`},null,2)],2)],2)])])]))}}),uy=Ct(ly,[[`__scopeId`,`data-v-f71732e8`]]);const dy=[`checked`,`name`,`value`],fy={flex:`~ col`,"min-h-16":``,"w-full":``,"items-start":``,"justify-center":``,"pb-2":``,"pl-5":``,"pr-4":``,"pt-2":``};var py=H({__name:`RadioCardSimple`,props:Gt({id:null,name:null,value:null,title:null,description:null},{modelValue:{required:!0},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=Tn(e,`modelValue`);return(n,r)=>(U(),V(`label`,{key:e.id,border:`2px solid`,class:Jt([`form_radio-card-simple relative`,[t.value===e.value?`bg-primary-50 dark:bg-primary-900/20 border-primary-100 dark:border-primary-900 hover:border-primary-500/30 dark:hover:border-primary-400/30`:`bg-white dark:bg-neutral-900/20 border-neutral-100 dark:border-neutral-900 hover:border-primary-500/30 dark:hover:border-primary-400/30`,t.value===e.value?`form_radio-card-simple-active`:``]]),transition:`all duration-200 ease-in-out`,flex:`~ col`,block:``,"min-w-50":``,"w-fit":``,"cursor-pointer":``,"items-start":``,"rounded-xl":``,"p-4":``,"text-left":``},[Rn(B(`input`,{"onUpdate:modelValue":r[0]||=e=>t.value=e,checked:t.value===e.value,type:`radio`,name:e.name,value:e.value,class:`absolute opacity-0 [&:checked+div]:border-primary-500 [&:checked+div_.radio-dot]:opacity-100 dark:[&:checked+div]:border-primary-400`},null,8,dy),[[jn,t.value]]),r[1]||=B(`div`,{class:`radio-circle absolute left-2 top-2 size-5 rounded-full`,border:`2 solid neutral-300 dark:neutral-600`,transition:`all duration-200 ease-in-out`},[B(`div`,{class:`radio-dot absolute left-1/2 top-1/2 size-3 rounded-full opacity-0 -translate-x-1/2 -translate-y-1/2`,transition:`all duration-200 ease-in-out`,bg:`primary-500 dark:primary-400`})],-1),B(`div`,fy,[B(`span`,{class:Jt([`radio-item-name font-normal`,[t.value===e.value?`text-neutral-700 dark:text-neutral-300`:`text-neutral-500 dark:text-neutral-500`]]),text:`md`,transition:`all duration-200 ease-in-out`},mn(e.title),3),e.description?(U(),V(`span`,{key:0,class:Jt([`radio-item-description`,[t.value===e.value?`text-neutral-600 dark:text-neutral-400`:`text-neutral-400 dark:text-neutral-600`]]),transition:`all duration-200 ease-in-out`},mn(e.description),3)):jt(``,!0)]),r[2]||=B(`div`,{class:`bg-dotted-neutral-200/80 dark:bg-dotted-neutral-700/50 [input:checked~&]:bg-dotted-primary-300/50 dark:[input:checked~&]:bg-dotted-primary-200/20`,absolute:``,"inset-0":``,"z--1":``,style:{"background-size":`10px 10px`,"mask-image":`linear-gradient(165deg, white 30%, transparent 50%)`}},null,-1)],2))}}),my=Ct(py,[[`__scopeId`,`data-v-0df44f43`]]);const hy={class:`p-3`},gy={class:`flex items-start`},_y=[`checked`,`name`,`value`],vy={class:`relative mr-3 mt-0.5 flex-shrink-0`},yy={key:0,class:`i-solar:pause-circle-bold-duotone text-xl text-neutral-400 dark:text-neutral-500`},by={key:1,class:`i-solar:play-circle-bold-duotone text-xl text-neutral-400 dark:text-neutral-500`},xy={key:1,class:`mt-auto w-full flex items-center justify-center bg-neutral-50 py-3 text-xs text-neutral-400 italic dark:bg-neutral-800/50 dark:text-neutral-600`},Sy={class:`flex-1 cursor-pointer`},Cy={class:`flex items-center`},wy={key:0,class:`mt-1 flex flex-wrap gap-1`},Ty={key:1,class:`mt-3`},Ey={relative:``},Dy={key:0,class:`h-16 px-3 pb-2`};var Oy=H({__name:`VoiceCard`,props:Gt({name:null,voice:null,currentlyPlayingId:null,customInputPlaceholder:{default:`Enter custom voice name`},showVisualizer:{type:Boolean,default:!0},audioStream:{default:null}},{"voice-id":{required:!1,default:``},"voice-idModifiers":{},"custom-voice-name":{required:!1,default:``},"custom-voice-nameModifiers":{}}),emits:Gt([`togglePlayback`],[`update:voice-id`,`update:custom-voice-name`]),setup(e,{emit:t}){let n=e,r=t,i=Tn(e,`voice-id`),a=Tn(e,`custom-voice-name`);function o(e){return e.previewURL||e.preview_audio_url}function s(e){var t,n,r;let i=[];if((t=e.labels)?.gender&&i.push(e.labels.gender),(n=e.labels)?.age&&i.push(e.labels.age),(r=e.labels)?.accent&&i.push(e.labels.accent),e.languages&&e.languages.length>0){let t=e.languages.map(e=>e.name).join(`, `);i.push(t)}return i}function c(){r(`togglePlayback`,n.voice)}return(t,r)=>(U(),V(`label`,{border:`2px solid`,class:Jt([`scroll-snap-align-start form_voice-card relative flex flex-col overflow-hidden rounded-xl`,[i.value===n.voice.id?`bg-primary-50 dark:bg-primary-900/20 border-primary-100 dark:border-primary-900 hover:border-primary-500/30 dark:hover:border-primary-400/30`:`bg-white dark:bg-neutral-900/20 border-neutral-100 dark:border-neutral-900 hover:border-primary-500/30 dark:hover:border-primary-400/30`,i.value===n.voice.id?`form_voice-card-active`:``]]),transition:`all duration-200 ease-in-out`},[B(`div`,hy,[B(`div`,gy,[Rn(B(`input`,{"onUpdate:modelValue":r[0]||=e=>i.value=e,checked:i.value===n.voice.id,type:`radio`,name:e.name,value:n.voice.id,class:`absolute cursor-pointer opacity-0`},null,8,_y),[[jn,i.value]]),B(`div`,vy,[B(`div`,{class:Jt([`size-5 border-2 rounded-full transition-colors duration-200`,[i.value===n.voice.id?`border-primary-500 dark:border-primary-400`:`border-neutral-300 dark:border-neutral-600`]])},[B(`div`,{class:Jt([`absolute left-1/2 top-1/2 size-3 rounded-full transition-opacity duration-200 -translate-x-1/2 -translate-y-1/2`,[i.value===n.voice.id?`opacity-100 bg-primary-500 dark:bg-primary-400`:`opacity-0`]])},null,2)],2)]),o(e.voice)?(U(),V(`button`,{key:0,absolute:``,"right-0":``,top:`0`,"z-3":``,class:Jt([`translate-x-[-50%] translate-y-[50%]`,[e.currentlyPlayingId===e.voice.id?`text-white dark:text-white`:``]]),onClick:c},[e.currentlyPlayingId===e.voice.id?(U(),V(`div`,yy)):(U(),V(`div`,by))],2)):(U(),V(`div`,xy,` No preview available `)),B(`div`,Sy,[B(`div`,Cy,[B(`span`,{class:Jt([`line-clamp-1 font-medium`,[i.value===e.voice.id?`text-neutral-700 dark:text-neutral-300`:`text-neutral-700 dark:text-neutral-400`]])},mn(e.voice.name),3)]),s(e.voice).length>0?(U(),V(`div`,wy,[(U(!0),V(P,null,on(s(e.voice),(t,n)=>(U(),V(`span`,{key:n,class:Jt([`inline-flex items-center rounded-md px-1.5 py-0.5 text-xs`,[i.value===e.voice.id?`bg-primary-100 text-primary-700 dark:bg-primary-900/30 dark:text-primary-400`:`bg-neutral-100 text-neutral-700 dark:bg-neutral-800 dark:text-neutral-300`]])},mn(t),3))),128))])):jt(``,!0),e.voice.customizable&&i.value===e.voice.id?(U(),V(`div`,Ty,[Nt(G(Zn),{modelValue:a.value,"onUpdate:modelValue":r[1]||=e=>a.value=e,type:`text`,class:`w-full border border-neutral-300 rounded bg-white px-2 py-1 text-sm dark:border-neutral-700 dark:bg-neutral-900`,placeholder:e.customInputPlaceholder},null,8,[`modelValue`,`placeholder`])])):jt(``,!0),e.voice.description?(U(),V(`div`,{key:2,class:Jt([`line-clamp-2 mt-1 text-xs`,[i.value===e.voice.id?`text-neutral-600 dark:text-neutral-400`:`text-neutral-500 dark:text-neutral-500`]])},mn(e.voice.description),3)):jt(``,!0)])])]),B(`div`,Ey,[Nt(G(Jn),null,{default:Ln(()=>[e.showVisualizer&&e.currentlyPlayingId===e.voice.id&&e.audioStream?(U(),V(`div`,Dy,[Nt(G(da),{stream:e.audioStream,bars:24,"min-freq":60,"max-freq":4e3},{default:Ln(({frequencies:t})=>[Nt(G(ha),{frequencies:t,"bars-class":i.value===e.voice.id?`bg-primary-500 dark:bg-primary-400`:`bg-neutral-400 dark:bg-neutral-600`},null,8,[`frequencies`,`bars-class`])]),_:1},8,[`stream`])])):jt(``,!0)]),_:1})])],2))}}),ky=Ct(Oy,[[`__scopeId`,`data-v-a5ae8da9`]]);const Ay={class:`voice-preview-player`},jy={key:0,class:`relative`,"inline-flex":`~`,"w-full":``,"items-center":``},My=[`placeholder`],Ny={class:`mt-4 space-y-2`},Py={key:0,class:`text-sm text-neutral-500 dark:text-neutral-400`},Fy={key:1,class:`flex items-center gap-3 border border-2 border-amber-200 rounded-xl bg-amber-50 p-4 dark:border-amber-800 dark:bg-amber-900/20`},Iy={class:`flex flex-col`},Ly={class:`font-medium`},Ry={class:`text-sm text-amber-600 dark:text-amber-400`},zy={class:`relative`};var By=H({__name:`VoiceCardManySelect`,props:Gt({voices:null,searchable:{type:Boolean,default:!0},searchPlaceholder:{default:`Search voices...`},searchNoResultsTitle:{default:`No voices found`},searchNoResultsDescription:{default:`Try a different search term`},searchResultsText:{default:`{count} of {total} voices`},customInputPlaceholder:{default:`Enter custom voice name`},expandButtonText:{default:`Show more`},collapseButtonText:{default:`Show less`},playButtonText:{default:`Play sample`},pauseButtonText:{default:`Pause`},showVisualizer:{type:Boolean,default:!0}},{"search-query":{required:!1,default:``},"search-queryModifiers":{},"voice-id":{required:!1,default:``},"voice-idModifiers":{}}),emits:[`update:search-query`,`update:voice-id`],setup(e){let t=e,n=W(!1),r=W(),i=W(new Map),a=W(new Map),o=W(new Map),s=W(new Map),c=W(null);function l(){return c.value||=new(window.AudioContext||window.webkitAudioContext),c.value}let u=Tn(e,`search-query`),d=Tn(e,`voice-id`),f=kt(()=>{if(!u.value)return t.voices;let e=u.value.toLowerCase();return t.voices.filter(t=>{let n=t.name.toLowerCase().includes(e),r=t.description&&t.description.toLowerCase().includes(e),i=t.tags&&t.tags.some(t=>t.toLowerCase().includes(e)),a=t.labels&&Object.values(t.labels).some(t=>typeof t==`string`&&t.toLowerCase().includes(e)),o=t.languages&&t.languages.some(t=>t.name.toLowerCase().includes(e)||t.code.toLowerCase().includes(e));return n||r||i||a||o})});function p(e){return e.previewURL||e.preview_audio_url}function m(e){let t=p(e);if(!t)return null;if(i.value.has(e.id))return i.value.get(e.id)||null;let n=new Audio(t);return n.crossOrigin=`anonymous`,n.preload=`auto`,n.addEventListener(`ended`,()=>{if(r.value===e.id){r.value=void 0;let t=a.value.get(e.id);t&&(t.getTracks().forEach(e=>e.stop()),a.value.delete(e.id))}}),i.value.set(e.id,n),n}function h(e,t){try{if(a.value.has(t))return a.value.get(t)||null;let n=l();if(s.value.has(t)){let e=s.value.get(t),r=n.createMediaStreamDestination();e.connect(r);let i=r.stream;return a.value.set(t,i),i}let r=n.createMediaElementSource(e);s.value.set(t,r),r.connect(n.destination);let i=n.createMediaStreamDestination();r.connect(i);let o=i.stream;return a.value.set(t,o),o}catch(e){return console.error(`Failed to create audio stream for visualizer:`,e),null}}function g(e){try{let n=p(e);if(!n)return;let o=m(e);if(!o)return;if(r.value===e.id){o.pause(),r.value=void 0;let t=a.value.get(e.id);t&&(t.getTracks().forEach(e=>e.stop()),a.value.delete(e.id));return}if(r.value){let e=i.value.get(r.value);e&&e.pause();let t=a.value.get(r.value);t&&(t.getTracks().forEach(e=>e.stop()),a.value.delete(r.value))}t.showVisualizer&&!a.value.has(e.id)&&h(o,e.id),o.currentTime=0,o.play().catch(e=>{console.error(`Failed to play audio:`,e)}),r.value=e.id}catch(e){console.error(e),r.value=void 0}}function _(){i.value.forEach(e=>{e.pause(),e.src=``}),i.value.clear(),a.value.forEach(e=>{e.getTracks().forEach(e=>e.stop())}),a.value.clear(),o.value.forEach(e=>{e.state!==`closed`&&e.close()}),o.value.clear(),s.value.clear(),r.value=void 0}K(u,()=>{if(r.value){let e=i.value.get(r.value);e&&e.pause();let t=a.value.get(r.value);t&&(t.getTracks().forEach(e=>e.stop()),a.value.delete(r.value)),r.value=void 0}}),Qt(_);let v=W(``);return(t,i)=>(U(),V(`div`,Ay,[e.searchable?(U(),V(`div`,jy,[i[4]||=B(`div`,{class:`pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3`},[B(`div`,{"i-solar:magnifer-line-duotone":``,class:`text-neutral-500 dark:text-neutral-400`})],-1),Rn(B(`input`,{"onUpdate:modelValue":i[0]||=e=>u.value=e,type:`search`,class:`w-full rounded-xl p-2.5 pl-10 text-sm outline-none`,border:`focus:primary-100 dark:focus:primary-400/50 2 solid neutral-200 dark:neutral-800`,transition:`all duration-200 ease-in-out`,bg:`white dark:neutral-900`,placeholder:e.searchPlaceholder},null,8,My),[[Nn,u.value]])])):jt(``,!0),B(`div`,Ny,[u.value?(U(),V(`div`,Py,mn(e.searchResultsText.replace(`{count}`,f.value.length.toString()).replace(`{total}`,e.voices.length.toString())),1)):jt(``,!0),u.value&&f.value.length===0?(U(),V(`div`,Fy,[i[5]||=B(`div`,{"i-solar:info-circle-line-duotone":``,class:`text-2xl text-amber-500 dark:text-amber-400`},null,-1),B(`div`,Iy,[B(`span`,Ly,mn(e.searchNoResultsTitle),1),B(`span`,Ry,mn(e.searchNoResultsDescription.replace(`{query}`,u.value)),1)])])):jt(``,!0),B(`div`,zy,[B(`div`,{class:Jt([`grid auto-cols-[350px] grid-flow-col max-h-[calc(100dvh-7lh)] gap-4 overflow-x-auto scrollbar-none`,[n.value?`grid-cols-1 md:grid-cols-2 grid-flow-row auto-cols-auto`:``]]),transition:`all duration-200 ease-in-out`,style:{"scroll-snap-type":`x mandatory`}},[(U(!0),V(P,null,on(f.value,t=>(U(),At(ky,{key:t.id,"voice-id":d.value,"onUpdate:voiceId":i[1]||=e=>d.value=e,"custom-voice-name":v.value,"onUpdate:customVoiceName":i[2]||=e=>v.value=e,name:`voice`,voice:t,"currently-playing-id":r.value,"custom-input-placeholder":e.customInputPlaceholder,"show-visualizer":e.showVisualizer,"audio-stream":a.value.get(t.id),onTogglePlayback:g},null,8,[`voice-id`,`custom-voice-name`,`voice`,`currently-playing-id`,`custom-input-placeholder`,`show-visualizer`,`audio-stream`]))),128))],2),B(`div`,{bg:`neutral-100 dark:[rgba(0,0,0,0.3)]`,"rounded-xl":``,class:Jt([n.value?`w-full`:`mt-4 w-full rounded-lg`])},[B(`button`,{"w-full":``,flex:``,"items-center":``,"justify-center":``,"gap-2":``,"rounded-lg":``,"py-2":``,transition:`all duration-200 ease-in-out`,class:Jt([n.value?`bg-primary-500 hover:bg-primary-600 text-white`:`bg-white dark:bg-neutral-900 hover:bg-neutral-100 dark:hover:bg-neutral-800`]),onClick:i[3]||=e=>n.value=!n.value},[B(`span`,null,mn(n.value?e.collapseButtonText:e.expandButtonText),1),B(`div`,{class:Jt([n.value?`rotate-180`:``,`text-lg`]),"i-solar:alt-arrow-down-linear":``,transition:`transform duration-200 ease-in-out`},null,2)],2)],2)])])]))}}),Vy=Ct(By,[[`__scopeId`,`data-v-bd06a081`]]),Hy=H({__name:`CursorFloating`,props:{intensity:{default:1.5}},setup(e){let t=e,n=W(null),r=W(``),i=W(`50% 50%`),a=W(`50% 50%`),o=W(.5);function s(e){if(!n.value)return;let s=n.value,c=s.getBoundingClientRect(),l=e.clientX-c.left,u=e.clientY-c.top,d=s.offsetWidth,f=s.offsetHeight,p=Math.abs(Math.floor(100/d*l)-100),m=Math.abs(Math.floor(100/f*u)-100),h=50+(p-50)/1.5,g=50+(m-50)/1.5,_=50+(p-50)/7,v=50+(m-50)/7,y=(h-50)/1.5*.2*t.intensity,b=(g-50)/2*-1*.2*t.intensity,x=50-p+(50-m),S=.5+Math.abs(x)*.008*t.intensity;r.value=`perspective(1200px) rotateX(${b}deg) rotateY(${y}deg) scale3d(${1+.015*t.intensity}, ${1+.015*t.intensity}, ${1+.015*t.intensity})`,i.value=`${h}% ${g}%`,a.value=`${_}% ${v}%`,o.value=S}function c(){r.value=`perspective(1200px) rotateX(0deg) rotateY(0deg) scale3d(1, 1, 1)`,i.value=`50% 50%`,a.value=`50% 50%`,o.value=.5}return $t(()=>{r.value=`perspective(1200px) rotateX(0deg) rotateY(0deg) scale3d(1, 1, 1)`}),(t,i)=>(U(),V(`div`,{ref_key:`cardRef`,ref:n,class:`card-hover-effect`,style:Xt({transform:r.value,"--effect-intensity":e.intensity}),onMousemove:s,onMouseleave:c},[sn(t.$slots,`default`,{},void 0,!0)],36))}}),Uy=Ct(Hy,[[`__scopeId`,`data-v-895421da`]]),Wy=H({__name:`ProviderAccountIdInput`,props:Gt({placeholder:null,required:{type:Boolean},label:null,description:null},{modelValue:{required:!0},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=Tn(e,`modelValue`);return(e,r)=>(U(),At(G(Xn),{modelValue:n.value,"onUpdate:modelValue":r[0]||=e=>n.value=e,label:t.label||`Account ID`,description:t.description||`Account ID`,placeholder:t.placeholder,required:t.required,type:`text`},null,8,[`modelValue`,`label`,`description`,`placeholder`,`required`]))}}),Gy=Wy;const Ky=[`onClick`],qy={class:`text-lg text-neutral-500 md:text-2xl dark:text-neutral-400`},Jy={"mt-4":``};var Yy=H({__name:`ProviderAdvancedSettings`,props:{title:null,initialVisible:{type:Boolean}},setup(e){let t=e,n=W(t.initialVisible||!1);function r(){n.value=!n.value}return(t,n)=>(U(),At(qn,{"w-full":``},{trigger:Ln(t=>[B(`button`,{transition:`all ease-in-out duration-250`,"w-full":``,flex:``,"items-center":``,"gap-1.5":``,"outline-none":``,class:`[&_.provider-icon]:grayscale-100 [&_.provider-icon]:hover:grayscale-0`,onClick:()=>t.setVisible(!t.visible)&&r()},[B(`h2`,qy,[B(`span`,null,mn(e.title||`Advanced`),1)]),B(`div`,{transform:``,transition:`transform duration-250`,class:Jt({"rotate-180":t.visible})},n[0]||=[B(`div`,{"i-solar:alt-arrow-down-linear":``},null,-1)],2)],8,Ky)]),default:Ln(()=>[B(`div`,Jy,[sn(t.$slots,`default`)])]),_:3}))}}),Xy=Yy,Zy=H({__name:`ProviderApiKeyInput`,props:Gt({providerName:null,placeholder:null,required:{type:Boolean},label:null,description:null},{modelValue:{required:!0},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,{t:n}=wn(),r=Tn(e,`modelValue`),i=kt(()=>t.description||`API Key for ${t.providerName}`);return(t,a)=>(U(),At(G(Xn),{modelValue:r.value,"onUpdate:modelValue":a[0]||=e=>r.value=e,label:e.label||G(n)(`settings.pages.providers.common.fields.field.api-key.label`),description:i.value,placeholder:e.placeholder,required:e.required,type:`password`},null,8,[`modelValue`,`label`,`description`,`placeholder`,`required`]))}}),Qy=Zy,$y=H({__name:`ProviderBaseUrlInput`,props:Gt({placeholder:null,required:{type:Boolean},label:null,description:null},{modelValue:{required:!0},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let t=e,n=Tn(e,`modelValue`);return(e,r)=>(U(),At(G(Xn),{modelValue:n.value,"onUpdate:modelValue":r[0]||=e=>n.value=e,label:t.label||`Base URL`,description:t.description||`Custom base URL (optional)`,placeholder:t.placeholder,required:t.required,type:`text`},null,8,[`modelValue`,`label`,`description`,`placeholder`,`required`]))}}),eb=$y;const tb={flex:`~ col gap-6`},nb={flex:`~ row`,"items-center":``,"justify-between":``},rb={class:`text-lg text-neutral-500 md:text-2xl dark:text-neutral-400`},ib={text:`neutral-400 dark:neutral-500`};var ab=H({__name:`ProviderBasicSettings`,props:{title:null,description:null,onReset:{type:Function}},setup(e){return(t,n)=>(U(),V(`div`,tb,[B(`div`,nb,[B(`div`,null,[B(`h2`,rb,mn(e.title||`Basic`),1),B(`div`,ib,[B(`span`,null,mn(e.description||`Essential settings`),1)])]),e.onReset?(U(),V(`button`,{key:0,title:`Reset settings`,flex:``,"items-center":``,"justify-center":``,"rounded-full":``,"p-2":``,transition:`all duration-250 ease-in-out`,text:`neutral-500 dark:neutral-400`,bg:`transparent dark:transparent hover:neutral-200 dark:hover:neutral-800 active:neutral-300 dark:active:neutral-700`,onClick:n[0]||=(...t)=>e.onReset&&e.onReset(...t)},n[1]||=[B(`div`,{"i-solar:refresh-bold-duotone":``,"text-xl":``},null,-1)])):jt(``,!0)]),sn(t.$slots,`default`)]))}}),ob=ab;const sb={bg:`neutral-50 dark:[rgba(0,0,0,0.3)]`,"rounded-xl":``,"p-4":``,flex:`~ col gap-6`};var cb=H({__name:`ProviderSettingsContainer`,setup(e){return(e,t)=>(U(),V(`div`,sb,[sn(e.$slots,`default`)]))}}),lb=cb;const ub={text:`neutral-200/50 dark:neutral-600/20`,"pointer-events-none":``,fixed:``,top:`[calc(100dvh-15rem)]`,"bottom-0":``,"right--5":``,"z--1":``,initial:{scale:.9,opacity:0,x:20},enter:{scale:1,opacity:1,x:0},duration:500,"size-60":``};var db=H({__name:`ProviderSettingsLayout2`,props:{providerName:null,providerIcon:null,providerIconColor:null,onBack:{type:Function}},setup(e){return(t,n)=>{let r=ln(`motion`);return U(),V(P,null,[sn(t.$slots,`default`),Rn((U(),V(`div`,ub,[B(`div`,{text:`60`,class:Jt(e.providerIcon||e.providerIconColor)},null,2)])),[[r]])],64)}}}),fb=db;const pb={text:`neutral-200/50 dark:neutral-600/20`,"pointer-events-none":``,fixed:``,top:`[calc(100dvh-15rem)]`,"bottom-0":``,"right--5":``,"z--1":``,initial:{scale:.9,opacity:0,x:20},enter:{scale:1,opacity:1,x:0},duration:500,"size-60":``};var mb=H({__name:`ProviderSettingsLayout`,props:{providerName:null,providerIcon:null,providerIconColor:null,onBack:{type:Function}},setup(e){return(t,n)=>{let r=ln(`motion`);return U(),V(P,null,[sn(t.$slots,`default`),Rn((U(),V(`div`,pb,[B(`div`,{text:`60`,class:Jt(e.providerIcon||e.providerIconColor)},null,2)])),[[r]])],64)}}}),hb=mb;const gb={"w-full":``,"rounded-xl":``},_b={class:`mb-4 text-lg text-neutral-500 md:text-2xl dark:text-neutral-400`,"w-full":``},vb={class:`inline-flex items-center gap-4`},yb={flex:`~ col gap-4`},bb=[`placeholder`],xb=[`placeholder`],Sb={flex:`~ col gap-6`},Cb={grid:`~ cols-2 gap-4`},wb={class:`flex items-center gap-1 text-sm font-medium`},Tb={class:`text-xs text-neutral-500 dark:text-neutral-400`},Eb=[`value`],Db={flex:`~ row`,"gap-4":``},Ob=[`disabled`],kb={flex:`~ row`,"items-center":``,"gap-2":``},Ab={flex:`~ row`,"items-center":``,"gap-2":``},jb={key:2,class:`mt-2 text-sm text-red-500`},Mb={key:3,class:`mt-2 text-sm text-red-500`},Nb={key:4,class:`mt-2 text-sm text-red-500`},Pb=[`src`];var Fb=H({__name:`SpeechPlayground`,props:{defaultText:null,availableVoices:null,generateSpeech:{type:Function},apiKeyConfigured:{type:Boolean}},setup(e,{expose:t}){let n=e,{t:r}=wn(),i=W(n.defaultText||`Hello! This is a test of the voice synthesis.`),a=W(!1),o=W(``),s=W(``),c=W(null),l=W(!1),u=W(``),d=W(``);K(()=>n.availableVoices,e=>{var t;e.length>0&&!d.value&&(d.value=(t=e[0])?.id||``)},{immediate:!0});async function f(){if(!(!i.value.trim()&&!l.value||l.value&&!u.value.trim()||!d.value)){a.value=!0,s.value=``;try{o.value&&p();let e=l.value?u.value:i.value,t=await n.generateSpeech(e,d.value,l.value);o.value=URL.createObjectURL(new Blob([t])),setTimeout(()=>{c.value&&c.value.play()},100)}catch(e){console.error(`Error generating speech:`,e),s.value=e instanceof Error?e.message:`An unknown error occurred`}finally{a.value=!1}}}function p(){c.value&&(c.value.pause(),c.value.currentTime=0),o.value&&(URL.revokeObjectURL(o.value),o.value=``)}return tn(()=>{o.value&&URL.revokeObjectURL(o.value)}),t({testText:i,ssmlText:u,useSSML:l,selectedVoice:d,isGenerating:a,audioUrl:o,errorMessage:s,audioPlayer:c,generateTestSpeech:f,stopTestAudio:p}),(t,n)=>(U(),V(`div`,gb,[B(`h2`,_b,[B(`div`,vb,[Nt(G(Oa)),B(`div`,null,mn(G(r)(`settings.pages.providers.provider.elevenlabs.playground.title`)),1)])]),B(`div`,yb,[Nt(G(Yn),{modelValue:l.value,"onUpdate:modelValue":n[0]||=e=>l.value=e,label:G(r)(`settings.pages.modules.speech.sections.section.voice-settings.use-ssml.label`),description:G(r)(`settings.pages.modules.speech.sections.section.voice-settings.use-ssml.description`)},null,8,[`modelValue`,`label`,`description`]),l.value?Rn((U(),V(`textarea`,{key:1,"onUpdate:modelValue":n[2]||=e=>u.value=e,placeholder:G(r)(`settings.pages.modules.speech.sections.section.voice-settings.input-ssml.placeholder`),border:`neutral-100 dark:neutral-800 solid 2 focus:neutral-200 dark:focus:neutral-700`,transition:`all duration-250 ease-in-out`,bg:`neutral-100 dark:neutral-800 focus:neutral-50 dark:focus:neutral-900`,"h-48":``,"w-full":``,"rounded-lg":``,"px-3":``,"py-2":``,"text-sm":``,"font-mono":``,"outline-none":``},null,8,xb)),[[Nn,u.value]]):Rn((U(),V(`textarea`,{key:0,"onUpdate:modelValue":n[1]||=e=>i.value=e,placeholder:G(r)(`settings.pages.providers.provider.elevenlabs.playground.fields.field.input.placeholder`),border:`neutral-100 dark:neutral-800 solid 2 focus:neutral-200 dark:focus:neutral-700`,transition:`all duration-250 ease-in-out`,bg:`neutral-100 dark:neutral-800 focus:neutral-50 dark:focus:neutral-900`,"h-24":``,"w-full":``,"rounded-lg":``,"px-3":``,"py-2":``,"text-sm":``,"outline-none":``},null,8,bb)),[[Nn,i.value]]),B(`div`,Sb,[B(`label`,Cb,[B(`div`,null,[B(`div`,wb,mn(G(r)(`settings.pages.providers.provider.elevenlabs.playground.fields.field.voice.label`)),1),B(`div`,Tb,mn(G(r)(`settings.pages.providers.provider.elevenlabs.playground.fields.field.voice.description`)),1)]),Rn(B(`select`,{"onUpdate:modelValue":n[3]||=e=>d.value=e,border:`neutral-300 dark:neutral-800 solid 2 focus:neutral-400 dark:focus:neutral-600`,transition:`border duration-250 ease-in-out`,"w-full":``,"rounded-lg":``,"px-2":``,"py-1":``,"text-nowrap":``,"text-sm":``,"outline-none":``},[(U(!0),V(P,null,on(e.availableVoices,e=>(U(),V(`option`,{key:e.id,value:e.id},mn(e.name),9,Eb))),128))],512),[[Mn,d.value]])])]),B(`div`,Db,[B(`button`,{border:`neutral-800 dark:neutral-200 solid 2`,transition:`border duration-250 ease-in-out`,"rounded-lg":``,"px-4":``,text:`neutral-100 dark:neutral-900`,"py-2":``,"text-sm":``,disabled:a.value||!i.value.trim()&&!l.value||l.value&&!u.value.trim()||!d.value||!e.apiKeyConfigured,class:Jt({"opacity-50 cursor-not-allowed":a.value||!i.value.trim()&&!l.value||l.value&&!u.value.trim()||!d.value||!e.apiKeyConfigured}),bg:`neutral-700 dark:neutral-300`,onClick:f},[B(`div`,kb,[n[4]||=B(`div`,{"i-solar:play-circle-bold-duotone":``},null,-1),B(`span`,null,mn(a.value?G(r)(`settings.pages.providers.provider.elevenlabs.playground.buttons.button.test-voice.generating`):G(r)(`settings.pages.providers.provider.elevenlabs.playground.buttons.button.test-voice.label`)),1)])],10,Ob),o.value?(U(),V(`button`,{key:0,border:`primary-300 dark:primary-800 solid 2`,transition:`border duration-250 ease-in-out`,"rounded-lg":``,"px-4":``,"py-2":``,"text-sm":``,onClick:p},[B(`div`,Ab,[n[5]||=B(`div`,{"i-solar:stop-circle-bold-duotone":``},null,-1),B(`span`,null,mn(G(r)(`settings.pages.modules.speech.sections.section.playground.buttons.stop.label`)),1)])])):jt(``,!0)]),e.apiKeyConfigured?jt(``,!0):(U(),V(`div`,jb,mn(G(r)(`settings.pages.providers.provider.elevenlabs.playground.validation.error-missing-api-key`)),1)),d.value?jt(``,!0):(U(),V(`div`,Mb,mn(G(r)(`settings.pages.modules.speech.sections.section.playground.select-voice.required`)),1)),s.value?(U(),V(`div`,Nb,mn(s.value),1)):jt(``,!0),o.value?(U(),V(`audio`,{key:5,ref_key:`audioPlayer`,ref:c,src:o.value,controls:``,class:`mt-2 w-full`},null,8,Pb)):jt(``,!0)]),sn(t.$slots,`default`)]))}}),Ib=Fb;const Lb={flex:`~ col md:row gap-6`},Rb={flex:`~ col gap-6`},zb={class:`text-lg text-neutral-500 md:text-2xl dark:text-neutral-400`},Bb={flex:`~ col gap-4`},Vb={flex:`~ col gap-6`,class:`w-full md:w-[60%]`},Hb={"w-full":``,"rounded-xl":``};var Ub=H({__name:`SpeechProviderSettings`,props:{providerId:null,defaultModel:null,additionalSettings:null},setup(e){let t=e,{t:n}=wn(),r=En(),i=Wn(),a=Kn(),{providers:o}=pn(i),s=kt(()=>i.getProviderMetadata(t.providerId)),c=kt({get:()=>{var e;return(e=o.value[t.providerId])?.apiKey||``},set:e=>{o.value[t.providerId]||(o.value[t.providerId]={}),o.value[t.providerId].apiKey=e}}),l=kt({get:()=>{var e,n,r;return(e=o.value[t.providerId])?.baseUrl||((n=s.value)==null||(r=n.defaultOptions)==null?void 0:r.call(n).baseUrl)||``},set:e=>{o.value[t.providerId]||(o.value[t.providerId]={}),o.value[t.providerId].baseUrl=e}}),u=W(`Hello! This is a test of voice synthesis.`),d=W(!1),f=W(``),p=W(``),m=W(null),h=W(!1),g=W(``),_=W(``),v=W({});function y(){var e;(e=o.value[t.providerId])?.voiceSettings?v.value={...o.value[t.providerId].voiceSettings}:v.value={pitch:0,speed:1,volume:0,...t.additionalSettings}}$t(()=>{var e,n,r,u;i.initializeProvider(t.providerId),c.value=(e=o.value[t.providerId])?.apiKey||``,l.value=(n=o.value[t.providerId])?.baseUrl||((r=s.value)==null||(u=r.defaultOptions)==null?void 0:u.call(r).baseUrl)||``,y(),i.configuredProviders[t.providerId]&&a.loadVoicesForProvider(t.providerId)});let b=Sn(()=>{var e,n;o.value[t.providerId]={...o.value[t.providerId],apiKey:c.value,baseUrl:l.value||((e=s.value)==null||(n=e.defaultOptions)==null?void 0:n.call(e).baseUrl)||``,voiceSettings:{...v.value}}},1e3);K([c,l],b),K(v,b,{deep:!0});async function x(){if(!u.value.trim()&&!h.value||h.value&&!g.value.trim())return;let e=i.getProviderInstance(t.providerId);if(!e){console.error(`Failed to initialize speech provider`);return}if(!_.value){console.error(`No active speech voice selected`);return}d.value=!0,p.value=``;try{f.value&&S();let n=t.defaultModel||`default`,r=h.value?g.value:u.value,i=await Vn({...e.speech(n,{voiceSettings:v.value}),input:r,voice:_.value});f.value=URL.createObjectURL(new Blob([i])),setTimeout(()=>{m.value&&m.value.play()},100)}catch(e){console.error(`Error generating speech:`,e),p.value=e instanceof Error?e.message:`An unknown error occurred`}finally{d.value=!1}}function S(){m.value&&(m.value.pause(),m.value.currentTime=0),f.value&&(URL.revokeObjectURL(f.value),f.value=``)}tn(()=>{f.value&&URL.revokeObjectURL(f.value)});function C(){var e,t;v.value={...((e=s.value)==null||(t=e.defaultOptions)==null?void 0:t.call(e).voiceSettings)||{}},b()}function w(e,t){v.value[e]=t}let T=kt(()=>({voiceSettings:v.value,updateVoiceSettings:w,isGenerating:d.value,testText:u.value,useSSML:h.value,ssmlText:g.value,generateTestSpeech:x,stopTestAudio:S,audioUrl:f.value,audioPlayer:m.value,errorMessage:p.value}));return(e,t)=>{var i,a;return U(),At(fb,{"provider-name":(i=s.value)?.localizedName,"provider-icon":(a=s.value)?.icon,"on-back":()=>G(r).back()},{default:Ln(()=>[B(`div`,Lb,[Nt(G(lb),{class:`w-full md:w-[40%]`},{default:Ln(()=>[Nt(G(ob),{title:G(n)(`settings.pages.providers.common.section.basic.title`),description:G(n)(`settings.pages.providers.common.section.basic.description`),"on-reset":C},{default:Ln(()=>{var n;return[Nt(G(Qy),{modelValue:c.value,"onUpdate:modelValue":t[0]||=e=>c.value=e,"provider-name":(n=s.value)?.localizedName,placeholder:`sk-`},null,8,[`modelValue`,`provider-name`]),sn(e.$slots,`basic-settings`)]}),_:3},8,[`title`,`description`]),B(`div`,Rb,[B(`h2`,zb,mn(G(n)(`settings.pages.providers.common.section.voice.title`)),1),B(`div`,Bb,[sn(e.$slots,`voice-settings`,Yt(Bt(T.value)))])]),Nt(G(Xy),{title:G(n)(`settings.pages.providers.common.section.advanced.title`)},{default:Ln(()=>{var n,r;return[Nt(G(eb),{modelValue:l.value,"onUpdate:modelValue":t[1]||=e=>l.value=e,placeholder:((n=s.value)==null||(r=n.defaultOptions)==null?void 0:r.call(n).baseUrl)||``,required:``},null,8,[`modelValue`,`placeholder`]),sn(e.$slots,`advanced-settings`)]}),_:3},8,[`title`])]),_:3}),B(`div`,Vb,[B(`div`,Hb,[sn(e.$slots,`playground`,Yt(Bt(T.value)))])])])]),_:3},8,[`provider-name`,`provider-icon`,`on-back`])}}}),Wb=Ub,Gb=H({__name:`Screen`,setup(e){let t=W(),n=bn(Ot),{width:r,height:i}=kn(),a=Cn(t,{immediate:!0,windowResize:!0,reset:!0}),o=kt(()=>n.between(`sm`,`md`).value||n.smaller(`sm`).value),s=kt(()=>n.between(`md`,`lg`).value),c=kt(()=>n.greaterOrEqual(`lg`).value),l=kt(()=>c.value?a.width.value:o.value||s.value?r.value-16:a.width.value),u=W(0);return K([r,i,t],()=>{var e;let n=(e=t.value)==null||(e=e.parentElement)==null?void 0:e.getBoundingClientRect();c.value||o.value||s.value?u.value=n?.height||0:u.value=600}),K([a.width,a.height],()=>{c.value||o.value||s.value?u.value=a.height.value:u.value=600}),$t(async()=>{t.value&&a.update()}),(e,n)=>(U(),V(`div`,{ref_key:`containerRef`,ref:t,"h-full":``,"w-full":``},[sn(e.$slots,`default`,{width:l.value,height:u.value})],512))}}),Kb=Gb,qb=xt((exports,t)=>{ +/*! + +JSZip v3.10.1 - A JavaScript class for generating and reading zip files + + +(c) 2009-2016 Stuart Knightley +Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown. + +JSZip uses the library pako released under the MIT license : +https://github.com/nodeca/pako/blob/main/LICENSE +*/ +(function(n){typeof exports==`object`&&t!==void 0?t.exports=n():typeof define==`function`&&define.amd?define([],n):(typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:this).JSZip=n()})(function(){return function e(t,n,r){function i(o,s){if(!n[o]){if(!t[o]){var c=typeof wt==`function`&&wt;if(!s&&c)return c(o,!0);if(a)return a(o,!0);var l=Error(`Cannot find module '`+o+`'`);throw l.code=`MODULE_NOT_FOUND`,l}var u=n[o]={exports:{}};t[o][0].call(u.exports,function(e){var n=t[o][1][e];return i(n||e)},u,u.exports,e,t,n,r)}return n[o].exports}for(var a=typeof wt==`function`&&wt,o=0;o>2,s=(3&t)<<4|n>>4,c=1>6:64,l=2>4,n=(15&o)<<4|(s=a.indexOf(e.charAt(l++)))>>2,r=(3&s)<<6|(c=a.indexOf(e.charAt(l++))),f[u++]=t,s!==64&&(f[u++]=n),c!==64&&(f[u++]=r);return f}},{"./support":30,"./utils":32}],2:[function(e,t,n){"use strict";var r=e(`./external`),i=e(`./stream/DataWorker`),a=e(`./stream/Crc32Probe`),o=e(`./stream/DataLengthProbe`);function s(e,t,n,r,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=n,this.compression=r,this.compressedContent=i}s.prototype={getContentWorker:function(){var e=new i(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new o(`data_length`)),t=this;return e.on(`end`,function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw Error(`Bug : uncompressed data size mismatch`)}),e},getCompressedWorker:function(){return new i(r.Promise.resolve(this.compressedContent)).withStreamInfo(`compressedSize`,this.compressedSize).withStreamInfo(`uncompressedSize`,this.uncompressedSize).withStreamInfo(`crc32`,this.crc32).withStreamInfo(`compression`,this.compression)}},s.createWorkerFrom=function(e,t,n){return e.pipe(new a).pipe(new o(`uncompressedSize`)).pipe(t.compressWorker(n)).pipe(new o(`compressedSize`)).withStreamInfo(`compression`,t)},t.exports=s},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,n){"use strict";var r=e(`./stream/GenericWorker`);n.STORE={magic:`\0\0`,compressWorker:function(){return new r(`STORE compression`)},uncompressWorker:function(){return new r(`STORE decompression`)}},n.DEFLATE=e(`./flate`)},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,n){"use strict";var r=e(`./utils`),i=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t){return e!==void 0&&e.length?r.getTypeOf(e)===`string`?function(e,t,n,r){var a=i,o=r+n;e^=-1;for(var s=r;s>>8^a[255&(e^t.charCodeAt(s))];return-1^e}(0|t,e,e.length,0):function(e,t,n,r){var a=i,o=r+n;e^=-1;for(var s=r;s>>8^a[255&(e^t[s])];return-1^e}(0|t,e,e.length,0):0}},{"./utils":32}],5:[function(e,t,n){"use strict";n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(e,t,n){"use strict";var r=null;r=typeof Promise<`u`?Promise:e(`lie`),t.exports={Promise:r}},{lie:37}],7:[function(e,t,n){"use strict";var r=typeof Uint8Array<`u`&&typeof Uint16Array<`u`&&typeof Uint32Array<`u`,i=e(`pako`),a=e(`./utils`),o=e(`./stream/GenericWorker`),s=r?`uint8array`:`array`;function c(e,t){o.call(this,`FlateWorker/`+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}n.magic=`\b\0`,a.inherits(c,o),c.prototype.processChunk=function(e){this.meta=e.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(s,e.data),!1)},c.prototype.flush=function(){o.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},c.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this._pako=null},c.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},n.compressWorker=function(e){return new c(`Deflate`,e)},n.uncompressWorker=function(){return new c(`Inflate`,{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,n){"use strict";function r(e,t){var n,r=``;for(n=0;n>>=8;return r}function i(e,t,n,i,o,u){var d,f,p=e.file,m=e.compression,h=u!==s.utf8encode,g=a.transformTo(`string`,u(p.name)),_=a.transformTo(`string`,s.utf8encode(p.name)),v=p.comment,y=a.transformTo(`string`,u(v)),b=a.transformTo(`string`,s.utf8encode(v)),x=_.length!==p.name.length,S=b.length!==v.length,C=``,w=``,T=``,E=p.dir,D=p.date,O={crc32:0,compressedSize:0,uncompressedSize:0};t&&!n||(O.crc32=e.crc32,O.compressedSize=e.compressedSize,O.uncompressedSize=e.uncompressedSize);var k=0;t&&(k|=8),h||!x&&!S||(k|=2048);var A=0,j=0;E&&(A|=16),o===`UNIX`?(j=798,A|=function(e,t){var n=e;return e||(n=t?16893:33204),(65535&n)<<16}(p.unixPermissions,E)):(j=20,A|=function(e){return 63&(e||0)}(p.dosPermissions)),d=D.getUTCHours(),d<<=6,d|=D.getUTCMinutes(),d<<=5,d|=D.getUTCSeconds()/2,f=D.getUTCFullYear()-1980,f<<=4,f|=D.getUTCMonth()+1,f<<=5,f|=D.getUTCDate(),x&&(w=r(1,1)+r(c(g),4)+_,C+=`up`+r(w.length,2)+w),S&&(T=r(1,1)+r(c(y),4)+b,C+=`uc`+r(T.length,2)+T);var M=``;return M+=` +\0`,M+=r(k,2),M+=m.magic,M+=r(d,2),M+=r(f,2),M+=r(O.crc32,4),M+=r(O.compressedSize,4),M+=r(O.uncompressedSize,4),M+=r(g.length,2),M+=r(C.length,2),{fileRecord:l.LOCAL_FILE_HEADER+M+g+C,dirRecord:l.CENTRAL_FILE_HEADER+r(j,2)+M+r(y.length,2)+`\0\0\0\0`+r(A,4)+r(i,4)+g+C+y}}var a=e(`../utils`),o=e(`../stream/GenericWorker`),s=e(`../utf8`),c=e(`../crc32`),l=e(`../signature`);function u(e,t,n,r){o.call(this,`ZipFileWorker`),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=n,this.encodeFileName=r,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(u,o),u.prototype.push=function(e){var t=e.meta.percent||0,n=this.entriesCount,r=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,o.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:n?(t+100*(n-r-1))/n:100}}))},u.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var n=i(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:n.fileRecord,meta:{percent:0}})}else this.accumulate=!0},u.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,n=i(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(n.dirRecord),t)this.push({data:function(e){return l.DATA_DESCRIPTOR+r(e.crc32,4)+r(e.compressedSize,4)+r(e.uncompressedSize,4)}(e),meta:{percent:100}});else for(this.push({data:n.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},u.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t=this.index;t--)n=(n<<8)+this.byteAt(t);return this.index+=e,n},readString:function(e){return r.transformTo(`string`,this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i},{"../utils":32}],19:[function(e,t,n){"use strict";var r=e(`./Uint8ArrayReader`);function i(e){r.call(this,e)}e(`../utils`).inherits(i,r),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,n){"use strict";var r=e(`./DataReader`);function i(e){r.call(this,e)}e(`../utils`).inherits(i,r),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],21:[function(e,t,n){"use strict";var r=e(`./ArrayReader`);function i(e){r.call(this,e)}e(`../utils`).inherits(i,r),i.prototype.readData=function(e){if(this.checkOffset(e),e===0)return new Uint8Array;var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,n){"use strict";var r=e(`../utils`),i=e(`../support`),a=e(`./ArrayReader`),o=e(`./StringReader`),s=e(`./NodeBufferReader`),c=e(`./Uint8ArrayReader`);t.exports=function(e){var t=r.getTypeOf(e);return r.checkSupport(t),t!==`string`||i.uint8array?t===`nodebuffer`?new s(e):i.uint8array?new c(r.transformTo(`uint8array`,e)):new a(r.transformTo(`array`,e)):new o(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,n){"use strict";n.LOCAL_FILE_HEADER=`PK`,n.CENTRAL_FILE_HEADER=`PK`,n.CENTRAL_DIRECTORY_END=`PK`,n.ZIP64_CENTRAL_DIRECTORY_LOCATOR=`PK\x07`,n.ZIP64_CENTRAL_DIRECTORY_END=`PK`,n.DATA_DESCRIPTOR=`PK\x07\b`},{}],24:[function(e,t,n){"use strict";var r=e(`./GenericWorker`),i=e(`../utils`);function a(e){r.call(this,`ConvertWorker to `+e),this.destType=e}i.inherits(a,r),a.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta})},t.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,n){"use strict";var r=e(`./GenericWorker`),i=e(`../crc32`);function a(){r.call(this,`Crc32Probe`),this.withStreamInfo(`crc32`,0)}e(`../utils`).inherits(a,r),a.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,n){"use strict";var r=e(`../utils`),i=e(`./GenericWorker`);function a(e){i.call(this,`DataLengthProbe for `+e),this.propName=e,this.withStreamInfo(e,0)}r.inherits(a,i),a.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}i.prototype.processChunk.call(this,e)},t.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,n){"use strict";var r=e(`../utils`),i=e(`./GenericWorker`);function a(e){i.call(this,`DataWorker`);var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type=``,this._tickScheduled=!1,e.then(function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=r.getTypeOf(e),t.isPaused||t._tickAndRepeat()},function(e){t.error(e)})}r.inherits(a,i),a.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case`string`:e=this.data.substring(this.index,t);break;case`uint8array`:e=this.data.subarray(this.index,t);break;case`array`:case`nodebuffer`:e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,n){"use strict";function r(e){this.name=e||`default`,this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}r.prototype={push:function(e){this.emit(`data`,e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit(`end`),this.cleanUp(),this.isFinished=!0}catch(e){this.emit(`error`,e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit(`error`,e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var n=0;n `+e:e}},t.exports=r},{}],29:[function(e,t,n){"use strict";var r=e(`../utils`),i=e(`./ConvertWorker`),a=e(`./GenericWorker`),o=e(`../base64`),s=e(`../support`),c=e(`../external`),l=null;if(s.nodestream)try{l=e(`../nodejs/NodejsStreamOutputAdapter`)}catch{}function u(e,t){return new c.Promise(function(n,i){var a=[],s=e._internalType,c=e._outputType,l=e._mimeType;e.on(`data`,function(e,n){a.push(e),t&&t(n)}).on(`error`,function(e){a=[],i(e)}).on(`end`,function(){try{var e=function(e,t,n){switch(e){case`blob`:return r.newBlob(r.transformTo(`arraybuffer`,t),n);case`base64`:return o.encode(t);default:return r.transformTo(e,t)}}(c,function(e,t){var n,r=0,i=null,a=0;for(n=0;n`u`)n.blob=!1;else{var r=new ArrayBuffer(0);try{n.blob=new Blob([r],{type:`application/zip`}).size===0}catch{try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(r),n.blob=i.getBlob(`application/zip`).size===0}catch{n.blob=!1}}}try{n.nodestream=!!e(`readable-stream`).Readable}catch{n.nodestream=!1}},{"readable-stream":16}],31:[function(e,t,n){"use strict";for(var r=e(`./utils`),i=e(`./support`),a=e(`./nodejsUtils`),o=e(`./stream/GenericWorker`),s=Array(256),c=0;c<256;c++)s[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;s[254]=s[254]=1;function l(){o.call(this,`utf-8 decode`),this.leftOver=null}function u(){o.call(this,`utf-8 encode`)}n.utf8encode=function(e){return i.nodebuffer?a.newBufferFrom(e,`utf-8`):function(e){var t,n,r,a,o,s=e.length,c=0;for(a=0;a>>6:(n<65536?t[o++]=224|n>>>12:(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63),t[o++]=128|n>>>6&63),t[o++]=128|63&n);return t}(e)},n.utf8decode=function(e){return i.nodebuffer?r.transformTo(`nodebuffer`,e).toString(`utf-8`):function(e){var t,n,i,a,o=e.length,c=Array(2*o);for(t=n=0;t>10&1023,c[n++]=56320|1023&i)}return c.length!==n&&(c.subarray?c=c.subarray(0,n):c.length=n),r.applyFromCharCode(c)}(e=r.transformTo(i.uint8array?`uint8array`:`array`,e))},r.inherits(l,o),l.prototype.processChunk=function(e){var t=r.transformTo(i.uint8array?`uint8array`:`array`,e.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var a=t;(t=new Uint8Array(a.length+this.leftOver.length)).set(this.leftOver,0),t.set(a,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var o=function(e,t){var n;for((t||=e.length)>e.length&&(t=e.length),n=t-1;0<=n&&(192&e[n])==128;)n--;return n<0||n===0?t:n+s[e[n]]>t?n:t}(t),c=t;o!==t.length&&(i.uint8array?(c=t.subarray(0,o),this.leftOver=t.subarray(o,t.length)):(c=t.slice(0,o),this.leftOver=t.slice(o,t.length))),this.push({data:n.utf8decode(c),meta:e.meta})},l.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=l,r.inherits(u,o),u.prototype.processChunk=function(e){this.push({data:n.utf8encode(e.data),meta:e.meta})},n.Utf8EncodeWorker=u},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,n){"use strict";var r=e(`./support`),i=e(`./base64`),a=e(`./nodejsUtils`),o=e(`./external`);function s(e){return e}function c(e,t){for(var n=0;n>8;this.dir=!!(16&this.externalFileAttributes),e==0&&(this.dosPermissions=63&this.externalFileAttributes),e==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!==`/`||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=r(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t,n,r,i=e.index+this.extraFieldsLength;for(this.extraFields||={};e.index+4>>6:(n<65536?t[o++]=224|n>>>12:(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63),t[o++]=128|n>>>6&63),t[o++]=128|63&n);return t},n.buf2binstring=function(e){return c(e,e.length)},n.binstring2buf=function(e){for(var t=new r.Buf8(e.length),n=0,i=t.length;n>10&1023,l[r++]=56320|1023&i)}return c(l,r)},n.utf8border=function(e,t){var n;for((t||=e.length)>e.length&&(t=e.length),n=t-1;0<=n&&(192&e[n])==128;)n--;return n<0||n===0?t:n+o[e[n]]>t?n:t}},{"./common":41}],43:[function(e,t,n){"use strict";t.exports=function(e,t,n,r){for(var i=65535&e|0,a=e>>>16&65535|0,o=0;n!==0;){for(n-=o=2e3>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var a=r,o=i+n;e^=-1;for(var s=i;s>>8^a[255&(e^t[s])];return-1^e}},{}],46:[function(e,t,n){"use strict";var r,i=e(`../utils/common`),a=e(`./trees`),o=e(`./adler32`),s=e(`./crc32`),c=e(`./messages`),l=0,u=4,d=0,f=-2,p=-1,m=4,h=2,g=8,_=9,v=286,y=30,b=19,x=2*v+1,S=15,C=3,w=258,T=w+C+1,E=42,D=113,O=1,k=2,A=3,j=4;function M(e,t){return e.msg=c[t],t}function N(e){return(e<<1)-(4e.avail_out&&(n=e.avail_out),n!==0&&(i.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))}function F(e,t){a._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,P(e.strm)}function I(e,t){e.pending_buf[e.pending++]=t}function te(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function ne(e,t){var n,r,i=e.max_chain_length,a=e.strstart,o=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-T?e.strstart-(e.w_size-T):0,l=e.window,u=e.w_mask,d=e.prev,f=e.strstart+w,p=l[a+o-1],m=l[a+o];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do if(l[(n=t)+o]===m&&l[n+o-1]===p&&l[n]===l[a]&&l[++n]===l[a+1]){a+=2,n++;do;while(l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&ac&&--i!=0);return o<=e.lookahead?o:e.lookahead}function L(e){var t,n,r,a,c,l,u,d,f,p,m=e.w_size;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=m+(m-T)){for(i.arraySet(e.window,e.window,m,m,0),e.match_start-=m,e.strstart-=m,e.block_start-=m,t=n=e.hash_size;r=e.head[--t],e.head[t]=m<=r?r-m:0,--n;);for(t=n=m;r=e.prev[--t],e.prev[t]=m<=r?r-m:0,--n;);a+=m}if(e.strm.avail_in===0)break;if(l=e.strm,u=e.window,d=e.strstart+e.lookahead,f=a,p=void 0,p=l.avail_in,f=C)for(c=e.strstart-e.insert,e.ins_h=e.window[c],e.ins_h=(e.ins_h<=C&&(e.ins_h=(e.ins_h<=C)if(r=a._tr_tally(e,e.strstart-e.match_start,e.match_length-C),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=C){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<=C&&(e.ins_h=(e.ins_h<=C&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-C,r=a._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-C),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(L(e),e.lookahead===0&&t===l)return O;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((e.strstart===0||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,F(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-T&&(F(e,!1),e.strm.avail_out===0))return O}return e.insert=0,t===u?(F(e,!0),e.strm.avail_out===0?A:j):(e.strstart>e.block_start&&(F(e,!1),e.strm.avail_out),O)}),new ie(4,4,8,4,re),new ie(4,5,16,8,re),new ie(4,6,32,32,re),new ie(4,4,16,16,R),new ie(8,16,32,32,R),new ie(8,16,128,128,R),new ie(8,32,128,256,R),new ie(32,128,258,1024,R),new ie(32,258,258,4096,R)],n.deflateInit=function(e,t){return ce(e,t,g,15,8,0)},n.deflateInit2=ce,n.deflateReset=se,n.deflateResetKeep=oe,n.deflateSetHeader=function(e,t){return e&&e.state&&e.state.wrap===2?(e.state.gzhead=t,d):f},n.deflate=function(e,t){var n,i,o,c;if(!e||!e.state||5>8&255),I(i,i.gzhead.time>>16&255),I(i,i.gzhead.time>>24&255),I(i,i.level===9?2:2<=i.strategy||i.level<2?4:0),I(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(I(i,255&i.gzhead.extra.length),I(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=s(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(I(i,0),I(i,0),I(i,0),I(i,0),I(i,0),I(i,i.level===9?2:2<=i.strategy||i.level<2?4:0),I(i,3),i.status=D);else{var p=g+(i.w_bits-8<<4)<<8;p|=(2<=i.strategy||i.level<2?0:i.level<6?1:i.level===6?2:3)<<6,i.strstart!==0&&(p|=32),p+=31-p%31,i.status=D,te(i,p),i.strstart!==0&&(te(i,e.adler>>>16),te(i,65535&e.adler)),e.adler=1}if(i.status===69)if(i.gzhead.extra){for(o=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>o&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),P(e),o=i.pending,i.pending!==i.pending_buf_size));)I(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>o&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(i.status===73)if(i.gzhead.name){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),P(e),o=i.pending,i.pending===i.pending_buf_size)){c=1;break}c=i.gzindexo&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),c===0&&(i.gzindex=0,i.status=91)}else i.status=91;if(i.status===91)if(i.gzhead.comment){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),P(e),o=i.pending,i.pending===i.pending_buf_size)){c=1;break}c=i.gzindexo&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),c===0&&(i.status=103)}else i.status=103;if(i.status===103&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&P(e),i.pending+2<=i.pending_buf_size&&(I(i,255&e.adler),I(i,e.adler>>8&255),e.adler=0,i.status=D)):i.status=D),i.pending!==0){if(P(e),e.avail_out===0)return i.last_flush=-1,d}else if(e.avail_in===0&&N(t)<=N(n)&&t!==u)return M(e,-5);if(i.status===666&&e.avail_in!==0)return M(e,-5);if(e.avail_in!==0||i.lookahead!==0||t!==l&&i.status!==666){var m=i.strategy===2?function(e,t){for(var n;;){if(e.lookahead===0&&(L(e),e.lookahead===0)){if(t===l)return O;break}if(e.match_length=0,n=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(F(e,!1),e.strm.avail_out===0))return O}return e.insert=0,t===u?(F(e,!0),e.strm.avail_out===0?A:j):e.last_lit&&(F(e,!1),e.strm.avail_out===0)?O:k}(i,t):i.strategy===3?function(e,t){for(var n,r,i,o,s=e.window;;){if(e.lookahead<=w){if(L(e),e.lookahead<=w&&t===l)return O;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=C&&0e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=C?(n=a._tr_tally(e,1,e.match_length-C),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(F(e,!1),e.strm.avail_out===0))return O}return e.insert=0,t===u?(F(e,!0),e.strm.avail_out===0?A:j):e.last_lit&&(F(e,!1),e.strm.avail_out===0)?O:k}(i,t):r[i.level].func(i,t);if(m!==A&&m!==j||(i.status=666),m===O||m===A)return e.avail_out===0&&(i.last_flush=-1),d;if(m===k&&(t===1?a._tr_align(i):t!==5&&(a._tr_stored_block(i,0,0,!1),t===3&&(ee(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),P(e),e.avail_out===0))return i.last_flush=-1,d}return t===u?i.wrap<=0?1:(i.wrap===2?(I(i,255&e.adler),I(i,e.adler>>8&255),I(i,e.adler>>16&255),I(i,e.adler>>24&255),I(i,255&e.total_in),I(i,e.total_in>>8&255),I(i,e.total_in>>16&255),I(i,e.total_in>>24&255)):(te(i,e.adler>>>16),te(i,65535&e.adler)),P(e),0=n.w_size&&(s===0&&(ee(n.head),n.strstart=0,n.block_start=0,n.insert=0),p=new i.Buf8(n.w_size),i.arraySet(p,t,m-n.w_size,n.w_size,0),t=p,m=n.w_size),c=e.avail_in,l=e.next_in,u=e.input,e.avail_in=m,e.next_in=0,e.input=t,L(n);n.lookahead>=C;){for(r=n.strstart,a=n.lookahead-(C-1);n.ins_h=(n.ins_h<>>=b=y>>>24,m-=b,(b=y>>>16&255)==0)E[a++]=65535&y;else{if(!(16&b)){if(!(64&b)){y=h[(65535&y)+(p&(1<>>=b,m-=b),m<15&&(p+=T[r++]<>>=b=y>>>24,m-=b,!(16&(b=y>>>16&255))){if(!(64&b)){y=g[(65535&y)+(p&(1<>>=b,m-=b,(b=a-o)>3,p&=(1<<(m-=x<<3))-1,e.next_in=r,e.next_out=a,e.avail_in=r>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function g(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg=``,t.wrap&&(e.adler=1&t.wrap),t.mode=f,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new r.Buf32(p),t.distcode=t.distdyn=new r.Buf32(m),t.sane=1,t.back=-1,u):d}function v(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,_(e)):d}function y(e,t){var n,r;return e&&e.state?(r=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15=o.wsize?(r.arraySet(o.window,t,n-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(i<(a=o.wsize-o.wnext)&&(a=i),r.arraySet(o.window,t,n-i,a,o.wnext),(i-=a)?(r.arraySet(o.window,t,n-i,i,0),o.wnext=i,o.whave=o.wsize):(o.wnext+=a,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,n.check=a(n.check,L,2,0),x=b=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&b)<<8)+(b>>8))%31){e.msg=`incorrect header check`,n.mode=30;break}if((15&b)!=8){e.msg=`unknown compression method`,n.mode=30;break}if(x-=4,P=8+(15&(b>>>=4)),n.wbits===0)n.wbits=P;else if(P>n.wbits){e.msg=`invalid window size`,n.mode=30;break}n.dmax=1<>8&1),512&n.flags&&(L[0]=255&b,L[1]=b>>>8&255,n.check=a(n.check,L,2,0)),x=b=0,n.mode=3;case 3:for(;x<32;){if(v===0)break e;v--,b+=p[g++]<>>8&255,L[2]=b>>>16&255,L[3]=b>>>24&255,n.check=a(n.check,L,4,0)),x=b=0,n.mode=4;case 4:for(;x<16;){if(v===0)break e;v--,b+=p[g++]<>8),512&n.flags&&(L[0]=255&b,L[1]=b>>>8&255,n.check=a(n.check,L,2,0)),x=b=0,n.mode=5;case 5:if(1024&n.flags){for(;x<16;){if(v===0)break e;v--,b+=p[g++]<>>8&255,n.check=a(n.check,L,2,0)),x=b=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(v<(E=n.length)&&(E=v),E&&(n.head&&(P=n.head.extra_len-n.length,n.head.extra||(n.head.extra=Array(n.head.extra_len)),r.arraySet(n.head.extra,p,g,E,P)),512&n.flags&&(n.check=a(n.check,p,E,g)),v-=E,g+=E,n.length-=E),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(v===0)break e;for(E=0;P=p[g+ E++],n.head&&P&&n.length<65536&&(n.head.name+=String.fromCharCode(P)),P&&E>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;x<32;){if(v===0)break e;v--,b+=p[g++]<>>=7&x,x-=7&x,n.mode=27;break}for(;x<3;){if(v===0)break e;v--,b+=p[g++]<>>=1)){case 0:n.mode=14;break;case 1:if(w(n),n.mode=20,t!==6)break;b>>>=2,x-=2;break e;case 2:n.mode=17;break;case 3:e.msg=`invalid block type`,n.mode=30}b>>>=2,x-=2;break;case 14:for(b>>>=7&x,x-=7&x;x<32;){if(v===0)break e;v--,b+=p[g++]<>>16^65535)){e.msg=`invalid stored block lengths`,n.mode=30;break}if(n.length=65535&b,x=b=0,n.mode=15,t===6)break e;case 15:n.mode=16;case 16:if(E=n.length){if(v>>=5,x-=5,n.ndist=1+(31&b),b>>>=5,x-=5,n.ncode=4+(15&b),b>>>=4,x-=4,286>>=3,x-=3}for(;n.have<19;)n.lens[re[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,I={bits:n.lenbits},F=s(0,n.lens,0,19,n.lencode,0,n.work,I),n.lenbits=I.bits,F){e.msg=`invalid code lengths set`,n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have>>16&255,j=65535&ne,!((k=ne>>>24)<=x);){if(v===0)break e;v--,b+=p[g++]<>>=k,x-=k,n.lens[n.have++]=j;else{if(j===16){for(te=k+2;x>>=k,x-=k,n.have===0){e.msg=`invalid bit length repeat`,n.mode=30;break}P=n.lens[n.have-1],E=3+(3&b),b>>>=2,x-=2}else if(j===17){for(te=k+3;x>>=k)),b>>>=3,x-=3}else{for(te=k+7;x>>=k)),b>>>=7,x-=7}if(n.have+E>n.nlen+n.ndist){e.msg=`invalid bit length repeat`,n.mode=30;break}for(;E--;)n.lens[n.have++]=P}}if(n.mode===30)break;if(n.lens[256]===0){e.msg=`invalid code -- missing end-of-block`,n.mode=30;break}if(n.lenbits=9,I={bits:n.lenbits},F=s(c,n.lens,0,n.nlen,n.lencode,0,n.work,I),n.lenbits=I.bits,F){e.msg=`invalid literal/lengths set`,n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,I={bits:n.distbits},F=s(l,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,I),n.distbits=I.bits,F){e.msg=`invalid distances set`,n.mode=30;break}if(n.mode=20,t===6)break e;case 20:n.mode=21;case 21:if(6<=v&&258<=y){e.next_out=_,e.avail_out=y,e.next_in=g,e.avail_in=v,n.hold=b,n.bits=x,o(e,C),_=e.next_out,m=e.output,y=e.avail_out,g=e.next_in,p=e.input,v=e.avail_in,b=n.hold,x=n.bits,n.mode===12&&(n.back=-1);break}for(n.back=0;A=(ne=n.lencode[b&(1<>>16&255,j=65535&ne,!((k=ne>>>24)<=x);){if(v===0)break e;v--,b+=p[g++]<>M)])>>>16&255,j=65535&ne,!(M+(k=ne>>>24)<=x);){if(v===0)break e;v--,b+=p[g++]<>>=M,x-=M,n.back+=M}if(b>>>=k,x-=k,n.back+=k,n.length=j,A===0){n.mode=26;break}if(32&A){n.back=-1,n.mode=12;break}if(64&A){e.msg=`invalid literal/length code`,n.mode=30;break}n.extra=15&A,n.mode=22;case 22:if(n.extra){for(te=n.extra;x>>=n.extra,x-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;A=(ne=n.distcode[b&(1<>>16&255,j=65535&ne,!((k=ne>>>24)<=x);){if(v===0)break e;v--,b+=p[g++]<>M)])>>>16&255,j=65535&ne,!(M+(k=ne>>>24)<=x);){if(v===0)break e;v--,b+=p[g++]<>>=M,x-=M,n.back+=M}if(b>>>=k,x-=k,n.back+=k,64&A){e.msg=`invalid distance code`,n.mode=30;break}n.offset=j,n.extra=15&A,n.mode=24;case 24:if(n.extra){for(te=n.extra;x>>=n.extra,x-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg=`invalid distance too far back`,n.mode=30;break}n.mode=25;case 25:if(y===0)break e;if(E=C-y,n.offset>E){if((E=n.offset-E)>n.whave&&n.sane){e.msg=`invalid distance too far back`,n.mode=30;break}D=E>n.wnext?(E-=n.wnext,n.wsize-E):n.wnext-E,E>n.length&&(E=n.length),O=n.window}else O=m,D=_-n.offset,E=n.length;for(yv?(b=I[te+d[w]],N[ee+d[w]]):(b=96,0),p=1<>k)+(m-=p)]=y<<24|b<<16|x|0,m!==0;);for(p=1<>=1;if(p===0?M=0:(M&=p-1,M+=p),w++,--P[C]==0){if(C===E)break;C=t[n+d[w]]}if(D>>7)]}function I(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function te(e,t,n){e.bi_valid>h-n?(e.bi_buf|=t<>h-e.bi_valid,e.bi_valid+=n-h):(e.bi_buf|=t<>>=1,n<<=1,0<--t;);return n>>>1}function re(e,t,n){var r,i,a=Array(m+1),o=0;for(r=1;r<=m;r++)a[r]=o=o+n[r-1]<<1;for(i=0;i<=t;i++){var s=e[2*i+1];s!==0&&(e[2*i]=L(a[s]++,s))}}function R(e){var t;for(t=0;t>1;1<=n;n--)oe(e,a,n);for(i=c;n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],oe(e,a,1),r=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=r,a[2*i]=a[2*n]+a[2*r],e.depth[i]=(e.depth[n]>=e.depth[r]?e.depth[n]:e.depth[r])+1,a[2*n+1]=a[2*r+1]=i,e.heap[1]=i++,oe(e,a,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,r,i,a,o,s,c=t.dyn_tree,l=t.max_code,u=t.stat_desc.static_tree,d=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,h=t.stat_desc.extra_base,g=t.stat_desc.max_length,_=0;for(a=0;a<=m;a++)e.bl_count[a]=0;for(c[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n>=7;r>>=1)if(1&n&&e.dyn_ltree[2*t]!==0)return i;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return a;for(t=32;t>>3,(s=e.static_len+3+7>>>3)<=o&&(o=s)):o=s=n+5,n+4<=o&&t!==-1?fe(e,t,n,r):e.strategy===4||s===o?(te(e,2+(r?1:0),3),se(e,T,E)):(te(e,4+(r?1:0),3),function(e,t,n,r){var i;for(te(e,t-257,5),te(e,n-1,5),te(e,r-4,4),i=0;i>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,t===0?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(O[n]+l+1)]++,e.dyn_dtree[2*F(t)]++),e.last_lit===e.lit_bufsize-1},n._tr_align=function(e){te(e,2,3),ne(e,_,T),function(e){e.bi_valid===16?(I(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":41}],53:[function(e,t,n){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=``,this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,n){(function(e){(function(e,t){"use strict";if(!e.setImmediate){var n,r,i,a,o=1,s={},c=!1,l=e.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(e);u=u&&u.setTimeout?u:e,n={}.toString.call(e.process)===`[object process]`?function(e){process.nextTick(function(){f(e)})}:function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage(``,`*`),e.onmessage=n,t}}()?(a=`setImmediate$`+Math.random()+`$`,e.addEventListener?e.addEventListener(`message`,p,!1):e.attachEvent(`onmessage`,p),function(t){e.postMessage(a+t,`*`)}):e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){f(e.data)},function(e){i.port2.postMessage(e)}):l&&`onreadystatechange`in l.createElement(`script`)?(r=l.documentElement,function(e){var t=l.createElement(`script`);t.onreadystatechange=function(){f(e),t.onreadystatechange=null,r.removeChild(t),t=null},r.appendChild(t)}):function(e){setTimeout(f,0,e)},u.setImmediate=function(e){typeof e!=`function`&&(e=Function(``+e));for(var t=Array(arguments.length-1),r=0;r`u`?e===void 0?this:e:self)}).call(this,typeof global<`u`?global:typeof self<`u`?self:typeof window<`u`?window:{})},{}]},{},[10])(10)})}),Jb=Et(qb());Lm.zipReader=(e,t)=>Jb.default.loadAsync(e);const Yb=Lm.createSettings;Lm.createSettings=async e=>{let t=Object.keys(e.files);return t.find(e=>Xb(e))?Yb(e):$b(t)};function Xb(e){return e.endsWith(`model3.json`)}function Zb(e){return e.endsWith(`.moc3`)}function Qb(e){return e.split(/[\\/]/).pop()}function $b(e){let t=e.filter(e=>Zb(e));if(t.length!==1){let e=t.length?`(${t.map(e=>`"${e}"`).join(`,`)})`:``;throw Error(`Expected exactly one moc file, got ${t.length} ${e}`)}let n=t[0],r=Qb(n).replace(/\.moc3?/,``),i=e.filter(e=>e.endsWith(`.png`));if(!i.length)throw Error(`Textures not found`);let a=e.filter(e=>e.endsWith(`.mtn`)||e.endsWith(`.motion3.json`)),o=e.find(e=>e.includes(`physics`)),s=e.find(e=>e.includes(`pose`)),c=new zm({url:`${r}.model3.json`,Version:3,FileReferences:{Moc:n,Textures:i,Physics:o,Pose:s,Motions:a.length?{"":a.map(e=>({File:e}))}:void 0}});return c.name=r,c._objectURL=`example://${c.url}`,c}Lm.readText=(e,t)=>{let n=e.file(t);if(!n)throw Error(`Cannot find file: ${t}`);return n.async(`text`)},Lm.getFilePaths=e=>{let t=[];return e.forEach(e=>t.push(e)),Promise.resolve(t)},Lm.getFiles=(e,t)=>Promise.all(t.map(async t=>{let n=t.slice(t.lastIndexOf(`/`)+1),r=await e.file(t).async(`blob`);return new File([r],n)}));const ex={absolute:``,bottom:`3`,right:`3`},tx={flex:`~ row`,"cursor-pointer":``},nx=[`checked`,`aria-checked`],rx={key:0,"min-w":`50vw`,z:`(U(),At(Kb,{relative:``},{default:Ln(({width:i,height:o})=>[Nt(Ym,{width:i,height:o,resolution:2,"max-h":`100dvh`},{default:Ln(({app:t})=>[Nt(Ov,{app:t,"mouth-open-size":e.mouthOpenSize,width:i,height:o,paused:e.paused,"focus-at":e.focusAt},null,8,[`app`,`mouth-open-size`,`width`,`height`,`paused`,`focus-at`])]),_:2},1032,[`width`,`height`]),B(`div`,ex,[B(`div`,tx,[B(`label`,{class:Jt([n.value?`bg-neutral-300 dark:bg-neutral-200`:`bg-neutral-100 dark:bg-neutral-700`]),transition:`all ease-in-out duration-500`,text:`lg neutral-500 dark:neutral-400`,"m-1":``,"h-fit":``,"w-fit":``,"cursor-pointer":``,"appearance-none":``,"gap-1":``,"rounded-lg":``,"rounded-md":``,"border-none":``,"p-2":``,"outline-none":``},[Rn(B(`input`,{"onUpdate:modelValue":a[0]||=e=>n.value=e,checked:n.value,"aria-checked":n.value,name:`showLive2DViewerInspector`,type:`checkbox`,"appearance-none":``,"outline-none":``,hidden:``},null,8,nx),[[An,n.value]]),a[8]||=B(`div`,{"select-none":``},[B(`div`,{"i-solar:bug-bold-duotone":``})],-1)],2)]),Nt(G(Jn),null,{default:Ln(()=>[n.value?(U(),V(`div`,rx,[B(`div`,ix,[B(`div`,ax,[B(`span`,null,mn(G(t)(`stage.viewers.debug-menu.emotions`)),1)]),B(`div`,ox,[B(`button`,{"rounded-lg":``,bg:`neutral-100/70 dark:neutral-800/50`,"px-2":``,"py-1":``,"backdrop-blur-sm":``,onClick:a[1]||=e=>r.value={group:`Surprise`,index:0}},mn(G(t)(`stage.viewers.debug-menu.emotions-btn.surprised`)),1),B(`button`,{"rounded-lg":``,bg:`neutral-100/70 dark:neutral-800/50`,"px-2":``,"py-1":``,"backdrop-blur-sm":``,onClick:a[2]||=e=>r.value={group:`Sad`,index:0}},mn(G(t)(`stage.viewers.debug-menu.emotions-btn.sad`)),1),B(`button`,{"rounded-lg":``,bg:`neutral-100/70 dark:neutral-800/50`,"px-2":``,"py-1":``,"backdrop-blur-sm":``,onClick:a[3]||=e=>r.value={group:`Angry`,index:0}},mn(G(t)(`stage.viewers.debug-menu.emotions-btn.angry`)),1),B(`button`,{"rounded-lg":``,bg:`neutral-100/70 dark:neutral-800/50`,"px-2":``,"py-1":``,"backdrop-blur-sm":``,onClick:a[4]||=e=>r.value={group:`Happy`,index:0}},mn(G(t)(`stage.viewers.debug-menu.emotions-btn.happy`)),1),B(`button`,{"rounded-lg":``,bg:`neutral-100/70 dark:neutral-800/50`,"px-2":``,"py-1":``,"backdrop-blur-sm":``,onClick:a[5]||=e=>r.value={group:`Awkward`,index:0}},mn(G(t)(`stage.viewers.debug-menu.emotions-btn.awkward`)),1),B(`button`,{"rounded-lg":``,bg:`neutral-100/70 dark:neutral-800/50`,"px-2":``,"py-1":``,"backdrop-blur-sm":``,onClick:a[6]||=e=>r.value={group:`Question`,index:0}},mn(G(t)(`stage.viewers.debug-menu.emotions-btn.question`)),1),B(`button`,{"rounded-lg":``,bg:`neutral-100/70 dark:neutral-800/50`,"px-2":``,"py-1":``,"backdrop-blur-sm":``,onClick:a[7]||=e=>r.value={group:`Think`,index:0}},mn(G(t)(`stage.viewers.debug-menu.emotions-btn.think`)),1)])])])):jt(``,!0)]),_:1})])]),_:1}))}}),cx=sx,lx=Object.defineProperty,ux=(e,t,n)=>t in e?lx(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,dx=(e,t,n)=>ux(e,typeof t==`symbol`?t:t+``,n);function fx(e){return zt()?(en(e),!0):!1}function px(e){return typeof e==`function`?e():G(e)}const mx=typeof window<`u`&&typeof document<`u`;typeof WorkerGlobalScope<`u`&&globalThis instanceof WorkerGlobalScope;const hx=Object.prototype.toString,gx=e=>hx.call(e)===`[object Object]`,_x=()=>{};function vx(e,t){function n(...n){return new Promise((r,i)=>{Promise.resolve(e(()=>t.apply(this,n),{fn:t,thisArg:this,args:n})).then(r).catch(i)})}return n}function yx(e,t={}){let n,r,i=_x,a=e=>{clearTimeout(e),i(),i=_x};return o=>{let s=px(e),c=px(t.maxWait);return n&&a(n),s<=0||c!==void 0&&c<=0?(r&&(a(r),r=null),Promise.resolve(o())):new Promise((e,l)=>{i=t.rejectOnCancel?l:e,c&&!r&&(r=setTimeout(()=>{n&&a(n),r=null,e(o())},c)),n=setTimeout(()=>{r&&a(r),r=null,e(o())},s)})}}function bx(...e){let t=0,n,r=!0,i=_x,a,o,s,c,l;!Wt(e[0])&&typeof e[0]==`object`?{delay:o,trailing:s=!0,leading:c=!0,rejectOnCancel:l=!1}=e[0]:[o,s=!0,c=!0,l=!1]=e;let u=()=>{n&&(clearTimeout(n),n=void 0,i(),i=_x)};return e=>{let d=px(o),f=Date.now()-t,p=()=>a=e();return u(),d<=0?(t=Date.now(),p()):(f>d&&(c||!r)?(t=Date.now(),p()):s&&(a=new Promise((e,a)=>{i=l?a:e,n=setTimeout(()=>{t=Date.now(),r=!0,e(p()),u()},Math.max(0,d-f))})),!c&&!n&&(n=setTimeout(()=>r=!0,d)),r=!1,a)}}function xx(e){return Rt()}function Sx(e,t=200,n={}){return vx(yx(t,n),e)}function Cx(e,t=200,n=!1,r=!0,i=!1){return vx(bx(t,n,r,i),e)}function wx(e,t=!0,n){xx()?$t(e,n):t?e():qt(e)}const Tx=mx?window:void 0;function Ex(e){var t;let n=px(e);return(t=n?.$el)??n}function Dx(...e){let t,n,r,i;if(typeof e[0]==`string`||Array.isArray(e[0])?([n,r,i]=e,t=Tx):[t,n,r,i]=e,!t)return _x;Array.isArray(n)||(n=[n]),Array.isArray(r)||(r=[r]);let a=[],o=()=>{a.forEach(e=>e()),a.length=0},s=(e,t,n,r)=>(e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)),c=K(()=>[Ex(t),px(i)],([e,t])=>{if(o(),!e)return;let i=gx(t)?{...t}:t;a.push(...n.flatMap(t=>r.map(n=>s(e,t,n,i))))},{immediate:!0,flush:`post`}),l=()=>{c(),o()};return fx(l),l}function Ox(){let e=W(!1),t=Rt();return t&&$t(()=>{e.value=!0},t),e}function kx(e){let t=Ox();return kt(()=>(t.value,!!e()))}function Ax(e,t={}){let{window:n=Tx}=t,r=kx(()=>n&&`matchMedia`in n&&typeof n.matchMedia==`function`),i,a=W(!1),o=e=>{a.value=e.matches},s=()=>{i&&(`removeEventListener`in i?i.removeEventListener(`change`,o):i.removeListener(o))},c=Fn(()=>{r.value&&(s(),i=n.matchMedia(px(e)),`addEventListener`in i?i.addEventListener(`change`,o):i.addListener(o),a.value=i.matches)});return fx(()=>{c(),s(),i=void 0}),a}function jx(e,t,n={}){let{window:r=Tx,...i}=n,a,o=kx(()=>r&&`ResizeObserver`in r),s=()=>{a&&(a.disconnect(),a=void 0)},c=kt(()=>{let t=px(e);return Array.isArray(t)?t.map(e=>Ex(e)):[Ex(t)]}),l=K(c,e=>{if(s(),o.value&&r){a=new ResizeObserver(t);for(let t of e)t&&a.observe(t,i)}},{immediate:!0,flush:`post`}),u=()=>{s(),l()};return fx(u),{isSupported:o,stop:u}}function Mx(e,t={width:0,height:0},n={}){let{window:r=Tx,box:i=`content-box`}=n,a=kt(()=>{var t,n;return(n=(t=Ex(e))?.namespaceURI)?.includes(`svg`)}),o=W(t.width),s=W(t.height),{stop:c}=jx(e,([t])=>{let n=i===`border-box`?t.borderBoxSize:i===`content-box`?t.contentBoxSize:t.devicePixelContentBoxSize;if(r&&a.value){let t=Ex(e);if(t){let e=t.getBoundingClientRect();o.value=e.width,s.value=e.height}}else if(n){let e=Array.isArray(n)?n:[n];o.value=e.reduce((e,{inlineSize:t})=>e+t,0),s.value=e.reduce((e,{blockSize:t})=>e+t,0)}else o.value=t.contentRect.width,s.value=t.contentRect.height},n);wx(()=>{let n=Ex(e);n&&(o.value=`offsetWidth`in n?n.offsetWidth:t.width,s.value=`offsetHeight`in n?n.offsetHeight:t.height)});let l=K(()=>Ex(e),e=>{o.value=e?t.width:0,s.value=e?t.height:0});function u(){c(),l()}return{width:o,height:s,stop:u}}const Nx=1;function Px(e,t={}){let{throttle:n=0,idle:r=200,onStop:i=_x,onScroll:a=_x,offset:o={left:0,right:0,top:0,bottom:0},eventListenerOptions:s={capture:!1,passive:!0},behavior:c=`auto`,window:l=Tx,onError:u=e=>{console.error(e)}}=t,d=W(0),f=W(0),p=kt({get(){return d.value},set(e){h(e,void 0)}}),m=kt({get(){return f.value},set(e){h(void 0,e)}});function h(t,n){var r,i,a,o;if(!l)return;let s=px(e);if(!s)return;(a=s instanceof Document?l.document.body:s)==null||a.scrollTo({top:(r=px(n))??m.value,left:(i=px(t))??p.value,behavior:px(c)});let u=(o=s?.document)?.documentElement||s?.documentElement||s;p!=null&&(d.value=u.scrollLeft),m!=null&&(f.value=u.scrollTop)}let g=W(!1),_=rn({left:!0,right:!1,top:!0,bottom:!1}),v=rn({left:!1,right:!1,top:!1,bottom:!1}),y=e=>{g.value&&(g.value=!1,v.left=!1,v.right=!1,v.top=!1,v.bottom=!1,i(e))},b=Sx(y,n+r),x=e=>{var t;if(!l)return;let n=(t=e?.document)?.documentElement||e?.documentElement||Ex(e),{display:r,flexDirection:i}=getComputedStyle(n),a=n.scrollLeft;v.left=ad.value;let s=Math.abs(a)<=(o.left||0),c=Math.abs(a)+n.clientWidth>=n.scrollWidth-(o.right||0)-Nx;r===`flex`&&i===`row-reverse`?(_.left=c,_.right=s):(_.left=s,_.right=c),d.value=a;let u=n.scrollTop;e===l.document&&!u&&(u=l.document.body.scrollTop),v.top=uf.value;let p=Math.abs(u)<=(o.top||0),m=Math.abs(u)+n.clientHeight>=n.scrollHeight-(o.bottom||0)-Nx;r===`flex`&&i===`column-reverse`?(_.top=m,_.bottom=p):(_.top=p,_.bottom=m),f.value=u},S=e=>{var t;if(!l)return;let n=(t=e.target.documentElement)??e.target;x(n),g.value=!0,b(e),a(e)};return Dx(e,`scroll`,n?Cx(S,n,!0,!1):S,s),wx(()=>{try{let t=px(e);if(!t)return;x(t)}catch(e){u(e)}}),Dx(e,`scrollend`,y,s),{x:p,y:m,isScrolling:g,arrivedState:_,directions:v,measure(){let t=px(e);l&&t&&x(t)}}}const Fx={ctrl:`control`,command:`meta`,cmd:`meta`,option:`alt`,up:`arrowup`,down:`arrowdown`,left:`arrowleft`,right:`arrowright`};function Ix(e={}){let{reactive:t=!1,target:n=Tx,aliasMap:r=Fx,passive:i=!0,onEventFired:a=_x}=e,o=rn(new Set),s={toJSON(){return{}},current:o},c=t?rn(s):s,l=new Set,u=new Set;function d(e,n){e in c&&(t?c[e]=n:c[e].value=n)}function f(){o.clear();for(let e of u)d(e,!1)}function p(e,t){var n,r;let i=(n=e.key)?.toLowerCase(),a=[(r=e.code)?.toLowerCase(),i].filter(Boolean);i&&(t?o.add(i):o.delete(i));for(let e of a)u.add(e),d(e,t);i===`meta`&&!t?(l.forEach(e=>{o.delete(e),d(e,!1)}),l.clear()):typeof e.getModifierState==`function`&&e.getModifierState(`Meta`)&&t&&[...o,...a].forEach(e=>l.add(e))}Dx(n,`keydown`,e=>(p(e,!0),a(e)),{passive:i}),Dx(n,`keyup`,e=>(p(e,!1),a(e)),{passive:i}),Dx(`blur`,f,{passive:!0}),Dx(`focus`,f,{passive:!0});let m=new Proxy(c,{get(e,n,i){if(typeof n!=`string`)return Reflect.get(e,n,i);if(n=n.toLowerCase(),n in r&&(n=r[n]),!(n in c))if(/[+_-]/.test(n)){let e=n.split(/[+_-]/g).map(e=>e.trim());c[n]=kt(()=>e.every(e=>px(m[e])))}else c[n]=W(!1);let a=Reflect.get(e,n,i);return t?px(a):a}});return m}const Lx={page:e=>[e.pageX,e.pageY],client:e=>[e.clientX,e.clientY],screen:e=>[e.screenX,e.screenY],movement:e=>e instanceof Touch?null:[e.movementX,e.movementY]};function Rx(e={}){let{type:t=`page`,touch:n=!0,resetOnTouchEnds:r=!1,initialValue:i={x:0,y:0},window:a=Tx,target:o=a,scroll:s=!0,eventFilter:c}=e,l=null,u=0,d=0,f=W(i.x),p=W(i.y),m=W(null),h=typeof t==`function`?t:Lx[t],g=e=>{let t=h(e);l=e,t&&([f.value,p.value]=t,m.value=`mouse`),a&&(u=a.scrollX,d=a.scrollY)},_=e=>{if(e.touches.length>0){let t=h(e.touches[0]);t&&([f.value,p.value]=t,m.value=`touch`)}},v=()=>{if(!l||!a)return;let e=h(l);l instanceof MouseEvent&&e&&(f.value=e[0]+a.scrollX-u,p.value=e[1]+a.scrollY-d)},y=()=>{f.value=i.x,p.value=i.y},b=c?e=>c(()=>g(e),{}):e=>g(e),x=c?e=>c(()=>_(e),{}):e=>_(e),S=c?()=>c(()=>v(),{}):()=>v();if(o){let e={passive:!0};Dx(o,[`mousemove`,`dragover`],b,e),n&&t!==`movement`&&(Dx(o,[`touchstart`,`touchmove`],x,e),r&&Dx(o,`touchend`,y,e)),s&&t===`page`&&Dx(a,`scroll`,S,{passive:!0})}return{x:f,y:p,sourceType:m}}function zx(e={}){let{window:t=Tx,behavior:n=`auto`}=e;if(!t)return{x:W(0),y:W(0)};let r=W(t.scrollX),i=W(t.scrollY),a=kt({get(){return r.value},set(e){scrollTo({left:e,behavior:n})}}),o=kt({get(){return i.value},set(e){scrollTo({top:e,behavior:n})}});return Dx(t,`scroll`,()=>{r.value=t.scrollX,i.value=t.scrollY},{capture:!1,passive:!0}),{x:a,y:o}}function Bx(e={}){let{window:t=Tx,initialWidth:n=1/0,initialHeight:r=1/0,listenOrientation:i=!0,includeScrollbar:a=!0,type:o=`inner`}=e,s=W(n),c=W(r),l=()=>{t&&(o===`outer`?(s.value=t.outerWidth,c.value=t.outerHeight):a?(s.value=t.innerWidth,c.value=t.innerHeight):(s.value=t.document.documentElement.clientWidth,c.value=t.document.documentElement.clientHeight))};if(l(),wx(l),Dx(`resize`,l,{passive:!0}),i){let e=Ax(`(orientation: portrait)`);K(e,()=>l())}return{width:s,height:c}}function Vx(e){let{resolution:t,renderer:n,scene:r,envMap:i,fog:a,near:o,far:s}=e;n??=fn().renderer,r??=fn().scene,Fn(()=>{t=vn(e.resolution)??255,o=vn(e.near)??.1,s=vn(e.far)??1e3,i=vn(e.envMap)??void 0,a=vn(e.fog)??void 0,n=vn(e.renderer)??n,r=vn(e.scene)??r});let c=kt(()=>new _t(vn(t)));c.value.texture.type=te,fx(()=>{c.value.dispose()});let l=kt(()=>new _(vn(o),vn(s),vn(c))),u=()=>{let e=vn(r),t=e.fog,o=e.background;e.background=vn(i)||o,e.fog=vn(a)||t,l.value.update(vn(n),e),e.fog=t,e.background=o};return Fn(u),{fbo:c,camera:l,update:u}}const Hx=[`object`],Ux=H({__name:`component`,props:{frames:{default:1/0},resolution:{},near:{},far:{},envMap:{},fog:{},renderer:{},scene:{}},setup(e,{expose:t}){let n=e,r=dn(),{fbo:i,camera:a,update:o}=Vx(n),s=0;return Ht().onBeforeRender(()=>{r.value&&(n.frames===1/0||s{`material`in e&&typeof e.material==`object`&&e.material&&`envMap`in e.material&&(e.material.envMap=i.value.texture)}),s++)}),t({instance:r,fbo:i,camera:a,update:o}),(e,t)=>(U(),V(`TresGroup`,{ref_key:`groupRef`,ref:r},[B(`primitive`,{object:G(a)},null,8,Hx),sn(e.$slots,`default`)],512))}}),Wx=H({__name:`Billboard`,props:{autoUpdate:{type:Boolean,default:!0},lockX:{type:Boolean,default:!1},lockY:{type:Boolean,default:!1},lockZ:{type:Boolean,default:!1}},setup(e,{expose:t}){let n=e,r=dn(new I),i=dn(new I),a=new Be,o=new k;function s(e){r.value&&(!e&&(e=fn().camera.value,!e)||(i.value.rotation.copy(o),r.value.updateMatrix(),r.value.updateWorldMatrix(!1,!1),r.value.getWorldQuaternion(a),e.getWorldQuaternion(i.value.quaternion).premultiply(a.invert()),n.lockX&&(i.value.rotation.x=o.x),n.lockY&&(i.value.rotation.y=o.y),n.lockZ&&(i.value.rotation.z=o.z)))}return Ht().onBeforeRender(({camera:e})=>{n.autoUpdate&&s(e)}),t({instance:r,update:s}),(e,t)=>(U(),V(`TresGroup`,{ref_key:`outerRef`,ref:r},[B(`TresGroup`,{ref_key:`innerRef`,ref:i},[sn(e.$slots,`default`)],512)],512))}}),Gx=H({name:`GlobalAudio`,props:[`src`,`loop`,`volume`,`playbackRate`,`playTrigger`,`stopTrigger`],async setup(e,{expose:t,emit:n}){var r;let{camera:s,renderer:c}=nn(),l=new a;(r=s.value)==null||r.add(l);let u=new i(l),d=new o;t({instance:u}),tn(()=>{u&&u.disconnect()}),K(()=>[e.playbackRate],()=>u.setPlaybackRate(e.playbackRate??1),{immediate:!0}),K(()=>[e.volume],()=>u.setVolume(e.volume??.5),{immediate:!0}),K(()=>[e.loop],()=>u.setLoop(e.loop??!1),{immediate:!0}),K(()=>[e.src],async()=>{let t=await d.loadAsync(e.src);u.setBuffer(t)},{immediate:!0});let f=document.getElementById(e.playTrigger??``)||c.value.domElement;Dx(f,`click`,()=>{u.isPlaying?u.pause():u.play(),n(`isPlaying`,u.isPlaying)});let p=document.getElementById(e.stopTrigger??``);return p&&Dx(p,`click`,()=>{u.stop(),n(`isPlaying`,u.isPlaying)}),null}}),Kx=[`color-space`,`args`,`attach`],qx=H({__name:`GradientTexture`,props:{stops:{},colors:{},attach:{default:`map`},height:{default:1024},width:{default:16},type:{default:`linear`},innerCircleRadius:{default:0},outerCircleRadius:{default:`auto`}},setup(e,{expose:t}){let n=e,r=dn(),i=document.createElement(`canvas`);function a(e){let t=e.getContext(`2d`);e.width=n.width,e.height=n.height;let i;if(n.type===`linear`)i=t.createLinearGradient(0,0,0,n.height);else{let r=e.width/2,a=e.height/2,o=n.outerCircleRadius===`auto`?Math.sqrt(r**2+a**2):Math.abs(Number(n.outerCircleRadius));i=t.createRadialGradient(r,a,Math.abs(n.innerCircleRadius),r,a,o)}let a=new h,o=n.stops.length;for(;o--;)i.addColorStop(n.stops[o],a.set(n.colors[o]).getStyle());t.save(),t.fillStyle=i,t.fillRect(0,0,n.width,n.height),t.restore(),r.value&&(r.value.needsUpdate=!0)}let o=fn().renderer;return K(()=>[n.colors,n.stops,n.height,n.width,n.type,n.innerCircleRadius,n.outerCircleRadius],()=>{a(i)},{immediate:!0}),Ut(n.colors)&&K(n.colors,()=>a(i)),Ut(n.stops)&&K(n.stops,()=>a(i)),t({instance:r}),(e,t)=>(U(),V(`TresCanvasTexture`,{ref_key:`textureRef`,ref:r,"color-space":G(o).outputColorSpace,args:[G(i)],attach:n.attach},null,8,Kx))}});function Jx(e,t,n,r){let i=class extends Xe{constructor(r={}){let i=Object.entries(e);super({uniforms:i.reduce((e,[t,n])=>{let r=pt.clone({[t]:{value:n}});return{...e,...r}},{}),vertexShader:t,fragmentShader:n}),dx(this,`key`,``),i.forEach(([e])=>Object.defineProperty(this,e,{get:()=>this.uniforms[e].value,set:t=>this.uniforms[e].value=t})),Object.assign(this,r)}};return i.key=_e.generateUUID(),i}const Yx=Jx({color:new h(`white`),scale:new mt(1,1),imageBounds:new mt(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 + } + `),Xx=H({__name:`ImageMaterial`,setup(e,{expose:t}){D({ImageMaterial:Yx});let n=dn();return t({instance:n}),(e,t)=>(U(),V(`TresImageMaterial`,{ref_key:`materialRef`,ref:n},null,512))}}),Zx=[`scale`],Qx=[`args`],$x=H({__name:`component`,props:{segments:{default:1},scale:{default:1},color:{default:()=>new h(`white`)},zoom:{default:1},radius:{default:0},grayscale:{default:0},toneMapped:{type:Boolean,default:!0},transparent:{type:Boolean,default:!1},opacity:{default:1},side:{default:F},texture:{},url:{}},setup(e,{expose:t}){let n=e,r=dn(),i=dn(n.texture??null),a=fn().sizes,o=kt(()=>Array.isArray(n.scale)?[n.scale[0],n.scale[1]]:[n.scale,n.scale]),s=kt(()=>{var e,t;return[(e=i.value)?.image.width??0,(t=i.value)?.image.height??0]}),c=kt(()=>Math.max(a.width.value,a.height.value));Fn(()=>{n.texture?i.value=n.texture:Ft([n.url]).then(e=>i.value=e)});let l=kt(()=>Array.isArray(n.scale)?[...n.scale,1]:n.scale);return t({instance:r}),(e,t)=>(U(),V(`TresMesh`,{ref_key:`imageRef`,ref:r,scale:l.value},[sn(e.$slots,`default`,{},()=>[B(`TresPlaneGeometry`,{args:[1,1,n.segments,n.segments]},null,8,Qx)]),Nt(Xx,{color:n.color,map:i.value,zoom:n.zoom,grayscale:n.grayscale,opacity:n.opacity,scale:o.value,imageBounds:s.value,resolution:c.value,radius:e.radius,toneMapped:e.toneMapped,transparent:e.transparent,side:e.side},null,8,[`color`,`map`,`zoom`,`grayscale`,`opacity`,`scale`,`imageBounds`,`resolution`,`radius`,`toneMapped`,`transparent`,`side`])],8,Zx))}}),eS=parseInt(Ve.replace(/\D+/g,``)),tS=eS>=125?`uv1`:`uv2`;function nS(e,t=Math.PI/3){let n=Math.cos(t),r=1.0000000001*100,i=[new z,new z,new z],a=new z,o=new z,s=new z,c=new z;function l(e){let t=~~(e.x*r),n=~~(e.y*r),i=~~(e.z*r);return`${t},${n},${i}`}let u=e.index?e.toNonIndexed():e,f=u.attributes.position,p={};for(let e=0,t=f.count/3;en&&c.add(t)}c.normalize(),h.setXYZ(t+e,c.x,c.y,c.z)}}return u.setAttribute(`normal`,h),u}var rS=Object.defineProperty,iS=(e,t,n)=>t in e?rS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,aS=(e,t,n)=>(iS(e,t+``,n),n);async function oS(e){let t=await e.arrayBuffer(),n=btoa(String.fromCharCode(...new Uint8Array(t)));return`data:${e.type||``};base64,${n}`}let sS,cS,lS,uS;function dS(e,t=1/0,n=null){cS||=new Ie(2,2,1,1),lS||=new Xe({uniforms:{blitTexture:new dt(e)},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 + } + `}),lS.uniforms.blitTexture.value=e,lS.defines.IS_SRGB=`colorSpace`in e?e.colorSpace===`srgb`:e.encoding===3001,lS.needsUpdate=!0,uS||(uS=new be(cS,lS),uS.frustrumCulled=!1);let r=new Pe,i=new Je;i.add(uS),n||=sS=new yt({antialias:!1}),n.setSize(Math.min(e.image.width,t),Math.min(e.image.height,t)),n.clear(),n.render(i,r);let a=new ot(n.domElement);return a.minFilter=e.minFilter,a.magFilter=e.magFilter,a.wrapS=e.wrapS,a.wrapT=e.wrapT,a.name=e.name,sS&&(sS.dispose(),sS=null),a}const fS={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`]};var pS=class{constructor(){this.pluginCallbacks=[],this.register(function(e){return new PS(e)}),this.register(function(e){return new FS(e)}),this.register(function(e){return new RS(e)}),this.register(function(e){return new zS(e)}),this.register(function(e){return new BS(e)}),this.register(function(e){return new VS(e)}),this.register(function(e){return new IS(e)}),this.register(function(e){return new LS(e)}),this.register(function(e){return new HS(e)}),this.register(function(e){return new US(e)}),this.register(function(e){return new WS(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,t,n,r){let i=new NS,a=[];for(let e=0,t=this.pluginCallbacks.length;ee.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<.001)return e.times.length-1;r[r.length-1]=t,r.set(e.times,0),i.set(e.values,0),i.set(a.evaluate(t),e.values.length),o=r.length-1}else for(let s=0;st){r.set(e.times.slice(0,s+1),0),r[s+1]=t,r.set(e.times.slice(s+1),s+2),i.set(e.values.slice(0,(s+1)*n),0),i.set(a.evaluate(t),(s+1)*n),i.set(e.values.slice((s+1)*n),(s+2)*n),o=s+1;break}}return e.times=r,e.values=i,o},mergeMorphTargetTracks:function(e,t){let n=[],r={},i=e.tracks;for(let e=0;e4?n=e.array[i*e.itemSize+t]:(t===0?n=e.getX(i):t===1?n=e.getY(i):t===2?n=e.getZ(i):t===3&&(n=e.getW(i)),e.normalized===!0&&(n=_e.normalize(n,e.array))),r.min[t]=Math.min(r.min[t],n),r.max[t]=Math.max(r.max[t],n)}return r}function kS(e){return Math.ceil(e/4)*4}function AS(e,t=0){let n=kS(e.byteLength);if(n!==e.byteLength){let r=new Uint8Array(n);if(r.set(new Uint8Array(e)),t!==0)for(let i=e.byteLength;i`u`&&typeof OffscreenCanvas<`u`?new OffscreenCanvas(1,1):document.createElement(`canvas`)}function MS(e,t){if(e.toBlob!==void 0)return new Promise(n=>e.toBlob(n,t));let n;return t===`image/jpeg`?n=.92:t===`image/webp`&&(n=.8),e.convertToBlob({type:t,quality:n})}var NS=class{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,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);let r=this,i=r.buffers,a=r.json;n=r.options;let o=r.extensionsUsed,s=r.extensionsRequired,c=new Blob(i,{type:`application/octet-stream`}),l=Object.keys(o),u=Object.keys(s);l.length>0&&(a.extensionsUsed=l),u.length>0&&(a.extensionsRequired=u),a.buffers&&a.buffers.length>0&&(a.buffers[0].byteLength=c.size),n.binary===!0?c.arrayBuffer().then(e=>{let n=AS(e),r=new DataView(new ArrayBuffer(SS));r.setUint32(0,n.byteLength,!0),r.setUint32(4,wS,!0);let i=AS(ES(JSON.stringify(a)),32),o=new DataView(new ArrayBuffer(SS));o.setUint32(0,i.byteLength,!0),o.setUint32(4,CS,!0);let s=new ArrayBuffer(yS),c=new DataView(s);c.setUint32(0,bS,!0),c.setUint32(4,xS,!0);let l=yS+o.byteLength+i.byteLength+r.byteLength+n.byteLength;c.setUint32(8,l,!0),new Blob([s,o,i,r,n],{type:`application/octet-stream`}).arrayBuffer().then(t)}):a.buffers&&a.buffers.length>0?oS(c).then(e=>{a.buffers[0].uri=e,t(a)}):t(a)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;let n=this.options,r=this.extensionsUsed;try{let i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){for(let e in t.extensions===void 0&&(t.extensions={}),i.gltfExtensions)t.extensions[e]=i.gltfExtensions[e],r[e]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(t.extras=i)}catch(t){console.warn(`THREE.GLTFExporter: userData of '`+e.name+`' won't be serialized because of JSON.stringify error - `+t.message)}}getUID(e,t=!1){if(this.uids.has(e)===!1){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let t=new z;for(let n=0,r=e.count;n5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let n=e.clone(),r=new z;for(let e=0,t=n.count;e4?r=e.array[i*e.itemSize+n]:(n===0?r=e.getX(i):n===1?r=e.getY(i):n===2?r=e.getZ(i):n===3&&(r=e.getW(i)),e.normalized===!0&&(r=_e.normalize(r,e.array))),t===mS.FLOAT?c.setFloat32(l,r,!0):t===mS.INT?c.setInt32(l,r,!0):t===mS.UNSIGNED_INT?c.setUint32(l,r,!0):t===mS.SHORT?c.setInt16(l,r,!0):t===mS.UNSIGNED_SHORT?c.setUint16(l,r,!0):t===mS.BYTE?c.setInt8(l,r):t===mS.UNSIGNED_BYTE&&c.setUint8(l,r),l+=o}let u={buffer:this.processBuffer(c.buffer),byteOffset:this.byteOffset,byteLength:s};return i!==void 0&&(u.target=i),i===mS.ARRAY_BUFFER&&(u.byteStride=e.itemSize*o),this.byteOffset+=s,a.bufferViews.push(u),{id:a.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||=[],e.arrayBuffer().then(e=>{let r=AS(e),i={buffer:t.processBuffer(r),byteOffset:t.byteOffset,byteLength:r.byteLength};return t.byteOffset+=r.byteLength,n.bufferViews.push(i)-1})}processAccessor(e,t,n,r){let i=this.json,a={1:`SCALAR`,2:`VEC2`,3:`VEC3`,4:`VEC4`,9:`MAT3`,16:`MAT4`},o;if(e.array.constructor===Float32Array)o=mS.FLOAT;else if(e.array.constructor===Int32Array)o=mS.INT;else if(e.array.constructor===Uint32Array)o=mS.UNSIGNED_INT;else if(e.array.constructor===Int16Array)o=mS.SHORT;else if(e.array.constructor===Uint16Array)o=mS.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)o=mS.BYTE;else if(e.array.constructor===Uint8Array)o=mS.UNSIGNED_BYTE;else throw Error(`THREE.GLTFExporter: Unsupported bufferAttribute component type: `+e.array.constructor.name);if(n===void 0&&(n=0),r===void 0&&(r=e.count),r===0)return null;let s=OS(e,n,r),c;t!==void 0&&(c=e===t.index?mS.ELEMENT_ARRAY_BUFFER:mS.ARRAY_BUFFER);let l=this.processBufferView(e,o,n,r,c),u={bufferView:l.id,byteOffset:l.byteOffset,componentType:o,count:r,max:s.max,min:s.min,type:a[e.itemSize]};return e.normalized===!0&&(u.normalized=!0),i.accessors||=[],i.accessors.push(u)-1}processImage(e,t,n,r=`image/png`){if(e!==null){let i=this,a=i.cache,o=i.json,s=i.options,c=i.pending;a.images.has(e)||a.images.set(e,{});let l=a.images.get(e),u=r+`:flipY/`+n.toString();if(l[u]!==void 0)return l[u];o.images||=[];let d={mimeType:r},f=jS();f.width=Math.min(e.width,s.maxTextureSize),f.height=Math.min(e.height,s.maxTextureSize);let p=f.getContext(`2d`);if(n===!0&&(p.translate(0,f.height),p.scale(1,-1)),e.data!==void 0){t!==He&&console.error(`GLTFExporter: Only RGBAFormat is supported.`,t),(e.width>s.maxTextureSize||e.height>s.maxTextureSize)&&console.warn(`GLTFExporter: Image size is bigger than maxTextureSize`,e);let n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;ti.processBufferViewImage(e)).then(e=>{d.bufferView=e})):f.toDataURL===void 0?c.push(MS(f,r).then(oS).then(e=>{d.uri=e})):d.uri=f.toDataURL(r);let m=o.images.push(d)-1;return l[u]=m,m}else throw Error(`THREE.GLTFExporter: No valid image data found. Unable to process texture.`)}processSampler(e){let t=this.json;t.samplers||=[];let n={magFilter:gS[e.magFilter],minFilter:gS[e.minFilter],wrapS:gS[e.wrapS],wrapT:gS[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){let t=this.options,n=this.cache,r=this.json;if(n.textures.has(e))return n.textures.get(e);r.textures||=[],e instanceof g&&(e=dS(e,t.maxTextureSize));let i=e.userData.mimeType;i===`image/webp`&&(i=`image/png`);let a={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,i)};e.name&&(a.name=e.name),this._invokeAll(function(t){t.writeTexture&&t.writeTexture(e,a)});let o=r.textures.push(a)-1;return n.textures.set(e,o),o}processMaterial(e){let t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn(`GLTFExporter: THREE.ShaderMaterial not supported.`),null;n.materials||=[];let r={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn(`GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.`);let i=e.color.toArray().concat([e.opacity]);if(TS(i,[1,1,1,1])||(r.pbrMetallicRoughness.baseColorFactor=i),e.isMeshStandardMaterial?(r.pbrMetallicRoughness.metallicFactor=e.metalness,r.pbrMetallicRoughness.roughnessFactor=e.roughness):(r.pbrMetallicRoughness.metallicFactor=.5,r.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){let t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),n={index:this.processTexture(t),channel:t.channel};this.applyTextureTransform(n,t),r.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){let t={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),r.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){let t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(r.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let t={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),r.emissiveTexture=t}}if(e.normalMap){let t={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),r.normalTexture=t}if(e.aoMap){let t={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),r.occlusionTexture=t}e.transparent?r.alphaMode=`BLEND`:e.alphaTest>0&&(r.alphaMode=`MASK`,r.alphaCutoff=e.alphaTest),e.side===T&&(r.doubleSided=!0),e.name!==``&&(r.name=e.name),this.serializeUserData(e,r),this._invokeAll(function(t){t.writeMaterial&&t.writeMaterial(e,r)});let a=n.materials.push(r)-1;return t.materials.set(e,a),a}processMesh(e){let t=this.cache,n=this.json,r=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t=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`},p=a.getAttribute(`normal`);p!==void 0&&!this.isNormalizedNormalAttribute(p)&&(console.warn(`THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one.`),a.setAttribute(`normal`,this.createNormalizedNormalAttribute(p)));let m=null;for(let e in a.attributes){if(e.slice(0,5)===`morph`)continue;let n=a.attributes[e];if(e=f[e]||e.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(e)||(e=`_`+e),t.attributes.has(this.getUID(n))){c[e]=t.attributes.get(this.getUID(n));continue}m=null;let r=n.array;e===`JOINTS_0`&&!(r instanceof Uint16Array)&&!(r instanceof Uint8Array)&&(console.warn(`GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.`),m=new d(new Uint16Array(r),n.itemSize,n.normalized));let i=this.processAccessor(m||n,a);i!==null&&(e.startsWith(`_`)||this.detectMeshQuantization(e,n),c[e]=i,t.attributes.set(this.getUID(n),i))}if(p!==void 0&&a.setAttribute(`normal`,p),Object.keys(c).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){let n=[],r=[],i={};if(e.morphTargetDictionary!==void 0)for(let t in e.morphTargetDictionary)i[e.morphTargetDictionary[t]]=t;for(let o=0;o0&&(s.extras={},s.extras.targetNames=r)}let h=Array.isArray(e.material);if(h&&a.groups.length===0)return null;let g=h?e.material:[e.material],_=h?a.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,n=_.length;e0&&(n.targets=u),a.index!==null){let r=this.getUID(a.index);(_[e].start!==void 0||_[e].count!==void 0)&&(r+=`:`+_[e].start+`:`+_[e].count),t.attributes.has(r)?n.indices=t.attributes.get(r):(n.indices=this.processAccessor(a.index,a,_[e].start,_[e].count),t.attributes.set(r,n.indices)),n.indices===null&&delete n.indices}let r=this.processMaterial(g[_[e].materialIndex]);r!==null&&(n.material=r),l.push(n)}s.primitives=l,n.meshes||=[],this._invokeAll(function(t){t.writeMesh&&t.writeMesh(e,s)});let v=n.meshes.push(s)-1;return t.meshes.set(i,v),v}detectMeshQuantization(e,t){if(this.extensionsUsed[hS])return;let n;switch(t.array.constructor){case Int8Array:n=`byte`;break;case Uint8Array:n=`unsigned byte`;break;case Int16Array:n=`short`;break;case Uint16Array:n=`unsigned short`;break;default:return}t.normalized&&(n+=` normalized`);let r=e.split(`_`,1)[0];fS[r]&&fS[r].includes(n)&&(this.extensionsUsed[hS]=!0,this.extensionsRequired[hS]=!0)}processCamera(e){let t=this.json;t.cameras||=[];let n=e.isOrthographicCamera,r={type:n?`orthographic`:`perspective`};return n?r.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:_e.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==``&&(r.name=e.type),t.cameras.push(r)-1}processAnimation(e,t){let n=this.json,r=this.nodeMap;n.animations||=[],e=pS.Utils.mergeMorphTargetTracks(e.clone(),t);let i=e.tracks,a=[],o=[];for(let e=0;e0){let t=[];for(let r=0,i=e.children.length;r0&&(i.children=t)}this._invokeAll(function(t){t.writeNode&&t.writeNode(e,i)});let a=t.nodes.push(i)-1;return r.set(e,a),a}processScene(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let r={};e.name!==``&&(r.name=e.name),t.scenes.push(r);let i=[];for(let t=0,r=e.children.length;t0&&(r.nodes=i),this.serializeUserData(e,r)}processObjects(e){let t=new Je;t.name=`AuxScene`;for(let n=0;n0&&this.processObjects(n);for(let e=0;e0&&(a.range=e.distance)):e.isSpotLight&&(a.type=`spot`,e.distance>0&&(a.range=e.distance),a.spot={},a.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,a.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.`),i[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},i[this.name]=!0);let o=r.extensions[this.name].lights;o.push(a),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}};let FS=class{constructor(e){this.writer=e,this.name=`KHR_materials_unlit`}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},IS=class{constructor(e){this.writer=e,this.name=`KHR_materials_clearcoat`}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){let t={index:n.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(t,e.clearcoatMap),i.clearcoatTexture=t}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let t={index:n.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(t,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){let t={index:n.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};n.applyTextureTransform(t,e.clearcoatNormalMap),i.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},LS=class{constructor(e){this.writer=e,this.name=`KHR_materials_iridescence`}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){let t={index:n.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(t,e.iridescenceMap),i.iridescenceTexture=t}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let t={index:n.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(t,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},RS=class{constructor(e){this.writer=e,this.name=`KHR_materials_transmission`}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){let t={index:n.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(t,e.transmissionMap),i.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},zS=class{constructor(e){this.writer=e,this.name=`KHR_materials_volume`}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){let t={index:n.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(t,e.thicknessMap),i.thicknessTexture=t}i.attenuationDistance=e.attenuationDistance,i.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},BS=class{constructor(e){this.writer=e,this.name=`KHR_materials_ior`}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;let n=this.writer.extensionsUsed,r={};r.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}},VS=class{constructor(e){this.writer=e,this.name=`KHR_materials_specular`}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(vS)&&!e.specularIntensityMap&&!e.specularColorTexture)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.specularIntensityMap){let t={index:n.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(t,e.specularIntensityMap),i.specularTexture=t}if(e.specularColorMap){let t={index:n.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(t,e.specularColorMap),i.specularColorTexture=t}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},HS=class{constructor(e){this.writer=e,this.name=`KHR_materials_sheen`}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.sheenRoughnessMap){let t={index:n.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(t,e.sheenRoughnessMap),i.sheenRoughnessTexture=t}if(e.sheenColorMap){let t={index:n.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(t,e.sheenColorMap),i.sheenColorTexture=t}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},US=class{constructor(e){this.writer=e,this.name=`KHR_materials_anisotropy`}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.anisotropyMap){let t={index:n.processTexture(e.anisotropyMap)};n.applyTextureTransform(t,e.anisotropyMap),i.anisotropyTexture=t}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},WS=class{constructor(e){this.writer=e,this.name=`KHR_materials_emissive_strength`}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;let n=this.writer.extensionsUsed,r={};r.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}};var GS=Uint8Array,KS=Uint16Array,qS=Uint32Array,JS=new GS([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]),YS=new GS([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]),XS=new GS([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ZS=function(e,t){for(var n=new KS(31),r=0;r<31;++r)n[r]=t+=1<>>1|(iC&21845)<<1;aC=(aC&52428)>>>2|(aC&13107)<<2,aC=(aC&61680)>>>4|(aC&3855)<<4,rC[iC]=((aC&65280)>>>8|(aC&255)<<8)>>>1}for(var oC=function(e,t,n){for(var r=e.length,i=0,a=new KS(t);i>>c]=l}else for(s=new KS(r),i=0;i>>15-e[i]);return s},sC=new GS(288),iC=0;iC<144;++iC)sC[iC]=8;for(var iC=144;iC<256;++iC)sC[iC]=9;for(var iC=256;iC<280;++iC)sC[iC]=7;for(var iC=280;iC<288;++iC)sC[iC]=8;for(var cC=new GS(32),iC=0;iC<32;++iC)cC[iC]=5;var lC=oC(sC,9,1),uC=oC(cC,5,1),dC=function(e){for(var t=e[0],n=1;nt&&(t=e[n]);return t},fC=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},pC=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},mC=function(e){return(e/8|0)+(e&7&&1)},hC=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof KS?KS:e instanceof qS?qS:GS)(n-t);return r.set(e.subarray(t,n)),r},gC=function(e,t,n){var r=e.length;if(!r||n&&!n.l&&r<5)return t||new GS(0);var i=!t||n,a=!n||n.i;n||={},t||=new GS(r*3);var o=function(e){var n=t.length;if(e>n){var r=new GS(Math.max(n*2,e));r.set(t),t=r}},s=n.f||0,c=n.p||0,l=n.b||0,u=n.l,d=n.d,f=n.m,p=n.n,m=r*8;do{if(!u){n.f=s=fC(e,c,1);var h=fC(e,c+1,3);if(c+=3,h)if(h==1)u=lC,d=uC,f=9,p=5;else if(h==2){var g=fC(e,c,31)+257,_=fC(e,c+10,15)+4,v=g+fC(e,c+5,31)+1;c+=14;for(var y=new GS(v),b=new GS(19),x=0;x<_;++x)b[XS[x]]=fC(e,c+x*3,7);c+=_*3;for(var S=dC(b),C=(1<>>4;if(E<16)y[x++]=E;else{var D=0,O=0;for(E==16?(O=3+fC(e,c,3),c+=2,D=y[x-1]):E==17?(O=3+fC(e,c,7),c+=3):E==18&&(O=11+fC(e,c,127),c+=7);O--;)y[x++]=D}}var k=y.subarray(0,g),A=y.subarray(g);f=dC(k),p=dC(A),u=oC(k,f,1),d=oC(A,p,1)}else throw`invalid block type`;else{var E=mC(c)+4,j=e[E-4]|e[E-3]<<8,M=E+j;if(M>r){if(a)throw`unexpected EOF`;break}i&&o(l+j),t.set(e.subarray(E,M),l),n.b=l+=j,n.p=c=M*8;continue}if(c>m){if(a)throw`unexpected EOF`;break}}i&&o(l+131072);for(var N=(1<>>4;if(c+=D&15,c>m){if(a)throw`unexpected EOF`;break}if(!D)throw`invalid length/literal`;if(F<256)t[l++]=F;else if(F==256){P=c,u=null;break}else{var I=F-254;if(F>264){var x=F-257,te=JS[x];I=fC(e,c,(1<>>4;if(!ne)throw`invalid distance`;c+=ne&15;var A=nC[L];if(L>3){var te=YS[L];A+=pC(e,c)&(1<m){if(a)throw`unexpected EOF`;break}i&&o(l+131072);for(var re=l+I;l>>4>7||(e[0]<<8|e[1])%31)throw`invalid zlib data`;if(e[1]&32)throw`invalid zlib data: preset dictionaries not supported`},yC=typeof TextDecoder<`u`&&new TextDecoder,bC=0;try{yC.decode(_C,{stream:!0}),bC=1}catch{}var xC=Object.defineProperty,SC=(e,t,n)=>t in e?xC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,CC=(e,t,n)=>(SC(e,t+``,n),n);const wC=class extends be{constructor(e,t={}){super(e),this.isReflector=!0,this.type=`Reflector`,this.camera=new Pe;let n=this,r=t.color===void 0?new h(8355711):new h(t.color),i=t.textureWidth||512,a=t.textureHeight||512,o=t.clipBias||0,s=t.shader||wC.ReflectorShader,c=t.multisample===void 0?4:t.multisample,l=new Fe,u=new z,d=new z,f=new z,p=new ye,m=new z(0,0,-1),g=new ht,_=new z,v=new z,y=new ht,b=new ye,x=this.camera,S=new vt(i,a,{samples:c,type:te}),C=new Xe({uniforms:pt.clone(s.uniforms),fragmentShader:s.fragmentShader,vertexShader:s.vertexShader});C.uniforms.tDiffuse.value=S.texture,C.uniforms.color.value=r,C.uniforms.textureMatrix.value=b,this.material=C,this.onBeforeRender=function(e,t,r){if(d.setFromMatrixPosition(n.matrixWorld),f.setFromMatrixPosition(r.matrixWorld),p.extractRotation(n.matrixWorld),u.set(0,0,1),u.applyMatrix4(p),_.subVectors(d,f),_.dot(u)>0)return;_.reflect(u).negate(),_.add(d),p.extractRotation(r.matrixWorld),m.set(0,0,-1),m.applyMatrix4(p),m.add(f),v.subVectors(d,m),v.reflect(u).negate(),v.add(d),x.position.copy(_),x.up.set(0,1,0),x.up.applyMatrix4(p),x.up.reflect(u),x.lookAt(v),x.far=r.far,x.updateMatrixWorld(),x.projectionMatrix.copy(r.projectionMatrix),b.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),b.multiply(x.projectionMatrix),b.multiply(x.matrixWorldInverse),b.multiply(n.matrixWorld),l.setFromNormalAndCoplanarPoint(u,d),l.applyMatrix4(x.matrixWorldInverse),g.set(l.normal.x,l.normal.y,l.normal.z,l.constant);let i=x.projectionMatrix;y.x=(Math.sign(g.x)+i.elements[8])/i.elements[0],y.y=(Math.sign(g.y)+i.elements[9])/i.elements[5],y.z=-1,y.w=(1+i.elements[10])/i.elements[14],g.multiplyScalar(2/g.dot(y)),i.elements[2]=g.x,i.elements[6]=g.y,i.elements[10]=g.z+1-o,i.elements[14]=g.w,n.visible=!1;let a=e.getRenderTarget(),s=e.xr.enabled,c=e.shadowMap.autoUpdate,h=e.toneMapping,C=!1;C=`outputColorSpace`in e?e.outputColorSpace===`srgb`:e.outputEncoding===3001,e.xr.enabled=!1,e.shadowMap.autoUpdate=!1,`outputColorSpace`in e?e.outputColorSpace=`srgb-linear`:e.outputEncoding=3e3,e.toneMapping=ke,e.setRenderTarget(S),e.state.buffers.depth.setMask(!0),e.autoClear===!1&&e.clear(),e.render(t,x),e.xr.enabled=s,e.shadowMap.autoUpdate=c,e.toneMapping=h,`outputColorSpace`in e?e.outputColorSpace=C?`srgb`:`srgb-linear`:e.outputEncoding=C?3001:3e3,e.setRenderTarget(a);let w=r.viewport;w!==void 0&&e.state.viewport(w),n.visible=!0},this.getRenderTarget=function(){return S},this.dispose=function(){S.dispose(),n.material.dispose()}}};let TC=wC;CC(TC,`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 <${eS>=154?`colorspace_fragment`:`encodings_fragment`}> + + }`});var EC=Object.defineProperty,DC=(e,t,n)=>t in e?EC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,OC=(e,t,n)=>(DC(e,typeof t==`symbol`?t:t+``,n),n);const kC=new f,AC=new Float32Array([-1,-1,0,0,0,1,-1,0,1,0,1,1,0,1,1,-1,1,0,0,1]),jC=new R(AC,5);kC.setIndex([0,1,2,0,2,3]),kC.setAttribute(`position`,new ie(jC,3,0,!1)),kC.setAttribute(`uv`,new ie(jC,2,3,!1));const MC=class extends be{constructor(){super(MC.Geometry,new xe({opacity:0,transparent:!0})),this.isLensflare=!0,this.type=`Lensflare`,this.frustumCulled=!1,this.renderOrder=1/0;let e=new z,n=new z,r=new x(new Uint8Array(16*16*3),16,16,He);r.minFilter=Ee,r.magFilter=Ee,r.wrapS=m,r.wrapT=m;let i=new x(new Uint8Array(16*16*3),16,16,He);i.minFilter=Ee,i.magFilter=Ee,i.wrapS=m,i.wrapT=m;let a=MC.Geometry,o=new Ue({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 Ue({uniforms:{map:{value:r},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}),l=new be(a,o),u=[],d=PC.Shader,f=new Ue({uniforms:{map:{value:null},occlusionMap:{value:i},color:{value:new h(16777215)},scale:{value:new mt},screenPosition:{value:new z}},vertexShader:d.vertexShader,fragmentShader:d.fragmentShader,blending:t,transparent:!0,depthWrite:!1}),p=new be(a,f);this.addElement=function(e){u.push(e)};let g=new mt,_=new mt,v=new c,y=new ht;this.onBeforeRender=function(t,c,d){t.getCurrentViewport(y);let m=y.w/y.z,h=y.z/2,b=y.w/2,x=16/y.w;if(g.set(x*m,x),v.min.set(y.x,y.y),v.max.set(y.x+(y.z-16),y.y+(y.w-16)),n.setFromMatrixPosition(this.matrixWorld),n.applyMatrix4(d.matrixWorldInverse),!(n.z>0)&&(e.copy(n).applyMatrix4(d.projectionMatrix),_.x=y.x+e.x*h+h-8,_.y=y.y+e.y*b+b-8,v.containsPoint(_))){t.copyFramebufferToTexture(_,r);let n=o.uniforms;n.scale.value=g,n.screenPosition.value=e,t.renderBufferDirect(d,null,a,o,l,null),t.copyFramebufferToTexture(_,i),n=s.uniforms,n.scale.value=g,n.screenPosition.value=e,t.renderBufferDirect(d,null,a,s,l,null);let c=-e.x*2,m=-e.y*2;for(let n=0,r=u.length;n + #include + #include + #include + + void main() { + mirrorCoord = modelMatrix * vec4( position, 1.0 ); + worldPosition = mirrorCoord.xyzw; + mirrorCoord = textureMatrix * mirrorCoord; + vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); + gl_Position = projectionMatrix * mvPosition; + + #include + #include + #include + #include + #include + }`,fragmentShader:` + uniform sampler2D mirrorSampler; + uniform float alpha; + uniform float time; + uniform float size; + uniform float distortionScale; + uniform sampler2D normalSampler; + uniform vec3 sunColor; + uniform vec3 sunDirection; + uniform vec3 eye; + uniform vec3 waterColor; + + varying vec4 mirrorCoord; + varying vec4 worldPosition; + + vec4 getNoise( vec2 uv ) { + vec2 uv0 = ( uv / 103.0 ) + vec2(time / 17.0, time / 29.0); + vec2 uv1 = uv / 107.0-vec2( time / -19.0, time / 31.0 ); + vec2 uv2 = uv / vec2( 8907.0, 9803.0 ) + vec2( time / 101.0, time / 97.0 ); + vec2 uv3 = uv / vec2( 1091.0, 1027.0 ) - vec2( time / 109.0, time / -113.0 ); + vec4 noise = texture2D( normalSampler, uv0 ) + + texture2D( normalSampler, uv1 ) + + texture2D( normalSampler, uv2 ) + + texture2D( normalSampler, uv3 ); + return noise * 0.5 - 1.0; + } + + void sunLight( const vec3 surfaceNormal, const vec3 eyeDirection, float shiny, float spec, float diffuse, inout vec3 diffuseColor, inout vec3 specularColor ) { + vec3 reflection = normalize( reflect( -sunDirection, surfaceNormal ) ); + float direction = max( 0.0, dot( eyeDirection, reflection ) ); + specularColor += pow( direction, shiny ) * sunColor * spec; + diffuseColor += max( dot( sunDirection, surfaceNormal ), 0.0 ) * sunColor * diffuse; + } + + #include + #include + #include + #include + #include + #include + #include + #include + + void main() { + + #include + vec4 noise = getNoise( worldPosition.xz * size ); + vec3 surfaceNormal = normalize( noise.xzy * vec3( 1.5, 1.0, 1.5 ) ); + + vec3 diffuseLight = vec3(0.0); + vec3 specularLight = vec3(0.0); + + vec3 worldToEye = eye-worldPosition.xyz; + vec3 eyeDirection = normalize( worldToEye ); + sunLight( surfaceNormal, eyeDirection, 100.0, 2.0, 0.5, diffuseLight, specularLight ); + + float distance = length(worldToEye); + + vec2 distortion = surfaceNormal.xz * ( 0.001 + 1.0 / distance ) * distortionScale; + vec3 reflectionSample = vec3( texture2D( mirrorSampler, mirrorCoord.xy / mirrorCoord.w + distortion ) ); + + float theta = max( dot( eyeDirection, surfaceNormal ), 0.0 ); + float rf0 = 0.3; + float reflectance = rf0 + ( 1.0 - rf0 ) * pow( ( 1.0 - theta ), 5.0 ); + vec3 scatter = max( 0.0, dot( surfaceNormal, eyeDirection ) ) * waterColor; + vec3 albedo = mix( ( sunColor * diffuseLight * 0.3 + scatter ) * getShadowMask(), ( vec3( 0.1 ) + reflectionSample * 0.9 + reflectionSample * specularLight ), reflectance); + vec3 outgoingLight = albedo; + gl_FragColor = vec4( outgoingLight, alpha ); + + #include + #include <${parseInt(Ve.replace(/\D+/g,``))>=154?`colorspace_fragment`:`encodings_fragment`}> + #include + }`},j=new Xe({fragmentShader:A.fragmentShader,vertexShader:A.vertexShader,uniforms:pt.clone(A.uniforms),lights:!0,side:m,fog:g});j.uniforms.mirrorSampler.value=k.texture,j.uniforms.textureMatrix.value=D,j.uniforms.alpha.value=o,j.uniforms.time.value=s,j.uniforms.normalSampler.value=c,j.uniforms.sunColor.value=u,j.uniforms.waterColor.value=d,j.uniforms.sunDirection.value=l,j.uniforms.distortionScale.value=p,j.uniforms.eye.value=f,n.material=j,n.onBeforeRender=function(e,t,r){if(y.setFromMatrixPosition(n.matrixWorld),b.setFromMatrixPosition(r.matrixWorld),x.extractRotation(n.matrixWorld),v.set(0,0,1),v.applyMatrix4(x),w.subVectors(y,b),w.dot(v)>0)return;w.reflect(v).negate(),w.add(y),x.extractRotation(r.matrixWorld),S.set(0,0,-1),S.applyMatrix4(x),S.add(b),T.subVectors(y,S),T.reflect(v).negate(),T.add(y),O.position.copy(w),O.up.set(0,1,0),O.up.applyMatrix4(x),O.up.reflect(v),O.lookAt(T),O.far=r.far,O.updateMatrixWorld(),O.projectionMatrix.copy(r.projectionMatrix),D.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),D.multiply(O.projectionMatrix),D.multiply(O.matrixWorldInverse),_.setFromNormalAndCoplanarPoint(v,y),_.applyMatrix4(O.matrixWorldInverse),C.set(_.normal.x,_.normal.y,_.normal.z,_.constant);let i=O.projectionMatrix;E.x=(Math.sign(C.x)+i.elements[8])/i.elements[0],E.y=(Math.sign(C.y)+i.elements[9])/i.elements[5],E.z=-1,E.w=(1+i.elements[10])/i.elements[14],C.multiplyScalar(2/C.dot(E)),i.elements[2]=C.x,i.elements[6]=C.y,i.elements[10]=C.z+1-a,i.elements[14]=C.w,f.setFromMatrixPosition(r.matrixWorld);let o=e.getRenderTarget(),s=e.xr.enabled,c=e.shadowMap.autoUpdate;n.visible=!1,e.xr.enabled=!1,e.shadowMap.autoUpdate=!1,e.setRenderTarget(k),e.state.buffers.depth.setMask(!0),e.autoClear===!1&&e.clear(),e.render(t,O),n.visible=!0,e.xr.enabled=s,e.shadowMap.autoUpdate=c,e.setRenderTarget(o);let l=r.viewport;l!==void 0&&e.state.viewport(l)}}},IC=Object.defineProperty,LC=(e,t,n)=>t in e?IC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,RC=(e,t,n)=>(LC(e,typeof t==`symbol`?t:t+``,n),n);const zC={uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new z},up:{value:new z(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 <${eS>=154?`colorspace_fragment`:`encodings_fragment`}> + + } + `},BC=new Xe({name:`SkyShader`,fragmentShader:zC.fragmentShader,vertexShader:zC.vertexShader,uniforms:pt.clone(zC.uniforms),side:s,depthWrite:!1});var VC=class extends be{constructor(){super(new u(1,1,1),BC)}};RC(VC,`SkyShader`,zC),RC(VC,`material`,BC);const HC=new ut,UC=new z;var WC=class{constructor(e){let t=e.geometry;t.index&&(console.warn(`THREE.MeshSurfaceSampler: Converting geometry to non-indexed BufferGeometry.`),t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute(`position`),this.colorAttribute=this.geometry.getAttribute(`color`),this.weightAttribute=null,this.distribution=null}setWeightAttribute(e){return this.weightAttribute=e?this.geometry.getAttribute(e):null,this}build(){let e=this.positionAttribute,t=this.weightAttribute,n=new Float32Array(e.count/3);for(let r=0;re){i=a;break}else e1&&(i=1-i,a=1-a),HC.a.fromBufferAttribute(this.positionAttribute,e*3),HC.b.fromBufferAttribute(this.positionAttribute,e*3+1),HC.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(HC.a,i).addScaledVector(HC.b,a).addScaledVector(HC.c,1-(i+a)),n!==void 0&&HC.getNormal(n),r!==void 0&&this.colorAttribute!==void 0&&(HC.a.fromBufferAttribute(this.colorAttribute,e*3),HC.b.fromBufferAttribute(this.colorAttribute,e*3+1),HC.c.fromBufferAttribute(this.colorAttribute,e*3+2),UC.set(0,0,0).addScaledVector(HC.a,i).addScaledVector(HC.b,a).addScaledVector(HC.c,1-(i+a)),r.r=UC.x,r.g=UC.y,r.b=UC.z),this}},GC=Object.defineProperty,KC=(e,t,n)=>t in e?GC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,q=(e,t,n)=>(KC(e,typeof t==`symbol`?t:t+``,n),n),qC=class extends Ae{constructor(e,t){super(),q(this,`isTransformControls`,!0),q(this,`visible`,!1),q(this,`domElement`),q(this,`raycaster`,new Ge),q(this,`gizmo`),q(this,`plane`),q(this,`tempVector`,new z),q(this,`tempVector2`,new z),q(this,`tempQuaternion`,new Be),q(this,`unit`,{X:new z(1,0,0),Y:new z(0,1,0),Z:new z(0,0,1)}),q(this,`pointStart`,new z),q(this,`pointEnd`,new z),q(this,`offset`,new z),q(this,`rotationAxis`,new z),q(this,`startNorm`,new z),q(this,`endNorm`,new z),q(this,`rotationAngle`,0),q(this,`cameraPosition`,new z),q(this,`cameraQuaternion`,new Be),q(this,`cameraScale`,new z),q(this,`parentPosition`,new z),q(this,`parentQuaternion`,new Be),q(this,`parentQuaternionInv`,new Be),q(this,`parentScale`,new z),q(this,`worldPositionStart`,new z),q(this,`worldQuaternionStart`,new Be),q(this,`worldScaleStart`,new z),q(this,`worldPosition`,new z),q(this,`worldQuaternion`,new Be),q(this,`worldQuaternionInv`,new Be),q(this,`worldScale`,new z),q(this,`eye`,new z),q(this,`positionStart`,new z),q(this,`quaternionStart`,new Be),q(this,`scaleStart`,new z),q(this,`camera`),q(this,`object`),q(this,`enabled`,!0),q(this,`axis`,null),q(this,`mode`,`translate`),q(this,`translationSnap`,null),q(this,`rotationSnap`,null),q(this,`scaleSnap`,null),q(this,`space`,`world`),q(this,`size`,1),q(this,`dragging`,!1),q(this,`showX`,!0),q(this,`showY`,!0),q(this,`showZ`,!0),q(this,`changeEvent`,{type:`change`}),q(this,`mouseDownEvent`,{type:`mouseDown`,mode:this.mode}),q(this,`mouseUpEvent`,{type:`mouseUp`,mode:this.mode}),q(this,`objectChangeEvent`,{type:`objectChange`}),q(this,`intersectObjectWithRay`,(e,t,n)=>{let r=t.intersectObject(e,!0);for(let e=0;e(this.object=e,this.visible=!0,this)),q(this,`detach`,()=>(this.object=void 0,this.visible=!1,this.axis=null,this)),q(this,`reset`,()=>(this.enabled&&this.dragging&&this.object!==void 0&&(this.object.position.copy(this.positionStart),this.object.quaternion.copy(this.quaternionStart),this.object.scale.copy(this.scaleStart),this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent),this.pointStart.copy(this.pointEnd)),this)),q(this,`updateMatrixWorld`,()=>{this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error(`TransformControls: The attached 3D object must be a part of the scene graph.`):this.object.parent.matrixWorld.decompose(this.parentPosition,this.parentQuaternion,this.parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this.worldScale),this.parentQuaternionInv.copy(this.parentQuaternion).invert(),this.worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this.cameraScale),this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld()}),q(this,`pointerHover`,e=>{if(this.object===void 0||this.dragging===!0)return;this.raycaster.setFromCamera(e,this.camera);let t=this.intersectObjectWithRay(this.gizmo.picker[this.mode],this.raycaster);t?this.axis=t.object.name:this.axis=null}),q(this,`pointerDown`,e=>{if(!(this.object===void 0||this.dragging===!0||e.button!==0)&&this.axis!==null){this.raycaster.setFromCamera(e,this.camera);let t=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(t){let e=this.space;if(this.mode===`scale`?e=`local`:(this.axis===`E`||this.axis===`XYZE`||this.axis===`XYZ`)&&(e=`world`),e===`local`&&this.mode===`rotate`){let e=this.rotationSnap;this.axis===`X`&&e&&(this.object.rotation.x=Math.round(this.object.rotation.x/e)*e),this.axis===`Y`&&e&&(this.object.rotation.y=Math.round(this.object.rotation.y/e)*e),this.axis===`Z`&&e&&(this.object.rotation.z=Math.round(this.object.rotation.z/e)*e)}this.object.updateMatrixWorld(),this.object.parent&&this.object.parent.updateMatrixWorld(),this.positionStart.copy(this.object.position),this.quaternionStart.copy(this.object.quaternion),this.scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this.worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)}this.dragging=!0,this.mouseDownEvent.mode=this.mode,this.dispatchEvent(this.mouseDownEvent)}}),q(this,`pointerMove`,e=>{let t=this.axis,n=this.mode,r=this.object,i=this.space;if(n===`scale`?i=`local`:(t===`E`||t===`XYZE`||t===`XYZ`)&&(i=`world`),r===void 0||t===null||this.dragging===!1||e.button!==-1)return;this.raycaster.setFromCamera(e,this.camera);let a=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),n===`translate`)this.offset.copy(this.pointEnd).sub(this.pointStart),i===`local`&&t!==`XYZ`&&this.offset.applyQuaternion(this.worldQuaternionInv),t.indexOf(`X`)===-1&&(this.offset.x=0),t.indexOf(`Y`)===-1&&(this.offset.y=0),t.indexOf(`Z`)===-1&&(this.offset.z=0),i===`local`&&t!==`XYZ`?this.offset.applyQuaternion(this.quaternionStart).divide(this.parentScale):this.offset.applyQuaternion(this.parentQuaternionInv).divide(this.parentScale),r.position.copy(this.offset).add(this.positionStart),this.translationSnap&&(i===`local`&&(r.position.applyQuaternion(this.tempQuaternion.copy(this.quaternionStart).invert()),t.search(`X`)!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search(`Y`)!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search(`Z`)!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.position.applyQuaternion(this.quaternionStart)),i===`world`&&(r.parent&&r.position.add(this.tempVector.setFromMatrixPosition(r.parent.matrixWorld)),t.search(`X`)!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search(`Y`)!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search(`Z`)!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.parent&&r.position.sub(this.tempVector.setFromMatrixPosition(r.parent.matrixWorld))));else if(n===`scale`){if(t.search(`XYZ`)!==-1){let e=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(e*=-1),this.tempVector2.set(e,e,e)}else this.tempVector.copy(this.pointStart),this.tempVector2.copy(this.pointEnd),this.tempVector.applyQuaternion(this.worldQuaternionInv),this.tempVector2.applyQuaternion(this.worldQuaternionInv),this.tempVector2.divide(this.tempVector),t.search(`X`)===-1&&(this.tempVector2.x=1),t.search(`Y`)===-1&&(this.tempVector2.y=1),t.search(`Z`)===-1&&(this.tempVector2.z=1);r.scale.copy(this.scaleStart).multiply(this.tempVector2),this.scaleSnap&&this.object&&(t.search(`X`)!==-1&&(this.object.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search(`Y`)!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search(`Z`)!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(n===`rotate`){this.offset.copy(this.pointEnd).sub(this.pointStart);let e=20/this.worldPosition.distanceTo(this.tempVector.setFromMatrixPosition(this.camera.matrixWorld));t===`E`?(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this.startNorm.copy(this.pointStart).normalize(),this.endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this.endNorm.cross(this.startNorm).dot(this.eye)<0?1:-1):t===`XYZE`?(this.rotationAxis.copy(this.offset).cross(this.eye).normalize(),this.rotationAngle=this.offset.dot(this.tempVector.copy(this.rotationAxis).cross(this.eye))*e):(t===`X`||t===`Y`||t===`Z`)&&(this.rotationAxis.copy(this.unit[t]),this.tempVector.copy(this.unit[t]),i===`local`&&this.tempVector.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.offset.dot(this.tempVector.cross(this.eye).normalize())*e),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),i===`local`&&t!==`E`&&t!==`XYZE`?(r.quaternion.copy(this.quaternionStart),r.quaternion.multiply(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this.parentQuaternionInv),r.quaternion.copy(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),r.quaternion.multiply(this.quaternionStart).normalize())}this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent)}}),q(this,`pointerUp`,e=>{e.button===0&&(this.dragging&&this.axis!==null&&(this.mouseUpEvent.mode=this.mode,this.dispatchEvent(this.mouseUpEvent)),this.dragging=!1,this.axis=null)}),q(this,`getPointer`,e=>{var t;if(this.domElement&&(t=this.domElement.ownerDocument)!=null&&t.pointerLockElement)return{x:0,y:0,button:e.button};{let t=e.changedTouches?e.changedTouches[0]:e,n=this.domElement.getBoundingClientRect();return{x:(t.clientX-n.left)/n.width*2-1,y:-(t.clientY-n.top)/n.height*2+1,button:e.button}}}),q(this,`onPointerHover`,e=>{if(this.enabled)switch(e.pointerType){case`mouse`:case`pen`:this.pointerHover(this.getPointer(e));break}}),q(this,`onPointerDown`,e=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction=`none`,this.domElement.ownerDocument.addEventListener(`pointermove`,this.onPointerMove),this.pointerHover(this.getPointer(e)),this.pointerDown(this.getPointer(e)))}),q(this,`onPointerMove`,e=>{this.enabled&&this.pointerMove(this.getPointer(e))}),q(this,`onPointerUp`,e=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction=``,this.domElement.ownerDocument.removeEventListener(`pointermove`,this.onPointerMove),this.pointerUp(this.getPointer(e)))}),q(this,`getMode`,()=>this.mode),q(this,`setMode`,e=>{this.mode=e}),q(this,`setTranslationSnap`,e=>{this.translationSnap=e}),q(this,`setRotationSnap`,e=>{this.rotationSnap=e}),q(this,`setScaleSnap`,e=>{this.scaleSnap=e}),q(this,`setSize`,e=>{this.size=e}),q(this,`setSpace`,e=>{this.space=e}),q(this,`update`,()=>{console.warn(`THREE.TransformControls: update function has no more functionality and therefore has been deprecated.`)}),q(this,`connect`,e=>{e===document&&console.error(`THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.`),this.domElement=e,this.domElement.addEventListener(`pointerdown`,this.onPointerDown),this.domElement.addEventListener(`pointermove`,this.onPointerHover),this.domElement.ownerDocument.addEventListener(`pointerup`,this.onPointerUp)}),q(this,`dispose`,()=>{var e,t,n,r,i,a;(e=this.domElement)==null||e.removeEventListener(`pointerdown`,this.onPointerDown),(t=this.domElement)==null||t.removeEventListener(`pointermove`,this.onPointerHover),(r=(n=this.domElement)?.ownerDocument)==null||r.removeEventListener(`pointermove`,this.onPointerMove),(a=(i=this.domElement)?.ownerDocument)==null||a.removeEventListener(`pointerup`,this.onPointerUp),this.traverse(e=>{let t=e;t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}),this.domElement=t,this.camera=e,this.gizmo=new JC,this.add(this.gizmo),this.plane=new YC,this.add(this.plane);let n=(e,t)=>{let n=t;Object.defineProperty(this,e,{get:function(){return n===void 0?t:n},set:function(t){n!==t&&(n=t,this.plane[e]=t,this.gizmo[e]=t,this.dispatchEvent({type:e+`-changed`,value:t}),this.dispatchEvent(this.changeEvent))}}),this[e]=t,this.plane[e]=t,this.gizmo[e]=t};n(`camera`,this.camera),n(`object`,this.object),n(`enabled`,this.enabled),n(`axis`,this.axis),n(`mode`,this.mode),n(`translationSnap`,this.translationSnap),n(`rotationSnap`,this.rotationSnap),n(`scaleSnap`,this.scaleSnap),n(`space`,this.space),n(`size`,this.size),n(`dragging`,this.dragging),n(`showX`,this.showX),n(`showY`,this.showY),n(`showZ`,this.showZ),n(`worldPosition`,this.worldPosition),n(`worldPositionStart`,this.worldPositionStart),n(`worldQuaternion`,this.worldQuaternion),n(`worldQuaternionStart`,this.worldQuaternionStart),n(`cameraPosition`,this.cameraPosition),n(`cameraQuaternion`,this.cameraQuaternion),n(`pointStart`,this.pointStart),n(`pointEnd`,this.pointEnd),n(`rotationAxis`,this.rotationAxis),n(`rotationAngle`,this.rotationAngle),n(`eye`,this.eye),t!==void 0&&this.connect(t)}},JC=class extends Ae{constructor(){super(),q(this,`isTransformControlsGizmo`,!0),q(this,`type`,`TransformControlsGizmo`),q(this,`tempVector`,new z(0,0,0)),q(this,`tempEuler`,new k),q(this,`alignVector`,new z(0,1,0)),q(this,`zeroVector`,new z(0,0,0)),q(this,`lookAtMatrix`,new ye),q(this,`tempQuaternion`,new Be),q(this,`tempQuaternion2`,new Be),q(this,`identityQuaternion`,new Be),q(this,`unitX`,new z(1,0,0)),q(this,`unitY`,new z(0,1,0)),q(this,`unitZ`,new z(0,0,1)),q(this,`gizmo`),q(this,`picker`),q(this,`helper`),q(this,`rotationAxis`,new z),q(this,`cameraPosition`,new z),q(this,`worldPositionStart`,new z),q(this,`worldQuaternionStart`,new Be),q(this,`worldPosition`,new z),q(this,`worldQuaternion`,new Be),q(this,`eye`,new z),q(this,`camera`,null),q(this,`enabled`,!0),q(this,`axis`,null),q(this,`mode`,`translate`),q(this,`space`,`world`),q(this,`size`,1),q(this,`dragging`,!1),q(this,`showX`,!0),q(this,`showY`,!0),q(this,`showZ`,!0),q(this,`updateMatrixWorld`,()=>{let e=this.space;this.mode===`scale`&&(e=`local`);let t=e===`local`?this.worldQuaternion:this.identityQuaternion;this.gizmo.translate.visible=this.mode===`translate`,this.gizmo.rotate.visible=this.mode===`rotate`,this.gizmo.scale.visible=this.mode===`scale`,this.helper.translate.visible=this.mode===`translate`,this.helper.rotate.visible=this.mode===`rotate`,this.helper.scale.visible=this.mode===`scale`;let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let e=0;e.9&&(r.visible=!1)),this.axis===`Y`&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,Math.PI/2)),r.quaternion.copy(t).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),this.axis===`Z`&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),r.quaternion.copy(t).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),this.axis===`XYZE`&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),this.alignVector.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector,this.alignVector,this.unitY)),r.quaternion.multiply(this.tempQuaternion),r.visible=this.dragging),this.axis===`E`&&(r.visible=!1)):r.name===`START`?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):r.name===`END`?(r.position.copy(this.worldPosition),r.visible=this.dragging):r.name===`DELTA`?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),this.tempVector.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),this.tempVector.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(this.tempVector),r.visible=this.dragging):(r.quaternion.copy(t),this.dragging?r.position.copy(this.worldPositionStart):r.position.copy(this.worldPosition),this.axis&&(r.visible=this.axis.search(r.name)!==-1));continue}r.quaternion.copy(t),this.mode===`translate`||this.mode===`scale`?((r.name===`X`||r.name===`XYZX`)&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(t).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),(r.name===`Y`||r.name===`XYZY`)&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(t).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),(r.name===`Z`||r.name===`XYZZ`)&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(t).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`XY`&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(t).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`YZ`&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(t).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`XZ`&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(t).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name.search(`X`)!==-1&&(this.alignVector.copy(this.unitX).applyQuaternion(t).dot(this.eye)<0?r.tag===`fwd`?r.visible=!1:r.scale.x*=-1:r.tag===`bwd`&&(r.visible=!1)),r.name.search(`Y`)!==-1&&(this.alignVector.copy(this.unitY).applyQuaternion(t).dot(this.eye)<0?r.tag===`fwd`?r.visible=!1:r.scale.y*=-1:r.tag===`bwd`&&(r.visible=!1)),r.name.search(`Z`)!==-1&&(this.alignVector.copy(this.unitZ).applyQuaternion(t).dot(this.eye)<0?r.tag===`fwd`?r.visible=!1:r.scale.z*=-1:r.tag===`bwd`&&(r.visible=!1))):this.mode===`rotate`&&(this.tempQuaternion2.copy(t),this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(t).invert()),r.name.search(`E`)!==-1&&r.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye,this.zeroVector,this.unitY)),r.name===`X`&&(this.tempQuaternion.setFromAxisAngle(this.unitX,Math.atan2(-this.alignVector.y,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),r.quaternion.copy(this.tempQuaternion)),r.name===`Y`&&(this.tempQuaternion.setFromAxisAngle(this.unitY,Math.atan2(this.alignVector.x,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),r.quaternion.copy(this.tempQuaternion)),r.name===`Z`&&(this.tempQuaternion.setFromAxisAngle(this.unitZ,Math.atan2(this.alignVector.y,this.alignVector.x)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),r.quaternion.copy(this.tempQuaternion))),r.visible=r.visible&&(r.name.indexOf(`X`)===-1||this.showX),r.visible=r.visible&&(r.name.indexOf(`Y`)===-1||this.showY),r.visible=r.visible&&(r.name.indexOf(`Z`)===-1||this.showZ),r.visible=r.visible&&(r.name.indexOf(`E`)===-1||this.showX&&this.showY&&this.showZ),r.material.tempOpacity=r.material.tempOpacity||r.material.opacity,r.material.tempColor=r.material.tempColor||r.material.color.clone(),r.material.color.copy(r.material.tempColor),r.material.opacity=r.material.tempOpacity,this.enabled?this.axis&&(r.name===this.axis||this.axis.split(``).some(function(e){return r.name===e})?(r.material.opacity=1,r.material.color.lerp(new h(1,1,1),.5)):(r.material.opacity*=.25,r.material.color.lerp(new h(1,1,1),.5))):(r.material.opacity*=.5,r.material.color.lerp(new h(1,1,1),.5))}super.updateMatrixWorld()});let e=new xe({depthTest:!1,depthWrite:!1,transparent:!0,side:T,fog:!1,toneMapped:!1}),t=new ue({depthTest:!1,depthWrite:!1,transparent:!0,linewidth:1,fog:!1,toneMapped:!1}),n=e.clone();n.opacity=.15;let r=e.clone();r.opacity=.33;let i=e.clone();i.color.set(16711680);let a=e.clone();a.color.set(65280);let o=e.clone();o.color.set(255);let s=e.clone();s.opacity=.25;let c=s.clone();c.color.set(16776960);let l=s.clone();l.color.set(65535);let d=s.clone();d.color.set(16711935),e.clone().color.set(16776960);let p=t.clone();p.color.set(16711680);let m=t.clone();m.color.set(65280);let g=t.clone();g.color.set(255);let _=t.clone();_.color.set(65535);let v=t.clone();v.color.set(16711935);let y=t.clone();y.color.set(16776960);let x=t.clone();x.color.set(7895160);let S=y.clone();S.opacity=.25;let C=new b(0,.05,.2,12,1,!1),w=new u(.125,.125,.125),E=new f;E.setAttribute(`position`,new N([0,0,0,1,0,0],3));let D=(e,t)=>{let n=new f,r=[];for(let n=0;n<=64*t;++n)r.push(0,Math.cos(n/32*Math.PI)*e,Math.sin(n/32*Math.PI)*e);return n.setAttribute(`position`,new N(r,3)),n},O=()=>{let e=new f;return e.setAttribute(`position`,new N([0,0,0,1,1,1],3)),e},A={X:[[new be(C,i),[1,0,0],[0,0,-Math.PI/2],null,`fwd`],[new be(C,i),[1,0,0],[0,0,Math.PI/2],null,`bwd`],[new ce(E,p)]],Y:[[new be(C,a),[0,1,0],null,null,`fwd`],[new be(C,a),[0,1,0],[Math.PI,0,0],null,`bwd`],[new ce(E,m),null,[0,0,Math.PI/2]]],Z:[[new be(C,o),[0,0,1],[Math.PI/2,0,0],null,`fwd`],[new be(C,o),[0,0,1],[-Math.PI/2,0,0],null,`bwd`],[new ce(E,g),null,[0,-Math.PI/2,0]]],XYZ:[[new be(new je(.1,0),s.clone()),[0,0,0],[0,0,0]]],XY:[[new be(new Ie(.295,.295),c.clone()),[.15,.15,0]],[new ce(E,y),[.18,.3,0],null,[.125,1,1]],[new ce(E,y),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new be(new Ie(.295,.295),l.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new ce(E,_),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new ce(E,_),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new be(new Ie(.295,.295),d.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new ce(E,v),[.18,0,.3],null,[.125,1,1]],[new ce(E,v),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},j={X:[[new be(new b(.2,0,1,4,1,!1),n),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new be(new b(.2,0,1,4,1,!1),n),[0,.6,0]]],Z:[[new be(new b(.2,0,1,4,1,!1),n),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new be(new je(.2,0),n)]],XY:[[new be(new Ie(.4,.4),n),[.2,.2,0]]],YZ:[[new be(new Ie(.4,.4),n),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new be(new Ie(.4,.4),n),[.2,0,.2],[-Math.PI/2,0,0]]]},M={START:[[new be(new je(.01,2),r),null,null,null,`helper`]],END:[[new be(new je(.01,2),r),null,null,null,`helper`]],DELTA:[[new ce(O(),r),null,null,null,`helper`]],X:[[new ce(E,r.clone()),[-1e3,0,0],null,[1e6,1,1],`helper`]],Y:[[new ce(E,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],`helper`]],Z:[[new ce(E,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],`helper`]]},ee={X:[[new ce(D(1,.5),p)],[new be(new je(.04,0),i),[0,0,.99],null,[1,3,1]]],Y:[[new ce(D(1,.5),m),null,[0,0,-Math.PI/2]],[new be(new je(.04,0),a),[0,0,.99],null,[3,1,1]]],Z:[[new ce(D(1,.5),g),null,[0,Math.PI/2,0]],[new be(new je(.04,0),o),[.99,0,0],null,[1,3,1]]],E:[[new ce(D(1.25,1),S),null,[0,Math.PI/2,0]],[new be(new b(.03,0,.15,4,1,!1),S),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new be(new b(.03,0,.15,4,1,!1),S),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new be(new b(.03,0,.15,4,1,!1),S),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new be(new b(.03,0,.15,4,1,!1),S),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new ce(D(1,1),x),null,[0,Math.PI/2,0]]]},P={AXIS:[[new ce(E,r.clone()),[-1e3,0,0],null,[1e6,1,1],`helper`]]},F={X:[[new be(new ct(1,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new be(new ct(1,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new be(new ct(1,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new be(new ct(1.25,.1,2,24),n)]],XYZE:[[new be(new rt(.7,10,8),n)]]},I={X:[[new be(w,i),[.8,0,0],[0,0,-Math.PI/2]],[new ce(E,p),null,null,[.8,1,1]]],Y:[[new be(w,a),[0,.8,0]],[new ce(E,m),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new be(w,o),[0,0,.8],[Math.PI/2,0,0]],[new ce(E,g),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new be(w,c),[.85,.85,0],null,[2,2,.2]],[new ce(E,y),[.855,.98,0],null,[.125,1,1]],[new ce(E,y),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new be(w,l),[0,.85,.85],null,[.2,2,2]],[new ce(E,_),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new ce(E,_),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new be(w,d),[.85,0,.85],null,[2,.2,2]],[new ce(E,v),[.855,0,.98],null,[.125,1,1]],[new ce(E,v),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new be(new u(.125,.125,.125),s.clone()),[1.1,0,0]]],XYZY:[[new be(new u(.125,.125,.125),s.clone()),[0,1.1,0]]],XYZZ:[[new be(new u(.125,.125,.125),s.clone()),[0,0,1.1]]]},te={X:[[new be(new b(.2,0,.8,4,1,!1),n),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new be(new b(.2,0,.8,4,1,!1),n),[0,.5,0]]],Z:[[new be(new b(.2,0,.8,4,1,!1),n),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new be(w,n),[.85,.85,0],null,[3,3,.2]]],YZ:[[new be(w,n),[0,.85,.85],null,[.2,3,3]]],XZ:[[new be(w,n),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new be(new u(.2,.2,.2),n),[1.1,0,0]]],XYZY:[[new be(new u(.2,.2,.2),n),[0,1.1,0]]],XYZZ:[[new be(new u(.2,.2,.2),n),[0,0,1.1]]]},ne={X:[[new ce(E,r.clone()),[-1e3,0,0],null,[1e6,1,1],`helper`]],Y:[[new ce(E,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],`helper`]],Z:[[new ce(E,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],`helper`]]},L=e=>{let t=new Ae;for(let n in e)for(let r=e[n].length;r--;){let i=e[n][r][0].clone(),a=e[n][r][1],o=e[n][r][2],s=e[n][r][3],c=e[n][r][4];i.name=n,i.tag=c,a&&i.position.set(a[0],a[1],a[2]),o&&i.rotation.set(o[0],o[1],o[2]),s&&i.scale.set(s[0],s[1],s[2]),i.updateMatrix();let l=i.geometry.clone();l.applyMatrix4(i.matrix),i.geometry=l,i.renderOrder=1/0,i.position.set(0,0,0),i.rotation.set(0,0,0),i.scale.set(1,1,1),t.add(i)}return t};this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=L(A)),this.add(this.gizmo.rotate=L(ee)),this.add(this.gizmo.scale=L(I)),this.add(this.picker.translate=L(j)),this.add(this.picker.rotate=L(F)),this.add(this.picker.scale=L(te)),this.add(this.helper.translate=L(M)),this.add(this.helper.rotate=L(P)),this.add(this.helper.scale=L(ne)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}},YC=class extends be{constructor(){super(new Ie(1e5,1e5,2,2),new xe({visible:!1,wireframe:!0,side:T,transparent:!0,opacity:.1,toneMapped:!1})),q(this,`isTransformControlsPlane`,!0),q(this,`type`,`TransformControlsPlane`),q(this,`unitX`,new z(1,0,0)),q(this,`unitY`,new z(0,1,0)),q(this,`unitZ`,new z(0,0,1)),q(this,`tempVector`,new z),q(this,`dirVector`,new z),q(this,`alignVector`,new z),q(this,`tempMatrix`,new ye),q(this,`identityQuaternion`,new Be),q(this,`cameraQuaternion`,new Be),q(this,`worldPosition`,new z),q(this,`worldQuaternion`,new Be),q(this,`eye`,new z),q(this,`axis`,null),q(this,`mode`,`translate`),q(this,`space`,`world`),q(this,`updateMatrixWorld`,()=>{let e=this.space;switch(this.position.copy(this.worldPosition),this.mode===`scale`&&(e=`local`),this.unitX.set(1,0,0).applyQuaternion(e===`local`?this.worldQuaternion:this.identityQuaternion),this.unitY.set(0,1,0).applyQuaternion(e===`local`?this.worldQuaternion:this.identityQuaternion),this.unitZ.set(0,0,1).applyQuaternion(e===`local`?this.worldQuaternion:this.identityQuaternion),this.alignVector.copy(this.unitY),this.mode){case`translate`:case`scale`:switch(this.axis){case`X`:this.alignVector.copy(this.eye).cross(this.unitX),this.dirVector.copy(this.unitX).cross(this.alignVector);break;case`Y`:this.alignVector.copy(this.eye).cross(this.unitY),this.dirVector.copy(this.unitY).cross(this.alignVector);break;case`Z`:this.alignVector.copy(this.eye).cross(this.unitZ),this.dirVector.copy(this.unitZ).cross(this.alignVector);break;case`XY`:this.dirVector.copy(this.unitZ);break;case`YZ`:this.dirVector.copy(this.unitX);break;case`XZ`:this.alignVector.copy(this.unitZ),this.dirVector.copy(this.unitY);break;case`XYZ`:case`E`:this.dirVector.set(0,0,0);break}break;case`rotate`:default:this.dirVector.set(0,0,0)}this.dirVector.length()===0?this.quaternion.copy(this.cameraQuaternion):(this.tempMatrix.lookAt(this.tempVector.set(0,0,0),this.dirVector,this.alignVector),this.quaternion.setFromRotationMatrix(this.tempMatrix)),super.updateMatrixWorld()})}},XC=Object.defineProperty,ZC=(e,t,n)=>t in e?XC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,QC=(e,t,n)=>(ZC(e,typeof t==`symbol`?t:t+``,n),n);const $C=new k(0,0,0,`YXZ`),ew=new z,tw={type:`change`},nw={type:`lock`},rw={type:`unlock`},iw=Math.PI/2;var aw=class extends A{constructor(e,t){super(),QC(this,`camera`),QC(this,`domElement`),QC(this,`isLocked`),QC(this,`minPolarAngle`),QC(this,`maxPolarAngle`),QC(this,`pointerSpeed`),QC(this,`onMouseMove`,e=>{if(!this.domElement||this.isLocked===!1)return;let t=e.movementX||e.mozMovementX||e.webkitMovementX||0,n=e.movementY||e.mozMovementY||e.webkitMovementY||0;$C.setFromQuaternion(this.camera.quaternion),$C.y-=t*.002*this.pointerSpeed,$C.x-=n*.002*this.pointerSpeed,$C.x=Math.max(iw-this.maxPolarAngle,Math.min(iw-this.minPolarAngle,$C.x)),this.camera.quaternion.setFromEuler($C),this.dispatchEvent(tw)}),QC(this,`onPointerlockChange`,()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(nw),this.isLocked=!0):(this.dispatchEvent(rw),this.isLocked=!1))}),QC(this,`onPointerlockError`,()=>{console.error(`THREE.PointerLockControls: Unable to use Pointer Lock API`)}),QC(this,`connect`,e=>{this.domElement=e||this.domElement,this.domElement&&(this.domElement.ownerDocument.addEventListener(`mousemove`,this.onMouseMove),this.domElement.ownerDocument.addEventListener(`pointerlockchange`,this.onPointerlockChange),this.domElement.ownerDocument.addEventListener(`pointerlockerror`,this.onPointerlockError))}),QC(this,`disconnect`,()=>{this.domElement&&(this.domElement.ownerDocument.removeEventListener(`mousemove`,this.onMouseMove),this.domElement.ownerDocument.removeEventListener(`pointerlockchange`,this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener(`pointerlockerror`,this.onPointerlockError))}),QC(this,`dispose`,()=>{this.disconnect()}),QC(this,`getObject`,()=>this.camera),QC(this,`direction`,new z(0,0,-1)),QC(this,`getDirection`,e=>e.copy(this.direction).applyQuaternion(this.camera.quaternion)),QC(this,`moveForward`,e=>{ew.setFromMatrixColumn(this.camera.matrix,0),ew.crossVectors(this.camera.up,ew),this.camera.position.addScaledVector(ew,e)}),QC(this,`moveRight`,e=>{ew.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(ew,e)}),QC(this,`lock`,()=>{this.domElement&&this.domElement.requestPointerLock()}),QC(this,`unlock`,()=>{this.domElement&&this.domElement.ownerDocument.exitPointerLock()}),this.camera=e,this.domElement=t,this.isLocked=!1,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.pointerSpeed=1,t&&this.connect(t)}},ow=Object.defineProperty,sw=(e,t,n)=>t in e?ow(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,cw=(e,t,n)=>(sw(e,typeof t==`symbol`?t:t+``,n),n);const lw=new We,uw=new Fe,dw=Math.cos(70*(Math.PI/180)),fw=(e,t)=>(e%t+t)%t;var pw=class extends A{constructor(e,t){super(),cw(this,`object`),cw(this,`domElement`),cw(this,`enabled`,!0),cw(this,`target`,new z),cw(this,`minDistance`,0),cw(this,`maxDistance`,1/0),cw(this,`minZoom`,0),cw(this,`maxZoom`,1/0),cw(this,`minPolarAngle`,0),cw(this,`maxPolarAngle`,Math.PI),cw(this,`minAzimuthAngle`,-1/0),cw(this,`maxAzimuthAngle`,1/0),cw(this,`enableDamping`,!1),cw(this,`dampingFactor`,.05),cw(this,`enableZoom`,!0),cw(this,`zoomSpeed`,1),cw(this,`enableRotate`,!0),cw(this,`rotateSpeed`,1),cw(this,`enablePan`,!0),cw(this,`panSpeed`,1),cw(this,`screenSpacePanning`,!0),cw(this,`keyPanSpeed`,7),cw(this,`zoomToCursor`,!1),cw(this,`autoRotate`,!1),cw(this,`autoRotateSpeed`,2),cw(this,`reverseOrbit`,!1),cw(this,`reverseHorizontalOrbit`,!1),cw(this,`reverseVerticalOrbit`,!1),cw(this,`keys`,{LEFT:`ArrowLeft`,UP:`ArrowUp`,RIGHT:`ArrowRight`,BOTTOM:`ArrowDown`}),cw(this,`mouseButtons`,{LEFT:he.ROTATE,MIDDLE:he.DOLLY,RIGHT:he.PAN}),cw(this,`touches`,{ONE:at.ROTATE,TWO:at.DOLLY_PAN}),cw(this,`target0`),cw(this,`position0`),cw(this,`zoom0`),cw(this,`_domElementKeyEvents`,null),cw(this,`getPolarAngle`),cw(this,`getAzimuthalAngle`),cw(this,`setPolarAngle`),cw(this,`setAzimuthalAngle`),cw(this,`getDistance`),cw(this,`getZoomScale`),cw(this,`listenToKeyEvents`),cw(this,`stopListenToKeyEvents`),cw(this,`saveState`),cw(this,`reset`),cw(this,`update`),cw(this,`connect`),cw(this,`dispose`),cw(this,`dollyIn`),cw(this,`dollyOut`),cw(this,`getScale`),cw(this,`setScale`),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>l.phi,this.getAzimuthalAngle=()=>l.theta,this.setPolarAngle=e=>{let t=fw(e,2*Math.PI),r=l.phi;r<0&&(r+=2*Math.PI),t<0&&(t+=2*Math.PI);let i=Math.abs(t-r);2*Math.PI-i{let t=fw(e,2*Math.PI),r=l.theta;r<0&&(r+=2*Math.PI),t<0&&(t+=2*Math.PI);let i=Math.abs(t-r);2*Math.PI-in.object.position.distanceTo(n.target),this.listenToKeyEvents=e=>{e.addEventListener(`keydown`,Te),this._domElementKeyEvents=e},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener(`keydown`,Te),this._domElementKeyEvents=null},this.saveState=()=>{n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(r),n.update(),s=o.NONE},this.update=(()=>{let t=new z,i=new z(0,1,0),a=new Be().setFromUnitVectors(e.up,i),p=a.clone().invert(),m=new z,h=new Be,g=2*Math.PI;return function(){let _=n.object.position;a.setFromUnitVectors(e.up,i),p.copy(a).invert(),t.copy(_).sub(n.target),t.applyQuaternion(a),l.setFromVector3(t),n.autoRotate&&s===o.NONE&&k(D()),n.enableDamping?(l.theta+=u.theta*n.dampingFactor,l.phi+=u.phi*n.dampingFactor):(l.theta+=u.theta,l.phi+=u.phi);let v=n.minAzimuthAngle,y=n.maxAzimuthAngle;isFinite(v)&&isFinite(y)&&(v<-Math.PI?v+=g:v>Math.PI&&(v-=g),y<-Math.PI?y+=g:y>Math.PI&&(y-=g),v<=y?l.theta=Math.max(v,Math.min(y,l.theta)):l.theta=l.theta>(v+y)/2?Math.max(v,l.theta):Math.min(y,l.theta)),l.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,l.phi)),l.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(f,n.dampingFactor):n.target.add(f),n.zoomToCursor&&w||n.object.isOrthographicCamera?l.radius=te(l.radius):l.radius=te(l.radius*d),t.setFromSpherical(l),t.applyQuaternion(p),_.copy(n.target).add(t),n.object.matrixAutoUpdate||n.object.updateMatrix(),n.object.lookAt(n.target),n.enableDamping===!0?(u.theta*=1-n.dampingFactor,u.phi*=1-n.dampingFactor,f.multiplyScalar(1-n.dampingFactor)):(u.set(0,0,0),f.set(0,0,0));let b=!1;if(n.zoomToCursor&&w){let r=null;if(n.object instanceof Pe&&n.object.isPerspectiveCamera){let e=t.length();r=te(e*d);let i=e-r;n.object.position.addScaledVector(S,i),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){let e=new z(C.x,C.y,0);e.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/d)),n.object.updateProjectionMatrix(),b=!0;let i=new z(C.x,C.y,0);i.unproject(n.object),n.object.position.sub(i).add(e),n.object.updateMatrixWorld(),r=t.length()}else console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled.`),n.zoomToCursor=!1;r!==null&&(n.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(r).add(n.object.position):(lw.origin.copy(n.object.position),lw.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(lw.direction))c||8*(1-h.dot(n.object.quaternion))>c?(n.dispatchEvent(r),m.copy(n.object.position),h.copy(n.object.quaternion),b=!1,!0):!1}})(),this.connect=e=>{n.domElement=e,n.domElement.style.touchAction=`none`,n.domElement.addEventListener(`contextmenu`,Oe),n.domElement.addEventListener(`pointerdown`,ye),n.domElement.addEventListener(`pointercancel`,xe),n.domElement.addEventListener(`wheel`,we)},this.dispose=()=>{var e,t,r,i,a,o;n.domElement&&(n.domElement.style.touchAction=`auto`),(e=n.domElement)==null||e.removeEventListener(`contextmenu`,Oe),(t=n.domElement)==null||t.removeEventListener(`pointerdown`,ye),(r=n.domElement)==null||r.removeEventListener(`pointercancel`,xe),(i=n.domElement)==null||i.removeEventListener(`wheel`,we),(a=n.domElement)==null||a.ownerDocument.removeEventListener(`pointermove`,be),(o=n.domElement)==null||o.ownerDocument.removeEventListener(`pointerup`,xe),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener(`keydown`,Te)};let n=this,r={type:`change`},i={type:`start`},a={type:`end`},o={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},s=o.NONE,c=1e-6,l=new it,u=new it,d=1,f=new z,p=new mt,m=new mt,h=new mt,g=new mt,_=new mt,v=new mt,y=new mt,b=new mt,x=new mt,S=new z,C=new mt,w=!1,T=[],E={};function D(){return 2*Math.PI/60/60*n.autoRotateSpeed}function O(){return .95**n.zoomSpeed}function k(e){n.reverseOrbit||n.reverseHorizontalOrbit?u.theta+=e:u.theta-=e}function A(e){n.reverseOrbit||n.reverseVerticalOrbit?u.phi+=e:u.phi-=e}let j=(()=>{let e=new z;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),f.add(e)}})(),M=(()=>{let e=new z;return function(t,r){n.screenSpacePanning===!0?e.setFromMatrixColumn(r,1):(e.setFromMatrixColumn(r,0),e.crossVectors(n.object.up,e)),e.multiplyScalar(t),f.add(e)}})(),N=(()=>{let e=new z;return function(t,r){let i=n.domElement;if(i&&n.object instanceof Pe&&n.object.isPerspectiveCamera){let a=n.object.position;e.copy(a).sub(n.target);let o=e.length();o*=Math.tan(n.object.fov/2*Math.PI/180),j(2*t*o/i.clientHeight,n.object.matrix),M(2*r*o/i.clientHeight,n.object.matrix)}else i&&n.object instanceof Me&&n.object.isOrthographicCamera?(j(t*(n.object.right-n.object.left)/n.object.zoom/i.clientWidth,n.object.matrix),M(r*(n.object.top-n.object.bottom)/n.object.zoom/i.clientHeight,n.object.matrix)):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.`),n.enablePan=!1)}})();function ee(e){n.object instanceof Pe&&n.object.isPerspectiveCamera||n.object instanceof Me&&n.object.isOrthographicCamera?d=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),n.enableZoom=!1)}function P(e){ee(d/e)}function F(e){ee(d*e)}function I(e){if(!n.zoomToCursor||!n.domElement)return;w=!0;let t=n.domElement.getBoundingClientRect(),r=e.clientX-t.left,i=e.clientY-t.top,a=t.width,o=t.height;C.x=r/a*2-1,C.y=-(i/o)*2+1,S.set(C.x,C.y,1).unproject(n.object).sub(n.object.position).normalize()}function te(e){return Math.max(n.minDistance,Math.min(n.maxDistance,e))}function ne(e){p.set(e.clientX,e.clientY)}function L(e){I(e),y.set(e.clientX,e.clientY)}function re(e){g.set(e.clientX,e.clientY)}function R(e){m.set(e.clientX,e.clientY),h.subVectors(m,p).multiplyScalar(n.rotateSpeed);let t=n.domElement;t&&(k(2*Math.PI*h.x/t.clientHeight),A(2*Math.PI*h.y/t.clientHeight)),p.copy(m),n.update()}function ie(e){b.set(e.clientX,e.clientY),x.subVectors(b,y),x.y>0?P(O()):x.y<0&&F(O()),y.copy(b),n.update()}function ae(e){_.set(e.clientX,e.clientY),v.subVectors(_,g).multiplyScalar(n.panSpeed),N(v.x,v.y),g.copy(_),n.update()}function oe(e){I(e),e.deltaY<0?F(O()):e.deltaY>0&&P(O()),n.update()}function se(e){let t=!1;switch(e.code){case n.keys.UP:N(0,n.keyPanSpeed),t=!0;break;case n.keys.BOTTOM:N(0,-n.keyPanSpeed),t=!0;break;case n.keys.LEFT:N(n.keyPanSpeed,0),t=!0;break;case n.keys.RIGHT:N(-n.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),n.update())}function ce(){if(T.length==1)p.set(T[0].pageX,T[0].pageY);else{let e=.5*(T[0].pageX+T[1].pageX),t=.5*(T[0].pageY+T[1].pageY);p.set(e,t)}}function le(){if(T.length==1)g.set(T[0].pageX,T[0].pageY);else{let e=.5*(T[0].pageX+T[1].pageX),t=.5*(T[0].pageY+T[1].pageY);g.set(e,t)}}function ue(){let e=T[0].pageX-T[1].pageX,t=T[0].pageY-T[1].pageY,n=Math.sqrt(e*e+t*t);y.set(0,n)}function de(){n.enableZoom&&ue(),n.enablePan&&le()}function fe(){n.enableZoom&&ue(),n.enableRotate&&ce()}function pe(e){if(T.length==1)m.set(e.pageX,e.pageY);else{let t=Ne(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);m.set(n,r)}h.subVectors(m,p).multiplyScalar(n.rotateSpeed);let t=n.domElement;t&&(k(2*Math.PI*h.x/t.clientHeight),A(2*Math.PI*h.y/t.clientHeight)),p.copy(m)}function me(e){if(T.length==1)_.set(e.pageX,e.pageY);else{let t=Ne(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);_.set(n,r)}v.subVectors(_,g).multiplyScalar(n.panSpeed),N(v.x,v.y),g.copy(_)}function ge(e){let t=Ne(e),r=e.pageX-t.x,i=e.pageY-t.y,a=Math.sqrt(r*r+i*i);b.set(0,a),x.set(0,(b.y/y.y)**+n.zoomSpeed),P(x.y),y.copy(b)}function _e(e){n.enableZoom&&ge(e),n.enablePan&&me(e)}function ve(e){n.enableZoom&&ge(e),n.enableRotate&&pe(e)}function ye(e){var t,r;n.enabled!==!1&&(T.length===0&&((t=n.domElement)==null||t.ownerDocument.addEventListener(`pointermove`,be),(r=n.domElement)==null||r.ownerDocument.addEventListener(`pointerup`,xe)),ke(e),e.pointerType===`touch`?Ee(e):Se(e))}function be(e){n.enabled!==!1&&(e.pointerType===`touch`?De(e):Ce(e))}function xe(e){var t,r,i;Ae(e),T.length===0&&((t=n.domElement)==null||t.releasePointerCapture(e.pointerId),(r=n.domElement)==null||r.ownerDocument.removeEventListener(`pointermove`,be),(i=n.domElement)==null||i.ownerDocument.removeEventListener(`pointerup`,xe)),n.dispatchEvent(a),s=o.NONE}function Se(e){let t;switch(e.button){case 0:t=n.mouseButtons.LEFT;break;case 1:t=n.mouseButtons.MIDDLE;break;case 2:t=n.mouseButtons.RIGHT;break;default:t=-1}switch(t){case he.DOLLY:if(n.enableZoom===!1)return;L(e),s=o.DOLLY;break;case he.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(n.enablePan===!1)return;re(e),s=o.PAN}else{if(n.enableRotate===!1)return;ne(e),s=o.ROTATE}break;case he.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(n.enableRotate===!1)return;ne(e),s=o.ROTATE}else{if(n.enablePan===!1)return;re(e),s=o.PAN}break;default:s=o.NONE}s!==o.NONE&&n.dispatchEvent(i)}function Ce(e){if(n.enabled!==!1)switch(s){case o.ROTATE:if(n.enableRotate===!1)return;R(e);break;case o.DOLLY:if(n.enableZoom===!1)return;ie(e);break;case o.PAN:if(n.enablePan===!1)return;ae(e);break}}function we(e){n.enabled===!1||n.enableZoom===!1||s!==o.NONE&&s!==o.ROTATE||(e.preventDefault(),n.dispatchEvent(i),oe(e),n.dispatchEvent(a))}function Te(e){n.enabled===!1||n.enablePan===!1||se(e)}function Ee(e){switch(je(e),T.length){case 1:switch(n.touches.ONE){case at.ROTATE:if(n.enableRotate===!1)return;ce(),s=o.TOUCH_ROTATE;break;case at.PAN:if(n.enablePan===!1)return;le(),s=o.TOUCH_PAN;break;default:s=o.NONE}break;case 2:switch(n.touches.TWO){case at.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;de(),s=o.TOUCH_DOLLY_PAN;break;case at.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;fe(),s=o.TOUCH_DOLLY_ROTATE;break;default:s=o.NONE}break;default:s=o.NONE}s!==o.NONE&&n.dispatchEvent(i)}function De(e){switch(je(e),s){case o.TOUCH_ROTATE:if(n.enableRotate===!1)return;pe(e),n.update();break;case o.TOUCH_PAN:if(n.enablePan===!1)return;me(e),n.update();break;case o.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;_e(e),n.update();break;case o.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;ve(e),n.update();break;default:s=o.NONE}}function Oe(e){n.enabled!==!1&&e.preventDefault()}function ke(e){T.push(e)}function Ae(e){delete E[e.pointerId];for(let t=0;t{F(e),n.update()},this.dollyOut=(e=O())=>{P(e),n.update()},this.getScale=()=>d,this.setScale=e=>{ee(e),n.update()},this.getZoomScale=()=>O(),t!==void 0&&this.connect(t),this.update()}},mw=class extends pw{constructor(e,t){super(e,t),this.screenSpacePanning=!1,this.mouseButtons.LEFT=he.PAN,this.mouseButtons.RIGHT=he.ROTATE,this.touches.ONE=at.PAN,this.touches.TWO=at.DOLLY_ROTATE}};const hw=new Be,gw={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},_w={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},vw={9728:Ee,9729:de,9984:Oe,9985:pe,9986:De,9987:fe},yw={33071:m,33648:we,10497:Ke},bw={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},xw={POSITION:`position`,NORMAL:`normal`,TANGENT:`tangent`,...eS>=152?{TEXCOORD_0:`uv`,TEXCOORD_1:`uv1`,TEXCOORD_2:`uv2`,TEXCOORD_3:`uv3`}:{TEXCOORD_0:`uv`,TEXCOORD_1:`uv2`},COLOR_0:`color`,WEIGHTS_0:`skinWeight`,JOINTS_0:`skinIndex`},Sw={scale:`scale`,translation:`position`,rotation:`quaternion`,weights:`morphTargetInfluences`},Cw={CUBICSPLINE:void 0,LINEAR:oe,STEP:ae},ww={OPAQUE:`OPAQUE`,MASK:`MASK`,BLEND:`BLEND`},Tw=new ye,Ew=new z;function Dw(e,t,n,r,i,a){let o=2*Math.PI*i/4,s=Math.max(a-2*i,0),c=Math.PI/4;Ew.copy(t),Ew[r]=0,Ew.normalize();let l=.5*o/(o+s),u=1-Ew.angleTo(e)/c;return Math.sign(Ew[n])===1?u*l:s/(o+s)+l+l*(1-u)}var Ow=class extends u{constructor(e=1,t=1,n=1,r=2,i=.1){if(r=r*2+1,i=Math.min(e/2,t/2,n/2,i),super(1,1,1,r,r,r),r===1)return;let a=this.toNonIndexed();this.index=null,this.attributes.position=a.attributes.position,this.attributes.normal=a.attributes.normal,this.attributes.uv=a.attributes.uv;let o=new z,s=new z,c=new z(e,t,n).divideScalar(2).subScalar(i),l=this.attributes.position.array,u=this.attributes.normal.array,d=this.attributes.uv.array,f=l.length/6,p=new z,m=.5/r;for(let r=0,a=0;rt in e?Pw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Iw=(e,t,n)=>(Fw(e,typeof t==`symbol`?t:t+``,n),n),Lw=class extends me{constructor(e){super(e)}load(e,t,n,r){let i=new M(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,e=>{if(typeof e!=`string`)throw Error(`unsupported data type`);let n=JSON.parse(e),r=this.parse(n);t&&t(r)},n,r)}loadAsync(e,t){return super.loadAsync(e,t)}parse(e){return new Rw(e)}},Rw=class{constructor(e){Iw(this,`data`),this.data=e}generateShapes(e,t=100,n){let r=[],i={letterSpacing:0,lineHeight:1,...n},a=zw(e,t,this.data,i);for(let e=0,t=a.length;e(a=c.indexOf(n))&&o=e.byteLength||!(l=r(e)))&&t(1,`no header found`),(u=l.match(n))||t(3,`bad initial token`),c.valid|=1,c.programtype=u[1],c.string+=l+` +`;l=r(e),l!==!1;){if(c.string+=l+` +`,l.charAt(0)===`#`){c.comments+=l+` +`;continue}if((u=l.match(i))&&(c.gamma=parseFloat(u[1])),(u=l.match(a))&&(c.exposure=parseFloat(u[1])),(u=l.match(o))&&(c.valid|=2,c.format=u[1]),(u=l.match(s))&&(c.valid|=4,c.height=parseInt(u[1],10),c.width=parseInt(u[2],10)),c.valid&2&&c.valid&4)break}return c.valid&2||t(3,`missing format specifier`),c.valid&4||t(3,`missing image size specifier`),c},a=function(e,n,r){let i=n;if(i<8||i>32767||e[0]!==2||e[1]!==2||e[2]&128)return new Uint8Array(e);i!==(e[2]<<8|e[3])&&t(3,`wrong scanline width`);let a=new Uint8Array(4*n*r);a.length||t(4,`unable to allocate buffer space`);let o=0,s=0,c=4*i,l=new Uint8Array(4),u=new Uint8Array(c),d=r;for(;d>0&&se.byteLength&&t(1),l[0]=e[s++],l[1]=e[s++],l[2]=e[s++],l[3]=e[s++],(l[0]!=2||l[1]!=2||(l[2]<<8|l[3])!=i)&&t(3,`bad rgbe scanline format`);let n=0,r;for(;n128;if(i&&(r-=128),(r===0||n+r>c)&&t(3,`bad scanline data`),i){let t=e[s++];for(let e=0;e0?F.copy(k[k.length-1]):F.identity())}function r(e){let t=new $e,n=new mt,r=new mt,i=new mt,o=!0,s=!1,c=e.getAttribute(`d`);if(c===``||c===`none`)return null;let l=c.match(/[a-df-z][^a-df-z]*/gi);for(let e=0,c=l.length;e0&&(n.copy(i),t.currentPath.currentPoint.copy(n),o=!0);break;default:console.warn(c)}s=!1}return t}function i(e){if(!(!e.sheet||!e.sheet.cssRules||!e.sheet.cssRules.length))for(let t=0;te.trim());for(let e=0;ee!==``));O[r[e]]=Object.assign(O[r[e]]||{},t)}}}function a(e,t,n,r,i,a,s,c){if(t==0||n==0){e.lineTo(c.x,c.y);return}r=r*Math.PI/180,t=Math.abs(t),n=Math.abs(n);let l=(s.x-c.x)/2,u=(s.y-c.y)/2,d=Math.cos(r)*l+Math.sin(r)*u,f=-Math.sin(r)*l+Math.cos(r)*u,p=t*t,m=n*n,h=d*d,g=f*f,_=h/p+g/m;if(_>1){let e=Math.sqrt(_);t=e*t,n=e*n,p=t*t,m=n*n}let v=p*g+m*h,y=(p*m-v)/v,b=Math.sqrt(Math.max(0,y));i===a&&(b=-b);let x=b*t*f/n,S=-b*n*d/t,C=Math.cos(r)*x-Math.sin(r)*S+(s.x+c.x)/2,w=Math.sin(r)*x+Math.cos(r)*S+(s.y+c.y)/2,T=o(1,0,(d-x)/t,(f-S)/n),E=o((d-x)/t,(f-S)/n,(-d-x)/t,(-f-S)/n)%(Math.PI*2);e.currentPath.absellipse(C,w,t,n,T,T+E,a===0,r)}function o(e,t,n,r){let i=e*n+t*r,a=Math.sqrt(e*e+t*t)*Math.sqrt(n*n+r*r),o=Math.acos(Math.max(-1,Math.min(1,i/a)));return e*r-t*n<0&&(o=-o),o}function s(e){let t=v(e.getAttribute(`x`)||0),n=v(e.getAttribute(`y`)||0),r=v(e.getAttribute(`rx`)||e.getAttribute(`ry`)||0),i=v(e.getAttribute(`ry`)||e.getAttribute(`rx`)||0),a=v(e.getAttribute(`width`)),o=v(e.getAttribute(`height`)),s=.448084975506,c=new $e;return c.moveTo(t+r,n),c.lineTo(t+a-r,n),(r!==0||i!==0)&&c.bezierCurveTo(t+a-r*s,n,t+a,n+i*s,t+a,n+i),c.lineTo(t+a,n+o-i),(r!==0||i!==0)&&c.bezierCurveTo(t+a,n+o-i*s,t+a-r*s,n+o,t+a-r,n+o),c.lineTo(t+r,n+o),(r!==0||i!==0)&&c.bezierCurveTo(t+r*s,n+o,t,n+o-i*s,t,n+o-i),c.lineTo(t,n+i),(r!==0||i!==0)&&c.bezierCurveTo(t,n+i*s,t+r*s,n,t+r,n),c}function c(e){function t(e,t,n){let a=v(t),o=v(n);i===0?r.moveTo(a,o):r.lineTo(a,o),i++}let n=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,r=new $e,i=0;return e.getAttribute(`points`).replace(n,t),r.currentPath.autoClose=!0,r}function l(e){function t(e,t,n){let a=v(t),o=v(n);i===0?r.moveTo(a,o):r.lineTo(a,o),i++}let n=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,r=new $e,i=0;return e.getAttribute(`points`).replace(n,t),r.currentPath.autoClose=!1,r}function u(e){let t=v(e.getAttribute(`cx`)||0),n=v(e.getAttribute(`cy`)||0),r=v(e.getAttribute(`r`)||0),i=new Ne;i.absarc(t,n,r,0,Math.PI*2);let a=new $e;return a.subPaths.push(i),a}function d(e){let t=v(e.getAttribute(`cx`)||0),n=v(e.getAttribute(`cy`)||0),r=v(e.getAttribute(`rx`)||0),i=v(e.getAttribute(`ry`)||0),a=new Ne;a.absellipse(t,n,r,i,0,Math.PI*2);let o=new $e;return o.subPaths.push(a),o}function f(e){let t=v(e.getAttribute(`x1`)||0),n=v(e.getAttribute(`y1`)||0),r=v(e.getAttribute(`x2`)||0),i=v(e.getAttribute(`y2`)||0),a=new $e;return a.moveTo(t,n),a.lineTo(r,i),a.currentPath.autoClose=!1,a}function p(e,t){t=Object.assign({},t);let n={};if(e.hasAttribute(`class`)){let t=e.getAttribute(`class`).split(/\s/).filter(Boolean).map(e=>e.trim());for(let e=0;e0&&t.premultiply(k[k.length-1]),F.copy(t),k.push(t),t}function b(e){let t=new ve,n=A;if(e.nodeName===`use`&&(e.hasAttribute(`x`)||e.hasAttribute(`y`))){let n=v(e.getAttribute(`x`)),r=v(e.getAttribute(`y`));t.translate(n,r)}if(e.hasAttribute(`transform`)){let r=e.getAttribute(`transform`).split(`)`);for(let e=r.length-1;e>=0;e--){let i=r[e].trim();if(i===``)continue;let a=i.indexOf(`(`),o=i.length;if(a>0&&a=1){let e=t[0],r=0;t.length>=2&&(r=t[1]),n.translate(e,r)}break;case`rotate`:if(t.length>=1){let e=0,r=0,i=0;e=t[0]*Math.PI/180,t.length>=3&&(r=t[1],i=t[2]),j.makeTranslation(-r,-i),M.makeRotation(e),N.multiplyMatrices(M,j),j.makeTranslation(r,i),n.multiplyMatrices(j,N)}break;case`scale`:if(t.length>=1){let e=t[0],r=e;t.length>=2&&(r=t[1]),n.scale(e,r)}break;case`skewX`:t.length===1&&n.set(1,Math.tan(t[0]*Math.PI/180),0,0,1,0,0,0,1);break;case`skewY`:t.length===1&&n.set(1,0,0,Math.tan(t[0]*Math.PI/180),1,0,0,0,1);break;case`matrix`:t.length===6&&n.set(t[0],t[2],t[4],t[1],t[3],t[5],0,0,1);break}}t.premultiply(n)}}return t}function x(e,t){function n(e){P.set(e.x,e.y,1).applyMatrix3(t),e.set(P.x,P.y)}function r(e){let n=e.xRadius,r=e.yRadius,i=Math.cos(e.aRotation),a=Math.sin(e.aRotation),o=new z(n*i,n*a,0),s=new z(-r*a,r*i,0),c=o.applyMatrix3(t),l=s.applyMatrix3(t),u=A.set(c.x,l.x,0,c.y,l.y,0,0,0,1),d=j.copy(u).invert(),f=M.copy(d).transpose().multiply(d).elements,p=E(f[0],f[1],f[4]),m=Math.sqrt(p.rt1),h=Math.sqrt(p.rt2);if(e.xRadius=1/m,e.yRadius=1/h,e.aRotation=Math.atan2(p.sn,p.cs),!((e.aEndAngle-e.aStartAngle)%(2*Math.PI)<2**-52)){let n=j.set(m,0,0,0,h,0,0,0,1),r=M.set(p.cs,p.sn,0,-p.sn,p.cs,0,0,0,1),i=n.multiply(r).multiply(u),a=e=>{let{x:t,y:n}=new z(Math.cos(e),Math.sin(e),0).applyMatrix3(i);return Math.atan2(n,t)};e.aStartAngle=a(e.aStartAngle),e.aEndAngle=a(e.aEndAngle),S(t)&&(e.aClockwise=!e.aClockwise)}}function i(e){let n=w(t),r=T(t);e.xRadius*=n,e.yRadius*=r;let i=n>2**-52?Math.atan2(t.elements[1],t.elements[0]):Math.atan2(-t.elements[3],t.elements[4]);e.aRotation+=i,S(t)&&(e.aStartAngle*=-1,e.aEndAngle*=-1,e.aClockwise=!e.aClockwise)}let a=e.subPaths;for(let e=0,o=a.length;e2**-52}function w(e){let t=e.elements;return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function T(e){let t=e.elements;return Math.sqrt(t[3]*t[3]+t[4]*t[4])}function E(e,t,n){let r,i,a,o,s,c=e+n,l=e-n,u=Math.sqrt(l*l+4*t*t);return c>0?(r=.5*(c+u),s=1/r,i=e*s*n-t*s*t):c<0?i=.5*(c-u):(r=.5*u,i=-.5*u),a=l>0?l+u:l-u,Math.abs(a)>2*Math.abs(t)?(s=-2*t/a,o=1/Math.sqrt(1+s*s),a=s*o):Math.abs(t)===0?(a=1,o=0):(s=-.5*a/t,a=1/Math.sqrt(1+s*s),o=s*a),l>0&&(s=a,a=-o,o=s),{rt1:r,rt2:i,cs:a,sn:o}}let D=[],O={},k=[],A=new ve,j=new ve,M=new ve,N=new ve,ee=new mt,P=new z,F=new ve,I=new DOMParser().parseFromString(e,`image/svg+xml`);return n(I.documentElement,{fill:`#000`,fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:`miter`,strokeLineCap:`butt`,strokeMiterLimit:4}),{paths:D,xml:I.documentElement}}static createShapes(e){let t={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},n={loc:t.ORIGIN,t:0};function r(e,r,a,o){let s=e.x,c=r.x,l=a.x,u=o.x,d=e.y,f=r.y,p=a.y,m=o.y,h=(u-l)*(d-p)-(m-p)*(s-l),g=(c-s)*(d-p)-(f-d)*(s-l),_=(m-p)*(c-s)-(u-l)*(f-d),v=h/_,y=g/_;if(_===0&&h!==0||v<=0||v>=1||y<0||y>1)return null;if(h===0&&_===0){for(let l=0;l<2;l++)if(i(l===0?a:o,e,r),n.loc==t.ORIGIN){let e=l===0?a:o;return{x:e.x,y:e.y,t:n.t}}else if(n.loc==t.BETWEEN){let e=+(s+n.t*(c-s)).toPrecision(10),t=+(d+n.t*(f-d)).toPrecision(10);return{x:e,y:t,t:n.t}}return null}else{for(let s=0;s<2;s++)if(i(s===0?a:o,e,r),n.loc==t.ORIGIN){let e=s===0?a:o;return{x:e.x,y:e.y,t:n.t}}let l=+(s+v*(c-s)).toPrecision(10),u=+(d+v*(f-d)).toPrecision(10);return{x:l,y:u,t:v}}}function i(e,r,i){let a=i.x-r.x,o=i.y-r.y,s=e.x-r.x,c=e.y-r.y,l=a*c-s*o;if(e.x===r.x&&e.y===r.y){n.loc=t.ORIGIN,n.t=0;return}if(e.x===i.x&&e.y===i.y){n.loc=t.DESTINATION,n.t=1;return}if(l<-(2**-52)){n.loc=t.LEFT;return}if(l>2**-52){n.loc=t.RIGHT;return}if(a*s<0||o*c<0){n.loc=t.BEHIND;return}if(Math.sqrt(a*a+o*o)e.t<=l.t+2**-52&&e.t>=l.t-2**-52)===void 0&&(n.push(l),i.push(new mt(l.x,l.y)))}}return i}function o(e,t,n){let r=new mt;t.getCenter(r);let i=[];return n.forEach(t=>{t.boundingBox.containsPoint(r)&&a(e,t.points).forEach(e=>{i.push({identifier:t.identifier,isCW:t.isCW,point:e})})}),i.sort((e,t)=>e.point.x-t.point.x),i}function s(e,t,n,r,i){(i==null||i===``)&&(i=`nonzero`);let a=new mt;e.boundingBox.getCenter(a);let s=[new mt(n,a.y),new mt(r,a.y)],c=o(s,e.boundingBox,t);c.sort((e,t)=>e.point.x-t.point.x);let l=[],u=[];c.forEach(t=>{t.identifier===e.identifier?l.push(t):u.push(t)});let d=l[0].point.x,f=[],p=0;for(;p0&&f[f.length-1]===u[p].identifier?f.pop():f.push(u[p].identifier),p++;if(f.push(e.identifier),i===`evenodd`){let t=f.length%2==0,n=f[f.length-2];return{identifier:e.identifier,isHole:t,for:n}}else if(i===`nonzero`){let n=!0,r=null,i=null;for(let e=0;e{let t=e.getPoints(),n=-999999999,r=999999999,i=-999999999,a=999999999;for(let e=0;en&&(n=o.y),o.yi&&(i=o.x),o.x=a&&(l=a-1),{curves:e.curves,points:t,isCW:et.isClockWise(t),identifier:-1,boundingBox:new c(new mt(a,r),new mt(i,n))}});d=d.filter(e=>e.points.length>1);for(let e=0;es(t,d,l,u,e.userData?e.userData.style.fillRule:void 0)),p=[];return d.forEach(e=>{if(!f[e.identifier].isHole){let t=new Ze;t.curves=e.curves,f.filter(t=>t.isHole&&t.for===e.identifier).forEach(e=>{let n=d[e.identifier],r=new Ne;r.curves=n.curves,t.holes.push(r)}),p.push(t)}}),p}static getStrokeStyle(e,t,n,r,i){return e=e===void 0?1:e,t=t===void 0?`#000`:t,n=n===void 0?`miter`:n,r=r===void 0?`butt`:r,i=i===void 0?4:i,{strokeColor:t,strokeWidth:e,strokeLineJoin:n,strokeLineCap:r,strokeMiterLimit:i}}static pointsToStroke(t,n,r,i){let a=[],o=[],s=[];if(e.pointsToStrokeWithBuffers(t,n,r,i,a,o,s)===0)return null;let c=new f;return c.setAttribute(`position`,new N(a,3)),c.setAttribute(`normal`,new N(o,3)),c.setAttribute(`uv`,new N(s,2)),c}static pointsToStrokeWithBuffers(e,t,n,r,i,a,o,s){let c=new mt,l=new mt,u=new mt,d=new mt,f=new mt,p=new mt,m=new mt,h=new mt,g=new mt,_=new mt,v=new mt,y=new mt,b=new mt,x=new mt,S=new mt,C=new mt,w=new mt;n=n===void 0?12:n,r=r===void 0?.001:r,s=s===void 0?0:s,e=le(e);let T=e.length;if(T<2)return 0;let E=e[0].equals(e[T-1]),D,O=e[0],k,A=t.strokeWidth/2,j=1/(T-1),M=0,N,ee,P,F,I=!1,te=0,ne=s*3,L=s*2;re(e[0],e[1],c).multiplyScalar(A),h.copy(e[0]).sub(c),g.copy(e[0]).add(c),_.copy(h),v.copy(g);for(let n=1;n2**-52){let n=A/e;u.multiplyScalar(-n),d.subVectors(D,O),f.copy(d).setLength(n).add(u),C.copy(f).negate();let r=f.length(),i=d.length();d.divideScalar(i),p.subVectors(k,D);let a=p.length();switch(p.divideScalar(a),d.dot(C)=r&&n.push(e[t]);return n.push(e[e.length-1]),n}}};const Ww=new l,Gw=new z;var Kw=class extends ne{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type=`LineSegmentsGeometry`;let e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute(`position`,new N(e,3)),this.setAttribute(`uv`,new N(t,2))}applyMatrix4(e){let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let n=new L(t,6,1);return this.setAttribute(`instanceStart`,new ie(n,3,0)),this.setAttribute(`instanceEnd`,new ie(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e,t=3){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));let r=new L(n,t*2,1);return this.setAttribute(`instanceColorStart`,new ie(r,t,0)),this.setAttribute(`instanceColorEnd`,new ie(r,t,t)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new bt(e.geometry)),this}fromLineSegments(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new l);let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),Ww.setFromBufferAttribute(t),this.boundingBox.union(Ww))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new nt),this.boundingBox===null&&this.computeBoundingBox();let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){let n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let i=0,a=e.count;i + #include + #include + #include + + uniform float linewidth; + uniform vec2 resolution; + + attribute vec3 instanceStart; + attribute vec3 instanceEnd; + + #ifdef USE_COLOR + #ifdef USE_LINE_COLOR_ALPHA + varying vec4 vLineColor; + attribute vec4 instanceColorStart; + attribute vec4 instanceColorEnd; + #else + varying vec3 vLineColor; + attribute vec3 instanceColorStart; + attribute vec3 instanceColorEnd; + #endif + #endif + + #ifdef WORLD_UNITS + + varying vec4 worldPos; + varying vec3 worldStart; + varying vec3 worldEnd; + + #ifdef USE_DASH + + varying vec2 vUv; + + #endif + + #else + + varying vec2 vUv; + + #endif + + #ifdef USE_DASH + + uniform float dashScale; + attribute float instanceDistanceStart; + attribute float instanceDistanceEnd; + varying float vLineDistance; + + #endif + + void trimSegment( const in vec4 start, inout vec4 end ) { + + // trim end segment so it terminates between the camera plane and the near plane + + // conservative estimate of the near plane + float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column + float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column + float nearEstimate = - 0.5 * b / a; + + float alpha = ( nearEstimate - start.z ) / ( end.z - start.z ); + + end.xyz = mix( start.xyz, end.xyz, alpha ); + + } + + void main() { + + #ifdef USE_COLOR + + vLineColor = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd; + + #endif + + #ifdef USE_DASH + + vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd; + vUv = uv; + + #endif + + float aspect = resolution.x / resolution.y; + + // camera space + vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 ); + vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 ); + + #ifdef WORLD_UNITS + + worldStart = start.xyz; + worldEnd = end.xyz; + + #else + + vUv = uv; + + #endif + + // special case for perspective projection, and segments that terminate either in, or behind, the camera plane + // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space + // but we need to perform ndc-space calculations in the shader, so we must address this issue directly + // perhaps there is a more elegant solution -- WestLangley + + bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column + + if ( perspective ) { + + if ( start.z < 0.0 && end.z >= 0.0 ) { + + trimSegment( start, end ); + + } else if ( end.z < 0.0 && start.z >= 0.0 ) { + + trimSegment( end, start ); + + } + + } + + // clip space + vec4 clipStart = projectionMatrix * start; + vec4 clipEnd = projectionMatrix * end; + + // ndc space + vec3 ndcStart = clipStart.xyz / clipStart.w; + vec3 ndcEnd = clipEnd.xyz / clipEnd.w; + + // direction + vec2 dir = ndcEnd.xy - ndcStart.xy; + + // account for clip-space aspect ratio + dir.x *= aspect; + dir = normalize( dir ); + + #ifdef WORLD_UNITS + + // get the offset direction as perpendicular to the view vector + vec3 worldDir = normalize( end.xyz - start.xyz ); + vec3 offset; + if ( position.y < 0.5 ) { + + offset = normalize( cross( start.xyz, worldDir ) ); + + } else { + + offset = normalize( cross( end.xyz, worldDir ) ); + + } + + // sign flip + if ( position.x < 0.0 ) offset *= - 1.0; + + float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) ); + + // don't extend the line if we're rendering dashes because we + // won't be rendering the endcaps + #ifndef USE_DASH + + // extend the line bounds to encompass endcaps + start.xyz += - worldDir * linewidth * 0.5; + end.xyz += worldDir * linewidth * 0.5; + + // shift the position of the quad so it hugs the forward edge of the line + offset.xy -= dir * forwardOffset; + offset.z += 0.5; + + #endif + + // endcaps + if ( position.y > 1.0 || position.y < 0.0 ) { + + offset.xy += dir * 2.0 * forwardOffset; + + } + + // adjust for linewidth + offset *= linewidth * 0.5; + + // set the world position + worldPos = ( position.y < 0.5 ) ? start : end; + worldPos.xyz += offset; + + // project the worldpos + vec4 clip = projectionMatrix * worldPos; + + // shift the depth of the projected points so the line + // segments overlap neatly + vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd; + clip.z = clipPose.z * clip.w; + + #else + + vec2 offset = vec2( dir.y, - dir.x ); + // undo aspect ratio adjustment + dir.x /= aspect; + offset.x /= aspect; + + // sign flip + if ( position.x < 0.0 ) offset *= - 1.0; + + // endcaps + if ( position.y < 0.0 ) { + + offset += - dir; + + } else if ( position.y > 1.0 ) { + + offset += dir; + + } + + // adjust for linewidth + offset *= linewidth; + + // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ... + offset /= resolution.y; + + // select end + vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd; + + // back to clip space + offset *= clip.w; + + clip.xy += offset; + + #endif + + gl_Position = clip; + + vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation + + #include + #include + #include + + } + `,fragmentShader:` + uniform vec3 diffuse; + uniform float opacity; + uniform float linewidth; + + #ifdef USE_DASH + + uniform float dashOffset; + uniform float dashSize; + uniform float gapSize; + + #endif + + varying float vLineDistance; + + #ifdef WORLD_UNITS + + varying vec4 worldPos; + varying vec3 worldStart; + varying vec3 worldEnd; + + #ifdef USE_DASH + + varying vec2 vUv; + + #endif + + #else + + varying vec2 vUv; + + #endif + + #include + #include + #include + #include + + #ifdef USE_COLOR + #ifdef USE_LINE_COLOR_ALPHA + varying vec4 vLineColor; + #else + varying vec3 vLineColor; + #endif + #endif + + vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) { + + float mua; + float mub; + + vec3 p13 = p1 - p3; + vec3 p43 = p4 - p3; + + vec3 p21 = p2 - p1; + + float d1343 = dot( p13, p43 ); + float d4321 = dot( p43, p21 ); + float d1321 = dot( p13, p21 ); + float d4343 = dot( p43, p43 ); + float d2121 = dot( p21, p21 ); + + float denom = d2121 * d4343 - d4321 * d4321; + + float numer = d1343 * d4321 - d1321 * d4343; + + mua = numer / denom; + mua = clamp( mua, 0.0, 1.0 ); + mub = ( d1343 + d4321 * ( mua ) ) / d4343; + mub = clamp( mub, 0.0, 1.0 ); + + return vec2( mua, mub ); + + } + + void main() { + + #include + + #ifdef USE_DASH + + if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps + + if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX + + #endif + + float alpha = opacity; + + #ifdef WORLD_UNITS + + // Find the closest points on the view ray and the line segment + vec3 rayEnd = normalize( worldPos.xyz ) * 1e5; + vec3 lineDir = worldEnd - worldStart; + vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd ); + + vec3 p1 = worldStart + lineDir * params.x; + vec3 p2 = rayEnd * params.y; + vec3 delta = p1 - p2; + float len = length( delta ); + float norm = len / linewidth; + + #ifndef USE_DASH + + #ifdef USE_ALPHA_TO_COVERAGE + + float dnorm = fwidth( norm ); + alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm ); + + #else + + if ( norm > 0.5 ) { + + discard; + + } + + #endif + + #endif + + #else + + #ifdef USE_ALPHA_TO_COVERAGE + + // artifacts appear on some hardware if a derivative is taken within a conditional + float a = vUv.x; + float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; + float len2 = a * a + b * b; + float dlen = fwidth( len2 ); + + if ( abs( vUv.y ) > 1.0 ) { + + alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 ); + + } + + #else + + if ( abs( vUv.y ) > 1.0 ) { + + float a = vUv.x; + float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0; + float len2 = a * a + b * b; + + if ( len2 > 1.0 ) discard; + + } + + #endif + + #endif + + vec4 diffuseColor = vec4( diffuse, alpha ); + #ifdef USE_COLOR + #ifdef USE_LINE_COLOR_ALPHA + diffuseColor *= vLineColor; + #else + diffuseColor.rgb *= vLineColor; + #endif + #endif + + #include + + gl_FragColor = diffuseColor; + + #include + #include <${parseInt(Ve.replace(/\D+/g,``))>=154?`colorspace_fragment`:`encodings_fragment`}> + #include + #include + + } + `,clipping:!0}),this.isLineMaterial=!0,this.onBeforeCompile=function(){this.transparent?this.defines.USE_LINE_COLOR_ALPHA=`1`:delete this.defines.USE_LINE_COLOR_ALPHA},Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},worldUnits:{enumerable:!0,get:function(){return`WORLD_UNITS`in this.defines},set:function(e){e===!0?this.defines.WORLD_UNITS=``:delete this.defines.WORLD_UNITS}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth.value=e}},dashed:{enumerable:!0,get:function(){return`USE_DASH`in this.defines},set(e){!!e!=`USE_DASH`in this.defines&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH=``:delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(e){this.uniforms.dashOffset.value=e}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}},alphaToCoverage:{enumerable:!0,get:function(){return`USE_ALPHA_TO_COVERAGE`in this.defines},set:function(e){!!e!=`USE_ALPHA_TO_COVERAGE`in this.defines&&(this.needsUpdate=!0),e===!0?(this.defines.USE_ALPHA_TO_COVERAGE=``,this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(e)}};const Yw=new ht,Xw=new z,Zw=new z,Qw=new ht,$w=new ht,eT=new ht,tT=new z,nT=new ye,rT=new le,iT=new z,aT=new l,oT=new nt,sT=new ht;let cT,lT;function uT(e,t,n){return sT.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),sT.multiplyScalar(1/sT.w),sT.x=lT/n.width,sT.y=lT/n.height,sT.applyMatrix4(e.projectionMatrixInverse),sT.multiplyScalar(1/sT.w),Math.abs(Math.max(sT.x,sT.y))}function dT(e,t){let n=e.matrixWorld,r=e.geometry,i=r.attributes.instanceStart,a=r.attributes.instanceEnd,o=Math.min(r.instanceCount,i.count);for(let r=0,s=o;ru&&$w.z>u)continue;if(Qw.z>u){let e=Qw.z-$w.z,t=(Qw.z-u)/e;Qw.lerp($w,t)}else if($w.z>u){let e=$w.z-Qw.z,t=($w.z-u)/e;$w.lerp(Qw,t)}Qw.applyMatrix4(r),$w.applyMatrix4(r),Qw.multiplyScalar(1/Qw.w),$w.multiplyScalar(1/$w.w),Qw.x*=i.x/2,Qw.y*=i.y/2,$w.x*=i.x/2,$w.y*=i.y/2,rT.start.copy(Qw),rT.start.z=0,rT.end.copy($w),rT.end.z=0;let o=rT.closestPointToPointParameter(tT,!0);rT.at(o,iT);let l=_e.lerp(Qw.z,$w.z,o),d=l>=-1&&l<=1,f=tT.distanceTo(iT)t)),o=Math.min(e.length,i);return a.slice(0,o).sort().map(t=>e[t])}shuffle(e){return e.map(e=>({value:e,sort:this._getNext()})).sort((e,t)=>e.sort-t.sort).map(({value:e})=>e)}getMulberry32(e=0){return e>0&&e<1&&(e=Math.floor(e*2**16)),()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}};const UT=[gT,_T,vT,yT,bT],WT=_e.lerp,GT=(e=0,t=zT)=>{let n=new HT(e).choice(UT);return t.map((t,r)=>{let i=new HT(e*(r*7907+1)+(typeof t.seed==`number`?t.seed:0)),a=i.int(t.length[0],t.length[1]);return Array.from({length:a}).fill(0).map(()=>{let e=n(i.rand());return{texture:i.defaultChoice(t.texture,BT.texture),size:WT(t.size[0],t.size[1],n(1-e)),distance:WT(t.distance[0],t.distance[1],e),color:i.defaultChoice(t.color,BT.color)}})}).flat()},KT=(e,t,n=void 0,r=void 0,i=BT)=>{if(e!==void 0&&e.length>0&&(typeof n==`number`||typeof r<`u`)){let a=GT(n??0,r??zT),o=a.length,s=e.length;return o>=s?a.map((n,r)=>Object.assign(n,t,rObject.assign({},i,n0){let n=Object.assign({},i,t);return e.map(e=>Object.assign({},n,e))}let a=r===void 0||r.length===0?zT:r;return GT(n??0,a).map(e=>Object.assign({},e,t))};function qT(e){return JT(e,(e,t)=>t in BT&&e!==void 0)}function JT(e,t){let n={};return Object.keys(e).forEach(r=>{t(e[r],r)&&(n[r]=e[r])}),n}const YT=H({__name:`component`,props:{scale:{default:1},elements:{default:void 0},seed:{default:void 0},seedProps:{default:void 0},color:{default:void 0},distance:{default:void 0},size:{default:void 0},texture:{default:void 0}},setup(e,{expose:t}){let n=e,r=dn(),i=dn([]),a=dn(qT(n));t({instance:r});let o=new st,s=new NC,c=[],l=()=>{for(var e,t,n;c.length;)c.pop();(e=r.value)==null||e.children.forEach(e=>{`dispose`in e&&e.dispose()}),(t=r.value)==null||t.remove(...r.value.children),(n=r.value)==null||n.dispose()},u=e=>{if(typeof e.texture==`string`){let t=e.texture;e.texture=o.load(t),e.texture.name=t}return e.color=Te(e.color),e},d=()=>{for(let e=i.value.length-1;e{c[t].size=e.size*n.scale})},f=()=>{for(;i.value.length>c.length;){let e={...u(i.value[c.length])};c.push(e),s.addElement(e)}i.value.forEach((e,t)=>{let n=c[t],{texture:r,size:i,distance:a,color:s}=e;if(typeof r==`string`){if(n.texture.name!==r){n.texture.dispose();let e=r;n.texture=o.load(e),n.texture.name=e}}else n.texture!==r&&(n.texture.dispose(),n.texture=r);n.size=i,n.distance=a,n.color=Te(s)}),d()};return tn(()=>{l()}),$t(()=>{var e;(e=r.value)==null||e.add(s),i.value=KT(n.elements,a.value,n.seed,n.seedProps)}),K(()=>[n.color,n.distance,n.size,n.texture],()=>{a.value={color:n.color,distance:n.distance,size:n.size,texture:n.texture}}),K(()=>[a.value,n.elements,n.seed,n.seedProps],()=>{i.value=KT(n.elements,a.value,n.seed,n.seedProps)}),K(()=>n.scale,()=>{d()}),K(()=>i.value,()=>{f()}),(e,t)=>(U(),V(`TresGroup`,{ref_key:`lensflareRef`,ref:r},null,512))}}),XT=H({__name:`Levioso`,props:{speed:{default:1},rotationFactor:{default:1},floatFactor:{default:1},range:{default:()=>[-.1,.1]}},setup(e,{expose:t}){let n=e,r=dn();t({instance:r});{let e=Math.random()*1e4,{onBeforeRender:t}=Ht(),i=e;t(({delta:e,invalidate:t})=>{if(!r.value)return;i+=e*n.speed;let a=i*.25,o=r.value;o.rotation.x=Math.cos(a)*.125*n.rotationFactor,o.rotation.y=Math.sin(a)*.125*n.rotationFactor,o.rotation.z=Math.sin(a)*.05*n.rotationFactor,o.position.y=_e.mapLinear(Math.sin(a),-1,1,n.range[0],n.range[1])*n.floatFactor,t()})}return(e,t)=>(U(),V(`TresGroup`,Kt(e.$attrs,{ref_key:`groupRef`,ref:r}),[sn(e.$slots,`default`)],16))}}),ZT=[`render-order`],QT=H({__name:`component`,props:{id:{default:1},colorWrite:{type:Boolean,default:!0},depthWrite:{type:Boolean,default:!1}},setup(e,{expose:t}){let r=e,i=dn();function a(){var e,t;let a=Array.isArray((e=i.value)?.material)?i.value.material[0]:(t=i.value)?.material;a&&(a.colorWrite=r.colorWrite,a.depthWrite=r.depthWrite,a.stencilWrite=!0,a.stencilRef=r.id,a.stencilFunc=n,a.stencilFail=qe,a.stencilZFail=qe,a.stencilZPass=qe)}return Fn(a),t({instance:i}),(e,t)=>(U(),V(`TresMesh`,{ref_key:`meshRef`,ref:i,"render-order":-r.id},[sn(e.$slots,`default`)],8,ZT))}}),$T=H({__name:`MouseParallax`,props:{disabled:{type:Boolean,default:!1},factor:{default:2.5},ease:{default:.1},local:{type:Boolean,default:!1}},setup(e){let t=e,{camera:n,renderer:r}=nn(),{disabled:i,factor:a,ease:o,local:s}=_n(t),c={};s.value&&(c.target=r.value.domElement,c.type=`client`);let{x:l,y:u}=Rx(c),{width:d,height:f}=s.value?Mx(r.value.domElement):Bx(),p=dn(),m=W(),h=W();K([a,o],()=>{m.value=Array.isArray(a.value)?a.value:[a.value,a.value],h.value=Array.isArray(o.value)?o.value:[o.value,o.value]},{immediate:!0});let g=kt(()=>(l.value/d.value-.5)*m.value[0]),_=kt(()=>-(u.value/f.value-.5)*m.value[1]),{onBeforeRender:v}=Ht();return v(({delta:e,invalidate:t})=>{i.value||!p.value||Number.isNaN(g.value)||Number.isNaN(_.value)||(p.value.position.x+=(g.value-p.value.position.x)*h.value[0]*e,p.value.position.y+=(_.value-p.value.position.y)*h.value[1]*e,t())}),K(()=>p.value,e=>e?.add(n.value)),(e,t)=>(U(),V(`TresGroup`,{ref_key:`cameraGroupRef`,ref:p},null,512))}}),eE=Jx({screenspace:!1,color:new h(`black`),opacity:1,thickness:.05,size:new mt(1,1)},`#include + #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 + }`),tE=H({__name:`component`,props:{color:{default:`black`},screenspace:{type:Boolean,default:!1},opacity:{default:1},transparent:{type:Boolean,default:!1},thickness:{default:.05},angle:{default:Math.PI},toneMapped:{type:Boolean,default:!0},polygonOffset:{type:Boolean,default:!1},polygonOffsetFactor:{default:0},renderOrder:{default:0}},setup(e,{expose:t}){let n=e,r=dn();t({instance:r});let i=new eE({...n}),a=new mt(1,1),o=0,c=null;function l(e){var t;let r=e.parent;if(!(!r||!r.geometry)&&(o!==n.angle||c!==r.geometry)){o=n.angle,c=r.geometry;let a=(t=e.children)?.[0];a&&(n.angle&&a.geometry.dispose(),e.remove(a)),r.skeleton?(a=new tt,a.material=i,a.bind(r.skeleton,r.bindMatrix),e.add(a)):r.isInstancedMesh?(a=new re(r.geometry,i,r.count),a.instanceMatrix=r.instanceMatrix,e.add(a)):(a=new be,a.material=i,e.add(a)),a.geometry=n.angle?nS(r.geometry,n.angle):r.geometry}}function u(){i.side=s,i.transparent=n.transparent,i.thickness=n.thickness,i.color=Te(n.color),i.opacity=n.opacity,i.size=a,i.screenspace=n.screenspace,i.toneMapped=n.toneMapped,i.polygonOffset=n.polygonOffset,i.polygonOffsetFactor=n.polygonOffsetFactor}let d=fn().sizes;return K(()=>[d.width.value,d.height.value],([e,t])=>{a.set(e,t)}),K(()=>[n.angle],()=>{r.value&&l(r.value)}),K(()=>[n.transparent,n.thickness,n.color,n.opacity,a,n.screenspace,n.toneMapped,n.polygonOffset,n.polygonOffsetFactor],()=>u(),{immediate:!0}),$t(()=>l(r.value)),tn(()=>{var e;let t=(e=r.value)?.children[0];t&&(t.geometry.dispose(),i.dispose(),t.removeFromParent())}),(e,t)=>(U(),V(`TresGroup`,{ref_key:`groupRef`,ref:r},null,512))}}),nE=[`args`],rE=H({__name:`PositionalAudio`,props:{ready:{type:Boolean,default:!1},url:{},distance:{default:2},helper:{type:Boolean,default:!1},loop:{type:Boolean,default:!1},autoplay:{type:Boolean,default:!1},innerAngle:{default:360},outerAngle:{default:360},outerGain:{default:0}},emits:[`isPlaying`],async setup(e,{expose:t,emit:n}){let r,i,s=e,c=n,{ready:u,url:d,distance:f,helper:p,loop:m,autoplay:h,innerAngle:g,outerAngle:_,outerGain:v}=_n(s),{camera:y}=nn(),b=dn(null),x=dn(null),S=dn(null),C=un(new a),w=()=>{var e,t,n;(e=b?.value)!=null&&e.isPlaying||((t=b?.value)==null||t.play(),c(`isPlaying`,(n=b?.value)?.isPlaying))},T=()=>{var e,t;(e=b?.value)!=null&&e.isPlaying&&(b.value.pause(),c(`isPlaying`,(t=b?.value)?.isPlaying))},E=()=>{var e;b.value&&(b.value.stop(),c(`isPlaying`,(e=b?.value)?.isPlaying))},D=()=>{if(!(b!=null&&b.value))return;E();let e=b.value;e.source&&e.disconnect()},O=()=>{var e,t;!(b!=null&&b.value)||!(x!=null&&x.value)||((e=x?.value)==null||e.dispose(),(t=b?.value)==null||t.remove(x?.value))},k=()=>{var e;if(b.value&&(b.value.setBuffer(S.value),b.value.setRefDistance(f.value),b.value.setLoop(m.value),b.value.setDirectionalCone(g.value,_.value,v.value),(e=x?.value)==null||e.update(),x!=null&&x.value)){let e=x.value.material[0];!e.visible&&_.value!==g.value&&(e.visible=!0)}},A=()=>{var e,t;k();let n=(e=b.value)?.parent,r=new l().setFromObject(n),i=(r.max.z-r.min.z)*2;x.value=new hT(b.value,i,32,16),(t=b?.value)==null||t.add(x.value),x.value.update()},j=()=>{var e;(e=y?.value)==null||e.remove(C),D(),O()};return t({instance:b,play:w,stop:E,pause:T,dispose:j}),S.value=([r,i]=In(()=>se(o,d.value)),r=await r,i(),r),K(b,()=>{b!=null&&b.value&&(p.value&&A(),u.value&&h&&w())}),K(p,()=>{p.value?A():O()}),K(u,()=>{u.value&&k(),h.value&&u.value&&w(),!h.value&&u.value&&E()}),K([f,m,S,g,_,v,h],()=>{k()}),$t(()=>{var e;(e=y?.value)==null||e.add(C)}),Qt(()=>{j()}),(e,t)=>(U(),V(`TresPositionalAudio`,Kt({ref_key:`positionalAudioRef`,ref:b,args:[G(C)]},e.$attrs),null,16,nE))}}),iE=[`args`,`material-uniforms-color-value`],aE=H({__name:`Reflector`,props:{color:{default:`#333`},textureWidth:{default:512},textureHeight:{default:512},clipBias:{default:0},multisample:{default:4},shader:{default:TC.ReflectorShader}},setup(e,{expose:t}){let n=e,{extend:r,invalidate:i}=nn(),a=dn();r({Reflector:TC});let{color:o,textureWidth:s,textureHeight:c,clipBias:l,multisample:u,shader:d}=_n(n);return K(n,()=>i()),t({instance:a}),(e,t)=>(U(),V(`TresReflector`,{ref_key:`reflectorRef`,ref:a,args:[void 0,{textureWidth:G(s),textureHeight:G(c),clipBias:G(l),multisample:G(u),shader:G(d)}],"material-uniforms-color-value":G(o)},[sn(e.$slots,`default`,{},()=>[t[0]||=B(`TresPlaneGeometry`,{args:[5,5]},null,-1)])],8,iE))}}),oE=[`position-z`],sE=H({__name:`ScreenSpace`,props:{depth:{default:-1}},setup(e,{expose:t}){let n=dn();return Ht().onBeforeRender(({camera:e})=>{n.value&&(n.value.quaternion.copy(e.quaternion),n.value.position.copy(e.position))}),t({instance:n}),(e,t)=>(U(),V(`TresGroup`,{ref_key:`outerRef`,ref:n},[B(`TresGroup`,{"position-z":-e.depth},[sn(e.$slots,`default`)],8,oE)],512))}}),cE=[`args`,`center`],lE=H({__name:`Text3D`,props:{font:{},text:{},size:{default:.5},height:{default:.2},curveSegments:{default:5},bevelEnabled:{type:Boolean,default:!0},bevelThickness:{default:.05},bevelSize:{default:.02},bevelOffset:{default:0},bevelSegments:{default:4},center:{type:Boolean,default:!1},needUpdates:{type:Boolean,default:!1}},async setup(e,{expose:t}){let n,r,i=e,{center:a,font:o,text:s,needUpdates:c,size:l,height:u,curveSegments:d,bevelEnabled:f,bevelThickness:p,bevelSize:m,bevelOffset:h,bevelSegments:g}=_n(i),{extend:_,invalidate:v}=nn();K(i,()=>v()),_({TextGeometry:kw});let y=new Lw,b=On(),x=kt(()=>{var e;return s!=null&&s.value?s.value:b.default?(e=b.default()[0].children)?.trim():c.value?``:`TresJS`}),S=dn();t({instance:S});let C=([n,r]=In(()=>new Promise((e,t)=>{try{typeof o.value==`string`?y.load(o.value,t=>{e(t)}):e(o.value)}catch(e){t(console.error(`cientos`,e))}})),n=await n,r(),n),w=kt(()=>({font:C,size:vn(l),height:vn(u),curveSegments:vn(d),bevelEnabled:vn(f),bevelThickness:vn(p),bevelSize:vn(m),bevelOffset:vn(h),bevelSegments:vn(g)}));return Fn(()=>{S.value&&c.value&&(S.value.geometry.dispose(),S.value.geometry=new kw(x.value,w.value),a.value&&S.value.geometry.center())}),(e,t)=>G(o)?(U(),V(`TresMesh`,{key:0,ref_key:`text3DRef`,ref:S},[x.value?(U(),V(`TresTextGeometry`,{key:0,args:[x.value,w.value],center:G(a)},null,8,cE)):jt(``,!0),sn(e.$slots,`default`)],512)):jt(``,!0)}});function uE(e){let t=W(null),{height:n,width:r,settings:i,depth:a,autoRender:o=W(!0)}=Ut(e)?_n(e):_n(rn(e)),{onBeforeRender:s}=Ht(),{camera:c,renderer:l,scene:u,sizes:d,invalidate:f}=nn();return K(()=>[r?.value,d.width.value,n?.value,d.height.value],()=>{var e;(e=t.value)==null||e.dispose(),t.value=new vt(r?.value||d.width.value,n?.value||d.height.value,{minFilter:de,magFilter:de,type:te,...i?.value}),a!=null&&a.value&&(t.value.depthTexture=new w(r?.value||d.width.value,n?.value||d.height.value,ee)),f()},{immediate:!0}),s(()=>{o.value&&(l.value.setRenderTarget(t.value),l.value.clear(),l.value.render(u.value,c.value),l.value.setRenderTarget(null))},1/0),Qt(()=>{var e;(e=t.value)==null||e.dispose()}),t}const dE=H({__name:`component`,props:{width:{},height:{},depth:{type:Boolean,default:!1},settings:{default:void 0},autoRender:{type:Boolean,default:!0}},setup(e,{expose:t}){let n=uE(e);return t({instance:n}),()=>{}}}),fE=(e,t=16,n,r,i)=>{let a=new Float32Array(t*16),o=W(new R(a,16));return(()=>{if(!e)return;let a=new WC(e);r&&a.setWeightAttribute(r),a.build();let s=new z,c=new z,l=new h,u=new Ae;e.updateMatrixWorld(!0);for(let r=0;ro()),Fn(()=>{var e,t;i.value=n.instanceMesh??(e=r.value)?.children.find(e=>Object.prototype.hasOwnProperty.call(e,`instanceMatrix`)),a.value=n.mesh??(t=r.value)?.children.find(e=>e.type===`Mesh`),fE(a.value,n.count,i.value,n.weight,n.transform)}),t({samplerRef:r}),(e,t)=>(U(),V(`TresGroup`,{ref_key:`samplerRef`,ref:r},[sn(e.$slots,`default`)],512))}}),mE=new z,hE=new z,gE=new z,_E=(e,t,n)=>{let r=n.width/2,i=n.height/2;t.updateMatrixWorld(!1);let a=e.project(t);return a.x=a.x*r+r,a.y=-(a.y*i)+i,a},vE=(e,t,n,r=1)=>{let i=mE.set(e.x/n.width*2-1,-(e.y/n.height)*2+1,r);return i.unproject(t),i},yE=(e,t,n,r)=>{let i=_E(gE.copy(e),n,r),a=0;for(let o=0;o<2;++o){let s=hE.copy(i).setComponent(o,i.getComponent(o)+t),c=vE(s,n,r,s.z);a=Math.max(a,e.distanceTo(c))}return a},bE=H({__name:`ScreenSizer`,setup(e,{expose:t}){let n=new z,r=dn(),i=dn(),a=fn().sizes,o=kt(()=>({width:a.width.value,height:a.height.value}));return Ht().onBeforeRender(({camera:e})=>{let t=i.value;if(!t)return;let r=yE(t.getWorldPosition(n),1,e,o.value);t.scale.setScalar(r)}),t({instance:r}),(e,t)=>(U(),V(`TresObject3D`,{ref_key:`outerRef`,ref:r},[B(`TresObject3D`,{ref_key:`innerRef`,ref:i},[sn(e.$slots,`default`)],512)],512))}}),xE=[`color`],SE=H({__name:`Edges`,props:{color:{default:`#ff0000`},threshold:{default:15}},setup(e,{expose:t}){let n=e,{color:r,threshold:i}=_n(n),a=dn(),o=W(null),s=W(1);return t({instance:a}),K(()=>[a.value,i.value],()=>{if(a.value){let e=a.value.parent;if(e&&`geometry`in e&&e.geometry instanceof f){let t=e.geometry;(t!==o.value||i.value!==s.value)&&(o.value=t,s.value=i.value,a.value.geometry=new E(t,i.value))}}}),(e,t)=>(U(),V(`TresLineSegments`,Kt({ref_key:`lineSegmentsRef`,ref:a},e.$attrs),[sn(e.$slots,`default`,{},()=>[B(`TresLineBasicMaterial`,{color:G(r)},null,8,xE)])],16))}}),CE={sunset:`venice/venice_sunset_1k.hdr`,studio:`studio/poly_haven_studio_1k.hdr`,city:`city/canary_wharf_1k.hdr`,umbrellas:`outdoor/outdoor_umbrellas_1k.hdr`,night:`outdoor/satara_night_1k.hdr`,forest:`outood/mossy_forest_1k.hdr`,snow:`outdoor/snowy_forest_path_01_1k.hdr`,dawn:`kiara/kiara_1_dawn_1k.hdr`,hangar:`indoor/small_hangar_01_1k.hdr`,urban:`indoor/abandoned_games_room_02_1k.hdr`,modern:`city/modern_buildings_2_1k.hdr`,shangai:`city/shanghai_bund_1k.hdr`},wE=`https://raw.githubusercontent.com/Tresjs/assets/main/textures/hdr/`;function TE(e){return e instanceof k?e:Array.isArray(e)?new k(e[0],e[1],e[2]):typeof e==`number`?new k(e,e,e):e instanceof z||typeof e==`object`&&`x`in e&&`y`in e&&`z`in e?new k(e.x,e.y,e.z):null}function EE(e){e.traverse(e=>{e instanceof be&&e.material&&(e.material.needsUpdate=!0)})}async function DE(e,t){let{scene:n,invalidate:r}=nn(),{preset:i,blur:a,files:o=W([]),path:s=W(``),background:c,backgroundIntensity:l=W(1),environmentIntensity:u=W(1),backgroundRotation:d=W([0,0,0]),environmentRotation:f=W([0,0,0]),syncMaterials:p=W(!1)}=_n(e);K(e,()=>{r()});let m=W(null),h=kt(()=>Array.isArray(o.value)),g=kt(()=>h.value?y:Vw);return K([o,s],async([e,t])=>{if(e&&e.length>0&&!(i!=null&&i.value)){try{let n=await se(g.value,h.value?[...G(e)]:G(e),e=>{t&&e.setPath(G(t))});m.value=Array.isArray(n)?n[0]:n}catch(e){throw Error(`Failed to load environment map: ${e}`)}m.value&&(m.value.mapping=h.value?v:O)}},{immediate:!0}),K(m,e=>{n.value&&e&&(n.value.environment=e)},{immediate:!0}),K([c,m],([e,r])=>{if(n.value){let i=t!=null&&t.value?t.value.texture:r;i&&(n.value.background=e?i:null)}},{immediate:!0}),K(()=>a?.value,e=>{n.value&&e&&(n.value.backgroundBlurriness=e)},{immediate:!0}),K(()=>l?.value,e=>{n.value&&(n.value.backgroundIntensity=e??1)},{immediate:!0}),K(()=>u?.value,e=>{n.value&&(n.value.environmentIntensity=e??1)},{immediate:!0}),K(()=>d?.value,e=>{if(n.value){let t=TE(e);t&&(n.value.backgroundRotation=t)}},{immediate:!0}),K(()=>f?.value,e=>{if(n.value&&!(p!=null&&p.value)){let t=TE(e);t&&(n.value.environmentRotation=t,EE(n.value))}},{immediate:!0}),K(()=>i?.value,async e=>{if(e&&e in CE){let t=wE,n=CE[e];try{let e=await se(Vw,n,e=>{t&&e.setPath(t)});m.value=Array.isArray(e)?e[0]:e}catch(e){throw Error(`Failed to load environment map: ${e}`)}m.value&&(m.value.mapping=O),r()}else if(e&&!(e in CE))throw Error(`Preset must be one of: ${Object.keys(CE).join(`, `)}`)},{immediate:!0}),K([p,d],([e,t])=>{if(e&&n.value){let e=TE(t);e&&(n.value.environmentRotation=e,EE(n.value))}},{immediate:!0}),m} +/*! +* camera-controls +* https://github.com/yomotsu/camera-controls +* (c) 2017 @yomotsu +* Released under the MIT License. +*/ +const OE={LEFT:1,RIGHT:2,MIDDLE:4},J=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768}),kE={NONE:0,IN:1,OUT:-1};function AE(e){return e.isPerspectiveCamera}function jE(e){return e.isOrthographicCamera}const ME=Math.PI*2,NE=Math.PI/2,PE=1e-5,FE=Math.PI/180;function IE(e,t,n){return Math.max(t,Math.min(n,e))}function LE(e,t=PE){return Math.abs(e)0==p>u&&(p=u,n.value=(p-u)/a),p}function UE(e,t,n,r,i=1/0,a,o){r=Math.max(1e-4,r);let s=2/r,c=s*a,l=1/(1+c+.48*c*c+.235*c*c*c),u=t.x,d=t.y,f=t.z,p=e.x-u,m=e.y-d,h=e.z-f,g=u,_=d,v=f,y=i*r,b=y*y,x=p*p+m*m+h*h;if(x>b){let e=Math.sqrt(x);p=p/e*y,m=m/e*y,h=h/e*y}u=e.x-p,d=e.y-m,f=e.z-h;let S=(n.x+s*p)*a,C=(n.y+s*m)*a,w=(n.z+s*h)*a;n.x=(n.x-s*S)*l,n.y=(n.y-s*C)*l,n.z=(n.z-s*w)*l,o.x=u+(p+S)*l,o.y=d+(m+C)*l,o.z=f+(h+w)*l;let T=g-e.x,E=_-e.y,D=v-e.z,O=o.x-g,k=o.y-_,A=o.z-v;return T*O+E*k+D*A>0&&(o.x=g,o.y=_,o.z=v,n.x=(o.x-g)/a,n.y=(o.y-_)/a,n.z=(o.z-v)/a),o}function WE(e,t){t.set(0,0),e.forEach(e=>{t.x+=e.clientX,t.y+=e.clientY}),t.x/=e.length,t.y/=e.length}function GE(e,t){return jE(e)?(console.warn(`${t} is not supported in OrthographicCamera`),!0):!1}var KE=class{constructor(){this._listeners={}}addEventListener(e,t){let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners[e];if(n!==void 0){let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){let t=this._listeners[e.type];if(t!==void 0){e.target=this;let n=t.slice(0);for(let t=0,r=n.length;t{},this._enabled=!0,this._state=J.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._dragNeedsUpdate=!0,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=kE.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new ZE.Vector3,this._focalOffsetVelocity=new ZE.Vector3,this._zoomVelocity={value:0},this._truckInternal=(e,t,n)=>{let r,i;if(AE(this._camera)){let n=nD.copy(this._camera.position).sub(this._target),a=this._camera.getEffectiveFOV()*FE,o=n.length()*Math.tan(a*.5);r=this.truckSpeed*e*o/this._elementRect.height,i=this.truckSpeed*t*o/this._elementRect.height}else if(jE(this._camera)){let n=this._camera;r=e*(n.right-n.left)/n.zoom/this._elementRect.width,i=t*(n.top-n.bottom)/n.zoom/this._elementRect.height}else return;this.verticalDragToForward?(n?this.setFocalOffset(this._focalOffsetEnd.x+r,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(r,0,!0),this.forward(-i,!0)):n?this.setFocalOffset(this._focalOffsetEnd.x+r,this._focalOffsetEnd.y+i,this._focalOffsetEnd.z,!0):this.truck(r,i,!0)},this._rotateInternal=(e,t)=>{let n=ME*this.azimuthRotateSpeed*e/this._elementRect.height,r=ME*this.polarRotateSpeed*t/this._elementRect.height;this.rotate(n,r,!0)},this._dollyInternal=(e,t,n)=>{let r=.95**(-e*this.dollySpeed),i=this._sphericalEnd.radius,a=this._sphericalEnd.radius*r,o=IE(a,this.minDistance,this.maxDistance),s=o-a;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(a,!0):(this.infinityDolly&&!this.dollyToCursor&&this.dollyInFixed(s,!0),this._dollyToNoClamp(o,!0)),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?a:o)-i,this._dollyControlCoord.set(t,n)),this._lastDollyDirection=Math.sign(-e)},this._zoomInternal=(e,t,n)=>{let r=.95**(e*this.dollySpeed),i=this._zoom,a=this._zoom*r;this.zoomTo(a,!0),this.dollyToCursor&&(this._changedZoom+=a-i,this._dollyControlCoord.set(t,n))},typeof ZE>`u`&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=t,this._yAxisUpSpace=new ZE.Quaternion().setFromUnitVectors(this._camera.up,$E),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=J.NONE,this._target=new ZE.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new ZE.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new ZE.Spherical().setFromVector3(nD.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new ZE.Vector3,new ZE.Vector3,new ZE.Vector3,new ZE.Vector3],this._updateNearPlaneCorners(),this._boundary=new ZE.Box3(new ZE.Vector3(-1/0,-1/0,-1/0),new ZE.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new ZE.Vector2,this.mouseButtons={left:J.ROTATE,middle:J.DOLLY,right:J.TRUCK,wheel:AE(this._camera)?J.DOLLY:jE(this._camera)?J.ZOOM:J.NONE},this.touches={one:J.TOUCH_ROTATE,two:AE(this._camera)?J.TOUCH_DOLLY_TRUCK:jE(this._camera)?J.TOUCH_ZOOM_TRUCK:J.NONE,three:J.TOUCH_TRUCK};let r=new ZE.Vector2,i=new ZE.Vector2,a=new ZE.Vector2,o=e=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){let t=this._domElement.getBoundingClientRect(),n=e.clientX/t.width,r=e.clientY/t.height;if(nthis._interactiveArea.right||rthis._interactiveArea.bottom)return}let t=e.pointerType===`mouse`?(e.buttons&OE.LEFT)===OE.LEFT?OE.LEFT:(e.buttons&OE.MIDDLE)===OE.MIDDLE?OE.MIDDLE:(e.buttons&OE.RIGHT)===OE.RIGHT?OE.RIGHT:null:null;if(t!==null){let e=this._findPointerByMouseButton(t);e&&this._disposePointer(e)}if((e.buttons&OE.LEFT)===OE.LEFT&&this._lockedPointer)return;let n={pointerId:e.pointerId,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:0,mouseButton:t};this._activePointers.push(n),this._domElement.ownerDocument.removeEventListener(`pointermove`,s,{passive:!1}),this._domElement.ownerDocument.removeEventListener(`pointerup`,c),this._domElement.ownerDocument.addEventListener(`pointermove`,s,{passive:!1}),this._domElement.ownerDocument.addEventListener(`pointerup`,c),this._isDragging=!0,f(e)},s=e=>{e.cancelable&&e.preventDefault();let t=e.pointerId,n=this._lockedPointer||this._findPointerById(t);if(n){if(n.clientX=e.clientX,n.clientY=e.clientY,n.deltaX=e.movementX,n.deltaY=e.movementY,this._state=0,e.pointerType===`touch`)switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else (!this._isDragging&&this._lockedPointer||this._isDragging&&(e.buttons&OE.LEFT)===OE.LEFT)&&(this._state|=this.mouseButtons.left),this._isDragging&&(e.buttons&OE.MIDDLE)===OE.MIDDLE&&(this._state|=this.mouseButtons.middle),this._isDragging&&(e.buttons&OE.RIGHT)===OE.RIGHT&&(this._state|=this.mouseButtons.right);p()}},c=e=>{let t=this._findPointerById(e.pointerId);if(!(t&&t===this._lockedPointer)){if(t&&this._disposePointer(t),e.pointerType===`touch`)switch(this._activePointers.length){case 0:this._state=J.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=J.NONE;m()}},l=-1,u=e=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===J.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){let t=this._domElement.getBoundingClientRect(),n=e.clientX/t.width,r=e.clientY/t.height;if(nthis._interactiveArea.right||rthis._interactiveArea.bottom)return}if(e.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===J.ROTATE||this.mouseButtons.wheel===J.TRUCK){let e=performance.now();l-e<1e3&&this._getClientRect(this._elementRect),l=e}let t=XE?-1:-3,n=e.deltaMode===1?e.deltaY/t:e.deltaY/(t*10),r=this.dollyToCursor?(e.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,i=this.dollyToCursor?(e.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case J.ROTATE:this._rotateInternal(e.deltaX,e.deltaY),this._isUserControllingRotate=!0;break;case J.TRUCK:this._truckInternal(e.deltaX,e.deltaY,!1),this._isUserControllingTruck=!0;break;case J.OFFSET:this._truckInternal(e.deltaX,e.deltaY,!0),this._isUserControllingOffset=!0;break;case J.DOLLY:this._dollyInternal(-n,r,i),this._isUserControllingDolly=!0;break;case J.ZOOM:this._zoomInternal(-n,r,i),this._isUserControllingZoom=!0;break}this.dispatchEvent({type:`control`})},d=t=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===e.ACTION.NONE){let e=t instanceof PointerEvent?t.pointerId:0,n=this._findPointerById(e);n&&this._disposePointer(n),this._domElement.ownerDocument.removeEventListener(`pointermove`,s,{passive:!1}),this._domElement.ownerDocument.removeEventListener(`pointerup`,c);return}t.preventDefault()}},f=e=>{if(this._enabled){if(WE(this._activePointers,tD),this._getClientRect(this._elementRect),r.copy(tD),i.copy(tD),this._activePointers.length>=2){let e=tD.x-this._activePointers[1].clientX,t=tD.y-this._activePointers[1].clientY,n=Math.sqrt(e*e+t*t);a.set(0,n);let r=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,o=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;i.set(r,o)}if(this._state=0,!e)this._lockedPointer&&(this._state|=this.mouseButtons.left);else if(`pointerType`in e&&e.pointerType===`touch`)switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else !this._lockedPointer&&(e.buttons&OE.LEFT)===OE.LEFT&&(this._state|=this.mouseButtons.left),(e.buttons&OE.MIDDLE)===OE.MIDDLE&&(this._state|=this.mouseButtons.middle),(e.buttons&OE.RIGHT)===OE.RIGHT&&(this._state|=this.mouseButtons.right);((this._state&J.ROTATE)===J.ROTATE||(this._state&J.TOUCH_ROTATE)===J.TOUCH_ROTATE||(this._state&J.TOUCH_DOLLY_ROTATE)===J.TOUCH_DOLLY_ROTATE||(this._state&J.TOUCH_ZOOM_ROTATE)===J.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&J.TRUCK)===J.TRUCK||(this._state&J.TOUCH_TRUCK)===J.TOUCH_TRUCK||(this._state&J.TOUCH_DOLLY_TRUCK)===J.TOUCH_DOLLY_TRUCK||(this._state&J.TOUCH_ZOOM_TRUCK)===J.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&J.DOLLY)===J.DOLLY||(this._state&J.TOUCH_DOLLY)===J.TOUCH_DOLLY||(this._state&J.TOUCH_DOLLY_TRUCK)===J.TOUCH_DOLLY_TRUCK||(this._state&J.TOUCH_DOLLY_OFFSET)===J.TOUCH_DOLLY_OFFSET||(this._state&J.TOUCH_DOLLY_ROTATE)===J.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&J.ZOOM)===J.ZOOM||(this._state&J.TOUCH_ZOOM)===J.TOUCH_ZOOM||(this._state&J.TOUCH_ZOOM_TRUCK)===J.TOUCH_ZOOM_TRUCK||(this._state&J.TOUCH_ZOOM_OFFSET)===J.TOUCH_ZOOM_OFFSET||(this._state&J.TOUCH_ZOOM_ROTATE)===J.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&J.OFFSET)===J.OFFSET||(this._state&J.TOUCH_OFFSET)===J.TOUCH_OFFSET||(this._state&J.TOUCH_DOLLY_OFFSET)===J.TOUCH_DOLLY_OFFSET||(this._state&J.TOUCH_ZOOM_OFFSET)===J.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:`controlstart`})}},p=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,WE(this._activePointers,tD);let e=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,t=e?-e.deltaX:i.x-tD.x,n=e?-e.deltaY:i.y-tD.y;if(i.copy(tD),((this._state&J.ROTATE)===J.ROTATE||(this._state&J.TOUCH_ROTATE)===J.TOUCH_ROTATE||(this._state&J.TOUCH_DOLLY_ROTATE)===J.TOUCH_DOLLY_ROTATE||(this._state&J.TOUCH_ZOOM_ROTATE)===J.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(t,n),this._isUserControllingRotate=!0),(this._state&J.DOLLY)===J.DOLLY||(this._state&J.ZOOM)===J.ZOOM){let e=this.dollyToCursor?(r.x-this._elementRect.x)/this._elementRect.width*2-1:0,t=this.dollyToCursor?(r.y-this._elementRect.y)/this._elementRect.height*-2+1:0,i=this.dollyDragInverted?-1:1;(this._state&J.DOLLY)===J.DOLLY?(this._dollyInternal(i*n*YE,e,t),this._isUserControllingDolly=!0):(this._zoomInternal(i*n*YE,e,t),this._isUserControllingZoom=!0)}if((this._state&J.TOUCH_DOLLY)===J.TOUCH_DOLLY||(this._state&J.TOUCH_ZOOM)===J.TOUCH_ZOOM||(this._state&J.TOUCH_DOLLY_TRUCK)===J.TOUCH_DOLLY_TRUCK||(this._state&J.TOUCH_ZOOM_TRUCK)===J.TOUCH_ZOOM_TRUCK||(this._state&J.TOUCH_DOLLY_OFFSET)===J.TOUCH_DOLLY_OFFSET||(this._state&J.TOUCH_ZOOM_OFFSET)===J.TOUCH_ZOOM_OFFSET||(this._state&J.TOUCH_DOLLY_ROTATE)===J.TOUCH_DOLLY_ROTATE||(this._state&J.TOUCH_ZOOM_ROTATE)===J.TOUCH_ZOOM_ROTATE){let e=tD.x-this._activePointers[1].clientX,t=tD.y-this._activePointers[1].clientY,n=Math.sqrt(e*e+t*t),r=a.y-n;a.set(0,n);let o=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,s=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&J.TOUCH_DOLLY)===J.TOUCH_DOLLY||(this._state&J.TOUCH_DOLLY_ROTATE)===J.TOUCH_DOLLY_ROTATE||(this._state&J.TOUCH_DOLLY_TRUCK)===J.TOUCH_DOLLY_TRUCK||(this._state&J.TOUCH_DOLLY_OFFSET)===J.TOUCH_DOLLY_OFFSET?(this._dollyInternal(r*YE,o,s),this._isUserControllingDolly=!0):(this._zoomInternal(r*YE,o,s),this._isUserControllingZoom=!0)}((this._state&J.TRUCK)===J.TRUCK||(this._state&J.TOUCH_TRUCK)===J.TOUCH_TRUCK||(this._state&J.TOUCH_DOLLY_TRUCK)===J.TOUCH_DOLLY_TRUCK||(this._state&J.TOUCH_ZOOM_TRUCK)===J.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(t,n,!1),this._isUserControllingTruck=!0),((this._state&J.OFFSET)===J.OFFSET||(this._state&J.TOUCH_OFFSET)===J.TOUCH_OFFSET||(this._state&J.TOUCH_DOLLY_OFFSET)===J.TOUCH_DOLLY_OFFSET||(this._state&J.TOUCH_ZOOM_OFFSET)===J.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(t,n,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:`control`})},m=()=>{WE(this._activePointers,tD),i.copy(tD),this._dragNeedsUpdate=!1,(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener(`pointermove`,s,{passive:!1}),this._domElement.ownerDocument.removeEventListener(`pointerup`,c),this.dispatchEvent({type:`controlend`}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener(`pointermove`,s,{passive:!1}),this._domElement.ownerDocument.removeEventListener(`pointerup`,c),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener(`pointerlockchange`,h),this._domElement.ownerDocument.addEventListener(`pointerlockerror`,g),this._domElement.ownerDocument.addEventListener(`pointermove`,s,{passive:!1}),this._domElement.ownerDocument.addEventListener(`pointerup`,c),f())},this.unlockPointer=()=>{var e,t,n;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(e=this._domElement)==null||e.ownerDocument.exitPointerLock(),(t=this._domElement)==null||t.ownerDocument.removeEventListener(`pointerlockchange`,h),(n=this._domElement)==null||n.ownerDocument.removeEventListener(`pointerlockerror`,g),this.cancel()};let h=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},g=()=>{this.unlockPointer()};this._addAllEventListeners=e=>{this._domElement=e,this._domElement.style.touchAction=`none`,this._domElement.style.userSelect=`none`,this._domElement.style.webkitUserSelect=`none`,this._domElement.addEventListener(`pointerdown`,o),this._domElement.addEventListener(`pointercancel`,c),this._domElement.addEventListener(`wheel`,u,{passive:!1}),this._domElement.addEventListener(`contextmenu`,d)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction=``,this._domElement.style.userSelect=``,this._domElement.style.webkitUserSelect=``,this._domElement.removeEventListener(`pointerdown`,o),this._domElement.removeEventListener(`pointercancel`,c),this._domElement.removeEventListener(`wheel`,u,{passive:!1}),this._domElement.removeEventListener(`contextmenu`,d),this._domElement.ownerDocument.removeEventListener(`pointermove`,s,{passive:!1}),this._domElement.ownerDocument.removeEventListener(`pointerup`,c),this._domElement.ownerDocument.removeEventListener(`pointerlockchange`,h),this._domElement.ownerDocument.removeEventListener(`pointerlockerror`,g))},this.cancel=()=>{this._state!==J.NONE&&(this._state=J.NONE,this._activePointers.length=0,m())},n&&this.connect(n),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction=`none`,this._domElement.style.userSelect=`none`,this._domElement.style.webkitUserSelect=`none`):(this.cancel(),this._domElement.style.touchAction=``,this._domElement.style.userSelect=``,this._domElement.style.webkitUserSelect=``))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=IE(e.width,0,1),this._interactiveArea.height=IE(e.height,0,1),this._interactiveArea.x=IE(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=IE(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,n=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,n)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,n=!1){this._isUserControllingRotate=!1;let r=IE(e,this.minAzimuthAngle,this.maxAzimuthAngle),i=IE(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=r,this._sphericalEnd.phi=i,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,n||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);let a=!n||RE(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&RE(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(a)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=kE.NONE,this._changedDolly=0,this._dollyToNoClamp(IE(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){let n=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){let t=this._collisionTest(),r=RE(t,this._spherical.radius);if(!(n>e)&&r)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,t)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);let r=!t||RE(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(r)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(aD).multiplyScalar(e)),t||this._target.copy(this._targetEnd);let n=!t||RE(this._target.x,this._targetEnd.x,this.restThreshold)&&RE(this._target.y,this._targetEnd.y,this.restThreshold)&&RE(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=IE(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);let n=!t||RE(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(n)}pan(e,t,n=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,n)}truck(e,t,n=!1){this._camera.updateMatrix(),oD.setFromMatrixColumn(this._camera.matrix,0),sD.setFromMatrixColumn(this._camera.matrix,1),oD.multiplyScalar(e),sD.multiplyScalar(-t);let r=nD.copy(oD).add(sD),i=rD.copy(this._targetEnd).add(r);return this.moveTo(i.x,i.y,i.z,n)}forward(e,t=!1){nD.setFromMatrixColumn(this._camera.matrix,0),nD.crossVectors(this._camera.up,nD),nD.multiplyScalar(e);let n=rD.copy(this._targetEnd).add(nD);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return nD.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+nD.x,this._targetEnd.y+nD.y,this._targetEnd.z+nD.z,t)}moveTo(e,t,n,r=!1){this._isUserControllingTruck=!1;let i=nD.set(e,t,n).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,i,this.boundaryFriction),this._needsUpdate=!0,r||this._target.copy(this._targetEnd);let a=!r||RE(this._target.x,this._targetEnd.x,this.restThreshold)&&RE(this._target.y,this._targetEnd.y,this.restThreshold)&&RE(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}lookInDirectionOf(e,t,n,r=!1){let i=nD.set(e,t,n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(i.x,i.y,i.z,r)}fitToBox(e,t,{cover:n=!1,paddingLeft:r=0,paddingRight:i=0,paddingBottom:a=0,paddingTop:o=0}={}){let s=[],c=e.isBox3?pD.copy(e):pD.setFromObject(e);c.isEmpty()&&(console.warn(`camera-controls: fitTo() cannot be used with an empty box. Aborting`),Promise.resolve());let l=zE(this._sphericalEnd.theta,NE),u=zE(this._sphericalEnd.phi,NE);s.push(this.rotateTo(l,u,t));let d=nD.setFromSpherical(this._sphericalEnd).normalize(),f=gD.setFromUnitVectors(d,eD),p=RE(Math.abs(d.y),1);p&&f.multiply(_D.setFromAxisAngle($E,l)),f.multiply(this._yAxisUpSpaceInverse);let m=mD.makeEmpty();rD.copy(c.min).applyQuaternion(f),m.expandByPoint(rD),rD.copy(c.min).setX(c.max.x).applyQuaternion(f),m.expandByPoint(rD),rD.copy(c.min).setY(c.max.y).applyQuaternion(f),m.expandByPoint(rD),rD.copy(c.max).setZ(c.min.z).applyQuaternion(f),m.expandByPoint(rD),rD.copy(c.min).setZ(c.max.z).applyQuaternion(f),m.expandByPoint(rD),rD.copy(c.max).setY(c.min.y).applyQuaternion(f),m.expandByPoint(rD),rD.copy(c.max).setX(c.min.x).applyQuaternion(f),m.expandByPoint(rD),rD.copy(c.max).applyQuaternion(f),m.expandByPoint(rD),m.min.x-=r,m.min.y-=a,m.max.x+=i,m.max.y+=o,f.setFromUnitVectors(eD,d),p&&f.premultiply(_D.invert()),f.premultiply(this._yAxisUpSpace);let h=m.getSize(nD),g=m.getCenter(rD).applyQuaternion(f);if(AE(this._camera)){let e=this.getDistanceToFitBox(h.x,h.y,h.z,n);s.push(this.moveTo(g.x,g.y,g.z,t)),s.push(this.dollyTo(e,t)),s.push(this.setFocalOffset(0,0,0,t))}else if(jE(this._camera)){let e=this._camera,r=e.right-e.left,i=e.top-e.bottom,a=n?Math.max(r/h.x,i/h.y):Math.min(r/h.x,i/h.y);s.push(this.moveTo(g.x,g.y,g.z,t)),s.push(this.zoomTo(a,t)),s.push(this.setFocalOffset(0,0,0,t))}return Promise.all(s)}fitToSphere(t,n){let r=[],i=`isObject3D`in t?e.createBoundingSphere(t,hD):hD.copy(t);if(r.push(this.moveTo(i.center.x,i.center.y,i.center.z,n)),AE(this._camera)){let e=this.getDistanceToFitSphere(i.radius);r.push(this.dollyTo(e,n))}else if(jE(this._camera)){let e=this._camera.right-this._camera.left,t=this._camera.top-this._camera.bottom,a=2*i.radius,o=Math.min(e/a,t/a);r.push(this.zoomTo(o,n))}return r.push(this.setFocalOffset(0,0,0,n)),Promise.all(r)}setLookAt(e,t,n,r,i,a,o=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=kE.NONE,this._changedDolly=0;let s=rD.set(r,i,a),c=nD.set(e,t,n);this._targetEnd.copy(s),this._sphericalEnd.setFromVector3(c.sub(s).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,o||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));let l=!o||RE(this._target.x,this._targetEnd.x,this.restThreshold)&&RE(this._target.y,this._targetEnd.y,this.restThreshold)&&RE(this._target.z,this._targetEnd.z,this.restThreshold)&&RE(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&RE(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&RE(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(l)}lerpLookAt(e,t,n,r,i,a,o,s,c,l,u,d,f,p=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=kE.NONE,this._changedDolly=0;let m=nD.set(r,i,a),h=rD.set(e,t,n);dD.setFromVector3(h.sub(m).applyQuaternion(this._yAxisUpSpace));let g=iD.set(l,u,d),_=rD.set(o,s,c);fD.setFromVector3(_.sub(g).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(m.lerp(g,f));let v=fD.theta-dD.theta,y=fD.phi-dD.phi,b=fD.radius-dD.radius;this._sphericalEnd.set(dD.radius+b*f,dD.phi+y*f,dD.theta+v*f),this.normalizeRotations(),this._needsUpdate=!0,p||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));let x=!p||RE(this._target.x,this._targetEnd.x,this.restThreshold)&&RE(this._target.y,this._targetEnd.y,this.restThreshold)&&RE(this._target.z,this._targetEnd.z,this.restThreshold)&&RE(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&RE(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&RE(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(x)}setPosition(e,t,n,r=!1){return this.setLookAt(e,t,n,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,r)}setTarget(e,t,n,r=!1){let i=this.getPosition(nD),a=this.setLookAt(i.x,i.y,i.z,e,t,n,r);return this._sphericalEnd.phi=IE(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),a}setFocalOffset(e,t,n,r=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,n),this._needsUpdate=!0,r||this._focalOffset.copy(this._focalOffsetEnd);let i=!r||RE(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&RE(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&RE(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),oD.setFromMatrixColumn(this._camera.matrixWorldInverse,0),sD.setFromMatrixColumn(this._camera.matrixWorldInverse,1),cD.setFromMatrixColumn(this._camera.matrixWorldInverse,2);let r=nD.set(e,t,n),i=r.distanceTo(this._camera.position),a=r.sub(this._camera.position);oD.multiplyScalar(a.x),sD.multiplyScalar(a.y),cD.multiplyScalar(a.z),nD.copy(oD).add(sD).add(cD),nD.z+=i,this.dollyTo(i,!1),this.setFocalOffset(-nD.x,nD.y,-nD.z,!1),this.moveTo(e,t,n,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,n,r){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new ZE.Vector4,typeof e==`number`?this._viewport.set(e,t,n,r):this._viewport.copy(e)}getDistanceToFitBox(e,t,n,r=!1){if(GE(this._camera,`getDistanceToFitBox`))return this._spherical.radius;let i=e/t,a=this._camera.getEffectiveFOV()*FE,o=this._camera.aspect;return((r?i>o:it.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,n){let r=t.lengthSq();if(r===0)return e;let i=rD.copy(t).add(e),a=this._boundary.clampPoint(i,iD).sub(i),o=a.lengthSq();if(o===0)return e.add(t);if(o===r)return e;if(n===0)return e.add(t).add(a);{let r=1+n*o/t.dot(a);return e.add(rD.copy(t).multiplyScalar(r)).add(a.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(AE(this._camera)){let e=this._camera,t=e.near,n=e.getEffectiveFOV()*FE,r=Math.tan(n*.5)*t,i=r*e.aspect;this._nearPlaneCorners[0].set(-i,-r,0),this._nearPlaneCorners[1].set(i,-r,0),this._nearPlaneCorners[2].set(i,r,0),this._nearPlaneCorners[3].set(-i,r,0)}else if(jE(this._camera)){let e=this._camera,t=1/e.zoom,n=e.left*t,r=e.right*t,i=e.top*t,a=e.bottom*t;this._nearPlaneCorners[0].set(n,i,0),this._nearPlaneCorners[1].set(r,i,0),this._nearPlaneCorners[2].set(r,a,0),this._nearPlaneCorners[3].set(n,a,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||GE(this._camera,`_collisionTest`))return e;let t=this._getTargetDirection(aD);vD.lookAt(QE,t,this._camera.up);for(let n=0;n<4;n++){let r=rD.copy(this._nearPlaneCorners[n]);r.applyMatrix4(vD);let i=iD.addVectors(this._target,r);yD.set(i,t),yD.far=this._spherical.radius+1;let a=yD.intersectObjects(this.colliderMeshes);a.length!==0&&a[0].distance{let t=()=>{this.removeEventListener(`rest`,t),e()};this.addEventListener(`rest`,t)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(`.dampingFactor has been deprecated. use smoothTime (in seconds) instead.`),0}set dampingFactor(e){console.warn(`.dampingFactor has been deprecated. use smoothTime (in seconds) instead.`)}get draggingDampingFactor(){return console.warn(`.draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.`),0}set draggingDampingFactor(e){console.warn(`.draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.`)}static createBoundingSphere(e,t=new ZE.Sphere){let n=t,r=n.center;pD.makeEmpty(),e.traverseVisible(e=>{e.isMesh&&pD.expandByObject(e)}),pD.getCenter(r);let i=0;return e.traverseVisible(e=>{if(!e.isMesh)return;let t=e,n=t.geometry.clone();n.applyMatrix4(t.matrixWorld);let a=n.attributes.position;for(let e=0,t=a.count;e!!(e&&e.isPerspectiveCamera),SD=e=>!!(e&&e.isOrthographicCamera),CD=`min-polar-angle.max-polar-angle.min-azimuth-angle.max-azimuth-angle.distance.min-distance.max-distance.infinity-dolly.min-zoom.max-zoom.smooth-time.dragging-smooth-time.max-speed.azimuth-rotate-speed.polar-rotate-speed.dolly-speed.dolly-drag-inverted.truck-speed.dolly-to-cursor.drag-to-offset.vertical-drag-to-forward.boundary-friction.rest-threshold.collider-meshes.args.mouse-buttons.touches`.split(`.`),wD=(e,t)=>({left:bD.ACTION.ROTATE,middle:bD.ACTION.DOLLY,right:bD.ACTION.TRUCK,wheel:xD(e)?bD.ACTION.DOLLY:SD(e)?bD.ACTION.ZOOM:bD.ACTION.NONE,...t}),TD=(e,t)=>({one:bD.ACTION.TOUCH_ROTATE,two:xD(e)?bD.ACTION.TOUCH_DOLLY_TRUCK:SD(e)?bD.ACTION.TOUCH_ZOOM_TRUCK:bD.ACTION.NONE,three:bD.ACTION.TOUCH_TRUCK,...t}),ED=H({__name:`CameraControls`,props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},minPolarAngle:{default:0},maxPolarAngle:{default:Math.PI},minAzimuthAngle:{default:-1/0},maxAzimuthAngle:{default:1/0},distance:{default:()=>nn().camera.value.position.z},minDistance:{default:2**-52},maxDistance:{default:1/0},infinityDolly:{type:Boolean,default:!1},minZoom:{default:.01},maxZoom:{default:1/0},smoothTime:{default:.25},draggingSmoothTime:{default:.125},maxSpeed:{default:1/0},azimuthRotateSpeed:{default:1},polarRotateSpeed:{default:1},dollySpeed:{default:1},dollyDragInverted:{type:Boolean,default:!1},truckSpeed:{default:2},dollyToCursor:{type:Boolean,default:!1},dragToOffset:{type:Boolean,default:!1},verticalDragToForward:{type:Boolean,default:!1},boundaryFriction:{default:0},restThreshold:{default:.01},colliderMeshes:{default:()=>[]},mouseButtons:{default:()=>wD(nn().camera.value)},touches:{default:()=>TD(nn().camera.value)}},emits:[`change`,`start`,`end`],setup(e,{expose:t,emit:n}){let r=e,i=n,{makeDefault:a,minPolarAngle:o,maxPolarAngle:s,minAzimuthAngle:c,maxAzimuthAngle:u,distance:d,minDistance:f,maxDistance:p,infinityDolly:m,minZoom:h,maxZoom:g,smoothTime:_,draggingSmoothTime:v,maxSpeed:y,azimuthRotateSpeed:b,polarRotateSpeed:x,dollySpeed:S,dollyDragInverted:C,truckSpeed:w,dollyToCursor:T,dragToOffset:E,verticalDragToForward:D,boundaryFriction:O,restThreshold:k,colliderMeshes:A}=_n(r),j={Box3:l,MathUtils:{clamp:_e.clamp},Matrix4:ye,Quaternion:Be,Raycaster:Ge,Sphere:nt,Spherical:it,Vector2:mt,Vector3:z,Vector4:ht};bD.install({THREE:j});let{camera:M,renderer:N,extend:ee,controls:P,invalidate:F}=nn();K(r,()=>{F()});let I=kt(()=>wD(r.camera||M.value,r.mouseButtons)),te=kt(()=>TD(r.camera||M.value,r.touches)),ne=dn(null);ee({CameraControls:bD}),Fn(()=>{L(),ne.value&&a.value?P.value=ne.value:P.value=null});function L(){Dx(ne.value,`update`,()=>{i(`change`,ne.value),F()}),Dx(ne.value,`controlend`,()=>i(`end`,ne.value)),Dx(ne.value,`controlstart`,()=>i(`start`,ne.value))}let{onBeforeRender:re}=Ht();return re(({delta:e,invalidate:t})=>{var n,r;(n=ne.value)!=null&&n.enabled&&((r=ne.value)==null||r.update(e),t())}),tn(()=>{ne.value&&ne.value.disconnect()}),t({instance:ne}),(e,t)=>(e.camera||G(M))&&(e.domElement||G(N))?(U(),V(`TresCameraControls`,{key:0,ref_key:`controlsRef`,ref:ne,"min-polar-angle":G(o),"max-polar-angle":G(s),"min-azimuth-angle":G(c),"max-azimuth-angle":G(u),distance:G(d),"min-distance":G(f),"max-distance":G(p),"infinity-dolly":G(m),"min-zoom":G(h),"max-zoom":G(g),"smooth-time":G(_),"dragging-smooth-time":G(v),"max-speed":G(y),"azimuth-rotate-speed":G(b),"polar-rotate-speed":G(x),"dolly-speed":G(S),"dolly-drag-inverted":G(C),"truck-speed":G(w),"dolly-to-cursor":G(T),"drag-to-offset":G(E),"vertical-drag-to-forward":G(D),"boundary-friction":G(O),"rest-threshold":G(k),"collider-meshes":G(A),args:[e.camera||G(M),e.domElement||G(N).domElement],"mouse-buttons":I.value,touches:te.value},null,8,CD)):jt(``,!0)}}),DD=H({__name:`KeyboardControls`,props:{makeDefault:{type:Boolean,default:!0},camera:{},domElement:{},moveSpeed:{default:.2},selector:{}},emits:[`isLock`,`change`],setup(e,{expose:t,emit:n}){let r=e,i=n,{moveSpeed:a}=_n(r),{camera:o,controls:s,renderer:c,invalidate:l}=nn();K(r,()=>{l()});let u=W(0),d=W(0),{KeyW:f,KeyA:p,KeyS:m,KeyD:h,Up:g,Down:_,Left:v,Right:y}=Ix();Fn(()=>{p.value||v.value?u.value=-a.value:h.value||y.value?u.value=a.value:u.value=0,f.value||g.value?d.value=a.value:m.value||_.value?d.value=-a.value:d.value=0}),t({instance:s});let b=e=>i(`isLock`,e),x=e=>i(`change`,e),S=new z,C=new z,w=new Be,T=(e,t)=>{var n;if(!((n=o.value)!=null&&n.position)&&!S)return;let r=o.value,a=e*.001;r?.translateZ(-t),w.set(C.x*a,C.y*a,C.z*a,1).normalize(),r?.quaternion.multiply(w),(u.value||d.value)&&i(`change`,s.value)},{onBeforeRender:E}=Ht();return E(({delta:e,invalidate:t})=>{var n;s.value instanceof aw&&(n=s.value)!=null&&n.isLocked&&(T(e,d.value),s.value.moveRight(u.value),t())}),(e,t)=>(U(),At(G(ND),{selector:e.selector,"make-default":e.makeDefault,camera:e.camera||G(o),"dom-element":e.domElement||G(c).domElement,onIsLock:b,onChange:x},null,8,[`selector`,`make-default`,`camera`,`dom-element`]))}}),OD=[`args`,`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`,`enable-zoom`,`zoom-speed`,`enable-rotate`,`rotate-speed`],kD=H({__name:`MapControls`,props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},target:{},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:1/0},minAzimuthAngle:{default:-1/0},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:1/0},minZoom:{default:0},maxZoom:{default:1/0},touches:{},enableZoom:{type:Boolean,default:!0},zoomSpeed:{default:1},enableRotate:{type:Boolean,default:!0},rotateSpeed:{default:1}},emits:[`change`,`start`,`end`],setup(e,{expose:t,emit:n}){let r=e,{autoRotate:i,autoRotateSpeed:a,enableDamping:o,dampingFactor:s,enablePan:c,keyPanSpeed:l,maxAzimuthAngle:u,minAzimuthAngle:d,maxPolarAngle:f,minPolarAngle:p,minDistance:m,maxDistance:h,minZoom:g,maxZoom:_,enableZoom:v,zoomSpeed:y,enableRotate:b,rotateSpeed:x}=_n(r),{camera:S,renderer:C,extend:w,controls:T,invalidate:E}=nn();K(r,()=>{E()});let D=dn(null);w({MapControls:mw}),K(T,e=>{e&&r.makeDefault?T.value=e:T.value=null});let{onBeforeRender:O}=Ht();return O(({invalidate:e})=>{D.value&&(o.value||i.value)&&(D.value.update(),e())}),tn(()=>{D.value&&D.value.dispose()}),t({instance:D}),(e,t)=>(e.camera||G(S))&&(e.domElement||G(C))?(U(),V(`TresMapControls`,{key:0,ref_key:`controlsRef`,ref:D,args:[e.camera||G(S),e.domElement||G(C).domElement],"auto-rotate":G(i),"auto-rotate-speed":G(a),"enable-damping":G(o),"damping-factor":G(s),"enable-pan":G(c),"key-pan-speed":G(l),keys:e.keys,"max-azimuth-angle":G(u),"min-azimuth-angle":G(d),"max-polar-angle":G(f),"min-polar-angle":G(p),"min-distance":G(m),"max-distance":G(h),"min-zoom":G(g),"max-zoom":G(_),"enable-zoom":G(v),"zoom-speed":G(y),"enable-rotate":G(b),"rotate-speed":G(x)},null,8,OD)):jt(``,!0)}}),AD=[`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`],jD=H({__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:1/0},minAzimuthAngle:{default:-1/0},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:1/0},minZoom:{default:0},maxZoom:{default:1/0},touches:{default:()=>({ONE:at.ROTATE,TWO:at.DOLLY_PAN})},enableZoom:{type:Boolean,default:!0},zoomSpeed:{default:1},enableRotate:{type:Boolean,default:!0},rotateSpeed:{default:1},mouseButtons:{default:()=>({LEFT:he.ROTATE,MIDDLE:he.DOLLY,RIGHT:he.PAN})}},emits:[`change`,`start`,`end`],setup(e,{expose:t,emit:n}){let r=e,i=n,{makeDefault:a,autoRotate:o,autoRotateSpeed:s,enableDamping:c,dampingFactor:l,enablePan:u,keyPanSpeed:d,maxAzimuthAngle:f,minAzimuthAngle:p,maxPolarAngle:m,minPolarAngle:h,minDistance:g,maxDistance:_,minZoom:v,maxZoom:y,enableZoom:b,zoomSpeed:x,enableRotate:S,touches:C,rotateSpeed:w,target:T,mouseButtons:E}=_n(r),{camera:D,renderer:O,extend:k,controls:A,invalidate:j}=nn(),M=dn(null);k({OrbitControls:pw}),K(M,e=>{N(),e&&a.value?A.value=e:A.value=null});function N(){Dx(M.value,`change`,()=>{i(`change`,M.value),j()}),Dx(M.value,`start`,()=>i(`start`,M.value)),Dx(M.value,`end`,()=>i(`end`,M.value))}let{onBeforeRender:ee}=Ht();return ee(({invalidate:e})=>{M.value&&(c.value||o.value)&&(M.value.update(),o.value&&e())}),tn(()=>{M.value&&M.value.dispose()}),t({instance:M}),(e,t)=>(e.camera||G(D))&&(e.domElement||G(O))?(U(),V(`TresOrbitControls`,{key:0,ref_key:`controlsRef`,ref:M,target:G(T),"auto-rotate":G(o),"auto-rotate-speed":G(s),"enable-damping":G(c),"damping-factor":G(l),"enable-pan":G(u),"key-pan-speed":G(d),keys:e.keys,"max-azimuth-angle":G(f),"min-azimuth-angle":G(p),"max-polar-angle":G(m),"min-polar-angle":G(h),"min-distance":G(g),"max-distance":G(_),"min-zoom":G(v),"max-zoom":G(y),touches:G(C),"enable-zoom":G(b),"zoom-speed":G(x),"enable-rotate":G(S),"rotate-speed":G(w),"mouse-buttons":G(E),args:[e.camera||G(D),e.domElement||G(O).domElement]},null,8,AD)):jt(``,!0)}}),MD=[`args`],ND=H({__name:`PointerLockControls`,props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},selector:{}},emits:[`isLock`,`change`],setup(e,{expose:t,emit:n}){let r=e,i=n,{camera:a,renderer:o,extend:s,controls:c,invalidate:l}=nn();K(r,()=>{l()});let u=dn(null),d;s({PointerLockControls:aw});let f=e=>{i(`isLock`,e)};return K(u,e=>{e&&r.makeDefault?c.value=e:c.value=null,d=document.getElementById(r.selector||``)||o.value.domElement,Dx(d,`click`,()=>{u.value&&(u.value.lock(),u.value.addEventListener(`lock`,()=>f(!0)),u.value.addEventListener(`unlock`,()=>f(!1)),l())})}),tn(()=>{let e=u.value;e&&(e.removeEventListener(`lock`,()=>f(!0)),e.removeEventListener(`unlock`,()=>f(!1)),e.dispose())}),t({instance:c}),(e,t)=>(e.camera||G(a))&&(e.domElement||G(o))?(U(),V(`TresPointerLockControls`,{key:0,ref_key:`controlsRef`,ref:u,args:[e.camera||G(a),e.domElement||G(o).domElement]},null,8,MD)):jt(``,!0)}}),PD=H({__name:`ScrollControls`,props:{pages:{default:4},distance:{default:4},smoothScroll:{default:.1},horizontal:{type:Boolean,default:!1},htmlScroll:{type:Boolean,default:!1}},emits:[`update:modelValue`],setup(e,{expose:t,emit:n}){let r=e,i=n,{logWarning:a}=Re();r.smoothScroll<0&&a(`SmoothControl must be greater than zero`),r.pages<0&&a(`Pages must be greater than zero`);let{camera:o,controls:s,renderer:c,invalidate:l}=nn();K(r,()=>{l()});let u=dn(),d=document.createElement(`div`),{y:f}=zx(),{x:p,y:m,isScrolling:h}=Px(d),{height:g,width:_}=Bx(),v=0,y=W(!1),b=W(0),x=W(0),S=W(0),C=r.horizontal?`x`:`y`,w=K(o,e=>{if(y.value){w();return}v=r.horizontal?e?.position.x||0:e?.position.y||0,y.value=!0},{immediate:!0});K(h,e=>{s.value&&(s.value.enabled=!e)},{immediate:!0}),K(f,e=>{!h.value&&!r.htmlScroll||(x.value=e/g.value/(S.value/g.value-1),b.value=-1*x.value,i(`update:modelValue`,x.value))}),K(m,e=>{x.value=e/g.value/(S.value/g.value),b.value=-1*x.value,i(`update:modelValue`,x.value)}),K(p,e=>{x.value=e/_.value/(S.value/_.value-1),b.value=+x.value,i(`update:modelValue`,x.value)}),K(c,e=>{var t,n;let i=e?.domElement;if(r.htmlScroll&&e!=null&&e.domElement)i!=null&&i.style.width&&i!=null&&i.style.position&&i!=null&&i.style.top&&i!=null&&i.style.left&&(i.style.width=`100%`,i.style.position=`fixed`,i.style.zIndex=` -99999`,i.style.top=`0`,i.style.left=`0`),S.value=document.body.scrollHeight;else{let a=document.createElement(`div`),o=document.createElement(`div`);d.style[r.horizontal?`overflowX`:`overflowY`]=`auto`,d.style[r.horizontal?`overflowY`:`overflowX`]=`hidden`,d.style.position=`absolute`,d.style.width=`100%`,d.style.height=` 100%`,d.style.top=`0`,d.style.left=`0`,d.classList.add(`scrollContainer`),a.style.position=`sticky`,a.style.top=`0px`,a.style.left=`0px`,a.style.width=`100%`,a.style.height=`100%`,a.style.overflow=`hidden`,d.appendChild(a),o.style.height=r.horizontal?`100%`:`${g.value*r.pages}px`,o.style.width=r.horizontal?`${_.value*r.pages}px`:`100vw`,o.style.pointerEvents=`none`,i.style.position=`fixed`,i.style.zIndex=`0`,i!=null&&i.style.width&&(i.style.width=`100%`),d.appendChild(o),e!=null&&e.domElement.parentNode&&(e.domElement.parentNode.style.position=`relative`),(n=(t=e?.domElement)?.parentNode)==null||n.appendChild(d),S.value=r.horizontal?_.value*r.pages:g.value*r.pages}},{immediate:!0});let{onBeforeRender:T}=Ht();return T(({invalidate:e})=>{var t;if((t=o.value)!=null&&t.position){let t=(b.value*r.distance-o.value.position[C]+v)*r.smoothScroll;o.value.position[C]+=t,u.value.children.length>0&&(u.value.position[C]+=t),e()}}),t({instance:u}),(e,t)=>(U(),V(`TresGroup`,{ref_key:`wrapperRef`,ref:u},[sn(e.$slots,`default`)],512))}}),FD=[`object`,`args`,`mode`,`enabled`,`axis`,`translation-snap`,`rotation-snap`,`scale-snap`,`space`,`size`,`show-x`,`show-y`,`show-z`],ID=H({__name:`TransformControls`,props:{object:{},camera:{},mode:{default:`translate`},enabled:{type:Boolean,default:!0},axis:{default:`XYZ`},translationSnap:{},rotationSnap:{},scaleSnap:{},space:{default:`world`},size:{default:1},showX:{type:Boolean,default:!0},showY:{type:Boolean,default:!0},showZ:{type:Boolean,default:!0}},emits:[`dragging`,`change`,`mouseDown`,`mouseUp`,`objectChange`],setup(e,{expose:t,emit:n}){let r=e,i=n,{object:a,mode:o,enabled:s,axis:c,translationSnap:l,rotationSnap:u,scaleSnap:d,space:f,size:p,showX:m,showY:h,showZ:g}=_n(r),_=dn(null),{controls:v,camera:y,renderer:b,extend:x,invalidate:S}=nn();K([a,o,s,c,l,u,d,f,p,m,h,g],()=>{S()}),x({TransformControls:qC});let C=()=>{S(),i(`change`)},w=e=>{v.value&&(v.value.enabled=!e.value),S(),i(`dragging`,e.value)},T=()=>{S(),i(`mouseDown`)},E=()=>{S(),i(`mouseDown`)},D=()=>{S(),i(`objectChange`)};function O(){Dx(_.value,`change`,C),Dx(_.value,`dragging-changed`,w),Dx(_.value,`mouseDown`,T),Dx(_.value,`mouseUp`,E),Dx(_.value,`objectChange`,D)}return K(_,e=>{e&&O()}),tn(()=>{_.value&&_.value.dispose()}),t({instance:_}),(e,t)=>{var n;return(e.camera||G(y))&&G(b)?(U(),V(`TresTransformControls`,{ref_key:`controlsRef`,ref:_,key:(n=e.camera||G(y))?.uuid,object:G(a),args:[e.camera||G(y),G(b).domElement],mode:G(o),enabled:G(s),axis:G(c),"translation-snap":G(l),"rotation-snap":G(u),"scale-snap":G(d),space:G(f),size:G(p),"show-x":G(m),"show-y":G(h),"show-z":G(g),visible:!0},null,8,FD)):jt(``,!0)}}}),LD=[`geometry`,`render-order`],RD=H({__name:`component`,props:{src:{},skipStrokes:{type:Boolean,default:!1},skipFills:{type:Boolean,default:!1},fillMaterial:{},strokeMaterial:{},fillMeshProps:{},strokeMeshProps:{},depth:{default:`renderOrder`}},setup(e,{expose:t}){let n=e;class r extends Uw{load(e,t,n,r){let i=Array.isArray(e)?e[0]:e;super.load(i,t,n,r)}}let{src:i,skipStrokes:a,skipFills:o,fillMaterial:s,strokeMaterial:c,fillMeshProps:l,strokeMeshProps:u,depth:d}=_n(n),f=dn(),p=dn([]),m=dn([]);t({instance:f}),Fn(async()=>h(i.value).then(e=>m.value=e.paths)),K([o,a,s,c,m],_);async function h(e){let t=e.startsWith(`e.geometry.dispose())}function _(){var e,t,r;g();let i=[],[s,c]=(()=>{let e={flat:!1,renderOrder:!1,offsetZ:!0},t={flat:0,renderOrder:0,offsetZ:.025},n=d.value;return typeof n==`number`?[!0,n]:[e[n],t[n]]})(),l=0;for(let u of m.value){let d=(e=u.userData)?.style??{},f=Object.assign({color:d.fill,opacity:d.fillOpacity,transparent:!0,side:T,depthWrite:s},n.fillMaterial);if(!o.value&&d.fill!==void 0&&d.fill!==`none`)for(let e of Uw.createShapes(u)){let t=new Qe(e);t.scale(1,-1,1),c&&t.translate(0,0,l++*c),i.push({geometry:t,material:f,isStroke:!1})}if(!a.value&&d.stroke!==void 0&&d.stroke!==`none`){let e=Object.assign({color:(t=u.userData)?.style.stroke,opacity:(r=u.userData)?.style.strokeOpacity,transparent:!0,side:T,depthWrite:s},n.strokeMaterial);for(let t of u.subPaths){let n=t.getPoints().map(e=>new mt(e.x,-e.y)),r=Uw.pointsToStroke(n,d||`none`);c&&r.translate(0,0,l++*c),i.push({geometry:r,material:e,isStroke:!0})}}}p.value=i}return(e,t)=>(U(),V(`TresGroup`,{ref_key:`svgRef`,ref:f},[(U(!0),V(P,null,on(p.value,({geometry:e,material:t,isStroke:n},r)=>(U(),V(`TresMesh`,Kt({key:`${r}`,ref_for:!0},G(n?u:l),{geometry:e,"render-order":G(d)===`renderOrder`?r:0}),[B(`TresMeshBasicMaterial`,Kt({ref_for:!0},t),null,16)],16,LD))),128))],512))}});function zD(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}function BD(e){throw Error(`Could not dynamically require "`+e+`". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.`)}var VD={exports:{}},HD;function UD(){return HD||(HD=1,function(e,t){(function(t){e.exports=t()})(function(){return function e(t,n,r){function i(o,s){if(!n[o]){if(!t[o]){var c=typeof BD==`function`&&BD;if(!s&&c)return c(o,!0);if(a)return a(o,!0);throw Error(`Cannot find module '`+o+`'`)}s=n[o]={exports:{}},t[o][0].call(s.exports,function(e){var n=t[o][1][e];return i(n||e)},s,s.exports,e,t,n,r)}return n[o].exports}for(var a=typeof BD==`function`&&BD,o=0;o>16),c((65280&r)>>8),c(255&r);return i==2?c(255&(r=l(e.charAt(n))<<2|l(e.charAt(n+1))>>4)):i==1&&(c((r=l(e.charAt(n))<<10|l(e.charAt(n+1))<<4|l(e.charAt(n+2))>>2)>>8&255),c(255&r)),a},e.fromByteArray=function(e){var t,n,r,i,a=e.length%3,o=``;function s(e){return`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.charAt(e)}for(t=0,r=e.length-a;t>18&63)+s(i>>12&63)+s(i>>6&63)+s(63&i);switch(a){case 1:o=(o+=s((n=e[e.length-1])>>2))+s(n<<4&63)+`==`;break;case 2:o=(o=(o+=s((n=(e[e.length-2]<<8)+e[e.length-1])>>10))+s(n>>4&63))+s(n<<2&63)+`=`}return o}})(n===void 0?this.base64js={}:n)}).call(this,e(`lYpoI2`),typeof self<`u`?self:typeof window<`u`?window:{},e(`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(e,t,n){(function(t,r,i,a,o,s,c,l,u){var d=e(`base64-js`),f=e(`ieee754`);function i(e,t,n){if(!(this instanceof i))return new i(e,t,n);var r,a,o,s,c=typeof e;if(t===`base64`&&c==`string`)for(e=(s=e).trim?s.trim():s.replace(/^\s+|\s+$/g,``);e.length%4!=0;)e+=`=`;if(c==`number`)r=A(e);else if(c==`string`)r=i.byteLength(e,t);else{if(c!=`object`)throw Error(`First argument needs to be a number, array or string.`);r=A(e.length)}if(i._useTypedArrays?a=i._augment(new Uint8Array(r)):((a=this).length=r,a._isBuffer=!0),i._useTypedArrays&&typeof e.byteLength==`number`)a._set(e);else if(j(s=e)||i.isBuffer(s)||s&&typeof s==`object`&&typeof s.length==`number`)for(o=0;o>8,n%=256,r.push(n),r.push(t);return r}(t),e,n,r)}function h(e,t,n){var r=``;n=Math.min(e.length,n);for(var i=t;i>>0)):(t+1>>0),i}function v(e,t,n,r){if(r||(L(typeof n==`boolean`,`missing or invalid endian`),L(t!=null,`missing offset`),L(t+1>>8*(r?a:1-a)}function C(e,t,n,r,i){if(i||(L(t!=null,`missing value`),L(typeof r==`boolean`,`missing or invalid endian`),L(n!=null,`missing offset`),L(n+3>>8*(r?a:3-a)&255}function w(e,t,n,r,i){i||(L(t!=null,`missing value`),L(typeof r==`boolean`,`missing or invalid endian`),L(n!=null,`missing offset`),L(n+1this.length&&(r=this.length);var a=(r=e.length-t=this.length))return this[e]},i.prototype.readUInt16LE=function(e,t){return g(this,e,!0,t)},i.prototype.readUInt16BE=function(e,t){return g(this,e,!1,t)},i.prototype.readUInt32LE=function(e,t){return _(this,e,!0,t)},i.prototype.readUInt32BE=function(e,t){return _(this,e,!1,t)},i.prototype.readInt8=function(e,t){if(t||(L(e!=null,`missing offset`),L(e=this.length))return 128&this[e]?-1*(255-this[e]+1):this[e]},i.prototype.readInt16LE=function(e,t){return v(this,e,!0,t)},i.prototype.readInt16BE=function(e,t){return v(this,e,!1,t)},i.prototype.readInt32LE=function(e,t){return y(this,e,!0,t)},i.prototype.readInt32BE=function(e,t){return y(this,e,!1,t)},i.prototype.readFloatLE=function(e,t){return b(this,e,!0,t)},i.prototype.readFloatBE=function(e,t){return b(this,e,!1,t)},i.prototype.readDoubleLE=function(e,t){return x(this,e,!0,t)},i.prototype.readDoubleBE=function(e,t){return x(this,e,!1,t)},i.prototype.writeUInt8=function(e,t,n){n||(L(e!=null,`missing value`),L(t!=null,`missing offset`),L(t=this.length||(this[t]=e)},i.prototype.writeUInt16LE=function(e,t,n){S(this,e,t,!0,n)},i.prototype.writeUInt16BE=function(e,t,n){S(this,e,t,!1,n)},i.prototype.writeUInt32LE=function(e,t,n){C(this,e,t,!0,n)},i.prototype.writeUInt32BE=function(e,t,n){C(this,e,t,!1,n)},i.prototype.writeInt8=function(e,t,n){n||(L(e!=null,`missing value`),L(t!=null,`missing offset`),L(t=this.length||(0<=e?this.writeUInt8(e,t,n):this.writeUInt8(255+e+1,t,n))},i.prototype.writeInt16LE=function(e,t,n){w(this,e,t,!0,n)},i.prototype.writeInt16BE=function(e,t,n){w(this,e,t,!1,n)},i.prototype.writeInt32LE=function(e,t,n){T(this,e,t,!0,n)},i.prototype.writeInt32BE=function(e,t,n){T(this,e,t,!1,n)},i.prototype.writeFloatLE=function(e,t,n){E(this,e,t,!0,n)},i.prototype.writeFloatBE=function(e,t,n){E(this,e,t,!1,n)},i.prototype.writeDoubleLE=function(e,t,n){D(this,e,t,!0,n)},i.prototype.writeDoubleBE=function(e,t,n){D(this,e,t,!1,n)},i.prototype.fill=function(e,t,n){if(t||=0,n||=this.length,L(typeof(e=typeof(e||=0)==`string`?e.charCodeAt(0):e)==`number`&&!isNaN(e),`value is not a number`),L(t<=n,`end < start`),n!==t&&this.length!==0){L(0<=t&&t`},i.prototype.toArrayBuffer=function(){if(typeof Uint8Array>`u`)throw Error(`Buffer.toArrayBuffer not supported in this browser`);if(i._useTypedArrays)return new i(this).buffer;for(var e=new Uint8Array(this.length),t=0,n=e.length;t=t.length||i>=e.length);i++)t[i+n]=e[i];return i}function F(e){try{return decodeURIComponent(e)}catch{return`�`}}function I(e,t){L(typeof e==`number`,`cannot write a non-number as a number`),L(0<=e,`specified a negative value for writing an unsigned value`),L(e<=t,`value is larger than maximum value for type`),L(Math.floor(e)===e,`value has a fractional component`)}function te(e,t,n){L(typeof e==`number`,`cannot write a non-number as a number`),L(e<=t,`value larger than maximum allowed value`),L(n<=e,`value smaller than minimum allowed value`),L(Math.floor(e)===e,`value has a fractional component`)}function ne(e,t,n){L(typeof e==`number`,`cannot write a non-number as a number`),L(e<=t,`value larger than maximum allowed value`),L(n<=e,`value smaller than minimum allowed value`)}function L(e,t){if(!e)throw Error(t||`Failed assertion`)}i._augment=function(e){return e._isBuffer=!0,e._get=e.get,e._set=e.set,e.get=O.get,e.set=O.set,e.write=O.write,e.toString=O.toString,e.toLocaleString=O.toString,e.toJSON=O.toJSON,e.copy=O.copy,e.slice=O.slice,e.readUInt8=O.readUInt8,e.readUInt16LE=O.readUInt16LE,e.readUInt16BE=O.readUInt16BE,e.readUInt32LE=O.readUInt32LE,e.readUInt32BE=O.readUInt32BE,e.readInt8=O.readInt8,e.readInt16LE=O.readInt16LE,e.readInt16BE=O.readInt16BE,e.readInt32LE=O.readInt32LE,e.readInt32BE=O.readInt32BE,e.readFloatLE=O.readFloatLE,e.readFloatBE=O.readFloatBE,e.readDoubleLE=O.readDoubleLE,e.readDoubleBE=O.readDoubleBE,e.writeUInt8=O.writeUInt8,e.writeUInt16LE=O.writeUInt16LE,e.writeUInt16BE=O.writeUInt16BE,e.writeUInt32LE=O.writeUInt32LE,e.writeUInt32BE=O.writeUInt32BE,e.writeInt8=O.writeInt8,e.writeInt16LE=O.writeInt16LE,e.writeInt16BE=O.writeInt16BE,e.writeInt32LE=O.writeInt32LE,e.writeInt32BE=O.writeInt32BE,e.writeFloatLE=O.writeFloatLE,e.writeFloatBE=O.writeFloatBE,e.writeDoubleLE=O.writeDoubleLE,e.writeDoubleBE=O.writeDoubleBE,e.fill=O.fill,e.inspect=O.inspect,e.toArrayBuffer=O.toArrayBuffer,e}}).call(this,e(`lYpoI2`),typeof self<`u`?self:typeof window<`u`?window:{},e(`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(e,t,n){(function(n,r,i,a,o,s,c,l,u){var i=e(`buffer`).Buffer,d=4,f=new i(d);f.fill(0),t.exports={hash:function(e,t,n,r){for(var a=t(function(e,t){e.length%d!=0&&(n=e.length+(d-e.length%d),e=i.concat([e,f],n));for(var n,r=[],a=t?e.readInt32BE:e.readInt32LE,o=0;oh?t=e(t):t.length>5]|=128<>>9<<4)]=t;for(var n=1732584193,r=-271733879,i=-1732584194,a=271733878,o=0;o>>32-i,n)}function m(e,t,n,r,i,a,o){return p(t&n|~t&r,e,t,i,a,o)}function h(e,t,n,r,i,a,o){return p(t&r|n&~r,e,t,i,a,o)}function g(e,t,n,r,i,a,o){return p(t^n^r,e,t,i,a,o)}function _(e,t,n,r,i,a,o){return p(n^(t|~r),e,t,i,a,o)}function v(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}t.exports=function(e){return d.hash(e,f,16)}}).call(this,e(`lYpoI2`),typeof self<`u`?self:typeof window<`u`?window:{},e(`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(e,t,n){(function(e,n,r,i,a,o,s,c,l){t.exports=function(e){for(var t,n=Array(e),r=0;r>>((3&r)<<3)&255;return n}}).call(this,e(`lYpoI2`),typeof self<`u`?self:typeof window<`u`?window:{},e(`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(e,t,n){(function(n,r,i,a,o,s,c,l,u){var d=e(`./helpers`);function f(e,t){e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;for(var n,r,i,a=Array(80),o=1732584193,s=-271733879,c=-1732584194,l=271733878,u=-1009589776,d=0;d>16)+(t>>16)+(n>>16)<<16|65535&n}function m(e,t){return e<>>32-t}t.exports=function(e){return d.hash(e,f,20,!0)}}).call(this,e(`lYpoI2`),typeof self<`u`?self:typeof window<`u`?window:{},e(`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(e,t,n){(function(n,r,i,a,o,s,c,l,u){function d(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function f(e,t){var n,r=[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],i=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],a=Array(64);e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;for(var o,s,c=0;c>>t|e<<32-t},h=function(e,t){return e>>>t};t.exports=function(e){return p.hash(e,f,32,!0)}}).call(this,e(`lYpoI2`),typeof self<`u`?self:typeof window<`u`?window:{},e(`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(e,t,n){(function(e,t,r,i,a,o,s,c,l){n.read=function(e,t,n,r,i){var a,o,s=8*i-r-1,c=(1<>1,u=-7,d=n?i-1:0,f=n?-1:1,i=e[t+d];for(d+=f,a=i&(1<<-u)-1,i>>=-u,u+=s;0>=-u,u+=r;0>1,d=i===23?2**-24-2**-77:0,f=r?0:a-1,p=r?1:-1,a=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(r=2**-o)<1&&(o--,r*=2),2<=(t+=1<=o+u?d/r:d*2**(1-u))*r&&(o++,r/=2),l<=o+u?(s=0,o=l):1<=o+u?(s=(t*r-1)*2**i,o+=u):(s=t*2**(u-1)*2**i,o=0));8<=i;e[n+f]=255&s,f+=p,s/=256,i-=8);for(o=o<>= ++ -- << >> <= >= == != && || += -= *= /= %= &= ^^ ^= |= ( ) [ ] . ! ~ * / % + - < > & ^ | ? : = , ; { }`.split(` `)),YD}var QD,$D;function eO(){return $D||($D=1,QD=`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`.split(`.`)),QD}var tO,nO;function rO(){if(nO)return tO;nO=1;var e=JD();return tO=e.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`.split(`.`)),tO}var iO,aO;function oO(){if(aO)return iO;aO=1;var e=eO();return e=e.slice().filter(function(e){return!/^(gl\_|texture)/.test(e)}),iO=e.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`.split(`.`)),iO}var sO,cO;function lO(){if(cO)return sO;cO=1,sO=b;var e=JD(),t=ZD(),n=eO(),r=rO(),i=oO(),a=999,o=9999,s=0,c=1,l=2,u=3,d=4,f=5,p=6,m=7,h=8,g=9,_=10,v=11,y=[`block-comment`,`line-comment`,`preprocessor`,`operator`,`integer`,`float`,`ident`,`builtin`,`keyword`,`whitespace`,`eof`,`integer`];function b(b){var x=0,S=0,C=a,w,T,E=[],D=[],O=1,k=0,A=0,j=!1,M=!1,N=``,ee;b||={};var P=n,F=e;b.version===`300 es`&&(P=i,F=r);for(var I={},te={},x=0;x0)continue;i=e.slice(0,1).join(``)}return ne(i),A+=i.length,E=E.slice(i.length),E.length}while(!0)}function ue(){return/[^a-fA-F0-9]/.test(w)?(ne(E.join(``)),C=a,x):(E.push(w),T=w,x+1)}function de(){return w===`.`||/[eE]/.test(w)?(E.push(w),C=f,T=w,x+1):w===`x`&&E.length===1&&E[0]===`0`?(C=v,E.push(w),T=w,x+1):/[^\d]/.test(w)?(ne(E.join(``)),C=a,x):(E.push(w),T=w,x+1)}function fe(){return w===`f`&&(E.push(w),T=w,x+=1),/[eE]/.test(w)||(w===`-`||w===`+`)&&/[eE]/.test(T)?(E.push(w),T=w,x+1):/[^\d]/.test(w)?(ne(E.join(``)),C=a,x):(E.push(w),T=w,x+1)}function pe(){if(/[^\d\w_]/.test(w)){var e=E.join(``);return C=te[e]?h:I[e]?m:p,ne(E.join(``)),C=a,x}return E.push(w),T=w,x+1}}return sO}var uO,dO;function fO(){if(dO)return uO;dO=1;var e=lO();uO=t;function t(t,n){var r=e(n),i=[];return i=i.concat(r(t)),i=i.concat(r(null)),i}return uO}var pO=fO();const mO=zD(pO);var hO,gO;function _O(){if(gO)return hO;gO=1,hO=e;function e(e){for(var t=[],n=0;n=0;i--){if(n(e[i]))return i;if(r&&r(e[i]))return-1}return-1}}function t(e){return function(t){return t.type===`operator`&&(!e||t.data===e)}}function n(e){return e.type!==`whitespace`}return bO}var CO=SO();const wO=zD(CO);function TO(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return String(e)}function EO(e){var t=TO(e,`string`);return typeof t==`symbol`?t:String(t)}function DO(e,t,n){return t=EO(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function OO(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function kO(e){for(var t=1;t=0)&&(n[i]=e[i]);return n}function jO(e,t){if(e==null)return{};var n=AO(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function MO(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function NO(e,t){for(var n=0;n`u`||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy==`function`)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function BO(e,t){if(t&&(typeof t==`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return FO(e)}function VO(e){var t=zO();return function(){var n=RO(e),r;if(t){var i=RO(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return BO(this,r)}}var HO={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`},UO,WO,GO=(UO={},DO(UO,`${HO.normal}`,{"#include ":` + vec3 objectNormal = ${HO.normal}; + #ifdef USE_TANGENT + vec3 objectTangent = vec3( tangent.xyz ); + #endif + `}),DO(UO,`${HO.position}`,{"#include ":` + vec3 transformed = ${HO.position}; + `}),DO(UO,`${HO.positionRaw}`,{"#include ":` + vec4 csm_internal_positionUnprojected = ${HO.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; + `}),DO(UO,`${HO.pointSize}`,{"gl_PointSize = size;":` + gl_PointSize = ${HO.pointSize}; + `}),DO(UO,`${HO.diffuseColor}`,{"#include ":` + #include + diffuseColor = ${HO.diffuseColor}; + `}),DO(UO,`${HO.fragColor}`,{"#include ":` + #include + gl_FragColor = ${HO.fragColor}; + `}),DO(UO,`${HO.emissive}`,{"vec3 totalEmissiveRadiance = emissive;":` + vec3 totalEmissiveRadiance = ${HO.emissive}; + `}),DO(UO,`${HO.roughness}`,{"#include ":` + #include + roughnessFactor = ${HO.roughness}; + `}),DO(UO,`${HO.metalness}`,{"#include ":` + #include + metalnessFactor = ${HO.metalness}; + `}),DO(UO,`${HO.ao}`,{"#include ":` + #include + reflectedLight.indirectDiffuse *= 1. - ${HO.ao}; + `}),DO(UO,`${HO.bump}`,{"#include ":` + #include + + vec3 csm_internal_orthogonal = ${HO.bump} - (dot(${HO.bump}, normal) * normal); + vec3 csm_internal_projectedbump = mat3(csm_internal_vModelViewMatrix) * csm_internal_orthogonal; + normal = normalize(normal - csm_internal_projectedbump); + `}),DO(UO,`${HO.depthAlpha}`,{"gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );":` + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity * ${HO.depthAlpha} ); + `,"gl_FragColor = packDepthToRGBA( fragCoordZ );":` + gl_FragColor = packDepthToRGBA( fragCoordZ ); + gl_FragColor.a *= ${HO.depthAlpha}; + `}),UO),KO=(WO={},DO(WO,`${HO.position}`,{"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );":` + gl_Position = projectionMatrix * modelViewMatrix * vec4( ${HO.position}, 1.0 ); + `}),DO(WO,`${HO.positionRaw}`,{"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );":` + gl_Position = ${HO.position}; + `}),DO(WO,`${HO.diffuseColor}`,{"gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );":` + gl_FragColor = ${HO.diffuseColor}; + `}),DO(WO,`${HO.fragColor}`,{"gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );":` + gl_FragColor = ${HO.fragColor}; + `}),WO),qO=` + +#ifdef IS_VERTEX + // csm_Position & csm_PositionRaw + #ifdef IS_UNKNOWN + vec3 csm_Position = vec3(0.0); + vec4 csm_PositionRaw = vec4(0.0); + vec3 csm_Normal = vec3(0.0); + #else + vec3 csm_Position = position; + vec4 csm_PositionRaw = projectionMatrix * modelViewMatrix * vec4(position, 1.); + vec3 csm_Normal = normal; + #endif + + // csm_PointSize + #ifdef IS_POINTSMATERIAL + float csm_PointSize = size; + #endif +#else + // csm_DiffuseColor & csm_FragColor + #if defined IS_UNKNOWN || defined IS_SHADERMATERIAL || defined IS_MESHDEPTHMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_SHADOWMATERIAL + vec4 csm_DiffuseColor = vec4(1.0, 0.0, 1.0, 1.0); + vec4 csm_FragColor = vec4(1.0, 0.0, 1.0, 1.0); + #else + #ifdef USE_MAP + vec4 _csm_sampledDiffuseColor = texture2D(map, vMapUv); + + #ifdef DECODE_VIDEO_TEXTURE + // inline sRGB decode (TODO: Remove this code when https://crbug.com/1256340 is solved) + _csm_sampledDiffuseColor = vec4(mix(pow(_csm_sampledDiffuseColor.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), _csm_sampledDiffuseColor.rgb * 0.0773993808, vec3(lessThanEqual(_csm_sampledDiffuseColor.rgb, vec3(0.04045)))), _csm_sampledDiffuseColor.w); + #endif + + vec4 csm_DiffuseColor = vec4(diffuse, opacity) * _csm_sampledDiffuseColor; + vec4 csm_FragColor = vec4(diffuse, opacity) * _csm_sampledDiffuseColor; + #else + vec4 csm_DiffuseColor = vec4(diffuse, opacity); + vec4 csm_FragColor = vec4(diffuse, opacity); + #endif + #endif + + // csm_Emissive, csm_Roughness, csm_Metalness + #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL + vec3 csm_Emissive = emissive; + float csm_Roughness = roughness; + float csm_Metalness = metalness; + #endif + + // csm_AO + #if defined IS_MESHSTANDARDMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHBASICMATERIAL || defined IS_MESHLAMBERTMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHTOONMATERIAL + float csm_AO = 0.0; + #endif + + // csm_Bump + #if defined IS_MESHLAMBERTMATERIAL || defined IS_MESHMATCAPMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_MESHPHONGMATERIAL || defined IS_MESHPHYSICALMATERIAL || defined IS_MESHSTANDARDMATERIAL || defined IS_MESHTOONMATERIAL || defined IS_SHADOWMATERIAL + vec3 csm_Bump = vec3(0.0); + #endif + + float csm_DepthAlpha = 1.0; +#endif +`,JO=` + varying mat4 csm_internal_vModelViewMatrix; +`,YO=` + csm_internal_vModelViewMatrix = modelViewMatrix; +`,XO=` + varying mat4 csm_internal_vModelViewMatrix; +`,ZO=` + +`,QO,$O=(QO={},DO(QO,`${HO.position}`,`*`),DO(QO,`${HO.positionRaw}`,`*`),DO(QO,`${HO.normal}`,`*`),DO(QO,`${HO.pointSize}`,[`PointsMaterial`]),DO(QO,`${HO.diffuseColor}`,`*`),DO(QO,`${HO.fragColor}`,`*`),DO(QO,`${HO.emissive}`,[`MeshStandardMaterial`,`MeshPhysicalMaterial`]),DO(QO,`${HO.roughness}`,[`MeshStandardMaterial`,`MeshPhysicalMaterial`]),DO(QO,`${HO.metalness}`,[`MeshStandardMaterial`,`MeshPhysicalMaterial`]),DO(QO,`${HO.ao}`,[`MeshStandardMaterial`,`MeshPhysicalMaterial`,`MeshBasicMaterial`,`MeshLambertMaterial`,`MeshPhongMaterial`,`MeshToonMaterial`]),DO(QO,`${HO.bump}`,[`MeshLambertMaterial`,`MeshMatcapMaterial`,`MeshNormalMaterial`,`MeshPhongMaterial`,`MeshPhysicalMaterial`,`MeshStandardMaterial`,`MeshToonMaterial`,`ShadowMaterial`]),DO(QO,`${HO.depthAlpha}`,`*`),QO),ek=[`baseMaterial`,`fragmentShader`,`vertexShader`,`uniforms`,`patchMap`,`cacheKey`,`silent`],tk=function(e,t,n){return e.split(t).join(n)},nk=function(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,`\\$&`)},rk=function(e,t){return RegExp(`\\b${nk(t)}\\b`).test(e)};function ik(e){try{new e}catch(e){if(e.message.indexOf(`is not a constructor`)>=0)return!1}return!0}function ak(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;Object.assign(e,t);var r=Object.getPrototypeOf(t);Object.entries(Object.getOwnPropertyDescriptors(r)).filter(function(e){var t=typeof e[1].get==`function`,n=typeof e[1].set==`function`,r=typeof e[1].value==`function`,i=e[0]===`constructor`;return(t||n||r)&&!i}).forEach(function(t){if(typeof e[t[0]]==`function`){n||console.warn(`Function ${t[0]} already exists on CSM, renaming to base_${t[0]}`);var r=`base_${t[0]}`;e[r]=t[1].value.bind(e);return}Object.defineProperty(e,t[0],t[1])})}function ok(e){var t=e.toString().trim(),n=t.substring(t.indexOf(`{`)+1,t.lastIndexOf(`}`));return n.trim().length===0}function sk(e){return e.replace(/\s/g,``)}function ck(e,t,n){var r=e.lastIndexOf(t);return r===-1?e:e.substring(0,r)+n+e.substring(r+t.length)}var lk=function(e){LO(n,e);var t=VO(n);function n(e){var r,i=e.baseMaterial,a=e.fragmentShader,o=e.vertexShader,s=e.uniforms,c=e.patchMap,l=e.cacheKey,u=e.silent,d=jO(e,ek);MO(this,n);var f;if(ik(i)?f=new i(d):(f=i,Object.assign(f,d)),f.type===`RawShaderMaterial`)throw Error(`CustomShaderMaterial does not support RawShaderMaterial`);r=t.call(this),ak(FO(r),f,u),r.__csm={patchMap:c||{},fragmentShader:a||``,vertexShader:o||``,cacheKey:l,baseMaterial:i,instanceID:_e.generateUUID(),type:f.type,isAlreadyExtended:!ok(f.onBeforeCompile),cacheHash:``,silent:u},r.uniforms=kO(kO({},r.uniforms||{}),s||{});var p=r.__csm,m=p.fragmentShader,h=p.vertexShader,g=r.uniforms;return r.__csm.cacheHash=r.getCacheHash(),r.generateMaterial(m,h,g),r}return PO(n,[{key:`update`,value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.uniforms=e.uniforms||this.uniforms,Object.assign(this.__csm,e);var t=this.__csm,n=t.fragmentShader,r=t.vertexShader,i=this.uniforms,a=this.getCacheHash();this.__csm.cacheHash=a,this.generateMaterial(n,r,i)}},{key:`clone`,value:function(){var e={baseMaterial:this.__csm.baseMaterial,fragmentShader:this.__csm.fragmentShader,vertexShader:this.__csm.vertexShader,uniforms:this.uniforms,silent:this.__csm.silent,patchMap:this.__csm.patchMap,cacheKey:this.__csm.cacheKey},t=new this.constructor(e);return Object.assign(this,t),t}},{key:`getCacheHash`,value:function(){var e=this.__csm,t=e.fragmentShader,n=e.vertexShader,r=this.uniforms,i=Object.values(r).reduce(function(e,t){var n=t.value;return e+JSON.stringify(n)},``),a=sk(t)+sk(n)+i;return a.trim().length>0?GD(a):this.customProgramCacheKey()}},{key:`generateMaterial`,value:function(e,t,n){var r=this,i=this.parseShader(e),a=this.parseShader(t);this.uniforms=n||{},this.customProgramCacheKey=function(){return r.__csm.cacheHash};var o=function(e){try{if(i){var t=r.patchShader(i,e.fragmentShader,!0);e.fragmentShader=r.getMaterialDefine()+t}if(a){var n=r.patchShader(a,e.vertexShader);e.vertexShader=`#define IS_VERTEX; +`+n,e.vertexShader=r.getMaterialDefine()+e.vertexShader}e.uniforms=kO(kO({},e.uniforms),r.uniforms),r.uniforms=e.uniforms}catch(e){console.error(e)}};if(this.__csm.isAlreadyExtended){var s=this.onBeforeCompile;this.onBeforeCompile=function(e,t){s(e,t),o(e)}}else this.onBeforeCompile=o;this.needsUpdate=!0}},{key:`patchShader`,value:function(e,t,n){var r=this,i=t,a=kO(kO({},this.getPatchMapForMaterial()),this.__csm.patchMap);Object.keys(a).forEach(function(t){Object.keys(a[t]).forEach(function(n){var o=$O[t],s=r.__csm.type;if(t===`*`||rk(e.main,t))if(!o||Array.isArray(o)&&o.includes(s)||o===`*`)i=tk(i,n,a[t][n]);else throw Error(`CSM: ${t} is not available in ${s}. Shader cannot compile.`)})}),i=i.replace(`void main() {`,` + #ifndef CSM_IS_HEAD_DEFAULTS_DEFINED + ${n?XO:JO} + #define CSM_IS_HEAD_DEFAULTS_DEFINED 1 + #endif + + ${e.header} + + void main() { + #ifndef CSM_IS_DEFAULTS_DEFINED + ${qO} + #define CSM_IS_DEFAULTS_DEFINED 1 + #endif + + #ifndef CSM_IS_MAIN_DEFAULTS_DEFINED + ${n?ZO:YO} + #define CSM_IS_MAIN_DEFAULTS_DEFINED 1 + #endif + + // CSM_START + `);var o=this.__csm.isAlreadyExtended,s=i.includes(`// CSM_END`);return i=o&&s?ck(i,`// CSM_END`,` + // CSM_END + ${e.main} + // CSM_END + `):i.replace(`// CSM_START`,` + // CSM_START + ${e.main} + // CSM_END + `),i=e.defines+i,i}},{key:`parseShader`,value:function(e){if(e){var t=e.replace(/\/\*\*(.*?)\*\/|\/\/(.*?)\n/gm,``),n=mO(t),r=wO(n),i=r.map(function(e){return e.name}).indexOf(`main`),a=yO(n.slice(0,i>=0?r[i].outer[0]:void 0)),o=i>=0?this.getShaderFromIndex(n,r[i].body):``;return{defines:``,header:a,main:o}}}},{key:`getMaterialDefine`,value:function(){var e=this.__csm.type;return e?`#define IS_${e.toUpperCase()}; +`:`#define IS_UNKNOWN; +`}},{key:`getPatchMapForMaterial`,value:function(){switch(this.__csm.type){case`ShaderMaterial`:return KO;default:return GO}}},{key:`getShaderFromIndex`,value:function(e,t){return yO(e.slice(t[0],t[1]))}}]),n}(ge),uk=class extends Ce{constructor(e={}){super(e),dx(this,`_time`),dx(this,`_factor`),this.setValues(e),this._time={value:0},this._factor={value:1}}onBeforeCompile(e){e.uniforms||={},e.uniforms.time=this._time,e.uniforms.factor=this._factor,e.vertexShader=` + uniform float time; + uniform float factor; + ${e.vertexShader} + `,e.vertexShader=e.vertexShader.replace(`#include `,`float theta = sin( time + position.y ) / 2.0 * factor; + float c = cos( theta ); + float s = sin( theta ); + mat3 m = mat3( c, 0, s, 0, 1, 0, -s, 0, c ); + vec3 transformed = vec3( position ) * m; + vNormal = vNormal * m;`)}get time(){return this._time.value}set time(e){this._time.value=e}get factor(){return this._factor.value}set factor(e){this._factor.value=e}};const dk=[`factor`],fk=H({__name:`index`,props:{speed:{default:1},factor:{default:1}},setup(e,{expose:t}){let n=e,r=dn(),{extend:i,invalidate:a}=nn();i({MeshWobbleMaterial:uk}),K(n,()=>a());let{onBeforeRender:o}=Ht();return o(({elapsed:e,invalidate:t})=>{r.value&&(r.value.time=e*n?.speed,t())}),t({instance:r}),(e,t)=>(U(),V(`TresMeshWobbleMaterial`,Kt({ref_key:`materialRef`,ref:r,factor:e.factor},e.$attrs),null,16,dk))}}),pk=H({name:`BakeShadows`,setup(){let{renderer:e}=nn();Fn(()=>{e.value.shadowMap.autoUpdate=!1,e.value.shadowMap.needsUpdate=!0})}});var mk=`void main() { + gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); +}`,hk=`#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 gk=new z(0,0,0),_k=new z(0,0,0),vk=new z(0,0,0);function yk(e,t,n){let r=gk.setFromMatrixPosition(e.matrixWorld);r.project(t);let i=n.width/2,a=n.height/2;return[(Number.isNaN(r.x)?0:r.x)*i+i,-(r.y*a)+a,r.z]}function bk(e,t){let n=gk.setFromMatrixPosition(e.matrixWorld),r=_k.setFromMatrixPosition(t.matrixWorld),i=n.sub(r),a=t.getWorldDirection(vk);return i.angleTo(a)>Math.PI/2}function xk(e,t,n,r){let i=gk.setFromMatrixPosition(e.matrixWorld),a=i.clone();a.project(t),n.setFromCamera(new mt(a.x,a.y),t);let o=n.intersectObjects(r,!0);if(o.length>0){let e=o[0].distance;return i.distanceTo(n.ray.origin)Math.abs(e)<1e-10?0:e;function Tk(e,t,n=``){let r=`matrix3d(`;for(let n=0;n!==16;n++)r+=wk(t[n]*e.elements[n])+(n===15?`)`:`,`);return n+r}const Ek=(e=>t=>Tk(t,e))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),Dk=(e=>(t,n)=>Tk(t,e(n),`translate(-50%,-50%)`))(e=>[1/e,1/e,1/e,1,-1/e,-1/e,-1/e,-1,1/e,1/e,1/e,1,1,1,1,1]),Ok=[`geometry`,`material`],kk=H({__name:`HTML`,props:{geometry:{default:new Ie},material:{},as:{default:`div`},transform:{type:Boolean,default:!1},portal:{},wrapperClass:{},eps:{default:1e-4},distanceFactor:{},fullscreen:{type:Boolean},center:{type:Boolean},pointerEvents:{default:`auto`},sprite:{type:Boolean,default:!1},zIndexRange:{default:()=>[16777271,0]},occlude:{type:[Object,null,Array,Boolean,String]}},emits:[`onOcclude`],setup(e,{expose:t,emit:n}){let r=e,i=n,a=On(),o=yn(),s=W(),c=W(),{geometry:l,material:u,as:d,transform:f,portal:p,wrapperClass:m,eps:h,distanceFactor:g,fullscreen:_,center:v,pointerEvents:y,sprite:b,occlude:x,zIndexRange:S}=_n(r),{renderer:C,scene:w,camera:E,raycaster:D,sizes:O}=nn(),k=kt(()=>document.createElement(d.value)),A=W([0,0,0]),j=W(0),M=W(),N=kt(()=>f.value?{position:`absolute`,top:0,left:0,width:`${O.width.value}px`,height:`${O.height.value}px`,transformStyle:`preserve-3d`,pointerEvents:`none`,zIndex:2}:{position:`absolute`,transform:v.value?`translate3d(-50%,-50%,0)`:`none`,..._.value&&{top:-O.height.value/2,left:-O.width.value/2,width:`${O.width.value}px`,height:`${O.height.value}px`},zIndex:2,...Object.assign({},o.style)}),ee=kt(()=>({position:`absolute`,pointerEvents:y.value})),P=W(null),F=W(!1),I=kt(()=>x?.value&&x?.value!==`blending`||Array.isArray(x?.value)&&x?.value.length&&Wt(x.value[0]));K(()=>x,({value:e})=>{e===`blending`?(k.value.style.zIndex=`${Math.floor(S.value[0]/2)}`,k.value.style.position=`absolute`,k.value.style.pointerEvents=`none`):(k.value.style.zIndex=null,k.value.style.position=null,k.value.style.pointerEvents=null)}),K(()=>{var e;return[s.value,C.value,O.width.value,O.height.value,(e=a.default)?.call(a)]},([e,t])=>{var n,r,i,s,l,u;if(e&&t){let d=p?.value||t.domElement;if((n=w.value)==null||n.updateMatrixWorld(),f.value)k.value.style.cssText=`position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;`;else{let t=yk(e,E.value,{width:O.width.value,height:O.height.value});k.value.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${t[0]}px,${t[1]}px,0);transform-origin:0 0;`}d&&!k.value.parentNode&&((r=d.parentNode)==null||r.appendChild(k.value)),f.value?M.value=Nt(`div`,{id:`outer`,style:N.value},[Nt(`div`,{id:`inner`,style:ee.value},[Nt(`div`,{key:(i=c.value)?.uuid,id:w?.value.uuid,class:o.class,style:o.style},(s=a.default)?.call(a))])]):M.value=Nt(`div`,{key:(l=c.value)?.uuid,id:w?.value.uuid,style:N.value},(u=a.default)?.call(a)),an(M.value,k.value)}}),Fn(()=>{m!=null&&m.value&&(k.value.className=m.value)});let te=W(!0),{onBeforeRender:ne}=Ht();ne(({invalidate:e})=>{var t,n,r,a,u,d,p;if(e(),s.value&&E.value&&C.value){(t=E.value)==null||t.updateMatrixWorld(),s.value.updateWorldMatrix(!0,!1);let e=f.value?A.value:yk(s.value,E.value,{width:O.width.value||0,height:O.height.value||0});if(f.value||Math.abs(j.value-E.value.zoom)>h.value||Math.abs(A.value[0]-e[0])>h.value||Math.abs(A.value[1]-e[1])>h.value||Math.abs(A.value[2]-e[2])>h.value){let t=bk(s.value,E.value),a=!1;I.value&&(Array.isArray(x?.value)?a=x?.value:x?.value!==`blending`&&(a=[w.value]));let o=te.value;if(a){let e=xk(s.value,E.value,D.value,a);te.value=e&&!t}else te.value=!t;o!==te.value&&(i(`onOcclude`,!te.value),k.value.style.display=te.value?`block`:`none`);let c=Math.floor(S.value[0]/2),l=x!=null&&x.value?I.value?[S.value[0],c]:[c-1,0]:S.value;if(k.value.style.zIndex=`${Ck(s.value,E.value,l)}`,f.value){let[e,t]=[O.width.value/2,O.height.value/2],i=E.value.projectionMatrix.elements[5]*t,{isOrthographicCamera:a,top:o,left:c,bottom:l,right:u}=E.value,d=Ek(E.value.matrixWorldInverse),f=a?`scale(${i})translate(${wk(-(u+c)/2)}px,${wk((o+l)/2)}px)`:`translateZ(${i}px)`,p=s.value.matrixWorld;if(b.value&&(p=E.value.matrixWorldInverse.clone().transpose().copyPosition(p).scale(s.value.scale),p.elements[3]=p.elements[7]=p.elements[11]=0,p.elements[15]=1),k.value.style.width=`${O.width.value}px`,k.value.style.height=`${O.height.value}px`,k.value.style.perspective=a?``:`${i}px`,(n=M.value)!=null&&n.el&&(r=M.value)!=null&&r.children&&Array.isArray(M.value.children)){M.value.el.style.transform=`${f}${d}translate(${e}px,${t}px)`;let n=M.value.children[0];n&&n.el&&(n.el.style.transform=Dk(p,1/((g?.value||10)/400)))}}else{let t=g?.value===void 0?1:Sk(s.value,E.value)*g?.value;k.value.style.transform=`translate3d(${e[0]}px,${e[1]}px,0) scale(${t})`}}A.value=e,j.value=E.value.zoom}if(!I.value&&c.value&&!F.value)if(f.value){if((a=M.value)!=null&&a.el&&(u=M.value)!=null&&u.children){let e=((d=M.value)?.children)[0];if(e!=null&&e.clientWidth&&e!=null&&e.clientHeight){let{isOrthographicCamera:t}=E.value;if(t||l)o.scale&&(Array.isArray(o.scale)?o.scale instanceof z?c.value.scale.copy(o.scale.clone().divideScalar(1)):c.value.scale.set(1/o.scale[0],1/o.scale[1],1/o.scale[2]):c.value.scale.setScalar(1/o.scale));else{let t=(g?.value||10)/400,n=e.clientWidth*t,r=e.clientHeight*t;c.value.scale.set(n,r,1)}F.value=!0}}}else{let e=k.value.children[0];if(e!=null&&e.clientWidth&&e!=null&&e.clientHeight){let t=e.clientWidth*1,n=e.clientHeight*1;c.value.scale.set(t,n,1),F.value=!0}P.value.lookAt((p=E.value)?.position)}});let L=kt(()=>({vertexShader:f.value?void 0:hk,fragmentShader:mk})),re=kt(()=>{let e=L.value;return u.value||new Xe({vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,side:T})});return tn(()=>{re.value&&re.value.dispose(),k.value.remove()}),t({instance:s}),(e,t)=>(U(),V(`TresGroup`,{ref_key:`groupRef`,ref:s},[G(x)&&!I.value?(U(),V(`TresMesh`,{key:0,ref_key:`meshRef`,ref:c,geometry:G(l),material:re.value},null,8,Ok)):jt(``,!0)],512))}});var Ak={exports:{}},jk=Ak.exports,Mk;function Nk(){return Mk||(Mk=1,function(e,t){(function(t,n){e.exports=n()})(jk,function(){var e=function(){function t(e){return i.appendChild(e.dom),e}function n(e){for(var t=0;to+1e3&&(c.update(1e3*s/(e-o),100),o=e,s=0,u)){var t=performance.memory;u.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){a=this.end()},domElement:i,setMode:n}};return e.Panel=function(e,t,n){var r=1/0,i=0,a=Math.round,o=a(window.devicePixelRatio||1),s=80*o,c=48*o,l=3*o,u=2*o,d=3*o,f=15*o,p=74*o,m=30*o,h=document.createElement(`canvas`);h.width=s,h.height=c,h.style.cssText=`width:80px;height:48px`;var g=h.getContext(`2d`);return g.font=`bold `+9*o+`px Helvetica,Arial,sans-serif`,g.textBaseline=`top`,g.fillStyle=n,g.fillRect(0,0,s,c),g.fillStyle=t,g.fillText(e,l,u),g.fillRect(d,f,p,m),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(d,f,p,m),{dom:h,update:function(c,_){r=Math.min(r,c),i=Math.max(i,c),g.fillStyle=n,g.globalAlpha=1,g.fillRect(0,0,s,f),g.fillStyle=t,g.fillText(a(c)+` `+e+` (`+a(r)+`-`+a(i)+`)`,l,u),g.drawImage(h,d+o,f,p-o,m,d,f,p-o,m),g.fillRect(d+p-o,f,o,m),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(d+p-o,f,o,a((1-c/_)*m))}}},e})}(Ak)),Ak.exports}var Pk=Nk();const Fk=zD(Pk),Ik=H({name:`Stats`,props:{showPanel:{type:Number,default:0}},setup(e,{expose:t}){let n=new Fk;t({instance:n});let r=document.body;n.showPanel(e.showPanel||0),r?.appendChild(n.dom);let{onBeforeRender:i,onAfterRender:a}=Ht();i(()=>n.begin(),-1/0),a(()=>n.end(),1/0),tn(()=>{r?.removeChild(n.dom)})}});var Lk=class{constructor(e,t,n){this.name=e,this.fg=t,this.bg=n,this.gradient=null,this.PR=Math.round(window.devicePixelRatio||1),this.WIDTH=90*this.PR,this.HEIGHT=48*this.PR,this.TEXT_X=3*this.PR,this.TEXT_Y=2*this.PR,this.GRAPH_X=3*this.PR,this.GRAPH_Y=15*this.PR,this.GRAPH_WIDTH=84*this.PR,this.GRAPH_HEIGHT=30*this.PR,this.canvas=document.createElement(`canvas`),this.canvas.width=this.WIDTH,this.canvas.height=this.HEIGHT,this.canvas.style.width=`90px`,this.canvas.style.height=`48px`,this.canvas.style.position=`absolute`,this.canvas.style.cssText=`width:90px;height:48px`,this.context=this.canvas.getContext(`2d`),this.initializeCanvas()}createGradient(){if(!this.context)throw Error(`No context`);let e=this.context.createLinearGradient(0,this.GRAPH_Y,0,this.GRAPH_Y+this.GRAPH_HEIGHT),t,n=this.fg;switch(this.fg.toLowerCase()){case`#0ff`:t=`#006666`;break;case`#0f0`:t=`#006600`;break;case`#ff0`:t=`#666600`;break;case`#e1e1e1`:t=`#666666`;break;default:t=this.bg;break}return e.addColorStop(0,t),e.addColorStop(1,n),e}initializeCanvas(){this.context&&(this.context.font=`bold `+9*this.PR+`px Helvetica,Arial,sans-serif`,this.context.textBaseline=`top`,this.gradient=this.createGradient(),this.context.fillStyle=this.bg,this.context.fillRect(0,0,this.WIDTH,this.HEIGHT),this.context.fillStyle=this.fg,this.context.fillText(this.name,this.TEXT_X,this.TEXT_Y),this.context.fillStyle=this.fg,this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT),this.context.fillStyle=this.bg,this.context.globalAlpha=.9,this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT))}update(e,t,n,r,i=0){if(!this.context||!this.gradient)return;let a=Math.min(1/0,e),o=Math.max(n,e);r=Math.max(r,t),this.context.globalAlpha=1,this.context.fillStyle=this.bg,this.context.fillRect(0,0,this.WIDTH,this.GRAPH_Y),this.context.fillStyle=this.fg,this.context.fillText(`${e.toFixed(i)} ${this.name} (${a.toFixed(i)}-${parseFloat(o.toFixed(i))})`,this.TEXT_X,this.TEXT_Y),this.context.drawImage(this.canvas,this.GRAPH_X+this.PR,this.GRAPH_Y,this.GRAPH_WIDTH-this.PR,this.GRAPH_HEIGHT,this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH-this.PR,this.GRAPH_HEIGHT);let s=this.GRAPH_HEIGHT-(1-t/r)*this.GRAPH_HEIGHT;s>0&&(this.context.globalAlpha=1,this.context.fillStyle=this.gradient,this.context.fillRect(this.GRAPH_X+this.GRAPH_WIDTH-this.PR,this.GRAPH_Y+this.GRAPH_HEIGHT-s,this.PR,s))}};const Rk=class e{constructor({trackGPU:t=!1,logsPerSecond:n=30,samplesLog:r=60,samplesGraph:i=10,precision:a=2,minimal:o=!1,horizontal:s=!0,mode:c=0}={}){this.gl=null,this.ext=null,this.activeQuery=null,this.gpuQueries=[],this.threeRendererPatched=!1,this.frames=0,this.renderCount=0,this.isRunningCPUProfiling=!1,this.totalCpuDuration=0,this.totalGpuDuration=0,this.totalGpuDurationCompute=0,this.totalFps=0,this.gpuPanel=null,this.gpuPanelCompute=null,this.averageFps={logs:[],graph:[]},this.averageCpu={logs:[],graph:[]},this.averageGpu={logs:[],graph:[]},this.averageGpuCompute={logs:[],graph:[]},this.handleClick=e=>{e.preventDefault(),this.showPanel(++this.mode%this.dom.children.length)},this.handleResize=()=>{this.resizePanel(this.fpsPanel,0),this.resizePanel(this.msPanel,1),this.gpuPanel&&this.resizePanel(this.gpuPanel,2),this.gpuPanelCompute&&this.resizePanel(this.gpuPanelCompute,3)},this.mode=c,this.horizontal=s,this.minimal=o,this.trackGPU=t,this.samplesLog=r,this.samplesGraph=i,this.precision=a,this.logsPerSecond=n,this.dom=document.createElement(`div`),this.initializeDOM(),this.beginTime=performance.now(),this.prevTime=this.beginTime,this.prevCpuTime=this.beginTime,this.fpsPanel=this.addPanel(new e.Panel(`FPS`,`#0ff`,`#002`),0),this.msPanel=this.addPanel(new e.Panel(`CPU`,`#0f0`,`#020`),1),this.setupEventListeners()}initializeDOM(){this.dom.style.cssText=` + position: fixed; + top: 0; + left: 0; + opacity: 0.9; + z-index: 10000; + ${this.minimal?`cursor: pointer;`:``} + `}setupEventListeners(){this.minimal?(this.dom.addEventListener(`click`,this.handleClick),this.showPanel(this.mode)):window.addEventListener(`resize`,this.handleResize)}async init(e){if(!e){console.error(`Stats: The "canvas" parameter is undefined.`);return}this.handleThreeRenderer(e)||await this.handleWebGPURenderer(e)||this.initializeWebGL(e)}handleThreeRenderer(e){return e.isWebGLRenderer&&!this.threeRendererPatched?(this.patchThreeRenderer(e),this.gl=e.getContext(),this.trackGPU&&this.initializeGPUTracking(),!0):!1}async handleWebGPURenderer(e){return e.isWebGPURenderer?(this.trackGPU&&(e.backend.trackTimestamp=!0,await e.hasFeatureAsync(`timestamp-query`)&&this.initializeWebGPUPanels()),this.info=e.info,!0):!1}initializeWebGPUPanels(){this.gpuPanel=this.addPanel(new e.Panel(`GPU`,`#ff0`,`#220`),2),this.gpuPanelCompute=this.addPanel(new e.Panel(`CPT`,`#e1e1e1`,`#212121`),3)}initializeWebGL(e){if(e instanceof WebGL2RenderingContext)this.gl=e;else if(e instanceof HTMLCanvasElement||e instanceof OffscreenCanvas){if(this.gl=e.getContext(`webgl2`),!this.gl)return console.error(`Stats: Unable to obtain WebGL2 context.`),!1}else return console.error(`Stats: Invalid input type. Expected WebGL2RenderingContext, HTMLCanvasElement, or OffscreenCanvas.`),!1;return!0}initializeGPUTracking(){this.gl&&(this.ext=this.gl.getExtension(`EXT_disjoint_timer_query_webgl2`),this.ext&&(this.gpuPanel=this.addPanel(new e.Panel(`GPU`,`#ff0`,`#220`),2)))}begin(){this.isRunningCPUProfiling||this.beginProfiling(`cpu-started`),!(!this.gl||!this.ext)&&(this.activeQuery&&this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.activeQuery=this.gl.createQuery(),this.activeQuery&&this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,this.activeQuery))}end(){this.renderCount++,this.gl&&this.ext&&this.activeQuery&&(this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.gpuQueries.push({query:this.activeQuery}),this.activeQuery=null)}update(){this.info?this.processWebGPUTimestamps():this.processGpuQueries(),this.endProfiling(`cpu-started`,`cpu-finished`,`cpu-duration`),this.updateAverages(),this.resetCounters()}processWebGPUTimestamps(){this.totalGpuDuration=this.info.render.timestamp,this.totalGpuDurationCompute=this.info.compute.timestamp,this.addToAverage(this.totalGpuDurationCompute,this.averageGpuCompute)}updateAverages(){this.addToAverage(this.totalCpuDuration,this.averageCpu),this.addToAverage(this.totalGpuDuration,this.averageGpu)}resetCounters(){this.renderCount=0,this.totalCpuDuration===0&&this.beginProfiling(`cpu-started`),this.totalCpuDuration=0,this.totalFps=0,this.beginTime=this.endInternal()}resizePanel(e,t){e.canvas.style.position=`absolute`,this.minimal?e.canvas.style.display=`none`:(e.canvas.style.display=`block`,this.horizontal?(e.canvas.style.top=`0px`,e.canvas.style.left=t*e.WIDTH/e.PR+`px`):(e.canvas.style.left=`0px`,e.canvas.style.top=t*e.HEIGHT/e.PR+`px`))}addPanel(e,t){return e.canvas&&(this.dom.appendChild(e.canvas),this.resizePanel(e,t)),e}showPanel(e){for(let t=0;t{if(this.gl){let n=this.gl.getQueryParameter(e.query,this.gl.QUERY_RESULT_AVAILABLE),r=this.gl.getParameter(this.ext.GPU_DISJOINT_EXT);if(n&&!r){let n=this.gl.getQueryParameter(e.query,this.gl.QUERY_RESULT)*1e-6;this.totalGpuDuration+=n,this.gl.deleteQuery(e.query),this.gpuQueries.splice(t,1)}}}))}endInternal(){this.frames++;let e=(performance||Date).now(),t=e-this.prevTime;if(e>=this.prevCpuTime+1e3/this.logsPerSecond){let n=Math.round(this.frames*1e3/t);this.addToAverage(n,this.averageFps),this.updatePanel(this.fpsPanel,this.averageFps,0),this.updatePanel(this.msPanel,this.averageCpu,this.precision),this.updatePanel(this.gpuPanel,this.averageGpu,this.precision),this.gpuPanelCompute&&this.updatePanel(this.gpuPanelCompute,this.averageGpuCompute),this.frames=0,this.prevCpuTime=e,this.prevTime=e}return e}addToAverage(e,t){t.logs.push(e),t.logs.length>this.samplesLog&&t.logs.shift(),t.graph.push(e),t.graph.length>this.samplesGraph&&t.graph.shift()}beginProfiling(e){window.performance&&(window.performance.mark(e),this.isRunningCPUProfiling=!0)}endProfiling(e,t,n){if(window.performance&&t&&this.isRunningCPUProfiling){window.performance.mark(t);let r=performance.measure(n,e,t);this.totalCpuDuration+=r.duration,this.isRunningCPUProfiling=!1}}updatePanel(e,t,n=2){if(t.logs.length>0){let r=0,i=.01;for(let e=0;ei&&(i=t.logs[e]);let a=0,o=.01;for(let e=0;eo&&(o=t.graph[e]);e&&e.update(r/Math.min(t.logs.length,this.samplesLog),a/Math.min(t.graph.length,this.samplesGraph),i,o,n)}}get domElement(){return this.dom}patchThreeRenderer(e){let t=e.render,n=this;e.render=function(e,r){n.begin(),t.call(this,e,r),n.end()},this.threeRendererPatched=!0}};Rk.Panel=Lk;let zk=Rk;const Bk=H({name:`StatsGl`,props:[`logsPerSecond`,`samplesLog`,`samplesGraph`,`precision`,`horizontal`,`minimal`,`mode`],setup(e,{expose:t}){let n=new zk({logsPerSecond:e.logsPerSecond,samplesLog:e.samplesLog,samplesGraph:e.samplesGraph,precision:e.precision,horizontal:e.horizontal,minimal:e.minimal,mode:e.mode});t({instance:n});let r=document.body,i=n.dom||n.container;r?.appendChild(i);let{renderer:a}=nn(),{onAfterRender:o}=Ht();n.init(a.value),o(()=>n.update(),1/0),tn(()=>{r?.removeChild(i)})}}),{logError:Vk}=Re(),Hk=[`args`],Uk=[`color`],Wk=H({__name:`Box`,props:{args:{default:()=>[1,1,1]},color:{default:`#ffffff`}},setup(e,{expose:t}){let n=e,{invalidate:r}=nn(),{args:i,color:a}=_n(n);K(i,()=>r());let o=dn();return t({instance:o}),(e,t)=>(U(),V(`TresMesh`,Kt({ref_key:`boxRef`,ref:o},e.$attrs),[B(`TresBoxGeometry`,{args:G(i)},null,8,Hk),sn(e.$slots,`default`,{},()=>[B(`TresMeshBasicMaterial`,{color:G(a)},null,8,Uk)])],16))}}),Gk=[`object`],Kk=H({__name:`Line2`,props:{points:{},vertexColors:{default:null},color:{default:`white`},lineWidth:{default:1},worldUnits:{type:Boolean,default:!1},alphaToCoverage:{type:Boolean,default:!1},dashed:{type:Boolean,default:!1},dashSize:{default:1},gapSize:{default:1},dashScale:{default:1},dashOffset:{default:0}},setup(e,{expose:t}){let n=e;function r(e,t){if(!e||e.length===0)return Array.from({length:t}).fill(Te(n.color));if(e.length===1)return Array.from({length:t}).fill(Te(e[0]));if(e.length===t)return e.map(Te);let r=t-1,i=e.map(Te);closed&&i.push(i[0].clone());let a=[i[0]],o=r/(i.length-1);for(let e=1;eArray.isArray(n.vertexColors));function u(e,t){e.color=Te(t.color),e.linewidth=t.lineWidth,e.alphaToCoverage=t.alphaToCoverage,e.worldUnits=t.worldUnits,e.vertexColors=Array.isArray(t.vertexColors),e.dashed=t.dashed,e.dashScale=t.dashScale,e.dashSize=t.dashSize,e.dashOffset=t.dashOffset,e.gapSize=t.gapSize,e.needsUpdate=!0}function d(e,t,n){let i=t.map(e=>e instanceof z?[e.x,e.y,e.z]:e instanceof mt?[e.x,e.y,0]:Array.isArray(e)&&e.length===2?[e[0],e[1],0]:e).flat();e.setPositions(i.flat());let a=r(n,t.length).map(e=>e.toArray()).flat();e.setColors(a),o.computeLineDistances()}u(i,n),d(a,n.points,n.vertexColors),o.computeLineDistances(),K(()=>[n.color,n.lineWidth,n.alphaToCoverage,n.worldUnits,l,n.dashed,n.dashScale,n.dashSize,n.dashOffset],()=>{u(i,n),c()}),K(()=>[n.points,n.vertexColors],()=>{d(a,n.points,n.vertexColors),c()}),K(()=>[s.height,s.width],()=>{i.resolution=new mt(s.width.value,s.height.value),c()}),tn(()=>{a.dispose(),i.dispose()});let f=dn();return t({instance:f}),(e,t)=>(U(),V(`primitive`,{ref:f.value,object:G(o)},null,8,Gk))}}),qk=H({__name:`CatmullRomCurve3`,props:{segments:{default:20},closed:{type:Boolean,default:!1},curveType:{default:`centripetal`},tension:{default:.5},points:{},vertexColors:{},color:{},lineWidth:{},alphaToCoverage:{type:Boolean},dashed:{type:Boolean},dashSize:{},dashScale:{},dashOffset:{},gapSize:{},worldUnits:{type:Boolean}},setup(e,{expose:t}){let n=e;function r(e,t,n,r){let i=e.map(e=>e instanceof z?e:new z(...e));return new p(i,t,n,r)}function i(e,t){return e.getPoints(t)}let a=kt(()=>r(n.points,n.closed,n.curveType,n.tension)),o=kt(()=>i(a.value,n.segments)),s=dn();return t({instance:s}),(e,t)=>(U(),At(Kk,{ref:s.value,points:o.value,"vertex-colors":n.vertexColors,color:n.color,"line-width":n.lineWidth,"alpha-to-coverage":n.alphaToCoverage,dashed:n.dashed,"dash-size":n.dashSize,"dash-scale":n.dashScale,"dash-offset":n.dashOffset,"gap-size":n.gapSize,"world-units":n.worldUnits},null,8,[`points`,`vertex-colors`,`color`,`line-width`,`alpha-to-coverage`,`dashed`,`dash-size`,`dash-scale`,`dash-offset`,`gap-size`,`world-units`]))}}),Jk=[`args`],Yk=[`color`],Xk=H({__name:`Circle`,props:{args:{default:()=>[1,32,0,Math.PI*2]},color:{default:`#ffffff`}},setup(e,{expose:t}){let n=e,{args:r,color:i}=_n(n),{invalidate:a}=nn();K(r,()=>a());let o=dn();return t({instance:o}),(e,t)=>(U(),V(`TresMesh`,Kt({ref_key:`circleRef`,ref:o},e.$attrs),[B(`TresCircleGeometry`,{args:G(r)},null,8,Jk),sn(e.$slots,`default`,{},()=>[B(`TresMeshBasicMaterial`,{color:G(i)},null,8,Yk)])],16))}}),Zk=[`args`],Qk=[`color`],$k=H({__name:`Cone`,props:{args:{default:()=>[1,1,12,12,!1,0,Math.PI*2]},color:{default:`#ffffff`}},setup(e,{expose:t}){let n=e,{args:r,color:i}=_n(n),{invalidate:a}=nn();K(r,()=>a());let o=dn();return t({instance:o}),(e,t)=>(U(),V(`TresMesh`,Kt({ref_key:`coneRef`,ref:o},e.$attrs),[B(`TresConeGeometry`,{args:G(r)},null,8,Zk),sn(e.$slots,`default`,{},()=>[B(`TresMeshBasicMaterial`,{color:G(i)},null,8,Qk)])],16))}}),eA=[`args`],tA=[`color`],nA=H({__name:`Cylinder`,props:{args:{default:()=>[1,1,1,32,1,!1,0,Math.PI*2]},color:{default:`#ffffff`}},setup(e,{expose:t}){let n=e,{args:r,color:i}=_n(n),{invalidate:a}=nn();K(r,()=>a());let o=dn();return t({instance:o}),(e,t)=>(U(),V(`TresMesh`,Kt({ref_key:`cylinderRef`,ref:o},e.$attrs),[B(`TresCylinderGeometry`,{args:G(r)},null,8,eA),sn(e.$slots,`default`,{},()=>[B(`TresMeshBasicMaterial`,{color:G(i)},null,8,tA)])],16))}}),rA=[`args`],iA=[`color`],aA=H({__name:`Dodecahedron`,props:{args:{default:()=>[1,0]},color:{default:`#ffffff`}},setup(e,{expose:t}){let n=e,{args:r,color:i}=_n(n),a=dn(),{invalidate:o}=nn();return K(r,()=>o()),t({instance:a}),(e,t)=>(U(),V(`TresMesh`,Kt({ref_key:`dodecahedronRef`,ref:a},e.$attrs),[B(`TresDodecahedronGeometry`,{args:G(r)},null,8,rA),sn(e.$slots,`default`,{},()=>[B(`TresMeshBasicMaterial`,{color:G(i)},null,8,iA)])],16))}}),oA=[`args`],sA=[`color`],cA=H({__name:`Icosahedron`,props:{args:{default:()=>[1,0]},color:{default:`#ffffff`}},setup(e,{expose:t}){let n=e,{args:r,color:i}=_n(n),{invalidate:a}=nn();K(r,()=>a());let o=dn();return t({instance:o}),(e,t)=>(U(),V(`TresMesh`,Kt({ref_key:`icosahedronRef`,ref:o},e.$attrs),[B(`TresIcosahedronGeometry`,{args:G(r)},null,8,oA),sn(e.$slots,`default`,{},()=>[B(`TresMeshBasicMaterial`,{color:G(i)},null,8,sA)])],16))}}),lA=[`args`],uA=[`color`],dA=H({__name:`Octahedron`,props:{args:{default:()=>[1,0]},color:{default:`#ffffff`}},setup(e,{expose:t}){let n=e,{args:r,color:i}=_n(n),{invalidate:a}=nn();K(r,()=>a());let o=dn();return t({instance:o}),(e,t)=>(U(),V(`TresMesh`,Kt({ref_key:`octahedronRef`,ref:o},e.$attrs),[B(`TresOctahedronGeometry`,{args:G(r)},null,8,lA),sn(e.$slots,`default`,{},()=>[B(`TresMeshBasicMaterial`,{color:G(i)},null,8,uA)])],16))}}),fA=[`rotation`],pA=[`args`],mA=[`color`],hA=H({__name:`Plane`,props:{args:{default:()=>[1,1]},color:{default:`#ffffff`}},setup(e,{expose:t}){let n=e,{args:r,color:i}=_n(n),{invalidate:a}=nn();K(r,()=>a());let o=dn();return t({instance:o}),(e,t)=>(U(),V(`TresMesh`,Kt({ref_key:`planeRef`,ref:o,rotation:[-Math.PI/2,0,0]},e.$attrs),[B(`TresPlaneGeometry`,{args:G(r)},null,8,pA),sn(e.$slots,`default`,{},()=>[B(`TresMeshBasicMaterial`,{color:G(i)},null,8,mA)])],16,fA))}}),gA=[`args`],_A=[`color`],vA=H({__name:`Ring`,props:{args:{default:()=>[.5,1,32]},color:{default:`#ffffff`}},setup(e,{expose:t}){let n=e,{args:r,color:i}=_n(n),{invalidate:a}=nn();K(r,()=>a());let o=dn();return t({instance:o}),(e,t)=>(U(),V(`TresMesh`,Kt({ref_key:`ringRef`,ref:o},e.$attrs),[B(`TresRingGeometry`,{args:G(r)},null,8,gA),sn(e.$slots,`default`,{},()=>[B(`TresMeshBasicMaterial`,{color:G(i)},null,8,_A)])],16))}}),yA=[`args`],bA=[`color`],xA=H({__name:`RoundedBox`,props:{args:{default:()=>[1,1,1,2,.1]},color:{default:`#ffffff`}},setup(e,{expose:t}){let n=e,{args:r,color:i}=_n(n),{invalidate:a,extend:o}=nn();o({RoundedBoxGeometry:Ow}),K(r,()=>a());let s=dn();return t({instance:s}),(e,t)=>(U(),V(`TresMesh`,{ref_key:`roundedBoxRef`,ref:s},[B(`TresRoundedBoxGeometry`,{args:G(r)},null,8,yA),sn(e.$slots,`default`,{},()=>[B(`TresMeshBasicMaterial`,{color:G(i)},null,8,bA)])],512))}}),SA=[`args`],CA=[`color`],wA=H({__name:`Sphere`,props:{args:{default:()=>[2,32,16]},color:{default:`#ffffff`}},setup(e,{expose:t}){let n=e,{args:r,color:i}=_n(n),{invalidate:a}=nn();K(r,()=>a());let o=dn();return t({instance:o}),(e,t)=>(U(),V(`TresMesh`,Kt({ref_key:`sphereRef`,ref:o},e.$attrs),[B(`TresSphereGeometry`,{args:G(r)},null,8,SA),sn(e.$slots,`default`,{},()=>[B(`TresMeshBasicMaterial`,{color:G(i)},null,8,CA)])],16))}}),TA=[`geometry`],EA=[`color`],DA=H({__name:`Superformula`,props:{widthSegments:{default:32},heightSegments:{default:32},numArmsA:{default:4},expA:{default:()=>[40,1.3,.9]},numArmsB:{default:4},expB:{default:()=>[40,1.3,.9]},color:{default:`white`}},setup(e,{expose:t}){let n=e,{invalidate:r}=nn(),{cos:i,sin:a,abs:o}=Math,s=dn(),c=dn(n.color);function l(e,t){let n=new f,r=e*t,i=new Float32Array(Array.from({length:3*r}).fill(0)),a=new Float32Array(Array.from({length:3*r}).fill(0)),o=[];for(let n=0;nn.color,()=>c.value=n.color),K(()=>[n.widthSegments,n.heightSegments],()=>{s.value&&s.value.dispose(),s.value=l(n.widthSegments,n.heightSegments),r()},{immediate:!0}),K(()=>[n.numArmsA,n.expA[0],n.expA[1],n.expA[2],n.numArmsB,n.expB[0],n.expB[1],n.expB[2]],()=>{p(s.value,n.numArmsA,n.expA[0],n.expA[1],n.expA[2],n.numArmsB,n.expB[0],n.expB[1],n.expB[2],n.widthSegments,n.heightSegments),r()},{immediate:!0}),tn(()=>{s.value&&s.value.dispose()});let m=dn();return t({instance:m}),(e,t)=>(U(),V(`TresMesh`,Kt({ref_key:`superformulaRef`,ref:m},e.$attrs,{geometry:s.value}),[sn(e.$slots,`default`,{},()=>[B(`TresMeshBasicMaterial`,{color:c.value},null,8,EA)])],16,TA))}}),OA=[`rotation`],kA=[`args`],AA=[`color`],jA=H({__name:`Tetrahedron`,props:{args:{default:()=>[1,0]},color:{default:`#ffffff`}},setup(e,{expose:t}){let n=e,{args:r,color:i}=_n(n),a=dn();return t({instance:a}),(e,t)=>(U(),V(`TresMesh`,Kt({ref_key:`tetrahedronRef`,ref:a,rotation:[-Math.PI/2,0,0]},e.$attrs),[B(`TresTetrahedronGeometry`,{args:G(r)},null,8,kA),sn(e.$slots,`default`,{},()=>[B(`TresMeshBasicMaterial`,{color:G(i)},null,8,AA)])],16,OA))}}),MA=[`args`],NA=[`color`],PA=H({__name:`Torus`,props:{args:{default:()=>[1,1,16,80]},color:{default:`#ffffff`}},setup(e,{expose:t}){let n=e,{args:r,color:i}=_n(n),{invalidate:a}=nn();K(r,()=>a());let o=dn();return t({instance:o}),(e,t)=>(U(),V(`TresMesh`,Kt({ref_key:`torusRef`,ref:o},e.$attrs),[B(`TresTorusGeometry`,{args:G(r)},null,8,MA),sn(e.$slots,`default`,{},()=>[B(`TresMeshBasicMaterial`,{color:G(i)},null,8,NA)])],16))}}),FA=[`args`],IA=[`color`],LA=H({__name:`TorusKnot`,props:{args:{default:()=>[1,.4,64,8]},color:{default:`#ffffff`}},setup(e,{expose:t}){let n=e,{args:r,color:i}=_n(n),{invalidate:a}=nn();K(r,()=>a());let o=dn();return t({instance:o}),(e,t)=>(U(),V(`TresMesh`,Kt({ref_key:`torusKnotRef`,ref:o},e.$attrs),[B(`TresTorusKnotGeometry`,{args:G(r)},null,8,FA),sn(e.$slots,`default`,{},()=>[B(`TresMeshBasicMaterial`,{color:G(i)},null,8,IA)])],16))}}),RA=[`args`],zA=[`color`],BA=H({__name:`Tube`,props:{args:{default:()=>[new ze(new z(-1,0,0),new z(0,1,0),new z(1,0,0)),20,.2,8,!1]},color:{default:`#ffffff`}},setup(e,{expose:t}){let n=e,{args:r,color:i}=_n(n),{invalidate:a}=nn();K(r,()=>a());let o=dn();return t({instance:o}),(e,t)=>(U(),V(`TresMesh`,Kt({ref_key:`tubeRef`,ref:o},e.$attrs),[B(`TresTubeGeometry`,{args:G(r)},null,8,RA),sn(e.$slots,`default`,{},()=>[B(`TresMeshBasicMaterial`,{color:G(i)},null,8,zA)])],16))}}),VA=H({__name:`Align`,props:{top:{type:Boolean},right:{type:Boolean},bottom:{type:Boolean},left:{type:Boolean},front:{type:Boolean},back:{type:Boolean},disable:{type:Boolean},disableX:{type:Boolean},disableY:{type:Boolean},disableZ:{type:Boolean},precise:{type:Boolean,default:!0},onAlign:{},cacheKey:{default:void 0}},setup(e,{expose:t}){let n=e,r=dn(),i=dn(),a=dn(),o=new l,s=new z,c=new nt;function u(){if(!i.value||!a.value||!r.value)return;i.value.matrixWorld.identity(),o.setFromObject(a.value,n.precise);let e=o.max.x-o.min.x,t=o.max.y-o.min.y,l=o.max.z-o.min.z;o.getCenter(s),o.getBoundingSphere(c);let u=n.top?t/2:n.bottom?-t/2:0,d=n.left?-e/2:n.right?e/2:0,f=n.front?l/2:n.back?-l/2:0;i.value.position.set(n.disable||n.disableX?0:-s.x+d,n.disable||n.disableY?0:-s.y+u,n.disable||n.disableZ?0:-s.z+f),typeof n.onAlign<`u`&&n.onAlign({parent:r.value.parent,container:r.value,width:e,height:t,depth:l,boundingBox:o,boundingSphere:c,center:s,verticalAlignment:u,horizontalAlignment:d,depthAlignment:f})}let d=null,f=null,p=Ht();return Fn(()=>{d?.(),d=null;let e=vn(n.cacheKey);e===f&&f!=null||(f=e,n.cacheKey===null||n.cacheKey===void 0?d=p.onBeforeRender(()=>{u()}).off:u())}),t({instance:r,update:u}),(e,t)=>(U(),V(`TresGroup`,{ref_key:`ref`,ref:r},[B(`TresGroup`,{ref_key:`outer`,ref:i},[B(`TresGroup`,{ref_key:`inner`,ref:a},[sn(e.$slots,`default`)],512)],512)],512))}}),HA=[`receive-shadow`,`rotation`],UA=[`args`],WA=H({__name:`Backdrop`,props:{floor:{default:.25},segments:{default:20},receiveShadow:{type:Boolean,default:!1}},setup(e,{expose:t}){let n=e,r=e=>e===0?0:2**(10*e-10),{floor:i,segments:a,receiveShadow:o}=_n(n),s=W(null);K([a,i,s],([e,t,n])=>{if(!n||e===null)return;let i=0,a=e/e/2,o=n.attributes.position;for(let n=0;n(U(),V(`TresGroup`,Kt({ref_key:`backdropRef`,ref:c},e.$attrs),[B(`TresMesh`,{"receive-shadow":G(o),rotation:[-Math.PI/2,0,Math.PI/2]},[B(`TresPlaneGeometry`,{ref_key:`planeRef`,ref:s,args:[1,1,G(a),G(a)]},null,8,UA),sn(e.$slots,`default`,{},()=>[t[0]||=B(`TresMeshStandardMaterial`,{color:8421504,side:2},null,-1)])],8,HA)],16))}}),GA=[`object`],KA=H({__name:`ContactShadows`,props:{opacity:{default:1},blur:{default:1},color:{default:`#000000`},tint:{default:void 0},scale:{default:10},width:{default:1},height:{default:1},far:{default:10},smooth:{type:Boolean,default:!0},resolution:{default:512},frames:{default:1/0},depthWrite:{type:Boolean,default:!1}},setup(e,{expose:t}){let n=e;function r(e,t,n){n.blurPlane.visible=!0,n.blurPlane.material=n.horizontalBlurMaterial,n.horizontalBlurMaterial.uniforms.tDiffuse.value=n.renderTarget.texture,n.horizontalBlurMaterial.uniforms.h.value=e/256,t.setRenderTarget(n.renderTargetBlur),t.render(n.blurPlane,n.shadowCamera),n.blurPlane.material=n.verticalBlurMaterial,n.verticalBlurMaterial.uniforms.tDiffuse.value=n.renderTargetBlur.texture,n.verticalBlurMaterial.uniforms.v.value=e/256,t.setRenderTarget(n.renderTarget),t.render(n.blurPlane,n.shadowCamera),n.blurPlane.visible=!1}function i(e,t,n,i){let{renderTarget:a,shadowCamera:o,depthMaterial:s}=i,c=t.background;t.background=null,t.overrideMaterial=s;let l=n.getClearAlpha();n.setClearAlpha(0),n.setRenderTarget(a),n.render(t,o),t.overrideMaterial=null,r(e.blur,n,i),e.smooth&&r(e.blur*.4,n,i),n.setRenderTarget(null),n.setClearAlpha(l),t.background=c}function a(e){let t=new I,n=new vt(e.resolution,e.resolution);n.texture.generateMipmaps=!1;let r=new vt(e.resolution,e.resolution);r.texture.generateMipmaps=!1;let i=new Ie(e.width,e.height).rotateX(Math.PI/2),a=new xe({map:n.texture,opacity:e.opacity,transparent:!0,depthWrite:e.depthWrite,color:new h(e.color??`black`)}),o=new be(i,a);t.add(o),o.scale.y=-1;let s=new be(i);s.visible=!1,t.add(s);let c=new Me(-e.width/2,e.width/2,e.height/2,-e.height/2,0,.3);c.rotation.x=Math.PI/2,t.add(c);let l=new Se,u=new Xe(Aw);u.depthTest=!1;let d=new Xe(jw);return d.depthTest=!1,{renderTarget:n,renderTargetBlur:r,shadowCamera:c,depthMaterial:l,horizontalBlurMaterial:u,verticalBlurMaterial:d,shadowGroup:t,plane:o,blurPlane:s}}function o(e,t){let n=t.shadowCamera;n.left=-e.width/2,n.right=e.width/2,n.top=e.height/2,n.bottom=-e.height/2,n.far=e.far;let r=e.width*(Array.isArray(e.scale)?e.scale[0]:e.scale||1),i=e.height*(Array.isArray(e.scale)?e.scale[1]:e.scale||1);t.shadowGroup.scale.set(r,e.far,i)}function s(e,t){t.renderTarget.dispose(),t.renderTargetBlur.dispose(),t.renderTarget=new vt(e,e),t.renderTarget.texture.generateMipmaps=!1,t.renderTargetBlur=new vt(e,e),t.renderTargetBlur.texture.generateMipmaps=!1,t.plane.material.map=t.renderTarget.texture}function c(e,t){t.plane.material.color=new h(e.color??`black`),t.depthMaterial.dispose(),t.depthMaterial=new Se,t.depthMaterial.onBeforeCompile=function(t){let n=e.tint?new h(e.tint):new h(`white`),{r,g:i,b:a}=n,o=t.fragmentShader.replace(`gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );`,`gl_FragColor = vec4( ${r}, ${i}, ${a}, ( 1.0 - fragCoordZ ) * opacity);`);t.fragmentShader=o}}let{onBeforeRender:l}=Ht(),u=a(n),d=0,f=()=>d=d>=n.frames?n.frames-1:d;return l(({renderer:e,scene:t,invalidate:r})=>{d[n.opacity,n.depthWrite,n.blur,n.smooth],()=>{u.plane.material.opacity=n.opacity??1,u.plane.material.depthWrite=n.depthWrite??!1,f()},{immediate:!0}),K(()=>[n.color,n.tint],()=>{c(n,u),f()},{immediate:!0}),K(()=>[n.resolution],()=>{s(n.resolution,u),f()}),K(()=>[n.width,n.height,n.scale,n.far],()=>{o(n,u),f()},{immediate:!0}),tn(()=>{for(let e of Object.values(u))e&&`dispose`in e&&typeof e.dispose==`function`&&e.dispose()}),t({instance:u.shadowGroup}),(e,t)=>(U(),V(`primitive`,{object:G(u).shadowGroup},null,8,GA))}}),qA=H({__name:`Fit`,props:{into:{default:()=>new l(new z(-.5,-.5,-.5),new z(.5,.5,.5))},precise:{type:Boolean,default:!1}},setup(e,{expose:t}){let n=e,{invalidate:r}=nn(),i=dn(new I),a=dn(new I);function o(e,t){if(i.value.position.set(0,0,0),i.value.updateMatrixWorld(),a.value.scale.set(1,1,1),a.value.updateMatrixWorld(),!a.value.children.length||e===null)return;let{box3:n,use:o}=s(e,t),c=new l;a.value.children.forEach(e=>c.expandByObject(e,t));let u=c.getSize(new z),d=n.getSize(new z),f=Math.min(d.x/u.x,d.y/u.y,d.z/u.z);a.value.scale.setScalar(f===1/0?1:f),a.value.updateMatrixWorld();let p=i.value.worldToLocal(c.getCenter(new z));if(o.position){let e=i.value.worldToLocal(n.getCenter(new z));i.value.position.copy(e.sub(p.multiplyScalar(f)))}else i.value.position.copy(p.sub(p.multiplyScalar(f)));r()}function s(e,t){return typeof e==`number`?e=new z(e,e,e):Array.isArray(e)&&(e=new z(...e)),e&&`isVector3`in e&&e.isVector3?{box3:new l(new z(0,0,0),e),use:{position:!1}}:e&&`isBox3`in e&&e.isBox3?{box3:e,use:{position:!0}}:e&&`isObject3D`in e&&e.isObject3D?{box3:new l().setFromObject(e,t??!1),use:{position:!0}}:{box3:new l(new z(-.5,-.5,-.5),new z(.5,.5,.5)),use:{position:!0}}}K(()=>[n.into,n.precise],()=>o(n.into,n.precise)),$t(()=>{o(n.into,n.precise),qt().then(()=>{o(n.into,n.precise)})});let c=dn();return t({instance:c,fit:(e=new l(new z(-.5,-.5,-.5),new z(.5,.5,.5)),t=!1)=>{o(e,t)},update:()=>o(n.into,n.precise)}),(e,t)=>(U(),V(`TresGroup`,{ref_key:`outer`,ref:c},[B(`TresGroup`,{ref_key:`middle`,ref:i},[B(`TresGroup`,{ref_key:`inner`,ref:a},[sn(e.$slots,`default`)],512)],512)],512))}}),JA=[`side`,`cell-size`,`section-size`,`cell-color`,`section-color`,`cell-thickness`,`section-thickness`,`fade-distance`,`fade-strength`,`fade-from`,`infinite-grid`,`follow-camera`],YA=[`args`],XA=H({__name:`Grid`,props:{cellSize:{default:.5},cellThickness:{default:.5},cellColor:{default:`#000000`},sectionSize:{default:1},sectionThickness:{default:1},sectionColor:{default:`#0000ff`},followCamera:{type:Boolean,default:!1},infiniteGrid:{type:Boolean,default:!1},fadeDistance:{default:100},fadeStrength:{default:1},fadeFrom:{default:1},side:{default:s},args:{}},setup(e){let t=e,n=Jx({cellSize:.5,sectionSize:1,fadeDistance:100,fadeStrength:1,fadeFrom:1,cellThickness:.5,sectionThickness:1,cellColor:new h,sectionColor:new h,infiniteGrid:!1,followCamera:!1,worldCamProjPosition:new z,worldPlanePosition:new z},` + varying vec3 localPosition; + varying vec4 worldPosition; + + uniform vec3 worldCamProjPosition; + uniform vec3 worldPlanePosition; + uniform float fadeDistance; + uniform bool infiniteGrid; + uniform bool followCamera; + + void main() { + localPosition = position.xzy; + if (infiniteGrid) localPosition *= 1.0 + fadeDistance; + + worldPosition = modelMatrix * vec4(localPosition, 1.0); + if (followCamera) { + worldPosition.xyz += (worldCamProjPosition - worldPlanePosition); + localPosition = (inverse(modelMatrix) * worldPosition).xyz; + } + + gl_Position = projectionMatrix * viewMatrix * worldPosition; + } + `,` + varying vec3 localPosition; + varying vec4 worldPosition; + + uniform vec3 worldCamProjPosition; + uniform float cellSize; + uniform float sectionSize; + uniform vec3 cellColor; + uniform vec3 sectionColor; + uniform float fadeDistance; + uniform float fadeStrength; + uniform float fadeFrom; + uniform float cellThickness; + uniform float sectionThickness; + + float getGrid(float size, float thickness) { + vec2 r = localPosition.xz / size; + vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r); + float line = min(grid.x, grid.y) + 1.0 - thickness; + return 1.0 - min(line, 1.0); + } + + void main() { + float g1 = getGrid(cellSize, cellThickness); + float g2 = getGrid(sectionSize, sectionThickness); + + vec3 from = worldCamProjPosition*vec3(fadeFrom); + float dist = distance(from, worldPosition.xyz); + float d = 1.0 - min(dist / fadeDistance, 1.0); + vec3 color = mix(cellColor, sectionColor, min(1.0, sectionThickness * g2)); + + gl_FragColor = vec4(color, (g1 + g2) * pow(d, fadeStrength)); + gl_FragColor.a = mix(0.75 * gl_FragColor.a, gl_FragColor.a, g2); + if (gl_FragColor.a <= 0.0) discard; + + #include + #include + } + `);D({GridMaterial:n});let r=dn(new be),i=new Fe,a=new z(0,1,0),o=new z(0,0,0);return Ht().onBeforeRender(e=>{i.setFromNormalAndCoplanarPoint(a,o).applyMatrix4(r.value.matrixWorld);let t=r.value.material,n=t.uniforms.worldCamProjPosition,s=t.uniforms.worldPlanePosition;i.projectPoint(e.camera.position,n.value),s.value.set(0,0,0).applyMatrix4(r.value.matrixWorld)}),(e,n)=>(U(),V(`TresMesh`,{ref_key:`ref`,ref:r,"frustum-culled":!1},[B(`TresGridMaterial`,{transparent:!0,"extensions-derivatives":!0,side:t.side,"cell-size":t.cellSize,"section-size":t.sectionSize,"cell-color":t.cellColor,"section-color":t.sectionColor,"cell-thickness":t.cellThickness,"section-thickness":t.sectionThickness,"fade-distance":t.fadeDistance,"fade-strength":t.fadeStrength,"fade-from":t.fadeFrom,"infinite-grid":t.infiniteGrid,"follow-camera":t.followCamera},null,8,JA),B(`TresPlaneGeometry`,{args:t.args},null,8,YA)],512))}}),ZA=[`rotation-x`,`args`],QA=H({__name:`Ocean`,props:{textureWidth:{default:512},textureHeight:{default:512},waterNormals:{default:`https://raw.githubusercontent.com/Tresjs/assets/main/textures/water-normals/Water_1_M_Normal.jpg`},sunDirection:{default:()=>new z},sunColor:{default:16777215},waterColor:{default:7695},distortionScale:{default:3.7},size:{default:1},clipBias:{default:0},alpha:{default:1},side:{default:F}},async setup(e,{expose:t}){let n,r,i=e,{textureWidth:a,textureHeight:o,waterNormals:s,sunDirection:c,sunColor:l,waterColor:u,distortionScale:d,size:f,clipBias:p,alpha:m,side:h}=_n(i),{extend:g,scene:_}=nn();g({Water:FC});let v=dn(),y=dn(),b=_.value.fog!==void 0;t({instance:v}),_.value.traverse(e=>{Object.prototype.hasOwnProperty.call(e,`isSky`)&&(y.value=e)}),$t(async()=>{if(await qt(),y.value){let e=y.value.material.uniforms.sunPosition.value;v.value.material.uniforms.sunDirection.value.copy(e)}});let{normalMap:x}=([n,r]=In(()=>Ft({normalMap:s.value})),n=await n,r(),n);x.wrapS=x.wrapT=Ke;let{onBeforeRender:S}=Ht();return S(({delta:e,invalidate:t})=>{v.value.material.uniforms.time.value+=e,t()}),(e,t)=>(U(),V(`TresWater`,{ref_key:`waterRef`,ref:v,"rotation-x":-Math.PI/2,args:[void 0,{textureWidth:G(a),textureHeight:G(o),waterNormals:G(x),sunDirection:G(c),sunColor:G(l),waterColor:G(u),distortionScale:G(d),fog:b,size:G(f),clipBias:G(p),alpha:G(m),side:G(h)}]},[sn(e.$slots,`default`,{},()=>[t[0]||=B(`TresPlaneGeometry`,{args:[1e4,1e4]},null,-1)])],8,ZA))}}),$A=[`size`,`color`,`alpha-map`,`map`,`opacity`,`alpha-test`,`depth-write`,`transparent`,`size-attenuation`],ej=[`position`,`velocity`],tj=H({__name:`Precipitation`,props:{size:{default:.1},area:{default:()=>[10,10,20]},color:{default:16777215},map:{},alphaMap:{},alphaTest:{default:.01},opacity:{default:.8},count:{default:5e3},speed:{default:.1},randomness:{default:.5},depthWrite:{type:Boolean,default:!1},transparent:{type:Boolean,default:!0},sizeAttenuation:{type:Boolean,default:!0}},setup(e,{expose:t}){let n=e,{size:r,area:i,color:a,alphaMap:o,map:s,opacity:c,alphaTest:l,depthWrite:u,transparent:d,sizeAttenuation:f,count:p,speed:m,randomness:h}=_n(n),g=dn(),_=[],v=[],y=()=>{_=new Float32Array(p.value*3);for(let e=0;e{v=new Float32Array(p.value*2);for(let e=0;e{b(),y()});let x=dn(null),S=dn(null);Fn(async()=>{Fn(async()=>{if(typeof o.value==`string`){let e=await Ft({alphaMap:o.value});x.value=e.alphaMap}else x.value=o.value??null;if(typeof s.value==`string`){let e=await Ft({map:s.value});S.value=e.map}else S.value=s.value??null})});let{onBeforeRender:C}=Ht();C(({invalidate:e})=>{var t,n;if((t=g.value)!=null&&t.attributes.position.array&&(n=g.value)!=null&&n.attributes.position.count){let t=g.value.attributes.position.array;for(let e=0;e=i.value[0]/2)&&(t[e*3]=t[e*3]*-1),(t[e*3+1]<=-i.value[1]/2||t[e*3+1]>=i.value[1]/2)&&(t[e*3+1]=t[e*3+1]*-1)}g.value.attributes.position.needsUpdate=!0,e()}});let w=dn();return t({instance:w}),(e,t)=>(U(),V(`TresPoints`,{ref_key:`pointsRef`,ref:w},[B(`TresPointsMaterial`,{size:G(r),color:G(a),"alpha-map":x.value,map:S.value,opacity:G(c),"alpha-test":G(l),"depth-write":G(u),transparent:G(d),"size-attenuation":G(f)},null,8,$A),B(`TresBufferGeometry`,{ref_key:`geometryRef`,ref:g,position:[G(_),3],velocity:[G(v)]},null,8,ej)],512))}}),nj=[`object`,`material-uniforms-turbidity-value`,`material-uniforms-rayleigh-value`,`material-uniforms-mieCoefficient-value`,`material-uniforms-mieDirectionalG-value`,`material-uniforms-sunPosition-value`,`scale`],rj=H({__name:`Sky`,props:{turbidity:{default:3.4},rayleigh:{default:3},mieCoefficient:{default:.005},mieDirectionalG:{default:.7},elevation:{default:.6},azimuth:{default:180},distance:{default:45e4}},setup(e,{expose:t}){let n=e,{invalidate:r}=nn();K(n,()=>r());let i=dn(),a=new VC,o=kt(()=>s(n.azimuth,n.elevation));function s(e,t){let n=_e.degToRad(90-t),r=_e.degToRad(e);return new z().setFromSphericalCoords(1,n,r)}return t({instance:i,sunPosition:o.value}),(e,t)=>(U(),V(`primitive`,{ref_key:`skyRef`,ref:i,object:G(a),"material-uniforms-turbidity-value":n.turbidity,"material-uniforms-rayleigh-value":n.rayleigh,"material-uniforms-mieCoefficient-value":n.mieCoefficient,"material-uniforms-mieDirectionalG-value":n.mieDirectionalG,"material-uniforms-sunPosition-value":o.value,scale:n.distance},null,8,nj))}}),ij=[`position`],aj=[`position`],oj=[`scale`],sj=[`map`,`depth-test`,`color-space`,`color`,`opacity`],cj=H({__name:`Smoke`,props:{color:{default:`#ffffff`},opacity:{default:.5},speed:{default:.4},width:{default:10},depth:{default:1.5},segments:{default:20},texture:{default:`https://raw.githubusercontent.com/Tresjs/assets/main/textures/clouds/defaultCloud.png`},depthTest:{type:Boolean,default:!0}},async setup(e,{expose:t}){let n,r,i=e,{width:a,depth:o,segments:s,texture:c,color:l,depthTest:u,opacity:d,speed:f}=_n(i),p=dn(),m=dn();t({instance:p});let h=[s].map((e,t)=>({x:a.value/2-Math.random()*a.value,y:a.value/2-Math.random()*a.value,scale:.4+Math.sin((t+1)/s.value*Math.PI)*((.2+Math.random())*10),density:Math.max(.2,Math.random()),rotation:Math.max(.002,.005*Math.random())*f.value})),g=(e,t)=>e/6*t*d.value,{map:_}=([n,r]=In(()=>Ft({map:c.value})),n=await n,r(),n),{renderer:v,camera:y}=nn(),b=kt(()=>{var e;return(e=v.value)?.outputColorSpace}),{onBeforeRender:x}=Ht();return x(({invalidate:e})=>{var t,n;p.value&&y.value&&m.value&&((t=m.value)==null||t.children.forEach((e,t)=>{e.rotation.z+=h[t].rotation}),p.value.lookAt((n=y.value)?.position),e())}),(e,t)=>(U(),V(`TresGroup`,Kt({ref_key:`smokeRef`,ref:p},e.$attrs),[B(`TresGroup`,{ref_key:`groupRef`,ref:m,position:[0,0,G(s)/2*G(o)]},[(U(!0),V(P,null,on(G(h),({scale:e,x:t,y:n,density:r},i)=>(U(),V(`TresMesh`,{key:`${i}`,position:[t,n,-i*G(o)]},[B(`TresPlaneGeometry`,{scale:[e,e,e],rotation:[0,0,0]},null,8,oj),B(`TresMeshStandardMaterial`,{map:G(_),"depth-test":G(u),"color-space":b.value,color:G(l),"depth-write":!1,transparent:``,opacity:g(e,r)},null,8,sj)],8,aj))),128))],8,ij)],16))}}),lj=` +return PCSS( shadowMap, shadowCoord ); +`,uj=H({__name:`SoftShadows`,props:{size:{default:25},samples:{default:10},focus:{default:0}},setup(e){let t=e,n=({focus:e=0,size:t=25,samples:n=10}={})=>` +#define PENUMBRA_FILTER_SIZE float(${t}) +#define RGB_NOISE_FUNCTION(uv) (randRGB(uv)) +vec3 randRGB(vec2 uv) { + return vec3( + fract(sin(dot(uv, vec2(12.75613, 38.12123))) * 13234.76575), + fract(sin(dot(uv, vec2(19.45531, 58.46547))) * 43678.23431), + fract(sin(dot(uv, vec2(23.67817, 78.23121))) * 93567.23423) + ); +} + +vec3 lowPassRandRGB(vec2 uv) { + // 3x3 convolution (average) + // can be implemented as separable with an extra buffer for a total of 6 samples instead of 9 + vec3 result = vec3(0); + result += RGB_NOISE_FUNCTION(uv + vec2(-1.0, -1.0)); + result += RGB_NOISE_FUNCTION(uv + vec2(-1.0, 0.0)); + result += RGB_NOISE_FUNCTION(uv + vec2(-1.0, +1.0)); + result += RGB_NOISE_FUNCTION(uv + vec2( 0.0, -1.0)); + result += RGB_NOISE_FUNCTION(uv + vec2( 0.0, 0.0)); + result += RGB_NOISE_FUNCTION(uv + vec2( 0.0, +1.0)); + result += RGB_NOISE_FUNCTION(uv + vec2(+1.0, -1.0)); + result += RGB_NOISE_FUNCTION(uv + vec2(+1.0, 0.0)); + result += RGB_NOISE_FUNCTION(uv + vec2(+1.0, +1.0)); + result *= 0.111111111; // 1.0 / 9.0 + return result; +} +vec3 highPassRandRGB(vec2 uv) { + // by subtracting the low-pass signal from the original signal, we're being left with the high-pass signal + // hp(x) = x - lp(x) + return RGB_NOISE_FUNCTION(uv) - lowPassRandRGB(uv) + 0.5; +} + + +vec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) { + const float goldenAngle = 2.399963f; // radians + float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount)); + float theta = float(sampleIndex) * goldenAngle + angle; + float sine = sin(theta); + float cosine = cos(theta); + return vec2(cosine, sine) * r; +} +float penumbraSize( const in float zReceiver, const in float zBlocker ) { // Parallel plane estimation + return (zReceiver - zBlocker) / zBlocker; +} +float findBlocker(sampler2D shadowMap, vec2 uv, float compare, float angle) { + float texelSize = 1.0 / float(textureSize(shadowMap, 0).x); + float blockerDepthSum = float(${e}); + float blockers = 0.0; + + int j = 0; + vec2 offset = vec2(0.); + float depth = 0.; + + #pragma unroll_loop_start + for(int i = 0; i < ${n}; i ++) { + offset = (vogelDiskSample(j, ${n}, angle) * texelSize) * 2.0 * PENUMBRA_FILTER_SIZE; + depth = unpackRGBAToDepth( texture2D( shadowMap, uv + offset)); + if (depth < compare) { + blockerDepthSum += depth; + blockers++; + } + j++; + } + #pragma unroll_loop_end + + if (blockers > 0.0) { + return blockerDepthSum / blockers; + } + return -1.0; +} + + +float vogelFilter(sampler2D shadowMap, vec2 uv, float zReceiver, float filterRadius, float angle) { + float texelSize = 1.0 / float(textureSize(shadowMap, 0).x); + float shadow = 0.0f; + int j = 0; + vec2 vogelSample = vec2(0.0); + vec2 offset = vec2(0.0); + #pragma unroll_loop_start + for (int i = 0; i < ${n}; i++) { + vogelSample = vogelDiskSample(j, ${n}, angle) * texelSize; + offset = vogelSample * (1.0 + filterRadius * float(${t})); + shadow += step( zReceiver, unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ) ); + j++; + } + #pragma unroll_loop_end + return shadow * 1.0 / ${n}.0; +} + +float PCSS (sampler2D shadowMap, vec4 coords) { + vec2 uv = coords.xy; + float zReceiver = coords.z; // Assumed to be eye-space z in this code + float angle = highPassRandRGB(gl_FragCoord.xy).r * PI2; + float avgBlockerDepth = findBlocker(shadowMap, uv, zReceiver, angle); + if (avgBlockerDepth == -1.0) { + return 1.0; + } + float penumbraRatio = penumbraSize(zReceiver, avgBlockerDepth); + return vogelFilter(shadowMap, uv, zReceiver, 1.25 * penumbraRatio, angle); +}`,r=Ye.shadowmap_pars_fragment,{renderer:i,scene:a,camera:o}=fn();function s(e,t){let i=r;i=i.replace(`#ifdef USE_SHADOWMAP`,`#ifdef USE_SHADOWMAP + ${n(t)}`),i=i.replace(`#if defined( SHADOWMAP_TYPE_PCF )`,`${lj} + #if defined( SHADOWMAP_TYPE_PCF )`),Ye.shadowmap_pars_fragment=i,e.shadowMap.enabled=!0}function c(e,t,n){t.traverse(t=>{var n,r;`material`in t&&t.material&&(e.properties.remove(t.material),typeof t.material==`object`&&`dispose`in t.material&&typeof t.material.dispose==`function`&&((r=(n=t.material).dispose)==null||r.call(n)))}),e.info.programs&&(e.info.programs.length=0),e.compile(t,n)}return tn(()=>{o.value&&(Ye.shadowmap_pars_fragment=r,c(i.value,a.value,o.value))}),K(t,()=>{o.value&&(s(i.value,t),c(i.value,a.value,o.value))},{immediate:!0}),(e,t)=>(U(),V(`TresGroup`))}});var dj=class extends Ae{constructor(){super(),dx(this,`virtualScene`,null),this.virtualScene=new Je}add(...e){return this.virtualScene.add(...e),this}dispose(){this.virtualScene.traverse(e=>{e instanceof be&&(e.geometry.dispose(),e.material.dispose(),e.material.map&&e.material.map.dispose(),this.virtualScene.remove(e))}),this.virtualScene=null}};const fj=H({__name:`component`,props:{background:{type:[Boolean,String],default:!1},blur:{default:0},files:{default:()=>[]},path:{default:``},preset:{default:void 0},resolution:{default:256},near:{default:1},far:{default:1e3},frames:{default:1/0},backgroundIntensity:{default:1},backgroundRotation:{},environmentIntensity:{default:1},environmentRotation:{},syncMaterials:{type:Boolean}},async setup(e,{expose:t}){let n,r,i=e,a=W(null);t({texture:a});let{extend:o,renderer:c,scene:l}=nn();o({EnvironmentScene:dj});let d=null,f=W(null),p=null,m=W(null),h=([n,r]=In(()=>DE(i,f)),n=await n,r(),n),{onBeforeRender:g}=Ht(),v=1;g(()=>{if(p&&m.value&&f.value&&(i.frames===1/0||v{if(e&&t!=null&&t.virtualScene){let n=hn(t).virtualScene,r=n.children.find(e=>e instanceof be&&e.userData.isEnvironment);r||(r=new be(new u(1,1,1),new xe({side:s})),r.userData.isEnvironment=!0,n.add(r)),n.background=e,n.backgroundBlurriness=i.blur}},{immediate:!0});let y=e=>{e&&d!=null&&d.length?(l.value.environment=e.texture,i.background&&(l.value.background=e.texture)):h.value&&(l.value.environment=h.value,i.background&&(l.value.background=h.value))};return K(h,()=>{f.value&&y(f.value)},{immediate:!0,deep:!0}),K(()=>On().default,e=>{var t;if(e&&(d=e(),Array.isArray(d)&&d.length>0)){o({EnvironmentScene:dj}),f.value=new _t(i.resolution),f.value.texture.type=te,p=new _(i.near,i.far,f.value),y(f.value);return}(t=f.value)==null||t.dispose(),f.value=null,y()},{immediate:!0,deep:!0}),a.value=h.value,tn(()=>{var e,t;(e=m.value)==null||e.dispose(),(t=f.value)==null||t.dispose()}),(e,t)=>f.value?(U(),V(`TresEnvironmentScene`,{key:0,ref_key:`environmentScene`,ref:m},[sn(e.$slots,`default`)],512)):jt(``,!0)}}),pj={key:0,args:[0,1,64]},mj={key:1,args:[.5,1,64]},hj={key:2},gj=[`tone-mapped`,`map`,`side`,`color`],_j=H({__name:`index`,props:{args:{default:null},form:{default:`rect`},toneMapped:{type:Boolean,default:!1},map:{default:null},intensity:{default:1},color:{default:new h(16777215)}},setup(e,{expose:t}){let n=e,r=W(),i=W();return Fn(()=>{r.value&&(r.value.color.copy(new h(n.color)),r.value.color.multiplyScalar(n.intensity),r.value.needsUpdate=!0)}),t({mesh:i}),(e,t)=>(U(),V(`TresMesh`,{ref_key:`mesh`,ref:i},[e.form===`circle`?(U(),V(`TresRingGeometry`,pj)):e.form===`ring`?(U(),V(`TresRingGeometry`,mj)):e.form===`rect`?(U(),V(`TresPlaneGeometry`,hj)):(U(),At(n.form,{key:3,args:e.args},null,8,[`args`])),B(`TresMeshBasicMaterial`,{ref_key:`material`,ref:r,"tone-mapped":e.toneMapped,map:e.map,side:G(T),color:e.color},null,8,gj)],512))}});var vj=H({__name:`Range`,props:{modelValue:null,min:{default:0},max:{default:100},step:{default:1},disabled:{type:Boolean,default:!1}},emits:[`update:modelValue`,`mousedown`],setup(e,{emit:t}){let n=e,r=t,i=W(null);function a(e,t,n){return Math.min(Math.max(e,t),n)}function o(e){let t=e.toString();if(t.includes(`e-`))return Number.parseInt(t.split(`e-`)[1],10);let n=t.includes(`.`)?t.split(`.`)[1].length:0;return n}function s(e,t){let n=o(t),r=10**(n+3);return Number.parseFloat((e*r/r).toFixed(n))}let c=kt(()=>s(a(n.modelValue,n.min,n.max),n.step)),l=kt(()=>{let e=(c.value-n.min)/(n.max-n.min)*100;return{width:`${e}%`,backgroundSize:`${e}% 100%`}});function u(e){if(!i.value)return c.value;let t=i.value.getBoundingClientRect(),r=e.clientX-t.left,a=r/t.width,o=n.max-n.min,s=n.min+o*a,l=Math.round(s/n.step)*n.step;return Math.min(Math.max(l,n.min),n.max)}function d(e){if(n.disabled)return;let t=u(e);r(`update:modelValue`,t)}function f(e){if(n.disabled)return;e.preventDefault();let t=u(e);r(`update:modelValue`,t),window.addEventListener(`mousemove`,d),window.addEventListener(`mouseup`,p)}function p(e){window.removeEventListener(`mousemove`,d),window.removeEventListener(`mouseup`,p)}return tn(()=>{window.removeEventListener(`mousemove`,d),window.removeEventListener(`mouseup`,p)}),(t,n)=>(U(),V(`span`,{ref_key:`sliderRef`,ref:i,class:Jt([`range-slider disabled:pointer-events-none disabled:cursor-default disabled:opacity-50`,{disabled:e.disabled}]),bg:`[#e6e1fc] dark:[#676085]`,"touch-action-none":``,relative:``,"inline-block":``,"w-full":``,"cursor-ew-resize":``,"rounded-sm":``,onMousedown:f},[B(`span`,{style:Xt(l.value),bg:`[#cabeff] dark:[#4e34b9]`,relative:``,block:``,"rounded-sm":``,h:`[14px]`},null,4),B(`span`,{role:`slider`,class:`slider-thumb`,style:Xt({left:`${(c.value-e.min)/(e.max-e.min)*100}%`}),absolute:``,"rounded-sm":``,w:`[1px]`,h:`[14px]`,bg:`neutral-100 dark:neutral-400`,top:`50%`,transform:`translate-x-[50%] translate-y-[-50%]`},null,4)],34))}}),yj=vj,bj=H({__name:`Model`,props:{model:null,idleAnimation:null,loadAnimations:null,position:null,paused:{type:Boolean}},emits:[`loadModelProgress`,`error`],setup(e,{expose:t,emit:n}){let i=e,a=n,o,s=W(),c=W(),{scene:l}=nn(),{onBeforeRender:u}=Ht(),d=mr(),f=hr(),p=W();K(()=>i.position,([e,t,n])=>{s.value&&s.value.scene.position.set(e,t,n)}),$t(async()=>{if(l.value)try{let e=await dr(i.model,{scene:l.value,lookAt:!0,position:i.position,onProgress:e=>a(`loadModelProgress`,Number.parseFloat((100*(e.loaded/e.total)).toFixed(2)))});if(!e){console.warn(`No VRM model loaded`);return}let t=await ur(i.idleAnimation),n=await cr(e,t);if(!n){console.warn(`No VRM animation loaded`);return}c.value=new r(e.scene),c.value.clipAction(n).play(),p.value=_r(e),s.value=e,o=u(({delta:e})=>{var t,n,r;(t=c.value)?.update(e),(n=s.value)?.update(e),d.update(s.value,e),f.update(s.value,e),(r=p.value)?.update(e)}).off}catch(e){a(`error`,e)}}),tn(()=>{o?.(),s.value&&(s.value.scene.removeFromParent(),sr.deepDispose(s.value.scene))}),t({setExpression(e){var t;(t=p.value)?.setEmotionWithResetAfter(e,1e3)}});let{pause:m,resume:h}=Ht();return K(()=>i.paused,e=>{e?m():h()}),(e,t)=>sn(e.$slots,`default`)}}),xj=bj;const Sj=[`position`],Cj={absolute:``,bottom:`3`,right:`3`},wj={flex:`~ row`,"cursor-pointer":``},Tj=[`checked`,`aria-checked`],Ej={key:0,"min-w":`50vw`,z:`{var t;(t=f.value)?.setExpression(e)}}),(e,t)=>(U(),At(Kb,{relative:``},{default:Ln(({height:e,width:n})=>[Nt(G(gt),{alpha:!0,antialias:!0,width:n,height:e},{default:Ln(()=>[Nt(G(jD)),B(`TresPerspectiveCamera`,{position:[o.value,s.value,c.value]},null,8,Sj),t[14]||=B(`TresDirectionalLight`,{color:16777215,intensity:1.2,position:[1,1,1]},null,-1),t[15]||=B(`TresAmbientLight`,{color:16777215,intensity:1.5},null,-1),Nt(xj,{ref_key:`modelRef`,ref:f,model:r.model,"idle-animation":r.idleAnimation,position:[l.value,u.value,d.value],paused:r.paused,onLoadModelProgress:t[0]||=e=>i(`loadModelProgress`,e),onError:t[1]||=e=>i(`error`,e)},null,8,[`model`,`idle-animation`,`position`,`paused`])]),_:2,__:[14,15]},1032,[`width`,`height`]),B(`div`,Cj,[B(`div`,wj,[B(`label`,{class:Jt([a.value?`bg-neutral-300 dark:bg-neutral-200`:`bg-neutral-100 dark:bg-neutral-700`]),transition:`all ease-in-out duration-500`,text:`lg neutral-500 dark:neutral-400`,"m-1":``,"h-fit":``,"w-fit":``,"cursor-pointer":``,"appearance-none":``,"gap-1":``,"rounded-lg":``,"rounded-md":``,"border-none":``,"p-2":``,"outline-none":``},[Rn(B(`input`,{"onUpdate:modelValue":t[2]||=e=>a.value=e,checked:a.value,"aria-checked":a.value,name:`showLive2DViewerInspector`,type:`checkbox`,"appearance-none":``,"outline-none":``,hidden:``},null,8,Tj),[[An,a.value]]),t[16]||=B(`div`,{"select-none":``},[B(`div`,{"i-solar:bug-bold-duotone":``})],-1)],2)]),Nt(G(Jn),null,{default:Ln(()=>[a.value?(U(),V(`div`,Ej,[B(`div`,Dj,[B(`div`,Oj,[B(`span`,null,mn(G(p)(`stage.viewers.debug-menu.vrm.model.title`)),1)]),Nt(qn,{"h-fit":``,"w-full":``,flex:`~ col`,border:`~ gray/25 rounded-lg`,divide:`y dashed gray/25`,"of-clip":``,"shadow-sm":``},{label:Ln(()=>[B(`span`,kj,mn(G(p)(`stage.viewers.debug-menu.vrm.camera`)),1)]),default:Ln(()=>[B(`div`,Aj,[t[17]||=B(`div`,{text:`neutral-400 dark:neutral-500`},[B(`span`,null,`X`)],-1),B(`label`,jj,[Nt(yj,{modelValue:o.value,"onUpdate:modelValue":t[3]||=e=>o.value=e,min:-10,max:10,step:.01},null,8,[`modelValue`])]),B(`div`,Mj,[B(`span`,null,mn(o.value),1)]),t[18]||=B(`div`,{text:`neutral-400 dark:neutral-500`},[B(`span`,null,`Y`)],-1),B(`label`,Nj,[Nt(yj,{modelValue:s.value,"onUpdate:modelValue":t[4]||=e=>s.value=e,min:-10,max:10,step:.01},null,8,[`modelValue`])]),B(`div`,Pj,[B(`span`,null,mn(s.value),1)]),t[19]||=B(`div`,{text:`neutral-400 dark:neutral-500`},[B(`span`,null,`Z`)],-1),B(`label`,Fj,[Nt(yj,{modelValue:c.value,"onUpdate:modelValue":t[5]||=e=>c.value=e,min:-10,max:10,step:.01},null,8,[`modelValue`])]),B(`div`,Ij,[B(`span`,null,mn(c.value),1)])])]),_:1}),Nt(qn,{"h-fit":``,"w-full":``,flex:`~ col`,border:`~ gray/25 rounded-lg`,divide:`y dashed gray/25`,"of-clip":``,"shadow-sm":``},{label:Ln(()=>[B(`span`,Lj,mn(G(p)(`stage.viewers.debug-menu.vrm.model.title`)),1)]),default:Ln(()=>[B(`div`,Rj,[t[20]||=B(`div`,{text:`neutral-400 dark:neutral-500`},[B(`span`,null,`X`)],-1),B(`label`,zj,[Nt(yj,{modelValue:l.value,"onUpdate:modelValue":t[6]||=e=>l.value=e,min:-10,max:10,step:.01},null,8,[`modelValue`])]),B(`div`,Bj,[B(`span`,null,mn(l.value),1)]),t[21]||=B(`div`,{text:`neutral-400 dark:neutral-500`},[B(`span`,null,`Y`)],-1),B(`label`,Vj,[Nt(yj,{modelValue:u.value,"onUpdate:modelValue":t[7]||=e=>u.value=e,min:-10,max:10,step:.01},null,8,[`modelValue`])]),B(`div`,Hj,[B(`span`,null,mn(u.value),1)]),t[22]||=B(`div`,{text:`neutral-400 dark:neutral-500`},[B(`span`,null,`Z`)],-1),B(`label`,Uj,[Nt(yj,{modelValue:d.value,"onUpdate:modelValue":t[8]||=e=>d.value=e,min:-10,max:10,step:.01},null,8,[`modelValue`])]),B(`div`,Wj,[B(`span`,null,mn(d.value),1)])])]),_:1}),B(`div`,Gj,[B(`span`,null,mn(G(p)(`stage.viewers.debug-menu.emotions`)),1)]),B(`div`,Kj,[B(`button`,{"rounded-lg":``,bg:`neutral-100/70 dark:neutral-800/50`,"px-2":``,"py-1":``,"backdrop-blur-sm":``,onClick:t[9]||=e=>{var t;return(t=f.value)?.setExpression(`neutral`)}},mn(G(p)(`stage.viewers.debug-menu.emotions-btn.neutral`)),1),B(`button`,{"rounded-lg":``,bg:`neutral-100/70 dark:neutral-800/50`,"px-2":``,"py-1":``,"backdrop-blur-sm":``,onClick:t[10]||=e=>{var t;return(t=f.value)?.setExpression(`surprised`)}},mn(G(p)(`stage.viewers.debug-menu.emotions-btn.surprised`)),1),B(`button`,{"rounded-lg":``,bg:`neutral-100/70 dark:neutral-800/50`,"px-2":``,"py-1":``,"backdrop-blur-sm":``,onClick:t[11]||=e=>{var t;return(t=f.value)?.setExpression(`sad`)}},mn(G(p)(`stage.viewers.debug-menu.emotions-btn.sad`)),1),B(`button`,{"rounded-lg":``,bg:`neutral-100/70 dark:neutral-800/50`,"px-2":``,"py-1":``,"backdrop-blur-sm":``,onClick:t[12]||=e=>{var t;return(t=f.value)?.setExpression(`angry`)}},mn(G(p)(`stage.viewers.debug-menu.emotions-btn.angry`)),1),B(`button`,{"rounded-lg":``,bg:`neutral-100/70 dark:neutral-800/50`,"px-2":``,"py-1":``,"backdrop-blur-sm":``,onClick:t[13]||=e=>{var t;return(t=f.value)?.setExpression(`happy`)}},mn(G(p)(`stage.viewers.debug-menu.emotions-btn.happy`)),1)])])])):jt(``,!0)]),_:1})])]),_:1}))}}),Jj=qj;const Yj=[`onClick`],Xj={flex:``,"gap-1.5":``};var Zj=H({__name:`Section`,props:{title:null,icon:null,innerClass:null,expand:{type:Boolean,default:!0}},setup(e){return(t,n)=>(U(),At(qn,{default:e.expand},{trigger:Ln(t=>[B(`button`,{class:`w-full flex items-center justify-between rounded-lg px-4 py-3 outline-none transition-all duration-250 ease-in-out`,bg:`neutral-100 dark:neutral-800`,hover:`bg-neutral-200 dark:bg-neutral-700`,onClick:e=>t.setVisible(!t.visible)},[B(`div`,Xj,[B(`div`,{class:Jt(e.icon),"size-6":``},null,2),Mt(` `+mn(e.title),1)]),B(`div`,{"i-solar:alt-arrow-down-linear":``,transition:`transform duration-250`,class:Jt({"rotate-180":t.visible})},null,2)],8,Yj)]),default:Ln(()=>[B(`div`,{grid:``,"gap-2":``,"p-4":``,class:Jt(e.innerClass)},[sn(t.$slots,`default`)],2)]),_:3},8,[`default`]))}}),Qj=Zj;function $j(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function eM(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function tM(e){return this instanceof tM?(this.v=e,this):new tM(e)}function nM(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof tM?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function rM(e){var t,n;return t={},r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:tM(e[r](t)),done:!1}:i?i(t):t}:i}}function iM(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof eM==`function`?eM(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}const aM=new TextDecoder(`utf-8`),oM=e=>aM.decode(e),sM=new TextEncoder,cM=e=>sM.encode(e),lM=e=>typeof e==`number`,uM=e=>typeof e==`boolean`,dM=e=>typeof e==`function`,fM=e=>e!=null&&Object(e)===e,pM=e=>fM(e)&&dM(e.then),mM=e=>fM(e)&&dM(e[Symbol.iterator]),hM=e=>fM(e)&&dM(e[Symbol.asyncIterator]),gM=e=>fM(e)&&fM(e.schema),_M=e=>fM(e)&&`done`in e&&`value`in e,vM=e=>fM(e)&&dM(e.stat)&&lM(e.fd),yM=e=>fM(e)&&SM(e.body),bM=e=>`_getDOMStream`in e&&`_getNodeStream`in e,xM=e=>fM(e)&&dM(e.abort)&&dM(e.getWriter)&&!bM(e),SM=e=>fM(e)&&dM(e.cancel)&&dM(e.getReader)&&!bM(e),CM=e=>fM(e)&&dM(e.end)&&dM(e.write)&&uM(e.writable)&&!bM(e),wM=e=>fM(e)&&dM(e.read)&&dM(e.pipe)&&uM(e.readable)&&!bM(e),TM=e=>fM(e)&&dM(e.clear)&&dM(e.bytes)&&dM(e.position)&&dM(e.setPosition)&&dM(e.capacity)&&dM(e.getBufferIdentifier)&&dM(e.createLong),EM=typeof SharedArrayBuffer<`u`?SharedArrayBuffer:ArrayBuffer;function DM(e){let t=e[0]?[e[0]]:[],n,r,i,a;for(let o,s,c=0,l=0,u=e.length;++ce+t.byteLength,0),i,a,o,s=0,c=-1,l=Math.min(t||1/0,r);for(let e=n.length;++cAM(Int32Array,e),MM=e=>AM(BigInt64Array,e),NM=e=>AM(Uint8Array,e),PM=e=>(e.next(),e);function*FM(e,t){let n=function*(e){yield e},r=typeof t==`string`||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof EM?n(t):mM(t)?t:n(t);return yield*PM(function*(t){let n=null;do n=t.next(yield AM(e,n));while(!n.done)}(r[Symbol.iterator]())),new e}const IM=e=>FM(Uint8Array,e);function LM(e,t){return nM(this,arguments,function*(){if(pM(t))return yield tM(yield tM(yield*rM(iM(LM(e,yield tM(t))))));let n=function(e){return nM(this,arguments,function*(){yield yield tM(yield tM(e))})},r=function(e){return nM(this,arguments,function*(){yield tM(yield*rM(iM(PM(function*(e){let t=null;do t=e.next(yield t?.value);while(!t.done)}(e[Symbol.iterator]())))))})},i=typeof t==`string`||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof EM?n(t):mM(t)?r(t):hM(t)?t:n(t);return yield tM(yield*rM(iM(PM(function(t){return nM(this,arguments,function*(){let n=null;do n=yield tM(t.next(yield yield tM(AM(e,n))));while(!n.done)})}(i[Symbol.asyncIterator]()))))),yield tM(new e)})}const RM=e=>LM(Uint8Array,e);function zM(e,t,n){if(e!==0){n=n.slice(0,t);for(let t=-1,r=n.length;++t0)do if(e[n]!==t[n])return!1;while(++n(e.next(),e);function*UM(e){let t,n=!1,r=[],i,a,o,s=0;function c(){return a===`peek`?kM(r,o)[0]:([i,r,s]=kM(r,o),i)}({cmd:a,size:o}=(yield(()=>null)())||{cmd:`read`,size:0});let l=IM(e)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(o-s)?l.next():l.next(o-s),!t&&i.byteLength>0&&(r.push(i),s+=i.byteLength),t||o<=s)do({cmd:a,size:o}=yield c());while(onull)()))||{cmd:`read`,size:0});let l=RM(e)[Symbol.asyncIterator]();try{do if({done:t,value:i}=Number.isNaN(o-s)?yield tM(l.next()):yield tM(l.next(o-s)),!t&&i.byteLength>0&&(r.push(i),s+=i.byteLength),t||o<=s)do({cmd:a,size:o}=yield yield tM(c()));while(onull)()))||{cmd:`read`,size:0});let l=new KM(e);try{do if({done:t,value:i}=Number.isNaN(o-s)?yield tM(l.read()):yield tM(l.read(o-s)),!t&&i.byteLength>0&&(r.push(NM(i)),s+=i.byteLength),t||o<=s)do({cmd:a,size:o}=yield yield tM(c()));while(o{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return $j(this,void 0,void 0,function*(){let{reader:t,source:n}=this;t&&(yield t.cancel(e).catch(()=>{})),n&&n.locked&&this.releaseLock()})}read(e){return $j(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array};let t=yield this.reader.read();return!t.done&&(t.value=NM(t)),t})}};const qM=(e,t)=>{let n=e=>r([t,e]),r;return[t,n,new Promise(i=>(r=i)&&e.once(t,n))]};function JM(e){return nM(this,arguments,function*(){let t=[],n=`error`,r=!1,i=null,a,o,s=0,c=[],l;function u(){return a===`peek`?kM(c,o)[0]:([l,c,s]=kM(c,o),l)}if({cmd:a,size:o}=(yield yield tM((()=>null)()))||{cmd:`read`,size:0},e.isTTY)return yield yield tM(new Uint8Array),yield tM(null);try{t[0]=qM(e,`end`),t[1]=qM(e,`error`);do{if(t[2]=qM(e,`readable`),[n,i]=yield tM(Promise.race(t.map(e=>e[2]))),n===`error`)break;if((r=n===`end`)||(Number.isFinite(o-s)?(l=NM(e.read(o-s)),l.byteLength0&&(c.push(l),s+=l.byteLength)),r||o<=s)do({cmd:a,size:o}=yield yield tM(u()));while(o{for(let[n,r]of t)e.off(n,r);try{let t=e.destroy;t&&t.call(e,n),n=void 0}catch(e){n=e||n}finally{n==null?r():i(n)}})}})}var YM;(function(e){e[e.V1=0]=`V1`,e[e.V2=1]=`V2`,e[e.V3=2]=`V3`,e[e.V4=3]=`V4`,e[e.V5=4]=`V5`})(YM||={});var XM;(function(e){e[e.Sparse=0]=`Sparse`,e[e.Dense=1]=`Dense`})(XM||={});var ZM;(function(e){e[e.HALF=0]=`HALF`,e[e.SINGLE=1]=`SINGLE`,e[e.DOUBLE=2]=`DOUBLE`})(ZM||={});var QM;(function(e){e[e.DAY=0]=`DAY`,e[e.MILLISECOND=1]=`MILLISECOND`})(QM||={});var $M;(function(e){e[e.SECOND=0]=`SECOND`,e[e.MILLISECOND=1]=`MILLISECOND`,e[e.MICROSECOND=2]=`MICROSECOND`,e[e.NANOSECOND=3]=`NANOSECOND`})($M||={});var eN;(function(e){e[e.YEAR_MONTH=0]=`YEAR_MONTH`,e[e.DAY_TIME=1]=`DAY_TIME`,e[e.MONTH_DAY_NANO=2]=`MONTH_DAY_NANO`})(eN||={});const tN=2,nN=4,rN=4,iN=4,aN=new Int32Array(2),oN=new Float32Array(aN.buffer),sN=new Float64Array(aN.buffer),cN=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var lN;(function(e){e[e.UTF8_BYTES=1]=`UTF8_BYTES`,e[e.UTF16_STRING=2]=`UTF16_STRING`})(lN||={});var uN=class e{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new e(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,Number(BigInt.asIntN(32,t))),this.writeInt32(e+4,Number(BigInt.asIntN(32,t>>BigInt(32))))}writeUint64(e,t){this.writeUint32(e,Number(BigInt.asUintN(32,t))),this.writeUint32(e+4,Number(BigInt.asUintN(32,t>>BigInt(32))))}writeFloat32(e,t){oN[0]=t,this.writeInt32(e,aN[0])}writeFloat64(e,t){sN[0]=t,this.writeInt32(e,aN[cN?0:1]),this.writeInt32(e+4,aN[cN?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=t);let r=~(this.bb.capacity()-this.space+n)+1&t-1;for(;this.space=0&&this.vtable[t]==0;t--);let n=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]==0?0:e-this.vtable[t]);let r=2;this.addInt16(e-this.object_start);let i=(n+r)*tN;this.addInt16(i);let a=0,o=this.space;outer_loop:for(t=0;t=0;t--)this.writeInt8(e.charCodeAt(t))}this.prep(this.minalign,nN+r),this.addOffset(e),r&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){let n=this.bb.capacity()-e,r=n-this.bb.readInt32(n),i=t=0;n--)e.addInt32(t[n]);return e.endVector()}static startTypeIdsVector(e,t){e.startVector(4,t,4)}static endUnion(e){let t=e.endObject();return t}static createUnion(t,n,r){return e.startUnion(t),e.addMode(t,n),e.addTypeIds(t,r),e.endUnion(t)}},HN=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsUtf8(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,n){return t.setPosition(t.position()+iN),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(e){e.startObject(0)}static endUtf8(e){let t=e.endObject();return t}static createUtf8(t){return e.startUtf8(t),e.endUtf8(t)}},UN;(function(e){e[e.NONE=0]=`NONE`,e[e.Null=1]=`Null`,e[e.Int=2]=`Int`,e[e.FloatingPoint=3]=`FloatingPoint`,e[e.Binary=4]=`Binary`,e[e.Utf8=5]=`Utf8`,e[e.Bool=6]=`Bool`,e[e.Decimal=7]=`Decimal`,e[e.Date=8]=`Date`,e[e.Time=9]=`Time`,e[e.Timestamp=10]=`Timestamp`,e[e.Interval=11]=`Interval`,e[e.List=12]=`List`,e[e.Struct_=13]=`Struct_`,e[e.Union=14]=`Union`,e[e.FixedSizeBinary=15]=`FixedSizeBinary`,e[e.FixedSizeList=16]=`FixedSizeList`,e[e.Map=17]=`Map`,e[e.Duration=18]=`Duration`,e[e.LargeBinary=19]=`LargeBinary`,e[e.LargeUtf8=20]=`LargeUtf8`,e[e.LargeList=21]=`LargeList`,e[e.RunEndEncoded=22]=`RunEndEncoded`})(UN||={});var WN=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsField(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,n){return t.setPosition(t.position()+iN),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}name(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}nullable(){let e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):UN.NONE}type(e){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__union(e,this.bb_pos+t):null}dictionary(e){let t=this.bb.__offset(this.bb_pos,12);return t?(e||new SN).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}children(t,n){let r=this.bb.__offset(this.bb_pos,14);return r?(n||new e).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}childrenLength(){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){let n=this.bb.__offset(this.bb_pos,16);return n?(t||new CN).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,t){e.addFieldOffset(0,t,0)}static addNullable(e,t){e.addFieldInt8(1,+t,0)}static addTypeType(e,t){e.addFieldInt8(2,t,UN.NONE)}static addType(e,t){e.addFieldOffset(3,t,0)}static addDictionary(e,t){e.addFieldOffset(4,t,0)}static addChildren(e,t){e.addFieldOffset(5,t,0)}static createChildrenVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startChildrenVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(6,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endField(e){let t=e.endObject();return t}},GN=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSchema(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,n){return t.setPosition(t.position()+iN),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}endianness(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):yN.Little}fields(e,t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new WN).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}fieldsLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){let n=this.bb.__offset(this.bb_pos,8);return n?(t||new CN).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+e*8):BigInt(0)}featuresLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,t){e.addFieldInt16(0,t,yN.Little)}static addFields(e,t){e.addFieldOffset(1,t,0)}static createFieldsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startFieldsVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(2,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static addFeatures(e,t){e.addFieldOffset(3,t,0)}static createFeaturesVector(e,t){e.startVector(8,t.length,8);for(let n=t.length-1;n>=0;n--)e.addInt64(t[n]);return e.endVector()}static startFeaturesVector(e,t){e.startVector(8,t,8)}static endSchema(e){let t=e.endObject();return t}static finishSchemaBuffer(e,t){e.finish(t)}static finishSizePrefixedSchemaBuffer(e,t){e.finish(t,void 0,!0)}static createSchema(t,n,r,i,a){return e.startSchema(t),e.addEndianness(t,n),e.addFields(t,r),e.addCustomMetadata(t,i),e.addFeatures(t,a),e.endSchema(t)}},KN;(function(e){e[e.NONE=0]=`NONE`,e[e.Schema=1]=`Schema`,e[e.DictionaryBatch=2]=`DictionaryBatch`,e[e.RecordBatch=3]=`RecordBatch`,e[e.Tensor=4]=`Tensor`,e[e.SparseTensor=5]=`SparseTensor`})(KN||={});var Y;(function(e){e[e.NONE=0]=`NONE`,e[e.Null=1]=`Null`,e[e.Int=2]=`Int`,e[e.Float=3]=`Float`,e[e.Binary=4]=`Binary`,e[e.Utf8=5]=`Utf8`,e[e.Bool=6]=`Bool`,e[e.Decimal=7]=`Decimal`,e[e.Date=8]=`Date`,e[e.Time=9]=`Time`,e[e.Timestamp=10]=`Timestamp`,e[e.Interval=11]=`Interval`,e[e.List=12]=`List`,e[e.Struct=13]=`Struct`,e[e.Union=14]=`Union`,e[e.FixedSizeBinary=15]=`FixedSizeBinary`,e[e.FixedSizeList=16]=`FixedSizeList`,e[e.Map=17]=`Map`,e[e.Duration=18]=`Duration`,e[e.LargeBinary=19]=`LargeBinary`,e[e.LargeUtf8=20]=`LargeUtf8`,e[e.Dictionary=-1]=`Dictionary`,e[e.Int8=-2]=`Int8`,e[e.Int16=-3]=`Int16`,e[e.Int32=-4]=`Int32`,e[e.Int64=-5]=`Int64`,e[e.Uint8=-6]=`Uint8`,e[e.Uint16=-7]=`Uint16`,e[e.Uint32=-8]=`Uint32`,e[e.Uint64=-9]=`Uint64`,e[e.Float16=-10]=`Float16`,e[e.Float32=-11]=`Float32`,e[e.Float64=-12]=`Float64`,e[e.DateDay=-13]=`DateDay`,e[e.DateMillisecond=-14]=`DateMillisecond`,e[e.TimestampSecond=-15]=`TimestampSecond`,e[e.TimestampMillisecond=-16]=`TimestampMillisecond`,e[e.TimestampMicrosecond=-17]=`TimestampMicrosecond`,e[e.TimestampNanosecond=-18]=`TimestampNanosecond`,e[e.TimeSecond=-19]=`TimeSecond`,e[e.TimeMillisecond=-20]=`TimeMillisecond`,e[e.TimeMicrosecond=-21]=`TimeMicrosecond`,e[e.TimeNanosecond=-22]=`TimeNanosecond`,e[e.DenseUnion=-23]=`DenseUnion`,e[e.SparseUnion=-24]=`SparseUnion`,e[e.IntervalDayTime=-25]=`IntervalDayTime`,e[e.IntervalYearMonth=-26]=`IntervalYearMonth`,e[e.DurationSecond=-27]=`DurationSecond`,e[e.DurationMillisecond=-28]=`DurationMillisecond`,e[e.DurationMicrosecond=-29]=`DurationMicrosecond`,e[e.DurationNanosecond=-30]=`DurationNanosecond`})(Y||={});var qN;(function(e){e[e.OFFSET=0]=`OFFSET`,e[e.DATA=1]=`DATA`,e[e.VALIDITY=2]=`VALIDITY`,e[e.TYPE=3]=`TYPE`})(qN||={});const JN=void 0;function YN(e){if(e===null)return`null`;if(e===JN)return`undefined`;switch(typeof e){case`number`:return`${e}`;case`bigint`:return`${e}`;case`string`:return`"${e}"`}return typeof e[Symbol.toPrimitive]==`function`?e[Symbol.toPrimitive](`string`):ArrayBuffer.isView(e)?e instanceof BigInt64Array||e instanceof BigUint64Array?`[${[...e].map(e=>YN(e))}]`:`[${e}]`:ArrayBuffer.isView(e)?`[${e}]`:JSON.stringify(e,(e,t)=>typeof t==`bigint`?`${t}`:t)}function XN(e){if(typeof e==`bigint`&&(e<-(2**53-1)||e>2**53-1))throw TypeError(`${e} is not safe to convert to a number.`);return Number(e)}function ZN(e,t){return XN(e/t)+XN(e%t)/XN(t)}const QN=Symbol.for(`isArrowBigNum`);function $N(e,...t){return t.length===0?Object.setPrototypeOf(AM(this.TypedArray,e),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(e,...t),this.constructor.prototype)}$N.prototype[QN]=!0,$N.prototype.toJSON=function(){return`"${oP(this)}"`},$N.prototype.valueOf=function(e){return aP(this,e)},$N.prototype.toString=function(){return oP(this)},$N.prototype[Symbol.toPrimitive]=function(e=`default`){switch(e){case`number`:return aP(this);case`string`:return oP(this);case`default`:return sP(this)}return oP(this)};function eP(...e){return $N.apply(this,e)}function tP(...e){return $N.apply(this,e)}function nP(...e){return $N.apply(this,e)}Object.setPrototypeOf(eP.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(tP.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(nP.prototype,Object.create(Uint32Array.prototype)),Object.assign(eP.prototype,$N.prototype,{constructor:eP,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(tP.prototype,$N.prototype,{constructor:tP,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(nP.prototype,$N.prototype,{constructor:nP,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const rP=BigInt(4294967296)*BigInt(4294967296),iP=rP-BigInt(1);function aP(e,t){let{buffer:n,byteOffset:r,byteLength:i,signed:a}=e,o=new BigUint64Array(n,r,i/8),s=a&&o.at(-1)&BigInt(1)<=0)return cP(e);t=t.slice();let r=1;for(let e=0;e(e.children=null,e.ArrayType=Array,e.OffsetArrayType=Int32Array,e[Symbol.toStringTag]=`DataType`))(MP.prototype);var NP=class extends MP{constructor(){super(Y.Null)}toString(){return`Null`}};dP=Symbol.toStringTag,NP[dP]=(e=>e[Symbol.toStringTag]=`Null`)(NP.prototype);var PP=class extends MP{constructor(e,t){super(Y.Int),this.isSigned=e,this.bitWidth=t}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?`I`:`Ui`}nt${this.bitWidth}`}};fP=Symbol.toStringTag,PP[fP]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]=`Int`))(PP.prototype);var FP=class extends PP{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},IP=class extends PP{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},LP=class extends PP{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},RP=class extends PP{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},zP=class extends PP{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},BP=class extends PP{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},VP=class extends PP{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},HP=class extends PP{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(FP.prototype,`ArrayType`,{value:Int8Array}),Object.defineProperty(IP.prototype,`ArrayType`,{value:Int16Array}),Object.defineProperty(LP.prototype,`ArrayType`,{value:Int32Array}),Object.defineProperty(RP.prototype,`ArrayType`,{value:BigInt64Array}),Object.defineProperty(zP.prototype,`ArrayType`,{value:Uint8Array}),Object.defineProperty(BP.prototype,`ArrayType`,{value:Uint16Array}),Object.defineProperty(VP.prototype,`ArrayType`,{value:Uint32Array}),Object.defineProperty(HP.prototype,`ArrayType`,{value:BigUint64Array});var UP=class extends MP{constructor(e){super(Y.Float),this.precision=e}get ArrayType(){switch(this.precision){case ZM.HALF:return Uint16Array;case ZM.SINGLE:return Float32Array;case ZM.DOUBLE:return Float64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};pP=Symbol.toStringTag,UP[pP]=(e=>(e.precision=null,e[Symbol.toStringTag]=`Float`))(UP.prototype);var WP=class extends UP{constructor(){super(ZM.HALF)}},GP=class extends UP{constructor(){super(ZM.SINGLE)}},KP=class extends UP{constructor(){super(ZM.DOUBLE)}};Object.defineProperty(WP.prototype,`ArrayType`,{value:Uint16Array}),Object.defineProperty(GP.prototype,`ArrayType`,{value:Float32Array}),Object.defineProperty(KP.prototype,`ArrayType`,{value:Float64Array});var qP=class extends MP{constructor(){super(Y.Binary)}toString(){return`Binary`}};mP=Symbol.toStringTag,qP[mP]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Binary`))(qP.prototype);var JP=class extends MP{constructor(){super(Y.LargeBinary)}toString(){return`LargeBinary`}};hP=Symbol.toStringTag,JP[hP]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeBinary`))(JP.prototype);var YP=class extends MP{constructor(){super(Y.Utf8)}toString(){return`Utf8`}};gP=Symbol.toStringTag,YP[gP]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Utf8`))(YP.prototype);var XP=class extends MP{constructor(){super(Y.LargeUtf8)}toString(){return`LargeUtf8`}};_P=Symbol.toStringTag,XP[_P]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeUtf8`))(XP.prototype);var ZP=class extends MP{constructor(){super(Y.Bool)}toString(){return`Bool`}};vP=Symbol.toStringTag,ZP[vP]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Bool`))(ZP.prototype);var QP=class extends MP{constructor(e,t,n=128){super(Y.Decimal),this.scale=e,this.precision=t,this.bitWidth=n}toString(){return`Decimal[${this.precision}e${this.scale>0?`+`:``}${this.scale}]`}};yP=Symbol.toStringTag,QP[yP]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]=`Decimal`))(QP.prototype);var $P=class extends MP{constructor(e){super(Y.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${QM[this.unit]}>`}get ArrayType(){return this.unit===QM.DAY?Int32Array:BigInt64Array}};bP=Symbol.toStringTag,$P[bP]=(e=>(e.unit=null,e[Symbol.toStringTag]=`Date`))($P.prototype);var eF=class extends MP{constructor(e,t){super(Y.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${$M[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};xP=Symbol.toStringTag,eF[xP]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]=`Time`))(eF.prototype);var tF=class extends MP{constructor(e,t){super(Y.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${$M[this.unit]}${this.timezone?`, ${this.timezone}`:``}>`}};SP=Symbol.toStringTag,tF[SP]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Timestamp`))(tF.prototype);var nF=class extends MP{constructor(e){super(Y.Interval),this.unit=e}toString(){return`Interval<${eN[this.unit]}>`}};CP=Symbol.toStringTag,nF[CP]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]=`Interval`))(nF.prototype);var rF=class extends MP{constructor(e){super(Y.Duration),this.unit=e}toString(){return`Duration<${$M[this.unit]}>`}};wP=Symbol.toStringTag,rF[wP]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Duration`))(rF.prototype);var iF=class extends MP{constructor(e){super(Y.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};TP=Symbol.toStringTag,iF[TP]=(e=>(e.children=null,e[Symbol.toStringTag]=`List`))(iF.prototype);var aF=class extends MP{constructor(e){super(Y.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(`, `)}}>`}};EP=Symbol.toStringTag,aF[EP]=(e=>(e.children=null,e[Symbol.toStringTag]=`Struct`))(aF.prototype);var oF=class extends MP{constructor(e,t,n){super(Y.Union),this.mode=e,this.children=n,this.typeIds=t=Int32Array.from(t),this.typeIdToChildIndex=t.reduce((e,t,n)=>(e[t]=n)&&e||e,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(` | `)}>`}};DP=Symbol.toStringTag,oF[DP]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]=`Union`))(oF.prototype);var sF=class extends MP{constructor(e){super(Y.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};OP=Symbol.toStringTag,sF[OP]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`FixedSizeBinary`))(sF.prototype);var cF=class extends MP{constructor(e,t){super(Y.FixedSizeList),this.listSize=e,this.children=[t]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}};kP=Symbol.toStringTag,cF[kP]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]=`FixedSizeList`))(cF.prototype);var lF=class extends MP{constructor(e,t=!1){var n,r,i;if(super(Y.Map),this.children=[e],this.keysSorted=t,e&&(e.name=`entries`,(n=e?.type)?.children)){let t=(r=e?.type)?.children[0];t&&(t.name=`key`);let n=(i=e?.type)?.children[1];n&&(n.name=`value`)}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(`, `)}}>`}};AP=Symbol.toStringTag,lF[AP]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]=`Map_`))(lF.prototype);const uF=(e=>()=>++e)(-1);var dF=class extends MP{constructor(e,t,n,r){super(Y.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=r||!1,this.id=n==null?uF():XN(n)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}};jP=Symbol.toStringTag,dF[jP]=(e=>(e.id=null,e.indices=null,e.isOrdered=null,e.dictionary=null,e[Symbol.toStringTag]=`Dictionary`))(dF.prototype);function fF(e){let t=e;switch(e.typeId){case Y.Decimal:return e.bitWidth/32;case Y.Interval:return 1+t.unit;case Y.FixedSizeList:return t.listSize;case Y.FixedSizeBinary:return t.byteWidth;default:return 1}}var pF=class{visitMany(e,...t){return e.map((e,n)=>this.visit(e,...t.map(e=>e[n])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,t=!0){return mF(this,e,t)}getVisitFnByTypeId(e,t=!0){return hF(this,e,t)}visitNull(e,...t){return null}visitBool(e,...t){return null}visitInt(e,...t){return null}visitFloat(e,...t){return null}visitUtf8(e,...t){return null}visitLargeUtf8(e,...t){return null}visitBinary(e,...t){return null}visitLargeBinary(e,...t){return null}visitFixedSizeBinary(e,...t){return null}visitDate(e,...t){return null}visitTimestamp(e,...t){return null}visitTime(e,...t){return null}visitDecimal(e,...t){return null}visitList(e,...t){return null}visitStruct(e,...t){return null}visitUnion(e,...t){return null}visitDictionary(e,...t){return null}visitInterval(e,...t){return null}visitDuration(e,...t){return null}visitFixedSizeList(e,...t){return null}visitMap(e,...t){return null}};function mF(e,t,n=!0){return typeof t==`number`?hF(e,t,n):typeof t==`string`&&t in Y?hF(e,Y[t],n):t&&t instanceof MP?hF(e,gF(t),n):t?.type&&t.type instanceof MP?hF(e,gF(t.type),n):hF(e,Y.NONE,n)}function hF(e,t,n=!0){let r=null;switch(t){case Y.Null:r=e.visitNull;break;case Y.Bool:r=e.visitBool;break;case Y.Int:r=e.visitInt;break;case Y.Int8:r=e.visitInt8||e.visitInt;break;case Y.Int16:r=e.visitInt16||e.visitInt;break;case Y.Int32:r=e.visitInt32||e.visitInt;break;case Y.Int64:r=e.visitInt64||e.visitInt;break;case Y.Uint8:r=e.visitUint8||e.visitInt;break;case Y.Uint16:r=e.visitUint16||e.visitInt;break;case Y.Uint32:r=e.visitUint32||e.visitInt;break;case Y.Uint64:r=e.visitUint64||e.visitInt;break;case Y.Float:r=e.visitFloat;break;case Y.Float16:r=e.visitFloat16||e.visitFloat;break;case Y.Float32:r=e.visitFloat32||e.visitFloat;break;case Y.Float64:r=e.visitFloat64||e.visitFloat;break;case Y.Utf8:r=e.visitUtf8;break;case Y.LargeUtf8:r=e.visitLargeUtf8;break;case Y.Binary:r=e.visitBinary;break;case Y.LargeBinary:r=e.visitLargeBinary;break;case Y.FixedSizeBinary:r=e.visitFixedSizeBinary;break;case Y.Date:r=e.visitDate;break;case Y.DateDay:r=e.visitDateDay||e.visitDate;break;case Y.DateMillisecond:r=e.visitDateMillisecond||e.visitDate;break;case Y.Timestamp:r=e.visitTimestamp;break;case Y.TimestampSecond:r=e.visitTimestampSecond||e.visitTimestamp;break;case Y.TimestampMillisecond:r=e.visitTimestampMillisecond||e.visitTimestamp;break;case Y.TimestampMicrosecond:r=e.visitTimestampMicrosecond||e.visitTimestamp;break;case Y.TimestampNanosecond:r=e.visitTimestampNanosecond||e.visitTimestamp;break;case Y.Time:r=e.visitTime;break;case Y.TimeSecond:r=e.visitTimeSecond||e.visitTime;break;case Y.TimeMillisecond:r=e.visitTimeMillisecond||e.visitTime;break;case Y.TimeMicrosecond:r=e.visitTimeMicrosecond||e.visitTime;break;case Y.TimeNanosecond:r=e.visitTimeNanosecond||e.visitTime;break;case Y.Decimal:r=e.visitDecimal;break;case Y.List:r=e.visitList;break;case Y.Struct:r=e.visitStruct;break;case Y.Union:r=e.visitUnion;break;case Y.DenseUnion:r=e.visitDenseUnion||e.visitUnion;break;case Y.SparseUnion:r=e.visitSparseUnion||e.visitUnion;break;case Y.Dictionary:r=e.visitDictionary;break;case Y.Interval:r=e.visitInterval;break;case Y.IntervalDayTime:r=e.visitIntervalDayTime||e.visitInterval;break;case Y.IntervalYearMonth:r=e.visitIntervalYearMonth||e.visitInterval;break;case Y.Duration:r=e.visitDuration;break;case Y.DurationSecond:r=e.visitDurationSecond||e.visitDuration;break;case Y.DurationMillisecond:r=e.visitDurationMillisecond||e.visitDuration;break;case Y.DurationMicrosecond:r=e.visitDurationMicrosecond||e.visitDuration;break;case Y.DurationNanosecond:r=e.visitDurationNanosecond||e.visitDuration;break;case Y.FixedSizeList:r=e.visitFixedSizeList;break;case Y.Map:r=e.visitMap;break}if(typeof r==`function`)return r;if(!n)return()=>null;throw Error(`Unrecognized type '${Y[t]}'`)}function gF(e){switch(e.typeId){case Y.Null:return Y.Null;case Y.Int:{let{bitWidth:t,isSigned:n}=e;switch(t){case 8:return n?Y.Int8:Y.Uint8;case 16:return n?Y.Int16:Y.Uint16;case 32:return n?Y.Int32:Y.Uint32;case 64:return n?Y.Int64:Y.Uint64}return Y.Int}case Y.Float:switch(e.precision){case ZM.HALF:return Y.Float16;case ZM.SINGLE:return Y.Float32;case ZM.DOUBLE:return Y.Float64}return Y.Float;case Y.Binary:return Y.Binary;case Y.LargeBinary:return Y.LargeBinary;case Y.Utf8:return Y.Utf8;case Y.LargeUtf8:return Y.LargeUtf8;case Y.Bool:return Y.Bool;case Y.Decimal:return Y.Decimal;case Y.Time:switch(e.unit){case $M.SECOND:return Y.TimeSecond;case $M.MILLISECOND:return Y.TimeMillisecond;case $M.MICROSECOND:return Y.TimeMicrosecond;case $M.NANOSECOND:return Y.TimeNanosecond}return Y.Time;case Y.Timestamp:switch(e.unit){case $M.SECOND:return Y.TimestampSecond;case $M.MILLISECOND:return Y.TimestampMillisecond;case $M.MICROSECOND:return Y.TimestampMicrosecond;case $M.NANOSECOND:return Y.TimestampNanosecond}return Y.Timestamp;case Y.Date:switch(e.unit){case QM.DAY:return Y.DateDay;case QM.MILLISECOND:return Y.DateMillisecond}return Y.Date;case Y.Interval:switch(e.unit){case eN.DAY_TIME:return Y.IntervalDayTime;case eN.YEAR_MONTH:return Y.IntervalYearMonth}return Y.Interval;case Y.Duration:switch(e.unit){case $M.SECOND:return Y.DurationSecond;case $M.MILLISECOND:return Y.DurationMillisecond;case $M.MICROSECOND:return Y.DurationMicrosecond;case $M.NANOSECOND:return Y.DurationNanosecond}return Y.Duration;case Y.Map:return Y.Map;case Y.List:return Y.List;case Y.Struct:return Y.Struct;case Y.Union:switch(e.mode){case XM.Dense:return Y.DenseUnion;case XM.Sparse:return Y.SparseUnion}return Y.Union;case Y.FixedSizeBinary:return Y.FixedSizeBinary;case Y.FixedSizeList:return Y.FixedSizeList;case Y.Dictionary:return Y.Dictionary}throw Error(`Unrecognized type '${Y[e.typeId]}'`)}pF.prototype.visitInt8=null,pF.prototype.visitInt16=null,pF.prototype.visitInt32=null,pF.prototype.visitInt64=null,pF.prototype.visitUint8=null,pF.prototype.visitUint16=null,pF.prototype.visitUint32=null,pF.prototype.visitUint64=null,pF.prototype.visitFloat16=null,pF.prototype.visitFloat32=null,pF.prototype.visitFloat64=null,pF.prototype.visitDateDay=null,pF.prototype.visitDateMillisecond=null,pF.prototype.visitTimestampSecond=null,pF.prototype.visitTimestampMillisecond=null,pF.prototype.visitTimestampMicrosecond=null,pF.prototype.visitTimestampNanosecond=null,pF.prototype.visitTimeSecond=null,pF.prototype.visitTimeMillisecond=null,pF.prototype.visitTimeMicrosecond=null,pF.prototype.visitTimeNanosecond=null,pF.prototype.visitDenseUnion=null,pF.prototype.visitSparseUnion=null,pF.prototype.visitIntervalDayTime=null,pF.prototype.visitIntervalYearMonth=null,pF.prototype.visitDuration=null,pF.prototype.visitDurationSecond=null,pF.prototype.visitDurationMillisecond=null,pF.prototype.visitDurationMicrosecond=null,pF.prototype.visitDurationNanosecond=null;const _F=new Float64Array(1),vF=new Uint32Array(_F.buffer);function yF(e){let t=(e&31744)>>10,n=(e&1023)/1024,r=(-1)**((e&32768)>>15);switch(t){case 31:return r*(n?NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*2**(t-15)*(1+n)}function bF(e){if(e!==e)return 32256;_F[0]=e;let t=(vF[1]&2147483648)>>16&65535,n=vF[1]&2146435072,r=0;return n>=1089470464?vF[0]>0?n=31744:(n=(n&2080374784)>>16,r=(vF[1]&1048575)>>10):n<=1056964608?(r=1048576+(vF[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(vF[1]&1048575)+512>>10),t|n|r&65535}var xF=class extends pF{};function SF(e){return(t,n,r)=>{if(t.setValid(n,r!=null))return e(t,n,r)}}const CF=(e,t,n)=>{e[t]=Math.floor(n/864e5)},wF=(e,t,n,r)=>{if(n+1{let i=e+n;r?t[i>>3]|=1<>3]&=~(1<{e[t]=n},DF=({values:e},t,n)=>{e[t]=n},OF=({values:e},t,n)=>{e[t]=bF(n)},kF=(e,t,n)=>{switch(e.type.precision){case ZM.HALF:return OF(e,t,n);case ZM.SINGLE:case ZM.DOUBLE:return DF(e,t,n)}},AF=({values:e},t,n)=>{CF(e,t,n.valueOf())},jF=({values:e},t,n)=>{e[t]=BigInt(n)},MF=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},NF=({values:e,valueOffsets:t},n,r)=>wF(e,t,n,r),PF=({values:e,valueOffsets:t},n,r)=>wF(e,t,n,cM(r)),FF=(e,t,n)=>{e.type.unit===QM.DAY?AF(e,t,n):jF(e,t,n)},IF=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},LF=({values:e},t,n)=>{e[t]=BigInt(n)},RF=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},zF=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},BF=(e,t,n)=>{switch(e.type.unit){case $M.SECOND:return IF(e,t,n);case $M.MILLISECOND:return LF(e,t,n);case $M.MICROSECOND:return RF(e,t,n);case $M.NANOSECOND:return zF(e,t,n)}},VF=({values:e},t,n)=>{e[t]=n},HF=({values:e},t,n)=>{e[t]=n},UF=({values:e},t,n)=>{e[t]=n},WF=({values:e},t,n)=>{e[t]=n},GF=(e,t,n)=>{switch(e.type.unit){case $M.SECOND:return VF(e,t,n);case $M.MILLISECOND:return HF(e,t,n);case $M.MICROSECOND:return UF(e,t,n);case $M.NANOSECOND:return WF(e,t,n)}},KF=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},qF=(e,t,n)=>{let r=e.children[0],i=e.valueOffsets,a=pI.getVisitFn(r);if(Array.isArray(n))for(let e=-1,o=i[t],s=i[t+1];o{let r=e.children[0],{valueOffsets:i}=e,a=pI.getVisitFn(r),{[t]:o,[t+1]:s}=i,c=n instanceof Map?n.entries():Object.entries(n);for(let e of c)if(a(r,o,e),++o>=s)break},YF=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[a]),XF=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(a)),ZF=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(i.name)),QF=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[i.name]),$F=(e,t,n)=>{let r=e.type.children.map(e=>pI.getVisitFn(e.type)),i=n instanceof Map?ZF(t,n):n instanceof fR?XF(t,n):Array.isArray(n)?YF(t,n):QF(t,n);e.type.children.forEach((t,n)=>i(r[n],e.children[n],t,n))},eI=(e,t,n)=>{e.type.mode===XM.Dense?tI(e,t,n):nI(e,t,n)},tI=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];pI.visit(i,e.valueOffsets[t],n)},nI=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];pI.visit(i,t,n)},rI=(e,t,n)=>{var r;(r=e.dictionary)==null||r.set(e.values[t],n)},iI=(e,t,n)=>{e.type.unit===eN.DAY_TIME?aI(e,t,n):oI(e,t,n)},aI=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},oI=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},sI=({values:e},t,n)=>{e[t]=n},cI=({values:e},t,n)=>{e[t]=n},lI=({values:e},t,n)=>{e[t]=n},uI=({values:e},t,n)=>{e[t]=n},dI=(e,t,n)=>{switch(e.type.unit){case $M.SECOND:return sI(e,t,n);case $M.MILLISECOND:return cI(e,t,n);case $M.MICROSECOND:return lI(e,t,n);case $M.NANOSECOND:return uI(e,t,n)}},fI=(e,t,n)=>{let{stride:r}=e,i=e.children[0],a=pI.getVisitFn(i);if(Array.isArray(n))for(let e=-1,o=t*r;++e`${YN(e)}: ${YN(t)}`).join(`, `)}}`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}[Symbol.iterator](){return new _I(this[mI],this[hI])}},_I=class{constructor(e,t){this.childIndex=0,this.children=e.children,this.rowIndex=t,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let e=this.childIndex;return ee.name)}has(e,t){return e[mI].type.children.findIndex(e=>e.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[mI].type.children.findIndex(e=>e.name===t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];let n=e[mI].type.children.findIndex(e=>e.name===t);if(n!==-1){let r=lL.visit(e[mI].children[n],e[hI]);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[mI].type.children.findIndex(e=>e.name===t);return r===-1?Reflect.has(e,t)||typeof t==`symbol`?Reflect.set(e,t,n):!1:(pI.visit(e[mI].children[r],e[hI],n),Reflect.set(e,t,n))}},yI=class extends pF{};function bI(e){return(t,n)=>t.getValid(n)?e(t,n):null}const xI=(e,t)=>864e5*e[t],SI=(e,t)=>null,CI=(e,t,n)=>{if(n+1>=t.length)return null;let r=XN(t[n]),i=XN(t[n+1]);return e.subarray(r,i)},wI=({offset:e,values:t},n)=>{let r=e+n,i=t[r>>3];return(i&1<xI(e,t),EI=({values:e},t)=>XN(e[t]),DI=({stride:e,values:t},n)=>t[e*n],OI=({stride:e,values:t},n)=>yF(t[e*n]),kI=({values:e},t)=>e[t],AI=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),jI=({values:e,valueOffsets:t},n)=>CI(e,t,n),MI=({values:e,valueOffsets:t},n)=>{let r=CI(e,t,n);return r===null?null:oM(r)},NI=({values:e},t)=>e[t],PI=({type:e,values:t},n)=>e.precision===ZM.HALF?yF(t[n]):t[n],FI=(e,t)=>e.type.unit===QM.DAY?TI(e,t):EI(e,t),II=({values:e},t)=>1e3*XN(e[t]),LI=({values:e},t)=>XN(e[t]),RI=({values:e},t)=>ZN(e[t],BigInt(1e3)),zI=({values:e},t)=>ZN(e[t],BigInt(1e6)),BI=(e,t)=>{switch(e.type.unit){case $M.SECOND:return II(e,t);case $M.MILLISECOND:return LI(e,t);case $M.MICROSECOND:return RI(e,t);case $M.NANOSECOND:return zI(e,t)}},VI=({values:e},t)=>e[t],HI=({values:e},t)=>e[t],UI=({values:e},t)=>e[t],WI=({values:e},t)=>e[t],GI=(e,t)=>{switch(e.type.unit){case $M.SECOND:return VI(e,t);case $M.MILLISECOND:return HI(e,t);case $M.MICROSECOND:return UI(e,t);case $M.NANOSECOND:return WI(e,t)}},KI=({values:e,stride:t},n)=>lP.decimal(e.subarray(t*n,t*(n+1))),qI=(e,t)=>{let{valueOffsets:n,stride:r,children:i}=e,{[t*r]:a,[t*r+1]:o}=n,s=i[0],c=s.slice(a,o-a);return new fR([c])},JI=(e,t)=>{let{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:a}=n,o=r[0];return new mL(o.slice(i,a-i))},YI=(e,t)=>new gI(e,t),XI=(e,t)=>e.type.mode===XM.Dense?ZI(e,t):QI(e,t),ZI=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return lL.visit(r,e.valueOffsets[t])},QI=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return lL.visit(r,t)},$I=(e,t)=>{var n;return(n=e.dictionary)?.get(e.values[t])},eL=(e,t)=>e.type.unit===eN.DAY_TIME?tL(e,t):nL(e,t),tL=({values:e},t)=>e.subarray(2*t,2*(t+1)),nL=({values:e},t)=>{let n=e[t],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},rL=({values:e},t)=>e[t],iL=({values:e},t)=>e[t],aL=({values:e},t)=>e[t],oL=({values:e},t)=>e[t],sL=(e,t)=>{switch(e.type.unit){case $M.SECOND:return rL(e,t);case $M.MILLISECOND:return iL(e,t);case $M.MICROSECOND:return aL(e,t);case $M.NANOSECOND:return oL(e,t)}},cL=(e,t)=>{let{stride:n,children:r}=e,i=r[0],a=i.slice(t*n,n);return new fR([a])};yI.prototype.visitNull=bI(SI),yI.prototype.visitBool=bI(wI),yI.prototype.visitInt=bI(NI),yI.prototype.visitInt8=bI(DI),yI.prototype.visitInt16=bI(DI),yI.prototype.visitInt32=bI(DI),yI.prototype.visitInt64=bI(kI),yI.prototype.visitUint8=bI(DI),yI.prototype.visitUint16=bI(DI),yI.prototype.visitUint32=bI(DI),yI.prototype.visitUint64=bI(kI),yI.prototype.visitFloat=bI(PI),yI.prototype.visitFloat16=bI(OI),yI.prototype.visitFloat32=bI(DI),yI.prototype.visitFloat64=bI(DI),yI.prototype.visitUtf8=bI(MI),yI.prototype.visitLargeUtf8=bI(MI),yI.prototype.visitBinary=bI(jI),yI.prototype.visitLargeBinary=bI(jI),yI.prototype.visitFixedSizeBinary=bI(AI),yI.prototype.visitDate=bI(FI),yI.prototype.visitDateDay=bI(TI),yI.prototype.visitDateMillisecond=bI(EI),yI.prototype.visitTimestamp=bI(BI),yI.prototype.visitTimestampSecond=bI(II),yI.prototype.visitTimestampMillisecond=bI(LI),yI.prototype.visitTimestampMicrosecond=bI(RI),yI.prototype.visitTimestampNanosecond=bI(zI),yI.prototype.visitTime=bI(GI),yI.prototype.visitTimeSecond=bI(VI),yI.prototype.visitTimeMillisecond=bI(HI),yI.prototype.visitTimeMicrosecond=bI(UI),yI.prototype.visitTimeNanosecond=bI(WI),yI.prototype.visitDecimal=bI(KI),yI.prototype.visitList=bI(qI),yI.prototype.visitStruct=bI(YI),yI.prototype.visitUnion=bI(XI),yI.prototype.visitDenseUnion=bI(ZI),yI.prototype.visitSparseUnion=bI(QI),yI.prototype.visitDictionary=bI($I),yI.prototype.visitInterval=bI(eL),yI.prototype.visitIntervalDayTime=bI(tL),yI.prototype.visitIntervalYearMonth=bI(nL),yI.prototype.visitDuration=bI(sL),yI.prototype.visitDurationSecond=bI(rL),yI.prototype.visitDurationMillisecond=bI(iL),yI.prototype.visitDurationMicrosecond=bI(aL),yI.prototype.visitDurationNanosecond=bI(oL),yI.prototype.visitFixedSizeList=bI(cL),yI.prototype.visitMap=bI(JI);const lL=new yI,uL=Symbol.for(`keys`),dL=Symbol.for(`vals`),fL=Symbol.for(`kKeysAsStrings`),pL=Symbol.for(`_kKeysAsStrings`);var mL=class{constructor(e){return this[uL]=new fR([e.children[0]]).memoize(),this[dL]=e.children[1],new Proxy(this,new gL)}get[fL](){return this[pL]||(this[pL]=Array.from(this[uL].toArray(),String))}[Symbol.iterator](){return new hL(this[uL],this[dL])}get size(){return this[uL].length}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[uL],t=this[dL],n={};for(let r=-1,i=e.length;++r`${YN(e)}: ${YN(t)}`).join(`, `)}}`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}},hL=class{constructor(e,t){this.keys=e,this.vals=t,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){let e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),lL.visit(this.vals,e)]})}},gL=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[fL]}has(e,t){return e[fL].includes(t)}getOwnPropertyDescriptor(e,t){let n=e[fL].indexOf(t);if(n!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];let n=e[fL].indexOf(t);if(n!==-1){let r=lL.visit(Reflect.get(e,dL),n);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[fL].indexOf(t);return r===-1?Reflect.has(e,t)?Reflect.set(e,t,n):!1:(pI.visit(Reflect.get(e,dL),r,n),Reflect.set(e,t,n))}};Object.defineProperties(mL.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:`Row`},[uL]:{writable:!0,enumerable:!1,configurable:!1,value:null},[dL]:{writable:!0,enumerable:!1,configurable:!1,value:null},[pL]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let _L;function vL(e,t,n,r){let{length:i=0}=e,a=typeof t==`number`?t:0,o=typeof n==`number`?n:i;return a<0&&(a=(a%i+i)%i),o<0&&(o=(o%i+i)%i),oi&&(o=i),r?r(e,a,o):[a,o]}const yL=(e,t)=>e<0?t+e:e,bL=e=>e!==e;function xL(e){let t=typeof e;if(t!==`object`||e===null)return bL(e)?bL:t=>t===e;if(e instanceof Date){let t=e.valueOf();return e=>e instanceof Date?e.valueOf()===t:!1}return ArrayBuffer.isView(e)?t=>t?BM(e,t):!1:e instanceof Map?CL(e):Array.isArray(e)?SL(e):e instanceof fR?wL(e):TL(e,!0)}function SL(e){let t=[];for(let n=-1,r=e.length;++n!1;let r=[];for(let t=-1,i=n.length;++t{if(!n||typeof n!=`object`)return!1;switch(n.constructor){case Array:return DL(e,n);case Map:return kL(e,n,n.keys());case mL:case gI:case Object:case void 0:return kL(e,n,t||Object.keys(n))}return n instanceof fR?OL(e,n):!1}}function DL(e,t){let n=e.length;if(t.length!==n)return!1;for(let r=-1;++r>r}function ML(e,t,n){let r=n.byteLength+7&-8;if(e>0||n.byteLength>3):NL(new PL(n,e,t,null,AL)).subarray(0,r)),i}return n}function NL(e){let t=[],n=0,r=0,i=0;for(let a of e)a&&(i|=1<0)&&(t[n++]=i);let a=new Uint8Array(t.length+7&-8);return a.set(t),a}var PL=class{constructor(e,t,n,r,i){this.bytes=e,this.length=n,this.context=r,this.get=i,this.bit=t%8,this.byteIndex=t>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,i=t+(t%8==0?0:8-t%8);return FL(e,t,i)+FL(e,r,n)+IL(e,i>>3,r-i>>3)}function IL(e,t,n){let r=0,i=Math.trunc(t),a=new DataView(e.buffer,e.byteOffset,e.byteLength),o=n===void 0?e.byteLength:i+n;for(;o-i>=4;)r+=LL(a.getUint32(i)),i+=4;for(;o-i>=2;)r+=LL(a.getUint16(i)),i+=2;for(;o-i>=1;)r+=LL(a.getUint8(i)),i+=1;return r}function LL(e){let t=Math.trunc(e);return t-=t>>>1&1431655765,t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}const RL=-1;var zL=class e{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){let{type:e}=this;return MP.isSparseUnion(e)||MP.isDenseUnion(e)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0,{valueOffsets:t,values:n,nullBitmap:r,typeIds:i}=this;return t&&(e+=t.byteLength),n&&(e+=n.byteLength),r&&(e+=r.byteLength),i&&(e+=i.byteLength),this.children.reduce((e,t)=>e+t.byteLength,e)}get nullCount(){if(MP.isUnion(this.type))return this.children.reduce((e,t)=>e+t.nullCount,0);let e=this._nullCount,t;return e<=RL&&(t=this.nullBitmap)&&(this._nullCount=e=t.length===0?0:this.length-FL(t,this.offset,this.offset+this.length)),e}constructor(t,n,r,i,a,o=[],s){this.type=t,this.children=o,this.dictionary=s,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let c;a instanceof e?(this.stride=a.stride,this.values=a.values,this.typeIds=a.typeIds,this.nullBitmap=a.nullBitmap,this.valueOffsets=a.valueOffsets):(this.stride=fF(t),a&&((c=a[0])&&(this.valueOffsets=c),(c=a[1])&&(this.values=c),(c=a[2])&&(this.nullBitmap=c),(c=a[3])&&(this.typeIds=c)))}getValid(e){let{type:t}=this;if(MP.isUnion(t)){let n=t,r=this.children[n.typeIdToChildIndex[this.typeIds[e]]],i=n.mode===XM.Dense?this.valueOffsets[e]:e;return r.getValid(i)}if(this.nullable&&this.nullCount>0){let t=this.offset+e,n=this.nullBitmap[t>>3];return(n&1<>3;(!r||r.byteLength<=c)&&(r=new Uint8Array((i+a+63&-64)>>3).fill(255),this.nullCount>0?(r.set(ML(i,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:r})):Object.assign(this,{nullBitmap:r,_nullCount:0}));let l=r[c];n=(l&s)!==0,r[c]=t?l|s:l&~s}return n!==!!t&&(this._nullCount=this.nullCount+(t?-1:1)),t}clone(t=this.type,n=this.offset,r=this.length,i=this._nullCount,a=this,o=this.children){return new e(t,n,r,i,a,o,this.dictionary)}slice(e,t){let{stride:n,typeId:r,children:i}=this,a=(this._nullCount===0)-1,o=r===16?n:1,s=this._sliceBuffers(e,t,n,r);return this.clone(this.type,this.offset+e,t,a,s,i.length===0||this.valueOffsets?i:this._sliceChildren(i,o*e,o*t))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===Y.Null)return this.clone(this.type,0,e,0);let{length:t,nullCount:n}=this,r=new Uint8Array((e+63&-64)>>3).fill(255,0,t>>3);r[t>>3]=(1<0&&r.set(ML(this.offset,t,this.nullBitmap),0);let i=this.buffers;return i[qN.VALIDITY]=r,this.clone(this.type,0,e,n+(e-t),i)}_sliceBuffers(e,t,n,r){let i,{buffers:a}=this;return(i=a[qN.TYPE])&&(a[qN.TYPE]=i.subarray(e,e+t)),(i=a[qN.OFFSET])&&(a[qN.OFFSET]=i.subarray(e,e+t+1))||(i=a[qN.DATA])&&(a[qN.DATA]=r===6?i:i.subarray(n*e,n*(e+t))),a}_sliceChildren(e,t,n){return e.map(e=>e.slice(t,n))}};zL.prototype.children=Object.freeze([]);var BL=class e extends pF{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){let{type:t,offset:n=0,length:r=0}=e;return new zL(t,n,r,r)}visitBool(e){let{type:t,offset:n=0}=e,r=NM(e.nullBitmap),i=AM(t.ArrayType,e.data),{length:a=i.length>>3,nullCount:o=e.nullBitmap?-1:0}=e;return new zL(t,n,a,o,[void 0,i,r])}visitInt(e){let{type:t,offset:n=0}=e,r=NM(e.nullBitmap),i=AM(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new zL(t,n,a,o,[void 0,i,r])}visitFloat(e){let{type:t,offset:n=0}=e,r=NM(e.nullBitmap),i=AM(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new zL(t,n,a,o,[void 0,i,r])}visitUtf8(e){let{type:t,offset:n=0}=e,r=NM(e.data),i=NM(e.nullBitmap),a=jM(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new zL(t,n,o,s,[a,r,i])}visitLargeUtf8(e){let{type:t,offset:n=0}=e,r=NM(e.data),i=NM(e.nullBitmap),a=MM(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new zL(t,n,o,s,[a,r,i])}visitBinary(e){let{type:t,offset:n=0}=e,r=NM(e.data),i=NM(e.nullBitmap),a=jM(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new zL(t,n,o,s,[a,r,i])}visitLargeBinary(e){let{type:t,offset:n=0}=e,r=NM(e.data),i=NM(e.nullBitmap),a=MM(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new zL(t,n,o,s,[a,r,i])}visitFixedSizeBinary(e){let{type:t,offset:n=0}=e,r=NM(e.nullBitmap),i=AM(t.ArrayType,e.data),{length:a=i.length/fF(t),nullCount:o=e.nullBitmap?-1:0}=e;return new zL(t,n,a,o,[void 0,i,r])}visitDate(e){let{type:t,offset:n=0}=e,r=NM(e.nullBitmap),i=AM(t.ArrayType,e.data),{length:a=i.length/fF(t),nullCount:o=e.nullBitmap?-1:0}=e;return new zL(t,n,a,o,[void 0,i,r])}visitTimestamp(e){let{type:t,offset:n=0}=e,r=NM(e.nullBitmap),i=AM(t.ArrayType,e.data),{length:a=i.length/fF(t),nullCount:o=e.nullBitmap?-1:0}=e;return new zL(t,n,a,o,[void 0,i,r])}visitTime(e){let{type:t,offset:n=0}=e,r=NM(e.nullBitmap),i=AM(t.ArrayType,e.data),{length:a=i.length/fF(t),nullCount:o=e.nullBitmap?-1:0}=e;return new zL(t,n,a,o,[void 0,i,r])}visitDecimal(e){let{type:t,offset:n=0}=e,r=NM(e.nullBitmap),i=AM(t.ArrayType,e.data),{length:a=i.length/fF(t),nullCount:o=e.nullBitmap?-1:0}=e;return new zL(t,n,a,o,[void 0,i,r])}visitList(e){let{type:t,offset:n=0,child:r}=e,i=NM(e.nullBitmap),a=jM(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new zL(t,n,o,s,[a,void 0,i],[r])}visitStruct(e){let{type:t,offset:n=0,children:r=[]}=e,i=NM(e.nullBitmap),{length:a=r.reduce((e,{length:t})=>Math.max(e,t),0),nullCount:o=e.nullBitmap?-1:0}=e;return new zL(t,n,a,o,[void 0,void 0,i],r)}visitUnion(e){let{type:t,offset:n=0,children:r=[]}=e,i=AM(t.ArrayType,e.typeIds),{length:a=i.length,nullCount:o=-1}=e;if(MP.isSparseUnion(t))return new zL(t,n,a,o,[void 0,void 0,void 0,i],r);let s=jM(e.valueOffsets);return new zL(t,n,a,o,[s,void 0,void 0,i],r)}visitDictionary(t){let{type:n,offset:r=0}=t,i=NM(t.nullBitmap),a=AM(n.indices.ArrayType,t.data),{dictionary:o=new fR([new e().visit({type:n.dictionary})])}=t,{length:s=a.length,nullCount:c=t.nullBitmap?-1:0}=t;return new zL(n,r,s,c,[void 0,a,i],[],o)}visitInterval(e){let{type:t,offset:n=0}=e,r=NM(e.nullBitmap),i=AM(t.ArrayType,e.data),{length:a=i.length/fF(t),nullCount:o=e.nullBitmap?-1:0}=e;return new zL(t,n,a,o,[void 0,i,r])}visitDuration(e){let{type:t,offset:n=0}=e,r=NM(e.nullBitmap),i=AM(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new zL(t,n,a,o,[void 0,i,r])}visitFixedSizeList(t){let{type:n,offset:r=0,child:i=new e().visit({type:n.valueType})}=t,a=NM(t.nullBitmap),{length:o=i.length/fF(n),nullCount:s=t.nullBitmap?-1:0}=t;return new zL(n,r,o,s,[void 0,void 0,a],[i])}visitMap(t){let{type:n,offset:r=0,child:i=new e().visit({type:n.childType})}=t,a=NM(t.nullBitmap),o=jM(t.valueOffsets),{length:s=o.length-1,nullCount:c=t.nullBitmap?-1:0}=t;return new zL(n,r,s,c,[o,void 0,a],[i])}};const VL=new BL;function HL(e){return VL.visit(e)}var UL=class{constructor(e=0,t){this.numChunks=e,this.getChunkIterator=t,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function GL(e){return e.reduce((e,t)=>e+t.nullCount,0)}function KL(e){return e.reduce((e,t,n)=>(e[n+1]=e[n]+t.length,e),new Uint32Array(e.length+1))}function qL(e,t,n,r){let i=[];for(let a=-1,o=e.length;++a=r)break;if(n>=s+c)continue;if(s>=n&&s+c<=r){i.push(o);continue}let l=Math.max(0,n-s),u=Math.min(r-s,c);i.push(o.slice(l,u-l))}return i.length===0&&i.push(e[0].slice(0,0)),i}function JL(e,t,n,r){let i=0,a=0,o=t.length-1;do{if(i>=o-1)return n0?0:-1}function tR(e,t){let{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(let i of new PL(n,e.offset+(t||0),e.length,n,AL)){if(!i)return r;++r}return-1}function nR(e,t,n){if(t===void 0)return-1;if(t===null)switch(e.typeId){case Y.Union:break;case Y.Dictionary:break;default:return tR(e,n)}let r=lL.getVisitFn(e),i=xL(t);for(let t=(n||0)-1,a=e.length;++t{let n=e.data[t];return n.values.subarray(0,n.length)[Symbol.iterator]()});let n=0;return new UL(e.data.length,t=>{let r=e.data[t],i=r.length,a=e.slice(n,n+i);return n+=i,new sR(a)})}var sR=class{constructor(e){this.vector=e,this.index=0}next(){return this.indexe.data):t;if(a.length===0||a.some(e=>!(e instanceof zL)))throw TypeError(`Vector constructor expects an Array of Data instances.`);let o=(n=a[0])?.type;switch(a.length){case 0:this._offsets=[0];break;case 1:{let{get:e,set:t,indexOf:n}=uR[o.typeId],r=a[0];this.isValid=e=>YL(r,e),this.get=t=>e(r,t),this.set=(e,n)=>t(r,e,n),this.indexOf=e=>n(r,e),this._offsets=[0,r.length];break}default:Object.setPrototypeOf(this,dR[o.typeId]),this._offsets=KL(a);break}this.data=a,this.type=o,this.stride=fF(o),this.numChildren=(i=(r=o.children)?.length)??0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,t)=>e+t.byteLength,0)}get nullable(){return WL(this.data)}get nullCount(){return GL(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${Y[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(yL(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return cR.visit(this)}concat(...t){return new e(this.data.concat(t.flatMap(e=>e.data).flat(1/0)))}slice(t,n){return new e(vL(this,t,n,({data:e,_offsets:t},n,r)=>qL(e,t,n,r)))}toJSON(){return[...this]}toArray(){let{type:e,data:t,length:n,stride:r,ArrayType:i}=this;switch(e.typeId){case Y.Int:case Y.Float:case Y.Decimal:case Y.Time:case Y.Timestamp:switch(t.length){case 0:return new i;case 1:return t[0].values.subarray(0,n*r);default:return t.reduce((e,{values:t,length:n})=>(e.array.set(t.subarray(0,n*r),e.offset),e.offset+=n*r,e),{array:new i(n*r),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(`,`)}]`}getChild(e){var t;return this.getChildAt((t=this.type.children)?.findIndex(t=>t.name===e))}getChildAt(t){return t>-1&&te[t])):null}get isMemoized(){return MP.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(MP.isDictionary(this.type)){let t=new pR(this.data[0].dictionary),n=this.data.map(e=>{let n=e.clone();return n.dictionary=t,n});return new e(n)}return new pR(this)}unmemoize(){if(MP.isDictionary(this.type)&&this.isMemoized){let t=this.data[0].dictionary.unmemoize(),n=this.data.map(e=>{let n=e.clone();return n.dictionary=t,n});return new e(n)}return this}};lR=Symbol.toStringTag,fR[lR]=(e=>{e.type=MP.prototype,e.data=[],e.length=0,e.stride=1,e.numChildren=0,e._offsets=new Uint32Array([0]),e[Symbol.isConcatSpreadable]=!0;let t=Object.keys(Y).map(e=>Y[e]).filter(e=>typeof e==`number`&&e!==Y.NONE);for(let n of t){let t=lL.getVisitFnByTypeId(n),r=pI.getVisitFnByTypeId(n),i=iR.getVisitFnByTypeId(n);uR[n]={get:t,set:r,indexOf:i},dR[n]=Object.create(e,{isValid:{value:XL(YL)},get:{value:XL(lL.getVisitFnByTypeId(n))},set:{value:ZL(pI.getVisitFnByTypeId(n))},indexOf:{value:QL(iR.getVisitFnByTypeId(n))}})}return`Vector`})(fR.prototype);var pR=class e extends fR{constructor(t){super(t.data);let n=this.get,r=this.set,i=this.slice,a=Array(this.length);Object.defineProperty(this,`get`,{value(e){let t=a[e];if(t!==void 0)return t;let r=n.call(this,e);return a[e]=r,r}}),Object.defineProperty(this,`set`,{value(e,t){r.call(this,e,t),a[e]=t}}),Object.defineProperty(this,`slice`,{value:(t,n)=>new e(i.call(this,t,n))}),Object.defineProperty(this,`isMemoized`,{value:!0}),Object.defineProperty(this,`unmemoize`,{value:()=>new fR(this.data)}),Object.defineProperty(this,`memoize`,{value:()=>this})}},mR=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,t,n,r){return e.prep(8,24),e.writeInt64(BigInt(r??0)),e.pad(4),e.writeInt32(n),e.writeInt64(BigInt(t??0)),e.offset()}},hR=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFooter(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,n){return t.setPosition(t.position()+iN),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}version(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):YM.V1}schema(e){let t=this.bb.__offset(this.bb_pos,6);return t?(e||new GN).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}dictionaries(e,t){let n=this.bb.__offset(this.bb_pos,8);return n?(t||new mR).__init(this.bb.__vector(this.bb_pos+n)+e*24,this.bb):null}dictionariesLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,t){let n=this.bb.__offset(this.bb_pos,10);return n?(t||new mR).__init(this.bb.__vector(this.bb_pos+n)+e*24,this.bb):null}recordBatchesLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){let n=this.bb.__offset(this.bb_pos,12);return n?(t||new CN).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,YM.V1)}static addSchema(e,t){e.addFieldOffset(1,t,0)}static addDictionaries(e,t){e.addFieldOffset(2,t,0)}static startDictionariesVector(e,t){e.startVector(24,t,8)}static addRecordBatches(e,t){e.addFieldOffset(3,t,0)}static startRecordBatchesVector(e,t){e.startVector(24,t,8)}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endFooter(e){let t=e.endObject();return t}static finishFooterBuffer(e,t){e.finish(t)}static finishSizePrefixedFooterBuffer(e,t){e.finish(t,void 0,!0)}},gR=class e{constructor(e=[],t,n,r=YM.V5){this.fields=e||[],this.metadata=t||new Map,n||=yR(this.fields),this.dictionaries=n,this.metadataVersion=r}get[Symbol.toStringTag](){return`Schema`}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,t)=>`${t}: ${e}`).join(`, `)} }>`}select(t){let n=new Set(t),r=this.fields.filter(e=>n.has(e.name));return new e(r,this.metadata)}selectAt(t){let n=t.map(e=>this.fields[e]).filter(Boolean);return new e(n,this.metadata)}assign(...t){let n=t[0]instanceof e?t[0]:Array.isArray(t[0])?new e(t[0]):new e(t),r=[...this.fields],i=vR(vR(new Map,this.metadata),n.metadata),a=n.fields.filter(e=>{let t=r.findIndex(t=>t.name===e.name);return~t?(r[t]=e.clone({metadata:vR(vR(new Map,r[t].metadata),e.metadata)}))&&!1:!0}),o=yR(a,new Map);return new e([...r,...a],i,new Map([...this.dictionaries,...o]))}};gR.prototype.fields=null,gR.prototype.metadata=null,gR.prototype.dictionaries=null;var _R=class e{static new(...t){let[n,r,i,a]=t;return t[0]&&typeof t[0]==`object`&&({name:n}=t[0],r===void 0&&(r=t[0].type),i===void 0&&(i=t[0].nullable),a===void 0&&(a=t[0].metadata)),new e(`${n}`,r,i,a)}constructor(e,t,n=!1,r){this.name=e,this.type=t,this.nullable=n,this.metadata=r||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return`Field`}toString(){return`${this.name}: ${this.type}`}clone(...t){let[n,r,i,a]=t;return!t[0]||typeof t[0]!=`object`?[n=this.name,r=this.type,i=this.nullable,a=this.metadata]=t:{name:n=this.name,type:r=this.type,nullable:i=this.nullable,metadata:a=this.metadata}=t[0],e.new(n,r,i,a)}};_R.prototype.type=null,_R.prototype.name=null,_R.prototype.nullable=null,_R.prototype.metadata=null;function vR(e,t){return new Map([...e||new Map,...t||new Map])}function yR(e,t=new Map){for(let n=-1,r=e.length;++n0&&yR(i.children,t)}return t}var bR=dN,xR=uN,SR=class{static decode(e){e=new xR(NM(e));let t=hR.getRootAsFooter(e),n=gR.decode(t.schema(),new Map,t.version());return new CR(n,t)}static encode(e){let t=new bR,n=gR.encode(t,e.schema);hR.startRecordBatchesVector(t,e.numRecordBatches);for(let n of[...e.recordBatches()].slice().reverse())wR.encode(t,n);let r=t.endVector();hR.startDictionariesVector(t,e.numDictionaries);for(let n of[...e.dictionaryBatches()].slice().reverse())wR.encode(t,n);let i=t.endVector();return hR.startFooter(t),hR.addSchema(t,n),hR.addVersion(t,YM.V5),hR.addRecordBatches(t,r),hR.addDictionaries(t,i),hR.finishFooterBuffer(t,hR.endFooter(t)),t.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,t=YM.V5,n,r){this.schema=e,this.version=t,n&&(this._recordBatches=n),r&&(this._dictionaryBatches=r)}*recordBatches(){for(let e,t=-1,n=this.numRecordBatches;++t=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return $j(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){let{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(TR);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return VM.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return VM.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return $j(this,void 0,void 0,function*(){return yield this.abort(e),TR})}return(e){return $j(this,void 0,void 0,function*(){return yield this.close(),TR})}read(e){return $j(this,void 0,void 0,function*(){return(yield this.next(e,`read`)).value})}peek(e){return $j(this,void 0,void 0,function*(){return(yield this.next(e,`peek`)).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((e,t)=>{this.resolvers.push({resolve:e,reject:t})}):Promise.resolve(TR)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw Error(`AsyncQueue is closed`)}},kR=class extends OR{write(e){if((e=NM(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?oM(this.toUint8Array(!0)):this.toUint8Array(!1).then(oM)}toUint8Array(e=!1){return e?kM(this._values)[0]:(()=>$j(this,void 0,void 0,function*(){var e,t,n,r;let i=[],a=0;try{for(var o=!0,s=iM(this),c;c=yield s.next(),e=c.done,!e;o=!0){r=c.value,o=!1;let e=r;i.push(e),a+=e.byteLength}}catch(e){t={error:e}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(t)throw t.error}}return kM(i,a)[0]}))()}},AR=class{constructor(e){e&&(this.source=new MR(VM.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}},jR=class e{constructor(t){t instanceof e?this.source=t.source:t instanceof kR?this.source=new NR(VM.fromAsyncIterable(t)):wM(t)?this.source=new NR(VM.fromNodeStream(t)):SM(t)?this.source=new NR(VM.fromDOMStream(t)):yM(t)?this.source=new NR(VM.fromDOMStream(t.body)):mM(t)?this.source=new NR(VM.fromIterable(t)):(pM(t)||hM(t))&&(this.source=new NR(VM.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}},MR=class{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,`peek`).value}read(e){return this.next(e,`read`).value}next(e,t=`read`){return this.source.next({cmd:t,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||TR)}return(e){return Object.create(this.source.return&&this.source.return(e)||TR)}},NR=class{constructor(e){this.source=e,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(e){return $j(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return $j(this,void 0,void 0,function*(){return(yield this.next(e,`read`)).value})}peek(e){return $j(this,void 0,void 0,function*(){return(yield this.next(e,`peek`)).value})}next(e){return $j(this,arguments,void 0,function*(e,t=`read`){return yield this.source.next({cmd:t,size:e})})}throw(e){return $j(this,void 0,void 0,function*(){let t=this.source.throw&&(yield this.source.throw(e))||TR;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}return(e){return $j(this,void 0,void 0,function*(){let t=this.source.return&&(yield this.source.return(e))||TR;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}},PR=class extends AR{constructor(e,t){super(),this.position=0,this.buffer=NM(e),this.size=t===void 0?this.buffer.byteLength:t}readInt32(e){let{buffer:t,byteOffset:n}=this.readAt(e,4);return new DataView(t,n).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),e$j(this,void 0,void 0,function*(){this.size=(yield e.stat()).size,delete this._pending}))()}readInt32(e){return $j(this,void 0,void 0,function*(){let{buffer:t,byteOffset:n}=yield this.readAt(e,4);return new DataView(t,n).getInt32(0,!0)})}seek(e){return $j(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(e,this.size),e>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),n=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]),r=t[3]*n[3];this.buffer[0]=r&65535;let i=r>>>16;return r=t[2]*n[3],i+=r,r=t[3]*n[2]>>>0,i+=r,this.buffer[0]+=i<<16,this.buffer[1]=i>>>0>>16,this.buffer[1]+=t[1]*n[3]+t[2]*n[2]+t[3]*n[1],this.buffer[1]+=t[0]*n[3]+t[1]*n[2]+t[2]*n[1]+t[3]*n[0]<<16,this}_plus(e){let t=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],t>>0&&++this.buffer[1],this.buffer[0]=t}lessThan(e){return this.buffer[1]>>0,t[2]=this.buffer[2]+e.buffer[2]>>>0,t[1]=this.buffer[1]+e.buffer[1]>>>0,t[0]=this.buffer[0]+e.buffer[0]>>>0,t[0]>>0&&++t[1],t[1]>>0&&++t[2],t[2]>>0&&++t[3],this.buffer[3]=t[3],this.buffer[2]=t[2],this.buffer[1]=t[1],this.buffer[0]=t[0],this}hex(){return`${LR(this.buffer[3])} ${LR(this.buffer[2])} ${LR(this.buffer[1])} ${LR(this.buffer[0])}`}static multiply(t,n){let r=new e(new Uint32Array(t.buffer));return r.times(n)}static add(t,n){let r=new e(new Uint32Array(t.buffer));return r.plus(n)}static from(t,n=new Uint32Array(4)){return e.fromString(typeof t==`string`?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(4)){return e.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(4)){let r=t.startsWith(`-`),i=t.length,a=new e(n);for(let n=r?1:0;n0&&this.readData(e,n)||new Uint8Array}readOffsets(e,t){return this.readData(e,t)}readTypeIds(e,t){return this.readData(e,t)}readData(e,{length:t,offset:n}=this.nextBufferRange()){return this.bytes.subarray(n,n+t)}readDictionary(e){return this.dictionaries.get(e.id)}},GR=class extends WR{constructor(e,t,n,r,i){super(new Uint8Array,t,n,r,i),this.sources=e}readNullBitmap(e,t,{offset:n}=this.nextBufferRange()){return t<=0?new Uint8Array:NL(this.sources[n])}readOffsets(e,{offset:t}=this.nextBufferRange()){return AM(Uint8Array,AM(e.OffsetArrayType,this.sources[t]))}readTypeIds(e,{offset:t}=this.nextBufferRange()){return AM(Uint8Array,AM(e.ArrayType,this.sources[t]))}readData(e,{offset:t}=this.nextBufferRange()){let{sources:n}=this;return MP.isTimestamp(e)||(MP.isInt(e)||MP.isTime(e))&&e.bitWidth===64||MP.isDuration(e)||MP.isDate(e)&&e.unit===QM.MILLISECOND?AM(Uint8Array,HR.convertArray(n[t])):MP.isDecimal(e)?AM(Uint8Array,UR.convertArray(n[t])):MP.isBinary(e)||MP.isLargeBinary(e)||MP.isFixedSizeBinary(e)?KR(n[t]):MP.isBool(e)?NL(n[t]):MP.isUtf8(e)||MP.isLargeUtf8(e)?cM(n[t].join(``)):AM(Uint8Array,AM(e.ArrayType,n[t].map(e=>+e)))}};function KR(e){let t=e.join(``),n=new Uint8Array(t.length/2);for(let e=0;e>1]=Number.parseInt(t.slice(e,e+2),16);return n}var qR=class extends pF{compareSchemas(e,t){return e===t||t instanceof e.constructor&&this.compareManyFields(e.fields,t.fields)}compareManyFields(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>this.compareFields(e,t[n]))}compareFields(e,t){return e===t||t instanceof e.constructor&&e.name===t.name&&e.nullable===t.nullable&&this.visit(e.type,t.type)}};function JR(e,t){return t instanceof e.constructor}function YR(e,t){return e===t||JR(e,t)}function XR(e,t){return e===t||JR(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function ZR(e,t){return e===t||JR(e,t)&&e.precision===t.precision}function QR(e,t){return e===t||JR(e,t)&&e.byteWidth===t.byteWidth}function $R(e,t){return e===t||JR(e,t)&&e.unit===t.unit}function ez(e,t){return e===t||JR(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function tz(e,t){return e===t||JR(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function nz(e,t){return e===t||JR(e,t)&&e.children.length===t.children.length&&uz.compareManyFields(e.children,t.children)}function rz(e,t){return e===t||JR(e,t)&&e.children.length===t.children.length&&uz.compareManyFields(e.children,t.children)}function iz(e,t){return e===t||JR(e,t)&&e.mode===t.mode&&e.typeIds.every((e,n)=>e===t.typeIds[n])&&uz.compareManyFields(e.children,t.children)}function az(e,t){return e===t||JR(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&uz.visit(e.indices,t.indices)&&uz.visit(e.dictionary,t.dictionary)}function oz(e,t){return e===t||JR(e,t)&&e.unit===t.unit}function sz(e,t){return e===t||JR(e,t)&&e.unit===t.unit}function cz(e,t){return e===t||JR(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&uz.compareManyFields(e.children,t.children)}function lz(e,t){return e===t||JR(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&uz.compareManyFields(e.children,t.children)}qR.prototype.visitNull=YR,qR.prototype.visitBool=YR,qR.prototype.visitInt=XR,qR.prototype.visitInt8=XR,qR.prototype.visitInt16=XR,qR.prototype.visitInt32=XR,qR.prototype.visitInt64=XR,qR.prototype.visitUint8=XR,qR.prototype.visitUint16=XR,qR.prototype.visitUint32=XR,qR.prototype.visitUint64=XR,qR.prototype.visitFloat=ZR,qR.prototype.visitFloat16=ZR,qR.prototype.visitFloat32=ZR,qR.prototype.visitFloat64=ZR,qR.prototype.visitUtf8=YR,qR.prototype.visitLargeUtf8=YR,qR.prototype.visitBinary=YR,qR.prototype.visitLargeBinary=YR,qR.prototype.visitFixedSizeBinary=QR,qR.prototype.visitDate=$R,qR.prototype.visitDateDay=$R,qR.prototype.visitDateMillisecond=$R,qR.prototype.visitTimestamp=ez,qR.prototype.visitTimestampSecond=ez,qR.prototype.visitTimestampMillisecond=ez,qR.prototype.visitTimestampMicrosecond=ez,qR.prototype.visitTimestampNanosecond=ez,qR.prototype.visitTime=tz,qR.prototype.visitTimeSecond=tz,qR.prototype.visitTimeMillisecond=tz,qR.prototype.visitTimeMicrosecond=tz,qR.prototype.visitTimeNanosecond=tz,qR.prototype.visitDecimal=YR,qR.prototype.visitList=nz,qR.prototype.visitStruct=rz,qR.prototype.visitUnion=iz,qR.prototype.visitDenseUnion=iz,qR.prototype.visitSparseUnion=iz,qR.prototype.visitDictionary=az,qR.prototype.visitInterval=oz,qR.prototype.visitIntervalDayTime=oz,qR.prototype.visitIntervalYearMonth=oz,qR.prototype.visitDuration=sz,qR.prototype.visitDurationSecond=sz,qR.prototype.visitDurationMillisecond=sz,qR.prototype.visitDurationMicrosecond=sz,qR.prototype.visitDurationNanosecond=sz,qR.prototype.visitFixedSizeList=cz,qR.prototype.visitMap=lz;const uz=new qR;function dz(e,t){return uz.compareSchemas(e,t)}function fz(e,t){return pz(e,t.map(e=>e.data.concat()))}function pz(e,t){let n=[...e.fields],r=[],i={numBatches:t.reduce((e,t)=>Math.max(e,t.length),0)},a=0,o=0,s=-1,c=t.length,l,u=[];for(;i.numBatches-- >0;){for(o=1/0,s=-1;++s0&&(r[a++]=HL({type:new aF(n),length:o,nullCount:0,children:u.slice()})))}return[e=e.assign(n),r.map(t=>new vz(e,t))]}function mz(e,t,n,r,i){var a;let o=(t+63&-64)>>3;for(let s=-1,c=r.length;++s=t)l===t?n[s]=c:(n[s]=c.slice(0,t),i.numBatches=Math.max(i.numBatches,r[s].unshift(c.slice(t,l-t))));else{let r=e[s];e[s]=r.clone({nullable:!0}),n[s]=(a=c?._changeLengthAndBackfillNullBitmap(t))??HL({type:r.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return n}var hz,gz=class e{constructor(...t){var n,r;if(t.length===0)return this.batches=[],this.schema=new gR([]),this._offsets=[0],this;let i,a;t[0]instanceof gR&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(a=t.pop());let o=t=>{if(t){if(t instanceof vz)return[t];if(t instanceof e)return t.batches;if(t instanceof zL){if(t.type instanceof aF)return[new vz(new gR(t.type.children),t)]}else if(Array.isArray(t))return t.flatMap(e=>o(e));else if(typeof t[Symbol.iterator]==`function`)return[...t].flatMap(e=>o(e));else if(typeof t==`object`){let e=Object.keys(t),n=e.map(e=>new fR([t[e]])),r=i??new gR(e.map((e,t)=>new _R(String(e),n[t].type,n[t].nullable))),[,a]=fz(r,n);return a.length===0?[new vz(t)]:a}}return[]},s=t.flatMap(e=>o(e));if(i=(r=i??(n=s[0])?.schema)??new gR([]),!(i instanceof gR))throw TypeError(`Table constructor expects a [Schema, RecordBatch[]] pair.`);for(let e of s){if(!(e instanceof vz))throw TypeError(`Table constructor expects a [Schema, RecordBatch[]] pair.`);if(!dz(i,e.schema))throw TypeError(`Table and inner RecordBatch schemas must be equivalent.`)}this.schema=i,this.batches=s,this._offsets=a??KL(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,t)=>e+t.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=GL(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(yL(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?cR.visit(new fR(this.data)):[][Symbol.iterator]()}toArray(){return[...this]}toString(){return`[\n ${this.toArray().join(`, + `)}\n]`}concat(...t){let n=this.schema,r=this.data.concat(t.flatMap(({data:e})=>e));return new e(n,r.map(e=>new vz(n,e)))}slice(t,n){let r=this.schema;[t,n]=vL({length:this.numRows},t,n);let i=qL(this.data,this._offsets,t,n);return new e(r,i.map(e=>new vz(r,e)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(t=>t.name===e))}getChildAt(e){if(e>-1&&et.children[e]);if(t.length===0){let{type:n}=this.schema.fields[e],r=HL({type:n,length:0,nullCount:0});t.push(r._changeLengthAndBackfillNullBitmap(this.numRows))}return new fR(t)}return null}setChild(e,t){var n;return this.setChildAt((n=this.schema.fields)?.findIndex(t=>t.name===e),t)}setChildAt(t,n){let r=this.schema,i=[...this.batches];if(t>-1&&tthis.getChildAt(t));[e[t],o[t]]=[a,n],[r,i]=fz(r,o)}return new e(r,i)}select(e){let t=this.schema.fields.reduce((e,t,n)=>e.set(t.name,n),new Map);return this.selectAt(e.map(e=>t.get(e)).filter(e=>e>-1))}selectAt(t){let n=this.schema.selectAt(t),r=this.batches.map(e=>e.selectAt(t));return new e(n,r)}assign(t){let n=this.schema.fields,[r,i]=t.schema.fields.reduce((e,t,r)=>{let[i,a]=e,o=n.findIndex(e=>e.name===t.name);return~o?a[o]=r:i.push(r),e},[[],[]]),a=this.schema.assign(t.schema),o=[...n.map((e,t)=>[t,i[t]]).map(([e,n])=>n===void 0?this.getChildAt(e):t.getChildAt(n)),...r.map(e=>t.getChildAt(e))].filter(Boolean);return new e(...fz(a,o))}};hz=Symbol.toStringTag,gz[hz]=(e=>(e.schema=null,e.batches=[],e._offsets=new Uint32Array([0]),e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,e.isValid=XL(YL),e.get=XL(lL.getVisitFn(Y.Struct)),e.set=ZL(pI.getVisitFn(Y.Struct)),e.indexOf=QL(iR.getVisitFn(Y.Struct)),`Table`))(gz.prototype);var _z,vz=class e{constructor(...e){switch(e.length){case 2:if([this.schema]=e,!(this.schema instanceof gR)||([,this.data=HL({nullCount:0,type:new aF(this.schema.fields),children:this.schema.fields.map(e=>HL({type:e.type,nullCount:0}))})]=e,!(this.data instanceof zL)))throw TypeError(`RecordBatch constructor expects a [Schema, Data] pair.`);[this.schema,this.data]=yz(this.schema,this.data.children);break;case 1:{let[t]=e,{fields:n,children:r,length:i}=Object.keys(t).reduce((e,n,r)=>(e.children[r]=t[n],e.length=Math.max(e.length,t[n].length),e.fields[r]=_R.new({name:n,type:t[n].type,nullable:!0}),e),{length:0,fields:[],children:[]}),a=new gR(n),o=HL({type:new aF(n),length:i,children:r,nullCount:0});[this.schema,this.data]=yz(a,o.children,i);break}default:throw TypeError(`RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.`)}}get dictionaries(){return this._dictionaries||=bz(this.schema.fields,this.data.children)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return lL.visit(this.data,e)}at(e){return this.get(yL(e,this.numRows))}set(e,t){return pI.visit(this.data,e,t)}indexOf(e,t){return iR.visit(this.data,e,t)}[Symbol.iterator](){return cR.visit(new fR([this.data]))}toArray(){return[...this]}concat(...e){return new gz(this.schema,[this,...e])}slice(t,n){let[r]=new fR([this.data]).slice(t,n).data;return new e(this.schema,r)}getChild(e){var t;return this.getChildAt((t=this.schema.fields)?.findIndex(t=>t.name===e))}getChildAt(e){return e>-1&&et.name===e),t)}setChildAt(t,n){let r=this.schema,i=this.data;if(t>-1&&tt.name===e);~t&&(i[t]=this.data.children[t])}return new e(n,HL({type:r,length:this.numRows,children:i}))}selectAt(t){let n=this.schema.selectAt(t),r=t.map(e=>this.data.children[e]).filter(Boolean),i=HL({type:new aF(n.fields),length:this.numRows,children:r});return new e(n,i)}};_z=Symbol.toStringTag,vz[_z]=(e=>(e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,`RecordBatch`))(vz.prototype);function yz(e,t,n=t.reduce((e,t)=>Math.max(e,t.length),0)){var r;let i=[...e.fields],a=[...t],o=(n+63&-64)>>3;for(let[s,c]of e.fields.entries()){let e=t[s];(!e||e.length!==n)&&(i[s]=c.clone({nullable:!0}),a[s]=(r=e?._changeLengthAndBackfillNullBitmap(n))??HL({type:c.type,length:n,nullCount:n,nullBitmap:new Uint8Array(o)}))}return[e.assign(i),HL({type:new aF(i),length:n,children:a})]}function bz(e,t,n=new Map){var r,i;if(((r=e?.length)??0)>0&&e?.length===t?.length)for(let r=-1,a=e.length;++rHL({type:e.type})),n=HL({type:new aF(e.fields),nullCount:0,children:t});super(e,n)}},Sz=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsMessage(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,n){return t.setPosition(t.position()+iN),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}version(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):YM.V1}headerType(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):KN.NONE}header(e){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__union(e,this.bb_pos+t):null}bodyLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt(`0`)}customMetadata(e,t){let n=this.bb.__offset(this.bb_pos,12);return n?(t||new CN).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,YM.V1)}static addHeaderType(e,t){e.addFieldInt8(1,t,KN.NONE)}static addHeader(e,t){e.addFieldOffset(2,t,0)}static addBodyLength(e,t){e.addFieldInt64(3,t,BigInt(`0`))}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endMessage(e){let t=e.endObject();return t}static finishMessageBuffer(e,t){e.finish(t)}static finishSizePrefixedMessageBuffer(e,t){e.finish(t,void 0,!0)}static createMessage(t,n,r,i,a,o){return e.startMessage(t),e.addVersion(t,n),e.addHeaderType(t,r),e.addHeader(t,i),e.addBodyLength(t,a),e.addCustomMetadata(t,o),e.endMessage(t)}},Cz=class extends pF{visit(e,t){return e==null||t==null?void 0:super.visit(e,t)}visitNull(e,t){return LN.startNull(t),LN.endNull(t)}visitInt(e,t){return xN.startInt(t),xN.addBitWidth(t,e.bitWidth),xN.addIsSigned(t,e.isSigned),xN.endInt(t)}visitFloat(e,t){return jN.startFloatingPoint(t),jN.addPrecision(t,e.precision),jN.endFloatingPoint(t)}visitBinary(e,t){return wN.startBinary(t),wN.endBinary(t)}visitLargeBinary(e,t){return NN.startLargeBinary(t),NN.endLargeBinary(t)}visitBool(e,t){return TN.startBool(t),TN.endBool(t)}visitUtf8(e,t){return HN.startUtf8(t),HN.endUtf8(t)}visitLargeUtf8(e,t){return PN.startLargeUtf8(t),PN.endLargeUtf8(t)}visitDecimal(e,t){return DN.startDecimal(t),DN.addScale(t,e.scale),DN.addPrecision(t,e.precision),DN.addBitWidth(t,e.bitWidth),DN.endDecimal(t)}visitDate(e,t){return EN.startDate(t),EN.addUnit(t,e.unit),EN.endDate(t)}visitTime(e,t){return zN.startTime(t),zN.addUnit(t,e.unit),zN.addBitWidth(t,e.bitWidth),zN.endTime(t)}visitTimestamp(e,t){let n=e.timezone&&t.createString(e.timezone)||void 0;return BN.startTimestamp(t),BN.addUnit(t,e.unit),n!==void 0&&BN.addTimezone(t,n),BN.endTimestamp(t)}visitInterval(e,t){return MN.startInterval(t),MN.addUnit(t,e.unit),MN.endInterval(t)}visitDuration(e,t){return ON.startDuration(t),ON.addUnit(t,e.unit),ON.endDuration(t)}visitList(e,t){return FN.startList(t),FN.endList(t)}visitStruct(e,t){return RN.startStruct_(t),RN.endStruct_(t)}visitUnion(e,t){VN.startTypeIdsVector(t,e.typeIds.length);let n=VN.createTypeIdsVector(t,e.typeIds);return VN.startUnion(t),VN.addMode(t,e.mode),VN.addTypeIds(t,n),VN.endUnion(t)}visitDictionary(e,t){let n=this.visit(e.indices,t);return SN.startDictionaryEncoding(t),SN.addId(t,BigInt(e.id)),SN.addIsOrdered(t,e.isOrdered),n!==void 0&&SN.addIndexType(t,n),SN.endDictionaryEncoding(t)}visitFixedSizeBinary(e,t){return kN.startFixedSizeBinary(t),kN.addByteWidth(t,e.byteWidth),kN.endFixedSizeBinary(t)}visitFixedSizeList(e,t){return AN.startFixedSizeList(t),AN.addListSize(t,e.listSize),AN.endFixedSizeList(t)}visitMap(e,t){return IN.startMap(t),IN.addKeysSorted(t,e.keysSorted),IN.endMap(t)}};const wz=new Cz;function Tz(e,t=new Map){return new gR(Oz(e,t),Pz(e.metadata),t)}function Ez(e){return new Bz(e.count,Az(e.columns),jz(e.columns))}function Dz(e){return new Vz(Ez(e.data),e.id,e.isDelta)}function Oz(e,t){return(e.fields||[]).filter(Boolean).map(e=>_R.fromJSON(e,t))}function kz(e,t){return(e.children||[]).filter(Boolean).map(e=>_R.fromJSON(e,t))}function Az(e){return(e||[]).reduce((e,t)=>[...e,new Uz(t.count,Mz(t.VALIDITY)),...Az(t.children)],[])}function jz(e,t=[]){for(let n=-1,r=(e||[]).length;++ne+ +(t===0),0)}function Nz(e,t){let n,r,i,a,o,s;return!t||!(a=e.dictionary)?(o=Iz(e,kz(e,t)),i=new _R(e.name,o,e.nullable,Pz(e.metadata))):t.has(n=a.id)?(r=(r=a.indexType)?Fz(r):new LP,s=new dF(t.get(n),r,n,a.isOrdered),i=new _R(e.name,s,e.nullable,Pz(e.metadata))):(r=(r=a.indexType)?Fz(r):new LP,t.set(n,o=Iz(e,kz(e,t))),s=new dF(o,r,n,a.isOrdered),i=new _R(e.name,s,e.nullable,Pz(e.metadata))),i||null}function Pz(e=[]){return new Map(e.map(({key:e,value:t})=>[e,t]))}function Fz(e){return new PP(e.isSigned,e.bitWidth)}function Iz(e,t){let n=e.type.name;switch(n){case`NONE`:return new NP;case`null`:return new NP;case`binary`:return new qP;case`largebinary`:return new JP;case`utf8`:return new YP;case`largeutf8`:return new XP;case`bool`:return new ZP;case`list`:return new iF((t||[])[0]);case`struct`:return new aF(t||[]);case`struct_`:return new aF(t||[])}switch(n){case`int`:{let t=e.type;return new PP(t.isSigned,t.bitWidth)}case`floatingpoint`:{let t=e.type;return new UP(ZM[t.precision])}case`decimal`:{let t=e.type;return new QP(t.scale,t.precision,t.bitWidth)}case`date`:{let t=e.type;return new $P(QM[t.unit])}case`time`:{let t=e.type;return new eF($M[t.unit],t.bitWidth)}case`timestamp`:{let t=e.type;return new tF($M[t.unit],t.timezone)}case`interval`:{let t=e.type;return new nF(eN[t.unit])}case`duration`:{let t=e.type;return new rF($M[t.unit])}case`union`:{let n=e.type,[r,...i]=(n.mode+``).toLowerCase(),a=r.toUpperCase()+i.join(``);return new oF(XM[a],n.typeIds||[],t||[])}case`fixedsizebinary`:{let t=e.type;return new sF(t.byteWidth)}case`fixedsizelist`:{let n=e.type;return new cF(n.listSize,(t||[])[0])}case`map`:{let n=e.type;return new lF((t||[])[0],n.keysSorted)}}throw Error(`Unrecognized type: "${n}"`)}var Lz=dN,Rz=uN,zz=class e{static fromJSON(t,n){let r=new e(0,YM.V5,n);return r._createHeader=Wz(t,n),r}static decode(t){t=new Rz(NM(t));let n=Sz.getRootAsMessage(t),r=n.bodyLength(),i=n.version(),a=n.headerType(),o=new e(r,i,a);return o._createHeader=Gz(n,a),o}static encode(e){let t=new Lz,n=-1;return e.isSchema()?n=gR.encode(t,e.header()):e.isRecordBatch()?n=Bz.encode(t,e.header()):e.isDictionaryBatch()&&(n=Vz.encode(t,e.header())),Sz.startMessage(t),Sz.addVersion(t,YM.V5),Sz.addHeader(t,n),Sz.addHeaderType(t,e.headerType),Sz.addBodyLength(t,BigInt(e.bodyLength)),Sz.finishMessageBuffer(t,Sz.endMessage(t)),t.asUint8Array()}static from(t,n=0){if(t instanceof gR)return new e(0,YM.V5,KN.Schema,t);if(t instanceof Bz)return new e(n,YM.V5,KN.RecordBatch,t);if(t instanceof Vz)return new e(n,YM.V5,KN.DictionaryBatch,t);throw Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===KN.Schema}isRecordBatch(){return this.headerType===KN.RecordBatch}isDictionaryBatch(){return this.headerType===KN.DictionaryBatch}constructor(e,t,n,r){this._version=t,this._headerType=n,this.body=new Uint8Array,r&&(this._createHeader=()=>r),this._bodyLength=XN(e)}},Bz=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,t,n){this._nodes=t,this._buffers=n,this._length=XN(e)}},Vz=class{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(e,t,n=!1){this._data=e,this._isDelta=n,this._id=XN(t)}},Hz=class{constructor(e,t){this.offset=XN(e),this.length=XN(t)}},Uz=class{constructor(e,t){this.length=XN(e),this.nullCount=XN(t)}};function Wz(e,t){return()=>{switch(t){case KN.Schema:return gR.fromJSON(e);case KN.RecordBatch:return Bz.fromJSON(e);case KN.DictionaryBatch:return Vz.fromJSON(e)}throw Error(`Unrecognized Message type: { name: ${KN[t]}, type: ${t} }`)}}function Gz(e,t){return()=>{switch(t){case KN.Schema:return gR.decode(e.header(new GN),new Map,e.version());case KN.RecordBatch:return Bz.decode(e.header(new _N),e.version());case KN.DictionaryBatch:return Vz.decode(e.header(new vN),e.version())}throw Error(`Unrecognized Message type: { name: ${KN[t]}, type: ${t} }`)}}_R.encode=oB,_R.decode=tB,_R.fromJSON=Nz,gR.encode=aB,gR.decode=Kz,gR.fromJSON=Tz,Bz.encode=sB,Bz.decode=qz,Bz.fromJSON=Ez,Vz.encode=cB,Vz.decode=Jz,Vz.fromJSON=Dz,Uz.encode=lB,Uz.decode=Xz,Hz.encode=uB,Hz.decode=Yz;function Kz(e,t=new Map,n=YM.V5){let r=$z(e,t);return new gR(r,nB(e),t,n)}function qz(e,t=YM.V5){if(e.compression()!==null)throw Error(`Record batch compression not implemented`);return new Bz(e.length(),Zz(e),Qz(e,t))}function Jz(e,t=YM.V5){return new Vz(Bz.decode(e.data(),t),e.id(),e.isDelta())}function Yz(e){return new Hz(e.offset(),e.length())}function Xz(e){return new Uz(e.length(),e.nullCount())}function Zz(e){let t=[];for(let n,r=-1,i=-1,a=e.nodesLength();++r_R.encode(e,t));GN.startFieldsVector(e,n.length);let r=GN.createFieldsVector(e,n),i=t.metadata&&t.metadata.size>0?GN.createCustomMetadataVector(e,[...t.metadata].map(([t,n])=>{let r=e.createString(`${t}`),i=e.createString(`${n}`);return CN.startKeyValue(e),CN.addKey(e,r),CN.addValue(e,i),CN.endKeyValue(e)})):-1;return GN.startSchema(e),GN.addFields(e,r),GN.addEndianness(e,dB?yN.Little:yN.Big),i!==-1&&GN.addCustomMetadata(e,i),GN.endSchema(e)}function oB(e,t){let n=-1,r=-1,i=-1,a=t.type,o=t.typeId;MP.isDictionary(a)?(o=a.dictionary.typeId,i=wz.visit(a,e),r=wz.visit(a.dictionary,e)):r=wz.visit(a,e);let s=(a.children||[]).map(t=>_R.encode(e,t)),c=WN.createChildrenVector(e,s),l=t.metadata&&t.metadata.size>0?WN.createCustomMetadataVector(e,[...t.metadata].map(([t,n])=>{let r=e.createString(`${t}`),i=e.createString(`${n}`);return CN.startKeyValue(e),CN.addKey(e,r),CN.addValue(e,i),CN.endKeyValue(e)})):-1;return t.name&&(n=e.createString(t.name)),WN.startField(e),WN.addType(e,r),WN.addTypeType(e,o),WN.addChildren(e,c),WN.addNullable(e,!!t.nullable),n!==-1&&WN.addName(e,n),i!==-1&&WN.addDictionary(e,i),l!==-1&&WN.addCustomMetadata(e,l),WN.endField(e)}function sB(e,t){let n=t.nodes||[],r=t.buffers||[];_N.startNodesVector(e,n.length);for(let t of n.slice().reverse())Uz.encode(e,t);let i=e.endVector();_N.startBuffersVector(e,r.length);for(let t of r.slice().reverse())Hz.encode(e,t);let a=e.endVector();return _N.startRecordBatch(e),_N.addLength(e,BigInt(t.length)),_N.addNodes(e,i),_N.addBuffers(e,a),_N.endRecordBatch(e)}function cB(e,t){let n=Bz.encode(e,t.data);return vN.startDictionaryBatch(e),vN.addId(e,BigInt(t.id)),vN.addIsDelta(e,t.isDelta),vN.addData(e,n),vN.endDictionaryBatch(e)}function lB(e,t){return gN.createFieldNode(e,BigInt(t.length),BigInt(t.nullCount))}function uB(e,t){return hN.createBuffer(e,BigInt(t.offset),BigInt(t.length))}const dB=(()=>{let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]===256})(),fB=e=>`Expected ${KN[e]} Message in stream, but was null or length 0.`,pB=e=>`Header pointer of flatbuffer-encoded ${KN[e]} Message is null or length 0.`,mB=(e,t)=>`Expected to read ${e} metadata bytes, but only read ${t}.`,hB=(e,t)=>`Expected to read ${e} bytes for message body, but only read ${t}.`;var gB=class{constructor(e){this.source=e instanceof AR?e:new AR(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done||e.value===-1&&(e=this.readMetadataLength()).done||(e=this.readMetadata(e.value)).done?TR:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw Error(fB(e));return t.value}readMessageBody(e){if(e<=0)return new Uint8Array;let t=NM(this.source.read(e));if(t.byteLength[...e,...n.VALIDITY&&[n.VALIDITY]||[],...n.TYPE_ID&&[n.TYPE_ID]||[],...n.OFFSET&&[n.OFFSET]||[],...n.DATA&&[n.DATA]||[],...t(n.children)],[])}}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw Error(fB(e));return t.value}readSchema(){let e=KN.Schema,t=this.readMessage(e),n=t?.header();if(!t||!n)throw Error(pB(e));return n}};const yB=4,bB=`ARROW1`,xB=new Uint8Array(bB.length);for(let e=0;ethis):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return VM.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return VM.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw Error(`"throughNode" not available in this environment`)}static throughDOM(e,t){throw Error(`"throughDOM" not available in this environment`)}static from(t){return t instanceof e?t:gM(t)?BB(t):vM(t)?UB(t):pM(t)?(()=>$j(this,void 0,void 0,function*(){return yield e.from(yield t)}))():yM(t)||SM(t)||wM(t)||hM(t)?HB(new jR(t)):VB(new AR(t))}static readAll(t){return t instanceof e?t.isSync()?RB(t):zB(t):gM(t)||ArrayBuffer.isView(t)||mM(t)||_M(t)?RB(t):zB(t)}},DB=class extends EB{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return nM(this,arguments,function*(){yield tM(yield*rM(iM(this[Symbol.iterator]())))})}},OB=class extends EB{constructor(e){super(e),this._impl=e}readAll(){return $j(this,void 0,void 0,function*(){var e,t,n,r;let i=[];try{for(var a=!0,o=iM(this),s;s=yield o.next(),e=s.done,!e;a=!0){r=s.value,a=!1;let e=r;i.push(e)}}catch(e){t={error:e}}finally{try{!a&&!e&&(n=o.return)&&(yield n.call(o))}finally{if(t)throw t.error}}return i})}[Symbol.iterator](){throw Error(`AsyncRecordBatchStreamReader is not Iterable`)}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},kB=class extends DB{constructor(e){super(e),this._impl=e}},AB=class extends OB{constructor(e){super(e),this._impl=e}},jB=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,t){let n=this._loadVectors(e,t,this.schema.fields),r=HL({type:new aF(this.schema.fields),length:e.length,children:n});return new vz(this.schema,r)}_loadDictionaryBatch(e,t){let{id:n,isDelta:r}=e,{dictionaries:i,schema:a}=this,o=i.get(n),s=a.dictionaries.get(n),c=this._loadVectors(e.data,t,[s]);return(o&&r?o.concat(new fR(c)):new fR(c)).memoize()}_loadVectors(e,t,n){return new WR(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},MB=class extends jB{constructor(e,t){super(t),this._reader=gM(e)?new vB(this._handle=e):new gB(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=LB(this,e),(this.schema||=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):TR}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):TR}next(){if(this.closed)return TR;let e,{_reader:t}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let n=e.header(),r=t.readMessageBody(e.bodyLength),i=this._loadRecordBatch(n,r);return{done:!1,value:i}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let n=e.header(),r=t.readMessageBody(e.bodyLength),i=this._loadDictionaryBatch(n,r);this.dictionaries.set(n.id,i)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new xz(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}},NB=class extends jB{constructor(e,t){super(t),this._reader=new _B(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return $j(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return $j(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=LB(this,e),(this.schema||=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return $j(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):TR})}return(e){return $j(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):TR})}next(){return $j(this,void 0,void 0,function*(){if(this.closed)return TR;let e,{_reader:t}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let n=e.header(),r=yield t.readMessageBody(e.bodyLength),i=this._loadRecordBatch(n,r);return{done:!1,value:i}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let n=e.header(),r=yield t.readMessageBody(e.bodyLength),i=this._loadDictionaryBatch(n,r);this.dictionaries.set(n.id,i)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new xz(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return $j(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}},PB=class extends MB{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,t){super(e instanceof PR?e:new PR(e),t)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var t;if(this.closed)return null;this._footer||this.open();let n=(t=this._footer)?.getRecordBatch(e);if(n&&this._handle.seek(n.offset)){let e=this._reader.readMessage(KN.RecordBatch);if(e?.isRecordBatch()){let t=e.header(),n=this._reader.readMessageBody(e.bodyLength),r=this._loadRecordBatch(t,n);return r}}return null}_readDictionaryBatch(e){var t;let n=(t=this._footer)?.getDictionaryBatch(e);if(n&&this._handle.seek(n.offset)){let e=this._reader.readMessage(KN.DictionaryBatch);if(e?.isDictionaryBatch()){let t=e.header(),n=this._reader.readMessageBody(e.bodyLength),r=this._loadDictionaryBatch(t,n);this.dictionaries.set(t.id,r)}}}_readFooter(){let{_handle:e}=this,t=e.size-wB,n=e.readInt32(t),r=e.readAt(t-n,n);return SR.decode(r)}_readNextMessageAndValidate(e){var t;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return $j(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield t.open.call(this,e)})}readRecordBatch(e){return $j(this,void 0,void 0,function*(){var t;if(this.closed)return null;this._footer||(yield this.open());let n=(t=this._footer)?.getRecordBatch(e);if(n&&(yield this._handle.seek(n.offset))){let e=yield this._reader.readMessage(KN.RecordBatch);if(e?.isRecordBatch()){let t=e.header(),n=yield this._reader.readMessageBody(e.bodyLength),r=this._loadRecordBatch(t,n);return r}}return null})}_readDictionaryBatch(e){return $j(this,void 0,void 0,function*(){var t;let n=(t=this._footer)?.getDictionaryBatch(e);if(n&&(yield this._handle.seek(n.offset))){let e=yield this._reader.readMessage(KN.DictionaryBatch);if(e?.isDictionaryBatch()){let t=e.header(),n=yield this._reader.readMessageBody(e.bodyLength),r=this._loadDictionaryBatch(t,n);this.dictionaries.set(t.id,r)}}})}_readFooter(){return $j(this,void 0,void 0,function*(){let{_handle:e}=this;e._pending&&(yield e._pending);let t=e.size-wB,n=yield e.readInt32(t),r=yield e.readAt(t-n,n);return SR.decode(r)})}_readNextMessageAndValidate(e){return $j(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?SB(t)?new kB(new PB(e.read())):new DB(new MB(e)):new DB(new MB(function*(){}()))}function HB(e){return $j(this,void 0,void 0,function*(){let t=yield e.peek(CB+7&-8);return t&&t.byteLength>=4?SB(t)?new kB(new PB(yield e.read())):new OB(new NB(e)):new OB(new NB(function(){return nM(this,arguments,function*(){})}()))})}function UB(e){return $j(this,void 0,void 0,function*(){let{size:t}=yield e.stat(),n=new FR(e,t);return t>=TB&&SB(yield n.readAt(0,CB+7&-8))?new AB(new FB(n)):new OB(new NB(n))})}var WB=class e extends pF{static assemble(...t){let n=e=>e.flatMap(e=>Array.isArray(e)?n(e):e instanceof vz?e.data.children:e.data),r=new e;return r.visitMany(n(t)),r}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(e){if(e instanceof fR)return this.visitMany(e.data),this;let{type:t}=e;if(!MP.isDictionary(t)){let{length:n}=e;if(n>2147483647)throw RangeError(`Cannot write arrays larger than 2^31 - 1 in length`);if(MP.isUnion(t))this.nodes.push(new Uz(n,0));else{let{nullCount:r}=e;MP.isNull(t)||GB.call(this,r<=0?new Uint8Array:ML(e.offset,n,e.nullBitmap)),this.nodes.push(new Uz(n,r))}}return super.visit(e)}visitNull(e){return this}visitDictionary(e){return this.visit(e.clone(e.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}};function GB(e){let t=e.byteLength+7&-8;return this.buffers.push(e),this.bufferRegions.push(new Hz(this._byteLength,t)),this._byteLength+=t,this}function KB(e){var t;let{type:n,length:r,typeIds:i,valueOffsets:a}=e;if(GB.call(this,i),n.mode===XM.Sparse)return ZB.call(this,e);if(n.mode===XM.Dense){if(e.offset<=0)return GB.call(this,a),ZB.call(this,e);{let o=new Int32Array(r),s=Object.create(null),c=Object.create(null);for(let e,n,l=-1;++l{let i=n.typeIds[t],a=s[i],o=c[i];return e.slice(a,Math.min(r,o))}))}}return this}function qB(e){let t;return e.nullCount>=e.length?GB.call(this,new Uint8Array):(t=e.values)instanceof Uint8Array?GB.call(this,ML(e.offset,e.length,t)):GB.call(this,NL(e.values))}function JB(e){return GB.call(this,e.values.subarray(0,e.length*e.stride))}function YB(e){let{length:t,values:n,valueOffsets:r}=e,i=XN(r[0]),a=XN(r[t]),o=Math.min(a-i,n.byteLength-i);return GB.call(this,zM(-i,t+1,r)),GB.call(this,n.subarray(i,i+o)),this}function XB(e){let{length:t,valueOffsets:n}=e;if(n){let{0:r,[t]:i}=n;return GB.call(this,zM(-r,t+1,n)),this.visit(e.children[0].slice(r,i-r))}return this.visit(e.children[0])}function ZB(e){return this.visitMany(e.type.children.map((t,n)=>e.children[n]).filter(Boolean))[0]}WB.prototype.visitBool=qB,WB.prototype.visitInt=JB,WB.prototype.visitFloat=JB,WB.prototype.visitUtf8=YB,WB.prototype.visitLargeUtf8=YB,WB.prototype.visitBinary=YB,WB.prototype.visitLargeBinary=YB,WB.prototype.visitFixedSizeBinary=JB,WB.prototype.visitDate=JB,WB.prototype.visitTimestamp=JB,WB.prototype.visitTime=JB,WB.prototype.visitDecimal=JB,WB.prototype.visitList=XB,WB.prototype.visitStruct=ZB,WB.prototype.visitUnion=KB,WB.prototype.visitInterval=JB,WB.prototype.visitDuration=JB,WB.prototype.visitFixedSizeList=XB,WB.prototype.visitMap=XB;var QB=class extends DR{static throughNode(e){throw Error(`"throughNode" not available in this environment`)}static throughDOM(e,t){throw Error(`"throughDOM" not available in this environment`)}constructor(e){super(),this._position=0,this._started=!1,this._sink=new kR,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,fM(e)||(e={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof e.autoDestroy==`boolean`?e.autoDestroy:!0,this._writeLegacyIpcFormat=typeof e.writeLegacyIpcFormat==`boolean`?e.writeLegacyIpcFormat:!1}toString(e=!1){return this._sink.toString(e)}toUint8Array(e=!1){return this._sink.toUint8Array(e)}writeAll(e){return pM(e)?e.then(e=>this.writeAll(e)):hM(e)?nV(this,e):tV(this,e)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(e){return this._sink.toDOMStream(e)}toNodeStream(e){return this._sink.toNodeStream(e)}close(){return this.reset()._sink.close()}abort(e){return this.reset()._sink.abort(e)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(e=this._sink,t=null){return e===this._sink||e instanceof kR?this._sink=e:(this._sink=new kR,e&&xM(e)?this.toDOMStream({type:`bytes`}).pipeTo(e):e&&CM(e)&&this.toNodeStream({objectMode:!1}).pipe(e)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!t||!dz(t,this._schema))&&(t==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=t,this._writeSchema(t))),this}write(e){let t=null;if(this._sink){if(e==null||e instanceof gz&&!(t=e.schema)||e instanceof vz&&!(t=e.schema))return this.finish()&&void 0}else throw Error(`RecordBatchWriter is closed`);if(t&&!dz(t,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,t)}e instanceof vz?e instanceof xz||this._writeRecordBatch(e):e instanceof gz?this.writeAll(e.batches):mM(e)&&this.writeAll(e)}_writeMessage(e,t=8){let n=t-1,r=zz.encode(e),i=r.byteLength,a=this._writeLegacyIpcFormat?4:8,o=i+a+n&~n,s=o-i-a;return e.headerType===KN.RecordBatch?this._recordBatchBlocks.push(new wR(o,e.bodyLength,this._position)):e.headerType===KN.DictionaryBatch&&this._dictionaryBlocks.push(new wR(o,e.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(o-a)),i>0&&this._write(r),this._writePadding(s)}_write(e){if(this._started){let t=NM(e);t&&t.byteLength>0&&(this._sink.write(t),this._position+=t.byteLength)}return this}_writeSchema(e){return this._writeMessage(zz.from(e))}_writeFooter(e){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(xB)}_writePadding(e){return e>0?this._write(new Uint8Array(e)):this}_writeRecordBatch(e){let{byteLength:t,nodes:n,bufferRegions:r,buffers:i}=WB.assemble(e),a=new Bz(e.numRows,n,r),o=zz.from(a,t);return this._writeDictionaries(e)._writeMessage(o)._writeBodyBuffers(i)}_writeDictionaryBatch(e,t,n=!1){let{byteLength:r,nodes:i,bufferRegions:a,buffers:o}=WB.assemble(new fR([e])),s=new Bz(e.length,i,a),c=new Vz(s,t,n),l=zz.from(c,r);return this._writeMessage(l)._writeBodyBuffers(o)}_writeBodyBuffers(e){let t,n,r;for(let i=-1,a=e.length;++i0&&(this._write(t),(r=(n+7&-8)-n)>0&&this._writePadding(r));return this}_writeDictionaries(e){var t,n;for(let[r,i]of e.dictionaries){let e=(t=i?.data)??[],a=this._seenDictionaries.get(r),o=(n=this._dictionaryDeltaOffsets.get(r))??0;if(!a||a.data[0]!==e[0])for(let[t,n]of e.entries())this._writeDictionaryBatch(n,r,t>0);else if(or.writeAll(e)):hM(t)?nV(r,t):tV(r,t)}},eV=class e extends QB{static writeAll(t){let n=new e;return pM(t)?t.then(e=>n.writeAll(e)):hM(t)?nV(n,t):tV(n,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(e){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(e,t,n=!1){if(!n&&this._seenDictionaries.has(t))throw Error(`The Arrow File format does not support replacement dictionaries. `);return super._writeDictionaryBatch(e,t,n)}_writeFooter(e){let t=SR.encode(new SR(e,YM.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(e)._write(t)._write(Int32Array.of(t.byteLength))._writeMagic()}};function tV(e,t){let n=t;t instanceof gz&&(n=t.batches,e.reset(void 0,t.schema));for(let t of n)e.write(t);return e.finish()}function nV(e,t){return $j(this,void 0,void 0,function*(){var n,r,i,a,o,s,c;try{for(n=!0,r=iM(t);i=yield r.next(),a=i.done,!a;n=!0){c=i.value,n=!1;let t=c;e.write(t)}}catch(e){o={error:e}}finally{try{!n&&!a&&(s=r.return)&&(yield s.call(r))}finally{if(o)throw o.error}}return e.finish()})}function rV(e,t=`stream`){return(t===`stream`?$B:eV).writeAll(e).toUint8Array(!0)}var iV=Object.create,aV=Object.defineProperty,oV=Object.getOwnPropertyDescriptor,sV=Object.getOwnPropertyNames,cV=Object.getPrototypeOf,lV=Object.prototype.hasOwnProperty,uV=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),dV=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of sV(t))!lV.call(e,i)&&i!==n&&aV(e,i,{get:()=>t[i],enumerable:!(r=oV(t,i))||r.enumerable});return e},fV=(e,t,n)=>(n=e==null?{}:iV(cV(e)),dV(t||!e||!e.__esModule?aV(n,`default`,{value:e,enumerable:!0}):n,e)),pV=uV((e,t)=>{t.exports=Worker}),mV=(e=>(e[e.UNDEFINED=0]=`UNDEFINED`,e[e.AUTOMATIC=1]=`AUTOMATIC`,e[e.READ_ONLY=2]=`READ_ONLY`,e[e.READ_WRITE=3]=`READ_WRITE`,e))(mV||{}),hV=(e=>(e[e.IDENTIFIER=0]=`IDENTIFIER`,e[e.NUMERIC_CONSTANT=1]=`NUMERIC_CONSTANT`,e[e.STRING_CONSTANT=2]=`STRING_CONSTANT`,e[e.OPERATOR=3]=`OPERATOR`,e[e.KEYWORD=4]=`KEYWORD`,e[e.COMMENT=5]=`COMMENT`,e))(hV||{}),gV=(e=>(e[e.NONE=0]=`NONE`,e[e.DEBUG=1]=`DEBUG`,e[e.INFO=2]=`INFO`,e[e.WARNING=3]=`WARNING`,e[e.ERROR=4]=`ERROR`,e))(gV||{}),_V=(e=>(e[e.NONE=0]=`NONE`,e[e.CONNECT=1]=`CONNECT`,e[e.DISCONNECT=2]=`DISCONNECT`,e[e.OPEN=3]=`OPEN`,e[e.QUERY=4]=`QUERY`,e[e.INSTANTIATE=5]=`INSTANTIATE`,e))(_V||{}),vV=(e=>(e[e.NONE=0]=`NONE`,e[e.OK=1]=`OK`,e[e.ERROR=2]=`ERROR`,e[e.START=3]=`START`,e[e.RUN=4]=`RUN`,e[e.CAPTURE=5]=`CAPTURE`,e))(vV||{}),yV=(e=>(e[e.NONE=0]=`NONE`,e[e.WEB_WORKER=1]=`WEB_WORKER`,e[e.NODE_WORKER=2]=`NODE_WORKER`,e[e.BINDINGS=3]=`BINDINGS`,e[e.ASYNC_DUCKDB=4]=`ASYNC_DUCKDB`,e))(yV||{}),bV=class{log(e){}},xV=class{constructor(e=2){this.level=e}log(e){e.level>=this.level&&console.log(e)}},SV=(e=>(e[e.SUCCESS=0]=`SUCCESS`,e))(SV||{}),CV=class{constructor(e,t){this._bindings=e,this._conn=t}get bindings(){return this._bindings}async close(){return this._bindings.disconnect(this._conn)}useUnsafe(e){return e(this._bindings,this._conn)}async query(e){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let t=await this._bindings.runQuery(this._conn,e),n=EB.from(t);return console.assert(n.isSync(),`Reader is not sync`),console.assert(n.isFile(),`Reader is not file`),new gz(n)}async send(e,t=!1){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let n=await this._bindings.startPendingQuery(this._conn,e,t);for(;n==null;)n=await this._bindings.pollPendingQuery(this._conn);let r=new wV(this._bindings,this._conn,n),i=await EB.from(r);return console.assert(i.isAsync()),console.assert(i.isStream()),i}async cancelSent(){return await this._bindings.cancelPendingQuery(this._conn)}async getTableNames(e){return await this._bindings.getTableNames(this._conn,e)}async prepare(e){let t=await this._bindings.createPrepared(this._conn,e);return new TV(this._bindings,this._conn,t)}async insertArrowTable(e,t){let n=rV(e,`stream`);await this.insertArrowFromIPCStream(n,t)}async insertArrowFromIPCStream(e,t){await this._bindings.insertArrowFromIPCStream(this._conn,e,t)}async insertCSVFromPath(e,t){await this._bindings.insertCSVFromPath(this._conn,e,t)}async insertJSONFromPath(e,t){await this._bindings.insertJSONFromPath(this._conn,e,t)}},wV=class{constructor(e,t,n){this.db=e,this.conn=t,this.header=n,this._first=!0,this._depleted=!1,this._inFlight=null}async next(){if(this._first)return this._first=!1,{done:!1,value:this.header};if(this._depleted)return{done:!0,value:null};let e;return this._inFlight==null?e=await this.db.fetchQueryResults(this.conn):(e=await this._inFlight,this._inFlight=null),this._depleted=e.length==0,this._depleted||(this._inFlight=this.db.fetchQueryResults(this.conn)),{done:this._depleted,value:e}}[Symbol.asyncIterator](){return this}},TV=class{constructor(e,t,n){this.bindings=e,this.connectionId=t,this.statementId=n}async close(){await this.bindings.closePrepared(this.connectionId,this.statementId)}async query(...e){let t=await this.bindings.runPrepared(this.connectionId,this.statementId,e),n=EB.from(t);return console.assert(n.isSync()),console.assert(n.isFile()),new gz(n)}async send(...e){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,e),n=new wV(this.bindings,this.connectionId,t),r=await EB.from(n);return console.assert(r.isAsync()),console.assert(r.isStream()),r}},EV=(e=>(e.CANCEL_PENDING_QUERY=`CANCEL_PENDING_QUERY`,e.CLOSE_PREPARED=`CLOSE_PREPARED`,e.COLLECT_FILE_STATISTICS=`COLLECT_FILE_STATISTICS`,e.REGISTER_OPFS_FILE_NAME=`REGISTER_OPFS_FILE_NAME`,e.CONNECT=`CONNECT`,e.COPY_FILE_TO_BUFFER=`COPY_FILE_TO_BUFFER`,e.COPY_FILE_TO_PATH=`COPY_FILE_TO_PATH`,e.CREATE_PREPARED=`CREATE_PREPARED`,e.DISCONNECT=`DISCONNECT`,e.DROP_FILE=`DROP_FILE`,e.DROP_FILES=`DROP_FILES`,e.EXPORT_FILE_STATISTICS=`EXPORT_FILE_STATISTICS`,e.FETCH_QUERY_RESULTS=`FETCH_QUERY_RESULTS`,e.FLUSH_FILES=`FLUSH_FILES`,e.GET_FEATURE_FLAGS=`GET_FEATURE_FLAGS`,e.GET_TABLE_NAMES=`GET_TABLE_NAMES`,e.GET_VERSION=`GET_VERSION`,e.GLOB_FILE_INFOS=`GLOB_FILE_INFOS`,e.INSERT_ARROW_FROM_IPC_STREAM=`INSERT_ARROW_FROM_IPC_STREAM`,e.INSERT_CSV_FROM_PATH=`IMPORT_CSV_FROM_PATH`,e.INSERT_JSON_FROM_PATH=`IMPORT_JSON_FROM_PATH`,e.INSTANTIATE=`INSTANTIATE`,e.OPEN=`OPEN`,e.PING=`PING`,e.POLL_PENDING_QUERY=`POLL_PENDING_QUERY`,e.REGISTER_FILE_BUFFER=`REGISTER_FILE_BUFFER`,e.REGISTER_FILE_HANDLE=`REGISTER_FILE_HANDLE`,e.REGISTER_FILE_URL=`REGISTER_FILE_URL`,e.RESET=`RESET`,e.RUN_PREPARED=`RUN_PREPARED`,e.RUN_QUERY=`RUN_QUERY`,e.SEND_PREPARED=`SEND_PREPARED`,e.START_PENDING_QUERY=`START_PENDING_QUERY`,e.TOKENIZE=`TOKENIZE`,e))(EV||{}),DV=(e=>(e.CONNECTION_INFO=`CONNECTION_INFO`,e.ERROR=`ERROR`,e.FEATURE_FLAGS=`FEATURE_FLAGS`,e.FILE_BUFFER=`FILE_BUFFER`,e.FILE_INFOS=`FILE_INFOS`,e.FILE_SIZE=`FILE_SIZE`,e.FILE_STATISTICS=`FILE_STATISTICS`,e.INSTANTIATE_PROGRESS=`INSTANTIATE_PROGRESS`,e.LOG=`LOG`,e.OK=`OK`,e.PREPARED_STATEMENT_ID=`PREPARED_STATEMENT_ID`,e.QUERY_PLAN=`QUERY_PLAN`,e.QUERY_RESULT=`QUERY_RESULT`,e.QUERY_RESULT_CHUNK=`QUERY_RESULT_CHUNK`,e.QUERY_RESULT_HEADER=`QUERY_RESULT_HEADER`,e.QUERY_RESULT_HEADER_OR_NULL=`QUERY_RESULT_HEADER_OR_NULL`,e.REGISTERED_FILE=`REGISTERED_FILE`,e.SCRIPT_TOKENS=`SCRIPT_TOKENS`,e.SUCCESS=`SUCCESS`,e.TABLE_NAMES=`TABLE_NAMES`,e.VERSION_STRING=`VERSION_STRING`,e))(DV||{}),OV=class{constructor(e,t){this.promiseResolver=()=>{},this.promiseRejecter=()=>{},this.type=e,this.data=t,this.promise=new Promise((e,t)=>{this.promiseResolver=e,this.promiseRejecter=t})}};function kV(e){switch(e.typeId){case Y.Binary:return{sqlType:`binary`};case Y.Bool:return{sqlType:`bool`};case Y.Date:return{sqlType:`date`};case Y.DateDay:return{sqlType:`date32[d]`};case Y.DateMillisecond:return{sqlType:`date64[ms]`};case Y.Decimal:{let t=e;return{sqlType:`decimal`,precision:t.precision,scale:t.scale}}case Y.Float:return{sqlType:`float`};case Y.Float16:return{sqlType:`float16`};case Y.Float32:return{sqlType:`float32`};case Y.Float64:return{sqlType:`float64`};case Y.Int:return{sqlType:`int32`};case Y.Int16:return{sqlType:`int16`};case Y.Int32:return{sqlType:`int32`};case Y.Int64:return{sqlType:`int64`};case Y.Uint16:return{sqlType:`uint16`};case Y.Uint32:return{sqlType:`uint32`};case Y.Uint64:return{sqlType:`uint64`};case Y.Uint8:return{sqlType:`uint8`};case Y.IntervalDayTime:return{sqlType:`interval[dt]`};case Y.IntervalYearMonth:return{sqlType:`interval[m]`};case Y.List:return{sqlType:`list`,valueType:kV(e.valueType)};case Y.FixedSizeBinary:return{sqlType:`fixedsizebinary`,byteWidth:e.byteWidth};case Y.Null:return{sqlType:`null`};case Y.Utf8:return{sqlType:`utf8`};case Y.Struct:return{sqlType:`struct`,fields:e.children.map(e=>AV(e.name,e.type))};case Y.Map:{let t=e;return{sqlType:`map`,keyType:kV(t.keyType),valueType:kV(t.valueType)}}case Y.Time:return{sqlType:`time[s]`};case Y.TimeMicrosecond:return{sqlType:`time[us]`};case Y.TimeMillisecond:return{sqlType:`time[ms]`};case Y.TimeNanosecond:return{sqlType:`time[ns]`};case Y.TimeSecond:return{sqlType:`time[s]`};case Y.Timestamp:return{sqlType:`timestamp`,timezone:e.timezone||void 0};case Y.TimestampSecond:return{sqlType:`timestamp[s]`,timezone:e.timezone||void 0};case Y.TimestampMicrosecond:return{sqlType:`timestamp[us]`,timezone:e.timezone||void 0};case Y.TimestampNanosecond:return{sqlType:`timestamp[ns]`,timezone:e.timezone||void 0};case Y.TimestampMillisecond:return{sqlType:`timestamp[ms]`,timezone:e.timezone||void 0}}throw Error(`unsupported arrow type: ${e.toString()}`)}function AV(e,t){let n=kV(t);return n.name=e,n}var jV=new TextEncoder,MV=class{constructor(e,t=null){this._onInstantiationProgress=[],this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{},this._nextMessageId=0,this._pendingRequests=new Map,this._logger=e,this._onMessageHandler=this.onMessage.bind(this),this._onErrorHandler=this.onError.bind(this),this._onCloseHandler=this.onClose.bind(this),t!=null&&this.attach(t)}get logger(){return this._logger}attach(e){this._worker=e,this._worker.addEventListener(`message`,this._onMessageHandler),this._worker.addEventListener(`error`,this._onErrorHandler),this._worker.addEventListener(`close`,this._onCloseHandler),this._workerShutdownPromise=new Promise((e,t)=>{this._workerShutdownResolver=e})}detach(){this._worker&&(this._worker.removeEventListener(`message`,this._onMessageHandler),this._worker.removeEventListener(`error`,this._onErrorHandler),this._worker.removeEventListener(`close`,this._onCloseHandler),this._worker=null,this._workerShutdownResolver(null),this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async terminate(){this._worker&&(this._worker.terminate(),this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async postTask(e,t=[]){if(!this._worker){console.error(`cannot send a message since the worker is not set!`);return}let n=this._nextMessageId++;return this._pendingRequests.set(n,e),this._worker.postMessage({messageId:n,type:e.type,data:e.data},t),await e.promise}onMessage(e){var t;let n=e.data;switch(n.type){case`LOG`:this._logger.log(n.data);return;case`INSTANTIATE_PROGRESS`:for(let e of this._onInstantiationProgress)e(n.data);return}let r=this._pendingRequests.get(n.requestId);if(!r){console.warn(`unassociated response: [${n.requestId}, ${n.type.toString()}]`);return}if(this._pendingRequests.delete(n.requestId),n.type==`ERROR`){let e=Error(n.data.message);e.name=n.data.name,(t=Object.getOwnPropertyDescriptor(e,`stack`))!=null&&t.writable&&(e.stack=n.data.stack),r.promiseRejecter(e);return}switch(r.type){case`CLOSE_PREPARED`:case`COLLECT_FILE_STATISTICS`:case`REGISTER_OPFS_FILE_NAME`:case`COPY_FILE_TO_PATH`:case`DISCONNECT`:case`DROP_FILE`:case`DROP_FILES`:case`FLUSH_FILES`:case`INSERT_ARROW_FROM_IPC_STREAM`:case`IMPORT_CSV_FROM_PATH`:case`IMPORT_JSON_FROM_PATH`:case`OPEN`:case`PING`:case`REGISTER_FILE_BUFFER`:case`REGISTER_FILE_HANDLE`:case`REGISTER_FILE_URL`:case`RESET`:if(n.type==`OK`){r.promiseResolver(n.data);return}break;case`INSTANTIATE`:if(this._onInstantiationProgress=[],n.type==`OK`){r.promiseResolver(n.data);return}break;case`GLOB_FILE_INFOS`:if(n.type==`FILE_INFOS`){r.promiseResolver(n.data);return}break;case`GET_VERSION`:if(n.type==`VERSION_STRING`){r.promiseResolver(n.data);return}break;case`GET_FEATURE_FLAGS`:if(n.type==`FEATURE_FLAGS`){r.promiseResolver(n.data);return}break;case`GET_TABLE_NAMES`:if(n.type==`TABLE_NAMES`){r.promiseResolver(n.data);return}break;case`TOKENIZE`:if(n.type==`SCRIPT_TOKENS`){r.promiseResolver(n.data);return}break;case`COPY_FILE_TO_BUFFER`:if(n.type==`FILE_BUFFER`){r.promiseResolver(n.data);return}break;case`EXPORT_FILE_STATISTICS`:if(n.type==`FILE_STATISTICS`){r.promiseResolver(n.data);return}break;case`CONNECT`:if(n.type==`CONNECTION_INFO`){r.promiseResolver(n.data);return}break;case`RUN_PREPARED`:case`RUN_QUERY`:if(n.type==`QUERY_RESULT`){r.promiseResolver(n.data);return}break;case`SEND_PREPARED`:if(n.type==`QUERY_RESULT_HEADER`){r.promiseResolver(n.data);return}break;case`START_PENDING_QUERY`:if(n.type==`QUERY_RESULT_HEADER_OR_NULL`){r.promiseResolver(n.data);return}break;case`POLL_PENDING_QUERY`:if(n.type==`QUERY_RESULT_HEADER_OR_NULL`){r.promiseResolver(n.data);return}break;case`CANCEL_PENDING_QUERY`:if(this._onInstantiationProgress=[],n.type==`SUCCESS`){r.promiseResolver(n.data);return}break;case`FETCH_QUERY_RESULTS`:if(n.type==`QUERY_RESULT_CHUNK`){r.promiseResolver(n.data);return}break;case`CREATE_PREPARED`:if(n.type==`PREPARED_STATEMENT_ID`){r.promiseResolver(n.data);return}break}r.promiseRejecter(Error(`unexpected response type: ${n.type.toString()}`))}onError(e){console.error(e),console.error(`error in duckdb worker: ${e.message}`),this._pendingRequests.clear()}onClose(){if(this._workerShutdownResolver(null),this._pendingRequests.size!=0){console.warn(`worker terminated with ${this._pendingRequests.size} pending requests`);return}this._pendingRequests.clear()}async reset(){let e=new OV(`RESET`,null);return await this.postTask(e)}async ping(){let e=new OV(`PING`,null);await this.postTask(e)}async dropFile(e){let t=new OV(`DROP_FILE`,e);return await this.postTask(t)}async dropFiles(){let e=new OV(`DROP_FILES`,null);return await this.postTask(e)}async flushFiles(){let e=new OV(`FLUSH_FILES`,null);return await this.postTask(e)}async instantiate(e,t=null,n=e=>{}){this._onInstantiationProgress.push(n);let r=new OV(`INSTANTIATE`,[e,t]);return await this.postTask(r)}async getVersion(){let e=new OV(`GET_VERSION`,null);return await this.postTask(e)}async getFeatureFlags(){let e=new OV(`GET_FEATURE_FLAGS`,null);return await this.postTask(e)}async open(e){let t=new OV(`OPEN`,e);await this.postTask(t)}async tokenize(e){let t=new OV(`TOKENIZE`,e);return await this.postTask(t)}async connectInternal(){let e=new OV(`CONNECT`,null);return await this.postTask(e)}async connect(){let e=await this.connectInternal();return new CV(this,e)}async disconnect(e){let t=new OV(`DISCONNECT`,e);await this.postTask(t)}async runQuery(e,t){let n=new OV(`RUN_QUERY`,[e,t]);return await this.postTask(n)}async startPendingQuery(e,t,n=!1){let r=new OV(`START_PENDING_QUERY`,[e,t,n]);return await this.postTask(r)}async pollPendingQuery(e){let t=new OV(`POLL_PENDING_QUERY`,e);return await this.postTask(t)}async cancelPendingQuery(e){let t=new OV(`CANCEL_PENDING_QUERY`,e);return await this.postTask(t)}async fetchQueryResults(e){let t=new OV(`FETCH_QUERY_RESULTS`,e);return await this.postTask(t)}async getTableNames(e,t){let n=new OV(`GET_TABLE_NAMES`,[e,t]);return await this.postTask(n)}async createPrepared(e,t){let n=new OV(`CREATE_PREPARED`,[e,t]);return await this.postTask(n)}async closePrepared(e,t){let n=new OV(`CLOSE_PREPARED`,[e,t]);await this.postTask(n)}async runPrepared(e,t,n){let r=new OV(`RUN_PREPARED`,[e,t,n]);return await this.postTask(r)}async sendPrepared(e,t,n){let r=new OV(`SEND_PREPARED`,[e,t,n]);return await this.postTask(r)}async globFiles(e){let t=new OV(`GLOB_FILE_INFOS`,e);return await this.postTask(t)}async registerFileText(e,t){let n=jV.encode(t);await this.registerFileBuffer(e,n)}async registerFileURL(e,t,n,r){t===void 0&&(t=e);let i=new OV(`REGISTER_FILE_URL`,[e,t,n,r]);await this.postTask(i)}async registerEmptyFileBuffer(e){}async registerFileBuffer(e,t){let n=new OV(`REGISTER_FILE_BUFFER`,[e,t]);await this.postTask(n,[t.buffer])}async registerFileHandle(e,t,n,r){let i=new OV(`REGISTER_FILE_HANDLE`,[e,t,n,r]);await this.postTask(i,[])}async registerOPFSFileName(e){let t=new OV(`REGISTER_OPFS_FILE_NAME`,[e]);await this.postTask(t,[])}async collectFileStatistics(e,t){let n=new OV(`COLLECT_FILE_STATISTICS`,[e,t]);await this.postTask(n,[])}async exportFileStatistics(e){let t=new OV(`EXPORT_FILE_STATISTICS`,e);return await this.postTask(t,[])}async copyFileToBuffer(e){let t=new OV(`COPY_FILE_TO_BUFFER`,e);return await this.postTask(t)}async copyFileToPath(e,t){let n=new OV(`COPY_FILE_TO_PATH`,[e,t]);await this.postTask(n)}async insertArrowFromIPCStream(e,t,n){if(t.length==0)return;let r=new OV(`INSERT_ARROW_FROM_IPC_STREAM`,[e,t,n]);await this.postTask(r,[t.buffer])}async insertCSVFromPath(e,t,n){if(n.columns!==void 0){let e=[];for(let t in n.columns){let r=n.columns[t];e.push(AV(t,r))}n.columnsFlat=e,delete n.columns}let r=new OV(`IMPORT_CSV_FROM_PATH`,[e,t,n]);await this.postTask(r)}async insertJSONFromPath(e,t,n){if(n.columns!==void 0){let e=[];for(let t in n.columns){let r=n.columns[t];e.push(AV(t,r))}n.columnsFlat=e,delete n.columns}let r=new OV(`IMPORT_JSON_FROM_PATH`,[e,t,n]);await this.postTask(r)}};function NV(){let e=new TextDecoder;return t=>(typeof SharedArrayBuffer<`u`&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),e.decode(t))}var PV=NV(),FV=(e=>(e[e.BUFFER=0]=`BUFFER`,e[e.NODE_FS=1]=`NODE_FS`,e[e.BROWSER_FILEREADER=2]=`BROWSER_FILEREADER`,e[e.BROWSER_FSACCESS=3]=`BROWSER_FSACCESS`,e[e.HTTP=4]=`HTTP`,e[e.S3=5]=`S3`,e))(FV||{}),IV=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11])),LV=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,6,64,25,11,11])),RV=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),zV=()=>(async e=>{try{return typeof MessageChannel<`u`&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(e)}catch{return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])),BV={name:`@duckdb/duckdb-wasm`,version:`1.29.1-dev68.0`,description:`DuckDB powered by WebAssembly`,license:`MIT`,repository:{type:`git`,url:`https://github.com/duckdb/duckdb-wasm.git`},keywords:[`sql`,`duckdb`,`relational`,`database`,`data`,`query`,`wasm`,`analytics`,`olap`,`arrow`,`parquet`,`json`,`csv`],dependencies:{"apache-arrow":`^17.0.0`},devDependencies:{"@types/emscripten":`^1.39.10`,"@types/jasmine":`^5.1.4`,"@typescript-eslint/eslint-plugin":`^6.21.0`,"@typescript-eslint/parser":`^6.21.0`,esbuild:`^0.20.2`,eslint:`^8.57.0`,"eslint-plugin-jasmine":`^4.1.3`,"eslint-plugin-react":`^7.34.0`,"fast-glob":`^3.3.2`,jasmine:`^5.1.0`,"jasmine-core":`^5.1.2`,"jasmine-spec-reporter":`^7.0.0`,"js-sha256":`^0.11.0`,karma:`^6.4.2`,"karma-chrome-launcher":`^3.2.0`,"karma-coverage":`^2.2.1`,"karma-firefox-launcher":`^2.1.3`,"karma-jasmine":`^5.1.0`,"karma-jasmine-html-reporter":`^2.1.0`,"karma-sourcemap-loader":`^0.4.0`,"karma-spec-reporter":`^0.0.36`,"make-dir":`^4.0.0`,nyc:`^15.1.0`,prettier:`^3.2.5`,puppeteer:`^22.8.0`,rimraf:`^5.0.5`,s3rver:`^3.7.1`,typedoc:`^0.25.13`,typescript:`^5.3.3`,"wasm-feature-detect":`^1.6.1`,"web-worker":`^1.2.0`},scripts:{"build:debug":`node bundle.mjs debug && tsc --emitDeclarationOnly`,"build:release":`node bundle.mjs release && tsc --emitDeclarationOnly`,docs:`typedoc`,report:`node ./coverage.mjs`,"test:node":`node --enable-source-maps ../../node_modules/jasmine/bin/jasmine ./dist/tests-node.cjs`,"test:node:debug":`node --inspect-brk --enable-source-maps ../../node_modules/jasmine/bin/jasmine ./dist/tests-node.cjs`,"test:node:coverage":`nyc -r json --report-dir ./coverage/node node ../../node_modules/jasmine/bin/jasmine ./dist/tests-node.cjs`,"test:firefox":`karma start ./karma/tests-firefox.cjs`,"test:chrome":`karma start ./karma/tests-chrome.cjs`,"test:chrome:eh":`karma start ./karma/tests-chrome-eh.cjs`,"test:chrome:coverage":`karma start ./karma/tests-chrome-coverage.cjs`,"test:browser":`karma start ./karma/tests-all.cjs`,"test:browser:debug":`karma start ./karma/tests-debug.cjs`,test:`npm run test:chrome && npm run test:node`,"test:coverage":`npm run test:chrome:coverage && npm run test:node:coverage && npm run report`,lint:`eslint src test`},files:[`dist`,`!dist/tests-*`,`!dist/duckdb-browser-mvp.worker.js.map`,`!dist/types/test`],main:`dist/duckdb-browser.cjs`,module:`dist/duckdb-browser.mjs`,types:`dist/duckdb-browser.d.ts`,jsdelivr:`dist/duckdb-browser.cjs`,unpkg:`dist/duckdb-browser.mjs`,sideEffects:!1,browser:{fs:!1,path:!1,perf_hooks:!1,os:!1,worker_threads:!1},exports:{"./dist/duckdb-mvp.wasm":`./dist/duckdb-mvp.wasm`,"./dist/duckdb-eh.wasm":`./dist/duckdb-eh.wasm`,"./dist/duckdb-coi.wasm":`./dist/duckdb-coi.wasm`,"./dist/duckdb-browser":`./dist/duckdb-browser.mjs`,"./dist/duckdb-browser.cjs":`./dist/duckdb-browser.cjs`,"./dist/duckdb-browser.mjs":`./dist/duckdb-browser.mjs`,"./dist/duckdb-browser-coi.pthread.worker.js":`./dist/duckdb-browser-coi.pthread.worker.js`,"./dist/duckdb-browser-coi.worker.js":`./dist/duckdb-browser-coi.worker.js`,"./dist/duckdb-browser-eh.worker.js":`./dist/duckdb-browser-eh.worker.js`,"./dist/duckdb-browser-mvp.worker.js":`./dist/duckdb-browser-mvp.worker.js`,"./dist/duckdb-node":`./dist/duckdb-node.cjs`,"./dist/duckdb-node.cjs":`./dist/duckdb-node.cjs`,"./dist/duckdb-node-blocking":`./dist/duckdb-node-blocking.cjs`,"./dist/duckdb-node-blocking.cjs":`./dist/duckdb-node-blocking.cjs`,"./dist/duckdb-node-eh.worker.cjs":`./dist/duckdb-node-eh.worker.cjs`,"./dist/duckdb-node-mvp.worker.cjs":`./dist/duckdb-node-mvp.worker.cjs`,"./blocking":{node:{types:`./dist/duckdb-node-blocking.d.ts`,require:`./dist/duckdb-node-blocking.cjs`,import:`./dist/duckdb-node-blocking.cjs`},types:`./dist/duckdb-node-blocking.d.ts`,import:`./dist/duckdb-node-blocking.mjs`,require:`./dist/duckdb-node-blocking.cjs`},".":{browser:{types:`./dist/duckdb-browser.d.ts`,import:`./dist/duckdb-browser.mjs`,require:`./dist/duckdb-browser.cjs`},node:{types:`./dist/duckdb-node.d.ts`,import:`./dist/duckdb-node.cjs`,require:`./dist/duckdb-node.cjs`},types:`./dist/duckdb-browser.d.ts`,import:`./dist/duckdb-browser.mjs`,require:`./dist/duckdb-browser.cjs`}}},VV=BV.name,HV=BV.version,UV=BV.version.split(`.`),WV=UV[0],GV=UV[1],KV=UV[2],qV=()=>typeof navigator>`u`,JV=()=>qV()?`node`:navigator.userAgent,YV=()=>JV().includes(`Firefox`),XV=()=>/^((?!chrome|android).)*safari/i.test(JV()),ZV=null,QV=null,$V=null,eH=null,tH=null;async function nH(){return ZV??=typeof BigInt64Array<`u`,QV??=await LV(),$V??=await zV(),eH??=await RV(),tH??=await IV(),{bigInt64Array:ZV,crossOriginIsolated:qV()||globalThis.crossOriginIsolated||!1,wasmExceptions:QV,wasmSIMD:eH,wasmThreads:$V,wasmBulkMemory:tH}}async function rH(e){let t=await nH();if(t.wasmExceptions){if(t.wasmSIMD&&t.wasmThreads&&t.crossOriginIsolated&&e.coi)return{mainModule:e.coi.mainModule,mainWorker:e.coi.mainWorker,pthreadWorker:e.coi.pthreadWorker};if(e.eh)return{mainModule:e.eh.mainModule,mainWorker:e.eh.mainWorker,pthreadWorker:null}}return{mainModule:e.mvp.mainModule,mainWorker:e.mvp.mainWorker,pthreadWorker:null}}var iH=fV(pV());const aH=Symbol.for(`constructDateFrom`),oH={},sH={};function cH(e,t){try{let n=oH[e]||(oH[e]=new Intl.DateTimeFormat(`en-GB`,{timeZone:e,hour:`numeric`,timeZoneName:`longOffset`}).format),r=n(t).split(`GMT`)[1]||``;return r in sH?sH[r]:uH(r,r.split(`:`))}catch{if(e in sH)return sH[e];let t=e?.match(lH);return t?uH(e,t.slice(1)):NaN}}const lH=/([+-]\d\d):?(\d\d)?/;function uH(e,t){let n=+t[0],r=+(t[1]||0);return sH[e]=n>0?n*60+r:n*60-r}var dH=class e extends Date{constructor(...e){super(),e.length>1&&typeof e[e.length-1]==`string`&&(this.timeZone=e.pop()),this.internal=new Date,isNaN(cH(this.timeZone,this))?this.setTime(NaN):e.length?typeof e[0]==`number`&&(e.length===1||e.length===2&&typeof e[1]!=`number`)?this.setTime(e[0]):typeof e[0]==`string`?this.setTime(+new Date(e[0])):e[0]instanceof Date?this.setTime(+e[0]):(this.setTime(+new Date(...e)),hH(this,NaN),pH(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new e(...n,t):new e(Date.now(),t)}withTimeZone(t){return new e(+this,t)}getTimezoneOffset(){return-cH(this.timeZone,this)}setTime(e){return Date.prototype.setTime.apply(this,arguments),pH(this),+this}[Symbol.for(`constructDateFrom`)](t){return new e(+new Date(t),this.timeZone)}};const fH=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!fH.test(e))return;let t=e.replace(fH,`$1UTC`);dH.prototype[t]&&(e.startsWith(`get`)?dH.prototype[e]=function(){return this.internal[t]()}:(dH.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),mH(this),+this},dH.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),pH(this),+this}))});function pH(e){e.internal.setTime(+e),e.internal.setUTCMinutes(e.internal.getUTCMinutes()-e.getTimezoneOffset())}function mH(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),hH(e)}function hH(e){let t=cH(e.timeZone,e),n=new Date(+e);n.setUTCHours(n.getUTCHours()-1);let r=-new Date(+e).getTimezoneOffset(),i=-new Date(+n).getTimezoneOffset(),a=r-i,o=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();a&&o&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+a);let s=r-t;s&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+s);let c=cH(e.timeZone,e),l=-new Date(+e).getTimezoneOffset(),u=l-c,d=c!==t,f=u-s;if(d&&f){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+f);let t=cH(e.timeZone,e),n=c-t;n&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+n),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+n))}}var gH=class e extends dH{static tz(t,...n){return n.length?new e(...n,t):new e(Date.now(),t)}toISOString(){let[e,t,n]=this.tzComponents(),r=`${e}${t}:${n}`;return this.internal.toISOString().slice(0,-1)+r}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){let[e,t,n,r]=this.internal.toUTCString().split(` `);return`${e?.slice(0,-1)} ${n} ${t} ${r}`}toTimeString(){let e=this.internal.toUTCString().split(` `)[4],[t,n,r]=this.tzComponents();return`${e} GMT${t}${n}${r} (${_H(this.timeZone,this)})`}toLocaleString(e,t){return Date.prototype.toLocaleString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}toLocaleDateString(e,t){return Date.prototype.toLocaleDateString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}toLocaleTimeString(e,t){return Date.prototype.toLocaleTimeString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}tzComponents(){let e=this.getTimezoneOffset(),t=e>0?`-`:`+`,n=String(Math.floor(Math.abs(e)/60)).padStart(2,`0`),r=String(Math.abs(e)%60).padStart(2,`0`);return[t,n,r]}withTimeZone(t){return new e(+this,t)}[Symbol.for(`constructDateFrom`)](t){return new e(+new Date(t),this.timeZone)}};function _H(e,t){return new Intl.DateTimeFormat(`en-GB`,{timeZone:e,timeZoneName:`long`}).format(t).slice(12)}const vH=new TextDecoder(`utf-8`),yH=e=>vH.decode(e),bH=new TextEncoder,xH=e=>bH.encode(e),SH=e=>typeof e==`function`,CH=e=>e!=null&&Object(e)===e,wH=e=>CH(e)&&SH(e.then),TH=e=>CH(e)&&SH(e[Symbol.iterator]),EH=e=>CH(e)&&SH(e[Symbol.asyncIterator]),DH=e=>CH(e)&&`done`in e&&`value`in e,OH=e=>CH(e)&&SH(e.clear)&&SH(e.bytes)&&SH(e.position)&&SH(e.setPosition)&&SH(e.capacity)&&SH(e.getBufferIdentifier)&&SH(e.createLong);var kH={};St(kH,{compareArrayLike:()=>mU,joinUint8Arrays:()=>NH,memcpy:()=>MH,rebaseValueOffsets:()=>pU,toArrayBufferView:()=>PH,toArrayBufferViewAsyncIterator:()=>rU,toArrayBufferViewIterator:()=>qH,toBigInt64Array:()=>RH,toBigUint64Array:()=>HH,toFloat32Array:()=>UH,toFloat32ArrayAsyncIterator:()=>uU,toFloat32ArrayIterator:()=>eU,toFloat64Array:()=>WH,toFloat64ArrayAsyncIterator:()=>dU,toFloat64ArrayIterator:()=>tU,toInt16Array:()=>IH,toInt16ArrayAsyncIterator:()=>aU,toInt16ArrayIterator:()=>YH,toInt32Array:()=>LH,toInt32ArrayAsyncIterator:()=>oU,toInt32ArrayIterator:()=>XH,toInt8Array:()=>FH,toInt8ArrayAsyncIterator:()=>iU,toInt8ArrayIterator:()=>JH,toUint16Array:()=>BH,toUint16ArrayAsyncIterator:()=>cU,toUint16ArrayIterator:()=>QH,toUint32Array:()=>VH,toUint32ArrayAsyncIterator:()=>lU,toUint32ArrayIterator:()=>$H,toUint8Array:()=>zH,toUint8ArrayAsyncIterator:()=>sU,toUint8ArrayIterator:()=>ZH,toUint8ClampedArray:()=>GH,toUint8ClampedArrayAsyncIterator:()=>fU,toUint8ClampedArrayIterator:()=>nU});const AH=typeof SharedArrayBuffer<`u`?SharedArrayBuffer:ArrayBuffer;function jH(e){let t=e[0]?[e[0]]:[],n,r,i,a;for(let o,s,c=0,l=0,u=e.length;++ce+t.byteLength,0),i,a,o,s=0,c=-1,l=Math.min(t||1/0,r);for(let e=n.length;++cPH(Int8Array,e),IH=e=>PH(Int16Array,e),LH=e=>PH(Int32Array,e),RH=e=>PH(BigInt64Array,e),zH=e=>PH(Uint8Array,e),BH=e=>PH(Uint16Array,e),VH=e=>PH(Uint32Array,e),HH=e=>PH(BigUint64Array,e),UH=e=>PH(Float32Array,e),WH=e=>PH(Float64Array,e),GH=e=>PH(Uint8ClampedArray,e),KH=e=>(e.next(),e);function*qH(e,t){let n=function*(e){yield e},r=typeof t==`string`||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof AH?n(t):TH(t)?t:n(t);return yield*KH(function*(t){let n=null;do n=t.next(yield PH(e,n));while(!n.done)}(r[Symbol.iterator]())),new e}const JH=e=>qH(Int8Array,e),YH=e=>qH(Int16Array,e),XH=e=>qH(Int32Array,e),ZH=e=>qH(Uint8Array,e),QH=e=>qH(Uint16Array,e),$H=e=>qH(Uint32Array,e),eU=e=>qH(Float32Array,e),tU=e=>qH(Float64Array,e),nU=e=>qH(Uint8ClampedArray,e);function rU(e,t){return nM(this,arguments,function*(){if(wH(t))return yield tM(yield tM(yield*rM(iM(rU(e,yield tM(t))))));let n=function(e){return nM(this,arguments,function*(){yield yield tM(yield tM(e))})},r=function(e){return nM(this,arguments,function*(){yield tM(yield*rM(iM(KH(function*(e){let t=null;do t=e.next(yield t?.value);while(!t.done)}(e[Symbol.iterator]())))))})},i=typeof t==`string`||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof AH?n(t):TH(t)?r(t):EH(t)?t:n(t);return yield tM(yield*rM(iM(KH(function(t){return nM(this,arguments,function*(){let n=null;do n=yield tM(t.next(yield yield tM(PH(e,n))));while(!n.done)})}(i[Symbol.asyncIterator]()))))),yield tM(new e)})}const iU=e=>rU(Int8Array,e),aU=e=>rU(Int16Array,e),oU=e=>rU(Int32Array,e),sU=e=>rU(Uint8Array,e),cU=e=>rU(Uint16Array,e),lU=e=>rU(Uint32Array,e),uU=e=>rU(Float32Array,e),dU=e=>rU(Float64Array,e),fU=e=>rU(Uint8ClampedArray,e);function pU(e,t,n){if(e!==0){n=n.slice(0,t);for(let t=-1,r=n.length;++t0)do if(e[n]!==t[n])return!1;while(++nCU});const SU=void 0;function CU(e){if(e===null)return`null`;if(e===SU)return`undefined`;switch(typeof e){case`number`:return`${e}`;case`bigint`:return`${e}`;case`string`:return`"${e}"`}return typeof e[Symbol.toPrimitive]==`function`?e[Symbol.toPrimitive](`string`):ArrayBuffer.isView(e)?e instanceof BigInt64Array||e instanceof BigUint64Array?`[${[...e].map(e=>CU(e))}]`:`[${e}]`:ArrayBuffer.isView(e)?`[${e}]`:JSON.stringify(e,(e,t)=>typeof t==`bigint`?`${t}`:t)}function wU(e){if(typeof e==`bigint`&&(e<-(2**53-1)||e>2**53-1))throw TypeError(`${e} is not safe to convert to a number.`);return Number(e)}function TU(e,t){return wU(e/t)+wU(e%t)/wU(t)}var EU={};St(EU,{BN:()=>RU,bigNumToBigInt:()=>IU,bigNumToNumber:()=>PU,bigNumToString:()=>FU,isArrowBigNumSymbol:()=>DU});const DU=Symbol.for(`isArrowBigNum`);function OU(e,...t){return t.length===0?Object.setPrototypeOf(PH(this.TypedArray,e),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(e,...t),this.constructor.prototype)}OU.prototype[DU]=!0,OU.prototype.toJSON=function(){return`"${FU(this)}"`},OU.prototype.valueOf=function(e){return PU(this,e)},OU.prototype.toString=function(){return FU(this)},OU.prototype[Symbol.toPrimitive]=function(e=`default`){switch(e){case`number`:return PU(this);case`string`:return FU(this);case`default`:return IU(this)}return FU(this)};function kU(...e){return OU.apply(this,e)}function AU(...e){return OU.apply(this,e)}function jU(...e){return OU.apply(this,e)}Object.setPrototypeOf(kU.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(AU.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(jU.prototype,Object.create(Uint32Array.prototype)),Object.assign(kU.prototype,OU.prototype,{constructor:kU,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(AU.prototype,OU.prototype,{constructor:AU,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(jU.prototype,OU.prototype,{constructor:jU,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const MU=BigInt(4294967296)*BigInt(4294967296),NU=MU-BigInt(1);function PU(e,t){let{buffer:n,byteOffset:r,byteLength:i,signed:a}=e,o=new BigUint64Array(n,r,i/8),s=a&&o.at(-1)&BigInt(1)<0){let e=BigInt(`1`.padEnd(t+1,`0`)),n=c/e,r=s?-(c%e):c%e,i=wU(n),a=`${r}`.padStart(t,`0`),o=s&&i===0?`-`:``;return+`${o}${i}.${a}`}return wU(c)}function FU(e){if(e.byteLength===8){let t=new e.BigIntArray(e.buffer,e.byteOffset,1);return`${t[0]}`}if(!e.signed)return LU(e);let t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),n=new Int16Array([t.at(-1)])[0];if(n>=0)return LU(e);t=t.slice();let r=1;for(let e=0;e(e.children=null,e.ArrayType=Array,e.OffsetArrayType=Int32Array,e[Symbol.toStringTag]=`DataType`))(sW.prototype);var cW=class extends sW{constructor(){super(X.Null)}toString(){return`Null`}};BU=Symbol.toStringTag,cW[BU]=(e=>e[Symbol.toStringTag]=`Null`)(cW.prototype);var lW=class extends sW{constructor(e,t){super(X.Int),this.isSigned=e,this.bitWidth=t}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?`I`:`Ui`}nt${this.bitWidth}`}};VU=Symbol.toStringTag,lW[VU]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]=`Int`))(lW.prototype);var uW=class extends lW{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},dW=class extends lW{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},fW=class extends lW{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},pW=class extends lW{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},mW=class extends lW{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},hW=class extends lW{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},gW=class extends lW{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},_W=class extends lW{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(uW.prototype,`ArrayType`,{value:Int8Array}),Object.defineProperty(dW.prototype,`ArrayType`,{value:Int16Array}),Object.defineProperty(fW.prototype,`ArrayType`,{value:Int32Array}),Object.defineProperty(pW.prototype,`ArrayType`,{value:BigInt64Array}),Object.defineProperty(mW.prototype,`ArrayType`,{value:Uint8Array}),Object.defineProperty(hW.prototype,`ArrayType`,{value:Uint16Array}),Object.defineProperty(gW.prototype,`ArrayType`,{value:Uint32Array}),Object.defineProperty(_W.prototype,`ArrayType`,{value:BigUint64Array});var vW=class extends sW{constructor(e){super(X.Float),this.precision=e}get ArrayType(){switch(this.precision){case gU.HALF:return Uint16Array;case gU.SINGLE:return Float32Array;case gU.DOUBLE:return Float64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};HU=Symbol.toStringTag,vW[HU]=(e=>(e.precision=null,e[Symbol.toStringTag]=`Float`))(vW.prototype);var yW=class extends vW{constructor(){super(gU.HALF)}},bW=class extends vW{constructor(){super(gU.SINGLE)}},xW=class extends vW{constructor(){super(gU.DOUBLE)}};Object.defineProperty(yW.prototype,`ArrayType`,{value:Uint16Array}),Object.defineProperty(bW.prototype,`ArrayType`,{value:Float32Array}),Object.defineProperty(xW.prototype,`ArrayType`,{value:Float64Array});var SW=class extends sW{constructor(){super(X.Binary)}toString(){return`Binary`}};UU=Symbol.toStringTag,SW[UU]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Binary`))(SW.prototype);var CW=class extends sW{constructor(){super(X.LargeBinary)}toString(){return`LargeBinary`}};WU=Symbol.toStringTag,CW[WU]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeBinary`))(CW.prototype);var wW=class extends sW{constructor(){super(X.Utf8)}toString(){return`Utf8`}};GU=Symbol.toStringTag,wW[GU]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Utf8`))(wW.prototype);var TW=class extends sW{constructor(){super(X.LargeUtf8)}toString(){return`LargeUtf8`}};KU=Symbol.toStringTag,TW[KU]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeUtf8`))(TW.prototype);var EW=class extends sW{constructor(){super(X.Bool)}toString(){return`Bool`}};qU=Symbol.toStringTag,EW[qU]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Bool`))(EW.prototype);var DW=class extends sW{constructor(e,t,n=128){super(X.Decimal),this.scale=e,this.precision=t,this.bitWidth=n}toString(){return`Decimal[${this.precision}e${this.scale>0?`+`:``}${this.scale}]`}};JU=Symbol.toStringTag,DW[JU]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]=`Decimal`))(DW.prototype);var OW=class extends sW{constructor(e){super(X.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${_U[this.unit]}>`}get ArrayType(){return this.unit===_U.DAY?Int32Array:BigInt64Array}};YU=Symbol.toStringTag,OW[YU]=(e=>(e.unit=null,e[Symbol.toStringTag]=`Date`))(OW.prototype);var kW=class extends sW{constructor(e,t){super(X.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${vU[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};XU=Symbol.toStringTag,kW[XU]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]=`Time`))(kW.prototype);var AW=class extends sW{constructor(e,t){super(X.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${vU[this.unit]}${this.timezone?`, ${this.timezone}`:``}>`}};ZU=Symbol.toStringTag,AW[ZU]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Timestamp`))(AW.prototype);var jW=class extends sW{constructor(e){super(X.Interval),this.unit=e}toString(){return`Interval<${yU[this.unit]}>`}};QU=Symbol.toStringTag,jW[QU]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]=`Interval`))(jW.prototype);var MW=class extends sW{constructor(e){super(X.Duration),this.unit=e}toString(){return`Duration<${vU[this.unit]}>`}};$U=Symbol.toStringTag,MW[$U]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Duration`))(MW.prototype);var NW=class extends sW{constructor(e){super(X.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};eW=Symbol.toStringTag,NW[eW]=(e=>(e.children=null,e[Symbol.toStringTag]=`List`))(NW.prototype);var PW=class extends sW{constructor(e){super(X.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(`, `)}}>`}};tW=Symbol.toStringTag,PW[tW]=(e=>(e.children=null,e[Symbol.toStringTag]=`Struct`))(PW.prototype);var FW=class extends sW{constructor(e,t,n){super(X.Union),this.mode=e,this.children=n,this.typeIds=t=Int32Array.from(t),this.typeIdToChildIndex=t.reduce((e,t,n)=>(e[t]=n)&&e||e,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(` | `)}>`}};nW=Symbol.toStringTag,FW[nW]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]=`Union`))(FW.prototype);var IW=class extends sW{constructor(e){super(X.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};rW=Symbol.toStringTag,IW[rW]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`FixedSizeBinary`))(IW.prototype);var LW=class extends sW{constructor(e,t){super(X.FixedSizeList),this.listSize=e,this.children=[t]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}};iW=Symbol.toStringTag,LW[iW]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]=`FixedSizeList`))(LW.prototype);var RW=class extends sW{constructor(e,t=!1){var n,r,i;if(super(X.Map),this.children=[e],this.keysSorted=t,e&&(e.name=`entries`,(n=e?.type)?.children)){let t=(r=e?.type)?.children[0];t&&(t.name=`key`);let n=(i=e?.type)?.children[1];n&&(n.name=`value`)}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(`, `)}}>`}};aW=Symbol.toStringTag,RW[aW]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]=`Map_`))(RW.prototype);const zW=(e=>()=>++e)(-1);var BW=class extends sW{constructor(e,t,n,r){super(X.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=r||!1,this.id=n==null?zW():wU(n)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}};oW=Symbol.toStringTag,BW[oW]=(e=>(e.id=null,e.indices=null,e.isOrdered=null,e.dictionary=null,e[Symbol.toStringTag]=`Dictionary`))(BW.prototype);function VW(e){let t=e;switch(e.typeId){case X.Decimal:return e.bitWidth/32;case X.Interval:return t.unit===yU.MONTH_DAY_NANO?4:1+t.unit;case X.FixedSizeList:return t.listSize;case X.FixedSizeBinary:return t.byteWidth;default:return 1}}var HW=class{visitMany(e,...t){return e.map((e,n)=>this.visit(e,...t.map(e=>e[n])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,t=!0){return UW(this,e,t)}getVisitFnByTypeId(e,t=!0){return WW(this,e,t)}visitNull(e,...t){return null}visitBool(e,...t){return null}visitInt(e,...t){return null}visitFloat(e,...t){return null}visitUtf8(e,...t){return null}visitLargeUtf8(e,...t){return null}visitBinary(e,...t){return null}visitLargeBinary(e,...t){return null}visitFixedSizeBinary(e,...t){return null}visitDate(e,...t){return null}visitTimestamp(e,...t){return null}visitTime(e,...t){return null}visitDecimal(e,...t){return null}visitList(e,...t){return null}visitStruct(e,...t){return null}visitUnion(e,...t){return null}visitDictionary(e,...t){return null}visitInterval(e,...t){return null}visitDuration(e,...t){return null}visitFixedSizeList(e,...t){return null}visitMap(e,...t){return null}};function UW(e,t,n=!0){return typeof t==`number`?WW(e,t,n):typeof t==`string`&&t in X?WW(e,X[t],n):t&&t instanceof sW?WW(e,GW(t),n):t?.type&&t.type instanceof sW?WW(e,GW(t.type),n):WW(e,X.NONE,n)}function WW(e,t,n=!0){let r=null;switch(t){case X.Null:r=e.visitNull;break;case X.Bool:r=e.visitBool;break;case X.Int:r=e.visitInt;break;case X.Int8:r=e.visitInt8||e.visitInt;break;case X.Int16:r=e.visitInt16||e.visitInt;break;case X.Int32:r=e.visitInt32||e.visitInt;break;case X.Int64:r=e.visitInt64||e.visitInt;break;case X.Uint8:r=e.visitUint8||e.visitInt;break;case X.Uint16:r=e.visitUint16||e.visitInt;break;case X.Uint32:r=e.visitUint32||e.visitInt;break;case X.Uint64:r=e.visitUint64||e.visitInt;break;case X.Float:r=e.visitFloat;break;case X.Float16:r=e.visitFloat16||e.visitFloat;break;case X.Float32:r=e.visitFloat32||e.visitFloat;break;case X.Float64:r=e.visitFloat64||e.visitFloat;break;case X.Utf8:r=e.visitUtf8;break;case X.LargeUtf8:r=e.visitLargeUtf8;break;case X.Binary:r=e.visitBinary;break;case X.LargeBinary:r=e.visitLargeBinary;break;case X.FixedSizeBinary:r=e.visitFixedSizeBinary;break;case X.Date:r=e.visitDate;break;case X.DateDay:r=e.visitDateDay||e.visitDate;break;case X.DateMillisecond:r=e.visitDateMillisecond||e.visitDate;break;case X.Timestamp:r=e.visitTimestamp;break;case X.TimestampSecond:r=e.visitTimestampSecond||e.visitTimestamp;break;case X.TimestampMillisecond:r=e.visitTimestampMillisecond||e.visitTimestamp;break;case X.TimestampMicrosecond:r=e.visitTimestampMicrosecond||e.visitTimestamp;break;case X.TimestampNanosecond:r=e.visitTimestampNanosecond||e.visitTimestamp;break;case X.Time:r=e.visitTime;break;case X.TimeSecond:r=e.visitTimeSecond||e.visitTime;break;case X.TimeMillisecond:r=e.visitTimeMillisecond||e.visitTime;break;case X.TimeMicrosecond:r=e.visitTimeMicrosecond||e.visitTime;break;case X.TimeNanosecond:r=e.visitTimeNanosecond||e.visitTime;break;case X.Decimal:r=e.visitDecimal;break;case X.List:r=e.visitList;break;case X.Struct:r=e.visitStruct;break;case X.Union:r=e.visitUnion;break;case X.DenseUnion:r=e.visitDenseUnion||e.visitUnion;break;case X.SparseUnion:r=e.visitSparseUnion||e.visitUnion;break;case X.Dictionary:r=e.visitDictionary;break;case X.Interval:r=e.visitInterval;break;case X.IntervalDayTime:r=e.visitIntervalDayTime||e.visitInterval;break;case X.IntervalYearMonth:r=e.visitIntervalYearMonth||e.visitInterval;break;case X.IntervalMonthDayNano:r=e.visitIntervalMonthDayNano||e.visitInterval;break;case X.Duration:r=e.visitDuration;break;case X.DurationSecond:r=e.visitDurationSecond||e.visitDuration;break;case X.DurationMillisecond:r=e.visitDurationMillisecond||e.visitDuration;break;case X.DurationMicrosecond:r=e.visitDurationMicrosecond||e.visitDuration;break;case X.DurationNanosecond:r=e.visitDurationNanosecond||e.visitDuration;break;case X.FixedSizeList:r=e.visitFixedSizeList;break;case X.Map:r=e.visitMap;break}if(typeof r==`function`)return r;if(!n)return()=>null;throw Error(`Unrecognized type '${X[t]}'`)}function GW(e){switch(e.typeId){case X.Null:return X.Null;case X.Int:{let{bitWidth:t,isSigned:n}=e;switch(t){case 8:return n?X.Int8:X.Uint8;case 16:return n?X.Int16:X.Uint16;case 32:return n?X.Int32:X.Uint32;case 64:return n?X.Int64:X.Uint64}return X.Int}case X.Float:switch(e.precision){case gU.HALF:return X.Float16;case gU.SINGLE:return X.Float32;case gU.DOUBLE:return X.Float64}return X.Float;case X.Binary:return X.Binary;case X.LargeBinary:return X.LargeBinary;case X.Utf8:return X.Utf8;case X.LargeUtf8:return X.LargeUtf8;case X.Bool:return X.Bool;case X.Decimal:return X.Decimal;case X.Time:switch(e.unit){case vU.SECOND:return X.TimeSecond;case vU.MILLISECOND:return X.TimeMillisecond;case vU.MICROSECOND:return X.TimeMicrosecond;case vU.NANOSECOND:return X.TimeNanosecond}return X.Time;case X.Timestamp:switch(e.unit){case vU.SECOND:return X.TimestampSecond;case vU.MILLISECOND:return X.TimestampMillisecond;case vU.MICROSECOND:return X.TimestampMicrosecond;case vU.NANOSECOND:return X.TimestampNanosecond}return X.Timestamp;case X.Date:switch(e.unit){case _U.DAY:return X.DateDay;case _U.MILLISECOND:return X.DateMillisecond}return X.Date;case X.Interval:switch(e.unit){case yU.DAY_TIME:return X.IntervalDayTime;case yU.YEAR_MONTH:return X.IntervalYearMonth;case yU.MONTH_DAY_NANO:return X.IntervalMonthDayNano}return X.Interval;case X.Duration:switch(e.unit){case vU.SECOND:return X.DurationSecond;case vU.MILLISECOND:return X.DurationMillisecond;case vU.MICROSECOND:return X.DurationMicrosecond;case vU.NANOSECOND:return X.DurationNanosecond}return X.Duration;case X.Map:return X.Map;case X.List:return X.List;case X.Struct:return X.Struct;case X.Union:switch(e.mode){case hU.Dense:return X.DenseUnion;case hU.Sparse:return X.SparseUnion}return X.Union;case X.FixedSizeBinary:return X.FixedSizeBinary;case X.FixedSizeList:return X.FixedSizeList;case X.Dictionary:return X.Dictionary}throw Error(`Unrecognized type '${X[e.typeId]}'`)}HW.prototype.visitInt8=null,HW.prototype.visitInt16=null,HW.prototype.visitInt32=null,HW.prototype.visitInt64=null,HW.prototype.visitUint8=null,HW.prototype.visitUint16=null,HW.prototype.visitUint32=null,HW.prototype.visitUint64=null,HW.prototype.visitFloat16=null,HW.prototype.visitFloat32=null,HW.prototype.visitFloat64=null,HW.prototype.visitDateDay=null,HW.prototype.visitDateMillisecond=null,HW.prototype.visitTimestampSecond=null,HW.prototype.visitTimestampMillisecond=null,HW.prototype.visitTimestampMicrosecond=null,HW.prototype.visitTimestampNanosecond=null,HW.prototype.visitTimeSecond=null,HW.prototype.visitTimeMillisecond=null,HW.prototype.visitTimeMicrosecond=null,HW.prototype.visitTimeNanosecond=null,HW.prototype.visitDenseUnion=null,HW.prototype.visitSparseUnion=null,HW.prototype.visitIntervalDayTime=null,HW.prototype.visitIntervalYearMonth=null,HW.prototype.visitIntervalMonthDayNano=null,HW.prototype.visitDuration=null,HW.prototype.visitDurationSecond=null,HW.prototype.visitDurationMillisecond=null,HW.prototype.visitDurationMicrosecond=null,HW.prototype.visitDurationNanosecond=null;var KW={};St(KW,{float64ToUint16:()=>XW,uint16ToFloat64:()=>YW});const qW=new Float64Array(1),JW=new Uint32Array(qW.buffer);function YW(e){let t=(e&31744)>>10,n=(e&1023)/1024,r=(-1)**((e&32768)>>15);switch(t){case 31:return r*(n?NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*2**(t-15)*(1+n)}function XW(e){if(e!==e)return 32256;qW[0]=e;let t=(JW[1]&2147483648)>>16&65535,n=JW[1]&2146435072,r=0;return n>=1089470464?JW[0]>0?n=31744:(n=(n&2080374784)>>16,r=(JW[1]&1048575)>>10):n<=1056964608?(r=1048576+(JW[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(JW[1]&1048575)+512>>10),t|n|r&65535}var ZW=class extends HW{};function QW(e){return(t,n,r)=>{if(t.setValid(n,r!=null))return e(t,n,r)}}const $W=(e,t,n)=>{e[t]=Math.floor(n/864e5)},eG=(e,t,n,r)=>{if(n+1{let i=e+n;r?t[i>>3]|=1<>3]&=~(1<{e[t]=n},rG=({values:e},t,n)=>{e[t]=n},iG=({values:e},t,n)=>{e[t]=XW(n)},aG=(e,t,n)=>{switch(e.type.precision){case gU.HALF:return iG(e,t,n);case gU.SINGLE:case gU.DOUBLE:return rG(e,t,n)}},oG=({values:e},t,n)=>{$W(e,t,n.valueOf())},sG=({values:e},t,n)=>{e[t]=BigInt(n)},cG=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},lG=({values:e,valueOffsets:t},n,r)=>eG(e,t,n,r),uG=({values:e,valueOffsets:t},n,r)=>eG(e,t,n,xH(r)),dG=(e,t,n)=>{e.type.unit===_U.DAY?oG(e,t,n):sG(e,t,n)},fG=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},pG=({values:e},t,n)=>{e[t]=BigInt(n)},mG=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},hG=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},gG=(e,t,n)=>{switch(e.type.unit){case vU.SECOND:return fG(e,t,n);case vU.MILLISECOND:return pG(e,t,n);case vU.MICROSECOND:return mG(e,t,n);case vU.NANOSECOND:return hG(e,t,n)}},_G=({values:e},t,n)=>{e[t]=n},vG=({values:e},t,n)=>{e[t]=n},yG=({values:e},t,n)=>{e[t]=n},bG=({values:e},t,n)=>{e[t]=n},xG=(e,t,n)=>{switch(e.type.unit){case vU.SECOND:return _G(e,t,n);case vU.MILLISECOND:return vG(e,t,n);case vU.MICROSECOND:return yG(e,t,n);case vU.NANOSECOND:return bG(e,t,n)}},SG=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},CG=(e,t,n)=>{let r=e.children[0],i=e.valueOffsets,a=WG.getVisitFn(r);if(Array.isArray(n))for(let e=-1,o=i[t],s=i[t+1];o{let r=e.children[0],{valueOffsets:i}=e,a=WG.getVisitFn(r),{[t]:o,[t+1]:s}=i,c=n instanceof Map?n.entries():Object.entries(n);for(let e of c)if(a(r,o,e),++o>=s)break},TG=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[a]),EG=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(a)),DG=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(i.name)),OG=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[i.name]),kG=(e,t,n)=>{let r=e.type.children.map(e=>WG.getVisitFn(e.type)),i=n instanceof Map?DG(t,n):n instanceof qq?EG(t,n):Array.isArray(n)?TG(t,n):OG(t,n);e.type.children.forEach((t,n)=>i(r[n],e.children[n],t,n))},AG=(e,t,n)=>{e.type.mode===hU.Dense?jG(e,t,n):MG(e,t,n)},jG=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];WG.visit(i,e.valueOffsets[t],n)},MG=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];WG.visit(i,t,n)},NG=(e,t,n)=>{var r;(r=e.dictionary)==null||r.set(e.values[t],n)},PG=(e,t,n)=>{switch(e.type.unit){case yU.YEAR_MONTH:return IG(e,t,n);case yU.DAY_TIME:return FG(e,t,n);case yU.MONTH_DAY_NANO:return LG(e,t,n)}},FG=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},IG=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},LG=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},RG=({values:e},t,n)=>{e[t]=n},zG=({values:e},t,n)=>{e[t]=n},BG=({values:e},t,n)=>{e[t]=n},VG=({values:e},t,n)=>{e[t]=n},HG=(e,t,n)=>{switch(e.type.unit){case vU.SECOND:return RG(e,t,n);case vU.MILLISECOND:return zG(e,t,n);case vU.MICROSECOND:return BG(e,t,n);case vU.NANOSECOND:return VG(e,t,n)}},UG=(e,t,n)=>{let{stride:r}=e,i=e.children[0],a=WG.getVisitFn(i);if(Array.isArray(n))for(let e=-1,o=t*r;++e`${CU(e)}: ${CU(t)}`).join(`, `)}}`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}[Symbol.iterator](){return new JG(this[GG],this[KG])}},JG=class{constructor(e,t){this.childIndex=0,this.children=e.children,this.rowIndex=t,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let e=this.childIndex;return ee.name)}has(e,t){return e[GG].type.children.some(e=>e.name===t)}getOwnPropertyDescriptor(e,t){if(e[GG].type.children.some(e=>e.name===t))return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];let n=e[GG].type.children.findIndex(e=>e.name===t);if(n!==-1){let r=HK.visit(e[GG].children[n],e[KG]);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[GG].type.children.findIndex(e=>e.name===t);return r===-1?Reflect.has(e,t)||typeof t==`symbol`?Reflect.set(e,t,n):!1:(WG.visit(e[GG].children[r],e[KG],n),Reflect.set(e,t,n))}};const XG=new YG;var ZG=class extends HW{};function QG(e){return(t,n)=>t.getValid(n)?e(t,n):null}const $G=(e,t)=>864e5*e[t],eK=(e,t)=>null,tK=(e,t,n)=>{if(n+1>=t.length)return null;let r=wU(t[n]),i=wU(t[n+1]);return e.subarray(r,i)},nK=({offset:e,values:t},n)=>{let r=e+n,i=t[r>>3];return(i&1<$G(e,t),iK=({values:e},t)=>wU(e[t]),aK=({stride:e,values:t},n)=>t[e*n],oK=({stride:e,values:t},n)=>YW(t[e*n]),sK=({values:e},t)=>e[t],cK=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),lK=({values:e,valueOffsets:t},n)=>tK(e,t,n),uK=({values:e,valueOffsets:t},n)=>{let r=tK(e,t,n);return r===null?null:yH(r)},dK=({values:e},t)=>e[t],fK=({type:e,values:t},n)=>e.precision===gU.HALF?YW(t[n]):t[n],pK=(e,t)=>e.type.unit===_U.DAY?rK(e,t):iK(e,t),mK=({values:e},t)=>1e3*wU(e[t]),hK=({values:e},t)=>wU(e[t]),gK=({values:e},t)=>TU(e[t],BigInt(1e3)),_K=({values:e},t)=>TU(e[t],BigInt(1e6)),vK=(e,t)=>{switch(e.type.unit){case vU.SECOND:return mK(e,t);case vU.MILLISECOND:return hK(e,t);case vU.MICROSECOND:return gK(e,t);case vU.NANOSECOND:return _K(e,t)}},yK=({values:e},t)=>e[t],bK=({values:e},t)=>e[t],xK=({values:e},t)=>e[t],SK=({values:e},t)=>e[t],CK=(e,t)=>{switch(e.type.unit){case vU.SECOND:return yK(e,t);case vU.MILLISECOND:return bK(e,t);case vU.MICROSECOND:return xK(e,t);case vU.NANOSECOND:return SK(e,t)}},wK=({values:e,stride:t},n)=>RU.decimal(e.subarray(t*n,t*(n+1))),TK=(e,t)=>{let{valueOffsets:n,stride:r,children:i}=e,{[t*r]:a,[t*r+1]:o}=n,s=i[0],c=s.slice(a,o-a);return new qq([c])},EK=(e,t)=>{let{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:a}=n,o=r[0];return new qK(o.slice(i,a-i))},DK=(e,t)=>new qG(e,t),OK=(e,t)=>e.type.mode===hU.Dense?kK(e,t):AK(e,t),kK=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return HK.visit(r,e.valueOffsets[t])},AK=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return HK.visit(r,t)},jK=(e,t)=>{var n;return(n=e.dictionary)?.get(e.values[t])},MK=(e,t)=>e.type.unit===yU.MONTH_DAY_NANO?FK(e,t):e.type.unit===yU.DAY_TIME?NK(e,t):PK(e,t),NK=({values:e},t)=>e.subarray(2*t,2*(t+1)),PK=({values:e},t)=>{let n=e[t],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},FK=({values:e},t)=>e.subarray(4*t,4*(t+1)),IK=({values:e},t)=>e[t],LK=({values:e},t)=>e[t],RK=({values:e},t)=>e[t],zK=({values:e},t)=>e[t],BK=(e,t)=>{switch(e.type.unit){case vU.SECOND:return IK(e,t);case vU.MILLISECOND:return LK(e,t);case vU.MICROSECOND:return RK(e,t);case vU.NANOSECOND:return zK(e,t)}},VK=(e,t)=>{let{stride:n,children:r}=e,i=r[0],a=i.slice(t*n,n);return new qq([a])};ZG.prototype.visitNull=QG(eK),ZG.prototype.visitBool=QG(nK),ZG.prototype.visitInt=QG(dK),ZG.prototype.visitInt8=QG(aK),ZG.prototype.visitInt16=QG(aK),ZG.prototype.visitInt32=QG(aK),ZG.prototype.visitInt64=QG(sK),ZG.prototype.visitUint8=QG(aK),ZG.prototype.visitUint16=QG(aK),ZG.prototype.visitUint32=QG(aK),ZG.prototype.visitUint64=QG(sK),ZG.prototype.visitFloat=QG(fK),ZG.prototype.visitFloat16=QG(oK),ZG.prototype.visitFloat32=QG(aK),ZG.prototype.visitFloat64=QG(aK),ZG.prototype.visitUtf8=QG(uK),ZG.prototype.visitLargeUtf8=QG(uK),ZG.prototype.visitBinary=QG(lK),ZG.prototype.visitLargeBinary=QG(lK),ZG.prototype.visitFixedSizeBinary=QG(cK),ZG.prototype.visitDate=QG(pK),ZG.prototype.visitDateDay=QG(rK),ZG.prototype.visitDateMillisecond=QG(iK),ZG.prototype.visitTimestamp=QG(vK),ZG.prototype.visitTimestampSecond=QG(mK),ZG.prototype.visitTimestampMillisecond=QG(hK),ZG.prototype.visitTimestampMicrosecond=QG(gK),ZG.prototype.visitTimestampNanosecond=QG(_K),ZG.prototype.visitTime=QG(CK),ZG.prototype.visitTimeSecond=QG(yK),ZG.prototype.visitTimeMillisecond=QG(bK),ZG.prototype.visitTimeMicrosecond=QG(xK),ZG.prototype.visitTimeNanosecond=QG(SK),ZG.prototype.visitDecimal=QG(wK),ZG.prototype.visitList=QG(TK),ZG.prototype.visitStruct=QG(DK),ZG.prototype.visitUnion=QG(OK),ZG.prototype.visitDenseUnion=QG(kK),ZG.prototype.visitSparseUnion=QG(AK),ZG.prototype.visitDictionary=QG(jK),ZG.prototype.visitInterval=QG(MK),ZG.prototype.visitIntervalDayTime=QG(NK),ZG.prototype.visitIntervalYearMonth=QG(PK),ZG.prototype.visitIntervalMonthDayNano=QG(FK),ZG.prototype.visitDuration=QG(BK),ZG.prototype.visitDurationSecond=QG(IK),ZG.prototype.visitDurationMillisecond=QG(LK),ZG.prototype.visitDurationMicrosecond=QG(RK),ZG.prototype.visitDurationNanosecond=QG(zK),ZG.prototype.visitFixedSizeList=QG(VK),ZG.prototype.visitMap=QG(EK);const HK=new ZG,UK=Symbol.for(`keys`),WK=Symbol.for(`vals`),GK=Symbol.for(`kKeysAsStrings`),KK=Symbol.for(`_kKeysAsStrings`);var qK=class{constructor(e){return this[UK]=new qq([e.children[0]]).memoize(),this[WK]=e.children[1],new Proxy(this,new YK)}get[GK](){return this[KK]||(this[KK]=Array.from(this[UK].toArray(),String))}[Symbol.iterator](){return new JK(this[UK],this[WK])}get size(){return this[UK].length}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[UK],t=this[WK],n={};for(let r=-1,i=e.length;++r`${CU(e)}: ${CU(t)}`).join(`, `)}}`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}},JK=class{constructor(e,t){this.keys=e,this.vals=t,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){let e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),HK.visit(this.vals,e)]})}},YK=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[GK]}has(e,t){return e[GK].includes(t)}getOwnPropertyDescriptor(e,t){let n=e[GK].indexOf(t);if(n!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];let n=e[GK].indexOf(t);if(n!==-1){let r=HK.visit(Reflect.get(e,WK),n);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[GK].indexOf(t);return r===-1?Reflect.has(e,t)?Reflect.set(e,t,n):!1:(WG.visit(Reflect.get(e,WK),r,n),Reflect.set(e,t,n))}};Object.defineProperties(qK.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:`Row`},[UK]:{writable:!0,enumerable:!1,configurable:!1,value:null},[WK]:{writable:!0,enumerable:!1,configurable:!1,value:null},[KK]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var XK={};St(XK,{clampRange:()=>QK,createElementComparator:()=>tq,wrapIndex:()=>$K});let ZK;function QK(e,t,n,r){let{length:i=0}=e,a=typeof t==`number`?t:0,o=typeof n==`number`?n:i;return a<0&&(a=(a%i+i)%i),o<0&&(o=(o%i+i)%i),oi&&(o=i),r?r(e,a,o):[a,o]}const $K=(e,t)=>e<0?t+e:e,eq=e=>e!==e;function tq(e){let t=typeof e;if(t!==`object`||e===null)return eq(e)?eq:t=>t===e;if(e instanceof Date){let t=e.valueOf();return e=>e instanceof Date?e.valueOf()===t:!1}return ArrayBuffer.isView(e)?t=>t?mU(e,t):!1:e instanceof Map?rq(e):Array.isArray(e)?nq(e):e instanceof qq?iq(e):aq(e,!0)}function nq(e){let t=[];for(let n=-1,r=e.length;++n!1;let r=[];for(let t=-1,i=n.length;++t{if(!n||typeof n!=`object`)return!1;switch(n.constructor){case Array:return sq(e,n);case Map:return lq(e,n,n.keys());case qK:case qG:case Object:case void 0:return lq(e,n,t||Object.keys(n))}return n instanceof qq?cq(e,n):!1}}function sq(e,t){let n=e.length;if(t.length!==n)return!1;for(let r=-1;++rgq,getBit:()=>fq,getBool:()=>dq,packBools:()=>hq,popcnt_array:()=>vq,popcnt_bit_range:()=>_q,popcnt_uint32:()=>yq,setBool:()=>pq,truncateBitmap:()=>mq});function dq(e,t,n,r){return(n&1<>r}function pq(e,t,n){return n?!!(e[t>>3]|=1<>3]&=~(1<0||n.byteLength>3):hq(new gq(n,e,t,null,dq)).subarray(0,r)),i}return n}function hq(e){let t=[],n=0,r=0,i=0;for(let a of e)a&&(i|=1<0)&&(t[n++]=i);let a=new Uint8Array(t.length+7&-8);return a.set(t),a}var gq=class{constructor(e,t,n,r,i){this.bytes=e,this.length=n,this.context=r,this.get=i,this.bit=t%8,this.byteIndex=t>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,i=t+(t%8==0?0:8-t%8);return _q(e,t,i)+_q(e,r,n)+vq(e,i>>3,r-i>>3)}function vq(e,t,n){let r=0,i=Math.trunc(t),a=new DataView(e.buffer,e.byteOffset,e.byteLength),o=n===void 0?e.byteLength:i+n;for(;o-i>=4;)r+=yq(a.getUint32(i)),i+=4;for(;o-i>=2;)r+=yq(a.getUint16(i)),i+=2;for(;o-i>=1;)r+=yq(a.getUint8(i)),i+=1;return r}function yq(e){let t=Math.trunc(e);return t-=t>>>1&1431655765,t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}const bq=-1;var xq=class e{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){let{type:e}=this;return sW.isSparseUnion(e)||sW.isDenseUnion(e)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0,{valueOffsets:t,values:n,nullBitmap:r,typeIds:i}=this;return t&&(e+=t.byteLength),n&&(e+=n.byteLength),r&&(e+=r.byteLength),i&&(e+=i.byteLength),this.children.reduce((e,t)=>e+t.byteLength,e)}get nullCount(){if(sW.isUnion(this.type))return this.children.reduce((e,t)=>e+t.nullCount,0);let e=this._nullCount,t;return e<=bq&&(t=this.nullBitmap)&&(this._nullCount=e=t.length===0?0:this.length-_q(t,this.offset,this.offset+this.length)),e}constructor(t,n,r,i,a,o=[],s){this.type=t,this.children=o,this.dictionary=s,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let c;a instanceof e?(this.stride=a.stride,this.values=a.values,this.typeIds=a.typeIds,this.nullBitmap=a.nullBitmap,this.valueOffsets=a.valueOffsets):(this.stride=VW(t),a&&((c=a[0])&&(this.valueOffsets=c),(c=a[1])&&(this.values=c),(c=a[2])&&(this.nullBitmap=c),(c=a[3])&&(this.typeIds=c)))}getValid(e){let{type:t}=this;if(sW.isUnion(t)){let n=t,r=this.children[n.typeIdToChildIndex[this.typeIds[e]]],i=n.mode===hU.Dense?this.valueOffsets[e]:e;return r.getValid(i)}if(this.nullable&&this.nullCount>0){let t=this.offset+e,n=this.nullBitmap[t>>3];return(n&1<>3;(!r||r.byteLength<=c)&&(r=new Uint8Array((i+a+63&-64)>>3).fill(255),this.nullCount>0?(r.set(mq(i,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:r})):Object.assign(this,{nullBitmap:r,_nullCount:0}));let l=r[c];n=(l&s)!==0,r[c]=t?l|s:l&~s}return n!==!!t&&(this._nullCount=this.nullCount+(t?-1:1)),t}clone(t=this.type,n=this.offset,r=this.length,i=this._nullCount,a=this,o=this.children){return new e(t,n,r,i,a,o,this.dictionary)}slice(e,t){let{stride:n,typeId:r,children:i}=this,a=(this._nullCount===0)-1,o=r===16?n:1,s=this._sliceBuffers(e,t,n,r);return this.clone(this.type,this.offset+e,t,a,s,i.length===0||this.valueOffsets?i:this._sliceChildren(i,o*e,o*t))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===X.Null)return this.clone(this.type,0,e,0);let{length:t,nullCount:n}=this,r=new Uint8Array((e+63&-64)>>3).fill(255,0,t>>3);r[t>>3]=(1<0&&r.set(mq(this.offset,t,this.nullBitmap),0);let i=this.buffers;return i[bU.VALIDITY]=r,this.clone(this.type,0,e,n+(e-t),i)}_sliceBuffers(e,t,n,r){let i,{buffers:a}=this;return(i=a[bU.TYPE])&&(a[bU.TYPE]=i.subarray(e,e+t)),(i=a[bU.OFFSET])&&(a[bU.OFFSET]=i.subarray(e,e+t+1))||(i=a[bU.DATA])&&(a[bU.DATA]=r===6?i:i.subarray(n*e,n*(e+t))),a}_sliceChildren(e,t,n){return e.map(e=>e.slice(t,n))}};xq.prototype.children=Object.freeze([]);var Sq=class e extends HW{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){let{type:t,offset:n=0,length:r=0}=e;return new xq(t,n,r,r)}visitBool(e){let{type:t,offset:n=0}=e,r=zH(e.nullBitmap),i=PH(t.ArrayType,e.data),{length:a=i.length>>3,nullCount:o=e.nullBitmap?-1:0}=e;return new xq(t,n,a,o,[void 0,i,r])}visitInt(e){let{type:t,offset:n=0}=e,r=zH(e.nullBitmap),i=PH(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new xq(t,n,a,o,[void 0,i,r])}visitFloat(e){let{type:t,offset:n=0}=e,r=zH(e.nullBitmap),i=PH(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new xq(t,n,a,o,[void 0,i,r])}visitUtf8(e){let{type:t,offset:n=0}=e,r=zH(e.data),i=zH(e.nullBitmap),a=LH(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new xq(t,n,o,s,[a,r,i])}visitLargeUtf8(e){let{type:t,offset:n=0}=e,r=zH(e.data),i=zH(e.nullBitmap),a=RH(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new xq(t,n,o,s,[a,r,i])}visitBinary(e){let{type:t,offset:n=0}=e,r=zH(e.data),i=zH(e.nullBitmap),a=LH(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new xq(t,n,o,s,[a,r,i])}visitLargeBinary(e){let{type:t,offset:n=0}=e,r=zH(e.data),i=zH(e.nullBitmap),a=RH(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new xq(t,n,o,s,[a,r,i])}visitFixedSizeBinary(e){let{type:t,offset:n=0}=e,r=zH(e.nullBitmap),i=PH(t.ArrayType,e.data),{length:a=i.length/VW(t),nullCount:o=e.nullBitmap?-1:0}=e;return new xq(t,n,a,o,[void 0,i,r])}visitDate(e){let{type:t,offset:n=0}=e,r=zH(e.nullBitmap),i=PH(t.ArrayType,e.data),{length:a=i.length/VW(t),nullCount:o=e.nullBitmap?-1:0}=e;return new xq(t,n,a,o,[void 0,i,r])}visitTimestamp(e){let{type:t,offset:n=0}=e,r=zH(e.nullBitmap),i=PH(t.ArrayType,e.data),{length:a=i.length/VW(t),nullCount:o=e.nullBitmap?-1:0}=e;return new xq(t,n,a,o,[void 0,i,r])}visitTime(e){let{type:t,offset:n=0}=e,r=zH(e.nullBitmap),i=PH(t.ArrayType,e.data),{length:a=i.length/VW(t),nullCount:o=e.nullBitmap?-1:0}=e;return new xq(t,n,a,o,[void 0,i,r])}visitDecimal(e){let{type:t,offset:n=0}=e,r=zH(e.nullBitmap),i=PH(t.ArrayType,e.data),{length:a=i.length/VW(t),nullCount:o=e.nullBitmap?-1:0}=e;return new xq(t,n,a,o,[void 0,i,r])}visitList(e){let{type:t,offset:n=0,child:r}=e,i=zH(e.nullBitmap),a=LH(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new xq(t,n,o,s,[a,void 0,i],[r])}visitStruct(e){let{type:t,offset:n=0,children:r=[]}=e,i=zH(e.nullBitmap),{length:a=r.reduce((e,{length:t})=>Math.max(e,t),0),nullCount:o=e.nullBitmap?-1:0}=e;return new xq(t,n,a,o,[void 0,void 0,i],r)}visitUnion(e){let{type:t,offset:n=0,children:r=[]}=e,i=PH(t.ArrayType,e.typeIds),{length:a=i.length,nullCount:o=-1}=e;if(sW.isSparseUnion(t))return new xq(t,n,a,o,[void 0,void 0,void 0,i],r);let s=LH(e.valueOffsets);return new xq(t,n,a,o,[s,void 0,void 0,i],r)}visitDictionary(t){let{type:n,offset:r=0}=t,i=zH(t.nullBitmap),a=PH(n.indices.ArrayType,t.data),{dictionary:o=new qq([new e().visit({type:n.dictionary})])}=t,{length:s=a.length,nullCount:c=t.nullBitmap?-1:0}=t;return new xq(n,r,s,c,[void 0,a,i],[],o)}visitInterval(e){let{type:t,offset:n=0}=e,r=zH(e.nullBitmap),i=PH(t.ArrayType,e.data),{length:a=i.length/VW(t),nullCount:o=e.nullBitmap?-1:0}=e;return new xq(t,n,a,o,[void 0,i,r])}visitDuration(e){let{type:t,offset:n=0}=e,r=zH(e.nullBitmap),i=PH(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new xq(t,n,a,o,[void 0,i,r])}visitFixedSizeList(t){let{type:n,offset:r=0,child:i=new e().visit({type:n.valueType})}=t,a=zH(t.nullBitmap),{length:o=i.length/VW(n),nullCount:s=t.nullBitmap?-1:0}=t;return new xq(n,r,o,s,[void 0,void 0,a],[i])}visitMap(t){let{type:n,offset:r=0,child:i=new e().visit({type:n.childType})}=t,a=zH(t.nullBitmap),o=LH(t.valueOffsets),{length:s=o.length-1,nullCount:c=t.nullBitmap?-1:0}=t;return new xq(n,r,s,c,[o,void 0,a],[i])}};const Cq=new Sq;var wq=class{constructor(e=0,t){this.numChunks=e,this.getChunkIterator=t,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe.nullable)}function Eq(e){return e.reduce((e,t)=>e+t.nullCount,0)}function Dq(e){return e.reduce((e,t,n)=>(e[n+1]=e[n]+t.length,e),new Uint32Array(e.length+1))}function Oq(e,t,n,r){let i=[];for(let a=-1,o=e.length;++a=r)break;if(n>=s+c)continue;if(s>=n&&s+c<=r){i.push(o);continue}let l=Math.max(0,n-s),u=Math.min(r-s,c);i.push(o.slice(l,u-l))}return i.length===0&&i.push(e[0].slice(0,0)),i}function kq(e,t,n,r){let i=0,a=0,o=t.length-1;do{if(i>=o-1)return n0?0:-1}function Iq(e,t){let{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(let i of new gq(n,e.offset+(t||0),e.length,n,dq)){if(!i)return r;++r}return-1}function Lq(e,t,n){if(t===void 0)return-1;if(t===null)switch(e.typeId){case X.Union:break;case X.Dictionary:break;default:return Iq(e,n)}let r=HK.getVisitFn(e),i=tq(t);for(let t=(n||0)-1,a=e.length;++t{let n=e.data[t];return n.values.subarray(0,n.length)[Symbol.iterator]()});let n=0;return new wq(e.data.length,t=>{let r=e.data[t],i=r.length,a=e.slice(n,n+i);return n+=i,new Hq(a)})}var Hq=class{constructor(e){this.vector=e,this.index=0}next(){return this.indexe.data):t;if(a.length===0||a.some(e=>!(e instanceof xq)))throw TypeError(`Vector constructor expects an Array of Data instances.`);let o=(n=a[0])?.type;switch(a.length){case 0:this._offsets=[0];break;case 1:{let{get:e,set:t,indexOf:n}=Gq[o.typeId],r=a[0];this.isValid=e=>Aq(r,e),this.get=t=>e(r,t),this.set=(e,n)=>t(r,e,n),this.indexOf=e=>n(r,e),this._offsets=[0,r.length];break}default:Object.setPrototypeOf(this,Kq[o.typeId]),this._offsets=Dq(a);break}this.data=a,this.type=o,this.stride=VW(o),this.numChildren=(i=(r=o.children)?.length)??0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,t)=>e+t.byteLength,0)}get nullable(){return Tq(this.data)}get nullCount(){return Eq(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${X[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get($K(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return Uq.visit(this)}concat(...t){return new e(this.data.concat(t.flatMap(e=>e.data).flat(1/0)))}slice(t,n){return new e(QK(this,t,n,({data:e,_offsets:t},n,r)=>Oq(e,t,n,r)))}toJSON(){return[...this]}toArray(){let{type:e,data:t,length:n,stride:r,ArrayType:i}=this;switch(e.typeId){case X.Int:case X.Float:case X.Decimal:case X.Time:case X.Timestamp:switch(t.length){case 0:return new i;case 1:return t[0].values.subarray(0,n*r);default:return t.reduce((e,{values:t,length:n})=>(e.array.set(t.subarray(0,n*r),e.offset),e.offset+=n*r,e),{array:new i(n*r),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(`,`)}]`}getChild(e){var t;return this.getChildAt((t=this.type.children)?.findIndex(t=>t.name===e))}getChildAt(t){return t>-1&&te[t])):null}get isMemoized(){return sW.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(sW.isDictionary(this.type)){let t=new Jq(this.data[0].dictionary),n=this.data.map(e=>{let n=e.clone();return n.dictionary=t,n});return new e(n)}return new Jq(this)}unmemoize(){if(sW.isDictionary(this.type)&&this.isMemoized){let t=this.data[0].dictionary.unmemoize(),n=this.data.map(e=>{let n=e.clone();return n.dictionary=t,n});return new e(n)}return this}};Wq=Symbol.toStringTag,qq[Wq]=(e=>{e.type=sW.prototype,e.data=[],e.length=0,e.stride=1,e.numChildren=0,e._offsets=new Uint32Array([0]),e[Symbol.isConcatSpreadable]=!0;let t=Object.keys(X).map(e=>X[e]).filter(e=>typeof e==`number`&&e!==X.NONE);for(let n of t){let t=HK.getVisitFnByTypeId(n),r=WG.getVisitFnByTypeId(n),i=zq.getVisitFnByTypeId(n);Gq[n]={get:t,set:r,indexOf:i},Kq[n]=Object.create(e,{isValid:{value:jq(Aq)},get:{value:jq(HK.getVisitFnByTypeId(n))},set:{value:Mq(WG.getVisitFnByTypeId(n))},indexOf:{value:Nq(zq.getVisitFnByTypeId(n))}})}return`Vector`})(qq.prototype);var Jq=class e extends qq{constructor(t){super(t.data);let n=this.get,r=this.set,i=this.slice,a=Array(this.length);Object.defineProperty(this,`get`,{value(e){let t=a[e];if(t!==void 0)return t;let r=n.call(this,e);return a[e]=r,r}}),Object.defineProperty(this,`set`,{value(e,t){r.call(this,e,t),a[e]=t}}),Object.defineProperty(this,`slice`,{value:(t,n)=>new e(i.call(this,t,n))}),Object.defineProperty(this,`isMemoized`,{value:!0}),Object.defineProperty(this,`unmemoize`,{value:()=>new qq(this.data)}),Object.defineProperty(this,`memoize`,{value:()=>this})}},Yq={};St(Yq,{BaseInt64:()=>eJ,Int128:()=>rJ,Int64:()=>nJ,Uint64:()=>tJ});const Xq=65536;function Zq(e){return e<0&&(e=4294967295+e+1),`0x${e.toString(16)}`}const Qq=8,$q=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];var eJ=class{constructor(e){this.buffer=e}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(e){let t=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),n=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]),r=t[3]*n[3];this.buffer[0]=r&65535;let i=r>>>16;return r=t[2]*n[3],i+=r,r=t[3]*n[2]>>>0,i+=r,this.buffer[0]+=i<<16,this.buffer[1]=i>>>0>>16,this.buffer[1]+=t[1]*n[3]+t[2]*n[2]+t[3]*n[1],this.buffer[1]+=t[0]*n[3]+t[1]*n[2]+t[2]*n[1]+t[3]*n[0]<<16,this}_plus(e){let t=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],t>>0&&++this.buffer[1],this.buffer[0]=t}lessThan(e){return this.buffer[1]>>0,t[2]=this.buffer[2]+e.buffer[2]>>>0,t[1]=this.buffer[1]+e.buffer[1]>>>0,t[0]=this.buffer[0]+e.buffer[0]>>>0,t[0]>>0&&++t[1],t[1]>>0&&++t[2],t[2]>>0&&++t[3],this.buffer[3]=t[3],this.buffer[2]=t[2],this.buffer[1]=t[1],this.buffer[0]=t[0],this}hex(){return`${Zq(this.buffer[3])} ${Zq(this.buffer[2])} ${Zq(this.buffer[1])} ${Zq(this.buffer[0])}`}static multiply(t,n){let r=new e(new Uint32Array(t.buffer));return r.times(n)}static add(t,n){let r=new e(new Uint32Array(t.buffer));return r.plus(n)}static from(t,n=new Uint32Array(4)){return e.fromString(typeof t==`string`?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(4)){return e.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(4)){let r=t.startsWith(`-`),i=t.length,a=new e(n);for(let n=r?1:0;naJ,toIntervalDayTimeObjects:()=>sJ,toIntervalMonthDayNanoInt32Array:()=>oJ,toIntervalMonthDayNanoObjects:()=>cJ});function aJ(e){var t,n;let r=e.length,i=new Int32Array(r*2);for(let a=0,o=0;a>BigInt(32))):o+=2}return i}function sJ(e){let t=e.length,n=Array(t/2);for(let r=0,i=0;r>>0);r[a++]={months:e[i],days:e[i+1],nanoseconds:t?`${n}`:n}}return r}var lJ=class extends HW{compareSchemas(e,t){return e===t||t instanceof e.constructor&&this.compareManyFields(e.fields,t.fields)}compareManyFields(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>this.compareFields(e,t[n]))}compareFields(e,t){return e===t||t instanceof e.constructor&&e.name===t.name&&e.nullable===t.nullable&&this.visit(e.type,t.type)}};function uJ(e,t){return t instanceof e.constructor}function dJ(e,t){return e===t||uJ(e,t)}function fJ(e,t){return e===t||uJ(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function pJ(e,t){return e===t||uJ(e,t)&&e.precision===t.precision}function mJ(e,t){return e===t||uJ(e,t)&&e.byteWidth===t.byteWidth}function hJ(e,t){return e===t||uJ(e,t)&&e.unit===t.unit}function gJ(e,t){return e===t||uJ(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function _J(e,t){return e===t||uJ(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function vJ(e,t){return e===t||uJ(e,t)&&e.children.length===t.children.length&&EJ.compareManyFields(e.children,t.children)}function yJ(e,t){return e===t||uJ(e,t)&&e.children.length===t.children.length&&EJ.compareManyFields(e.children,t.children)}function bJ(e,t){return e===t||uJ(e,t)&&e.mode===t.mode&&e.typeIds.every((e,n)=>e===t.typeIds[n])&&EJ.compareManyFields(e.children,t.children)}function xJ(e,t){return e===t||uJ(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&EJ.visit(e.indices,t.indices)&&EJ.visit(e.dictionary,t.dictionary)}function SJ(e,t){return e===t||uJ(e,t)&&e.unit===t.unit}function CJ(e,t){return e===t||uJ(e,t)&&e.unit===t.unit}function wJ(e,t){return e===t||uJ(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&EJ.compareManyFields(e.children,t.children)}function TJ(e,t){return e===t||uJ(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&EJ.compareManyFields(e.children,t.children)}lJ.prototype.visitNull=dJ,lJ.prototype.visitBool=dJ,lJ.prototype.visitInt=fJ,lJ.prototype.visitInt8=fJ,lJ.prototype.visitInt16=fJ,lJ.prototype.visitInt32=fJ,lJ.prototype.visitInt64=fJ,lJ.prototype.visitUint8=fJ,lJ.prototype.visitUint16=fJ,lJ.prototype.visitUint32=fJ,lJ.prototype.visitUint64=fJ,lJ.prototype.visitFloat=pJ,lJ.prototype.visitFloat16=pJ,lJ.prototype.visitFloat32=pJ,lJ.prototype.visitFloat64=pJ,lJ.prototype.visitUtf8=dJ,lJ.prototype.visitLargeUtf8=dJ,lJ.prototype.visitBinary=dJ,lJ.prototype.visitLargeBinary=dJ,lJ.prototype.visitFixedSizeBinary=mJ,lJ.prototype.visitDate=hJ,lJ.prototype.visitDateDay=hJ,lJ.prototype.visitDateMillisecond=hJ,lJ.prototype.visitTimestamp=gJ,lJ.prototype.visitTimestampSecond=gJ,lJ.prototype.visitTimestampMillisecond=gJ,lJ.prototype.visitTimestampMicrosecond=gJ,lJ.prototype.visitTimestampNanosecond=gJ,lJ.prototype.visitTime=_J,lJ.prototype.visitTimeSecond=_J,lJ.prototype.visitTimeMillisecond=_J,lJ.prototype.visitTimeMicrosecond=_J,lJ.prototype.visitTimeNanosecond=_J,lJ.prototype.visitDecimal=dJ,lJ.prototype.visitList=vJ,lJ.prototype.visitStruct=yJ,lJ.prototype.visitUnion=bJ,lJ.prototype.visitDenseUnion=bJ,lJ.prototype.visitSparseUnion=bJ,lJ.prototype.visitDictionary=xJ,lJ.prototype.visitInterval=SJ,lJ.prototype.visitIntervalDayTime=SJ,lJ.prototype.visitIntervalYearMonth=SJ,lJ.prototype.visitIntervalMonthDayNano=SJ,lJ.prototype.visitDuration=CJ,lJ.prototype.visitDurationSecond=CJ,lJ.prototype.visitDurationMillisecond=CJ,lJ.prototype.visitDurationMicrosecond=CJ,lJ.prototype.visitDurationNanosecond=CJ,lJ.prototype.visitFixedSizeList=wJ,lJ.prototype.visitMap=TJ;const EJ=new lJ;function DJ(e,t){return EJ.compareSchemas(e,t)}function OJ(e,t){return EJ.compareFields(e,t)}function kJ(e,t){return EJ.visit(e,t)}const AJ=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},EU),Yq),uq),KW),kH),XK),xU),iJ),{compareSchemas:DJ,compareFields:OJ,compareTypes:kJ}),jJ=365.2425,MJ=10**8*24*60*60*1e3,NJ=6048e5,PJ=864e5,FJ=3600,IJ=FJ*24,LJ=IJ*7,RJ=IJ*jJ,zJ=RJ/12,BJ=zJ*3,VJ=Symbol.for(`constructDateFrom`);function HJ(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&VJ in e?e[VJ](t):e instanceof Date?new e.constructor(t):new Date(t)}function UJ(e,t){return HJ(t||e,e)}let WJ={};function GJ(){return WJ}function KJ(e,t){var n,r;let i=GJ(),a=t?.weekStartsOn??(t==null||(n=t.locale)==null||(n=n.options)==null?void 0:n.weekStartsOn)??i.weekStartsOn??((r=i.locale)==null||(r=r.options)==null?void 0:r.weekStartsOn)??0,o=UJ(e,t?.in),s=o.getDay(),c=(s=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function YJ(e){let t=UJ(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),e-+n}function XJ(e,...t){let n=HJ.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}function ZJ(e,t){let n=UJ(e,t?.in);return n.setHours(0,0,0,0),n}function QJ(e,t,n){let[r,i]=XJ(n?.in,e,t),a=ZJ(r),o=ZJ(i),s=+a-YJ(a),c=+o-YJ(o);return Math.round((s-c)/PJ)}function $J(e,t){let n=JJ(e,t),r=HJ(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),qJ(r)}function eY(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function tY(e){return!(!eY(e)&&typeof e!=`number`||isNaN(+UJ(e)))}function nY(e,t){let n=UJ(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const rY={lessThanXSeconds:{one:`less than a second`,other:`less than {{count}} seconds`},xSeconds:{one:`1 second`,other:`{{count}} seconds`},halfAMinute:`half a minute`,lessThanXMinutes:{one:`less than a minute`,other:`less than {{count}} minutes`},xMinutes:{one:`1 minute`,other:`{{count}} minutes`},aboutXHours:{one:`about 1 hour`,other:`about {{count}} hours`},xHours:{one:`1 hour`,other:`{{count}} hours`},xDays:{one:`1 day`,other:`{{count}} days`},aboutXWeeks:{one:`about 1 week`,other:`about {{count}} weeks`},xWeeks:{one:`1 week`,other:`{{count}} weeks`},aboutXMonths:{one:`about 1 month`,other:`about {{count}} months`},xMonths:{one:`1 month`,other:`{{count}} months`},aboutXYears:{one:`about 1 year`,other:`about {{count}} years`},xYears:{one:`1 year`,other:`{{count}} years`},overXYears:{one:`over 1 year`,other:`over {{count}} years`},almostXYears:{one:`almost 1 year`,other:`almost {{count}} years`}},iY=(e,t,n)=>{let r,i=rY[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`in `+r:r+` ago`:r};function aY(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth,r=e.formats[n]||e.formats[e.defaultWidth];return r}}const oY={full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},sY={full:`h:mm:ss a zzzz`,long:`h:mm:ss a z`,medium:`h:mm:ss a`,short:`h:mm a`},cY={full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},lY={date:aY({formats:oY,defaultWidth:`full`}),time:aY({formats:sY,defaultWidth:`full`}),dateTime:aY({formats:cY,defaultWidth:`full`})},uY={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},dY=(e,t,n,r)=>uY[e];function fY(e){return(t,n)=>{let r=n?.context?String(n.context):`standalone`,i;if(r===`formatting`&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,r=n?.width?String(n.width):t;i=e.formattingValues[r]||e.formattingValues[t]}else{let t=e.defaultWidth,r=n?.width?String(n.width):e.defaultWidth;i=e.values[r]||e.values[t]}let a=e.argumentCallback?e.argumentCallback(t):t;return i[a]}}const pY={narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},mY={narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`1st quarter`,`2nd quarter`,`3rd quarter`,`4th quarter`]},hY={narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],wide:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]},gY={narrow:[`S`,`M`,`T`,`W`,`T`,`F`,`S`],short:[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],abbreviated:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],wide:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]},_Y={narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`}},vY={narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`}},yY=(e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+`st`;case 2:return n+`nd`;case 3:return n+`rd`}return n+`th`},bY={ordinalNumber:yY,era:fY({values:pY,defaultWidth:`wide`}),quarter:fY({values:mY,defaultWidth:`wide`,argumentCallback:e=>e-1}),month:fY({values:hY,defaultWidth:`wide`}),day:fY({values:gY,defaultWidth:`wide`}),dayPeriod:fY({values:_Y,defaultWidth:`wide`,formattingValues:vY,defaultFormattingWidth:`wide`})};function xY(e){return(t,n={})=>{let r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(i);if(!a)return null;let o=a[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?CY(s,e=>e.test(o)):SY(s,e=>e.test(o)),l;l=e.valueCallback?e.valueCallback(c):c,l=n.valueCallback?n.valueCallback(l):l;let u=t.slice(o.length);return{value:l,rest:u}}}function SY(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function CY(e,t){for(let n=0;n{let r=t.match(e.matchPattern);if(!r)return null;let i=r[0],a=t.match(e.parsePattern);if(!a)return null;let o=e.valueCallback?e.valueCallback(a[0]):a[0];o=n.valueCallback?n.valueCallback(o):o;let s=t.slice(i.length);return{value:o,rest:s}}}const TY=/^(\d+)(th|st|nd|rd)?/i,EY=/\d+/i,DY={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},OY={any:[/^b/i,/^(a|c)/i]},kY={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},AY={any:[/1/i,/2/i,/3/i,/4/i]},jY={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},MY={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},NY={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},PY={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},FY={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},IY={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},LY={ordinalNumber:wY({matchPattern:TY,parsePattern:EY,valueCallback:e=>parseInt(e,10)}),era:xY({matchPatterns:DY,defaultMatchWidth:`wide`,parsePatterns:OY,defaultParseWidth:`any`}),quarter:xY({matchPatterns:kY,defaultMatchWidth:`wide`,parsePatterns:AY,defaultParseWidth:`any`,valueCallback:e=>e+1}),month:xY({matchPatterns:jY,defaultMatchWidth:`wide`,parsePatterns:MY,defaultParseWidth:`any`}),day:xY({matchPatterns:NY,defaultMatchWidth:`wide`,parsePatterns:PY,defaultParseWidth:`any`}),dayPeriod:xY({matchPatterns:FY,defaultMatchWidth:`any`,parsePatterns:IY,defaultParseWidth:`any`})},RY={code:`en-US`,formatDistance:iY,formatLong:lY,formatRelative:dY,localize:bY,match:LY,options:{weekStartsOn:0,firstWeekContainsDate:1}};function zY(e,t){let n=UJ(e,t?.in),r=QJ(n,nY(n)),i=r+1;return i}function BY(e,t){let n=UJ(e,t?.in),r=qJ(n)-+$J(n);return Math.round(r/NJ)+1}function VY(e,t){var n,r;let i=UJ(e,t?.in),a=i.getFullYear(),o=GJ(),s=t?.firstWeekContainsDate??(t==null||(n=t.locale)==null||(n=n.options)==null?void 0:n.firstWeekContainsDate)??o.firstWeekContainsDate??((r=o.locale)==null||(r=r.options)==null?void 0:r.firstWeekContainsDate)??1,c=HJ(t?.in||e,0);c.setFullYear(a+1,0,s),c.setHours(0,0,0,0);let l=KJ(c,t),u=HJ(t?.in||e,0);u.setFullYear(a,0,s),u.setHours(0,0,0,0);let d=KJ(u,t);return+i>=+l?a+1:+i>=+d?a:a-1}function HY(e,t){var n,r;let i=GJ(),a=t?.firstWeekContainsDate??(t==null||(n=t.locale)==null||(n=n.options)==null?void 0:n.firstWeekContainsDate)??i.firstWeekContainsDate??((r=i.locale)==null||(r=r.options)==null?void 0:r.firstWeekContainsDate)??1,o=VY(e,t),s=HJ(t?.in||e,0);s.setFullYear(o,0,a),s.setHours(0,0,0,0);let c=KJ(s,t);return c}function UY(e,t){let n=UJ(e,t?.in),r=KJ(n,t)-+HY(n,t);return Math.round(r/NJ)+1}function WY(e,t){let n=e<0?`-`:``,r=Math.abs(e).toString().padStart(t,`0`);return n+r}const GY={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return WY(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):WY(n+1,2)},d(e,t){return WY(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.toUpperCase();case`aaa`:return n;case`aaaaa`:return n[0];case`aaaa`:default:return n===`am`?`a.m.`:`p.m.`}},h(e,t){return WY(e.getHours()%12||12,t.length)},H(e,t){return WY(e.getHours(),t.length)},m(e,t){return WY(e.getMinutes(),t.length)},s(e,t){return WY(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds(),i=Math.trunc(r*10**(n-3));return WY(i,t.length)}},KY={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},qY={G:function(e,t,n){let r=e.getFullYear()>0?1:0;switch(t){case`G`:case`GG`:case`GGG`:return n.era(r,{width:`abbreviated`});case`GGGGG`:return n.era(r,{width:`narrow`});case`GGGG`:default:return n.era(r,{width:`wide`})}},y:function(e,t,n){if(t===`yo`){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:`year`})}return GY.y(e,t)},Y:function(e,t,n,r){let i=VY(e,r),a=i>0?i:1-i;if(t===`YY`){let e=a%100;return WY(e,2)}return t===`Yo`?n.ordinalNumber(a,{unit:`year`}):WY(a,t.length)},R:function(e,t){let n=JJ(e);return WY(n,t.length)},u:function(e,t){let n=e.getFullYear();return WY(n,t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`Q`:return String(r);case`QQ`:return WY(r,2);case`Qo`:return n.ordinalNumber(r,{unit:`quarter`});case`QQQ`:return n.quarter(r,{width:`abbreviated`,context:`formatting`});case`QQQQQ`:return n.quarter(r,{width:`narrow`,context:`formatting`});case`QQQQ`:default:return n.quarter(r,{width:`wide`,context:`formatting`})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`q`:return String(r);case`qq`:return WY(r,2);case`qo`:return n.ordinalNumber(r,{unit:`quarter`});case`qqq`:return n.quarter(r,{width:`abbreviated`,context:`standalone`});case`qqqqq`:return n.quarter(r,{width:`narrow`,context:`standalone`});case`qqqq`:default:return n.quarter(r,{width:`wide`,context:`standalone`})}},M:function(e,t,n){let r=e.getMonth();switch(t){case`M`:case`MM`:return GY.M(e,t);case`Mo`:return n.ordinalNumber(r+1,{unit:`month`});case`MMM`:return n.month(r,{width:`abbreviated`,context:`formatting`});case`MMMMM`:return n.month(r,{width:`narrow`,context:`formatting`});case`MMMM`:default:return n.month(r,{width:`wide`,context:`formatting`})}},L:function(e,t,n){let r=e.getMonth();switch(t){case`L`:return String(r+1);case`LL`:return WY(r+1,2);case`Lo`:return n.ordinalNumber(r+1,{unit:`month`});case`LLL`:return n.month(r,{width:`abbreviated`,context:`standalone`});case`LLLLL`:return n.month(r,{width:`narrow`,context:`standalone`});case`LLLL`:default:return n.month(r,{width:`wide`,context:`standalone`})}},w:function(e,t,n,r){let i=UY(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):WY(i,t.length)},I:function(e,t,n){let r=BY(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):WY(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):GY.d(e,t)},D:function(e,t,n){let r=zY(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):WY(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case`E`:case`EE`:case`EEE`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`EEEEE`:return n.day(r,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(r,{width:`short`,context:`formatting`});case`EEEE`:default:return n.day(r,{width:`wide`,context:`formatting`})}},e:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`e`:return String(a);case`ee`:return WY(a,2);case`eo`:return n.ordinalNumber(a,{unit:`day`});case`eee`:return n.day(i,{width:`abbreviated`,context:`formatting`});case`eeeee`:return n.day(i,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(i,{width:`short`,context:`formatting`});case`eeee`:default:return n.day(i,{width:`wide`,context:`formatting`})}},c:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`c`:return String(a);case`cc`:return WY(a,t.length);case`co`:return n.ordinalNumber(a,{unit:`day`});case`ccc`:return n.day(i,{width:`abbreviated`,context:`standalone`});case`ccccc`:return n.day(i,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(i,{width:`short`,context:`standalone`});case`cccc`:default:return n.day(i,{width:`wide`,context:`standalone`})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case`i`:return String(i);case`ii`:return WY(i,t.length);case`io`:return n.ordinalNumber(i,{unit:`day`});case`iii`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`iiiii`:return n.day(r,{width:`narrow`,context:`formatting`});case`iiiiii`:return n.day(r,{width:`short`,context:`formatting`});case`iiii`:default:return n.day(r,{width:`wide`,context:`formatting`})}},a:function(e,t,n){let r=e.getHours(),i=r/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`aaa`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`aaaaa`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});case`aaaa`:default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},b:function(e,t,n){let r=e.getHours(),i;switch(i=r===12?KY.noon:r===0?KY.midnight:r/12>=1?`pm`:`am`,t){case`b`:case`bb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`bbb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`bbbbb`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});case`bbbb`:default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},B:function(e,t,n){let r=e.getHours(),i;switch(i=r>=17?KY.evening:r>=12?KY.afternoon:r>=4?KY.morning:KY.night,t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`BBBBB`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});case`BBBB`:default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},h:function(e,t,n){if(t===`ho`){let t=e.getHours()%12;return t===0&&(t=12),n.ordinalNumber(t,{unit:`hour`})}return GY.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):GY.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):WY(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):WY(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):GY.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):GY.s(e,t)},S:function(e,t){return GY.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return YY(r);case`XXXX`:case`XX`:return XY(r);case`XXXXX`:case`XXX`:default:return XY(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return YY(r);case`xxxx`:case`xx`:return XY(r);case`xxxxx`:case`xxx`:default:return XY(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+JY(r,`:`);case`OOOO`:default:return`GMT`+XY(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+JY(r,`:`);case`zzzz`:default:return`GMT`+XY(r,`:`)}},t:function(e,t,n){let r=Math.trunc(e/1e3);return WY(r,t.length)},T:function(e,t,n){return WY(+e,t.length)}};function JY(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+t+WY(a,2)}function YY(e,t){if(e%60==0){let t=e>0?`-`:`+`;return t+WY(Math.abs(e)/60,2)}return XY(e,t)}function XY(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=WY(Math.trunc(r/60),2),a=WY(r%60,2);return n+i+t+a}const ZY=(e,t)=>{switch(e){case`P`:return t.date({width:`short`});case`PP`:return t.date({width:`medium`});case`PPP`:return t.date({width:`long`});case`PPPP`:default:return t.date({width:`full`})}},QY=(e,t)=>{switch(e){case`p`:return t.time({width:`short`});case`pp`:return t.time({width:`medium`});case`ppp`:return t.time({width:`long`});case`pppp`:default:return t.time({width:`full`})}},$Y=(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return ZY(e,t);let a;switch(r){case`P`:a=t.dateTime({width:`short`});break;case`PP`:a=t.dateTime({width:`medium`});break;case`PPP`:a=t.dateTime({width:`long`});break;case`PPPP`:default:a=t.dateTime({width:`full`});break}return a.replace(`{{date}}`,ZY(r,t)).replace(`{{time}}`,QY(i,t))},eX={p:QY,P:$Y},tX=/^D+$/,nX=/^Y+$/,rX=[`D`,`DD`,`YY`,`YYYY`];function iX(e){return tX.test(e)}function aX(e){return nX.test(e)}function oX(e,t,n){let r=sX(e,t,n);if(console.warn(r),rX.includes(e))throw RangeError(r)}function sX(e,t,n){let r=e[0]===`Y`?`years`:`days of the month`;return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const cX=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,lX=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,uX=/^'([^]*?)'?$/,dX=/''/g,fX=/[a-zA-Z]/;function pX(e,t,n){var r,i,a,o;let s=GJ(),c=n?.locale??s.locale??RY,l=n?.firstWeekContainsDate??(n==null||(r=n.locale)==null||(r=r.options)==null?void 0:r.firstWeekContainsDate)??s.firstWeekContainsDate??((i=s.locale)==null||(i=i.options)==null?void 0:i.firstWeekContainsDate)??1,u=n?.weekStartsOn??(n==null||(a=n.locale)==null||(a=a.options)==null?void 0:a.weekStartsOn)??s.weekStartsOn??((o=s.locale)==null||(o=o.options)==null?void 0:o.weekStartsOn)??0,d=UJ(e,n?.in);if(!tY(d))throw RangeError(`Invalid time value`);let f=t.match(lX).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=eX[t];return n(e,c.formatLong)}return e}).join(``).match(cX).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:mX(e)};if(qY[t])return{isToken:!0,value:e};if(t.match(fX))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});c.localize.preprocessor&&(f=c.localize.preprocessor(d,f));let p={firstWeekContainsDate:l,weekStartsOn:u,locale:c};return f.map(r=>{if(!r.isToken)return r.value;let i=r.value;(!n?.useAdditionalWeekYearTokens&&aX(i)||!n?.useAdditionalDayOfYearTokens&&iX(i))&&oX(i,t,String(e));let a=qY[i[0]];return a(d,i,c.localize,p)}).join(``)}function mX(e){let t=e.match(uX);return t?t[1].replace(dX,`'`):e}function hX(e,t){return UJ(e*1e3,t?.in)}function gX(e,t){let n=_X(t)?new t(0):HJ(t,0);return n.setFullYear(e.getFullYear(),e.getMonth(),e.getDate()),n.setHours(e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()),n}function _X(e){var t;return typeof e==`function`&&(t=e.prototype)?.constructor===e}function vX(e,t){if(t===void 0)return e.trimEnd();let n=e.length;switch(typeof t){case`string`:if(t.length!==1)throw Error(`The 'chars' parameter should be a single character string.`);for(;n>0&&e[n-1]===t;)n--;break;case`object`:for(;n>0&&t.includes(e[n-1]);)n--}return e.substring(0,n)}function yX(e){return e==null}function bX(e){return e!=null}async function xX(){if(typeof window<`u`&&window!==null)return`browser`;try{let e=await Dt(()=>import(`./__vite-browser-external-0_TDy7U3.js`).then(Tt(1)),__vite__mapDeps([0,1,2]));return e!==void 0&&e.versions!=null&&e.versions.node!=null?`node`:`unknown`}catch{return`unknown`}}function SX(e){return yX(e)?!1:sW.isInt(e.type)&&!OX(e)||CX(e)}function CX(e){return yX(e)?!1:sW.isInt(e.type)&&e.type.isSigned===!1}function wX(e){return yX(e)?!1:sW.isFloat(e.type)??!1}function TX(e){return yX(e)?!1:sW.isDecimal(e.type)}function EX(e){return yX(e)?!1:sW.isBool(e.type)}function DX(e){return yX(e)?!1:sW.isDuration(e.type)}function OX(e){return yX(e)?!1:sW.isInt(e.type)&&e.metadata.get(`ARROW:extension:name`)===`period`}function kX(e){return yX(e)?!1:sW.isTimestamp(e.type)}function AX(e){return yX(e)?!1:sW.isDate(e.type)}function jX(e){return yX(e)?!1:sW.isTime(e.type)}function MX(e){return yX(e)?!1:sW.isList(e.type)||sW.isFixedSizeList(e.type)}function NX(e){return yX(e)?!1:sW.isStruct(e.type)||sW.isMap(e.type)}function PX(e){return yX(e)?!1:sW.isStruct(e.type)&&e.metadata.get(`ARROW:extension:name`)===`interval`||sW.isInterval(e.type)}const FX=new Date(1970,0,1);function IX(e,t){let n;if(t===vU.MILLISECOND)n=1e3;else if(t===vU.MICROSECOND)n=1e3*1e3;else if(t===vU.NANOSECOND)n=1e3*1e3*1e3;else return Number(e);return typeof e==`bigint`&&!Number.isSafeInteger(Number(e))?Number(e/BigInt(n)):Number(e)/n}function LX(e,t){var n;let r=IX(e,(t==null||(n=t.type)==null?void 0:n.unit)??vU.SECOND);return hX(r)}function RX(e,t){let n=LX(e,t);return pX(n,n.getMilliseconds()===0?`HH:mm:ss`:`HH:mm:ss.SSS`)}function zX(e){let t=`yyyy-MM-dd`;return e instanceof Date||typeof e==`number`&&Number.isFinite(e)?pX(e,t):(console.warn(`Unsupported date value: ${e}`),String(e))}function BX(e,t){var n;if(!(e instanceof Date||typeof e==`number`&&Number.isFinite(e)))return console.warn(`Unsupported datetime value: ${e}`),null;let r,i=t==null||(n=t.type)==null?void 0:n.timezone;return r=i?new dH(e,i):new dH(e),gX(r,Date)}function VX(e,t){var n;let r=(t==null||(n=t.type)==null?void 0:n.scale)||0,i=AJ.bigNumToString(new AJ.BN(e)).padStart(r,`0`);if(r===0)return i;let a=``;i.startsWith(`-`)&&(a=`-`,i=i.slice(1));let o=i.slice(0,-r)||`0`,s=vX(i.slice(-r),`0`)||``;return`${a}${o}${s?`.${s}`:``}`}const HX=new Intl.NumberFormat(`en-US`,{style:`decimal`,maximumFractionDigits:4,minimumFractionDigits:4,useGrouping:!0});function UX(e){let t=e[0],n=e[1],r=[];return t!==0&&r.push(`${t} year${t>1?`s`:``}`),n!==0&&r.push(`${n} month${n>1?`s`:``}`),r.length?r.join(` `):`0 months`}function WX(e,t){if(sW.isInterval(t?.type))return UX(e);let n=t&&t.metadata.get(`ARROW:extension:name`);if(n&&n===`pandas.interval`){var r,i;let n=JSON.parse(t.metadata.get(`ARROW:extension:metadata`)),{closed:a}=n,o=e.toJSON(),s=a===`both`||a===`left`?`[`:`(`,c=a===`both`||a===`right`?`]`:`)`,l=KX(o.left,(r=t.type)==null||(r=r.children)==null?void 0:r[0]),u=KX(o.right,(i=t.type)==null||(i=i.children)==null?void 0:i[1]);return`${s+l}, ${u+c}`}return String(e)}function GX(e,t){return t?.type instanceof PW?JSON.parse(JSON.stringify(e,(e,t)=>{if(bX(t))return typeof t==`bigint`?Number(t):t})):JSON.parse(JSON.stringify(e,(e,t)=>typeof t==`bigint`?Number(t):t))}function KX(e,t){if(yX(e))return null;let n=e instanceof Date||Number.isFinite(e);if(n&&AX(t))return zX(e);if(typeof e==`bigint`&&jX(t))return RX(Number(e),t);if(n&&kX(t))return BX(e,t);if(OX(t))throw Error(`Period type is not supported yet`);if(PX(t))return WX(e,t);if(DX(t))throw Error(`Duration type is not supported yet`);return TX(t)?VX(e,t):wX(t)&&Number.isFinite(e)||SX(t)?e:NX(t)||MX(t)?GX(e,t):EX(t)?!!e:String(e)}function qX(e){let t=(e.toArray()||[]).map(e=>e.toJSON())||[],n=t.map(t=>(e.schema.fields.forEach(e=>t[e.name]=KX(t[e.name],e)),t));return n}let JX=function(e){return e.ORIGIN_PRIVATE_FS=`origin-private-fs`,e.NODE_FS=`node-fs`,e}({});async function YX(e){let t=Pt(e,{logger:!1}),n,r,i=await xX();if(i===`browser`){if(t.bundles===void 0){let{getBundles:e}=await Dt(async()=>{let{getBundles:e}=await import(`./default-browser-vwqgKA0M.js`);return{getBundles:e}},[]);t.bundles=await e()}r=await rH(await t.bundles),n=new Worker(r.mainWorker)}else if(i===`node`){if(t.bundles===void 0){let{getBundles:e}=await Dt(async()=>{let{getBundles:e}=await import(`./default-node-D--pDlDQ.js`);return{getBundles:e}},__vite__mapDeps([3,1,2]));t.bundles=await e()}r=await rH(await t.bundles);let e=r.mainWorker;e.startsWith(`/@fs/`)&&(e=e.replace(`/@fs/`,`file://`));let i=await Dt(()=>import(`./browser-CMSJHaBF.js`),[]);n=new i.default(e,{type:`module`})}else throw Error(`Unsupported environment: ${i}`);let a;a=t.logger===!0?new xV:t.logger===!1?new bV:t.logger;let o=new MV(a,n);if(await o.instantiate(r.mainModule,r.pthreadWorker),t.storage)switch(t.storage.type){case JX.ORIGIN_PRIVATE_FS:try{let e=t.storage.path;e.startsWith(`/`)&&(e=e.slice(1)),await o.open({path:`opfs://${e}`,accessMode:t.storage.accessMode})}catch(e){throw await o.terminate(),await n.terminate(),e}break;case JX.NODE_FS:try{await o.open({path:t.storage.path,accessMode:t.storage.accessMode,useDirectIO:!0})}catch(e){throw await o.terminate(),await n.terminate(),e}break}let s=await o.connect();async function c(e,t=[]){if(!t||t.length===0){let t=await s.query(e);return{_results:t,_schema:t.schema,columns:t.schema.fields,rows:qX(t)}}let n=await s.prepare(e),r=await n.query(...t);return n.close(),{_results:r,_schema:r.schema,columns:r.schema.fields,rows:qX(r)}}return{worker:n,db:o,conn:s,query:async(e,t=[])=>c(e,t).then(e=>e.rows),queryWithColumns:async(e,t=[])=>c(e,t),close:async()=>{await s.close(),await o.terminate(),await n.terminate()}}}async function XX(e,t){await(await e).conn.send(`BEGIN TRANSACTION`);try{let n=await t(e);return await(await e).conn.send(`COMMIT`),n}catch(t){throw await(await e).conn.send(`ROLLBACK`),t}}async function ZX(e,t,n){await(await e).conn.send(`SAVEPOINT ${t}`);try{let r=await n(e);return await(await e).conn.send(`RELEASE SAVEPOINT ${t}`),r}catch(n){throw await(await e).conn.send(`ROLLBACK TO SAVEPOINT ${t}`),n}}const Z=Symbol.for(`drizzle:entityKind`),QX=Symbol.for(`drizzle:hasOwnEntityKind`);function Q(e,t){if(!e||typeof e!=`object`)return!1;if(e instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,Z))throw Error(`Class "${t.name??``}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let n=Object.getPrototypeOf(e).constructor;if(n)for(;n;){if(Z in n&&n[Z]===t[Z])return!0;n=Object.getPrototypeOf(n)}return!1}var $X=(yr=class{constructor(t,n){e.defineProperty(this,`name`,void 0),e.defineProperty(this,`keyAsName`,void 0),e.defineProperty(this,`primary`,void 0),e.defineProperty(this,`notNull`,void 0),e.defineProperty(this,`default`,void 0),e.defineProperty(this,`defaultFn`,void 0),e.defineProperty(this,`onUpdateFn`,void 0),e.defineProperty(this,`hasDefault`,void 0),e.defineProperty(this,`isUnique`,void 0),e.defineProperty(this,`uniqueName`,void 0),e.defineProperty(this,`uniqueType`,void 0),e.defineProperty(this,`dataType`,void 0),e.defineProperty(this,`columnType`,void 0),e.defineProperty(this,`enumValues`,void 0),e.defineProperty(this,`generated`,void 0),e.defineProperty(this,`generatedIdentity`,void 0),e.defineProperty(this,`config`,void 0),this.table=t,this.config=n,this.name=n.name,this.keyAsName=n.keyAsName,this.notNull=n.notNull,this.default=n.default,this.defaultFn=n.defaultFn,this.onUpdateFn=n.onUpdateFn,this.hasDefault=n.hasDefault,this.primary=n.primaryKey,this.isUnique=n.isUnique,this.uniqueName=n.uniqueName,this.uniqueType=n.uniqueType,this.dataType=n.dataType,this.columnType=n.columnType,this.generated=n.generated,this.generatedIdentity=n.generatedIdentity}mapFromDriverValue(e){return e}mapToDriverValue(e){return e}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!==`byDefault`}},e.defineProperty(yr,Z,`Column`),yr),eZ=(br=class{constructor(t,n,r){e.defineProperty(this,`config`,void 0),e.defineProperty(this,`$default`,this.$defaultFn),e.defineProperty(this,`$onUpdate`,this.$onUpdateFn),this.config={name:t,keyAsName:t===``,notNull:!1,default:void 0,hasDefault:!1,primaryKey:!1,isUnique:!1,uniqueName:void 0,uniqueType:void 0,dataType:n,columnType:r,generated:void 0}}$type(){return this}notNull(){return this.config.notNull=!0,this}default(e){return this.config.default=e,this.config.hasDefault=!0,this}$defaultFn(e){return this.config.defaultFn=e,this.config.hasDefault=!0,this}$onUpdateFn(e){return this.config.onUpdateFn=e,this.config.hasDefault=!0,this}primaryKey(){return this.config.primaryKey=!0,this.config.notNull=!0,this}setName(e){this.config.name===``&&(this.config.name=e)}},e.defineProperty(br,Z,`ColumnBuilder`),br);const tZ=Symbol.for(`drizzle:Name`);var nZ=(xr=class{constructor(t,n){e.defineProperty(this,`reference`,void 0),e.defineProperty(this,`_onUpdate`,`no action`),e.defineProperty(this,`_onDelete`,`no action`),this.reference=()=>{let{name:e,columns:n,foreignColumns:r}=t();return{name:e,columns:n,foreignTable:r[0].table,foreignColumns:r}},n&&(this._onUpdate=n.onUpdate,this._onDelete=n.onDelete)}onUpdate(e){return this._onUpdate=e===void 0?`no action`:e,this}onDelete(e){return this._onDelete=e===void 0?`no action`:e,this}build(e){return new rZ(e,this)}},e.defineProperty(xr,Z,`PgForeignKeyBuilder`),xr),rZ=(Sr=class{constructor(t,n){e.defineProperty(this,`reference`,void 0),e.defineProperty(this,`onUpdate`,void 0),e.defineProperty(this,`onDelete`,void 0),this.table=t,this.reference=n.reference,this.onUpdate=n._onUpdate,this.onDelete=n._onDelete}getName(){let{name:e,columns:t,foreignColumns:n}=this.reference(),r=t.map(e=>e.name),i=n.map(e=>e.name),a=[this.table[tZ],...r,n[0].table[tZ],...i];return e??`${a.join(`_`)}_fk`}},e.defineProperty(Sr,Z,`PgForeignKey`),Sr);function iZ(e,...t){return e(...t)}function aZ(e,t){return`${e[tZ]}_${t.join(`_`)}_unique`}var oZ=(Cr=class{constructor(t,n){e.defineProperty(this,`columns`,void 0),e.defineProperty(this,`nullsNotDistinctConfig`,!1),this.name=n,this.columns=t}nullsNotDistinct(){return this.nullsNotDistinctConfig=!0,this}build(e){return new cZ(e,this.columns,this.nullsNotDistinctConfig,this.name)}},e.defineProperty(Cr,Z,`PgUniqueConstraintBuilder`),Cr),sZ=(wr=class{constructor(t){e.defineProperty(this,`name`,void 0),this.name=t}on(...e){return new oZ(e,this.name)}},e.defineProperty(wr,Z,`PgUniqueOnConstraintBuilder`),wr),cZ=(Tr=class{constructor(t,n,r,i){e.defineProperty(this,`columns`,void 0),e.defineProperty(this,`name`,void 0),e.defineProperty(this,`nullsNotDistinct`,!1),this.table=t,this.columns=n,this.name=i??aZ(this.table,this.columns.map(e=>e.name)),this.nullsNotDistinct=r}getName(){return this.name}},e.defineProperty(Tr,Z,`PgUniqueConstraint`),Tr);function lZ(e,t,n){for(let r=t;rArray.isArray(e)?fZ(e):typeof e==`string`?`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`:`${e}`).join(`,`)}}`}var pZ=(Er=class extends eZ{constructor(...t){super(...t),e.defineProperty(this,`foreignKeyConfigs`,[])}array(e){return new _Z(this.config.name,this,e)}references(e,t={}){return this.foreignKeyConfigs.push({ref:e,actions:t}),this}unique(e,t){return this.config.isUnique=!0,this.config.uniqueName=e,this.config.uniqueType=t?.nulls,this}generatedAlwaysAs(e){return this.config.generated={as:e,type:`always`,mode:`stored`},this}buildForeignKeys(e,t){return this.foreignKeyConfigs.map(({ref:n,actions:r})=>iZ((n,r)=>{let i=new nZ(()=>{let t=n();return{columns:[e],foreignColumns:[t]}});return r.onUpdate&&i.onUpdate(r.onUpdate),r.onDelete&&i.onDelete(r.onDelete),i.build(t)},n,r))}buildExtraConfigColumn(e){return new hZ(e,this.config)}},e.defineProperty(Er,Z,`PgColumnBuilder`),Er),mZ=(Dr=class extends $X{constructor(e,t){t.uniqueName||=aZ(e,[t.name]),super(e,t),this.table=e}},e.defineProperty(Dr,Z,`PgColumn`),Dr),hZ=(Or=class extends mZ{constructor(...t){super(...t),e.defineProperty(this,`indexConfig`,{order:this.config.order??`asc`,nulls:this.config.nulls??`last`,opClass:this.config.opClass}),e.defineProperty(this,`defaultConfig`,{order:`asc`,nulls:`last`,opClass:void 0})}getSQLType(){return this.getSQLType()}asc(){return this.indexConfig.order=`asc`,this}desc(){return this.indexConfig.order=`desc`,this}nullsFirst(){return this.indexConfig.nulls=`first`,this}nullsLast(){return this.indexConfig.nulls=`last`,this}op(e){return this.indexConfig.opClass=e,this}},e.defineProperty(Or,Z,`ExtraConfigColumn`),Or),gZ=(kr=class{constructor(t,n,r,i){e.defineProperty(this,`name`,void 0),e.defineProperty(this,`keyAsName`,void 0),e.defineProperty(this,`type`,void 0),e.defineProperty(this,`indexConfig`,void 0),this.name=t,this.keyAsName=n,this.type=r,this.indexConfig=i}},e.defineProperty(kr,Z,`IndexedColumn`),kr),_Z=(Ar=class extends pZ{constructor(e,t,n){super(e,`array`,`PgArray`),this.config.baseBuilder=t,this.config.size=n}build(e){let t=this.config.baseBuilder.build(e);return new vZ(e,this.config,t)}},e.defineProperty(Ar,Z,`PgArrayBuilder`),Ar),vZ=(jr=class t extends mZ{constructor(t,n,r,i){super(t,n),e.defineProperty(this,`size`,void 0),this.baseColumn=r,this.range=i,this.size=n.size}getSQLType(){return`${this.baseColumn.getSQLType()}[${typeof this.size==`number`?this.size:``}]`}mapFromDriverValue(e){return typeof e==`string`&&(e=dZ(e)),e.map(e=>this.baseColumn.mapFromDriverValue(e))}mapToDriverValue(e,n=!1){let r=e.map(e=>e===null?null:Q(this.baseColumn,t)?this.baseColumn.mapToDriverValue(e,!0):this.baseColumn.mapToDriverValue(e));return n?r:fZ(r)}},e.defineProperty(jr,Z,`PgArray`),jr),yZ=(Mr=class extends pZ{constructor(e,t){super(e,`string`,`PgEnumObjectColumn`),this.config.enum=t}build(e){return new bZ(e,this.config)}},e.defineProperty(Mr,Z,`PgEnumObjectColumnBuilder`),Mr),bZ=(Nr=class extends mZ{constructor(t,n){super(t,n),e.defineProperty(this,`enum`,void 0),e.defineProperty(this,`enumValues`,this.config.enum.enumValues),this.enum=n.enum}getSQLType(){return this.enum.enumName}},e.defineProperty(Nr,Z,`PgEnumObjectColumn`),Nr);const xZ=Symbol.for(`drizzle:isPgEnum`);function SZ(e){return!!e&&typeof e==`function`&&xZ in e&&e[xZ]===!0}var CZ=(Pr=class extends pZ{constructor(e,t){super(e,`string`,`PgEnumColumn`),this.config.enum=t}build(e){return new wZ(e,this.config)}},e.defineProperty(Pr,Z,`PgEnumColumnBuilder`),Pr),wZ=(Fr=class extends mZ{constructor(t,n){super(t,n),e.defineProperty(this,`enum`,this.config.enum),e.defineProperty(this,`enumValues`,this.config.enum.enumValues),this.enum=n.enum}getSQLType(){return this.enum.enumName}},e.defineProperty(Fr,Z,`PgEnumColumn`),Fr),TZ=(Ir=class{constructor(e,t,n,r=!1,i=[]){this._={brand:`Subquery`,sql:e,selectedFields:t,alias:n,isWith:r,usedTables:i}}},e.defineProperty(Ir,Z,`Subquery`),Ir),EZ=(Lr=class extends TZ{},e.defineProperty(Lr,Z,`WithSubquery`),Lr),DZ=`0.44.2`;let OZ,kZ;const AZ={startActiveSpan(e,t){return OZ?(kZ||=OZ.trace.getTracer(`drizzle-orm`,DZ),iZ((n,r)=>r.startActiveSpan(e,e=>{try{return t(e)}catch(t){throw e.setStatus({code:n.SpanStatusCode.ERROR,message:t instanceof Error?t.message:`Unknown error`}),t}finally{e.end()}}),OZ,kZ)):t()}},jZ=Symbol.for(`drizzle:ViewBaseConfig`),MZ=Symbol.for(`drizzle:Schema`),NZ=Symbol.for(`drizzle:Columns`),PZ=Symbol.for(`drizzle:ExtraConfigColumns`),FZ=Symbol.for(`drizzle:OriginalName`),IZ=Symbol.for(`drizzle:BaseName`),LZ=Symbol.for(`drizzle:IsAlias`),RZ=Symbol.for(`drizzle:ExtraConfigBuilder`),zZ=Symbol.for(`drizzle:IsDrizzleTable`);var BZ=(Rr=class{constructor(t,n,r){e.defineProperty(this,tZ,void 0),e.defineProperty(this,FZ,void 0),e.defineProperty(this,MZ,void 0),e.defineProperty(this,NZ,void 0),e.defineProperty(this,PZ,void 0),e.defineProperty(this,IZ,void 0),e.defineProperty(this,LZ,!1),e.defineProperty(this,zZ,!0),e.defineProperty(this,RZ,void 0),this[tZ]=this[FZ]=t,this[MZ]=n,this[IZ]=r}},e.defineProperty(Rr,Z,`Table`),e.defineProperty(Rr,`Symbol`,{Name:tZ,Schema:MZ,OriginalName:FZ,Columns:NZ,ExtraConfigColumns:PZ,BaseName:IZ,IsAlias:LZ,ExtraConfigBuilder:RZ}),Rr);function VZ(e){return e[tZ]}function HZ(e){return`${e[MZ]??`public`}.${e[tZ]}`}var UZ=(zr=class{},e.defineProperty(zr,Z,`FakePrimitiveParam`),zr);function WZ(e){return e!=null&&typeof e.getSQL==`function`}function GZ(e){let t={sql:``,params:[]};for(let r of e){var n;t.sql+=r.sql,t.params.push(...r.params),(n=r.typings)?.length&&(t.typings||=[],t.typings.push(...r.typings))}return t}var KZ=(Br=class{constructor(t){e.defineProperty(this,`value`,void 0),this.value=Array.isArray(t)?t:[t]}getSQL(){return new qZ([this])}},e.defineProperty(Br,Z,`StringChunk`),Br),qZ=(Vr=class t{constructor(t){e.defineProperty(this,`decoder`,XZ),e.defineProperty(this,`shouldInlineParams`,!1),e.defineProperty(this,`usedTables`,[]),this.queryChunks=t;for(let e of t)if(Q(e,BZ)){let t=e[BZ.Symbol.Schema];this.usedTables.push(t===void 0?e[BZ.Symbol.Name]:t+`.`+e[BZ.Symbol.Name])}}append(e){return this.queryChunks.push(...e.queryChunks),this}toQuery(e){return AZ.startActiveSpan(`drizzle.buildSQL`,t=>{let n=this.buildQueryFromSourceParams(this.queryChunks,e);return t?.setAttributes({"drizzle.query.text":n.sql,"drizzle.query.params":JSON.stringify(n.params)}),n})}buildQueryFromSourceParams(e,n){let r=Object.assign({},n,{inlineParams:n.inlineParams||this.shouldInlineParams,paramStartIndex:n.paramStartIndex||{value:0}}),{casing:i,escapeName:a,escapeParam:o,prepareTyping:s,inlineParams:c,paramStartIndex:l}=r;return GZ(e.map(e=>{if(Q(e,KZ))return{sql:e.value.join(``),params:[]};if(Q(e,JZ))return{sql:a(e.value),params:[]};if(e===void 0)return{sql:``,params:[]};if(Array.isArray(e)){let t=[new KZ(`(`)];for(let[n,r]of e.entries())t.push(r),ne},ZZ={mapToDriverValue:e=>e},QZ={...XZ,...ZZ};var $Z=(Ur=class{constructor(t,n=ZZ){e.defineProperty(this,`brand`,void 0),this.value=t,this.encoder=n}getSQL(){return new qZ([this])}},e.defineProperty(Ur,Z,`Param`),Ur);function $(e,...t){let n=[];(t.length>0||e.length>0&&e[0]!==``)&&n.push(new KZ(e[0]));for(let[r,i]of t.entries())n.push(i,new KZ(e[r+1]));return new qZ(n)}(e=>{function t(){return new qZ([])}e.empty=t;function n(e){return new qZ(e)}e.fromList=n;function r(e){return new qZ([new KZ(e)])}e.raw=r;function i(e,t){let n=[];for(let[r,i]of e.entries())r>0&&t!==void 0&&n.push(t),n.push(i);return new qZ(n)}e.join=i;function a(e){return new JZ(e)}e.identifier=a;function o(e){return new eQ(e)}e.placeholder=o;function s(e,t){return new $Z(e,t)}e.param=s})($||={}),(t=>{class n{constructor(t,n){e.defineProperty(this,`isSelectionField`,!1),this.sql=t,this.fieldAlias=n}getSQL(){return this.sql}clone(){return new n(this.sql,this.fieldAlias)}}e.defineProperty(n,Z,`SQL.Aliased`),t.Aliased=n})(qZ||={});var eQ=(Wr=class{constructor(e){this.name=e}getSQL(){return new qZ([this])}},e.defineProperty(Wr,Z,`Placeholder`),Wr);function tQ(e,t){return e.map(e=>{if(Q(e,eQ)){if(!(e.name in t))throw Error(`No value for placeholder "${e.name}" was provided`);return t[e.name]}if(Q(e,$Z)&&Q(e.value,eQ)){if(!(e.value.name in t))throw Error(`No value for placeholder "${e.value.name}" was provided`);return e.encoder.mapToDriverValue(t[e.value.name])}return e})}const nQ=Symbol.for(`drizzle:IsDrizzleView`);var rQ=(Gr=class{constructor({name:t,schema:n,selectedFields:r,query:i}){e.defineProperty(this,jZ,void 0),e.defineProperty(this,nQ,!0),this[jZ]={name:t,originalName:t,schema:n,selectedFields:r,query:i,isExisting:!i,isAlias:!1}}getSQL(){return new qZ([this])}},e.defineProperty(Gr,Z,`View`),Gr);$X.prototype.getSQL=function(){return new qZ([this])},BZ.prototype.getSQL=function(){return new qZ([this])},TZ.prototype.getSQL=function(){return new qZ([this])};var iQ=(Kr=class{constructor(e){this.table=e}get(e,t){return t===`table`?this.table:e[t]}},e.defineProperty(Kr,Z,`ColumnAliasProxyHandler`),Kr),aQ=(qr=class{constructor(e,t){this.alias=e,this.replaceOriginalName=t}get(e,t){if(t===BZ.Symbol.IsAlias)return!0;if(t===BZ.Symbol.Name||this.replaceOriginalName&&t===BZ.Symbol.OriginalName)return this.alias;if(t===jZ)return{...e[jZ],name:this.alias,isAlias:!0};if(t===BZ.Symbol.Columns){let t=e[BZ.Symbol.Columns];if(!t)return t;let n={};return Object.keys(t).map(r=>{n[r]=new Proxy(t[r],new iQ(new Proxy(e,this)))}),n}let n=e[t];return Q(n,$X)?new Proxy(n,new iQ(new Proxy(e,this))):n}},e.defineProperty(qr,Z,`TableAliasProxyHandler`),qr),oQ=(Jr=class{constructor(e){this.alias=e}get(e,t){return t===`sourceTable`?sQ(e.sourceTable,this.alias):e[t]}},e.defineProperty(Jr,Z,`RelationTableAliasProxyHandler`),Jr);function sQ(e,t){return new Proxy(e,new aQ(t,!1))}function cQ(e,t){return new Proxy(e,new iQ(new Proxy(e.table,new aQ(t,!1))))}function lQ(e,t){return new qZ.Aliased(uQ(e.sql,t),e.fieldAlias)}function uQ(e,t){return $.join(e.queryChunks.map(e=>Q(e,$X)?cQ(e,t):Q(e,qZ)?uQ(e,t):Q(e,qZ.Aliased)?lQ(e,t):e))}var dQ=(Yr=class extends Error{constructor({message:e,cause:t}){super(e),this.name=`DrizzleError`,this.cause=t}},e.defineProperty(Yr,Z,`DrizzleError`),Yr),fQ=(Xr=class extends dQ{constructor(){super({message:`Rollback`})}},e.defineProperty(Xr,Z,`TransactionRollbackError`),Xr),pQ=(Zr=class{write(e){console.log(e)}},e.defineProperty(Zr,Z,`ConsoleLogWriter`),Zr),mQ=(Qr=class{constructor(t){e.defineProperty(this,`writer`,void 0),this.writer=t?.writer??new pQ}logQuery(e,t){let n=t.map(e=>{try{return JSON.stringify(e)}catch{return String(e)}}),r=n.length?` -- params: [${n.join(`, `)}]`:``;this.writer.write(`Query: ${e}${r}`)}},e.defineProperty(Qr,Z,`DefaultLogger`),Qr),hQ=($r=class{logQuery(){}},e.defineProperty($r,Z,`NoopLogger`),$r),gQ=(oa=Symbol.toStringTag,ei=class{constructor(){e.defineProperty(this,oa,`QueryPromise`)}catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}then(e,t){return this.execute().then(e,t)}},e.defineProperty(ei,Z,`QueryPromise`),ei);function _Q(e,t){return Object.entries(e).reduce((e,[n,r])=>{if(typeof n!=`string`)return e;let i=t?[...t,n]:[n];return Q(r,$X)||Q(r,qZ)||Q(r,qZ.Aliased)?e.push({path:i,field:r}):Q(r,BZ)?e.push(..._Q(r[BZ.Symbol.Columns],i)):e.push(..._Q(r,i)),e},[])}function vQ(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let[e,t]of n.entries())if(t!==r[e])return!1;return!0}function yQ(e,t){let n=Object.entries(t).filter(([,e])=>e!==void 0).map(([t,n])=>Q(n,qZ)||Q(n,$X)?[t,n]:[t,new $Z(n,e[BZ.Symbol.Columns][t])]);if(n.length===0)throw Error(`No values to set`);return Object.fromEntries(n)}function bQ(e,t){for(let n of t)for(let t of Object.getOwnPropertyNames(n.prototype)){if(t===`constructor`)continue;Object.defineProperty(e.prototype,t,Object.getOwnPropertyDescriptor(n.prototype,t)||Object.create(null))}}function xQ(e){return e[BZ.Symbol.Columns]}function SQ(e){return Q(e,TZ)?e._.alias:Q(e,rQ)?e[jZ].name:Q(e,qZ)?void 0:e[BZ.Symbol.IsAlias]?e[BZ.Symbol.Name]:e[BZ.Symbol.BaseName]}function CQ(e){if(typeof e!=`object`||!e||e.constructor.name!==`Object`)return!1;if(`logger`in e){let t=typeof e.logger;return!(t!==`boolean`&&(t!==`object`||typeof e.logger.logQuery!=`function`)&&t!==`undefined`)}if(`schema`in e){let t=typeof e.schema;return!(t!==`object`&&t!==`undefined`)}if(`casing`in e){let t=typeof e.casing;return!(t!==`string`&&t!==`undefined`)}if(`mode`in e)return!(e.mode!==`default`||e.mode!==`planetscale`||e.mode!==void 0);if(`connection`in e){let t=typeof e.connection;return!(t!==`string`&&t!==`object`&&t!==`undefined`)}if(`client`in e){let t=typeof e.client;return!(t!==`object`&&t!==`function`&&t!==`undefined`)}return Object.keys(e).length===0}var wQ=(ti=class extends pZ{defaultNow(){return this.default($`now()`)}},e.defineProperty(ti,Z,`PgDateColumnBaseBuilder`),ti),TQ=(ni=class extends wQ{constructor(e){super(e,`date`,`PgDate`)}build(e){return new EQ(e,this.config)}},e.defineProperty(ni,Z,`PgDateBuilder`),ni),EQ=(ri=class extends mZ{getSQLType(){return`date`}mapFromDriverValue(e){return new Date(e)}mapToDriverValue(e){return e.toISOString()}},e.defineProperty(ri,Z,`PgDate`),ri),DQ=(ii=class extends wQ{constructor(e){super(e,`string`,`PgDateString`)}build(e){return new OQ(e,this.config)}},e.defineProperty(ii,Z,`PgDateStringBuilder`),ii),OQ=(ai=class extends mZ{getSQLType(){return`date`}},e.defineProperty(ai,Z,`PgDateString`),ai),kQ=(oi=class extends pZ{constructor(e){super(e,`json`,`PgJson`)}build(e){return new AQ(e,this.config)}},e.defineProperty(oi,Z,`PgJsonBuilder`),oi),AQ=(si=class extends mZ{constructor(e,t){super(e,t)}getSQLType(){return`json`}mapToDriverValue(e){return JSON.stringify(e)}mapFromDriverValue(e){if(typeof e==`string`)try{return JSON.parse(e)}catch{return e}return e}},e.defineProperty(si,Z,`PgJson`),si),jQ=(ci=class extends pZ{constructor(e){super(e,`json`,`PgJsonb`)}build(e){return new MQ(e,this.config)}},e.defineProperty(ci,Z,`PgJsonbBuilder`),ci),MQ=(li=class extends mZ{constructor(e,t){super(e,t)}getSQLType(){return`jsonb`}mapToDriverValue(e){return JSON.stringify(e)}mapFromDriverValue(e){if(typeof e==`string`)try{return JSON.parse(e)}catch{return e}return e}},e.defineProperty(li,Z,`PgJsonb`),li),NQ=(ui=class extends pZ{constructor(e,t,n){super(e,`string`,`PgNumeric`),this.config.precision=t,this.config.scale=n}build(e){return new PQ(e,this.config)}},e.defineProperty(ui,Z,`PgNumericBuilder`),ui),PQ=(di=class extends mZ{constructor(t,n){super(t,n),e.defineProperty(this,`precision`,void 0),e.defineProperty(this,`scale`,void 0),this.precision=n.precision,this.scale=n.scale}mapFromDriverValue(e){return typeof e==`string`?e:String(e)}getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?`numeric`:`numeric(${this.precision})`}},e.defineProperty(di,Z,`PgNumeric`),di),FQ=(fi=class extends pZ{constructor(e,t,n){super(e,`number`,`PgNumericNumber`),this.config.precision=t,this.config.scale=n}build(e){return new IQ(e,this.config)}},e.defineProperty(fi,Z,`PgNumericNumberBuilder`),fi),IQ=(pi=class extends mZ{constructor(t,n){super(t,n),e.defineProperty(this,`precision`,void 0),e.defineProperty(this,`scale`,void 0),e.defineProperty(this,`mapToDriverValue`,String),this.precision=n.precision,this.scale=n.scale}mapFromDriverValue(e){return typeof e==`number`?e:Number(e)}getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?`numeric`:`numeric(${this.precision})`}},e.defineProperty(pi,Z,`PgNumericNumber`),pi),LQ=(mi=class extends pZ{constructor(e,t,n){super(e,`bigint`,`PgNumericBigInt`),this.config.precision=t,this.config.scale=n}build(e){return new RQ(e,this.config)}},e.defineProperty(mi,Z,`PgNumericBigIntBuilder`),mi),RQ=(hi=class extends mZ{constructor(t,n){super(t,n),e.defineProperty(this,`precision`,void 0),e.defineProperty(this,`scale`,void 0),e.defineProperty(this,`mapFromDriverValue`,BigInt),e.defineProperty(this,`mapToDriverValue`,String),this.precision=n.precision,this.scale=n.scale}getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?`numeric`:`numeric(${this.precision})`}},e.defineProperty(hi,Z,`PgNumericBigInt`),hi),zQ=(gi=class extends wQ{constructor(e,t,n){super(e,`string`,`PgTime`),this.withTimezone=t,this.precision=n,this.config.withTimezone=t,this.config.precision=n}build(e){return new BQ(e,this.config)}},e.defineProperty(gi,Z,`PgTimeBuilder`),gi),BQ=(_i=class extends mZ{constructor(t,n){super(t,n),e.defineProperty(this,`withTimezone`,void 0),e.defineProperty(this,`precision`,void 0),this.withTimezone=n.withTimezone,this.precision=n.precision}getSQLType(){let e=this.precision===void 0?``:`(${this.precision})`;return`time${e}${this.withTimezone?` with time zone`:``}`}},e.defineProperty(_i,Z,`PgTime`),_i),VQ=(vi=class extends wQ{constructor(e,t,n){super(e,`date`,`PgTimestamp`),this.config.withTimezone=t,this.config.precision=n}build(e){return new HQ(e,this.config)}},e.defineProperty(vi,Z,`PgTimestampBuilder`),vi),HQ=(yi=class extends mZ{constructor(t,n){super(t,n),e.defineProperty(this,`withTimezone`,void 0),e.defineProperty(this,`precision`,void 0),e.defineProperty(this,`mapFromDriverValue`,e=>new Date(this.withTimezone?e:e+`+0000`)),e.defineProperty(this,`mapToDriverValue`,e=>e.toISOString()),this.withTimezone=n.withTimezone,this.precision=n.precision}getSQLType(){let e=this.precision===void 0?``:` (${this.precision})`;return`timestamp${e}${this.withTimezone?` with time zone`:``}`}},e.defineProperty(yi,Z,`PgTimestamp`),yi),UQ=(bi=class extends wQ{constructor(e,t,n){super(e,`string`,`PgTimestampString`),this.config.withTimezone=t,this.config.precision=n}build(e){return new WQ(e,this.config)}},e.defineProperty(bi,Z,`PgTimestampStringBuilder`),bi),WQ=(xi=class extends mZ{constructor(t,n){super(t,n),e.defineProperty(this,`withTimezone`,void 0),e.defineProperty(this,`precision`,void 0),this.withTimezone=n.withTimezone,this.precision=n.precision}getSQLType(){let e=this.precision===void 0?``:`(${this.precision})`;return`timestamp${e}${this.withTimezone?` with time zone`:``}`}},e.defineProperty(xi,Z,`PgTimestampString`),xi),GQ=(Si=class extends pZ{constructor(e){super(e,`string`,`PgUUID`)}defaultRandom(){return this.default($`gen_random_uuid()`)}build(e){return new KQ(e,this.config)}},e.defineProperty(Si,Z,`PgUUIDBuilder`),Si),KQ=(Ci=class extends mZ{getSQLType(){return`uuid`}},e.defineProperty(Ci,Z,`PgUUID`),Ci);const qQ=Symbol.for(`drizzle:PgInlineForeignKeys`),JQ=Symbol.for(`drizzle:EnableRLS`);var YQ=(sa=BZ.Symbol.ExtraConfigBuilder,ca=BZ.Symbol.ExtraConfigColumns,wi=class extends BZ{constructor(...t){super(...t),e.defineProperty(this,qQ,[]),e.defineProperty(this,JQ,!1),e.defineProperty(this,sa,void 0),e.defineProperty(this,ca,{})}},e.defineProperty(wi,Z,`PgTable`),e.defineProperty(wi,`Symbol`,Object.assign({},BZ.Symbol,{InlineForeignKeys:qQ,EnableRLS:JQ})),wi),XQ=(Ti=class{constructor(t,n){e.defineProperty(this,`columns`,void 0),e.defineProperty(this,`name`,void 0),this.columns=t,this.name=n}build(e){return new ZQ(e,this.columns,this.name)}},e.defineProperty(Ti,Z,`PgPrimaryKeyBuilder`),Ti),ZQ=(Ei=class{constructor(t,n,r){e.defineProperty(this,`columns`,void 0),e.defineProperty(this,`name`,void 0),this.table=t,this.columns=n,this.name=r}getName(){return this.name??`${this.table[YQ.Symbol.Name]}_${this.columns.map(e=>e.name).join(`_`)}_pk`}},e.defineProperty(Ei,Z,`PgPrimaryKey`),Ei);function QQ(e,t){return YZ(t)&&!WZ(e)&&!Q(e,$Z)&&!Q(e,eQ)&&!Q(e,$X)&&!Q(e,BZ)&&!Q(e,rQ)?new $Z(e,t):e}const $Q=(e,t)=>$`${e} = ${QQ(t,e)}`,e$=(e,t)=>$`${e} <> ${QQ(t,e)}`;function t$(...e){let t=e.filter(e=>e!==void 0);if(t.length!==0)return t.length===1?new qZ(t):new qZ([new KZ(`(`),$.join(t,new KZ(` and `)),new KZ(`)`)])}function n$(...e){let t=e.filter(e=>e!==void 0);if(t.length!==0)return t.length===1?new qZ(t):new qZ([new KZ(`(`),$.join(t,new KZ(` or `)),new KZ(`)`)])}function r$(e){return $`not ${e}`}const i$=(e,t)=>$`${e} > ${QQ(t,e)}`,a$=(e,t)=>$`${e} >= ${QQ(t,e)}`,o$=(e,t)=>$`${e} < ${QQ(t,e)}`,s$=(e,t)=>$`${e} <= ${QQ(t,e)}`;function c$(e,t){return Array.isArray(t)?t.length===0?$`false`:$`${e} in ${t.map(t=>QQ(t,e))}`:$`${e} in ${QQ(t,e)}`}function l$(e,t){return Array.isArray(t)?t.length===0?$`true`:$`${e} not in ${t.map(t=>QQ(t,e))}`:$`${e} not in ${QQ(t,e)}`}function u$(e){return $`${e} is null`}function d$(e){return $`${e} is not null`}function f$(e){return $`exists ${e}`}function p$(e){return $`not exists ${e}`}function m$(e,t,n){return $`${e} between ${QQ(t,e)} and ${QQ(n,e)}`}function h$(e,t,n){return $`${e} not between ${QQ(t,e)} and ${QQ(n,e)}`}function g$(e,t){return $`${e} like ${t}`}function _$(e,t){return $`${e} not like ${t}`}function v$(e,t){return $`${e} ilike ${t}`}function y$(e,t){return $`${e} not ilike ${t}`}function b$(e){return $`${e} asc`}function x$(e){return $`${e} desc`}var S$=(Di=class{constructor(t,n,r){e.defineProperty(this,`referencedTableName`,void 0),e.defineProperty(this,`fieldName`,void 0),this.sourceTable=t,this.referencedTable=n,this.relationName=r,this.referencedTableName=n[BZ.Symbol.Name]}},e.defineProperty(Di,Z,`Relation`),Di),C$=(Oi=class{constructor(e,t){this.table=e,this.config=t}},e.defineProperty(Oi,Z,`Relations`),Oi),w$=(ki=class e extends S${constructor(e,t,n,r){super(e,t,n?.relationName),this.config=n,this.isNullable=r}withFieldName(t){let n=new e(this.sourceTable,this.referencedTable,this.config,this.isNullable);return n.fieldName=t,n}},e.defineProperty(ki,Z,`One`),ki),T$=(Ai=class e extends S${constructor(e,t,n){super(e,t,n?.relationName),this.config=n}withFieldName(t){let n=new e(this.sourceTable,this.referencedTable,this.config);return n.fieldName=t,n}},e.defineProperty(Ai,Z,`Many`),Ai);function E$(){return{and:t$,between:m$,eq:$Q,exists:f$,gt:i$,gte:a$,ilike:v$,inArray:c$,isNull:u$,isNotNull:d$,like:g$,lt:o$,lte:s$,ne:e$,not:r$,notBetween:h$,notExists:p$,notLike:_$,notIlike:y$,notInArray:l$,or:n$,sql:$}}function D$(){return{sql:$,asc:b$,desc:x$}}function O$(e,t){Object.keys(e).length===1&&`default`in e&&!Q(e.default,BZ)&&(e=e.default);let n={},r={},i={};for(let[o,s]of Object.entries(e))if(Q(s,BZ)){var a;let e=HZ(s),t=r[e];n[e]=o,i[o]={tsName:o,dbName:s[BZ.Symbol.Name],schema:s[BZ.Symbol.Schema],columns:s[BZ.Symbol.Columns],relations:t?.relations??{},primaryKey:t?.primaryKey??[]};for(let e of Object.values(s[BZ.Symbol.Columns]))e.primary&&i[o].primaryKey.push(e);let c=(a=s[BZ.Symbol.ExtraConfigBuilder])?.call(s,s[BZ.Symbol.ExtraConfigColumns]);if(c)for(let e of Object.values(c))Q(e,XQ)&&i[o].primaryKey.push(...e.columns)}else if(Q(s,C$)){let e=HZ(s.table),a=n[e],o=s.config(t(s.table)),c;for(let[t,n]of Object.entries(o))if(a){let e=i[a];e.relations[t]=n,c&&e.primaryKey.push(...c)}else e in r||(r[e]={relations:{},primaryKey:c}),r[e].relations[t]=n}return{tables:i,tableNamesMap:n}}function k$(e){return function(t,n){return new w$(e,t,n,n?.fields.reduce((e,t)=>e&&t.notNull,!0)??!1)}}function A$(e){return function(t,n){return new T$(e,t,n)}}function j$(e,t,n){if(Q(n,w$)&&n.config)return{fields:n.config.fields,references:n.config.references};let r=t[HZ(n.referencedTable)];if(!r)throw Error(`Table "${n.referencedTable[BZ.Symbol.Name]}" not found in schema`);let i=e[r];if(!i)throw Error(`Table "${r}" not found in schema`);let a=n.sourceTable,o=t[HZ(a)];if(!o)throw Error(`Table "${a[BZ.Symbol.Name]}" not found in schema`);let s=[];for(let e of Object.values(i.relations))(n.relationName&&n!==e&&e.relationName===n.relationName||!n.relationName&&e.referencedTable===n.sourceTable)&&s.push(e);if(s.length>1)throw n.relationName?Error(`There are multiple relations with name "${n.relationName}" in table "${r}"`):Error(`There are multiple relations between "${r}" and "${n.sourceTable[BZ.Symbol.Name]}". Please specify relation name`);if(s[0]&&Q(s[0],w$)&&s[0].config)return{fields:s[0].config.references,references:s[0].config.fields};throw Error(`There is not enough information to infer relation "${o}.${n.fieldName}"`)}function M$(e){return{one:k$(e),many:A$(e)}}function N$(e,t,n,r,i=e=>e){let a={};for(let[o,s]of r.entries())if(s.isJson){let r=t.relations[s.tsKey],c=n[o],l=typeof c==`string`?JSON.parse(c):c;a[s.tsKey]=Q(r,w$)?l&&N$(e,e[s.relationTableTsKey],l,s.selection,i):l.map(t=>N$(e,e[s.relationTableTsKey],t,s.selection,i))}else{let e=i(n[o]),t=s.field,r;r=Q(t,$X)?t:Q(t,qZ)?t.decoder:t.sql.decoder,a[s.tsKey]=e===null?null:r.mapFromDriverValue(e)}return a}var P$=(ji=class t{constructor(t){e.defineProperty(this,`config`,void 0),this.config={...t}}get(e,n){if(n===`_`)return{...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(n===jZ)return{...e[jZ],selectedFields:new Proxy(e[jZ].selectedFields,this)};if(typeof n==`symbol`)return e[n];let r=Q(e,TZ)?e._.selectedFields:Q(e,rQ)?e[jZ].selectedFields:e,i=r[n];if(Q(i,qZ.Aliased)){if(this.config.sqlAliasedBehavior===`sql`&&!i.isSelectionField)return i.sql;let e=i.clone();return e.isSelectionField=!0,e}if(Q(i,qZ)){if(this.config.sqlBehavior===`sql`)return i;throw Error(`You tried to reference "${n}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}return Q(i,$X)?this.config.alias?new Proxy(i,new iQ(new Proxy(i.table,new aQ(this.config.alias,this.config.replaceOriginalName??!1)))):i:typeof i!=`object`||!i?i:new Proxy(i,new t(this.config))}},e.defineProperty(ji,Z,`SelectionProxyHandler`),ji);function F$(e){let t=e.replace(/['\u2019]/g,``).match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[];return t.map(e=>e.toLowerCase()).join(`_`)}function I$(e){let t=e.replace(/['\u2019]/g,``).match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[];return t.reduce((e,t,n)=>{let r=n===0?t.toLowerCase():`${t[0].toUpperCase()}${t.slice(1)}`;return e+r},``)}function L$(e){return e}var R$=(Mi=class{constructor(t){e.defineProperty(this,`cache`,{}),e.defineProperty(this,`cachedTables`,{}),e.defineProperty(this,`convert`,void 0),this.convert=t===`snake_case`?F$:t===`camelCase`?I$:L$}getColumnCasing(e){if(!e.keyAsName)return e.name;let t=e.table[BZ.Symbol.Schema]??`public`,n=e.table[BZ.Symbol.OriginalName],r=`${t}.${n}.${e.name}`;return this.cache[r]||this.cacheTable(e.table),this.cache[r]}cacheTable(e){let t=e[BZ.Symbol.Schema]??`public`,n=e[BZ.Symbol.OriginalName],r=`${t}.${n}`;if(!this.cachedTables[r]){for(let t of Object.values(e[BZ.Symbol.Columns])){let e=`${r}.${t.name}`;this.cache[e]=this.convert(t.name)}this.cachedTables[r]=!0}}clearCache(){this.cache={},this.cachedTables={}}},e.defineProperty(Mi,Z,`CasingCache`),Mi),z$=(Ni=class extends rQ{},e.defineProperty(Ni,Z,`PgViewBase`),Ni),B$=(Pi=class{constructor(t){e.defineProperty(this,`casing`,void 0),this.casing=new R$(t?.casing)}async migrate(e,t,n){let r=typeof n==`string`?`__drizzle_migrations`:n.migrationsTable??`__drizzle_migrations`,i=typeof n==`string`?`drizzle`:n.migrationsSchema??`drizzle`,a=$` + CREATE TABLE IF NOT EXISTS ${$.identifier(i)}.${$.identifier(r)} ( + id SERIAL PRIMARY KEY, + hash text NOT NULL, + created_at bigint + ) + `;await t.execute($`CREATE SCHEMA IF NOT EXISTS ${$.identifier(i)}`),await t.execute(a);let o=await t.all($`select id, hash, created_at from ${$.identifier(i)}.${$.identifier(r)} order by created_at desc limit 1`),s=o[0];await t.transaction(async t=>{for await(let n of e)if(!s||Number(s.created_at){var r;return t[e]!==void 0||(r=n[e])?.onUpdateFn!==void 0}),i=r.length;return $.join(r.flatMap((e,r)=>{let a=n[e],o=t[e]??$.param(a.onUpdateFn(),a),s=$`${$.identifier(this.casing.getColumnCasing(a))} = ${o}`;return r{let i=[];if(Q(e,qZ.Aliased)&&e.isSelectionField)i.push($.identifier(e.fieldAlias));else if(Q(e,qZ.Aliased)||Q(e,qZ)){let n=Q(e,qZ.Aliased)?e.sql:e;t?i.push(new qZ(n.queryChunks.map(e=>Q(e,mZ)?$.identifier(this.casing.getColumnCasing(e)):e))):i.push(n),Q(e,qZ.Aliased)&&i.push($` as ${$.identifier(e.fieldAlias)}`)}else Q(e,$X)&&(t?i.push($.identifier(this.casing.getColumnCasing(e))):i.push(e));return ro?.some(({alias:t})=>t===(e[BZ.Symbol.IsAlias]?VZ(e):e[BZ.Symbol.BaseName])))(e.field.table)){let t=VZ(e.field.table);throw Error(`Your "${e.path.join(`->`)}" field references a column "${t}"."${e.field.name}", but the table "${t}" is not part of the query! Did you forget to join it?`)}let h=!o||o.length===0,g=this.buildWithCTE(e),_;f&&(_=f===!0?$` distinct`:$` distinct on (${$.join(f.on,$`, `)})`);let v=this.buildSelection(m,{isSingleTable:h}),y=this.buildFromTable(a),b=this.buildJoins(o),x=r?$` where ${r}`:void 0,S=i?$` having ${i}`:void 0,C;s&&s.length>0&&(C=$` order by ${$.join(s,$`, `)}`);let w;c&&c.length>0&&(w=$` group by ${$.join(c,$`, `)}`);let T=typeof l==`object`||typeof l==`number`&&l>=0?$` limit ${l}`:void 0,E=u?$` offset ${u}`:void 0,D=$.empty();if(d){let e=$` for ${$.raw(d.strength)}`;d.config.of&&e.append($` of ${$.join(Array.isArray(d.config.of)?d.config.of:[d.config.of],$`, `)}`),d.config.noWait?e.append($` nowait`):d.config.skipLocked&&e.append($` skip locked`),D.append(e)}let O=$`${g}select${_} ${v} from ${y}${b}${x}${w}${S}${C}${T}${E}${D}`;return p.length>0?this.buildSetOperations(O,p):O}buildSetOperations(e,t){let[n,...r]=t;if(!n)throw Error(`Cannot pass undefined values to any set operator`);return r.length===0?this.buildSetOperationQuery({leftSelect:e,setOperator:n}):this.buildSetOperations(this.buildSetOperationQuery({leftSelect:e,setOperator:n}),r)}buildSetOperationQuery({leftSelect:e,setOperator:{type:t,isAll:n,rightSelect:r,limit:i,orderBy:a,offset:o}}){let s=$`(${e.getSQL()}) `,c=$`(${r.getSQL()})`,l;if(a&&a.length>0){let e=[];for(let t of a)if(Q(t,mZ))e.push($.identifier(t.name));else if(Q(t,qZ)){for(let e=0;e=0?$` limit ${i}`:void 0,d=$.raw(`${t} ${n?`all `:``}`),f=o?$` offset ${o}`:void 0;return $`${s}${d}${c}${l}${u}${f}`}buildInsertQuery({table:e,values:t,onConflict:n,returning:r,withList:i,select:a,overridingSystemValue_:o}){let s=[],c=e[BZ.Symbol.Columns],l=Object.entries(c).filter(([e,t])=>!t.shouldDisableInsert()),u=l.map(([,e])=>$.identifier(this.casing.getColumnCasing(e)));if(a){let e=t;Q(e,qZ)?s.push(e):s.push(e.getSQL())}else{let e=t;s.push($.raw(`values `));for(let[t,n]of e.entries()){let r=[];for(let[e,t]of l){let i=n[e];if(i===void 0||Q(i,$Z)&&i.value===void 0)if(t.defaultFn!==void 0){let e=t.defaultFn(),n=Q(e,qZ)?e:$.param(e,t);r.push(n)}else if(!t.default&&t.onUpdateFn!==void 0){let e=t.onUpdateFn(),n=Q(e,qZ)?e:$.param(e,t);r.push(n)}else r.push($`default`);else r.push(i)}s.push(r),t({dbKey:t.name,tsKey:e,field:cQ(t,o),relationTableTsKey:void 0,isJson:!1,selection:[]}))}else{let r=Object.fromEntries(Object.entries(i.columns).map(([e,t])=>[e,cQ(t,o)]));if(a.where){let e=typeof a.where==`function`?a.where(r,E$()):a.where;p=e&&uQ(e,o)}let s=[],c=[];if(a.columns){let e=!1;for(let[t,n]of Object.entries(a.columns)){if(n===void 0)continue;t in i.columns&&(!e&&n===!0&&(e=!0),c.push(t))}c.length>0&&(c=e?c.filter(e=>{var t;return(t=a.columns)?.[e]===!0}):Object.keys(i.columns).filter(e=>!c.includes(e)))}else c=Object.keys(i.columns);for(let e of c){let t=i.columns[e];s.push({tsKey:e,value:t})}let h=[];a.with&&(h=Object.entries(a.with).filter(e=>!!e[1]).map(([e,t])=>({tsKey:e,queryConfig:t,relation:i.relations[e]})));let g;if(a.extras){g=typeof a.extras==`function`?a.extras(r,{sql:$}):a.extras;for(let[e,t]of Object.entries(g))s.push({tsKey:e,value:lQ(t,o)})}for(let{tsKey:e,value:t}of s)l.push({dbKey:Q(t,qZ.Aliased)?t.fieldAlias:i.columns[e].name,tsKey:e,field:Q(t,$X)?cQ(t,o):t,relationTableTsKey:void 0,isJson:!1,selection:[]});let _=typeof a.orderBy==`function`?a.orderBy(r,D$()):a.orderBy??[];Array.isArray(_)||(_=[_]),f=_.map(e=>Q(e,$X)?cQ(e,o):uQ(e,o)),u=a.limit,d=a.offset;for(let{tsKey:r,queryConfig:i,relation:a}of h){let s=j$(t,n,a),c=HZ(a.referencedTable),u=n[c],d=`${o}_${r}`,f=t$(...s.fields.map((e,t)=>$Q(cQ(s.references[t],d),cQ(e,o)))),p=this.buildRelationalQueryWithoutPK({fullSchema:e,schema:t,tableNamesMap:n,table:e[u],tableConfig:t[u],queryConfig:Q(a,w$)?i===!0?{limit:1}:{...i,limit:1}:i,tableAlias:d,joinOn:f,nestedQueryRelation:a}),h=$`${$.identifier(d)}.${$.identifier(`data`)}`.as(r);m.push({on:$`true`,table:new TZ(p.sql,{},d),alias:d,joinType:`left`,lateral:!0}),l.push({dbKey:r,tsKey:r,field:h,relationTableTsKey:u,isJson:!0,selection:p.selection})}}if(l.length===0)throw new dQ({message:`No fields selected for table "${i.tsName}" ("${o}")`});let h;if(p=t$(c,p),s){let e=$`json_build_array(${$.join(l.map(({field:e,tsKey:t,isJson:n})=>n?$`${$.identifier(`${o}_${t}`)}.${$.identifier(`data`)}`:Q(e,qZ.Aliased)?e.sql:e),$`, `)})`;Q(s,T$)&&(e=$`coalesce(json_agg(${e}${f.length>0?$` order by ${$.join(f,$`, `)}`:void 0}), '[]'::json)`);let t=[{dbKey:`data`,tsKey:`data`,field:e.as(`data`),isJson:!0,relationTableTsKey:i.tsName,selection:l}],n=u!==void 0||d!==void 0||f.length>0;n?(h=this.buildSelectQuery({table:sQ(r,o),fields:{},fieldsFlat:[{path:[],field:$.raw(`*`)}],where:p,limit:u,offset:d,orderBy:f,setOperators:[]}),p=void 0,u=void 0,d=void 0,f=[]):h=sQ(r,o),h=this.buildSelectQuery({table:Q(h,YQ)?h:new TZ(h,{},o),fields:{},fieldsFlat:t.map(({field:e})=>({path:[],field:Q(e,$X)?cQ(e,o):e})),joins:m,where:p,limit:u,offset:d,orderBy:f,setOperators:[]})}else h=this.buildSelectQuery({table:sQ(r,o),fields:{},fieldsFlat:l.map(({field:e})=>({path:[],field:Q(e,$X)?cQ(e,o):e})),joins:m,where:p,limit:u,offset:d,orderBy:f,setOperators:[]});return{tableTsKey:i.tsName,sql:h,selection:l}}},e.defineProperty(Pi,Z,`PgDialect`),Pi),V$=(Fi=class{getSelectedFields(){return this._.selectedFields}},e.defineProperty(Fi,Z,`TypedQueryBuilder`),Fi),H$=(Ii=class{constructor(t){e.defineProperty(this,`fields`,void 0),e.defineProperty(this,`session`,void 0),e.defineProperty(this,`dialect`,void 0),e.defineProperty(this,`withList`,[]),e.defineProperty(this,`distinct`,void 0),e.defineProperty(this,`authToken`,void 0),this.fields=t.fields,this.session=t.session,this.dialect=t.dialect,t.withList&&(this.withList=t.withList),this.distinct=t.distinct}setToken(e){return this.authToken=e,this}from(e){let t=!!this.fields,n=e,r;return r=this.fields?this.fields:Q(n,TZ)?Object.fromEntries(Object.keys(n._.selectedFields).map(e=>[e,n[e]])):Q(n,z$)?n[jZ].selectedFields:Q(n,qZ)?{}:xQ(n),new W$({table:n,fields:r,isPartialSelect:t,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct}).setToken(this.authToken)}},e.defineProperty(Ii,Z,`PgSelectBuilder`),Ii),U$=(Li=class extends V${constructor({table:t,fields:n,isPartialSelect:r,session:i,dialect:a,withList:o,distinct:s}){super(),e.defineProperty(this,`_`,void 0),e.defineProperty(this,`config`,void 0),e.defineProperty(this,`joinsNotNullableMap`,void 0),e.defineProperty(this,`tableName`,void 0),e.defineProperty(this,`isPartialSelect`,void 0),e.defineProperty(this,`session`,void 0),e.defineProperty(this,`dialect`,void 0),e.defineProperty(this,`cacheConfig`,void 0),e.defineProperty(this,`usedTables`,new Set),e.defineProperty(this,`leftJoin`,this.createJoin(`left`,!1)),e.defineProperty(this,`leftJoinLateral`,this.createJoin(`left`,!0)),e.defineProperty(this,`rightJoin`,this.createJoin(`right`,!1)),e.defineProperty(this,`innerJoin`,this.createJoin(`inner`,!1)),e.defineProperty(this,`innerJoinLateral`,this.createJoin(`inner`,!0)),e.defineProperty(this,`fullJoin`,this.createJoin(`full`,!1)),e.defineProperty(this,`crossJoin`,this.createJoin(`cross`,!1)),e.defineProperty(this,`crossJoinLateral`,this.createJoin(`cross`,!0)),e.defineProperty(this,`union`,this.createSetOperator(`union`,!1)),e.defineProperty(this,`unionAll`,this.createSetOperator(`union`,!0)),e.defineProperty(this,`intersect`,this.createSetOperator(`intersect`,!1)),e.defineProperty(this,`intersectAll`,this.createSetOperator(`intersect`,!0)),e.defineProperty(this,`except`,this.createSetOperator(`except`,!1)),e.defineProperty(this,`exceptAll`,this.createSetOperator(`except`,!0)),this.config={withList:o,table:t,fields:{...n},distinct:s,setOperators:[]},this.isPartialSelect=r,this.session=i,this.dialect=a,this._={selectedFields:n,config:this.config},this.tableName=SQ(t),this.joinsNotNullableMap=typeof this.tableName==`string`?{[this.tableName]:!0}:{};for(let e of e1(t))this.usedTables.add(e)}getUsedTables(){return[...this.usedTables]}createJoin(e,t){return(n,r)=>{var i;let a=this.tableName,o=SQ(n);for(let e of e1(n))this.usedTables.add(e);if(typeof o==`string`&&(i=this.config.joins)?.some(e=>e.alias===o))throw Error(`Alias "${o}" is already used in this query`);if(!this.isPartialSelect&&(Object.keys(this.joinsNotNullableMap).length===1&&typeof a==`string`&&(this.config.fields={[a]:this.config.fields}),typeof o==`string`&&!Q(n,qZ))){let e=Q(n,TZ)?n._.selectedFields:Q(n,rQ)?n[jZ].selectedFields:n[BZ.Symbol.Columns];this.config.fields[o]=e}if(typeof r==`function`&&(r=r(new Proxy(this.config.fields,new P$({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:r,table:n,joinType:e,alias:o,lateral:t}),typeof o==`string`)switch(e){case`left`:this.joinsNotNullableMap[o]=!1;break;case`right`:this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[o]=!0;break;case`cross`:case`inner`:this.joinsNotNullableMap[o]=!0;break;case`full`:this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[o]=!1;break}return this}}createSetOperator(e,t){return n=>{let r=typeof n==`function`?n(K$()):n;if(!vQ(this.getSelectedFields(),r.getSelectedFields()))throw Error(`Set operator error (union / intersect / except): selected fields are not the same or are in a different order`);return this.config.setOperators.push({type:e,isAll:t,rightSelect:r}),this}}addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){return typeof e==`function`&&(e=e(new Proxy(this.config.fields,new P$({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})))),this.config.where=e,this}having(e){return typeof e==`function`&&(e=e(new Proxy(this.config.fields,new P$({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})))),this.config.having=e,this}groupBy(...e){if(typeof e[0]==`function`){let t=e[0](new Proxy(this.config.fields,new P$({sqlAliasedBehavior:`alias`,sqlBehavior:`sql`})));this.config.groupBy=Array.isArray(t)?t:[t]}else this.config.groupBy=e;return this}orderBy(...e){if(typeof e[0]==`function`){let t=e[0](new Proxy(this.config.fields,new P$({sqlAliasedBehavior:`alias`,sqlBehavior:`sql`}))),n=Array.isArray(t)?t:[t];this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=n:this.config.orderBy=n}else{let t=e;this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=t:this.config.orderBy=t}return this}limit(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).limit=e:this.config.limit=e,this}offset(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).offset=e:this.config.offset=e,this}for(e,t={}){return this.config.lockingClause={strength:e,config:t},this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}as(e){let t=[];if(t.push(...e1(this.config.table)),this.config.joins)for(let e of this.config.joins)t.push(...e1(e.table));return new Proxy(new TZ(this.getSQL(),this.config.fields,e,!1,[...new Set(t)]),new P$({alias:e,sqlAliasedBehavior:`alias`,sqlBehavior:`error`}))}getSelectedFields(){return new Proxy(this.config.fields,new P$({alias:this.tableName,sqlAliasedBehavior:`alias`,sqlBehavior:`error`}))}$dynamic(){return this}$withCache(e){return this.cacheConfig=e===void 0?{config:{},enable:!0,autoInvalidate:!0}:e===!1?{enable:!1}:{enable:!0,autoInvalidate:!0,...e},this}},e.defineProperty(Li,Z,`PgSelectQueryBuilder`),Li),W$=(Ri=class extends U${constructor(...t){super(...t),e.defineProperty(this,`authToken`,void 0),e.defineProperty(this,`execute`,e=>AZ.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(e,this.authToken)))}_prepare(e){let{session:t,config:n,dialect:r,joinsNotNullableMap:i,authToken:a,cacheConfig:o,usedTables:s}=this;if(!t)throw Error(`Cannot execute a query on a query builder. Please use a database instance instead.`);let{fields:c}=n;return AZ.startActiveSpan(`drizzle.prepareQuery`,()=>{let n=_Q(c),l=t.prepareQuery(r.sqlToQuery(this.getSQL()),n,e,!0,void 0,{type:`select`,tables:[...s]},o);return l.joinsNotNullableMap=i,l.setToken(a)})}prepare(e){return this._prepare(e)}setToken(e){return this.authToken=e,this}},e.defineProperty(Ri,Z,`PgSelect`),Ri);bQ(W$,[gQ]);function G$(e,t){return(n,r,...i)=>{let a=[r,...i].map(n=>({type:e,isAll:t,rightSelect:n}));for(let e of a)if(!vQ(n.getSelectedFields(),e.rightSelect.getSelectedFields()))throw Error(`Set operator error (union / intersect / except): selected fields are not the same or are in a different order`);return n.addSetOperators(a)}}const K$=()=>({union:q$,unionAll:J$,intersect:Y$,intersectAll:X$,except:Z$,exceptAll:Q$}),q$=G$(`union`,!1),J$=G$(`union`,!0),Y$=G$(`intersect`,!1),X$=G$(`intersect`,!0),Z$=G$(`except`,!1),Q$=G$(`except`,!0);var $$=(zi=class{constructor(t){e.defineProperty(this,`dialect`,void 0),e.defineProperty(this,`dialectConfig`,void 0),e.defineProperty(this,`$with`,(e,t)=>{let n=this,r=r=>(typeof r==`function`&&(r=r(n)),new Proxy(new EZ(r.getSQL(),t??(`getSelectedFields`in r?r.getSelectedFields()??{}:{}),e,!0),new P$({alias:e,sqlAliasedBehavior:`alias`,sqlBehavior:`error`})));return{as:r}}),this.dialect=Q(t,B$)?t:void 0,this.dialectConfig=Q(t,B$)?void 0:t}with(...e){let t=this;function n(n){return new H$({fields:n??void 0,session:void 0,dialect:t.getDialect(),withList:e})}function r(e){return new H$({fields:e??void 0,session:void 0,dialect:t.getDialect(),distinct:!0})}function i(e,n){return new H$({fields:n??void 0,session:void 0,dialect:t.getDialect(),distinct:{on:e}})}return{select:n,selectDistinct:r,selectDistinctOn:i}}select(e){return new H$({fields:e??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(e){return new H$({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}selectDistinctOn(e,t){return new H$({fields:t??void 0,session:void 0,dialect:this.getDialect(),distinct:{on:e}})}getDialect(){return this.dialect||=new B$(this.dialectConfig),this.dialect}},e.defineProperty(zi,Z,`PgQueryBuilder`),zi);function e1(e){return Q(e,YQ)?[e[MZ]?`${e[MZ]}.${e[BZ.Symbol.BaseName]}`:e[BZ.Symbol.BaseName]]:Q(e,TZ)?e._.usedTables??[]:Q(e,qZ)?e.usedTables??[]:[]}var t1=(Bi=class extends gQ{constructor(t,n,r,i){super(),e.defineProperty(this,`config`,void 0),e.defineProperty(this,`cacheConfig`,void 0),e.defineProperty(this,`authToken`,void 0),e.defineProperty(this,`execute`,e=>AZ.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(e,this.authToken))),this.session=n,this.dialect=r,this.config={table:t,withList:i}}where(e){return this.config.where=e,this}returning(e=this.config.table[BZ.Symbol.Columns]){return this.config.returningFields=e,this.config.returning=_Q(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){return AZ.startActiveSpan(`drizzle.prepareQuery`,()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0,void 0,{type:`delete`,tables:e1(this.config.table)},this.cacheConfig))}prepare(e){return this._prepare(e)}setToken(e){return this.authToken=e,this}getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new P$({alias:VZ(this.config.table),sqlAliasedBehavior:`alias`,sqlBehavior:`error`})):void 0}$dynamic(){return this}},e.defineProperty(Bi,Z,`PgDelete`),Bi),n1=(Vi=class{constructor(t,n,r,i,a){e.defineProperty(this,`authToken`,void 0),this.table=t,this.session=n,this.dialect=r,this.withList=i,this.overridingSystemValue_=a}setToken(e){return this.authToken=e,this}overridingSystemValue(){return this.overridingSystemValue_=!0,this}values(e){if(e=Array.isArray(e)?e:[e],e.length===0)throw Error(`values() must be called with at least one value`);let t=e.map(e=>{let t={},n=this.table[BZ.Symbol.Columns];for(let r of Object.keys(e)){let i=e[r];t[r]=Q(i,qZ)?i:new $Z(i,n[r])}return t});return new r1(this.table,t,this.session,this.dialect,this.withList,!1,this.overridingSystemValue_).setToken(this.authToken)}select(e){let t=typeof e==`function`?e(new $$):e;if(!Q(t,qZ)&&!vQ(this.table[NZ],t._.selectedFields))throw Error(`Insert select error: selected fields are not the same or are in a different order compared to the table definition`);return new r1(this.table,t,this.session,this.dialect,this.withList,!0)}},e.defineProperty(Vi,Z,`PgInsertBuilder`),Vi),r1=(Hi=class extends gQ{constructor(t,n,r,i,a,o,s){super(),e.defineProperty(this,`config`,void 0),e.defineProperty(this,`cacheConfig`,void 0),e.defineProperty(this,`authToken`,void 0),e.defineProperty(this,`execute`,e=>AZ.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(e,this.authToken))),this.session=r,this.dialect=i,this.config={table:t,values:n,withList:a,select:o,overridingSystemValue_:s}}returning(e=this.config.table[BZ.Symbol.Columns]){return this.config.returningFields=e,this.config.returning=_Q(e),this}onConflictDoNothing(e={}){if(e.target===void 0)this.config.onConflict=$`do nothing`;else{let t=``;t=Array.isArray(e.target)?e.target.map(e=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(e))).join(`,`):this.dialect.escapeName(this.dialect.casing.getColumnCasing(e.target));let n=e.where?$` where ${e.where}`:void 0;this.config.onConflict=$`(${$.raw(t)})${n} do nothing`}return this}onConflictDoUpdate(e){if(e.where&&(e.targetWhere||e.setWhere))throw Error(`You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.`);let t=e.where?$` where ${e.where}`:void 0,n=e.targetWhere?$` where ${e.targetWhere}`:void 0,r=e.setWhere?$` where ${e.setWhere}`:void 0,i=this.dialect.buildUpdateSet(this.config.table,yQ(this.config.table,e.set)),a=``;return a=Array.isArray(e.target)?e.target.map(e=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(e))).join(`,`):this.dialect.escapeName(this.dialect.casing.getColumnCasing(e.target)),this.config.onConflict=$`(${$.raw(a)})${n} do update set ${i}${t}${r}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){return AZ.startActiveSpan(`drizzle.prepareQuery`,()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0,void 0,{type:`insert`,tables:e1(this.config.table)},this.cacheConfig))}prepare(e){return this._prepare(e)}setToken(e){return this.authToken=e,this}getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new P$({alias:VZ(this.config.table),sqlAliasedBehavior:`alias`,sqlBehavior:`error`})):void 0}$dynamic(){return this}},e.defineProperty(Hi,Z,`PgInsert`),Hi),i1=(Ui=class extends gQ{constructor(t,n,r){super(),e.defineProperty(this,`config`,void 0),e.defineProperty(this,`authToken`,void 0),e.defineProperty(this,`execute`,e=>AZ.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(e,this.authToken))),this.session=n,this.dialect=r,this.config={view:t}}concurrently(){if(this.config.withNoData!==void 0)throw Error(`Cannot use concurrently and withNoData together`);return this.config.concurrently=!0,this}withNoData(){if(this.config.concurrently!==void 0)throw Error(`Cannot use concurrently and withNoData together`);return this.config.withNoData=!0,this}getSQL(){return this.dialect.buildRefreshMaterializedViewQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){return AZ.startActiveSpan(`drizzle.prepareQuery`,()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),void 0,e,!0))}prepare(e){return this._prepare(e)}setToken(e){return this.authToken=e,this}},e.defineProperty(Ui,Z,`PgRefreshMaterializedView`),Ui),a1=(Wi=class{constructor(t,n,r,i){e.defineProperty(this,`authToken`,void 0),this.table=t,this.session=n,this.dialect=r,this.withList=i}setToken(e){return this.authToken=e,this}set(e){return new o1(this.table,yQ(this.table,e),this.session,this.dialect,this.withList).setToken(this.authToken)}},e.defineProperty(Wi,Z,`PgUpdateBuilder`),Wi),o1=(Gi=class extends gQ{constructor(t,n,r,i,a){super(),e.defineProperty(this,`config`,void 0),e.defineProperty(this,`tableName`,void 0),e.defineProperty(this,`joinsNotNullableMap`,void 0),e.defineProperty(this,`cacheConfig`,void 0),e.defineProperty(this,`leftJoin`,this.createJoin(`left`)),e.defineProperty(this,`rightJoin`,this.createJoin(`right`)),e.defineProperty(this,`innerJoin`,this.createJoin(`inner`)),e.defineProperty(this,`fullJoin`,this.createJoin(`full`)),e.defineProperty(this,`authToken`,void 0),e.defineProperty(this,`execute`,e=>this._prepare().execute(e,this.authToken)),this.session=r,this.dialect=i,this.config={set:n,table:t,withList:a,joins:[]},this.tableName=SQ(t),this.joinsNotNullableMap=typeof this.tableName==`string`?{[this.tableName]:!0}:{}}from(e){let t=e,n=SQ(t);return typeof n==`string`&&(this.joinsNotNullableMap[n]=!0),this.config.from=t,this}getTableLikeFields(e){return Q(e,YQ)?e[BZ.Symbol.Columns]:Q(e,TZ)?e._.selectedFields:e[jZ].selectedFields}createJoin(e){return(t,n)=>{let r=SQ(t);if(typeof r==`string`&&this.config.joins.some(e=>e.alias===r))throw Error(`Alias "${r}" is already used in this query`);if(typeof n==`function`){let e=this.config.from&&!Q(this.config.from,qZ)?this.getTableLikeFields(this.config.from):void 0;n=n(new Proxy(this.config.table[BZ.Symbol.Columns],new P$({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})),e&&new Proxy(e,new P$({sqlAliasedBehavior:`sql`,sqlBehavior:`sql`})))}if(this.config.joins.push({on:n,table:t,joinType:e,alias:r}),typeof r==`string`)switch(e){case`left`:this.joinsNotNullableMap[r]=!1;break;case`right`:this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[r]=!0;break;case`inner`:this.joinsNotNullableMap[r]=!0;break;case`full`:this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([e])=>[e,!1])),this.joinsNotNullableMap[r]=!1;break}return this}}where(e){return this.config.where=e,this}returning(e){if(!e&&(e=Object.assign({},this.config.table[BZ.Symbol.Columns]),this.config.from)){let t=SQ(this.config.from);if(typeof t==`string`&&this.config.from&&!Q(this.config.from,qZ)){let n=this.getTableLikeFields(this.config.from);e[t]=n}for(let t of this.config.joins){let n=SQ(t.table);if(typeof n==`string`&&!Q(t.table,qZ)){let r=this.getTableLikeFields(t.table);e[n]=r}}}return this.config.returningFields=e,this.config.returning=_Q(e),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){let{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e){let t=this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0,void 0,{type:`insert`,tables:e1(this.config.table)},this.cacheConfig);return t.joinsNotNullableMap=this.joinsNotNullableMap,t}prepare(e){return this._prepare(e)}setToken(e){return this.authToken=e,this}getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new P$({alias:VZ(this.config.table),sqlAliasedBehavior:`alias`,sqlBehavior:`error`})):void 0}$dynamic(){return this}},e.defineProperty(Gi,Z,`PgUpdate`),Gi),s1=(la=Symbol.toStringTag,Ki=class t extends qZ{constructor(n){super(t.buildEmbeddedCount(n.source,n.filters).queryChunks),e.defineProperty(this,`sql`,void 0),e.defineProperty(this,`token`,void 0),e.defineProperty(this,la,`PgCountBuilder`),e.defineProperty(this,`session`,void 0),this.params=n,this.mapWith(Number),this.session=n.session,this.sql=t.buildCount(n.source,n.filters)}static buildEmbeddedCount(e,t){return $`(select count(*) from ${e}${$.raw(` where `).if(t)}${t})`}static buildCount(e,t){return $`select count(*) as count from ${e}${$.raw(` where `).if(t)}${t};`}setToken(e){return this.token=e,this}then(e,t){return Promise.resolve(this.session.count(this.sql,this.token)).then(e,t)}catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}},e.defineProperty(Ki,Z,`PgCountBuilder`),Ki),c1=(qi=class{constructor(e,t,n,r,i,a,o){this.fullSchema=e,this.schema=t,this.tableNamesMap=n,this.table=r,this.tableConfig=i,this.dialect=a,this.session=o}findMany(e){return new l1(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e||{},`many`)}findFirst(e){return new l1(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,e?{...e,limit:1}:{limit:1},`first`)}},e.defineProperty(qi,Z,`PgRelationalQueryBuilder`),qi),l1=(Ji=class extends gQ{constructor(t,n,r,i,a,o,s,c,l){super(),e.defineProperty(this,`authToken`,void 0),this.fullSchema=t,this.schema=n,this.tableNamesMap=r,this.table=i,this.tableConfig=a,this.dialect=o,this.session=s,this.config=c,this.mode=l}_prepare(e){return AZ.startActiveSpan(`drizzle.prepareQuery`,()=>{let{query:t,builtQuery:n}=this._toSQL();return this.session.prepareQuery(n,void 0,e,!0,(e,n)=>{let r=e.map(e=>N$(this.schema,this.tableConfig,e,t.selection,n));return this.mode===`first`?r[0]:r})})}prepare(e){return this._prepare(e)}_getQuery(){return this.dialect.buildRelationalQueryWithoutPK({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName})}getSQL(){return this._getQuery().sql}_toSQL(){let e=this._getQuery(),t=this.dialect.sqlToQuery(e.sql);return{query:e,builtQuery:t}}toSQL(){return this._toSQL().builtQuery}setToken(e){return this.authToken=e,this}execute(){return AZ.startActiveSpan(`drizzle.operation`,()=>this._prepare().execute(void 0,this.authToken))}},e.defineProperty(Ji,Z,`PgRelationalQuery`),Ji),u1=(Yi=class extends gQ{constructor(e,t,n,r){super(),this.execute=e,this.sql=t,this.query=n,this.mapBatchResult=r}getSQL(){return this.sql}getQuery(){return this.query}mapResult(e,t){return t?this.mapBatchResult(e):e}_prepare(){return this}isResponseInArrayMode(){return!1}},e.defineProperty(Yi,Z,`PgRaw`),Yi),d1=(Xi=class{constructor(t,n,r){if(e.defineProperty(this,`query`,void 0),e.defineProperty(this,`$with`,(e,t)=>{let n=this,r=r=>(typeof r==`function`&&(r=r(new $$(n.dialect))),new Proxy(new EZ(r.getSQL(),t??(`getSelectedFields`in r?r.getSelectedFields()??{}:{}),e,!0),new P$({alias:e,sqlAliasedBehavior:`alias`,sqlBehavior:`error`})));return{as:r}}),e.defineProperty(this,`$cache`,void 0),e.defineProperty(this,`authToken`,void 0),this.dialect=t,this.session=n,this._=r?{schema:r.schema,fullSchema:r.fullSchema,tableNamesMap:r.tableNamesMap,session:n}:{schema:void 0,fullSchema:{},tableNamesMap:{},session:n},this.query={},this._.schema)for(let[e,i]of Object.entries(this._.schema))this.query[e]=new c1(r.fullSchema,this._.schema,this._.tableNamesMap,r.fullSchema[e],i,t,n);this.$cache={invalidate:async e=>{}}}$count(e,t){return new s1({source:e,filters:t,session:this.session})}with(...e){let t=this;function n(n){return new H$({fields:n??void 0,session:t.session,dialect:t.dialect,withList:e})}function r(n){return new H$({fields:n??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:!0})}function i(n,r){return new H$({fields:r??void 0,session:t.session,dialect:t.dialect,withList:e,distinct:{on:n}})}function a(n){return new a1(n,t.session,t.dialect,e)}function o(n){return new n1(n,t.session,t.dialect,e)}function s(n){return new t1(n,t.session,t.dialect,e)}return{select:n,selectDistinct:r,selectDistinctOn:i,update:a,insert:o,delete:s}}select(e){return new H$({fields:e??void 0,session:this.session,dialect:this.dialect})}selectDistinct(e){return new H$({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn(e,t){return new H$({fields:t??void 0,session:this.session,dialect:this.dialect,distinct:{on:e}})}update(e){return new a1(e,this.session,this.dialect)}insert(e){return new n1(e,this.session,this.dialect)}delete(e){return new t1(e,this.session,this.dialect)}refreshMaterializedView(e){return new i1(e,this.session,this.dialect)}execute(e){let t=typeof e==`string`?$.raw(e):e.getSQL(),n=this.dialect.sqlToQuery(t),r=this.session.prepareQuery(n,void 0,void 0,!1);return new u1(()=>r.execute(void 0,this.authToken),t,n,e=>r.mapResult(e,!0))}transaction(e,t){return this.session.transaction(e,t)}},e.defineProperty(Xi,Z,`PgDatabase`),Xi),f1=(Zi=class{},e.defineProperty(Zi,Z,`Cache`),Zi),p1=(Qi=class extends f1{strategy(){return`all`}async get(e){}async put(e,t,n,r){}async onMutate(e){}},e.defineProperty(Qi,Z,`NoopCache`),Qi);async function m1(e,t){let n=`${e}-${JSON.stringify(t)}`,r=new TextEncoder,i=r.encode(n),a=await crypto.subtle.digest(`SHA-256`,i),o=[...new Uint8Array(a)],s=o.map(e=>e.toString(16).padStart(2,`0`)).join(``);return s}var h1=class e extends Error{constructor(t,n,r){super(`Failed query: ${t} +params: ${n}`),this.query=t,this.params=n,this.cause=r,Error.captureStackTrace(this,e),r&&(this.cause=r)}},g1=($i=class{constructor(t,n,r,i){var a;e.defineProperty(this,`authToken`,void 0),e.defineProperty(this,`joinsNotNullableMap`,void 0),this.query=t,this.cache=n,this.queryMetadata=r,this.cacheConfig=i,n&&n.strategy()===`all`&&i===void 0&&(this.cacheConfig={enable:!0,autoInvalidate:!0}),(a=this.cacheConfig)?.enable||(this.cacheConfig=void 0)}getQuery(){return this.query}mapResult(e,t){return e}setToken(e){return this.authToken=e,this}async queryWithCache(e,t,n){if(this.cache===void 0||Q(this.cache,p1)||this.queryMetadata===void 0)try{return await n()}catch(n){throw new h1(e,t,n)}if(this.cacheConfig&&!this.cacheConfig.enable)try{return await n()}catch(n){throw new h1(e,t,n)}if((this.queryMetadata.type===`insert`||this.queryMetadata.type===`update`||this.queryMetadata.type===`delete`)&&this.queryMetadata.tables.length>0)try{let[e]=await Promise.all([n(),this.cache.onMutate({tables:this.queryMetadata.tables})]);return e}catch(n){throw new h1(e,t,n)}if(!this.cacheConfig)try{return await n()}catch(n){throw new h1(e,t,n)}if(this.queryMetadata.type===`select`){let r=await this.cache.get(this.cacheConfig.tag??await m1(e,t),this.queryMetadata.tables,this.cacheConfig.tag!==void 0,this.cacheConfig.autoInvalidate);if(r===void 0){let r;try{r=await n()}catch(n){throw new h1(e,t,n)}return await this.cache.put(this.cacheConfig.tag??await m1(e,t),r,this.cacheConfig.autoInvalidate?this.queryMetadata.tables:[],this.cacheConfig.tag!==void 0,this.cacheConfig.config),r}return r}try{return await n()}catch(n){throw new h1(e,t,n)}}},e.defineProperty($i,Z,`PgPreparedQuery`),$i),_1=(ea=class{constructor(e){this.dialect=e}execute(e,t){return AZ.startActiveSpan(`drizzle.operation`,()=>{let n=AZ.startActiveSpan(`drizzle.prepareQuery`,()=>this.prepareQuery(this.dialect.sqlToQuery(e),void 0,void 0,!1));return n.setToken(t).execute(void 0,t)})}all(e){return this.prepareQuery(this.dialect.sqlToQuery(e),void 0,void 0,!1).all()}async count(e,t){let n=await this.execute(e,t);return Number(n[0].count)}},e.defineProperty(ea,Z,`PgSession`),ea),v1=(ta=class extends d1{constructor(e,t,n,r=0){super(e,t,n),this.schema=n,this.nestedIndex=r}rollback(){throw new fQ}getTransactionConfigSQL(e){let t=[];return e.isolationLevel&&t.push(`isolation level ${e.isolationLevel}`),e.accessMode&&t.push(e.accessMode),typeof e.deferrable==`boolean`&&t.push(e.deferrable?`deferrable`:`not deferrable`),$.raw(t.join(` `))}setTransaction(e){return this.session.execute($`set transaction ${this.getTransactionConfigSQL(e)}`)}},e.defineProperty(ta,Z,`PgTransaction`),ta);function y1(e){return typeof e==`string`&&/^true$/i.test(e)}function b1(e){let t={scheme:`duckdb-wasm:`},n=new URL(e);if(!n.protocol.startsWith(`duckdb-wasm:`))throw Error(`Expected scheme to be "duckdb-wasm:" but got "${n.protocol}"`);n.searchParams.get(`bundles`)===`import-url`&&(t.bundles=`import-url`);let r=n.searchParams.get(`logger`);r&&y1(r)&&(t.logger=!0);let i=n.searchParams.get(`storage`);switch(i){case JX.ORIGIN_PRIVATE_FS:{n.host.length>0&&console.warn(`Host "${n.host}" will be ignored while using Origin Private FS`);let e=n.searchParams.get(`write`);t.storage={type:JX.ORIGIN_PRIVATE_FS,path:n.pathname.startsWith(`/`)?n.pathname.slice(1):n.pathname,...e&&y1(e)&&{accessMode:mV.READ_WRITE}};break}case null:break;default:console.warn(`Unknown storage type "${i}"`);break}return t}var x1=(na=class extends g1{constructor(e,t,n,r,i,a){super({sql:t,params:n}),this.client=e,this.queryString=t,this.params=n,this.logger=r,this.fields=i,this.customResultMapper=a}async execute(e={}){let t=tQ(this.params,e);this.logger.logQuery(this.queryString,t);let{fields:n,queryString:r,client:i,customResultMapper:a}=this,o=await i;return o.query(r,t)}async all(e={}){let t=tQ(this.params,e);this.logger.logQuery(this.queryString,t);let n=await this.client;return n.query(this.queryString,t)}},e.defineProperty(na,Z,`DuckDBWasmPreparedQuery`),na),S1=(ra=class t extends _1{constructor(t,n,r,i={}){super(n),e.defineProperty(this,`logger`,void 0),this.client=t,this.schema=r,this.options=i,this.logger=i.logger??new hQ}prepareQuery(e,t,n,r,i){return new x1(this.client,e.sql,e.params,this.logger,t,i)}async query(e,t){this.logger.logQuery(e,t);let n=await this.client;return n.query(e,t)}async queryObjects(e,t){this.logger.logQuery(e,t);let n=await this.client;return n.query(e,t)}transaction(e,n){return XX(this.client,async r=>{let i=new t(r,this.dialect,this.schema,this.options),a=new C1(this.dialect,i,this.schema);return n&&await a.setTransaction(n),e(a)})}},e.defineProperty(ra,Z,`DuckDBWasmSession`),ra),C1=(ia=class t extends v1{constructor(t,n,r,i=0){super(t,n,r,i),e.defineProperty(this,`dialect`,void 0),e.defineProperty(this,`session`,void 0),this.dialect=t,this.session=n}async transaction(e){return ZX(this.session.client,``,async n=>{let r=new S1(n,this.dialect,this.schema,this.session.options),i=new t(this.dialect,r,this.schema);return e(i)})}},e.defineProperty(ia,Z,`DuckDBWasmTransaction`),ia),w1=(aa=class extends d1{},e.defineProperty(aa,Z,`DuckDBWasmDatabase`),aa);function T1(e,t={}){let n=new B$({casing:t.casing}),r;t.logger===!0?r=new mQ:t.logger!==!1&&(r=t.logger);let i;if(t.schema){let e=O$(t.schema,M$);i={fullSchema:t.schema,schema:e.tables,tableNamesMap:e.tableNamesMap}}let a=new S1(e,n,i,{logger:r}),o=new w1(n,a,i);return o.$client=e,o}function E1(e,t){let n=b1(e),r;if(n.bundles===`import-url`){let e=async()=>{let e=await xX();switch(e){case`browser`:return(await Dt(async()=>{let{getImportUrlBundles:e}=await import(`./import-url-browser-D6kI1pk-.js`);return{getImportUrlBundles:e}},__vite__mapDeps([4,5,6]))).getImportUrlBundles();case`node`:return await(await Dt(async()=>{let{getImportUrlBundles:e}=await import(`./import-url-node-CDn8y3R9.js`);return{getImportUrlBundles:e}},__vite__mapDeps([7,6]))).getImportUrlBundles();default:throw Error(`Unsupported environment: "${e}"`)}};r=e()}else{let e=async()=>{let e=await xX();switch(e){case`browser`:return(await Dt(async()=>{let{getBundles:e}=await import(`./default-browser-vwqgKA0M.js`);return{getBundles:e}},[])).getBundles();case`node`:return await(await Dt(async()=>{let{getBundles:e}=await import(`./default-node-D--pDlDQ.js`);return{getBundles:e}},__vite__mapDeps([3,1,2]))).getBundles();default:throw Error(`Unsupported environment: "${e}"`)}};r=e()}return T1(YX({bundles:r,logger:n.logger?new xV:void 0,storage:n.storage}),t)}function D1(...e){if(typeof e[0]==`string`)return E1(e[0],e[1]);if(CQ(e[0])){let{connection:t,client:n,...r}=e[0];if(n)return T1(n,r);if(typeof t==`string`)return E1(t,r);if(t===void 0)throw Error(`connection option is required`);return T1(YX({bundles:t.bundles,logger:t.logger,storage:t.storage}),r)}return T1(e[0],e[1])}(function(e){function t(e){return T1({options:{parsers:{},serializers:{}}},e)}e.mock=t})(D1||={});const O1={relative:``},k1={"h-full":``,"w-full":``},A1={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`},j1={bg:`primary-50`,"rounded-xl":``,"px-10":``,"py-6":``},M1=[`innerHTML`];var N1=H({__name:`Stage`,props:{paused:{type:Boolean,default:!1},focusAt:null},setup(e){let t=W(),n=W(),{stageView:r}=pn(Dn()),{mouthOpenSize:i}=pn(Gn()),{audioContext:a,calculateVolume:o}=Hn(),{onBeforeMessageComposed:s,onBeforeSend:c,onTokenLiteral:l,onTokenSpecial:u,onStreamEnd:d,streamingMessage:f,onAssistantResponseEnd:p}=Un(),{process:m}=gr(),h=Wn(),g=W(),_=W(!1),v=W(!1),y=vr({handlers:[e=>new Promise(t=>{let n=a.createBufferSource();n.buffer=e.data.audioBuffer,n.connect(a.destination),n.connect(g.value),_.value=!0,n.start(0),n.onended=()=>{_.value=!1,t()}})]}),b=Kn(),{ssmlEnabled:x,activeSpeechProvider:S,activeSpeechModel:C,activeSpeechVoice:w,pitch:T}=pn(b);async function E(e){try{if(!S.value){console.warn(`No active speech provider configured`);return}if(!w.value){console.warn(`No active speech voice configured`);return}let t=h.getProviderInstance(S.value);if(!t){console.error(`Failed to initialize speech provider`);return}let n=h.getProviderConfig(S.value),r=x.value?b.generateSSML(e.data,w.value,{...n,pitch:T.value}):e.data,i=await Vn({...t.speech(C.value,n),input:r,voice:w.value.id}),o=await a.decodeAudioData(i);await y.add({audioBuffer:o,text:e.data})}catch(e){console.error(`Speech generation failed:`,e)}}let D=vr({handlers:[E]});D.on(`add`,e=>{console.debug(`ttsQueue added`,e)});let O=or(D),{live2dCurrentMotion:k}=pn(Dn()),A=vr({handlers:[async e=>{if(r.value===`3d`){let t=$n[e.data];if(!t)return;await n.value.setExpression(t)}else r.value===`2d`&&(k.value={group:Qn[e.data]})}]}),j=ar(A);j.onHandlerEvent(`emotion`,e=>{console.debug(`emotion detected`,e)});let M=ir();M.onHandlerEvent(`delay`,e=>{console.debug(`delay detected`,e)});function N(){requestAnimationFrame(N),_.value&&(i.value=o(g.value,`linear`))}function ee(){v.value||(N(),a.resume(),v.value=!0)}function P(){g.value||=a.createAnalyser()}return s(async()=>{P(),ee()}),c(async()=>{k.value={group:er}}),l(async e=>{await O.add(e)}),u(async e=>{await M.add(e),await j.add(e)}),d(async()=>{await M.add(rr)}),p(async e=>{}),tn(()=>{v.value=!1}),$t(async()=>{t.value=D1({connection:{bundles:Bn()}}),await t.value.execute(`CREATE TABLE memory_test (vec FLOAT[768]);`)}),(t,a)=>(U(),V(`div`,O1,[B(`div`,k1,[G(r)===`2d`?(U(),At(cx,{key:0,"focus-at":e.focusAt,"mouth-open-size":G(i),"min-w":`50%