vendor: 29,122 bytes, lines 1-10
1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ddsTextureLoader-BYSe_S31.js","assets/dds-By3LClNY.js","assets/passPostProcess-ELyOWk1n.js","assets/envTextureLoader-DDBJ-Fu2.js","assets/dumpTools-DqSCTfgH.js","assets/kernelBlur.fragment-6KL_RhP4.js","assets/kernelBlurVaryingDeclaration-DJ5kzBQs.js","assets/packingFunctions-DqUVTU4U.js","assets/kernelBlur.vertex-DM3d8DeT.js","assets/kernelBlur.fragment-HBFz0pEB.js","assets/kernelBlurVaryingDeclaration-DIhSo5x2.js","assets/kernelBlur.vertex--iz_TC9N.js","assets/shadowMap.fragment-D8YKWezw.js","assets/clipPlaneFragment-D5FJsegM.js","assets/shadowMap.vertex-Cae3rOL3.js","assets/clipPlaneVertex-CyyoJefB.js","assets/morphTargetsVertex-CkfZwDjY.js","assets/helperFunctions-Bvvdmknz.js","assets/meshUboDeclaration-C_x-SJCU.js","assets/depth.vertex-BxJAezBI.js","assets/instancesDeclaration-D1MAOQHs.js","assets/depth.fragment-DM1noNGy.js","assets/color.vertex-BSgtbXOA.js","assets/vertexColorMixing-BK1QNlui.js","assets/color.fragment-B8wxVUHr.js","assets/fogFragment-DKO31M35.js","assets/default.vertex-BwMGLOQH.js","assets/logDepthDeclaration-CnFslgNm.js","assets/default.fragment-B1Enzn3Y.js"])))=>i.map(i=>d[i]); 2function uD(n,e){for(var t=0;t<e.length;t++){const i=e[t];if(typeof i!="string"&&!Array.isArray(i)){for(const s in i)if(s!=="default"&&!(s in n)){const r=Object.getOwnPropertyDescriptor(i,s);r&&Object.defineProperty(n,s,r.get?r:{enumerable:!0,get:()=>i[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();function bA(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var dg={exports:{}},ch={};/** 3 * @license React 4 * react-jsx-runtime.production.js 5 * 6 * Copyright (c) Meta Platforms, Inc. and affiliates. 7 * 8 * This source code is licensed under the MIT license found in the 9 * LICENSE file in the root directory of this source tree. 10 */var Yx;function dD(){if(Yx)return ch;Yx=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(i,s,r){var a=null;if(r!==void 0&&(a=""+r),s.key!==void 0&&(a=""+s.key),"key"in s){r={};for(var o in s)o!=="key"&&(r[o]=s[o])}else r=s;return s=r.ref,{$$typeof:n,type:i,key:a,ref:s!==void 0?s:null,props:r}}return ch.Fragment=e,ch.jsx=t,ch.jsxs=t,ch}var Kx;function fD(){return Kx||(Kx=1,dg.exports=dD()),dg.exports}var B=fD(),Wo=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(n){return this.listeners.add(n),this.onSubscribe(),()=>{this.listeners.delete(n),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},pD={setTimeout:(n,e)=>setTimeout(n,e),clearTimeout:n=>clearTimeout(n),setInterval:(n,e)=>setInterval(n,e),clearInterval:n=>clearInterval(n)},_D=class{#t=pD;#e=!1;setTimeoutProvider(n){this.#t=n}setTimeout(n,e){return this.#t.setTimeout(n,e)}clearTimeout(n){this.#t.clearTimeout(n)}setInterval(n,e){return this.#t.setInterval(n,e)}clearInterval(n){this.#t.clearInterval(n)}},Lo=new _D;function gD(n){setTimeout(n,0)}var Bo=typeof window>"u"||"Deno"in globalThis;function _s(){}function mD(n,e){return typeof n=="function"?n(e):n}function qg(n){return typeof n=="number"&&n>=0&&n!==1/0}function yA(n,e){return Math.max(n+(e||0)-Date.now(),0)}function Ya(n,e){return typeof n=="function"?n(e):n}function Rr(n,e){return typeof n=="function"?n(e):n}function qx(n,e){const{type:t="all",exact:i,fetchStatus:s,predicate:r,queryKey:a,stale:o}=n;if(a){if(i){if(e.queryHash!==qm(a,e.options))return!1}else if(!Eh(e.queryKey,a))return!1}if(t!=="all"){const c=e.isActive();if(t==="active"&&!c||t==="inactive"&&c)return!1}return!(typeof o=="boolean"&&e.isStale()!==o||s&&s!==e.state.fetchStatus||r&&!r(e))}function Zx(n,e){const{exact:t,status:i,predicate:s,mutationKey:r}=n;if(r){if(!e.options.mutationKey)return!1;if(t){if(Ka(e.options.mutationKey)!==Ka(r))return!1}else if(!Eh(e.options.mutationKey,r))return!1}return!(i&&e.state.status!==i||s&&!s(e))}function qm(n,e){return(e?.queryKeyHashFn||Ka)(n)}function Ka(n){return JSON.stringify(n,(e,t)=>Zg(t)?Object.keys(t).sort().reduce((i,s)=>(i[s]=t[s],i),{}):t)}function Eh(n,e){return n===e?!0:typeof n!=typeof e?!1:n&&e&&typeof n=="object"&&typeof e=="object"?Object.keys(e).every(t=>Eh(n[t],e[t])):!1}var bD=Object.prototype.hasOwnProperty;function Zm(n,e){if(n===e)return n;const t=$x(n)&&$x(e);if(!t&&!(Zg(n)&&Zg(e)))return e;const s=(t?n:Object.keys(n)).length,r=t?e:Object.keys(e),a=r.length,o=t?new Array(a):{};let c=0;for(let u=0;u<a;u++){const d=t?u:r[u],f=n[d],g=e[d];if(f===g){o[d]=f,(t?u<s:bD.call(n,d))&&c++;continue}if(f===null||g===null||typeof f!="object"||typeof g!="object"){o[d]=g;continue}const m=Zm(f,g);o[d]=m,m===f&&c++}return s===a&&c===s?n:o}function Ah(n,e){if(!e||Object.keys(n).length!==Object.keys(e).length)return!1;for(const t in n)if(n[t]!==e[t])return!1;return!0}function $x(n){return Array.isArray(n)&&n.length===Object.keys(n).length}function Zg(n){if(!Qx(n))return!1;const e=n.constructor;if(e===void 0)return!0;const t=e.prototype;return!(!Qx(t)||!t.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(n)!==Object.prototype)}function Qx(n){return Object.prototype.toString.call(n)==="[object Object]"}function yD(n){return new Promise(e=>{Lo.setTimeout(e,n)})}function $g(n,e,t){return typeof t.structuralSharing=="function"?t.structuralSharing(n,e):t.structuralSharing!==!1?Zm(n,e):e}function vD(n,e,t=0){const i=[...n,e];return t&&i.length>t?i.slice(1):i}function xD(n,e,t=0){const i=[e,...n];return t&&i.length>t?i.slice(0,-1):i}var sr=Symbol();function vA(n,e){return!n.queryFn&&e?.initialPromise?()=>e.initialPromise:!n.queryFn||n.queryFn===sr?()=>Promise.reject(new Error(`Missing queryFn: '${n.queryHash}'`)):n.queryFn}function xA(n,e){return typeof n=="function"?n(...e):!!n}var SD=class extends Wo{#t;#e;#i;constructor(){super(),this.#i=n=>{if(!Bo&&window.addEventListener){const e=()=>n();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#e||this.setEventListener(this.#i)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(n){this.#i=n,this.#e?.(),this.#e=n(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(n){this.#t!==n&&(this.#t=n,this.onFocus())}onFocus(){const n=this.isFocused();this.listeners.forEach(e=>{e(n)})}isFocused(){return typeof this.#t=="boolean"?this.#t:globalThis.document?.visibilityState!=="hidden"}},$m=new SD;function Qg(){let n,e;const t=new Promise((s,r)=>{n=s,e=r});t.status="pending",t.catch(()=>{});function i(s){Object.assign(t,s),delete t.resolve,delete t.reject}return t.resolve=s=>{i({status:"fulfilled",value:s}),n(s)},t.reject=s=>{i({status:"rejected",reason:s}),e(s)},t}var TD=gD;function ED(){let n=[],e=0,t=o=>{o()},i=o=>{o()},s=TD;const r=o=>{e?n.push(o):s(()=>{t(o)})},a=()=>{const o=n;n=[],o.length&&s(()=>{i(()=>{o.forEach(c=>{t(c)})})})};return{batch:o=>{let c;e++;try{c=o()}finally{e--,e||a()}return c},batchCalls:o=>(...c)=>{r(()=>{o(...c)})},schedule:r,setNotifyFunction:o=>{t=o},setBatchNotifyFunction:o=>{i=o},setScheduler:o=>{s=o}}}var Ri=ED(),AD=class extends Wo{#t=!0;#e;#i;constructor(){super(),this.#i=n=>{if(!Bo&&window.addEventListener){const e=()=>n(!0),t=()=>n(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",t,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",t)}}}}onSubscribe(){this.#e||this.setEventListener(this.#i)}onUnsubscribe(){this.hasListeners()||(this.#e?.(),this.#e=void 0)}setEventListener(n){this.#i=n,this.#e?.(),this.#e=n(this.setOnline.bind(this))}setOnline(n){this.#t!==n&&(this.#t=n,this.listeners.forEach(t=>{t(n)}))}isOnline(){return this.#t}},zd=new AD;function RD(n){return Math.min(1e3*2**n,3e4)}function SA(n){return(n??"online")==="online"?zd.isOnline():!0}var Jg=class extends Error{constructor(n){super("CancelledError"),this.revert=n?.revert,this.silent=n?.silent}};function TA(n){let e=!1,t=0,i;const s=Qg(),r=()=>s.status!=="pending",a=x=>{if(!r()){const v=new Jg(x);g(v),n.onCancel?.(v)}},o=()=>{e=!0},c=()=>{e=!1},u=()=>$m.isFocused()&&(n.networkMode==="always"||zd.isOnline())&&n.canRun(),d=()=>SA(n.networkMode)&&n.canRun(),f=x=>{r()||(i?.(),s.resolve(x))},g=x=>{r()||(i?.(),s.reject(x))},m=()=>new Promise(x=>{i=v=>{(r()||u())&&x(v)},n.onPause?.()}).then(()=>{i=void 0,r()||n.onContinue?.()}),b=()=>{if(r())return;let x;const v=t===0?n.initialPromise:void 0;try{x=v??n.fn()}catch(E){x=Promise.reject(E)}Promise.resolve(x).then(f).catch(E=>{if(r())return;const A=n.retry??(Bo?0:3),D=n.retryDelay??RD,I=typeof D=="function"?D(t,E):D,R=A===!0||typeof A=="number"&&t<A||typeof A=="function"&&A(t,E);if(e||!R){g(E);return}t++,n.onFail?.(t,E),yD(I).then(()=>u()?void 0:m()).then(()=>{e?g(E):b()})})};return{promise:s,status:()=>s.status,cancel:a,continue:()=>(i?.(),s),cancelRetry:o,continueRetry:c,canStart:d,start:()=>(d()?b():m().then(b),s)}}var EA=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),qg(this.gcTime)&&(this.#t=Lo.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(n){this.gcTime=Math.max(this.gcTime||0,n??(Bo?1/0:300*1e3))}clearGcTimeout(){this.#t&&(Lo.clearTimeout(this.#t),this.#t=void 0)}},MD=class extends EA{#t;#e;#i;#r;#s;#n;#o;constructor(n){super(),this.#o=!1,this.#n=n.defaultOptions,this.setOptions(n.options),this.observers=[],this.#r=n.client,this.#i=this.#r.getQueryCache(),this.queryKey=n.queryKey,this.queryHash=n.queryHash,this.#t=Jx(this.options),this.state=n.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#s?.promise}setOptions(n){if(this.options={...this.#n,...n},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=Jx(this.options);e.data!==void 0&&(this.setData(e.data,{updatedAt:e.dataUpdatedAt,manual:!0}),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#i.remove(this)}setData(n,e){const t=$g(this.state.data,n,this.options);return this.#a({data:t,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),t}setState(n,e){this.#a({type:"setState",state:n,setStateOptions:e})}cancel(n){const e=this.#s?.promise;return this.#s?.cancel(n),e?e.then(_s).catch(_s):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(n=>Rr(n.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===sr||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(n=>Ya(n.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(n=>n.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(n=0){return this.state.data===void 0?!0:n==="static"?!1:this.state.isInvalidated?!0:!yA(this.state.dataUpdatedAt,n)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#s?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#s?.continue()}addObserver(n){this.observers.includes(n)||(this.observers.push(n),this.clearGcTimeout(),this.#i.notify({type:"observerAdded",query:this,observer:n}))}removeObserver(n){this.observers.includes(n)&&(this.observers=this.observers.filter(e=>e!==n),this.observers.length||(this.#s&&(this.#o?this.#s.cancel({revert:!0}):this.#s.cancelRetry()),this.scheduleGc()),this.#i.notify({type:"observerRemoved",query:this,observer:n}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#a({type:"invalidate"})}async fetch(n,e){if(this.state.fetchStatus!=="idle"&&this.#s?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#s)return this.#s.continueRetry(),this.#s.promise}if(n&&this.setOptions(n),!this.options.queryFn){const o=this.observers.find(c=>c.options.queryFn);o&&this.setOptions(o.options)}const t=new AbortController,i=o=>{Object.defineProperty(o,"signal",{enumerable:!0,get:()=>(this.#o=!0,t.signal)})},s=()=>{const o=vA(this.options,e),u=(()=>{const d={client:this.#r,queryKey:this.queryKey,meta:this.meta};return i(d),d})();return this.#o=!1,this.options.persister?this.options.persister(o,u,this):o(u)},a=(()=>{const o={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:s};return i(o),o})();this.options.behavior?.onFetch(a,this),this.#e=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#a({type:"fetch",meta:a.fetchOptions?.meta}),this.#s=TA({initialPromise:e?.initialPromise,fn:a.fetchFn,onCancel:o=>{o instanceof Jg&&o.revert&&this.setState({...this.#e,fetchStatus:"idle"}),t.abort()},onFail:(o,c)=>{this.#a({type:"failed",failureCount:o,error:c})},onPause:()=>{this.#a({type:"pause"})},onContinue:()=>{this.#a({type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{const o=await this.#s.start();if(o===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(o),this.#i.config.onSuccess?.(o,this),this.#i.config.onSettled?.(o,this.state.error,this),o}catch(o){if(o instanceof Jg){if(o.silent)return this.#s.promise;if(o.revert){if(this.state.data===void 0)throw o;return this.state.data}}throw this.#a({type:"error",error:o}),this.#i.config.onError?.(o,this),this.#i.config.onSettled?.(this.state.data,o,this),o}finally{this.scheduleGc()}}#a(n){const e=t=>{switch(n.type){case"failed":return{...t,fetchFailureCount:n.failureCount,fetchFailureReason:n.error};case"pause":return{...t,fetchStatus:"paused"};case"continue":return{...t,fetchStatus:"fetching"};case"fetch":return{...t,...AA(t.data,this.options),fetchMeta:n.meta??null};case"success":const i={...t,data:n.data,dataUpdateCount:t.dataUpdateCount+1,dataUpdatedAt:n.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!n.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#e=n.manual?i:void 0,i;case"error":const s=n.error;return{...t,error:s,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error"};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...n.state}}};this.state=e(this.state),Ri.batch(()=>{this.observers.forEach(t=>{t.onQueryUpdate()}),this.#i.notify({query:this,type:"updated",action:n})})}};function AA(n,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:SA(e.networkMode)?"fetching":"paused",...n===void 0&&{error:null,status:"pending"}}}function Jx(n){const e=typeof n.initialData=="function"?n.initialData():n.initialData,t=e!==void 0,i=t?typeof n.initialDataUpdatedAt=="function"?n.initialDataUpdatedAt():n.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:t?i??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:t?"success":"pending",fetchStatus:"idle"}}var Gh=class extends Wo{constructor(n,e){super(),this.options=e,this.#t=n,this.#a=null,this.#o=Qg(),this.bindMethods(),this.setOptions(e)}#t;#e=void 0;#i=void 0;#r=void 0;#s;#n;#o;#a;#f;#u;#d;#c;#h;#l;#_=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),eS(this.#e,this.options)?this.#p():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return em(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return em(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),this.#x(),this.#e.removeObserver(this)}setOptions(n){const e=this.options,t=this.#e;if(this.options=this.#t.defaultQueryOptions(n),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Rr(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#S(),this.#e.setOptions(this.options),e._defaulted&&!Ah(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const i=this.hasListeners();i&&tS(this.#e,t,this.options,e)&&this.#p(),this.updateResult(),i&&(this.#e!==t||Rr(this.options.enabled,this.#e)!==Rr(e.enabled,this.#e)||Ya(this.options.staleTime,this.#e)!==Ya(e.staleTime,this.#e))&&this.#g();const s=this.#m();i&&(this.#e!==t||Rr(this.options.enabled,this.#e)!==Rr(e.enabled,this.#e)||s!==this.#l)&&this.#b(s)}getOptimisticResult(n){const e=this.#t.getQueryCache().build(this.#t,n),t=this.createResult(e,n);return ID(this,t)&&(this.#r=t,this.#n=this.options,this.#s=this.#e.state),t}getCurrentResult(){return this.#r}trackResult(n,e){return new Proxy(n,{get:(t,i)=>(this.trackProp(i),e?.(i),i==="promise"&&!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),Reflect.get(t,i))})}trackProp(n){this.#_.add(n)}getCurrentQuery(){return this.#e}refetch({...n}={}){return this.fetch({...n})}fetchOptimistic(n){const e=this.#t.defaultQueryOptions(n),t=this.#t.getQueryCache().build(this.#t,e);return t.fetch().then(()=>this.createResult(t,e))}fetch(n){return this.#p({...n,cancelRefetch:n.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#p(n){this.#S();let e=this.#e.fetch(this.options,n);return n?.throwOnError||(e=e.catch(_s)),e}#g(){this.#v();const n=Ya(this.options.staleTime,this.#e);if(Bo||this.#r.isStale||!qg(n))return;const t=yA(this.#r.dataUpdatedAt,n)+1;this.#c=Lo.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#m(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(n){this.#x(),this.#l=n,!(Bo||Rr(this.options.enabled,this.#e)===!1||!qg(this.#l)||this.#l===0)&&(this.#h=Lo.setInterval(()=>{(this.options.refetchIntervalInBackground||$m.isFocused())&&this.#p()},this.#l))}#y(){this.#g(),this.#b(this.#m())}#v(){this.#c&&(Lo.clearTimeout(this.#c),this.#c=void 0)}#x(){this.#h&&(Lo.clearInterval(this.#h),this.#h=void 0)}createResult(n,e){const t=this.#e,i=this.options,s=this.#r,r=this.#s,a=this.#n,c=n!==t?n.state:this.#i,{state:u}=n;let d={...u},f=!1,g;if(e._optimisticResults){const F=this.hasListeners(),U=!F&&eS(n,e),k=F&&tS(n,t,e,i);(U||k)&&(d={...d,...AA(u.data,n.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:m,errorUpdatedAt:b,status:x}=d;g=d.data;let v=!1;if(e.placeholderData!==void 0&&g===void 0&&x==="pending"){let F;s?.isPlaceholderData&&e.placeholderData===a?.placeholderData?(F=s.data,v=!0):F=typeof e.placeholderData=="function"?e.placeholderData(this.#d?.state.data,this.#d):e.placeholderData,F!==void 0&&(x="success",g=$g(s?.data,F,e),f=!0)}if(e.select&&g!==void 0&&!v)if(s&&g===r?.data&&e.select===this.#f)g=this.#u;else try{this.#f=e.select,g=e.select(g),g=$g(s?.data,g,e),this.#u=g,this.#a=null}catch(F){this.#a=F}this.#a&&(m=this.#a,g=this.#u,b=Date.now(),x="error");const E=d.fetchStatus==="fetching",A=x==="pending",D=x==="error",I=A&&E,R=g!==void 0,M={status:x,fetchStatus:d.fetchStatus,isPending:A,isSuccess:x==="success",isError:D,isInitialLoading:I,isLoading:I,data:g,dataUpdatedAt:d.dataUpdatedAt,error:m,errorUpdatedAt:b,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:E,isRefetching:E&&!A,isLoadingError:D&&!R,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:D&&R,isStale:Qm(n,e),refetch:this.refetch,promise:this.#o,isEnabled:Rr(e.enabled,n)!==!1};if(this.options.experimental_prefetchInRender){const F=q=>{M.status==="error"?q.reject(M.error):M.data!==void 0&&q.resolve(M.data)},U=()=>{const q=this.#o=M.promise=Qg();F(q)},k=this.#o;switch(k.status){case"pending":n.queryHash===t.queryHash&&F(k);break;case"fulfilled":(M.status==="error"||M.data!==k.value)&&U();break;case"rejected":(M.status!=="error"||M.error!==k.reason)&&U();break}}return M}updateResult(){const n=this.#r,e=this.createResult(this.#e,this.options);if(this.#s=this.#e.state,this.#n=this.options,this.#s.data!==void 0&&(this.#d=this.#e),Ah(e,n))return;this.#r=e;const t=()=>{if(!n)return!0;const{notifyOnChangeProps:i}=this.options,s=typeof i=="function"?i():i;if(s==="all"||!s&&!this.#_.size)return!0;const r=new Set(s??this.#_);return this.options.throwOnError&&r.add("error"),Object.keys(this.#r).some(a=>{const o=a;return this.#r[o]!==n[o]&&r.has(o)})};this.#T({listeners:t()})}#S(){const n=this.#t.getQueryCache().build(this.#t,this.options);if(n===this.#e)return;const e=this.#e;this.#e=n,this.#i=n.state,this.hasListeners()&&(e?.removeObserver(this),n.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#T(n){Ri.batch(()=>{n.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function CD(n,e){return Rr(e.enabled,n)!==!1&&n.state.data===void 0&&!(n.state.status==="error"&&e.retryOnMount===!1)}function eS(n,e){return CD(n,e)||n.state.data!==void 0&&em(n,e,e.refetchOnMount)}function em(n,e,t){if(Rr(e.enabled,n)!==!1&&Ya(e.staleTime,n)!=="static"){const i=typeof t=="function"?t(n):t;return i==="always"||i!==!1&&Qm(n,e)}return!1}function tS(n,e,t,i){return(n!==e||Rr(i.enabled,n)===!1)&&(!t.suspense||n.state.status!=="error")&&Qm(n,t)}function Qm(n,e){return Rr(e.enabled,n)!==!1&&n.isStaleByTime(Ya(e.staleTime,n))}function ID(n,e){return!Ah(n.getCurrentResult(),e)}function Gd(n){return{onFetch:(e,t)=>{const i=e.options,s=e.fetchOptions?.meta?.fetchMore?.direction,r=e.state.data?.pages||[],a=e.state.data?.pageParams||[];let o={pages:[],pageParams:[]},c=0;const u=async()=>{let d=!1;const f=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},g=vA(e.options,e.fetchOptions),m=async(b,x,v)=>{if(d)return Promise.reject();if(x==null&&b.pages.length)return Promise.resolve(b);const A=(()=>{const C={client:e.client,queryKey:e.queryKey,pageParam:x,direction:v?"backward":"forward",meta:e.options.meta};return f(C),C})(),D=await g(A),{maxPages:I}=e.options,R=v?xD:vD;return{pages:R(b.pages,D,I),pageParams:R(b.pageParams,x,I)}};if(s&&r.length){const b=s==="backward",x=b?RA:tm,v={pages:r,pageParams:a},E=x(i,v);o=await m(v,E,b)}else{const b=n??r.length;do{const x=c===0?a[0]??i.initialPageParam:tm(i,o);if(c>0&&x==null)break;o=await m(o,x),c++}while(c<b)}return o};e.options.persister?e.fetchFn=()=>e.options.persister?.(u,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},t):e.fetchFn=u}}}function tm(n,{pages:e,pageParams:t}){const i=e.length-1;return e.length>0?n.getNextPageParam(e[i],e,t[i],t):void 0}function RA(n,{pages:e,pageParams:t}){return e.length>0?n.getPreviousPageParam?.(e[0],e,t[0],t):void 0}function PD(n,e){return e?tm(n,e)!=null:!1}function DD(n,e){return!e||!n.getPreviousPageParam?!1:RA(n,e)!=null}var MA=class extends Gh{constructor(n,e){super(n,e)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(n){super.setOptions({...n,behavior:Gd()})}getOptimisticResult(n){return n.behavior=Gd(),super.getOptimisticResult(n)}fetchNextPage(n){return this.fetch({...n,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(n){return this.fetch({...n,meta:{fetchMore:{direction:"backward"}}})}createResult(n,e){const{state:t}=n,i=super.createResult(n,e),{isFetching:s,isRefetching:r,isError:a,isRefetchError:o}=i,c=t.fetchMeta?.fetchMore?.direction,u=a&&c==="forward",d=s&&c==="forward",f=a&&c==="backward",g=s&&c==="backward";return{...i,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:PD(e,t.data),hasPreviousPage:DD(e,t.data),isFetchNextPageError:u,isFetchingNextPage:d,isFetchPreviousPageError:f,isFetchingPreviousPage:g,isRefetchError:o&&!u&&!f,isRefetching:r&&!d&&!g}}},OD=class extends EA{#t;#e;#i;#r;constructor(n){super(),this.#t=n.client,this.mutationId=n.mutationId,this.#i=n.mutationCache,this.#e=[],this.state=n.state||CA(),this.setOptions(n.options),this.scheduleGc()}setOptions(n){this.options=n,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(n){this.#e.includes(n)||(this.#e.push(n),this.clearGcTimeout(),this.#i.notify({type:"observerAdded",mutation:this,observer:n}))}removeObserver(n){this.#e=this.#e.filter(e=>e!==n),this.scheduleGc(),this.#i.notify({type:"observerRemoved",mutation:this,observer:n})}optionalRemove(){this.#e.length||(this.state.status==="pending"?this.scheduleGc():this.#i.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(n){const e=()=>{this.#s({type:"continue"})},t={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=TA({fn:()=>this.options.mutationFn?this.options.mutationFn(n,t):Promise.reject(new Error("No mutationFn found")),onFail:(r,a)=>{this.#s({type:"failed",failureCount:r,error:a})},onPause:()=>{this.#s({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#i.canRun(this)});const i=this.state.status==="pending",s=!this.#r.canStart();try{if(i)e();else{this.#s({type:"pending",variables:n,isPaused:s}),await this.#i.config.onMutate?.(n,this,t);const a=await this.options.onMutate?.(n,t);a!==this.state.context&&this.#s({type:"pending",context:a,variables:n,isPaused:s})}const r=await this.#r.start();return await this.#i.config.onSuccess?.(r,n,this.state.context,this,t),await this.options.onSuccess?.(r,n,this.state.context,t),await this.#i.config.onSettled?.(r,null,this.state.variables,this.state.context,this,t),await this.options.onSettled?.(r,null,n,this.state.context,t),this.#s({type:"success",data:r}),r}catch(r){try{throw await this.#i.config.onError?.(r,n,this.state.context,this,t),await this.options.onError?.(r,n,this.state.context,t),await this.#i.config.onSettled?.(void 0,r,this.state.variables,this.state.context,this,t),await this.options.onSettled?.(void 0,r,n,this.state.context,t),r}finally{this.#s({type:"error",error:r})}}finally{this.#i.runNext(this)}}#s(n){const e=t=>{switch(n.type){case"failed":return{...t,failureCount:n.failureCount,failureReason:n.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};case"pending":return{...t,context:n.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:n.isPaused,status:"pending",variables:n.variables,submittedAt:Date.now()};case"success":return{...t,data:n.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:n.error,failureCount:t.failureCount+1,failureReason:n.error,isPaused:!1,status:"error"}}};this.state=e(this.state),Ri.batch(()=>{this.#e.forEach(t=>{t.onMutationUpdate(n)}),this.#i.notify({mutation:this,type:"updated",action:n})})}};function CA(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var wD=class extends Wo{constructor(n={}){super(),this.config=n,this.#t=new Set,this.#e=new Map,this.#i=0}#t;#e;#i;build(n,e,t){const i=new OD({client:n,mutationCache:this,mutationId:++this.#i,options:n.defaultMutationOptions(e),state:t});return this.add(i),i}add(n){this.#t.add(n);const e=gd(n);if(typeof e=="string"){const t=this.#e.get(e);t?t.push(n):this.#e.set(e,[n])}this.notify({type:"added",mutation:n})}remove(n){if(this.#t.delete(n)){const e=gd(n);if(typeof e=="string"){const t=this.#e.get(e);if(t)if(t.length>1){const i=t.indexOf(n);i!==-1&&t.splice(i,1)}else t[0]===n&&this.#e.delete(e)}}this.notify({type:"removed",mutation:n})}canRun(n){const e=gd(n);if(typeof e=="string"){const i=this.#e.get(e)?.find(s=>
10s.state.status==="pending");return!i||i===n}else return!0}runNext(n){const e=gd(n);return typeof e=="string"?this.#e.get(e)?.find(i=>i!==n&&i.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Ri.batch(()=>{this.#t.forEach(n=>{this.notify({type:"removed",mutation:n})}),this.#t.clear(),this.#e.clear()})}getAll(){return Array.from(this.#t)}find(n){const e={exact:!0,...n};return this.getAll().find(t=>Zx(e,t))}findAll(n={}){return this.getAll().filter(e=>Zx(n,e))}notify(n){Ri.batch(()=>{this.listeners.forEach(e=>{e(n)})})}resumePausedMutations(){const n=this.getAll().filter(e=>e.state.isPaused);return Ri.batch(()=>Promise.all(n.map(e=>e.continue().catch(_s))))}};function gd(n){return n.options.scope?.id}var FD=class extends Wo{#t;#e=void 0;#i;#r;constructor(e,t){super(),this.#t=e,this.setOptions(t),this.bindMethods(),this.#s()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const t=this.options;this.options=this.#t.defaultMutationOptions(e),Ah(this.options,t)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#i,observer:this}),t?.mutationKey&&this.options.mutationKey&&Ka(t.mutationKey)!==Ka(this.options.mutationKey)?this.reset():this.#i?.state.status==="pending"&&this.#i.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#i?.removeObserver(this)}onMutationUpdate(e){this.#s(),this.#n(e)}getCurrentResult(){return this.#e}reset(){this.#i?.removeObserver(this),this.#i=void 0,this.#s(),this.#n()}mutate(e,t){return this.#r=t,this.#i?.removeObserver(this),this.#i=this.#t.getMutationCache().build(this.#t,this.options),this.#i.addObserver(this),this.#i.execute(e)}#s(){const e=this.#i?.state??CA();this.#e={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#n(e){Ri.batch(()=>{if(this.#r&&this.hasListeners()){const t=this.#e.variables,i=this.#e.context,s={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};e?.type==="success"?(this.#r.onSuccess?.(e.data,t,i,s),this.#r.onSettled?.(e.data,null,t,i,s)):e?.type==="error"&&(this.#r.onError?.(e.error,t,i,s),this.#r.onSettled?.(void 0,e.error,t,i,s))}this.listeners.forEach(t=>{t(this.#e)})})}};function iS(n,e){const t=new Set(e);return n.filter(i=>!t.has(i))}function LD(n,e,t){const i=n.slice(0);return i[e]=t,i}var ND=class extends Wo{#t;#e;#i;#r;#s;#n;#o;#a;#f=[];constructor(n,e,t){super(),this.#t=n,this.#r=t,this.#i=[],this.#s=[],this.#e=[],this.setQueries(e)}onSubscribe(){this.listeners.size===1&&this.#s.forEach(n=>{n.subscribe(e=>{this.#h(n,e)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#s.forEach(n=>{n.destroy()})}setQueries(n,e){this.#i=n,this.#r=e,Ri.batch(()=>{const t=this.#s,i=this.#c(this.#i);this.#f=i,i.forEach(d=>d.observer.setOptions(d.defaultedQueryOptions));const s=i.map(d=>d.observer),r=s.map(d=>d.getCurrentResult()),a=t.length!==s.length,o=s.some((d,f)=>d!==t[f]),c=a||o,u=c?!0:r.some((d,f)=>{const g=this.#e[f];return!g||!Ah(d,g)});!c&&!u||(c&&(this.#s=s),this.#e=r,this.hasListeners()&&(c&&(iS(t,s).forEach(d=>{d.destroy()}),iS(s,t).forEach(d=>{d.subscribe(f=>{this.#h(d,f)})})),this.#l()))})}getCurrentResult(){return this.#e}getQueries(){return this.#s.map(n=>n.getCurrentQuery())}getObservers(){return this.#s}getOptimisticResult(n,e){const t=this.#c(n),i=t.map(s=>s.observer.getOptimisticResult(s.defaultedQueryOptions));return[i,s=>this.#d(s??i,e),()=>this.#u(i,t)]}#u(n,e){return e.map((t,i)=>{const s=n[i];return t.defaultedQueryOptions.notifyOnChangeProps?s:t.observer.trackResult(s,r=>{e.forEach(a=>{a.observer.trackProp(r)})})})}#d(n,e){return e?((!this.#n||this.#e!==this.#a||e!==this.#o)&&(this.#o=e,this.#a=this.#e,this.#n=Zm(this.#n,e(n))),this.#n):n}#c(n){const e=new Map(this.#s.map(i=>[i.options.queryHash,i])),t=[];return n.forEach(i=>{const s=this.#t.defaultQueryOptions(i),r=e.get(s.queryHash);r?t.push({defaultedQueryOptions:s,observer:r}):t.push({defaultedQueryOptions:s,observer:new Gh(this.#t,s)})}),t}#h(n,e){const t=this.#s.indexOf(n);t!==-1&&(this.#e=LD(this.#e,t,e),this.#l())}#l(){if(this.hasListeners()){const n=this.#n,e=this.#u(this.#e,this.#f),t=this.#d(e,this.#r?.combine);n!==t&&Ri.batch(()=>
vendor: 14,403 bytes, lines 10-18
10{this.listeners.forEach(i=>{i(this.#e)})})}}},BD=class extends Wo{constructor(n={}){super(),this.config=n,this.#t=new Map}#t;build(n,e,t){const i=e.queryKey,s=e.queryHash??qm(i,e);let r=this.get(s);return r||(r=new MD({client:n,queryKey:i,queryHash:s,options:n.defaultQueryOptions(e),state:t,defaultOptions:n.getQueryDefaults(i)}),this.add(r)),r}add(n){this.#t.has(n.queryHash)||(this.#t.set(n.queryHash,n),this.notify({type:"added",query:n}))}remove(n){const e=this.#t.get(n.queryHash);e&&(n.destroy(),e===n&&this.#t.delete(n.queryHash),this.notify({type:"removed",query:n}))}clear(){Ri.batch(()=>{this.getAll().forEach(n=>{this.remove(n)})})}get(n){return this.#t.get(n)}getAll(){return[...this.#t.values()]}find(n){const e={exact:!0,...n};return this.getAll().find(t=>qx(e,t))}findAll(n={}){const e=this.getAll();return Object.keys(n).length>0?e.filter(t=>qx(n,t)):e}notify(n){Ri.batch(()=>{this.listeners.forEach(e=>{e(n)})})}onFocus(){Ri.batch(()=>{this.getAll().forEach(n=>{n.onFocus()})})}onOnline(){Ri.batch(()=>{this.getAll().forEach(n=>{n.onOnline()})})}},UD=class{#t;#e;#i;#r;#s;#n;#o;#a;constructor(n={}){this.#t=n.queryCache||new BD,this.#e=n.mutationCache||new wD,this.#i=n.defaultOptions||{},this.#r=new Map,this.#s=new Map,this.#n=0}mount(){this.#n++,this.#n===1&&(this.#o=$m.subscribe(async n=>{n&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#a=zd.subscribe(async n=>{n&&(await this.resumePausedMutations(),this.#t.onOnline())}))}unmount(){this.#n--,this.#n===0&&(this.#o?.(),this.#o=void 0,this.#a?.(),this.#a=void 0)}isFetching(n){return this.#t.findAll({...n,fetchStatus:"fetching"}).length}isMutating(n){return this.#e.findAll({...n,status:"pending"}).length}getQueryData(n){const e=this.defaultQueryOptions({queryKey:n});return this.#t.get(e.queryHash)?.state.data}ensureQueryData(n){const e=this.defaultQueryOptions(n),t=this.#t.build(this,e),i=t.state.data;return i===void 0?this.fetchQuery(n):(n.revalidateIfStale&&t.isStaleByTime(Ya(e.staleTime,t))&&this.prefetchQuery(e),Promise.resolve(i))}getQueriesData(n){return this.#t.findAll(n).map(({queryKey:e,state:t})=>{const i=t.data;return[e,i]})}setQueryData(n,e,t){const i=this.defaultQueryOptions({queryKey:n}),r=this.#t.get(i.queryHash)?.state.data,a=mD(e,r);if(a!==void 0)return this.#t.build(this,i).setData(a,{...t,manual:!0})}setQueriesData(n,e,t){return Ri.batch(()=>this.#t.findAll(n).map(({queryKey:i})=>[i,this.setQueryData(i,e,t)]))}getQueryState(n){const e=this.defaultQueryOptions({queryKey:n});return this.#t.get(e.queryHash)?.state}removeQueries(n){const e=this.#t;Ri.batch(()=>{e.findAll(n).forEach(t=>{e.remove(t)})})}resetQueries(n,e){const t=this.#t;return Ri.batch(()=>(t.findAll(n).forEach(i=>{i.reset()}),this.refetchQueries({type:"active",...n},e)))}cancelQueries(n,e={}){const t={revert:!0,...e},i=Ri.batch(()=>this.#t.findAll(n).map(s=>s.cancel(t)));return Promise.all(i).then(_s).catch(_s)}invalidateQueries(n,e={}){return Ri.batch(()=>(this.#t.findAll(n).forEach(t=>{t.invalidate()}),n?.refetchType==="none"?Promise.resolve():this.refetchQueries({...n,type:n?.refetchType??n?.type??"active"},e)))}refetchQueries(n,e={}){const t={...e,cancelRefetch:e.cancelRefetch??!0},i=Ri.batch(()=>this.#t.findAll(n).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let r=s.fetch(void 0,t);return t.throwOnError||(r=r.catch(_s)),s.state.fetchStatus==="paused"?Promise.resolve():r}));return Promise.all(i).then(_s)}fetchQuery(n){const e=this.defaultQueryOptions(n);e.retry===void 0&&(e.retry=!1);const t=this.#t.build(this,e);return t.isStaleByTime(Ya(e.staleTime,t))?t.fetch(e):Promise.resolve(t.state.data)}prefetchQuery(n){return this.fetchQuery(n).then(_s).catch(_s)}fetchInfiniteQuery(n){return n.behavior=Gd(n.pages),this.fetchQuery(n)}prefetchInfiniteQuery(n){return this.fetchInfiniteQuery(n).then(_s).catch(_s)}ensureInfiniteQueryData(n){return n.behavior=Gd(n.pages),this.ensureQueryData(n)}resumePausedMutations(){return zd.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#t}getMutationCache(){return this.#e}getDefaultOptions(){return this.#i}setDefaultOptions(n){this.#i=n}setQueryDefaults(n,e){this.#r.set(Ka(n),{queryKey:n,defaultOptions:e})}getQueryDefaults(n){const e=[...this.#r.values()],t={};return e.forEach(i=>{Eh(n,i.queryKey)&&Object.assign(t,i.defaultOptions)}),t}setMutationDefaults(n,e){this.#s.set(Ka(n),{mutationKey:n,defaultOptions:e})}getMutationDefaults(n){const e=[...this.#s.values()],t={};return e.forEach(i=>{Eh(n,i.mutationKey)&&Object.assign(t,i.defaultOptions)}),t}defaultQueryOptions(n){if(n._defaulted)return n;const e={...this.#i.queries,...this.getQueryDefaults(n.queryKey),...n,_defaulted:!0};return e.queryHash||(e.queryHash=qm(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===sr&&(e.enabled=!1),e}defaultMutationOptions(n){return n?._defaulted?n:{...this.#i.mutations,...n?.mutationKey&&this.getMutationDefaults(n.mutationKey),...n,_defaulted:!0}}clear(){this.#t.clear(),this.#e.clear()}},fg={exports:{}},gt={};/** 11 * @license React 12 * react.production.js 13 * 14 * Copyright (c) Meta Platforms, Inc. and affiliates. 15 * 16 * This source code is licensed under the MIT license found in the 17 * LICENSE file in the root directory of this source tree. 18 */var sS;function kD(){if(sS)return gt;sS=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),r=Symbol.for("react.consumer"),a=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),g=Symbol.iterator;function m(w){return w===null||typeof w!="object"?null:(w=g&&w[g]||w["@@iterator"],typeof w=="function"?w:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,v={};function E(w,L,V){this.props=w,this.context=L,this.refs=v,this.updater=V||b}E.prototype.isReactComponent={},E.prototype.setState=function(w,L){if(typeof w!="object"&&typeof w!="function"&&w!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,w,L,"setState")},E.prototype.forceUpdate=function(w){this.updater.enqueueForceUpdate(this,w,"forceUpdate")};function A(){}A.prototype=E.prototype;function D(w,L,V){this.props=w,this.context=L,this.refs=v,this.updater=V||b}var I=D.prototype=new A;I.constructor=D,x(I,E.prototype),I.isPureReactComponent=!0;var R=Array.isArray;function C(){}var M={H:null,A:null,T:null,S:null},F=Object.prototype.hasOwnProperty;function U(w,L,V){var j=V.ref;return{$$typeof:n,type:w,key:L,ref:j!==void 0?j:null,props:V}}function k(w,L){return U(w.type,L,w.props)}function q(w){return typeof w=="object"&&w!==null&&w.$$typeof===n}function Q(w){var L={"=":"=0",":":"=2"};return"$"+w.replace(/[=:]/g,function(V){return L[V]})}var ie=/\/+/g;function $(w,L){return typeof w=="object"&&w!==null&&w.key!=null?Q(""+w.key):L.toString(36)}function ce(w){switch(w.status){case"fulfilled":return w.value;case"rejected":throw w.reason;default:switch(typeof w.status=="string"?w.then(C,C):(w.status="pending",w.then(function(L){w.status==="pending"&&(w.status="fulfilled",w.value=L)},function(L){w.status==="pending"&&(w.status="rejected",w.reason=L)})),w.status){case"fulfilled":return w.value;case"rejected":throw w.reason}}throw w}function G(w,L,V,j,ae){var he=typeof w;(he==="undefined"||he==="boolean")&&(w=null);var be=!1;if(w===null)be=!0;else switch(he){case"bigint":case"string":case"number":be=!0;break;case"object":switch(w.$$typeof){case n:case e:be=!0;break;case d:return be=w._init,G(be(w._payload),L,V,j,ae)}}if(be)return ae=ae(w),be=j===""?"."+$(w,0):j,R(ae)?(V="",be!=null&&(V=be.replace(ie,"$&/")+"/"),G(ae,L,V,"",function(it){return it})):ae!=null&&(q(ae)&&(ae=k(ae,V+(ae.key==null||w&&w.key===ae.key?"":(""+ae.key).replace(ie,"$&/")+"/")+be)),L.push(ae)),1;be=0;var Le=j===""?".":j+":";if(R(w))for(var Xe=0;Xe<w.length;Xe++)j=w[Xe],he=Le+$(j,Xe),be+=G(j,L,V,he,ae);else if(Xe=m(w),typeof Xe=="function")for(w=Xe.call(w),Xe=0;!(j=w.next()).done;)j=j.value,he=Le+$(j,Xe++),be+=G(j,L,V,he,ae);else if(he==="object"){if(typeof w.then=="function")return G(ce(w),L,V,j,ae);throw L=String(w),Error("Objects are not valid as a React child (found: "+(L==="[object Object]"?"object with keys {"+Object.keys(w).join(", ")+"}":L)+"). If you meant to render a collection of children, use an array instead.")}return be}function K(w,L,V){if(w==null)return w;var j=[],ae=0;return G(w,j,"","",function(he){return L.call(V,he,ae++)}),j}function X(w){if(w._status===-1){var L=w._result;L=L(),L.then(function(V){(w._status===0||w._status===-1)&&(w._status=1,w._result=V)},function(V){(w._status===0||w._status===-1)&&(w._status=2,w._result=V)}),w._status===-1&&(w._status=0,w._result=L)}if(w._status===1)return w._result.default;throw w._result}var J=typeof reportError=="function"?reportError:function(w){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var L=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof w=="object"&&w!==null&&typeof w.message=="string"?String(w.message):String(w),error:w});if(!window.dispatchEvent(L))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",w);return}console.error(w)},se={map:K,forEach:function(w,L,V){K(w,function(){L.apply(this,arguments)},V)},count:function(w){var L=0;return K(w,function(){L++}),L},toArray:function(w){return K(w,function(L){return L})||[]},only:function(w){if(!q(w))throw Error("React.Children.only expected to receive a single React element child.");return w}};return gt.Activity=f,gt.Children=se,gt.Component=E,gt.Fragment=t,gt.Profiler=s,gt.PureComponent=D,gt.StrictMode=i,gt.Suspense=c,gt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=M,gt.__COMPILER_RUNTIME={__proto__:null,c:function(w){return M.H.useMemoCache(w)}},gt.cache=function(w){return function(){return w.apply(null,arguments)}},gt.cacheSignal=function(){return null},gt.cloneElement=function(w,L,V){if(w==null)throw Error("The argument must be a React element, but you passed "+w+".");var j=x({},w.props),ae=w.key;if(L!=null)for(he in L.key!==void 0&&(ae=""+L.key),L)!F.call(L,he)||he==="key"||he==="__self"||he==="__source"||he==="ref"&&L.ref===void 0||(j[he]=L[he]);var he=arguments.length-2;if(he===1)j.children=V;else if(1<he){for(var be=Array(he),Le=0;Le<he;Le++)be[Le]=arguments[Le+2];j.children=be}return U(w.type,ae,j)},gt.createContext=function(w){return w={$$typeof:a,_currentValue:w,_currentValue2:w,_threadCount:0,Provider:null,Consumer:null},w.Provider=w,w.Consumer={$$typeof:r,_context:w},w},gt.createElement=function(w,L,V){var j,ae={},he=null;if(L!=null)for(j in L.key!==void 0&&(he=""+L.key),L)F.call(L,j)&&j!=="key"&&j!=="__self"&&j!=="__source"&&(ae[j]=L[j]);var be=arguments.length-2;if(be===1)ae.children=V;else if(1<be){for(var Le=Array(be),Xe=0;Xe<be;Xe++)Le[Xe]=arguments[Xe+2];ae.children=Le}if(w&&w.defaultProps)for(j in be=w.defaultProps,be)ae[j]===void 0&&(ae[j]=be[j]);return U(w,he,ae)},gt.createRef=function(){return{current:null}},gt.forwardRef=function(w){return{$$typeof:o,render:w}},gt.isValidElement=q,gt.lazy=function(w){return{$$typeof:d,_payload:{_status:-1,_result:w},_init:X}},gt.memo=function(w,L){return{$$typeof:u,type:w,compare:L===void 0?null:L}},gt.startTransition=function(w){var L=M.T,V={};M.T=V;try{var j=w(),ae=M.S;ae!==null&&ae(V,j),typeof j=="object"&&j!==null&&typeof j.then=="function"&&j.then(C,J)}catch(he){J(he)}finally{L!==null&&V.types!==null&&(L.types=V.types),M.T=L}},gt.unstable_useCacheRefresh=function(){return M.H.useCacheRefresh()},gt.use=function(w){return M.H.use(w)},gt.useActionState=function(w,L,V){return M.H.useActionState(w,L,V)},gt.useCallback=function(w,L){return M.H.useCallback(w,L)},gt.useContext=function(w){return M.H.useContext(w)},gt.useDebugValue=function(){},gt.useDeferredValue=function(w,L){return M.H.useDeferredValue(w,L)},gt.useEffect=function(w,L){return M.H.useEffect(w,L)},gt.useEffectEvent=function(w){return M.H.useEffectEvent(w)},gt.useId=function(){return M.H.useId()},gt.useImperativeHandle=function(w,L,V){return M.H.useImperativeHandle(w,L,V)},gt.useInsertionEffect=function(w,L){return M.H.useInsertionEffect(w,L)},gt.useLayoutEffect=function(w,L){return M.H.useLayoutEffect(w,L)},gt.useMemo=function(w,L){return M.H.useMemo(w,L)},gt.useOptimistic=function(w,L){return M.H.useOptimistic(w,L)},gt.useReducer=function(w,L,V){return M.H.useReducer(w,L,V)},gt.useRef=function(w){return M.H.useRef(w)},gt.useState=function(w){return M.H.useState(w)},gt.useSyncExternalStore=function(w,L,V){return M.H.useSyncExternalStore(w,L,V)},gt.useTransition=function(){return M.H.useTransition()},gt.version="19.2.1",gt}var rS;function gf(){return rS||(rS=1,fg.exports=kD()),fg.exports}var Y=gf();const Ue=bA(Y),Jm=uD({__proto__:null,default:Ue},[Y]);var IA=Y.createContext(void 0),Hh=n=>{const e=Y.useContext(IA);if(n)return n;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},VD=({client:n,children:e})=>(Y.useEffect(()=>(n.mount(),()=>{n.unmount()}),[n]),B.jsx(IA.Provider,{value:n,children:e})),PA=Y.createContext(!1),DA=()=>Y.useContext(PA);PA.Provider;function zD(){let n=!1;return{clearReset:()=>{n=!1},reset:()=>{n=!0},isReset:()=>n}}var GD=Y.createContext(zD()),OA=()=>Y.useContext(GD),wA=(n,e)=>{(n.suspense||n.throwOnError||n.experimental_prefetchInRender)&&(e.isReset()||(n.retryOnMount=!1))},FA=n=>{Y.useEffect(()=>{n.clearReset()},[n])},LA=({result:n,errorResetBoundary:e,throwOnError:t,query:i,suspense:s})=>n.isError&&!e.isReset()&&!n.isFetching&&i&&(s&&n.data===void 0||xA(t,[n.error,i])),eb=(n,e)=>e.state.data===void 0,NA=n=>{if(n.suspense){const t=s=>s==="static"?s:Math.max(s??1e3,1e3),i=n.staleTime;n.staleTime=typeof i=="function"?(...s)=>t(i(...s)):t(i),typeof n.gcTime=="number"&&(n.gcTime=Math.max(n.gcTime,1e3))}},BA=(n,e)=>n.isLoading&&n.isFetching&&!e,im=(n,e)=>n?.suspense&&e.isPending,Hd=(n,e,t)=>e.fetchOptimistic(n).catch(()=>{t.clearReset()});function UA({queries:n,...e}
18,t){const i=Hh(t),s=DA(),r=OA(),a=Y.useMemo(()=>n.map(x=>{const v=i.defaultQueryOptions(x);return v._optimisticResults=s?"isRestoring":"optimistic",v}),[n,i,s]);a.forEach(x=>{NA(x),wA(x,r)}),FA(r);const[o]=Y.useState(()=>new ND(i,a,e)),[c,u,d]=o.getOptimisticResult(a,e.combine),f=!s&&e.subscribed!==!1;Y.useSyncExternalStore(Y.useCallback(x=>f?o.subscribe(Ri.batchCalls(x)):_s,[o,f]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),Y.useEffect(()=>{o.setQueries(a,e)},[a,e,o]);const m=c.some((x,v)=>im(a[v],x))?c.flatMap((x,v)=>{const E=a[v];if(E){const A=new Gh(i,E);if(im(E,x))return Hd(E,A,r);BA(x,s)&&Hd(E,A,r)}return[]}):[];if(m.length>0)throw Promise.all(m);const b=c.find((x,v)=>{const E=a[v];return E&&LA({result:x,errorResetBoundary:r,throwOnError:E.throwOnError,query:i.getQueryCache().get(E.queryHash),suspense:E.suspense})});if(b?.error)throw b.error;return u(d())}function mf(n,e,t){const i=DA(),s=OA(),r=Hh(t),a=r.defaultQueryOptions(n);r.getDefaultOptions().queries?._experimental_beforeQuery?.(a),a._optimisticResults=i?"isRestoring":"optimistic",NA(a),wA(a,s),FA(s);const o=!r.getQueryCache().get(a.queryHash),[c]=Y.useState(()=>new e(r,a)),u=c.getOptimisticResult(a),d=!i&&n.subscribed!==!1;if(Y.useSyncExternalStore(Y.useCallback(f=>{const g=d?c.subscribe(Ri.batchCalls(f)):_s;return c.updateResult(),g},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),Y.useEffect(()=>{c.setOptions(a)},[a,c]),im(a,u))throw Hd(a,c,s);if(LA({result:u,errorResetBoundary:s,throwOnError:a.throwOnError,query:r.getQueryCache().get(a.queryHash),suspense:a.suspense}))throw u.error;return r.getDefaultOptions().queries?._experimental_afterQuery?.(a,u),a.experimental_prefetchInRender&&!Bo&&BA(u,i)&&(o?Hd(a,c,s):r.getQueryCache().get(a.queryHash)?.promise)?.catch(_s).finally(()=>{c.updateResult()}),a.notifyOnChangeProps?u:c.trackResult(u)}function HD(n,e){return mf(n,Gh,e)}function WD(n,e){return mf({...n,enabled:!0,suspense:!0,throwOnError:eb,placeholderData:void 0},Gh,e)}function XD(n,e){return mf({...n,enabled:!0,suspense:!0,throwOnError:eb},MA,e)}function jD(n,e){return UA({...n,queries:n.queries.map(t=>({...t,suspense:!0,throwOnError:eb,enabled:!0,placeholderData:void 0}))},e)}function YD(n,e){const t=Hh(e);t.getQueryState(n.queryKey)||t.prefetchQuery(n)}function KD(n,e){const t=Hh(e);t.getQueryState(n.queryKey)||t.prefetchInfiniteQuery(n)}function qD(n,e){const t=Hh(e),[i]=Y.useState(()=>new FD(t,n));Y.useEffect(()=>{i.setOptions(n)},[i,n]);const s=Y.useSyncExternalStore(Y.useCallback(a=>i.subscribe(Ri.batchCalls(a)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),r=Y.useCallback((a,o)=>{i.mutate(a,o).catch(_s)},[i]);if(s.error&&xA(i.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:r,mutateAsync:s.mutate}}function ZD(n,e){return mf(n,MA,e)}function Uo(n){return!!n&&!Array.isArray(n)&&typeof n=="object"}const $D=typeof Symbol=="function"&&!!Symbol.asyncIterator;function kA(n){return $D&&Uo(n)&&Symbol.asyncIterator in n}var QD=Object.create,VA=Object.defineProperty,JD=Object.getOwnPropertyDescriptor,zA=Object.getOwnPropertyNames,eO=Object.getPrototypeOf,tO=Object.prototype.hasOwnProperty,Wh=(n,e)=>function(){return e||(0,n[zA(n)[0]])((e={exports:{}}).exports,e),e.exports},iO=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(var s=zA(e),r=0,a=s.length,o;r<a;r++)o=s[r],!tO.call(n,o)&&o!==t&&VA(n,o,{get:(c=>e[c]).bind(null,o),enumerable:!(i=JD(e,o))||i.enumerable});return n},bf=(n,e,t)=>(t=n!=null?QD(eO(n)):{},iO(VA(t,"default",{value:n,enumerable:!0}),n));const GA=()=>{},nS=n=>{Object.freeze&&Object.freeze(n)};function HA(n,e,t){var i;const s=e.join(".");return(i=t[s])!==null&&i!==void 0||(t[s]=new Proxy(GA,{get(r,a){if(!(typeof a!="string"||a==="then"))return HA(n,[...e,a],t)},apply(r,a,o){const c=e[e.length-1];let u={args:o,path:e};return c==="call"?u={args:o.length>=2?[o[1]]:[],path:e.slice(0,-1)}:c==="apply"&&(u={args:o.length>=2?o[1]:[],path:e.slice(0,-1)}),nS(u.args),nS(u.path),n(u)}})),t[s]}const yf=n=>HA(n,[],Object.create(null)),tb=n=>new Proxy(GA,{get(e,t){if(t!=="then")return n(t)}});var WA=Wh({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(n,e){function t(i){"@babel/helpers - typeof";return e.exports=t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},e.exports.__esModule=!0,e.exports.default=e.exports,t(i)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}}),sO=Wh({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(n,e){var t=WA().default;function i(s,r){if(t(s)!="object"||!s)return s;var a=s[Symbol.toPrimitive];if(a!==void 0){var o=a.call(s,r||"default");if(t(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(s)}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports}}),rO=Wh({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(n,e){var t=WA().default,i=sO();function s(r){var a=i(r,"string");return t(a)=="symbol"?a:a+""}e.exports=s,e.exports.__esModule=!0,e.exports.default=e.exports}}),XA=Wh({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/
18defineProperty.js"(n,e){var t=rO();function i(s,r,a){return(r=t(r))in s?Object.defineProperty(s,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):s[r]=a,s}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports}}),ib=Wh({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(n,e){var t=XA();function i(r,a){var o=Object.keys(r);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(r);a&&(c=c.filter(function(u){return Object.getOwnPropertyDescriptor(r,u).enumerable})),o.push.apply(o,c)}return o}function s(r){for(var a=1;a<arguments.length;a++){var o=arguments[a]!=null?arguments[a]:{};a%2?i(Object(o),!0).forEach(function(c){t(r,c,o[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):i(Object(o)).forEach(function(c){Object.defineProperty(r,c,Object.getOwnPropertyDescriptor(o,c))})}return r}e.exports=s,e.exports.__esModule=!0,e.exports.default=e.exports}});bf(ib());bf(XA());var md=bf(ib());function nO(n,e){if("error"in n){const i=e.deserialize(n.error);return{ok:!1,error:(0,md.default)((0,md.default)({},n),{},{error:i})}}return{ok:!0,result:(0,md.default)((0,md.default)({},n.result),(!n.result.type||n.result.type==="data")&&{type:"data",data:e.deserialize(n.result.data)})}}var pg=class extends Error{constructor(){super("Unable to transform response from server")}};function aO(n,e){let t;try{t=nO(n,e)}catch{throw new pg}if(!t.ok&&(!Uo(t.error.error)||typeof t.error.error.code!="number"))throw new pg;if(t.ok&&!Uo(t.result))throw new pg;return t}bf(ib());function vf(n){const e={subscribe(t){let i=null,s=!1,r=!1,a=!1;function o(){if(i===null){a=!0;return}r||(r=!0,typeof i=="function"?i():i&&i.unsubscribe())}return i=n({next(c){var u;s||(u=t.next)===null||u===void 0||u.call(t,c)},error(c){var u;s||(s=!0,(u=t.error)===null||u===void 0||u.call(t,c),o())},complete(){var c;s||(s=!0,(c=t.complete)===null||c===void 0||c.call(t),o())}}),a&&o(),{unsubscribe:o}},pipe(...t){return t.reduce(oO,e)}};return e}function oO(n,e){return e(n)}function lO(n){const e=new AbortController;return new Promise((i,s)=>{let r=!1;function a(){r||(r=!0,o.unsubscribe())}e.signal.addEventListener("abort",()=>{s(e.signal.reason)});const o=n.subscribe({next(c){r=!0,i(c),a()},error(c){s(c)},complete(){e.abort(),a()}})})}var cO=Object.create,jA=Object.defineProperty,hO=Object.getOwnPropertyDescriptor,YA=Object.getOwnPropertyNames,uO=Object.getPrototypeOf,dO=Object.prototype.hasOwnProperty,ro=(n,e)=>function(){return e||(0,n[YA(n)[0]])((e={exports:{}}).exports,e),e.exports},fO=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(var s=YA(e),r=0,a=s.length,o;r<a;r++)o=s[r],!dO.call(n,o)&&o!==t&&jA(n,o,{get:(c=>e[c]).bind(null,o),enumerable:!(i=hO(e,o))||i.enumerable});return n},Xo=(n,e,t)=>(t=n!=null?cO(uO(n)):{},fO(e||!n||!n.__esModule?jA(t,"default",{value:n,enumerable:!0}):t,n)),pO=ro({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/objectWithoutPropertiesLoose.js"(n,e){function t(i,s){if(i==null)return{};var r={};for(var a in i)if({}
18.hasOwnProperty.call(i,a)){if(s.includes(a))continue;r[a]=i[a]}return r}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}}),_O=ro({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/objectWithoutProperties.js"(n,e){var t=pO();function i(s,r){if(s==null)return{};var a,o,c=t(s,r);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(s);for(o=0;o<u.length;o++)a=u[o],r.includes(a)||{}.propertyIsEnumerable.call(s,a)&&(c[a]=s[a])}return c}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports}}),KA=ro({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(n,e){function t(i){"@babel/helpers - typeof";return e.exports=t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},e.exports.__esModule=!0,e.exports.default=e.exports,t(i)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}}),gO=ro({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(n,e){var t=KA().default;function i(s,r){if(t(s)!="object"||!s)return s;var a=s[Symbol.toPrimitive];if(a!==void 0){var o=a.call(s,r||"default");if(t(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(s)}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports}}),mO=ro({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(n,e){var t=KA().default,i=gO();function s(r){var a=i(r,"string");return t(a)=="symbol"?a:a+""}e.exports=s,e.exports.__esModule=!0,e.exports.default=e.exports}}),bO=ro({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(n,e){var t=mO();function i(s,r,a){return(r=t(r))in s?Object.defineProperty(s,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):s[r]=a,s}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports}}),Xh=ro({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(n,e){var t=bO();function i(r,a){var o=Object.keys(r);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(r);a&&(c=c.filter(function(u){return Object.getOwnPropertyDescriptor(r,u).enumerable})),o.push.apply(o,c)}return o}function s(r){for(var a=1;a<arguments.length;a++){var o=arguments[a]!=null?arguments[a]:{};a%2?i(Object(o),!0).forEach(function(c){t(r,c,o[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):i(Object(o)).forEach(function(c){Object.defineProperty(r,c,Object.getOwnPropertyDescriptor(o,c))})}return r}e.exports=s,e.exports.__esModule=!0,e.exports.default=e.exports}}),yO=Xo(_O(),1),aS=Xo(Xh(),1);const vO=["cursor","direction"];function pn(n,e,t){const i=n.flatMap(s=>s.split("."));if(!e&&(!t||t==="any"))return i.length?[i]:[];if(t==="infinite"&&Uo(e)&&("direction"in e||"cursor"in e)){const{cursor:s,direction:r}=e,a=(0,yO.default)(e,vO);return[i,{input:a,type:"infinite"}]}return[i,(0,aS.default)((0,aS.default)({},typeof e<"u"&&e!==sr&&{input:e}),t&&t!=="any"&&{type:t})]}function wd(n){return pn(n,void 0,"any")}var xO=Object.create,qA=Object.defineProperty,SO=Object.getOwnPropertyDescriptor,ZA=Object.getOwnPropertyNames,TO=Object.getPrototypeOf,EO=Object.prototype.hasOwnProperty,En=(n,e)=>function(){return e||(0,n[ZA(n)[0]])((e={exports:{}}).exports,e),e.exports},AO=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(var s=ZA(e),r=0,a=s.length,o;r<a;r++)o=s[r],!EO.call(n,o)&&o!==t&&qA(n,o,{get:(c=>e[c]).bind(null,o),enumerable:!(i=SO(e,o))||i.enumerable});return n},wi=(n,e,t)=>(t=n!=null?xO(TO(n)):{},AO(e||!n||!n.__esModule?qA(t,"default",{value:n,enumerable:!0}):t,n)),$A=En({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(n,e){function t(i){"@babel/helpers - typeof";return e.exports=t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},e.exports.__esModule=!0,e.exports.default=e.exports,t(i)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}}),RO=En({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(n,e){var t=$A().default;function i(s,r){if(t(s)!="object"||!s)return s;var a=s[Symbol.toPrimitive];if(a!==void 0){var o=a.call(s,r||"default");if(t(o)!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(s)}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports}}),MO=En({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(n,e){var t=$A().default,i=RO();function s(r){var a=i(r,"string");return t(a)=="symbol"?a:a+""}e.exports=s,e.exports.__esModule=!0,e.exports.default=e.exports}}),jo=En({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/
18defineProperty.js"(n,e){var t=MO();function i(s,r,a){return(r=t(r))in s?Object.defineProperty(s,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):s[r]=a,s}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports}}),Zr=En({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(n,e){var t=jo();function i(r,a){var o=Object.keys(r);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(r);a&&(c=c.filter(function(u){return Object.getOwnPropertyDescriptor(r,u).enumerable})),o.push.apply(o,c)}return o}function s(r){for(var a=1;a<arguments.length;a++){var o=arguments[a]!=null?arguments[a]:{};a%2?i(Object(o),!0).forEach(function(c){t(r,c,o[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):i(Object(o)).forEach(function(c){Object.defineProperty(r,c,Object.getOwnPropertyDescriptor(o,c))})}return r}e.exports=s,e.exports.__esModule=!0,e.exports.default=e.exports}});function CO(n){return e=>{let t=0,i=null;const s=[];function r(){i||(i=e.subscribe({next(o){for(const u of s){var c;(c=u.next)===null||c===void 0||c.call(u,o)}},error(o){for(const u of s){var c;(c=u.error)===null||c===void 0||c.call(u,o)}},complete(){for(const c of s){var o;(o=c.complete)===null||o===void 0||o.call(c)}}}))}function a(){if(t===0&&i){const o=i;i=null,o.unsubscribe()}}return vf(o=>(t++,s.push(o),r(),{unsubscribe(){t--,a();const c=s.findIndex(u=>u===o);c>-1&&s.splice(c,1)}}))}}function IO(n){let e=n;const t=[],i=a=>{e!==void 0&&a.next(e),t.push(a)},s=a=>{t.splice(t.indexOf(a),1)},r=vf(a=>(i(a),()=>{s(a)}));return r.next=a=>{if(e!==a){e=a;for(const o of t)o.next(a)}},r.get=()=>e,r}function PO(n){return vf(e=>{function t(s=0,r=n.op){const a=n.links[s];if(!a)throw new Error("No more links to execute - did you forget to add an ending link?");return a({op:r,next(c){return t(s+1,c)}})}return t().subscribe(e)})}var bd=wi(jo(),1),Ul=wi(Zr(),1);function DO(n){return n instanceof Jl}function OO(n){return Uo(n)&&Uo(n.error)&&typeof n.error.code=="number"&&typeof n.error.message=="string"}function wO(n,e){return typeof n=="string"?n:Uo(n)&&typeof n.message=="string"?n.message:e}var Jl=class Fd extends Error{constructor(e,t){var i,s;const r=t?.cause;super(e,{cause:r}),(0,bd.default)(this,"cause",void 0),(0,bd.default)(this,"shape",void 0),(0,bd.default)(this,"data",void 0),(0,bd.default)(this,"meta",void 0),this.meta=t?.meta,this.cause=r,this.shape=t==null||(i=t.result)===null||i===void 0?void 0:i.error,this.data=t==null||(s=t.result)===null||s===void 0?void 0:s.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,Fd.prototype)}static from(e,t={}){const i=e;return DO(i)?(t.meta&&(i.meta=(0,Ul.default)((0,Ul.default)({},i.meta),t.meta)),i):OO(i)?new Fd(i.error.message,(0,Ul.default)((0,Ul.default)({},t),{},{result:i})):new Fd(wO(i,"Unknown error"),(0,Ul.default)((0,Ul.default)({},t),{},{cause:i}))}};function FO(n){const e=n;return e?"input"in e?e:{input:e,output:e}:{input:{serialize:t=>t,deserialize:t=>t},output:{serialize:t=>t,deserialize:t=>t}}}const oS=n=>typeof n=="function";function LO(n){if(n)return n;if(typeof window<"u"&&oS(window.fetch))return window.fetch;if(typeof globalThis<"u"&&oS(globalThis.fetch))return globalThis.fetch;throw new Error("No fetch implementation found")}var gh=wi(Zr());function NO(n){return{url:n.url.toString(),fetch:n.fetch,transformer:FO(n.transformer),methodOverride:n.methodOverride}}function BO(n){const e={};for(let t=0;t<n.length;t++){const i=n[t];e[t]=i}return e}const UO={query:"GET",mutation:"POST",subscription:"PATCH"};function QA(n){return"input"in n?n.transformer.input.serialize(n.input):BO(n.inputs.map(e=>n.transformer.input.serialize(e)))}const JA=n=>{const e=n.url.split("?");let i=e[0].replace(/\/$/,"")+"/"+n.path;const s=[];if(e[1]&&s.push(e[1]),"inputs"in n&&s.push("batch=1"),n.type==="query"||n.type==="subscription"){const r=QA(n);r!==void 0&&n.methodOverride!=="POST"&&s.push(`input=${encodeURIComponent(JSON.stringify(r))}`)}return s.length&&(i+="?"+s.join("&")),i},kO=n=>{if(n.type==="query"&&n.methodOverride!=="POST")return;const e=QA(n);return e!==void 0?JSON.stringify(e):void 0},VO=n=>WO((0,gh.default)((0,gh.default)({},n),{},{contentTypeHeader:"application/json",getUrl:JA,getBody:kO}));
18var zO=class extends Error{constructor(){const n="AbortError";super(n),this.name=n,this.message=n}};const GO=n=>{var e;if(n?.aborted)throw(e=n.throwIfAborted)===null||e===void 0||e.call(n),typeof DOMException<"u"?new DOMException("AbortError","AbortError"):new zO};async function HO(n){var e;GO(n.signal);const t=n.getUrl(n),i=n.getBody(n),s=(e=n.methodOverride)!==null&&e!==void 0?e:UO[n.type],r=await(async()=>{const o=await n.headers();return Symbol.iterator in o?Object.fromEntries(o):o})(),a=(0,gh.default)((0,gh.default)((0,gh.default)({},n.contentTypeHeader&&s!=="GET"?{"content-type":n.contentTypeHeader}:{}),n.trpcAcceptHeader?{"trpc-accept":n.trpcAcceptHeader}:void 0),r);return LO(n.fetch)(t,{method:s,signal:n.signal,body:i,headers:a})}async function WO(n){const e={},t=await HO(n);e.response=t;const i=await t.json();return e.responseJSON=i,{json:i,meta:e}}wi(Zr(),1);const lS=()=>{throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new")};function cS(n){let e=null,t=null;const i=()=>{clearTimeout(t),t=null,e=null};function s(o){const c=[[]];let u=0;for(;;){const g=o[u];if(!g)break;const m=c[c.length-1];if(g.aborted){var d;(d=g.reject)===null||d===void 0||d.call(g,new Error("Aborted")),u++;continue}if(n.validate(m.concat(g).map(x=>x.key))){m.push(g),u++;continue}if(m.length===0){var f;(f=g.reject)===null||f===void 0||f.call(g,new Error("Input is too big for a single dispatch")),u++;continue}c.push([])}return c}function r(){const o=s(e);i();for(const c of o){if(!c.length)continue;const u={items:c};for(const f of c)f.batch=u;n.fetch(u.items.map(f=>f.key)).then(async f=>{await Promise.all(f.map(async(m,b)=>{const x=u.items[b];try{var v;const A=await Promise.resolve(m);(v=x.resolve)===null||v===void 0||v.call(x,A)}catch(A){var E;(E=x.reject)===null||E===void 0||E.call(x,A)}x.batch=null,x.reject=null,x.resolve=null}));for(const m of u.items){var g;(g=m.reject)===null||g===void 0||g.call(m,new Error("Missing result")),m.batch=null}}).catch(f=>{for(const m of u.items){var g;(g=m.reject)===null||g===void 0||g.call(m,f),m.batch=null}})}}function a(o){var c;const u={aborted:!1,key:o,batch:null,resolve:lS,reject:lS},d=new Promise((f,g)=>{var m;u.reject=g,u.resolve=f,(m=e)!==null&&m!==void 0||(e=[]),e.push(u)});return(c=t)!==null&&c!==void 0||(t=setTimeout(r)),d}return{load:a}}function XO(...n){const e=new AbortController,t=n.length;let i=0;const s=()=>{++i===t&&e.abort()};for(const r of n)r?.aborted?s():r?.addEventListener("abort",s,{once:!0});return e.signal}var yd=wi(Zr(),1);function jO(n){var e,t;const i=NO(n),s=(e=n.maxURLLength)!==null&&e!==void 0?e:1/0,r=(t=n.maxItems)!==null&&t!==void 0?t:1/0;return()=>{const a=d=>({validate(f){if(s===1/0&&r===1/0)return!0;if(f.length>r)return!1;const g=f.map(x=>x.path).join(","),m=f.map(x=>x.input);return JA((0,yd.default)((0,yd.default)({},i),{},{type:d,path:g,inputs:m,signal:null})).length<=s},async fetch(f){const g=f.map(A=>A.path).join(","),m=f.map(A=>A.input),b=XO(...f.map(A=>A.signal)),x=await VO((0,yd.default)((0,yd.default)({},i),{},{path:g,inputs:m,type:d,headers(){return n.headers?typeof n.headers=="function"?n.headers({opList:f}):n.headers:{}},signal:b}));return(Array.isArray(x.json)?x.json:f.map(()=>x.json)).map(A=>({meta:x.meta,json:A}))}}),o=cS(a("query")),c=cS(a("mutation")),u={query:o,mutation:c};return({op:d})=>vf(f=>{/* istanbul ignore if -- @preserve */if(d.type==="subscription")throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");const m=u[d.type].load(d);let b;return m.then(x=>{b=x;const v=aO(x.json,i.transformer.output);if(!v.ok){f.error(Jl.from(v.error,{meta:x.meta}));return}f.next({context:x.meta,result:v.result}),f.complete()}).catch(x=>{f.error(Jl.from(x,{meta:b?.meta}))}),()=>{}})}}wi(Zr(),1);const eR=(n,...e)=>typeof n=="function"?n(...e):n;wi(jo(),1);function YO(){let n,e;return{promise:new Promise((i,s)=>{n=i,e=s}),resolve:n,reject:e}}async function KO(n){const e=await eR(n.url);if(!n.connectionParams)return e;const i=`${e.includes("?")?"&":"?"}connectionParams=1`;return e+i}async function qO(n){const e={method:"connectionParams",data:await eR(n)};return JSON.stringify(e)}wi(jo(),1);var Po=wi(jo(),1);function ZO(n){const{promise:e,resolve:t,reject:i}=YO();return n.addEventListener("open",()=>{n.removeEventListener("error",i),t()}),n.addEventListener("error",i),e}function $O(n,{intervalMs:e,pongTimeoutMs:t}){let i,s;function r(){i=setTimeout(()=>{n.send("PING"),s=setTimeout(()=>{n.close()},t)},e)}function a(){clearTimeout(i),r()}function o(){clearTimeout(s),a()}n.addEventListener("open",r),n.addEventListener("message",({data:c})=>{clearTimeout(i),r(),c==="PONG"&&o()}),n.addEventListener("close",()=>{clearTimeout(i),clearTimeout(s)})}var QO=class sm{constructor(e){var t;if((0,Po.default)(this,"id",++sm.connectCount),(0,Po.default)(this,"WebSocketPonyfill",void 0),(0,Po.default)(this,"urlOptions",void 0),(0,Po.default)(this,"keepAliveOpts",void 0),(0,Po.default)(this,"wsObservable",IO(null)),(0,Po.default)(this,"openPromise",null),this.WebSocketPonyfill=(t=e.WebSocketPonyfill)!==null&&t!==void 0?t:WebSocket,!this.WebSocketPonyfill)throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");this.urlOptions=e.urlOptions,this.keepAliveOpts=e.keepAlive}get ws(){return this.wsObservable.get()}set ws(e){this.wsObservable.next(e)}isOpen(){return!!this.ws&&this.ws.readyState===this.WebSocketPonyfill.OPEN&&!this.openPromise}isClosed(){return!!this.ws&&(this.ws.readyState===this.WebSocketPonyfill.CLOSING||this.ws.readyState===this.WebSocketPonyfill.CLOSED)}async open(){var e=this;if(e.openPromise)return e.openPromise;e.id=++sm.connectCount;const t=KO(e.urlOptions).then(i=>new e.WebSocketPonyfill(i));e.openPromise=t.then(async i=>{e.ws=i,i.addEventListener("message",function({data:s}){s==="PING"&&this.send("PONG")}),e.keepAliveOpts.enabled&&$O(i,e.keepAliveOpts),i.addEventListener("close",()=>{e.ws===i&&(e.ws=null)}),await ZO(i),e.urlOptions.connectionParams&&i.send(await qO(e.urlOptions.connectionParams))});try{await e.openPromise}finally{e.openPromise=null}}async close(){var e=this;try{await e.openPromise}finally{var t;(t=e.ws)===null||t===void 0||t.close()}}};(0,Po.default)(QO,"connectCount",0);wi(jo(),1);wi(Zr(),1);var _g=wi(jo(),1),hS=wi(Zr(),1),xf=class{constructor(n){(0,_g.default)(this,"links",void 0),(0,_g.default)(this,"runtime",void 0),(0,_g.default)(this,"requestId",void 0),this.requestId=0,this.runtime={},this.links=n.links.map(e=>e(this.runtime))}$request(n){var e;return PO({links:this.links,op:(0,hS.default)((0,hS.default)({},n),{},{context:(e=n.context)!==null&&e!==void 0?e:{},id:++this.requestId})}).pipe(CO())}async requestAsPromise(n){var e=this;try{const t=e.$request(n);return(await lO(t)).result.data}catch(t){throw Jl.from(t)}}query(n,e,t){return this.requestAsPromise({type:"query",path:n,input:e,context:t?.context,signal:t?.signal})}mutation(n,e,t){return this.requestAsPromise({type:"mutation",path:n,input:e,context:t?.context,signal:t?.signal})}subscription(n,e,t){return this.$request({type:"subscription",path:n,input:e,context:t.context,signal:t.signal}).subscribe({next(s){switch(s.result.type){case"state":{var r;(r=t.onConnectionStateChange)===null||r===void 0||r.call(t,s.result);break}case"started":{var a;(a=t.onStarted)===null||a===void 0||a.call(t,{context:s.context});break}case"stopped":{var o;(o=t.onStopped)===null||o===void 0||o.call(t);break}case"data":case void 0:{var c;
18(c=t.onData)===null||c===void 0||c.call(t,s.result.data);break}}},error(s){var r;(r=t.onError)===null||r===void 0||r.call(t,s)},complete(){var s;(s=t.onComplete)===null||s===void 0||s.call(t)}})}};const tR=Symbol.for("trpc_untypedClient"),JO={query:"query",mutate:"mutation",subscribe:"subscription"},ew=n=>JO[n];function iR(n){const e=yf(({path:t,args:i})=>{const s=[...t],r=ew(s.pop()),a=s.join(".");return n[r](a,...i)});return tb(t=>t===tR?n:e[t])}function tw(n){const e=new xf(n);return iR(e)}function sb(n){return n[tR]}wi(Zr(),1);wi(Zr(),1);var iw=En({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(n,e){function t(s){var r,a,o,c=2;for(typeof Symbol<"u"&&(a=Symbol.asyncIterator,o=Symbol.iterator);c--;){if(a&&(r=s[a])!=null)return r.call(s);if(o&&(r=s[o])!=null)return new i(r.call(s));a="@@asyncIterator",o="@@iterator"}throw new TypeError("Object is not async iterable")}function i(s){function r(a){if(Object(a)!==a)return Promise.reject(new TypeError(a+" is not an object."));var o=a.done;return Promise.resolve(a.value).then(function(c){return{value:c,done:o}})}return i=function(o){this.s=o,this.n=o.next},i.prototype={s:null,n:null,next:function(){return r(this.n.apply(this.s,arguments))},return:function(o){var c=this.s.return;return c===void 0?Promise.resolve({value:o,done:!0}):r(c.apply(this.s,arguments))},throw:function(o){var c=this.s.return;return c===void 0?Promise.reject(o):r(c.apply(this.s,arguments))}},new i(s)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}});wi(iw(),1);wi(Zr(),1);var sw=En({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(n,e){function t(){var i=typeof SuppressedError=="function"?SuppressedError:function(o,c){var u=Error();return u.name="SuppressedError",u.error=o,u.suppressed=c,u},s={},r=[];function a(o,c){if(c!=null){if(Object(c)!==c)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(o)var u=c[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(u===void 0&&(u=c[Symbol.dispose||Symbol.for("Symbol.dispose")],o))var d=u;if(typeof u!="function")throw new TypeError("Object is not disposable.");d&&(u=function(){try{d.call(c)}catch(g){return Promise.reject(g)}}),r.push({v:c,d:u,a:o})}else o&&r.push({d:c,a:o});return c}return{e:s,u:a.bind(null,!1),a:a.bind(null,!0),d:function(){var c,u=this.e,d=0;function f(){for(;c=r.pop();)try{if(!c.a&&d===1)return d=0,r.push(c),Promise.resolve().then(f);if(c.d){var m=c.d.call(c.v);if(c.a)return d|=2,Promise.resolve(m).then(f,g)}else d|=1}catch(b){return g(b)}if(d===1)return u!==s?Promise.reject(u):Promise.resolve();if(u!==s)throw u}function g(m){return u=u!==s?new i(m,u):m,f()}return f()}}}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}}),sR=En({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(n,e){function t(i,s){this.v=i,this.k=s}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}}),rw=En({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(n,e){var t=sR();function i(s){return new t(s,0)}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports}}),nw=En({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(n,e){var t=sR();function i(r){return function(){return new s(r.apply(this,arguments))}}function s(r){var a,o;function c(d,f){try{var g=r[d](f),m=g.value,b=m instanceof t;Promise.resolve(b?m.v:m).then(function(x){if(b){var v=d==="return"?"return":"next";if(!m.k||x.done)return c(v,x);x=r[v](x).value}u(g.done?"return":"normal",x)},function(x){c("throw",x)})}catch(x){u("throw",x)}}function u(d,f){switch(d){case"return":a.resolve({value:f,done:!0});break;case"throw":a.reject(f);break;default:a.resolve({value:f,done:!1})}(a=a.next)?c(a.key,a.arg):o=null}this._invoke=function(d,f){return new Promise(function(g,m){var b={key:d,arg:f,resolve:g,reject:m,next:null};o?o=o.next=b:(a=o=b,c(d,f))})},typeof r.return!="function"&&(this.return=void 0)}s.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},s.prototype.next=function(r){return this._invoke("next",r)},s.prototype.throw=function(r){return this._invoke("throw",r)},s.prototype.return=function(r){return this._invoke("return",r)},e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports}});wi(sw(),1);wi(rw(),1);wi(nw(),1);wi(Zr(),1);function aw(n){return yf(({path:e,args:t})=>{var i;const s=[...e],r=s.pop();if(r==="useMutation")return n[r](s,...t);if(r==="_def")return{path:s};const[a,...o]=t,c=(i=o[0])!==null&&i!==void 0?i:{};return n[r](s,a,c)})}var gg;const ow=["client","ssrContext","ssrState","abortOnUnmount"],lw=(gg=Y.createContext)===null||gg===void 0?void 0:gg.call(Jm,null),cw=n=>
18{switch(n){case"queryOptions":case"fetch":case"ensureData":case"prefetch":case"getData":case"setData":case"setQueriesData":return"query";case"infiniteQueryOptions":case"fetchInfinite":case"prefetchInfinite":case"getInfiniteData":case"setInfiniteData":return"infinite";case"setMutationDefaults":case"getMutationDefaults":case"isMutating":case"cancel":case"invalidate":case"refetch":case"reset":return"any"}};function hw(n){return yf(e=>{const t=[...e.path],i=t.pop(),s=[...e.args],r=s.shift(),a=cw(i),o=pn(t,r,a);return{infiniteQueryOptions:()=>n.infiniteQueryOptions(t,o,s[0]),queryOptions:()=>n.queryOptions(t,o,...s),fetch:()=>n.fetchQuery(o,...s),fetchInfinite:()=>n.fetchInfiniteQuery(o,s[0]),prefetch:()=>n.prefetchQuery(o,...s),prefetchInfinite:()=>n.prefetchInfiniteQuery(o,s[0]),ensureData:()=>n.ensureQueryData(o,...s),invalidate:()=>n.invalidateQueries(o,...s),reset:()=>n.resetQueries(o,...s),refetch:()=>n.refetchQueries(o,...s),cancel:()=>n.cancelQuery(o,...s),setData:()=>{n.setQueryData(o,s[0],s[1])},setQueriesData:()=>n.setQueriesData(o,s[0],s[1],s[2]),setInfiniteData:()=>{n.setInfiniteQueryData(o,s[0],s[1])},getData:()=>n.getQueryData(o),getInfiniteData:()=>n.getInfiniteQueryData(o),setMutationDefaults:()=>n.setMutationDefaults(wd(t),r),getMutationDefaults:()=>n.getMutationDefaults(wd(t)),isMutating:()=>n.isMutating({mutationKey:wd(t)})}[i]()})}function uw(n){const e=iR(n.client),t=hw(n);return tb(i=>{const s=i;return s==="client"?e:ow.includes(s)?n[s]:t[i]})}var dw=Xo(Xh(),1);function uS(n){const e=n instanceof xf?n:sb(n);return yf(t=>{const i=t.path,s=i.join("."),[r,a]=t.args;return(0,dw.default)({queryKey:pn(i,r,"query"),queryFn:()=>e.query(s,r,a?.trpc)},a)})}var mg=Xo(Xh(),1);function xs(n,e,t){var i;const s=n[0];let r=(i=n[1])===null||i===void 0?void 0:i.input;if(t){var a;r=(0,mg.default)((0,mg.default)((0,mg.default)({},(a=r)!==null&&a!==void 0?a:{}),t.pageParam?{cursor:t.pageParam}:{}),{},{direction:t.direction})}return[s.join("."),r,e?.trpc]}var fw=ro({"../../node_modules/.pnpm/@[email protected]/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(n,e){function t(s){var r,a,o,c=2;for(typeof Symbol<"u"&&(a=Symbol.asyncIterator,o=Symbol.iterator);c--;){if(a&&(r=s[a])!=null)return r.call(s);if(o&&(r=s[o])!=null)return new i(r.call(s));a="@@asyncIterator",o="@@iterator"}throw new TypeError("Object is not async iterable")}function i(s){function r(a){if(Object(a)!==a)return Promise.reject(new TypeError(a+" is not an object."));var o=a.done;return Promise.resolve(a.value).then(function(c){return{value:c,done:o}})}return i=function(o){this.s=o,this.n=o.next},i.prototype={s:null,n:null,next:function(){return r(this.n.apply(this.s,arguments))},return:function(o){var c=this.s.return;return c===void 0?Promise.resolve({value:o,done:!0}):r(c.apply(this.s,arguments))},throw:function(o){var c=this.s.return;return c===void 0?Promise.reject(o):r(c.apply(this.s,arguments))}},new i(s)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}}),pw=Xo(fw(),1);function rm(n){return{path:n.path.join(".")}}function hh(n){const e=rm(n);return Y.useMemo(()=>e,[e])}async function rR(n,e,t){const s=e.getQueryCache().build(e,{queryKey:t});s.setState({data:[],status:"success"});const r=[];var a=!1,o=!1,c;try{for(var u=(0,pw.default)(n),d;a=!(d=await u.next()).done;a=!1){const f=d.value;r.push(f),s.setState({data:[...r]})}}catch(f){o=!0,c=f}finally{try{a&&u.return!=null&&await u.return()}finally{if(o)throw c}}return r}var Gt=Xo(Xh(),1);function _w(n){const{client:e,queryClient:t}=n,i=e instanceof xf?e:sb(e);return{infiniteQueryOptions:(s,r,a)=>{var o,c;const u=((o=r[1])===null||o===void 0?void 0:o.input)===sr,d=async f=>{var g;const m=(0,Gt.default)((0,Gt.default)({},a),{},{trpc:(0,Gt.default)((0,Gt.default)({},a?.trpc),!(a==null||(g=a.trpc)===null||g===void 0)&&g.abortOnUnmount?{signal:f.signal}:{signal:null})});return await i.query(...xs(r,m,{direction:f.direction,pageParam:f.pageParam}))};return Object.assign((0,Gt.default)((0,Gt.default)({},a),{},{initialData:a?.initialData,queryKey:r,queryFn:u?sr:d,initialPageParam:(c=a?.initialCursor)!==null&&c!==void 0?c:null}),{trpc:rm({path:s})})},queryOptions:(s,r,a)=>{var o;const c=((o=r[1])===null||o===void 0?void 0:o.input)===sr,u=async d=>{var f;const g=(0,Gt.default)((0,Gt.default)({},a),{},{trpc:(0,Gt.default)((0,Gt.default)({},a?.trpc),!(a==null||(f=a.trpc)===null||f===void 0)&&f.abortOnUnmount?{signal:d.signal}:{signal:null})}),m=await i.query(...xs(r,g));return kA(m)?rR(m,t,r):m};return Object.assign((0,Gt.default)((0,Gt.default)({},a),{},{initialData:a?.initialData,queryKey:r,queryFn:c?sr:u}),{trpc:rm({path:s})})},fetchQuery:(s,r)=>t.fetchQuery((0,Gt.default)((0,Gt.default)({},r),{},{queryKey:s,queryFn:()=>i.query(...xs(s,r))})),fetchInfiniteQuery:(s,r)=>{var a;return t.fetchInfiniteQuery((0,Gt.default)((0,Gt.default)({},r),{},{queryKey:s,queryFn:({pageParam:o,direction:c})=>i.query(...xs(s,r,{pageParam:o,direction:c})),initialPageParam:(a=r?.initialCursor)!==null&&a!==void 0?a:null}))},prefetchQuery:(s,r)=>t.prefetchQuery((0,Gt.default)((0,Gt.default)({},r),{},{queryKey:s,queryFn:()=>i.query(...xs(s,r))})),prefetchInfiniteQuery:(s,r)=>{var a;return t.prefetchInfiniteQuery((0,Gt.default)((0,Gt.default)({},r),{},{queryKey:s,queryFn:({pageParam:o,direction:c})=>i.query(...xs(s,r,{pageParam:o,direction:c})),initialPageParam:(a=r?.initialCursor)!==null&&a!==void 0?a:null}))},ensureQueryData:(s,r)=>t.ensureQueryData((0,Gt.default)((0,Gt.default)({},r),{},{queryKey:s,queryFn:()=>i.query(...xs(s,r))})),invalidateQueries:(s,r,a)=>
18t.invalidateQueries((0,Gt.default)((0,Gt.default)({},r),{},{queryKey:s}),a),resetQueries:(s,r,a)=>t.resetQueries((0,Gt.default)((0,Gt.default)({},r),{},{queryKey:s}),a),refetchQueries:(s,r,a)=>t.refetchQueries((0,Gt.default)((0,Gt.default)({},r),{},{queryKey:s}),a),cancelQuery:(s,r)=>t.cancelQueries({queryKey:s},r),setQueryData:(s,r,a)=>t.setQueryData(s,r,a),setQueriesData:(s,r,a,o)=>t.setQueriesData((0,Gt.default)((0,Gt.default)({},r),{},{queryKey:s}),a,o),getQueryData:s=>t.getQueryData(s),setInfiniteQueryData:(s,r,a)=>t.setQueryData(s,r,a),getInfiniteQueryData:s=>t.getQueryData(s),setMutationDefaults:(s,r)=>{const a=s[0],o=c=>i.mutation(...xs([a,{input:c}],n));return t.setMutationDefaults(s,typeof r=="function"?r({canonicalMutationFn:o}):r)},getMutationDefaults:s=>t.getMutationDefaults(s),isMutating:s=>t.isMutating((0,Gt.default)((0,Gt.default)({},s),{},{exact:!0}))}}var He=Xo(Xh());const dS=(n,e)=>new Proxy(n,{get(i,s){return e(s),i[s]}});function gw(n){var e,t;const i=(e=void 0)!==null&&e!==void 0?e:R=>R.originalFn(),s=(t=void 0)!==null&&t!==void 0?t:lw,r=tw,a=R=>{var C;const{abortOnUnmount:M=!1,queryClient:F,ssrContext:U}=R,[k,q]=Y.useState((C=R.ssrState)!==null&&C!==void 0?C:!1),Q=R.client instanceof xf?R.client:sb(R.client),ie=Y.useMemo(()=>_w({client:Q,queryClient:F}),[Q,F]),$=Y.useMemo(()=>(0,He.default)({abortOnUnmount:M,queryClient:F,client:Q,ssrContext:U??null,ssrState:k},ie),[M,Q,ie,F,U,k]);return Y.useEffect(()=>{q(ce=>ce?"mounted":!1)},[]),B.jsx(s.Provider,{value:$,children:R.children})};function o(){const R=Y.useContext(s);if(!R)throw new Error("Unable to find tRPC Context. Did you forget to wrap your App inside `withTRPC` HoC?");return R}function c(R,C){var M;const{queryClient:F,ssrState:U}=o();return U&&U!=="mounted"&&((M=F.getQueryCache().find({queryKey:R}))===null||M===void 0?void 0:M.state.status)==="error"?(0,He.default)({retryOnMount:!1},C):C}function u(R,C,M){var F,U,k,q,Q;const ie=o(),{abortOnUnmount:$,client:ce,ssrState:G,queryClient:K,prefetchQuery:X}=ie,J=pn(R,C,"query"),se=K.getQueryDefaults(J),w=C===sr;typeof window>"u"&&G==="prepass"&&(M==null||(F=M.trpc)===null||F===void 0?void 0:F.ssr)!==!1&&((U=M?.enabled)!==null&&U!==void 0?U:se?.enabled)!==!1&&!w&&!K.getQueryCache().find({queryKey:J})&&X(J,M);const L=c(J,(0,He.default)((0,He.default)({},se),M)),V=(k=(q=M==null||(Q=M.trpc)===null||Q===void 0?void 0:Q.abortOnUnmount)!==null&&q!==void 0?q:void 0)!==null&&k!==void 0?k:$,j=HD((0,He.default)((0,He.default)({},L),{},{queryKey:J,queryFn:w?C:async ae=>{const he=(0,He.default)((0,He.default)({},L),{},{trpc:(0,He.default)((0,He.default)({},L?.trpc),V?{signal:ae.signal}:{signal:null})}),be=await ce.query(...xs(J,he));return kA(be)?rR(be,K,J):be}}),K);return j.trpc=hh({path:R}),j}function d(R,C,M){var F,U,k;const q=o(),Q=pn(R,C,"query"),ie=C===sr,$=(F=(U=M==null||(k=M.trpc)===null||k===void 0?void 0:k.abortOnUnmount)!==null&&U!==void 0?U:void 0)!==null&&F!==void 0?F:q.abortOnUnmount;YD((0,He.default)((0,He.default)({},M),{},{queryKey:Q,queryFn:ie?C:ce=>{const G={trpc:(0,He.default)((0,He.default)({},M?.trpc),$?{signal:ce.signal}:{})};return q.client.query(...xs(Q,G))}}))}function f(R,C,M){var F,U,k;const q=o(),Q=pn(R,C,"query"),ie=(F=(U=M==null||(k=M.trpc)===null||k===void 0?void 0:k.abortOnUnmount)!==null&&U!==void 0?U:void 0)!==null&&F!==void 0?F:q.abortOnUnmount,$=WD((0,He.default)((0,He.default)({},M),{},{queryKey:Q,queryFn:ce=>{const G=(0,He.default)((0,He.default)({},M),{},{trpc:(0,He.default)((0,He.default)({},M?.trpc),ie?{signal:ce.signal}:{signal:null})});return q.client.query(...xs(Q,G))}}),q.queryClient);return $.trpc=hh({path:R}),[$.data,$]}function g(R,C){const{client:M,queryClient:F}=o(),U=wd(R),k=F.defaultMutationOptions(F.getMutationDefaults(U)),q=qD((0,He.default)((0,He.default)({},C),{},{mutationKey:U,mutationFn:Q=>M.mutation(...xs([R,{input:Q}],C)),onSuccess(...Q){var ie,$;return i({originalFn:()=>{var G,K,X;return(G=C==null||(K=C.onSuccess)===null||K===void 0?void 0:K.call(C,...Q))!==null&&G!==void 0?G:k==null||(X=k.onSuccess)===null||X===void 0?void 0:X.call(k,...Q)},queryClient:F,meta:(ie=($=C?.meta)!==null&&$!==void 0?$:k?.meta)!==null&&ie!==void 0?ie:{}})}}),F);return q.trpc=hh({path:R}),q}const m={data:void 0,error:null,status:"idle"},b={data:void 0,error:null,status:"connecting"};/* istanbul ignore next -- @preserve */function x(R,C,M){var F;const U=(F=M?.enabled)!==null&&F!==void 0?F:C!==sr,k=Ka(pn(R,C,"any")),{client:q}=o(),Q=Y.useRef(M);Y.useEffect(()=>{Q.current=M});const[ie]=Y.useState(new Set([])),$=Y.useCallback(w=>{ie.add(w)},[ie]),ce=Y.useRef(null),G=Y.useCallback(w=>{const L=X.current,V=X.current=w(L);let j=!1;for(const ae of ie)if(L[ae]!==V[ae]){j=!0;break}j&&se(dS(V,$))},[$,ie]),K=Y.useCallback(()=>{var w;if((w=ce.current)===null||w===void 0||w.unsubscribe(),!U){G(()=>(0,He.default)((0,He.default)({},m),{},{reset:K}));return}G(()=>(0,He.default)((0,He.default)({},b),{},{reset:K}));const L=q.subscription(R.join("."),C??void 0,{onStarted:()=>{var V,j;(V=(j=Q.current).onStarted)===null||V===void 0||V.call(j),G(ae=>(0,He.default)((0,He.default)({},ae),{},{status:"pending",error:null}))},onData:V=>{var j,ae;(j=(ae=Q.current).onData)===null||j===void 0||j.call(ae,V),G(he=>(0,He.default)((0,He.default)({},he),{},{status:"pending",data:V,error:null}))},onError:V=>{var j,ae;(j=(ae=Q.current).onError)===null||j===void 0||j.call(ae,V),G(he=>(0,He.default)((0,He.default)({},he),{},{status:"error",error:V}))},onConnectionStateChange:V=>{G(j=>{switch(V.state){case"idle":return(0,He.default)((0,He.default)({},j),{},{status:V.state,error:null,data:void 0});case"connecting":return(0,He.default)((0,He.default)({},j),{},{error:V.error,status:V.state});
18case"pending":return j}})},onComplete:()=>{var V,j;(V=(j=Q.current).onComplete)===null||V===void 0||V.call(j),G(ae=>(0,He.default)((0,He.default)({},ae),{},{status:"idle",error:null,data:void 0}))}});ce.current=L},[q,k,U,G]);Y.useEffect(()=>(K(),()=>{var w;(w=ce.current)===null||w===void 0||w.unsubscribe()}),[K]);const X=Y.useRef(U?(0,He.default)((0,He.default)({},b),{},{reset:K}):(0,He.default)((0,He.default)({},m),{},{reset:K})),[J,se]=Y.useState(dS(X.current,$));return J}function v(R,C,M){var F,U,k,q,Q;const{client:ie,ssrState:$,prefetchInfiniteQuery:ce,queryClient:G,abortOnUnmount:K}=o(),X=pn(R,C,"infinite"),J=G.getQueryDefaults(X),se=C===sr;typeof window>"u"&&$==="prepass"&&(M==null||(F=M.trpc)===null||F===void 0?void 0:F.ssr)!==!1&&((U=M?.enabled)!==null&&U!==void 0?U:J?.enabled)!==!1&&!se&&!G.getQueryCache().find({queryKey:X})&&ce(X,(0,He.default)((0,He.default)({},J),M));const w=c(X,(0,He.default)((0,He.default)({},J),M)),L=(k=M==null||(q=M.trpc)===null||q===void 0?void 0:q.abortOnUnmount)!==null&&k!==void 0?k:K,V=ZD((0,He.default)((0,He.default)({},w),{},{initialPageParam:(Q=M.initialCursor)!==null&&Q!==void 0?Q:null,persister:M.persister,queryKey:X,queryFn:se?C:j=>{var ae;const he=(0,He.default)((0,He.default)({},w),{},{trpc:(0,He.default)((0,He.default)({},w?.trpc),L?{signal:j.signal}:{signal:null})});return ie.query(...xs(X,he,{pageParam:(ae=j.pageParam)!==null&&ae!==void 0?ae:M.initialCursor,direction:j.direction}))}}),G);return V.trpc=hh({path:R}),V}function E(R,C,M){var F,U,k;const q=o(),Q=pn(R,C,"infinite"),ie=q.queryClient.getQueryDefaults(Q),$=C===sr,ce=c(Q,(0,He.default)((0,He.default)({},ie),M)),G=(F=M==null||(U=M.trpc)===null||U===void 0?void 0:U.abortOnUnmount)!==null&&F!==void 0?F:q.abortOnUnmount;KD((0,He.default)((0,He.default)({},M),{},{initialPageParam:(k=M.initialCursor)!==null&&k!==void 0?k:null,queryKey:Q,queryFn:$?C:K=>{var X;const J=(0,He.default)((0,He.default)({},ce),{},{trpc:(0,He.default)((0,He.default)({},ce?.trpc),G?{signal:K.signal}:{})});return q.client.query(...xs(Q,J,{pageParam:(X=K.pageParam)!==null&&X!==void 0?X:M.initialCursor,direction:K.direction}))}}))}function A(R,C,M){var F,U,k;const q=o(),Q=pn(R,C,"infinite"),ie=q.queryClient.getQueryDefaults(Q),$=c(Q,(0,He.default)((0,He.default)({},ie),M)),ce=(F=M==null||(U=M.trpc)===null||U===void 0?void 0:U.abortOnUnmount)!==null&&F!==void 0?F:q.abortOnUnmount,G=XD((0,He.default)((0,He.default)({},M),{},{initialPageParam:(k=M.initialCursor)!==null&&k!==void 0?k:null,queryKey:Q,queryFn:K=>{var X;const J=(0,He.default)((0,He.default)({},$),{},{trpc:(0,He.default)((0,He.default)({},$?.trpc),ce?{signal:K.signal}:{})});return q.client.query(...xs(Q,J,{pageParam:(X=K.pageParam)!==null&&X!==void 0?X:M.initialCursor,direction:K.direction}))}}),q.queryClient);return G.trpc=hh({path:R}),[G.data,G]}return{Provider:a,createClient:r,useContext:o,useUtils:o,useQuery:u,usePrefetchQuery:d,useSuspenseQuery:f,useQueries:(R,C)=>{const{ssrState:M,queryClient:F,prefetchQuery:U,client:k}=o(),q=uS(k),Q=R(q);if(typeof window>"u"&&M==="prepass")for(const $ of Q){var ie;const ce=$;((ie=ce.trpc)===null||ie===void 0?void 0:ie.ssr)!==!1&&!F.getQueryCache().find({queryKey:ce.queryKey})&&U(ce.queryKey,ce)}return UA({queries:Q.map($=>(0,He.default)((0,He.default)({},$),{},{queryKey:$.queryKey})),combine:C?.combine},F)},useSuspenseQueries:R=>{const{queryClient:C,client:M}=o(),F=uS(M),U=R(F),k=jD({queries:U.map(q=>(0,He.default)((0,He.default)({},q),{},{queryFn:q.queryFn,queryKey:q.queryKey}))},C);return[k.map(q=>q.data),k]},useMutation:g,useSubscription:x,useInfiniteQuery:v,usePrefetchInfiniteQuery:E,useSuspenseInfiniteQuery:A}}function mw(n){const e=aw(n);return tb(t=>t==="useContext"||t==="useUtils"?()=>{const i=n.useUtils();return Y.useMemo(()=>uw(i),[i])}:n.hasOwnProperty(t)?n[t]:e[t])}function bw(n){const e=gw();return mw(e)}const ns=bw(),yw="app_session_id",vw="Please login (10001)",xw="__Host-oauth_state",Sw=n=>btoa(JSON.stringify(n));var bg={exports:{}},uh={},yg={exports:{}},vg={};/** 19 * @license React 20 * scheduler.production.js 21 * 22 * Copyright (c) Meta Platforms, Inc. and affiliates. 23 * 24 * This source code is licensed under the MIT license found in the 25 * LICENSE file in the root directory of this source tree. 26 */var fS;
vendor: 12,679 bytes, lines 26-44
26function Tw(){return fS||(fS=1,(function(n){function e(G,K){var X=G.length;G.push(K);e:for(;0<X;){var J=X-1>>>1,se=G[J];if(0<s(se,K))G[J]=K,G[X]=se,X=J;else break e}}function t(G){return G.length===0?null:G[0]}function i(G){if(G.length===0)return null;var K=G[0],X=G.pop();if(X!==K){G[0]=X;e:for(var J=0,se=G.length,w=se>>>1;J<w;){var L=2*(J+1)-1,V=G[L],j=L+1,ae=G[j];if(0>s(V,X))j<se&&0>s(ae,V)?(G[J]=ae,G[j]=X,J=j):(G[J]=V,G[L]=X,J=L);else if(j<se&&0>s(ae,X))G[J]=ae,G[j]=X,J=j;else break e}}return K}function s(G,K){var X=G.sortIndex-K.sortIndex;return X!==0?X:G.id-K.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var r=performance;n.unstable_now=function(){return r.now()}}else{var a=Date,o=a.now();n.unstable_now=function(){return a.now()-o}}var c=[],u=[],d=1,f=null,g=3,m=!1,b=!1,x=!1,v=!1,E=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,D=typeof setImmediate<"u"?setImmediate:null;function I(G){for(var K=t(u);K!==null;){if(K.callback===null)i(u);else if(K.startTime<=G)i(u),K.sortIndex=K.expirationTime,e(c,K);else break;K=t(u)}}function R(G){if(x=!1,I(G),!b)if(t(c)!==null)b=!0,C||(C=!0,Q());else{var K=t(u);K!==null&&ce(R,K.startTime-G)}}var C=!1,M=-1,F=5,U=-1;function k(){return v?!0:!(n.unstable_now()-U<F)}function q(){if(v=!1,C){var G=n.unstable_now();U=G;var K=!0;try{e:{b=!1,x&&(x=!1,A(M),M=-1),m=!0;var X=g;try{t:{for(I(G),f=t(c);f!==null&&!(f.expirationTime>G&&k());){var J=f.callback;if(typeof J=="function"){f.callback=null,g=f.priorityLevel;var se=J(f.expirationTime<=G);if(G=n.unstable_now(),typeof se=="function"){f.callback=se,I(G),K=!0;break t}f===t(c)&&i(c),I(G)}else i(c);f=t(c)}if(f!==null)K=!0;else{var w=t(u);w!==null&&ce(R,w.startTime-G),K=!1}}break e}finally{f=null,g=X,m=!1}K=void 0}}finally{K?Q():C=!1}}}var Q;if(typeof D=="function")Q=function(){D(q)};else if(typeof MessageChannel<"u"){var ie=new MessageChannel,$=ie.port2;ie.port1.onmessage=q,Q=function(){$.postMessage(null)}}else Q=function(){E(q,0)};function ce(G,K){M=E(function(){G(n.unstable_now())},K)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(G){G.callback=null},n.unstable_forceFrameRate=function(G){0>G||125<G?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):F=0<G?Math.floor(1e3/G):5},n.unstable_getCurrentPriorityLevel=function(){return g},n.unstable_next=function(G){switch(g){case 1:case 2:case 3:var K=3;break;default:K=g}var X=g;g=K;try{return G()}finally{g=X}},n.unstable_requestPaint=function(){v=!0},n.unstable_runWithPriority=function(G,K){switch(G){case 1:case 2:case 3:case 4:case 5:break;default:G=3}var X=g;g=G;try{return K()}finally{g=X}},n.unstable_scheduleCallback=function(G,K,X){var J=n.unstable_now();switch(typeof X=="object"&&X!==null?(X=X.delay,X=typeof X=="number"&&0<X?J+X:J):X=J,G){case 1:var se=-1;break;case 2:se=250;break;case 5:se=1073741823;break;case 4:se=1e4;break;default:se=5e3}return se=X+se,G={id:d++,callback:K,priorityLevel:G,startTime:X,expirationTime:se,sortIndex:-1},X>J?(G.sortIndex=X,e(u,G),t(c)===null&&G===t(u)&&(x?(A(M),M=-1):x=!0,ce(R,X-J))):(G.sortIndex=se,e(c,G),b||m||(b=!0,C||(C=!0,Q()))),G},n.unstable_shouldYield=k,n.unstable_wrapCallback=function(G){var K=g;return function(){var X=g;g=K;try{return G.apply(this,arguments)}finally{g=X}}}})(vg)),vg}var pS;function Ew(){return pS||(pS=1,yg.exports=Tw()),yg.exports}var xg={exports:{}},us={};/** 27 * @license React 28 * react-dom.production.js 29 * 30 * Copyright (c) Meta Platforms, Inc. and affiliates. 31 * 32 * This source code is licensed under the MIT license found in the 33 * LICENSE file in the root directory of this source tree. 34 */var _S;function Aw(){if(_S)return us;_S=1;var n=gf();function e(c){var u="https://react.dev/errors/"+c;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)u+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+c+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function t(){}var i={d:{f:t,r:function(){throw Error(e(522))},D:t,C:t,L:t,m:t,X:t,S:t,M:t},p:0,findDOMNode:null},s=Symbol.for("react.portal");function r(c,u,d){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:s,key:f==null?null:""+f,children:c,containerInfo:u,implementation:d}}var a=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function o(c,u){if(c==="font")return"";if(typeof u=="string")return u==="use-credentials"?u:""}return us.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,us.createPortal=function(c,u){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)throw Error(e(299));return r(c,u,null,d)},us.flushSync=function(c){var u=a.T,d=i.p;try{if(a.T=null,i.p=2,c)return c()}finally{a.T=u,i.p=d,i.d.f()}},us.preconnect=function(c,u){typeof c=="string"&&(u?(u=u.crossOrigin,u=typeof u=="string"?u==="use-credentials"?u:"":void 0):u=null,i.d.C(c,u))},us.prefetchDNS=function(c){typeof c=="string"&&i.d.D(c)},us.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,f=o(d,u.crossOrigin),g=typeof u.integrity=="string"?u.integrity:void 0,m=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?i.d.S(c,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:f,integrity:g,fetchPriority:m}):d==="script"&&i.d.X(c,{crossOrigin:f,integrity:g,fetchPriority:m,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},us.preinitModule=function(c,u){if(typeof c=="string")if(typeof u=="object"&&u!==null){if(u.as==null||u.as==="script"){var d=o(u.as,u.crossOrigin);i.d.M(c,{crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0})}}else u==null&&i.d.M(c)},us.preload=function(c,u){if(typeof c=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,f=o(d,u.crossOrigin);i.d.L(c,d,{crossOrigin:f,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0,type:typeof u.type=="string"?u.type:void 0,fetchPriority:typeof u.fetchPriority=="string"?u.fetchPriority:void 0,referrerPolicy:typeof u.referrerPolicy=="string"?u.referrerPolicy:void 0,imageSrcSet:typeof u.imageSrcSet=="string"?u.imageSrcSet:void 0,imageSizes:typeof u.imageSizes=="string"?u.imageSizes:void 0,media:typeof u.media=="string"?u.media:void 0})}},us.preloadModule=function(c,u){if(typeof c=="string")if(u){var d=o(u.as,u.crossOrigin);i.d.m(c,{as:typeof u.as=="string"&&u.as!=="script"?u.as:void 0,crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0})}else i.d.m(c)},us.requestFormReset=function(c){i.d.r(c)},us.unstable_batchedUpdates=function(c,u){return c(u)},us.useFormState=function(c,u,d){return a.H.useFormState(c,u,d)},us.useFormStatus=function(){return a.H.useHostTransitionStatus()},us.version="19.2.1",us}var gS;function nR(){if(gS)return xg.exports;gS=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),xg.exports=Aw(),xg.exports}/** 35 * @license React 36 * react-dom-client.production.js 37 * 38 * Copyright (c) Meta Platforms, Inc. and affiliates. 39 * 40 * This source code is licensed under the MIT license found in the 41 * LICENSE file in the root directory of this source tree. 42 */var mS;function Rw(){if(mS)return uh;mS=1;var n=Ew(),e=gf(),t=nR();function i(l){var h="https://react.dev/errors/"+l;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)h+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+l+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11)}function r(l){var h=l,p=l;if(l.alternate)for(;h.return;)h=h.return;else{l=h;do h=l,(h.flags&4098)!==0&&(p=h.return),l=h.return;while(l)}return h.tag===3?p:null}function a(l){if(l.tag===13){var h=l.memoizedState;if(h===null&&(l=l.alternate,l!==null&&(h=l.memoizedState)),h!==null)return h.dehydrated}return null}function o(l){if(l.tag===31){var h=l.memoizedState;if(h===null&&(l=l.alternate,l!==null&&(h=l.memoizedState)),h!==null)return h.dehydrated}return null}function c(l){if(r(l)!==l)throw Error(i(188))}function u(l){var h=l.alternate;if(!h){if(h=r(l),h===null)throw Error(i(188));return h!==l?null:l}for(var p=l,_=h;;){var y=p.return;if(y===null)break;var S=y.alternate;if(S===null){if(_=y.return,_!==null){p=_;continue}break}if(y.child===S.child){for(S=y.child;S;){if(S===p)return c(y),l;if(S===_)return c(y),h;S=S.sibling}throw Error(i(188))}if(p.return!==_.return)p=y,_=S;else{for(var P=!1,z=y.child;z;){if(z===p){P=!0,p=y,_=S;break}if(z===_){P=!0,_=y,p=S;break}z=z.sibling}if(!P){for(z=S.child;z;){if(z===p){P=!0,p=S,_=y;break}if(z===_){P=!0,_=S,p=y;break}z=z.sibling}if(!P)throw Error(i(189))}}if(p.alternate!==_)throw Error(i(190))}if(p.tag!==3)throw Error(i(188));return p.stateNode.current===p?l:h}function d(l){var h=l.tag;if(h===5||h===26||h===27||h===6)return l;for(l=l.child;l!==null;){if(h=d(l),h!==null)return h;l=l.sibling}return null}var f=Object.assign,g=Symbol.for("react.element"),m=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),x=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),D=Symbol.for("react.context"),I=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),F=Symbol.for("react.lazy"),U=Symbol.for("react.activity"),k=Symbol.for("react.memo_cache_sentinel"),q=Symbol.iterator;function Q(l){return l===null||typeof l!="object"?null:(l=q&&l[q]||l["@@iterator"],typeof l=="function"?l:null)}var ie=Symbol.for("react.client.reference");function $(l){if(l==null)return null;if(typeof l=="function")return l.$$typeof===ie?null:l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case x:return"Fragment";case E:return"Profiler";case v:return"StrictMode";case R:return"Suspense";case C:return"SuspenseList";case U:return"Activity"}if(typeof l=="object")switch(l.$$typeof){case b:return"Portal";case D:return l.displayName||"Context";case A:return(l._context.displayName||"Context")+".Consumer";case I:var h=l.render;return l=l.displayName,l||(l=h.displayName||h.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case M:return h=l.displayName||null,h!==null?h:$(l.type)||"Memo";case F:h=l._payload,l=l._init;try{return $(l(h))}catch{}}return null}var ce=Array.isArray,G=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,K=t.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X={pending:!1,data:null,method:null,action:null},J=[],se=-1;function w(l){return{current:l}}function L(l){0>se||(l.current=J[se],J[se]=null,se--)}function V(l,h){se++,J[se]=l.current,l.current=h}var j=w(null),ae=w(null),he=w(null),be=w(null);function Le(l,h){switch(V(he,h),V(ae,l),V(j,null),h.nodeType){case 9:case 11:l=(l=h.documentElement)&&(l=l.namespaceURI)?gx(l):0;break;default:if(l=h.tagName,h=h.namespaceURI)h=gx(h),l=mx(h,l);else switch(l){case"svg":l=1;break;case"math":l=2;break;default:l=0}}L(j),V(j,l)}function Xe(){L(j),L(ae),L(he)}function it(l){l.memoizedState!==null&&V(be,l);var h=j.current,p=mx(h,l.type);h!==p&&(V(ae,l),V(j,p))}function ut(l){ae.current===l&&(L(j),L(ae)),be.current===l&&(L(be),nh._currentValue=X)}var Oe,Qe;function Be(l){if(Oe===void 0)try{throw Error()}catch(p){var h=p.stack.trim().match(/\n( *(at )?)/);Oe=h&&h[1]||"",Qe=-1<p.stack.indexOf(` 43 at`)?" (<anonymous>)":-1<p.stack.indexOf("@")?"@unknown:0:0":""}return` 44`+Oe+l+Qe}var Ot=!1;function Wt(l,h){if(!l||Ot)return"";Ot=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var _={DetermineComponentFrameRoot:function(){try{if(h){var Me=function(){throw Error()};if(Object.defineProperty(Me.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Me,[])}catch(ye){var me=ye}Reflect.construct(l,[],Me)}else{try{Me.call()}catch(ye){me=ye}l.call(Me.prototype)}}else{try{throw Error()}catch(ye){me=ye}(Me=l())&&typeof Me.catch=="function"&&Me.catch(function(){})}}
vendor: 6,510 bytes, lines 44-49
44catch(ye){if(ye&&me&&typeof ye.stack=="string")return[ye.stack,me.stack]}return[null,null]}};_.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var y=Object.getOwnPropertyDescriptor(_.DetermineComponentFrameRoot,"name");y&&y.configurable&&Object.defineProperty(_.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var S=_.DetermineComponentFrameRoot(),P=S[0],z=S[1];if(P&&z){var ee=P.split(` 45`),ge=z.split(` 46`);for(y=_=0;_<ee.length&&!ee[_].includes("DetermineComponentFrameRoot");)_++;for(;y<ge.length&&!ge[y].includes("DetermineComponentFrameRoot");)y++;if(_===ee.length||y===ge.length)for(_=ee.length-1,y=ge.length-1;1<=_&&0<=y&&ee[_]!==ge[y];)y--;for(;1<=_&&0<=y;_--,y--)if(ee[_]!==ge[y]){if(_!==1||y!==1)do if(_--,y--,0>y||ee[_]!==ge[y]){var Ee=` 47`+ee[_].replace(" at new "," at ");return l.displayName&&Ee.includes("<anonymous>")&&(Ee=Ee.replace("<anonymous>",l.displayName)),Ee}while(1<=_&&0<=y);break}}}finally{Ot=!1,Error.prepareStackTrace=p}return(p=l?l.displayName||l.name:"")?Be(p):""}function vi(l,h){switch(l.tag){case 26:case 27:case 5:return Be(l.type);case 16:return Be("Lazy");case 13:return l.child!==h&&h!==null?Be("Suspense Fallback"):Be("Suspense");case 19:return Be("SuspenseList");case 0:case 15:return Wt(l.type,!1);case 11:return Wt(l.type.render,!1);case 1:return Wt(l.type,!0);case 31:return Be("Activity");default:return""}}function Wi(l){try{var h="",p=null;do h+=vi(l,p),p=l,l=l.return;while(l);return h}catch(_){return` 48Error generating stack: `+_.message+` 49`+_.stack}}var Fi=Object.prototype.hasOwnProperty,ls=n.unstable_scheduleCallback,ur=n.unstable_cancelCallback,Mi=n.unstable_shouldYield,dr=n.unstable_requestPaint,Ci=n.unstable_now,ao=n.unstable_getCurrentPriorityLevel,tn=n.unstable_ImmediatePriority,pa=n.unstable_UserBlockingPriority,sn=n.unstable_NormalPriority,_a=n.unstable_LowPriority,Qi=n.unstable_IdlePriority,Rn=n.log,Li=n.unstable_setDisableYieldValue,Xs=null,ms=null;function Br(l){if(typeof Rn=="function"&&Li(l),ms&&typeof ms.setStrictMode=="function")try{ms.setStrictMode(Xs,l)}catch{}}var cs=Math.clz32?Math.clz32:rn,tp=Math.log,yc=Math.LN2;function rn(l){return l>>>=0,l===0?32:31-(tp(l)/yc|0)|0}var $o=256,Qo=262144,oo=4194304;function nn(l){var h=l&42;if(h!==0)return h;switch(l&-l){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return l&261888;case 262144:case 524288:case 1048576:case 2097152:return l&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return l&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return l}}function pt(l,h,p){var _=l.pendingLanes;if(_===0)return 0;var y=0,S=l.suspendedLanes,P=l.pingedLanes;l=l.warmLanes;var z=_&134217727;return z!==0?(_=z&~S,_!==0?y=nn(_):(P&=z,P!==0?y=nn(P):p||(p=z&~l,p!==0&&(y=nn(p))))):(z=_&~S,z!==0?y=nn(z):P!==0?y=nn(P):p||(p=_&~l,p!==0&&(y=nn(p)))),y===0?0:h!==0&&h!==y&&(h&S)===0&&(S=y&-y,p=h&-h,S>=p||S===32&&(p&4194048)!==0)?h:y}function pi(l,h){return(l.pendingLanes&~(l.suspendedLanes&~l.pingedLanes)&h)===0}function Ki(l,h){switch(l){case 1:case 2:case 4:case 8:case 64:return h+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return h+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function hs(){var l=oo;return oo<<=1,(oo&62914560)===0&&(oo=4194304),l}function ga(l){for(var h=[],p=0;31>p;p++)h.push(l);return h}function xi(l,h){l.pendingLanes|=h,h!==268435456&&(l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0)}function Is(l,h,p,_,y,S){var P=l.pendingLanes;l.pendingLanes=p,l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0,l.expiredLanes&=p,l.entangledLanes&=p,l.errorRecoveryDisabledLanes&=p,l.shellSuspendCounter=0;var z=l.entanglements,ee=l.expirationTimes,ge=l.hiddenUpdates;for(p=P&~p;0<p;){var Ee=31-cs(p),Me=1<<Ee;z[Ee]=0,ee[Ee]=-1;var me=ge[Ee];if(me!==null)for(ge[Ee]=null,Ee=0;Ee<me.length;Ee++){var ye=me[Ee];ye!==null&&(ye.lane&=-536870913)}p&=~Me}_!==0&&lo(l,_,0),S!==0&&y===0&&l.tag!==0&&(l.suspendedLanes|=S&~(P&~h))}function lo(l,h,p){l.pendingLanes|=h,l.suspendedLanes&=~h;var _=31-cs(h);l.entangledLanes|=h,l.entanglements[_]=l.entanglements[_]|1073741824|p&261930}function Ps(l,h){var p=l.entangledLanes|=h;for(l=l.entanglements;p;){var _=31-cs(p),y=1<<_;y&h|l[_]&h&&(l[_]|=h),p&=~y}}function Ds(l,h){var p=h&-h;return p=(p&42)!==0?1:Jo(p),(p&(l.suspendedLanes|h))!==0?0:p}function Jo(l){switch(l){case 2:l=1;break;case 8:l=4;break;case 32:l=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:l=128;break;case 268435456:l=134217728;break;default:l=0}return l}function Ur(l){return l&=-l,2<l?8<l?(l&134217727)!==0?32:268435456:8:2}function ip(){var l=K.p;return l!==0?l:(l=window.event,l===void 0?32:Vx(l.type))}function iy(l,h){var p=K.p;try{return K.p=l,h()}finally{K.p=p}}var ma=Math.random().toString(36).slice(2),Ji="__reactFiber$"+ma,Os="__reactProps$"+ma,el="__reactContainer$"+ma,sp="__reactEvents$"+ma,eP="__reactListeners$"+ma,tP="__reactHandles$"+ma,sy="__reactResources$"+ma,vc="__reactMarker$"+ma;function rp(l){delete l[Ji],delete l[Os],delete l[sp],delete l[eP],delete l[tP]}function tl(l){var h=l[Ji];if(h)return h;for(var p=l.parentNode;p;){if(h=p[el]||p[Ji]){if(p=h.alternate,h.child!==null||p!==null&&p.child!==null)for(l=Ex(l);l!==null;){if(p=l[Ji])return p;l=Ex(l)}return h}l=p,p=l.parentNode}return null}function il(l){if(l=l[Ji]||l[el]){var h=l.tag;if(h===5||h===6||h===13||h===31||h===26||h===27||h===3)return l}return null}function xc(l){var h=l.tag;if(h===5||h===26||h===27||h===6)return l.stateNode;throw Error(i(33))}function sl(l){var h=l[sy];return h||(h=l[sy]={hoistableStyles:new Map,hoistableScripts:new Map}),h}function qi(l){l[vc]=!0}var ry=new Set,ny={};function co(l,h){rl(l,h),rl(l+"Capture",h)}function rl(l,h){for(ny[l]=h,l=0;l<h.length;l++)ry.add(h[l])}var iP=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u
49037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),ay={},oy={};function sP(l){return Fi.call(oy,l)?!0:Fi.call(ay,l)?!1:iP.test(l)?oy[l]=!0:(ay[l]=!0,!1)}function ru(l,h,p){if(sP(h))if(p===null)l.removeAttribute(h);else{switch(typeof p){case"undefined":case"function":case"symbol":l.removeAttribute(h);return;case"boolean":var _=h.toLowerCase().slice(0,5);if(_!=="data-"&&_!=="aria-"){l.removeAttribute(h);return}}l.setAttribute(h,""+p)}}function nu(l,h,p){if(p===null)l.removeAttribute(h);else{switch(typeof p){case"undefined":case"function":case"symbol":case"boolean":l.removeAttribute(h);return}l.setAttribute(h,""+p)}}function Mn(l,h,p,_){if(_===null)l.removeAttribute(p);else{switch(typeof _){case"undefined":case"function":case"symbol":case"boolean":l.removeAttribute(p);return}l.setAttributeNS(h,p,""+_)}}function fr(l){switch(typeof l){case"bigint":case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function ly(l){var h=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(h==="checkbox"||h==="radio")}function rP(l,h,p){var _=Object.getOwnPropertyDescriptor(l.constructor.prototype,h);if(!l.hasOwnProperty(h)&&typeof _<"u"&&typeof _.get=="function"&&typeof _.set=="function"){var y=_.get,S=_.set;return Object.defineProperty(l,h,{configurable:!0,get:function(){return y.call(this)},set:function(P){p=""+P,S.call(this,P)}}),Object.defineProperty(l,h,{enumerable:_.enumerable}),{getValue:function(){return p},setValue:function(P){p=""+P},stopTracking:function(){l._valueTracker=null,delete l[h]}}}}function np(l){if(!l._valueTracker){var h=ly(l)?"checked":"value";l._valueTracker=rP(l,h,""+l[h])}}function cy(l){if(!l)return!1;var h=l._valueTracker;if(!h)return!0;var p=h.getValue(),_="";return l&&(_=ly(l)?l.checked?"true":"false":l.value),l=_,l!==p?(h.setValue(l),!0):!1}function au(l){if(l=l||(typeof document<"u"?document:void 0),typeof l>"u")return null;try{return l.activeElement||l.body}catch{return l.body}}var nP=/[\n"\\]/g;function pr(l){return l.replace(nP,function(h){return"\\"+h.charCodeAt(0).toString(16)+" "})}function ap(l,h,p,_,y,S,P,z){l.name="",P!=null&&typeof P!="function"&&typeof P!="symbol"&&typeof P!="boolean"?l.type=P:l.removeAttribute("type"),h!=null?P==="number"?(h===0&&l.value===""||l.value!=h)&&(l.value=""+fr(h)):l.value!==""+fr(h)&&(l.value=""+fr(h)):P!=="submit"&&P!=="reset"||l.removeAttribute("value"),h!=null?op(l,P,fr(h)):p!=null?op(l,P,fr(p)):_!=null&&l.removeAttribute("value"),y==null&&S!=null&&(l.defaultChecked=!!S),y!=null&&(l.checked=y&&t
vendor: 3,046 bytes, line 49
49ypeof y!="function"&&typeof y!="symbol"),z!=null&&typeof z!="function"&&typeof z!="symbol"&&typeof z!="boolean"?l.name=""+fr(z):l.removeAttribute("name")}function hy(l,h,p,_,y,S,P,z){if(S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(l.type=S),h!=null||p!=null){if(!(S!=="submit"&&S!=="reset"||h!=null)){np(l);return}p=p!=null?""+fr(p):"",h=h!=null?""+fr(h):p,z||h===l.value||(l.value=h),l.defaultValue=h}_=_??y,_=typeof _!="function"&&typeof _!="symbol"&&!!_,l.checked=z?l.checked:!!_,l.defaultChecked=!!_,P!=null&&typeof P!="function"&&typeof P!="symbol"&&typeof P!="boolean"&&(l.name=P),np(l)}function op(l,h,p){h==="number"&&au(l.ownerDocument)===l||l.defaultValue===""+p||(l.defaultValue=""+p)}function nl(l,h,p,_){if(l=l.options,h){h={};for(var y=0;y<p.length;y++)h["$"+p[y]]=!0;for(p=0;p<l.length;p++)y=h.hasOwnProperty("$"+l[p].value),l[p].selected!==y&&(l[p].selected=y),y&&_&&(l[p].defaultSelected=!0)}else{for(p=""+fr(p),h=null,y=0;y<l.length;y++){if(l[y].value===p){l[y].selected=!0,_&&(l[y].defaultSelected=!0);return}h!==null||l[y].disabled||(h=l[y])}h!==null&&(h.selected=!0)}}function uy(l,h,p){if(h!=null&&(h=""+fr(h),h!==l.value&&(l.value=h),p==null)){l.defaultValue!==h&&(l.defaultValue=h);return}l.defaultValue=p!=null?""+fr(p):""}function dy(l,h,p,_){if(h==null){if(_!=null){if(p!=null)throw Error(i(92));if(ce(_)){if(1<_.length)throw Error(i(93));_=_[0]}p=_}p==null&&(p=""),h=p}p=fr(h),l.defaultValue=p,_=l.textContent,_===p&&_!==""&&_!==null&&(l.value=_),np(l)}function al(l,h){if(h){var p=l.firstChild;if(p&&p===l.lastChild&&p.nodeType===3){p.nodeValue=h;return}}l.textContent=h}var aP=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function fy(l,h,p){var _=h.indexOf("--")===0;p==null||typeof p=="boolean"||p===""?_?l.setProperty(h,""):h==="float"?l.cssFloat="":l[h]="":_?l.setProperty(h,p):typeof p!="number"||p===0||aP.has(h)?h==="float"?l.cssFloat=p:l[h]=(""+p).trim():l[h]=p+"px"}function py(l,h,p){if(h!=null&&typeof h!="object")throw Error(i(62));if(l=l.style,p!=null){for(var _ in p)!p.hasOwnProperty(_)||h!=null&&h.hasOwnProperty(_)||(_.indexOf("--")===0?l.setProperty(_,""):_
vendor: 6,602 bytes, line 49
49==="float"?l.cssFloat="":l[_]="");for(var y in h)_=h[y],h.hasOwnProperty(y)&&p[y]!==_&&fy(l,y,_)}else for(var S in h)h.hasOwnProperty(S)&&fy(l,S,h[S])}function lp(l){if(l.indexOf("-")===-1)return!1;switch(l){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var oP=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),lP=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function ou(l){return lP.test(""+l)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":l}function Cn(){}var cp=null;function hp(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var ol=null,ll=null;function _y(l){var h=il(l);if(h&&(l=h.stateNode)){var p=l[Os]||null;e:switch(l=h.stateNode,h.type){case"input":if(ap(l,p.value,p.defaultValue,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name),h=p.name,p.type==="radio"&&h!=null){for(p=l;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll('input[name="'+pr(""+h)+'"][type="radio"]'),h=0;h<p.length;h++){var _=p[h];if(_!==l&&_.form===l.form){var y=_[Os]||null;if(!y)throw Error(i(90));ap(_,y.value,y.defaultValue,y.defaultValue,y.checked,y.defaultChecked,y.type,y.name)}}for(h=0;h<p.length;h++)_=p[h],_.form===l.form&&cy(_)}break e;case"textarea":uy(l,p.value,p.defaultValue);break e;case"select":h=p.value,h!=null&&nl(l,!!p.multiple,h,!1)}}}var up=!1;function gy(l,h,p){if(up)return l(h,p);up=!0;try{var _=l(h);return _}finally{if(up=!1,(ol!==null||ll!==null)&&(Ku(),ol&&(h=ol,l=ll,ll=ol=null,_y(h),l)))for(h=0;h<l.length;h++)_y(l[h])}}function Sc(l,h){var p=l.stateNode;if(p===null)return null;var _=p[Os]||null;if(_===null)return null;p=_[h];e:switch(h){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(_=!_.disabled)||(l=l.type,_=!(l==="button"||l==="input"||l==="select"||l==="textarea")),l=!_;break e;default:l=!1}if(l)return null;if(p&&typeof p!="function")throw Error(i(231,h,typeof p));return p}var In=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),dp=!1;if(In)try{var Tc={};Object.defineProperty(Tc,"passive",{get:function(){dp=!0}}),window.addEventListener("test",Tc,Tc),window.removeEventListener("test",Tc,Tc)}catch{dp=!1}var ba=null,fp=null,lu=null;function my(){if(lu)return lu;var l,h=fp,p=h.length,_,y="value"in ba?ba.value:ba.textContent,S=y.length;for(l=0;l<p&&h[l]===y[l];l++);var P=p-l;for(_=1;_<=P&&h[p-_]===y[S-_];_++);return lu=y.slice(l,1<_?1-_:void 0)}function cu(l){var h=l.keyCode;return"charCode"in l?(l=l.charCode,l===0&&h===13&&(l=13)):l=h,l===10&&(l=13),32<=l||l===13?l:0}function hu(){return!0}function by(){return!1}function ws(l){function h(p,_,y,S,P){this._reactName=p,this._targetInst=y,this.type=_,this.nativeEvent=S,this.target=P,this.currentTarget=null;for(var z in l)l.hasOwnProperty(z)&&(p=l[z],this[z]=p?p(S):S[z]);return this.isDefaultPrevented=(S.defaultPrevented!=null?S.defaultPrevented:S.returnValue===!1)?hu:by,this.isPropagationStopped=by,this}return f(h.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=hu)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=hu)},persist:function(){},isPersistent:hu}),h}var ho={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(l){return l.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},uu=ws(ho),Ec=f({},ho,{view:0,detail:0}
vendor: 4,144 bytes, line 49
49),cP=ws(Ec),pp,_p,Ac,du=f({},Ec,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:mp,button:0,buttons:0,relatedTarget:function(l){return l.relatedTarget===void 0?l.fromElement===l.srcElement?l.toElement:l.fromElement:l.relatedTarget},movementX:function(l){return"movementX"in l?l.movementX:(l!==Ac&&(Ac&&l.type==="mousemove"?(pp=l.screenX-Ac.screenX,_p=l.screenY-Ac.screenY):_p=pp=0,Ac=l),pp)},movementY:function(l){return"movementY"in l?l.movementY:_p}}),yy=ws(du),hP=f({},du,{dataTransfer:0}),uP=ws(hP),dP=f({},Ec,{relatedTarget:0}),gp=ws(dP),fP=f({},ho,{animationName:0,elapsedTime:0,pseudoElement:0}),pP=ws(fP),_P=f({},ho,{clipboardData:function(l){return"clipboardData"in l?l.clipboardData:window.clipboardData}}),gP=ws(_P),mP=f({},ho,{data:0}),vy=ws(mP),bP={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},yP={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},vP={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function xP(l){var h=this.nativeEvent;return h.getModifierState?h.getModifierState(l):(l=vP[l])?!!h[l]:!1}function mp(){return xP}var SP=f({},Ec,{key:function(l){if(l.key){var h=bP[l.key]||l.key;if(h!=="Unidentified")return h}return l.type==="keypress"?(l=cu(l),l===13?"Enter":String.fromCharCode(l)):l.type==="keydown"||l.type==="keyup"?yP[l.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:mp,charCode:function(l){return l.type==="keypress"?cu(l):0},keyCode:function(l){return l.type==="keydown"||l.type==="keyup"?l.keyCode:0},which:function(l){return l.type==="keypress"?cu(l):l.type==="keydown"||l.type==="keyup"?l.keyCode:0}}),TP=ws(SP),EP=f({},du,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),xy=ws(EP),AP=f({},Ec,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:mp}),RP=ws(AP),MP=f({},ho,{propertyName:0,elapsedTime:0,pseudoElement:0}),CP=ws(MP),IP=f({},du,{deltaX:function(l){return"deltaX"in l?l.deltaX:"wheelDeltaX"in l?-l.wheelDeltaX:0},deltaY:function(l){return"deltaY"in l?l.deltaY:"wheelDeltaY"in l?-l.wheelDeltaY:"wheelDelta"in l?-l.wheelDelta:0},deltaZ:0,deltaMode:0}),PP=ws(IP),DP=f({},ho,{newState:0,oldState:0}),OP=ws(DP),wP=[9,13,27,32],bp=In&&"CompositionEvent"in window,Rc=null;In&&"documentMode"in document&&(Rc=document.documentMode);var FP=In&&"TextEvent"in window&&!Rc,Sy=In&&(!bp||Rc&&8<Rc&&11>=Rc),Ty=" ",Ey=!1;function Ay(l,h){switch(l){case"keyup":return wP.indexOf(h.keyCode)!==-1;case"keydown":return h.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ry(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var cl=!1;function LP(l,h){switch(l){case"compositionend":return Ry(h);case"keypress":return h.which!==32?null:(Ey=!0,Ty);case"textInput":return l=h.data,l===Ty&&Ey?null:l;default:return null}}function NP(l,h){if(cl)return l==="compositionend"||!bp&&Ay(l,h)?(l=my(),lu=fp=ba=null,cl=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(h.ctrlKey||h.altKey||h.metaKey)||h.ctrlKey&&h.altKey){if(h.char&&1<h.char.length)return h.char;if(h.which)return String.fromCharCode(h.which)}return null;case"compositionend":return Sy&&h.locale!=="ko"?null:h.data;default:return null}}var BP={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function My(l){var h=l&&l.nodeName&&l.nodeName.toLowerCase();return h==="input"?!!BP[l.type]:h==="textarea"}
vendor: 6,273 bytes, line 49
49function Cy(l,h,p,_){ol?ll?ll.push(_):ll=[_]:ol=_,h=td(h,"onChange"),0<h.length&&(p=new uu("onChange","change",null,p,_),l.push({event:p,listeners:h}))}var Mc=null,Cc=null;function UP(l){hx(l,0)}function fu(l){var h=xc(l);if(cy(h))return l}function Iy(l,h){if(l==="change")return h}var Py=!1;if(In){var yp;if(In){var vp="oninput"in document;if(!vp){var Dy=document.createElement("div");Dy.setAttribute("oninput","return;"),vp=typeof Dy.oninput=="function"}yp=vp}else yp=!1;Py=yp&&(!document.documentMode||9<document.documentMode)}function Oy(){Mc&&(Mc.detachEvent("onpropertychange",wy),Cc=Mc=null)}function wy(l){if(l.propertyName==="value"&&fu(Cc)){var h=[];Cy(h,Cc,l,hp(l)),gy(UP,h)}}function kP(l,h,p){l==="focusin"?(Oy(),Mc=h,Cc=p,Mc.attachEvent("onpropertychange",wy)):l==="focusout"&&Oy()}function VP(l){if(l==="selectionchange"||l==="keyup"||l==="keydown")return fu(Cc)}function zP(l,h){if(l==="click")return fu(h)}function GP(l,h){if(l==="input"||l==="change")return fu(h)}function HP(l,h){return l===h&&(l!==0||1/l===1/h)||l!==l&&h!==h}var js=typeof Object.is=="function"?Object.is:HP;function Ic(l,h){if(js(l,h))return!0;if(typeof l!="object"||l===null||typeof h!="object"||h===null)return!1;var p=Object.keys(l),_=Object.keys(h);if(p.length!==_.length)return!1;for(_=0;_<p.length;_++){var y=p[_];if(!Fi.call(h,y)||!js(l[y],h[y]))return!1}return!0}function Fy(l){for(;l&&l.firstChild;)l=l.firstChild;return l}function Ly(l,h){var p=Fy(l);l=0;for(var _;p;){if(p.nodeType===3){if(_=l+p.textContent.length,l<=h&&_>=h)return{node:p,offset:h-l};l=_}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=Fy(p)}}function Ny(l,h){return l&&h?l===h?!0:l&&l.nodeType===3?!1:h&&h.nodeType===3?Ny(l,h.parentNode):"contains"in l?l.contains(h):l.compareDocumentPosition?!!(l.compareDocumentPosition(h)&16):!1:!1}function By(l){l=l!=null&&l.ownerDocument!=null&&l.ownerDocument.defaultView!=null?l.ownerDocument.defaultView:window;for(var h=au(l.document);h instanceof l.HTMLIFrameElement;){try{var p=typeof h.contentWindow.location.href=="string"}catch{p=!1}if(p)l=h.contentWindow;else break;h=au(l.document)}return h}function xp(l){var h=l&&l.nodeName&&l.nodeName.toLowerCase();return h&&(h==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||h==="textarea"||l.contentEditable==="true")}var WP=In&&"documentMode"in document&&11>=document.documentMode,hl=null,Sp=null,Pc=null,Tp=!1;function Uy(l,h,p){var _=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;Tp||hl==null||hl!==au(_)||(_=hl,"selectionStart"in _&&xp(_)?_={start:_.selectionStart,end:_.selectionEnd}:(_=(_.ownerDocument&&_.ownerDocument.defaultView||window).getSelection(),_={anchorNode:_.anchorNode,anchorOffset:_.anchorOffset,focusNode:_.focusNode,focusOffset:_.focusOffset}),Pc&&Ic(Pc,_)||(Pc=_,_=td(Sp,"onSelect"),0<_.length&&(h=new uu("onSelect","select",null,h,p),l.push({event:h,listeners:_}),h.target=hl)))}function uo(l,h){var p={};return p[l.toLowerCase()]=h.toLowerCase(),p["Webkit"+l]="webkit"+h,p["Moz"+l]="moz"+h,p}var ul={animationend:uo("Animation","AnimationEnd"),animationiteration:uo("Animation","AnimationIteration"),animationstart:uo("Animation","AnimationStart"),transitionrun:uo("Transition","TransitionRun"),transitionstart:uo("Transition","TransitionStart"),transitioncancel:uo("Transition","TransitionCancel"),transitionend:uo("Transition","TransitionEnd")},Ep={},ky={};In&&(ky=document.createElement("div").style,"AnimationEvent"in window||(delete ul.animationend.animation,delete ul.animationiteration.animation,delete ul.animationstart.animation),"TransitionEvent"in window||delete ul.transitionend.transition);function fo(l){if(Ep[l])return Ep[l];if(!ul[l])return l;var h=ul[l],p;for(p in h)if(h.hasOwnProperty(p)&&p in ky)return Ep[l]=h[p];return l}var Vy=fo("animationend"),zy=fo("animationiteration"),Gy=fo("animationstart"),XP=fo("transitionrun"),jP=fo("transitionstart"),YP=fo("transitioncancel"),Hy=fo("transitionend"),Wy=new Map,Ap="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");Ap.push("scrollEnd");function kr(l,h){Wy.set(l,h),co(h,[l])}var pu=typeof reportError=="function"?reportError:function(l){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var h=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof l=="object"&&l!==null&&typeof l.message=="string"?String(l.message):String(l),error:l});if(!window.dispatchEvent(h))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",l);return}console.error(l)},_r=[],dl=0,Rp=0;function _u(){for(var l=dl,h=Rp=dl=0;h<l;){var p=_r[h];_r[h++]=null;var _=_r[h];_r[h++]=null;var y=_r[h];_r[h++]=null;var S=_r[h];if(_r[h++]=null,_!==null&&y!==null){var P=_.pending;P===null?y.next=y:(y.next=P.next,P.next=y),_.pending=y}S!==0&&Xy(p,y,S)}}function gu(l,h,p,_){_r[dl++]=l,_r[dl++]=h,_r[dl++]=p,_r[dl++]=_,Rp|=_,l.lanes|=_,l=l.alternate,l!==null&&(l.lanes|=_)}function Mp(l,h,p,_){return gu(l,h,p,_),mu(l)}function po(l,h){return gu(l,null,null,h),mu(l)}function Xy(l,h,p){l.lanes|=p;var _=l.alternate;_!==null&&(_.lanes|=p);for(var y=!1,S=l.return;S!==null;)S.childLanes|=p,_=S.alternate,_!==null&&(_.childLanes|=p),S.tag===22&&(l=S.stateNode,l===null||l._visibility&1||(y=!0)),l=S,S=S.return;return l.tag===3?(S=l.stateNode,y&&h!==null&&(y=31-cs(p),l=S.hiddenUpdates,_=l[y],_===null?l[y]=[h]:_.push(h),h.lane=p|536870912),S):null}function mu(l){if(50<Qc)throw Qc=0,N_=null,Error(i(185));for(var h=l.return;h!==null;)l=h,h=l.return;return l.tag===3?l.stateNode:null}var fl={};function KP(l,h,p,_){this.tag=l,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.t
vendor: 18,959 bytes, line 49
49ype=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=h,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=_,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ys(l,h,p,_){return new KP(l,h,p,_)}function Cp(l){return l=l.prototype,!(!l||!l.isReactComponent)}function Pn(l,h){var p=l.alternate;return p===null?(p=Ys(l.tag,h,l.key,l.mode),p.elementType=l.elementType,p.type=l.type,p.stateNode=l.stateNode,p.alternate=l,l.alternate=p):(p.pendingProps=h,p.type=l.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=l.flags&65011712,p.childLanes=l.childLanes,p.lanes=l.lanes,p.child=l.child,p.memoizedProps=l.memoizedProps,p.memoizedState=l.memoizedState,p.updateQueue=l.updateQueue,h=l.dependencies,p.dependencies=h===null?null:{lanes:h.lanes,firstContext:h.firstContext},p.sibling=l.sibling,p.index=l.index,p.ref=l.ref,p.refCleanup=l.refCleanup,p}function jy(l,h){l.flags&=65011714;var p=l.alternate;return p===null?(l.childLanes=0,l.lanes=h,l.child=null,l.subtreeFlags=0,l.memoizedProps=null,l.memoizedState=null,l.updateQueue=null,l.dependencies=null,l.stateNode=null):(l.childLanes=p.childLanes,l.lanes=p.lanes,l.child=p.child,l.subtreeFlags=0,l.deletions=null,l.memoizedProps=p.memoizedProps,l.memoizedState=p.memoizedState,l.updateQueue=p.updateQueue,l.type=p.type,h=p.dependencies,l.dependencies=h===null?null:{lanes:h.lanes,firstContext:h.firstContext}),l}function bu(l,h,p,_,y,S){var P=0;if(_=l,typeof l=="function")Cp(l)&&(P=1);else if(typeof l=="string")P=J1(l,p,j.current)?26:l==="html"||l==="head"||l==="body"?27:5;else e:switch(l){case U:return l=Ys(31,p,h,y),l.elementType=U,l.lanes=S,l;case x:return _o(p.children,y,S,h);case v:P=8,y|=24;break;case E:return l=Ys(12,p,h,y|2),l.elementType=E,l.lanes=S,l;case R:return l=Ys(13,p,h,y),l.elementType=R,l.lanes=S,l;case C:return l=Ys(19,p,h,y),l.elementType=C,l.lanes=S,l;default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case D:P=10;break e;case A:P=9;break e;case I:P=11;break e;case M:P=14;break e;case F:P=16,_=null;break e}P=29,p=Error(i(130,l===null?"null":typeof l,"")),_=null}return h=Ys(P,p,h,y),h.elementType=l,h.type=_,h.lanes=S,h}function _o(l,h,p,_){return l=Ys(7,l,_,h),l.lanes=p,l}function Ip(l,h,p){return l=Ys(6,l,null,h),l.lanes=p,l}function Yy(l){var h=Ys(18,null,null,0);return h.stateNode=l,h}function Pp(l,h,p){return h=Ys(4,l.children!==null?l.children:[],l.key,h),h.lanes=p,h.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},h}var Ky=new WeakMap;function gr(l,h){if(typeof l=="object"&&l!==null){var p=Ky.get(l);return p!==void 0?p:(h={value:l,source:h,stack:Wi(h)},Ky.set(l,h),h)}return{value:l,source:h,stack:Wi(h)}}var pl=[],_l=0,yu=null,Dc=0,mr=[],br=0,ya=null,an=1,on="";function Dn(l,h){pl[_l++]=Dc,pl[_l++]=yu,yu=l,Dc=h}function qy(l,h,p){mr[br++]=an,mr[br++]=on,mr[br++]=ya,ya=l;var _=an;l=on;var y=32-cs(_)-1;_&=~(1<<y),p+=1;var S=32-cs(h)+y;if(30<S){var P=y-y%5;S=(_&(1<<P)-1).toString(32),_>>=P,y-=P,an=1<<32-cs(h)+y|p<<y|_,on=S+l}else an=1<<S|p<<y|_,on=l}function Dp(l){l.return!==null&&(Dn(l,1),qy(l,1,0))}function Op(l){for(;l===yu;)yu=pl[--_l],pl[_l]=null,Dc=pl[--_l],pl[_l]=null;for(;l===ya;)ya=mr[--br],mr[br]=null,on=mr[--br],mr[br]=null,an=mr[--br],mr[br]=null}function Zy(l,h){mr[br++]=an,mr[br++]=on,mr[br++]=ya,an=h.id,on=h.overflow,ya=l}var es=null,ci=null,wt=!1,va=null,yr=!1,wp=Error(i(519));function xa(l){var h=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Oc(gr(h,l)),wp}function $y(l){var h=l.stateNode,p=l.type,_=l.memoizedProps;switch(h[Ji]=l,h[Os]=_,p){case"dialog":Mt("cancel",h),Mt("close",h);break;case"iframe":case"object":case"embed":Mt("load",h);break;case"video":case"audio":for(p=0;p<eh.length;p++)Mt(eh[p],h);break;case"source":Mt("error",h);break;case"img":case"image":case"link":Mt("error",h),Mt("load",h);break;case"details":Mt("toggle",h);break;case"input":Mt("invalid",h),hy(h,_.value,_.defaultValue,_.checked,_.defaultChecked,_.type,_.name,!0);break;case"select":Mt("invalid",h);break;case"textarea":Mt("invalid",h),dy(h,_.value,_.defaultValue,_.children)}p=_.children,typeof p!="string"&&typeof p!="number"&&typeof p!="bigint"||h.textContent===""+p||_.suppressHydrationWarning===!0||px(h.textContent,p)?(_.popover!=null&&(Mt("beforetoggle",h),Mt("toggle",h)),_.onScroll!=null&&Mt("scroll",h),_.onScrollEnd!=null&&Mt("scrollend",h),_.onClick!=null&&(h.onclick=Cn),h=!0):h=!1,h||xa(l,!0)}function Qy(l){for(es=l.return;es;)switch(es.tag){case 5:case 31:case 13:yr=!1;return;case 27:case 3:yr=!0;return;default:es=es.return}}function gl(l){if(l!==es)return!1;if(!wt)return Qy(l),wt=!0,!1;var h=l.tag,p;if((p=h!==3&&h!==27)&&((p=h===5)&&(p=l.type,p=!(p!=="form"&&p!=="button")||$_(l.type,l.memoizedProps)),p=!p),p&&ci&&xa(l),Qy(l),h===13){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(i(317));ci=Tx(l)}else if(h===31){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(i(317));ci=Tx(l)}else h===27?(h=ci,La(l.type)?(l=ig,ig=null,ci=l):ci=h):ci=es?xr(l.stateNode.nextSibling):null;return!0}function go(){ci=es=null,wt=!1}function Fp(){var l=va;return l!==null&&(Bs===null?Bs=l:Bs.push.apply(Bs,l),va=null),l}function Oc(l){va===null?va=[l]:va.push(l)}var Lp=w(null),mo=null,On=null;function Sa(l,h,p){V(Lp,h._currentValue),h._currentValue=p}function wn(l){l._currentValue=Lp.current,L(Lp)}function Np(l,h,p){for(;l!==null;){var _=l.alternate;if((l.childLanes&h)!==h?(l.childLanes|=h,_!==null&&(_.childLanes|=h)):_!==null&&(_.childLanes&h)!==h&&(_.childLanes|=h),l===p)break;l=l.return}}function Bp(l,h,p,_){var y=l.child;for(y!==null&&(y.return=l);y!==null;){var S=y.dependencies;if(S!==null){var P=y.child;S=S.firstContext;e:for(;S!==null;){var z=S;S=y;for(var ee=0;ee<h.length;ee++)if(z.context===h[ee]){S.lanes|=p,z=S.alternate,z!==null&&(z.lanes|=p),Np(S.return,p,l),_||(P=null);break e}S=z.next}}else if(y.tag===18){if(P=y.return,P===null)throw Error(i(341));P.lanes|=p,S=P.alternate,S!==null&&(S.lanes|=p),Np(P,p,l),P=null}else P=y.child;if(P!==null)P.return=y;else for(P=y;P!==null;){if(P===l){P=null;break}if(y=P.sibling,y!==null){y.return=P.return,P=y;break}P=P.return}y=P}}function ml(l,h,p,_){l=null;for(var y=h,S=!1;y!==null;){if(!S){if((y.flags&524288)!==0)S=!0;else if((y.flags&262144)!==0)break}if(y.tag===10){var P=y.alternate;if(P===null)throw Error(i(387));if(P=P.memoizedProps,P!==null){var z=y.type;js(y.pendingProps.value,P.value)||(l!==null?l.push(z):l=[z])}}else if(y===be.current){if(P=y.alternate,P===null)throw Error(i(387));P.memoizedState.memoizedState!==y.memoizedState.memoizedState&&(l!==null?l.push(nh):l=[nh])}y=y.return}l!==null&&Bp(h,l,p,_),h.flags|=262144}function vu(l){for(l=l.firstContext;l!==null;){if(!js(l.context._currentValue,l.memoizedValue))return!0;l=l.next}return!1}function bo(l){mo=l,On=null,l=l.dependencies,l!==null&&(l.firstContext=null)}function ts(l){return Jy(mo,l)}function xu(l,h){return mo===null&&bo(l),Jy(l,h)}function Jy(l,h){var p=h._currentValue;if(h={context:h,memoizedValue:p,next:null},On===null){if(l===null)throw Error(i(308));On=h,l.dependencies={lanes:0,firstContext:h},l.flags|=524288}else On=On.next=h;return p}var qP=typeof AbortController<"u"?AbortController:function(){var l=[],h=this.signal={aborted:!1,addEventListener:function(p,_){l.push(_)}};this.abort=function(){h.aborted=!0,l.forEach(function(p){return p()})}},ZP=n.unstable_scheduleCallback,$P=n.unstable_NormalPriority,Ni={$$typeof:D,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Up(){return{controller:new qP,data:new Map,refCount:0}}function wc(l){l.refCount--,l.refCount===0&&ZP($P,function(){l.controller.abort()})}var Fc=null,kp=0,bl=0,yl=null;function QP(l,h){if(Fc===null){var p=Fc=[];kp=0,bl=G_(),yl={status:"pending",value:void 0,then:function(_){p.push(_)}}}return kp++,h.then(e0,e0),h}function e0(){if(--kp===0&&Fc!==null){yl!==null&&(yl.status="fulfilled");var l=Fc;Fc=null,bl=0,yl=null;for(var h=0;h<l.length;h++)(0,l[h])()}}function JP(l,h){var p=[],_={status:"pending",value:null,reason:null,then:function(y){p.push(y)}};return l.then(function(){_.status="fulfilled",_.value=h;for(var y=0;y<p.length;y++)(0,p[y])(h)},function(y){for(_.status="rejected",_.reason=y,y=0;y<p.length;y++)(0,p[y])(void 0)}),_}var t0=G.S;G.S=function(l,h){Uv=Ci(),typeof h=="object"&&h!==null&&typeof h.then=="function"&&QP(l,h),t0!==null&&t0(l,h)};var yo=w(null);function Vp(){var l=yo.current;return l!==null?l:ii.pooledCache}function Su(l,h){h===null?V(yo,yo.current):V(yo,h.pool)}function i0(){var l=Vp();return l===null?null:{parent:Ni._currentValue,pool:l}}var vl=Error(i(460)),zp=Error(i(474)),Tu=Error(i(542)),Eu={then:function(){}};function s0(l){return l=l.status,l==="fulfilled"||l==="rejected"}function r0(l,h,p){switch(p=l[p],p===void 0?l.push(h):p!==h&&(h.then(Cn,Cn),h=p),h.status){case"fulfilled":return h.value;case"rejected":throw l=h.reason,a0(l),l;default:if(typeof h.status=="string")h.then(Cn,Cn);else{if(l=ii,l!==null&&100<l.shellSuspendCounter)throw Error(i(482));l=h,l.status="pending",l.then(function(_){if(h.status==="pending"){var y=h;y.status="fulfilled",y.value=_}},function(_){if(h.status==="pending"){var y=h;y.status="rejected",y.reason=_}})}switch(h.status){case"fulfilled":return h.value;case"rejected":throw l=h.reason,a0(l),l}throw xo=h,vl}}function vo(l){try{var h=l._init;return h(l._payload)}catch(p){throw p!==null&&typeof p=="object"&&typeof p.then=="function"?(xo=p,vl):p}}var xo=null;function n0(){if(xo===null)throw Error(i(459));var l=xo;return xo=null,l}function a0(l){if(l===vl||l===Tu)throw Error(i(483))}var xl=null,Lc=0;function Au(l){var h=Lc;return Lc+=1,xl===null&&(xl=[]),r0(xl,l,h)}function Nc(l,h){h=h.props.ref,l.ref=h!==void 0?h:null}function Ru(l,h){throw h.$$typeof===g?Error(i(525)):(l=Object.prototype.toString.call(h),Error(i(31,l==="[object Object]"?"object with keys {"+Object.keys(h).join(", ")+"}":l)))}function o0(l){function h(ue,ne){if(l){var _e=ue.deletions;_e===null?(ue.deletions=[ne],ue.flags|=16):_e.push(ne)}}function p(ue,ne){if(!l)return null;for(;ne!==null;)h(ue,ne),ne=ne.sibling;return null}function _(ue){for(var ne=new Map;ue!==null;)ue.key!==null?ne.set(ue.key,ue):ne.set(ue.index,ue),ue=ue.sibling;return ne}function y(ue,ne){return ue=Pn(ue,ne),ue.index=0,ue.sibling=null,ue}function S(ue,ne,_e){return ue.index=_e,l?(_e=ue.alternate,_e!==null?(_e=_e.index,_e<ne?(ue.flags|=67108866,ne):_e):(ue.flags|=67108866,ne)):(ue.flags|=1048576,ne)}function P(ue){return l&&ue.alternate===null&&(ue.flags|=67108866),ue}function z(ue,ne,_e,Re){return ne===null||ne.tag!==6?(ne=Ip(_e,ue.mode,Re),ne.return=ue,ne):(ne=y(ne,_e),ne.return=ue,ne)}function ee(ue,ne,_e,Re){var nt=_e.type;return nt===x?Ee(ue,ne,_e.props.children,Re,_e.key):ne!==null&&(ne.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===F&&vo(nt)===ne.type)?(ne=y(ne,_e.props),Nc(ne,_e),ne.return=ue,ne):(ne=bu(_e.type,_e.key,_e.props,null,ue.mode,Re),Nc(ne,_e),ne.return=ue,ne)}function ge(ue,ne,_e,Re){return ne===null||ne.tag!==4||ne.stateNode.containerInfo!==_e.containerInfo||ne.stateNode.implementation!==_e.implementation?(ne=Pp(_e,ue.mode,Re),ne.return=ue,ne):(ne=y(ne,_e.children||[]),ne.return=ue,ne)}function Ee(ue,ne,_e,Re,nt){return ne===null||ne.tag!==7?(ne=_o(_e,ue.mode,Re,nt),ne.return=ue,ne):(ne=y(ne,_e),ne.return=ue,ne)}function Me(ue,ne,_e){if(typeof ne=="string"&&ne!==""||typeof ne=="number"||typeof ne=="bigint")return ne=Ip(""+ne,ue.mode,_e),ne.return=ue,ne;if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case m:return _e=bu(ne.type,ne.key,ne.props,null,ue.mode,_e),Nc(_e,ne),_e.return=ue,_e;case b:return ne=Pp(ne,ue.mode,_e),ne.return=ue,ne;case F:return ne=vo(ne),Me(ue,ne,_e)}if(ce(ne)||Q(ne))return ne=_o(ne,ue.mode,_e,null),ne.return=ue,ne;if(typeof ne.then=="function")return Me(ue,Au(ne),_e);if(ne.$$typeof===D)return Me(ue,xu(ue,ne),_e);Ru(ue,ne)}return null}function me(ue,ne,_e,Re){var nt=ne!==null?ne.key:null;if(typeof _e=="string"&&_e!==""||typeof _e=="number"||typeof _e=="bigint")return nt!==null?null:z(ue,ne,""+_e,Re);if(typeof _e=="object"&&_e!==null){switch(_e.$$typeof){case m:return _e.key===nt?ee(ue,ne,_e,Re):null;case b:return _e.key===nt?ge(ue,ne,_e,Re):null;case F:return _e=vo(_e),me(ue,ne,_e,Re)}if(ce(_e)||Q(_e))return nt!==null?null:Ee(ue,ne,_e,Re,null);if(typeof _e.then=="function")return me(ue,ne,Au(_e),Re);if(_e.$$typeof===D)return me(ue,ne,xu(ue,_e),Re);Ru(ue,_e)}return null}function ye(ue,ne,_e,Re,nt){if(typeof Re=="string"&&Re!==""||typeof Re=="number"||typeof Re=="bigint")return ue=ue.get(_e)||null,z(ne,ue,""+Re,nt);if(typeof Re=="object"&&Re!==null){switch(Re.$$typeof){case m:return ue=ue.get(Re.key===null?_e:Re.key)||null,ee(ne,ue,Re,nt);case b:return ue=ue.get(Re.key===null?_e:Re.key)||null,ge(ne,ue,Re,nt);case F:return Re=vo(Re),ye(ue,ne,_e,Re,nt)}if(ce(Re)||Q(Re))return ue=ue.get(_e)||null,Ee(ne,ue,Re,nt,null);if(typeof Re.then=="function")return ye(ue,ne,_e,Au(Re),nt);if(Re.$$typeof===D)return ye(ue,ne,_e,xu(ne,Re),nt);Ru(ne,Re)}return null}function Je(ue,ne,_e,Re){for(var nt=null,Vt=null,st=ne,St=ne=0,It=null;st!==null&&St<_e.length;St++){st.index>St?(It=st,st=null):It=st.sibling;var zt=me(ue,st,_e[St],Re);if(zt===null){st===null&&(st=It);break}l&&st&&zt.alternate===null&&h(ue,st),ne=S(zt,ne,St),Vt===null?nt=zt:Vt.sibling=zt,Vt=zt,st=It}if(St===_e.length)return p(ue,st),wt&&Dn(ue,St),nt;if(st===null){for(;St<_e.length;St++)st=Me(ue,_e[St],Re),st!==null&&(ne=S(st,ne,St),Vt===null?nt=st:Vt.sibling=st,Vt=st);return wt&&Dn(ue,St),nt}for(st=_(st);St<_e.length;St++)It=ye(st,ue,St,_e[St],Re),It!==null&&(l&&It.alternate!==null&&st.delete(It.key===null?St:It.key),ne=S(It,ne,St),Vt===null?nt=It:Vt.sibling=It,Vt=It);return l&&st.forEach(function(Va){return h(ue,Va)}),wt&&Dn(ue,St),nt}function ct(ue,ne,_e,Re){if(_e==null)throw Error(i(151));for(var nt=null,Vt=null,st=ne,St=ne=0,It=null,zt=_e.next();st!==null&&!zt.done;St++,zt=_e.next()){st.index>St?(It=st,st=null):It=st.sibling;var Va=me(ue,st,zt.value,Re);if(Va===null){st===null&&(st=It);break}l&&st&&Va.alternate===null&&h(ue,st),ne=S(Va,ne,St),Vt===null?nt=Va:Vt.sibling=Va,Vt=Va,st=It}if(zt.done)return p(ue,st),wt&&Dn(ue,St),nt;if(st===null){for(;!zt.done;St++,zt=_e.next())zt=Me(ue,zt.value,Re),zt!==null&&(ne=S(zt,ne,St),Vt===null?nt=zt:Vt.sibling=zt,Vt=zt);return wt&&Dn(ue,St),nt}for(st=_(st);!zt.done;St++,zt=_e.next())zt=ye(st,ue,St,zt.value,Re),zt!==null&&(l&&zt.alternate!==null&&st.delete(zt.key===null?St:zt.key),ne=S(zt,ne,St),Vt===null?nt=zt:Vt.sibling=zt,Vt=zt);return l&&st.forEach(function(hD){return h(ue,hD)}),wt&&Dn(ue,St),nt}function ti(ue,ne,_e,Re){if(typeof _e=="object"&&_e!==null&&_e.type===x&&_e.key===null&&(_e=_e.props.children),typeof _e=="object"&&_e!==null){switch(_e.$$typeof){case m:e:{for(var nt=_e.key;ne!==null;){if(ne.key===nt){if(nt=_e.type,nt===x){if(ne.tag===7){p(ue,ne.sibling),Re=y(ne,_e.props.children),Re.return=ue,ue=Re;break e}}else if(ne.elementType===nt||typeof nt=="object"&&nt!==null&&nt.$$typeof===F&&vo(nt)===ne.type){p(ue,ne.sibling),Re=y(ne,_e.props),Nc(Re,_e),Re.return=ue,ue=Re;break e}p(ue,ne);break}else h(ue,ne);ne=ne.sibling}_e.type===x?(Re=_o(_e.props.children,ue.mode,Re,_e.key),Re.return=ue,ue=Re):(Re=bu(_e.type,_e.key,_e.props,null,ue.mode,Re),Nc(Re,_e),Re.return=ue,ue=Re)}return P(ue);case b:e:{for(nt=_e.key;ne!==null;){if(ne.key===nt)if(ne.tag===4&&ne.stateNode.containerInfo===_e.containerInfo&&ne.stateNode.implementation===_e.implementation){p(ue,ne.sibling),Re=y(ne,_e.children||[]),Re.return=ue,ue=Re;break e}else{p(ue,ne);break}else h(ue,ne);ne=ne.sibling}Re=Pp(_e,ue.mode,Re),Re.return=ue,ue=Re}return P(ue);case F:return _e=vo(_e),ti(ue,ne,_e,Re)}if(ce(_e))return Je(ue,ne,_e,Re);if(Q(_e)){if(nt=Q(_e),typeof nt!="function")throw Error(i(150));return _e=nt.call(_e),ct(ue,ne,_e,Re)}if(typeof _e.then=="function")return ti(ue,ne,Au(_e),Re);if(_e.$$typeof===D)return ti(ue,ne,xu(ue,_e),Re);Ru(ue,_e)}return typeof _e=="string"&&_e!==""||typeof _e=="number"||typeof _e=="bigint"?(_e=""+_e,ne!==null&&ne.tag===6?(p(ue,ne.sibling),Re=y(ne,_e),Re.return=ue,ue=Re):(p(ue,ne),Re=Ip(_e,ue.mode,Re),Re.return=ue,ue=Re),P(ue)):p(ue,ne)}return function(ue,ne,_e,Re){try{Lc=0;var nt=ti(ue,ne,_e,Re);return xl=null,nt}catch(st){if(st===vl||st===Tu)throw st;var Vt=Ys(29,st,null,ue.mode);return Vt.lanes=Re,Vt.return=ue,Vt}finally{}}}var So=o0(!0),l0=o0(!1),Ta=!1;function Gp(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Hp(l,h){l=l.updateQueue,h.updateQueue===l&&(h.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,callbacks:null})}function Ea(l){return{lane:l,tag:0,payload:null,callback:null,next:null}}function Aa(l,h,p){var _=l.updateQueue;if(_===null)return null;if(_=_.shared,(Xt&2)!==0){var y=_.pending;return y===null?h.next=h:(h.next=y.next,y.next=h),_.pending=h,h=mu(l),Xy(l,null,p),h}return gu(l,_,h,p),mu(l)}function Bc(l,h,p){if(h=h.updateQueue,h!==null&&(h=h.shared,(p&4194048)!==0)){var _=h.lanes;_&=l.pendingLanes,p|=_,h.lanes=p,Ps(l,p)}}function Wp(l,h){var p=l.updateQueue,_=l.alternate;if(_!==null&&(_=_.updateQueue,p===_)){var y=null,S=null;if(p=p.firstBaseUpdate,p!==null){do{var P={lane:p.lane,tag:p.tag,payload:p.payload,callback:null,next:null};S===null?y=S=P:S=S.next=P,p=p.next}while(p!==null);S===null?y=S=h:S=S.next=h}else y=S=h;p={baseState:_.baseState,firstBaseUpdate:y,lastBaseUpdate:S,shared:_.shared,callbacks:_.callbacks},l.updateQueue=p;return}l=p.lastBaseUpdate,l===null?p.firstBaseUpdate=h:l.next=h,p.lastBaseUpdate=h}var Xp=!1;function Uc(){if(Xp){var l=yl;if(l!==null)throw l}}function kc(l,h,p,_){Xp=!1;var y=l.updateQueue;Ta=!1;var S=y.firstBaseUpdate,P=y.lastBaseUpdate,z=y.shared.pending;if(z!==null){y.shared.pending=null;var ee=z,ge=ee.next;ee.next=null,P===null?S=ge:P.next=ge,P=ee;var Ee=l.alternate;Ee!==null&&(Ee=Ee.updateQueue,z=Ee.lastBaseUpdate,z!==P&&(z===null?Ee.firstBaseUpdate=ge:z.next=ge,Ee.lastBaseUpdate=ee))}if(S!==null){var Me=y.baseState;P=0,Ee=ge=ee=null,z=S;do{var me=z.lane&-536870913,ye=me!==z.lane;if(ye?(Ct&me)===me:(_&me)===me){me!==0&&me===bl&&(Xp=!0),Ee!==null&&(Ee=Ee.next={lane:0,tag:z.tag,payload:z.payload,callback:null,next:null});e:{var Je=l,ct=z;me=h;var ti=p;switch(ct.tag){case 1:if(Je=ct.payload,typeof Je=="function"){Me=Je.call(ti,Me,me);break e}Me=Je;break e;case 3:Je.flags=Je.flags&-65537|128;case 0:if(Je=ct.payload,me=typeof Je=="function"?Je.call(ti,Me,me):Je,me==null)break e;Me=f({},Me,me);break e;case 2:Ta=!0}}me=z.callback,me!==null&&(l.flags|=64,ye&&(l.flags|=8192),ye=y.callbacks,ye===null?y.callbacks=[me]:ye.push(me))}else ye={lane:me,tag:z.tag,payload:z.payload,callback:z.callback,next:null},Ee===null?(ge=Ee=ye,ee=Me):Ee=Ee.next=ye,P|=me;
vendor: 5,414 bytes, line 49
49if(z=z.next,z===null){if(z=y.shared.pending,z===null)break;ye=z,z=ye.next,ye.next=null,y.lastBaseUpdate=ye,y.shared.pending=null}}while(!0);Ee===null&&(ee=Me),y.baseState=ee,y.firstBaseUpdate=ge,y.lastBaseUpdate=Ee,S===null&&(y.shared.lanes=0),Pa|=P,l.lanes=P,l.memoizedState=Me}}function c0(l,h){if(typeof l!="function")throw Error(i(191,l));l.call(h)}function h0(l,h){var p=l.callbacks;if(p!==null)for(l.callbacks=null,l=0;l<p.length;l++)c0(p[l],h)}var Sl=w(null),Mu=w(0);function u0(l,h){l=Gn,V(Mu,l),V(Sl,h),Gn=l|h.baseLanes}function jp(){V(Mu,Gn),V(Sl,Sl.current)}function Yp(){Gn=Mu.current,L(Sl),L(Mu)}var Ks=w(null),vr=null;function Ra(l){var h=l.alternate;V(Ii,Ii.current&1),V(Ks,l),vr===null&&(h===null||Sl.current!==null||h.memoizedState!==null)&&(vr=l)}function Kp(l){V(Ii,Ii.current),V(Ks,l),vr===null&&(vr=l)}function d0(l){l.tag===22?(V(Ii,Ii.current),V(Ks,l),vr===null&&(vr=l)):Ma()}function Ma(){V(Ii,Ii.current),V(Ks,Ks.current)}function qs(l){L(Ks),vr===l&&(vr=null),L(Ii)}var Ii=w(0);function Cu(l){for(var h=l;h!==null;){if(h.tag===13){var p=h.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||eg(p)||tg(p)))return h}else if(h.tag===19&&(h.memoizedProps.revealOrder==="forwards"||h.memoizedProps.revealOrder==="backwards"||h.memoizedProps.revealOrder==="unstable_legacy-backwards"||h.memoizedProps.revealOrder==="together")){if((h.flags&128)!==0)return h}else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===l)break;for(;h.sibling===null;){if(h.return===null||h.return===l)return null;h=h.return}h.sibling.return=h.return,h=h.sibling}return null}var Fn=0,yt=null,Jt=null,Bi=null,Iu=!1,Tl=!1,To=!1,Pu=0,Vc=0,El=null,e1=0;function Ti(){throw Error(i(321))}function qp(l,h){if(h===null)return!1;for(var p=0;p<h.length&&p<l.length;p++)if(!js(l[p],h[p]))return!1;return!0}function Zp(l,h,p,_,y,S){return Fn=S,yt=h,h.memoizedState=null,h.updateQueue=null,h.lanes=0,G.H=l===null||l.memoizedState===null?q0:u_,To=!1,S=p(_,y),To=!1,Tl&&(S=p0(h,p,_,y)),f0(l),S}function f0(l){G.H=Hc;var h=Jt!==null&&Jt.next!==null;if(Fn=0,Bi=Jt=yt=null,Iu=!1,Vc=0,El=null,h)throw Error(i(300));l===null||Ui||(l=l.dependencies,l!==null&&vu(l)&&(Ui=!0))}function p0(l,h,p,_){yt=l;var y=0;do{if(Tl&&(El=null),Vc=0,Tl=!1,25<=y)throw Error(i(301));if(y+=1,Bi=Jt=null,l.updateQueue!=null){var S=l.updateQueue;S.lastEffect=null,S.events=null,S.stores=null,S.memoCache!=null&&(S.memoCache.index=0)}G.H=Z0,S=h(p,_)}while(Tl);return S}function t1(){var l=G.H,h=l.useState()[0];return h=typeof h.then=="function"?zc(h):h,l=l.useState()[0],(Jt!==null?Jt.memoizedState:null)!==l&&(yt.flags|=1024),h}function $p(){var l=Pu!==0;return Pu=0,l}function Qp(l,h,p){h.updateQueue=l.updateQueue,h.flags&=-2053,l.lanes&=~p}function Jp(l){if(Iu){for(l=l.memoizedState;l!==null;){var h=l.queue;h!==null&&(h.pending=null),l=l.next}Iu=!1}Fn=0,Bi=Jt=yt=null,Tl=!1,Vc=Pu=0,El=null}function bs(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Bi===null?yt.memoizedState=Bi=l:Bi=Bi.next=l,Bi}function Pi(){if(Jt===null){var l=yt.alternate;l=l!==null?l.memoizedState:null}else l=Jt.next;var h=Bi===null?yt.memoizedState:Bi.next;if(h!==null)Bi=h,Jt=l;else{if(l===null)throw yt.alternate===null?Error(i(467)):Error(i(310));Jt=l,l={memoizedState:Jt.memoizedState,baseState:Jt.baseState,baseQueue:Jt.baseQueue,queue:Jt.queue,next:null},Bi===null?yt.memoizedState=Bi=l:Bi=Bi.next=l}return Bi}function Du(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function zc(l){var h=Vc;return Vc+=1,El===null&&(El=[]),l=r0(El,l,h),h=yt,(Bi===null?h.memoizedState:Bi.next)===null&&(h=h.alternate,G.H=h===null||h.memoizedState===null?q0:u_),l}function Ou(l){if(l!==null&&typeof l=="object"){if(typeof l.then=="function")return zc(l);if(l.$$typeof===D)return ts(l)}throw Error(i(438,String(l)))}function e_(l){var h=null,p=yt.updateQueue;if(p!==null&&(h=p.memoCache),h==null){var _=yt.alternate;_!==null&&(_=_.updateQueue,_!==null&&(_=_.memoCache,_!=null&&(h={data:_.data.map(function(y){return y.slice()}),index:0})))}if(h==null&&(h={data:[],index:0}),p===null&&(p=Du(),yt.updateQueue=p),p.memoCache=h,p=h.data[h.index],p===void 0)for(p=h.data[h.index]=Array(l),_=0;_<l;_++)p[_]=k;return h.index++,p}function Ln(l,h){return typeof h=="function"?h(l):h}function wu(l){var h=Pi();return t_(h,Jt,l)}function t_(l,h,p){var _=l.queue;if(_===null)throw Error(i(311));_.lastRenderedReducer=p;var y=l.baseQueue,S=_.pending;if(S!==null){if(y!==null){var P=y.next;y.next=S.next,S.next=P}h.baseQueue=y=S,_.pending=null}if(S=l.baseState,y===null)l.memoizedState=S;else{h=y.next;var z=P=null,ee=null,ge=h,Ee=!1;do{var Me=ge.lane&-536870913;if(Me!==ge.lane?(Ct&Me)===Me:(Fn&Me)===Me){var me=ge.revertLane;if(me===0)ee!==null&&(ee=ee.next={lane:0,revertLane:0,gesture:null,action:ge.action,hasEagerState:ge.hasEagerState,eagerState:ge.eagerState,next:null}),Me===bl&&(Ee=!0);else if((Fn&me)===me){ge=ge.next,me===bl&&(Ee=!0);continue}else Me={lane:0,revertLane:ge.revertLane,gesture:null,action:ge.action,hasEagerState:ge.hasEagerState,eagerState:ge.eagerState,next:null},ee===null?(z=ee=Me,P=S):ee=ee.next=Me,yt.lanes|=me,Pa|=me;Me=ge.action,To&&p(S,Me),S=ge.hasEagerState?ge.eagerState:p(S,Me)}else me={lane:Me,revertLane:ge.revertLane,gesture:ge.gesture,action:ge.action,hasEagerState:ge.hasEagerState,eagerState:ge.eagerState,next:null},ee===null?(z=ee=me,P=S):ee=ee.next=me,yt.lanes|=Me,Pa|=Me;ge=ge.next}
vendor: 9,539 bytes, line 49
49while(ge!==null&&ge!==h);if(ee===null?P=S:ee.next=z,!js(S,l.memoizedState)&&(Ui=!0,Ee&&(p=yl,p!==null)))throw p;l.memoizedState=S,l.baseState=P,l.baseQueue=ee,_.lastRenderedState=S}return y===null&&(_.lanes=0),[l.memoizedState,_.dispatch]}function i_(l){var h=Pi(),p=h.queue;if(p===null)throw Error(i(311));p.lastRenderedReducer=l;var _=p.dispatch,y=p.pending,S=h.memoizedState;if(y!==null){p.pending=null;var P=y=y.next;do S=l(S,P.action),P=P.next;while(P!==y);js(S,h.memoizedState)||(Ui=!0),h.memoizedState=S,h.baseQueue===null&&(h.baseState=S),p.lastRenderedState=S}return[S,_]}function _0(l,h,p){var _=yt,y=Pi(),S=wt;if(S){if(p===void 0)throw Error(i(407));p=p()}else p=h();var P=!js((Jt||y).memoizedState,p);if(P&&(y.memoizedState=p,Ui=!0),y=y.queue,n_(b0.bind(null,_,y,l),[l]),y.getSnapshot!==h||P||Bi!==null&&Bi.memoizedState.tag&1){if(_.flags|=2048,Al(9,{destroy:void 0},m0.bind(null,_,y,p,h),null),ii===null)throw Error(i(349));S||(Fn&127)!==0||g0(_,h,p)}return p}function g0(l,h,p){l.flags|=16384,l={getSnapshot:h,value:p},h=yt.updateQueue,h===null?(h=Du(),yt.updateQueue=h,h.stores=[l]):(p=h.stores,p===null?h.stores=[l]:p.push(l))}function m0(l,h,p,_){h.value=p,h.getSnapshot=_,y0(h)&&v0(l)}function b0(l,h,p){return p(function(){y0(h)&&v0(l)})}function y0(l){var h=l.getSnapshot;l=l.value;try{var p=h();return!js(l,p)}catch{return!0}}function v0(l){var h=po(l,2);h!==null&&Us(h,l,2)}function s_(l){var h=bs();if(typeof l=="function"){var p=l;if(l=p(),To){Br(!0);try{p()}finally{Br(!1)}}}return h.memoizedState=h.baseState=l,h.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ln,lastRenderedState:l},h}function x0(l,h,p,_){return l.baseState=p,t_(l,Jt,typeof _=="function"?_:Ln)}function i1(l,h,p,_,y){if(Nu(l))throw Error(i(485));if(l=h.action,l!==null){var S={payload:y,action:l,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(P){S.listeners.push(P)}};G.T!==null?p(!0):S.isTransition=!1,_(S),p=h.pending,p===null?(S.next=h.pending=S,S0(h,S)):(S.next=p.next,h.pending=p.next=S)}}function S0(l,h){var p=h.action,_=h.payload,y=l.state;if(h.isTransition){var S=G.T,P={};G.T=P;try{var z=p(y,_),ee=G.S;ee!==null&&ee(P,z),T0(l,h,z)}catch(ge){r_(l,h,ge)}finally{S!==null&&P.types!==null&&(S.types=P.types),G.T=S}}else try{S=p(y,_),T0(l,h,S)}catch(ge){r_(l,h,ge)}}function T0(l,h,p){p!==null&&typeof p=="object"&&typeof p.then=="function"?p.then(function(_){E0(l,h,_)},function(_){return r_(l,h,_)}):E0(l,h,p)}function E0(l,h,p){h.status="fulfilled",h.value=p,A0(h),l.state=p,h=l.pending,h!==null&&(p=h.next,p===h?l.pending=null:(p=p.next,h.next=p,S0(l,p)))}function r_(l,h,p){var _=l.pending;if(l.pending=null,_!==null){_=_.next;do h.status="rejected",h.reason=p,A0(h),h=h.next;while(h!==_)}l.action=null}function A0(l){l=l.listeners;for(var h=0;h<l.length;h++)(0,l[h])()}function R0(l,h){return h}function M0(l,h){if(wt){var p=ii.formState;if(p!==null){e:{var _=yt;if(wt){if(ci){t:{for(var y=ci,S=yr;y.nodeType!==8;){if(!S){y=null;break t}if(y=xr(y.nextSibling),y===null){y=null;break t}}S=y.data,y=S==="F!"||S==="F"?y:null}if(y){ci=xr(y.nextSibling),_=y.data==="F!";break e}}xa(_)}_=!1}_&&(h=p[0])}}return p=bs(),p.memoizedState=p.baseState=h,_={pending:null,lanes:0,dispatch:null,lastRenderedReducer:R0,lastRenderedState:h},p.queue=_,p=j0.bind(null,yt,_),_.dispatch=p,_=s_(!1),S=h_.bind(null,yt,!1,_.queue),_=bs(),y={state:h,dispatch:null,action:l,pending:null},_.queue=y,p=i1.bind(null,yt,y,S,p),y.dispatch=p,_.memoizedState=l,[h,p,!1]}function C0(l){var h=Pi();return I0(h,Jt,l)}function I0(l,h,p){if(h=t_(l,h,R0)[0],l=wu(Ln)[0],typeof h=="object"&&h!==null&&typeof h.then=="function")try{var _=zc(h)}catch(P){throw P===vl?Tu:P}else _=h;h=Pi();var y=h.queue,S=y.dispatch;return p!==h.memoizedState&&(yt.flags|=2048,Al(9,{destroy:void 0},s1.bind(null,y,p),null)),[_,S,l]}function s1(l,h){l.action=h}function P0(l){var h=Pi(),p=Jt;if(p!==null)return I0(h,p,l);Pi(),h=h.memoizedState,p=Pi();var _=p.queue.dispatch;return p.memoizedState=l,[h,_,!1]}function Al(l,h,p,_){return l={tag:l,create:p,deps:_,inst:h,next:null},h=yt.updateQueue,h===null&&(h=Du(),yt.updateQueue=h),p=h.lastEffect,p===null?h.lastEffect=l.next=l:(_=p.next,p.next=l,l.next=_,h.lastEffect=l),l}function D0(){return Pi().memoizedState}function Fu(l,h,p,_){var y=bs();yt.flags|=l,y.memoizedState=Al(1|h,{destroy:void 0},p,_===void 0?null:_)}function Lu(l,h,p,_){var y=Pi();_=_===void 0?null:_;var S=y.memoizedState.inst;Jt!==null&&_!==null&&qp(_,Jt.memoizedState.deps)?y.memoizedState=Al(h,S,p,_):(yt.flags|=l,y.memoizedState=Al(1|h,S,p,_))}function O0(l,h){Fu(8390656,8,l,h)}function n_(l,h){Lu(2048,8,l,h)}function r1(l){yt.flags|=4;var h=yt.updateQueue;if(h===null)h=Du(),yt.updateQueue=h,h.events=[l];else{var p=h.events;p===null?h.events=[l]:p.push(l)}}function w0(l){var h=Pi().memoizedState;return r1({ref:h,nextImpl:l}),function(){if((Xt&2)!==0)throw Error(i(440));return h.impl.apply(void 0,arguments)}}function F0(l,h){return Lu(4,2,l,h)}function L0(l,h){return Lu(4,4,l,h)}function N0(l,h){if(typeof h=="function"){l=l();var p=h(l);return function(){typeof p=="function"?p():h(null)}}if(h!=null)return l=l(),h.current=l,function(){h.current=null}}function B0(l,h,p){p=p!=null?p.concat([l]):null,Lu(4,4,N0.bind(null,h,l),p)}function a_(){}function U0(l,h){var p=Pi();h=h===void 0?null:h;var _=p.memoizedState;return h!==null&&qp(h,_[1])?_[0]:(p.memoizedState=[l,h],l)}function k0(l,h){var p=Pi();h=h===void 0?null:h;var _=p.memoizedState;if(h!==null&&qp(h,_[1]))return _[0];if(_=l(),To){Br(!0);try{l()}finally{Br(!1)}}return p.memoizedState=[_,h],_}function o_(l,h,p){return p===void 0||(Fn&1073741824)!==0&&(Ct&261930)===0?l.memoizedState=h:(l.memoizedState=p,l=Vv(),yt.lanes|=l,Pa|=l,p)}function V0(l,h,p,_){return js(p,h)?p:Sl.current!==null?(l=o_(l,p,_),js(l,h)||(Ui=!0),l):(Fn&42)===0||(Fn&1073741824)!==0&&(Ct&261930)===0?(Ui=!0,l.memoizedState=p):(l=Vv(),yt.lanes|=l,Pa|=l,h)}function z0(l,h,p,_,y){var S=K.p;K.p=S!==0&&8>S?S:8;var P=G.T,z={};G.T=z,h_(l,!1,h,p);try{var ee=y(),ge=G.S;if(ge!==null&&ge(z,ee),ee!==null&&typeof ee=="object"&&typeof ee.then=="function"){var Ee=JP(ee,_);Gc(l,h,Ee,Qs(l))}else Gc(l,h,_,Qs(l))}catch(Me){Gc(l,h,{then:function(){},status:"rejected",reason:Me},Qs())}finally{K.p=S,P!==null&&z.types!==null&&(P.types=z.types),G.T=P}}function n1(){}function l_(l,h,p,_){if(l.tag!==5)throw Error(i(476));var y=G0(l).queue;z0(l,y,h,X,p===null?n1:function(){return H0(l),p(_)})}function G0(l){var h=l.memoizedState;if(h!==null)return h;h={memoizedState:X,baseState:X,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ln,lastRenderedState:X},next:null};var p={};return h.next={memoizedState:p,baseState:p,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ln,lastRenderedState:p},next:null},l.memoizedState=h,l=l.alternate,l!==null&&(l.memoizedState=h),h}function H0(l){var h=G0(l);h.next===null&&(h=l.alternate.memoizedState),Gc(l,h.next.queue,{},Qs())}function c_(){return ts(nh)}function W0(){return Pi().memoizedState}function X0(){return Pi().memoizedState}function a1(l){for(var h=l.return;h!==null;){switch(h.tag){case 24:case 3:var p=Qs();l=Ea(p);var _=Aa(h,l,p);_!==null&&(Us(_,h,p),Bc(_,h,p)),h={cache:Up()},l.payload=h;return}h=h.return}}function o1(l,h,p){var _=Qs();p={lane:_,revertLane:0,gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null},Nu(l)?Y0(h,p):(p=Mp(l,h,p,_),p!==null&&(Us(p,l,_),K0(p,h,_)))}function j0(l,h,p){var _=Qs();Gc(l,h,p,_)}function Gc(l,h,p,_){var y={lane:_,revertLane:0,gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null};if(Nu(l))Y0(h,y);else{var S=l.alternate;if(l.lanes===0&&(S===null||S.lanes===0)&&(S=h.lastRenderedReducer,S!==null))try{var P=h.lastRenderedState,z=S(P,p);if(y.hasEagerState=!0,y.eagerState=z,js(z,P))return gu(l,h,y,0),ii===null&&_u(),!1}catch{}finally{}if(p=Mp(l,h,y,_),p!==null)return Us(p,l,_),K0(p,h,_),!0}return!1}function h_(l,h,p,_){if(_={lane:2,revertLane:G_(),gesture:null,action:_,hasEagerState:!1,eagerState:null,next:null},Nu(l)){if(h)throw Error(i(479))}else h=Mp(l,p,_,2),h!==null&&Us(h,l,2)}function Nu(l){var h=l.alternate;return l===yt||h!==null&&h===yt}function Y0(l,h){Tl=Iu=!0;var p=l.pending;p===null?h.next=h:(h.next=p.next,p.next=h),l.pending=h}function K0(l,h,p){if((p&4194048)!==0){var _=h.lanes;_&=l.pendingLanes,p|=_,h.lanes=p,Ps(l,p)}}var Hc={readContext:ts,use:Ou,useCallback:Ti,useContext:Ti,useEffect:Ti,useImperativeHandle:Ti,useLayoutEffect:Ti,useInsertionEffect:Ti,useMemo:Ti,useReducer:Ti,useRef:Ti,useState:Ti,useDebugValue:Ti,useDeferredValue:Ti,useTransition:Ti,useSyncExternalStore:Ti,useId:Ti,useHostTransitionStatus:Ti,useFormState:Ti,useActionState:Ti,useOptimistic:Ti,useMemoCache:Ti,useCacheRefresh:Ti};Hc.useEffectEvent=Ti;var q0={readContext:ts,use:Ou,useCallback:function(l,h){return bs().memoizedState=[l,h===void 0?null:h],l},useContext:ts,useEffect:O0,useImperativeHandle:function(l,h,p){p=p!=null?p.concat([l]):null,Fu(4194308,4,N0.bind(null,h,l),p)},useLayoutEffect:function(l,h){return Fu(4194308,4,l,h)},useInsertionEffect:function(l,h){Fu(4,2,l,h)},useMemo:function(l,h){var p=bs();h=h===void 0?null:h;var _=l();if(To){Br(!0);try{l()}finally{Br(!1)}}return p.memoizedState=[_,h],_},useReducer:function(l,h,p){var _=bs();if(p!==void 0){var y=p(h);if(To){Br(!0);try{p(h)}finally{Br(!1)}}}else y=h;return _.memoizedState=_.baseState=y,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:y},_.queue=l,l=l.dispatch=o1.bind(null,yt,l),[_.memoizedState,l]}
vendor: 8,501 bytes, line 49
49,useRef:function(l){var h=bs();return l={current:l},h.memoizedState=l},useState:function(l){l=s_(l);var h=l.queue,p=j0.bind(null,yt,h);return h.dispatch=p,[l.memoizedState,p]},useDebugValue:a_,useDeferredValue:function(l,h){var p=bs();return o_(p,l,h)},useTransition:function(){var l=s_(!1);return l=z0.bind(null,yt,l.queue,!0,!1),bs().memoizedState=l,[!1,l]},useSyncExternalStore:function(l,h,p){var _=yt,y=bs();if(wt){if(p===void 0)throw Error(i(407));p=p()}else{if(p=h(),ii===null)throw Error(i(349));(Ct&127)!==0||g0(_,h,p)}y.memoizedState=p;var S={value:p,getSnapshot:h};return y.queue=S,O0(b0.bind(null,_,S,l),[l]),_.flags|=2048,Al(9,{destroy:void 0},m0.bind(null,_,S,p,h),null),p},useId:function(){var l=bs(),h=ii.identifierPrefix;if(wt){var p=on,_=an;p=(_&~(1<<32-cs(_)-1)).toString(32)+p,h="_"+h+"R_"+p,p=Pu++,0<p&&(h+="H"+p.toString(32)),h+="_"}else p=e1++,h="_"+h+"r_"+p.toString(32)+"_";return l.memoizedState=h},useHostTransitionStatus:c_,useFormState:M0,useActionState:M0,useOptimistic:function(l){var h=bs();h.memoizedState=h.baseState=l;var p={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return h.queue=p,h=h_.bind(null,yt,!0,p),p.dispatch=h,[l,h]},useMemoCache:e_,useCacheRefresh:function(){return bs().memoizedState=a1.bind(null,yt)},useEffectEvent:function(l){var h=bs(),p={impl:l};return h.memoizedState=p,function(){if((Xt&2)!==0)throw Error(i(440));return p.impl.apply(void 0,arguments)}}},u_={readContext:ts,use:Ou,useCallback:U0,useContext:ts,useEffect:n_,useImperativeHandle:B0,useInsertionEffect:F0,useLayoutEffect:L0,useMemo:k0,useReducer:wu,useRef:D0,useState:function(){return wu(Ln)},useDebugValue:a_,useDeferredValue:function(l,h){var p=Pi();return V0(p,Jt.memoizedState,l,h)},useTransition:function(){var l=wu(Ln)[0],h=Pi().memoizedState;return[typeof l=="boolean"?l:zc(l),h]},useSyncExternalStore:_0,useId:W0,useHostTransitionStatus:c_,useFormState:C0,useActionState:C0,useOptimistic:function(l,h){var p=Pi();return x0(p,Jt,l,h)},useMemoCache:e_,useCacheRefresh:X0};u_.useEffectEvent=w0;var Z0={readContext:ts,use:Ou,useCallback:U0,useContext:ts,useEffect:n_,useImperativeHandle:B0,useInsertionEffect:F0,useLayoutEffect:L0,useMemo:k0,useReducer:i_,useRef:D0,useState:function(){return i_(Ln)},useDebugValue:a_,useDeferredValue:function(l,h){var p=Pi();return Jt===null?o_(p,l,h):V0(p,Jt.memoizedState,l,h)},useTransition:function(){var l=i_(Ln)[0],h=Pi().memoizedState;return[typeof l=="boolean"?l:zc(l),h]},useSyncExternalStore:_0,useId:W0,useHostTransitionStatus:c_,useFormState:P0,useActionState:P0,useOptimistic:function(l,h){var p=Pi();return Jt!==null?x0(p,Jt,l,h):(p.baseState=l,[l,p.queue.dispatch])},useMemoCache:e_,useCacheRefresh:X0};Z0.useEffectEvent=w0;function d_(l,h,p,_){h=l.memoizedState,p=p(_,h),p=p==null?h:f({},h,p),l.memoizedState=p,l.lanes===0&&(l.updateQueue.baseState=p)}var f_={enqueueSetState:function(l,h,p){l=l._reactInternals;var _=Qs(),y=Ea(_);y.payload=h,p!=null&&(y.callback=p),h=Aa(l,y,_),h!==null&&(Us(h,l,_),Bc(h,l,_))},enqueueReplaceState:function(l,h,p){l=l._reactInternals;var _=Qs(),y=Ea(_);y.tag=1,y.payload=h,p!=null&&(y.callback=p),h=Aa(l,y,_),h!==null&&(Us(h,l,_),Bc(h,l,_))},enqueueForceUpdate:function(l,h){l=l._reactInternals;var p=Qs(),_=Ea(p);_.tag=2,h!=null&&(_.callback=h),h=Aa(l,_,p),h!==null&&(Us(h,l,p),Bc(h,l,p))}};function $0(l,h,p,_,y,S,P){return l=l.stateNode,typeof l.shouldComponentUpdate=="function"?l.shouldComponentUpdate(_,S,P):h.prototype&&h.prototype.isPureReactComponent?!Ic(p,_)||!Ic(y,S):!0}function Q0(l,h,p,_){l=h.state,typeof h.componentWillReceiveProps=="function"&&h.componentWillReceiveProps(p,_),typeof h.UNSAFE_componentWillReceiveProps=="function"&&h.UNSAFE_componentWillReceiveProps(p,_),h.state!==l&&f_.enqueueReplaceState(h,h.state,null)}function Eo(l,h){var p=h;if("ref"in h){p={};for(var _ in h)_!=="ref"&&(p[_]=h[_])}if(l=l.defaultProps){p===h&&(p=f({},p));for(var y in l)p[y]===void 0&&(p[y]=l[y])}return p}function J0(l){pu(l)}function ev(l){console.error(l)}function tv(l){pu(l)}function Bu(l,h){try{var p=l.onUncaughtError;p(h.value,{componentStack:h.stack})}catch(_){setTimeout(function(){throw _})}}function iv(l,h,p){try{var _=l.onCaughtError;_(p.value,{componentStack:p.stack,errorBoundary:h.tag===1?h.stateNode:null})}catch(y){setTimeout(function(){throw y})}}function p_(l,h,p){return p=Ea(p),p.tag=3,p.payload={element:null},p.callback=function(){Bu(l,h)},p}function sv(l){return l=Ea(l),l.tag=3,l}function rv(l,h,p,_){var y=p.type.getDerivedStateFromError;if(typeof y=="function"){var S=_.value;l.payload=function(){return y(S)},l.callback=function(){iv(h,p,_)}}var P=p.stateNode;P!==null&&typeof P.componentDidCatch=="function"&&(l.callback=function(){iv(h,p,_),typeof y!="function"&&(Da===null?Da=new Set([this]):Da.add(this));var z=_.stack;this.componentDidCatch(_.value,{componentStack:z!==null?z:""})})}function l1(l,h,p,_,y){if(p.flags|=32768,_!==null&&typeof _=="object"&&typeof _.then=="function"){if(h=p.alternate,h!==null&&ml(h,p,y,!0),p=Ks.current,p!==null){switch(p.tag){case 31:case 13:return vr===null?qu():p.alternate===null&&Ei===0&&(Ei=3),p.flags&=-257,p.flags|=65536,p.lanes=y,_===Eu?p.flags|=16384:(h=p.updateQueue,h===null?p.updateQueue=new Set([_]):h.add(_),k_(l,_,y)),!1;case 22:return p.flags|=65536,_===Eu?p.flags|=16384:(h=p.updateQueue,h===null?(h={transitions:null,markerInstances:null,retryQueue:new Set([_])},p.updateQueue=h):(p=h.retryQueue,p===null?h.retryQueue=new Set([_]):p.add(_)),k_(l,_,y)),!1}throw Error(i(435,p.tag))}return k_(l,_,y),qu(),!1}if(wt)return h=Ks.current,h!==null?((h.flags&65536)===0&&(h.flags|=256),h.flags|=65536,h.lanes=y,_!==wp&&(l=Error(i(422),{cause:_}),Oc(gr(l,p)))):(_!==wp&&(h=Error(i(423),{cause:_}),Oc(gr(h,p))),l=l.current.alternate,l.flags|=65536,y&=-y,l.lanes|=y,_=gr(_,p),y=p_(l.stateNode,_,y),Wp(l,y),Ei!==4&&(Ei=2)),!1;var S=Error(i(520),{cause:_});if(S=gr(S,p),$c===null?$c=[S]:$c.push(S),Ei!==4&&(Ei=2),h===null)return!0;_=gr(_,p),p=h;do{switch(p.tag){case 3:return p.flags|=65536,l=y&-y,p.lanes|=l,l=p_(p.stateNode,_,l),Wp(p,l),!1;case 1:if(h=p.type,S=p.stateNode,(p.flags&128)===0&&(typeof h.getDerivedStateFromError=="function"||S!==null&&typeof S.componentDidCatch=="function"&&(Da===null||!Da.has(S))))return p.flags|=65536,y&=-y,p.lanes|=y,y=sv(y),rv(y,l,p,_),Wp(p,y),!1}p=p.return}while(p!==null);return!1}var __=Error(i(461)),Ui=!1;function is(l,h,p,_){h.child=l===null?l0(h,null,p,_):So(h,l.child,p,_)}function nv(l,h,p,_,y){p=p.render;var S=h.ref;if("ref"in _){var P={};for(var z in _)z!=="ref"&&(P[z]=_[z])}else P=_;return bo(h),_=Zp(l,h,p,P,S,y),z=$p(),l!==null&&!Ui?(Qp(l,h,y),Nn(l,h,y)):(wt&&z&&Dp(h),h.flags|=1,is(l,h,_,y),h.child)}function av(l,h,p,_,y){if(l===null){var S=p.type;return typeof S=="function"&&!Cp(S)&&S.defaultProps===void 0&&p.compare===null?(h.tag=15,h.type=S,ov(l,h,S,_,y)):(l=bu(p.type,null,_,h,h.mode,y),l.ref=h.ref,l.return=h,h.child=l)}if(S=l.child,!T_(l,y)){var P=S.memoizedProps;if(p=p.compare,p=p!==null?p:Ic,p(P,_)&&l.ref===h.ref)return Nn(l,h,y)}return h.flags|=1,l=Pn(S,_),l.ref=h.ref,l.return=h,h.child=l}function ov(l,h,p,_,y){if(l!==null){var S=l.memoizedProps;if(Ic(S,_)&&l.ref===h.ref)if(Ui=!1,h.pendingProps=_=S,T_(l,y))(l.flags&131072)!==0&&(Ui=!0);else return h.lanes=l.lanes,Nn(l,h,y)}return g_(l,h,p,_,y)}function lv(l,h,p,_){var y=_.children,S=l!==null?l.memoizedState:null;if(l===null&&h.stateNode===null&&(h.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),_.mode==="hidden"){if((h.flags&128)!==0){if(S=S!==null?S.baseLanes|p:p,l!==null){for(_=h.child=l.child,y=0;_!==null;)y=y|_.lanes|_.childLanes,_=_.sibling;_=y&~S}else _=0,h.child=null;return cv(l,h,S,p,_)}if((p&536870912)!==0)h.memoizedState={baseLanes:0,cachePool:null},l!==null&&Su(h,S!==null?S.cachePool:null),S!==null?u0(h,S):jp(),d0(h);else return _=h.lanes=536870912,cv(l,h,S!==null?S.baseLanes|p:p,p,_)}else S!==null?(Su(h,S.cachePool),u0(h,S),Ma(),h.memoizedState=null):(l!==null&&Su(h,null),jp(),Ma());return is(l,h,y,p),h.child}function Wc(l,h){return l!==null&&l.tag===22||h.stateNode!==null||(h.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),h.sibling}function cv(l,h,p,_,y){var S=Vp();return S=S===null?null:{parent:Ni._currentValue,pool:S},h.memoizedState={baseLanes:p,cachePool:S},l!==null&&Su(h,null),jp(),d0(h),l!==null&&ml(l,h,_,!0),h.childLanes=y,null}function Uu(l,h){return h=Vu({mode:h.mode,children:h.children},l.mode),h.ref=l.ref,l.child=h,h.return=l,h}
vendor: 4,271 bytes, line 49
49function hv(l,h,p){return So(h,l.child,null,p),l=Uu(h,h.pendingProps),l.flags|=2,qs(h),h.memoizedState=null,l}function c1(l,h,p){var _=h.pendingProps,y=(h.flags&128)!==0;if(h.flags&=-129,l===null){if(wt){if(_.mode==="hidden")return l=Uu(h,_),h.lanes=536870912,Wc(null,l);if(Kp(h),(l=ci)?(l=Sx(l,yr),l=l!==null&&l.data==="&"?l:null,l!==null&&(h.memoizedState={dehydrated:l,treeContext:ya!==null?{id:an,overflow:on}:null,retryLane:536870912,hydrationErrors:null},p=Yy(l),p.return=h,h.child=p,es=h,ci=null)):l=null,l===null)throw xa(h);return h.lanes=536870912,null}return Uu(h,_)}var S=l.memoizedState;if(S!==null){var P=S.dehydrated;if(Kp(h),y)if(h.flags&256)h.flags&=-257,h=hv(l,h,p);else if(h.memoizedState!==null)h.child=l.child,h.flags|=128,h=null;else throw Error(i(558));else if(Ui||ml(l,h,p,!1),y=(p&l.childLanes)!==0,Ui||y){if(_=ii,_!==null&&(P=Ds(_,p),P!==0&&P!==S.retryLane))throw S.retryLane=P,po(l,P),Us(_,l,P),__;qu(),h=hv(l,h,p)}else l=S.treeContext,ci=xr(P.nextSibling),es=h,wt=!0,va=null,yr=!1,l!==null&&Zy(h,l),h=Uu(h,_),h.flags|=4096;return h}return l=Pn(l.child,{mode:_.mode,children:_.children}),l.ref=h.ref,h.child=l,l.return=h,l}function ku(l,h){var p=h.ref;if(p===null)l!==null&&l.ref!==null&&(h.flags|=4194816);else{if(typeof p!="function"&&typeof p!="object")throw Error(i(284));(l===null||l.ref!==p)&&(h.flags|=4194816)}}function g_(l,h,p,_,y){return bo(h),p=Zp(l,h,p,_,void 0,y),_=$p(),l!==null&&!Ui?(Qp(l,h,y),Nn(l,h,y)):(wt&&_&&Dp(h),h.flags|=1,is(l,h,p,y),h.child)}function uv(l,h,p,_,y,S){return bo(h),h.updateQueue=null,p=p0(h,_,p,y),f0(l),_=$p(),l!==null&&!Ui?(Qp(l,h,S),Nn(l,h,S)):(wt&&_&&Dp(h),h.flags|=1,is(l,h,p,S),h.child)}function dv(l,h,p,_,y){if(bo(h),h.stateNode===null){var S=fl,P=p.contextType;typeof P=="object"&&P!==null&&(S=ts(P)),S=new p(_,S),h.memoizedState=S.state!==null&&S.state!==void 0?S.state:null,S.updater=f_,h.stateNode=S,S._reactInternals=h,S=h.stateNode,S.props=_,S.state=h.memoizedState,S.refs={},Gp(h),P=p.contextType,S.context=typeof P=="object"&&P!==null?ts(P):fl,S.state=h.memoizedState,P=p.getDerivedStateFromProps,typeof P=="function"&&(d_(h,p,P,_),S.state=h.memoizedState),typeof p.getDerivedStateFromProps=="function"||typeof S.getSnapshotBeforeUpdate=="function"||typeof S.UNSAFE_componentWillMount!="function"&&typeof S.componentWillMount!="function"||(P=S.state,typeof S.componentWillMount=="function"&&S.componentWillMount(),typeof S.UNSAFE_componentWillMount=="function"&&S.UNSAFE_componentWillMount(),P!==S.state&&f_.enqueueReplaceState(S,S.state,null),kc(h,_,S,y),Uc(),S.state=h.memoizedState),typeof S.componentDidMount=="function"&&(h.flags|=4194308),_=!0}else if(l===null){S=h.stateNode;var z=h.memoizedProps,ee=Eo(p,z);S.props=ee;var ge=S.context,Ee=p.contextType;P=fl,typeof Ee=="object"&&Ee!==null&&(P=ts(Ee));var Me=p.getDerivedStateFromProps;Ee=typeof Me=="function"||typeof S.getSnapshotBeforeUpdate=="function",z=h.pendingProps!==z,Ee||typeof S.UNSAFE_componentWillReceiveProps!="function"&&typeof S.componentWillReceiveProps!="function"||(z||ge!==P)&&Q0(h,S,_,P),Ta=!1;var me=h.memoizedState;S.state=me,kc(h,_,S,y),Uc(),ge=h.memoizedState,z||me!==ge||Ta?(typeof Me=="function"&&(d_(h,p,Me,_),ge=h.memoizedState),(ee=Ta||$0(h,p,ee,_,me,ge,P))?(Ee||typeof S.UNSAFE_componentWillMount!="function"&&typeof S.componentWillMount!="function"||(typeof S.componentWillMount=="function"&&S.componentWillMount(),typeof S.UNSAFE_componentWillMount=="function"&&S.UNSAFE_componentWillMount()),typeof S.componentDidMount=="function"&&(h.flags|=4194308)):(typeof S.componentDidMount=="function"&&(h.flags|=4194308),h.memoizedProps=_,h.memoizedState=ge),S.props=_,S.state=ge,S.context=P,_=ee):(typeof S.componentDidMount=="function"&&(h.flags|=4194308),_=!1)}else{S=h.stateNode,Hp(l,h),P=h.memoizedProps,Ee=Eo(p,P),S.props=Ee,Me=h.pendingProps,me=S.context,ge=p.contextType,ee=fl,typeof ge=="object"&&ge!==null&&(ee=ts(ge)),z=p.getDerivedStateFromProps,(ge=typeof z=="function"||typeof S.getSnapshotBeforeUpdate=="function")||typeof S.UNSAFE_componentWillReceiveProps!="function"&&typeof S.componentWillReceiveProps!="function"||(P!==Me||me!==ee)&&Q0(h,S,_,ee),Ta=!1,me=h.memoizedState,S.state=me,kc(h,_,S,y),Uc();var ye=h.memoizedState;P!==Me||me!==ye||Ta||l!==null&&l.dependencies!==null&&vu(l.depen
vendor: 4,130 bytes, line 49
49dencies)?(typeof z=="function"&&(d_(h,p,z,_),ye=h.memoizedState),(Ee=Ta||$0(h,p,Ee,_,me,ye,ee)||l!==null&&l.dependencies!==null&&vu(l.dependencies))?(ge||typeof S.UNSAFE_componentWillUpdate!="function"&&typeof S.componentWillUpdate!="function"||(typeof S.componentWillUpdate=="function"&&S.componentWillUpdate(_,ye,ee),typeof S.UNSAFE_componentWillUpdate=="function"&&S.UNSAFE_componentWillUpdate(_,ye,ee)),typeof S.componentDidUpdate=="function"&&(h.flags|=4),typeof S.getSnapshotBeforeUpdate=="function"&&(h.flags|=1024)):(typeof S.componentDidUpdate!="function"||P===l.memoizedProps&&me===l.memoizedState||(h.flags|=4),typeof S.getSnapshotBeforeUpdate!="function"||P===l.memoizedProps&&me===l.memoizedState||(h.flags|=1024),h.memoizedProps=_,h.memoizedState=ye),S.props=_,S.state=ye,S.context=ee,_=Ee):(typeof S.componentDidUpdate!="function"||P===l.memoizedProps&&me===l.memoizedState||(h.flags|=4),typeof S.getSnapshotBeforeUpdate!="function"||P===l.memoizedProps&&me===l.memoizedState||(h.flags|=1024),_=!1)}return S=_,ku(l,h),_=(h.flags&128)!==0,S||_?(S=h.stateNode,p=_&&typeof p.getDerivedStateFromError!="function"?null:S.render(),h.flags|=1,l!==null&&_?(h.child=So(h,l.child,null,y),h.child=So(h,null,p,y)):is(l,h,p,y),h.memoizedState=S.state,l=h.child):l=Nn(l,h,y),l}function fv(l,h,p,_){return go(),h.flags|=256,is(l,h,p,_),h.child}var m_={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function b_(l){return{baseLanes:l,cachePool:i0()}}function y_(l,h,p){return l=l!==null?l.childLanes&~p:0,h&&(l|=$s),l}function pv(l,h,p){var _=h.pendingProps,y=!1,S=(h.flags&128)!==0,P;if((P=S)||(P=l!==null&&l.memoizedState===null?!1:(Ii.current&2)!==0),P&&(y=!0,h.flags&=-129),P=(h.flags&32)!==0,h.flags&=-33,l===null){if(wt){if(y?Ra(h):Ma(),(l=ci)?(l=Sx(l,yr),l=l!==null&&l.data!=="&"?l:null,l!==null&&(h.memoizedState={dehydrated:l,treeContext:ya!==null?{id:an,overflow:on}:null,retryLane:536870912,hydrationErrors:null},p=Yy(l),p.return=h,h.child=p,es=h,ci=null)):l=null,l===null)throw xa(h);return tg(l)?h.lanes=32:h.lanes=536870912,null}var z=_.children;return _=_.fallback,y?(Ma(),y=h.mode,z=Vu({mode:"hidden",children:z},y),_=_o(_,y,p,null),z.return=h,_.return=h,z.sibling=_,h.child=z,_=h.child,_.memoizedState=b_(p),_.childLanes=y_(l,P,p),h.memoizedState=m_,Wc(null,_)):(Ra(h),v_(h,z))}var ee=l.memoizedState;if(ee!==null&&(z=ee.dehydrated,z!==null)){if(S)h.flags&256?(Ra(h),h.flags&=-257,h=x_(l,h,p)):h.memoizedState!==null?(Ma(),h.child=l.child,h.flags|=128,h=null):(Ma(),z=_.fallback,y=h.mode,_=Vu({mode:"visible",children:_.children},y),z=_o(z,y,p,null),z.flags|=2,_.return=h,z.return=h,_.sibling=z,h.child=_,So(h,l.child,null,p),_=h.child,_.memoizedState=b_(p),_.childLanes=y_(l,P,p),h.memoizedState=m_,h=Wc(null,_));else if(Ra(h),tg(z)){if(P=z.nextSibling&&z.nextSibling.dataset,P)var ge=P.dgst;P=ge,_=Error(i(419)),_.stack="",_.digest=P,Oc({value:_,source:null,stack:null}),h=x_(l,h,p)}else if(Ui||ml(l,h,p,!1),P=(p&l.childLanes)!==0,Ui||P){if(P=ii,P!==null&&(_=Ds(P,p),_!==0&&_!==ee.retryLane))throw ee.retryLane=_,po(l,_),Us(P,l,_),__;eg(z)||qu(),h=x_(l,h,p)}else eg(z)?(h.flags|=192,h.child=l.child,h=null):(l=ee.treeContext,ci=xr(z.nextSibling),es=h,wt=!0,va=null,yr=!1,l!==null&&Zy(h,l),h=v_(h,_.children),h.flags|=4096);return h}return y?(Ma(),z=_.fallback,y=h.mode,ee=l.child,ge=ee.sibling,_=Pn(ee,{mode:"hidden",children:_.children}),_.subtreeFlags=ee.subtreeFlags&65011712,ge!==null?z=Pn(ge,z):(z=_o(z,y,p,null),z.flags|=2),z.return=h,_.return=h,_.sibling=z,h.child=_,Wc(null,_),_=h.child,z=l.child.memoizedState,z===null?z=b_(p):(y=z.cachePool,y!==null?(ee=Ni._currentValue,y=y.parent!==ee?{parent:ee,pool:ee}:y):y=i0(),z={baseLanes:z.baseLanes|p,cachePool:y}),_.memoizedState=z,_.childLanes=y_(l,P,p),h.memoizedState=m_,Wc(l.child,_)):(Ra(h),p=l.child,l=p.sibling,p=Pn(p,{mode:"visible",children:_.children}),p.return=h,p.sibling=null,l!==null&&(P=h.deletions,P===null?(h.deletions=[l],h.flags|=16):P.push(l)),h.child=p,h.memoizedState=null,p)}function v_(l,h){return h=Vu({mode:"visible",children:h},l.mode),h.return=l,l.child=h}function Vu(l,h){return l=Ys(22,l,null,h),l.lanes=0,l}
vendor: 4,362 bytes, line 49
49function x_(l,h,p){return So(h,l.child,null,p),l=v_(h,h.pendingProps.children),l.flags|=2,h.memoizedState=null,l}function _v(l,h,p){l.lanes|=h;var _=l.alternate;_!==null&&(_.lanes|=h),Np(l.return,h,p)}function S_(l,h,p,_,y,S){var P=l.memoizedState;P===null?l.memoizedState={isBackwards:h,rendering:null,renderingStartTime:0,last:_,tail:p,tailMode:y,treeForkCount:S}:(P.isBackwards=h,P.rendering=null,P.renderingStartTime=0,P.last=_,P.tail=p,P.tailMode=y,P.treeForkCount=S)}function gv(l,h,p){var _=h.pendingProps,y=_.revealOrder,S=_.tail;_=_.children;var P=Ii.current,z=(P&2)!==0;if(z?(P=P&1|2,h.flags|=128):P&=1,V(Ii,P),is(l,h,_,p),_=wt?Dc:0,!z&&l!==null&&(l.flags&128)!==0)e:for(l=h.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&_v(l,p,h);else if(l.tag===19)_v(l,p,h);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===h)break e;for(;l.sibling===null;){if(l.return===null||l.return===h)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}switch(y){case"forwards":for(p=h.child,y=null;p!==null;)l=p.alternate,l!==null&&Cu(l)===null&&(y=p),p=p.sibling;p=y,p===null?(y=h.child,h.child=null):(y=p.sibling,p.sibling=null),S_(h,!1,y,p,S,_);break;case"backwards":case"unstable_legacy-backwards":for(p=null,y=h.child,h.child=null;y!==null;){if(l=y.alternate,l!==null&&Cu(l)===null){h.child=y;break}l=y.sibling,y.sibling=p,p=y,y=l}S_(h,!0,p,null,S,_);break;case"together":S_(h,!1,null,null,void 0,_);break;default:h.memoizedState=null}return h.child}function Nn(l,h,p){if(l!==null&&(h.dependencies=l.dependencies),Pa|=h.lanes,(p&h.childLanes)===0)if(l!==null){if(ml(l,h,p,!1),(p&h.childLanes)===0)return null}else return null;if(l!==null&&h.child!==l.child)throw Error(i(153));if(h.child!==null){for(l=h.child,p=Pn(l,l.pendingProps),h.child=p,p.return=h;l.sibling!==null;)l=l.sibling,p=p.sibling=Pn(l,l.pendingProps),p.return=h;p.sibling=null}return h.child}function T_(l,h){return(l.lanes&h)!==0?!0:(l=l.dependencies,!!(l!==null&&vu(l)))}function h1(l,h,p){switch(h.tag){case 3:Le(h,h.stateNode.containerInfo),Sa(h,Ni,l.memoizedState.cache),go();break;case 27:case 5:it(h);break;case 4:Le(h,h.stateNode.containerInfo);break;case 10:Sa(h,h.type,h.memoizedProps.value);break;case 31:if(h.memoizedState!==null)return h.flags|=128,Kp(h),null;break;case 13:var _=h.memoizedState;if(_!==null)return _.dehydrated!==null?(Ra(h),h.flags|=128,null):(p&h.child.childLanes)!==0?pv(l,h,p):(Ra(h),l=Nn(l,h,p),l!==null?l.sibling:null);Ra(h);break;case 19:var y=(l.flags&128)!==0;if(_=(p&h.childLanes)!==0,_||(ml(l,h,p,!1),_=(p&h.childLanes)!==0),y){if(_)return gv(l,h,p);h.flags|=128}if(y=h.memoizedState,y!==null&&(y.rendering=null,y.tail=null,y.lastEffect=null),V(Ii,Ii.current),_)break;return null;case 22:return h.lanes=0,lv(l,h,p,h.pendingProps);case 24:Sa(h,Ni,l.memoizedState.cache)}return Nn(l,h,p)}function mv(l,h,p){if(l!==null)if(l.memoizedProps!==h.pendingProps)Ui=!0;else{if(!T_(l,p)&&(h.flags&128)===0)return Ui=!1,h1(l,h,p);Ui=(l.flags&131072)!==0}else Ui=!1,wt&&(h.flags&1048576)!==0&&qy(h,Dc,h.index);switch(h.lanes=0,h.tag){case 16:e:{var _=h.pendingProps;if(l=vo(h.elementType),h.type=l,typeof l=="function")Cp(l)?(_=Eo(l,_),h.tag=1,h=dv(null,h,l,_,p)):(h.tag=0,h=g_(null,h,l,_,p));else{if(l!=null){var y=l.$$typeof;if(y===I){h.tag=11,h=nv(null,h,l,_,p);break e}else if(y===M){h.tag=14,h=av(null,h,l,_,p);break e}}throw h=$(l)||l,Error(i(306,h,""))}}return h;case 0:return g_(l,h,h.type,h.pendingProps,p);case 1:return _=h.type,y=Eo(_,h.pendingProps),dv(l,h,_,y,p);case 3:e:{if(Le(h,h.stateNode.containerInfo),l===null)throw Error(i(387));_=h.pendingProps;var S=h.memoizedState;y=S.element,Hp(l,h),kc(h,_,null,p);var P=h.memoizedState;if(_=P.cache,Sa(h,Ni,_),_!==S.cache&&Bp(h,[Ni],p,!0),Uc(),_=P.element,S.isDehydrated)if(S={element:_,isDehydrated:!1,cache:P.cache},h.updateQueue.baseState=S,h.memoizedState=S,h.flags&256){h=fv(l,h,_,p);break e}else if(_!==y){y=gr(Error(i(424)),h),Oc(y),h=fv(l,h,_,p);break e}else{switch(l=h.stateNode.containerInfo,l.nodeType){case 9:l=l.body;break;default:l=l.nodeName==="HTML"?l.ownerDocument.body:l}for(ci=xr(l.firstChild),es=h,wt=!0,va=null,yr=!0,p=l0(h,null,_,p),h.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling}else{if(go(),_===y){h=Nn(l,h,p);break e}is(l,h,_,p)}h=h.child}return h;case 26:return ku(l,h),l===null?(p=Cx(h.type,null,h.pendingProps,null))?h.memoizedState=p:wt||(p=h.type,l=h.pe
vendor: 4,956 bytes, line 49
49ndingProps,_=id(he.current).createElement(p),_[Ji]=h,_[Os]=l,ss(_,p,l),qi(_),h.stateNode=_):h.memoizedState=Cx(h.type,l.memoizedProps,h.pendingProps,l.memoizedState),null;case 27:return it(h),l===null&&wt&&(_=h.stateNode=Ax(h.type,h.pendingProps,he.current),es=h,yr=!0,y=ci,La(h.type)?(ig=y,ci=xr(_.firstChild)):ci=y),is(l,h,h.pendingProps.children,p),ku(l,h),l===null&&(h.flags|=4194304),h.child;case 5:return l===null&&wt&&((y=_=ci)&&(_=V1(_,h.type,h.pendingProps,yr),_!==null?(h.stateNode=_,es=h,ci=xr(_.firstChild),yr=!1,y=!0):y=!1),y||xa(h)),it(h),y=h.type,S=h.pendingProps,P=l!==null?l.memoizedProps:null,_=S.children,$_(y,S)?_=null:P!==null&&$_(y,P)&&(h.flags|=32),h.memoizedState!==null&&(y=Zp(l,h,t1,null,null,p),nh._currentValue=y),ku(l,h),is(l,h,_,p),h.child;case 6:return l===null&&wt&&((l=p=ci)&&(p=z1(p,h.pendingProps,yr),p!==null?(h.stateNode=p,es=h,ci=null,l=!0):l=!1),l||xa(h)),null;case 13:return pv(l,h,p);case 4:return Le(h,h.stateNode.containerInfo),_=h.pendingProps,l===null?h.child=So(h,null,_,p):is(l,h,_,p),h.child;case 11:return nv(l,h,h.type,h.pendingProps,p);case 7:return is(l,h,h.pendingProps,p),h.child;case 8:return is(l,h,h.pendingProps.children,p),h.child;case 12:return is(l,h,h.pendingProps.children,p),h.child;case 10:return _=h.pendingProps,Sa(h,h.type,_.value),is(l,h,_.children,p),h.child;case 9:return y=h.type._context,_=h.pendingProps.children,bo(h),y=ts(y),_=_(y),h.flags|=1,is(l,h,_,p),h.child;case 14:return av(l,h,h.type,h.pendingProps,p);case 15:return ov(l,h,h.type,h.pendingProps,p);case 19:return gv(l,h,p);case 31:return c1(l,h,p);case 22:return lv(l,h,p,h.pendingProps);case 24:return bo(h),_=ts(Ni),l===null?(y=Vp(),y===null&&(y=ii,S=Up(),y.pooledCache=S,S.refCount++,S!==null&&(y.pooledCacheLanes|=p),y=S),h.memoizedState={parent:_,cache:y},Gp(h),Sa(h,Ni,y)):((l.lanes&p)!==0&&(Hp(l,h),kc(h,null,null,p),Uc()),y=l.memoizedState,S=h.memoizedState,y.parent!==_?(y={parent:_,cache:_},h.memoizedState=y,h.lanes===0&&(h.memoizedState=h.updateQueue.baseState=y),Sa(h,Ni,_)):(_=S.cache,Sa(h,Ni,_),_!==y.cache&&Bp(h,[Ni],p,!0))),is(l,h,h.pendingProps.children,p),h.child;case 29:throw h.pendingProps}throw Error(i(156,h.tag))}function Bn(l){l.flags|=4}function E_(l,h,p,_,y){if((h=(l.mode&32)!==0)&&(h=!1),h){if(l.flags|=16777216,(y&335544128)===y)if(l.stateNode.complete)l.flags|=8192;else if(Wv())l.flags|=8192;else throw xo=Eu,zp}else l.flags&=-16777217}function bv(l,h){if(h.type!=="stylesheet"||(h.state.loading&4)!==0)l.flags&=-16777217;else if(l.flags|=16777216,!wx(h))if(Wv())l.flags|=8192;else throw xo=Eu,zp}function zu(l,h){h!==null&&(l.flags|=4),l.flags&16384&&(h=l.tag!==22?hs():536870912,l.lanes|=h,Il|=h)}function Xc(l,h){if(!wt)switch(l.tailMode){case"hidden":h=l.tail;for(var p=null;h!==null;)h.alternate!==null&&(p=h),h=h.sibling;p===null?l.tail=null:p.sibling=null;break;case"collapsed":p=l.tail;for(var _=null;p!==null;)p.alternate!==null&&(_=p),p=p.sibling;_===null?h||l.tail===null?l.tail=null:l.tail.sibling=null:_.sibling=null}}function hi(l){var h=l.alternate!==null&&l.alternate.child===l.child,p=0,_=0;if(h)for(var y=l.child;y!==null;)p|=y.lanes|y.childLanes,_|=y.subtreeFlags&65011712,_|=y.flags&65011712,y.return=l,y=y.sibling;else for(y=l.child;y!==null;)p|=y.lanes|y.childLanes,_|=y.subtreeFlags,_|=y.flags,y.return=l,y=y.sibling;return l.subtreeFlags|=_,l.childLanes=p,h}function u1(l,h,p){var _=h.pendingProps;switch(Op(h),h.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return hi(h),null;case 1:return hi(h),null;case 3:return p=h.stateNode,_=null,l!==null&&(_=l.memoizedState.cache),h.memoizedState.cache!==_&&(h.flags|=2048),wn(Ni),Xe(),p.pendingContext&&(p.context=p.pendingContext,p.pendingContext=null),(l===null||l.child===null)&&(gl(h)?Bn(h):l===null||l.memoizedState.isDehydrated&&(h.flags&256)===0||(h.flags|=1024,Fp())),hi(h),null;case 26:var y=h.type,S=h.memoizedState;return l===null?(Bn(h),S!==null?(hi(h),bv(h,S)):(hi(h),E_(h,y,null,_,p))):S?S!==l.memoizedState?(Bn(h),hi(h),bv(h,S)):(hi(h),h.flags&=-16777217):(l=l.memoizedProps,l!==_&&Bn(h),hi(h),E_(h,y,l,_,p)),null;case 27:if(ut(h),p=he.current,y=h.type,l!==null&&h.stateNode!=null)l.memoizedProps!==_&&Bn(h);else{if(!_){if(h.stateNode===null)throw Error(i(166));return hi(h),null}l=j.current,gl(h)?$y(h):(l=Ax(y,_,p),h.stateNode=l,Bn(h))}return hi(h),null;case 5:if(ut(h),y=h.type,l!==null&&h.stateNode!=null)l.memoizedProps!==_&&Bn(h);else{if(!_){if(h.stateNode===null)throw Error(i(166));return hi(h),null}if(S=j.current,gl(h))$y(h);else{var P=id(he.current);switch(S){case 1:S=P.createElementNS("http://www.w3.org/2000/svg",y);break;case 2:S=P.createElementNS("http://www.w3.org/1998/Math/MathML",y);break;default:switch(y){case"svg":S=P.createElementNS("http://www.w3.org/2000/svg",y);break;case"math":S=P.createElementNS("http://www.w3.org/1998/Math/MathML",y);break;case"script":S=P.createElement("div"),S.innerHTML="<script><\/script>",S=S.removeChild(S.firstChild);break;
vendor: 27,140 bytes, line 49
49case"select":S=typeof _.is=="string"?P.createElement("select",{is:_.is}):P.createElement("select"),_.multiple?S.multiple=!0:_.size&&(S.size=_.size);break;default:S=typeof _.is=="string"?P.createElement(y,{is:_.is}):P.createElement(y)}}S[Ji]=h,S[Os]=_;e:for(P=h.child;P!==null;){if(P.tag===5||P.tag===6)S.appendChild(P.stateNode);else if(P.tag!==4&&P.tag!==27&&P.child!==null){P.child.return=P,P=P.child;continue}if(P===h)break e;for(;P.sibling===null;){if(P.return===null||P.return===h)break e;P=P.return}P.sibling.return=P.return,P=P.sibling}h.stateNode=S;e:switch(ss(S,y,_),y){case"button":case"input":case"select":case"textarea":_=!!_.autoFocus;break e;case"img":_=!0;break e;default:_=!1}_&&Bn(h)}}return hi(h),E_(h,h.type,l===null?null:l.memoizedProps,h.pendingProps,p),null;case 6:if(l&&h.stateNode!=null)l.memoizedProps!==_&&Bn(h);else{if(typeof _!="string"&&h.stateNode===null)throw Error(i(166));if(l=he.current,gl(h)){if(l=h.stateNode,p=h.memoizedProps,_=null,y=es,y!==null)switch(y.tag){case 27:case 5:_=y.memoizedProps}l[Ji]=h,l=!!(l.nodeValue===p||_!==null&&_.suppressHydrationWarning===!0||px(l.nodeValue,p)),l||xa(h,!0)}else l=id(l).createTextNode(_),l[Ji]=h,h.stateNode=l}return hi(h),null;case 31:if(p=h.memoizedState,l===null||l.memoizedState!==null){if(_=gl(h),p!==null){if(l===null){if(!_)throw Error(i(318));if(l=h.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(i(557));l[Ji]=h}else go(),(h.flags&128)===0&&(h.memoizedState=null),h.flags|=4;hi(h),l=!1}else p=Fp(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=p),l=!0;if(!l)return h.flags&256?(qs(h),h):(qs(h),null);if((h.flags&128)!==0)throw Error(i(558))}return hi(h),null;case 13:if(_=h.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(y=gl(h),_!==null&&_.dehydrated!==null){if(l===null){if(!y)throw Error(i(318));if(y=h.memoizedState,y=y!==null?y.dehydrated:null,!y)throw Error(i(317));y[Ji]=h}else go(),(h.flags&128)===0&&(h.memoizedState=null),h.flags|=4;hi(h),y=!1}else y=Fp(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=y),y=!0;if(!y)return h.flags&256?(qs(h),h):(qs(h),null)}return qs(h),(h.flags&128)!==0?(h.lanes=p,h):(p=_!==null,l=l!==null&&l.memoizedState!==null,p&&(_=h.child,y=null,_.alternate!==null&&_.alternate.memoizedState!==null&&_.alternate.memoizedState.cachePool!==null&&(y=_.alternate.memoizedState.cachePool.pool),S=null,_.memoizedState!==null&&_.memoizedState.cachePool!==null&&(S=_.memoizedState.cachePool.pool),S!==y&&(_.flags|=2048)),p!==l&&p&&(h.child.flags|=8192),zu(h,h.updateQueue),hi(h),null);case 4:return Xe(),l===null&&j_(h.stateNode.containerInfo),hi(h),null;case 10:return wn(h.type),hi(h),null;case 19:if(L(Ii),_=h.memoizedState,_===null)return hi(h),null;if(y=(h.flags&128)!==0,S=_.rendering,S===null)if(y)Xc(_,!1);else{if(Ei!==0||l!==null&&(l.flags&128)!==0)for(l=h.child;l!==null;){if(S=Cu(l),S!==null){for(h.flags|=128,Xc(_,!1),l=S.updateQueue,h.updateQueue=l,zu(h,l),h.subtreeFlags=0,l=p,p=h.child;p!==null;)jy(p,l),p=p.sibling;return V(Ii,Ii.current&1|2),wt&&Dn(h,_.treeForkCount),h.child}l=l.sibling}_.tail!==null&&Ci()>ju&&(h.flags|=128,y=!0,Xc(_,!1),h.lanes=4194304)}else{if(!y)if(l=Cu(S),l!==null){if(h.flags|=128,y=!0,l=l.updateQueue,h.updateQueue=l,zu(h,l),Xc(_,!0),_.tail===null&&_.tailMode==="hidden"&&!S.alternate&&!wt)return hi(h),null}else 2*Ci()-_.renderingStartTime>ju&&p!==536870912&&(h.flags|=128,y=!0,Xc(_,!1),h.lanes=4194304);_.isBackwards?(S.sibling=h.child,h.child=S):(l=_.last,l!==null?l.sibling=S:h.child=S,_.last=S)}return _.tail!==null?(l=_.tail,_.rendering=l,_.tail=l.sibling,_.renderingStartTime=Ci(),l.sibling=null,p=Ii.current,V(Ii,y?p&1|2:p&1),wt&&Dn(h,_.treeForkCount),l):(hi(h),null);case 22:case 23:return qs(h),Yp(),_=h.memoizedState!==null,l!==null?l.memoizedState!==null!==_&&(h.flags|=8192):_&&(h.flags|=8192),_?(p&536870912)!==0&&(h.flags&128)===0&&(hi(h),h.subtreeFlags&6&&(h.flags|=8192)):hi(h),p=h.updateQueue,p!==null&&zu(h,p.retryQueue),p=null,l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(p=l.memoizedState.cachePool.pool),_=null,h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(_=h.memoizedState.cachePool.pool),_!==p&&(h.flags|=2048),l!==null&&L(yo),null;case 24:return p=null,l!==null&&(p=l.memoizedState.cache),h.memoizedState.cache!==p&&(h.flags|=2048),wn(Ni),hi(h),null;case 25:return null;case 30:return null}throw Error(i(156,h.tag))}function d1(l,h){switch(Op(h),h.tag){case 1:return l=h.flags,l&65536?(h.flags=l&-65537|128,h):null;case 3:return wn(Ni),Xe(),l=h.flags,(l&65536)!==0&&(l&128)===0?(h.flags=l&-65537|128,h):null;case 26:case 27:case 5:return ut(h),null;case 31:if(h.memoizedState!==null){if(qs(h),h.alternate===null)throw Error(i(340));go()}return l=h.flags,l&65536?(h.flags=l&-65537|128,h):null;case 13:if(qs(h),l=h.memoizedState,l!==null&&l.dehydrated!==null){if(h.alternate===null)throw Error(i(340));go()}return l=h.flags,l&65536?(h.flags=l&-65537|128,h):null;case 19:return L(Ii),null;case 4:return Xe(),null;case 10:return wn(h.type),null;case 22:case 23:return qs(h),Yp(),l!==null&&L(yo),l=h.flags,l&65536?(h.flags=l&-65537|128,h):null;case 24:return wn(Ni),null;case 25:return null;default:return null}}function yv(l,h){switch(Op(h),h.tag){case 3:wn(Ni),Xe();break;case 26:case 27:case 5:ut(h);break;case 4:Xe();break;case 31:h.memoizedState!==null&&qs(h);break;case 13:qs(h);break;case 19:L(Ii);break;case 10:wn(h.type);break;case 22:case 23:qs(h),Yp(),l!==null&&L(yo);break;case 24:wn(Ni)}}function jc(l,h){try{var p=h.updateQueue,_=p!==null?p.lastEffect:null;if(_!==null){var y=_.next;p=y;do{if((p.tag&l)===l){_=void 0;var S=p.create,P=p.inst;_=S(),P.destroy=_}p=p.next}while(p!==y)}}catch(z){qt(h,h.return,z)}}function Ca(l,h,p){try{var _=h.updateQueue,y=_!==null?_.lastEffect:null;if(y!==null){var S=y.next;_=S;do{if((_.tag&l)===l){var P=_.inst,z=P.destroy;if(z!==void 0){P.destroy=void 0,y=h;var ee=p,ge=z;try{ge()}catch(Ee){qt(y,ee,Ee)}}}_=_.next}while(_!==S)}}catch(Ee){qt(h,h.return,Ee)}}function vv(l){var h=l.updateQueue;if(h!==null){var p=l.stateNode;try{h0(h,p)}catch(_){qt(l,l.return,_)}}}function xv(l,h,p){p.props=Eo(l.type,l.memoizedProps),p.state=l.memoizedState;try{p.componentWillUnmount()}catch(_){qt(l,h,_)}}function Yc(l,h){try{var p=l.ref;if(p!==null){switch(l.tag){case 26:case 27:case 5:var _=l.stateNode;break;case 30:_=l.stateNode;break;default:_=l.stateNode}typeof p=="function"?l.refCleanup=p(_):p.current=_}}catch(y){qt(l,h,y)}}function ln(l,h){var p=l.ref,_=l.refCleanup;if(p!==null)if(typeof _=="function")try{_()}catch(y){qt(l,h,y)}finally{l.refCleanup=null,l=l.alternate,l!=null&&(l.refCleanup=null)}else if(typeof p=="function")try{p(null)}catch(y){qt(l,h,y)}else p.current=null}function Sv(l){var h=l.type,p=l.memoizedProps,_=l.stateNode;try{e:switch(h){case"button":case"input":case"select":case"textarea":p.autoFocus&&_.focus();break e;case"img":p.src?_.src=p.src:p.srcSet&&(_.srcset=p.srcSet)}}catch(y){qt(l,l.return,y)}}function A_(l,h,p){try{var _=l.stateNode;F1(_,l.type,p,h),_[Os]=h}catch(y){qt(l,l.return,y)}}function Tv(l){return l.tag===5||l.tag===3||l.tag===26||l.tag===27&&La(l.type)||l.tag===4}function R_(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||Tv(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.tag===27&&La(l.type)||l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function M_(l,h,p){var _=l.tag;if(_===5||_===6)l=l.stateNode,h?(p.nodeType===9?p.body:p.nodeName==="HTML"?p.ownerDocument.body:p).insertBefore(l,h):(h=p.nodeType===9?p.body:p.nodeName==="HTML"?p.ownerDocument.body:p,h.appendChild(l),p=p._reactRootContainer,p!=null||h.onclick!==null||(h.onclick=Cn));else if(_!==4&&(_===27&&La(l.type)&&(p=l.stateNode,h=null),l=l.child,l!==null))for(M_(l,h,p),l=l.sibling;l!==null;)M_(l,h,p),l=l.sibling}function Gu(l,h,p){var _=l.tag;if(_===5||_===6)l=l.stateNode,h?p.insertBefore(l,h):p.appendChild(l);else if(_!==4&&(_===27&&La(l.type)&&(p=l.stateNode),l=l.child,l!==null))for(Gu(l,h,p),l=l.sibling;l!==null;)Gu(l,h,p),l=l.sibling}function Ev(l){var h=l.stateNode,p=l.memoizedProps;try{for(var _=l.type,y=h.attributes;y.length;)h.removeAttributeNode(y[0]);ss(h,_,p),h[Ji]=l,h[Os]=p}catch(S){qt(l,l.return,S)}}var Un=!1,ki=!1,C_=!1,Av=typeof WeakSet=="function"?WeakSet:Set,Zi=null;function f1(l,h){if(l=l.containerInfo,q_=cd,l=By(l),xp(l)){if("selectionStart"in l)var p={start:l.selectionStart,end:l.selectionEnd};else e:{p=(p=l.ownerDocument)&&p.defaultView||window;var _=p.getSelection&&p.getSelection();if(_&&_.rangeCount!==0){p=_.anchorNode;var y=_.anchorOffset,S=_.focusNode;_=_.focusOffset;try{p.nodeType,S.nodeType}catch{p=null;break e}var P=0,z=-1,ee=-1,ge=0,Ee=0,Me=l,me=null;t:for(;;){for(var ye;Me!==p||y!==0&&Me.nodeType!==3||(z=P+y),Me!==S||_!==0&&Me.nodeType!==3||(ee=P+_),Me.nodeType===3&&(P+=Me.nodeValue.length),(ye=Me.firstChild)!==null;)me=Me,Me=ye;for(;;){if(Me===l)break t;if(me===p&&++ge===y&&(z=P),me===S&&++Ee===_&&(ee=P),(ye=Me.nextSibling)!==null)break;Me=me,me=Me.parentNode}Me=ye}p=z===-1||ee===-1?null:{start:z,end:ee}}else p=null}p=p||{start:0,end:0}}else p=null;for(Z_={focusedElem:l,selectionRange:p},cd=!1,Zi=h;Zi!==null;)if(h=Zi,l=h.child,(h.subtreeFlags&1028)!==0&&l!==null)l.return=h,Zi=l;else for(;Zi!==null;){switch(h=Zi,S=h.alternate,l=h.flags,h.tag){case 0:if((l&4)!==0&&(l=h.updateQueue,l=l!==null?l.events:null,l!==null))for(p=0;p<l.length;p++)y=l[p],y.ref.impl=y.nextImpl;break;case 11:case 15:break;case 1:if((l&1024)!==0&&S!==null){l=void 0,p=h,y=S.memoizedProps,S=S.memoizedState,_=p.stateNode;try{var Je=Eo(p.type,y);l=_.getSnapshotBeforeUpdate(Je,S),_.__reactInternalSnapshotBeforeUpdate=l}catch(ct){qt(p,p.return,ct)}}break;case 3:if((l&1024)!==0){if(l=h.stateNode.containerInfo,p=l.nodeType,p===9)J_(l);else if(p===1)switch(l.nodeName){case"HEAD":case"HTML":case"BODY":J_(l);break;default:l.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((l&1024)!==0)throw Error(i(163))}if(l=h.sibling,l!==null){l.return=h.return,Zi=l;break}Zi=h.return}}function Rv(l,h,p){var _=p.flags;switch(p.tag){case 0:case 11:case 15:Vn(l,p),_&4&&jc(5,p);break;case 1:if(Vn(l,p),_&4)if(l=p.stateNode,h===null)try{l.componentDidMount()}catch(P){qt(p,p.return,P)}else{var y=Eo(p.type,h.memoizedProps);h=h.memoizedState;try{l.componentDidUpdate(y,h,l.__reactInternalSnapshotBeforeUpdate)}catch(P){qt(p,p.return,P)}}_&64&&vv(p),_&512&&Yc(p,p.return);break;case 3:if(Vn(l,p),_&64&&(l=p.updateQueue,l!==null)){if(h=null,p.child!==null)switch(p.child.tag){case 27:case 5:h=p.child.stateNode;break;case 1:h=p.child.stateNode}try{h0(l,h)}catch(P){qt(p,p.return,P)}}break;case 27:h===null&&_&4&&Ev(p);case 26:case 5:Vn(l,p),h===null&&_&4&&Sv(p),_&512&&Yc(p,p.return);break;case 12:Vn(l,p);break;case 31:Vn(l,p),_&4&&Iv(l,p);break;case 13:Vn(l,p),_&4&&Pv(l,p),_&64&&(l=p.memoizedState,l!==null&&(l=l.dehydrated,l!==null&&(p=S1.bind(null,p),G1(l,p))));break;case 22:if(_=p.memoizedState!==null||Un,!_){h=h!==null&&h.memoizedState!==null||ki,y=Un;var S=ki;Un=_,(ki=h)&&!S?zn(l,p,(p.subtreeFlags&8772)!==0):Vn(l,p),Un=y,ki=S}break;case 30:break;default:Vn(l,p)}}function Mv(l){var h=l.alternate;h!==null&&(l.alternate=null,Mv(h)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(h=l.stateNode,h!==null&&rp(h)),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}var _i=null,Fs=!1;function kn(l,h,p){for(p=p.child;p!==null;)Cv(l,h,p),p=p.sibling}function Cv(l,h,p){if(ms&&typeof ms.onCommitFiberUnmount=="function")try{ms.onCommitFiberUnmount(Xs,p)}catch{}switch(p.tag){case 26:ki||ln(p,h),kn(l,h,p),p.memoizedState?p.memoizedState.count--:p.stateNode&&(p=p.stateNode,p.parentNode.removeChild(p));break;case 27:ki||ln(p,h);var _=_i,y=Fs;La(p.type)&&(_i=p.stateNode,Fs=!1),kn(l,h,p),ih(p.stateNode),_i=_,Fs=y;break;case 5:ki||ln(p,h);case 6:if(_=_i,y=Fs,_i=null,kn(l,h,p),_i=_,Fs=y,_i!==null)if(Fs)try{(_i.nodeType===9?_i.body:_i.nodeName==="HTML"?_i.ownerDocument.body:_i).removeChild(p.stateNode)}catch(S){qt(p,h,S)}else try{_i.removeChild(p.stateNode)}catch(S){qt(p,h,S)}break;case 18:_i!==null&&(Fs?(l=_i,vx(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,p.stateNode),Bl(l)):vx(_i,p.stateNode));break;case 4:_=_i,y=Fs,_i=p.stateNode.containerInfo,Fs=!0,kn(l,h,p),_i=_,Fs=y;break;case 0:case 11:case 14:case 15:Ca(2,p,h),ki||Ca(4,p,h),kn(l,h,p);break;case 1:ki||(ln(p,h),_=p.stateNode,typeof _.componentWillUnmount=="function"&&xv(p,h,_)),kn(l,h,p);break;case 21:kn(l,h,p);break;case 22:ki=(_=ki)||p.memoizedState!==null,kn(l,h,p),ki=_;break;default:kn(l,h,p)}}function Iv(l,h){if(h.memoizedState===null&&(l=h.alternate,l!==null&&(l=l.memoizedState,l!==null))){l=l.dehydrated;try{Bl(l)}catch(p){qt(h,h.return,p)}}}function Pv(l,h){if(h.memoizedState===null&&(l=h.alternate,l!==null&&(l=l.memoizedState,l!==null&&(l=l.dehydrated,l!==null))))try{Bl(l)}catch(p){qt(h,h.return,p)}}function p1(l){switch(l.tag){case 31:case 13:case 19:var h=l.stateNode;return h===null&&(h=l.stateNode=new Av),h;case 22:return l=l.stateNode,h=l._retryCache,h===null&&(h=l._retryCache=new Av),h;default:throw Error(i(435,l.tag))}}function Hu(l,h){var p=p1(l);h.forEach(function(_){if(!p.has(_)){p.add(_);var y=T1.bind(null,l,_);_.then(y,y)}})}function Ls(l,h){var p=h.deletions;if(p!==null)for(var _=0;_<p.length;_++){var y=p[_],S=l,P=h,z=P;e:for(;z!==null;){switch(z.tag){case 27:if(La(z.type)){_i=z.stateNode,Fs=!1;break e}break;case 5:_i=z.stateNode,Fs=!1;break e;case 3:case 4:_i=z.stateNode.containerInfo,Fs=!0;break e}z=z.return}if(_i===null)throw Error(i(160));Cv(S,P,y),_i=null,Fs=!1,S=y.alternate,S!==null&&(S.return=null),y.return=null}if(h.subtreeFlags&13886)for(h=h.child;h!==null;)Dv(h,l),h=h.sibling}var Vr=null;function Dv(l,h){var p=l.alternate,_=l.flags;switch(l.tag){case 0:case 11:case 14:case 15:Ls(h,l),Ns(l),_&4&&(Ca(3,l,l.return),jc(3,l),Ca(5,l,l.return));break;case 1:Ls(h,l),Ns(l),_&512&&(ki||p===null||ln(p,p.return)),_&64&&Un&&(l=l.updateQueue,l!==null&&(_=l.callbacks,_!==null&&(p=l.shared.hiddenCallbacks,l.shared.hiddenCallbacks=p===null?_:p.concat(_))));break;case 26:var y=Vr;if(Ls(h,l),Ns(l),_&512&&(ki||p===null||ln(p,p.return)),_&4){var S=p!==null?p.memoizedState:null;if(_=l.memoizedState,p===null)if(_===null)if(l.stateNode===null){e:{_=l.type,p=l.memoizedProps,y=y.ownerDocument||y;t:switch(_){case"title":S=y.getElementsByTagName("title")[0],(!S||S[vc]||S[Ji]||S.namespaceURI==="http://www.w3.org/2000/svg"||S.hasAttribute("itemprop"))&&(S=y.createElement(_),y.head.insertBefore(S,y.querySelector("head > title"))),ss(S,_,p),S[Ji]=l,qi(S),_=S;break e;case"link":var P=Dx("link","href",y).get(_+(p.href||""));if(P){for(var z=0;z<P.length;z++)if(S=P[z],S.getAttribute("href")===(p.href==null||p.href===""?null:p.href)&&S.getAttribute("rel")===(p.rel==null?null:p.rel)&&S.getAttribute("title")===(p.title==null?null:p.title)&&S.getAttribute("crossorigin")===(p.crossOrigin==null?null:p.crossOrigin)){P.splice(z,1);break t}}S=y.createElement(_),ss(S,_,p),y.head.appendChild(S);break;case"meta":if(P=Dx("meta","content",y).get(_+(p.content||""))){for(z=0;z<P.length;z++)if(S=P[z],S.getAttribute("content")===(p.content==null?null:""+p.content)&&S.getAttribute("name")===(p.name==null?null:p.name)&&S.getAttribute("property")===(p.property==null?null:p.property)&&S.getAttribute("http-equiv")===(p.httpEquiv==null?null:p.httpEquiv)&&S.getAttribute("charset")===(p.charSet==null?null:p.charSet)){P.splice(z,1);break t}}S=y.createElement(_),ss(S,_,p),y.head.appendChild(S);break;default:throw Error(i(468,_))}S[Ji]=l,qi(S),_=S}l.stateNode=_}else Ox(y,l.type,l.stateNode);else l.stateNode=Px(y,_,l.memoizedProps);else S!==_?(S===null?p.stateNode!==null&&(p=p.stateNode,p.parentNode.removeChild(p)):S.count--,_===null?Ox(y,l.type,l.stateNode):Px(y,_,l.memoizedProps)):_===null&&l.stateNode!==null&&A_(l,l.memoizedProps,p.memoizedProps)}break;case 27:Ls(h,l),Ns(l),_&512&&(ki||p===null||ln(p,p.return)),p!==null&&_&4&&A_(l,l.memoizedProps,p.memoizedProps);break;case 5:if(Ls(h,l),Ns(l),_&512&&(ki||p===null||ln(p,p.return)),l.flags&32){y=l.stateNode;try{al(y,"")}catch(Je){qt(l,l.return,Je)}}_&4&&l.stateNode!=null&&(y=l.memoizedProps,A_(l,y,p!==null?p.memoizedProps:y)),_&1024&&(C_=!0);break;case 6:if(Ls(h,l),Ns(l),_&4){if(l.stateNode===null)throw Error(i(162));_=l.memoizedProps,p=l.stateNode;try{p.nodeValue=_}catch(Je){qt(l,l.return,Je)}}break;case 3:if(nd=null,y=Vr,Vr=sd(h.containerInfo),Ls(h,l),Vr=y,Ns(l),_&4&&p!==null&&p.memoizedState.isDehydrated)try{Bl(h.containerInfo)}catch(Je){qt(l,l.return,Je)}C_&&(C_=!1,Ov(l));break;case 4:_=Vr,Vr=sd(l.stateNode.containerInfo),Ls(h,l),Ns(l),Vr=_;break;case 12:Ls(h,l),Ns(l);break;case 31:Ls(h,l),Ns(l),_&4&&(_=l.updateQueue,_!==null&&(l.updateQueue=null,Hu(l,_)));break;case 13:Ls(h,l),Ns(l),l.child.flags&8192&&l.memoizedState!==null!=(p!==null&&p.memoizedState!==null)&&(Xu=Ci()),_&4&&(_=l.updateQueue,_!==null&&(l.updateQueue=null,Hu(l,_)));break;case 22:y=l.memoizedState!==null;var ee=p!==null&&p.memoizedState!==null,ge=Un,Ee=ki;if(Un=ge||y,ki=Ee||ee,Ls(h,l),ki=Ee,Un=ge,Ns(l),_&8192)e:for(h=l.stateNode,h._visibility=y?h._visibility&-2:h._visibility|1,y&&(p===null||ee||Un||ki||Ao(l)),p=null,h=l;;){if(h.tag===5||h.tag===26){if(p===null){ee=p=h;try{if(S=ee.stateNode,y)P=S.style,typeof P.setProperty=="function"?P.setProperty("display","none","important"):P.display="none";else{z=ee.stateNode;var Me=ee.memoizedProps.style,me=Me!=null&&Me.hasOwnProperty("display")?Me.display:null;z.style.display=me==null||typeof me=="boolean"?"":(""+me).trim()}}catch(Je){qt(ee,ee.return,Je)}}}else if(h.tag===6){if(p===null){ee=h;try{ee.stateNode.nodeValue=y?"":ee.memoizedProps}catch(Je){qt(ee,ee.return,Je)}}}else if(h.tag===18){if(p===null){ee=h;try{var ye=ee.stateNode;y?xx(ye,!0):xx(ee.stateNode,!1)}catch(Je){qt(ee,ee.return,Je)}}}else if((h.tag!==22&&h.tag!==23||h.memoizedState===null||h===l)&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===l)break e;for(;h.sibling===null;){if(h.return===null||h.return===l)break e;p===h&&(p=null),h=h.return}p===h&&(p=null),h.sibling.return=h.return,h=h.sibling}_&4&&(_=l.updateQueue,_!==null&&(p=_.retryQueue,p!==null&&(_.retryQueue=null,Hu(l,p))));break;case 19:Ls(h,l),Ns(l),_&4&&(_=l.updateQueue,_!==null&&(l.updateQueue=null,Hu(l,_)));break;case 30:break;case 21:break;default:Ls(h,l),Ns(l)}}function Ns(l){var h=l.flags;if(h&2){try{for(var p,_=l.return;_!==null;){if(Tv(_)){p=_;break}_=_.return}if(p==null)throw Error(i(160));switch(p.tag){case 27:var y=p.stateNode,S=R_(l);Gu(l,S,y);break;case 5:var P=p.stateNode;p.flags&32&&(al(P,""),p.flags&=-33);var z=R_(l);Gu(l,z,P);break;case 3:case 4:var ee=p.stateNode.containerInfo,ge=R_(l);M_(l,ge,ee);break;default:throw Error(i(161))}}catch(Ee){qt(l,l.return,Ee)}l.flags&=-3}h&4096&&(l.flags&=-4097)}function Ov(l){if(l.subtreeFlags&1024)for(l=l.child;l!==null;){var h=l;Ov(h),h.tag===5&&h.flags&1024&&h.stateNode.reset(),l=l.sibling}}function Vn(l,h){if(h.subtreeFlags&8772)for(h=h.child;h!==null;)Rv(l,h.alternate,h),h=h.sibling}function Ao(l){for(l=l.child;l!==null;){var h=l;switch(h.tag){case 0:case 11:case 14:case 15:Ca(4,h,h.return),Ao(h);break;case 1:ln(h,h.return);var p=h.stateNode;typeof p.componentWillUnmount=="function"&&xv(h,h.return,p),Ao(h);break;case 27:ih(h.stateNode);case 26:case 5:ln(h,h.return),Ao(h);break;case 22:h.memoizedState===null&&Ao(h);break;case 30:Ao(h);break;default:Ao(h)}l=l.sibling}}function zn(l,h,p){for(p=p&&(h.subtreeFlags&8772)!==0,h=h.child;h!==null;){var _=h.alternate,y=l,S=h,P=S.flags;switch(S.tag){case 0:case 11:case 15:zn(y,S,p),jc(4,S);break;case 1:if(zn(y,S,p),_=S,y=_.stateNode,typeof y.componentDidMount=="function")try{y.componentDidMount()}catch(ge){qt(_,_.return,ge)}if(_=S,y=_.updateQueue,y!==null){var z=_.stateNode;try{var ee=y.shared.hiddenCallbacks;if(ee!==null)for(y.shared.hiddenCallbacks=null,y=0;y<ee.length;y++)c0(ee[y],z)}catch(ge){qt(_,_.return,ge)}}p&&P&64&&vv(S),Yc(S,S.return);break;case 27:Ev(S);case 26:case 5:zn(y,S,p),p&&_===null&&P&4&&Sv(S),Yc(S,S.return);break;case 12:zn(y,S,p);break;case 31:zn(y,S,p),p&&P&4&&Iv(y,S);break;case 13:zn(y,S,p),p&&P&4&&Pv(y,S);break;case 22:S.memoizedState===null&&zn(y,S,p),Yc(S,S.return);break;case 30:break;default:zn(y,S,p)}h=h.sibling}}function I_(l,h){var p=null;l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(p=l.memoizedState.cachePool.pool),l=null,h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(l=h.memoizedState.cachePool.pool),l!==p&&(l!=null&&l.refCount++,p!=null&&wc(p))}function P_(l,h){l=null,h.alternate!==null&&(l=h.alternate.memoizedState.cache),h=h.memoizedState.cache,h!==l&&(h.refCount++,l!=null&&wc(l))}function zr(l,h,p,_){if(h.subtreeFlags&10256)for(h=h.child;h!==null;)wv(l,h,p,_),h=h.sibling}function wv(l,h,p,_){var y=h.flags;switch(h.tag){case 0:case 11:case 15:zr(l,h,p,_),y&2048&&jc(9,h);break;case 1:zr(l,h,p,_);break;case 3:zr(l,h,p,_),y&2048&&(l=null,h.alternate!==null&&(l=h.alternate.memoizedState.cache),h=h.memoizedState.cache,h!==l&&(h.refCount++,l!=null&&wc(l)));break;case 12:if(y&2048){zr(l,h,p,_),l=h.stateNode;try{var S=h.memoizedProps,P=S.id,z=S.onPostCommit;typeof z=="function"&&z(P,h.alternate===null?"mount":"update",l.passiveEffectDuration,-0)}catch(ee){qt(h,h.return,ee)}}else zr(l,h,p,_);break;case 31:zr(l,h,p,_);break;case 13:zr(l,h,p,_);break;case 23:break;case 22:S=h.stateNode,P=h.alternate,h.memoizedState!==null?S._visibility&2?zr(l,h,p,_):Kc(l,h):S._visibility&2?zr(l,h,p,_):(S._visibility|=2,Rl(l,h,p,_,(h.subtreeFlags&10256)!==0||!1)),y&2048&&I_(P,h);break;case 24:zr(l,h,p,_),y&2048&&P_(h.alternate,h);break;default:zr(l,h,p,_)}}function Rl(l,h,p,_,y){for(y=y&&((h.subtreeFlags&10256)!==0||!1),h=h.child;h!==null;){var S=l,P=h,z=p,ee=_,ge=P.flags;switch(P.tag){case 0:case 11:case 15:Rl(S,P,z,ee,y),jc(8,P);break;case 23:break;case 22:var Ee=P.stateNode;P.memoizedState!==null?Ee._visibility&2?Rl(S,P,z,ee,y):Kc(S,P):(Ee._visibility|=2,Rl(S,P,z,ee,y)),y&&ge&2048&&I_(P.alternate,P);break;case 24:Rl(S,P,z,ee,y),y&&ge&2048&&P_(P.alternate,P);break;default:Rl(S,P,z,ee,y)}h=h.sibling}}function Kc(l,h){if(h.subtreeFlags&10256)for(h=h.child;h!==null;){var p=l,_=h,y=_.flags;switch(_.tag){case 22:Kc(p,_),y&2048&&I_(_.alternate,_);break;case 24:Kc(p,_),y&2048&&P_(_.alternate,_);break;default:Kc(p,_)}h=h.sibling}}var qc=8192;function Ml(l,h,p){if(l.subtreeFlags&qc)for(l=l.child;l!==null;)Fv(l,h,p),l=l.sibling}function Fv(l,h,p){switch(l.tag){case 26:Ml(l,h,p),l.flags&qc&&l.memoizedState!==null&&eD(p,Vr,l.memoizedState,l.memoizedProps);break;case 5:Ml(l,h,p);break;case 3:case 4:var _=Vr;Vr=sd(l.stateNode.containerInfo),Ml(l,h,p),Vr=_;break;case 22:l.memoizedState===null&&(_=l.alternate,_!==null&&_.memoizedState!==null?(_=qc,qc=16777216,Ml(l,h,p),qc=_):Ml(l,h,p));break;default:Ml(l,h,p)}}function Lv(l){var h=l.alternate;if(h!==null&&(l=h.child,l!==null)){h.child=null;do h=l.sibling,l.sibling=null,l=h;while(l!==null)}}function Zc(l){var h=l.deletions;if((l.flags&16)!==0){if(h!==null)for(var p=0;p<h.length;p++){var _=h[p];Zi=_,Bv(_,l)}Lv(l)}if(l.subtreeFlags&10256)for(l=l.child;l!==null;)Nv(l),l=l.sibling}function Nv(l){switch(l.tag){case 0:case 11:case 15:Zc(l),l.flags&2048&&Ca(9,l,l.return);break;case 3:Zc(l);break;case 12:Zc(l);break;case 22:var h=l.stateNode;l.memoizedState!==null&&h._visibility&2&&(l.return===null||l.return.tag!==13)?(h._visibility&=-3,Wu(l)):Zc(l);break;default:Zc(l)}}function Wu(l){var h=l.deletions;if((l.flags&16)!==0){if(h!==null)for(var p=0;p<h.length;p++){var _=h[p];Zi=_,Bv(_,l)}Lv(l)}for(l=l.child;l!==null;){switch(h=l,h.tag){case 0:case 11:case 15:Ca(8,h,h.return),Wu(h);break;case 22:p=h.stateNode,p._visibility&2&&(p._visibility&=-3,Wu(h));break;default:Wu(h)}l=l.sibling}}function Bv(l,h){for(;Zi!==null;){var p=Zi;switch(p.tag){case 0:case 11:case 15:Ca(8,p,h);break;case 23:case 22:if(p.memoizedState!==null&&p.memoizedState.cachePool!==null){var _=p.memoizedState.cachePool.pool;_!=null&&_.refCount++}break;case 24:wc(p.memoizedState.cache)}if(_=p.child,_!==null)_.return=p,Zi=_;else e:for(p=l;Zi!==null;){_=Zi;var y=_.sibling,S=_.return;if(Mv(_),_===p){Zi=null;break e}if(y!==null){y.return=S,Zi=y;break e}Zi=S}}}var _1={getCacheForType:function(l){var h=ts(Ni),p=h.data.get(l);return p===void 0&&(p=l(),h.data.set(l,p)),p},cacheSignal:function(){return ts(Ni).controller.signal}},g1=typeof WeakMap=="function"?WeakMap:Map,Xt=0,ii=null,Rt=null,Ct=0,Kt=0,Zs=null,Ia=!1,Cl=!1,D_=!1,Gn=0,Ei=0,Pa=0,Ro=0,O_=0,$s=0,Il=0,$c=null,Bs=null,w_=!1,Xu=0,Uv=0,ju=1/0,Yu=null,Da=null,Xi=0,Oa=null,Pl=null,Hn=0,F_=0,L_=null,kv=null,Qc=0,N_=null;function Qs(){return(Xt&2)!==0&&Ct!==0?Ct&-Ct:G.T!==null?G_():ip()}function Vv(){if($s===0)if((Ct&536870912)===0||wt){var l=Qo;Qo<<=1,(Qo&3932160)===0&&(Qo=262144),$s=l}else $s=536870912;return l=Ks.current,l!==null&&(l.flags|=32),$s}function Us(l,h,p){(l===ii&&(Kt===2||Kt===9)||l.cancelPendingCommit!==null)&&(Dl(l,0),wa(l,Ct,$s,!1)),xi(l,p),((Xt&2)===0||l!==ii)&&(l===ii&&((Xt&2)===0&&(Ro|=p),Ei===4&&wa(l,Ct,$s,!1)),cn(l))}function zv(l,h,p){if((Xt&6)!==0)throw Error(i(327));var _=!p&&(h&127)===0&&(h&l.expiredLanes)===0||pi(l,h),y=_?y1(l,h):U_(l,h,!0),S=_;do{if(y===0){Cl&&!_&&wa(l,h,0,!1);break}else{if(p=l.current.alternate,S&&!m1(p)){y=U_(l,h,!1),S=!1;continue}if(y===2){if(S=h,l.errorRecoveryDisabledLanes&S)var P=0;else P=l.pendingLanes&-536870913,P=P!==0?P:P&536870912?536870912:0;if(P!==0){h=P;e:{var z=l;y=$c;var ee=z.current.memoizedState.isDehydrated;if(ee&&(Dl(z,P).flags|=256),P=U_(z,P,!1),P!==2){if(D_&&!ee){z.errorRecoveryDisabledLanes|=S,Ro|=S,y=4;break e}S=Bs,Bs=y,S!==null&&(Bs===null?Bs=S:Bs.push.apply(Bs,S))}y=P}if(S=!1,y!==2)continue}}if(y===1){Dl(l,0),wa(l,h,0,!0);break}e:{switch(_=l,S=y,S){case 0:case 1:throw Error(i(345));case 4:if((h&4194048)!==h)break;case 6:wa(_,h,$s,!Ia);break e;case 2:Bs=null;break;case 3:case 5:break;default:throw Error(i(329))}if((h&62914560)===h&&(y=Xu+300-Ci(),10<y)){if(wa(_,h,$s,!Ia),pt(_,0,!0)!==0)break e;Hn=h,_.timeoutHandle=bx(Gv.bind(null,_,p,Bs,Yu,w_,h,$s,Ro,Il,Ia,S,"Throttled",-0,0),y);break e}Gv(_,p,Bs,Yu,w_,h,$s,Ro,Il,Ia,S,null,-0,0)}}break}while(!0);cn(l)}function Gv(l,h,p,_,y,S,P,z,ee,ge,Ee,Me,me,ye){if(l.timeoutHandle=-1,Me=h.subtreeFlags,Me&8192||(Me&16785408)===16785408){Me={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Cn},Fv(h,S,Me);var Je=(S&62914560)===S?Xu-Ci():(S&4194048)===S?Uv-Ci():0;if(Je=tD(Me,Je),Je!==null){Hn=S,l.cancelPendingCommit=Je(Zv.bind(null,l,h,S,p,_,y,P,z,ee,Ee,Me,null,me,ye)),wa(l,S,P,!ge);return}}Zv(l,h,S,p,_,y,P,z,ee)}function m1(l){for(var h=l;;){var p=h.tag;if((p===0||p===11||p===15)&&h.flags&16384&&(p=h.updateQueue,p!==null&&(p=p.stores,p!==null)))for(var _=0;_<p.length;_++){var y=p[_],S=y.getSnapshot;y=y.value;try{if(!js(S(),y))return!1}catch{return!1}}if(p=h.child,h.subtreeFlags&16384&&p!==null)p.return=h,h=p;else{if(h===l)break;for(;h.sibling===null;){if(h.return===null||h.return===l)return!0;h=h.return}
vendor: 22,563 bytes, lines 49-50
49h.sibling.return=h.return,h=h.sibling}}return!0}function wa(l,h,p,_){h&=~O_,h&=~Ro,l.suspendedLanes|=h,l.pingedLanes&=~h,_&&(l.warmLanes|=h),_=l.expirationTimes;for(var y=h;0<y;){var S=31-cs(y),P=1<<S;_[S]=-1,y&=~P}p!==0&&lo(l,p,h)}function Ku(){return(Xt&6)===0?(Jc(0),!1):!0}function B_(){if(Rt!==null){if(Kt===0)var l=Rt.return;else l=Rt,On=mo=null,Jp(l),xl=null,Lc=0,l=Rt;for(;l!==null;)yv(l.alternate,l),l=l.return;Rt=null}}function Dl(l,h){var p=l.timeoutHandle;p!==-1&&(l.timeoutHandle=-1,B1(p)),p=l.cancelPendingCommit,p!==null&&(l.cancelPendingCommit=null,p()),Hn=0,B_(),ii=l,Rt=p=Pn(l.current,null),Ct=h,Kt=0,Zs=null,Ia=!1,Cl=pi(l,h),D_=!1,Il=$s=O_=Ro=Pa=Ei=0,Bs=$c=null,w_=!1,(h&8)!==0&&(h|=h&32);var _=l.entangledLanes;if(_!==0)for(l=l.entanglements,_&=h;0<_;){var y=31-cs(_),S=1<<y;h|=l[y],_&=~S}return Gn=h,_u(),p}function Hv(l,h){yt=null,G.H=Hc,h===vl||h===Tu?(h=n0(),Kt=3):h===zp?(h=n0(),Kt=4):Kt=h===__?8:h!==null&&typeof h=="object"&&typeof h.then=="function"?6:1,Zs=h,Rt===null&&(Ei=1,Bu(l,gr(h,l.current)))}function Wv(){var l=Ks.current;return l===null?!0:(Ct&4194048)===Ct?vr===null:(Ct&62914560)===Ct||(Ct&536870912)!==0?l===vr:!1}function Xv(){var l=G.H;return G.H=Hc,l===null?Hc:l}function jv(){var l=G.A;return G.A=_1,l}function qu(){Ei=4,Ia||(Ct&4194048)!==Ct&&Ks.current!==null||(Cl=!0),(Pa&134217727)===0&&(Ro&134217727)===0||ii===null||wa(ii,Ct,$s,!1)}function U_(l,h,p){var _=Xt;Xt|=2;var y=Xv(),S=jv();(ii!==l||Ct!==h)&&(Yu=null,Dl(l,h)),h=!1;var P=Ei;e:do try{if(Kt!==0&&Rt!==null){var z=Rt,ee=Zs;switch(Kt){case 8:B_(),P=6;break e;case 3:case 2:case 9:case 6:Ks.current===null&&(h=!0);var ge=Kt;if(Kt=0,Zs=null,Ol(l,z,ee,ge),p&&Cl){P=0;break e}break;default:ge=Kt,Kt=0,Zs=null,Ol(l,z,ee,ge)}}b1(),P=Ei;break}catch(Ee){Hv(l,Ee)}while(!0);return h&&l.shellSuspendCounter++,On=mo=null,Xt=_,G.H=y,G.A=S,Rt===null&&(ii=null,Ct=0,_u()),P}function b1(){for(;Rt!==null;)Yv(Rt)}function y1(l,h){var p=Xt;Xt|=2;var _=Xv(),y=jv();ii!==l||Ct!==h?(Yu=null,ju=Ci()+500,Dl(l,h)):Cl=pi(l,h);e:do try{if(Kt!==0&&Rt!==null){h=Rt;var S=Zs;t:switch(Kt){case 1:Kt=0,Zs=null,Ol(l,h,S,1);break;case 2:case 9:if(s0(S)){Kt=0,Zs=null,Kv(h);break}h=function(){Kt!==2&&Kt!==9||ii!==l||(Kt=7),cn(l)},S.then(h,h);break e;case 3:Kt=7;break e;case 4:Kt=5;break e;case 7:s0(S)?(Kt=0,Zs=null,Kv(h)):(Kt=0,Zs=null,Ol(l,h,S,7));break;case 5:var P=null;switch(Rt.tag){case 26:P=Rt.memoizedState;case 5:case 27:var z=Rt;if(P?wx(P):z.stateNode.complete){Kt=0,Zs=null;var ee=z.sibling;if(ee!==null)Rt=ee;else{var ge=z.return;ge!==null?(Rt=ge,Zu(ge)):Rt=null}break t}}Kt=0,Zs=null,Ol(l,h,S,5);break;case 6:Kt=0,Zs=null,Ol(l,h,S,6);break;case 8:B_(),Ei=6;break e;default:throw Error(i(462))}}v1();break}catch(Ee){Hv(l,Ee)}while(!0);return On=mo=null,G.H=_,G.A=y,Xt=p,Rt!==null?0:(ii=null,Ct=0,_u(),Ei)}function v1(){for(;Rt!==null&&!Mi();)Yv(Rt)}function Yv(l){var h=mv(l.alternate,l,Gn);l.memoizedProps=l.pendingProps,h===null?Zu(l):Rt=h}function Kv(l){var h=l,p=h.alternate;switch(h.tag){case 15:case 0:h=uv(p,h,h.pendingProps,h.type,void 0,Ct);break;case 11:h=uv(p,h,h.pendingProps,h.type.render,h.ref,Ct);break;case 5:Jp(h);default:yv(p,h),h=Rt=jy(h,Gn),h=mv(p,h,Gn)}l.memoizedProps=l.pendingProps,h===null?Zu(l):Rt=h}function Ol(l,h,p,_){On=mo=null,Jp(h),xl=null,Lc=0;var y=h.return;try{if(l1(l,y,h,p,Ct)){Ei=1,Bu(l,gr(p,l.current)),Rt=null;return}}catch(S){if(y!==null)throw Rt=y,S;Ei=1,Bu(l,gr(p,l.current)),Rt=null;return}h.flags&32768?(wt||_===1?l=!0:Cl||(Ct&536870912)!==0?l=!1:(Ia=l=!0,(_===2||_===9||_===3||_===6)&&(_=Ks.current,_!==null&&_.tag===13&&(_.flags|=16384))),qv(h,l)):Zu(h)}function Zu(l){var h=l;do{if((h.flags&32768)!==0){qv(h,Ia);return}l=h.return;var p=u1(h.alternate,h,Gn);if(p!==null){Rt=p;return}if(h=h.sibling,h!==null){Rt=h;return}Rt=h=l}while(h!==null);Ei===0&&(Ei=5)}function qv(l,h){do{var p=d1(l.alternate,l);if(p!==null){p.flags&=32767,Rt=p;return}if(p=l.return,p!==null&&(p.flags|=32768,p.subtreeFlags=0,p.deletions=null),!h&&(l=l.sibling,l!==null)){Rt=l;return}Rt=l=p}while(l!==null);Ei=6,Rt=null}function Zv(l,h,p,_,y,S,P,z,ee){l.cancelPendingCommit=null;do $u();while(Xi!==0);if((Xt&6)!==0)throw Error(i(327));if(h!==null){if(h===l.current)throw Error(i(177));if(S=h.lanes|h.childLanes,S|=Rp,Is(l,p,S,P,z,ee),l===ii&&(Rt=ii=null,Ct=0),Pl=h,Oa=l,Hn=p,F_=S,L_=y,kv=_,(h.subtreeFlags&10256)!==0||(h.flags&10256)!==0?(l.callbackNode=null,l.callbackPriority=0,E1(sn,function(){return tx(),null})):(l.callbackNode=null,l.callbackPriority=0),_=(h.flags&13878)!==0,(h.subtreeFlags&13878)!==0||_){_=G.T,G.T=null,y=K.p,K.p=2,P=Xt,Xt|=4;try{f1(l,h,p)}finally{Xt=P,K.p=y,G.T=_}}Xi=1,$v(),Qv(),Jv()}}function $v(){if(Xi===1){Xi=0;var l=Oa,h=Pl,p=(h.flags&13878)!==0;if((h.subtreeFlags&13878)!==0||p){p=G.T,G.T=null;var _=K.p;K.p=2;var y=Xt;Xt|=4;try{Dv(h,l);var S=Z_,P=By(l.containerInfo),z=S.focusedElem,ee=S.selectionRange;if(P!==z&&z&&z.ownerDocument&&Ny(z.ownerDocument.documentElement,z)){if(ee!==null&&xp(z)){var ge=ee.start,Ee=ee.end;if(Ee===void 0&&(Ee=ge),"selectionStart"in z)z.selectionStart=ge,z.selectionEnd=Math.min(Ee,z.value.length);else{var Me=z.ownerDocument||document,me=Me&&Me.defaultView||window;if(me.getSelection){var ye=me.getSelection(),Je=z.textContent.length,ct=Math.min(ee.start,Je),ti=ee.end===void 0?ct:Math.min(ee.end,Je);!ye.extend&&ct>ti&&(P=ti,ti=ct,ct=P);var ue=Ly(z,ct),ne=Ly(z,ti);if(ue&&ne&&(ye.rangeCount!==1||ye.anchorNode!==ue.node||ye.anchorOffset!==ue.offset||ye.focusNode!==ne.node||ye.focusOffset!==ne.offset)){var _e=Me.createRange();_e.setStart(ue.node,ue.offset),ye.removeAllRanges(),ct>ti?(ye.addRange(_e),ye.extend(ne.node,ne.offset)):(_e.setEnd(ne.node,ne.offset),ye.addRange(_e))}}}}for(Me=[],ye=z;ye=ye.parentNode;)ye.nodeType===1&&Me.push({element:ye,left:ye.scrollLeft,top:ye.scrollTop});for(typeof z.focus=="function"&&z.focus(),z=0;z<Me.length;z++){var Re=Me[z];Re.element.scrollLeft=Re.left,Re.element.scrollTop=Re.top}}cd=!!q_,Z_=q_=null}finally{Xt=y,K.p=_,G.T=p}}l.current=h,Xi=2}}function Qv(){if(Xi===2){Xi=0;var l=Oa,h=Pl,p=(h.flags&8772)!==0;if((h.subtreeFlags&8772)!==0||p){p=G.T,G.T=null;var _=K.p;K.p=2;var y=Xt;Xt|=4;try{Rv(l,h.alternate,h)}finally{Xt=y,K.p=_,G.T=p}}Xi=3}}function Jv(){if(Xi===4||Xi===3){Xi=0,dr();var l=Oa,h=Pl,p=Hn,_=kv;(h.subtreeFlags&10256)!==0||(h.flags&10256)!==0?Xi=5:(Xi=0,Pl=Oa=null,ex(l,l.pendingLanes));var y=l.pendingLanes;if(y===0&&(Da=null),Ur(p),h=h.stateNode,ms&&typeof ms.onCommitFiberRoot=="function")try{ms.onCommitFiberRoot(Xs,h,void 0,(h.current.flags&128)===128)}catch{}if(_!==null){h=G.T,y=K.p,K.p=2,G.T=null;try{for(var S=l.onRecoverableError,P=0;P<_.length;P++){var z=_[P];S(z.value,{componentStack:z.stack})}}finally{G.T=h,K.p=y}}(Hn&3)!==0&&$u(),cn(l),y=l.pendingLanes,(p&261930)!==0&&(y&42)!==0?l===N_?Qc++:(Qc=0,N_=l):Qc=0,Jc(0)}}function ex(l,h){(l.pooledCacheLanes&=h)===0&&(h=l.pooledCache,h!=null&&(l.pooledCache=null,wc(h)))}function $u(){return $v(),Qv(),Jv(),tx()}function tx(){if(Xi!==5)return!1;var l=Oa,h=F_;F_=0;var p=Ur(Hn),_=G.T,y=K.p;try{K.p=32>p?32:p,G.T=null,p=L_,L_=null;var S=Oa,P=Hn;if(Xi=0,Pl=Oa=null,Hn=0,(Xt&6)!==0)throw Error(i(331));var z=Xt;if(Xt|=4,Nv(S.current),wv(S,S.current,P,p),Xt=z,Jc(0,!1),ms&&typeof ms.onPostCommitFiberRoot=="function")try{ms.onPostCommitFiberRoot(Xs,S)}catch{}return!0}finally{K.p=y,G.T=_,ex(l,h)}}function ix(l,h,p){h=gr(p,h),h=p_(l.stateNode,h,2),l=Aa(l,h,2),l!==null&&(xi(l,2),cn(l))}function qt(l,h,p){if(l.tag===3)ix(l,l,p);else for(;h!==null;){if(h.tag===3){ix(h,l,p);break}else if(h.tag===1){var _=h.stateNode;if(typeof h.type.getDerivedStateFromError=="function"||typeof _.componentDidCatch=="function"&&(Da===null||!Da.has(_))){l=gr(p,l),p=sv(2),_=Aa(h,p,2),_!==null&&(rv(p,_,h,l),xi(_,2),cn(_));break}}h=h.return}}function k_(l,h,p){var _=l.pingCache;if(_===null){_=l.pingCache=new g1;var y=new Set;_.set(h,y)}else y=_.get(h),y===void 0&&(y=new Set,_.set(h,y));y.has(p)||(D_=!0,y.add(p),l=x1.bind(null,l,h,p),h.then(l,l))}function x1(l,h,p){var _=l.pingCache;_!==null&&_.delete(h),l.pingedLanes|=l.suspendedLanes&p,l.warmLanes&=~p,ii===l&&(Ct&p)===p&&(Ei===4||Ei===3&&(Ct&62914560)===Ct&&300>Ci()-Xu?(Xt&2)===0&&Dl(l,0):O_|=p,Il===Ct&&(Il=0)),cn(l)}function sx(l,h){h===0&&(h=hs()),l=po(l,h),l!==null&&(xi(l,h),cn(l))}function S1(l){var h=l.memoizedState,p=0;h!==null&&(p=h.retryLane),sx(l,p)}function T1(l,h){var p=0;switch(l.tag){case 31:case 13:var _=l.stateNode,y=l.memoizedState;y!==null&&(p=y.retryLane);break;case 19:_=l.stateNode;break;case 22:_=l.stateNode._retryCache;break;default:throw Error(i(314))}_!==null&&_.delete(h),sx(l,p)}function E1(l,h){return ls(l,h)}var Qu=null,wl=null,V_=!1,Ju=!1,z_=!1,Fa=0;function cn(l){l!==wl&&l.next===null&&(wl===null?Qu=wl=l:wl=wl.next=l),Ju=!0,V_||(V_=!0,R1())}function Jc(l,h){if(!z_&&Ju){z_=!0;do for(var p=!1,_=Qu;_!==null;){if(l!==0){var y=_.pendingLanes;if(y===0)var S=0;else{var P=_.suspendedLanes,z=_.pingedLanes;S=(1<<31-cs(42|l)+1)-1,S&=y&~(P&~z),S=S&201326741?S&201326741|1:S?S|2:0}S!==0&&(p=!0,ox(_,S))}else S=Ct,S=pt(_,_===ii?S:0,_.cancelPendingCommit!==null||_.timeoutHandle!==-1),(S&3)===0||pi(_,S)||(p=!0,ox(_,S));_=_.next}while(p);z_=!1}}function A1(){rx()}function rx(){Ju=V_=!1;var l=0;Fa!==0&&N1()&&(l=Fa);for(var h=Ci(),p=null,_=Qu;_!==null;){var y=_.next,S=nx(_,h);S===0?(_.next=null,p===null?Qu=y:p.next=y,y===null&&(wl=p)):(p=_,(l!==0||(S&3)!==0)&&(Ju=!0)),_=y}Xi!==0&&Xi!==5||Jc(l),Fa!==0&&(Fa=0)}function nx(l,h){for(var p=l.suspendedLanes,_=l.pingedLanes,y=l.expirationTimes,S=l.pendingLanes&-62914561;0<S;){var P=31-cs(S),z=1<<P,ee=y[P];ee===-1?((z&p)===0||(z&_)!==0)&&(y[P]=Ki(z,h)):ee<=h&&(l.expiredLanes|=z),S&=~z}if(h=ii,p=Ct,p=pt(l,l===h?p:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),_=l.callbackNode,p===0||l===h&&(Kt===2||Kt===9)||l.cancelPendingCommit!==null)return _!==null&&_!==null&&ur(_),l.callbackNode=null,l.callbackPriority=0;if((p&3)===0||pi(l,p)){if(h=p&-p,h===l.callbackPriority)return h;switch(_!==null&&ur(_),Ur(p)){case 2:case 8:p=pa;break;case 32:p=sn;break;case 268435456:p=Qi;break;default:p=sn}return _=ax.bind(null,l),p=ls(p,_),l.callbackPriority=h,l.callbackNode=p,h}return _!==null&&_!==null&&ur(_),l.callbackPriority=2,l.callbackNode=null,2}function ax(l,h){if(Xi!==0&&Xi!==5)return l.callbackNode=null,l.callbackPriority=0,null;var p=l.callbackNode;if($u()&&l.callbackNode!==p)return null;var _=Ct;return _=pt(l,l===ii?_:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),_===0?null:(zv(l,_,h),nx(l,Ci()),l.callbackNode!=null&&l.callbackNode===p?ax.bind(null,l):null)}function ox(l,h){if($u())return null;zv(l,h,!0)}function R1(){U1(function(){(Xt&6)!==0?ls(tn,A1):rx()})}function G_(){if(Fa===0){var l=bl;l===0&&(l=$o,$o<<=1,($o&261888)===0&&($o=256)),Fa=l}return Fa}function lx(l){return l==null||typeof l=="symbol"||typeof l=="boolean"?null:typeof l=="function"?l:ou(""+l)}function cx(l,h){var p=h.ownerDocument.createElement("input");return p.name=h.name,p.value=h.value,l.id&&p.setAttribute("form",l.id),h.parentNode.insertBefore(p,h),l=new FormData(l),p.parentNode.removeChild(p),l}function M1(l,h,p,_,y){if(h==="submit"&&p&&p.stateNode===y){var S=lx((y[Os]||null).action),P=_.submitter;P&&(h=(h=P[Os]||null)?lx(h.formAction):P.getAttribute("formAction"),h!==null&&(S=h,P=null));var z=new uu("action","action",null,_,y);l.push({event:z,listeners:[{instance:null,listener:function(){if(_.defaultPrevented){if(Fa!==0){var ee=P?cx(y,P):new FormData(y);l_(p,{pending:!0,data:ee,method:y.method,action:S},null,ee)}}else typeof S=="function"&&(z.preventDefault(),ee=P?cx(y,P):new FormData(y),l_(p,{pending:!0,data:ee,method:y.method,action:S},S,ee))},currentTarget:y}]})}}for(var H_=0;H_<Ap.length;H_++){var W_=Ap[H_],C1=W_.toLowerCase(),I1=W_[0].toUpperCase()+W_.slice(1);kr(C1,"on"+I1)}kr(Vy,"onAnimationEnd"),kr(zy,"onAnimationIteration"),kr(Gy,"onAnimationStart"),kr("dblclick","onDoubleClick"),kr("focusin","onFocus"),kr("focusout","onBlur"),kr(XP,"onTransitionRun"),kr(jP,"onTransitionStart"),kr(YP,"onTransitionCancel"),kr(Hy,"onTransitionEnd"),rl("onMouseEnter",["mouseout","mouseover"]),rl("onMouseLeave",["mouseout","mouseover"]),rl("onPointerEnter",["pointerout","pointerover"]),rl("onPointerLeave",["pointerout","pointerover"]),co("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),co("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),co("onBeforeInput",["compositionend","keypress","textInput","paste"]),co("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),co("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),co("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var eh="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),P1=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(eh));function hx(l,h){h=(h&4)!==0;for(var p=0;p<l.length;p++){var _=l[p],y=_.event;_=_.listeners;e:{var S=void 0;if(h)for(var P=_.length-1;0<=P;P--){var z=_[P],ee=z.instance,ge=z.currentTarget;if(z=z.listener,ee!==S&&y.isPropagationStopped())break e;S=z,y.currentTarget=ge;try{S(y)}catch(Ee){pu(Ee)}y.currentTarget=null,S=ee}else for(P=0;P<_.length;P++){if(z=_[P],ee=z.instance,ge=z.currentTarget,z=z.listener,ee!==S&&y.isPropagationStopped())break e;S=z,y.currentTarget=ge;try{S(y)}catch(Ee){pu(Ee)}y.currentTarget=null,S=ee}}}}function Mt(l,h){var p=h[sp];p===void 0&&(p=h[sp]=new Set);var _=l+"__bubble";p.has(_)||(ux(h,l,2,!1),p.add(_))}function X_(l,h,p){var _=0;h&&(_|=4),ux(p,l,_,h)}var ed="_reactListening"+Math.random().toString(36).slice(2);function j_(l){if(!l[ed]){l[ed]=!0,ry.forEach(function(p){p!=="selectionchange"&&(P1.has(p)||X_(p,!1,l),X_(p,!0,l))});var h=l.nodeType===9?l:l.ownerDocument;h===null||h[ed]||(h[ed]=!0,X_("selectionchange",!1,h))}}function ux(l,h,p,_){switch(Vx(h)){case 2:var y=rD;break;case 8:y=nD;break;default:y=og}p=y.bind(null,h,p,l),y=void 0,!dp||h!=="touchstart"&&h!=="touchmove"&&h!=="wheel"||(y=!0),_?y!==void 0?l.addEventListener(h,p,{capture:!0,passive:y}):l.addEventListener(h,p,!0):y!==void 0?l.addEventListener(h,p,{passive:y}):l.addEventListener(h,p,!1)}function Y_(l,h,p,_,y){var S=_;if((h&1)===0&&(h&2)===0&&_!==null)e:for(;;){if(_===null)return;var P=_.tag;if(P===3||P===4){var z=_.stateNode.containerInfo;if(z===y)break;if(P===4)for(P=_.return;P!==null;){var ee=P.tag;if((ee===3||ee===4)&&P.stateNode.containerInfo===y)return;P=P.return}for(;z!==null;){if(P=tl(z),P===null)return;if(ee=P.tag,ee===5||ee===6||ee===26||ee===27){_=S=P;continue e}z=z.parentNode}}_=_.return}gy(function(){var ge=S,Ee=hp(p),Me=[];e:{var me=Wy.get(l);if(me!==void 0){var ye=uu,Je=l;switch(l){case"keypress":if(cu(p)===0)break e;case"keydown":case"keyup":ye=TP;break;case"focusin":Je="focus",ye=gp;break;case"focusout":Je="blur",ye=gp;break;case"beforeblur":case"afterblur":ye=gp;break;case"click":if(p.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ye=yy;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ye=uP;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ye=RP;break;case Vy:case zy:case Gy:ye=pP;break;case Hy:ye=CP;break;case"scroll":case"scrollend":ye=cP;break;case"wheel":ye=PP;break;case"copy":case"cut":case"paste":ye=gP;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ye=xy;break;case"toggle":case"beforetoggle":ye=OP}var ct=(h&4)!==0,ti=!ct&&(l==="scroll"||l==="scrollend"),ue=ct?me!==null?me+"Capture":null:me;ct=[];for(var ne=ge,_e;ne!==null;){var Re=ne;if(_e=Re.stateNode,Re=Re.tag,Re!==5&&Re!==26&&Re!==27||_e===null||ue===null||(Re=Sc(ne,ue),Re!=null&&ct.push(th(ne,Re,_e))),ti)break;ne=ne.return}0<ct.length&&(me=new ye(me,Je,null,p,Ee),Me.push({event:me,listeners:ct}))}}if((h&7)===0){e:{if(me=l==="mouseover"||l==="pointerover",ye=l==="mouseout"||l==="pointerout",me&&p!==cp&&(Je=p.relatedTarget||p.fromElement)&&(tl(Je)||Je[el]))break e;if((ye||me)&&(me=Ee.window===Ee?Ee:(me=Ee.ownerDocument)?me.defaultView||me.parentWindow:window,ye?(Je=p.relatedTarget||p.toElement,ye=ge,Je=Je?tl(Je):null,Je!==null&&(ti=r(Je),ct=Je.tag,Je!==ti||ct!==5&&ct!==27&&ct!==6)&&(Je=null)):(ye=null,Je=ge),ye!==Je)){if(ct=yy,Re="onMouseLeave",ue="onMouseEnter",ne="mouse",(l==="pointerout"||l==="pointerover")&&(ct=xy,Re="onPointerLeave",ue="onPointerEnter",ne="pointer"),ti=ye==null?me:xc(ye),_e=Je==null?me:xc(Je),me=new ct(Re,ne+"leave",ye,p,Ee),me.target=ti,me.relatedTarget=_e,Re=null,tl(Ee)===ge&&(ct=new ct(ue,ne+"enter",Je,p,Ee),ct.target=_e,ct.relatedTarget=ti,Re=ct),ti=Re,ye&&Je)t:{for(ct=D1,ue=ye,ne=Je,_e=0,Re=ue;Re;Re=ct(Re))_e++;Re=0;for(var nt=ne;nt;nt=ct(nt))Re++;for(;0<_e-Re;)ue=ct(ue),_e--;for(;0<Re-_e;)ne=ct(ne),Re--;for(;_e--;){if(ue===ne||ne!==null&&ue===ne.alternate){ct=ue;break t}ue=ct(ue),ne=ct(ne)}ct=null}else ct=null;ye!==null&&dx(Me,me,ye,ct,!1),Je!==null&&ti!==null&&dx(Me,ti,Je,ct,!0)}}e:{if(me=ge?xc(ge):window,ye=me.nodeName&&me.nodeName.toLowerCase(),ye==="select"||ye==="input"&&me.type==="file")var Vt=Iy;else if(My(me))if(Py)Vt=GP;else{Vt=VP;var st=kP}else ye=me.nodeName,!ye||ye.toLowerCase()!=="input"||me.type!=="checkbox"&&me.type!=="radio"?ge&&lp(ge.elementType)&&(Vt=Iy):Vt=zP;if(Vt&&(Vt=Vt(l,ge))){Cy(Me,Vt,p,Ee);break e}st&&st(l,me,ge),l==="focusout"&&ge&&me.type==="number"&&ge.memoizedProps.value!=null&&op(me,"number",me.value)}switch(st=ge?xc(ge):window,l){case"focusin":(My(st)||st.contentEditable==="true")&&(hl=st,Sp=ge,Pc=null);break;case"focusout":Pc=Sp=hl=null;break;case"mousedown":Tp=!0;break;case"contextmenu":case"mouseup":case"dragend":Tp=!1,Uy(Me,p,Ee);break;case"selectionchange":if(WP)break;case"keydown":case"keyup":Uy(Me,p,Ee)}var St;if(bp)e:{switch(l){case"compositionstart":var It="onCompositionStart";break e;case"compositionend":It="onCompositionEnd";break e;case"compositionupdate":It="onCompositionUpdate";break e}It=void 0}else cl?Ay(l,p)&&(It="onCompositionEnd"):l==="keydown"&&p.keyCode===229&&(It="onCompositionStart");It&&(Sy&&p.locale!=="ko"&&(cl||It!=="onCompositionStart"?It==="onCompositionEnd"&&cl&&(St=my()):(ba=Ee,fp="value"in ba?ba.value:ba.textContent,cl=!0)),st=td(ge,It),0<st.length&&(It=new vy(It,l,null,p,Ee),Me.push({event:It,listeners:st}),St?It.data=St:(St=Ry(p),St!==null&&(It.data=St)))),(St=FP?LP(l,p):NP(l,p))&&(It=td(ge,"onBeforeInput"),0<It.length&&(st=new vy("onBeforeInput","beforeinput",null,p,Ee),Me.push({event:st,listeners:It}),st.data=St)),M1(Me,l,ge,p,Ee)}hx(Me,h)})}function th(l,h,p){return{instance:l,listener:h,currentTarget:p}}function td(l,h){for(var p=h+"Capture",_=[];l!==null;){var y=l,S=y.stateNode;if(y=y.tag,y!==5&&y!==26&&y!==27||S===null||(y=Sc(l,p),y!=null&&_.unshift(th(l,y,S)),y=Sc(l,h),y!=null&&_.push(th(l,y,S))),l.tag===3)return _;l=l.return}return[]}function D1(l){if(l===null)return null;do l=l.return;while(l&&l.tag!==5&&l.tag!==27);return l||null}function dx(l,h,p,_,y){for(var S=h._reactName,P=[];p!==null&&p!==_;){var z=p,ee=z.alternate,ge=z.stateNode;if(z=z.tag,ee!==null&&ee===_)break;z!==5&&z!==26&&z!==27||ge===null||(ee=ge,y?(ge=Sc(p,S),ge!=null&&P.unshift(th(p,ge,ee))):y||(ge=Sc(p,S),ge!=null&&P.push(th(p,ge,ee)))),p=p.return}P.length!==0&&l.push({event:h,listeners:P})}var O1=/\r\n?/g,w1=/\u0000|\uFFFD/g;function fx(l){return(typeof l=="string"?l:""+l).replace(O1,` 50`).replace(w1,"")}function px(l,h){return h=fx(h),fx(l)===h}function ei(l,h,p,_,y,S){switch(p){case"children":typeof _=="string"?h==="body"||h==="textarea"&&_===""||al(l,_):(typeof _=="number"||typeof _=="bigint")&&h!=="body"&&al(l,""+_);break;case"className":nu(l,"class",_);break;case"tabIndex":nu(l,"tabindex",_);break;case"dir":case"role":case"viewBox":case"width":case"height":nu(l,p,_);break;case"style":py(l,_,S);break;case"data":if(h!=="object"){nu(l,"data",_);break}case"src":case"href":if(_===""&&(h!=="a"||p!=="href")){l.removeAttribute(p);break}if(_==null||typeof _=="function"||typeof _=="symbol"||typeof _=="boolean"){l.removeAttribute(p);break}_=ou(""+_),l.setAttribute(p,_);break;case"action":case"formAction":if(typeof _=="function"){l.setAttribute(p,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof S=="function"&&(p==="formAction"?(h!=="input"&&ei(l,h,"name",y.name,y,null),ei(l,h,"formEncType",y.formEncType,y,null),ei(l,h,"formMethod",y.formMethod,y,null),ei(l,h,"formTarget",y.formTarget,y,null)):(ei(l,h,"encType",y.encType,y,null),ei(l,h,"method",y.method,y,null),ei(l,h,"target",y.target,y,null)));if(_==null||typeof _=="symbol"||typeof _=="boolean"){l.removeAttribute(p);break}_=ou(""+_),l.setAttribute(p,_);break;case"onClick":_!=null&&(l.onclick=Cn);break;case"onScroll":_!=null&&Mt("scroll",l);break;case"onScrollEnd":_!=null&&Mt("scrollend",l);break;case"dangerouslySetInnerHTML":if(_!=null){if(typeof _!="object"||!("__html"in _))throw Error(i(61));if(p=_.__html,p!=null){if(y.children!=null)throw Error(i(60));l.innerHTML=p}}break;case"multiple":l.multiple=_&&typeof _!="function"&&typeof _!="symbol";break;case"muted":l.muted=_&&typeof _!="function"&&typeof _!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(_==null||typeof _=="function"||typeof _=="boolean"||typeof _=="symbol"){l.removeAttribute("xlink:href");break}p=ou(""+_),l.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",p);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":_!=null&&typeof _!="function"&&typeof _!="symbol"?l.setAttribute(p,""+_):l.removeAttribute(p);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInl
50ine":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":_&&typeof _!="function"&&typeof _!="symbol"?l.setAttribute(p,""):l.removeAttribute(p);break;case"capture":case"download":_===!0?l.setAttribute(p,""):_!==!1&&_!=null&&typeof _!="function"&&typeof _!="symbol"?l.setAttribute(p,_):l.removeAttribute(p);break;case"cols":case"rows":case"size":case"span":_!=null&&typeof _!="function"&&typeof _!="symbol"&&!isNaN(_)&&1<=_?l.setAttribute(p,_):l.removeAttribute(p);break;case"rowSpan":case"start":_==null||typeof _=="function"||typeof _=="symbol"||isNaN(_)?l.removeAttribute(p):l.setAttribute(p,_);break;case"popover":Mt("beforetoggle",l),Mt("toggle",l),ru(l,"popover",_);break;case"xlinkActuate":Mn(l,"http://www.w3.org/1999/xlink","xlink:actuate",_);break;case"xlinkArcrole":Mn(l,"http://www.w3.org/1999/xlink","xlink:arcrole",_);break;case"xlinkRole":Mn(l,"http://www.w3.org/1999/xlink","xlink:role",_);break;case"xlinkShow":Mn(l,"http://www.w3.org/1999/xlink","xlink:show",_);break;case"xlinkTitle":Mn(l,"http://www.w3.org/1999/xlink","xlink:title",_);break;case"xlinkType":Mn(l,"http://www.w3.org/1999/xlink","xlink:type",_);break;case"xmlBase":Mn(l,"http://www.w3.org/XML/1998/namespace","xml:base",_);break;case"xmlLang":Mn(l,"http://www.w3.org/XML/1998/namespace","xml:lang",_);break;case"xmlSpace":Mn(l,"http://www.w3.org/XML/1998/namespace","xml:space",_);break;case"is":ru(l,"is",_);break;case"innerText":case"textContent":break;default:(!(2<p.length)||p[0]!=="o"&&p[0]!=="O"||p[1]!=="n"&&p[1]!=="N")&&(p=oP.get(p)||p,ru(l,p,_))}}function K_(l,h,p,_,y,S){switch(p){case"style":py(l,_,S);break;case"dangerouslySetInnerHTML":if(_!=null){if(typeof _!="object"||!("__html"in _))throw Error(i(61));if(p=_.__html,p!=null){if(y.children!=null)throw Error(i(60));l.innerHTML=p}}break;case"children":typeof _=="string"?al(l,_):(typeof _=="number"||typeof _=="bigint")&&al(l,""+_);break;case"onScroll":_!=null&&Mt("scroll",l);break;case"onScrollEnd":_!=null&&Mt("scrollend",l);break;case"onClick":_!=null&&(l.onclick=Cn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ny.hasOwnProperty(p))e:{if(p[0]==="o"&&p[1]==="n"&&(y=p.endsWith("Capture"),h=p.slice(2,y?p.length-7:void 0),S=l[Os]||null,S=S!=null?S[p]:null,typeof S=="function"&&l.removeEventListener(h,S,y),typeof _=="function")){typeof S!="function"&&S!==null&&(p in l?l[p]=null:l.hasAttribute(p)&&l.removeAttribute(p)),l.addEventListener(h,_,y);break e}p in l?l[p]=_:_===!0?l.setAttribute(p,""):ru(l,p,_)}}}function ss(l,h,p){switch(h){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Mt("error",l),Mt("load",l);var _=!1,y=!1,S;for(S in p)if(p.hasOwnProperty(S)){var P=p[S];if(P!=null)switch(S){case"src":_=!0;break;case"srcSet":y=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,h));default:ei(l,h,S,P,p,null)}}y&&ei(l,h,"srcSet",p.srcSet,p,null),_&&ei(l,h,"src",p.src,p,null);return;case"input":Mt("invalid",l);var z=S=P=y=null,ee=null,ge=null;for(_ in p)if(p.hasOwnProperty(_)){var Ee=p[_];if(Ee!=null)switch(_){case"name":y=Ee;break;case"type":P=Ee;break;case"checked":ee=Ee;break;case"defaultChecked":ge=Ee;break;case"value":S=Ee;break;case"defaultValue":z=Ee;break;case"children":case"dangerouslySetInnerHTML":if(Ee!=null)throw Error(i(137,h));break;default:ei(l,h,_,Ee,p,null)}}hy(l,S,z,ee,ge,P,y,!1);return;case"select":Mt("invalid",l),_=P=S=null;for(y in p)if(p.hasOwnProperty(y)&&(z=p[y],z!=null))switch(y){case"value":S=z;break;case"defaultValue":P=z;break;case"multiple":_=z;default:ei(l,h,y,z,p,null)}h=S,p=P,l.multiple=!!_,h!=null?nl(l,!!_,h,!1):p!=null&&nl(l,!!_,p,!0);return;case"textarea":Mt("invalid",l),S=y=_=null;for(P in p)if(p.hasOwnProperty(P)&&(z=p[P],z!=null))switch(P){case"value":_=z;break;case"defaultValue":y=z;break;case"children":S=z;break;case"dangerouslySetInnerHTML":if(z!=null)throw Error(i(91));break;default:ei(l,h,P,z,p,null)}dy(l,_,y,S);return;case"option":for(ee in p)if(p.hasOwnProperty(ee)&&(_=p[ee],_!=null))switch(ee){case"selected":l.selected=_&&typeof _!="function"&&typeof _!="symbol";break;default:ei(l,h,ee,_,p,null)}return;case"dialog":Mt("beforetoggle",l),Mt("toggle",l),Mt("cancel",l),Mt("close",l);break;case"iframe":case"object":Mt("load",l);break;case"video":case"audio":for(_=0;_<eh.length;_++)Mt(eh[_],l);break;case"image":Mt("error",l),Mt("load",l);break;case"details":Mt("toggle",l);break;case"embed":case"source":case"link":Mt("error",l),Mt("load",l);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(ge in p)if(p.hasOwnProperty(ge)&&(_=p[ge],_!=null))switch(ge){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,h));default:ei(l,h,ge,_,p,null)}return;default:if(lp(h)){for(Ee in p)p.hasOwnProperty(Ee)&&(_=p[Ee],_!==void 0&&K_(l,h,Ee,_,p,void 0));return}}for(z in p)p.hasOwnProperty(z)&&(_=p[z],_!=null&&ei(l,h,z,_,p,null))}function F1(l,h,p,_){switch(h){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var y=null,S=null,P=null,z=null,ee=null,ge=null,Ee=null;for(ye in p){var Me=p[ye];
vendor: 7,845 bytes, line 50
50if(p.hasOwnProperty(ye)&&Me!=null)switch(ye){case"checked":break;case"value":break;case"defaultValue":ee=Me;default:_.hasOwnProperty(ye)||ei(l,h,ye,null,_,Me)}}for(var me in _){var ye=_[me];if(Me=p[me],_.hasOwnProperty(me)&&(ye!=null||Me!=null))switch(me){case"type":S=ye;break;case"name":y=ye;break;case"checked":ge=ye;break;case"defaultChecked":Ee=ye;break;case"value":P=ye;break;case"defaultValue":z=ye;break;case"children":case"dangerouslySetInnerHTML":if(ye!=null)throw Error(i(137,h));break;default:ye!==Me&&ei(l,h,me,ye,_,Me)}}ap(l,P,z,ee,ge,Ee,S,y);return;case"select":ye=P=z=me=null;for(S in p)if(ee=p[S],p.hasOwnProperty(S)&&ee!=null)switch(S){case"value":break;case"multiple":ye=ee;default:_.hasOwnProperty(S)||ei(l,h,S,null,_,ee)}for(y in _)if(S=_[y],ee=p[y],_.hasOwnProperty(y)&&(S!=null||ee!=null))switch(y){case"value":me=S;break;case"defaultValue":z=S;break;case"multiple":P=S;default:S!==ee&&ei(l,h,y,S,_,ee)}h=z,p=P,_=ye,me!=null?nl(l,!!p,me,!1):!!_!=!!p&&(h!=null?nl(l,!!p,h,!0):nl(l,!!p,p?[]:"",!1));return;case"textarea":ye=me=null;for(z in p)if(y=p[z],p.hasOwnProperty(z)&&y!=null&&!_.hasOwnProperty(z))switch(z){case"value":break;case"children":break;default:ei(l,h,z,null,_,y)}for(P in _)if(y=_[P],S=p[P],_.hasOwnProperty(P)&&(y!=null||S!=null))switch(P){case"value":me=y;break;case"defaultValue":ye=y;break;case"children":break;case"dangerouslySetInnerHTML":if(y!=null)throw Error(i(91));break;default:y!==S&&ei(l,h,P,y,_,S)}uy(l,me,ye);return;case"option":for(var Je in p)if(me=p[Je],p.hasOwnProperty(Je)&&me!=null&&!_.hasOwnProperty(Je))switch(Je){case"selected":l.selected=!1;break;default:ei(l,h,Je,null,_,me)}for(ee in _)if(me=_[ee],ye=p[ee],_.hasOwnProperty(ee)&&me!==ye&&(me!=null||ye!=null))switch(ee){case"selected":l.selected=me&&typeof me!="function"&&typeof me!="symbol";break;default:ei(l,h,ee,me,_,ye)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var ct in p)me=p[ct],p.hasOwnProperty(ct)&&me!=null&&!_.hasOwnProperty(ct)&&ei(l,h,ct,null,_,me);for(ge in _)if(me=_[ge],ye=p[ge],_.hasOwnProperty(ge)&&me!==ye&&(me!=null||ye!=null))switch(ge){case"children":case"dangerouslySetInnerHTML":if(me!=null)throw Error(i(137,h));break;default:ei(l,h,ge,me,_,ye)}return;default:if(lp(h)){for(var ti in p)me=p[ti],p.hasOwnProperty(ti)&&me!==void 0&&!_.hasOwnProperty(ti)&&K_(l,h,ti,void 0,_,me);for(Ee in _)me=_[Ee],ye=p[Ee],!_.hasOwnProperty(Ee)||me===ye||me===void 0&&ye===void 0||K_(l,h,Ee,me,_,ye);return}}for(var ue in p)me=p[ue],p.hasOwnProperty(ue)&&me!=null&&!_.hasOwnProperty(ue)&&ei(l,h,ue,null,_,me);for(Me in _)me=_[Me],ye=p[Me],!_.hasOwnProperty(Me)||me===ye||me==null&&ye==null||ei(l,h,Me,me,_,ye)}function _x(l){switch(l){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function L1(){if(typeof performance.getEntriesByType=="function"){for(var l=0,h=0,p=performance.getEntriesByType("resource"),_=0;_<p.length;_++){var y=p[_],S=y.transferSize,P=y.initiatorType,z=y.duration;if(S&&z&&_x(P)){for(P=0,z=y.responseEnd,_+=1;_<p.length;_++){var ee=p[_],ge=ee.startTime;if(ge>z)break;var Ee=ee.transferSize,Me=ee.initiatorType;Ee&&_x(Me)&&(ee=ee.responseEnd,P+=Ee*(ee<z?1:(z-ge)/(ee-ge)))}if(--_,h+=8*(S+P)/(y.duration/1e3),l++,10<l)break}}if(0<l)return h/l/1e6}return navigator.connection&&(l=navigator.connection.downlink,typeof l=="number")?l:5}var q_=null,Z_=null;function id(l){return l.nodeType===9?l:l.ownerDocument}function gx(l){switch(l){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function mx(l,h){if(l===0)switch(h){case"svg":return 1;case"math":return 2;default:return 0}return l===1&&h==="foreignObject"?0:l}function $_(l,h){return l==="textarea"||l==="noscript"||typeof h.children=="string"||typeof h.children=="number"||typeof h.children=="bigint"||typeof h.dangerouslySetInnerHTML=="object"&&h.dangerouslySetInnerHTML!==null&&h.dangerouslySetInnerHTML.__html!=null}var Q_=null;function N1(){var l=window.event;return l&&l.type==="popstate"?l===Q_?!1:(Q_=l,!0):(Q_=null,!1)}var bx=typeof setTimeout=="function"?setTimeout:void 0,B1=typeof clearTimeout=="function"?clearTimeout:void 0,yx=typeof Promise=="function"?Promise:void 0,U1=typeof queueMicrotask=="function"?queueMicrotask:typeof yx<"u"?function(l){return yx.resolve(null).then(l).catch(k1)}:bx;function k1(l){setTimeout(function(){throw l})}function La(l){return l==="head"}function vx(l,h){var p=h,_=0;do{var y=p.nextSibling;if(l.removeChild(p),y&&y.nodeType===8)if(p=y.data,p==="/$"||p==="/&"){if(_===0){l.removeChild(y),Bl(h);return}_--}else if(p==="$"||p==="$?"||p==="$~"||p==="$!"||p==="&")_++;else if(p==="html")ih(l.ownerDocument.documentElement);else if(p==="head"){p=l.ownerDocument.head,ih(p);for(var S=p.firstChild;S;){var P=S.nextSibling,z=S.nodeName;S[vc]||z==="SCRIPT"||z==="STYLE"||z==="LINK"&&S.rel.toLowerCase()==="stylesheet"||p.removeChild(S),S=P}}else p==="body"&&ih(l.ownerDocument.body);p=y}while(p);Bl(h)}function xx(l,h){var p=l;l=0;do{var _=p.nextSibling;if(p.nodeType===1?h?(p._stashedDisplay=p.style.display,p.style.display="none"):(p.style.display=p._stashedDisplay||"",p.getAttribute("style")===""&&p.removeAttribute("style")):p.nodeType===3&&(h?(p._stashedText=p.nodeValue,p.nodeValue=""):p.nodeValue=p._stashedText||""),_&&_.nodeType===8)if(p=_.data,p==="/$"){if(l===0)break;l--}else p!=="$"&&p!=="$?"&&p!=="$~"&&p!=="$!"||l++;p=_}while(p)}function J_(l){var h=l.firstChild;for(h&&h.nodeType===10&&(h=h.nextSibling);h;){var p=h;switch(h=h.nextSibling,p.nodeName){case"HTML":case"HEAD":case"BODY":J_(p),rp(p);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(p.rel.toLowerCase()==="stylesheet")continue}l.removeChild(p)}}function V1(l,h,p,_){for(;l.nodeType===1;){var y=p;if(l.nodeName.toLowerCase()!==h.toLowerCase()){if(!_&&(l.nodeName!=="INPUT"||l.type!=="hidden"))break}else if(_){if(!l[vc])switch(h){case"meta":if(!l.hasAttribute("itemprop"))break;return l;case"link":if(S=l.getAttribute("rel"),S==="stylesheet"&&l.hasAttribute("data-precedence"))break;if(S!==y.rel||l.getAttribute("href")!==(y.href==null||y.href===""?null:y.href)||l.getAttribute("crossorigin")!==(y.crossOrigin==null?null:y.crossOrigin)||l.getAttribute("title")!==(y.title==null?null:y.title))break;return l;case"style":if(l.hasAttribute("data-precedence"))break;return l;case"script":if(S=l.getAttribute("src"),(S!==(y.src==null?null:y.src)||l.getAttribute("type")!==(y.type==null?null:y.type)||l.getAttribute("crossorigin")!==(y.crossOrigin==null?null:y.crossOrigin))&&S&&l.hasAttribute("async")&&!l.hasAttribute("itemprop"))break;return l;default:return l}}else if(h==="input"&&l.type==="hidden"){var S=y.name==null?null:""+y.name;if(y.type==="hidden"&&l.getAttribute("name")===S)return l}else return l;if(l=xr(l.nextSibling),l===null)break}return null}function z1(l,h,p){if(h==="")return null;for(;l.nodeType!==3;)if((l.nodeType!==1||l.nodeName!=="INPUT"||l.type!=="hidden")&&!p||(l=xr(l.nextSibling),l===null))return null;return l}function Sx(l,h){for(;l.nodeType!==8;)if((l.nodeType!==1||l.nodeName!=="INPUT"||l.type!=="hidden")&&!h||(l=xr(l.nextSibling),l===null))return null;return l}function eg(l){return l.data==="$?"||l.data==="$~"}function tg(l){return l.data==="$!"||l.data==="$?"&&l.ownerDocument.readyState!=="loading"}function G1(l,h){var p=l.ownerDocument;if(l.data==="$~")l._reactRetry=h;else if(l.data!=="$?"||p.readyState!=="loading")h();else{var _=function(){h(),p.removeEventListener("DOMContentLoaded",_)};p.addEventListener("DOMContentLoaded",_),l._reactRetry=_}}function xr(l){for(;l!=null;l=l.nextSibling){var h=l.nodeType;if(h===1||h===3)break;if(h===8){if(h=l.data,h==="$"||h==="$!"||h==="$?"||h==="$~"||h==="&"||h==="F!"||h==="F")break;
vendor: 9,681 bytes, line 50
50if(h==="/$"||h==="/&")return null}}return l}var ig=null;function Tx(l){l=l.nextSibling;for(var h=0;l;){if(l.nodeType===8){var p=l.data;if(p==="/$"||p==="/&"){if(h===0)return xr(l.nextSibling);h--}else p!=="$"&&p!=="$!"&&p!=="$?"&&p!=="$~"&&p!=="&"||h++}l=l.nextSibling}return null}function Ex(l){l=l.previousSibling;for(var h=0;l;){if(l.nodeType===8){var p=l.data;if(p==="$"||p==="$!"||p==="$?"||p==="$~"||p==="&"){if(h===0)return l;h--}else p!=="/$"&&p!=="/&"||h++}l=l.previousSibling}return null}function Ax(l,h,p){switch(h=id(p),l){case"html":if(l=h.documentElement,!l)throw Error(i(452));return l;case"head":if(l=h.head,!l)throw Error(i(453));return l;case"body":if(l=h.body,!l)throw Error(i(454));return l;default:throw Error(i(451))}}function ih(l){for(var h=l.attributes;h.length;)l.removeAttributeNode(h[0]);rp(l)}var Sr=new Map,Rx=new Set;function sd(l){return typeof l.getRootNode=="function"?l.getRootNode():l.nodeType===9?l:l.ownerDocument}var Wn=K.d;K.d={f:H1,r:W1,D:X1,C:j1,L:Y1,m:K1,X:Z1,S:q1,M:$1};function H1(){var l=Wn.f(),h=Ku();return l||h}function W1(l){var h=il(l);h!==null&&h.tag===5&&h.type==="form"?H0(h):Wn.r(l)}var Fl=typeof document>"u"?null:document;function Mx(l,h,p){var _=Fl;if(_&&typeof h=="string"&&h){var y=pr(h);y='link[rel="'+l+'"][href="'+y+'"]',typeof p=="string"&&(y+='[crossorigin="'+p+'"]'),Rx.has(y)||(Rx.add(y),l={rel:l,crossOrigin:p,href:h},_.querySelector(y)===null&&(h=_.createElement("link"),ss(h,"link",l),qi(h),_.head.appendChild(h)))}}function X1(l){Wn.D(l),Mx("dns-prefetch",l,null)}function j1(l,h){Wn.C(l,h),Mx("preconnect",l,h)}function Y1(l,h,p){Wn.L(l,h,p);var _=Fl;if(_&&l&&h){var y='link[rel="preload"][as="'+pr(h)+'"]';h==="image"&&p&&p.imageSrcSet?(y+='[imagesrcset="'+pr(p.imageSrcSet)+'"]',typeof p.imageSizes=="string"&&(y+='[imagesizes="'+pr(p.imageSizes)+'"]')):y+='[href="'+pr(l)+'"]';var S=y;switch(h){case"style":S=Ll(l);break;case"script":S=Nl(l)}Sr.has(S)||(l=f({rel:"preload",href:h==="image"&&p&&p.imageSrcSet?void 0:l,as:h},p),Sr.set(S,l),_.querySelector(y)!==null||h==="style"&&_.querySelector(sh(S))||h==="script"&&_.querySelector(rh(S))||(h=_.createElement("link"),ss(h,"link",l),qi(h),_.head.appendChild(h)))}}function K1(l,h){Wn.m(l,h);var p=Fl;if(p&&l){var _=h&&typeof h.as=="string"?h.as:"script",y='link[rel="modulepreload"][as="'+pr(_)+'"][href="'+pr(l)+'"]',S=y;switch(_){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":S=Nl(l)}if(!Sr.has(S)&&(l=f({rel:"modulepreload",href:l},h),Sr.set(S,l),p.querySelector(y)===null)){switch(_){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(p.querySelector(rh(S)))return}_=p.createElement("link"),ss(_,"link",l),qi(_),p.head.appendChild(_)}}}function q1(l,h,p){Wn.S(l,h,p);var _=Fl;if(_&&l){var y=sl(_).hoistableStyles,S=Ll(l);h=h||"default";var P=y.get(S);if(!P){var z={loading:0,preload:null};if(P=_.querySelector(sh(S)))z.loading=5;else{l=f({rel:"stylesheet",href:l,"data-precedence":h},p),(p=Sr.get(S))&&sg(l,p);var ee=P=_.createElement("link");qi(ee),ss(ee,"link",l),ee._p=new Promise(function(ge,Ee){ee.onload=ge,ee.onerror=Ee}),ee.addEventListener("load",function(){z.loading|=1}),ee.addEventListener("error",function(){z.loading|=2}),z.loading|=4,rd(P,h,_)}P={type:"stylesheet",instance:P,count:1,state:z},y.set(S,P)}}}function Z1(l,h){Wn.X(l,h);var p=Fl;if(p&&l){var _=sl(p).hoistableScripts,y=Nl(l),S=_.get(y);S||(S=p.querySelector(rh(y)),S||(l=f({src:l,async:!0},h),(h=Sr.get(y))&&rg(l,h),S=p.createElement("script"),qi(S),ss(S,"link",l),p.head.appendChild(S)),S={type:"script",instance:S,count:1,state:null},_.set(y,S))}}function $1(l,h){Wn.M(l,h);var p=Fl;if(p&&l){var _=sl(p).hoistableScripts,y=Nl(l),S=_.get(y);S||(S=p.querySelector(rh(y)),S||(l=f({src:l,async:!0,type:"module"},h),(h=Sr.get(y))&&rg(l,h),S=p.createElement("script"),qi(S),ss(S,"link",l),p.head.appendChild(S)),S={type:"script",instance:S,count:1,state:null},_.set(y,S))}}function Cx(l,h,p,_){var y=(y=he.current)?sd(y):null;if(!y)throw Error(i(446));switch(l){case"meta":case"title":return null;case"style":return typeof p.precedence=="string"&&typeof p.href=="string"?(h=Ll(p.href),p=sl(y).hoistableStyles,_=p.get(h),_||(_={type:"style",instance:null,count:0,state:null},p.set(h,_)),_):{type:"void",instance:null,count:0,state:null};case"link":if(p.rel==="stylesheet"&&typeof p.href=="string"&&typeof p.precedence=="string"){l=Ll(p.href);var S=sl(y).hoistableStyles,P=S.get(l);if(P||(y=y.ownerDocument||y,P={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},S.set(l,P),(S=y.querySelector(sh(l)))&&!S._p&&(P.instance=S,P.state.loading=5),Sr.has(l)||(p={rel:"preload",as:"style",href:p.href,crossOrigin:p.crossOrigin,integrity:p.integrity,media:p.media,hrefLang:p.hrefLang,referrerPolicy:p.referrerPolicy},Sr.set(l,p),S||Q1(y,l,p,P.state))),h&&_===null)throw Error(i(528,""));return P}if(h&&_!==null)throw Error(i(529,""));return null;case"script":return h=p.async,p=p.src,typeof p=="string"&&h&&typeof h!="function"&&typeof h!="symbol"?(h=Nl(p),p=sl(y).hoistableScripts,_=p.get(h),_||(_={type:"script",instance:null,count:0,state:null},p.set(h,_)),_):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,l))}}function Ll(l){return'href="'+pr(l)+'"'}function sh(l){return'link[rel="stylesheet"]['+l+"]"}function Ix(l){return f({},l,{"data-precedence":l.precedence,precedence:null})}function Q1(l,h,p,_){l.querySelector('link[rel="preload"][as="style"]['+h+"]")?_.loading=1:(h=l.createElement("link"),_.preload=h,h.addEventListener("load",function(){return _.loading|=1}),h.addEventListener("error",function(){return _.loading|=2}),ss(h,"link",p),qi(h),l.head.appendChild(h))}function Nl(l){return'[src="'+pr(l)+'"]'}function rh(l){return"script[async]"+l}function Px(l,h,p){if(h.count++,h.instance===null)switch(h.type){case"style":var _=l.querySelector('style[data-href~="'+pr(p.href)+'"]');if(_)return h.instance=_,qi(_),_;var y=f({},p,{"data-href":p.href,"data-precedence":p.precedence,href:null,precedence:null});return _=(l.ownerDocument||l).createElement("style"),qi(_),ss(_,"style",y),rd(_,p.precedence,l),h.instance=_;case"stylesheet":y=Ll(p.href);var S=l.querySelector(sh(y));if(S)return h.state.loading|=4,h.instance=S,qi(S),S;_=Ix(p),(y=Sr.get(y))&&sg(_,y),S=(l.ownerDocument||l).createElement("link"),qi(S);var P=S;return P._p=new Promise(function(z,ee){P.onload=z,P.onerror=ee}),ss(S,"link",_),h.state.loading|=4,rd(S,p.precedence,l),h.instance=S;case"script":return S=Nl(p.src),(y=l.querySelector(rh(S)))?(h.instance=y,qi(y),y):(_=p,(y=Sr.get(S))&&(_=f({},p),rg(_,y)),l=l.ownerDocument||l,y=l.createElement("script"),qi(y),ss(y,"link",_),l.head.appendChild(y),h.instance=y);case"void":return null;default:throw Error(i(443,h.type))}else h.type==="stylesheet"&&(h.state.loading&4)===0&&(_=h.instance,h.state.loading|=4,rd(_,p.precedence,l));return h.instance}function rd(l,h,p){for(var _=p.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),y=_.length?_[_.length-1]:null,S=y,P=0;P<_.length;P++){var z=_[P];if(z.dataset.precedence===h)S=z;else if(S!==y)break}S?S.parentNode.insertBefore(l,S.nextSibling):(h=p.nodeType===9?p.head:p,h.insertBefore(l,h.firstChild))}function sg(l,h){l.crossOrigin==null&&(l.crossOrigin=h.crossOrigin),l.referrerPolicy==null&&(l.referrerPolicy=h.referrerPolicy),l.title==null&&(l.title=h.title)}function rg(l,h){l.crossOrigin==null&&(l.crossOrigin=h.crossOrigin),l.referrerPolicy==null&&(l.referrerPolicy=h.referrerPolicy),l.integrity==null&&(l.integrity=h.integrity)}var nd=null;function Dx(l,h,p){if(nd===null){var _=new Map,y=nd=new Map;y.set(p,_)}else y=nd,_=y.get(p),_||(_=new Map,y.set(p,_));if(_.has(l))return _;for(_.set(l,null),p=p.getElementsByTagName(l),y=0;y<p.length;y++){var S=p[y];if(!(S[vc]||S[Ji]||l==="link"&&S.getAttribute("rel")==="stylesheet")&&S.namespaceURI!=="http://www.w3.org/2000/svg"){var P=S.getAttribute(h)||"";P=l+P;var z=_.get(P);z?z.push(S):_.set(P,[S])}}return _}function Ox(l,h,p){l=l.ownerDocument||l,l.head.insertBefore(p,h==="title"?l.querySelector("head > title"):null)}function J1(l,h,p){if(p===1||h.itemProp!=null)return!1;switch(l){case"meta":case"title":return!0;case"style":if(typeof h.precedence!="string"||typeof h.href!="string"||h.href==="")break;return!0;case"link":if(typeof h.rel!="string"||typeof h.href!="string"||h.href===""||h.onLoad||h.onError)break;switch(h.rel){case"stylesheet":return l=h.disabled,typeof h.precedence=="string"&&l==null;default:return!0}case"script":if(h.async&&typeof h.async!="function"&&typeof h.async!="symbol"&&!h.onLoad&&!h.onError&&h.src&&typeof h.src=="string")return!0}return!1}function wx(l){return!(l.type==="stylesheet"&&(l.state.loading&3)===0)}function eD(l,h,p,_){if(p.type==="stylesheet"&&(typeof _.media!="string"||matchMedia(_.media).matches!==!1)&&(p.state.loading&4)===0){if(p.instance===null){var y=Ll(_.href),S=h.querySelector(sh(y));if(S){h=S._p,h!==null&&typeof h=="object"&&typeof h.then=="function"&&(l.count++,l=ad.bind(l),h.then(l,l)),p.state.loading|=4,p.instance=S,qi(S);return}S=h.ownerDocument||h,_=Ix(_),(y=Sr.get(y))&&sg(_,y),S=S.createElement("link"),qi(S);var P=S;P._p=new Promise(function(z,ee){P.onload=z,P.onerror=ee}),ss(S,"link",_),p.instance=S}l.stylesheets===null&&(l.stylesheets=new Map),l.stylesheets.set(p,h),(h=p.state.preload)&&(p.state.loading&3)===0&&(l.count++,p=ad.bind(l),h.addEventListener("load",p),h.addEventListener("error",p))}}var ng=0;function tD(l,h){return l.stylesheets&&l.count===0&&ld(l,l.stylesheets),0<l.count||0<l.imgCount?function(p){var _=setTimeout(function(){if(l.stylesheets&&ld(l,l.stylesheets),l.unsu
vendor: 4,281 bytes, line 50
50spend){var S=l.unsuspend;l.unsuspend=null,S()}},6e4+h);0<l.imgBytes&&ng===0&&(ng=62500*L1());var y=setTimeout(function(){if(l.waitingForImages=!1,l.count===0&&(l.stylesheets&&ld(l,l.stylesheets),l.unsuspend)){var S=l.unsuspend;l.unsuspend=null,S()}},(l.imgBytes>ng?50:800)+h);return l.unsuspend=p,function(){l.unsuspend=null,clearTimeout(_),clearTimeout(y)}}:null}function ad(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ld(this,this.stylesheets);else if(this.unsuspend){var l=this.unsuspend;this.unsuspend=null,l()}}}var od=null;function ld(l,h){l.stylesheets=null,l.unsuspend!==null&&(l.count++,od=new Map,h.forEach(iD,l),od=null,ad.call(l))}function iD(l,h){if(!(h.state.loading&4)){var p=od.get(l);if(p)var _=p.get(null);else{p=new Map,od.set(l,p);for(var y=l.querySelectorAll("link[data-precedence],style[data-precedence]"),S=0;S<y.length;S++){var P=y[S];(P.nodeName==="LINK"||P.getAttribute("media")!=="not all")&&(p.set(P.dataset.precedence,P),_=P)}_&&p.set(null,_)}y=h.instance,P=y.getAttribute("data-precedence"),S=p.get(P)||_,S===_&&p.set(null,y),p.set(P,y),this.count++,_=ad.bind(this),y.addEventListener("load",_),y.addEventListener("error",_),S?S.parentNode.insertBefore(y,S.nextSibling):(l=l.nodeType===9?l.head:l,l.insertBefore(y,l.firstChild)),h.state.loading|=4}}var nh={$$typeof:D,Provider:null,Consumer:null,_currentValue:X,_currentValue2:X,_threadCount:0};function sD(l,h,p,_,y,S,P,z,ee){this.tag=1,this.containerInfo=l,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=ga(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ga(0),this.hiddenUpdates=ga(null),this.identifierPrefix=_,this.onUncaughtError=y,this.onCaughtError=S,this.onRecoverableError=P,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=ee,this.incompleteTransitions=new Map}function Fx(l,h,p,_,y,S,P,z,ee,ge,Ee,Me){return l=new sD(l,h,p,P,ee,ge,Ee,Me,z),h=1,S===!0&&(h|=24),S=Ys(3,null,null,h),l.current=S,S.stateNode=l,h=Up(),h.refCount++,l.pooledCache=h,h.refCount++,S.memoizedState={element:_,isDehydrated:p,cache:h},Gp(S),l}function Lx(l){return l?(l=fl,l):fl}function Nx(l,h,p,_,y,S){y=Lx(y),_.context===null?_.context=y:_.pendingContext=y,_=Ea(h),_.payload={element:p},S=S===void 0?null:S,S!==null&&(_.callback=S),p=Aa(l,_,h),p!==null&&(Us(p,l,h),Bc(p,l,h))}function Bx(l,h){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var p=l.retryLane;l.retryLane=p!==0&&p<h?p:h}}function ag(l,h){Bx(l,h),(l=l.alternate)&&Bx(l,h)}function Ux(l){if(l.tag===13||l.tag===31){var h=po(l,67108864);h!==null&&Us(h,l,67108864),ag(l,67108864)}}function kx(l){if(l.tag===13||l.tag===31){var h=Qs();h=Jo(h);var p=po(l,h);p!==null&&Us(p,l,h),ag(l,h)}}var cd=!0;function rD(l,h,p,_){var y=G.T;G.T=null;var S=K.p;try{K.p=2,og(l,h,p,_)}finally{K.p=S,G.T=y}}function nD(l,h,p,_){var y=G.T;G.T=null;var S=K.p;try{K.p=8,og(l,h,p,_)}finally{K.p=S,G.T=y}}function og(l,h,p,_){if(cd){var y=lg(_);if(y===null)Y_(l,h,_,hd,p),zx(l,_);else if(oD(y,l,h,p,_))_.stopPropagation();else if(zx(l,_),h&4&&-1<aD.indexOf(l)){for(;y!==null;){var S=il(y);if(S!==null)switch(S.tag){case 3:if(S=S.stateNode,S.current.memoizedState.isDehydrated){var P=nn(S.pendingLanes);if(P!==0){var z=S;for(z.pendingLanes|=2,z.entangledLanes|=2;P;){var ee=1<<31-cs(P);z.entanglements[1]|=ee,P&=~ee}cn(S),(Xt&6)===0&&(ju=Ci()+500,Jc(0))}}break;case 31:case 13:z=po(S,2),z!==null&&Us(z,S,2),Ku(),ag(S,2)}if(S=lg(_),S===null&&Y_(l,h,_,hd,p),S===y)break;y=S}y!==null&&_.stopPropagation()}else Y_(l,h,_,null,p)}}function lg(l){return l=hp(l),cg(l)}var hd=null;function cg(l){if(hd=null,l=tl(l),l!==null){var h=r(l);if(h===null)l=null;else{var p=h.tag;if(p===13){if(l=a(h),l!==null)return l;l=null}else if(p===31){if(l=o(h),l!==null)return l;l=null}else if(p===3){if(h.stateNode.current.memoizedState.isDehydrated)return h.tag===3?h.stateNode.containerInfo:null;l=null}else h!==l&&(l=null)}}return hd=l,null}function Vx(l){switch(l){case"beforetoggle":case"cancel":case"click":case"close"
vendor: 3,243 bytes, line 50
50:case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(ao()){case tn:return 2;case pa:return 8;case sn:case _a:return 32;case Qi:return 268435456;default:return 32}default:return 32}}var hg=!1,Na=null,Ba=null,Ua=null,ah=new Map,oh=new Map,ka=[],aD="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function zx(l,h){switch(l){case"focusin":case"focusout":Na=null;break;case"dragenter":case"dragleave":Ba=null;break;case"mouseover":case"mouseout":Ua=null;break;case"pointerover":case"pointerout":ah.delete(h.pointerId);break;case"gotpointercapture":case"lostpointercapture":oh.delete(h.pointerId)}}function lh(l,h,p,_,y,S){return l===null||l.nativeEvent!==S?(l={blockedOn:h,domEventName:p,eventSystemFlags:_,nativeEvent:S,targetContainers:[y]},h!==null&&(h=il(h),h!==null&&Ux(h)),l):(l.eventSystemFlags|=_,h=l.targetContainers,y!==null&&h.indexOf(y)===-1&&h.push(y),l)}function oD(l,h,p,_,y){switch(h){case"focusin":return Na=lh(Na,l,h,p,_,y),!0;case"dragenter":return Ba=lh(Ba,l,h,p,_,y),!0;case"mouseover":return Ua=lh(Ua,l,h,p,_,y),!0;case"pointerover":var S=y.pointerId;return ah.set(S,lh(ah.get(S)||null,l,h,p,_,y)),!0;case"gotpointercapture":return S=y.pointerId,oh.set(S,lh(oh.get(S)||null,l,h,p,_,y)),!0}return!1}function Gx(l){var h=tl(l.target);if(h!==null){var p=r(h);if(p!==null){if(h=p.tag,h===13){if(h=a(p),h!==null){l.blockedOn=h,iy(l.priority,function(){kx(p)});return}}else if(h===31){if(h=o(p),h!==null){l.blockedOn=h,iy(l.priority,function(){kx(p)});return}}else if(h===3&&p.stateNode.current.memoizedState.isDehydrated){l.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}l.blockedOn=null}function ud(l){if(l.blockedOn!==null)return!1;for(var h=l.targetContainers;0<h.length;){var p=lg(l.nativeEvent);if(p===null){p=l.nativeEvent;var _=new p.constructor(p.type,p);cp=_,p.target.dispatchEvent(_),cp=null}else return h=il(p),h!==null&&Ux(h),l.blockedOn=p,!1;h.shift()}return!0}function Hx(l,h,p){ud(l)&&p.delete(h)}function lD(){hg=!1,Na!==null&&ud(Na)&&(Na=null),Ba!==null&&ud(Ba)&&(B
vendor: 5,237 bytes, line 50
50a=null),Ua!==null&&ud(Ua)&&(Ua=null),ah.forEach(Hx),oh.forEach(Hx)}function dd(l,h){l.blockedOn===h&&(l.blockedOn=null,hg||(hg=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,lD)))}var fd=null;function Wx(l){fd!==l&&(fd=l,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){fd===l&&(fd=null);for(var h=0;h<l.length;h+=3){var p=l[h],_=l[h+1],y=l[h+2];if(typeof _!="function"){if(cg(_||p)===null)continue;break}var S=il(p);S!==null&&(l.splice(h,3),h-=3,l_(S,{pending:!0,data:y,method:p.method,action:_},_,y))}}))}function Bl(l){function h(ee){return dd(ee,l)}Na!==null&&dd(Na,l),Ba!==null&&dd(Ba,l),Ua!==null&&dd(Ua,l),ah.forEach(h),oh.forEach(h);for(var p=0;p<ka.length;p++){var _=ka[p];_.blockedOn===l&&(_.blockedOn=null)}for(;0<ka.length&&(p=ka[0],p.blockedOn===null);)Gx(p),p.blockedOn===null&&ka.shift();if(p=(l.ownerDocument||l).$$reactFormReplay,p!=null)for(_=0;_<p.length;_+=3){var y=p[_],S=p[_+1],P=y[Os]||null;if(typeof S=="function")P||Wx(p);else if(P){var z=null;if(S&&S.hasAttribute("formAction")){if(y=S,P=S[Os]||null)z=P.formAction;else if(cg(y)!==null)continue}else z=P.action;typeof z=="function"?p[_+1]=z:(p.splice(_,3),_-=3),Wx(p)}}}function Xx(){function l(S){S.canIntercept&&S.info==="react-transition"&&S.intercept({handler:function(){return new Promise(function(P){return y=P})},focusReset:"manual",scroll:"manual"})}function h(){y!==null&&(y(),y=null),_||setTimeout(p,20)}function p(){if(!_&&!navigation.transition){var S=navigation.currentEntry;S&&S.url!=null&&navigation.navigate(S.url,{state:S.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var _=!1,y=null;return navigation.addEventListener("navigate",l),navigation.addEventListener("navigatesuccess",h),navigation.addEventListener("navigateerror",h),setTimeout(p,100),function(){_=!0,navigation.removeEventListener("navigate",l),navigation.removeEventListener("navigatesuccess",h),navigation.removeEventListener("navigateerror",h),y!==null&&(y(),y=null)}}}function ug(l){this._internalRoot=l}pd.prototype.render=ug.prototype.render=function(l){var h=this._internalRoot;if(h===null)throw Error(i(409));var p=h.current,_=Qs();Nx(p,_,l,h,null,null)},pd.prototype.unmount=ug.prototype.unmount=function(){var l=this._internalRoot;if(l!==null){this._internalRoot=null;var h=l.containerInfo;Nx(l.current,2,null,l,null,null),Ku(),h[el]=null}};function pd(l){this._internalRoot=l}pd.prototype.unstable_scheduleHydration=function(l){if(l){var h=ip();l={blockedOn:null,target:l,priority:h};for(var p=0;p<ka.length&&h!==0&&h<ka[p].priority;p++);ka.splice(p,0,l),p===0&&Gx(l)}};var jx=e.version;if(jx!=="19.2.1")throw Error(i(527,jx,"19.2.1"));K.findDOMNode=function(l){var h=l._reactInternals;if(h===void 0)throw typeof l.render=="function"?Error(i(188)):(l=Object.keys(l).join(","),Error(i(268,l)));return l=u(h),l=l!==null?d(l):null,l=l===null?null:l.stateNode,l};var cD={bundleType:0,version:"19.2.1",rendererPackageName:"react-dom",currentDispatcherRef:G,reconcilerVersion:"19.2.1"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var _d=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!_d.isDisabled&&_d.supportsFiber)try{Xs=_d.inject(cD),ms=_d}catch{}}return uh.createRoot=function(l,h){if(!s(l))throw Error(i(299));var p=!1,_="",y=J0,S=ev,P=tv;return h!=null&&(h.unstable_strictMode===!0&&(p=!0),h.identifierPrefix!==void 0&&(_=h.identifierPrefix),h.onUncaughtError!==void 0&&(y=h.onUncaughtError),h.onCaughtError!==void 0&&(S=h.onCaughtError),h.onRecoverableError!==void 0&&(P=h.onRecoverableError)),h=Fx(l,1,!1,null,null,p,_,null,y,S,P,Xx),l[el]=h.current,j_(l),new ug(h)},uh.hydrateRoot=function(l,h,p){if(!s(l))throw Error(i(299));var _=!1,y="",S=J0,P=ev,z=tv,ee=null;return p!=null&&(p.unstable_strictMode===!0&&(_=!0),p.identifierPrefix!==void 0&&(y=p.identifierPrefix),p.onUncaughtError!==void 0&&(S=p.onUncaughtError),p.onCaughtError!==void 0&&(P=p.onCaughtError),p.onRecoverableError!==void 0&&(z=p.onRecoverableError),p.formState!==void 0&&(ee=p.formState)),h=Fx(l,1,!0,h,p??null,_,y,ee,S,P,z,Xx),h.context=Lx(null),p=h.current,_=Qs(),_=Jo(_),y=Ea(_),y.callback=null,Aa(p,y,_),p=_,h.current.lanes=p,xi(h,p),cn(h),l[el]=h.current,j_(l),new pd(h)},uh.version="19.2.1",uh}var bS;function Mw(){if(bS)return bg.exports;bS=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),bg.exports=Rw(),bg.exports}var Cw=Mw(),Iw=(function(){function n(){this.keyToValue=new Map,this.valueToKey=new Map}return n.prototype.set=function(e,t){this.keyToValue.set(e,t),this.valueToKey.set(t,e)},n.prototype.getByKey=function(e){return this.keyToValue.get(e)},n.prototype.getByValue=function(e){return this.valueToKey.get(e)},n.prototype.clear=function(){this.keyToValue.clear(),this.valueToKey.clear()},n})(),aR=(function(){function n(e){this.generateIdentifier=e,this.kv=new Iw}return n.prototype.register=function(e,t){this.kv.getByValue(e)||(t||(t=this.generateIdentifier(e)),this.kv.set(t,e))},n.prototype.clear=function(){this.kv.clear()},n.prototype.getIdentifier=function(e){return this.kv.getByValue(e)},n.prototype.getValue=function(e){return this.kv.getByKey(e)},n}
50)(),Pw=(function(){var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,s){i.__proto__=s}||function(i,s){for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(i[r]=s[r])},n(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");n(e,t);function i(){this.constructor=e}e.prototype=t===null?Object.create(t):(i.prototype=t.prototype,new i)}})(),Dw=(function(n){Pw(e,n);function e(){var t=n.call(this,function(i){return i.name})||this;return t.classToAllowedProps=new Map,t}return e.prototype.register=function(t,i){typeof i=="object"?(i.allowProps&&this.classToAllowedProps.set(t,i.allowProps),n.prototype.register.call(this,t,i.identifier)):n.prototype.register.call(this,t,i)},e.prototype.getAllowedProps=function(t){return this.classToAllowedProps.get(t)},e})(aR),Ow=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),s,r=[],a;try{for(;(e===void 0||e-- >0)&&!(s=i.next()).done;)r.push(s.value)}catch(o){a={error:o}}finally{try{s&&!s.done&&(t=i.return)&&t.call(i)}finally{if(a)throw a.error}}return r};function ww(n){if("values"in Object)return Object.values(n);var e=[];for(var t in n)n.hasOwnProperty(t)&&e.push(n[t]);return e}function Fw(n,e){var t=ww(n);if("find"in t)return t.find(e);for(var i=t,s=0;s<i.length;s++){var r=i[s];if(e(r))return r}}function ec(n,e){Object.entries(n).forEach(function(t){var i=Ow(t,2),s=i[0],r=i[1];return e(r,s)})}function Ld(n,e){return n.indexOf(e)!==-1}function yS(n,e){for(var t=0;t<n.length;t++){var i=n[t];if(e(i))return i}}var Lw=(function(){function n(){this.transfomers={}}return n.prototype.register=function(e){this.transfomers[e.name]=e},n.prototype.findApplicable=function(e){return Fw(this.transfomers,function(t){return t.isApplicable(e)}
50)},n.prototype.findByName=function(e){return this.transfomers[e]},n})(),Nw=function(n){return Object.prototype.toString.call(n).slice(8,-1)},oR=function(n){return typeof n>"u"},Bw=function(n){return n===null},Rh=function(n){return typeof n!="object"||n===null||n===Object.prototype?!1:Object.getPrototypeOf(n)===null?!0:Object.getPrototypeOf(n)===Object.prototype},nm=function(n){return Rh(n)&&Object.keys(n).length===0},qa=function(n){return Array.isArray(n)},Uw=function(n){return typeof n=="string"},kw=function(n){return typeof n=="number"&&!isNaN(n)},Vw=function(n){return typeof n=="boolean"},zw=function(n){return n instanceof RegExp},Mh=function(n){return n instanceof Map},Ch=function(n){return n instanceof Set},lR=function(n){return Nw(n)==="Symbol"},Gw=function(n){return n instanceof Date&&!isNaN(n.valueOf())},Hw=function(n){return n instanceof Error},vS=function(n){return typeof n=="number"&&isNaN(n)},Ww=function(n){return Vw(n)||Bw(n)||oR(n)||kw(n)||Uw(n)||lR(n)},Xw=function(n){return typeof n=="bigint"},jw=function(n){return n===1/0||n===-1/0},Yw=function(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)},Kw=function(n){return n instanceof URL},cR=function(n){return n.replace(/\./g,"\\.")},Sg=function(n){return n.map(String).map(cR).join(".")},mh=function(n){for(var e=[],t="",i=0;i<n.length;i++){var s=n.charAt(i),r=s==="\\"&&n.charAt(i+1)===".";if(r){t+=".",i++;continue}var a=s===".";if(a){e.push(t),t="";continue}t+=s}var o=t;return e.push(o),e},am=function(){return am=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=e[s])}return n},am.apply(this,arguments)},om=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),s,r=[],a;try{for(;(e===void 0||e-- >0)&&!(s=i.next()).done;)r.push(s.value)}catch(o){a={error:o}}finally{try{s&&!s.done&&(t=i.return)&&t.call(i)}finally{if(a)throw a.error}}return r},lm=function(n,e){for(var t=0,i=e.length,s=n.length;t<i;t++,s++)n[s]=e[t];return n};function hn(n,e,t,i){return{isApplicable:n,annotation:e,transform:t,untransform:i}}var hR=[hn(oR,"undefined",function(){return null},function(){}),hn(Xw,"bigint",function(n){return n.toString()},function(n){return typeof BigInt<"u"?BigInt(n):(console.error("Please add a BigInt polyfill."),n)}),hn(Gw,"Date",function(n){return n.toISOString()},function(n){return new Date(n)}),hn(Hw,"Error",function(n,e){var t={name:n.name,message:n.message};return e.allowedErrorProps.forEach(function(i){t[i]=n[i]}),t},function(n,e){var t=new Error(n.message);return t.name=n.name,t.stack=n.stack,e.allowedErrorProps.forEach(function(i){t[i]=n[i]}),t}),hn(zw,"regexp",function(n){return""+n},function(n){var e=n.slice(1,n.lastIndexOf("/")),t=n.slice(n.lastIndexOf("/")+1);return new RegExp(e,t)}),hn(Ch,"set",function(n){return lm([],om(n.values()))},function(n){return new Set(n)}),hn(Mh,"map",function(n){return lm([],om(n.entries()))},function(n){return new Map(n)}),hn(function(n){return vS(n)||jw(n)},"number",function(n){return vS(n)?"NaN":n>0?"Infinity":"-Infinity"},Number),hn(function(n){return n===0&&1/n===-1/0},"number",function(){return"-0"},Number),hn(Kw,"URL",function(n){return n.toString()},function(n){return new URL(n)})];function Sf(n,e,t,i){return{isApplicable:n,annotation:e,transform:t,untransform:i}}var uR=Sf(function(n,e){if(lR(n)){var t=!!e.symbolRegistry.getIdentifier(n);return t}return!1},function(n,e){var t=e.symbolRegistry.getIdentifier(n);return["symbol",t]},function(n){return n.description},function(n,e,t){var i=t.symbolRegistry.getValue(e[1]);if(!i)throw new Error("Trying to deserialize unknown symbol");return i}),qw=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce(function(n,e){return n[e.name]=e,n},{}),dR=Sf(Yw,function(n){return["typed-array",n.constructor.name]},function(n){return lm([],om(n))},function(n,e){var t=qw[e[1]];if(!t)throw new Error("Trying to deserialize unknown typed array");return new t(n)});function fR(n,e){if(n?.constructor){var t=!!e.classRegistry.getIdentifier(n.constructor);return t}return!1}var pR=Sf(fR,function(n,e){var t=e.classRegistry.getIdentifier(n.constructor);return["class",t]},function(n,e){var t=e.classRegistry.getAllowedProps(n.constructor);if(!t)return am({},n);var i={};return t.forEach(function(s){i[s]=n[s]}),i},function(n,e,t){var i=t.classRegistry.getValue(e[1]);
50if(!i)throw new Error("Trying to deserialize unknown class - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564");return Object.assign(Object.create(i.prototype),n)}),_R=Sf(function(n,e){return!!e.customTransformerRegistry.findApplicable(n)},function(n,e){var t=e.customTransformerRegistry.findApplicable(n);return["custom",t.name]},function(n,e){var t=e.customTransformerRegistry.findApplicable(n);return t.serialize(n)},function(n,e,t){var i=t.customTransformerRegistry.findByName(e[1]);if(!i)throw new Error("Trying to deserialize unknown custom value");return i.deserialize(n)}),Zw=[pR,uR,_R,dR],xS=function(n,e){var t=yS(Zw,function(s){return s.isApplicable(n,e)});if(t)return{value:t.transform(n,e),type:t.annotation(n,e)};var i=yS(hR,function(s){return s.isApplicable(n,e)});if(i)return{value:i.transform(n,e),type:i.annotation}},gR={};hR.forEach(function(n){gR[n.annotation]=n});var $w=function(n,e,t){if(qa(e))switch(e[0]){case"symbol":return uR.untransform(n,e,t);case"class":return pR.untransform(n,e,t);case"custom":return _R.untransform(n,e,t);case"typed-array":return dR.untransform(n,e,t);default:throw new Error("Unknown transformation: "+e)}else{var i=gR[e];if(!i)throw new Error("Unknown transformation: "+e);return i.untransform(n,t)}},Wl=function(n,e){for(var t=n.keys();e>0;)t.next(),e--;return t.next().value};function mR(n){if(Ld(n,"__proto__"))throw new Error("__proto__ is not allowed as a property");if(Ld(n,"prototype"))throw new Error("prototype is not allowed as a property");if(Ld(n,"constructor"))throw new Error("constructor is not allowed as a property")}var Qw=function(n,e){mR(e);for(var t=0;t<e.length;t++){var i=e[t];if(Ch(n))n=Wl(n,+i);else if(Mh(n)){var s=+i,r=+e[++t]==0?"key":"value",a=Wl(n,s);switch(r){case"key":n=a;break;case"value":n=n.get(a);break}}else n=n[i]}return n},cm=function(n,e,t){if(mR(e),e.length===0)return t(n);for(var i=n,s=0;s<e.length-1;s++){var r=e[s];if(qa(i)){var a=+r;i=i[a]}else if(Rh(i))i=i[r];else if(Ch(i)){var o=+r;i=Wl(i,o)}else if(Mh(i)){var c=s===e.length-2;if(c)break;var o=+r,u=+e[++s]==0?"key":"value",d=Wl(i,o);switch(u){case"key":i=d;break;case"value":i=i.get(d);break}}}var f=e[e.length-1];if(qa(i)?i[+f]=t(i[+f]):Rh(i)&&(i[f]=t(i[f])),Ch(i)){var g=Wl(i,+f),m=t(g);g!==m&&(i.delete(g),i.add(m))}if(Mh(i)){var o=+e[e.length-2],b=Wl(i,o),u=+f==0?"key":"value";switch(u){case"key":{var x=t(b);i.set(x,i.get(b)),x!==b&&i.delete(b);break}case"value":{i.set(b,t(i.get(b)));break}}}return n},Qn=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),s,r=[],a;try{for(;(e===void 0||e-- >0)&&!(s=i.next()).done;)r.push(s.value)}catch(o){a={error:o}}finally{try{s&&!s.done&&(t=i.return)&&t.call(i)}finally{if(a)throw a.error}}return r},Wa=function(n,e){for(var t=0,i=e.length,s=n.length;t<i;t++,s++)n[s]=e[t];return n};function hm(n,e,t){if(t===void 0&&(t=[]),!!n){if(!qa(n)){ec(n,function(a,o){return hm(a,e,Wa(Wa([],Qn(t)),Qn(mh(o))))});return}var i=Qn(n,2),s=i[0],r=i[1];r&&ec(r,function(a,o){hm(a,e,Wa(Wa([],Qn(t)),Qn(mh(o))))}),e(s,t)}}function Jw(n,e,t){return hm(e,function(i,s){n=cm(n,s,function(r){return $w(r,i,t)})}),n}function eF(n,e){function t(a,o){var c=Qw(n,mh(o));a.map(mh).forEach(function(u){n=cm(n,u,function(){return c})})}if(qa(e)){var i=Qn(e,2),s=i[0],r=i[1];s.forEach(function(a){n=cm(n,mh(a),function(){return n})}),r&&ec(r,t)}else ec(e,t);return n}var tF=function(n,e){return Rh(n)||qa(n)||Mh(n)||Ch(n)||fR(n,e)};function iF(n,e,t){var i=t.get(n);i?i.push(e):t.set(n,[e])}function sF(n,e){var t={},i=void 0;return n.forEach(function(s){if(!(s.length<=1)){e||(s=s.map(function(c){return c.map(String)}).sort(function(c,u){return c.length-u.length}));var r=Qn(s),a=r[0],o=r.slice(1);a.length===0?i=o.map(Sg):t[Sg(a)]=o.map(Sg)}}),i?nm(t)?[i]:[i,t]:nm(t)?void 0:t}var bR=function(n,e,t,i,s,r,a){var o;s===void 0&&(s=[]),r===void 0&&(r=[]),a===void 0&&(a=new Map);var c=Ww(n);if(!c){iF(n,s,e);var u=a.get(n);if(u)return i?{transformedValue:null}:u}if(!tF(n,t)){var d=xS(n,t),f=d?{transformedValue:d.value,annotations:[d.type]}:{transformedValue:n};return c||a.set(n,f),f}if(Ld(r,n))return{transformedValue:null};var g=xS(n,t),m=(o=g?.value)!==null&&o!==void 0?o:n,b=qa(m)?[]:{},x={};ec(m,function(E,A){var D=bR(E,e,t,i,Wa(Wa([],Qn(s)),[A]),Wa(Wa([],Qn(r)),[n]),a);b[A]=D.transformedValue,qa(D.annotations)?x[A]=D.annotations:Rh(D.annotations)&&ec(D.annotations,function(I,R){x[cR(A)+"."+R]=I})});var v=nm(x)?{transformedValue:b,annotations:g?[g.type]:void 0}:{transformedValue:b,annotations:g?[g.type,x]:x};return c||a.set(n,v),v};function yR(n){return Object.prototype.toString.call(n).slice(8,-1)}function SS(n){return yR(n)==="Array"}function rF(n){if(yR(n)!=="Object")return!1;const e=Object.getPrototypeOf(n);return!!e&&e.constructor===Object&&e===Object.prototype}function nF(n,e,t,i,s){const r={}.propertyIsEnumerable.call(i,e)?"enumerable":"nonenumerable";r==="enumerable"&&(n[e]=t),s&&r==="nonenumerable"&&Object.defineProperty(n,e,{value:t,enumerable:!1,writable:!0,configurable:!0})}function um(n,e={}){if(SS(n))return n.map(s=>um(s,e));if(!rF(n))return n;const t=Object.getOwnPropertyNames(n),i=Object.getOwnPropertySymbols(n);return[...t,...i].reduce((s,r)=>{if(SS(e.props)&&!e.props.includes(r))return s;const a=n[r],o=um(a,e);return nF(s,r,o,n,e.nonenumerable),s},{})}var wo=function(){return wo=Object.assign||function(n){for(var e,t=1,i=arguments.length;t<i;t++){e=arguments[t];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=e[s])}return n},wo.apply(this,arguments)},aF=function(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var i=t.call(n),s,r=[],a;try{for(;(e===void 0||e-- >0)&&!(s=i.next()).done;)r.push(s.value)}catch(o){a={error:o}}finally{try{s&&!s.done&&(t=i.return)&&t.call(i)}finally{if(a)throw a.error}}return r},oF=function(n,e){for(var t=0,i=e.length,s=n.length;t<i;t++,s++)n[s]=e[t];return n},ha=(function(){function n(e){var t=e===void 0?{}:e,i=t.dedupe,s=i===void 0?!1:i;this.classRegistry=new Dw,this.symbolRegistry=new aR(function(r){var a;return(a=r.description)!==null&&a!==void 0?a:""}),this.customTransformerRegistry=new Lw,this.allowedErrorProps=[],this.dedupe=s}
50return n.prototype.serialize=function(e){var t=new Map,i=bR(e,t,this,this.dedupe),s={json:i.transformedValue};i.annotations&&(s.meta=wo(wo({},s.meta),{values:i.annotations}));var r=sF(t,this.dedupe);return r&&(s.meta=wo(wo({},s.meta),{referentialEqualities:r})),s},n.prototype.deserialize=function(e){var t=e.json,i=e.meta,s=um(t);return i?.values&&(s=Jw(s,i.values,this)),i?.referentialEqualities&&(s=eF(s,i.referentialEqualities)),s},n.prototype.stringify=function(e){return JSON.stringify(this.serialize(e))},n.prototype.parse=function(e){return this.deserialize(JSON.parse(e))},n.prototype.registerClass=function(e,t){this.classRegistry.register(e,t)},n.prototype.registerSymbol=function(e,t){this.symbolRegistry.register(e,t)},n.prototype.registerCustom=function(e,t){this.customTransformerRegistry.register(wo({name:t},e))},n.prototype.allowErrorProps=function(){for(var e,t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];(e=this.allowedErrorProps).push.apply(e,oF([],aF(t)))},n.defaultInstance=new n,n.serialize=n.defaultInstance.serialize.bind(n.defaultInstance),n.deserialize=n.defaultInstance.deserialize.bind(n.defaultInstance),n.stringify=n.defaultInstance.stringify.bind(n.defaultInstance),n.parse=n.defaultInstance.parse.bind(n.defaultInstance),n.registerClass=n.defaultInstance.registerClass.bind(n.defaultInstance),n.registerSymbol=n.defaultInstance.registerSymbol.bind(n.defaultInstance),n.registerCustom=n.defaultInstance.registerCustom.bind(n.defaultInstance),n.allowErrorProps=n.defaultInstance.allowErrorProps.bind(n.defaultInstance),n})();ha.serialize;ha.deserialize;ha.stringify;ha.parse;ha.registerClass;ha.registerCustom;ha.registerSymbol;ha.allowErrorProps;var lF=(n,e,t,i,s,r,a,o)=>{let c=document.documentElement,u=["light","dark"];function d(m){(Array.isArray(n)?n:[n]).forEach(b=>{let x=b==="class",v=x&&r?s.map(E=>r[E]||E):s;x?(c.classList.remove(...v),c.classList.add(r&&r[m]?r[m]:m)):c.setAttribute(b,m)}),f(m)}function f(m){o&&u.includes(m)&&(c.style.colorScheme=m)}function g(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(i)d(i);else try{let m=localStorage.getItem(e)||t,b=a&&m==="system"?g():m;d(b)}catch{}},cF=Y.createContext(void 0),hF={setTheme:n=>{},themes:[]},uF=()=>{var n;return(n=Y.useContext(cF))!=null?n:hF};Y.memo(({forcedTheme:n,storageKey:e,attribute:t,enableSystem:i,enableColorScheme:s,defaultTheme:r,value:a,themes:o,nonce:c,scriptProps:u})=>{let d=JSON.stringify([t,e,r,n,o,a,i,s]).slice(1,-1);return Y.createElement("script",{...u,suppressHydrationWarning:!0,nonce:typeof window>"u"?c:"",dangerouslySetInnerHTML:{__html:`(${lF.toString()})(${d})`}})});var rb=nR();const dF=bA(rb);function fF(n){if(typeof document>"u")return;let e=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css",e.appendChild(t),t.styleSheet?t.styleSheet.cssText=n:t.appendChild(document.createTextNode(n))}const pF=n=>{switch(n){case"success":return mF;case"info":return yF;case"warning":return bF;case"error":return vF;default:return null}},_F=Array(12).fill(0),gF=({visible:n,className:e})=>Ue.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":n},Ue.createElement("div",{className:"sonner-spinner"},_F.map((t,i)=>Ue.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${i}`})))),mF=Ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Ue.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),bF=Ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},Ue.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),yF=Ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Ue.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),vF=Ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},Ue.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),xF=Ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},Ue.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),Ue.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),SF=()=>{const[n,e]=Ue.useState(document.hidden);return Ue.useEffect(()=>{const t=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",t),()=>window.removeEventListener("visibilitychange",t)},[]),n};let dm=1,TF=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{const t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>
vendor: 3,615 bytes, line 50
50{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;const{message:i,...s}=e,r=typeof e?.id=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:dm++,a=this.toasts.find(c=>c.id===r),o=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),a?this.toasts=this.toasts.map(c=>c.id===r?(this.publish({...c,...e,id:r,title:i}),{...c,...e,id:r,dismissible:o,title:i}):c):this.addToast({title:i,...s,dismissible:o,id:r}),r},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(t=>{this.subscribers.forEach(i=>i({id:t.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let i;t.loading!==void 0&&(i=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));const s=Promise.resolve(e instanceof Function?e():e);let r=i!==void 0,a;const o=s.then(async u=>{if(a=["resolve",u],Ue.isValidElement(u))r=!1,this.create({id:i,type:"default",message:u});else if(AF(u)&&!u.ok){r=!1;const f=typeof t.error=="function"?await t.error(`HTTP error! status: ${u.status}`):t.error,g=typeof t.description=="function"?await t.description(`HTTP error! status: ${u.status}`):t.description,b=typeof f=="object"&&!Ue.isValidElement(f)?f:{message:f};this.create({id:i,type:"error",description:g,...b})}else if(u instanceof Error){r=!1;const f=typeof t.error=="function"?await t.error(u):t.error,g=typeof t.description=="function"?await t.description(u):t.description,b=typeof f=="object"&&!Ue.isValidElement(f)?f:{message:f};this.create({id:i,type:"error",description:g,...b})}else if(t.success!==void 0){r=!1;const f=typeof t.success=="function"?await t.success(u):t.success,g=typeof t.description=="function"?await t.description(u):t.description,b=typeof f=="object"&&!Ue.isValidElement(f)?f:{message:f};this.create({id:i,type:"success",description:g,...b})}}).catch(async u=>{if(a=["reject",u],t.error!==void 0){r=!1;const d=typeof t.error=="function"?await t.error(u):t.error,f=typeof t.description=="function"?await t.description(u):t.description,m=typeof d=="object"&&!Ue.isValidElement(d)?d:{message:d};this.create({id:i,type:"error",description:f,...m})}}).finally(()=>{r&&(this.dismiss(i),i=void 0),t.finally==null||t.finally.call(t)}),c=()=>new Promise((u,d)=>o.then(()=>a[0]==="reject"?d(a[1]):u(a[1])).catch(d));return typeof i!="string"&&typeof i!="number"?{unwrap:c}:Object.assign(i,{unwrap:c})},this.custom=(e,t)=>{const i=t?.id||dm++;return this.create({jsx:e(i),id:i,...t}),i},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}};const Vs=new TF,EF=(n,e)=>{const t=e?.id||dm++;return Vs.addToast({title:n,...e,id:t}),t},AF=n=>n&&typeof n=="object"&&"ok"in n&&typeof n.ok=="boolean"&&"status"in n&&typeof n.status=="number",RF=EF,MF=()=>Vs.toasts,CF=()=>Vs.getActiveToasts();Object.assign(RF,{success:Vs.success,info:Vs.info,warning:Vs.warning,error:Vs.error,custom:Vs.custom,message:Vs.message,promise:Vs.promise,dismiss:Vs.dismiss,loading:Vs.loading},{getHistory:MF,getToasts:CF});fF
vendor: 14,873 bytes, line 50
50("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function
vendor: 1,672 bytes, line 50
50vd(n){return n.label!==void 0}const IF=3,PF="24px",DF="16px",TS=4e3,OF=356,wF=14,FF=45,LF=200;function un(...n){return n.filter(Boolean).join(" ")}function NF(n){const[e,t]=n.split("-"),i=[];return e&&i.push(e),t&&i.push(t),i}const BF=n=>{var e,t,i,s,r,a,o,c,u;const{invert:d,toast:f,unstyled:g,interacting:m,setHeights:b,visibleToasts:x,heights:v,index:E,toasts:A,expanded:D,removeToast:I,defaultRichColors:R,closeButton:C,style:M,cancelButtonStyle:F,actionButtonStyle:U,className:k="",descriptionClassName:q="",duration:Q,position:ie,gap:$,expandByDefault:ce,classNames:G,icons:K,closeButtonAriaLabel:X="Close toast"}=n,[J,se]=Ue.useState(null),[w,L]=Ue.useState(null),[V,j]=Ue.useState(!1),[ae,he]=Ue.useState(!1),[be,Le]=Ue.useState(!1),[Xe,it]=Ue.useState(!1),[ut,Oe]=Ue.useState(!1),[Qe,Be]=Ue.useState(0),[Ot,Wt]=Ue.useState(0),vi=Ue.useRef(f.duration||Q||TS),Wi=Ue.useRef(null),Fi=Ue.useRef(null),ls=E===0,ur=E+1<=x,Mi=f.type,dr=f.dismissible!==!1,Ci=f.className||"",ao=f.descriptionClassName||"",tn=Ue.useMemo(()=>v.findIndex(pt=>pt.toastId===f.id)||0,[v,f.id]),pa=Ue.useMemo(()=>{var pt;return(pt=f.closeButton)!=null?pt:C},[f.closeButton,C]),sn=Ue.useMemo(()=>f.duration||Q||TS,[f.duration,Q]),_a=Ue.useRef(0),Qi=Ue.useRef(0),Rn=Ue.useRef(0),Li=Ue.useRef(null),[Xs,ms]=ie.split("-"),Br=Ue.useMemo(()=>v.reduce((pt,pi,Ki)=>Ki>=tn?pt:pt+pi.height,0),[v,tn]),cs=SF(),tp=f.invert||d,yc=Mi==="loading";Qi.current=Ue.useMemo(()=>tn*$+Br,[tn,Br]),Ue.useEffect(()=>{vi.current=sn},[sn]),Ue.useEffect(()=>{j(!0)},[]),Ue.useEffect(()=>{const pt=Fi.current;if(pt){const pi=pt.getBoundingClientRect().height;return Wt(pi),b(Ki=>[{toastId:f.id,height:pi,position:f.position}
vendor: 21,023 bytes, line 50
50,...Ki]),()=>b(Ki=>Ki.filter(hs=>hs.toastId!==f.id))}},[b,f.id]),Ue.useLayoutEffect(()=>{if(!V)return;const pt=Fi.current,pi=pt.style.height;pt.style.height="auto";const Ki=pt.getBoundingClientRect().height;pt.style.height=pi,Wt(Ki),b(hs=>hs.find(xi=>xi.toastId===f.id)?hs.map(xi=>xi.toastId===f.id?{...xi,height:Ki}:xi):[{toastId:f.id,height:Ki,position:f.position},...hs])},[V,f.title,f.description,b,f.id,f.jsx,f.action,f.cancel]);const rn=Ue.useCallback(()=>{he(!0),Be(Qi.current),b(pt=>pt.filter(pi=>pi.toastId!==f.id)),setTimeout(()=>{I(f)},LF)},[f,I,b,Qi]);Ue.useEffect(()=>{if(f.promise&&Mi==="loading"||f.duration===1/0||f.type==="loading")return;let pt;return D||m||cs?(()=>{if(Rn.current<_a.current){const hs=new Date().getTime()-_a.current;vi.current=vi.current-hs}Rn.current=new Date().getTime()})():(()=>{vi.current!==1/0&&(_a.current=new Date().getTime(),pt=setTimeout(()=>{f.onAutoClose==null||f.onAutoClose.call(f,f),rn()},vi.current))})(),()=>clearTimeout(pt)},[D,m,f,Mi,cs,rn]),Ue.useEffect(()=>{f.delete&&(rn(),f.onDismiss==null||f.onDismiss.call(f,f))},[rn,f.delete]);function $o(){var pt;if(K?.loading){var pi;return Ue.createElement("div",{className:un(G?.loader,f==null||(pi=f.classNames)==null?void 0:pi.loader,"sonner-loader"),"data-visible":Mi==="loading"},K.loading)}return Ue.createElement(gF,{className:un(G?.loader,f==null||(pt=f.classNames)==null?void 0:pt.loader),visible:Mi==="loading"})}const Qo=f.icon||K?.[Mi]||pF(Mi);var oo,nn;return Ue.createElement("li",{tabIndex:0,ref:Fi,className:un(k,Ci,G?.toast,f==null||(e=f.classNames)==null?void 0:e.toast,G?.default,G?.[Mi],f==null||(t=f.classNames)==null?void 0:t[Mi]),"data-sonner-toast":"","data-rich-colors":(oo=f.richColors)!=null?oo:R,"data-styled":!(f.jsx||f.unstyled||g),"data-mounted":V,"data-promise":!!f.promise,"data-swiped":ut,"data-removed":ae,"data-visible":ur,"data-y-position":Xs,"data-x-position":ms,"data-index":E,"data-front":ls,"data-swiping":be,"data-dismissible":dr,"data-type":Mi,"data-invert":tp,"data-swipe-out":Xe,"data-swipe-direction":w,"data-expanded":!!(D||ce&&V),"data-testid":f.testId,style:{"--index":E,"--toasts-before":E,"--z-index":A.length-E,"--offset":`${ae?Qe:Qi.current}px`,"--initial-height":ce?"auto":`${Ot}px`,...M,...f.style},onDragEnd:()=>{Le(!1),se(null),Li.current=null},onPointerDown:pt=>{pt.button!==2&&(yc||!dr||(Wi.current=new Date,Be(Qi.current),pt.target.setPointerCapture(pt.pointerId),pt.target.tagName!=="BUTTON"&&(Le(!0),Li.current={x:pt.clientX,y:pt.clientY})))},onPointerUp:()=>{var pt,pi,Ki;if(Xe||!dr)return;Li.current=null;const hs=Number(((pt=Fi.current)==null?void 0:pt.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ga=Number(((pi=Fi.current)==null?void 0:pi.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),xi=new Date().getTime()-((Ki=Wi.current)==null?void 0:Ki.getTime()),Is=J==="x"?hs:ga,lo=Math.abs(Is)/xi;if(Math.abs(Is)>=FF||lo>.11){Be(Qi.current),f.onDismiss==null||f.onDismiss.call(f,f),L(J==="x"?hs>0?"right":"left":ga>0?"down":"up"),rn(),it(!0);return}else{var Ps,Ds;(Ps=Fi.current)==null||Ps.style.setProperty("--swipe-amount-x","0px"),(Ds=Fi.current)==null||Ds.style.setProperty("--swipe-amount-y","0px")}Oe(!1),Le(!1),se(null)},onPointerMove:pt=>{var pi,Ki,hs;if(!Li.current||!dr||((pi=window.getSelection())==null?void 0:pi.toString().length)>0)return;const xi=pt.clientY-Li.current.y,Is=pt.clientX-Li.current.x;var lo;const Ps=(lo=n.swipeDirections)!=null?lo:NF(ie);!J&&(Math.abs(Is)>1||Math.abs(xi)>1)&&se(Math.abs(Is)>Math.abs(xi)?"x":"y");let Ds={x:0,y:0};const Jo=Ur=>1/(1.5+Math.abs(Ur)/20);if(J==="y"){if(Ps.includes("top")||Ps.includes("bottom"))if(Ps.includes("top")&&xi<0||Ps.includes("bottom")&&xi>0)Ds.y=xi;else{const Ur=xi*Jo(xi);Ds.y=Math.abs(Ur)<Math.abs(xi)?Ur:xi}}else if(J==="x"&&(Ps.includes("left")||Ps.includes("right")))if(Ps.includes("left")&&Is<0||Ps.includes("right")&&Is>0)Ds.x=Is;else{const Ur=Is*Jo(Is);Ds.x=Math.abs(Ur)<Math.abs(Is)?Ur:Is}(Math.abs(Ds.x)>0||Math.abs(Ds.y)>0)&&Oe(!0),(Ki=Fi.current)==null||Ki.style.setProperty("--swipe-amount-x",`${Ds.x}px`),(hs=Fi.current)==null||hs.style.setProperty("--swipe-amount-y",`${Ds.y}px`)}},pa&&!f.jsx&&Mi!=="loading"?Ue.createElement("button",{"aria-label":X,"data-disabled":yc,"data-close-button":!0,onClick:yc||!dr?()=>{}:()=>{rn(),f.onDismiss==null||f.onDismiss.call(f,f)},className:un(G?.closeButton,f==null||(i=f.classNames)==null?void 0:i.closeButton)},(nn=K?.close)!=null?nn:xF):null,(Mi||f.icon||f.promise)&&f.icon!==null&&(K?.[Mi]!==null||f.icon)?Ue.createElement("div",{"data-icon":"",className:un(G?.icon,f==null||(s=f.classNames)==null?void 0:s.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||$o():null,f.type!=="loading"?Qo:null):null,Ue.createElement("div",{"data-content":"",className:un(G?.content,f==null||(r=f.classNames)==null?void 0:r.content)},Ue.createElement("div",{"data-title":"",className:un(G?.title,f==null||(a=f.classNames)==null?void 0:a.title)},f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title),f.description?Ue.createElement("div",{"data-description":"",className:un(q,ao,G?.description,f==null||(o=f.classNames)==null?void 0:o.description)},typeof f.description=="function"?f.description():f.description):null),Ue.isValidElement(f.cancel)?f.cancel:f.cancel&&vd(f.cancel)?Ue.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||F,onClick:pt=>{vd(f.cancel)&&dr&&(f.cancel.onClick==null||f.cancel.onClick.call(f.cancel,pt),rn())},className:un(G?.cancelButton,f==null||(c=f.classNames)==null?void 0:c.cancelButton)},f.cancel.label):null,Ue.isValidElement(f.action)?f.action:f.action&&vd(f.action)?Ue.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||U,onClick:pt=>{vd(f.action)&&(f.action.onClick==null||f.action.onClick.call(f.action,pt),!pt.defaultPrevented&&rn())},className:un(G?.actionButton,f==null||(u=f.classNames)==null?void 0:u.actionButton)},f.action.label):null)};function ES(){if(typeof window>"u"||typeof document>"u")return"ltr";const n=document.documentElement.getAttribute("dir");return n==="auto"||!n?window.getComputedStyle(document.documentElement).direction:n}function UF(n,e){const t={};return[n,e].forEach((i,s)=>{const r=s===1,a=r?"--mobile-offset":"--offset",o=r?DF:PF;function c(u){["top","right","bottom","left"].forEach(d=>{t[`${a}-${d}`]=typeof u=="number"?`${u}px`:u})}typeof i=="number"||typeof i=="string"?c(i):typeof i=="object"?["top","right","bottom","left"].forEach(u=>{i[u]===void 0?t[`${a}-${u}`]=o:t[`${a}-${u}`]=typeof i[u]=="number"?`${i[u]}px`:i[u]}):c(o)}),t}const kF=Ue.forwardRef(function(e,t){const{id:i,invert:s,position:r="bottom-right",hotkey:a=["altKey","KeyT"],expand:o,closeButton:c,className:u,offset:d,mobileOffset:f,theme:g="light",richColors:m,duration:b,style:x,visibleToasts:v=IF,toastOptions:E,dir:A=ES(),gap:D=wF,icons:I,containerAriaLabel:R="Notifications"}=e,[C,M]=Ue.useState([]),F=Ue.useMemo(()=>i?C.filter(V=>V.toasterId===i):C.filter(V=>!V.toasterId),[C,i]),U=Ue.useMemo(()=>Array.from(new Set([r].concat(F.filter(V=>V.position).map(V=>V.position)))),[F,r]),[k,q]=Ue.useState([]),[Q,ie]=Ue.useState(!1),[$,ce]=Ue.useState(!1),[G,K]=Ue.useState(g!=="system"?g:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),X=Ue.useRef(null),J=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),se=Ue.useRef(null),w=Ue.useRef(!1),L=Ue.useCallback(V=>{M(j=>{var ae;return(ae=j.find(he=>he.id===V.id))!=null&&ae.delete||Vs.dismiss(V.id),j.filter(({id:he})=>he!==V.id)})},[]);return Ue.useEffect(()=>Vs.subscribe(V=>{if(V.dismiss){requestAnimationFrame(()=>{M(j=>j.map(ae=>ae.id===V.id?{...ae,delete:!0}:ae))});return}setTimeout(()=>{dF.flushSync(()=>{M(j=>{const ae=j.findIndex(he=>he.id===V.id);return ae!==-1?[...j.slice(0,ae),{...j[ae],...V},...j.slice(ae+1)]:[V,...j]})})})}),[C]),Ue.useEffect(()=>{if(g!=="system"){K(g);return}if(g==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?K("dark"):K("light")),typeof window>"u")return;const V=window.matchMedia("(prefers-color-scheme: dark)");try{V.addEventListener("change",({matches:j})=>{K(j?"dark":"light")})}catch{V.addListener(({matches:ae})=>{try{K(ae?"dark":"light")}catch(he){console.error(he)}})}},[g]),Ue.useEffect(()=>{C.length<=1&&ie(!1)},[C]),Ue.useEffect(()=>{const V=j=>{var ae;if(a.every(Le=>j[Le]||j.code===Le)){var be;ie(!0),(be=X.current)==null||be.focus()}j.code==="Escape"&&(document.activeElement===X.current||(ae=X.current)!=null&&ae.contains(document.activeElement))&&ie(!1)};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[a]),Ue.useEffect(()=>{if(X.current)return()=>{se.current&&(se.current.focus({preventScroll:!0}),se.current=null,w.current=!1)}},[X.current]),Ue.createElement("section",{ref:t,"aria-label":`${R} ${J}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},U.map((V,j)=>{var ae;const[he,be]=V.split("-");return F.length?Ue.createElement("ol",{key:V,dir:A==="auto"?ES():A,tabIndex:-1,ref:X,className:u,"data-sonner-toaster":!0,"data-sonner-theme":G,"data-y-position":he,"data-x-position":be,style:{"--front-toast-height":`${((ae=k[0])==null?void 0:ae.height)||0}px`,"--width":`${OF}px`,"--gap":`${D}px`,...x,...UF(d,f)},onBlur:Le=>{w.current&&!Le.currentTarget.contains(Le.relatedTarget)&&(w.current=!1,se.current&&(se.current.focus({preventScroll:!0}),se.current=null))},onFocus:Le=>{Le.target instanceof HTMLElement&&Le.target.dataset.dismissible==="false"||w.current||(w.current=!0,se.current=Le.relatedTarget)},onMouseEnter:()=>ie(!0),onMouseMove:()=>ie(!0),onMouseLeave:()=>{$||ie(!1)},onDragEnd:()=>ie(!1),onPointerDown:Le=>{Le.target instanceof HTMLElement&&Le.target.dataset.dismissible==="false"||ce(!0)},onPointerUp:()=>ce(!1)},F.filter(Le=>!Le.position&&j===0||Le.position===V).map((Le,Xe)=>{var it,ut;return Ue.createElement(BF,{key:Le.id,icons:I,index:Xe,toast:Le,defaultRichColors:m,duration:(it=E?.duration)!=null?it:b,className:E?.className,descriptionClassName:E?.descriptionClassName,invert:s,visibleToasts:v,closeButton:(ut=E?.closeButton)!=null?ut:c,interacting:$,position:V,style:E?.style,unstyled:E?.unstyled,classNames:E?.classNames,cancelButtonStyle:E?.cancelButtonStyle,actionButtonStyle:E?.actionButtonStyle,closeButtonAriaLabel:E?.closeButtonAriaLabel,removeToast:L,toasts:F.filter(Oe=>Oe.position==Le.position),heights:k.filter(Oe=>Oe.position==Le.position),setHeights:q,expandByDefault:o,gap:D,expanded:Q,swipeDirections:e.swipeDirections})})):null}))}),VF=({...n})=>{const{theme:e="system"}=uF();return B.jsx(kF,{"data-loc":"client/src/components/ui/sonner.tsx:8",theme:e,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...n})};function Ts(n,e,{checkForDefaultPrevented:t=!0}={}){return function(s){if(n?.(s),t===!1||!s.defaultPrevented)return e?.(s)}}function AS(n,e){if(typeof n=="function")return n(e);n!=null&&(n.current=e)}function vR(...n){return e=>{let t=!1;const i=n.map(s=>{const r=AS(s,e);return!t&&typeof r=="function"&&(t=!0),r});if(t)return()=>{for(let s=0;s<i.length;s++){const r=i[s];typeof r=="function"?r():AS(n[s],null)}}}}function Ms(...n){return Y.useCallback(vR(...n),n)}function Tf(n,e=[]){let t=[];function i(r,a){const o=Y.createContext(a),c=t.length;t=[...t,a];const u=f=>{const{scope:g,children:m,...b}=f,x=g?.[n]?.[c]||o,v=Y.useMemo(()=>b,Object.values(b));return B.jsx(x.Provider,{value:v,children:m})};u.displayName=r+"Provider";function d(f,g){const m=g?.[n]?.[c]||o,b=Y.useContext(m);if(b)return b;if(a!==void 0)return a;throw new Error(`\`${f}\` must be used within \`${r}\``)}return[u,d]}const s=()=>{const r=t.map(a=>Y.createContext(a));return function(o){const c=o?.[n]||r;return Y.useMemo(()=>({[`__scope${n}`]:{...o,[n]:c}}),[o,c])}};return s.scopeName=n,[i,zF(s,...e)]}function zF(...n){const e=n[0];if(n.length===1)return e;const t=()=>{const i=n.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(r){const a=i.reduce((o,{useScope:c,scopeName:u})=>{const f=c(r)[`__scope${u}`];return{...o,...f}},{});return Y.useMemo(()=>({[`__scope${e.scopeName}`]:a}),[a])}};return t.scopeName=e.scopeName,t}function Wd(n){const e=GF(n),t=Y.forwardRef((i,s)=>{const{children:r,...a}=i,o=Y.Children.toArray(r),c=o.find(WF);if(c){const u=c.props.children,d=o.map(f=>f===c?Y.Children.count(u)>1?Y.Children.only(null):Y.isValidElement(u)?u.props.children:null:f);return B.jsx(e,{...a,ref:s,children:Y.isValidElement(u)?Y.cloneElement(u,void 0,d):null})}return B.jsx(e,{...a,ref:s,children:r})});return t.displayName=`${n}.Slot`,t}var xR=Wd("Slot");function GF(n){const e=Y.forwardRef((t,i)=>{const{children:s,...r}=t;if(Y.isValidElement(s)){const a=jF(s),o=XF(r,s.props);return s.type!==Y.Fragment&&(o.ref=i?vR(i,a):a),Y.cloneElement(s,o)}return Y.Children.count(s)>1?Y.Children.only(null):null});return e.displayName=`${n}.SlotClone`,e}var SR=Symbol("radix.slottable");function HF(n){const e=({children:t})=>B.jsx(B.Fragment,{children:t});return e.displayName=`${n}.Slottable`,e.__radixId=SR,e}function WF(n){return Y.isValidElement(n)&&typeof n.type=="function"&&"__radixId"in n.type&&n.type.__radixId===SR}function XF(n,e){const t={...e};for(const i in e){const s=n[i],r=e[i];/^on[A-Z]/.test(i)?s&&r?t[i]=(...o)=>{const c=r(...o);return s(...o),c}:s&&(t[i]=s):i==="style"?t[i]={...s,...r}:i==="className"&&(t[i]=[s,r].filter(Boolean).join(" "))}return{...n,...t}}function jF(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var YF=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Fr=YF.reduce((n,e)=>{const t=Wd(`Primitive.${e}`),i=Y.forwardRef((s,r)=>{const{asChild:a,...o}=s,c=a?t:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),B.jsx(c,{...o,ref:r})});return i.displayName=`Primitive.${e}`,{...n,[e]:i}},{});function KF(n,e){n&&rb.flushSync(()=>n.dispatchEvent(e))}function Ef(n){const e=Y.useRef(n);return Y.useEffect(()=>{e.current=n}),Y.useMemo(()=>(...t)=>e.current?.(...t),[])}function qF(n,e=globalThis?.document){const t=Ef(n);Y.useEffect(()=>{const i=s=>{s.key==="Escape"&&t(s)};return e.addEventListener("keydown",i,{capture:!0}),()=>e.removeEventListener("keydown",i,{capture:!0})},[t,e])}var ZF="DismissableLayer",fm="dismissableLayer.update",$F="dismissableLayer.pointerDownOutside",QF="dismissableLayer.focusOutside",RS,TR=Y.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ER=Y.forwardRef((n,e)=>{const{disableOutsidePointerEvents:t=!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:r,onInteractOutside:a,onDismiss:o,...c}=n,u=Y.useContext(TR),[d,f]=Y.useState(null),g=d?.ownerDocument??globalThis?.document,[,m]=Y.useState({}),b=Ms(e,M=>f(M)),x=Array.from(u.layers),[v]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),E=x.indexOf(v),A=d?x.indexOf(d):-1,D=u.layersWithOutsidePointerEventsDisabled.size>0,I=A>=E,R=tL(M=>{const F=M.target,U=[...u.branches].some(k=>k.contains(F));!I||U||(s?.(M),a?.(M),M.defaultPrevented||o?.())},g),C=iL(M=>{const F=M.target;[...u.branches].some(k=>k.contains(F))||(r?.(M),a?.(M),M.defaultPrevented||o?.())},g);return qF(M=>{A===u.layers.size-1&&(i?.(M),!M.defaultPrevented&&o&&(M.preventDefault(),o()))},g),Y.useEffect(()=>{if(d)return t&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(RS=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),MS(),()=>{t&&u.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=RS)}},[d,g,t,u]),Y.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),MS())},[d,u]),Y.useEffect(()=>{const M=()=>m({});return document.addEventListener(fm,M),()=>document.removeEventListener(fm,M)},[]),B.jsx(Fr.div,{...c,ref:b,style:{pointerEvents:D?I?"auto":"none":void 0,...n.style},onFocusCapture:Ts(n.onFocusCapture,C.onFocusCapture),onBlurCapture:Ts(n.onBlurCapture,C.onBlurCapture),onPointerDownCapture:Ts(n.onPointerDownCapture,R.onPointerDownCapture)})});ER.displayName=ZF;var JF="DismissableLayerBranch",eL=Y.forwardRef((n,e)=>{const t=Y.useContext(TR),i=Y.useRef(null),s=Ms(e,i);return Y.useEffect(()=>{const r=i.current;if(r)return t.branches.add(r),()=>{t.branches.delete(r)}},[t.branches]),B.jsx(Fr.div,{...n,ref:s})});eL.displayName=JF;function tL(n,e=globalThis?.document){const t=Ef(n),i=Y.useRef(!1),s=Y.useRef(()=>{});return Y.useEffect(()=>{const r=o=>{if(o.target&&!i.current){let c=function(){AR($F,t,u,{discrete:!0})};const u={originalEvent:o};o.pointerType==="touch"?(e.removeEventListener("click",s.current),s.current=c,e.addEventListener("click",s.current,{once:!0})):c()}else e.removeEventListener("click",s.current);i.current=!1},a=window.setTimeout(()=>{e.addEventListener("pointerdown",r)},0);return()=>{window.clearTimeout(a),e.removeEventListener("pointerdown",r),e.removeEventListener("click",s.current)}},[e,t]),{onPointerDownCapture:()=>i.current=!0}}function iL(n,e=globalThis?.document){const t=Ef(n),i=Y.useRef(!1);return Y.useEffect(()=>{const s=r=>{r.target&&!i.current&&AR(QF,t,{originalEvent:r},{discrete:!1})};return e.addEventListener("focusin",s),()=>e.removeEventListener("focusin",s)},[e,t]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}function MS(){const n=new CustomEvent(fm);document.dispatchEvent(n)}function AR(n,e,t,{discrete:i}){const s=t.originalEvent.target,r=new CustomEvent(n,{bubbles:!1,cancelable:!0,detail:t});e&&s.addEventListener(n,e,{once:!0}),i?KF(s,r):s.dispatchEvent(r)}var tc=globalThis?.document?Y.useLayoutEffect:()=>{};const sL=["top","right","bottom","left"],Za=Math.min,tr=Math.max,Xd=Math.round,xd=Math.floor,vn=n=>({x:n,y:n}),rL={left:"right",right:"left",bottom:"top",top:"bottom"},nL={start:"end",end:"start"};function pm(n,e,t){return tr(n,Za(e,t))}function aa(n,e){return typeof n=="function"?n(e):n}function oa(n){return n.split("-")[0]}function hc(n){return n.split("-")[1]}function nb(n){return n==="x"?"y":"x"}function ab(n){return n==="y"?"height":"width"}const aL=new Set(["top","bottom"]);function bn(n){return aL.has(oa(n))?"y":"x"}function ob(n){return nb(bn(n))}function oL(n,e,t){t===void 0&&(t=!1);const i=hc(n),s=ob(n),r=ab(s);let a=s==="x"?i===(t?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(a=jd(a)),[a,jd(a)]}function lL(n){const e=jd(n);return[_m(n),e,_m(e)]}function _m(n){return n.replace(/start|end/g,e=>nL[e])}const CS=["left","right"],IS=["right","left"],cL=["top","bottom"],hL=["bottom","top"];function uL(n,e,t){switch(n){case"top":case"bottom":return t?e?IS:CS:e?CS:IS;case"left":case"right":return e?cL:hL;default:return[]}}function dL(n,e,t,i){const s=hc(n);let r=uL(oa(n),t==="start",i);return s&&(r=r.map(a=>a+"-"+s),e&&(r=r.concat(r.map(_m)))),r}function jd(n){return n.replace(/left|right|bottom|top/g,e=>rL[e])}function fL(n){return{top:0,right:0,bottom:0,left:0,...n}}function RR(n){return typeof n!="number"?fL(n):{top:n,right:n,bottom:n,left:n}}function Yd(n){const{x:e,y:t,width:i,height:s}=n;return{width:i,height:s,top:t,left:e,right:e+i,bottom:t+s,x:e,y:t}}function PS(n,e,t){let{reference:i,floating:s}=n;const r=bn(e),a=ob(e),o=ab(a),c=oa(e),u=r==="y",d=i.x+i.width/2-s.width/2,f=i.y+i.height/2-s.height/2,g=i[o]/2-s[o]/2;let m;switch(c){case"top":m={x:d,y:i.y-s.height};break;case"bottom":m={x:d,y:i.y+i.height};break;case"right":m={x:i.x+i.width,y:f};break;case"left":m={x:i.x-s.width,y:f};break;default:m={x:i.x,y:i.y}}switch(hc(e)){case"start":m[a]-=g*(t&&u?-1:1);break;case"end":m[a]+=g*(t&&u?-1:1);break}return m}const pL=async(n,e,t)=>{const{placement:i="bottom",strategy:s="absolute",middleware:r=[],platform:a}=t,o=r.filter(Boolean),c=await(a.isRTL==null?void 0:a.isRTL(e));let u=await a.getElementRects({reference:n,floating:e,strategy:s}),{x:d,y:f}=PS(u,i,c),g=i,m={},b=0;for(let x=0;x<o.length;x++){const{name:v,fn:E}=o[x],{x:A,y:D,data:I,reset:R}=await E({x:d,y:f,initialPlacement:i,placement:g,strategy:s,middlewareData:m,rects:u,platform:a,elements:{reference:n,floating:e}});d=A??d,f=D??f,m={...m,[v]:{...m[v],...I}},R&&b<=50&&(b++,typeof R=="object"&&(R.placement&&(g=R.placement),R.rects&&(u=R.rects===!0?await a.getElementRects({reference:n,floating:e,strategy:s}):R.rects),{x:d,y:f}=PS(u,g,c)),x=-1)}return{x:d,y:f,placement:g,strategy:s,middlewareData:m}};async function Ih(n,e){var t;e===void 0&&(e={});const{x:i,y:s,platform:r,rects:a,elements:o,strategy:c}=n,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:g=!1,padding:m=0}=aa(e,n),b=RR(m),v=o[g?f==="floating"?"reference":"floating":f],E=Yd(await r.getClippingRect
vendor: 13,063 bytes, line 50
50({element:(t=await(r.isElement==null?void 0:r.isElement(v)))==null||t?v:v.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(o.floating)),boundary:u,rootBoundary:d,strategy:c})),A=f==="floating"?{x:i,y:s,width:a.floating.width,height:a.floating.height}:a.reference,D=await(r.getOffsetParent==null?void 0:r.getOffsetParent(o.floating)),I=await(r.isElement==null?void 0:r.isElement(D))?await(r.getScale==null?void 0:r.getScale(D))||{x:1,y:1}:{x:1,y:1},R=Yd(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:A,offsetParent:D,strategy:c}):A);return{top:(E.top-R.top+b.top)/I.y,bottom:(R.bottom-E.bottom+b.bottom)/I.y,left:(E.left-R.left+b.left)/I.x,right:(R.right-E.right+b.right)/I.x}}const _L=n=>({name:"arrow",options:n,async fn(e){const{x:t,y:i,placement:s,rects:r,platform:a,elements:o,middlewareData:c}=e,{element:u,padding:d=0}=aa(n,e)||{};if(u==null)return{};const f=RR(d),g={x:t,y:i},m=ob(s),b=ab(m),x=await a.getDimensions(u),v=m==="y",E=v?"top":"left",A=v?"bottom":"right",D=v?"clientHeight":"clientWidth",I=r.reference[b]+r.reference[m]-g[m]-r.floating[b],R=g[m]-r.reference[m],C=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let M=C?C[D]:0;(!M||!await(a.isElement==null?void 0:a.isElement(C)))&&(M=o.floating[D]||r.floating[b]);const F=I/2-R/2,U=M/2-x[b]/2-1,k=Za(f[E],U),q=Za(f[A],U),Q=k,ie=M-x[b]-q,$=M/2-x[b]/2+F,ce=pm(Q,$,ie),G=!c.arrow&&hc(s)!=null&&$!==ce&&r.reference[b]/2-($<Q?k:q)-x[b]/2<0,K=G?$<Q?$-Q:$-ie:0;return{[m]:g[m]+K,data:{[m]:ce,centerOffset:$-ce-K,...G&&{alignmentOffset:K}},reset:G}}}),gL=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,i;const{placement:s,middlewareData:r,rects:a,initialPlacement:o,platform:c,elements:u}=e,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:g,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:x=!0,...v}=aa(n,e);if((t=r.arrow)!=null&&t.alignmentOffset)return{};const E=oa(s),A=bn(o),D=oa(o)===o,I=await(c.isRTL==null?void 0:c.isRTL(u.floating)),R=g||(D||!x?[jd(o)]:lL(o)),C=b!=="none";!g&&C&&R.push(...dL(o,x,b,I));const M=[o,...R],F=await Ih(e,v),U=[];let k=((i=r.flip)==null?void 0:i.overflows)||[];if(d&&U.push(F[E]),f){const $=oL(s,a,I);U.push(F[$[0]],F[$[1]])}if(k=[...k,{placement:s,overflows:U}],!U.every($=>$<=0)){var q,Q;const $=(((q=r.flip)==null?void 0:q.index)||0)+1,ce=M[$];if(ce&&(!(f==="alignment"?A!==bn(ce):!1)||k.every(X=>bn(X.placement)===A?X.overflows[0]>0:!0)))return{data:{index:$,overflows:k},reset:{placement:ce}};let G=(Q=k.filter(K=>K.overflows[0]<=0).sort((K,X)=>K.overflows[1]-X.overflows[1])[0])==null?void 0:Q.placement;if(!G)switch(m){case"bestFit":{var ie;const K=(ie=k.filter(X=>{if(C){const J=bn(X.placement);return J===A||J==="y"}return!0}).map(X=>[X.placement,X.overflows.filter(J=>J>0).reduce((J,se)=>J+se,0)]).sort((X,J)=>X[1]-J[1])[0])==null?void 0:ie[0];K&&(G=K);break}case"initialPlacement":G=o;break}if(s!==G)return{reset:{placement:G}}}return{}}}};function DS(n,e){return{top:n.top-e.height,right:n.right-e.width,bottom:n.bottom-e.height,left:n.left-e.width}}function OS(n){return sL.some(e=>n[e]>=0)}const mL=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(e){const{rects:t}=e,{strategy:i="referenceHidden",...s}=aa(n,e);switch(i){case"referenceHidden":{const r=await Ih(e,{...s,elementContext:"reference"}),a=DS(r,t.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:OS(a)}}}case"escaped":{const r=await Ih(e,{...s,altBoundary:!0}),a=DS(r,t.floating);return{data:{escapedOffsets:a,escaped:OS(a)}}}default:return{}}}}},MR=new Set(["left","top"]);async function bL(n,e){const{placement:t,platform:i,elements:s}=n,r=await(i.isRTL==null?void 0:i.isRTL(s.floating)),a=oa(t),o=hc(t),c=bn(t)==="y",u=MR.has(a)?-1:1,d=r&&c?-1:1,f=aa(e,n);let{mainAxis:g,crossAxis:m,alignmentAxis:b}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return o&&typeof b=="number"&&(m=o==="end"?b*-1:b),c?{x:m*d,y:g*u}:{x:g*u,y:m*d}}const yL=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,i;const{x:s,y:r,placement:a,middlewareData:o}=e,c=await bL(e,n);return a===((t=o.offset)==null?void 0:t.placement)&&(i=o.arrow)!=null&&i.alignmentOffset?{}:{x:s+c.x,y:r+c.y,data:{...c,placement:a}}}}},vL=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:i,placement:s}=e,{mainAxis:r=!0,crossAxis:a=!1,limiter:o={fn:v=>{let{x:E,y:A}=v;return{x:E,y:A}}},...c}=aa(n,e),u={x:t,y:i},d=await Ih(e,c),f=bn(oa(s)),g=nb(f);let m=u[g],b=u[f];if(r){const v=g==="y"?"top":"left",E=g==="y"?"bottom":"right",A=m+d[v],D=m-d[E];m=pm(A,m,D)}if(a){const v=f==="y"?"top":"left",E=f==="y"?"bottom":"right",A=b+d[v],D=b-d[E];b=pm(A,b,D)}const x=o.fn({...e,[g]:m,[f]:b});return{...x,data:{x:x.x-t,y:x.y-i,enabled:{[g]:r,[f]:a}}}}}},xL=function(n){return n===void 0&&(n={}),{options:n,fn(e){const{x:t,y:i,placement:s,rects:r,middlewareData:a}=e,{offset:o=0,mainAxis:c=!0,crossAxis:u=!0}=aa(n,e),d={x:t,y:i},f=bn(s),g=nb(f);let m=d[g],b=d[f];const x=aa(o,e),v=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(c){const D=g==="y"?"height":"width",I=r.reference[g]-r.floating[D]+v.mainAxis,R=r.reference[g]+r.reference[D]-v.mainAxis;m<I?m=I:m>R&&(m=R)}if(u){var E,A;const D=g==="y"?"width":"height",I=MR.has(oa(s)),R=r.reference[f]-r.floating[D]+(I&&((E=a.offset)==null?void 0:E[f])||0)+(I?0:v.crossAxis),C=r.reference[f]+r.reference[D]+(I?0:((A=a.offset)==null?void 0:A[f])||0)-(I?v.crossAxis:0);b<R?b=R:b>C&&(b=C)}return{[g]:m,[f]:b}}}},SL=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(e){var t,i;const{placement:s,rects:r,platform:a,elements:o}=e,{apply:c=()=>{},...u}=aa(n,e),d=await Ih(e,u),f=oa(s),g=hc(s),m=bn(s)==="y",{width:b,height:x}=r.floating;let v,E;f==="top"||f==="bottom"?(v=f,E=g===(await(a.isRTL==null?void 0:a.isRTL(o.floating))?"start":"end")?"left":"right"):(E=f,v=g==="end"?"top":"bottom");const A=x-d.top-d.bottom,D=b-d.left-d.right,I=Za(x-d[v],A),R=Za(b-d[E],D),C=!e.middlewareData.shift;let M=I,F=R;if((t=e.middlewareData.shift)!=null&&t.enabled.x&&(F=D),(i=e.middlewareData.shift)!=null&&i.enabled.y&&(M=A),C&&!g){const k=tr(d.left,0),q=tr(d.right,0),Q=tr(d.top,0),ie=tr(d.bottom,0);m?F=b-2*(k!==0||q!==0?k+q:tr(d.left,d.right)):M=x-2*(Q!==0||ie!==0?Q+ie:tr(d.top,d.bottom))}await c({...e,availableWidth:F,availableHeight:M});const U=await a.getDimensions(o.floating);return b!==U.width||x!==U.height?{reset:{rects:!0}}:{}}}};function Af(){return typeof window<"u"}function uc(n){return CR(n)?(n.nodeName||"").toLowerCase():"#document"}function rr(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function An(n){var e;return(e=(CR(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function CR(n){return Af()?n instanceof Node||n instanceof rr(n).Node:!1}function jr(n){return Af()?n instanceof Element||n instanceof rr(n).Element:!1}function Sn(n){return Af()?n instanceof HTMLElement||n instanceof rr(n).HTMLElement:!1}function wS(n){return!Af()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof rr(n).ShadowRoot}const TL=new Set(["inline","contents"]);function jh(n){const{overflow:e,overflowX:t,overflowY:i,display:s}=Yr(n);return/auto|scroll|overlay|hidden|clip/.test(e+i+t)&&!TL.has(s)}const EL=new Set(["table","td","th"]);function AL(n){return EL.has(uc(n))}const RL=[":popover-open",":modal"];function Rf(n){return RL.some(e=>{try{return n.matches(e)}catch{return!1}})}const ML=["transform","translate","scale","rotate","perspective"],CL=["transform","translate","scale","rotate","perspective","filter"],IL=["paint","layout","strict","content"];function lb(n){const e=cb(),t=jr(n)?Yr(n):n;return ML.some(i=>t[i]?t[i]!=="none":!1)||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||CL.some(i=>(t.willChange||"").includes(i))||IL.some(i=>(t.contain||"").includes(i))}function PL(n){let e=$a(n);for(;Sn(e)&&!ic(e);){if(lb(e))return e;if(Rf(e))return null;e=$a(e)}return null}function cb(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const DL=new Set(["html","body","#document"]);function ic(n){return DL.has(uc(n))}function Yr(n){return rr(n).getComputedStyle(n)}function Mf(n){return jr(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function $a(n){if(uc(n)==="html")return n;const e=n.assignedSlot||n.parentNode||wS(n)&&n.host||An(n);return wS(e)?e.host:e}function IR(n){const e=$a(n);return ic(e)?n.ownerDocument?n.ownerDocument.body:n.body:Sn(e)&&jh(e)?e:IR(e)}function Ph(n,e,t){var i;e===void 0&&(e=[]),t===void 0&&(t=!0);const s=IR(n),r=s===((i=n.ownerDocument)==null?void 0:i.body),a=rr(s);if(r){const o=gm(a);return e.concat(a,a.visualViewport||[],jh(s)?s:[],o&&t?Ph(o):[])}return e.concat(s,Ph(s,[],t))}function gm(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function PR(n){const e=Yr(n);let t=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const s=Sn(n),r=s?n.offsetWidth:t,a=s?n.offsetHeight:i,o=Xd(t)!==r||Xd(i)!==a;return o&&(t=r,i=a),{width:t,height:i,$:o}}function hb(n){return jr(n)?n:n.contextElement}function jl(n){const e=hb(n);if(!Sn(e))return vn(1);const t=e.getBoundingClientRect(),{width:i,height:s,$:r}=PR(e);let a=(r?Xd(t.width):t.width)/i,o=(r?Xd(t.height):t.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!o||!Number.isFinite(o))&&(o=1),{x:a,y:o}}const OL=vn(0);function DR(n){const e=rr(n);return!cb()||!e.visualViewport?OL:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function wL(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==rr(n)?!1:e}function ko(n,e,t,i){e===void 0&&(e=!1),t===void 0&&(t=!1);const s=n.getBoundingClientRect(),r=hb(n);let a=vn(1);e&&(i?jr(i)&&(a=jl(i)):a=jl(n));const o=wL(r,t,i)?DR(r):vn(0);let c=(s.left+o.x)/a.x,u=(s.top+o.y)/a.y,d=s.width/a.x,f=s.height/a.y;if(r){const g=rr(r),m=i&&jr(i)?rr(i):i;let b=g,x=gm(b);for(;x&&i&&m!==b;){const v=jl(x),E=x.getBoundingClientRect(),A=Yr(x),D=E.left+(x.clientLeft+parseFloat(A.paddingLeft))*v.x,I=E.top+(x.clientTop+parseFloat(A.paddingTop))*v.y;c*=v.x,u*=v.y,d*=v.x,f*=v.y,c+=D,u+=I,b=rr(x),x=gm(b)}}return Yd({width:d,height:f,x:c,y:u})}function Cf(n,e){const t=Mf(n).scrollLeft;return e?e.left+t:ko(An(n)).left+t}function OR(n,e){const t=n.getBoundingClientRect(),i=t.left+e.scrollLeft-Cf(n,t),s=t.top+e.scrollTop;return{x:i,y:s}}function FL(n){let{elements:e,rect:t,offsetParent:i,strategy:s}=n;const r=s==="fixed",a=An(i),o=e?Rf(e.floating):!1;if(i===a||o&&r)return t;let c={scrollLeft:0,scrollTop:0},u=vn(1);const d=vn(0),f=Sn(i);if((f||!f&&!r)&&((uc(i)!=="body"||jh(a))&&(c=Mf(i)),Sn(i))){const m=ko(i);u=jl(i),d.x=m.x+i.clientLeft,d.y=m.y+i.clientTop}const g=a&&!f&&!r?OR(a,c):vn(0);return{width:t.width*u.x,height:t.height*u.y,x:t.x*u.x-c.scrollLeft*u.x+d.x+g.x,y:t.y*u.y-c.scrollTop*u.y+d.y+g.y}}function LL(n){return Array.from(n.getClientRects())}function NL(n){const e=An(n),t=Mf(n),i=n.ownerDocument.body,s=tr(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),r=tr(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);let a=-t.scrollLeft+Cf(n);const o=-t.scrollTop;return Yr(i).direction==="rtl"&&(a+=tr(e.clientWidth,i.clientWidth)-s),{width:s,height:r,x:a,y:o}}const FS=25;function BL(n,e){const t=rr(n),i=An(n),s=t.visualViewport;let r=i.clientWidth,a=i.clientHeight,o=0,c=0;if(s){r=s.width,a=s.height;const d=cb();(!d||d&&e==="fixed")&&(o=s.offsetLeft,c=s.offsetTop)}const u=Cf(i);if(u<=0){const d=i.ownerDocument,f=d.body,g=getComputedStyle(f),m=d.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,b=Math.abs(i.clientWidth-f.clientWidth-m);b<=FS&&(r-=b)}else u<=FS&&(r+=u);return{width:r,height:a,x:o,y:c}}const UL=new Set(["absolute","fixed"]);function kL(n,e){const t=ko(n,!0,e==="fixed"),i=t.top+n.clientTop,s=t.left+n.clientLeft,r=Sn(n)?jl(n):vn(1),a=n.clientWidth*r.x,o=n.clientHeight*r.y,c=s*r.x,u=i*r.y;return{width:a,height:o,x:c,y:u}}function LS(n,e,t){let i;if(e==="viewport")i=BL(n,t);else if(e==="document")i=NL(An(n));else if(jr(e))i=kL(e,t);else{const s=DR(n);i={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return Yd(i)}function wR(n,e){const t=$a(n);return t===e||!jr(t)||ic(t)?!1:Yr(t).position==="fixed"||wR(t,e)}function VL(n,e){const t=e.get(n);if(t)return t;let i=Ph(n,[],!1).filter(o=>jr(o)&&uc(o)!=="body"),s=null;const r=Yr(n).position==="fixed";let a=r?$a(n):n;for(;jr(a)&&!ic(a);){const o=Yr(a),c=lb(a);!c&&o.position==="fixed"&&(s=null),(r?!c&&!s:!c&&o.position==="static"&&!!s&&UL.has(s.position)||jh(a)&&!c&&wR(n,a))?i=i.filter(d=>d!==a):s=o,a=$a(a)}return e.set(n,i),i}function zL(n){let{element:e,boundary:t,rootBoundary:i,strategy:s}=n;const a=[...t==="clippingAncestors"?Rf(e)?[]:VL(e,this._c):[].concat(t),i],o=a[0],c=a.reduce((u,d)=>{const f=LS(e,d,s);
vendor: 4,834 bytes, line 50
50return u.top=tr(f.top,u.top),u.right=Za(f.right,u.right),u.bottom=Za(f.bottom,u.bottom),u.left=tr(f.left,u.left),u},LS(e,o,s));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function GL(n){const{width:e,height:t}=PR(n);return{width:e,height:t}}function HL(n,e,t){const i=Sn(e),s=An(e),r=t==="fixed",a=ko(n,!0,r,e);let o={scrollLeft:0,scrollTop:0};const c=vn(0);function u(){c.x=Cf(s)}if(i||!i&&!r)if((uc(e)!=="body"||jh(s))&&(o=Mf(e)),i){const m=ko(e,!0,r,e);c.x=m.x+e.clientLeft,c.y=m.y+e.clientTop}else s&&u();r&&!i&&s&&u();const d=s&&!i&&!r?OR(s,o):vn(0),f=a.left+o.scrollLeft-c.x-d.x,g=a.top+o.scrollTop-c.y-d.y;return{x:f,y:g,width:a.width,height:a.height}}function Tg(n){return Yr(n).position==="static"}function NS(n,e){if(!Sn(n)||Yr(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return An(n)===t&&(t=t.ownerDocument.body),t}function FR(n,e){const t=rr(n);if(Rf(n))return t;if(!Sn(n)){let s=$a(n);for(;s&&!ic(s);){if(jr(s)&&!Tg(s))return s;s=$a(s)}return t}let i=NS(n,e);for(;i&&AL(i)&&Tg(i);)i=NS(i,e);return i&&ic(i)&&Tg(i)&&!lb(i)?t:i||PL(n)||t}const WL=async function(n){const e=this.getOffsetParent||FR,t=this.getDimensions,i=await t(n.floating);return{reference:HL(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function XL(n){return Yr(n).direction==="rtl"}const jL={convertOffsetParentRelativeRectToViewportRelativeRect:FL,getDocumentElement:An,getClippingRect:zL,getOffsetParent:FR,getElementRects:WL,getClientRects:LL,getDimensions:GL,getScale:jl,isElement:jr,isRTL:XL};function LR(n,e){return n.x===e.x&&n.y===e.y&&n.width===e.width&&n.height===e.height}function YL(n,e){let t=null,i;const s=An(n);function r(){var o;clearTimeout(i),(o=t)==null||o.disconnect(),t=null}function a(o,c){o===void 0&&(o=!1),c===void 0&&(c=1),r();const u=n.getBoundingClientRect(),{left:d,top:f,width:g,height:m}=u;if(o||e(),!g||!m)return;const b=xd(f),x=xd(s.clientWidth-(d+g)),v=xd(s.clientHeight-(f+m)),E=xd(d),D={rootMargin:-b+"px "+-x+"px "+-v+"px "+-E+"px",threshold:tr(0,Za(1,c))||1};let I=!0;function R(C){const M=C[0].intersectionRatio;if(M!==c){if(!I)return a();M?a(!1,M):i=setTimeout(()=>{a(!1,1e-7)},1e3)}M===1&&!LR(u,n.getBoundingClientRect())&&a(),I=!1}try{t=new IntersectionObserver(R,{...D,root:s.ownerDocument})}catch{t=new IntersectionObserver(R,D)}t.observe(n)}return a(!0),r}function KL(n,e,t,i){i===void 0&&(i={});const{ancestorScroll:s=!0,ancestorResize:r=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:o=typeof IntersectionObserver=="function",animationFrame:c=!1}=i,u=hb(n),d=s||r?[...u?Ph(u):[],...Ph(e)]:[];d.forEach(E=>{s&&E.addEventListener("scroll",t,{passive:!0}),r&&E.addEventListener("resize",t)});const f=u&&o?YL(u,t):null;let g=-1,m=null;a&&(m=new ResizeObserver(E=>{let[A]=E;A&&A.target===u&&m&&(m.unobserve(e),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var D;(D=m)==null||D.observe(e)})),t()}),u&&!c&&m.observe(u),m.observe(e));let b,x=c?ko(n):null;c&&v();function v(){const E=ko(n);x&&!LR(x,E)&&t(),x=E,b=requestAnimationFrame(v)}return t(),()=>{var E;d.forEach(A=>{s&&A.removeEventListener("scroll",t),r&&A.removeEventListener("resize",t)}),f?.(),(E=m)==null||E.disconnect(),m=null,c&&cancelAnimationFrame(b)}}const qL=yL,ZL=vL,$L=gL,QL=SL,JL=mL,BS=_L,eN=xL,tN=(n,e,t)=>{const i=new Map,s={platform:jL,...t},r={...s.platform,_c:i};return pL(n,e,{...s,platform:r})};var iN=typeof document<"u",sN=function(){},Nd=iN?Y.useLayoutEffect:sN;function Kd(n,e){if(n===e)return!0;if(typeof n!=typeof e)return!1;if(typeof n=="function"&&n.toString()===e.toString())return!0;let t,i,s;if(n&&e&&typeof n=="object"){if(Array.isArray(n)){if(t=n.length,t!==e.length)return!1;for(i=t;i--!==0;)if(!Kd(n[i],e[i]))return!1;return!0}if(s=Object.keys(n),t=s.length,t!==Object.keys(e).length)return!1;for(i=t;i--!==0;)if(!{}.hasOwnProperty.call(e,s[i]))return!1;for(i=t;i--!==0;){const r=s[i];if(!(r==="_owner"&&n.$$typeof)&&!Kd(n[r],e[r]))return!1}return!0}return n!==n&&e!==e}function NR(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function US(n,e){const t=NR(n);return Math.round(e*t)/t}function Eg(n){const e=Y.useRef(n);return Nd(()=>{e.current=n}),e}function rN(n){n===void 0&&(n={});const{placement:e="bottom",strategy:t="absolute",middleware:i=[],platform:s,elements:{reference:r,floating:a}={},transform:o=!0,whileElementsMounted:c,open:u}=n,[d,f]=Y.useState({x:0,y:0,strategy:t,placement:e,middlewareData:{},isPositioned:!1}),[g,m]=Y.useState(i);Kd(g,i)||m(i);const[b,x]=Y.useState(null),[v,E]=Y.useState(null),A=Y.useCallback(X=>{X!==C.current&&(C.current=X,x(X))},[]),D=Y.useCallback(X=>{X!==M.current&&(M.current=X,E(X))},[]),I=r||b,R=a||v,C=Y.useRef(null),M=Y.useRef(null),F=Y.useRef(d),U=c!=null,k=Eg(c),q=Eg(s),Q=Eg(u),ie=Y.useCallback(()=>
vendor: 4,950 bytes, line 50
50{if(!C.current||!M.current)return;const X={placement:e,strategy:t,middleware:g};q.current&&(X.platform=q.current),tN(C.current,M.current,X).then(J=>{const se={...J,isPositioned:Q.current!==!1};$.current&&!Kd(F.current,se)&&(F.current=se,rb.flushSync(()=>{f(se)}))})},[g,e,t,q,Q]);Nd(()=>{u===!1&&F.current.isPositioned&&(F.current.isPositioned=!1,f(X=>({...X,isPositioned:!1})))},[u]);const $=Y.useRef(!1);Nd(()=>($.current=!0,()=>{$.current=!1}),[]),Nd(()=>{if(I&&(C.current=I),R&&(M.current=R),I&&R){if(k.current)return k.current(I,R,ie);ie()}},[I,R,ie,k,U]);const ce=Y.useMemo(()=>({reference:C,floating:M,setReference:A,setFloating:D}),[A,D]),G=Y.useMemo(()=>({reference:I,floating:R}),[I,R]),K=Y.useMemo(()=>{const X={position:t,left:0,top:0};if(!G.floating)return X;const J=US(G.floating,d.x),se=US(G.floating,d.y);return o?{...X,transform:"translate("+J+"px, "+se+"px)",...NR(G.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:J,top:se}},[t,o,G.floating,d.x,d.y]);return Y.useMemo(()=>({...d,update:ie,refs:ce,elements:G,floatingStyles:K}),[d,ie,ce,G,K])}const nN=n=>{function e(t){return{}.hasOwnProperty.call(t,"current")}return{name:"arrow",options:n,fn(t){const{element:i,padding:s}=typeof n=="function"?n(t):n;return i&&e(i)?i.current!=null?BS({element:i.current,padding:s}).fn(t):{}:i?BS({element:i,padding:s}).fn(t):{}}}},aN=(n,e)=>({...qL(n),options:[n,e]}),oN=(n,e)=>({...ZL(n),options:[n,e]}),lN=(n,e)=>({...eN(n),options:[n,e]}),cN=(n,e)=>({...$L(n),options:[n,e]}),hN=(n,e)=>({...QL(n),options:[n,e]}),uN=(n,e)=>({...JL(n),options:[n,e]}),dN=(n,e)=>({...nN(n),options:[n,e]});var fN="Arrow",BR=Y.forwardRef((n,e)=>{const{children:t,width:i=10,height:s=5,...r}=n;return B.jsx(Fr.svg,{...r,ref:e,width:i,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:n.asChild?t:B.jsx("polygon",{points:"0,0 30,0 15,10"})})});BR.displayName=fN;var pN=BR;function UR(n){const[e,t]=Y.useState(void 0);return tc(()=>{if(n){t({width:n.offsetWidth,height:n.offsetHeight});const i=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const r=s[0];let a,o;if("borderBoxSize"in r){const c=r.borderBoxSize,u=Array.isArray(c)?c[0]:c;a=u.inlineSize,o=u.blockSize}else a=n.offsetWidth,o=n.offsetHeight;t({width:a,height:o})});return i.observe(n,{box:"border-box"}),()=>i.unobserve(n)}else t(void 0)},[n]),e}var kR="Popper",[VR,zR]=Tf(kR),[q4,GR]=VR(kR),HR="PopperAnchor",WR=Y.forwardRef((n,e)=>{const{__scopePopper:t,virtualRef:i,...s}=n,r=GR(HR,t),a=Y.useRef(null),o=Ms(e,a),c=Y.useRef(null);return Y.useEffect(()=>{const u=c.current;c.current=i?.current||a.current,u!==c.current&&r.onAnchorChange(c.current)}),i?null:B.jsx(Fr.div,{...s,ref:o})});WR.displayName=HR;var ub="PopperContent",[_N,gN]=VR(ub),XR=Y.forwardRef((n,e)=>{const{__scopePopper:t,side:i="bottom",sideOffset:s=0,align:r="center",alignOffset:a=0,arrowPadding:o=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:g=!1,updatePositionStrategy:m="optimized",onPlaced:b,...x}=n,v=GR(ub,t),[E,A]=Y.useState(null),D=Ms(e,be=>A(be)),[I,R]=Y.useState(null),C=UR(I),M=C?.width??0,F=C?.height??0,U=i+(r!=="center"?"-"+r:""),k=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},q=Array.isArray(u)?u:[u],Q=q.length>0,ie={padding:k,boundary:q.filter(bN),altBoundary:Q},{refs:$,floatingStyles:ce,placement:G,isPositioned:K,middlewareData:X}=rN({strategy:"fixed",placement:U,whileElementsMounted:(...be)=>KL(...be,{animationFrame:m==="always"}),elements:{reference:v.anchor},middleware:[aN({mainAxis:s+F,alignmentAxis:a}),c&&oN({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?lN():void 0,...ie}),c&&cN({...ie}),hN({...ie,apply:({elements:be,rects:Le,availableWidth:Xe,availableHeight:it})=>{const{width:ut,height:Oe}=Le.reference,Qe=be.floating.style;Qe.setProperty("--radix-popper-available-width",`${Xe}px`),Qe.setProperty("--radix-popper-available-height",`${it}px`),Qe.setProperty("--radix-popper-anchor-width",`${ut}px`),Qe.setProperty("--radix-popper-anchor-height",`${Oe}px`)}}),I&&dN({element:I,padding:o}),yN({arrowWidth:M,arrowHeight:F}),g&&uN({strategy:"referenceHidden",...ie})]}),[J,se]=KR(G),w=Ef(b);tc(()=>{K&&w?.()},[K,w]);const L=X.arrow?.x,V=X.arrow?.y,j=X.arrow?.centerOffset!==0,[ae,he]=Y.useState();return tc(()=>{E&&he(window.getComputedStyle(E).zIndex)},[E]),B.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...ce,transform:K?ce.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ae,"--radix-popper-transform-origin":[X.transformOrigin?.x,X.transformOrigin?.y].join(" "),...X.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:n.dir,children:B.jsx(_N,{scope:t,placedSide:J,onArrowChange:R,arrowX:L,arrowY:V,shouldHideArrow:j,children:B.jsx(Fr.div,{"data-side":J,"data-align":se,...x,ref:D,style:{...x.style,animation:K?void 0:"none"}})})})});XR.displayName=ub;var jR="PopperArrow",mN={top:"bottom",right:"left",bottom:"top",left:"r
50ight"},YR=Y.forwardRef(function(e,t){const{__scopePopper:i,...s}=e,r=gN(jR,i),a=mN[r.placedSide];return B.jsx("span",{ref:r.onArrowChange,style:{position:"absolute",left:r.arrowX,top:r.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[r.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[r.placedSide],visibility:r.shouldHideArrow?"hidden":void 0},children:B.jsx(pN,{...s,ref:t,style:{...s.style,display:"block"}})})});YR.displayName=jR;function bN(n){return n!==null}var yN=n=>({name:"transformOrigin",options:n,fn(e){const{placement:t,rects:i,middlewareData:s}=e,a=s.arrow?.centerOffset!==0,o=a?0:n.arrowWidth,c=a?0:n.arrowHeight,[u,d]=KR(t),f={start:"0%",center:"50%",end:"100%"}[d],g=(s.arrow?.x??0)+o/2,m=(s.arrow?.y??0)+c/2;let b="",x="";return u==="bottom"?(b=a?f:`${g}px`,x=`${-c}px`):u==="top"?(b=a?f:`${g}px`,x=`${i.floating.height+c}px`):u==="right"?(b=`${-c}px`,x=a?f:`${m}px`):u==="left"&&(b=`${i.floating.width+c}px`,x=a?f:`${m}px`),{data:{x:b,y:x}}}});function KR(n){const[e,t="center"]=n.split("-");return[e,t]}var vN=WR,xN=XR,SN=YR;function TN(n,e){return Y.useReducer((t,i)=>e[t][i]??t,n)}var qR=n=>{const{present:e,children:t}=n,i=EN(e),s=typeof t=="function"?t({present:i.isPresent}):Y.Children.only(t),r=Ms(i.ref,AN(s));return typeof t=="function"||i.isPresent?Y.cloneElement(s,{ref:r}):null};qR.displayName="Presence";function EN(n){const[e,t]=Y.useState(),i=Y.useRef(null),s=Y.useRef(n),r=Y.useRef("none"),a=n?"mounted":"unmounted",[o,c]=TN(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return Y.useEffect(()=>{const u=Sd(i.current);r.current=o==="mounted"?u:"none"},[o]),tc(()=>{const u=i.current,d=s.current;if(d!==n){const g=r.current,m=Sd(u);n?c("MOUNT"):m==="none"||u?.display==="none"?c("UNMOUNT"):c(d&&g!==m?"ANIMATION_OUT":"UNMOUNT"),s.current=n}},[n,c]),tc(()=>{if(e){let u;const d=e.ownerDocument.defaultView??window,f=m=>{const x=Sd(i.current).includes(CSS.escape(m.animationName));if(m.target===e&&x&&(c("ANIMATION_END"),!s.current)){const v=e.style.animationFillMode;e.style.animationFillMode="forwards",u=d.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=v)})}},g=m=>{m.target===e&&(r.current=Sd(i.current))};return e.addEventListener("animationstart",g),e.addEventListener("animationcancel",f),e.addEventListener("animationend",f),()=>{d.clearTimeout(u),e.removeEventListener("animationstart",g),e.removeEventListener("animationcancel",f),e.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[e,c]),{isPresent:["mounted","unmountSuspended"].includes(o),ref:Y.useCallback(u=>{i.current=u?getComputedStyle(u):null,t(u)},[])}}function Sd(n){return n?.animationName||"none"}function AN(n){let e=Object.getOwnPropertyDescriptor(n.props,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning;return t?n.ref:(e=Object.getOwnPropertyDescriptor(n,"ref")?.get,t=e&&"isReactWarning"in e&&e.isReactWarning,t?n.props.ref:n.props.ref||n.ref)}var RN=Jm[" useInsertionEffect ".trim().toString()]||tc;function MN({prop:n,defaultProp:e,onChange:t=()=>{},caller:i}){const[s,r,a]=CN({defaultProp:e,onChange:t}),o=n!==void 0,c=o?n:s;{const d=Y.useRef(n!==void 0);Y.useEffect(()=>{const f=d.current;f!==o&&console.warn(`${i} is changing from ${f?"controlled":"uncontrolled"} to ${o?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=o},[o,i])}const u=Y.useCallback(d=>{if(o){const f=IN(d)?d(n):d;f!==n&&a.current?.(f)}else r(d)},[o,n,r,a]);return[c,u]}function CN({defaultProp:n,onChange:e}){const[t,i]=Y.useState(n),s=Y.useRef(t),r=Y.useRef(e);return RN(()=>{r.current=e},[e]),Y.useEffect(()=>{s.current!==t&&(r.current?.(t),s.current=t)},[t,s]),[t,i,r]}function IN(n){return typeof n=="function"}var PN=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),DN="VisuallyHidden",ZR=Y.forwardRef((n,e)=>B.jsx(Fr.span,{...n,ref:e,style:{...PN,...n.style}}));ZR.displayName=DN;var ON=ZR,[If]=Tf("Tooltip",[zR]),db=zR(),$R="TooltipProvider",wN=700,kS="tooltip.open",[FN,QR]=If($R),JR=n=>{const{__scopeTooltip:e,delayDuration:t=wN,skipDelayDuration:i=300,disableHoverableContent:s=!1,children:r}=n,a=Y.useRef(!0),o=Y.useRef(!1),c=Y.useRef(0);return Y.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),B.jsx(FN,{scope:e,isOpenDelayedRef:a,delayDuration:t,onOpen:Y.useCallback(()=>{window.clearTimeout(c.current),a.current=!1},[]),onClose:Y.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,i)},[i]),isPointerInTransitRef:o,onPointerInTransitChange:Y.useCallback(u=>{o.current=u},[]),disableHoverableContent:s,children:r})};JR.displayName=$R;var eM="Tooltip",[Z4,Pf]=If(eM),mm="TooltipTrigger",LN=Y.forwardRef((n,e)=>{const{__scopeTooltip:t,...i}=n,s=Pf(mm,t),r=QR(mm,t),a=db(t),o=Y.useRef(null),c=Ms(e,o,s.onTriggerChange),u=Y.useRef(!1),d=Y.useRef(!1),f=Y.useCallback(()=>u.current=!1,[]);return Y.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),B.jsx(vN,{asChild:!0,...a,children:B.jsx(Fr.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...i,ref:c,onPointerMove:Ts(n.onPointerMove,g=>{g.pointerType!=="touch"&&!d.current&&!r.isPointerInTransitRef.current&&(s.onTriggerEnter(),d.current=!0)}),onPointerLeave:Ts(n.onPointerLeave,()=>{s.onTriggerLeave(),d.current=!1}),onPointerDown:Ts(n.onPointerDown,()=>{s.open&&s.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Ts(n.onFocus,()=>{u.current||s.onOpen()}),onBlur:Ts(n.onBlur,s.onClose),onClick:Ts(n.onClick,s.onClose)})})});LN.displayName=mm;var NN="TooltipPortal",[$4,BN]=If(NN,{forceMount:void 0}),sc="TooltipContent",UN=Y.forwardRef((n,e)=>{const t=BN(sc,n.__scopeTooltip),{forceMount:i=t.forceMount,side:s="top",...r}=n,a=Pf(sc,n.__scopeTooltip);return B.jsx(qR,{present:i||a.open,children:a.disableHoverableContent?B.jsx(tM,{side:s,...r,ref:e}):B.jsx(kN,{side:s,...r,ref:e})})}),kN=Y.forwardRef((n,e)=>{const t=Pf(sc,n.__scopeTooltip),i=QR(sc,n.__scopeTooltip),s=Y.useRef(null),r=Ms(e,s),[a,o]=Y.useState(null),{trigger:c,onClose:u}=t,d=s.current,{onPointerInTransitChange:f}=i,g=Y.useCallback(()=>{o(null),f(!1)},[f]),m=Y.useCallback((b,x)=>{const v=b.currentTarget,E={x:b.clientX,y:b.clientY},A=WN(E,v.getBoundingClientRect()),D=XN(E,A),I=jN(x.getBoundingClientRect()),R=KN([...D,...I]);o(R),f(!0)},[f]);return Y.useEffect(()=>()=>g(),[g]),Y.useEffect(()=>{if(c&&d){const b=v=>m(v,d),x=v=>m(v,c);return c.addEventListener("pointerleave",b),d.addEventListener("pointerleave",x),()=>{c.removeEventListener("pointerleave",b),d.removeEventListener("pointerleave",x)}}},[c,d,m,g]),Y.useEffect(()=>{if(a){const b=x=>
vendor: 10,965 bytes, line 50
50{const v=x.target,E={x:x.clientX,y:x.clientY},A=c?.contains(v)||d?.contains(v),D=!YN(E,a);A?g():D&&(g(),u())};return document.addEventListener("pointermove",b),()=>document.removeEventListener("pointermove",b)}},[c,d,a,u,g]),B.jsx(tM,{...n,ref:r})}),[VN,zN]=If(eM,{isInside:!1}),GN=HF("TooltipContent"),tM=Y.forwardRef((n,e)=>{const{__scopeTooltip:t,children:i,"aria-label":s,onEscapeKeyDown:r,onPointerDownOutside:a,...o}=n,c=Pf(sc,t),u=db(t),{onClose:d}=c;return Y.useEffect(()=>(document.addEventListener(kS,d),()=>document.removeEventListener(kS,d)),[d]),Y.useEffect(()=>{if(c.trigger){const f=g=>{g.target?.contains(c.trigger)&&d()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,d]),B.jsx(ER,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:f=>f.preventDefault(),onDismiss:d,children:B.jsxs(xN,{"data-state":c.stateAttribute,...u,...o,ref:e,style:{...o.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[B.jsx(GN,{children:i}),B.jsx(VN,{scope:t,isInside:!0,children:B.jsx(ON,{id:c.contentId,role:"tooltip",children:s||i})})]})})});UN.displayName=sc;var iM="TooltipArrow",HN=Y.forwardRef((n,e)=>{const{__scopeTooltip:t,...i}=n,s=db(t);return zN(iM,t).isInside?null:B.jsx(SN,{...s,...i,ref:e})});HN.displayName=iM;function WN(n,e){const t=Math.abs(e.top-n.y),i=Math.abs(e.bottom-n.y),s=Math.abs(e.right-n.x),r=Math.abs(e.left-n.x);switch(Math.min(t,i,s,r)){case r:return"left";case s:return"right";case t:return"top";case i:return"bottom";default:throw new Error("unreachable")}}function XN(n,e,t=5){const i=[];switch(e){case"top":i.push({x:n.x-t,y:n.y+t},{x:n.x+t,y:n.y+t});break;case"bottom":i.push({x:n.x-t,y:n.y-t},{x:n.x+t,y:n.y-t});break;case"left":i.push({x:n.x+t,y:n.y-t},{x:n.x+t,y:n.y+t});break;case"right":i.push({x:n.x-t,y:n.y-t},{x:n.x-t,y:n.y+t});break}return i}function jN(n){const{top:e,right:t,bottom:i,left:s}=n;return[{x:s,y:e},{x:t,y:e},{x:t,y:i},{x:s,y:i}]}function YN(n,e){const{x:t,y:i}=n;let s=!1;for(let r=0,a=e.length-1;r<e.length;a=r++){const o=e[r],c=e[a],u=o.x,d=o.y,f=c.x,g=c.y;d>i!=g>i&&t<(f-u)*(i-d)/(g-d)+u&&(s=!s)}return s}function KN(n){const e=n.slice();return e.sort((t,i)=>t.x<i.x?-1:t.x>i.x?1:t.y<i.y?-1:t.y>i.y?1:0),qN(e)}function qN(n){if(n.length<=1)return n.slice();const e=[];for(let i=0;i<n.length;i++){const s=n[i];for(;e.length>=2;){const r=e[e.length-1],a=e[e.length-2];if((r.x-a.x)*(s.y-a.y)>=(r.y-a.y)*(s.x-a.x))e.pop();else break}e.push(s)}e.pop();const t=[];for(let i=n.length-1;i>=0;i--){const s=n[i];for(;t.length>=2;){const r=t[t.length-1],a=t[t.length-2];if((r.x-a.x)*(s.y-a.y)>=(r.y-a.y)*(s.x-a.x))t.pop();else break}t.push(s)}return t.pop(),e.length===1&&t.length===1&&e[0].x===t[0].x&&e[0].y===t[0].y?e:e.concat(t)}var ZN=JR;function sM(n){var e,t,i="";if(typeof n=="string"||typeof n=="number")i+=n;else if(typeof n=="object")if(Array.isArray(n)){var s=n.length;for(e=0;e<s;e++)n[e]&&(t=sM(n[e]))&&(i&&(i+=" "),i+=t)}else for(t in n)n[t]&&(i&&(i+=" "),i+=t);return i}function rM(){for(var n,e,t=0,i="",s=arguments.length;t<s;t++)(n=arguments[t])&&(e=sM(n))&&(i&&(i+=" "),i+=e);return i}const fb="-",$N=n=>{const e=JN(n),{conflictingClassGroups:t,conflictingClassGroupModifiers:i}=n;return{getClassGroupId:a=>{const o=a.split(fb);return o[0]===""&&o.length!==1&&o.shift(),nM(o,e)||QN(a)},getConflictingClassGroupIds:(a,o)=>{const c=t[a]||[];return o&&i[a]?[...c,...i[a]]:c}}},nM=(n,e)=>{if(n.length===0)return e.classGroupId;const t=n[0],i=e.nextPart.get(t),s=i?nM(n.slice(1),i):void 0;if(s)return s;if(e.validators.length===0)return;const r=n.join(fb);return e.validators.find(({validator:a})=>a(r))?.classGroupId},VS=/^\[(.+)\]$/,QN=n=>{if(VS.test(n)){const e=VS.exec(n)[1],t=e?.substring(0,e.indexOf(":"));if(t)return"arbitrary.."+t}},JN=n=>{const{theme:e,classGroups:t}=n,i={nextPart:new Map,validators:[]};for(const s in t)bm(t[s],i,s,e);return i},bm=(n,e,t,i)=>{n.forEach(s=>{if(typeof s=="string"){const r=s===""?e:zS(e,s);r.classGroupId=t;return}if(typeof s=="function"){if(eB(s)){bm(s(i),e,t,i);return}e.validators.push({validator:s,classGroupId:t});return}Object.entries(s).forEach(([r,a])=>{bm(a,zS(e,r),t,i)})})},zS=(n,e)=>{let t=n;return e.split(fb).forEach(i=>{t.nextPart.has(i)||t.nextPart.set(i,{nextPart:new Map,validators:[]}),t=t.nextPart.get(i)}),t},eB=n=>n.isThemeGetter,tB=n=>{if(n<1)return{get:()=>{},set:()=>{}};let e=0,t=new Map,i=new Map;const s=(r,a)=>{t.set(r,a),e++,e>n&&(e=0,i=t,t=new Map)};return{get(r){let a=t.get(r);if(a!==void 0)return a;if((a=i.get(r))!==void 0)return s(r,a),a},set(r,a){t.has(r)?t.set(r,a):s(r,a)}}},ym="!",vm=":",iB=vm.length,sB=n=>{const{prefix:e,experimentalParseClassName:t}=n;let i=s=>{const r=[];let a=0,o=0,c=0,u;for(let b=0;b<s.length;b++){let x=s[b];if(a===0&&o===0){if(x===vm){r.push(s.slice(c,b)),c=b+iB;continue}if(x==="/"){u=b;continue}}x==="["?a++:x==="]"?a--:x==="("?o++:x===")"&&o--}const d=r.length===0?s:s.substring(c),f=rB(d),g=f!==d,m=u&&u>c?u-c:void 0;return{modifiers:r,hasImportantModifier:g,baseClassName:f,maybePostfixModifierPosition:m}};if(e){const s=e+vm,r=i;i=a=>a.startsWith(s)?r(a.substring(s.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:a,maybePostfixModifierPosition:void 0}}if(t){const s=i;i=r=>t({className:r,parseClassName:s})}return i},rB=n=>n.endsWith(ym)?n.substring(0,n.length-1):n.startsWith(ym)?n.substring(1):n,nB=n=>{const e=Object.fromEntries(n.orderSensitiveModifiers.map(i=>[i,!0]));return i=>{if(i.length<=1)return i;const s=[];let r=[];return i.forEach(a=>{a[0]==="["||e[a]?(s.push(...r.sort(),a),r=[]):r.push(a)}),s.push(...r.sort()),s}},aB=n=>({cache:tB(n.cacheSize),parseClassName:sB(n),sortModifiers:nB(n),...$N(n)}),oB=/\s+/,lB=(n,e)=>{const{parseClassName:t,getClassGroupId:i,getConflictingClassGroupIds:s,sortModifiers:r}=e,a=[],o=n.trim().split(oB);let c="";for(let u=o.length-1;u>=0;u-=1){const d=o[u],{isExternal:f,modifiers:g,hasImportantModifier:m,baseClassName:b,maybePostfixModifierPosition:x}=t(d);if(f){c=d+(c.length>0?" "+c:c);continue}let v=!!x,E=i(v?b.substring(0,x):b);if(!E){if(!v){c=d+(c.length>0?" "+c:c);continue}if(E=i(b),!E){c=d+(c.length>0?" "+c:c);continue}v=!1}const A=r(g).join(":"),D=m?A+ym:A,I=D+E;if(a.includes(I))continue;a.push(I);const R=s(E,v);for(let C=0;C<R.length;++C){const M=R[C];a.push(D+M)}c=d+(c.length>0?" "+c:c)}return c};function cB(){let n=0,e,t,i="";for(;n<arguments.length;)(e=arguments[n++])&&(t=aM(e))&&(i&&(i+=" "),i+=t);return i}const aM=n=>{if(typeof n=="string")return n;let e,t="";for(let i=0;i<n.length;i++)n[i]&&(e=aM(n[i]))&&(t&&(t+=" "),t+=e);return t};function hB(n,...e){let t,i,s,r=a;function a(c){const u=e.reduce((d,f)=>f(d),n());return t=aB(u),i=t.cache.get,s=t.cache.set,r=o,o(c)}function o(c){const u=i(c);if(u)return u;const d=lB(c,t);return s(c,d),d}return function(){return r(cB.apply(null,arguments))}}const ji=n=>{const e=t=>t[n]||[];return e.isThemeGetter=!0,e},oM=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,lM=/^\((?:(\w[\w-]*):)?(.+)\)$/i,uB=/^\d+\/\d+$/,dB=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,fB=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,pB=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,_B=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,gB=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,kl=n=>uB.test(n),Et=n=>!!n&&!Number.isNaN(Number(n)),za=n=>!!n&&Number.isInteger(Number(n)),Ag=n=>n.endsWith("%")&&Et(n.slice(0,-1)),Xn=n=>dB.test(n),mB=()=>!0,bB=n=>fB.test(n)&&!pB.test(n),cM=()=>!1,yB=n=>_B.test(n),vB=n=>gB.test(n),xB=n=>!et(n)&&!tt(n),SB=n=>dc(n,dM,cM),et=n=>oM.test(n),Mo=n=>dc(n,fM,bB),Rg=n=>dc(n,MB,Et),GS=n=>dc(n,hM,cM),TB=n=>dc(n,uM,vB),Td=n=>dc(n,pM,yB),tt=n=>lM.test(n),dh=n=>fc(n,fM),EB=n=>fc(n,CB),HS=n=>fc(n,hM),AB=n=>fc(n,dM),RB=n=>fc(n,uM),Ed=n=>fc(n,pM,!0),dc=(n,e,t)=>{const i=oM.exec(n);return i?i[1]?e(i[1]):t(i[2]):!1},fc=(n,e,t=!1)=>{const i=lM.exec(n);return i?i[1]?e(i[1]):t:!1},hM=n=>n==="position"||n==="percentage",uM=n=>n==="image"||n==="url",dM=n=>n==="length"||n==="size"||n==="bg-size",fM=n=>n==="length",MB=n=>n==="number",CB=n=>n==="family-name",pM=n=>n==="shadow",IB=()=>{const n=ji("color"),e=ji("font"),t=ji("text"),i=ji("font-weight"),s=ji("tracking"),r=ji("leading"),a=ji("breakpoint"),o=ji("container"),c=ji("spacing"),u=ji("radius"),d=ji("shadow"),f=ji("inset-shadow"),g=ji("text-shadow"),m=ji("drop-shadow"),b=ji("blur"),x=ji("perspective"),v=ji("aspect"),E=ji("ease"),A=ji("animate"),D=()=>["auto","avoid","all","avoid-page","page","left","right","column"],I=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],R=()=>[...I(),tt,et],C=()=>["auto","hidden","clip","visible","scroll"],M=()=>["auto","contain","none"],F=()=>[tt,et,c],U=()=>[kl,"full","auto",...F()],k=()=>[za,"none","subgrid",tt,et],q=()=>["auto",{span:["full",za,tt,et]},za,tt,et],Q=()=>[za,"auto",tt,et],ie=()=>["auto","min","max","fr",tt,et],$=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],ce=()=>["start","end","center","stretch","center-safe","end-safe"],G=()=>["auto",...F()],K=()=>[kl,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...F()],X=()=>[n,tt,et],J=()=>[...I(),HS,GS,{position:[tt,et]}],se=()=>["no-repeat",{repeat:["","x","y","space","round"]}],w=()=>["auto","cover","contain",AB,SB,{size:[tt,et]}],L=()=>[Ag,dh,Mo],V=()=>["","none","full",u,tt,et],j=()=>["",Et,dh,Mo],ae=()=>["solid","dashed","dotted","double"],he=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],be=()=>[Et,Ag,HS,GS],Le=()=>["","none",b,tt,et],Xe=()=>["none",Et,tt,et],it=()=>["none",Et,tt,et],ut=()=>[Et,tt,et],Oe=()=>[kl,"full",...F()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Xn],breakpoint:[Xn],color:[mB],container:[Xn],"drop-shadow":[Xn],ease:["in","out","in-out"],font:[xB],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Xn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Xn],shadow:[Xn],spacing:["px",Et],text:[Xn],"text-shadow":[Xn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",kl,et,tt,v]}
vendor: 12,854 bytes, line 50
50],container:["container"],columns:[{columns:[Et,et,tt,o]}],"break-after":[{"break-after":D()}],"break-before":[{"break-before":D()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:R()}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:U()}],"inset-x":[{"inset-x":U()}],"inset-y":[{"inset-y":U()}],start:[{start:U()}],end:[{end:U()}],top:[{top:U()}],right:[{right:U()}],bottom:[{bottom:U()}],left:[{left:U()}],visibility:["visible","invisible","collapse"],z:[{z:[za,"auto",tt,et]}],basis:[{basis:[kl,"full","auto",o,...F()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Et,kl,"auto","initial","none",et]}],grow:[{grow:["",Et,tt,et]}],shrink:[{shrink:["",Et,tt,et]}],order:[{order:[za,"first","last","none",tt,et]}],"grid-cols":[{"grid-cols":k()}],"col-start-end":[{col:q()}],"col-start":[{"col-start":Q()}],"col-end":[{"col-end":Q()}],"grid-rows":[{"grid-rows":k()}],"row-start-end":[{row:q()}],"row-start":[{"row-start":Q()}],"row-end":[{"row-end":Q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ie()}],"auto-rows":[{"auto-rows":ie()}],gap:[{gap:F()}],"gap-x":[{"gap-x":F()}],"gap-y":[{"gap-y":F()}],"justify-content":[{justify:[...$(),"normal"]}],"justify-items":[{"justify-items":[...ce(),"normal"]}],"justify-self":[{"justify-self":["auto",...ce()]}],"align-content":[{content:["normal",...$()]}],"align-items":[{items:[...ce(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...ce(),{baseline:["","last"]}]}],"place-content":[{"place-content":$()}],"place-items":[{"place-items":[...ce(),"baseline"]}],"place-self":[{"place-self":["auto",...ce()]}],p:[{p:F()}],px:[{px:F()}],py:[{py:F()}],ps:[{ps:F()}],pe:[{pe:F()}],pt:[{pt:F()}],pr:[{pr:F()}],pb:[{pb:F()}],pl:[{pl:F()}],m:[{m:G()}],mx:[{mx:G()}],my:[{my:G()}],ms:[{ms:G()}],me:[{me:G()}],mt:[{mt:G()}],mr:[{mr:G()}],mb:[{mb:G()}],ml:[{ml:G()}],"space-x":[{"space-x":F()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":F()}],"space-y-reverse":["space-y-reverse"],size:[{size:K()}],w:[{w:[o,"screen",...K()]}],"min-w":[{"min-w":[o,"screen","none",...K()]}],"max-w":[{"max-w":[o,"screen","none","prose",{screen:[a]},...K()]}],h:[{h:["screen","lh",...K()]}],"min-h":[{"min-h":["screen","lh","none",...K()]}],"max-h":[{"max-h":["screen","lh",...K()]}],"font-size":[{text:["base",t,dh,Mo]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[i,tt,Rg]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Ag,et]}],"font-family":[{font:[EB,et,e]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,tt,et]}],"line-clamp":[{"line-clamp":[Et,"none",tt,Rg]}],leading:[{leading:[r,...F()]}],"list-image":[{"list-image":["none",tt,et]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",tt,et]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:X()}],"text-color":[{text:X()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ae(),"wavy"]}],"text-decoration-thickness":[{decoration:[Et,"from-font","auto",tt,Mo]}],"text-decoration-color":[{decoration:X()}],"underline-offset":[{"underline-offset":[Et,"auto",tt,et]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:F()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",tt,et]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",tt,et]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:J()}],"bg-repeat":[{bg:se()}],"bg-size":[{bg:w()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},za,tt,et],radial:["",tt,et],conic:[za,tt,et]},RB,TB]}],"bg-color":[{bg:X()}],"gradient-from-pos":[{from:L()}],"gradient-via-pos":[{via:L()}],"gradient-to-pos":[{to:L()}],"gradient-from":[{from:X()}],"gradient-via":[{via:X()}],"gradient-to":[{to:X()}],rounded:[{rounded:V()}],"rounded-s":[{"rounded-s":V()}],"rounded-e":[{"rounded-e":V()}],"rounded-t":[{"rounded-t":V()}],"rounded-r":[{"rounded-r":V()}],"rounded-b":[{"rounded-b":V()}],"rounded-l":[{"rounded-l":V()}],"rounded-ss":[{"rounded-ss":V()}],"rounded-se":[{"rounded-se":V()}],"rounded-ee":[{"rounded-ee":V()}],"rounded-es":[{"rounded-es":V()}],"rounded-tl":[{"rounded-tl":V()}],"rounded-tr":[{"rounded-tr":V()}],"rounded-br":[{"rounded-br":V()}],"rounded-bl":[{"rounded-bl":V()}],"border-w":[{border:j()}],"border-w-x":[{"border-x":j()}],"border-w-y":[{"border-y":j()}],"border-w-s":[{"border-s":j()}],"border-w-e":[{"border-e":j()}],"border-w-t":[{"border-t":j()}],"border-w-r":[{"border-r":j()}],"border-w-b":[{"border-b":j()}],"border-w-l":[{"border-l":j()}],"divide-x":[{"divide-x":j()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":j()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ae(),"hidden","none"]}],"divide-style":[{divide:[...ae(),"hidden","none"]}],"border-color":[{border:X()}],"border-color-x":[{"border-x":X()}],"border-color-y":[{"border-y":X()}],"border-color-s":[{"border-s":X()}],"border-color-e":[{"border-e":X()}],"border-color-t":[{"border-t":X()}],"border-color-r":[{"border-r":X()}],"border-color-b":[{"border-b":X()}],"border-color-l":[{"border-l":X()}],"divide-color":[{divide:X()}],"outline-style":[{outline:[...ae(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Et,tt,et]}],"outline-w":[{outline:["",Et,dh,Mo]}],"outline-color":[{outline:X()}],shadow:[{shadow:["","none",d,Ed,Td]}],"shadow-color":[{shadow:X()}],"inset-shadow":[{"inset-shadow":["none",f,Ed,Td]}],"inset-shadow-color":[{"inset-shadow":X()}],"ring-w":[{ring:j()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:X()}],"ring-offset-w":[{"ring-offset":[Et,Mo]}],"ring-offset-color":[{"ring-offset":X()}],"inset-ring-w":[{"inset-ring":j()}],"inset-ring-color":[{"inset-ring":X()}],"text-shadow":[{"text-shadow":["none",g,Ed,Td]}],"text-shadow-color":[{"text-shadow":X()}],opacity:[{opacity:[Et,tt,et]}],"mix-blend":[{"mix-blend":[...he(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":he()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Et]}],"mask-image-linear-from-pos":[{"mask-linear-from":be()}],"mask-image-linear-to-pos":[{"mask-linear-to":be()}],"mask-image-linear-from-color":[{"mask-linear-from":X()}],"mask-image-linear-to-color":[{"mask-linear-to":X()}],"mask-image-t-from-pos":[{"mask-t-from":be()}],"mask-image-t-to-pos":[{"mask-t-to":be()}],"mask-image-t-from-color":[{"mask-t-from":X()}],"mask-image-t-to-color":[{"mask-t-to":X()}],"mask-image-r-from-pos":[{"mask-r-from":be()}],"mask-image-r-to-pos":[{"mask-r-to":be()}],"mask-image-r-from-color":[{"mask-r-from":X()}],"mask-image-r-to-color":[{"mask-r-to":X()}],"mask-image-b-from-pos":[{"mask-b-from":be()}],"mask-image-b-to-pos":[{"mask-b-to":be()}],"mask-image-b-from-color":[{"mask-b-from":X()}],"mask-image-b-to-color":[{"mask-b-to":X()}],"mask-image-l-from-pos":[{"mask-l-from":be()}],"mask-image-l-to-pos":[{"mask-l-to":be()}],"mask-image-l-from-color":[{"mask-l-from":X()}],"mask-image-l-to-color":[{"mask-l-to":X()}],"mask-image-x-from-pos":[{"mask-x-from":be()}],"mask-image-x-to-pos":[{"mask-x-to":be()}],"mask-image-x-from-color":[{"mask-x-from":X()}],"mask-image-x-to-color":[{"mask-x-to":X()}],"mask-image-y-from-pos":[{"mask-y-from":be()}],"mask-image-y-to-pos":[{"mask-y-to":be()}],"mask-image-y-from-color":[{"mask-y-from":X()}],"mask-image-y-to-color":[{"mask-y-to":X()}],"mask-image-radial":[{"mask-radial":[tt,et]}],"mask-image-radial-from-pos":[{"mask-radial-from":be()}],"mask-image-radial-to-pos":[{"mask-radial-to":be()}],"mask-image-radial-from-color":[{"mask-radial-from":X()}],"mask-image-radial-to-color":[{"mask-radial-to":X()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":I()}],"mask-image-conic-pos":[{"mask-conic":[Et]}],"mask-image-conic-from-pos":[{"mask-conic-from":be()}],"mask-image-conic-to-pos":[{"mask-conic-to":be()}],"mask-image-conic-from-color":[{"mask-conic-from":X()}],"mask-image-conic-to-color":[{"mask-conic-to":X()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:J()}],"mask-repeat":[{mask:se()}],"mask-size":[{mask:w()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",tt,et]}],filter:[{filter:["","none",tt,et]}],blur:[{blur:Le()}],brightness:[{brightness:[Et,tt,et]}],contrast:[{contrast:[Et,tt,et]}],"drop-shadow":[{"drop-shadow":["","none",m,Ed,Td]}],"drop-shadow-color":[{"drop-shadow":X()}],grayscale:[{grayscale:["",Et,tt,et]}],"hue-rotate":[{"hue-rotate":[Et,tt,et]}],invert:[{invert:["",Et,tt,et]}],saturate:[{saturate:[Et,tt,et]}],sepia:[{sepia:["",Et,tt,et]}],"backdrop-filter":[{"backdrop-filter":["","none",tt,et]}],"backdrop-blur":[{"backdrop-blur":Le()}],"backdrop-brightness":[{"backdrop-brightness":[Et,tt,et]}],"backdrop-contrast":[{"backdrop-contrast":[Et,tt,et]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Et,tt,et]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Et,tt,et]}],"backdrop-invert":[{"backdrop-invert":["",Et,tt,et]}],"backdrop-opacity":[{"backdrop-opacity":[Et,tt,et]}],"backdrop-saturate":[{"backdrop-saturate":[Et,tt,et]}],"backdrop-sepia":[{"backdrop-sepia":["",Et,tt,et]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":F()}],"border-spacing-x":[{"border-spacing-x":F()}],"border-spacing-y":[{"border-spacing-y":F()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",tt,et]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Et,"initial",tt,et]}],ease:[{ease:["linear","initial",E,tt,et]}],delay:[{delay:[Et,tt,et]}],animate:[{animate:["none",A,tt,et]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,tt,et]}],"perspective-origin":[{"perspective-origin":R()}],rotate:[{rotate:Xe()}],"rotate-x":[{"rotate-x":Xe()}],"rotate-y":[{"rotate-y":Xe()}],"rotate-z":[{"rotate-z":Xe()}],scale:[{scale:it()}],"scale-x":[{"scale-x":it()}],"scale-y":[{"scale-y":it()}],"scale-z":[{"scale-z":it()}],"scale-3d":["scale-3d"],skew:[{skew:ut()}],"skew-x":[{"skew-x":ut()}],"skew-y":[{"skew-y":ut()}],transform:[{transform:[tt,et,"","none","gpu","cpu"]}],"transform-origin":[{origin:R()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Oe()}],"translate-x":[{"translate-x":Oe()}],"translate-y":[{"translate-y":Oe()}],"translate-z":[{"translate-z":Oe()}],"translate-none":["translate-none"],accent:[{accent:X()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:X()}
vendor: 6,970 bytes, line 50
50],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",tt,et]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":F()}],"scroll-mx":[{"scroll-mx":F()}],"scroll-my":[{"scroll-my":F()}],"scroll-ms":[{"scroll-ms":F()}],"scroll-me":[{"scroll-me":F()}],"scroll-mt":[{"scroll-mt":F()}],"scroll-mr":[{"scroll-mr":F()}],"scroll-mb":[{"scroll-mb":F()}],"scroll-ml":[{"scroll-ml":F()}],"scroll-p":[{"scroll-p":F()}],"scroll-px":[{"scroll-px":F()}],"scroll-py":[{"scroll-py":F()}],"scroll-ps":[{"scroll-ps":F()}],"scroll-pe":[{"scroll-pe":F()}],"scroll-pt":[{"scroll-pt":F()}],"scroll-pr":[{"scroll-pr":F()}],"scroll-pb":[{"scroll-pb":F()}],"scroll-pl":[{"scroll-pl":F()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",tt,et]}],fill:[{fill:["none",...X()]}],"stroke-w":[{stroke:[Et,dh,Mo,Rg]}],stroke:[{stroke:["none",...X()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},PB=hB(IB);function ia(...n){return PB(rM(n))}function DB({delayDuration:n=0,...e}){return B.jsx(ZN,{"data-loc":"client/src/components/ui/tooltip.tsx:11","data-slot":"tooltip-provider",delayDuration:n,...e})}const WS=n=>typeof n=="boolean"?`${n}`:n===0?"0":n,XS=rM,_M=(n,e)=>t=>{var i;if(e?.variants==null)return XS(n,t?.class,t?.className);const{variants:s,defaultVariants:r}=e,a=Object.keys(s).map(u=>{const d=t?.[u],f=r?.[u];if(d===null)return null;const g=WS(d)||WS(f);return s[u][g]}),o=t&&Object.entries(t).reduce((u,d)=>{let[f,g]=d;return g===void 0||(u[f]=g),u},{}),c=e==null||(i=e.compoundVariants)===null||i===void 0?void 0:i.reduce((u,d)=>{let{class:f,className:g,...m}=d;return Object.entries(m).every(b=>{let[x,v]=b;return Array.isArray(v)?v.includes({...r,...o}[x]):{...r,...o}[x]===v})?[...u,f,g]:u},[]);return XS(n,a,c,t?.class,t?.className)},OB=_M("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-transparent shadow-xs hover:bg-accent dark:bg-transparent dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function ai({className:n,variant:e,size:t,asChild:i=!1,...s}){const r=i?xR:"button";return B.jsx(r,{"data-loc":"client/src/components/ui/button.tsx:52","data-slot":"button",className:ia(OB({variant:e,size:t,className:n})),...s})}function wB({className:n,...e}){return B.jsx("div",{"data-loc":"client/src/components/ui/card.tsx:7","data-slot":"card",className:ia("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",n
vendor: 4,645 bytes, lines 50-114
50),...e})}function FB({className:n,...e}){return B.jsx("div",{"data-loc":"client/src/components/ui/card.tsx:66","data-slot":"card-content",className:ia("px-6",n),...e})}/** 51 * @license lucide-react v0.453.0 - ISC 52 * 53 * This source code is licensed under the ISC license. 54 * See the LICENSE file in the root directory of this source tree. 55 */const LB=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),gM=(...n)=>n.filter((e,t,i)=>!!e&&i.indexOf(e)===t).join(" ");/** 56 * @license lucide-react v0.453.0 - ISC 57 * 58 * This source code is licensed under the ISC license. 59 * See the LICENSE file in the root directory of this source tree. 60 */var NB={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** 61 * @license lucide-react v0.453.0 - ISC 62 * 63 * This source code is licensed under the ISC license. 64 * See the LICENSE file in the root directory of this source tree. 65 */const BB=Y.forwardRef(({color:n="currentColor",size:e=24,strokeWidth:t=2,absoluteStrokeWidth:i,className:s="",children:r,iconNode:a,...o},c)=>Y.createElement("svg",{ref:c,...NB,width:e,height:e,stroke:n,strokeWidth:i?Number(t)*24/Number(e):t,className:gM("lucide",s),...o},[...a.map(([u,d])=>Y.createElement(u,d)),...Array.isArray(r)?r:[r]]));/** 66 * @license lucide-react v0.453.0 - ISC 67 * 68 * This source code is licensed under the ISC license. 69 * See the LICENSE file in the root directory of this source tree. 70 */const fi=(n,e)=>{const t=Y.forwardRef(({className:i,...s},r)=>Y.createElement(BB,{ref:r,iconNode:e,className:gM(`lucide-${LB(n)}`,i),...s}));return t.displayName=`${n}`,t};/** 71 * @license lucide-react v0.453.0 - ISC 72 * 73 * This source code is licensed under the ISC license. 74 * See the LICENSE file in the root directory of this source tree. 75 */const mM=fi("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** 76 * @license lucide-react v0.453.0 - ISC 77 * 78 * This source code is licensed under the ISC license. 79 * See the LICENSE file in the root directory of this source tree. 80 */const UB=fi("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** 81 * @license lucide-react v0.453.0 - ISC 82 * 83 * This source code is licensed under the ISC license. 84 * See the LICENSE file in the root directory of this source tree. 85 */const kB=fi("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** 86 * @license lucide-react v0.453.0 - ISC 87 * 88 * This source code is licensed under the ISC license. 89 * See the LICENSE file in the root directory of this source tree. 90 */const VB=fi("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/** 91 * @license lucide-react v0.453.0 - ISC 92 * 93 * This source code is licensed under the ISC license. 94 * See the LICENSE file in the root directory of this source tree. 95 */const zB=fi("Headphones",[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",key:"1xhozi"}]]);/** 96 * @license lucide-react v0.453.0 - ISC 97 * 98 * This source code is licensed under the ISC license. 99 * See the LICENSE file in the root directory of this source tree. 100 */const bM=fi("Heart",[["path",{d:"M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",key:"c3ymky"}]]);/** 101 * @license lucide-react v0.453.0 - ISC 102 * 103 * This source code is licensed under the ISC license. 104 * See the LICENSE file in the root directory of this source tree. 105 */const GB=fi("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);/** 106 * @license lucide-react v0.453.0 - ISC 107 * 108 * This source code is licensed under the ISC license. 109 * See the LICENSE file in the root directory of this source tree. 110 */const HB=fi("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/** 111 * @license lucide-react v0.453.0 - ISC 112 * 113 * This source code is licensed under the ISC license. 114 * See the LICENSE file in the root directory of this source tree.
115 */const WB=fi("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** 116 * @license lucide-react v0.453.0 - ISC 117 * 118 * This source code is licensed under the ISC license. 119 * See the LICENSE file in the root directory of this source tree. 120 */const pb=fi("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** 121 * @license lucide-react v0.453.0 - ISC 122 * 123 * This source code is licensed under the ISC license. 124 * See the LICENSE file in the root directory of this source tree. 125 */const Yh=fi("LockKeyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]);/** 126 * @license lucide-react v0.453.0 - ISC 127 * 128 * This source code is licensed under the ISC license. 129 * See the LICENSE file in the root directory of this source tree. 130 */const XB=fi("MapPinned",[["path",{d:"M18 8c0 3.613-3.869 7.429-5.393 8.795a1 1 0 0 1-1.214 0C9.87 15.429 6 11.613 6 8a6 6 0 0 1 12 0",key:"11u0oz"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["path",{d:"M8.714 14h-3.71a1 1 0 0 0-.948.683l-2.004 6A1 1 0 0 0 3 22h18a1 1 0 0 0 .948-1.316l-2-6a1 1 0 0 0-.949-.684h-3.712",key:"q8zwxj"}]]);/** 131 * @license lucide-react v0.453.0 - ISC 132 * 133 * This source code is licensed under the ISC license. 134 * See the LICENSE file in the root directory of this source tree. 135 */const yM=fi("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/** 136 * @license lucide-react v0.453.0 - ISC 137 * 138 * This source code is licensed under the ISC license. 139 * See the LICENSE file in the root directory of this source tree. 140 */const jB=fi("Move3d",[["path",{d:"M5 3v16h16",key:"1mqmf9"}],["path",{d:"m5 19 6-6",key:"jh6hbb"}],["path",{d:"m2 6 3-3 3 3",key:"tkyvxa"}],["path",{d:"m18 16 3 3-3 3",key:"1d4glt"}]]);/** 141 * @license lucide-react v0.453.0 - ISC 142 * 143 * This source code is licensed under the ISC license. 144 * See the LICENSE file in the root directory of this source tree. 145 */const YB=fi("Radio",[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]]);/** 146 * @license lucide-react v0.453.0 - ISC 147 * 148 * This source code is licensed under the ISC license. 149 * See the LICENSE file in the root directory of this source tree. 150 */const KB=fi("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/** 151 * @license lucide-react v0.453.0 - ISC 152 * 153 * This source code is licensed under the ISC license. 154 * See the LICENSE file in the root directory of this source tree. 155 */const qB=fi("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/** 156 * @license lucide-react v0.453.0 - ISC 157 * 158 * This source code is licensed under the ISC license. 159 * See the LICENSE file in the root directory of this source tree. 160 */const vM=fi("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);/** 161 * @license lucide-react v0.453.0 - ISC 162 * 163 * This source code is licensed under the ISC license. 164 * See the LICENSE file in the root directory of this source tree. 165 */const ZB=fi("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** 166 * @license lucide-react v0.453.0 - ISC 167 * 168 * This source code is licensed under the ISC license. 169 * See the LICENSE file in the root directory of this source tree. 170 */const $B=fi("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/** 171 * @license lucide-react v0.453.0 - ISC 172 * 173 * This source code is licensed under the ISC license. 174 * See the LICENSE file in the root directory of this source tree. 175 */const QB=fi("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** 176 * @license lucide-react v0.453.0 - ISC 177 * 178 * This source code is licensed under the ISC license. 179 * See the LICENSE file in the root directory of this source tree. 180 */const xM=fi("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** 181 * @license lucide-react v0.453.0 - ISC 182 * 183 * This source code is licensed under the ISC license. 184 * See the LICENSE file in the root directory of this source tree. 185 */const SM=fi("Volume2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);/** 186 * @license lucide-react v0.453.0 - ISC 187 * 188 * This source code is licensed under the ISC license. 189 * See the LICENSE file in the root directory of this source tree. 190 */const JB=fi("WandSparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);/** 191 * @license lucide-react v0.453.0 - ISC 192 * 193 * This source code is licensed under the ISC license. 194 * See the LICENSE file in the root directory of this source tree. 195 */const TM=fi("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}
195],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function e2(n,e){if(n instanceof RegExp)return{keys:!1,pattern:n};var t,i,s,r,a=[],o="",c=n.split("/");for(c[0]||c.shift();s=c.shift();)t=s[0],t==="*"?(a.push(t),o+=s[1]==="?"?"(?:/(.*))?":"/(.*)"):t===":"?(i=s.indexOf("?",1),r=s.indexOf(".",1),a.push(s.substring(1,~i?i:~r?r:s.length)),o+=~i&&!~r?"(?:/([^/]+?))?":"/([^/]+?)",~r&&(o+=(~i?"?":"")+"\\"+s.substring(r))):o+="/"+s;return{keys:a,pattern:new RegExp("^"+o+(e?"(?=$|/)":"/?$"),"i")}}var Mg={exports:{}},Cg={};/** 196 * @license React 197 * use-sync-external-store-shim.production.js 198 * 199 * Copyright (c) Meta Platforms, Inc. and affiliates. 200 * 201 * This source code is licensed under the MIT license found in the 202 * LICENSE file in the root directory of this source tree. 203 */var jS;function t2(){if(jS)return Cg;jS=1;var n=gf();function e(f,g){return f===g&&(f!==0||1/f===1/g)||f!==f&&g!==g}var t=typeof Object.is=="function"?Object.is:e,i=n.useState,s=n.useEffect,r=n.useLayoutEffect,a=n.useDebugValue;function o(f,g){var m=g(),b=i({inst:{value:m,getSnapshot:g}}),x=b[0].inst,v=b[1];return r(function(){x.value=m,x.getSnapshot=g,c(x)&&v({inst:x})},[f,m,g]),s(function(){return c(x)&&v({inst:x}),f(function(){c(x)&&v({inst:x})})},[f]),a(m),m}function c(f){var g=f.getSnapshot;f=f.value;try{var m=g();return!t(f,m)}catch{return!0}}function u(f,g){return g()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:o;return Cg.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:d,Cg}var YS;function i2(){return YS||(YS=1,Mg.exports=t2()),Mg.exports}var s2=i2();const r2=Jm.useInsertionEffect,n2=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",a2=n2?Y.useLayoutEffect:Y.useEffect,o2=r2||a2,EM=n=>{const e=Y.useRef([n,(...t)=>e[0](...t)]).current;return o2(()=>{e[0]=n}),e[1]},l2="popstate",_b="pushState",gb="replaceState",c2="hashchange",KS=[l2,_b,gb,c2],h2=n=>{for(const e of KS)addEventListener(e,n);return()=>{for(const e of KS)removeEventListener(e,n)}},AM=(n,e)=>s2.useSyncExternalStore(h2,n,e),u2=()=>location.search,d2=({ssrSearch:n=""}={})=>AM(u2,()=>n),qS=()=>location.pathname,f2=({ssrPath:n}={})=>AM(qS,n?()=>n:qS),p2=(n,{replace:e=!1,state:t=null}={})=>history[e?gb:_b](t,"",n),_2=(n={})=>[f2(n),p2],ZS=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[ZS]>"u"){for(const n of[_b,gb]){const e=history[n];history[n]=function(){const t=e.apply(this,arguments),i=new Event(n);return i.arguments=arguments,dispatchEvent(i),t}}Object.defineProperty(window,ZS,{value:!0})}const g2=(n,e)=>e.toLowerCase().indexOf(n.toLowerCase())?"~"+e:e.slice(n.length)||"/",RM=(n="")=>n==="/"?"":n,m2=(n,e)=>n[0]==="~"?n.slice(1):RM(e)+n,b2=(n="",e)=>g2($S(RM(n)),$S(e)),$S=n=>{try{return decodeURI(n)}catch{return n}},MM={hook:_2,searchHook:d2,parser:e2,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:n=>n},CM=Y.createContext(MM),Kh=()=>Y.useContext(CM),IM={},PM=Y.createContext(IM),y2=()=>Y.useContext(PM),Df=n=>{const[e,t]=n.hook(n);return[b2(n.base,e),EM((i,s)=>t(m2(i,n.base),s))]},mb=()=>Df(Kh()),DM=(n,e,t,i)=>{const{pattern:s,keys:r}=e instanceof RegExp?{keys:!1,pattern:e}:n(e||"*",i),a=s.exec(t)||[],[o,...c]=a;return o!==void 0?[!0,(()=>{const u=r!==!1?Object.fromEntries(r.map((f,g)=>[f,c[g]])):a.groups;let d={...c};return u&&Object.assign(d,u),d})(),...i?[o]:[]]:[!1,null]},v2=({children:n,...e})=>{const t=Kh(),i=e.hook?MM:t;let s=i;const[r,a]=e.ssrPath?.split("?")??[];a&&(e.ssrSearch=a,e.ssrPath=r),e.hrefs=e.hrefs??e.hook?.hrefs;let o=Y.useRef({}),c=o.current,u=c;for(let d in i){const f=d==="base"?i[d]+(e[d]||""):e[d]||i[d];c===u&&f!==u[d]&&(o.current=u={...u}),u[d]=f,(f!==i[d]||f!==s[d])&&(s=u)}return Y.createElement(CM.Provider,{value:s,children:n})},QS=({children:n,component:e},t)=>e?Y.createElement(e,{params:t}):typeof n=="function"?n(t):n,x2=n=>{let e=Y.useRef(IM);const t=e.current;return e.current=Object.keys(n).length!==Object.keys(t).length||Object.entries(n).some(([i,s])=>s!==t[i])?n:t},Vl=({path:n,nest:e,match:t,...i})=>{const s=Kh(),[r]=Df(s),[a,o,c]=t??DM(s.parser,n,r,e),u=x2({...y2(),...o});if(!a)return null;const d=c?Y.createElement(v2,{base:c},QS(i,u)):QS(i,u);return Y.createElement(PM.Provider,{value:u,children:d})},Qa=Y.forwardRef((n,e)=>{const t=Kh(),[i,s]=Df(t),{to:r="",href:a=r,onClick:o,asChild:c,children:u,className:d,replace:f,state:g,...m}=n,b=EM(v=>{v.ctrlKey||v.metaKey||v.altKey||v.shiftKey||v.button!==0||(o?.(v),v.defaultPrevented||(v.preventDefault(),s(a,n)))}),x=t.hrefs(a[0]==="~"?a.slice(1):t.base+a,t);return c&&Y.isValidElement(u)?Y.cloneElement(u,{onClick:b,href:x}):Y.createElement("a",{...m,onClick:b,href:x,className:d?.call?d(i===a):d,children:u,ref:e})}),xm=n=>Array.isArray(n)?n.flatMap(e=>xm(e&&e.type===Y.Fragment?e.props.children:e)):[n],S2=({children:n,location:e})=>{const t=Kh(),[i]=Df(t);typeof window<"u"&&(window.__WOUTER_ROUTES__||(window.__WOUTER_ROUTES__=[]),xm(n).forEac
203h(r=>{if(Y.isValidElement(r)&&r.props.path){const a=r.props.path;window.__WOUTER_ROUTES__.includes(a)||window.__WOUTER_ROUTES__.push(a)}}));for(const s of xm(n)){let r=0;if(Y.isValidElement(s)&&(r=DM(t.parser,s.props.path,e||i,s.props.nest))[0])return Y.cloneElement(s,{match:r})}return null};function JS(){const[,n]=mb(),e=()=>{n("/")};return B.jsx("div",{"data-loc":"client/src/pages/NotFound.tsx:14",className:"min-h-screen w-full flex items-center justify-center bg-gradient-to-br from-slate-50 to-slate-100",children:B.jsx(wB,{"data-loc":"client/src/pages/NotFound.tsx:15",className:"w-full max-w-lg mx-4 shadow-lg border-0 bg-white/80 backdrop-blur-sm",children:B.jsxs(FB,{"data-loc":"client/src/pages/NotFound.tsx:16",className:"pt-8 pb-8 text-center",children:[B.jsx("div",{"data-loc":"client/src/pages/NotFound.tsx:17",className:"flex justify-center mb-6",children:B.jsxs("div",{"data-loc":"client/src/pages/NotFound.tsx:18",className:"relative",children:[B.jsx("div",{"data-loc":"client/src/pages/NotFound.tsx:19",className:"absolute inset-0 bg-red-100 rounded-full animate-pulse"}),B.jsx(UB,{"data-loc":"client/src/pages/NotFound.tsx:20",className:"relative h-16 w-16 text-red-500"})]})}),B.jsx("h1",{"data-loc":"client/src/pages/NotFound.tsx:24",className:"text-4xl font-bold text-slate-900 mb-2",children:"404"}),B.jsx("h2",{"data-loc":"client/src/pages/NotFound.tsx:26",className:"text-xl font-semibold text-slate-700 mb-4",children:"Page Not Found"}),B.jsxs("p",{"data-loc":"client/src/pages/NotFound.tsx:30",className:"text-slate-600 mb-8 leading-relaxed",children:["Sorry, the page you are looking for doesn't exist.",B.jsx("br",{"data-loc":"client/src/pages/NotFound.tsx:32"}),"It may have been moved or deleted."]}),B.jsx("div",{"data-loc":"client/src/pages/NotFound.tsx:36",id:"not-found-button-group",className:"flex flex-col sm:flex-row gap-3 justify-center",children:B.jsxs(ai,{"data-loc":"client/src/pages/NotFound.tsx:40",onClick:e,className:"bg-blue-600 hover:bg-blue-700 text-white px-6 py-2.5 rounded-lg transition-all duration-200 shadow-md hover:shadow-lg",children:[B.jsx(GB,{"data-loc":"client/src/pages/NotFound.tsx:44",className:"w-4 h-4 mr-2"}),"Go Home"]})})]})})})}class T2 extends Y.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}render(){return this.state.hasError?B.jsx("div",{"data-loc":"client/src/components/ErrorBoundary.tsx:27",className:"flex items-center justify-center min-h-screen p-8 bg-background",children:B.jsxs("div",{"data-loc":"client/src/components/ErrorBoundary.tsx:28",className:"flex flex-col items-center w-full max-w-2xl p-8",children:[B.jsx(xM,{"data-loc":"client/src/components/ErrorBoundary.tsx:29",size:48,className:"text-destructive mb-6 flex-shrink-0"}),B.jsx("h2",{"data-loc":"client/src/components/ErrorBoundary.tsx:34",className:"text-xl mb-4",children:"An unexpected error occurred."}),B.jsx("div",{"data-loc":"client/src/components/ErrorBoundary.tsx:36",className:"p-4 w-full rounded bg-muted overflow-auto mb-6",children:B.jsx("pre",{"data-loc":"client/src/components/ErrorBoundary.tsx:37",className:"text-sm text-muted-foreground whitespace-break-spaces",children:this.state.error?.stack})}),B.jsxs("button",{"data-loc":"client/src/components/ErrorBoundary.tsx:42",onClick:()=>window.location.reload(),className:ia("flex items-center gap-2 px-4 py-2 rounded-lg","bg-primary text-primary-foreground","hover:opacity-90 cursor-pointer"),children:[B.jsx(KB,{"data-loc":"client/src/components/ErrorBoundary.tsx:50",size:16}),"Reload Page"]})]})}):this.props.children}}const E2=Y.createContext(void 0);function A2({children:n,defaultTheme:e="light",switchable:t=!1}){const[i,s]=Y.useState(()=>t&&localStorage.getItem("theme")||e);Y.useEffect(()=>{const a=document.documentElement;i==="dark"?a.classList.add("dark"):a.classList.remove("dark"),t&&localStorage.setItem("theme",i)},[i,t]);const r=t?()=>{s(a=>a==="light"?"dark":"light")}:void 0;return B.jsx(E2.Provider,{"data-loc":"client/src/contexts/ThemeContext.tsx:52",value:{theme:i,toggleTheme:r,switchable:t},children:n})}const R2=_M("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function OM({className:n,variant:e,asChild:t=!1,...i}){const s=t?xR:"span";return B.jsx(s,{"data-loc":"client/src/components/ui/badge.tsx:38","data-slot":"badge",className:ia(R2({variant:e}),n),...i})}const M2=Y.createContext({isComposing:()=>!1,setComposing:()=>{},justEndedComposing:()=>!1,markCompositionEnd:()=>{}}
203),C2=()=>Y.useContext(M2);function Ad(n){const e=Y.useRef(n);e.current=n;const t=Y.useRef(null);return t.current||(t.current=function(...i){return e.current.apply(this,i)}),t.current}function I2(n={}){const{onKeyDown:e,onCompositionStart:t,onCompositionEnd:i}=n,s=Y.useRef(!1),r=Y.useRef(null),a=Y.useRef(null),o=Ad(f=>{r.current&&(clearTimeout(r.current),r.current=null),a.current&&(clearTimeout(a.current),a.current=null),s.current=!0,t?.(f)}),c=Ad(f=>{r.current=setTimeout(()=>{a.current=setTimeout(()=>{s.current=!1})}),i?.(f)}),u=Ad(f=>{if(s.current&&(f.key==="Escape"||f.key==="Enter"&&!f.shiftKey)){f.stopPropagation();return}e?.(f)}),d=Ad(()=>s.current);return{onCompositionStart:o,onCompositionEnd:c,onKeyDown:u,isComposing:d}}function Yl({className:n,type:e,onKeyDown:t,onCompositionStart:i,onCompositionEnd:s,...r}){const a=C2(),{onCompositionStart:o,onCompositionEnd:c,onKeyDown:u}=I2({onKeyDown:d=>{const f=d.nativeEvent.isComposing||a.justEndedComposing();d.key==="Enter"&&f||t?.(d)},onCompositionStart:d=>{a.setComposing(!0),i?.(d)},onCompositionEnd:d=>{a.markCompositionEnd(),setTimeout(()=>{a.setComposing(!1)},100),s?.(d)}});return B.jsx("input",{"data-loc":"client/src/components/ui/input.tsx:53",type:e,"data-slot":"input",className:ia("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",n),onCompositionStart:o,onCompositionEnd:c,onKeyDown:u,...r})}function wM(n,[e,t]){return Math.min(t,Math.max(e,n))}var P2=Y.createContext(void 0);function D2(n){const e=Y.useContext(P2);return n||e||"ltr"}function O2(n){const e=Y.useRef({value:n,previous:n});return Y.useMemo(()=>(e.current.value!==n&&(e.current.previous=e.current.value,e.current.value=n),e.current.previous),[n])}function w2(n){const e=n+"CollectionProvider",[t,i]=Tf(e),[s,r]=t(e,{collectionRef:{current:null},itemMap:new Map}),a=x=>{const{scope:v,children:E}=x,A=Ue.useRef(null),D=Ue.useRef(new Map).current;return B.jsx(s,{scope:v,itemMap:D,collectionRef:A,children:E})};a.displayName=e;const o=n+"CollectionSlot",c=Wd(o),u=Ue.forwardRef((x,v)=>{const{scope:E,children:A}=x,D=r(o,E),I=Ms(v,D.collectionRef);return B.jsx(c,{ref:I,children:A})});u.displayName=o;const d=n+"CollectionItemSlot",f="data-radix-collection-item",g=Wd(d),m=Ue.forwardRef((x,v)=>{const{scope:E,children:A,...D}=x,I=Ue.useRef(null),R=Ms(v,I),C=r(d,E);return Ue.useEffect(()=>(C.itemMap.set(I,{ref:I,...D}),()=>void C.itemMap.delete(I))),B.jsx(g,{[f]:"",ref:R,children:A})});m.displayName=d;function b(x){const v=r(n+"CollectionConsumer",x);return Ue.useCallback(()=>{const A=v.collectionRef.current;if(!A)return[];const D=Array.from(A.querySelectorAll(`[${f}]`));return Array.from(v.itemMap.values()).sort((C,M)=>D.indexOf(C.ref.current)-D.indexOf(M.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:a,Slot:u,ItemSlot:m},b,i]}var FM=["PageUp","PageDown"],LM=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],NM={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},pc="Slider",[Sm,F2,L2]=w2(pc),[BM]=Tf(pc,[L2]),[N2,Of]=BM(pc),UM=Y.forwardRef((n,e)=>{const{name:t,min:i=0,max:s=100,step:r=1,orientation:a="horizontal",disabled:o=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[i],value:d,onValueChange:f=()=>{},onValueCommit:g=()=>{},inverted:m=!1,form:b,...x}=n,v=Y.useRef(new Set),E=Y.useRef(0),D=a==="horizontal"?B2:U2,[I=[],R]=MN({prop:d,defaultProp:u,onChange:q=>{[...v.current][E.current]?.focus(),f(q)}}),C=Y.useRef(I);function M(q){const Q=H2(I,q);k(q,Q)}function F(q){k(q,E.current)}function U(){const q=C.current[E.current];I[E.current]!==q&&g(I)}function k(q,Q,{commit:ie}={commit:!1}){const $=Y2(r),ce=K2(Math.round((q-i)/r)*r+i,$),G=wM(ce,[i,s]);R((K=[])=>{const X=z2(K,G,Q);if(j2(X,c*r)){E.current=X.indexOf(G);const J=String(X)!==String(K);return J&&ie&&g(X),J?X:K}else return K})}return B.jsx(N2,{scope:n.__scopeSlider,name:t,disabled:o,min:i,max:s,valueIndexToChangeRef:E,thumbs:v.current,values:I,orientation:a,form:b,children:B.jsx(Sm.Provider,{scope:n.__scopeSlider,children:B.jsx(Sm.Slot,{scope:n.__scopeSlider,children:B.jsx(D,{"aria-disabled":o,"data-disabled":o?"":void 0,...x,ref:e,onPointerDown:Ts(x.onPointerDown,()=>{o||(C.current=I)}),min:i,max:s,inverted:m,onSlideStart:o?void 0:M,onSlideMove:o?void 0:F,onSlideEnd:o?void 0:U,onHomeKeyDown:()=>!o&&k(i,0,{commit:!0}),onEndKeyDown:()=>!o&&k(s,I.length-1,{commit:!0}),onStepKeyDown:({event:q,direction:Q})=>{if(!o){const ce=FM.includes(q.key)||q.shiftKey&&LM.includes(q.key)?10:1,G=E.current,K=I[G],X=r*ce*Q;k(K+X,G,{commit:!0})}}})})})})});UM.displayName=pc;var[kM,VM]=BM(pc,{startEdge:"left",endEdge:"right",size:"width",direction:1}),B2=Y.forwardRef((n,e)=>{const{min:t,max:i,dir:s,inverted:r,onSlideStart:a,onSlideMove:o,onSlideEnd:c,onStepKeyDown:u,...d}=n,[f,g]=Y.useState(null),m=Ms(e,D=>
203g(D)),b=Y.useRef(void 0),x=D2(s),v=x==="ltr",E=v&&!r||!v&&r;function A(D){const I=b.current||f.getBoundingClientRect(),R=[0,I.width],M=bb(R,E?[t,i]:[i,t]);return b.current=I,M(D-I.left)}return B.jsx(kM,{scope:n.__scopeSlider,startEdge:E?"left":"right",endEdge:E?"right":"left",direction:E?1:-1,size:"width",children:B.jsx(zM,{dir:x,"data-orientation":"horizontal",...d,ref:m,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:D=>{const I=A(D.clientX);a?.(I)},onSlideMove:D=>{const I=A(D.clientX);o?.(I)},onSlideEnd:()=>{b.current=void 0,c?.()},onStepKeyDown:D=>{const R=NM[E?"from-left":"from-right"].includes(D.key);u?.({event:D,direction:R?-1:1})}})})}),U2=Y.forwardRef((n,e)=>{const{min:t,max:i,inverted:s,onSlideStart:r,onSlideMove:a,onSlideEnd:o,onStepKeyDown:c,...u}=n,d=Y.useRef(null),f=Ms(e,d),g=Y.useRef(void 0),m=!s;function b(x){const v=g.current||d.current.getBoundingClientRect(),E=[0,v.height],D=bb(E,m?[i,t]:[t,i]);return g.current=v,D(x-v.top)}return B.jsx(kM,{scope:n.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:B.jsx(zM,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:x=>{const v=b(x.clientY);r?.(v)},onSlideMove:x=>{const v=b(x.clientY);a?.(v)},onSlideEnd:()=>{g.current=void 0,o?.()},onStepKeyDown:x=>{const E=NM[m?"from-bottom":"from-top"].includes(x.key);c?.({event:x,direction:E?-1:1})}})})}),zM=Y.forwardRef((n,e)=>{const{__scopeSlider:t,onSlideStart:i,onSlideMove:s,onSlideEnd:r,onHomeKeyDown:a,onEndKeyDown:o,onStepKeyDown:c,...u}=n,d=Of(pc,t);return B.jsx(Fr.span,{...u,ref:e,onKeyDown:Ts(n.onKeyDown,f=>{f.key==="Home"?(a(f),f.preventDefault()):f.key==="End"?(o(f),f.preventDefault()):FM.concat(LM).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:Ts(n.onPointerDown,f=>{const g=f.target;g.setPointerCapture(f.pointerId),f.preventDefault(),d.thumbs.has(g)?g.focus():i(f)}),onPointerMove:Ts(n.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&s(f)}),onPointerUp:Ts(n.onPointerUp,f=>{const g=f.target;g.hasPointerCapture(f.pointerId)&&(g.releasePointerCapture(f.pointerId),r(f))})})}),GM="SliderTrack",HM=Y.forwardRef((n,e)=>{const{__scopeSlider:t,...i}=n,s=Of(GM,t);return B.jsx(Fr.span,{"data-disabled":s.disabled?"":void 0,"data-orientation":s.orientation,...i,ref:e})});HM.displayName=GM;var Tm="SliderRange",WM=Y.forwardRef((n,e)=>{const{__scopeSlider:t,...i}=n,s=Of(Tm,t),r=VM(Tm,t),a=Y.useRef(null),o=Ms(e,a),c=s.values.length,u=s.values.map(g=>YM(g,s.min,s.max)),d=c>1?Math.min(...u):0,f=100-Math.max(...u);return B.jsx(Fr.span,{"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,...i,ref:o,style:{...n.style,[r.startEdge]:d+"%",[r.endEdge]:f+"%"}})});WM.displayName=Tm;var Em="SliderThumb",XM=Y.forwardRef((n,e)=>{const t=F2(n.__scopeSlider),[i,s]=Y.useState(null),r=Ms(e,o=>s(o)),a=Y.useMemo(()=>i?t().findIndex(o=>o.ref.current===i):-1,[t,i]);return B.jsx(k2,{...n,ref:r,index:a})}),k2=Y.forwardRef((n,e)=>{const{__scopeSlider:t,index:i,name:s,...r}=n,a=Of(Em,t),o=VM(Em,t),[c,u]=Y.useState(null),d=Ms(e,A=>u(A)),f=c?a.form||!!c.closest("form"):!0,g=UR(c),m=a.values[i],b=m===void 0?0:YM(m,a.min,a.max),x=G2(i,a.values.length),v=g?.[o.size],E=v?W2(v,b,o.direction):0;return Y.useEffect(()=>{if(c)return a.thumbs.add(c),()=>{a.thumbs.delete(c)}},[c,a.thumbs]),B.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[o.startEdge]:`calc(${b}% + ${E}px)`},children:[B.jsx(Sm.ItemSlot,{scope:n.__scopeSlider,children:B.jsx(Fr.span,{role:"slider","aria-label":n["aria-label"]||x,"aria-valuemin":a.min,"aria-valuenow":m,"aria-valuemax":a.max,"aria-orientation":a.orientation,"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,tabIndex:a.disabled?void 0:0,...r,ref:d,style:m===void 0?{display:"none"}:n.style,onFocus:Ts(n.onFocus,()=>{a.valueIndexToChangeRef.current=i})})}),f&&B.jsx(jM,{name:s??(a.name?a.name+(a.values.length>1?"[]":""):void 0),form:a.form,value:m},i)]})});XM.displayName=Em;var V2="RadioBubbleInput",jM=Y.forwardRef(({__scopeSlider:n,value:e,...t},i)=>{const s=Y.useRef(null),r=Ms(s,i),a=O2(e);return Y.useEffect(()=>{const o=s.current;if(!o)return;const c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(a!==e&&d){const f=new Event("input",{bubbles:!0});d.call(o,e),o.dispatchEvent(f)}},[a,e]),B.jsx(Fr.input,{style:{display:"none"},...t,ref:r,defaultValue:e})});jM.displayName=V2;function z2(n=[],e,t){const i=[...n];return i[t]=e,i.sort((s,r)=>s-r)}function YM(n,e,t){const r=100/(t-e)*(n-e);return wM(r,[0,100])}function G2(n,e){return e>2?`Value ${n+1} of ${e}`:e===2?["Minimum","Maximum"][n]:void 0}function H2(n,e){if(n.length===1)return 0;const t=n.map(s=>Math.abs(s-e)),i=Math.min(...t);return t.indexOf(i)}function W2(n,e,t){const i=n/2,r=bb([0,50],[0,i]);return(i-r(e)*t)*t}function X2(n){return n.slice(0,-1).map((e,t)=>n[t+1]-e)}function j2(n,e){if(e>0){const t=X2(n);return Math.min(...t)>=e}return!0}function bb(n,e){return t=>{if(n[0]===n[1]||e[0]===e[1])return e[0];const i=(e[1]-e[0])/(n[1]-n[0]);return e[0]+i*(t-n[0])}}function Y2(n){return(String(n).split(".")[1]||"").length}function K2(n,e){const t=Math.pow(10,e);return Math.round(n*t)/t}var q2=UM,Z2=HM,$2=WM,Q2=XM;function Ig({className:n,defaultValue:e,value:t,min:i=0,max:s=100,...r}){const a=Y.useMemo(()=>Array.isArray(t)?t:Array.isArray(e)?e:[i,s],[t,e,i,s]);return B.jsxs(q2,{"data-loc":"client/src/components/ui/slider.tsx:25","data-slot":"slider",defaultValue:e,value:t,min:i,max:s,className:ia("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",n),...r,children:[B.jsx(Z2,{"data-loc":"client/src/components/ui/slider.tsx:37","data-slot":"slider-track",className:ia("bg-muted relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"),children:B.jsx($2,{"data-loc":"client/src/components/ui/slider.tsx:43","data-slot":"slider-range",className:ia("bg-primary absolute data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")})}),Array.from({length:a.length},(o,c)=>B.jsx(Q2,{"data-loc":"client/src/components/ui/slider.tsx:51","data-slot":"slider-thumb",className:"border-primary ring-ring/50 block size-4 shrink-0 rounded-full border bg-white shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"},c))]})}const J2=typeof WeakRef<"u";class eU{constructor(e,t=!1,i,s){this.initialize(e,t,i,s)}initialize(e,t=!1,i,s){return this.mask=e,this.skipNextObservers=t,this.target=i,this.currentTarget=s,this}}class tU{constructor(e,t,i=null){this.callback=e,this.mask=t,this.scope=i,this._willBeUnregistered=!1,this.unregisterOnNextCall=!1,this._remove=null}remove(e=!1){this._remove&&this._remove(e)}}class le{static FromPromise(e,t){const i=new le;return e.then(s=>{i.notifyObservers(s)}).catch(s=>{if(t)t.notifyObservers(s);else throw s}),i}get observers(){return this._observers}constructor(e,t=!1){this.notifyIfTriggered=t,this._observers=new Array,this._numObserversMarkedAsDeleted=0,this._hasNotified=!1,this._eventState=new eU(0),e&&(this._onObserverAdded=e)}add(e,t=-1,i=!1,s=null,r=!1){if(!e)return null;const a=new tU(e,t,s);a.unregisterOnNextCall=r,i?this._observers.unshift(a):this._observers.push(a),this._onObserverAdded&&this._onObserverAdded(a),this._hasNotified&&this.notifyIfTriggered&&this._lastNotifiedValue!==void 0&&this.notifyObserver(a,this._lastNotifiedValue);const o=J2?new WeakRef(this):{deref:()=>this};return a._remove=(c=!1)=>{const u=o.deref();u&&(c?u.remove(a):u._remove(a))},a}addOnce(e){return this.add(e,void 0,void 0,void 0,!0)}remove(e){return e?(e._remove=null,this._observers.indexOf(e)!==-1?(this._deferUnregister(e),!0):!1):!1}removeCallback(e,t){for(let i=0;i<this._observers.length;i++){const s=this._observers[i];if(!s._willBeUnregistered&&s.callback===e&&(!t||t===s.scope))return this._deferUnregister(s),!0}return!1}_deferUnregister(e){e._willBeUnregistered||(this._numObserversMarkedAsDeleted++,e.unregisterOnNextCall=!1,e._willBeUnregistered=!0,setTimeout(()=>{this._remove(e)},0))}_remove(e,t=!0){if(!e)return!1;const i=this._observers.indexOf(e);return i!==-1?(t&&this._numObserversMarkedAsDeleted--,this._observers.splice(i,1),!0):!1}makeObserverTopPriority(e){this._remove(e,!1),this._observers.unshift(e)}makeObserverBottomPriority(e){this._remove(e,!1),this._observers.push(e)}notifyObservers(e,t=-1,i,s,r){if(this.notifyIfTriggered&&(this._hasNotified=!0,this._lastNotifiedValue=e),!this._observers.length)return!0;const a=this._eventState;a.mask=t,a.target=i,a.currentTarget=s,a.skipNextObservers=!1,a.lastReturnValue=e,a.userInfo=r;for(const o of this._observers)if(!o._willBeUnregistered&&(o.mask&t&&(o.unregisterOnNextCall&&this._deferUnregister(o),o.scope?a.lastReturnValue=o.callback.apply(o.scope,[e,a]):a.lastReturnValue=o.callback(e,a)),a.skipNextObservers))return!1;return!0}notifyObserver(e,t,i=-1){if(this.notifyIfTriggered&&(this._hasNotified=!0,this._lastNotifiedValue=t),e._willBeUnregistered)return;const s=this._eventState;s.mask=i,s.skipNextObservers=!1,e.unregisterOnNextCall&&this._deferUnregister(e),e.callback(t,s)}hasObservers(){return this._observers.length-this._numObserversMarkedAsDeleted>0}clear(){for(;this._observers.length;){const e=this._observers.pop();e&&(e._remove=null)}this._onObserverAdded=null,this._numObserversMarkedAsDeleted=0,this.cleanLastNotifiedState()}cleanLastNotifiedState(){this._hasNotified=!1,this._lastNotifiedValue=void 0}clone(){const e=new le;return e._observers=this._observers.slice(0),e}hasSpecificMask(e=-1){for(const t of this._observers)if(t.mask&e||t.mask===e)return!0;return!1}}class iU{get wrapU(){return this._cachedWrapU}set wrapU(e){this._cachedWrapU=e}get wrapV(){return this._cachedWrapV}set wrapV(e){this._cachedWrapV=e}get wrapR(){return this._cachedWrapR}set wrapR(e){this._cachedWrapR=e}get anisotropicFilteringLevel(){return this._cachedAnisotropicFilteringLevel}set anisotropicFilteringLevel(e){this._cachedAnisotropicFilteringLevel=e}get comparisonFunction(){return this._comparisonFunction}set comparisonFunction(e){this._comparisonFunction=e}get useMipMaps(){return this._useMipMaps}set useMipMaps(e){this._useMipMaps=e}constructor(){this.samplingMode=-1,this._useMipMaps=!0,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedWrapR=null,this._cachedAnisotropicFilteringLevel=null,this._comparisonFunction=0}setParameters(e=1,t=1,i=1,s=1,r=2,a=0){return this._cachedWrapU=e,this._cachedWrapV=t,this._cachedWrapR=i,this._cachedAnisotropicFilteringLevel=s,this.samplingMode=r,this._comparisonFunction=a,this}compareSampler(e){return this._cachedWrapU===e._cachedWrapU&&this._cachedWrapV===e._cachedWrapV&&this._cachedWrapR===e._cachedWrapR&&this._cachedAnisotropicFilteringLevel===e._cachedAnisotropicFilteringLevel&&this.samplingMode===e.samplingMode&&this._comparisonFunction===e._comparisonFunction&&this._useMipMaps===e._useMipMaps}}var eT;(function(n){n[n.Unknown=0]="Unknown",n[n.Url=1]="Url",n[n.Temp=2]="Temp",n[n.Raw=3]="Raw",n[n.Dynamic=4]="Dynamic",n[n.RenderTarget=5]="RenderTarget",n[n.MultiRenderTarget=6]="MultiRenderTarget",n[n.Cube=7]="Cube",n[n.CubeRaw=8]="CubeRaw",n[n.CubePrefiltered=9]="CubePrefiltered",n[n.Raw3D=10]="Raw3D",n[n.Raw2DArray=11]="Raw2DArray",n[n.DepthStencil=12]="DepthStencil",n[n.CubeRawRGBD=13]="CubeRawRGBD",n[n.Depth=14]="Depth"})(eT||(eT={}));class Cs extends iU{get useMipMaps(){return this.generateMipMaps}set useMipMaps(e){this.generateMipMaps=e}get uniqueId(){return this._uniqueId}_setUniqueId(e){this._uniqueId=e}getEngine(){return this._engine}get source(){return this._source}constructor(e,t,i=!1){super(),this.isReady=!1,this.isCube=!1,this.is3D=!1,this.is2DArray=!1,this.isMultiview=!1,this.url="",this.generateMipMaps=!1,this.samples=0,this.type=-1,this.format=-1,this.onLoadedObservable=new le,this.onErrorObservable=new le,this.onRebuildCallback=null,this.width=0,this.height=0,this.depth=0,this.baseWidth=0,this.baseHeight=0,this.baseDepth=0,this.invertY=!1,this._invertVScale=!1,this._associatedChannel=-1,this._source=0,this._buffer=null,this._bufferView=null,this._bufferViewArray=null,this._bufferViewArrayArray=null,this._size=0,this._extension="",this._files=null,this._workingCanvas=null,this._workingContext=null,this._cachedCoordinatesMode=null,this._isDisabled=!1,this._compression=null,this._sphericalPolynomial=null,this._sphericalPolynomialPromise=null,this._sphericalPolynomialComputed=!1,this._lodGenerationScale=0,this._lodGenerationOffset=0,this._useSRGBBuffer=!1,this._creationFlags=0,this._lodTextureHigh=null,this._lodTextureMid=null,this._lodTextureLow=null,this._isRGBD=!1,this._linearSpecularLOD=!1,this._irradianceTexture=null,this._hardwareTexture=null,this._maxLodLevel=null,this._references=1,this._gammaSpace=null,this._premulAlp
vendor: 18,136 bytes, lines 203-213
203ha=!1,this._dynamicTextureSource=null,this._autoMSAAManagement=!1,this._engine=e,this._source=t,this._uniqueId=Cs._Counter++,i||(this._hardwareTexture=e._createHardwareTexture())}incrementReferences(){this._references++}updateSize(e,t,i=1){this._engine.updateTextureDimensions(this,e,t,i),this.width=e,this.height=t,this.depth=i,this.baseWidth=e,this.baseHeight=t,this.baseDepth=i,this._size=e*t*i}_rebuild(){if(this.isReady=!1,this._cachedCoordinatesMode=null,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedWrapR=null,this._cachedAnisotropicFilteringLevel=null,this.onRebuildCallback){const t=this.onRebuildCallback(this),i=s=>{s._swapAndDie(this,!1),this.isReady=t.isReady};t.isAsync?t.proxy.then(i):i(t.proxy);return}let e;switch(this.source){case 2:break;case 1:e=this._engine.createTexture(this._originalUrl??this.url,!this.generateMipMaps,this.invertY,null,this.samplingMode,t=>{t._swapAndDie(this,!1),this.isReady=!0},null,this._buffer,void 0,this.format,this._extension,void 0,void 0,void 0,this._useSRGBBuffer);return;case 3:e=this._engine.createRawTexture(this._bufferView,this.baseWidth,this.baseHeight,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression,this.type,this._creationFlags,this._useSRGBBuffer),e._swapAndDie(this,!1),this.isReady=!0;break;case 10:e=this._engine.createRawTexture3D(this._bufferView,this.baseWidth,this.baseHeight,this.baseDepth,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression,this.type),e._swapAndDie(this,!1),this.isReady=!0;break;case 11:e=this._engine.createRawTexture2DArray(this._bufferView,this.baseWidth,this.baseHeight,this.baseDepth,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression,this.type),e._swapAndDie(this,!1),this.isReady=!0;break;case 4:e=this._engine.createDynamicTexture(this.baseWidth,this.baseHeight,this.generateMipMaps,this.samplingMode),e._swapAndDie(this,!1),this._dynamicTextureSource&&this._engine.updateDynamicTexture(this,this._dynamicTextureSource,this.invertY,this._premulAlpha,this.format,!0);break;case 7:e=this._engine.createCubeTexture(this.url,null,this._files,!this.generateMipMaps,()=>{e._swapAndDie(this,!1),this.isReady=!0},null,this.format,this._extension,!1,0,0,null,void 0,this._useSRGBBuffer,ArrayBuffer.isView(this._buffer)?this._buffer:null);return;case 8:e=this._engine.createRawCubeTexture(this._bufferViewArray,this.width,this._originalFormat??this.format,this.type,this.generateMipMaps,this.invertY,this.samplingMode,this._compression),e._swapAndDie(this,!1),this.isReady=!0;break;case 13:return;case 9:e=this._engine.createPrefilteredCubeTexture(this.url,null,this._lodGenerationScale,this._lodGenerationOffset,t=>{t&&t._swapAndDie(this,!1),this.isReady=!0},null,this.format,this._extension),e._sphericalPolynomial=this._sphericalPolynomial;return}}_swapAndDie(e,t=!0){this._hardwareTexture?.setUsage(e._source,this.generateMipMaps,this.is2DArray,this.isCube,this.is3D,this.width,this.height,this.depth),e._hardwareTexture=this._hardwareTexture,t&&(e._isRGBD=this._isRGBD),this._lodTextureHigh&&(e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureHigh=this._lodTextureHigh),this._lodTextureMid&&(e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureMid=this._lodTextureMid),this._lodTextureLow&&(e._lodTextureLow&&e._lodTextureLow.dispose(),e._lodTextureLow=this._lodTextureLow),this._irradianceTexture&&(e._irradianceTexture&&e._irradianceTexture.dispose(),e._irradianceTexture=this._irradianceTexture);const i=this._engine.getLoadedTexturesCache();let s=i.indexOf(this);s!==-1&&i.splice(s,1),s=i.indexOf(e),s===-1&&i.push(e)}dispose(){this._references--,this._references===0&&(this.onLoadedObservable.clear(),this.onErrorObservable.clear(),this._engine._releaseTexture(this),this._hardwareTexture=null,this._dynamicTextureSource=null)}}Cs._Counter=0;class Ke{static get LastCreatedEngine(){return this.Instances.length===0?null:this.Instances[this.Instances.length-1]}static get LastCreatedScene(){return this._LastCreatedScene}}Ke.Instances=[];Ke.OnEnginesDisposedObservable=new le;Ke._LastCreatedScene=null;Ke.UseFallbackTexture=!0;Ke.FallbackTexture="";class sU{constructor(){this._valueCache={},this.vertexCompilationError=null,this.fragmentCompilationError=null,this.programLinkError=null,this.programValidationError=null,this._isDisposed=!1}get isAsync(){return this.isParallelCompiled}get isReady(){return this.program?this.isParallelCompiled?this.engine._isRenderingStateCompiled(this):!0:!1}_handlesSpectorRebuildCallback(e){e&&this.program&&e(this.program)}setEngine(e){this.engine=e}_fillEffectInformation(e,t,i,s,r,a,o,c){const u=this.engine;if(u.supportsUniformBuffers)for(const g in t)e.bindUniformBlock(g,t[g]);this.engine.getUniforms(this,i).forEach((g,m)=>{s[i[m]]=g}),this._uniforms=s;let f;for(f=0;f<r.length;f++)e.getUniform(r[f])==null&&(r.splice(f,1),f--);r.forEach((g,m)=>{a[g]=m});for(const g of u.getAttributes(this,o))c.push(g)}dispose(){this._uniforms={},this._isDisposed=!0}_cacheMatrix(e,t){const i=this._valueCache[e],s=t.updateFlag;return i!==void 0&&i===s?!1:(this._valueCache[e]=s,!0)}_cacheFloat2(e,t,i){let s=this._valueCache[e];if(!s||s.length!==2)return s=[t,i],this._valueCache[e]=s,!0;let r=!1;return s[0]!==t&&(s[0]=t,r=!0),s[1]!==i&&(s[1]=i,r=!0),r}_cacheFloat3(e,t,i,s){let r=this._valueCache[e];if(!r||r.length!==3)return r=[t,i,s],this._valueCache[e]=r,!0;let a=!1;return r[0]!==t&&(r[0]=t,a=!0),r[1]!==i&&(r[1]=i,a=!0),r[2]!==s&&(r[2]=s,a=!0),a}_cacheFloat4(e,t,i,s,r){let a=this._valueCache[e];if(!a||a.length!==4)return a=[t,i,s,r],this._valueCache[e]=a,!0;let o=!1;return a[0]!==t&&(a[0]=t,o=!0),a[1]!==i&&(a[1]=i,o=!0),a[2]!==s&&(a[2]=s,o=!0),a[3]!==r&&(a[3]=r,o=!0),o}setInt(e,t){const i=this._valueCache[e];i!==void 0&&i===t||this.engine.setInt(this._uniforms[e],t)&&(this._valueCache[e]=t)}setInt2(e,t,i){this._cacheFloat2(e,t,i)&&(this.engine.setInt2(this._uniforms[e],t,i)||(this._valueCache[e]=null))}setInt3(e,t,i,s){this._cacheFloat3(e,t,i,s)&&(this.engine.setInt3(this._uniforms[e],t,i,s)||(this._valueCache[e]=null))}setInt4(e,t,i,s,r){this._cacheFloat4(e,t,i,s,r)&&(this.engine.setInt4(this._uniforms[e],t,i,s,r)||(this._valueCache[e]=null))}setIntArray(e,t){this._valueCache[e]=null,this.engine.setIntArray(this._uniforms[e],t)}setIntArray2(e,t){this._valueCache[e]=null,this.engine.setIntArray2(this._uniforms[e],t)}setIntArray3(e,t){this._valueCache[e]=null,this.engine.setIntArray3(this._uniforms[e],t)}setIntArray4(e,t){this._valueCache[e]=null,this.engine.setIntArray4(this._uniforms[e],t)}setUInt(e,t){const i=this._valueCache[e];i!==void 0&&i===t||this.engine.setUInt(this._uniforms[e],t)&&(this._valueCache[e]=t)}setUInt2(e,t,i){this._cacheFloat2(e,t,i)&&(this.engine.setUInt2(this._uniforms[e],t,i)||(this._valueCache[e]=null))}setUInt3(e,t,i,s){this._cacheFloat3(e,t,i,s)&&(this.engine.setUInt3(this._uniforms[e],t,i,s)||(this._valueCache[e]=null))}setUInt4(e,t,i,s,r){this._cacheFloat4(e,t,i,s,r)&&(this.engine.setUInt4(this._uniforms[e],t,i,s,r)||(this._valueCache[e]=null))}setUIntArray(e,t){this._valueCache[e]=null,this.engine.setUIntArray(this._uniforms[e],t)}setUIntArray2(e,t){this._valueCache[e]=null,this.engine.setUIntArray2(this._uniforms[e],t)}setUIntArray3(e,t){this._valueCache[e]=null,this.engine.setUIntArray3(this._uniforms[e],t)}setUIntArray4(e,t){this._valueCache[e]=null,this.engine.setUIntArray4(this._uniforms[e],t)}setArray(e,t){this._valueCache[e]=null,this.engine.setArray(this._uniforms[e],t)}setArray2(e,t){this._valueCache[e]=null,this.engine.setArray2(this._uniforms[e],t)}setArray3(e,t){this._valueCache[e]=null,this.engine.setArray3(this._uniforms[e],t)}setArray4(e,t){this._valueCache[e]=null,this.engine.setArray4(this._uniforms[e],t)}setMatrices(e,t){t&&(this._valueCache[e]=null,this.engine.setMatrices(this._uniforms[e],t))}setMatrix(e,t){this._cacheMatrix(e,t)&&(this.engine.setMatrices(this._uniforms[e],t.asArray())||(this._valueCache[e]=null))}setMatrix3x3(e,t){this._valueCache[e]=null,this.engine.setMatrix3x3(this._uniforms[e],t)}setMatrix2x2(e,t){this._valueCache[e]=null,this.engine.setMatrix2x2(this._uniforms[e],t)}setFloat(e,t){const i=this._valueCache[e];i!==void 0&&i===t||this.engine.setFloat(this._uniforms[e],t)&&(this._valueCache[e]=t)}setVector2(e,t){this._cacheFloat2(e,t.x,t.y)&&(this.engine.setFloat2(this._uniforms[e],t.x,t.y)||(this._valueCache[e]=null))}setFloat2(e,t,i){this._cacheFloat2(e,t,i)&&(this.engine.setFloat2(this._uniforms[e],t,i)||(this._valueCache[e]=null))}setVector3(e,t){this._cacheFloat3(e,t.x,t.y,t.z)&&(this.engine.setFloat3(this._uniforms[e],t.x,t.y,t.z)||(this._valueCache[e]=null))}setFloat3(e,t,i,s){this._cacheFloat3(e,t,i,s)&&(this.engine.setFloat3(this._uniforms[e],t,i,s)||(this._valueCache[e]=null))}setVector4(e,t){this._cacheFloat4(e,t.x,t.y,t.z,t.w)&&(this.engine.setFloat4(this._uniforms[e],t.x,t.y,t.z,t.w)||(this._valueCache[e]=null))}setQuaternion(e,t){this._cacheFloat4(e,t.x,t.y,t.z,t.w)&&(this.engine.setFloat4(this._uniforms[e],t.x,t.y,t.z,t.w)||(this._valueCache[e]=null))}setFloat4(e,t,i,s,r){this._cacheFloat4(e,t,i,s,r)&&(this.engine.setFloat4(this._uniforms[e],t,i,s,r)||(this._valueCache[e]=null))}setColor3(e,t){this._cacheFloat3(e,t.r,t.g,t.b)&&(this.engine.setFloat3(this._uniforms[e],t.r,t.g,t.b)||(this._valueCache[e]=null))}setColor4(e,t,i){this._cacheFloat4(e,t.r,t.g,t.b,i)&&(this.engine.setFloat4(this._uniforms[e],t.r,t.g,t.b,i)||(this._valueCache[e]=null))}setDirectColor4(e,t){this._cacheFloat4(e,t.r,t.g,t.b,t.a)&&(this.engine.setFloat4(this._uniforms[e],t.r,t.g,t.b,t.a)||(this._valueCache[e]=null))}_getVertexShaderCode(){return this.vertexShader?this.engine._getShaderSource(this.vertexShader):null}_getFragmentShaderCode(){return this.fragmentShader?this.engine._getShaderSource(this.fragmentShader):null}}const tT={};function We(n,e=!1){if(!(e&&tT[n]))return tT[n]=!0,`${n} needs to be imported before as it contains a side-effect required by your code.`}function Gi(){return typeof window<"u"}function Xl(){return typeof navigator<"u"}function bh(){return typeof document<"u"}function KM(n){let e="",t=n.firstChild;for(;t;)t.nodeType===3&&(e+=t.textContent),t=t.nextSibling;return e}const qd={};function qM(n,e,t=""){return t+(e?e+` 204`:"")+n}function ZM(n,e,t,i,s,r,a){const o=a||qd.loadFile;if(o)return o(n,e,t,i,s,r);throw We("FileTools")}function $M(n,e,t,i){if(n){e?n.IS_NDC_HALF_ZRANGE="":delete n.IS_NDC_HALF_ZRANGE,t?n.USE_REVERSE_DEPTHBUFFER="":delete n.USE_REVERSE_DEPTHBUFFER,i?n.USE_EXACT_SRGB_CONVERSIONS="":delete n.USE_EXACT_SRGB_CONVERSIONS;return}else{let s="";return e&&(s+="#define IS_NDC_HALF_ZRANGE"),t&&(s&&(s+=` 205`),s+="#define USE_REVERSE_DEPTHBUFFER"),i&&(s&&(s+=` 206`),s+="#define USE_EXACT_SRGB_CONVERSIONS"),s}}function rU(n,e,t=!1,i){switch(n){case 3:return e instanceof ArrayBuffer?new Int8Array(e):new Int8Array(e);case 0:return e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e);case 4:return e instanceof ArrayBuffer?new Int16Array(e):new Int16Array(t?e/2:e);case 5:case 8:case 9:case 10:case 2:return e instanceof ArrayBuffer?new Uint16Array(e):new Uint16Array(t?e/2:e);case 6:return e instanceof ArrayBuffer?new Int32Array(e):new Int32Array(t?e/4:e);case 7:case 11:case 12:case 13:case 14:case 15:return e instanceof ArrayBuffer?new Uint32Array(e):new Uint32Array(t?e/4:e);case 1:return e instanceof ArrayBuffer?new Float32Array(e):new Float32Array(t?e/4:e)}return e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e)}const Am=new WeakMap,nU={_webGLVersion:2,cachedPipelines:{}};function zs(n){let e=Am.get(n);if(!e){if(!n)return nU;e={_webGLVersion:n.TEXTURE_BINDING_3D?2:1,_context:n,parallelShaderCompile:n.getExtension("KHR_parallel_shader_compile")||void 0,cachedPipelines:{}},Am.set(n,e)}return e}function Pg(n){Am.delete(n)}function QM(n,e,t,i,s,r){const a=zs(i);r||(r=a._createShaderProgramInjection??yb);const o=Rm(e,"vertex",i,a._contextWasLost),c=Rm(t,"fragment",i,a._contextWasLost);return r(n,o,c,i,s,a.validateShaderPrograms)}function JM(n,e,t,i,s,r=null,a){const o=zs(s);a||(a=o._createShaderProgramInjection??yb);const c=o._webGLVersion>1?`#version 300 es 207#define WEBGL2 208`:"",u=iT(e,"vertex",i,c,s,o._contextWasLost),d=iT(t,"fragment",i,c,s,o._contextWasLost);return a(n,u,d,s,r,o.validateShaderPrograms)}function aU(n,e){const t=new sU,i=zs(n);return i.parallelShaderCompile&&!i.disableParallelShaderCompile&&(t.isParallelCompiled=!0),t.context=i._context,t}function yb(n,e,t,i,s=null,r){const a=i.createProgram();if(n.program=a,!a)throw new Error("Unable to create program");return i.attachShader(a,e),i.attachShader(a,t),i.linkProgram(a),n.context=i,n.vertexShader=e,n.fragmentShader=t,n.isParallelCompiled||vb(n,i,r),a}function oU(n,e,t){const i=n;if(i._isDisposed)return!1;const s=zs(e);return s&&s.parallelShaderCompile&&s.parallelShaderCompile.COMPLETION_STATUS_KHR&&i.program&&e.getProgramParameter(i.program,s.parallelShaderCompile.COMPLETION_STATUS_KHR)?(vb(i,e,t),!0):!1}function vb(n,e,t){const i=n.context,s=n.vertexShader,r=n.fragmentShader,a=n.program;if(!i.getProgramParameter(a,i.LINK_STATUS)){if(!e.getShaderParameter(s,e.COMPILE_STATUS)){const u=e.getShaderInfoLog(s);if(u)throw n.vertexCompilationError=u,new Error("VERTEX SHADER "+u)}if(!e.getShaderParameter(r,e.COMPILE_STATUS)){const u=e.getShaderInfoLog(r);if(u)throw n.fragmentCompilationError=u,new Error("FRAGMENT SHADER "+u)}const c=i.getProgramInfoLog(a);if(c)throw n.programLinkError=c,new Error(c)}if(t&&(i.validateProgram(a),!i.getProgramParameter(a,i.VALIDATE_STATUS))){const u=i.getProgramInfoLog(a);if(u)throw n.programValidationError=u,new Error(u)}i.deleteShader(s),i.deleteShader(r),n.vertexShader=void 0,n.fragmentShader=void 0,n.onCompiled&&(n.onCompiled(),n.onCompiled=void 0)}function lU(n,e,t,i,s,r,a,o,c,u="",d,f,g){const m=zs(n.context);f||(f=m.createRawShaderProgramInjection??QM),g||(g=m.createShaderProgramInjection??JM);const b=n;i?b.program=f(b,e,t,b.context,c):b.program=g(b,e,t,o,b.context,c),b.program.__SPECTOR_rebuildProgram=a,d()}function iT(n,e,t,i,s,r){return Rm(qM(n,t,i),e,s,r)}function Rm(n,e,t,i){const s=t.createShader(e==="vertex"?t.VERTEX_SHADER:t.FRAGMENT_SHADER);if(!s){let r=t.NO_ERROR,a=t.NO_ERROR;for(;(a=t.getError())!==t.NO_ERROR;)r=a;throw new Error(`Something went wrong while creating a gl ${e} shader object. gl error=${r}, gl isContextLost=${t.isContextLost()}, _contextWasLost=${i}`)}return t.shaderSource(s,n),t.compileShader(s),s}function cU(n,e){e.useProgram(n)}function hU(n,e){const t=n;if(!t.isParallelCompiled){e(n);return}const i=t.onCompiled;t.onCompiled=()=>{i?.(),e(n)}}function eC(n){return n.getPipelineContext===void 0}class oe{static _CheckLimit(e,t){let i=oe._LogLimitOutputs[e];return i?i.current++:(i={limit:t,current:1},oe._LogLimitOutputs[e]=i),i.current<=i.limit}static _GenerateLimitMessage(e,t=1){const i=oe._LogLimitOutputs[e];if(!i||!oe.MessageLimitReached)return;const s=this._Levels[t];i.current===i.limit&&oe[s.name](oe.MessageLimitReached.replace(/%LIMIT%/g,""+i.limit).replace(/%TYPE%/g,s.name??""))}static _AddLogEntry(e){oe._LogCache=e+oe._LogCache,oe.OnNewCacheEntry&&oe.OnNewCacheEntry(e)}static _FormatMessage(e){const t=s=>s<10?"0"+s:""+s,i=new Date;return"["+t(i.getHours())+":"+t(i.getMinutes())+":"+t(i.getSeconds())+"]: "+e}static _LogDisabled(e,t){}static _LogEnabled(e=1,t,i){const s=Array.isArray(t)?t[0]:t;if(i!==void 0&&!oe._CheckLimit(s,i))return;const r=oe._FormatMessage(s),a=this._Levels[e],o=Array.isArray(t)?t.slice(1):[];a.logFunc&&a.logFunc("BJS - "+r,...o);const c=`<div style='color:${a.color}'>${r}</div><br>`;oe._AddLogEntry(c),oe._GenerateLimitMessage(s,e)}static get LogCache(){return oe._LogCache}static ClearLogCache(){oe._LogCache="",oe._LogLimitOutputs={},oe.errorsCount=0}static set LogLevels(e){oe.Log=oe._LogDisabled,oe.Warn=oe._LogDisabled,oe.Error=oe._LogDisabled;const t=[oe.MessageLogLevel,oe.WarningLogLevel,oe.ErrorLogLevel];for(const i of t)if((e&i)===i){const s=this._Levels[i];oe[s.name]=oe._LogEnabled.bind(oe,i)}}}oe.NoneLogLevel=0;oe.MessageLogLevel=1;oe.WarningLogLevel=2;oe.ErrorLogLevel=4;oe.AllLogLevel=7;oe.MessageLimitReached="Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.";oe._LogCache="";oe._LogLimitOutputs={};oe._Levels=[{},{color:"white",logFunc:console.log,name:"Log"},{color:"orange",logFunc:console.warn,name:"Warn"},{},{color:"red",logFunc:console.error,name:"Error"}];oe.errorsCount=0;oe.Log=oe._LogEnabled.bind(oe,oe.MessageLogLevel);oe.Warn=oe._LogEnabled.bind(oe,oe.WarningLogLevel);oe.Error=oe._LogEnabled.bind(oe,oe.ErrorLogLevel);class tC{constructor(){this.shaderLanguage=0}postProcessor(e,t,i,s,r){if(r.drawBuffersExtensionDisabled){const a=/#extension.+GL_EXT_draw_buffers.+(enable|require)/g;e=e.replace(a,"")}return e}}const uU=/(flat\s)?\s*varying\s*.*/;class dU{constructor(){this.shaderLanguage=0}attributeProcessor(e){return e.replace("attribute","in")}varyingCheck(e,t){return uU.test(e)}varyingProcessor(e,t){return e.replace("varying",t?"in":"out")}postProcessor(e,t,i){const s=e.search(/#extension.+GL_EXT_draw_buffers.+require/)!==-1,r=/#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;if(e=e.replace(r,""),e=e.replace(/texture2D\s*\(/g,"texture("),i){const a=e.search(/layout *\(location *= *0\) *out/g)!==-1,o=t.indexOf("#define DUAL_SOURCE_BLENDING")!==-1,c=o?`layout(location = 0, index = 0) out vec4 glFragColor; 209layout(location = 0, index = 1) out vec4 glFragColor2; 210`:`layout(location = 0) out vec4 glFragColor; 211`;o&&(e=`#extension GL_EXT_blend_func_extended : require 212`+e),e=e.replace(/texture2DLodEXT\s*\(/g,"textureLod("),e=e.replace(/textureCubeLodEXT\s*\(/g,"textureLod("),e=e.replace(/textureCube\s*\(/g,"texture("),e=e.replace(/gl_FragDepthEXT/g,"gl_FragDepth"),e=e.replace(/gl_FragColor/g,"glFragColor"),e=e.replace(/gl_FragData/g,"glFragData"),e=e.replace(/void\s+?main\s*\(/g,(s||a?"":c)+"void main(")}else if(t.indexOf("#define VERTEXOUTPUT_INVARIANT")>=0&&(e=`invariant gl_Position; 213`+e),t.indexOf("#define MULTIVIEW")!==-1)return`#extension GL_OVR_multiview2 : require
214layout (num_views = 2) in; 215`+e;return e}}class qh{get underlyingResource(){return null}constructor(){this.references=0,this.capacity=0,this.is32Bits=!1,this.uniqueId=qh._Counter++}}qh._Counter=0;class Dh extends qh{constructor(e){super(),this._buffer=e}get underlyingResource(){return this._buffer}}function Oh(n){let e=1;do e*=2;while(e<n);return e===n}function Mm(n,e,t){return n*(1-t)+e*t}function iC(n){const e=sC(n),t=xb(n);return e-n>n-t?t:e}function sC(n){return n--,n|=n>>1,n|=n>>2,n|=n>>4,n|=n>>8,n|=n>>16,n++,n}function xb(n){return n=n|n>>1,n=n|n>>2,n=n|n>>4,n=n|n>>8,n=n|n>>16,n-(n>>1)}function Vo(n,e,t=2){let i;switch(t){case 1:i=xb(n);break;case 2:i=iC(n);break;case 3:default:i=sC(n);break}return Math.min(i,e)}class de{static GetShadersRepository(e=0){return e===0?de.ShadersRepository:de.ShadersRepositoryWGSL}static GetShadersStore(e=0){return e===0?de.ShadersStore:de.ShadersStoreWGSL}static GetIncludesShadersStore(e=0){return e===0?de.IncludesShadersStore:de.IncludesShadersStoreWGSL}}de.ShadersRepository="src/Shaders/";de.ShadersStore={};de.IncludesShadersStore={};de.ShadersRepositoryWGSL="src/ShadersWGSL/";de.ShadersStoreWGSL={};de.IncludesShadersStoreWGSL={};const fU="attribute",pU="varying";class Zh{constructor(){this.children=[]}isValid(e){return!0}process(e,t,i){let s="";if(this.line){let r=this.line;const a=t.processor;if(a){a.lineProcessor&&(r=a.lineProcessor(r,t.isFragment,t.processingContext));const o=t.processor?.attributeKeywordName??fU,c=t.isFragment&&t.processor?.varyingFragmentKeywordName?t.processor?.varyingFragmentKeywordName:!t.isFragment&&t.processor?.varyingVertexKeywordName?t.processor?.varyingVertexKeywordName:pU;!t.isFragment&&a.attributeProcessor&&this.line.startsWith(o)?r=a.attributeProcessor(this.line,e,t.processingContext):a.varyingProcessor&&(a.varyingCheck?.(this.line,t.isFragment)||!a.varyingCheck&&this.line.startsWith(c))?r=a.varyingProcessor(this.line,t.isFragment,e,t.processingContext):a.uniformProcessor&&a.uniformRegexp&&a.uniformRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(r=a.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):a.uniformBufferProcessor&&a.uniformBufferRegexp&&a.uniformBufferRegexp.test(this.line)?t.lookForClosingBracketForUniformBuffer||(r=a.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0):a.textureProcessor&&a.textureRegexp&&a.textureRegexp.test(this.line)?r=a.textureProcessor(this.line,t.isFragment,e,t.processingContext):(a.uniformProcessor||a.uniformBufferProcessor)&&this.line.startsWith("uniform")&&!t.lookForClosingBracketForUniformBuffer&&(/uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/.test(this.line)?a.uniformProcessor&&(r=a.uniformProcessor(this.line,t.isFragment,e,t.processingContext)):a.uniformBufferProcessor&&(r=a.uniformBufferProcessor(this.line,t.isFragment,t.processingContext),t.lookForClosingBracketForUniformBuffer=!0)),t.lookForClosingBracketForUniformBuffer&&this.line.indexOf("}")!==-1&&(t.lookForClosingBracketForUniformBuffer=!1,a.endOfUniformBufferProcessor&&(r=a.endOfUniformBufferProcessor(this.line,t.isFragment,t.processingContext)))}s+=r+` 216`}for(const r of this.children)s+=r.process(e,t,i);return this.additionalDefineKey&&(e[this.additionalDefineKey]=this.additionalDefineValue||"true",i[this.additionalDefineKey]=e[this.additionalDefineKey]),s}}class _U{constructor(){this._lines=[]}get currentLine(){return this._lines[this.lineIndex]}get canRead(){return this.lineIndex<this._lines.length-1}set lines(e){this._lines.length=0;for(const t of e){if(!t||t==="\r")continue;if(t[0]==="#"){this._lines.push(t);continue}const i=t.trim();if(!i)continue;if(i.startsWith("//")){this._lines.push(t);continue}const s=i.indexOf(";");if(s===-1)this._lines.push(i);else if(s===i.length-1)i.length>1&&this._lines.push(i);else{const r=t.split(";");for(let a=0;a<r.length;a++){let o=r[a];o&&(o=o.trim(),o&&this._lines.push(o+(a!==r.length-1?";":"")))}}}}}class Dg extends Zh{process(e,t,i){for(let s=0;s<this.children.length;s++){const r=this.children[s];if(r.isValid(e))return r.process(e,t,i)}return""}}class gU extends Zh{isValid(e){return this.testExpression.isTrue(e)}}class si{isTrue(e){return!0}static postfixToInfix(e){const t=[];for(const i of e)if(si._OperatorPriority[i]===void 0)t.push(i);else{const s=t[t.length-1],r=t[t.length-2];t.length-=2,t.push(`(${r}${i}${s})`)}return t[t.length-1]}static infixToPostfix(e){const t=si._InfixToPostfixCache.get(e);if(t)return t.accessTime=Date.now(),t.result;if(!e.includes("&&")&&!e.includes("||")&&!e.includes(")")&&!e.includes("("))return[e];const i=[];let s=-1;const r=()=>{d=d.trim(),d!==""&&(i.push(d),d="")},a=f=>{s<si._Stack.length-1&&(si._Stack[++s]=f)},o=()=>si._Stack[s],c=()=>s===-1?"!!INVALID EXPRESSION!!":si._Stack[s--];let u=0,d="";for(;u<e.length;
vendor: 33,849 bytes, lines 216-226
216){const f=e.charAt(u),g=u<e.length-1?e.substring(u,2+u):"";if(f==="(")d="",a(f);else if(f===")"){for(r();s!==-1&&o()!=="(";)i.push(c());c()}else if(si._OperatorPriority[g]>1){for(r();s!==-1&&si._OperatorPriority[o()]>=si._OperatorPriority[g];)i.push(c());a(g),u++}else d+=f;u++}for(r();s!==-1;)o()==="("?c():i.push(c());return si._InfixToPostfixCache.size>=si.InfixToPostfixCacheLimitSize&&si.ClearCache(),si._InfixToPostfixCache.set(e,{result:i,accessTime:Date.now()}),i}static ClearCache(){const e=Array.from(si._InfixToPostfixCache.entries()).sort((t,i)=>t[1].accessTime-i[1].accessTime);for(let t=0;t<si.InfixToPostfixCacheCleanupSize;t++)si._InfixToPostfixCache.delete(e[t][0])}}si.InfixToPostfixCacheLimitSize=5e4;si.InfixToPostfixCacheCleanupSize=25e3;si._InfixToPostfixCache=new Map;si._OperatorPriority={")":0,"(":1,"||":2,"&&":3};si._Stack=["","","","","","","","","","","","","","","","","","","",""];class Zd extends si{constructor(e,t=!1){super(),this.define=e,this.not=t}isTrue(e){let t=e[this.define]!==void 0;return this.not&&(t=!t),t}}class mU extends si{isTrue(e){return this.leftOperand.isTrue(e)||this.rightOperand.isTrue(e)}}class bU extends si{isTrue(e){return this.leftOperand.isTrue(e)&&this.rightOperand.isTrue(e)}}class yU extends si{constructor(e,t,i){super(),this.define=e,this.operand=t,this.testValue=i}toString(){return`${this.define} ${this.operand} ${this.testValue}`}isTrue(e){let t=!1;const i=parseInt(e[this.define]!=null?e[this.define]:this.define),s=parseInt(e[this.testValue]!=null?e[this.testValue]:this.testValue);if(isNaN(i)||isNaN(s))return!1;switch(this.operand){case">":t=i>s;break;case"<":t=i<s;break;case"<=":t=i<=s;break;case">=":t=i>=s;break;case"==":t=i===s;break;case"!=":t=i!==s;break}return t}}const vU=/defined\s*?\((.+?)\)/g,Og=/defined\s*?\[(.+?)\]/g,xU=/#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g,SU=/__decl__/,sT=/light\{X\}.(\w*)/g,rT=/\{X\}/g,Rd=[],TU=/(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/;function EU(n){n.processor&&n.processor.initializeShaders&&n.processor.initializeShaders(n.processingContext)}function Cm(n,e,t,i){e.processor?.preProcessShaderCode&&(n=e.processor.preProcessShaderCode(n,e.isFragment)),$d(n,e,s=>{e.processCodeAfterIncludes&&(s=e.processCodeAfterIncludes(e.isFragment?"fragment":"vertex",s,e.defines));const r=PU(s,e,i);t(r,s)})}function AU(n,e,t){return!t.processor||!t.processor.finalizeShaders?{vertexCode:n,fragmentCode:e}:t.processor.finalizeShaders(n,e,t.processingContext)}function RU(n,e){if(e.processor?.noPrecision)return n;const t=e.shouldUseHighPrecisionShader;return n.indexOf("precision highp float")===-1?t?n=`precision highp float; 217`+n:n=`precision mediump float; 218`+n:t||(n=n.replace("precision highp float","precision mediump float")),n}function wg(n){const t=/defined\((.+)\)/.exec(n);if(t&&t.length)return new Zd(t[1].trim(),n[0]==="!");const i=["==","!=",">=","<=","<",">"];let s="",r=0;for(s of i)if(r=n.indexOf(s),r>-1)break;if(r===-1)return new Zd(n);const a=n.substring(0,r).trim(),o=n.substring(r+s.length).trim();return new yU(a,s,o)}function MU(n){n=n.replace(vU,"defined[$1]");const e=si.infixToPostfix(n),t=[];for(const s of e)if(s!=="||"&&s!=="&&")t.push(s);else if(t.length>=2){let r=t[t.length-1],a=t[t.length-2];t.length-=2;const o=s=="&&"?new bU:new mU;typeof r=="string"&&(r=r.replace(Og,"defined($1)")),typeof a=="string"&&(a=a.replace(Og,"defined($1)")),o.leftOperand=typeof a=="string"?wg(a):a,o.rightOperand=typeof r=="string"?wg(r):r,t.push(o)}let i=t[t.length-1];return typeof i=="string"&&(i=i.replace(Og,"defined($1)")),typeof i=="string"?wg(i):i}function Bd(n,e){const t=new gU,i=n.substring(0,e);let s=n.substring(e);return s=s.substring(0,(s.indexOf("//")+1||s.length+1)-1).trim(),i==="#ifdef"?t.testExpression=new Zd(s):i==="#ifndef"?t.testExpression=new Zd(s,!0):t.testExpression=MU(s),t}function Fg(n,e,t,i){let s=n.currentLine;for(;Im(n,t);){s=n.currentLine;const r=s.substring(0,5).toLowerCase();if(r==="#else"){const a=new Zh;e.children.push(a),Im(n,a);return}else if(r==="#elif"){const a=Bd(s,5);e.children.push(a),t=a}}}function Im(n,e,t){for(;n.canRead;){n.lineIndex++;const i=n.currentLine;if(i.indexOf("#")>=0){const r=TU.exec(i);if(r&&r.length){switch(r[0]){case"#ifdef":{const o=new Dg;e.children.push(o);const c=Bd(i,6);o.children.push(c),Fg(n,o,c);break}case"#else":case"#elif":return!0;case"#endif":return!1;case"#ifndef":{const o=new Dg;e.children.push(o);const c=Bd(i,7);o.children.push(c),Fg(n,o,c);break}case"#if":{const o=new Dg,c=Bd(i,3);e.children.push(o),o.children.push(c),Fg(n,o,c);break}}continue}}const s=new Zh;if(s.line=i,e.children.push(s),i[0]==="#"&&i[1]==="d"){const r=i.replace(";","").split(" ");s.additionalDefineKey=r[1],r.length===3&&(s.additionalDefineValue=r[2])}}return!1}function CU(n,e,t,i){const s=new Zh,r=new _U;return r.lineIndex=-1,r.lines=n.split(` 219`),Im(r,s),s.process(e,t,i)}function IU(n,e){const t=n.defines,i={};for(const s of t){const a=s.replace("#define","").replace(";","").trim().split(" ");i[a[0]]=a.length>1?a[1]:""}return n.processor?.shaderLanguage===0&&(i.GL_ES="true"),i.__VERSION__=n.version,i[n.platformName]="true",$M(i,e?.isNDCHalfZRange,e?.useReverseDepthBuffer,e?.useExactSrgbConversions),i}function PU(n,e,t){let i=RU(n,e);if(!e.processor||e.processor.shaderLanguage===0&&i.indexOf("#version 3")!==-1&&(i=i.replace("#version 300 es",""),!e.processor.parseGLES3))return i;const s=e.defines,r=IU(e,t);e.processor.preProcessor&&(i=e.processor.preProcessor(i,s,r,e.isFragment,e.processingContext));const a={};return i=CU(i,r,e,a),e.processor.postProcessor&&(i=e.processor.postProcessor(i,s,e.isFragment,e.processingContext,t?{drawBuffersExtensionDisabled:!t.getCaps().drawBuffersExtension}:{},r,a)),t?._features.needShaderCodeInlining&&(i=t.inlineShaderCode(i)),i}function $d(n,e,t){Rd.length=0;let i;for(;(i=xU.exec(n))!==null;)Rd.push(i);let s=String(n),r=[n],a=!1;for(const o of Rd){let c=o[1];if(c.indexOf("__decl__")!==-1&&(c=c.replace(SU,""),e.supportsUniformBuffers&&(c=c.replace("Vertex","Ubo").replace("Fragment","Ubo")),c=c+"Declaration"),e.includesShadersStore[c]){let u=e.includesShadersStore[c];if(o[2]){const f=o[3].split(",");for(let g=0;g<f.length;g+=2){const m=new RegExp(f[g],"g"),b=f[g+1];u=u.replace(m,b)}}if(o[4]){const f=o[5];if(f.indexOf("..")!==-1){const g=f.split(".."),m=parseInt(g[0]);let b=parseInt(g[1]),x=u.slice(0);u="",isNaN(b)&&(b=e.indexParameters[g[1]]);for(let v=m;v<b;v++)e.supportsUniformBuffers||(x=x.replace(sT,(E,A)=>A+"{X}")),u+=x.replace(rT,v.toString())+` 220`}else e.supportsUniformBuffers||(u=u.replace(sT,(g,m)=>m+"{X}")),u=u.replace(rT,f)}const d=[];for(const f of r){const g=f.split(o[0]);for(let m=0;m<g.length-1;m++)d.push(g[m]),d.push(u);d.push(g[g.length-1])}r=d,a=a||u.indexOf("#include<")>=0||u.indexOf("#include <")>=0}else{const u=e.shadersRepository+"ShadersInclude/"+c+".fx";rC.loadFile(u,d=>{e.includesShadersStore[c]=d,$d(r.join(""),e,t)});return}}Rd.length=0,s=r.join(""),a?$d(s.toString(),e,t):t(s)}const rC={loadFile:(n,e,t,i,s,r)=>{throw We("FileTools")}};function DU(n,e){return zs(e).cachedPipelines[n]}function nC(n){const e=n._name,t=n.context;if(e&&t){const i=zs(t);i.cachedPipelines[e]?.dispose(),delete i.cachedPipelines[e]}}function OU(n,e,t,i,s,r,a){let o,c;const u=Gi()?r?.getHostDocument():null;typeof e=="string"?o=e:e.vertexSource?o="source:"+e.vertexSource:e.vertexElement?o=u?.getElementById(e.vertexElement)||e.vertexElement:o=e.vertex||e,typeof e=="string"?c=e:e.fragmentSource?c="source:"+e.fragmentSource:e.fragmentElement?c=u?.getElementById(e.fragmentElement)||e.fragmentElement:c=e.fragment||e;const d=[void 0,void 0],f=()=>{if(d[0]&&d[1]){n.isFragment=!0;const[g,m]=d;Cm(m,n,(b,x)=>{a&&(a._fragmentSourceCodeBeforeMigration=x),t&&(b=t("fragment",b));const v=AU(g,b,n);n=null;const E=wU(v.vertexCode,v.fragmentCode,e,s);i?.(E.vertexSourceCode,E.fragmentSourceCode)},r)}};nT(o,"Vertex","",g=>{EU(n),Cm(g,n,(m,b)=>{a&&(a._rawVertexSourceCode=g,a._vertexSourceCodeBeforeMigration=b),t&&(m=t("vertex",m)),d[0]=m,f()},r)},s),nT(c,"Fragment","Pixel",g=>{a&&(a._rawFragmentSourceCode=g),d[1]=g,f()},s)}function nT(n,e,t,i,s,r){if(typeof HTMLElement<"u"&&n instanceof HTMLElement){const c=KM(n);i(c);return}if(n.substring(0,7)==="source:"){i(n.substring(7));return}if(n.substring(0,7)==="base64:"){const c=window.atob(n.substring(7));i(c);return}const a=de.GetShadersStore(s);if(a[n+e+"Shader"]){i(a[n+e+"Shader"]);return}if(t&&a[n+t+"Shader"]){i(a[n+t+"Shader"]);return}let o;if(n[0]==="."||n[0]==="/"||n.indexOf("http")>-1?o=n:o=de.GetShadersRepository(s)+n,r=r||ZM,!r)throw new Error("loadFileInjection is not defined");r(o+"."+e.toLowerCase()+".fx",i)}function wU(n,e,t,i){if(t){const s=t.vertexElement||t.vertex||t.spectorName||t,r=t.fragmentElement||t.fragment||t.spectorName||t;return{vertexSourceCode:(i===1?"//":"")+"#define SHADER_NAME vertex:"+s+` 221`+n,fragmentSourceCode:(i===1?"//":"")+"#define SHADER_NAME fragment:"+r+` 222`+e}}else return{vertexSourceCode:n,fragmentSourceCode:e}}const FU=(n,e,t,i)=>{try{const s=n.context?zs(n.context):null;s&&(s.disableParallelShaderCompile=n.disableParallelCompilation);const r=n.existingPipelineContext||e(n.shaderProcessingContext);return r._name=n.name,n.name&&s&&(s.cachedPipelines[n.name]=r),t(r,n.vertex,n.fragment,!!n.createAsRaw,"","",n.rebuildRebind,n.defines,n.transformFeedbackVaryings,"",()=>{i(r,()=>{n.onRenderingStateCompiled?.(r)})}),r}catch(s){throw oe.Error("Error compiling effect"),s}};let Md=[];class zo{static SetImmediate(e){Md.length===0&&setTimeout(()=>{const t=Md;Md=[];for(const i of t)i()},1),Md.push(e)}}function aT(n,e,t){try{if(n())return e(),!0}catch(i){return t?.(i),!0}return!1}const wf=(n,e,t,i=16,s=3e4,r=!0,a)=>{if(r&&aT(n,e,t))return null;const o=setInterval(()=>{aT(n,e,t)?clearInterval(o):(s-=i,s<0&&(clearInterval(o),t?.(new Error("Operation timed out after maximum retries. "+(a||"")),!0)))},i);return()=>clearInterval(o)};class At{static get ShadersRepository(){return de.ShadersRepository}static set ShadersRepository(e){de.ShadersRepository=e}get isDisposed(){return this._isDisposed}get onBindObservable(){return this._onBindObservable||(this._onBindObservable=new le),this._onBindObservable}get shaderLanguage(){return this._shaderLanguage}constructor(e,t,i,s=null,r,a=null,o=null,c=null,u=null,d,f="",g=0,m){this.defines="",this.onCompiled=null,this.onError=null,this.onBind=null,this.uniqueId=0,this.onCompileObservable=new le,this.onErrorObservable=new le,this._onBindObservable=null,this._isDisposed=!1,this._refCount=1,this._bonesComputationForcedToCPU=!1,this._uniformBuffersNames={},this._multiTarget=!1,this._samplers={},this._isReady=!1,this._compilationError="",this._allFallbacksProcessed=!1,this._uniforms={},this._key="",this._fallbacks=null,this._vertexSourceCodeOverride="",this._fragmentSourceCodeOverride="",this._transformFeedbackVaryings=null,this._disableParallelShaderCompilation=!1,this._pipelineContext=null,this._vertexSourceCode="",this._fragmentSourceCode="",this._vertexSourceCodeBeforeMigration="",this._fragmentSourceCodeBeforeMigration="",this._rawVertexSourceCode="",this._rawFragmentSourceCode="",this._processCodeAfterIncludes=void 0,this._processFinalCode=null,this._onReleaseEffectsObserver=null,this.name=e,this._key=f;const b=this._key.replace(/\r/g,"").replace(/\n/g,"|");let x;if(t.attributes){const v=t;if(this._engine=i,this._attributesNames=v.attributes,this._uniformsNames=v.uniformsNames.concat(v.samplers),this._samplerList=v.samplers.slice(),this.defines=v.defines,this.onError=v.onError,this.onCompiled=v.onCompiled,this._fallbacks=v.fallbacks,this._indexParameters=v.indexParameters,this._transformFeedbackVaryings=v.transformFeedbackVaryings||null,this._multiTarget=!!v.multiTarget,this._shaderLanguage=v.shaderLanguage??0,this._disableParallelShaderCompilation=!!v.disableParallelShaderCompilation,v.uniformBuffersNames){this._uniformBuffersNamesList=v.uniformBuffersNames.slice();for(let E=0;E<v.uniformBuffersNames.length;E++)this._uniformBuffersNames[v.uniformBuffersNames[E]]=E}this._processFinalCode=v.processFinalCode??null,this._processCodeAfterIncludes=v.processCodeAfterIncludes??void 0,m=v.extraInitializationsAsync,x=v.existingPipelineContext}else this._engine=r,this.defines=a??"",this._uniformsNames=i.concat(s),this._samplerList=s?s.slice():[],this._attributesNames=t,this._uniformBuffersNamesList=[],this._shaderLanguage=g,this.onError=u,this.onCompiled=c,this._indexParameters=d,this._fallbacks=o;this._engine.shaderPlatformName==="WEBGL2"&&(x=DU(b,this._engine._gl)??x),this._attributeLocationByName={},this.uniqueId=At._UniqueIdSeed++,x?(this._pipelineContext=x,this._pipelineContext.setEngine(this._engine),this._onRenderingStateCompiled(this._pipelineContext),this._pipelineContext.program&&(this._pipelineContext.program.__SPECTOR_rebuildProgram=this._rebuildProgram.bind(this))):this._processShaderCodeAsync(null,!1,null,m),this._onReleaseEffectsObserver=this._engine.onReleaseEffectsObservable.addOnce(()=>{this._onReleaseEffectsObserver=null,!this.isDisposed&&this.dispose(!0)})}async _processShaderCodeAsync(e=null,t=!1,i=null,s){s&&await s(),this._processingContext=i||this._engine._getShaderProcessingContext(this._shaderLanguage,!1);const r={defines:this.defines.split(` 223`),indexParameters:this._indexParameters,isFragment:!1,shouldUseHighPrecisionShader:this._engine._shouldUseHighPrecisionShader,processor:e??this._engine._getShaderProcessor(this._shaderLanguage),supportsUniformBuffers:this._engine.supportsUniformBuffers,shadersRepository:de.GetShadersRepository(this._shaderLanguage),includesShadersStore:de.GetIncludesShadersStore(this._shaderLanguage),version:(this._engine.version*100).toString(),platformName:this._engine.shaderPlatformName,processingContext:this._processingContext,isNDCHalfZRange:this._engine.isNDCHalfZRange,useReverseDepthBuffer:this._engine.useReverseDepthBuffer,processCodeAfterIncludes:this._processCodeAfterIncludes};OU(r,this.name,this._processFinalCode,(a,o)=>{this._vertexSourceCode=a,this._fragmentSourceCode=o,this._prepareEffect(t)},this._shaderLanguage,this._engine,this)}get key(){return this._key}isReady(){try{return this._isReadyInternal()}catch{return!1}}_isReadyInternal(){return this._engine.isDisposed||this._isReady?!0:this._pipelineContext?this._pipelineContext.isReady:!1}getEngine(){return this._engine}getPipelineContext(){return this._pipelineContext}getAttributesNames(){return this._attributesNames}getAttributeLocation(e){return this._attributes[e]}getAttributeLocationByName(e){return this._attributeLocationByName[e]}getAttributesCount(){return this._attributes.length}getUniformIndex(e){return this._uniformsNames.indexOf(e)}getUniform(e){return this._uniforms[e]}getSamplers(){return this._samplerList}getUniformNames(){return this._uniformsNames}getUniformBuffersNames(){return this._uniformBuffersNamesList}getIndexParameters(){return this._indexParameters}getCompilationError(){return this._compilationError}allFallbacksProcessed(){return this._allFallbacksProcessed}async whenCompiledAsync(){return await new Promise(e=>{this.executeWhenCompiled(e)})}executeWhenCompiled(e){if(this.isReady()){e(this);return}this.onCompileObservable.add(t=>{e(t)}),(!this._pipelineContext||this._pipelineContext.isAsync)&&this._checkIsReady(null)}_checkIsReady(e){wf(()=>this._isReadyInternal()||this._isDisposed,()=>{},t=>{this._processCompilationErrors(t,e)},16,12e4,!0,` - Effect: ${typeof this.name=="string"?this.name:this.key}`)}get vertexSourceCode(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._vertexSourceCodeOverride:this._pipelineContext?._getVertexShaderCode()??this._vertexSourceCode}get fragmentSourceCode(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._fragmentSourceCodeOverride:this._pipelineContext?._getFragmentShaderCode()??this._fragmentSourceCode}get vertexSourceCodeBeforeMigration(){return this._vertexSourceCodeBeforeMigration}get fragmentSourceCodeBeforeMigration(){return this._fragmentSourceCodeBeforeMigration}get rawVertexSourceCode(){return this._rawVertexSourceCode}get rawFragmentSourceCode(){return this._rawFragmentSourceCode}getPipelineGenerationOptions(){return{platformName:this._engine.shaderPlatformName,shaderLanguage:this._shaderLanguage,shaderNameOrContent:this.name,key:this._key,defines:this.defines.split(` 224`),addGlobalDefines:!1,extendedProcessingOptions:{indexParameters:this._indexParameters,isNDCHalfZRange:this._engine.isNDCHalfZRange,useReverseDepthBuffer:this._engine.useReverseDepthBuffer,supportsUniformBuffers:this._engine.supportsUniformBuffers},extendedCreatePipelineOptions:{transformFeedbackVaryings:this._transformFeedbackVaryings,createAsRaw:!!(this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride)}}}_rebuildProgram(e,t,i,s){this._isReady=!1,this._vertexSourceCodeOverride=e,this._fragmentSourceCodeOverride=t,this.onError=(r,a)=>{s&&s(a)},this.onCompiled=()=>{const r=this.getEngine().scenes;if(r)for(let a=0;a<r.length;a++)r[a].markAllMaterialsAsDirty(127);this._pipelineContext._handlesSpectorRebuildCallback?.(i)},this._fallbacks=null,this._prepareEffect()}_onRenderingStateCompiled(e){if(this._pipelineContext=e,this._pipelineContext.setEngine(this._engine),this._attributes=[],this._pipelineContext._fillEffectInformation(this,this._uniformBuffersNames,this._uniformsNames,this._uniforms,this._samplerList,this._samplers,this._attributesNames,this._attributes),this._attributesNames)for(let t=0;t<this._attributesNames.length;t++){const i=this._attributesNames[t];this._attributeLocationByName[i]=this._attributes[t]}this._engine.bindSamplers(this),this._compilationError="",this._isReady=!0,this.onCompiled&&this.onCompiled(this),this.onCompileObservable.notifyObservers(this),this.onCompileObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh(),At.AutomaticallyClearCodeCache&&this.clearCodeCache()}_prepareEffect(e=!1){const t=this._pipelineContext;this._isReady=!1;try{const i=!!(this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride),s=i?null:this.defines,r=i?this._vertexSourceCodeOverride:this._vertexSourceCode,a=i?this._fragmentSourceCodeOverride:this._fragmentSourceCode,o=this._engine;this._pipelineContext=FU({existingPipelineContext:e?t:null,vertex:r,fragment:a,context:o.shaderPlatformName==="WEBGL2"||o.shaderPlatformName==="WEBGL1"?o._gl:void 0,rebuildRebind:(c,u,d,f)=>this._rebuildProgram(c,u,d,f),defines:s,transformFeedbackVaryings:this._transformFeedbackVaryings,name:this._key.replace(/\r/g,"").replace(/\n/g,"|"),createAsRaw:i,disableParallelCompilation:this._disableParallelShaderCompilation,shaderProcessingContext:this._processingContext,onRenderingStateCompiled:c=>{t&&!e&&this._engine._deletePipelineContext(t),c&&this._onRenderingStateCompiled(c)}},this._engine.createPipelineContext.bind(this._engine),this._engine._preparePipelineContextAsync.bind(this._engine),this._engine._executeWhenRenderingStateIsCompiled.bind(this._engine)),this._pipelineContext.isAsync&&this._checkIsReady(t)}catch(i){this._processCompilationErrors(i,t)}}_getShaderCodeAndErrorLine(e,t,i){const s=i?/FRAGMENT SHADER ERROR: 0:(\d+?):/:/VERTEX SHADER ERROR: 0:(\d+?):/;let r=null;if(t&&e){const a=t.match(s);if(a&&a.length===2){const o=parseInt(a[1]),c=e.split(` 225`,-1);c.length>=o&&(r=`Offending line [${o}] in ${i?"fragment":"vertex"} code: ${c[o-1]}`)}}return[e,r]}_processCompilationErrors(e,t=null){this._compilationError=e.message;const i=this._attributesNames,s=this._fallbacks;if(oe.Error("Unable to compile effect:"),oe.Error(`Uniforms: ${this._uniformsNames.join(" ")}`),oe.Error(`Attributes: ${i.join(" ")}`),oe.Error(`Defines: 226`+this.defines),At.LogShaderCodeOnCompilationError){let a=null,o=null,c=null;this._pipelineContext?._getVertexShaderCode()&&([c,a]=this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(),this._compilationError,!1),c&&(oe.Error("Vertex code:"),oe.Error(c))),this._pipelineContext?._getFragmentShaderCode()&&([c,o]=this._getShaderCodeAndErrorLine(this._pipelineContext?._getFragmentShaderCode(),this._compilationError,!0),c&&(oe.Error("Fragment code:"),oe.Error(c))),a&&oe.Error(a),o&&oe.Error(o)}oe.Error("Error: "+this._compilationError);const r=()=>{this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this),this._engine.onEffectErrorObservable.notifyObservers({effect:this,errors:this._compilationError})};t&&(this._pipelineContext=t,this._isReady=!0,r()),s?(this._pipelineContext=null,s.hasMoreFallbacks?(this._allFallbacksProcessed=!1,oe.Error("Trying next fallback."),this.defines=s.reduce(this.defines,this),this._prepareEffect()):(this._allFallbacksProcessed=!0,r(),this.onErrorObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh())):(this._allFallbacksProcessed=!0,t||r())}get isSupported(){return this._compilationError===""}_bindTexture(e,t){this._engine._bindTexture(this._samplers[e],t,e)}setTexture(e,t){this._engine.setTexture(this._samplers[e],this._uniforms[e],t,e)}setTextureArray(e,t){const i=e+"Ex";if(this._samplerList.indexOf(i+"0")===-1){const s=this._samplerList.indexOf(e);for(let a=1;a<t.length;a++){const o=i+(a-1).toString();this._samplerList.splice(s+a,0,o)}let r=0;for(const a of this._samplerList)this._samplers[a]=r,r+=1}this._engine.setTextureArray(this._samplers[e],this._uniforms[e],t,e)}bindUniformBuffer(e,t){const i=this._uniformBuffersNames[t];i===void 0||At._BaseCache[i]===e&&this._engine._features.useUBOBindingCache||(At._BaseCache[i]=e,this._engine.bindUniformBufferBase(e,i,t))}bindUniformBlock(e,t){this._engine.bindUniformBlock(this._pipelineContext,e,t)}setInt(e,t){return this._pipelineContext.setInt(e,t),this}setInt2(e,t,i){return this._pipelineContext.setInt2(e,t,i),this}setInt3(e,t,i,s){return this._pipelineContext.setInt3(e,t,i,s),this}setInt4(e,t,i,s,r){return this._pipelineContext.setInt4(e,t,i,s,r),this}setIntArray(e,t){return this._pipelineContext.setIntArray(e,t),this}setIntArray2(e,t){return this._pipelineContext.setIntArray2(e,t),this}setIntArray3(e,t){return this._pipelineContext.setIntArray3(e,t),this}setIntArray4(e,t){return this._pipelineContext.setIntArray4(e,t),this}setUInt(e,t){return this._pipelineContext.setUInt(e,t),this}setUInt2(e,t,i){return this._pipelineContext.setUInt2(e,t,i),this}setUInt3(e,t,i,s){return this._pipelineContext.setUInt3(e,t,i,s),this}setUInt4(e,t,i,s,r){return this._pipelineContext.setUInt4(e,t,i,s,r),this}setUIntArray(e,t){return this._pipelineContext.setUIntArray(e,t),this}setUIntArray2(e,t){return this._pipelineContext.setUIntArray2(e,t),this}setUIntArray3(e,t){return this._pipelineContext.setUIntArray3(e,t),this}setUIntArray4(e,t){return this._pipelineContext.setUIntArray4(e,t),this}setFloatArray(e,t){return this._pipelineContext.setArray(e,t),this}setFloatArray2(e,t){return this._pipelineContext.setArray2(e,t),this}setFloatArray3(e,t){return this._pipelineContext.setArray3(e,t),this}setFloatArray4(e,t){return this._pipelineContext.setArray4(e,t),this}setArray(e,t){return this._pipelineContext.setArray(e,t),this}setArray2(e,t){return this._pipelineContext.setArray2(e,t),this}setArray3(e,t){return this._pipelineContext.setArray3(e,t),this}setArray4(e,t){return this._pipelineContext.setArray4(e,t),this}setMatrices(e,t){return this._pipelineContext.setMatrices(e,t),this}setMatrix(e,t){return this._pipelineContext.setMatrix(e,t),this}setMatrix3x3(e,t){return this._pipelineContext.setMatrix3x3(e,t),this}setMatrix2x2(e,t){return this._pipelineContext.setMatrix2x2(e,t),this}setFloat(e,t){return this._pipelineContext.setFloat(e,t),this}setBool(e,t){return this._pipelineContext.setInt(e,t?1:0),this}setVector2(e,t){return this._pipelineContext.setVector2(e,t),this}setFloat2(e,t,i){return this._pipelineContext.setFloat2(e,t,i),this}setVector3(e,t){return this._pipelineContext.setVector3(e,t),this}setFloat3(e,t,i,s){return this._pipelineContext.setFloat3(e,t,i,s),this}setVector4(e,t){return this._pipelineContext.setVector4(e,t),this}setQuaternion(e,t){return this._pipelineContext.setQuaternion(e,t),this}setFloat4(e,t,i,s,r){return this._pipelineContext.setFloat4(e,t,i,s,r),this}setColor3(e,t){return this._pipelineContext.setColor3(e,t),this}setColor4(e,t,i){return this._pipelineContext.setColor4(e,t,i),this}setDirectColor4(e,t){return this._pipelineContext.setDirectColor4(e,t),this}clearCodeCache(){this._vertexSourceCode="",this._fragmentSourceCode="",this._fragmentSourceCodeBeforeMigration="",this._vertexSourceCodeBeforeMigration=""}dispose(e=!1){if(e)this._refCount=0;else{if(At.PersistentMode)return;this._refCount--}this._refCount>0||this._isDisposed||(this._onReleaseEffectsObserver&&(this._engine.onReleaseEffectsObservable.remove(this._onReleaseEffectsObserver),this._onReleaseEffectsObserver=null),this._pipelineContext&&nC(this._pipelineContext),this._engine._releaseEffect(this),this.clearCodeCache(),this._isDisposed=!0)}static RegisterShader(e,t,i,s=0){t&&(de.GetShadersStore(s)[`${e}PixelShader`]=t),i&&(de.GetShadersStore(s)[`${e}VertexShader`]=i)}static ResetCache(){At._BaseCache={}}}At.LogShaderCodeOnCompilationError=!0;At.PersistentMode=!1;At.AutomaticallyClearCodeCache=!1;At._UniqueIdSeed=0;At._BaseCache={};At.ShadersStore=de.ShadersStore;At.IncludesShadersStore=de.IncludesShadersStore;class Oi{static SetMatrixPrecision(e){if(Oi.MatrixTrackPrecisionChange=!1,e&&!Oi.MatrixUse64Bits&&Oi.MatrixTrackedMatrices)for(let t=0;t<Oi.MatrixTrackedMatrices.length;++t){const i=Oi.MatrixTrackedMatrices[t],s=i._m;i._m=new Array(16);for(let r=0;r<16;++r)i._m[r]=s[r]}Oi.MatrixUse64Bits=e,Oi.MatrixCurrentType=Oi.MatrixUse64Bits?Array:Float32Array,Oi.MatrixTrackedMatrices=null}}Oi.MatrixUse64Bits=!1;Oi.MatrixTrackPrecisionChange=!0;Oi.MatrixCurrentType=Float32Array;Oi.MatrixTrackedMatrices=[];class nr{static get Now(){return Gi()&&window.performance&&window.performance.now?window.performance.now():Date.now()}}class LU{constructor(e=!0){this._isDepthTestDirty=!1,this._isDepthMaskDirty=!1,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1,this._isFrontFaceDirty=!1,e&&this.reset()}get isDirty(){return this._isDepthFuncDirty||this._isDepthTestDirty||this._isDepthMaskDirty||this._isCullFaceDirty||this._isCullDirty||this._isZOffsetDirty||this._isFrontFaceDirty}get zOffset(){return this._zOffset}set zOffset(e){this._zOffset!==e&&(this._zOffset=e,this._isZOffsetDirty=!0)}get zOffsetUnits(){return this._zOffsetUnits}set zOffsetUnits(e){this._zOffsetUnits!==e&&(this._zOffsetUnits=e,this._isZOffsetDirty=!0)}get cullFace(){return this._cullFace}set cullFace(e){this._cullFace!==e&&(this._cullFace=e,this._isCullFaceDirty=!0)}get cull(){return this._cull}set cull(e){this._cull!==e&&(this._cull=e,this._isCullDirty=!0)}get depthFunc(){return this._depthFunc}set depthFunc(e){this._depthFunc!==e&&(this._depthFunc=e,this._isDepthFuncDirty=!0)}get depthMask(){return this._depthMask}set depthMask(e){this._depthMask!==e&&(this._depthMask=e,this._isDepthMaskDirty=!0)}get depthTest(){return this._depthTest}set depthTest(e){this._depthTest!==e&&(this._depthTest=e,this._isDepthTestDirty=!0)}get frontFace(){return this._frontFace}set frontFace(e){this._frontFace!==e&&(this._frontFace=e,this._isFrontFaceDirty=!0)}reset(){this._depthMask=!0,this._depthTest=!0,this._depthFunc=null,this._cullFace=null,this._cull=null,this._zOffset=0,this._zOffsetUnits=0,this._frontFace=null,this._isDepthTestDirty=!0,this._isDepthMaskDirty=!0,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!0,this._isFrontFaceDirty=!1}apply(e){this.isDirty&&(this._isCullDirty&&(this.cull?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this._isCullDirty=!1),this._isCullFaceDirty&&(e.cullFace(this.cullFace),this._isCullFaceDirty=!1),this._isDepthMaskDirty&&(e.depthMask(this.depthMask),this._isDepthMaskDirty=!1),this._isDepthTestDirty&&(this.depthTest?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this._isDepthTestDirty=!1),this._isDepthFuncDirty&&(e.depthFunc(this.depthFunc),this._isDepthFuncDirty=!1),this._isZOffsetDirty&&(this.zOffset||this.zOffsetUnits?(e.enable(e.POLYGON_OFFSET_FILL),e.polygonOffset(this.zOffset,this.zOffsetUnits)):e.disable(e.POLYGON_OFFSET_FILL),this._isZOffsetDirty=!1),this._isFrontFaceDirty&&(e.frontFace(this.frontFace),this._isFrontFaceDirty=!1))}}class NU{get isDirty(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty}get func(){return this._func}set func(e){this._func!==e&&(this._func=e,this._isStencilFuncDirty=!0)}get backFunc(){return this._func}set backFunc(e){this._backFunc!==e&&(this._backFunc=e,this._isStencilFuncDirty=!0)}get funcRef(){return this._funcRef}set funcRef(e){this._funcRef!==e&&(this._funcRef=e,this._isStencilFuncDirty=!0)}get funcMask(){return this._funcMask}set funcMask(e){this._funcMask!==e&&(this._funcMask=e,this._isStencilFuncDirty=!0)}get opStencilFail(){return this._opStencilFail}set opStencilFail(e){this._opStencilFail!==e&&(this._opStencilFail=e,this._isStencilOpDirty=!0)}get opDepthFail(){return this._opDepthFail}set opDepthFail(e){this._opDepthFail!==e&&(this._opDepthFail=e,this._isStencilOpDirty=!0)}get opStencilDepthPass(){return this._opStencilDepthPass}set opStencilDepthPass(e){this._opStencilDepthPass!==e&&(this._opStencilDepthPass=e,this._isStencilOpDirty=!0)}get backOpStencilFail(){return this._backOpStencilFail}set backOpStencilFail(e){this._backOpStencilFail!==e&&(this._backOpStencilFail=e,this._isStencilOpDirty=!0)}get backOpDepthFail(){return this._backOpDepthFail}set backOpDepthFail(e){this._backOpDepthFail!==e&&(this._backOpDepthFail=e,this._isStencilOpDirty=!0)}get backOpStencilDepthPass(){return this._backOpStencilDepthPass}set backOpStencilDepthPass(e){this._backOpStencilDepthPass!==e&&(this._backOpStencilDepthPass=e,this._isStencilOpDirty=!0)}get mask(){return this._mask}set mask(e){this._mask!==e&&(this._mask=e,this._isStencilMaskDirty=!0)}get enabled(){return this._enabled}set enabled(e){this._enabled!==e&&(this._enabled=e,this._isStencilTestDirty=!0)}constructor(e=!0){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.useStencilGlobalOnly=!1,e&&this.reset()}reset(){this.stencilMaterial=void 0,this.stencilGlobal?.reset(),this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0}apply(e){if(!e)return;const t=!this.useStencilGlobalOnly&&!!this.stencilMaterial?.enabled;this.enabled=t?this.stencilMaterial.enabled:this.stencilGlobal.enabled,this.func=t?this.stencilMaterial.func:this.stencilGlobal.func,this.backFunc=t?this.stencilMaterial.backFunc:this.stencilGlobal.backFunc,this.funcRef=t?this.stencilMaterial.funcRef:this.stencilGlobal.funcRef,this.funcMask=t?this.stencilMaterial.funcMask:this.stencilGlobal.funcMask,this.opStencilFail=t?this.stencilMaterial.opStencilFail:this.stencilGlobal.opStencilFail,this.opDepthFail=t?this.stencilMaterial.opDepthFail:this.stencilGlobal.opDepthFail,this.opStencilDepthPass=t?this.stencilMaterial.opStencilDepthPass:this.stencilGlobal.opStencilDepthPass,this.backOpStencilFail=t?this.stencilMaterial.backOpStencilFail:this.stencilGlobal.backOpStencilFail,this.backOpDepthFail=t?this.stencilMaterial.backOpDepthFail:this.stencilGlobal.backOpDepthFail,this.backOpStencilDepthPass=t?this.stencilMaterial.backOpStencilDepthPass:this.stencilGlobal.backOpStencilDepthPass,this.mask=t?this.stencilMaterial.mask:this.stencilGlobal.mask,this.isDirty&&(this._isStencilTestDirty&&(this.enabled?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(e.stencilMask(this.mask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(e.stencilFuncSeparate(e.FRONT,this.func,this.funcRef,this.funcMask),e.stencilFuncSeparate(e.BACK,this.backFunc,this.funcRef,this.funcMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOpSeparate(e.FRONT,this.opStencilFail,this.opDepthFail,this.opStencilDepthPass),e.stencilOpSeparate(e.BACK,this.backOpStencilFail,this.backOpDepthFail,this.backOpStencilDepthPass),this._isStencilOpDirty=!1))}}class Js{constructor(){this.reset()}reset(){this.enabled=!1,this.mask=255,this.funcRef=1,this.funcMask=255,this.func=Js.ALWAYS,this.opStencilFail=Js.KEEP,this.opDepthFail=Js.KEEP,this.opStencilDepthPass=Js.REPLACE,this.backFunc=Js.ALWAYS,this.backOpStencilFail=Js.KEEP,this.backOpDepthFail=Js.KEEP,this.backOpStencilDepthPass=Js.REPLACE}get stencilFunc(){return this.func}set stencilFunc(e){this.func=e}get stencilBackFunc(){return this.backFunc}set stencilBackFunc(e){this.backFunc=e}get stencilFuncRef(){return this.funcRef}set stencilFuncRef(e){this.funcRef=e}get stencilFuncMask(){return this.funcMask}set stencilFuncMask(e){this.funcMask=e}get stencilOpStencilFail(){return this.opStencilFail}set stencilOpStencilFail(e){this.opStencilFail=e}get stencilOpDepthFail(){return this.opDepthFail}set stencilOpDepthFail(e){this.opDepthFail=e}get stencilOpStencilDepthPass(){return this.opStencilDepthPass}set stencilOpStencilDepthPass(e){this.opStencilDepthPass=e}get stencilBackOpStencilFail(){return this.backOpStencilFail}set stencilBackOpStencilFail(e){this.backOpStencilFail=e}get stencilBackOpDepthFail(){return this.backOpDepthFail}set stencilBackOpDepthFail(e){this.backOpDepthFail=e}get stencilBackOpStencilDepthPass(){return this.backOpStencilDepthPass}set stencilBackOpStencilDepthPass(e){this.backOpStencilDepthPass=e}get stencilMask(){return this.mask}set stencilMask(e){this.mask=e}get stencilTest(){return this.enabled}set stencilTest(e){this.enabled=e}}Js.ALWAYS=519;Js.KEEP=7680;Js.REPLACE=7681;class aC{constructor(e){this._supportBlendParametersPerTarget=e,this._blendFunctionParameters=new Array(32),this._blendEquationParameters=new Array(16),this._blendConstants=new Array(4),this._isBlendConstantsDirt
226y=!1,this._alphaBlend=Array(8).fill(!1),this._numTargetEnabled=0,this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this.reset()}get isDirty(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty||this._isBlendEquationParametersDirty}get alphaBlend(){return this._numTargetEnabled>0}setAlphaBlend(e,t=0){this._alphaBlend[t]!==e&&(e?this._numTargetEnabled++:this._numTargetEnabled--,this._alphaBlend[t]=e,this._isAlphaBlendDirty=!0)}setAlphaBlendConstants(e,t,i,s){this._blendConstants[0]===e&&this._blendConstants[1]===t&&this._blendConstants[2]===i&&this._blendConstants[3]===s||(this._blendConstants[0]=e,this._blendConstants[1]=t,this._blendConstants[2]=i,this._blendConstants[3]=s,this._isBlendConstantsDirty=!0)}setAlphaBlendFunctionParameters(e,t,i,s,r=0){const a=r*4;this._blendFunctionParameters[a+0]===e&&this._blendFunctionParameters[a+1]===t&&this._blendFunctionParameters[a+2]===i&&this._blendFunctionParameters[a+3]===s||(this._blendFunctionParameters[a+0]=e,this._blendFunctionParameters[a+1]=t,this._blendFunctionParameters[a+2]=i,this._blendFunctionParameters[a+3]=s,this._isBlendFunctionParametersDirty=!0)}setAlphaEquationParameters(e,t,i=0){const s=i*2;this._blendEquationParameters[s+0]===e&&this._blendEquationParameters[s+1]===t||(this._blendEquationParameters[s+0]=e,this._blendEquationParameters[s+1]=t,this._isBlendEquationParametersDirty=!0)}reset(){this._alphaBlend.fill(!1),this._numTargetEnabled=0,this._blendFunctionParameters.fill(null),this._blendEquationParameters.fill(null),this._blendConstants[0]=null,this._blendConstants[1]=null,this._blendConstants[2]=null,this._blendConstants[3]=null,this._isAlphaBlendDirty=!0,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1}apply(e,t=1){if(!this.isDirty)return;if(this._isBlendConstantsDirty&&(e.blendColor(this._blendConstants[0],this._blendConstants[1],this._blendConstants[2],this._blendConstants[3]),this._isBlendConstantsDirty=!1),t===1||!this._supportBlendParametersPerTarget){this._isAlphaBlendDirty&&(this._alphaBlend[0]?e.enable(e.BLEND):e.disable(e.BLEND),this._isAlphaBlendDirty=!1),this._isBlendFunctionParametersDirty&&(e.blendFuncSeparate(this._blendFunctionParameters[0],this._blendFunctionParameters[1],this._blendFunctionParameters[2],this._blendFunctionParameters[3]),this._isBlendFunctionParametersDirty=!1),this._isBlendEquationParametersDirty&&(e.blendEquationSeparate(this._blendEquationParameters[0],this._blendEquationParameters[1]),this._isBlendEquationParametersDirty=!1);return}const i=e;if(this._isAlphaBlendDirty){for(let s=0;s<t;s++){const r=s<this._numTargetEnabled?s:0;this._alphaBlend[r]?i.enableIndexed(e.BLEND,s):i.disableIndexed(e.BLEND,s)}this._isAlphaBlendDirty=!1}if(this._isBlendFunctionParametersDirty){for(let s=0;s<t;s++){const r=s<this._numTargetEnabled?s*4:0;i.blendFuncSeparateIndexed(s,this._blendFunctionParameters[r+0],this._blendFunctionParameters[r+1],this._blendFunctionParameters[r+2],this._blendFunctionParameters[r+3])}this._isBlendFunctionParametersDirty=!1}if(this._isBlendEquationParametersDirty){for(let s=0;s<t;s++){const r=s<this._numTargetEnabled?s*2:0;i.blendEquationSeparateIndexed(s,this._blendEquationParameters[r+0],this._blendEquationParameters[r+1])}this._isBlendEquationParametersDirty=!1}}setAlphaMode(e,t){let i=32774;switch(e){case 0:break;case 7:this.setAlphaBlendFunctionParameters(1,771,1,1,t);break;case 8:this.setAlphaBlendFunctionParameters(1,771,1,771,t);break;case 2:this.setAlphaBlendFunctionParameters(770,771,1,1,t);break;case 6:this.setAlphaBlendFunctionParameters(1,1,0,1,t);break;case 1:this.setAlphaBlendFunctionParameters(770,1,0,1,t);break;case 3:this.setAlphaBlendFunctionParameters(0,769,1,1,t),i=32778;break;case 4:this.setAlphaBlendFunctionParameters(774,0,1,1,t);break;case 5:this.setAlphaBlendFunctionParameters(770,769,1,1,t);break;case 9:this.setAlphaBlendFunctionParameters(32769,32770,32771,32772,t);break;case 10:this.setAlphaBlendFunctionParameters(1,769,1,771,t);break;case 11:this.setAlphaBlendFunctionParameters(1,1,1,1,t);break;case 12:this.setAlphaBlendFunctionParameters(772,1,0,0,t);break;case 13:this.setAlphaBlendFunctionParameters(775,769,773,771,t);break;case 14:this.setAlphaBlendFunctionParameters(1,771,1,771,t);break;case 15:this.setAlphaBlendFunctionParameters(1,1,1,0,t);break;case 16:this.setAlphaBlendFunctionParameters(775,769,0,1,t);break;case 17:this.setAlphaBlendFunctionParameters(770,771,1,771,t);break;case 18:this.setAlphaBlendFunctionParameters(1,1,1,1,t),i=32775;break;case 19:this.setAlphaBlendFunctionParameters(1,1,1,1,t),i=32776;break;case 20:this.setAlphaBlendFunctionParameters(1,35065,0,1,t);break}this.setAlphaEquationParameters(i,i,t)}}const BU="modulepreload",UU=function(n){return"/"+n},oT={},_t=function(e,t,i){let s=Promise.resolve();if(t&&t.length>0){let c=function(u){return Promise.all(u.map(d=>Promise.resolve(d).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}
226))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=a?.nonce||a?.getAttribute("nonce");s=c(t.map(u=>{if(u=UU(u),u in oT)return;oT[u]=!0;const d=u.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${f}`))return;const g=document.createElement("link");if(g.rel=d?"stylesheet":BU,d||(g.as="script"),g.crossOrigin="",g.href=u,o&&g.setAttribute("nonce",o),document.head.appendChild(g),d)return new Promise((m,b)=>{g.addEventListener("load",m),g.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${u}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return s.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return e().catch(r)})},Qd=new Map;function jn(n,e){kU(n)&&oe.Warn(`Extension with the name '${n}' already exists`),Qd.set(n,e)}function kU(n){return Qd.delete(n)}function VU(n,e){(e==="image/ktx"||e==="image/ktx2")&&(n=".ktx"),Qd.has(n)||(n.endsWith(".ies")&&jn(".ies",async()=>await _t(()=>import("./iesTextureLoader-DyFJfGfD.js"),[]).then(i=>new i._IESTextureLoader)),n.endsWith(".dds")&&jn(".dds",async()=>await _t(()=>import("./ddsTextureLoader-BYSe_S31.js"),__vite__mapDeps([0,1,2])).then(i=>new i._DDSTextureLoader)),n.endsWith(".basis")&&jn(".basis",async()=>await _t(()=>import("./basisTextureLoader-BPItgXz4.js"),[]).then(i=>new i._BasisTextureLoader)),n.endsWith(".env")&&jn(".env",async()=>await _t(()=>import("./envTextureLoader-DDBJ-Fu2.js"),__vite__mapDeps([3,2,4])).then(i=>new i._ENVTextureLoader)),n.endsWith(".hdr")&&jn(".hdr",async()=>await _t(()=>import("./hdrTextureLoader-CYA8LatR.js"),[]).then(i=>new i._HDRTextureLoader)),(n.endsWith(".ktx")||n.endsWith(".ktx2"))&&(jn(".ktx",async()=>await _t(()=>import("./ktxTextureLoader-B1H5Vjed.js"),[]).then(i=>new i._KTXTextureLoader)),jn(".ktx2",async()=>await _t(()=>import("./ktxTextureLoader-B1H5Vjed.js"),[]).then(i=>new i._KTXTextureLoader))),n.endsWith(".tga")&&jn(".tga",async()=>await _t(()=>import("./tgaTextureLoader-N0BzC_ur.js"),[]).then(i=>new i._TGATextureLoader)),n.endsWith(".exr")&&jn(".exr",async()=>await _t(()=>import("./exrTextureLoader-BdLvETDk.js"),[]).then(i=>new i._ExrTextureLoader)));const t=Qd.get(n);return t?Promise.resolve(t(e)):null}function oC(n,e){if(Gi()){const{requestAnimationFrame:t}=e||window;if(typeof t=="function")return t(n)}else if(typeof requestAnimationFrame=="function")return requestAnimationFrame(n);return setTimeout(n,16)}class Ce{get frameId(){return this._frameId}get isWebGPU(){return this._isWebGPU}_getShaderProcessor(e){return this._shaderProcessor}_resetAlphaMode(){this._alphaMode.fill(-1),this._alphaEquation.fill(-1)}get shaderPlatformName(){return this._shaderPlatformName}_clearEmptyResources(){this._emptyTexture=null,this._emptyCubeTexture=null,this._emptyTexture3D=null,this._emptyTexture2DArray=null}get useReverseDepthBuffer(){return this._useReverseDepthBuffer}set useReverseDepthBuffer(e){e!==this._useReverseDepthBuffer&&(this._useReverseDepthBuffer=e,e?this._depthCullingState.depthFunc=518:this._depthCullingState.depthFunc=515)}setColorWrite(e){e!==this._colorWrite&&(this._colorWriteChanged=!0,this._colorWrite=e)}getColorWrite(){return this._colorWrite}get depthCullingState(){return this._depthCullingState}get alphaState(){return this._alphaState}get stencilState(){return this._stencilState}get stencilStateComposer(){return this._stencilStateComposer}_getGlobalDefines(e){if(e){this.isNDCHalfZRange?e.IS_NDC_HALF_ZRANGE="":delete e.IS_NDC_HALF_ZRANGE,this.useReverseDepthBuffer?e.USE_REVERSE_DEPTHBUFFER="":delete e.USE_REVERSE_DEPTHBUFFER,this.useExactSrgbConversions?e.USE_EXACT_SRGB_CONVERSIONS="":delete e.USE_EXACT_SRGB_CONVERSIONS;return}else{let t="";return this.isNDCHalfZRange&&(t+="#define IS_NDC_HALF_ZRANGE"),this.useReverseDepthBuffer&&(t&&(t+=` 227`),t+="#define USE_REVERSE_DEPTHBUFFER"),this.useExactSrgbConversions&&(t&&(t+=` 228`),t+="#define USE_EXACT_SRGB_CONVERSIONS"),t}}_rebuildInternalTextures(){const e=this._internalTexturesCache.slice();for(const t of e)t._rebuild()}_rebuildRenderTargetWrappers(){const e=this._renderTargetWrapperCache.slice();for(const t of e)t._rebuild()}_rebuildEffects(){for(const e in this._compiledEffects){const t=this._compiledEffects[e];
vendor: 29,568 bytes, line 228
228t._pipelineContext=null,t._prepareEffect()}At.ResetCache()}_rebuildGraphicsResources(){this.wipeCaches(!0),this._rebuildEffects(),this._rebuildComputeEffects?.(),this._rebuildBuffers(),this._rebuildInternalTextures(),this._rebuildTextures(),this._rebuildRenderTargetWrappers(),this.wipeCaches(!0)}_flagContextRestored(){oe.Warn(this.name+" context successfully restored."),this.onContextRestoredObservable.notifyObservers(this),this._contextWasLost=!1}_restoreEngineAfterContextLost(e){setTimeout(()=>{this._clearEmptyResources();const t=this._depthCullingState.depthTest,i=this._depthCullingState.depthFunc,s=this._depthCullingState.depthMask,r=this._stencilState.stencilTest;e(),this._rebuildGraphicsResources(),this._depthCullingState.depthTest=t,this._depthCullingState.depthFunc=i,this._depthCullingState.depthMask=s,this._stencilState.stencilTest=r,this._flagContextRestored()},0)}get isDisposed(){return this._isDisposed}get snapshotRendering(){return!1}set snapshotRendering(e){}get snapshotRenderingMode(){return 0}set snapshotRenderingMode(e){}getClassName(){return"AbstractEngine"}get emptyTexture(){return this._emptyTexture||(this._emptyTexture=this.createRawTexture(new Uint8Array(4),1,1,5,!1,!1,1)),this._emptyTexture}get emptyTexture3D(){return this._emptyTexture3D||(this._emptyTexture3D=this.createRawTexture3D(new Uint8Array(4),1,1,1,5,!1,!1,1)),this._emptyTexture3D}get emptyTexture2DArray(){return this._emptyTexture2DArray||(this._emptyTexture2DArray=this.createRawTexture2DArray(new Uint8Array(4),1,1,1,5,!1,!1,1)),this._emptyTexture2DArray}get emptyCubeTexture(){if(!this._emptyCubeTexture){const e=new Uint8Array(4),t=[e,e,e,e,e,e];this._emptyCubeTexture=this.createRawCubeTexture(t,1,5,0,!1,!1,1)}return this._emptyCubeTexture}get activeRenderLoops(){return this._activeRenderLoops}stopRenderLoop(e){if(!e){this._activeRenderLoops.length=0,this._cancelFrame();return}const t=this._activeRenderLoops.indexOf(e);t>=0&&(this._activeRenderLoops.splice(t,1),this._activeRenderLoops.length==0&&this._cancelFrame())}_cancelFrame(){if(this._frameHandler!==0){const e=this._frameHandler;if(this._frameHandler=0,Gi()){const{cancelAnimationFrame:t}=this.getHostWindow()||window;if(typeof t=="function")return t(e)}else if(typeof cancelAnimationFrame=="function")return cancelAnimationFrame(e);return clearTimeout(e)}}beginFrame(){this.onBeginFrameObservable.notifyObservers(this)}endFrame(){this._frameId++,this.onEndFrameObservable.notifyObservers(this)}get maxFPS(){return this._maxFPS}set maxFPS(e){if(this._maxFPS=e,e!==void 0){if(e<=0){this._minFrameTime=Number.MAX_VALUE;return}this._minFrameTime=1e3/e}}_isOverFrameTime(e){if(!e||this._maxFPS===void 0)return!1;const t=e-this._lastFrameTime;return this._lastFrameTime=e,this._renderAccumulator+=t,this._renderAccumulator<this._minFrameTime?!0:(this._renderAccumulator-=this._minFrameTime,this._renderAccumulator>this._minFrameTime&&(this._renderAccumulator=this._minFrameTime),!1)}_processFrame(e){if(this._frameHandler=0,!this._contextWasLost&&!this._isOverFrameTime(e)){let t=!0;(this.isDisposed||!this.renderEvenInBackground&&this._windowIsBackground)&&(t=!1),t&&(this.beginFrame(),!this.skipFrameRender&&!this._renderViews()&&this._renderFrame(),this.endFrame())}}_renderLoop(e){this._processFrame(e),this._activeRenderLoops.length>0&&this._frameHandler===0&&(this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()))}_renderFrame(){for(let e=0;e<this._activeRenderLoops.length;e++){const t=this._activeRenderLoops[e];t()}}_renderViews(){return!1}_queueNewFrame(e,t){return oC(e,t)}runRenderLoop(e){this._activeRenderLoops.indexOf(e)===-1&&(this._activeRenderLoops.push(e),this._activeRenderLoops.length===1&&this._frameHandler===0&&(this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow())))}getDepthBuffer(){return this._depthCullingState.depthTest}setDepthBuffer(e){this._depthCullingState.depthTest=e}setZOffset(e){this._depthCullingState.zOffset=this.useReverseDepthBuffer?-e:e}getZOffset(){const e=this._depthCullingState.zOffset;return this.useReverseDepthBuffer?-e:e}setZOffsetUnits(e){this._depthCullingState.zOffsetUnits=this.useReverseDepthBuffer?-e:e}getZOffsetUnits(){const e=this._depthCullingState.zOffsetUnits;return this.useReverseDepthBuffer?-e:e}getHostWindow(){return Gi()?this._renderingCanvas&&this._renderingCanvas.ownerDocument&&this._renderingCanvas.ownerDocument.defaultView?this._renderingCanvas.ownerDocument.defaultView:window:null}get compatibilityMode(){return this._compatibilityMode}set compatibilityMode(e){this._compatibilityMode=!0}_rebuildTextures(){for(const e of this.scenes)e._rebuildTextures();for(const e of this._virtualScenes)e._rebuildTextures()}_releaseRenderTargetWrapper(e){const t=this._renderTargetWrapperCache.indexOf(e);t!==-1&&this._renderTargetWrapperCache.splice(t,1)}get currentViewport(){return this._cachedViewport}setViewport(e,t,i){const s=t||this.getRenderWidth(),r=i||this.getRenderHeight(),a=e.x||0,o=e.y||0;this._cachedViewport=e,this._viewport(a*s,o*r,s*e.width,r*e.height)}createCanvasImage(){return document.createElement("img")}createCanvasPath2D(e){return new Path2D(e)}get description(){let e=this.name+this.version;return this._caps.parallelShaderCompile&&(e+=" - Parallel shader compilation"),e}_createTextureBase(e,t,i,s,r=3,a=null,o=null,c,u,d=null,f=null,g=null,m=null,b,x,v){e=e||"";const E=e.substring(0,5)==="data:",A=e.substring(0,5)==="blob:",D=E&&e.indexOf(";base64,")!==-1,I=f||new Cs(this,1);I!==f&&(I.label=e.substring(0,60));const R=e;this._transformTextureUrl&&!D&&!f&&!d&&(e=this._transformTextureUrl(e)),R!==e&&(I._originalUrl=R);const C=e.lastIndexOf(".");let M=m||(C>-1?e.substring(C).toLowerCase():"");M.indexOf("?")>-1&&(M=M.split("?")[0]);const U=VU(M,b);s&&s.addPendingData(I),I.url=e,I.generateMipMaps=!t,I.samplingMode=r,I.invertY=i,I._useSRGBBuffer=this._getUseSRGBBuffer(!!v,t),this._doNotHandleContextLost||(I._buffer=d);let k=null;a&&!f&&(k=I.onLoadedObservable.add(a)),f||this._internalTexturesCache.push(I);const q=(Q,ie)=>{s&&s.removePendingData(I),e===R?(k&&I.onLoadedObservable.remove(k),Ke.UseFallbackTexture&&e!==Ke.FallbackTexture&&this._createTextureBase(Ke.FallbackTexture,t,I.invertY,s,r,null,o,c,u,d,I),Q=(Q||"Unknown error")+(Ke.UseFallbackTexture?" - Fallback texture was used":""),I.onErrorObservable.notifyObservers({message:Q,exception:ie}),o&&o(Q,ie)):(oe.Warn(`Failed to load ${e}, falling back to ${R}`),this._createTextureBase(R,t,I.invertY,s,r,a,o,c,u,d,I,g,m,b,x,v))};if(U){const Q=async ie=>{(await U).loadData(ie,I,(ce,G,K,X,J,se)=>{se?q("TextureLoader failed to load data"):c(I,M,s,{width:ce,height:G},I.invertY,!K,X,()=>(J(),!1),r)},x)};d?d instanceof ArrayBuffer?Q(new Uint8Array(d)):ArrayBuffer.isView(d)?Q(d):o&&o("Unable to load: only ArrayBuffer or ArrayBufferView is supported",null):this._loadFile(e,ie=>{Q(new Uint8Array(ie))},void 0,s?s.offlineProvider:void 0,!0,(ie,$)=>{q("Unable to load "+(ie&&ie.responseURL,$))})}else{const Q=ie=>{A&&!this._doNotHandleContextLost&&(I._buffer=ie),c(I,M,s,ie,I.invertY,t,!1,u,r)};!E||D?d&&(typeof d.decoding=="string"||d.close)?Q(d):Ce._FileToolsLoadImage(e||"",Q,q,s?s.offlineProvider:null,b,I.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0,this):typeof d=="string"||d instanceof ArrayBuffer||ArrayBuffer.isView(d)||d instanceof Blob?Ce._FileToolsLoadImage(d,Q,q,s?s.offlineProvider:null,b,I.invertY&&this._features.needsInvertingBitmap?{imageOrientation:"flipY"}:void 0,this):d&&Q(d)}return I}_rebuildBuffers(){for(const e of this._uniformBuffers)e._rebuildAfterContextLost()}get _shouldUseHighPrecisionShader(){return!!(this._caps.highPrecisionShaderSupported&&this._highPrecisionShadersAllowed)}getHostDocument(){return this._renderingCanvas&&this._renderingCanvas.ownerDocument?this._renderingCanvas.ownerDocument:bh()?document:null}getLoadedTexturesCache(){return this._internalTexturesCache}clearInternalTexturesCache(){this._internalTexturesCache.length=0}getCaps(){return this._caps}resetTextureCache(){for(const e in this._boundTexturesCache)Object.prototype.hasOwnProperty.call(this._boundTexturesCache,e)&&(this._boundTexturesCache[e]=null);this._currentTextureChannel=-1}get name(){return this._name}set name(e){this._name=e}static get NpmPackage(){return"[email protected]"}static get Version(){return"8.38.0"}getRenderingCanvas(){return this._renderingCanvas}getAudioContext(){return this._audioContext}getAudioDestination(){return this._audioDestination}setHardwareScalingLevel(e){this._hardwareScalingLevel=e,this.resize()}getHardwareScalingLevel(){return this._hardwareScalingLevel}get doNotHandleContextLost(){return this._doNotHandleContextLost}set doNotHandleContextLost(e){this._doNotHandleContextLost=e}get isStencilEnable(){return this._isStencilEnable}getCreationOptions(){return this._creationOptions}constructor(e,t,i){this._colorWrite=!0,this._colorWriteChanged=!0,this._depthCullingState=new LU,this._stencilStateComposer=new NU,this._stencilState=new Js,this._alphaState=new aC(!1),this._alphaMode=Array(8).fill(-1),this._alphaEquation=Array(8).fill(-1),this._activeRequests=[],this._badOS=!1,this._badDesktopOS=!1,this._compatibilityMode=!0,this._internalTexturesCache=new Array,this._currentRenderTarget=null,this._boundTexturesCache={},this._activeChannel=0,this._currentTextureChannel=-1,this._viewportCached={x:0,y:0,z:0,w:0},this._isWebGPU=!1,this.onCanvasBlurObservable=new le,this.onCanvasFocusObservable=new le,this.onNewSceneAddedObservable=new le,this.onResizeObservable=new le,this.onCanvasPointerOutObservable=new le,this.onEffectErrorObservable=new le,this.disablePerformanceMonitorInBackground=!1,this.disableVertexArrayObjects=!1,this._frameId=0,this.hostInformation={isMobile:!1},this.isFullscreen=!1,this.enableOfflineSupport=!1,this.disableManifestCheck=!1,this.disableContextMenu=!0,this.currentRenderPassId=0,this.isPointerLock=!1,this.postProcesses=[],this.canvasTabIndex=1,this._contextWasLost=!1,this._useReverseDepthBuffer=!1,this.isNDCHalfZRange=!1,this.hasOriginBottomLeft=!0,this._renderTargetWrapperCache=new Array,this._compiledEffects={},this._isDisposed=!1,this.scenes=[],this._virtualScenes=new Array,this.onBeforeTextureInitObservable=new le,this.renderEvenInBackground=!0,this.preventCacheWipeBetweenFrames=!1,this._frameHandler=0,this._activeRenderLoops=new Array,this._windowIsBackground=!1,this._boundRenderFunction=a=>this._renderLoop(a),this._lastFrameTime=0,this._renderAccumulator=0,this.skipFrameRender=!1,this.onBeforeShaderCompilationObservable=new le,this.onAfterShaderCompilationObservable=new le,this.onBeginFrameObservable=new le,this.onEndFrameObservable=new le,this._transformTextureUrl=null,this._uniformBuffers=new Array,this._storageBuffers=new Array,this._highPrecisionShadersAllowed=!0,this.onContextLostObservable=new le,this.onContextRestoredObservable=new le,this._name="",this.premultipliedAlpha=!0,this.adaptToDeviceRatio=!1,this._lastDevicePixelRatio=1,this._doNotHandleContextLost=!1,this.cullBackFaces=null,this._renderPassNames=["main"],this._fps=60,this._deltaTime=0,this._deterministicLockstep=!1,this._lockstepMaxSteps=4,this._timeStep=1/60,this.onDisposeObservable=new le,this.onReleaseEffectsObservable=new le,Ke.Instances.push(this),this.startTime=nr.Now,this._stencilStateComposer.stencilGlobal=this._stencilState,Oi.SetMatrixPrecision(!!t.useLargeWorldRendering||!!t.useHighPrecisionMatrix),Xl()&&navigator.userAgent&&(this._badOS=/iPad/i.test(navigator.userAgent)||/iPhone/i.test(navigator.userAgent),this._badDesktopOS=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)),this.adaptToDeviceRatio=i??!1,t.antialias=e??t.antialias,t.deterministicLockstep=t.deterministicLockstep??!1,t.lockstepMaxSteps=t.lockstepMaxSteps??4,t.timeStep=t.timeStep??1/60,t.stencil=t.stencil??!0,this._audioContext=t.audioEngineOptions?.audioContext??null,this._audioDestination=t.audioEngineOptions?.audioDestination??null,this.premultipliedAlpha=t.premultipliedAlpha??!0,this._doNotHandleContextLost=!!t.doNotHandleContextLost,this._isStencilEnable=!!t.stencil,this.useExactSrgbConversions=t.useExactSrgbConversions??!1;const s=Gi()&&window.devicePixelRatio||1,r=t.limitDeviceRatio||s;i=i||t.adaptToDeviceRatio||!1,this._hardwareScalingLevel=i?1/Math.min(r,s):1,this._lastDevicePixelRatio=s,this._creationOptions=t}resize(e=!1){let t,i;if(this.adaptToDeviceRatio){const s=Gi()&&window.devicePixelRatio||1,r=this._lastDevicePixelRatio/s;this._lastDevicePixelRatio=s,this._hardwareScalingLevel*=r}if(Gi()&&bh())if(this._renderingCanvas){const s=this._renderingCanvas.getBoundingClientRect?.();t=this._renderingCanvas.clientWidth||s?.width||this._renderingCanvas.width*this._hardwareScalingLevel||100,i=this._renderingCanvas.clientHeight||s?.height||this._renderingCanvas.height*this._hardwareScalingLevel||100}else t=window.innerWidth,i=window.innerHeight;else t=this._renderingCanvas?this._renderingCanvas.width:100,i=this._renderingCanvas?this._renderingCanvas.height:100;this.setSize(t/this._hardwareScalingLevel,i/this._hardwareScalingLevel,e)}setSize(e,t,i=!1){if(!this._renderingCanvas||(e=e|0,t=t|0,!i&&this._renderingCanvas.width===e&&this._renderingCanvas.height===t))return!1;if(this._renderingCanvas.width=e,this._renderingCanvas.height=t,this.scenes){for(let s=0;s<this.scenes.length;s++){const r=this.scenes[s];for(let a=0;a<r.cameras.length;a++){const o=r.cameras[a];o._currentRenderId=0}}this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this)}return!0}createRawTexture(e,t,i,s,r,a,o,c,u,d,f){throw We("engine.rawTexture")}createRawCubeTexture(e,t,i,s,r,a,o,c){throw We("engine.rawTexture")}createRawTexture3D(e,t,i,s,r,a,o,c,u,d,f){throw We("engine.rawTexture")}createRawTexture2DArray(e,t,i,s,r,a,o,c,u,d,f){throw We("engine.rawTexture")}_sharedInit(e){this._renderingCanvas=e}_setupMobileChecks(){navigator&&navigator.userAgent&&(this._checkForMobile=()=>{const e=navigator.userAgent;this.hostInformation.isMobile=e.indexOf("Mobile")!==-1||e.indexOf("Mac")!==-1&&bh()&&"ontouchend"in document},this._checkForMobile(),Gi()&&window.addEventListener("resize",this._checkForMobile))}createVideoElement(e){return document.createElement("video")}_reportDrawCall(e=1){this._drawCalls?.addCount(e,!1)}getFps(){return this._fps}getDeltaTime(){return this._deltaTime}isDeterministicLockStep(){return this._deterministicLockstep}getLockstepMaxSteps(){return this._lockstepMaxSteps}getTimeStep(){return this._timeStep*1e3}_createImageBitmapFromSource(e,t){throw new Error("createImageBitmapFromSource is not implemented")}createImageBitmap(e,t){return createImageBitmap(e,t)}resizeImageBitmap(e,t,i){throw new Error("resizeImageBitmap is not implemented")}getFontOffset(e){throw new Error("getFontOffset is not implemented")}static _CreateCanvas(e,t){if(typeof document>"u")return new OffscreenCanvas(e,t);const i=document.createElement("canvas");return i.width=e,i.height=t,i}createCanvas(e,t){return Ce._CreateCanvas(e,t)}static _FileToolsLoadImage(e,t,i,s,r,a,o){throw We("FileTools")}_loadFile(e,t,i,s,r,a){const o=ZM(e,t,i,s,r,a);return this._activeRequests.push(o),o.onCompleteObservable.add(()=>{const c=this._activeRequests.indexOf(o);c!==-1&&this._activeRequests.splice(c,1)}),o}static _FileToolsLoadFile(e,t,i,s,r,a){if(qd.loadFile)return qd.loadFile(e,t,i,s,r,a);throw We("FileTools")}dispose(){for(this.releaseEffects(),this._isDisposed=!0,this.stopRenderLoop(),this._emptyTexture&&(this._releaseTexture(this._emptyTexture),this._emptyTexture=null),this._emptyCubeTexture&&(this._releaseTexture(this._emptyCubeTexture),this._emptyCubeTexture=null),this._renderingCanvas=null,this.onBeforeTextureInitObservable&&this.onBeforeTextureInitObservable.clear();this.postProcesses.length;)this.postProcesses[0].dispose();for(;this.scenes.length;)this.scenes[0].dispose();for(;this._virtualScenes.length;)this._virtualScenes[0].dispose();this.releaseComputeEffects?.(),At.ResetCache();for(const t of this._activeRequests)t.abort();this._boundRenderFunction=null,this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onResizeObservable.clear(),this.onCanvasBlurObservable.clear(),this.onCanvasFocusObservable.clear(),this.onCanvasPointerOutObservable.clear(),this.onNewSceneAddedObservable.clear(),this.onEffectErrorObservable.clear(),Gi()&&window.removeEventListener("resize",this._checkForMobile);const e=Ke.Instances.indexOf(this);e>=0&&Ke.Instances.splice(e,1),Ke.Instances.length||(Ke.OnEnginesDisposedObservable.notifyObservers(this),Ke.OnEnginesDisposedObservable.clear()),this.onBeginFrameObservable.clear(),this.onEndFrameObservable.clear()}static DefaultLoadingScreenFactory(e){throw We("LoadingScreen")}static MarkAllMaterialsAsDirty(e,t){for(let i=0;i<Ke.Instances.length;i++){const s=Ke.Instances[i];for(let r=0;r<s.scenes.length;r++)s.scenes[r].markAllMaterialsAsDirty(e,t)}}}Ce._RenderPassIdCounter=0;Ce._RescalePostProcessFactory=null;Ce.CollisionsEpsilon=.001;Ce.QueueNewFrame=oC;class lC{get underlyingResource(){return this._webGLTexture}constructor(e=null,t){if(this._MSAARenderBuffers=null,this._context=t,!e&&(e=t.createTexture(),!e))throw new Error("Unable to create webGL texture");this.set(e)}setUsage(){}set(e){this._webGLTexture=e}reset(){this._webGLTexture=null,this._MSAARenderBuffers=null}addMSAARenderBuffer(e){this._MSAARenderBuffers||(this._MSAARenderBuffers=[]),this._MSAARenderBuffers.push(e)}releaseMSAARenderBuffers(){if(this._MSAARenderBuffers){for(const e of this._MSAARenderBuffers)this._context.deleteRenderbuffer(e);this._MSAARenderBuffers=null}}getMSAARenderBuffer(e=0){return this._MSAARenderBuffers?.[e]??null}release(){this.releaseMSAARenderBuffers(),this._webGLTexture&&this._context.deleteTexture(this._webGLTexture),this.reset()}}function lT(n){return n===13||n===14||n===15||n===16||n===17||n===18||n===19}function wh(n){return n===13||n===17||n===18||n===19}class zU{}class ot extends Ce{get name(){return this._name}set name(e){this._name=e}get version(){return this._webGLVersion}static get ShadersRepository(){return At.ShadersRepository}static set ShadersRepository(e){At.ShadersRepository=e}get supportsUniformBuffers(){return this.webGLVersion>1&&!this.disableUniformBuffers}get needPOTTextures(){return this._webGLVersion<2||this.forcePOTTextures}get _supportsHardwareTextureRescaling(){return!1}set framebufferDimensionsObject(e){this._framebufferDimensionsObject=e}snapshotRenderingReset(){this.snapshotRendering=!1}constructor(e,t,i,s){if(i=i||{},super(t??i.antialias,i,s),this._name="WebGL",this.forcePOTTextures=!1,this.validateShaderPrograms=!1,this.disableUniformBuffers=!1,this._webGLVersion=1,this._vertexAttribArraysEnabled=[],this._uintIndicesCurrentlySet=!1,this._currentBoundBuffer=new Array,this._currentFramebuffer=null,this._dummyFramebuffer=null,this._currentBufferPointers=new Array,this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._vaoRecordInProgress=!1,this._mustWipeVertexAttributes=!1,this._nextFreeTextureSlots=new Array,this._maxSimultaneousTextures=0,this._maxMSAASamplesOverride=null,this._unpackFlipYCached=null,this.enableUnpackFlipYCached=!0,this._boundUniforms={},!e)return;let r=null;if(e.getContext){if(r=e,i.preserveDrawingBuffer===void 0&&(i.preserveDrawingBuffer=!1),i.xrCompatible===void 0&&(i.xrCompatible=!1),navigator&&navigator.userAgent){this._setupMobileChecks();const c=navigator.userAgent;for(const u of ot.ExceptionList){const d=u.key,f=u.targets;if(new RegExp(d).test(c)){if(u.capture&&u.captureConstraint){const m=u.capture,b=u.captureConstraint,v=new RegExp(m).exec(c);if(v&&v.length>0&&parseInt(v[v.length-1])>=b)continue}for(const m of f)switch(m){case"uniformBuffer":this.disableUniformBuffers=!0;break;case"vao":this.disableVertexArrayObjects=!0;break;case"antialias":i.antialias=!1;break;case"maxMSAASamples":this._maxMSAASamplesOverride=1;break}}}}if(this._doNotHandleContextLost?this._onContextLost=()=>{Pg(this._gl)}:(this._onContextLost=c=>{c.preventDefault(),this._contextWasLost=!0,Pg(this._gl),oe.Warn("WebGL context lost."),this.onContextLostObservable.notifyObservers(this)},this._onContextRestored=()=>{this._restoreEngineAfterContextLost(()=>this._initGLContext())},r.addEventListener("webglcontextrestored",this._onContextRestored,!1),i.powerPreference=i.powerPreference||"high-performance"),r.addEventListener("webglcontextlost",this._onContextLost,!1),this._badDesktopOS&&(i.xrCompatible=!1),!i.disableWebGL2Support)try{this._gl=r.getContext("webgl2",i)||r.getContext("experimental-webgl2",i),this._gl&&(this._webGLVersion=2,this._shaderPlatformName="WEBGL2",this._gl.deleteQuery||(this._webGLVersion=1,this._shaderPlatformName="WEBGL1"))}catch{}if(!this._gl){if(!r)throw new Error("The provided canvas is null or undefined.");try{this._gl=r.getContext("webgl",i)||r.getContext("experimental-webgl",i)}catch{throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported")}else{this._gl=e,r=this._gl.canvas,this._gl.renderbufferStorageMultisample?(this._webGLVersion=2,this._shaderPlatformName="WEBGL2"):this._shaderPlatformName="WEBGL1";const c=this._gl.getContextAttributes();c&&(i.stencil=c.stencil)}this._sharedInit(r),this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,this._gl.NONE),i.useHighPrecisionFloats!==void 0&&(this._highPrecisionShadersAllowed=i.useHighPrecisionFloats),this.resize(),this._initGLContext(),this._initFeatures();for(let c=0;c<this._caps.maxVertexAttribs;c++)this._currentBufferPointers[c]=new zU;this._shaderProcessor=this.webGLVersion>1?new dU:new tC;const a=`Babylon.js v${ot.Version}`;oe.Log(a+` - ${this.description}`),this._renderingCanvas&&this._renderingCanvas.setAttribute&&this._renderingCanvas.setAttribute("data-engine",a);const o=zs(this._gl);o.validateShaderPrograms=this.validateShaderPrograms,o.parallelShaderCompile=this._caps.parallelShaderCompile}_clearEmptyResources(){this._dummyFramebuffer=null,super._clearEmptyResources()}_getShaderProcessingContext(e){return null}areAllEffectsReady(){for(const e in this._compiledEffects)if(!this._compiledEffects[e].isReady())return!1;return!0}_initGLContext(){this._caps={maxTexturesImageUnits:this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),maxCombinedTexturesImageUnits:this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),maxVertexTextureImageUnits:this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),maxSamples:this._webGLVersion>1?this._gl.getParameter(this._gl.MAX_SAMPLES):1,maxCubemapTextureSize:this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),maxRenderTextureSize:this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),maxVertexAttribs:this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),maxVaryingVectors:this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),maxFragmentUniformVectors:this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),maxVertexUniformVectors:this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),shaderFloatPrecision:0,parallelShaderCompile:this._gl.getExtension("KHR_parallel_shader_compile")||void 0,standardDerivatives:this._webGLVersion>1||this._gl.getExtension("OES_standard_derivatives")!==null,maxAnisotropy:1,astc:this._gl.getExtension("WEBGL_compressed_texture_astc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"),bptc:this._gl.getExtension("EXT_texture_compression_bptc")||this._gl.getExtension("WEBKIT_EXT_texture_compression_bptc"),s3tc:this._gl.getExtension("WEBGL_compressed_texture_s3tc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),s3tc_srgb:this._gl.getExtension("WEBGL_compressed_texture_s3tc_srgb")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc_srgb"),pvrtc:this._gl.getExtension("WEBGL_compressed_texture_pvrtc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:this._gl.getExtension("WEBGL_compressed_texture_etc1")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),etc2:this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),textureAnisotropicFilterExtension:this._gl.getExtension("EXT_texture_filter_anisotropic")||this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),uintIndices:this._webGLVersion>1||this._gl.getExtension("OES_element_index_uint")!==null,fragmentDepthSupported:this._webGLVersion>1||this._gl.getExtension("EXT_frag_depth")!==null,highPrecisionShaderSupported:!1,timerQuery:this._gl.getExtension("EXT_disjoint_timer_query_webgl2")||this._gl.getExtension("EXT_disjoint_timer_query"),supportOcclusionQuery:this._webGLVersion>1,canUseTimestampForTimerQuery:!1,drawBuffersExtension:!1,maxMSAASamples:1,colorBufferFloat:!!(this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_float")),blendFloat:this._gl.getExtension("EXT_float_blend")!==null,supportFloatTexturesResolve:!1,rg11b10ufColorRenderable:!1,colorBufferHalfFloat:!!(this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_half_float")),textureFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_float")),textureHalfFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_half_float")),textureHalfFloatRender:!1,textureFloatLinearFiltering:!1,textureFloatRender:!1,textureHalfFloatLinearFiltering:!1,vertexArrayObject:!1,instancedArrays:!1,textureLOD:!!(this._webGLVersion>1||this._gl.getExtension("EXT_shader_texture_lod")),texelFetch:this._webGLVersion!==1,blendMinMax:!1,multiview:this._gl.getExtension("OVR_multiview2"),oculusMultiview:this._gl.getExtension("OCULUS_multiview"),depthTextureExtension:!1,canUseGLInstanceID:this._webGLVersion>1,canUseGLVertexID:this._webGLVersion>1,supportComputeShaders:!1,supportSRGBBuffers:!1,supportTransformFeedbacks:this._webGLVersion>1,textureMaxLevel:this._webGLVersion>1,texture2DArrayMaxLayerCount:this._webGLVersion>1?this._gl.getParameter(this._gl.MAX_ARRAY_TEXTURE_LAYERS):128,disableMorphTargetTexture:!1,textureNorm16:!!this._gl.getExtension("EXT_texture_norm16"),blendParametersPerTarget:!1,dualSourceBlending:!1},this._caps.supportFloatTexturesResolve=this._caps.colorBufferFloat,this._caps.rg11b10ufColorRenderable=this._caps.colorBufferFloat,this._glVersion=this._gl.getParameter(this._gl.VERSION);const e=this._gl.getExtension("WEBGL_debug_renderer_info");e!=null&&(this._glRenderer=this._gl.getParameter(e.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(e.UNMASKED_VENDOR_WEBGL)),this._glVendor||(this._glVendor=this._gl.getParameter(this._gl.VENDOR)||"Unknown vendor"),this._glRenderer||(this._glRenderer=this._gl.getParameter(this._gl.RENDERER)||"Unknown renderer"),this._gl.HALF_FLOAT_OES!==36193&&(this._gl.HALF_FLOAT_OES=36193),this._gl.RGBA16F!==34842&&(this._gl.RGBA16F=34842),this._gl.RGBA32F!==34836&&(this._gl.RGBA32F=34836),this._gl.DEPTH24_STENCIL8!==35056&&(this._gl.DEPTH24_STENCIL8=35056),this._caps.timerQuery&&(this._webGLVersion===1&&(this._gl.getQuery=this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery)),this._caps.canUseTimestampForTimerQuery=(this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT,this._caps.timerQuery.QUERY_COUNTER_BITS_EXT)??0)>0),this._caps.maxAnisotropy=this._caps.textureAnisotropicFilterExtension?this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,this._caps.textureFloatLinearFiltering=!!(this._caps.textureFloat&&this._gl.getExtension("OES_texture_float_linear")),this._caps.textureFloatRender=!!(this._caps.textureFloat&&this._canRenderToFloatFramebuffer()),this._caps.textureHalfFloatLinearFiltering=!!(this._webGLVersion>1||this._caps.textureHalfFloat&&this._gl.getExtension("OES_texture_half_float_linear")),this._caps.textureNorm16&&(this._gl.R16_EXT=33322,this._gl.RG16_EXT=33324,this._gl.RGB16_EXT=32852,this._gl.RGBA16_EXT=32859,this._gl.R16_SNORM_EXT=36760,this._gl.RG16_SNORM_EXT=36761,this._gl.RGB16_SNORM_EXT=36762,this._gl.RGBA16_SNORM_EXT=36763);const t=this._gl.getExtension("OES_draw_buffers_indexed");if(this._caps.blendParametersPerTarget=!!t,this._alphaState=new aC(this._caps.blendParametersPerTarget),t&&(this._gl.blendEquationSeparateIndexed=t.blendEquationSeparateiOES.bind(t),this._gl.blendEquationIndexed=t.blendEquationiOES.bind(t),this._gl.blendFuncSeparateIndexed=t.blendFuncSeparateiOES.bind(t),this._gl.blendFuncIndexed=t.blendFunciOES.bind(t),this._gl.colorMaskIndexed=t.colorMaskiOES.bind(t),this._gl.disableIndexed=t.disableiOES.bind(t),this._gl.enableIndexed=t.enableiOES.bind(t)),this._caps.dualSourceBlending=!!this._gl.getExtension("WEBGL_blend_func_extended"),this._caps.astc&&(this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR),this._caps.bptc&&(this._gl.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=this._caps.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT),this._caps.s3tc_srgb&&(this._gl.COMPRESSED_SRGB_S3TC_DXT1_EXT=this._caps.s3tc_srgb.COMPRESSED_SRGB_S3TC_DXT1_EXT,this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT),this._caps.etc2&&(this._gl.COMPRESSED_SRGB8_ETC2=this._caps.etc2.COMPRESSED_SRGB8_ETC2,this._gl.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=this._caps.etc2.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC),this._webGLVersion>1&&this._gl.HALF_FLOAT_OES!==5131&&(this._gl.HALF_FLOAT_OES=5131),this._caps.textureHalfFloatRen
228der=this._caps.textureHalfFloat&&this._canRenderToHalfFloatFramebuffer(),this._webGLVersion>1)this._caps.drawBuffersExtension=!0,this._caps.maxMSAASamples=this._maxMSAASamplesOverride!==null?this._maxMSAASamplesOverride:this._gl.getParameter(this._gl.MAX_SAMPLES),this._caps.maxDrawBuffers=this._gl.getParameter(this._gl.MAX_DRAW_BUFFERS);else{const i=this._gl.getExtension("WEBGL_draw_buffers");if(i!==null){this._caps.drawBuffersExtension=!0,this._gl.drawBuffers=i.drawBuffersWEBGL.bind(i),this._caps.maxDrawBuffers=this._gl.getParameter(i.MAX_DRAW_BUFFERS_WEBGL),this._gl.DRAW_FRAMEBUFFER=this._gl.FRAMEBUFFER;for(let s=0;s<16;s++)this._gl["COLOR_ATTACHMENT"+s+"_WEBGL"]=i["COLOR_ATTACHMENT"+s+"_WEBGL"]}}if(this._webGLVersion>1)this._caps.depthTextureExtension=!0;else{const i=this._gl.getExtension("WEBGL_depth_texture");i!=null&&(this._caps.depthTextureExtension=!0,this._gl.UNSIGNED_INT_24_8=i.UNSIGNED_INT_24_8_WEBGL)}if(this.disableVertexArrayObjects)this._caps.vertexArrayObject=!1;else if(this._webGLVersion>1)this._caps.vertexArrayObject=!0;else{const i=this._gl.getExtension("OES_vertex_array_object");i!=null&&(this._caps.vertexArrayObject=!0,this._gl.createVertexArray=i.createVertexArrayOES.bind(i),this._gl.bindVertexArray=i.bindVertexArrayOES.bind(i),this._gl.deleteVertexArray=i.deleteVertexArrayOES.bind(i))}if(this._webGLVersion>1)this._caps.instancedArrays=!0;else{const i=this._gl.getExtension("ANGLE_instanced_arrays");i!=null?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=i.drawArraysInstancedANGLE.bind(i),this._gl.drawElementsInstanced=i.drawElementsInstancedANGLE.bind(i),this._gl.vertexAttribDivisor=i.vertexAttribDivisorANGLE.bind(i)):this._caps.instancedArrays=!1}if(this._gl.getShaderPrecisionFormat){const i=this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER,this._gl.HIGH_FLOAT),s=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);if(i&&s&&(this._caps.highPrecisionShaderSupported=i.precision!==0&&s.precision!==0,this._caps.shaderFloatPrecision=Math.min(i.precision,s.precision)),!this._shouldUseHighPrecisionShader){const r=this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER,this._gl.MEDIUM_FLOAT),a=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.MEDIUM_FLOAT);r&&a&&(this._caps.shaderFloatPrecision=Math.min(r.precision,a.precision))}this._caps.shaderFloatPrecision<10&&(this._caps.shaderFloatPrecision=10)}if(this._webGLVersion>1)this._caps.blendMinMax=!0;else{const i=this._gl.getExtension("EXT_blend_minmax");i!=null&&(this._caps.blendMinMax=!0,this._gl.MAX=i.MAX_EXT,this._gl.MIN=i.MIN_EXT)}if(!this._caps.supportSRGBBuffers){if(this._webGLVersion>1)this._caps.supportSRGBBuffers=!0,this._glSRGBExtensionValues={SRGB:WebGL2RenderingContext.SRGB,SRGB8:WebGL2RenderingContext.SRGB8,SRGB8_ALPHA8:WebGL2RenderingContext.SRGB8_ALPHA8};else{const i=this._gl.getExtension("EXT_sRGB");i!=null&&(this._caps.supportSRGBBuffers=!0,this._glSRGBExtensionValues={SRGB:i.SRGB_EXT,SRGB8:i.SRGB_ALPHA_EXT,SRGB8_ALPHA8:i.SRGB_ALPHA_EXT})}if(this._creationOptions){const i=this._creationOptions.forceSRGBBufferSupportState;i!==void 0&&(this._caps.supportSRGBBuffers=this._caps.supportSRGBBuffers&&i)}}this._depthCullingState.depthTest=!0,this._depthCullingState.depthFunc=this._gl.LEQUAL,this._depthCullingState.depthMask=!0,this._maxSimultaneousTextures=this._caps.maxCombinedTexturesImageUnits;for(let i=0;i<this._maxSimultaneousTextures;i++)this._nextFreeTextureSlots.push(i);this._glRenderer==="Mali-G72"&&(this._caps.disableMorphTargetTexture=!0)}_initFeatures(){this._features={forceBitmapOverHTMLImageElement:typeof HTMLImageElement>"u",supportRenderAndCopyToLodForFloatTextures:this._webGLVersion!==1,supportDepthStencilTexture:this._webGLVersion!==1,supportShadowSamplers:this._webGLVersion!==1,uniformBufferHardCheckMatrix:!1,allowTexturePrefiltering:this._webGLVersion!==1,trackUbosInFrame:!1,checkUbosContentBeforeUpload:!1,supportCSM:this._webGLVersion!==1,basisNeedsPOT:this._webGLVersion===1,support3DTextures:this._webGLVersion!==1,needTypeSuffixInShaderConstants:this._webGLVersion!==1,supportMSAA:this._webGLVersion!==1,supportSSAO2:this._webGLVersion!==1,supportIBLShadows:this._webGLVersion!==1,supportExtendedTextureFormats:this._webGLVersion!==1,supportSwitchCaseInSha
vendor: 79,093 bytes, line 228
228der:this._webGLVersion!==1,supportSyncTextureRead:!0,needsInvertingBitmap:!0,useUBOBindingCache:!0,needShaderCodeInlining:!1,needToAlwaysBindUniformBuffers:!1,supportRenderPasses:!1,supportSpriteInstancing:!0,forceVertexBufferStrideAndOffsetMultiple4Bytes:!1,_checkNonFloatVertexBuffersDontRecreatePipelineContext:!1,_collectUbosUpdatedInFrame:!1}}get webGLVersion(){return this._webGLVersion}getClassName(){return"ThinEngine"}_prepareWorkingCanvas(){if(this._workingCanvas)return;this._workingCanvas=this.createCanvas(1,1);const e=this._workingCanvas.getContext("2d");e&&(this._workingContext=e)}getInfo(){return this.getGlInfo()}getGlInfo(){return{vendor:this._glVendor,renderer:this._glRenderer,version:this._glVersion}}extractDriverInfo(){const e=this.getGlInfo();return e&&e.renderer?e.renderer:""}getRenderWidth(e=!1){return!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._framebufferDimensionsObject?this._framebufferDimensionsObject.framebufferWidth:this._gl.drawingBufferWidth}getRenderHeight(e=!1){return!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._framebufferDimensionsObject?this._framebufferDimensionsObject.framebufferHeight:this._gl.drawingBufferHeight}clear(e,t,i,s=!1,r=0){const a=this.stencilStateComposer.useStencilGlobalOnly;this.stencilStateComposer.useStencilGlobalOnly=!0,this.applyStates(),this.stencilStateComposer.useStencilGlobalOnly=a;let o=0;if(t&&e){let c=!0;if(this._currentRenderTarget){const u=this._currentRenderTarget.texture?.format;if(u===8||u===9||u===10||u===11){const d=this._currentRenderTarget.texture?.type;d===7||d===5?(ot._TempClearColorUint32[0]=e.r*255,ot._TempClearColorUint32[1]=e.g*255,ot._TempClearColorUint32[2]=e.b*255,ot._TempClearColorUint32[3]=e.a*255,this._gl.clearBufferuiv(this._gl.COLOR,0,ot._TempClearColorUint32),c=!1):(ot._TempClearColorInt32[0]=e.r*255,ot._TempClearColorInt32[1]=e.g*255,ot._TempClearColorInt32[2]=e.b*255,ot._TempClearColorInt32[3]=e.a*255,this._gl.clearBufferiv(this._gl.COLOR,0,ot._TempClearColorInt32),c=!1)}}c&&(this._gl.clearColor(e.r,e.g,e.b,e.a!==void 0?e.a:1),o|=this._gl.COLOR_BUFFER_BIT)}i&&(this.useReverseDepthBuffer?(this._depthCullingState.depthFunc=this._gl.GEQUAL,this._gl.clearDepth(0)):this._gl.clearDepth(1),o|=this._gl.DEPTH_BUFFER_BIT),s&&(this._gl.clearStencil(r),o|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(o)}_viewport(e,t,i,s){(e!==this._viewportCached.x||t!==this._viewportCached.y||i!==this._viewportCached.z||s!==this._viewportCached.w)&&(this._viewportCached.x=e,this._viewportCached.y=t,this._viewportCached.z=i,this._viewportCached.w=s,this._gl.viewport(e,t,i,s))}endFrame(){super.endFrame(),this._badOS&&this.flushFramebuffer()}get performanceMonitor(){throw new Error("Not Supported by ThinEngine")}bindFramebuffer(e,t=0,i,s,r,a=0,o=0){const c=e;this._currentRenderTarget&&this._resolveAndGenerateMipMapsFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this._bindUnboundFramebuffer(c._framebuffer);const u=this._gl;e.isMulti||(e.is2DArray||e.is3D?(u.framebufferTextureLayer(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,e.texture._hardwareTexture?.underlyingResource,a,o),c._currentLOD=a):e.isCube?u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_CUBE_MAP_POSITIVE_X+t,e.texture._hardwareTexture?.underlyingResource,a):c._currentLOD!==a&&(u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,e.texture._hardwareTexture?.underlyingResource,a),c._currentLOD=a));const d=e._depthStencilTexture;if(d){e.is3D&&(e.texture.width!==d.width||e.texture.height!==d.height||e.texture.depth!==d.depth)&&oe.Warn("Depth/Stencil attachment for 3D target must have same dimensions as color attachment");const f=e._depthStencilTextureWithStencil?u.DEPTH_STENCIL_ATTACHMENT:u.DEPTH_ATTACHMENT;e.is2DArray||e.is3D?u.framebufferTextureLayer(u.FRAMEBUFFER,f,d._hardwareTexture?.underlyingResource,a,o):e.isCube?u.framebufferTexture2D(u.FRAMEBUFFER,f,u.TEXTURE_CUBE_MAP_POSITIVE_X+t,d._hardwareTexture?.underlyingResource,a):u.framebufferTexture2D(u.FRAMEBUFFER,f,u.TEXTURE_2D,d._hardwareTexture?.underlyingResource,a)}c._MSAAFramebuffer&&this._bindUnboundFramebuffer(c._MSAAFramebuffer),this._cachedViewport&&!r?this.setViewport(this._cachedViewport,i,s):(i||(i=e.width,a&&(i=i/Math.pow(2,a))),s||(s=e.height,a&&(s=s/Math.pow(2,a))),this._viewport(0,0,i,s)),this.wipeCaches()}setStateCullFaceType(e,t){const i=this.cullBackFaces??e??!0?this._gl.BACK:this._gl.FRONT;(this._depthCullingState.cullFace!==i||t)&&(this._depthCullingState.cullFace=i)}setState(e,t=0,i,s=!1,r,a,o=0){(this._depthCullingState.cull!==e||i)&&(this._depthCullingState.cull=e),this.setStateCullFaceType(r,i),this.setZOffset(t),this.setZOffsetUnits(o);const c=s?this._gl.CW:this._gl.CCW;(this._depthCullingState.frontFace!==c||i)&&(this._depthCullingState.frontFace=c),this._stencilStateComposer.stencilMaterial=a}_resolveAndGenerateMipMapsFramebuffer(e,t=!1){e.disableAutomaticMSAAResolve||(e.isMulti?this.resolveMultiFramebuffer(e):this.resolveFramebuffer(e)),t||(e.isMulti?this.generateMipMapsMultiFramebuffer(e):this.generateMipMapsFramebuffer(e))}_bindUnboundFramebuffer(e){this._currentFramebuffer!==e&&(this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,e),this._currentFramebuffer=e)}_currentFrameBufferIsDefaultFrameBuffer(){return this._currentFramebuffer===null}generateMipmaps(e){const t=this._getTextureTarget(e);this._bindTextureDirectly(t,e,!0),this._gl.generateMipmap(t),this._bindTextureDirectly(t,null)}unBindFramebuffer(e,t,i){const s=e;this._currentRenderTarget=null,this._resolveAndGenerateMipMapsFramebuffer(e,t),i&&(s._MSAAFramebuffer&&this._bindUnboundFramebuffer(s._framebuffer),i()),this._bindUnboundFramebuffer(null)}generateMipMapsFramebuffer(e){!e.isMulti&&e.texture?.generateMipMaps&&!e.isCube&&this.generateMipmaps(e.texture)}resolveFramebuffer(e){const t=e,i=this._gl;if(!t._MSAAFramebuffer||t.isMulti)return;let s=t.resolveMSAAColors?i.COLOR_BUFFER_BIT:0;s|=t._generateDepthBuffer&&t.resolveMSAADepth?i.DEPTH_BUFFER_BIT:0,s|=t._generateStencilBuffer&&t.resolveMSAAStencil?i.STENCIL_BUFFER_BIT:0,i.bindFramebuffer(i.READ_FRAMEBUFFER,t._MSAAFramebuffer),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,t._framebuffer),i.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,s,i.NEAREST)}flushFramebuffer(){this._gl.flush()}restoreDefaultFramebuffer(){this._currentRenderTarget?this.unBindFramebuffer(this._currentRenderTarget):this._bindUnboundFramebuffer(null),this._cachedViewport&&this.setViewport(this._cachedViewport),this.wipeCaches()}_resetVertexBufferBinding(){this.bindArrayBuffer(null),this._cachedVertexBuffers=null}createVertexBuffer(e,t,i){return this._createVertexBuffer(e,this._gl.STATIC_DRAW)}_createVertexBuffer(e,t){const i=this._gl.createBuffer();if(!i)throw new Error("Unable to create vertex buffer");const s=new Dh(i);return this.bindArrayBuffer(s),typeof e!="number"?e instanceof Array?(this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array(e),t),s.capacity=e.length*4):(this._gl.bufferData(this._gl.ARRAY_BUFFER,e,t),s.capacity=e.byteLength):(this._gl.bufferData(this._gl.ARRAY_BUFFER,new Uint8Array(e),t),s.capacity=e),this._resetVertexBufferBinding(),s.references=1,s}createDynamicVertexBuffer(e,t){return this._createVertexBuffer(e,this._gl.DYNAMIC_DRAW)}_resetIndexBufferBinding(){this.bindIndexBuffer(null),this._cachedIndexBuffer=null}createIndexBuffer(e,t,i){const s=this._gl.createBuffer(),r=new Dh(s);if(!s)throw new Error("Unable to create index buffer");this.bindIndexBuffer(r);const a=this._normalizeIndexData(e);return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,a,t?this._gl.DYNAMIC_DRAW:this._gl.STATIC_DRAW),this._resetIndexBufferBinding(),r.references=1,r.is32Bits=a.BYTES_PER_ELEMENT===4,r}_normalizeIndexData(e){if(e.BYTES_PER_ELEMENT===2)return e;if(this._caps.uintIndices){if(e instanceof Uint32Array)return e;for(let i=0;i<e.length;i++)if(e[i]>=65535)return new Uint32Array(e);return new Uint16Array(e)}return new Uint16Array(e)}bindArrayBuffer(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this._bindBuffer(e,this._gl.ARRAY_BUFFER)}bindUniformBlock(e,t,i){const s=e.program,r=this._gl.getUniformBlockIndex(s,t);this._gl.uniformBlockBinding(s,r,i)}bindIndexBuffer(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this._bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)}_bindBuffer(e,t){(this._vaoRecordInProgress||this._currentBoundBuffer[t]!==e)&&(this._gl.bindBuffer(t,e?e.underlyingResource:null),this._currentBoundBuffer[t]=e)}updateArrayBuffer(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)}_vertexAttribPointer(e,t,i,s,r,a,o){const c=this._currentBufferPointers[t];if(!c)return;let u=!1;c.active?(c.buffer!==e&&(c.buffer=e,u=!0),c.size!==i&&(c.size=i,u=!0),c.type!==s&&(c.type=s,u=!0),c.normalized!==r&&(c.normalized=r,u=!0),c.stride!==a&&(c.stride=a,u=!0),c.offset!==o&&(c.offset=o,u=!0)):(u=!0,c.active=!0,c.index=t,c.size=i,c.type=s,c.normalized=r,c.stride=a,c.offset=o,c.buffer=e),(u||this._vaoRecordInProgress)&&(this.bindArrayBuffer(e),s===this._gl.UNSIGNED_INT||s===this._gl.INT?this._gl.vertexAttribIPointer(t,i,s,a,o):this._gl.vertexAttribPointer(t,i,s,r,a,o))}_bindIndexBufferWithCache(e){e!=null&&this._cachedIndexBuffer!==e&&(this._cachedIndexBuffer=e,this.bindIndexBuffer(e),this._uintIndicesCurrentlySet=e.is32Bits)}_bindVertexBuffersAttributes(e,t,i){const s=t.getAttributesNames();this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.unbindAllAttributes();for(let r=0;r<s.length;r++){const a=t.getAttributeLocation(r);if(a>=0){const o=s[r];let c=null;if(i&&(c=i[o]),c||(c=e[o]),!c)continue;this._gl.enableVertexAttribArray(a),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[a]=!0);const u=c.getBuffer();u&&(this._vertexAttribPointer(u,a,c.getSize(),c.type,c.normalized,c.byteStride,c.byteOffset),c.getIsInstanced()&&(this._gl.vertexAttribDivisor(a,c.getInstanceDivisor()),this._vaoRecordInProgress||(this._currentInstanceLocations.push(a),this._currentInstanceBuffers.push(u))))}}}recordVertexArrayObject(e,t,i,s){const r=this._gl.createVertexArray();if(!r)throw new Error("Unable to create VAO");return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(r),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(e,i,s),this.bindIndexBuffer(t),this._vaoRecordInProgress=!1,this._gl.bindVertexArray(null),r}bindVertexArrayObject(e,t){this._cachedVertexArrayObject!==e&&(this._cachedVertexArrayObject=e,this._gl.bindVertexArray(e),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._uintIndicesCurrentlySet=t!=null&&t.is32Bits,this._mustWipeVertexAttributes=!0)}bindBuffersDirectly(e,t,i,s,r){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==r){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=r;const a=r.getAttributesCount();this._unbindVertexArrayObject(),this.unbindAllAttributes();let o=0;for(let c=0;c<a;c++)if(c<i.length){const u=r.getAttributeLocation(c);u>=0&&(this._gl.enableVertexAttribArray(u),this._vertexAttribArraysEnabled[u]=!0,this._vertexAttribPointer(e,u,i[c],this._gl.FLOAT,!1,s,o)),o+=i[c]*4}}this._bindIndexBufferWithCache(t)}_unbindVertexArrayObject(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))}bindBuffers(e,t,i,s){(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==i)&&(this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=i,this._bindVertexBuffersAttributes(e,i,s)),this._bindIndexBufferWithCache(t)}unbindInstanceAttributes(){let e;for(let t=0,i=this._currentInstanceLocations.length;t<i;t++){const s=this._currentInstanceBuffers[t];e!=s&&s.references&&(e=s,this.bindArrayBuffer(s));const r=this._currentInstanceLocations[t];this._gl.vertexAttribDivisor(r,0)}this._currentInstanceBuffers.length=0,this._currentInstanceLocations.length=0}releaseVertexArrayObject(e){this._gl.deleteVertexArray(e)}_releaseBuffer(e){return e.references--,e.references===0?(this._deleteBuffer(e),!0):!1}_deleteBuffer(e){this._gl.deleteBuffer(e.underlyingResource)}updateAndBindInstancesBuffer(e,t,i){if(this.bindArrayBuffer(e),t&&this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t),i[0].index!==void 0)this.bindInstancesBuffer(e,i,!0);else for(let s=0;s<4;s++){const r=i[s];this._vertexAttribArraysEnabled[r]||(this._gl.enableVertexAttribArray(r),this._vertexAttribArraysEnabled[r]=!0),this._vertexAttribPointer(e,r,4,this._gl.FLOAT,!1,64,s*16),this._gl.vertexAttribDivisor(r,1),this._currentInstanceLocations.push(r),this._currentInstanceBuffers.push(e)}}bindInstancesBuffer(e,t,i=!0){this.bindArrayBuffer(e);let s=0;if(i)for(let r=0;r<t.length;r++){const a=t[r];s+=a.attributeSize*4}for(let r=0;r<t.length;r++){const a=t[r];a.index===void 0&&(a.index=this._currentEffect.getAttributeLocationByName(a.attributeName)),!(a.index<0)&&(this._vertexAttribArraysEnabled[a.index]||(this._gl.enableVertexAttribArray(a.index),this._vertexAttribArraysEnabled[a.index]=!0),this._vertexAttribPointer(e,a.index,a.attributeSize,a.attributeType||this._gl.FLOAT,a.normalized||!1,s,a.offset),this._gl.vertexAttribDivisor(a.index,a.divisor===void 0?1:a.divisor),this._currentInstanceLocations.push(a.index),this._currentInstanceBuffers.push(e))}}disableInstanceAttributeByName(e){if(!this._currentEffect)return;const t=this._currentEffect.getAttributeLocationByName(e);this.disableInstanceAttribute(t)}disableInstanceAttribute(e){let t=!1,i;for(;(i=this._currentInstanceLocations.indexOf(e))!==-1;)this._currentInstanceLocations.splice(i,1),this._currentInstanceBuffers.splice(i,1),t=!0,i=this._currentInstanceLocations.indexOf(e);t&&(this._gl.vertexAttribDivisor(e,0),this.disableAttributeByIndex(e))}disableAttributeByIndex(e){this._gl.disableVertexAttribArray(e),this._vertexAttribArraysEnabled[e]=!1,this._currentBufferPointers[e].active=!1}draw(e,t,i,s){this.drawElementsType(e?0:1,t,i,s)}drawPointClouds(e,t,i){this.drawArraysType(2,e,t,i)}drawUnIndexed(e,t,i,s){this.drawArraysType(e?0:1,t,i,s)}drawElementsType(e,t,i,s){this.applyStates(),this._reportDrawCall();const r=this._drawMode(e),a=this._uintIndicesCurrentlySet?this._gl.UNSIGNED_INT:this._gl.UNSIGNED_SHORT,o=this._uintIndicesCurrentlySet?4:2;s?this._gl.drawElementsInstanced(r,i,a,t*o,s):this._gl.drawElements(r,i,a,t*o)}drawArraysType(e,t,i,s){this.applyStates(),this._reportDrawCall();const r=this._drawMode(e);s?this._gl.drawArraysInstanced(r,t,i,s):this._gl.drawArrays(r,t,i)}_drawMode(e){switch(e){case 0:return this._gl.TRIANGLES;case 2:return this._gl.POINTS;case 1:return this._gl.LINES;case 3:return this._gl.POINTS;case 4:return this._gl.LINES;case 5:return this._gl.LINE_LOOP;case 6:return this._gl.LINE_STRIP;case 7:return this._gl.TRIANGLE_STRIP;case 8:return this._gl.TRIANGLE_FAN;default:return this._gl.TRIANGLES}}_releaseEffect(e){this._compiledEffects[e._key]&&delete this._compiledEffects[e._key];const t=e.getPipelineContext();t&&this._deletePipelineContext(t)}_deletePipelineContext(e){const t=e;t&&t.program&&(t.program.__SPECTOR_rebuildProgram=null,nC(t),this._gl&&(this._currentProgram===t.program&&this._setProgram(null),this._gl.deleteProgram(t.program)))}_getGlobalDefines(e){return $M(e,this.isNDCHalfZRange,this.useReverseDepthBuffer,this.useExactSrgbConversions)}createEffect(e,t,i,s,r,a,o,c,u,d=0,f){const g=typeof e=="string"?e:e.vertexToken||e.vertexSource||e.vertexElement||e.vertex,m=typeof e=="string"?e:e.fragmentToken||e.fragmentSource||e.fragmentElement||e.fragment,b=this._getGlobalDefines(),x=t.attributes!==void 0;let v=r??t.defines??"";b&&(v+=b);const E=g+"+"+m+"@"+v;if(this._compiledEffects[E]){const D=this._compiledEffects[E];return o&&D.isReady()&&o(D),D._refCount++,D}this._gl&&zs(this._gl);const A=new At(e,t,x?this:i,s,this,r,a,o,c,u,E,t.shaderLanguage??d,t.extraInitializationsAsync??f);return this._compiledEffects[E]=A,A}_getShaderSource(e){return this._gl.getShaderSource(e)}createRawShaderProgram(e,t,i,s,r=null){const a=zs(this._gl);return a._contextWasLost=this._contextWasLost,a.validateShaderPrograms=this.validateShaderPrograms,QM(e,t,i,s||this._gl,r)}createShaderProgram(e,t,i,s,r,a=null){const o=zs(this._gl);return o._contextWasLost=this._contextWasLost,o.validateShaderPrograms=this.validateShaderPrograms,JM(e,t,i,s,r||this._gl,a)}inlineShaderCode(e){return e}createPipelineContext(e){if(this._gl){const i=zs(this._gl);i.parallelShaderCompile=this._caps.parallelShaderCompile}const t=aU(this._gl);return t.engine=this,t}createMaterialContext(){}createDrawContext(){}_finalizePipelineContext(e){return vb(e,this._gl,this.validateShaderPrograms)}_preparePipelineContextAsync(e,t,i,s,r,a,o,c,u,d,f){const g=zs(this._gl);return g._contextWasLost=this._contextWasLost,g.validateShaderPrograms=this.validateShaderPrograms,g._createShaderProgramInjection=this._createShaderProgram.bind(this),g.createRawShaderProgramInjection=this.createRawShaderProgram.bind(this),g.createShaderProgramInjection=this.createShaderProgram.bind(this),g.loadFileInjection=this._loadFile.bind(this),lU(e,t,i,s,r,a,o,c,u,d,f)}_createShaderProgram(e,t,i,s,r=null){return yb(e,t,i,s,r)}_isRenderingStateCompiled(e){return this._isDisposed?!1:oU(e,this._gl,this.validateShaderPrograms)}_executeWhenRenderingStateIsCompiled(e,t){hU(e,t)}getUniforms(e,t){const i=new Array,s=e;for(let r=0;r<t.length;r++)i.push(this._gl.getUniformLocation(s.program,t[r]));return i}getAttributes(e,t){const i=[],s=e;for(let r=0;r<t.length;r++)try{i.push(this._gl.getAttribLocation(s.program,t[r]))}catch{i.push(-1)}return i}enableEffect(e){e=e!==null&&eC(e)?e.effect:e,!(!e||e===this._currentEffect)&&(this._stencilStateComposer.stencilMaterial=void 0,this.bindSamplers(e),this._currentEffect=e,e.onBind&&e.onBind(e),e._onBindObservable&&e._onBindObservable.notifyObservers(e))}setInt(e,t){return e?(this._gl.uniform1i(e,t),!0):!1}setInt2(e,t,i){return e?(this._gl.uniform2i(e,t,i),!0):!1}setInt3(e,t,i,s){return e?(this._gl.uniform3i(e,t,i,s),!0):!1}setInt4(e,t,i,s,r){return e?(this._gl.uniform4i(e,t,i,s,r),!0):!1}setIntArray(e,t){return e?(this._gl.uniform1iv(e,t),!0):!1}setIntArray2(e,t){return!e||t.length%2!==0?!1:(this._gl.uniform2iv(e,t),!0)}setIntArray3(e,t){return!e||t.length%3!==0?!1:(this._gl.uniform3iv(e,t),!0)}setIntArray4(e,t){return!e||t.length%4!==0?!1:(this._gl.uniform4iv(e,t),!0)}setUInt(e,t){return e?(this._gl.uniform1ui(e,t),!0):!1}setUInt2(e,t,i){return e?(this._gl.uniform2ui(e,t,i),!0):!1}setUInt3(e,t,i,s){return e?(this._gl.uniform3ui(e,t,i,s),!0):!1}setUInt4(e,t,i,s,r){return e?(this._gl.uniform4ui(e,t,i,s,r),!0):!1}setUIntArray(e,t){return e?(this._gl.uniform1uiv(e,t),!0):!1}setUIntArray2(e,t){return!e||t.length%2!==0?!1:(this._gl.uniform2uiv(e,t),!0)}setUIntArray3(e,t){return!e||t.length%3!==0?!1:(this._gl.uniform3uiv(e,t),!0)}setUIntArray4(e,t){return!e||t.length%4!==0?!1:(this._gl.uniform4uiv(e,t),!0)}setArray(e,t){return!e||t.length<1?!1:(this._gl.uniform1fv(e,t),!0)}setArray2(e,t){return!e||t.length%2!==0?!1:(this._gl.uniform2fv(e,t),!0)}setArray3(e,t){return!e||t.length%3!==0?!1:(this._gl.uniform3fv(e,t),!0)}setArray4(e,t){return!e||t.length%4!==0?!1:(this._gl.uniform4fv(e,t),!0)}setMatrices(e,t){return e?(this._gl.uniformMatrix4fv(e,!1,t),!0):!1}setMatrix3x3(e,t){return e?(this._gl.uniformMatrix3fv(e,!1,t),!0):!1}setMatrix2x2(e,t){return e?(this._gl.uniformMatrix2fv(e,!1,t),!0):!1}setFloat(e,t){return e?(this._gl.uniform1f(e,t),!0):!1}setFloat2(e,t,i){return e?(this._gl.uniform2f(e,t,i),!0):!1}setFloat3(e,t,i,s){return e?(this._gl.uniform3f(e,t,i,s),!0):!1}setFloat4(e,t,i,s,r){return e?(this._gl.uniform4f(e,t,i,s,r),!0):!1}applyStates(){if(this._depthCullingState.apply(this._gl),this._stencilStateComposer.apply(this._gl),this._alphaState.apply(this._gl,this._currentRenderTarget&&this._currentRenderTarget.textures?this._currentRenderTarget.textures.length:1),this._colorWriteChanged){this._colorWriteChanged=!1;const e=this._colorWrite;this._gl.colorMask(e,e,e,e)}}wipeCaches(e){this.preventCacheWipeBetweenFrames&&!e||(this._currentEffect=null,this._viewportCached.x=0,this._viewportCached.y=0,this._viewportCached.z=0,this._viewportCached.w=0,this._unbindVertexArrayObject(),e&&(this._currentProgram=null,this.resetTextureCache(),this._stencilStateComposer.reset(),this._depthCullingState.reset(),this._depthCullingState.depthFunc=this._gl.LEQUAL,this._alphaState.reset(),this._resetAlphaMode(),this._colorWrite=!0,this._colorWriteChanged=!0,this._unpackFlipYCached=null,this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,this._gl.NONE),this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),this._mustWipeVertexAttributes=!0,this.unbindAllAttributes()),this._resetVertexBufferBinding(),this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null,this.bindIndexBuffer(null))}_getSamplingParameters(e,t){const i=this._gl;let s=i.NEAREST,r=i.NEAREST,a=!1;switch(e){case 11:s=i.LINEAR,t?r=i.LINEAR_MIPMAP_NEAREST:r=i.LINEAR;break;case 3:s=i.LINEAR,a=!0,t?r=i.LINEAR_MIPMAP_LINEAR:r=i.LINEAR;break;case 8:a=!0,s=i.NEAREST,t?r=i.NEAREST_MIPMAP_LINEAR:r=i.NEAREST;break;case 4:s=i.NEAREST,t?r=i.NEAREST_MIPMAP_NEAREST:r=i.NEAREST;break;case 5:s=i.NEAREST,t?r=i.LINEAR_MIPMAP_NEAREST:r=i.LINEAR;break;case 6:a=!0,s=i.NEAREST,t?r=i.LINEAR_MIPMAP_LINEAR:r=i.LINEAR;break;case 7:s=i.NEAREST,r=i.LINEAR;break;case 1:s=i.NEAREST,r=i.NEAREST;break;case 9:s=i.LINEAR,t?r=i.NEAREST_MIPMAP_NEAREST:r=i.NEAREST;break;case 10:a=!0,s=i.LINEAR,t?r=i.NEAREST_MIPMAP_LINEAR:r=i.NEAREST;break;case 2:s=i.LINEAR,r=i.LINEAR;break;case 12:s=i.LINEAR,r=i.NEAREST;break}return{min:r,mag:s,hasMipMaps:a}}_createTexture(){const e=this._gl.createTexture();if(!e)throw new Error("Unable to create texture");return e}_createHardwareTexture(){return new lC(this._createTexture(),this._gl)}_createInternalTexture(e,t,i=!0,s=0){let r=!1,a=!1,o=0,c=3,u=5,d=!1,f=1,g,m=!1,b=0;t!==void 0&&typeof t=="object"?(r=!!t.generateMipMaps,a=!!t.createMipMaps,o=t.type===void 0?0:t.type,c=t.samplingMode===void 0?3:t.samplingMode,u=t.format===void 0?5:t.format,d=t.useSRGBBuffer===void 0?!1:t.useSRGBBuffer,f=t.samples??1,g=t.label,m=!!t.createMSAATexture,b=t.comparisonFunction||0):r=!!t,d&&(d=this._caps.supportSRGBBuffers&&(this.webGLVersion>1||this.isWebGPU)),(o===1&&!this._caps.textureFloatLinearFiltering||o===2&&!this._caps.textureHalfFloatLinearFiltering)&&(c=1),o===1&&!this._caps.textureFloat&&(o=0,oe.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE"));const x=lT(u),v=wh(u),E=this._gl,A=new Cs(this,s),D=e.width||e,I=e.height||e,R=e.depth||0,C=e.layers||0,M=this._getSamplingParameters(c,(r||a)&&!x),F=C!==0?E.TEXTURE_2D_ARRAY:R!==0?E.TEXTURE_3D:E.TEXTURE_2D,U=x?this._getInternalFormatFromDepthTextureFormat(u,!0,v):this._getRGBABufferInternalSizedFormat(o,u,d),k=x?v?E.DEPTH_STENCIL:E.DEPTH_COMPONENT:this._getInternalFormat(u),q=x?this._getWebGLTextureTypeFromDepthTextureFormat(u):this._getWebGLTextureType(o);if(this._bindTextureDirectly(F,A),C!==0?(A.is2DArray=!0,E.texImage3D(F,0,U,D,I,C,0,k,q,null)):R!==0?(A.is3D=!0,E.texImage3D(F,0,U,D,I,R,0,k,q,null)):E.texImage2D(F,0,U,D,I,0,k,q,null),E.texParameteri(F,E.TEXTURE_MAG_FILTER,M.mag),E.texParameteri(F,E.TEXTURE_MIN_FILTER,M.min),E.texParameteri(F,E.TEXTURE_WRAP_S,E.CLAMP_TO_EDGE),E.texParameteri(F,E.TEXTURE_WRAP_T,E.CLAMP_TO_EDGE),x&&this.webGLVersion>1&&(b===0?(E.texParameteri(F,E.TEXTURE_COMPARE_FUNC,515),E.texParameteri(F,E.TEXTURE_COMPARE_MODE,E.NONE)):(E.texParameteri(F,E.TEXTURE_COMPARE_FUNC,b),E.texParameteri(F,E.TEXTURE_COMPARE_MODE,E.COMPARE_REF_TO_TEXTURE))),(r||a)&&this._gl.generateMipmap(F),this._bindTextureDirectly(F,null),A._useSRGBBuffer=d,A.baseWidth=D,A.baseHeight=I,A.width=D,A.height=I,A.depth=C||R,A.isReady=!0,A.samples=f,A.generateMipMaps=r,A.samplingMode=c,A.type=o,A.format=u,A.label=g,A.comparisonFunction=b,this._internalTexturesCache.push(A),m){let Q=null;if(lT(A.format)?Q=this._setupFramebufferDepthAttachments(wh(A.format),A.format!==19,A.width,A.height,f,A.format,!0):Q=this._createRenderBuffer(A.width,A.height,f,-1,this._getRGBABufferInternalSizedFormat(A.type,A.format,A._useSRGBBuffer),-1),!Q)throw new Error("Unable to create render buffer");A._autoMSAAManagement=!0;let ie=A._hardwareTexture;ie||(ie=A._hardwareTexture=this._createHardwareTexture()),ie.addMSAARenderBuffer(Q)}return A}_getUseSRGBBuffer(e,t){return e&&this._caps.supportSRGBBuffers&&(this.webGLVersion>1||t)}createTexture(e,t,i,s,r=3,a=null,o=null,c=null,u=null,d=null,f=null,g,m,b,x){return this._createTextureBase(e,t,i,s,r,a,o,(...v)=>this._prepareWebGLTexture(...v,d),(v,E,A,D,I,R)=>{const C=this._gl,M=A.width===v&&A.height===E;I._creationFlags=b??0;const F=this._getTexImageParametersForCreateTexture(I.format,I._useSRGBBuffer);if(M)return C.texImage2D(C.TEXTURE_2D,0,F.internalFormat,F.format,F.type,A),!1;const U=this._caps.maxTextureSize;if(A.width>U||A.height>U||!this._supportsHardwareTextureRescaling)return this._prepareWorkingCanvas(),!this._workingCanvas||!this._workingContext||(this._workingCanvas.width=v,this._workingCanvas.height=E,this._workingContext.drawImage(A,0,0,A.width,A.height,0,0,v,E),C.texImage2D(C.TEXTURE_2D,0,F.internalFormat,F.format,F.type,this._workingCanvas),I.width=v,I.height=E),!1;{const k=new Cs(this,2);this._bindTextureDirectly(C.TEXTURE_2D,k,!0),C.texImage2D(C.TEXTURE_2D,0,F.internalFormat,F.format,F.type,A),this._rescaleTexture(k,I,s,F.format,()=>{this._releaseTexture(k),this._bindTextureDirectly(C.TEXTURE_2D,I,!0),R()})}return!0},c,u,d,f,g,m,x)}_getTexImageParametersForCreateTexture(e,t){let i,s;return this.webGLVersion===1?(i=this._getInternalFormat(e,t),s=i):(i=this._getInternalFormat(e,!1),s=this._getRGBABufferInternalSizedFormat(0,e,t)),{internalFormat:s,format:i,type:this._gl.UNSIGNED_BYTE}}_rescaleTexture(e,t,i,s,r){}_unpackFlipY(e){this._unpackFlipYCached!==e&&(this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,e?1:0),this.enableUnpackFlipYCached&&(this._unpackFlipYCached=e))}_getUnpackAlignement(){return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT)}_getTextureTarget(e){return e.isCube?this._gl.TEXTURE_CUBE_MAP:e.is3D?this._gl.TEXTURE_3D:e.is2DArray||e.isMultiview?this._gl.TEXTURE_2D_ARRAY:this._gl.TEXTURE_2D}updateTextureSamplingMode(e,t,i=!1){const s=this._getTextureTarget(t),r=this._getSamplingParameters(e,t.useMipMaps||i);this._setTextureParameterInteger(s,this._gl.TEXTURE_MAG_FILTER,r.mag,t),this._setTextureParameterInteger(s,this._gl.TEXTURE_MIN_FILTER,r.min),i&&r.hasMipMaps&&(t.generateMipMaps=!0,this._gl.generateMipmap(s)),this._bindTextureDirectly(s,null),t.samplingMode=e}updateTextureDimensions(e,t,i,s=1){}updateTextureWrappingMode(e,t,i=null,s=null){const r=this._getTextureTarget(e);t!==null&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t),e),e._cachedWrapU=t),i!==null&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(i),e),e._cachedWrapV=i),(e.is2DArray||e.is3D)&&s!==null&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(s),e),e._cachedWrapR=s),this._bindTextureDirectly(r,null)}_uploadCompressedDataToTextureDirectly(e,t,i,s,r,a=0,o=0){const c=this._gl;let u=c.TEXTURE_2D;if(e.isCube&&(u=c.TEXTURE_CUBE_MAP_POSITIVE_X+a),e._useSRGBBuffer)switch(t){case 37492:case 36196:this._caps.etc2?t=c.COMPRESSED_SRGB8_ETC2:e._useSRGBBuffer=!1;break;case 37496:this._caps.etc2?t=c.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:e._useSRGBBuffer=!1;break;case 36492:t=c.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;break;case 37808:t=c.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;break;case 33776:this._caps.s3tc_srgb?t=c.COMPRESSED_SRGB_S3TC_DXT1_EXT:e._useSRGBBuffer=!1;break;case 33777:this._caps.s3tc_srgb?t=c.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:e._useSRGBBuffer=!1;break;case 33779:this._caps.s3tc_srgb?t=c.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:e._useSRGBBuffer=!1;break;default:e._useSRGBBuffer=!1;break}if(e.generateMipMaps){const d=e._hardwareTexture;d.memoryAllocated||(c.texStorage2D(c.TEXTURE_2D,Math.floor(Math.log2(Math.max(i,s)))+1,t,e.width,e.height),d.memoryAllocated=!0),this._gl.compressedTexSubImage2D(u,o,0,0,i,s,t,r)}else this._gl.compressedTexImage2D(u,o,t,i,s,0,r)}_uploadDataToTextureDirectly(e,t,i=0,s=0,r,a=!1){const o=this._gl,c=this._getWebGLTextureType(e.type),u=this._getInternalFormat(e.format),d=r===void 0?this._getRGBABufferInternalSizedFormat(e.type,e.format,e._useSRGBBuffer):this._getInternalFormat(r,e._useSRGBBuffer);this._unpackFlipY(e.invertY);let f=o.TEXTURE_2D;e.isCube&&(f=o.TEXTURE_CUBE_MAP_POSITIVE_X+i);const g=Math.round(Math.log(e.width)*Math.LOG2E),m=Math.round(Math.log(e.height)*Math.LOG2E),b=a?e.width:Math.pow(2,Math.max(g-s,0)),x=a?e.height:Math.pow(2,Math.max(m-s,0));o.texImage2D(f,s,d,b,x,0,u,c,t)}updateTextureData(e,t,i,s,r,a,o=0,c=0,u=!1){const d=this._gl,f=this._getWebGLTextureType(e.type),g=this._getInternalFormat(e.format);this._unpackFlipY(e.invertY);let m=d.TEXTURE_2D,b=d.TEXTURE_2D;e.isCube&&(b=d.TEXTURE_CUBE_MAP_POSITIVE_X+o,m=d.TEXTURE_CUBE_MAP),this._bindTextureDirectly(m,e,!0),d.texSubImage2D(b,c,i,s,r,a,g,f,t),u&&this._gl.generateMipmap(b),this._bindTextureDirectly(m,null)}_uploadArrayBufferViewToTexture(e,t,i=0,s=0){const r=this._gl,a=e.isCube?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D;this._bindTextureDirectly(a,e,!0),this._uploadDataToTextureDirectly(e,t,i,s),this._bindTextureDirectly(a,null,!0)}_prepareWebGLTextureContinuation(e,t,i,s,r){const a=this._gl;if(!a)return;const o=this._getSamplingParameters(r,!i);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,o.mag),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,o.min),!i&&!s&&a.generateMipmap(a.TEXTURE_2D),this._bindTextureDirectly(a.TEXTURE_2D,null),t&&t.removePendingData(e),e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear()}_prepareWebGLTexture(e,t,i,s,r,a,o,c,u,d){const f=this.getCaps().maxTextureSize,g=Math.min(f,this.needPOTTextures?Vo(s.width,f):s.width),m=Math.min(f,this.needPOTTextures?Vo(s.height,f):s.height),b=this._gl;if(b){if(!e._hardwareTexture){i&&i.removePendingData(e);return}this._bindTextureDirectly(b.TEXTURE_2D,e,!0),this._unpackFlipY(r===void 0?!0:!!r),e.baseWidth=s.width,e.baseHeight=s.height,e.width=g,e.height=m,e.isReady=!0,e.type=e.type!==-1?e.type:0,e.format=e.format!==-1?e.format:d??(t===".jpg"&&!e._useSRGBBuffer?4:5),!c(g,m,s,t,e,()=>{this._prepareWebGLTextureContinuation(e,i,a,o,u)})&&this._prepareWebGLTextureContinuation(e,i,a,o,u)}}_getInternalFormatFromDepthTextureFormat(e,t,i){const s=this._gl;if(!t)return s.STENCIL_INDEX8;let a=i?s.DEPTH_STENCIL:s.DEPTH_COMPONENT;return this.webGLVersion>1?e===15?a=s.DEPTH_COMPONENT16:e===16?a=s.DEPTH_COMPONENT24:e===17||e===13?a=i?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24:e===14?a=s.DEPTH_COMPONENT32F:e===18&&(a=i?s.DEPTH32F_STENCIL8:s.DEPTH_COMPONENT32F):a=s.DEPTH_COMPONENT16,a}_getWebGLTextureTypeFromDepthTextureFormat(e){const t=this._gl;let i=t.UNSIGNED_INT;return e===15?i=t.UNSIGNED_SHORT:e===17||e===13?i=t.UNSIGNED_INT_24_8:e===14?i=t.FLOAT:e===18?i=t.FLOAT_32_UNSIGNED_INT_24_8_REV:e===19&&(i=t.UNSIGNED_BYTE),i}_setupFramebufferDepthAttachments(e,t,i,s,r=1,a,o=!1){const c=this._gl;a=a??(e?13:14);const u=this._getInternalFormatFromDepthTextureFormat(a,t,e);return e&&t?this._createRenderBuffer(i,s,r,c.DEPTH_STENCIL,u,o?-1:c.DEPTH_STENCIL_ATTACHMENT):t?this._createRenderBuffer(i,s,r,u,u,o?-1:c.DEPTH_ATTACHMENT):e?this._createRenderBuffer(i,s,r,u,u,o?-1:c.STENCIL_ATTACHMENT):null}_createRenderBuffer(e,t,i,s,r,a,o=!0){const u=this._gl.createRenderbuffer();return this._updateRenderBuffer(u,e,t,i,s,r,a,o)}_updateRenderBuffer(e,t,i,s,r,a,o,c=!0){const u=this._gl;return u.bindRenderbuffer(u.RENDERBUFFER,e),s>1&&u.renderbufferStorageMultisample?u.renderbufferStorageMultisample(u.RENDERBUFFER,s,a,t,i):u.renderbufferStorage(u.RENDERBUFFER,r,t,i),o!==-1&&u.framebufferRenderbuffer(u.FRAMEBUFFER,o,u.RENDERBUFFER,e),c&&u.bindRenderbuffer(u.RENDERBUFFER,null),e}_releaseTexture(e){this._deleteTexture(e._hardwareTexture),this.unbindAllTextures();const t=this._internalTexturesCache.indexOf(e);t!==-1&&this._internalTexturesCache.splice(t,1),e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureLow&&e._lodTextureLow.dispose(),e._irradianceTexture&&e._irradianceTexture.dispose()}_deleteTexture(e){e?.release()}_setProgram(e){this._currentProgram!==e&&(cU(e,this._gl),this._currentProgram=e)}bindSamplers(e){const t=e.getPipelineContext();this._setProgram(t.program);const i=e.getSamplers();for(let s=0;s<i.length;s++){const r=e.getUniform(i[s]);r&&(this._boundUniforms[s]=r)}this._currentEffect=null}_activateCurrentTexture(){this._currentTextureChannel!==this._activeChannel&&(this._gl.activeTexture(this._gl.TEXTURE0+this._activeChannel),this._currentTextureChannel=this._activeChannel)}_bindTextureDirectly(e,t,i=!1,s=!1){let r=!1;const a=t&&t._associatedChannel>-1;if(i&&a&&(this._activeChannel=t._associatedChannel),this._boundTexturesCache[this._activeChannel]!==t||s){if(this._activateCurrentTexture(),t&&t.isMultiview)throw oe.Error(["_bindTextureDirectly called with a multiview texture!",e,t]),"_bindTextureDirectly called with a multiview texture!";this._gl.bindTexture(e,t?._hardwareTexture?.underlyingResource??null),this._boundTexturesCache[this._activeChannel]=t,t&&(t._associatedChannel=this._activeChannel)}else i&&(r=!0,this._activateCurrentTexture());return a&&!i&&this._bindSamplerUniformToChannel(t._associatedChannel,this._activeChannel),r}_bindTexture(e,t,i){if(e===void 0)return;t&&(t._associatedChannel=e),this._activeChannel=e;const s=t?this._getTextureTarget(t):this._gl.TEXTURE_2D;this._bindTextureDirectly(s,t)}unbindAllTextures(){for(let e=0;e<this._maxSimultaneousTextures;e++)this._activeChannel=e,this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),this.webGLVersion>1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))}setTexture(e,t,i,s){e!==void 0&&(t&&(this._boundUniforms[e]=t),this._setTexture(e,i))}_bindSamplerUniformToChannel(e,t){const i=this._boundUniforms[e];!i||i._currentState===t||(this._gl.uniform1i(i,t),i._currentState=t)}_getTextureWrapMode(e){switch(e){case 1:return this._gl.REPEAT;case 0:return this._gl.CLAMP_TO_EDGE;case 2:return this._gl.MIRRORED_REPEAT}return this._gl.REPEAT}_setTexture(e,t,i=!1,s=!1,r=""){if(!t)return this._boundTexturesCache[e]!=null&&(this._activeChannel=e,this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),this.webGLVersion>1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))),!1;if(t.video){this._activeChannel=e;const u=t.getInternalTexture();u&&(u._associatedChannel=e),t.update()}else if(t.delayLoadState===4)return t.delayLoad(),!1;let a;s?a=t.depthStencilTexture:t.isReady()?a=t.getInternalTexture():t.isCube?a=this.emptyCubeTexture:t.is3D?a=this.emptyTexture3D:t.is2DArray?a=this.emptyTexture2DArray:a=this.emptyTexture,!i&&a&&(a._associatedChannel=e);let o=!0;this._boundTexturesCache[e]===a&&(i||this._bindSamplerUniformToChannel(a._associatedChannel,e),o=!1),this._activeChannel=e;const c=this._getTextureTarget(a);if(o&&this._bindTextureDirectly(c,a,i),a&&!a.isMultiview){if(a.isCube&&a._cachedCoordinatesMode!==t.coordinatesMode){a._cachedCoordinatesMode=t.coordinatesMode;const u=t.coordinatesMode!==3&&t.coordinatesMode!==5?1:0;t.wrapU=u,t.wrapV=u}a._cachedWrapU!==t.wrapU&&(a._cachedWrapU=t.wrapU,this._setTextureParameterInteger(c,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t.wrapU),a)),a._cachedWrapV!==t.wrapV&&(a._cachedWrapV=t.wrapV,this._setTextureParameterInteger(c,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(t.wrapV),a)),a.is3D&&a._cachedWrapR!==t.wrapR&&(a._cachedWrapR=t.wrapR,this._setTextureParameterInteger(c,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(t.wrapR),a)),this._setAnisotropicLevel(c,a,t.anisotropicFilteringLevel)}return!0}setTextureArray(e,t,i,s){if(!(e===void 0||!t)){(!this._textureUnits||this._textureUnits.length!==i.length)&&(this._textureUnits=new Int32Array(i.length));for(let r=0;r<i.length;r++){const a=i[r].getInternalTexture();a?(this._textureUnits[r]=e+r,a._associatedChannel=e+r):this._textureUnits[r]=-1}this._gl.uniform1iv(t,this._textureUnits);for(let r=0;r<i.length;r++)this._setTexture(this._textureUnits[r],i[r],!0)}}_setAnisotropicLevel(e,t,i){const s=this._caps.textureAnisotropicFilterExtension;t.samplingMode!==11&&t.samplingMode!==3&&t.samplingMode!==2&&(i=1),s&&t._cachedAnisotropicFilteringLevel!==i&&(this._setTextureParameterFloat(e,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(i,this._caps.maxAnisotropy),t),t._cachedAnisotropicFilteringLevel=i)}_setTextureParameterFloat(e,t,i,s){this._bindTextureDirectly(e,s,!0,!0),this._gl.texParameterf(e,t,i)}_setTextureParameterInteger(e,t,i,s){s&&this._bindTextureDirectly(e,s,!0,!0),this._gl.texParameteri(e,t,i)}unbindAllAttributes(){if(this._mustWipeVertexAttributes){this._mustWipeVertexAttributes=!1;for(let e=0;e<this._caps.maxVertexAttribs;e++)this.disableAttributeByIndex(e);return}for(let e=0,t=this._vertexAttribArraysEnabled.length;e<t;e++)e>=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||this.disableAttributeByIndex(e)}releaseEffects(){this._compiledEffects={},this.onReleaseEffectsObservable.notifyObservers(this)}dispose(){Gi()&&this._renderingCanvas&&(this._renderingCanvas.removeEventListener("webglcontextlost",this._onContextLost),this._onContextRestored&&this._renderingCanvas.removeEventListener("webglcontextrestored",this._onContextRestored)),super.dispose(),this._dummyFramebuffer&&this._gl.deleteFramebuffer(this._dummyFramebuffer),this.unbindAllAttributes(),this._boundUniforms={},this._workingCanvas=null,this._workingContext=null,this._currentBufferPointers.length=0,this._currentProgram=null,this._creationOptions.loseContextOnDispose&&this._gl.getExtension("WEBGL_lose_context")?.loseContext(),Pg(this._gl)}attachContextLostEvent(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextlost",e,!1)}attachContextRestoredEvent(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextrestored",e,!1)}getError(){return this._gl.getError()}_canRenderToFloatFramebuffer(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(1)}_canRenderToHalfFloatFramebuffer(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(2)}_canRenderToFramebuffer(e){const t=this._gl;for(;t.getError()!==t.NO_ERROR;);let i=!0;const s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s),t.texImage2D(t.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(e),1,1,0,t.RGBA,this._getWebGLTextureType(e),null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST);const r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0);const a=t.checkFramebufferStatus(t.FRAMEBUFFER);if(i=i&&a===t.FRAMEBUFFER_COMPLETE,i=i&&t.getError()===t.NO_ERROR,i&&(t.clear(t.COLOR_BUFFER_BIT),i=i&&t.getError()===t.NO_ERROR),i){t.bindFramebuffer(t.FRAMEBUFFER,null);const o=t.RGBA,c=t.UNSIGNED_BYTE,u=new Uint8Array(4);t.readPixels(0,0,1,1,o,c,u),i=i&&t.getError()===t.NO_ERROR}for(t.deleteTexture(s),t.deleteFramebuffer(r),t.bindFramebuffer(t.FRAMEBUFFER,null);!i&&t.getError()!==t.NO_ERROR;);return i}_getWebGLTextureType(e){if(this._webGLVersion===1){switch(e){case 1:return this._gl.FLOAT;case 2:return this._gl.HALF_FLOAT_OES;case 0:return this._gl.UNSIGNED_BYTE;case 8:return this._gl.UNSIGNED_SHORT_4_4_4_4;case 9:return this._gl.UNSIGNED_SHORT_5_5_5_1;case 10:return this._gl.UNSIGNED_SHORT_5_6_5}return this._gl.UNSIGNED_BYTE}switch(e){case 3:return this._gl.BYTE;case 0:return this._gl.UNSIGNED_BYTE;case 4:return this._gl.SHORT;case 5:return this._gl.UNSIGNED_SHORT;case 6:return this._gl.INT;case 7:return this._gl.UNSIGNED_INT;case 1:return this._gl.FLOAT;case 2:return this._gl.HALF_FLOAT;case 8:return this._gl.UNSIGNED_SHORT_4_4_4_4;case 9:return this._gl.UNSIGNED_SHORT_5_5_5_1;case 10:return this._gl.UNSIGNED_SHORT_5_6_5;case 11:return this._gl.UNSIGNED_INT_2_10_10_10_REV;case 12:return this._gl.UNSIGNED_INT_24_8;case 13:return this._gl.UNSIGNED_INT_10F_11F_11F_REV;case 14:return this._gl.UNSIGNED_INT_5_9_9_9_REV;case 15:return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV}return this._gl.UNSIGNED_BYTE}_getInternalFormat(e,t=!1){let i=t?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA;switch(e){case 0:i=this._gl.ALPHA;break;case 1:i=this._gl.LUMINANCE;break;case 2:i=this._gl.LUMINANCE_ALPHA;break;case 6:case 33322:case 36760:i=this._gl.RED;break;case 7:case 33324:case 36761:i=this._gl.RG;break;case 4:case 32852:case 36762:i=t?this._glSRGBExtensionValues.SRGB:this._gl.RGB;break;case 5:case 32859:case 36763:i=t?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA;break}if(this._webGLVersion>1)switch(e){case 8:i=this._gl.RED_INTEGER;break;case 9:i=this._gl.RG_INTEGER;break;case 10:i=this._gl.RGB_INTEGER;break;case 11:i=this._gl.RGBA_INTEGER;break}return i}_getRGBABufferInternalSizedFormat(e,t,i=!1){if(this._webGLVersion===1){if(t!==void 0)switch(t){case 0:return this._gl.ALPHA;case 1:return this._gl.LUMINANCE;case 2:return this._gl.LUMINANCE_ALPHA;case 4:return i?this._glSRGBExtensionValues.SRGB:this._gl.RGB}return this._gl.RGBA}switch(e){case 3:switch(t){case 6:return this._gl.R8_SNORM;case 7:return this._gl.RG8_SNORM;case 4:return this._gl.RGB8_SNORM;case 8:return this._gl.R8I;case 9:return this._gl.RG8I;case 10:return this._gl.RGB8I;case 11:return this._gl.RGBA8I;default:return this._gl.RGBA8_SNORM}case 0:switch(t){case 6:return this._gl.R8;case 7:return this._gl.RG8;case 4:return i?this._glSRGBExtensionValues.SRGB8:this._gl.RGB8;case 5:return i?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA8;case 8:return this._gl.R8UI;case 9:return this._gl.RG8UI;case 10:return this._gl.RGB8UI;case 11:return this._gl.RGBA8UI;case 0:return this._gl.ALPHA;case 1:return this._gl.LUMINANCE;case 2:return this._gl.LUMINANCE_ALPHA;default:return this._gl.RGBA8}case 4:switch(t){case 8:return this._gl.R16I;case 36760:return this._gl.R16_SNORM_EXT;case 36761:return this._gl.RG16_SNORM_EXT;case 36762:return this._gl.RGB16_SNORM_EXT;case 36763:return this._gl.RGBA16_SNORM_EXT;case 9:return this._gl.RG16I;case 10:return this._gl.RGB16I;case 11:return this._gl.RGBA16I;default:return this._gl.RGBA16I}case 5:switch(t){case 8:return this._gl.R16UI;case 33322:return this._gl.R16_EXT;case 33324:return this._gl.RG16_EXT;case 32852:return this._gl.RGB16_EXT;case 32859:return this._gl.RGBA16_EXT;case 9:return this._gl.RG16UI;case 10:return this._gl.RGB16UI;case 11:return this._gl.RGBA16UI;default:return this._gl.RGBA16UI}case 6:switch(t){case 8:return this._gl.R32I;case 9:return this._gl.RG32I;case 10:return this._gl.RGB32I;case 11:return this._gl.RGBA32I;default:return this._gl.RGBA32I}case 7:switch(t){case 8:return this._gl.R32UI;case 9:return this._gl.RG32UI;case 10:return this._gl.RGB32UI;case 11:return this._gl.RGBA32UI;default:return this._gl.RGBA32UI}case 1:switch(t){case 6:return this._gl.R32F;case 7:return this._gl.RG32F;case 4:return this._gl.RGB32F;case 5:return this._gl.RGBA32F;default:return this._gl.RGBA32F}case 2:switch(t){case 6:return this._gl.R16F;case 7:return this._gl.RG16F;case 4:return this._gl.RGB16F;case 5:return this._gl.RGBA16F;default:return this._gl.RGBA16F}case 10:return this._gl.RGB565;case 13:return this._gl.R11F_G11F_B10F;case 14:return this._gl.RGB9_E5;case 8:return this._gl.RGBA4;case 9:return this._gl.RGB5_A1;case 11:switch(t){case 5:return this._gl.RGB10_A2;case 11:return this._gl.RGB10_A2UI;default:return this._gl.RGB10_A2}}return i?this._glSRGBExtensionValues.SRGB8_ALPHA8:this._gl.RGBA8}readPixels(e,t,i,s,r=!0,a=!0,o=null){const c=r?4:3,u=r?this._gl.RGBA:this._gl.RGB,d=i*s*c;if(!o)o=new Uint8Array(d);else if(o.length<d)return oe.Error(`Data buffer is too small to store the read pixels (${o.length} should be more than ${d})`),Promise.resolve(o);return a&&this.flushFramebuffer(),this._gl.readPixels(e,t,i,s,u,this._gl.UNSIGNED_BYTE,o),Promise.resolve(o)}static get IsSupportedAsync(){return Promise.resolve(this.isSupported())}static get IsSupported(){return this.isSupported()}static isSupported(){if(this._HasMajorPerformanceCaveat!==null)return!this._HasMajorPerformanceCaveat;if(this._IsSupported===null)try{const e=Ce._CreateCanvas(1,1),t=e.getContext("webgl")||e.getContext("experimental-webgl");this._IsSupported=t!=null&&!!window.WebGLRenderingContext}catch{this._IsSupported=!1}return this._IsSupported}static get HasMajorPerformanceCaveat(){if(this._HasMajorPerformanceCaveat===null)try{const e=Ce._CreateCanvas(1,1),t=e.getContext("webgl",{failIfMajorPerformanceCaveat:!0})||e.getContext("experimental-webgl",{failIfMajorPerformanceCaveat:!0});this._HasMajorPerformanceCaveat=!t}catch{this._HasMajorPerformanceCaveat=!1}return this._HasMajorPerformanceCaveat}}ot._TempClearColorUint32=new Uint32Array(4);ot._TempClearColorInt32=new Int32Array(4);ot.ExceptionList=[{key:"Chrome/63.0",capture:"63\\.0\\.3239\\.(\\d+)",captureConstraint:108,targets:["uniformBuffer"]},{key:"Firefox/58",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Firefox/59",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Chrome/72.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Chrome/73.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Chrome/74.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome/71",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome/72",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Chrome/12\\d\\..+?Mobile",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:".*AppleWebKit.*(15.4).*Safari",capture:null,captureConstraint:null,targets:["antialias","maxMSAASamples"]},{key:".*(15.4).*AppleWebKit.*Safari",capture:null,captureConstraint:null,targets:["antialias","maxMSAASamples"]}];ot._ConcatenateShader=qM;ot._IsSupported=null;ot._HasMajorPerformanceCaveat=null;const Q4=Object.freeze(Object.defineProperty({__proto__:null,ThinEngine:ot},Symbol.toStringTag,{value:"Module"}));class GU{constructor(e=30){this._enabled=!0,this._rollingFrameTime=new HU(e)}sampleFrame(e=nr.Now){if(this._enabled){if(this._lastFrameTimeMs!=null){const t=e-this._lastFrameTimeMs;this._rollingFrameTime.add(t)}this._lastFrameTimeMs=e}}get averageFrameTime(){return this._rollingFrameTime.average}get averageFrameTimeVariance(){return this._rollingFrameTime.variance}get instantaneousFrameTime(){return this._rollingFrameTime.history(0)}get averageFPS(){return 1e3/this._rollingFrameTime.average}get instantaneousFPS(){const e=this._rollingFrameTime.history(0);return e===0?0:1e3/e}get isSaturated(){return this._rollingFrameTime.isSaturated()}enable(){this._enabled=!0}disable(){this._enabled=!1,this._lastFrameTimeMs=null}get isEnabled(){return this._enabled}reset(){this._lastFrameTimeMs=null,this._rollingFrameTime.reset()}}class HU{constructor(e){this._samples=new Array(e),this.reset()}add(e){let t;if(this.isSaturated()){const i=this._samples[this._pos];t=i-this.average,this.average-=t/(this._sampleCount-1),this._m2-=t*(i-this.average)}else this._sampleCount++;t=e-this.average,this.average+=t/this._sampleCount,this._m2+=t*(e-this.average),this.variance=this._m2/(this._sampleCount-1),this._samples[this._pos]=e,this._pos++,this._pos%=this._samples.length}history(e){if(e>=this._sampleCount||e>=this._samples.length)return 0;const t=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(t-e)]}isSaturated(){return this._sampleCount>=this._samples.length}reset(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0}_wrapPosition(e){const t=this._samples.length;return(e%t+t)%t}}ot.prototype.setAlphaMode=function(n,e=!1,t=0){if(this._alphaMode[t]===n){if(!e){const s=n===0;this.depthCullingState.depthMask!==s&&(this.depthCullingState.depthMask=s)}return}const i=n===0;this._alphaState.setAlphaBlend(!i,t),this._alphaState.setAlphaMode(n,t),e||(this.depthCullingState.depthMask=i),this._alphaMode[t]=n};ot.prototype.updateRawTexture=function(n,e,t,i,s=null,r=0,a=!1){if(!n)return;const o=this._getRGBABufferInternalSizedFormat(r,t,a),c=this._getInternalFormat(t),u=this._getWebGLTextureType(r);this._bindTextureDirectly(this._gl.TEXTURE_2D,n,!0),this._unpackFlipY(i===void 0?!0:!!i),this._doNotHandleContextLost||(n._bufferView=e,n.format=t,n.type=r,n.invertY=i,n._compression=s),n.width%4!==0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),s&&e?this._gl.compressedTexImage2D(this._gl.TEXTURE_2D,0,this.getCaps().s3tc[s],n.width,n.height,0,e):this._gl.texImage2D(this._gl.TEXTURE_2D,0,o,n.width,n.height,0,c,u,e),n.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),n.isReady=!0};ot.prototype.createRawTexture=function(n,e,t,i,s,r,a,o=null,c=0,u=0,d=!1){const f=new Cs(this,3);f.baseWidth=e,f.baseHeight=t,f.width=e,f.height=t,f.format=i,f.generateMipMaps=s,f.samplingMode=a,f.invertY=r,f._compression=o,f.type=c,f._useSRGBBuffer=this._getUseSRGBBuffer(d,!s),this._doNotHandleContextLost||(f._bufferView=n),this.updateRawTexture(f,n,i,r,o,c,f._useSRGBBuffer),this._bindTextureDirectly(this._gl.TEXTURE_2D,f,!0);const g=this._getSamplingParameters(a,s);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,g.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,g.min),s&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._internalTexturesCache.push(f),f};ot.prototype.createRawCubeTexture=function(n,e,t,i,s,r,a,o=null){const c=this._gl,u=new Cs(this,8);u.isCube=!0,u.format=t,u.type=i,this._doNotHandleContextLost||(u._bufferViewArray=n);const d=this._getWebGLTextureType(i);let f=this._getInternalFormat(t);f===c.RGB&&(f=c.RGBA),d===c.FLOAT&&!this._caps.textureFloatLinearFiltering?(s=!1,a=1,oe.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):d===this._gl.HALF_FLOAT_OES&&!this._caps.textureHalfFloatLinearFiltering?(s=!1,a=1,oe.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):d===c.FLOAT&&!this._caps.textureFloatRender?(s=!1,oe.Warn("Render to float textures is not supported. Mipmap generation forced to false.")):d===c.HALF_FLOAT&&!this._caps.colorBufferFloat&&(s=!1,oe.Warn("Render to half float textures is not supported. Mipmap generation forced to false."));const g=e,m=g;if(u.width=g,u.height=m,u.invertY=r,u._compression=o,!this.needPOTTextures||Oh(u.width)&&Oh(u.height)||(s=!1),n)this.updateRawCubeTexture(u,n,t,i,r,o);else{const v=this._getRGBABufferInternalSizedFormat(i),E=0;this._bindTextureDirectly(c.TEXTURE_CUBE_MAP,u,!0);for(let A=0;A<6;A++)o?c.compressedTexImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+A,E,this.getCaps().s3tc[o],u.width,u.height,0,void 0):c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+A,E,v,u.width,u.height,0,f,d,null);this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)}this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,u,!0),n&&s&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);const x=this._getSamplingParameters(a,s);return c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,x.mag),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,x.min),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),this._bindTextureDirectly(c.TEXTURE_CUBE_MAP,null),u.generateMipMaps=s,u.samplingMode=a,u.isReady=!0,u};ot.prototype.updateRawCubeTexture=function(n,e,t,i,s,r=null,a=0){n._bufferViewArray=e,n.format=t,n.type=i,n.invertY=s,n._compression=r;const o=this._gl,c=this._getWebGLTextureType(i);let u=this._getInternalFormat(t);const d=this._getRGBABufferInternalSizedFormat(i);let f=!1;u===o.RGB&&(u=o.RGBA,f=!0),this._bindTextureDirectly(o.TEXTURE_CUBE_MAP,n,!0),this._unpackFlipY(s===void 0?!0:!!s),n.width%4!==0&&o.pixelStorei(o.UNPACK_ALIGNMENT,1);for(let m=0;m<6;m++){let b=e[m];r?o.compressedTexImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+m,a,this.getCaps().s3tc[r],n.width,n.height,0,b):(f&&(b=cC(b,n.width,n.height,i)),o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+m,a,d,n.width,n.height,0,u,c,b))}(!this.needPOTTextures||Oh(n.width)&&Oh(n.height))&&n.generateMipMaps&&a===0&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),n.isReady=!0};ot.prototype.createRawCubeTextureFromUrl=function(n,e,t,i,s,r,a,o,c=null,u=null,d=3,f=!1){const g=this._gl,m=this.createRawCubeTexture(null,t,i,s,!r,f,d,null);e?.addPendingData(m),m.url=n,m.isReady=!1,this._internalTexturesCache.push(m);const b=(v,E)=>{e?.removePendingData(m),u&&v&&u(v.status+" "+v.statusText,E)},x=async v=>{if(!m._hardwareTexture)return;const E=a(v);if(!E)return;const A=E instanceof Promise?await E:E,D=m.width;if(o){const I=this._getWebGLTextureType(s);let R=this._getInternalFormat(i);const C=this._getRGBABufferInternalSizedFormat(s);let M=!1;R===g.RGB&&(R=g.RGBA,M=!0),this._bindTextureDirectly(g.TEXTURE_CUBE_MAP,m,!0),this._unpackFlipY(!1);const F=o(A);for(let U=0;U<F.length;U++){const k=D>>U;for(let q=0;q<6;q++){let Q=F[U][q];M&&(Q=cC(Q,k,k,s)),g.texImage2D(q,U,C,k,k,0,R,I,Q)}}this._bindTextureDirectly(g.TEXTURE_CUBE_MAP,null)}else this.updateRawCubeTexture(m,A,i,s,f);m.isReady=!0,e?.removePendingData(m),m.onLoadedObservable.notifyObservers(m),m.onLoadedObservable.clear(),c&&c()};return this._loadFile(n,v=>{x(v).catch(E=>{b(void 0,E)})},void 0,e?.offlineProvider,!0,b),m};function cC(n,e,t,i){let s,r=1;i===1?s=new Float32Array(e*t*4):i===2?(s=new Uint16Array(e*t*4),r=15360):i===7?s=new Uint32Array(e*t*4):s=new Uint8Array(e*t*4);for(let a=0;a<e;a++)for(let o=0;o<t;o++){const c=(o*e+a)*3,u=(o*e+a)*4;s[u+0]=n[c+0],s[u+1]=n[c+1],s[u+2]=n[c+2],s[u+3]=r}return s}function hC(n){return function(e,t,i,s,r,a,o,c,u=null,d=0){const f=n?this._gl.TEXTURE_3D:this._gl.TEXTURE_2D_ARRAY,g=n?10:11,m=new Cs(this,g);m.baseWidth=t,m.baseHeight=i,m.baseDepth=s,m.width=t,m.height=i,m.depth=s,m.format=r,m.type=d,m.generateMipMaps=a,m.samplingMode=c,n?m.is3D=!0:m.is2DArray=!0,this._doNotHandleContextLost||(m._bufferView=e),n?this.updateRawTexture3D(m,e,r,o,u,d):this.updateRawTexture2DArray(m,e,r,o,u,d),this._bindTextureDirectly(f,m,!0);const b=this._getSamplingParameters(c,a);return this._gl.texParameteri(f,this._gl.TEXTURE_MAG_FILTER,b.mag),this._gl.texParameteri(f,this._gl.TEXTURE_MIN_FILTER,b.min),a&&this._gl.generateMipmap(f),this._bindTextureDirectly(f,null),this._internalTexturesCache.push(m),m}}ot.prototype.createRawTexture2DArray=hC(!1);ot.prototype.createRawTexture3D=hC(!0);function uC(n){return function(e,t,i,s,r=null,a=0){const o=n?this._gl.TEXTURE_3D:this._gl.TEXTURE_2D_ARRAY,c=this._getWebGLTextureType(a),u=this._getInternalFormat(i),d=this._getRGBABufferInternalSizedFormat(a,i);this._bindTextureDirectly(o,e,!0),this._unpackFlipY(s===void 0?!0:!!s),this._doNotHandleContextLost||(e._bufferView=t,e.format=i,e.invertY=s,e._compression=r),e.width%4!==0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),r&&t?this._gl.compressedTexImage3D(o,0,this.getCaps().s3tc[r],e.width,e.height,e.depth,0,t):this._gl.texImage3D(o,0,d,e.width,e.height,e.depth,0,u,c,t),e.generateMipMaps&&this._gl.generateMipmap(o),this._bindTextureDirectly(o,null),e.isReady=!0}}ot.prototype.updateRawTexture2DArray=uC(!1);ot.prototype.updateRawTexture3D=uC(!0);ot.prototype._readTexturePixelsSync=function(n,e,t,i=-1,s=0,r=null,a=!0,o=!1,c=0,u=0){const d=this._gl;if(!d)throw new Error("Engine does not have gl rendering context.");if(!this._dummyFramebuffer){const g=d.createFramebuffer();if(!g)throw new Error("Unable to create dummy framebuffer");this._dummyFramebuffer=g}d.bindFramebuffer(d.FRAMEBUFFER,this._dummyFramebuffer),i>-1?d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_CUBE_MAP_POSITIVE_X+i,n._hardwareTexture?.underlyingResource,s):d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,n._hardwareTexture?.underlyingResource,s);let f=n.type!==void 0?this._getWebGLTextureType(n.type):d.UNSIGNED_BYTE;if(o)r||(r=rU(n.type,4*e*t));else switch(f){case d.UNSIGNED_BYTE:r||(r=new Uint8Array(4*e*t)),f=d.UNSIGNED_BYTE;break;default:r||(r=new Float32Array(4*e*t)),f=d.FLOAT;break}return a&&this.flushFramebuffer(),d.readPixels(c,u,e,t,d.RGBA,f,r),d.bindFramebuffer(d.FRAMEBUFFER,this._currentFramebuffer),r};ot.prototype._readTexturePixels=function(n,e,t,i=-1,s=0,r=null,a=!0,o=!1,c=0,u=0){return Promise.resolve(this._readTexturePixelsSync(n,e,t,i,s,r,a,o,c,u))};ot.prototype.updateDynamicIndexBuffer=function(n,e,t=0){this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER]=null,this.bindIndexBuffer(n);let i;n.is32Bits?i=e instanceof Uint32Array?e:new Uint32Array(e):i=e instanceof Uint16Array?e:new Uint16Array(e),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,i,this._gl.DYNAMIC_DRAW),this._resetIndexBufferBinding()};ot.prototype.updateDynamicVertexBuffer=function(n,e,t,i){this.bindArrayBuffer(n),t===void 0&&(t=0);const s=e.byteLength||e.length;i===void 0||i>=s&&t===0?e instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,t,new Float32Array(e)):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,t,e):e instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,t,new Float32Array(e).subarray(0,i/4)):(e instanceof ArrayBuffer?e=new Uint8Array(e,0,i):e=new Uint8Array(e.buffer,e.byteOffset,i),this._gl.bufferSubData(this._gl.ARRAY_BUFFER,t,e)),this._resetVertexBufferBinding()};ot.prototype._createDepthStencilCubeTexture=function(n,e){const t=new Cs(this,12);if(t.isCube=!0,this.webGLVersion===1)return oe.Error("Depth cube texture is not supported by WebGL 1."),t;const i={bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,...e},s=this._gl;this._bindTextureDirectly(s.TEXTURE_CUBE_MAP,t,!0),this._setupDepthStencilTexture(t,n,i.bilinearFiltering,i.comparisonFunction);for(let r=0;r<6;r++)i.generateStencil?s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,s.DEPTH24_STENCIL8,n,n,0,s.DEPTH_STENCIL,s.UNSIGNED_INT_24_8,null):s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,s.DEPTH_COMPONENT24,n,n,0,s.DEPTH_COMPONENT,s.UNSIGNED_INT,null);return this._bindTextureDirectly(s.TEXTURE_CUBE_MAP,null),this._internalTexturesCache.push(t),t};ot.prototype._setCubeMapTextureParams=function(n,e,t){const i=this._gl;i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MIN_FILTER,e?i.LINEAR_MIPMAP_LINEAR:i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),n.samplingMode=e?3:2,e&&this.getCaps().textureMaxLevel&&t!==void 0&&t>0&&(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_LEVEL,t),n._maxLodLevel=t),this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,null)};ot.prototype.createCubeTexture=function(n,e,t,i,s=null,r=null,a,o=null,c=!1,u=0,d=0,f=null,g,m=!1,b=null){const x=this._gl;return this.createCubeTextureBase(n,e,t,!!i,s,r,a,o,c,u,d,f,v=>this._bindTextureDirectly(x.TEXTURE_CUBE_MAP,v,!0),(v,E)=>{const A=this.needPOTTextures?Vo(E[0].width,this._caps.maxCubemapTextureSize):E[0].width,D=A,I=[x.TEXTURE_CUBE_MAP_POSITIVE_X,x.TEXTURE_CUBE_MAP_POSITIVE_Y,x.TEXTURE_CUBE_MAP_POSITIVE_Z,x.TEXTURE_CUBE_MAP_NEGATIVE_X,x.TEXTURE_CUBE_MAP_NEGATIVE_Y,x.TEXTURE_CUBE_MAP_NEGATIVE_Z];this._bindTextureDirectly(x.TEXTURE_CUBE_MAP,v,!0),this._unpackFlipY(!1);const R=a?this._getInternalFormat(a,v._useSRGBBuffer):v._useSRGBBuffer?this._glSRGBExtensionValues.SRGB8_ALPHA8:x.RGBA;let C=a?this._getInternalFormat(a):x.RGBA;v._useSRGBBuffer&&this.webGLVersion===1&&(C=R);for(let M=0;M<I.length;M++)if(E[M].width!==A||E[M].height!==D){if(this._prepareWorkingCanvas(),!this._workingCanvas||!this._workingContext){oe.Warn("Cannot create canvas to resize texture.");return}this._workingCanvas.width=A,this._workingCanvas.height=D,this._workingContext.drawImage(E[M],0,0,E[M].width,E[M].height,0,0,A,D),x.texImage2D(I[M],0,R,C,x.UNSIGNED_BYTE,this._workingCanvas)}else x.texImage2D(I[M],0,R,C,x.UNSIGNED_BYTE,E[M]);i||x.generateMipmap(x.TEXTURE_CUBE_MAP),this._setCubeMapTextureParams(v,!i),v.width=A,v.height=D,v.isReady=!0,a&&(v.format=a),v.onLoadedObservable.notifyObservers(v),v.onLoadedObservable.clear(),s&&s()},!!m,b)};ot.prototype.generateMipMapsForCubemap=function(n,e=!0){if(n.generateMipMaps){const t=this._gl;this._bindTextureDirectly(t.TEXTURE_CUBE_MAP,n,!0),t.generateMipmap(t.TEXTURE_CUBE_MAP),e&&this._bindTextureDirectly(t.TEXTURE_CUBE_MAP,null)}};class WU{get depthStencilTexture(){return this._depthStencilTexture}setDepthStencilTexture(e,t=!0){t&&this._depthStencilTexture&&this._depthStencilTexture.dispose(),this._depthStencilTexture=e,this._generateDepthBuffer=this._generateStencilBuffer=this._depthStencilTextureWithStencil=!1,e&&(this._generateDepthBuffer=!0,this._generateStencilBuffer=this._depthStencilTextureWithStencil=wh(e.format))}get depthStencilTextureWithStencil(){return this._depthStencilTextureWithStencil}get isCube(){return this._isCube}get isMulti(){return this._isMulti}get is2DArray(){return this.layers>0}get is3D(){return this.depth>0}get size(){return this.width}get width(){return this._size.width??this._size}get height(){return this._size.height??this._size}get layers(){return this._size.layers||0}get depth(){return this._size.depth||0}get texture(){return this._textures?.[0]??null}get textures(){return this._textures}get faceIndices(){return this._faceIndices}get layerIndices(){return this._layerIndices}getBaseArrayLayer(e){if(!this._textures)return-1;const t=this._textures[e],i=this._layerIndices?.[e]??0,s=this._faceIndices?.[e]??0;return t.isCube?i*6+s:t.is3D?0:i}get samples(){return this._samples}setSamples(e,t=!0,i=!1){if(this.samples===e&&!i)return e;const s=this._isMulti?this._engine.updateMultipleRenderTargetTextureSampleCount(this,e,t):this._engine.updateRenderTargetTextureSampleCount(this,e);return this._samples=e,s}resolveMSAATextures(){this.isMulti?this._engine.resolveMultiFramebuffer(this):this._engine.resolveFramebuffer(this)}generateMipMaps(){this._engine._currentRenderTarget===this&&this._engine.unBindFramebuffer(this,!0),this.isMulti?this._engine.generateMipMapsMultiFramebuffer(this):this._engine.generateMipMapsFramebuffer(this)}constructor(e,t,i,s,r){this._textures=null,this._faceIndices=null,this._layerIndices=null,this._samples=1,this._attachments=null,this._generateStencilBuffer=!1,this._generateDepthBuffer=!1,this._depthStencilTextureWithStencil=!1,this.disableAutomaticMSAAResolve=!1,this.resolveMSAAColors=!0,this.resolveMSAADepth=!1,this.resolveMSAAStencil=!1,this.depthReadOnly=!1,this.stencilReadOnly=!1,this._isMulti=e,this._isCube=t,this._size=i,this._engine=s,this._depthStencilTexture=null,this.label=r}setTextures(e){Array.isArray(e)?this._textures=e:e?this._textures=[e]:this._textures=null}setTexture(e,t=0,i=!0){this._textures||(this._textures=[]),this._textures[t]!==e&&(this._textures[t]&&i&&this._textures[t].dispose(),this._textures[t]=e)}setLayerAndFaceIndices(e,t){this._layerIndices=e,this._faceIndices=t}setLayerAndFaceIndex(e=0,t,i){this._layerIndices||(this._layerIndices=[]),this._faceIndices||(this._faceIndices=[]),t!==void 0&&t>=0&&(this._layerIndices[e]=t),i!==void 0&&i>=0&&(this._faceIndices[e]=i)}createDepthStencilTexture(e=0,t=!0,i=!1,s=1,r=14,a){return this._depthStencilTexture?.dispose(),this._depthStencilTextureWithStencil=i,this._depthStencilTextureLabel=a,this._depthStencilTexture=this._engine.createDepthStencilTexture(this._size,{bilinearFiltering:t,comparisonFunction:e,generateStencil:i,isCube:this._isCube,samples:s,depthTextureFormat:r,label:a},this),this._depthStencilTexture}_shareDepth(e){this.shareDepth(e)}shareDepth(e){this._depthStencilTexture&&(e._depthStencilTexture&&e._depthStencilTexture.dispose(),e._depthStencilTexture=this._depthStencilTexture,e._depthStencilTextureWithStencil=this._depthStencilTextureWithStencil,this._depthStencilTexture.incrementReferences())}_swapAndDie(e){this.texture&&this.texture._swapAndDie(e),this._textures=null,this.dispose(!0)}_cloneRenderTargetWrapper(){let e=null;if(this._isMulti){const t=this.textures;if(t&&t.length>0){let i=!1,s=t.length,r=-1;const a=t[t.length-1]._source;(a===14||a===12)&&(i=!0,r=t[t.length-1].format,s--);const o=[],c=[],u=[],d=[],f=[],g=[],m=[],b={};for(let E=0;E<s;++E){const A=t[E];o.push(A.samplingMode),c.push(A.type),u.push(A.format),b[A.uniqueId]!==void 0?(d.push(-1),m.push(0)):(b[A.uniqueId]=E,A.is2DArray?(d.push(35866),m.push(A.depth)):A.isCube?(d.push(34067),m.push(0)):A.is3D?(d.push(32879),m.push(A.depth)):(d.push(3553),m.push(0))),this._faceIndices&&f.push(this._faceIndices[E]??0),this._layerIndices&&g.push(this._layerIndices[E]??0)}const x={samplingModes:o,generateMipMaps:t[0].generateMipMaps,generateDepthBuffer:this._generateDepthBuffer,generateStencilBuffer:this._generateStencilBuffer,generateDepthTexture:i,depthTextureFormat:r,types:c,formats:u,textureCount:s,targetTypes:d,faceIndex:f,layerIndex:g,layerCounts:m,label:this.label},v={width:this.width,height:this.height,depth:this.depth};e=this._engine.createMultipleRenderTarget(v,x);for(let E=0;E<s;++E){if(d[E]!==-1)continue;const A=b[t[E].uniqueId];e.setTexture(e.textures[A],E)}}}else{const t={};if(t.generateDepthBuffer=this._generateDepthBuffer,t.generateMipMaps=this.texture?.generateMipMaps??!1,t.generateStencilBuffer=this._generateStencilBuffer,t.samplingMode=this.texture?.samplingMode,t.type=this.texture?.type,t.format=this.texture?.format,t.noColorAttachment=!this._textures,t.label=this.label,this.isCube)e=this._engine.createRenderTargetCubeTexture(this.width,t);else{const i={width:this.width,height:this.height,layers:this.is2DArray||this.is3D?this.texture?.depth:void 0};e=this._engine.createRenderTargetTexture(i,t)}e.texture&&(e.texture.isReady=!0)}return e}_swapRenderTargetWrapper(e){if(this._textures&&e._textures)for(let t=0;t<this._textures.length;++t)this._textures[t]._swapAndDie(e._textures[t],!1),e._textures[t].isReady=!0;this._depthStencilTexture&&e._depthStencilTexture&&(this._depthStencilTexture._swapAndDie(e._depthStencilTexture),e._depthStencilTexture.isReady=!0),this._textures=null,this._depthStencilTexture=null}_rebuild(){const e=this._cloneRenderTargetWrapper();if(e){if(this._depthStencilTexture){const t=this._depthStencilTexture.samplingMode,i=this._depthStencilTexture.format,s=t===2||t===3||t===11;e.createDepthStencilTexture(this._depthStencilTexture._comparisonFunction,s,this._depthStencilTextureWithStencil,this._depthStencilTexture.samples,i,this._depthStencilTextureLabel)}this.samples>1&&e.setSamples(this.samples),e._swapRenderTargetWrapper(this),e.dispose()}}releaseTextures(){if(this._textures)for(let e=0;e<this._textures.length;++e)this._textures[e].dispose();this._textures=null}dispose(e=!1){e||(this._depthStencilTexture?.dispose(),this._depthStencilTexture=null,this.releaseTextures()),this._engine._releaseRenderTargetWrapper(this)}}class XU extends WU{setDepthStencilTexture(e,t=!0){if(super.setDepthStencilTexture(e,t),!e)return;const i=this._engine,s=this._context,r=e._hardwareTexture;if(r&&e._autoMSAAManagement&&this._MSAAFramebuffer){const a=i._currentFramebuffer;i._bindUnboundFramebuffer(this._MSAAFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,wh(e.format)?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,s.RENDERBUFFER,r.getMSAARenderBuffer()),i._bindUnboundFramebuffer(a)}}constructor(e,t,i,s,r){super(e,t,i,s),this._framebuffer=null,this._depthStencilBuffer=null,this._MSAAFramebuffer=null,this._colorTextureArray=null,this._depthStencilTextureArray=null,this._disposeOnlyFramebuffers=!1,this._currentLOD=0,this._context=r}_cloneRenderTargetWrapper(){let e=null;return this._colorTextureArray&&this._depthStencilTextureArray?(e=this._engine.createMultiviewRenderTargetTexture(this.width,this.height),e.texture.isReady=!0):e=super._cloneRenderTargetWrapper(),e}_swapRenderTargetWrapper(e){super._swapRenderTargetWrapper(e),e._framebuffer=this._framebuffer,e._depthStencilBuffer=this._depthStencilBuffer,e._MSAAFramebuffer=this._MSAAFramebuffer,e._colorTextureArray=this._colorTextureArray,e._depthStencilTextureArray=this._depthStencilTextureArray,this._framebuffer=this._depthStencilBuffer=this._MSAAFramebuffer=this._colorTextureArray=this._depthStencilTextureArray=null}createDepthStencilTexture(e=0,t=!0,i=!1,s=1,r=14,a){if(this._depthStencilBuffer){const o=this._engine,c=o._currentFramebuffer,u=this._context;o._bindUnboundFramebuffer(this._framebuffer),u.framebufferRenderbuffer(u.FRAMEBUFFER,u.DEPTH_STENCIL_ATTACHMENT,u.RENDERBUFFER,null),u.framebufferRenderbuffer(u.FRAMEBUFFER,u.DEPTH_ATTACHMENT,u.RENDERBUFFER,null),u.framebufferRenderbuffer(u.FRAMEBUFFER,u.STENCIL_ATTACHMENT,u.RENDERBUFFER,null),o._bindUnboundFramebuffer(c),u.deleteRenderbuffer(this._depthStencilBuffer),this._depthStencilBuffer=null}return super.createDepthStencilTexture(e,t,i,s,r,a)}shareDepth(e){super.shareDepth(e);const t=this._context,i=this._depthStencilBuffer,s=e._MSAAFramebuffer||e._framebuffer,r=this._engine;e._depthStencilBuffer&&e._depthStencilBuffer!==i&&t.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=i;const a=e._generateStencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;r._bindUnboundFramebuffer(s),t.framebufferRenderbuffer(t.FRAMEBUFFER,a,t.RENDERBUFFER,i),r._bindUnboundFramebuffer(null)}_bindTextureRenderTarget(e,t=0,i,s=0){const r=e._hardwareTexture;if(!r)return;const a=this._framebuffer,o=this._engine,c=o._currentFramebuffer;o._bindUnboundFramebuffer(a);let u;if(o.webGLVersion>1){const d=this._context;u=d["COLOR_ATTACHMENT"+t],e.is2DArray||e.is3D?(i=i??this.layerIndices?.[t]??0,d.framebufferTextureLayer(d.FRAMEBUFFER,u,r.underlyingResource,s,i)):e.isCube?(i=i??this.faceIndices?.[t]??0,d.framebufferTexture2D(d.FRAMEBUFFER,u,d.TEXTURE_CUBE_MAP_POSITIVE_X+i,r.underlyingResource,s)):d.framebufferTexture2D(d.FRAMEBUFFER,u,d.TEXTURE_2D,r.underlyingResource,s)}else{const d=this._context;u=d["COLOR_ATTACHMENT"+t+"_WEBGL"];const f=i!==void 0?d.TEXTURE_CUBE_MAP_POSITIVE_X+i:d.TEXTURE_2D;d.framebufferTexture2D(d.FRAMEBUFFER,u,f,r.underlyingResource,s)}if(e._autoMSAAManagement&&this._MSAAFramebuffer){const d=this._context;o._bindUnboundFramebuffer(this._MSAAFramebuffer),d.framebufferRenderbuffer(d.FRAMEBUFFER,u,d.RENDERBUFFER,r.getMSAARenderBuffer())}o._bindUnboundFramebuffer(c)}setTexture(e,t=0,i=!0){super.setTexture(e,t,i),this._bindTextureRenderTarget(e,t)}setLayerAndFaceIndices(e,t){if(super.setLayerAndFaceIndices(e,t),!this.textures||!this.layerIndices||!this.faceIndices)return;const i=this._attachments?.length??this.textures.length;for(let s=0;s<i;s++){const r=this.textures[s];r&&(r.is2DArray||r.is3D?this._bindTextureRenderTarget(r,s,this.layerIndices[s]):r.isCube?this._bindTextureRenderTarget(r,s,this.faceIndices[s]):this._bindTextureRenderTarget(r,s))}}setLayerAndFaceIndex(e=0,t,i){if(super.setLayerAndFaceIndex(e,t,i),!this.textures||!this.layerIndices||!this.faceIndices)return;const s=this.textures[e];s.is2DArray||s.is3D?this._bindTextureRenderTarget(this.textures[e],e,this.layerIndices[e]):s.isCube&&this._bindTextureRenderTarget(this.textures[e],e,this.faceIndices[e])}resolveMSAATextures(){const e=this._engine,t=e._currentFramebuffer;e._bindUnboundFramebuffer(this._MSAAFramebuffer),super.resolveMSAATextures(),e._bindUnboundFramebuffer(t)}dispose(e=this._disposeOnlyFramebuffers){const t=this._context;e||(this._colorTextureArray&&(this._context.deleteTexture(this._colorTextureArray),this._colorTextureArray=null),this._depthStencilTextureArray&&(this._context.deleteTexture(this._depthStencilTextureArray),this._depthStencilTextureArray=null)),this._framebuffer&&(t.deleteFramebuffer(this._framebuffer),this._framebuffer=null),this._depthStencilBuffer&&(t.deleteRenderbuffer(this._depthStencilBuffer),this._depthStencilBuffer=null),this._MSAAFramebuffer&&(t.deleteFramebuffer(this._MSAAFramebuffer),this._MSAAFramebuffer=null),super.dispose(e)}}Ce.prototype.createDepthStencilTexture=function(n,e,t){if(e.isCube){const i=n.width||n;return this._createDepthStencilCubeTexture(i,e)}else return this._createDepthStencilTexture(n,e,t)};ot.prototype._createHardwareRenderTargetWrapper=function(n,e,t){const i=new XU(n,e,t,this,this._gl);return this._renderTargetWrapperCache.push(i),i};ot.prototype.createRenderTargetTexture=function(n,e){const t=this._createHardwareRenderTargetWrapper(!1,!1,n);let i=!0,s=!1,r=!1,a,o=1,c;e!==void 0&&typeof e=="object"&&(i=e.generateDepthBuffer??!0,s=!!e.generateStencilBuffer,r=!!e.noColorAttachment,a=e.colorAttachment,o=e.samples??1,c=e.label);const u=a||(r?null:this._createInternalTexture(n,e,!0,5)),d=n.width||n,f=n.height||n,g=this._currentFramebuffer,m=this._gl,b=m.createFramebuffer();if(this._bindUnboundFramebuffer(b),t._depthStencilBuffer=this._setupFramebufferDepthAttachments(s,i,d,f),u&&!u.is2DArray&&!u.is3D&&m.framebufferTexture2D(m.FRAMEBUFFER,m.COLOR_ATTACHMENT0,m.TEXTURE_2D,u._hardwareTexture.underlyingResource,0),this._bindUnboundFramebuffer(g),t.label=c??"RenderTargetWrapper",t._framebuffer=b,t._generateDepthBuffer=i,t._generateStencilBuffer=s,t.setTextures(u),!a)this.updateRenderTargetTextureSampleCount(t,o);else if(t._samples=a.samples,a.samples>1){const x=a._hardwareTexture.getMSAARenderBuffer(0);t._MSAAFramebuffer=m.createFramebuffer(),this._bindUnboundFramebuffer(t._MSAAFramebuffer),m.framebufferRenderbuffer(m.FRAMEBUFFER,m.COLOR_ATTACHMENT0,m.RENDERBUFFER,x),this._bindUnboundFramebuffer(null)}return t};ot.prototype._createDepthStencilTexture=function(n,e,t){const i=this._gl,s=n.layers||0,r=n.depth||0;let a=i.TEXTURE_2D;s!==0?a=i.TEXTURE_2D_ARRAY:r!==0&&(a=i.TEXTURE_3D);const o=new Cs(this,12);if(o.label=e.label,!this._caps.depthTextureExtension)return oe.Error("Depth texture is not supported by your browser or hardware."),o;const c={bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,...e};if(this._bindTextureDirectly(a,o,!0),this._setupDepthStencilTexture(o,n,c.comparisonFunction===0?!1:c.bilinearFiltering,c.comparisonFunction,c.samples),c.depthTextureFormat!==void 0){if(c.depthTextureFormat!==15&&c.depthTextureFormat!==16&&c.depthTextureFormat!==17&&c.depthTextureFormat!==13&&c.depthTextureFormat!==14&&c.depthTextureFormat!==18)return oe.Error(`Depth texture ${c.depthTextureFormat} format is not supported.`),o;o.format=c.depthTextureFormat}else o.format=c.generateStencil?13:16;const u=wh(o.format),d=this._getWebGLTextureTypeFromDepthTextureFormat(o.format),f=u?i.DEPTH_STENCIL:i.DEPTH_COMPONENT,g=this._getInternalFormatFromDepthTextureFormat(o.format,!0,u);return o.is2DArray?i.texImage3D(a,0,g,o.width,o.height,s,0,f,d,null):o.is3D?i.texImage3D(a,0,g,o.width,o.height,r,0,f,d,null):i.texImage2D(a,0,g,o.width,o.height,0,f,d,null),this._bindTextureDirectly(a,null),this._internalTexturesCache.push(o),t._depthStencilBuffer&&(i.deleteRenderbuffer(t._depthStencilBuffer),t._depthStencilBuffer=null),this._bindUnboundFramebuffer(t._MSAAFramebuffer??t._framebuffer),t._generateStencilBuffer=u,t._depthStencilTextureWithStencil=u,t._depthStencilBuffer=this._setupFramebufferDepthAttachments(t._generateStencilBuffer,t._generateDepthBuffer,t.width,t.height,t.samples,o.format),this._bindUnboundFramebuffer(null),o};ot.prototype.updateRenderTargetTextureSampleCount=function(n,e){if(this.webGLVersion<2||!n)return 1;if(n.samples===e)return e;const t=this._gl;e=Math.min(e,this.getCaps().maxMSAASamples),n._depthStencilBuffer&&(t.deleteRenderbuffer(n._depthStencilBuffer),n._depthStencilBuffer=null),n._MSAAFramebuffer&&(t.deleteFramebuffer(n._MSAAFramebuffer),n._MSAAFramebuffer=null);const i=n.texture?._hardwareTexture;if(i?.releaseMSAARenderBuffers(),n.texture&&e>1&&typeof t.renderbufferStorageMultisample=="function"){const r=t.createFramebuffer();if(!r)throw new Error("Unable to create multi sampled framebuffer");n._MSAAFramebuffer=r,this._bindUnboundFramebuffer(n._MSAAFramebuffer);const a=this._createRenderBuffer(n.texture.width,n.texture.height,e,-1,this._getRGBABufferInternalSizedFormat(n.texture.type,n.texture.format,n.texture._useSRGBBuffer),t.COLOR_ATTACHMENT0,!1);if(!a)throw new Error("Unable to create multi sampled framebuffer");i?.addMSAARenderBuffer(a)}this._bindUnboundFramebuffer(n._MSAAFramebuffer??n._framebuffer),n.texture&&(n.texture.samples=e),n._samples=e;const s=n._depthStencilTexture?n._depthStencilTexture.format:void 0;return n._depthStencilBuffer=this._setupFramebufferDepthAttachments(n._generateStencilBuffer,n._generateDepthBuffer,n.width,n.height,e,s),this._bindUnboundFramebuffer(null),e};ot.prototype._setupDepthStencilTexture=function(n,e,t,i,s=1){const r=e.width??e,a=e.height??e,o=e.layers||0,c=e.depth||0;n.baseWidth=r,n.baseHeight=a,n.width=r,n.height=a,n.is2DArray=o>0,n.depth=o||c,n.isReady=!0,n.samples=s,n.generateMipMaps=!1,n.samplingMode=t?2:1,n.type=0,n._comparisonFunction=i;const u=this._gl,d=this._getTextureTarget(n),f=this._getSamplingParameters(n.samplingMode,!1);u.texParameteri(d,u.TEXTURE_MAG_FILTER,f.mag),u.texParameteri(d,u.TEXTURE_MIN_FILTER,f.min),u.texParameteri(d,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(d,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),this.webGLVersion>1&&(i===0?(u.texParameteri(d,u.TEXTURE_COMPARE_FUNC,515),u.texParameteri(d,u.TEXTURE_COMPARE_MODE,u.NONE)):(u.texParameteri(d,u.TEXTURE_COMPARE_FUNC,i),u.texParameteri(d,u.TEXTURE_COMPARE_MODE,u.COMPARE_REF_TO_TEXTURE)))};ot.prototype.setDepthStencilTexture=function(n,e,t,i){n!==void 0&&(e&&(this._boundUniforms[n]=e),!t||!t.depthStencilTexture?this._setTexture(n,null,void 0,void 0,i):this._setTexture(n,t,!1,!0,i))};ot.prototype.createRenderTargetCubeTexture=function(n,e){const t=this._createHardwareRenderTargetWrapper(!1,!0,n),i={generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:0,samplingMode:3,format:5,...e};i.generateStencilBuffer=i.generateDepthBuffer&&i.generateStencilBuffer,(i.type===1&&!this._caps.textureFloatLinearFiltering||i.type===2&&!this._caps.textureHalfFloatLinearFiltering)&&(i.samplingMode=1);const s=this._gl,r=new Cs(this,5);this._bindTextureDirectly(s.TEXTURE_CUBE_MAP,r,!0);const a=this._getSamplingParameters(i.samplingMode,i.generateMipMaps);i.type===1&&!this._caps.textureFloat&&(i.type=0,oe.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,a.mag),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,a.min),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE);for(let c=0;c<6;c++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,this._getRGBABufferInternalSizedFormat(i.type,i.format),n,n,0,this._getInternalFormat(i.format),this._getWebGLTextureType(i.type),null);const o=s.createFramebuffer();
228return this._bindUnboundFramebuffer(o),t._depthStencilBuffer=this._setupFramebufferDepthAttachments(i.generateStencilBuffer,i.generateDepthBuffer,n,n),i.generateMipMaps&&s.generateMipmap(s.TEXTURE_CUBE_MAP),this._bindTextureDirectly(s.TEXTURE_CUBE_MAP,null),this._bindUnboundFramebuffer(null),t._framebuffer=o,t._generateDepthBuffer=i.generateDepthBuffer,t._generateStencilBuffer=i.generateStencilBuffer,r.width=n,r.height=n,r.isReady=!0,r.isCube=!0,r.samples=1,r.generateMipMaps=i.generateMipMaps,r.samplingMode=i.samplingMode,r.type=i.type,r.format=i.format,this._internalTexturesCache.push(r),t.setTextures(r),t};const jU=1/2.2,YU=2.2,gi=(1+Math.sqrt(5))/2,bt=.001;function Xr(n,e){const t=[];for(let i=0;i<n;++i)t.push(e());return t}function no(n,e){return Xr(n,e)}function KU(n,e,t){const i=n[e];if(typeof i!="function")return null;const s=function(){const r=n.length,a=s.previous.apply(n,arguments);return t(e,r),a};return i.next=s,s.previous=i,n[e]=s,()=>{const r=s.previous;if(!r)return;const a=s.next;a?(r.next=a,a.previous=r):(r.next=void 0,n[e]=r),s.next=void 0,s.previous=void 0}}const qU=["push","splice","pop","shift","unshift"];function dC(n,e){const t=qU.map(i=>KU(n,i,e));return()=>{for(const i of t)i?.()}}const fC={};function Tt(n,e){fC[n]=e}function Kr(n){return fC[n]}function Lt(n,e,t=1401298e-51){return Math.abs(n-e)<=t}function li(n,e){return n===e?n:Math.random()*(e-n)+n}function Jd(n,e,t){return n+(e-n)*t}function ZU(n,e,t,i,s){const r=s*s,a=s*r,o=2*a-3*r+1,c=-2*a+3*r,u=a-2*r+s,d=a-r;return n*o+t*c+e*u+i*d}function Qt(n,e=0,t=1){return Math.min(t,Math.max(e,n))}function $U(n){return n-=Math.PI*2*Math.floor((n+Math.PI)/(Math.PI*2)),n}function _n(n){const e=n.toString(16);return n<=15?("0"+e).toUpperCase():e.toUpperCase()}function J4(n){if(Math.log2)return Math.floor(Math.log2(n));if(n<0)return NaN;if(n===0)return-1/0;let e=0;if(n<1){for(;n<1;)e++,n=n*2;e=-e}else if(n>1)for(;n>1;)e++,n=Math.floor(n/2);return e}function Pm(n,e){const t=n%e;return t===0?e:Pm(e,t)}class Sb{}Sb._UpdateFlagSeed=0;function pC(n){n.updateFlag=Sb._UpdateFlagSeed++}function _C(n,e,t,i=0){const s=n.asArray(),r=e.asArray(),a=s[0],o=s[1],c=s[2],u=s[3],d=s[4],f=s[5],g=s[6],m=s[7],b=s[8],x=s[9],v=s[10],E=s[11],A=s[12],D=s[13],I=s[14],R=s[15],C=r[0],M=r[1],F=r[2],U=r[3],k=r[4],q=r[5],Q=r[6],ie=r[7],$=r[8],ce=r[9],G=r[10],K=r[11],X=r[12],J=r[13],se=r[14],w=r[15];t[i]=a*C+o*k+c*$+u*X,t[i+1]=a*M+o*q+c*ce+u*J,t[i+2]=a*F+o*Q+c*G+u*se,t[i+3]=a*U+o*ie+c*K+u*w,t[i+4]=d*C+f*k+g*$+m*X,t[i+5]=d*M+f*q+g*ce+m*J,t[i+6]=d*F+f*Q+g*G+m*se,t[i+7]=d*U+f*ie+g*K+m*w,t[i+8]=b*C+x*k+v*$+E*X,t[i+9]=b*M+x*q+v*ce+E*J,t[i+10]=b*F+x*Q+v*G+E*se,t[i+11]=b*U+x*ie+v*K+E*w,t[i+12]=A*C+D*k+I*$+R*X,t[i+13]=A*M+D*q+I*ce+R*J,t[i+14]=A*F+D*Q+I*G+R*se,t[i+15]=A*U+D*ie+I*K+R*w}function rc(n,e,t,i=0){_C(n,e,t.asArray(),i),pC(t)}function QU(n,e,t=0){const i=n.asArray();e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15]}function ef(n,e){const t=gC(n,e.asArray());return t&&pC(e),t}function gC(n,e){const t=n.asArray(),i=t[0],s=t[1],r=t[2],a=t[3],o=t[4],c=t[5],u=t[6],d=t[7],f=t[8],g=t[9],m=t[10],b=t[11],x=t[12],v=t[13],E=t[14],A=t[15],D=m*A-E*b,I=g*A-v*b,R=g*E-v*m,C=f*A-x*b,M=f*E-m*x,F=f*v-x*g,U=+(c*D-u*I+d*R),k=-(o*D-u*C+d*M),q=+(o*I-c*C+d*F),Q=-(o*R-c*M+u*F),ie=i*U+s*k+r*q+a*Q;if(ie===0)return!1;const $=1/ie,ce=u*A-E*d,G=c*A-v*d,K=c*E-v*u,X=o*A-x*d,J=o*E-x*u,se=o*v-x*c,w=u*b-m*d,L=c*b-g*d,V=c*m-g*u,j=o*b-f*d,ae=o*m-f*u,he=o*g-f*c,be=-(s*D-r*I+a*R),Le=+(i*D-r*C+a*M),Xe=-(i*I-s*C+a*F),it=+(i*R-s*M+r*F),ut=+(s*ce-r*G+a*K),Oe=-(i*ce-r*X+a*J),Qe=+(i*G-s*X+a*se),Be=-(i*K-s*J+r*se),Ot=-(s*w-r*L+a*V),Wt=+(i*w-r*j+a*ae),vi=-(i*L-s*j+a*he),Wi=+(i*V-s*ae+r*he);return e[0]=U*$,e[1]=be*$,e[2]=ut*$,e[3]=Ot*$,e[4]=k*$,e[5]=Le*$,e[6]=Oe*$,e[7]=Wt*$,e[8]=q*$,e[9]=Xe*$,e[10]=Qe*$,e[11]=vi*$,e[12]=Q*$,e[13]=it*$,e[14]=Be*$,e[15]=Wi*$,!0}const Es=n=>parseInt(n.toString().replace(/\W/g,""));class Ie{constructor(e=0,t=0){this.x=e,this.y=t}toString(){return`{X: ${this.x} Y: ${this.y}}`}getClassName(){return"Vector2"}getHashCode(){const e=Es(this.x),t=Es(this.y);let i=e;return i=i*397^t,i}toArray(e,t=0){return e[t]=this.x,e[t+1]=this.y,this}fromArray(e,t=0){return Ie.FromArrayToRef(e,t,this),this}asArray(){return[this.x,this.y]}copyFrom(e){return this.x=e.x,this.y=e.y,this}copyFromFloats(e,t){return this.x=e,this.y=t,this}set(e,t){return this.copyFromFloats(e,t)}setAll(e){return this.copyFromFloats(e,e)}add(e){return new Ie(this.x+e.x,this.y+e.y)}addToRef(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,t}addInPlace(e){return this.x+=e.x,this.y+=e.y,this}addInPlaceFromFloats(e,t){return this.x+=e,this.y+=t,this}addVector3(e){return new Ie(this.x+e.x,this.y+e.y)}subtract(e){return new Ie(this.x-e.x,this.y-e.y)}subtractToRef(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,t}
vendor: 79,414 bytes, lines 228-231
228subtractInPlace(e){return this.x-=e.x,this.y-=e.y,this}multiplyInPlace(e){return this.x*=e.x,this.y*=e.y,this}multiply(e){return new Ie(this.x*e.x,this.y*e.y)}multiplyToRef(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,t}multiplyByFloats(e,t){return new Ie(this.x*e,this.y*t)}divide(e){return new Ie(this.x/e.x,this.y/e.y)}divideToRef(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,t}divideInPlace(e){return this.x=this.x/e.x,this.y=this.y/e.y,this}minimizeInPlace(e){return this.minimizeInPlaceFromFloats(e.x,e.y)}maximizeInPlace(e){return this.maximizeInPlaceFromFloats(e.x,e.y)}minimizeInPlaceFromFloats(e,t){return this.x=Math.min(e,this.x),this.y=Math.min(t,this.y),this}maximizeInPlaceFromFloats(e,t){return this.x=Math.max(e,this.x),this.y=Math.max(t,this.y),this}subtractFromFloats(e,t){return new Ie(this.x-e,this.y-t)}subtractFromFloatsToRef(e,t,i){return i.x=this.x-e,i.y=this.y-t,i}negate(){return new Ie(-this.x,-this.y)}negateInPlace(){return this.x*=-1,this.y*=-1,this}negateToRef(e){return e.x=-this.x,e.y=-this.y,e}scaleInPlace(e){return this.x*=e,this.y*=e,this}scale(e){return new Ie(this.x*e,this.y*e)}scaleToRef(e,t){return t.x=this.x*e,t.y=this.y*e,t}scaleAndAddToRef(e,t){return t.x+=this.x*e,t.y+=this.y*e,t}equals(e){return e&&this.x===e.x&&this.y===e.y}equalsWithEpsilon(e,t=bt){return e&&Lt(this.x,e.x,t)&&Lt(this.y,e.y,t)}equalsToFloats(e,t){return this.x===e&&this.y===t}floor(){return new Ie(Math.floor(this.x),Math.floor(this.y))}floorToRef(e){return e.x=Math.floor(this.x),e.y=Math.floor(this.y),e}fract(){return new Ie(this.x-Math.floor(this.x),this.y-Math.floor(this.y))}fractToRef(e){return e.x=this.x-Math.floor(this.x),e.y=this.y-Math.floor(this.y),e}rotate(e){return this.rotateToRef(e,new Ie)}rotateToRef(e,t){const i=Math.cos(e),s=Math.sin(e);return t.x=i*this.x-s*this.y,t.y=s*this.x+i*this.y,t}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}lengthSquared(){return this.x*this.x+this.y*this.y}normalize(){return this.normalizeFromLength(this.length())}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){const e=new Ie;return this.normalizeToRef(e),e}normalizeToRef(e){const t=this.length();return t===0&&(e.x=this.x,e.y=this.y),this.scaleToRef(1/t,e)}clone(){return new Ie(this.x,this.y)}dot(e){return this.x*e.x+this.y*e.y}static Zero(){return new Ie(0,0)}static One(){return new Ie(1,1)}static Random(e=0,t=1){return new Ie(li(e,t),li(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(li(e,t),li(e,t))}static get ZeroReadOnly(){return Ie._ZeroReadOnly}static FromArray(e,t=0){return new Ie(e[t],e[t+1])}static FromArrayToRef(e,t,i){return i.x=e[t],i.y=e[t+1],i}static FromFloatsToRef(e,t,i){return i.copyFromFloats(e,t),i}static CatmullRom(e,t,i,s,r){const a=r*r,o=r*a,c=.5*(2*t.x+(-e.x+i.x)*r+(2*e.x-5*t.x+4*i.x-s.x)*a+(-e.x+3*t.x-3*i.x+s.x)*o),u=.5*(2*t.y+(-e.y+i.y)*r+(2*e.y-5*t.y+4*i.y-s.y)*a+(-e.y+3*t.y-3*i.y+s.y)*o);return new Ie(c,u)}static ClampToRef(e,t,i,s){return s.x=Qt(e.x,t.x,i.x),s.y=Qt(e.y,t.y,i.y),s}static Clamp(e,t,i){const s=Qt(e.x,t.x,i.x),r=Qt(e.y,t.y,i.y);return new Ie(s,r)}static Hermite(e,t,i,s,r){const a=r*r,o=r*a,c=2*o-3*a+1,u=-2*o+3*a,d=o-2*a+r,f=o-a,g=e.x*c+i.x*u+t.x*d+s.x*f,m=e.y*c+i.y*u+t.y*d+s.y*f;return new Ie(g,m)}static Hermite1stDerivative(e,t,i,s,r){return this.Hermite1stDerivativeToRef(e,t,i,s,r,new Ie)}static Hermite1stDerivativeToRef(e,t,i,s,r,a){const o=r*r;return a.x=(o-r)*6*e.x+(3*o-4*r+1)*t.x+(-o+r)*6*i.x+(3*o-2*r)*s.x,a.y=(o-r)*6*e.y+(3*o-4*r+1)*t.y+(-o+r)*6*i.y+(3*o-2*r)*s.y,a}static Lerp(e,t,i){return Ie.LerpToRef(e,t,i,new Ie)}static LerpToRef(e,t,i,s){return s.x=e.x+(t.x-e.x)*i,s.y=e.y+(t.y-e.y)*i,s}static Dot(e,t){return e.x*t.x+e.y*t.y}static Normalize(e){return Ie.NormalizeToRef(e,new Ie)}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Minimize(e,t){const i=e.x<t.x?e.x:t.x,s=e.y<t.y?e.y:t.y;return new Ie(i,s)}static Maximize(e,t){const i=e.x>t.x?e.x:t.x,s=e.y>t.y?e.y:t.y;return new Ie(i,s)}static Transform(e,t){return Ie.TransformToRef(e,t,new Ie)}static TransformToRef(e,t,i){const s=t.m,r=e.x*s[0]+e.y*s[4]+s[12],a=e.x*s[1]+e.y*s[5]+s[13];return i.x=r,i.y=a,i}static PointInTriangle(e,t,i,s){const r=.5*(-i.y*s.x+t.y*(-i.x+s.x)+t.x*(i.y-s.y)+i.x*s.y),a=r<0?-1:1,o=(t.y*s.x-t.x*s.y+(s.y-t.y)*e.x+(t.x-s.x)*e.y)*a,c=(t.x*i.y-t.y*i.x+(t.y-i.y)*e.x+(i.x-t.x)*e.y)*a;return o>0&&c>0&&o+c<2*r*a}static Distance(e,t){return Math.sqrt(Ie.DistanceSquared(e,t))}static DistanceSquared(e,t){const i=e.x-t.x,s=e.y-t.y;return i*i+s*s}static Center(e,t){return Ie.CenterToRef(e,t,new Ie)}static CenterToRef(e,t,i){return i.copyFromFloats((e.x+t.x)/2,(e.y+t.y)/2)}static DistanceOfPointFromSegment(e,t,i){const s=Ie.DistanceSquared(t,i);if(s===0)return Ie.Distance(e,t);const r=i.subtract(t),a=Math.max(0,Math.min(1,Ie.Dot(e.subtract(t),r)/s)),o=t.add(r.multiplyByFloats(a,a));return Ie.Distance(e,o)}}Ie._V8PerformanceHack=new Ie(.5,.5);Ie._ZeroReadOnly=Ie.Zero();Object.defineProperties(Ie.prototype,{dimension:{value:[2]},rank:{value:1}});class T{get x(){return this._x}set x(e){this._x=e,this._isDirty=!0}get y(){return this._y}set y(e){this._y=e,this._isDirty=!0}get z(){return this._z}set z(e){this._z=e,this._isDirty=!0}constructor(e=0,t=0,i=0){this._isDirty=!0,this._x=e,this._y=t,this._z=i}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z}}`}getClassName(){return"Vector3"}getHashCode(){const e=Es(this._x),t=Es(this._y),i=Es(this._z);let s=e;return s=s*397^t,s=s*397^i,s}asArray(){return[this._x,this._y,this._z]}toArray(e,t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,this}fromArray(e,t=0){return T.FromArrayToRef(e,t,this),this}toQuaternion(){return Se.RotationYawPitchRoll(this._y,this._x,this._z)}addInPlace(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._isDirty=!0,this}addInPlaceFromFloats(e,t,i){return this._x+=e,this._y+=t,this._z+=i,this._isDirty=!0,this}add(e){return new T(this._x+e._x,this._y+e._y,this._z+e._z)}addToRef(e,t){return t._x=this._x+e._x,t._y=this._y+e._y,t._z=this._z+e._z,t._isDirty=!0,t}subtractInPlace(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._isDirty=!0,this}subtract(e){return new T(this._x-e._x,this._y-e._y,this._z-e._z)}subtractToRef(e,t){return this.subtractFromFloatsToRef(e._x,e._y,e._z,t)}subtractFromFloats(e,t,i){return new T(this._x-e,this._y-t,this._z-i)}subtractFromFloatsToRef(e,t,i,s){return s._x=this._x-e,s._y=this._y-t,s._z=this._z-i,s._isDirty=!0,s}negate(){return new T(-this._x,-this._y,-this._z)}negateInPlace(){return this._x*=-1,this._y*=-1,this._z*=-1,this._isDirty=!0,this}negateToRef(e){return e._x=this._x*-1,e._y=this._y*-1,e._z=this._z*-1,e._isDirty=!0,e}scaleInPlace(e){return this._x*=e,this._y*=e,this._z*=e,this._isDirty=!0,this}scale(e){return new T(this._x*e,this._y*e,this._z*e)}scaleToRef(e,t){return t._x=this._x*e,t._y=this._y*e,t._z=this._z*e,t._isDirty=!0,t}getNormalToRef(e){const t=this.length();let i=Math.acos(this._y/t);const s=Math.atan2(this._z,this._x);i>Math.PI/2?i-=Math.PI/2:i+=Math.PI/2;const r=t*Math.sin(i)*Math.cos(s),a=t*Math.cos(i),o=t*Math.sin(i)*Math.sin(s);return e.set(r,a,o),e}applyRotationQuaternionToRef(e,t){const i=this._x,s=this._y,r=this._z,a=e._x,o=e._y,c=e._z,u=e._w,d=2*(o*r-c*s),f=2*(c*i-a*r),g=2*(a*s-o*i);return t._x=i+u*d+o*g-c*f,t._y=s+u*f+c*d-a*g,t._z=r+u*g+a*f-o*d,t._isDirty=!0,t}applyRotationQuaternionInPlace(e){return this.applyRotationQuaternionToRef(e,this)}applyRotationQuaternion(e){return this.applyRotationQuaternionToRef(e,new T)}scaleAndAddToRef(e,t){return t._x+=this._x*e,t._y+=this._y*e,t._z+=this._z*e,t._isDirty=!0,t}projectOnPlane(e,t){return this.projectOnPlaneToRef(e,t,new T)}projectOnPlaneToRef(e,t,i){const s=e.normal,r=e.d,a=we.Vector3[0];this.subtractToRef(t,a),a.normalize();const o=T.Dot(a,s);if(Math.abs(o)<1e-10)i.setAll(1/0);else{const c=-(T.Dot(t,s)+r)/o,u=a.scaleInPlace(c);t.addToRef(u,i)}return i}equals(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z}equalsWithEpsilon(e,t=bt){return e&&Lt(this._x,e._x,t)&&Lt(this._y,e._y,t)&&Lt(this._z,e._z,t)}equalsToFloats(e,t,i){return this._x===e&&this._y===t&&this._z===i}multiplyInPlace(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._isDirty=!0,this}multiply(e){return this.multiplyByFloats(e._x,e._y,e._z)}multiplyToRef(e,t){return t._x=this._x*e._x,t._y=this._y*e._y,t._z=this._z*e._z,t._isDirty=!0,t}multiplyByFloats(e,t,i){return new T(this._x*e,this._y*t,this._z*i)}divide(e){return new T(this._x/e._x,this._y/e._y,this._z/e._z)}divideToRef(e,t){return t._x=this._x/e._x,t._y=this._y/e._y,t._z=this._z/e._z,t._isDirty=!0,t}divideInPlace(e){return this._x=this._x/e._x,this._y=this._y/e._y,this._z=this._z/e._z,this._isDirty=!0,this}minimizeInPlace(e){return this.minimizeInPlaceFromFloats(e._x,e._y,e._z)}maximizeInPlace(e){return this.maximizeInPlaceFromFloats(e._x,e._y,e._z)}minimizeInPlaceFromFloats(e,t,i){return e<this._x&&(this.x=e),t<this._y&&(this.y=t),i<this._z&&(this.z=i),this}maximizeInPlaceFromFloats(e,t,i){return e>this._x&&(this.x=e),t>this._y&&(this.y=t),i>this._z&&(this.z=i),this}isNonUniformWithinEpsilon(e){const t=Math.abs(this._x),i=Math.abs(this._y);if(!Lt(t,i,e))return!0;const s=Math.abs(this._z);return!Lt(t,s,e)||!Lt(i,s,e)}get isNonUniform(){const e=Math.abs(this._x),t=Math.abs(this._y);if(e!==t)return!0;const i=Math.abs(this._z);return e!==i}floorToRef(e){return e._x=Math.floor(this._x),e._y=Math.floor(this._y),e._z=Math.floor(this._z),e._isDirty=!0,e}floor(){return new T(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z))}fractToRef(e){return e._x=this._x-Math.floor(this._x),e._y=this._y-Math.floor(this._y),e._z=this._z-Math.floor(this._z),e._isDirty=!0,e}fract(){return new T(this._x-Math.floor(this._x),this._y-Math.floor(this._y),this._z-Math.floor(this._z))}length(){return Math.sqrt(this.lengthSquared())}lengthSquared(){return this._x*this._x+this._y*this._y+this._z*this._z}get hasAZeroComponent(){return this._x*this._y*this._z===0}normalize(){return this.normalizeFromLength(this.length())}reorderInPlace(e){if(e=e.toLowerCase(),e==="xyz")return this;const t=we.Vector3[0].copyFrom(this);return this.x=t[e[0]],this.y=t[e[1]],this.z=t[e[2]],this}rotateByQuaternionToRef(e,t){return e.toRotationMatrix(we.Matrix[0]),T.TransformCoordinatesToRef(this,we.Matrix[0],t),t}rotateByQuaternionAroundPointToRef(e,t,i){return this.subtractToRef(t,we.Vector3[0]),we.Vector3[0].rotateByQuaternionToRef(e,we.Vector3[0]),t.addToRef(we.Vector3[0],i),i}cross(e){return T.CrossToRef(this,e,new T)}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){return this.normalizeToRef(new T)}normalizeToRef(e){const t=this.length();return t===0||t===1?(e._x=this._x,e._y=this._y,e._z=this._z,e._isDirty=!0,e):this.scaleToRef(1/t,e)}clone(){return new T(this._x,this._y,this._z)}copyFrom(e){return this.copyFromFloats(e._x,e._y,e._z)}copyFromFloats(e,t,i){return this._x=e,this._y=t,this._z=i,this._isDirty=!0,this}set(e,t,i){return this.copyFromFloats(e,t,i)}setAll(e){return this._x=this._y=this._z=e,this._isDirty=!0,this}static GetClipFactor(e,t,i,s){const r=T.Dot(e,i),a=T.Dot(t,i);return(r-s)/(r-a)}static GetAngleBetweenVectors(e,t,i){const s=e.normalizeToRef(we.Vector3[1]),r=t.normalizeToRef(we.Vector3[2]);let a=T.Dot(s,r);a=Qt(a,-1,1);const o=Math.acos(a),c=we.Vector3[3];return T.CrossToRef(s,r,c),T.Dot(c,i)>0?isNaN(o)?0:o:isNaN(o)?-Math.PI:-Math.acos(a)}static GetAngleBetweenVectorsOnPlane(e,t,i){we.Vector3[0].copyFrom(e);const s=we.Vector3[0];we.Vector3[1].copyFrom(t);const r=we.Vector3[1];we.Vector3[2].copyFrom(i);const a=we.Vector3[2],o=we.Vector3[3],c=we.Vector3[4];s.normalize(),r.normalize(),a.normalize(),T.CrossToRef(a,s,o),T.CrossToRef(o,a,c);const u=Math.atan2(T.Dot(r,o),T.Dot(r,c));return $U(u)}static PitchYawRollToMoveBetweenPointsToRef(e,t,i){const s=te.Vector3[0];return t.subtractToRef(e,s),i._y=Math.atan2(s.x,s.z)||0,i._x=Math.atan2(Math.sqrt(s.x**2+s.z**2),s.y)||0,i._z=0,i._isDirty=!0,i}static PitchYawRollToMoveBetweenPoints(e,t){const i=T.Zero();return T.PitchYawRollToMoveBetweenPointsToRef(e,t,i)}static SlerpToRef(e,t,i,s){i=Qt(i,0,1);const r=we.Vector3[0],a=we.Vector3[1];r.copyFrom(e);const o=r.length();r.normalizeFromLength(o),a.copyFrom(t);const c=a.length();a.normalizeFromLength(c);const u=T.Dot(r,a);let d,f;if(u<1-bt){const g=Math.acos(u),m=1/Math.sin(g);d=Math.sin((1-i)*g)*m,f=Math.sin(i*g)*m}else d=1-i,f=i;return r.scaleInPlace(d),a.scaleInPlace(f),s.copyFrom(r).addInPlace(a),s.scaleInPlace(Jd(o,c,i)),s}static SmoothToRef(e,t,i,s,r){return T.SlerpToRef(e,t,s===0?1:i/s,r),r}static FromArray(e,t=0){return new T(e[t],e[t+1],e[t+2])}static FromFloatArray(e,t){return T.FromArray(e,t)}static FromArrayToRef(e,t,i){return i._x=e[t],i._y=e[t+1],i._z=e[t+2],i._isDirty=!0,i}static FromFloatArrayToRef(e,t,i){return T.FromArrayToRef(e,t,i)}static FromFloatsToRef(e,t,i,s){return s.copyFromFloats(e,t,i),s}static Zero(){return new T(0,0,0)}static One(){return new T(1,1,1)}static Up(){return new T(0,1,0)}static get UpReadOnly(){return T._UpReadOnly}static get DownReadOnly(){return T._DownReadOnly}static get RightReadOnly(){return T._RightReadOnly}static get LeftReadOnly(){return T._LeftReadOnly}static get LeftHandedForwardReadOnly(){return T._LeftHandedForwardReadOnly}static get RightHandedForwardReadOnly(){return T._RightHandedForwardReadOnly}static get LeftHandedBackwardReadOnly(){return T._LeftHandedBackwardReadOnly}static get RightHandedBackwardReadOnly(){return T._RightHandedBackwardReadOnly}static get ZeroReadOnly(){return T._ZeroReadOnly}static get OneReadOnly(){return T._OneReadOnly}static Down(){return new T(0,-1,0)}static Forward(e=!1){return new T(0,0,e?-1:1)}static Backward(e=!1){return new T(0,0,e?1:-1)}static Right(){return new T(1,0,0)}static Left(){return new T(-1,0,0)}static Random(e=0,t=1){return new T(li(e,t),li(e,t),li(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(li(e,t),li(e,t),li(e,t))}static TransformCoordinates(e,t){const i=T.Zero();return T.TransformCoordinatesToRef(e,t,i),i}static TransformCoordinatesToRef(e,t,i){return T.TransformCoordinatesFromFloatsToRef(e._x,e._y,e._z,t,i),i}static TransformCoordinatesFromFloatsToRef(e,t,i,s,r){const a=s.m,o=e*a[0]+t*a[4]+i*a[8]+a[12],c=e*a[1]+t*a[5]+i*a[9]+a[13],u=e*a[2]+t*a[6]+i*a[10]+a[14],d=1/(e*a[3]+t*a[7]+i*a[11]+a[15]);return r._x=o*d,r._y=c*d,r._z=u*d,r._isDirty=!0,r}static TransformNormal(e,t){const i=T.Zero();return T.TransformNormalToRef(e,t,i),i}static TransformNormalToRef(e,t,i){return this.TransformNormalFromFloatsToRef(e._x,e._y,e._z,t,i),i}static TransformNormalFromFloatsToRef(e,t,i,s,r){const a=s.m;return r._x=e*a[0]+t*a[4]+i*a[8],r._y=e*a[1]+t*a[5]+i*a[9],r._z=e*a[2]+t*a[6]+i*a[10],r._isDirty=!0,r}static CatmullRom(e,t,i,s,r){const a=r*r,o=r*a,c=.5*(2*t._x+(-e._x+i._x)*r+(2*e._x-5*t._x+4*i._x-s._x)*a+(-e._x+3*t._x-3*i._x+s._x)*o),u=.5*(2*t._y+(-e._y+i._y)*r+(2*e._y-5*t._y+4*i._y-s._y)*a+(-e._y+3*t._y-3*i._y+s._y)*o),d=.5*(2*t._z+(-e._z+i._z)*r+(2*e._z-5*t._z+4*i._z-s._z)*a+(-e._z+3*t._z-3*i._z+s._z)*o);return new T(c,u,d)}static Clamp(e,t,i){const s=new T;return T.ClampToRef(e,t,i,s),s}static ClampToRef(e,t,i,s){let r=e._x;r=r>i._x?i._x:r,r=r<t._x?t._x:r;let a=e._y;a=a>i._y?i._y:a,a=a<t._y?t._y:a;let o=e._z;return o=o>i._z?i._z:o,o=o<t._z?t._z:o,s.copyFromFloats(r,a,o),s}static CheckExtends(e,t,i){t.minimizeInPlace(e),i.maximizeInPlace(e)}static Hermite(e,t,i,s,r){const a=r*r,o=r*a,c=2*o-3*a+1,u=-2*o+3*a,d=o-2*a+r,f=o-a,g=e._x*c+i._x*u+t._x*d+s._x*f,m=e._y*c+i._y*u+t._y*d+s._y*f,b=e._z*c+i._z*u+t._z*d+s._z*f;return new T(g,m,b)}static Hermite1stDerivative(e,t,i,s,r){const a=new T;return this.Hermite1stDerivativeToRef(e,t,i,s,r,a),a}static Hermite1stDerivativeToRef(e,t,i,s,r,a){const o=r*r;return a._x=(o-r)*6*e._x+(3*o-4*r+1)*t._x+(-o+r)*6*i._x+(3*o-2*r)*s._x,a._y=(o-r)*6*e._y+(3*o-4*r+1)*t._y+(-o+r)*6*i._y+(3*o-2*r)*s._y,a._z=(o-r)*6*e._z+(3*o-4*r+1)*t._z+(-o+r)*6*i._z+(3*o-2*r)*s._z,a._isDirty=!0,a}static Lerp(e,t,i){const s=new T(0,0,0);return T.LerpToRef(e,t,i,s),s}static LerpToRef(e,t,i,s){return s._x=e._x+(t._x-e._x)*i,s._y=e._y+(t._y-e._y)*i,s._z=e._z+(t._z-e._z)*i,s._isDirty=!0,s}static Dot(e,t){return e._x*t._x+e._y*t._y+e._z*t._z}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z}static Cross(e,t){const i=new T;return T.CrossToRef(e,t,i),i}static CrossToRef(e,t,i){const s=e._y*t._z-e._z*t._y,r=e._z*t._x-e._x*t._z,a=e._x*t._y-e._y*t._x;return i.copyFromFloats(s,r,a),i}static Normalize(e){const t=T.Zero();return T.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Project(e,t,i,s){const r=new T;return T.ProjectToRef(e,t,i,s,r),r}static ProjectToRef(e,t,i,s,r){const a=s.width,o=s.height,c=s.x,u=s.y,d=we.Matrix[1],f=Ke.LastCreatedEngine?.isNDCHalfZRange,g=f?1:.5,m=f?0:.5;W.FromValuesToRef(a/2,0,0,0,0,-o/2,0,0,0,0,g,0,c+a/2,o/2+u,m,1,d);const b=we.Matrix[0];return t.multiplyToRef(i,b),b.multiplyToRef(d,b),T.TransformCoordinatesToRef(e,b,r),r}static Reflect(e,t){return this.ReflectToRef(e,t,new T)}static ReflectToRef(e,t,i){const s=te.Vector3[0];return s.copyFrom(t).scaleInPlace(2*T.Dot(e,t)),i.copyFrom(e).subtractInPlace(s)}static UnprojectFromTransform(e,t,i,s,r){return this.Unproject(e,t,i,s,r,W.IdentityReadOnly)}static Unproject(e,t,i,s,r,a){const o=new T;return T.UnprojectToRef(e,t,i,s,r,a,o),o}static UnprojectToRef(e,t,i,s,r,a,o){return T.UnprojectFloatsToRef(e._x,e._y,e._z,t,i,s,r,a,o),o}static UnprojectFloatsToRef(e,t,i,s,r,a,o,c,u){const d=we.Matrix[0];a.multiplyToRef(o,d),d.multiplyToRef(c,d),d.invert();const f=we.Vector3[0];return f.x=e/s*2-1,f.y=-(t/r*2-1),Ke.LastCreatedEngine?.isNDCHalfZRange?f.z=i:f.z=2*i-1,T.TransformCoordinatesToRef(f,d,u),u}static Minimize(e,t){const i=new T;return i.copyFrom(e),i.minimizeInPlace(t),i}static Maximize(e,t){const i=new T;return i.copyFrom(e),i.maximizeInPlace(t),i}static Distance(e,t){return Math.sqrt(T.DistanceSquared(e,t))}static DistanceSquared(e,t){const i=e._x-t._x,s=e._y-t._y,r=e._z-t._z;return i*i+s*s+r*r}static ProjectOnTriangleToRef(e,t,i,s,r){const a=we.Vector3[0],o=we.Vector3[1],c=we.Vector3[2],u=we.Vector3[3],d=we.Vector3[4];i.subtractToRef(t,a),s.subtractToRef(t,o),s.subtractToRef(i,c);const f=a.length(),g=o.length(),m=c.length();if(f<bt||g<bt||m<bt)return r.copyFrom(t),T.Distance(e,t);e.subtractToRef(t,d),T.CrossToRef(a,o,u);const b=u.length();if(b<bt)return r.copyFrom(t),T.Distance(e,t);u.normalizeFromLength(b);let x=d.length();if(x<bt)return r.copyFrom(t),0;d.normalizeFromLength(x);const v=T.Dot(u,d),E=we.Vector3[5],A=we.Vector3[6];E.copyFrom(u).scaleInPlace(-x*v),A.copyFrom(e).addInPlace(E);const D=we.Vector3[4],I=we.Vector3[5],R=we.Vector3[7],C=we.Vector3[8];D.copyFrom(a).scaleInPlace(1/f),C.copyFrom(o).scaleInPlace(1/g),D.addInPlace(C).scaleInPlace(-1),I.copyFrom(a).scaleInPlace(-1/f),C.copyFrom(c).scaleInPlace(1/m),I.addInPlace(C).scaleInPlace(-1),R.copyFrom(c).scaleInPlace(-1/m),C.copyFrom(o).scaleInPlace(-1/g),R.addInPlace(C).scaleInPlace(-1);const M=we.Vector3[9];let F;M.copyFrom(A).subtractInPlace(t),T.CrossToRef(D,M,C),F=T.Dot(C,u);const U=F;M.copyFrom(A).subtractInPlace(i),T.CrossToRef(I,M,C),F=T.Dot(C,u);const k=F;M.copyFrom(A).subtractInPlace(s),T.CrossToRef(R,M,C),F=T.Dot(C,u);const q=F,Q=we.Vector3[10];let ie,$;U>0&&k<0?(Q.copyFrom(a),ie=t,$=i):k>0&&q<0?(Q.copyFrom(c),ie=i,$=s):(Q.copyFrom(o).scaleInPlace(-1),ie=s,$=t);const ce=we.Vector3[9],G=we.Vector3[4];if(ie.subtractToRef(A,C),$.subtractToRef(A,ce),T.CrossToRef(C,ce,G),!(T.Dot(G,u)<0))return r.copyFrom(A),Math.abs(x*v);const X=we.Vector3[5];T.CrossToRef(Q,G,X),X.normalize();const J=we.Vector3[9];J.copyFrom(ie).subtractInPlace(A);const se=J.length();if(se<bt)return r.copyFrom(ie),T.Distance(e,ie);J.normalizeFromLength(se);const w=T.Dot(X,J),L=we.Vector3[7];L.copyFrom(A).addInPlace(X.scaleInPlace(se*w)),C.copyFrom(L).subtractInPlace(ie),x=Q.length(),Q.normalizeFromLength(x);let V=T.Dot(C,Q)/Math.max(x,bt);return V=Qt(V,0,1),L.copyFrom(ie).addInPlace(Q.scaleInPlace(V*x)),r.copyFrom(L),T.Distance(e,L)}static Center(e,t){return T.CenterToRef(e,t,T.Zero())}static CenterToRef(e,t,i){return i.copyFromFloats((e._x+t._x)/2,(e._y+t._y)/2,(e._z+t._z)/2)}static RotationFromAxis(e,t,i){const s=new T;return T.RotationFromAxisToRef(e,t,i,s),s}static RotationFromAxisToRef(e,t,i,s){const r=we.Quaternion[0];return Se.RotationQuaternionFromAxisToRef(e,t,i,r),r.toEulerAnglesToRef(s),s}}T._V8PerformanceHack=new T(.5,.5,.5);T._UpReadOnly=T.Up();T._DownReadOnly=T.Down();T._LeftHandedForwardReadOnly=T.Forward(!1);T._RightHandedForwardReadOnly=T.Forward(!0);T._LeftHandedBackwardReadOnly=T.Backward(!1);T._RightHandedBackwardReadOnly=T.Backward(!0);T._RightReadOnly=T.Right();T._LeftReadOnly=T.Left();T._ZeroReadOnly=T.Zero();T._OneReadOnly=T.One();Object.defineProperties(T.prototype,{dimension:{value:[3]},rank:{value:1}});class rt{get x(){return this._x}set x(e){this._x=e,this._isDirty=!0}get y(){return this._y}set y(e){this._y=e,this._isDirty=!0}get z(){return this._z}set z(e){this._z=e,this._isDirty=!0}get w(){return this._w}set w(e){this._w=e,this._isDirty=!0}constructor(e=0,t=0,i=0,s=0){this._isDirty=!0,this._x=e,this._y=t,this._z=i,this._w=s}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z} W: ${this._w}}`}getClassName(){return"Vector4"}getHashCode(){const e=Es(this._x),t=Es(this._y),i=Es(this._z),s=Es(this._w);let r=e;return r=r*397^t,r=r*397^i,r=r*397^s,r}asArray(){return[this._x,this._y,this._z,this._w]}toArray(e,t){return t===void 0&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,this}fromArray(e,t=0){return rt.FromArrayToRef(e,t,this),this}addInPlace(e){return this.x+=e._x,this.y+=e._y,this.z+=e._z,this.w+=e._w,this}addInPlaceFromFloats(e,t,i,s){return this.x+=e,this.y+=t,this.z+=i,this.w+=s,this}add(e){return new rt(this._x+e.x,this._y+e.y,this._z+e.z,this._w+e.w)}addToRef(e,t){return t.x=this._x+e.x,t.y=this._y+e.y,t.z=this._z+e.z,t.w=this._w+e.w,t}subtractInPlace(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subtract(e){return new rt(this._x-e.x,this._y-e.y,this._z-e.z,this._w-e.w)}subtractToRef(e,t){return t.x=this._x-e.x,t.y=this._y-e.y,t.z=this._z-e.z,t.w=this._w-e.w,t}subtractFromFloats(e,t,i,s){return new rt(this._x-e,this._y-t,this._z-i,this._w-s)}subtractFromFloatsToRef(e,t,i,s,r){return r.x=this._x-e,r.y=this._y-t,r.z=this._z-i,r.w=this._w-s,r}negate(){return new rt(-this._x,-this._y,-this._z,-this._w)}negateInPlace(){return this.x*=-1,this.y*=-1,this.z*=-1,this.w*=-1,this}negateToRef(e){return e.x=-this._x,e.y=-this._y,e.z=-this._z,e.w=-this._w,e}scaleInPlace(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}scale(e){return new rt(this._x*e,this._y*e,this._z*e,this._w*e)}scaleToRef(e,t){return t.x=this._x*e,t.y=this._y*e,t.z=this._z*e,t.w=this._w*e,t}scaleAndAddToRef(e,t){return t.x+=this._x*e,t.y+=this._y*e,t.z+=this._z*e,t.w+=this._w*e,t}equals(e){return e&&this._x===e.x&&this._y===e.y&&this._z===e.z&&this._w===e.w}equalsWithEpsilon(e,t=bt){return e&&Lt(this._x,e.x,t)&&Lt(this._y,e.y,t)&&Lt(this._z,e.z,t)&&Lt(this._w,e.w,t)}equalsToFloats(e,t,i,s){return this._x===e&&this._y===t&&this._z===i&&this._w===s}multiplyInPlace(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiply(e){return new rt(this._x*e.x,this._y*e.y,this._z*e.z,this._w*e.w)}multiplyToRef(e,t){return t.x=this._x*e.x,t.y=this._y*e.y,t.z=this._z*e.z,t.w=this._w*e.w,t}multiplyByFloats(e,t,i,s){return new rt(this._x*e,this._y*t,this._z*i,this._w*s)}divide(e){return new rt(this._x/e.x,this._y/e.y,this._z/e.z,this._w/e.w)}divideToRef(e,t){return t.x=this._x/e.x,t.y=this._y/e.y,t.z=this._z/e.z,t.w=this._w/e.w,t}divideInPlace(e){return this.divideToRef(e,this)}minimizeInPlace(e){return e.x<this._x&&(this.x=e.x),e.y<this._y&&(this.y=e.y),e.z<this._z&&(this.z=e.z),e.w<this._w&&(this.w=e.w),this}maximizeInPlace(e){return e.x>this._x&&(this.x=e.x),e.y>this._y&&(this.y=e.y),e.z>this._z&&(this.z=e.z),e.w>this._w&&(this.w=e.w),this}minimizeInPlaceFromFloats(e,t,i,s){return this.x=Math.min(e,this._x),this.y=Math.min(t,this._y),this.z=Math.min(i,this._z),this.w=Math.min(s,this._w),this}maximizeInPlaceFromFloats(e,t,i,s){return this.x=Math.max(e,this._x),this.y=Math.max(t,this._y),this.z=Math.max(i,this._z),this.w=Math.max(s,this._w),this}floorToRef(e){return e.x=Math.floor(this._x),e.y=Math.floor(this._y),e.z=Math.floor(this._z),e.w=Math.floor(this._w),e}floor(){return new rt(Math.floor(this._x),Math.floor(this._y),Math.floor(this._z),Math.floor(this._w))}fractToRef(e){return e.x=this._x-Math.floor(this._x),e.y=this._y-Math.floor(this._y),e.z=this._z-Math.floor(this._z),e.w=this._w-Math.floor(this._w),e}fract(){return new rt(this._x-Math.floor(this._x),this._y-Math.floor(this._y),this._z-Math.floor(this._z),this._w-Math.floor(this._w))}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}lengthSquared(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}normalize(){return this.normalizeFromLength(this.length())}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){return this.normalizeToRef(new rt)}normalizeToRef(e){const t=this.length();return t===0||t===1?(e.x=this._x,e.y=this._y,e.z=this._z,e.w=this._w,e):this.scaleToRef(1/t,e)}toVector3(){return new T(this._x,this._y,this._z)}clone(){return new rt(this._x,this._y,this._z,this._w)}copyFrom(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this}copyFromFloats(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}set(e,t,i,s){return this.copyFromFloats(e,t,i,s)}setAll(e){return this.x=this.y=this.z=this.w=e,this}dot(e){return this._x*e.x+this._y*e.y+this._z*e.z+this._w*e.w}static FromArray(e,t){return t||(t=0),new rt(e[t],e[t+1],e[t+2],e[t+3])}static FromArrayToRef(e,t,i){return i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3],i}static FromFloatArrayToRef(e,t,i){return rt.FromArrayToRef(e,t,i),i}static FromFloatsToRef(e,t,i,s,r){return r.x=e,r.y=t,r.z=i,r.w=s,r}static Zero(){return new rt(0,0,0,0)}static One(){return new rt(1,1,1,1)}static Random(e=0,t=1){return new rt(li(e,t),li(e,t),li(e,t),li(e,t))}static RandomToRef(e=0,t=1,i){return i.x=li(e,t),i.y=li(e,t),i.z=li(e,t),i.w=li(e,t),i}static Clamp(e,t,i){return rt.ClampToRef(e,t,i,new rt)}static ClampToRef(e,t,i,s){return s.x=Qt(e.x,t.x,i.x),s.y=Qt(e.y,t.y,i.y),s.z=Qt(e.z,t.z,i.z),s.w=Qt(e.w,t.w,i.w),s}static CheckExtends(e,t,i){t.minimizeInPlace(e),i.maximizeInPlace(e)}static get ZeroReadOnly(){return rt._ZeroReadOnly}static Normalize(e){return rt.NormalizeToRef(e,new rt)}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Minimize(e,t){const i=new rt;return i.copyFrom(e),i.minimizeInPlace(t),i}static Maximize(e,t){const i=new rt;return i.copyFrom(e),i.maximizeInPlace(t),i}static Distance(e,t){return Math.sqrt(rt.DistanceSquared(e,t))}static DistanceSquared(e,t){const i=e.x-t.x,s=e.y-t.y,r=e.z-t.z,a=e.w-t.w;return i*i+s*s+r*r+a*a}static Center(e,t){return rt.CenterToRef(e,t,new rt)}static CenterToRef(e,t,i){return i.x=(e.x+t.x)/2,i.y=(e.y+t.y)/2,i.z=(e.z+t.z)/2,i.w=(e.w+t.w)/2,i}static TransformCoordinates(e,t){return rt.TransformCoordinatesToRef(e,t,new rt)}static TransformCoordinatesToRef(e,t,i){return rt.TransformCoordinatesFromFloatsToRef(e._x,e._y,e._z,t,i),i}static TransformCoordinatesFromFloatsToRef(e,t,i,s,r){const a=s.m,o=e*a[0]+t*a[4]+i*a[8]+a[12],c=e*a[1]+t*a[5]+i*a[9]+a[13],u=e*a[2]+t*a[6]+i*a[10]+a[14],d=e*a[3]+t*a[7]+i*a[11]+a[15];return r.x=o,r.y=c,r.z=u,r.w=d,r}static TransformNormal(e,t){return rt.TransformNormalToRef(e,t,new rt)}static TransformNormalToRef(e,t,i){const s=t.m,r=e.x*s[0]+e.y*s[4]+e.z*s[8],a=e.x*s[1]+e.y*s[5]+e.z*s[9],o=e.x*s[2]+e.y*s[6]+e.z*s[10];return i.x=r,i.y=a,i.z=o,i.w=e.w,i}static TransformNormalFromFloatsToRef(e,t,i,s,r,a){const o=r.m;return a.x=e*o[0]+t*o[4]+i*o[8],a.y=e*o[1]+t*o[5]+i*o[9],a.z=e*o[2]+t*o[6]+i*o[10],a.w=s,a}static FromVector3(e,t=0){return new rt(e._x,e._y,e._z,t)}static Dot(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w}}rt._V8PerformanceHack=new rt(.5,.5,.5,.5);rt._ZeroReadOnly=rt.Zero();Object.defineProperties(rt.prototype,{dimension:{value:[4]},rank:{value:1}});class Se{get x(){return this._x}set x(e){this._x=e,this._isDirty=!0}get y(){return this._y}set y(e){this._y=e,this._isDirty=!0}get z(){return this._z}set z(e){this._z=e,this._isDirty=!0}get w(){return this._w}set w(e){this._w=e,this._isDirty=!0}constructor(e=0,t=0,i=0,s=1){this._isDirty=!0,this._x=e,this._y=t,this._z=i,this._w=s}toString(){return`{X: ${this._x} Y: ${this._y} Z: ${this._z} W: ${this._w}}`}getClassName(){return"Quaternion"}getHashCode(){const e=Es(this._x),t=Es(this._y),i=Es(this._z),s=Es(this._w);let r=e;return r=r*397^t,r=r*397^i,r=r*397^s,r}asArray(){return[this._x,this._y,this._z,this._w]}toArray(e,t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,this}fromArray(e,t=0){return Se.FromArrayToRef(e,t,this)}equals(e){return e&&this._x===e._x&&this._y===e._y&&this._z===e._z&&this._w===e._w}equalsWithEpsilon(e,t=bt){return e&&Lt(this._x,e._x,t)&&Lt(this._y,e._y,t)&&Lt(this._z,e._z,t)&&Lt(this._w,e._w,t)}isApprox(e,t=bt){return e&&(Lt(this._x,e._x,t)&&Lt(this._y,e._y,t)&&Lt(this._z,e._z,t)&&Lt(this._w,e._w,t)||Lt(this._x,-e._x,t)&&Lt(this._y,-e._y,t)&&Lt(this._z,-e._z,t)&&Lt(this._w,-e._w,t))}clone(){return new Se(this._x,this._y,this._z,this._w)}copyFrom(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._w=e._w,this._isDirty=!0,this}copyFromFloats(e,t,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,this._isDirty=!0,this}set(e,t,i,s){return this.copyFromFloats(e,t,i,s)}setAll(e){return this.copyFromFloats(e,e,e,e)}add(e){return new Se(this._x+e._x,this._y+e._y,this._z+e._z,this._w+e._w)}addInPlace(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._w+=e._w,this._isDirty=!0,this}addToRef(e,t){return t._x=this._x+e._x,t._y=this._y+e._y,t._z=this._z+e._z,t._w=this._w+e._w,t._isDirty=!0,t}addInPlaceFromFloats(e,t,i,s){return this._x+=e,this._y+=t,this._z+=i,this._w+=s,this._isDirty=!0,this}subtractToRef(e,t){return t._x=this._x-e._x,t._y=this._y-e._y,t._z=this._z-e._z,t._w=this._w-e._w,t._isDirty=!0,t}subtractFromFloats(e,t,i,s){return this.subtractFromFloatsToRef(e,t,i,s,new Se)}subtractFromFloatsToRef(e,t,i,s,r){return r._x=this._x-e,r._y=this._y-t,r._z=this._z-i,r._w=this._w-s,r._isDirty=!0,r}subtract(e){return new Se(this._x-e._x,this._y-e._y,this._z-e._z,this._w-e._w)}subtractInPlace(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._w-=e._w,this._isDirty=!0,this}scale(e){return new Se(this._x*e,this._y*e,this._z*e,this._w*e)}scaleToRef(e,t){return t._x=this._x*e,t._y=this._y*e,t._z=this._z*e,t._w=this._w*e,t._isDirty=!0,t}scaleInPlace(e){return this._x*=e,this._y*=e,this._z*=e,this._w*=e,this._isDirty=!0,this}scaleAndAddToRef(e,t){return t._x+=this._x*e,t._y+=this._y*e,t._z+=this._z*e,t._w+=this._w*e,t._isDirty=!0,t}multiply(e){const t=new Se(0,0,0,1);return this.multiplyToRef(e,t),t}multiplyToRef(e,t){const i=this._x*e._w+this._y*e._z-this._z*e._y+this._w*e._x,s=-this._x*e._z+this._y*e._w+this._z*e._x+this._w*e._y,r=this._x*e._y-this._y*e._x+this._z*e._w+this._w*e._z,a=-this._x*e._x-this._y*e._y-this._z*e._z+this._w*e._w;return t.copyFromFloats(i,s,r,a),t}multiplyInPlace(e){return this.multiplyToRef(e,this)}multiplyByFloats(e,t,i,s){return this._x*=e,this._y*=t,this._z*=i,this._w*=s,this._isDirty=!0,this}divide(e){throw new ReferenceError("Can not divide a quaternion")}divideToRef(e,t){throw new ReferenceError("Can not divide a quaternion")}divideInPlace(e){throw new ReferenceError("Can not divide a quaternion")}minimizeInPlace(){throw new ReferenceError("Can not minimize a quaternion")}minimizeInPlaceFromFloats(){throw new ReferenceError("Can not minimize a quaternion")}maximizeInPlace(){throw new ReferenceError("Can not maximize a quaternion")}maximizeInPlaceFromFloats(){throw new ReferenceError("Can not maximize a quaternion")}negate(){return this.negateToRef(new Se)}negateInPlace(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._isDirty=!0,this}negateToRef(e){return e._x=-this._x,e._y=-this._y,e._z=-this._z,e._w=-this._w,e._isDirty=!0,e}equalsToFloats(e,t,i,s){return this._x===e&&this._y===t&&this._z===i&&this._w===s}floorToRef(e){throw new ReferenceError("Can not floor a quaternion")}floor(){throw new ReferenceError("Can not floor a quaternion")}fractToRef(e){throw new ReferenceError("Can not fract a quaternion")}fract(){throw new ReferenceError("Can not fract a quaternion")}conjugateToRef(e){return e.copyFromFloats(-this._x,-this._y,-this._z,this._w),e}conjugateInPlace(){return this._x*=-1,this._y*=-1,this._z*=-1,this._isDirty=!0,this}conjugate(){return new Se(-this._x,-this._y,-this._z,this._w)}invert(){const e=this.conjugate(),t=this.lengthSquared();return t==0||t==1||e.scaleInPlace(1/t),e}invertInPlace(){this.conjugateInPlace();const e=this.lengthSquared();return e==0||e==1?this:(this.scaleInPlace(1/e),this)}lengthSquared(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this.lengthSquared())}normalize(){return this.normalizeFromLength(this.length())}normalizeFromLength(e){return e===0||e===1?this:this.scaleInPlace(1/e)}normalizeToNew(){const e=new Se(0,0,0,1);return this.normalizeToRef(e),e}normalizeToRef(e){const t=this.length();return t===0||t===1?e.copyFromFloats(this._x,this._y,this._z,this._w):this.scaleToRef(1/t,e)}toEulerAngles(){const e=T.Zero();return this.toEulerAnglesToRef(e),e}toEulerAnglesToRef(e){const t=this._z,i=this._x,s=this._y,r=this._w,a=s*t-i*r,o=.4999999;if(a<-o)e._y=2*Math.atan2(s,r),e._x=Math.PI/2,e._z=0,e._isDirty=!0;else if(a>o)e._y=2*Math.atan2(s,r),e._x=-Math.PI/2,e._z=0,e._isDirty=!0;else{const c=r*r,u=t*t,d=i*i,f=s*s;e._z=Math.atan2(2*(i*s+t*r),-u-d+f+c),e._x=Math.asin(-2*a),e._y=Math.atan2(2*(t*i+s*r),u-d-f+c),e._isDirty=!0}return e}toAlphaBetaGammaToRef(e){const t=this._z,i=this._x,s=this._y,r=this._w,a=Math.sqrt(i*i+s*s),o=Math.sqrt(t*t+r*r),c=2*Math.atan2(a,o),u=2*Math.atan2(t,r),d=2*Math.atan2(s,i),f=(u+d)/2,g=(u-d)/2;return e.set(g,c,f),e}toRotationMatrix(e){return W.FromQuaternionToRef(this,e),e}fromRotationMatrix(e){return Se.FromRotationMatrixToRef(e,this),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}toAxisAngle(){const e=T.Zero(),t=this.toAxisAngleToRef(e);return{axis:e,angle:t}}toAxisAngleToRef(e){let t=0;const i=Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z),s=this._w;return i>0?(t=2*Math.atan2(i,s),e.set(this._x/i,this._y/i,this._z/i)):(t=0,e.set(1,0,0)),t}static FromRotationMatrix(e){const t=new Se;return Se.FromRotationMatrixToRef(e,t),t}static FromRotationMatrixToRef(e,t){const i=e.m,s=i[0],r=i[4],a=i[8],o=i[1],c=i[5],u=i[9],d=i[2],f=i[6],g=i[10],m=s+c+g;let b;return m>0?(b=.5/Math.sqrt(m+1),t._w=.25/b,t._x=(f-u)*b,t._y=(a-d)*b,t._z=(o-r)*b,t._isDirty=!0):s>c&&s>g?(b=2*Math.sqrt(1+s-c-g),t._w=(f-u)/b,t._x=.25*b,t._y=(r+o)/b,t._z=(a+d)/b,t._isDirty=!0):c>g?(b=2*Math.sqrt(1+c-s-g),t._w=(a-d)/b,t._x=(r+o)/b,t._y=.25*b,t._z=(u+f)/b,t._isDirty=!0):(b=2*Math.sqrt(1+g-s-c),t._w=(o-r)/b,t._x=(a+d)/b,t._y=(u+f)/b,t._z=.25*b,t._isDirty=!0),t}static Dot(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w}static AreClose(e,t,i=.1){const s=Se.Dot(e,t);return 1-s*s<=i}static SmoothToRef(e,t,i,s,r){let a=s===0?1:i/s;return a=Qt(a,0,1),Se.SlerpToRef(e,t,a,r),r}static Zero(){return new Se(0,0,0,0)}static Inverse(e){return new Se(-e._x,-e._y,-e._z,e._w)}static InverseToRef(e,t){return t.set(-e._x,-e._y,-e._z,e._w),t}static Identity(){return new Se(0,0,0,1)}static IsIdentity(e){return e&&e._x===0&&e._y===0&&e._z===0&&e._w===1}static RotationAxis(e,t){return Se.RotationAxisToRef(e,t,new Se)}static RotationAxisToRef(e,t,i){i._w=Math.cos(t/2);const s=Math.sin(t/2)/e.length();return i._x=e._x*s,i._y=e._y*s,i._z=e._z*s,i._isDirty=!0,i}static FromArray(e,t){return t||(t=0),new Se(e[t],e[t+1],e[t+2],e[t+3])}static FromArrayToRef(e,t,i){return i._x=e[t],i._y=e[t+1],i._z=e[t+2],i._w=e[t+3],i._isDirty=!0,i}static FromFloatsToRef(e,t,i,s,r){return r.copyFromFloats(e,t,i,s),r}static FromEulerAngles(e,t,i){const s=new Se;return Se.RotationYawPitchRollToRef(t,e,i,s),s}static FromEulerAnglesToRef(e,t,i,s){return Se.RotationYawPitchRollToRef(t,e,i,s),s}static FromEulerVector(e){const t=new Se;return Se.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromEulerVectorToRef(e,t){return Se.RotationYawPitchRollToRef(e._y,e._x,e._z,t),t}static FromUnitVectorsToRef(e,t,i,s=bt){const r=T.Dot(e,t)+1;return r<s?Math.abs(e.x)>Math.abs(e.z)?i.set(-e.y,e.x,0,0):i.set(0,-e.z,e.y,0):(T.CrossToRef(e,t,te.Vector3[0]),i.set(te.Vector3[0].x,te.Vector3[0].y,te.Vector3[0].z,r)),i.normalize()}static RotationYawPitchRoll(e,t,i){const s=new Se;return Se.RotationYawPitchRollToRef(e,t,i,s),s}static RotationYawPitchRollToRef(e,t,i,s){const r=i*.5,a=t*.5,o=e*.5,c=Math.sin(r),u=Math.cos(r),d=Math.sin(a),f=Math.cos(a),g=Math.sin(o),m=Math.cos(o);return s._x=m*d*u+g*f*c,s._y=g*f*u-m*d*c,s._z=m*f*c-g*d*u,s._w=m*f*u+g*d*c,s._isDirty=!0,s}static RotationAlphaBetaGamma(e,t,i){const s=new Se;return Se.RotationAlphaBetaGammaToRef(e,t,i,s),s}static RotationAlphaBetaGammaToRef(e,t,i,s){const r=(i+e)*.5,a=(i-e)*.5,o=t*.5;return s._x=Math.cos(a)*Math.sin(o),s._y=Math.sin(a)*Math.sin(o),s._z=Math.sin(r)*Math.cos(o),s._w=Math.cos(r)*Math.cos(o),s._isDirty=!0,s}static RotationQuaternionFromAxis(e,t,i){const s=new Se(0,0,0,0);return Se.RotationQuaternionFromAxisToRef(e,t,i,s),s}static RotationQuaternionFromAxisToRef(e,t,i,s){const r=we.Matrix[0];return e=e.normalizeToRef(we.Vector3[0]),t=t.normalizeToRef(we.Vector3[1]),i=i.normalizeToRef(we.Vector3[2]),W.FromXYZAxesToRef(e,t,i,r),Se.FromRotationMatrixToRef(r,s),s}static FromLookDirectionLH(e,t){const i=new Se;return Se.FromLookDirectionLHToRef(e,t,i),i}static FromLookDirectionLHToRef(e,t,i){const s=we.Matrix[0];return W.LookDirectionLHToRef(e,t,s),Se.FromRotationMatrixToRef(s,i),i}static FromLookDirectionRH(e,t){const i=new Se;return Se.FromLookDirectionRHToRef(e,t,i),i}static FromLookDirectionRHToRef(e,t,i){const s=we.Matrix[0];return W.LookDirectionRHToRef(e,t,s),Se.FromRotationMatrixToRef(s,i)}static Slerp(e,t,i){const s=Se.Identity();return Se.SlerpToRef(e,t,i,s),s}static SlerpToRef(e,t,i,s){let r,a,o=e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w,c=!1;if(o<0&&(c=!0,o=-o),o>.999999)a=1-i,r=c?-i:i;else{const u=Math.acos(o),d=1/Math.sin(u);a=Math.sin((1-i)*u)*d,r=c?-Math.sin(i*u)*d:Math.sin(i*u)*d}return s._x=a*e._x+r*t._x,s._y=a*e._y+r*t._y,s._z=a*e._z+r*t._z,s._w=a*e._w+r*t._w,s._isDirty=!0,s}static Hermite(e,t,i,s,r){const a=r*r,o=r*a,c=2*o-3*a+1,u=-2*o+3*a,d=o-2*a+r,f=o-a,g=e._x*c+i._x*u+t._x*d+s._x*f,m=e._y*c+i._y*u+t._y*d+s._y*f,b=e._z*c+i._z*u+t._z*d+s._z*f,x=e._w*c+i._w*u+t._w*d+s._w*f;return new Se(g,m,b,x)}static Hermite1stDerivative(e,t,i,s,r){const a=new Se;return this.Hermite1stDerivativeToRef(e,t,i,s,r,a),a}static Hermite1stDerivativeToRef(e,t,i,s,r,a){const o=r*r;return a._x=(o-r)*6*e._x+(3*o-4*r+1)*t._x+(-o+r)*6*i._x+(3*o-2*r)*s._x,a._y=(o-r)*6*e._y+(3*o-4*r+1)*t._y+(-o+r)*6*i._y+(3*o-2*r)*s._y,a._z=(o-r)*6*e._z+(3*o-4*r+1)*t._z+(-o+r)*6*i._z+(3*o-2*r)*s._z,a._w=(o-r)*6*e._w+(3*o-4*r+1)*t._w+(-o+r)*6*i._w+(3*o-2*r)*s._w,a._isDirty=!0,a}static Normalize(e){const t=Se.Zero();return Se.NormalizeToRef(e,t),t}static NormalizeToRef(e,t){return e.normalizeToRef(t),t}static Clamp(e,t,i){const s=new Se;return Se.ClampToRef(e,t,i,s),s}static ClampToRef(e,t,i,s){return s.copyFromFloats(Qt(e.x,t.x,i.x),Qt(e.y,t.y,i.y),Qt(e.z,t.z,i.z),Qt(e.w,t.w,i.w))}static Random(e=0,t=1){return new Se(li(e,t),li(e,t),li(e,t),li(e,t))}static RandomToRef(e=0,t=1,i){return i.copyFromFloats(li(e,t),li(e,t),li(e,t),li(e,t))}static Minimize(){throw new ReferenceError("Quaternion.Minimize does not make sense")}static Maximize(){throw new ReferenceError("Quaternion.Maximize does not make sense")}static Distance(e,t){return Math.sqrt(Se.DistanceSquared(e,t))}static DistanceSquared(e,t){const i=e.x-t.x,s=e.y-t.y,r=e.z-t.z,a=e.w-t.w;return i*i+s*s+r*r+a*a}static Center(e,t){return Se.CenterToRef(e,t,Se.Zero())}static CenterToRef(e,t,i){return i.copyFromFloats((e.x+t.x)/2,(e.y+t.y)/2,(e.z+t.z)/2,(e.w+t.w)/2)}}Se._V8PerformanceHack=new Se(.5,.5,.5,.5);Object.defineProperties(Se.prototype,{dimension:{value:[4]},rank:{value:1}});class W{static get Use64Bits(){return Oi.MatrixUse64Bits}get m(){return this._m}markAsUpdated(){this.updateFlag=Sb._UpdateFlagSeed++,this._isIdentity=!1,this._isIdentity3x2=!1,this._isIdentityDirty=!0,this._isIdentity3x2Dirty=!0}_updateIdentityStatus(e,t=!1,i=!1,s=!0){this._isIdentity=e,this._isIdentity3x2=e||i,this._isIdentityDirty=this._isIdentity?!1:t,this._isIdentity3x2Dirty=this._isIdentity3x2?!1:s}constructor(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,Oi.MatrixTrackPrecisionChange&&Oi.MatrixTrackedMatrices.push(this),this._m=new Oi.MatrixCurrentType(16),this.markAsUpdated()}isIdentity(){if(this._isIdentityDirty){this._isIdentityDirty=!1;const e=this._m;this._isIdentity=e[0]===1&&e[1]===0&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===1&&e[6]===0&&e[7]===0&&e[8]===0&&e[9]===0&&e[10]===1&&e[11]===0&&e[12]===0&&e[13]===0&&e[14]===0&&e[15]===1}return this._isIdentity}isIdentityAs3x2(){return this._isIdentity3x2Dirty&&(this._isIdentity3x2Dirty=!1,this._m[0]!==1||this._m[5]!==1||this._m[15]!==1?this._isIdentity3x2=!1:this._m[1]!==0||this._m[2]!==0||this._m[3]!==0||this._m[4]!==0||this._m[6]!==0||this._m[7]!==0||this._m[8]!==0||this._m[9]!==0||this._m[10]!==0||this._m[11]!==0||this._m[12]!==0||this._m[13]!==0||this._m[14]!==0?this._isIdentity3x2=!1:this._isIdentity3x2=!0),this._isIdentity3x2}determinant(){if(this._isIdentity===!0)return 1;const e=this._m,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],c=e[6],u=e[7],d=e[8],f=e[9],g=e[10],m=e[11],b=e[12],x=e[13],v=e[14],E=e[15],A=g*E-v*m,D=f*E-x*m,I=f*v-x*g,R=d*E-b*m,C=d*v-g*b,M=d*x-b*f,F=+(o*A-c*D+u*I),U=-(a*A-c*R+u*C),k=+(a*D-o*R+u*M),q=-(a*I-o*C+c*M);return t*F+i*U+s*k+r*q}toString(){return`{${this.m[0]}, ${this.m[1]}, ${this.m[2]}, ${this.m[3]} 229${this.m[4]}, ${this.m[5]}, ${this.m[6]}, ${this.m[7]} 230${this.m[8]}, ${this.m[9]}, ${this.m[10]}, ${this.m[11]} 231${this.m[12]}, ${this.m[13]}, ${this.m[14]}, ${this.m[15]}}`}toArray(e=null,t=0){if(!e)return this._m;const i=this._m;for(let s=0;s<16;s++)e[t+s]=i[s];return this}asArray(){return this._m}fromArray(e,t=0){return W.FromArrayToRef(e,t,this)}copyFromFloats(...e){return W.FromArrayToRef(e,0,this)}set(...e){const t=this._m;for(let i=0;i<16;i++)t[i]=e[i];return this.markAsUpdated(),this}setAll(e){const t=this._m;for(let i=0;i<16;i++)t[i]=e;return this.markAsUpdated(),this}invert(){return this.invertToRef(this),this}reset(){return W.FromValuesToRef(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,this),this._updateIdentityStatus(!1),this}add(e){const t=new W;return this.addToRef(e,t),t}addToRef(e,t){const i=this._m,s=t._m,r=e.m;for(let a=0;a<16;a++)s[a]=i[a]+r[a];return t.markAsUpdated(),t}addToSelf(e){const t=this._m,i=e.m;return t[0]+=i[0],t[1]+=i[1],t[2]+=i[2],t[3]+=i[3],t[4]+=i[4],t[5]+=i[5],t[6]+=i[6],t[7]+=i[7],t[8]+=i[8],t[9]+=i[9],t[10]+=i[10],t[11]+=i[11],t[12]+=i[12],t[13]+=i[13],t[14]+=i[14],t[15]+=i[15],this.markAsUpdated(),this}addInPlace(e){const t=this._m,i=e.m;for(let s=0;s<16;s++)t[s]+=i[s];return this.markAsUpdated(),this}addInPlaceFromFloats(...e){const t=this._m;for(let i=0;i<16;i++)t[i]+=e[i];return this.markAsUpdated(),this}subtract(e){const t=this._m,i=e.m;for(let s=0;s<16;s++)t[s]-=i[s];return this.markAsUpdated(),this}subtractToRef(e,t){const i=this._m,s=e.m,r=t._m;for(let a=0;a<16;a++)r[a]=i[a]-s[a];return t.markAsUpdated(),t}subtractInPlace(e){const t=this._m,i=e.m;for(let s=0;s<16;s++)t[s]-=i[s];return this.markAsUpdated(),this}subtractFromFloats(...e){return this.subtractFromFloatsToRef(...e,new W)}subtractFromFloatsToRef(...e){const t=e.pop(),i=this._m,s=t._m,r=e;for(let a=0;a<16;a++)s[a]=i[a]-r[a];return t.markAsUpdated(),t}invertToRef(e){return this._isIdentity===!0?(W.IdentityToRef(e),e):(gC(this,e.asArray())?e.markAsUpdated():e.copyFrom(this),e)}addAtIndex(e,t){return this._m[e]+=t,this.markAsUpdated(),this}multiplyAtIndex(e,t){return this._m[e]*=t,this.markAsUpdated(),this}setTranslationFromFloats(e,t,i){return this._m[12]=e,this._m[13]=t,this._m[14]=i,this.markAsUpdated(),this}addTranslationFromFloats(e,t,i){return this._m[12]+=e,this._m[13]+=t,this._m[14]+=i,this.markAsUpdated(),this}setTranslation(e){return this.setTranslationFromFloats(e._x,e._y,e._z)}getTranslation(){return new T(this._m[12],this._m[13],this._m[14])}getTranslationToRef(e){return e.x=this._m[12],e.y=this._m[13],e.z=this._m[14],e}removeRotationAndScaling(){const e=this.m;return W.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e[12],e[13],e[14],e[15],this),this._updateIdentityStatus(e[12]===0&&e[13]===0&&e[14]===0&&e[15]===1),this}copyFrom(e){e.copyToArray(this._m);const t=e;return this.updateFlag=t.updateFlag,this._updateIdentityStatus(t._isIdentity,t._isIdentityDirty,t._isIdentity3x2,t._isIdentity3x2Dirty),this}copyToArray(e,t=0){return QU(this,e,t),this}multiply(e){const t=new W;return this.multiplyToRef(e,t),t}multiplyInPlace(e){const t=this._m,i=e.m;for(let s=0;s<16;s++)t[s]*=i[s];return this.markAsUpdated(),this}multiplyByFloats(...e){const t=this._m;for(let i=0;i<16;i++)t[i]*=e[i];return this.markAsUpdated(),this}multiplyByFloatsToRef(...e){const t=e.pop(),i=this._m,s=t._m,r=e;for(let a=0;a<16;a++)s[a]=i[a]*r[a];return t.markAsUpdated(),t}multiplyToRef(e,t){return this._isIdentity?(t.copyFrom(e),t):e._isIdentity?(t.copyFrom(this),t):(this.multiplyToArray(e,t._m,0),t.markAsUpdated(),t)}multiplyToArray(e,t,i){return _C(this,e,t,i),this}divide(e){return this.divideToRef(e,new W)}divideToRef(e,t){const i=this._m,s=e.m,r=t._m;for(let a=0;a<16;a++)r[a]=i[a]/s[a];return t.markAsUpdated(),t}divideInPlace(e){const t=this._m,i=e.m;for(let s=0;s<16;s++)t[s]/=i[s];return this.markAsUpdated(),this}minimizeInPlace(e){const t=this._m,i=e.m;for(let s=0;s<16;s++)t[s]=Math.min(t[s],i[s]);return this.markAsUpdated(),this}minimizeInPlaceFromFloats(...e){const t=this._m;for(let i=0;i<16;i++)t[i]=Math.min(t[i],e[i]);return this.markAsUpdated(),this}maximizeInPlace(e){const t=this._m,i=e.m;for(let s=0;s<16;s++)t[s]=Math.min(t[s],i[s]);return this.markAsUpdated(),this}maximizeInPlaceFromFloats(...e){const t=this._m;for(let i=0;i<16;i++)t[i]=Math.min(t[i],e[i]);return this.markAsUpdated(),this}negate(){return this.negateToRef(new W)}negateInPlace(){const e=this._m;for(let t=0;t<16;t++)e[t]=-e[t];return this.markAsUpdated(),this}negateToRef(e){const t=this._m,i=e._m;for(let s=0;s<16;s++)i[s]=-t[s];return e.markAsUpdated(),e}equals(e){const t=e;if(!t)return!1;if((this._isIdentity||t._isIdentity)&&!this._isIdentityDirty&&!t._isIdentityDirty)return this._isIdentity&&t._isIdentity;const i=this.m,s=t.m;return i[0]===s[0]&&i[1]===s[1]&&i[2]===s[2]&&i[3]===s[3]&&i[4]===s[4]&&i[5]===s[5]&&i[6]===s[6]&&i[7]===s[7]&&i[8]===s[8]&&i[9]===s[9]&&i[10]===s[10]&&i[11]===s[11]&&i[12]===s[12]&&i[13]===s[13]&&i[14]===s[14]&&i[15]===s[15]}equalsWithEpsilon(e,t=0){const i=this._m,s=e.m;for(let r=0;r<16;r++)if(!Lt(i[r],s[r],t))return!1;return!0}equalsToFloats(...e){const t=this._m;for(let i=0;i<16;i++)if(t[i]!=e[i])return!1;return!0}floor(){return this.floorToRef(new W)}floorToRef(e){const t=this._m,i=e._m;for(let s=0;s<16;s++)i[s]=Math.floor(t[s]);return e.markAsUpdated(),e}fract(){return this.fractToRef(new W)}fractToRef(e){const t=this._m,i=e._m;for(let s=0;s<16;s++)i[s]=t[s]-Math.floor(t[s]);return e.markAsUpdated(),e}clone(){const e=new W;return e.copyFrom(this),e}getClassName(){return"Matrix"}getHashCode(){let e=Es(this._m[0]);for(let t=1;t<16;t++)e=e*397^Es(this._m[t]);return e}decomposeToTransformNode(e){return e.rotationQuaternion=e.rotationQuaternion||new Se,this.decompose(e.scaling,e.rotationQuaternion,e.position)}decompose(e,t,i,s,r=!0){if(this._isIdentity)return i&&i.setAll(0),e&&e.setAll(1),t&&t.copyFromFloats(0,0,0,1),!0;const a=this._m;if(i&&i.copyFromFloats(a[12],a[13],a[14]),e=e||we.Vector3[0],e.x=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]),e.y=Math.sqrt(a[4]*a[4]+a[5]*a[5]+a[6]*a[6]),e.z=Math.sqrt(a[8]*a[8]+a[9]*a[9]+a[10]*a[10]),s){const o=(r?s.absoluteScaling.x:s.scaling.x)<0?-1:1,c=(r?s.absoluteScaling.y:s.scaling.y)<0?-1:1,u=(r?s.absoluteScaling.z:s.scaling.z)<0?-1:1;e.x*=o,e.y*=c,e.z*=u}else this.determinant()<=0&&(e.y*=-1);if(e._x===0||e._y===0||e._z===0)return t&&t.copyFromFloats(0,0,0,1),!1;if(t){const o=1/e._x,c=1/e._y,u=1/e._z;W.FromValuesToRef(a[0]*o,a[1]*o,a[2]*o,0,a[4]*c,a[5]*c,a[6]*c,0,a[8]*u,a[9]*u,a[10]*u,0,0,0,0,1,we.Matrix[0]),Se.FromRotationMatrixToRef(we.Matrix[0],t)}return!0}getRow(e){if(e<0||e>3)return null;const t=e*4;return new rt(this._m[t+0],this._m[t+1],this._m[t+2],this._m[t+3])}getRowToRef(e,t){if(e>=0&&e<=3){const i=e*4;t.x=this._m[i+0],t.y=this._m[i+1],t.z=this._m[i+2],t.w=this._m[i+3]}return t}setRow(e,t){return this.setRowFromFloats(e,t.x,t.y,t.z,t.w)}transpose(){const e=new W;return W.TransposeToRef(this,e),e}transposeToRef(e){return W.TransposeToRef(this,e),e}setRowFromFloats(e,t,i,s,r){if(e<0||e>3)return this;const a=e*4;return this._m[a+0]=t,this._m[a+1]=i,this._m[a+2]=s,this._m[a+3]=r,this.markAsUpdated(),this}scale(e){const t=new W;return this.scaleToRef(e,t),t}scaleToRef(e,t){for(let i=0;i<16;i++)t._m[i]=this._m[i]*e;return t.markAsUpdated(),t}scaleAndAddToRef(e,t){for(let i=0;i<16;i++)t._m[i]+=this._m[i]*e;return t.markAsUpdated(),t}scaleInPlace(e){const t=this._m;for(let i=0;i<16;i++)t[i]*=e;return this.markAsUpdated(),this}toNormalMatrix(e){const t=we.Matrix[0];this.invertToRef(t),t.transposeToRef(e);const i=e._m;return W.FromValuesToRef(i[0],i[1],i[2],0,i[4],i[5],i[6],0,i[8],i[9],i[10],0,0,0,0,1,e),e}getRotationMatrix(){const e=new W;return this.getRotationMatrixToRef(e),e}getRotationMatrixToRef(e){const t=we.Vector3[0];if(!this.decompose(t))return W.IdentityToRef(e),e;const i=this._m,s=1/t._x,r=1/t._y,a=1/t._z;return W.FromValuesToRef(i[0]*s,i[1]*s,i[2]*s,0,i[4]*r,i[5]*r,i[6]*r,0,i[8]*a,i[9]*a,i[10]*a,0,0,0,0,1,e),e}toggleModelMatrixHandInPlace(){const e=this._m;return e[2]*=-1,e[6]*=-1,e[8]*=-1,e[9]*=-1,e[14]*=-1,this.markAsUpdated(),this}toggleProjectionMatrixHandInPlace(){const e=this._m;return e[8]*=-1,e[9]*=-1,e[10]*=-1,e[11]*=-1,this.markAsUpdated(),this}static FromArray(e,t=0){const i=new W;return W.FromArrayToRef(e,t,i),i}static FromArrayToRef(e,t,i){for(let s=0;s<16;s++)i._m[s]=e[s+t];return i.markAsUpdated(),i}static FromFloat32ArrayToRefScaled(e,t,i,s){return s._m[0]=e[0+t]*i,s._m[1]=e[1+t]*i,s._m[2]=e[2+t]*i,s._m[3]=e[3+t]*i,s._m[4]=e[4+t]*i,s._m[5]=e[5+t]*i,s._m[6]=e[6+t]*i,s._m[7]=e[7+t]*i,s._m[8]=e[8+t]*i,s._m[9]=e[9+t]*i,s._m[10]=e[10+t]*i,s._m[11]=e[11+t]*i,s._m[12]=e[12+t]*i,s._m[13]=e[13+t]*i,s._m[14]=e[14+t]*i,s._m[15]=e[15+t]*i,s.markAsUpdated(),s}static get IdentityReadOnly(){return W._IdentityReadOnly}static FromValuesToRef(e,t,i,s,r,a,o,c,u,d,f,g,m,b,x,v,E){const A=E._m;A[0]=e,A[1]=t,A[2]=i,A[3]=s,A[4]=r,A[5]=a,A[6]=o,A[7]=c,A[8]=u,A[9]=d,A[10]=f,A[11]=g,A[12]=m,A[13]=b,A[14]=x,A[15]=v,E.markAsUpdated()}static FromValues(e,t,i,s,r,a,o,c,u,d,f,g,m,b,x,v){const E=new W,A=E._m;return A[0]=e,A[1]=t,A[2]=i,A[3]=s,A[4]=r,A[5]=a,A[6]=o,A[7]=c,A[8]=u,A[9]=d,A[10]=f,A[11]=g,A[12]=m,A[13]=b,A[14]=x,A[15]=v,E.markAsUpdated(),E}static Compose(e,t,i){const s=new W;return W.ComposeToRef(e,t,i,s),s}static ComposeToRef(e,t,i,s){const r=s._m,a=t._x,o=t._y,c=t._z,u=t._w,d=a+a,f=o+o,g=c+c,m=a*d,b=a*f,x=a*g,v=o*f,E=o*g,A=c*g,D=u*d,I=u*f,R=u*g,C=e._x,M=e._y,F=e._z;return r[0]=(1-(v+A))*C,r[1]=(b+R)*C,r[2]=(x-I)*C,r[3]=0,r[4]=(b-R)*M,r[5]=(1-(m+A))*M,r[6]=(E+D)*M,r[7]=0,r[8]=(x+I)*F,r[9]=(E-D)*F,r[10]=(1-(m+v))*F,r[11]=0,r[12]=i._x,r[13]=i._y,r[14]=i._z,r[15]=1,s.markAsUpdated(),s}static Identity(){const e=W.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return e._updateIdentityStatus(!0),e}static IdentityToRef(e){return W.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,e),e._updateIdentityStatus(!0),e}static Zero(){const e=W.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return e._updateIdentityStatus(!1),e}static RotationX(e){const t=new W;return W.RotationXToRef(e,t),t}static Invert(e){const t=new W;return e.invertToRef(t),t}static RotationXToRef(e,t){const i=Math.sin(e),s=Math.cos(e);return W.FromValuesToRef(1,0,0,0,0,s,i,0,0,-i,s,0,0,0,0,1,t),t._updateIdentityStatus(s===1&&i===0),t}static RotationY(e){const t=new W;return W.RotationYToRef(e,t),t}static RotationYToRef(e,t){const i=Math.sin(e),s=Math.cos(e);return W.FromValuesToRef(s,0,-i,0,0,1,0,0,i,0,s,0,0,0,0,1,t),t._updateIdentityStatus(s===1&&i===0),t}static RotationZ(e){const t=new W;return W.RotationZToRef(e,t),t}static RotationZToRef(e,t){const i=Math.sin(e),s=Math.cos(e);return W.FromValuesToRef(s,i,0,0,-i,s,0,0,0,0,1,0,0,0,0,1,t),t._updateIdentityStatus(s===1&&i===0),t}static RotationAxis(e,t){const i=new W;return W.RotationAxisToRef(e,t,i),i}static RotationAxisToRef(e,t,i){const s=Math.sin(-t),r=Math.cos(-t),a=1-r;e=e.normalizeToRef(we.Vector3[0]);const o=i._m;return o[0]=e._x*e._x*a+r,o[1]=e._x*e._y*a-e._z*s,o[2]=e._x*e._z*a+e._y*s,o[3]=0,o[4]=e._y*e._x*a+e._z*s,o[5]=e._y*e._y*a+r,o[6]=e._y*e._z*a-e._x*s,o[7]=0,o[8]=e._z*e._x*a-e._y*s,o[9]=e._z*e._y*a+e._x*s,o[10]=e._z*e._z*a+r,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,i.markAsUpdated(),i}static RotationAlignToRef(e,t,i,s=!1){const r=T.Dot(t,e),a=i._m;if(r<-1+bt)a[0]=-1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=s?1:-1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=s?-1:1,a[11]=0;else{const o=T.Cross(t,e),c=1/(1+r);a[0]=o._x*o._x*c+r,a[1]=o._y*o._x*c-o._z,a[2]=o._z*o._x*c+o._y,a[3]=0,a[4]=o._x*o._y*c+o._z,a[5]=o._y*o._y*c+r,a[6]=o._z*o._y*c-o._x,a[7]=0,a[8]=o._x*o._z*c-o._y,a[9]=o._y*o._z*c+o._x,a[10]=o._z*o._z*c+r,a[11]=0}return a[12]=0,a[13]=0,a[14]=0,a[15]=1,i.markAsUpdated(),i}static RotationYawPitchRoll(e,t,i){const s=new W;return W.RotationYawPitchRollToRef(e,t,i,s),s}static RotationYawPitchRollToRef(e,t,i,s){return Se.RotationYawPitchRollToRef(e,t,i,we.Quaternion[0]),we.Quaternion[0].toRotationMatrix(s),s}static Scaling(e,t,i){const s=new W;return W.ScalingToRef(e,t,i,s),s}static ScalingToRef(e,t,i,s){return W.FromValuesToRef(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1,s),s._updateIdentityStatus(e===1&&t===1&&i===1),s}static Translation(e,t,i){const s=new W;return W.TranslationToRef(e,t,i,s),s}static TranslationToRef(e,t,i,s){return W.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e,t,i,1,s),s._updateIdentityStatus(e===0&&t===0&&i===0),s}static Lerp(e,t,i){const s=new W;return W.LerpToRef(e,t,i,s),s}static LerpToRef(e,t,i,s){const r=s._m,a=e.m,o=t.m;for(let c=0;c<16;c++)r[c]=a[c]*(1-i)+o[c]*i;return s.markAsUpdated(),s}static DecomposeLerp(e,t,i){const s=new W;return W.DecomposeLerpToRef(e,t,i,s),s}static DecomposeLerpToRef(e,t,i,s){const r=we.Vector3[0],a=we.Quaternion[0],o=we.Vector3[1];e.decompose(r,a,o);const c=we.Vector3[2],u=we.Quaternion[1],d=we.Vector3[3];t.decompose(c,u,d);const f=we.Vector3[4];T.LerpToRef(r,c,i,f);const g=we.Quaternion[2];Se.SlerpToRef(a,u,i,g);const m=we.Vector3[5];return T.LerpToRef(o,d,i,m),W.ComposeToRef(f,g,m,s),s}static LookAtLH(e,t,i){const s=new W;return W.LookAtLHToRef(e,t,i,s),s}static LookAtLHToRef(e,t,i,s){const r=we.Vector3[0],a=we.Vector3[1],o=we.Vector3[2];t.subtractToRef(e,o),o.normalize(),T.CrossToRef(i,o,r);const c=r.lengthSquared();c===0?r.x=1:r.normalizeFromLength(Math.sqrt(c)),T.CrossToRef(o,r,a),a.normalize();const u=-T.Dot(r,e),d=-T.Dot(a,e),f=-T.Dot(o,e);return W.FromValuesToRef(r._x,a._x,o._x,0,r._y,a._y,o._y,0,r._z,a._z,o._z,0,u,d,f,1,s),s}static LookAtRH(e,t,i){const s=new W;return W.LookAtRHToRef(e,t,i,s),s}static LookAtRHToRef(e,t,i,s){const r=we.Vector3[0],a=we.Vector3[1],o=we.Vector3[2];e.subtractToRef(t,o),o.normalize(),T.CrossToRef(i,o,r);const c=r.lengthSquared();c===0?r.x=1:r.normalizeFromLength(Math.sqrt(c)),T.CrossToRef(o,r,a),a.normalize();const u=-T.Dot(r,e),d=-T.Dot(a,e),f=-T.Dot(o,e);return W.FromValuesToRef(r._x,a._x,o._x,0,r._y,a._y,o._y,0,r._z,a._z,o._z,0,u,d,f,1,s),s}static LookDirectionLH(e,t){const i=new W;return W.LookDirectionLHToRef(e,t,i),i}static LookDirectionLHToRef(e,t,i){const s=we.Vector3[0];s.copyFrom(e),s.scaleInPlace(-1);const r=we.Vector3[1];return T.CrossToRef(t,s,r),W.FromValuesToRef(r._x,r._y,r._z,0,t._x,t._y,t._z,0,s._x,s._y,s._z,0,0,0,0,1,i),i}static LookDirectionRH(e,t){const i=new W;return W.LookDirectionRHToRef(e,t,i),i}static LookDirectionRHToRef(e,t,i){const s=we.Vector3[2];return T.CrossToRef(t,e,s),W.FromValuesToRef(s._x,s._y,s._z,0,t._x,t._y,t._z,0,e._x,e._y,e._z,0,0,0,0,1,i),i}static OrthoLH(e,t,i,s,r){const a=new W;return W.OrthoLHToRef(e,t,i,s,a,r),a}static OrthoLHToRef(e,t,i,s,r,a){const o=i,c=s,u=2/e,d=2/t,f=2/(c-o),g=-(c+o)/(c-o);return W.FromValuesToRef(u,0,0,0,0,d,0,0,0,0,f,0,0,0,g,1,r),a&&r.multiplyToRef(Co,r),r._updateIdentityStatus(u===1&&d===1&&f===1&&g===0),r}static OrthoOffCenterLH(e,t,i,s,r,a,o){const c=new W;return W.OrthoOffCenterLHToRef(e,t,i,s,r,a,c,o),c}static OrthoOffCenterLHToRef(e,t,i,s,r,a,o,c){const u=r,d=a,f=2/(t-e),g=2/(s-i),m=2/(d-u),b=-(d+u)/(d-u),x=(e+t)/(e-t),v=(s+i)/(i-s);return W.FromValuesToRef(f,0,0,0,0,g,0,0,0,0,m,0,x,v,b,1,o),c&&o.multiplyToRef(Co,o),o.markAsUpdated(),o}static ObliqueOffCenterLHToRef(e,t,i,s,r,a,o,c,u,d,f){const g=-o*Math.cos(c),m=-o*Math.sin(c);return W.TranslationToRef(0,0,-u,we.Matrix[1]),W.FromValuesToRef(1,0,0,0,0,1,0,0,g,m,1,0,0,0,0,1,we.Matrix[0]),we.Matrix[1].multiplyToRef(we.Matrix[0],we.Matrix[0]),W.TranslationToRef(0,0,u,we.Matrix[1]),we.Matrix[0].multiplyToRef(we.Matrix[1],we.Matrix[0]),W.OrthoOffCenterLHToRef(e,t,i,s,r,a,d,f),we.Matrix[0].multiplyToRef(d,d),d}static OrthoOffCenterRH(e,t,i,s,r,a,o){const c=new W;return W.OrthoOffCenterRHToRef(e,t,i,s,r,a,c,o),c}static OrthoOffCenterRHToRef(e,t,i,s,r,a,o,c){return W.OrthoOffCenterLHToRef(e,t,i,s,r,a,o,c),o._m[10]*=-1,o}static ObliqueOffCenterRHToRef(e,t,i,s,r,a,o,c,u,d,f){const g=o*Math.cos(c),m=o*Math.sin(c);return W.TranslationToRef(0,0,u,we.Matrix[1]),W.FromValuesToRef(1,0,0,0,0,1,0,0,g,m,1,0,0,0,0,1,we.Matrix[0]),we.Matrix[1].multiplyToRef(we.Matrix[0],we.Matrix[0]),W.TranslationToRef(0,0,-u,we.Matrix[1]),we.Matrix[0].multiplyToRef(we.Matrix[1],we.Matrix[0]),W.OrthoOffCenterRHToRef(e,t,i,s,r,a,d,f),we.Matrix[0].multiplyToRef(d,d),d}static PerspectiveLH(e,t,i,s,r,a=0){const o=new W,c=i,u=s,d=2*c/e,f=2*c/t,g=(u+c)/(u-c),m=-2*u*c/(u-c),b=Math.tan(a);return W.FromValuesToRef(d,0,0,0,0,f,0,b,0,0,g,1,0,0,m,0,o),r&&o.multiplyToRef(Co,o),o._updateIdentityStatus(!1),o}static PerspectiveFovLH(e,t,i,s,r,a=0,o=!1){const c=new W;return W.PerspectiveFovLHToRef(e,t,i,s,c,!0,r,a,o),c}static PerspectiveFovLHToRef(e,t,i,s,r,a=!0,o,c=0,u=!1){const d=i,f=s,g=1/Math.tan(e*.5),m=a?g/t:g,b=a?g:g*t,x=u&&d===0?-1:f!==0?(f+d)/(f-d):1,v=u&&d===0?2*f:f!==0?-2*f*d/(f-d):-2*d,E=Math.tan(c);return W.FromValuesToRef(m,0,0,0,0,b,0,E,0,0,x,1,0,0,v,0,r),o&&r.multiplyToRef(Co,r),r._updateIdentityStatus(!1),r}static PerspectiveFovReverseLHToRef(e,t,i,s,r,a=!0,o,c=0){const u=1/Math.tan(e*.5),d=a?u/t:u,f=a?u:u*t,g=Math.tan(c);return W.FromValuesToRef(d,0,0,0,0,f,0,g,0,0,-i,1,0,0,1,0,r),o&&r.multiplyToRef(Co,r),r._updateIdentityStatus(!1),r}static PerspectiveFovRH(e,t,i,s,r,a=0,o=!1){const c=new W;return W.PerspectiveFovRHToRef(e,t,i,s,c,!0,r,a,o),c}static PerspectiveFovRHToRef(e,t,i,s,r,a=!0,o,c=0,u=!1){const d=i,f=s,g=1/Math.tan(e*.5),m=a?g/t:g,b=a?g:g*t,x=u&&d===0?1:f!==0?-(f+d)/(f-d):-1,v=u&&d===0?2*f:f!==0?-2*f*d/(f-d):-2*d,E=Math.tan(c);return W.FromValuesToRef(m,0,0,0,0,b,0,E,0,0,x,-1,0,0,v,0,r),o&&r.multiplyToRef(Co,r),r._updateIdentityStatus(!1),r}static PerspectiveFovReverseRHToRef(e,t,i,s,r,a=!0,o,c=0){const u=1/Math.tan(e*.5),d=a?u/t:u,f=a?u:u*t,g=Math.tan(c);return W.FromValuesToRef(d,0,0,0,0,f,0,g,0,0,-i,-1,0,0,-1,0,r),o&&r.multiplyToRef(Co,r),r._updateIdentityStatus(!1),r}static GetFinalMatrix(e,t,i,s,r,a){const o=e.width,c=e.height,u=e.x,d=e.y,f=W.FromValues(o/2,0,0,0,0,-c/2,0,0,0,0,a-r,0,u+o/2,c/2+d,r,1),g=new W;return t.multiplyToRef(i,g),g.multiplyToRef(s,g),g.multiplyToRef(f,g)}static GetAsMatrix2x2(e){const t=e.m,i=[t[0],t[1],t[4],t[5]];return Oi.MatrixUse64Bits?i:new Float32Array(i)}static GetAsMatrix3x3(e){const t=e.m,i=[t[0],t[1],t[2],t[4],t[5],t[6],t[8],t[9],t[10]];return Oi.MatrixUse64Bits?i:new Float32Array(i)}static Transpose(e){const t=new W;return W.TransposeToRef(e,t),t}static TransposeToRef(e,t){const i=e.m,s=i[0],r=i[4],a=i[8],o=i[12],c=i[1],u=i[5],d=i[9],f=i[13],g=i[2],m=i[6],b=i[10],x=i[14],v=i[3],E=i[7],A=i[11],D=i[15],I=t._m;return I[0]=s,I[1]=r,I[2]=a,I[3]=o,I[4]=c,I[5]=u,I[6]=d,I[7]=f,I[8]=g,I[9]=m,I[10]=b,I[11]=x,I[12]=v,I[13]=E,I[14]=A,I[15]=D,t.markAsUpdated(),t._updateIdentityStatus(e._isIdentity,e._isIdentityDirty),t}static Reflection(e){const t=new W;return W.ReflectionToRef(e,t),t}static ReflectionToRef(e,t){e.normalize();const i=e.normal.x,s=e.normal.y,r=e.normal.z,a=-2*i,o=-2*s,c=-2*r;return W.FromValuesToRef(a*i+1,o*i,c*i,0,a*s,o*s+1,c*s,0,a*r,o*r,c*r+1,0,a*e.d,o*e.d,c*e.d,1,t),t}static FromXYZAxesToRef(e,t,i,s){return W.FromValuesToRef(e._x,e._y,e._z,0,t._x,t._y,t._z,0,i._x,i._y,i._z,0,0,0,0,1,s),s}static FromQuaternionToRef(e,t){const i=e._x*e._x,s=e._y*e._y,r=e._z*e._z,a=e._x*e._y,o=e._z*e._w,c=e._z*e._x,u=e._y*e._w,d=e._y*e._z,f=e._x*e._w;return t._m[0]=1-2*(s+r),t._m[1]=2*(a+o),t._m[2]=2*(c-u),t._m[3]=0,t._m[4]=2*(a-o),t._m[5]=1-2*(r+i),t._m[6]=2*(d+f),t._m[7]=0,t._m[8]=2*(c+u),t._m[9]=2*(d-f),t._m[10]=1-2*(s+i),t._m[11]=0,t._m[12]=0,t._m[13]=0,t._m[14]=0,t._m[15]=1,t.markAsUpdated(),t}}W._IdentityReadOnly=W.Identity();Object.defineProperties(W.prototype,{dimension:{value:[4,4]},rank:{value:2}});class we{}we.Vector3=no(11,T.Zero);we.Matrix=no(2,W.Identity);we.Quaternion=no(3,Se.Zero);class te{}te.Vector2=no(3,Ie.Zero);te.Vector3=no(13,T.Zero);te.Vector4=no(3,rt.Zero);te.Quaternion=no(3,Se.Zero);te.Matrix=no(8,W.Identity);Tt("BABYLON.Vector2",Ie);Tt("BABYLON.Vector3",T);Tt("BABYLON.Vector4",rt);Tt("BABYLON.Matrix",W);const Co=W.FromValues(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);var cT;(function(n){n[n.LOCAL=0]="LOCAL",n[n.WORLD=1]="WORLD",n[n.BONE=2]="BONE"})(cT||(cT={}));class wr{}wr.X=new T(1,0,0);wr.Y=new T(0,1,0);wr.Z=new T(0,0,1);var hT;(function(n){n[n.X=0]="X",n[n.Y=1]="Y",n[n.Z=2]="Z"})(hT||(hT={}));function Kl(n){return Math.pow(n,YU)}function ql(n){return n<=.04045?.0773993808*n:Math.pow(.947867299*(n+.055),2.4)}function Zl(n){return Math.pow(n,jU)}function $l(n){return n<=.0031308?12.92*n:1.055*Math.pow(n,.41666)-.055}class Ne{constructor(e=0,t=0,i=0){this.r=e,this.g=t,this.b=i}toString(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"}getClassName(){return"Color3"}getHashCode(){let e=this.r*255|0;return e=e*397^(this.g*255|0),e=e*397^(this.b*255|0),e}toArray(e,t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,this}fromArray(e,t=0){return Ne.FromArrayToRef(e,t,this),this}toColor4(e=1){return new Ze(this.r,this.g,this.b,e)}asArray(){return[this.r,this.g,this.b]}toLuminance(){return this.r*.3+this.g*.59+this.b*.11}multiply(e){return new Ne(this.r*e.r,this.g*e.g,this.b*e.b)}multiplyToRef(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t}multiplyInPlace(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyByFloats(e,t,i){return new Ne(this.r*e,this.g*t,this.b*i)}divide(e){throw new ReferenceError("Can not divide a color")}divideToRef(e,t){throw new ReferenceError("Can not divide a color")}divideInPlace(e){throw new ReferenceError("Can not divide a color")}minimizeInPlace(e){return this.minimizeInPlaceFromFloats(e.r,e.g,e.b)}maximizeInPlace(e){return this.maximizeInPlaceFromFloats(e.r,e.g,e.b)}minimizeInPlaceFromFloats(e,t,i){return this.r=Math.min(e,this.r),this.g=Math.min(t,this.g),this.b=Math.min(i,this.b),this}maximizeInPlaceFromFloats(e,t,i){return this.r=Math.max(e,this.r),this.g=Math.max(t,this.g),this.b=Math.max(i,this.b),this}floorToRef(e){throw new ReferenceError("Can not floor a color")}floor(){throw new ReferenceError("Can not floor a color")}fractToRef(e){throw new ReferenceError("Can not fract a color")}fract(){throw new ReferenceError("Can not fract a color")}equals(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b}equalsFloats(e,t,i){return this.equalsToFloats(e,t,i)}equalsToFloats(e,t,i){return this.r===e&&this.g===t&&this.b===i}equalsWithEpsilon(e,t=bt){return Lt(this.r,e.r,t)&&Lt(this.g,e.g,t)&&Lt(this.b,e.b,t)}negate(){throw new ReferenceError("Can not negate a color")}negateInPlace(){throw new ReferenceError("Can not negate a color")}negateToRef(e){throw new ReferenceError("Can not negate a color")}scale(e){return new Ne(this.r*e,this.g*e,this.b*e)}scaleInPlace(e){return this.r*=e,this.g*=e,this.b*=e,this}scaleToRef(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t}scaleAndAddToRef(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,t}clampToRef(e=0,t=1,i){return i.r=Qt(this.r,e,t),i.g=Qt(this.g,e,t),i.b=Qt(this.b,e,t),i}add(e){return new Ne(this.r+e.r,this.g+e.g,this.b+e.b)}addInPlace(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addInPlaceFromFloats(e,t,i){return this.r+=e,this.g+=t,this.b+=i,this}addToRef(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,t}subtract(e){return new Ne(this.r-e.r,this.g-e.g,this.b-e.b)}subtractToRef(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t}subtractInPlace(e){return this.r-=e.r,this.g-=e.g,this.b-=e.b,this}subtractFromFloats(e,t,i){return new Ne(this.r-e,this.g-t,this.b-i)}subtractFromFloatsToRef(e,t,i,s){return s.r=this.r-e,s.g=this.g-t,s.b=this.b-i,s}clone(){return new Ne(this.r,this.g,this.b)}copyFrom(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copyFromFloats(e,t,i){return this.r=e,this.g=t,this.b=i,this}set(e,t,i){return this.copyFromFloats(e,t,i)}setAll(e){return this.r=this.g=this.b=e,this}toHexString(){const e=Math.round(this.r*255),t=Math.round(this.g*255),i=Math.round(this.b*255);return"#"+_n(e)+_n(t)+_n(i)}fromHexString(e){return e.substring(0,1)!=="#"||e.length!==7?this:(this.r=parseInt(e.substring(1,3),16)/255,this.g=parseInt(e.substring(3,5),16)/255,this.b=parseInt(e.substring(5,7),16)/255,this)}toHSV(){return this.toHSVToRef(new Ne)}toHSVToRef(e){const t=this.r,i=this.g,s=this.b,r=Math.max(t,i,s),a=Math.min(t,i,s);let o=0,c=0;const u=r,d=r-a;return r!==0&&(c=d/r),r!=a&&(r==t?(o=(i-s)/d,i<s&&(o+=6)):r==i?o=(s-t)/d+2:r==s&&(o=(t-i)/d+4),o*=60),e.r=o,e.g=c,e.b=u,e}toLinearSpace(e=!1){const t=new Ne;return this.toLinearSpaceToRef(t,e),t}toLinearSpaceToRef(e,t=!1){return t?(e.r=ql(this.r),e.g=ql(this.g),e.b=ql(this.b)):(e.r=Kl(this.r),e.g=Kl(this.g),e.b=Kl(this.b)),this}toGammaSpace(e=!1){const t=new Ne;return this.toGammaSpaceToRef(t,e),t}toGammaSpaceToRef(e,t=!1){return t?(e.r=$l(this.r),e.g=$l(this.g),e.b=$l(this.b)):(e.r=Zl(this.r),e.g=Zl(this.g),e.b=Zl(this.b)),this}static HSVtoRGBToRef(e,t,i,s){const r=i*t,a=e/60,o=r*(1-Math.abs(a%2-1));let c=0,u=0,d=0;a>=0&&a<=1?(c=r,u=o):a>=1&&a<=2?(c=o,u=r):a>=2&&a<=3?(u=r,d=o):a>=3&&a<=4?(u=o,d=r):a>=4&&a<=5?(c=o,d=r):a>=5&&a<=6&&(c=r,d=o);const f=i-r;return s.r=c+f,s.g=u+f,s.b=d+f,s}static FromHSV(e,t,i){const s=new Ne(0,0,0);return Ne.HSVtoRGBToRef(e,t,i,s),s}static FromHexString(e){return new Ne(0,0,0).fromHexString(e)}static FromArray(e,t=0){return new Ne(e[t],e[t+1],e[t+2])}static FromArrayToRef(e,t=0,i){i.r=e[t],i.g=e[t+1],i.b=e[t+2]}static FromInts(e,t,i){return new Ne(e/255,t/255,i/255)}static Lerp(e,t,i){const s=new Ne(0,0,0);return Ne.LerpToRef(e,t,i,s),s}static LerpToRef(e,t,i,s){s.r=e.r+(t.r-e.r)*i,s.g=e.g+(t.g-e.g)*i,s.b=e.b+(t.b-e.b)*i}static Hermite(e,t,i,s,r){const a=r*r,o=r*a,c=2*o-3*a+1,u=-2*o+3*a,d=o-2*a+r,f=o-a,g=e.r*c+i.r*u+t.r*d+s.r*f,m=e.g*c+i.g*u+t.g*d+s.g*f,b=e.b*c+i.b*u+t.b*d+s.b*f;return new Ne(g,m,b)}static Hermite1stDerivative(e,t,i,s,r){const a=Ne.Black();return this.Hermite1stDerivativeToRef(e,t,i,s,r,a),a}static Hermite1stDerivativeToRef(e,t,i,s,r,a){const o=r*r;a.r=(o-r)*6*e.r+(3*o-4*r+1)*t.r+(-o+r)*6*i.r+(3*o-2*r)*s.r,a.g=(o-r)*6*e.g+(3*o-4*r+1)*t.g+(-o+r)*6*i.g+(3*o-2*r)*s.g,a.b=(o-r)*6*e.b+(3*o-4*r+1)*t.b+(-o+r)*6*i.b+(3*o-2*r)*s.b}static Red(){return new Ne(1,0,0)}static Green(){return new Ne(0,1,0)}static Blue(){return new Ne(0,0,1)}static Black(){return new Ne(0,0,0)}static get BlackReadOnly(){return Ne._BlackReadOnly}static White(){return new Ne(1,1,1)}static Purple(){return new Ne(.5,0,.5)}static Magenta(){return new Ne(1,0,1)}static Yellow(){return new Ne(1,1,0)}static Gray(){return new Ne(.5,.5,.5)}static Teal(){return new Ne(0,1,1)}static Random(){return new Ne(Math.random(),Math.random(),Math.random())}}Ne._V8PerformanceHack=new Ne(.5,.5,.5);Ne._BlackReadOnly=Ne.Black();Object.defineProperties(Ne.prototype,{dimension:{value:[3]},rank:{value:1}});class Ze{constructor(e=0,t=0,i=0,s=1){this.r=e,this.g=t,this.b=i,this.a=s}asArray(){return[this.r,this.g,this.b,this.a]}toArray(e,t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e[t+3]=this.a,this}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this.a=e[t+3],this}equals(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b&&this.a===e.a}add(e){return new Ze(this.r+e.r,this.g+e.g,this.b+e.b,this.a+e.a)}addToRef(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,t.a=this.a+e.a,t}addInPlace(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this}addInPlaceFromFloats(e,t,i,s){return this.r+=e,this.g+=t,this.b+=i,this.a+=s,this}subtract(e){return new Ze(this.r-e.r,this.g-e.g,this.b-e.b,this.a-e.a)}subtractToRef(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t.a=this.a-e.a,t}subtractInPlace(e){return this.r-=e.r,this.g-=e.g,this.b-=e.b,this.a-=e.a,this}subtractFromFloats(e,t,i,s){return new Ze(this.r-e,this.g-t,this.b-i,this.a-s)}subtractFromFloatsToRef(e,t,i,s,r){return r.r=this.r-e,r.g=this.g-t,r.b=this.b-i,r.a=this.a-s,r}scale(e){return new Ze(this.r*e,this.g*e,this.b*e,this.a*e)}scaleInPlace(e){return this.r*=e,this.g*=e,this.b*=e,this.a*=e,this}scaleToRef(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t.a=this.a*e,t}scaleAndAddToRef(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,t.a+=this.a*e,t}clampToRef(e=0,t=1,i){return i.r=Qt(this.r,e,t),i.g=Qt(this.g,e,t),i.b=Qt(this.b,e,t),i.a=Qt(this.a,e,t),i}multiply(e){return new Ze(this.r*e.r,this.g*e.g,this.b*e.b,this.a*e.a)}multiplyToRef(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t.a=this.a*e.a,t}multiplyInPlace(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this.a*=e.a,this}multiplyByFloats(e,t,i,s){return new Ze(this.r*e,this.g*t,this.b*i,this.a*s)}divide(e){throw new ReferenceError("Can not divide a color")}divideToRef(e,t){throw new ReferenceError("Can not divide a color")}divideInPlace(e){throw new ReferenceError("Can not divide a color")}minimizeInPlace(e){return this.r=Math.min(this.r,e.r),this.g=Math.min(this.g,e.g),this.b=Math.min(this.b,e.b),this.a=Math.min(this.a,e.a),this}maximizeInPlace(e){return this.r=Math.max(this.r,e.r),this.g=Math.max(this.g,e.g),this.b=Math.max(this.b,e.b),this.a=Math.max(this.a,e.a),this}minimizeInPlaceFromFloats(e,t,i,s){return this.r=Math.min(e,this.r),this.g=Math.min(t,this.g),this.b=Math.min(i,this.b),this.a=Math.min(s,this.a),this}maximizeInPlaceFromFloats(e,t,i,s){return this.r=Math.max(e,this.r),this.g=Math.max(t,this.g),this.b=Math.max(i,this.b),this.a=Math.max(s,this.a),this}floorToRef(e){throw new ReferenceError("Can not floor a color")}floor(){throw new ReferenceError("Can not floor a color")}fractToRef(e){throw new ReferenceError("Can not fract a color")}fract(){throw new ReferenceError("Can not fract a color")}negate(){throw new ReferenceError("Can not negate a color")}negateInPlace(){throw new ReferenceError("Can not negate a color")}negateToRef(e){throw new ReferenceError("Can not negate a color")}equalsWithEpsilon(e,t=bt){return Lt(this.r,e.r,t)&&Lt(this.g,e.g,t)&&Lt(this.b,e.b,t)&&Lt(this.a,e.a,t)}equalsToFloats(e,t,i,s){return this.r===e&&this.g===t&&this.b===i&&this.a===s}toString(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"}getClassName(){return"Color4"}getHashCode(){let e=this.r*255|0;return e=e*397^(this.g*255|0),e=e*397^(this.b*255|0),e=e*397^(this.a*255|0),e}clone(){return new Ze().copyFrom(this)}copyFrom(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this}copyFromFloats(e,t,i,s){return this.r=e,this.g=t,this.b=i,this.a=s,this}set(e,t,i,s){return this.copyFromFloats(e,t,i,s)}setAll(e){return this.r=this.g=this.b=this.a=e,this}toHexString(e=!1){const t=Math.round(this.r*255),i=Math.round(this.g*255),s=Math.round(this.b*255);if(e)return"#"+_n(t)+_n(i)+_n(s);const r=Math.round(this.a*255);return"#"+_n(t)+_n(i)+_n(s)+_n(r)}fromHexString(e){return e.substring(0,1)!=="#"||e.length!==9&&e.length!==7?this:(this.r=parseInt(e.substring(1,3),16)/255,this.g=parseInt(e.substring(3,5),16)/255,this.b=parseInt(e.substring(5,7),16)/255,e.length===9&&(this.a=parseInt(e.substring(7,9),16)/255),this)}toLinearSpace(e=!1){const t=new Ze;return this.toLinearSpaceToRef(t,e),t}toLinearSpaceToRef(e,t=!1){return t?(e.r=ql(this.r),e.g=ql(this.g),e.b=ql(this.b)):(e.r=Kl(this.r),e.g=Kl(this.g),e.b=Kl(this.b)),e.a=this.a,this}toGammaSpace(e=!1){const t=new Ze;return this.toGammaSpaceToRef(t,e),t}toGammaSpaceToRef(e,t=!1){return t?(e.r=$l(this.r),e.g=$l(this.g),e.b=$l(this.b)):(e.r=Zl(this.r),e.g=Zl(this.g),e.b=Zl(this.b)),e.a=this.a,this}static FromHexString(e){return e.substring(0,1)!=="#"||e.length!==9&&e.length!==7?new Ze(0,0,0,0):new Ze(0,0,0,1).fromHexString(e)}static Lerp(e,t,i){return Ze.LerpToRef(e,t,i,new Ze)}static LerpToRef(e,t,i,s){return s.r=e.r+(t.r-e.r)*i,s.g=e.g+(t.g-e.g)*i,s.b=e.b+(t.b-e.b)*i,s.a=e.a+(t.a-e.a)*i,s}static Hermite(e,t,i,s,r){const a=r*r,o=r*a,c=2*o-3*a+1,u=-2*o+3*a,d=o-2*a+r,f=o-a,g=e.r*c+i.r*u+t.r*d+s.r*f,m=e.g*c+i.g*u+t.g*d+s.g*f,b=e.b*c+i.b*u+t.b*d+s.b*f,x=e.a*c+i.a*u+t.a*d+s.a*f;return new Ze(g,m,b,x)}static Hermite1stDerivative(e,t,i,s,r){const a=new Ze;return this.Hermite1stDerivativeToRef(e,t,i,s,r,a),a}static Hermite1stDerivativeToRef(e,t,i,s,r,a){const o=r*r;a.r=(o-r)*6*e.r+(3*o-4*r+1)*t.r+(-o+r)*6*i.r+(3*o-2*r)*s.r,a.g=(o-r)*6*e.g+(3*o-4*r+1)*t.g+(-o+r)*6*i.g+(3*o-2*r)*s.g,a.b=(o-r)*6*e.b+(3*o-4*r+1)*t.b+(-o+r)*6*i.b+(3*o-2*r)*s.b,a.a=(o-r)*6*e.a+(3*o-4*r+1)*t.a+(-o+r)*6*i.a+(3*o-2*r)*s.a}static FromColor3(e,t=1){return new Ze(e.r,e.g,e.b,t)}static FromArray(e,t=0){return new Ze(e[t],e[t+1],e[t+2],e[t+3])}static FromArrayToRef(e,t=0,i){i.r=e[t],i.g=e[t+1],i.b=e[t+2],i.a=e[t+3]}static FromInts(e,t,i,s){return new Ze(e/255,t/255,i/255,s/255)}static CheckColors4(e,t){if(e.length===t*3){const i=[];for(let s=0;s<e.length;s+=3){const r=s/3*4;i[r]=e[s],i[r+1]=e[s+1],i[r+2]=e[s+2],i[r+3]=1}return i}return e}}Ze._V8PerformanceHack=new Ze(.5,.5,.5,.5);Object.defineProperties(Ze.prototype,{dimension:{value:[4]},rank:{value:1}});class Ft{}Ft.Color3=Xr(3,Ne.Black);Ft.Color4=Xr(3,()=>new Ze(0,0,0,0));Tt("BABYLON.Color3",Ne);Tt("BABYLON.Color4",Ze);class Cr{constructor(e,t,i,s){this.normal=new T(e,t,i),this.d=s}asArray(){return[this.normal.x,this.normal.y,this.normal.z,this.d]}clone(){return new Cr(this.normal.x,this.normal.y,this.normal.z,this.d)}getClassName(){return"Plane"}getHashCode(){let e=this.normal.getHashCode();return e=e*397^(this.d|0),e}normalize(){const e=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z);let t=0;return e!==0&&(t=1/e),this.normal.x*=t,this.normal.y*=t,this.normal.z*=t,this.d*=t,this}transform(e){const t=Cr._TmpMatrix;e.invertToRef(t);const i=t.m,s=this.normal.x,r=this.normal.y,a=this.normal.z,o=this.d,c=s*i[0]+r*i[1]+a*i[2]+o*i[3],u=s*i[4]+r*i[5]+a*i[6]+o*i[7],d=s*i[8]+r*i[9]+a*i[10]+o*i[11],f=s*i[12]+r*i[13]+a*i[14]+o*i[15];return new Cr(c,u,d,f)}dotCoordinate(e){return this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z+this.d}copyFromPoints(e,t,i){const s=t.x-e.x,r=t.y-e.y,a=t.z-e.z,o=i.x-e.x,c=i.y-e.y,u=i.z-e.z,d=r*u-a*c,f=a*o-s*u,g=s*c-r*o,m=Math.sqrt(d*d+f*f+g*g);let b;return m!==0?b=1/m:b=0,this.normal.x=d*b,this.normal.y=f*b,this.normal.z=g*b,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this}isFrontFacingTo(e,t){return T.Dot(this.normal,e)<=t}signedDistanceTo(e){return T.Dot(e,this.normal)+this.d}static FromArray(e){return new Cr(e[0],e[1],e[2],e[3])}static FromPoints(e,t,i){const s=new Cr(0,0,0,0);return s.copyFromPoints(e,t,i),s}static FromPositionAndNormal(e,t){const i=new Cr(0,0,0,0);return this.FromPositionAndNormalToRef(e,t,i)}static FromPositionAndNormalToRef(e,t,i){return i.normal.copyFrom(t),i.normal.normalize(),i.d=-e.dot(i.normal),i}static SignedDistanceToPlaneFromPositionAndNormal(e,t,i){const s=-(t.x*e.x+t.y*e.y+t.z*e.z);return T.Dot(i,t)+s}}Cr._TmpMatrix=W.Identity();class Mr{static GetPlanes(e){const t=[];for(let i=0;i<6;i++)t.push(new Cr(0,0,0,0));return Mr.GetPlanesToRef(e,t),t}static GetNearPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]+i[2],t.normal.y=i[7]+i[6],t.normal.z=i[11]+i[10],t.d=i[15]+i[14],t.normalize()}static GetFarPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]-i[2],t.normal.y=i[7]-i[6],t.normal.z=i[11]-i[10],t.d=i[15]-i[14],t.normalize()}static GetLeftPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]+i[0],t.normal.y=i[7]+i[4],t.normal.z=i[11]+i[8],t.d=i[15]+i[12],t.normalize()}static GetRightPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]-i[0],t.normal.y=i[7]-i[4],t.normal.z=i[11]-i[8],t.d=i[15]-i[12],t.normalize()}static GetTopPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]-i[1],t.normal.y=i[7]-i[5],t.normal.z=i[11]-i[9],t.d=i[15]-i[13],t.normalize()}static GetBottomPlaneToRef(e,t){const i=e.m;t.normal.x=i[3]+i[1],t.normal.y=i[7]+i[5],t.normal.z=i[11]+i[9],t.d=i[15]+i[13],t.normalize()}static GetPlanesToRef(e,t){Mr.GetNearPlaneToRef(e,t[0]),Mr.GetFarPlaneToRef(e,t[1]),Mr.GetLeftPlaneToRef(e,t[2]),Mr.GetRightPlaneToRef(e,t[3]),Mr.GetTopPlaneToRef(e,t[4]),Mr.GetBottomPlaneToRef(e,t[5])}static IsPointInFrustum(e,t){for(let i=0;i<6;i++)if(t[i].dotCoordinate(e)<0)return!1;return!0}}var uT;(function(n){n[n.CW=0]="CW",n[n.CCW=1]="CCW"})(uT||(uT={}));class gn{constructor(e){this._radians=e,this._radians<0&&(this._radians+=2*Math.PI)}degrees(){return this._radians*180/Math.PI}radians(){return this._radians}static BetweenTwoPoints(e,t){const i=t.subtract(e),s=Math.atan2(i.y,i.x);return new gn(s)}static BetweenTwoVectors(e,t){let i=e.lengthSquared()*t.lengthSquared();if(i===0)return new gn(Math.PI/2);i=Math.sqrt(i);let s=e.dot(t)/i;s=Qt(s,-1,1);const r=Math.acos(s);return new gn(r)}static FromRadians(e){return new gn(e)}static FromDegrees(e){return new gn(e*Math.PI/180)}}class JU{constructor(e,t,i){this.startPoint=e,this.midPoint=t,this.endPoint=i;const s=Math.pow(t.x,2)+Math.pow(t.y,2),r=(Math.pow(e.x,2)+Math.pow(e.y,2)-s)/2,a=(s-Math.pow(i.x,2)-Math.pow(i.y,2))/2,o=(e.x-t.x)*(t.y-i.y)-(t.x-i.x)*(e.y-t.y);this.centerPoint=new Ie((r*(t.y-i.y)-a*(e.y-t.y))/o,((e.x-t.x)*a-(t.x-i.x)*r)/o),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=gn.BetweenTwoPoints(this.centerPoint,this.startPoint);const c=this.startAngle.degrees();let u=gn.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),d=gn.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();u-c>180&&(u-=360),u-c<-180&&(u+=360),d-u>180&&(d-=360),d-u<-180&&(d+=360),this.orientation=u-c<0?0:1,this.angle=gn.FromDegrees(this.orientation===0?c-d:d-c)}}class Ff{constructor(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new Ie(e,t))}addLineTo(e,t){if(this.closed)return this;const i=new Ie(e,t),s=this._points[this._points.length-1];return this._points.push(i),this._length+=i.subtract(s).length(),this}addArcTo(e,t,i,s,r=36){if(this.closed)return this;const a=this._points[this._points.length-1],o=new Ie(e,t),c=new Ie(i,s),u=new JU(a,o,c);let d=u.angle.radians()/r;
231u.orientation===0&&(d*=-1);let f=u.startAngle.radians()+d;for(let g=0;g<r;g++){const m=Math.cos(f)*u.radius+u.centerPoint.x,b=Math.sin(f)*u.radius+u.centerPoint.y;this.addLineTo(m,b),f+=d}return this}addQuadraticCurveTo(e,t,i,s,r=36){if(this.closed)return this;const a=(c,u,d,f)=>(1-c)*(1-c)*u+2*c*(1-c)*d+c*c*f,o=this._points[this._points.length-1];for(let c=0;c<=r;c++){const u=c/r,d=a(u,o.x,e,i),f=a(u,o.y,t,s);this.addLineTo(d,f)}return this}addBezierCurveTo(e,t,i,s,r,a,o=36){if(this.closed)return this;const c=(d,f,g,m,b)=>(1-d)*(1-d)*(1-d)*f+3*d*(1-d)*(1-d)*g+3*d*d*(1-d)*m+d*d*d*b,u=this._points[this._points.length-1];for(let d=0;d<=o;d++){const f=d/o,g=c(f,u.x,e,i,r),m=c(f,u.y,t,s,a);this.addLineTo(g,m)}return this}isPointInside(e){let t=!1;const i=this._points.length;for(let s=i-1,r=0;r<i;s=r++){let a=this._points[s],o=this._points[r],c=o.x-a.x,u=o.y-a.y;if(Math.abs(u)>Number.EPSILON){if(u<0&&(a=this._points[r],c=-c,o=this._points[s],u=-u),e.y<a.y||e.y>o.y)continue;if(e.y===a.y&&e.x===a.x)return!0;{const d=u*(e.x-a.x)-c*(e.y-a.y);if(d===0)return!0;if(d<0)continue;t=!t}}else{if(e.y!==a.y)continue;if(o.x<=e.x&&e.x<=a.x||a.x<=e.x&&e.x<=o.x)return!0}}return t}close(){return this.closed=!0,this}length(){let e=this._length;if(this.closed){const t=this._points[this._points.length-1],i=this._points[0];e+=i.subtract(t).length()}return e}area(){const e=this._points.length;let t=0;for(let i=e-1,s=0;s<e;i=s++)t+=this._points[i].x*this._points[s].y-this._points[s].x*this._points[i].y;return t*.5}getPoints(){return this._points}getPointAtLengthPosition(e){if(e<0||e>1)return Ie.Zero();const t=e*this.length();let i=0;for(let s=0;s<this._points.length;s++){const r=(s+1)%this._points.length,a=this._points[s],c=this._points[r].subtract(a),u=c.length()+i;if(t>=i&&t<=u){const d=c.normalize(),f=t-i;return new Ie(a.x+d.x*f,a.y+d.y*f)}i=u}return Ie.Zero()}static StartingAt(e,t){return new Ff(e,t)}}class Fh{constructor(e,t=null,i,s=!1){this.path=e,this._curve=new Array,this._distances=new Array,this._tangents=new Array,this._normals=new Array,this._binormals=new Array,this._pointAtData={id:0,point:T.Zero(),previousPointArrayIndex:0,position:0,subPosition:0,interpolateReady:!1,interpolationMatrix:W.Identity()};for(let r=0;r<e.length;r++)this._curve[r]=e[r].clone();this._raw=i||!1,this._alignTangentsWithPath=s,this._compute(t,s)}getCurve(){return this._curve}getPoints(){return this._curve}length(){return this._distances[this._distances.length-1]}getTangents(){return this._tangents}getNormals(){return this._normals}getBinormals(){return this._binormals}getDistances(){return this._distances}getPointAt(e){return this._updatePointAtData(e).point}getTangentAt(e,t=!1){return this._updatePointAtData(e,t),t?T.TransformCoordinates(T.Forward(),this._pointAtData.interpolationMatrix):this._tangents[this._pointAtData.previousPointArrayIndex]}getNormalAt(e,t=!1){return this._updatePointAtData(e,t),t?T.TransformCoordinates(T.Right(),this._pointAtData.interpolationMatrix):this._normals[this._pointAtData.previousPointArrayIndex]}getBinormalAt(e,t=!1){return this._updatePointAtData(e,t),t?T.TransformCoordinates(T.UpReadOnly,this._pointAtData.interpolationMatrix):this._binormals[this._pointAtData.previousPointArrayIndex]}getDistanceAt(e){return this.length()*e}getPreviousPointIndexAt(e){return this._updatePointAtData(e),this._pointAtData.previousPointArrayIndex}getSubPositionAt(e){return this._updatePointAtData(e),this._pointAtData.subPosition}getClosestPositionTo(e){let t=Number.MAX_VALUE,i=0;for(let s=0;s<this._curve.length-1;s++){const r=this._curve[s+0],a=this._curve[s+1].subtract(r).normalize(),o=this._distances[s+1]-this._distances[s+0],c=Math.min(Math.max(T.Dot(a,e.subtract(r).normalize()),0)*T.Distance(r,e)/o,1),u=T.Distance(r.add(a.scale(c*o)),e);u<t&&(t=u,i=(this._distances[s+0]+o*c)/this.length())}return i}slice(e=0,t=1){if(e<0&&(e=1-e*-1%1),t<0&&(t=1-t*-1%1),e>t){const u=e;e=t,t=u}const i=this.getCurve(),s=this.getPointAt(e);let r=this.getPreviousPointIndexAt(e);const a=this.getPointAt(t),o=this.getPreviousPointIndexAt(t)+1,c=[];return e!==0&&(r++,c.push(s)),c.push(...i.slice(r,o)),(t!==1||e===1)&&c.push(a),new Fh(c,this.getNormalAt(e),this._raw,this._alignTangentsWithPath)}update(e,t=null,i=!1){for(let s=0;s<e.length;s++)this._curve[s].x=e[s].x,this._curve[s].y=e[s].y,this._curve[s].z=e[s].z;return this._compute(t,i),this}_compute(e,t=!1){const i=this._curve.length;if(i<2)return;this._tangents[0]=this._getFirstNonNullVector(0),this._raw||this._tangents[0].normalize(),this._tangents[i-1]=this._curve[i-1].subtract(this._curve[i-2]),this._raw||this._tangents[i-1].normalize();const s=this._tangents[0],r=this._normalVector(s,e);this._normals[0]=r,this._raw||this._normals[0].normalize(),this._binormals[0]=T.Cross(s,this._normals[0]),this._raw||this._binormals[0].normalize(),this._distances[0]=0;let a,o,c,u,d;for(let f=1;f<i;f++)a=this._getLastNonNullVector(f),f<i-1&&(o=this._getFirstNonNullVector(f),this._tangents[f]=t?o:a.add(o),this._tangents[f].normalize()),this._distances[f]=this._distances[f-1]+this._curve[f].subtract(this._curve[f-1]).length(),c=this._tangents[f],d=this._binormals[f
231-1],this._normals[f]=T.Cross(d,c),this._raw||(this._normals[f].length()===0?(u=this._normals[f-1],this._normals[f]=u.clone()):this._normals[f].normalize()),this._binormals[f]=T.Cross(c,this._normals[f]),this._raw||this._binormals[f].normalize();this._pointAtData.id=NaN}_getFirstNonNullVector(e){let t=1,i=this._curve[e+t].subtract(this._curve[e]);for(;i.length()===0&&e+t+1<this._curve.length;)t++,i=this._curve[e+t].subtract(this._curve[e]);return i}_getLastNonNullVector(e){let t=1,i=this._curve[e].subtract(this._curve[e-t]);for(;i.length()===0&&e>t+1;)t++,i=this._curve[e].subtract(this._curve[e-t]);return i}_normalVector(e,t){let i,s=e.length();if(s===0&&(s=1),t==null){let r;Lt(Math.abs(e.y)/s,1,bt)?Lt(Math.abs(e.x)/s,1,bt)?Lt(Math.abs(e.z)/s,1,bt)?r=T.Zero():r=new T(0,0,1):r=new T(1,0,0):r=new T(0,-1,0),i=T.Cross(e,r)}else i=T.Cross(e,t),T.CrossToRef(i,e,i);return i.normalize(),i}_updatePointAtData(e,t=!1){if(this._pointAtData.id===e)return this._pointAtData.interpolateReady||this._updateInterpolationMatrix(),this._pointAtData;this._pointAtData.id=e;const i=this.getPoints();if(e<=0)return this._setPointAtData(0,0,i[0],0,t);if(e>=1)return this._setPointAtData(1,1,i[i.length-1],i.length-1,t);let s=i[0],r,a=0;const o=e*this.length();for(let c=1;c<i.length;c++){r=i[c];const u=T.Distance(s,r);if(a+=u,a===o)return this._setPointAtData(e,1,r,c,t);
231if(a>o){const f=(a-o)/u,g=s.subtract(r),m=r.add(g.scaleInPlace(f));return this._setPointAtData(e,1-f,m,c-1,t)}s=r}return this._pointAtData}_setPointAtData(e,t,i,s,r){return this._pointAtData.point=i,this._pointAtData.position=e,this._pointAtData.subPosition=t,this._pointAtData.previousPointArrayIndex=s,this._pointAtData.interpolateReady=r,r&&this._updateInterpolationMatrix(),this._pointAtData}_updateInterpolationMatrix(){this._pointAtData.interpolationMatrix=W.Identity();const e=this._pointAtData.previousPointArrayIndex;if(e!==this._tangents.length-1){const t=e+1,i=this._tangents[e].clone(),s=this._normals[e].clone(),r=this._binormals[e].clone(),a=this._tangents[t].clone(),o=this._normals[t].clone(),c=this._binormals[t].clone(),u=Se.RotationQuaternionFromAxis(s,r,i),d=Se.RotationQuaternionFromAxis(o,c,a);Se.Slerp(u,d,this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix)}}}class Zn{static CreateQuadraticBezier(e,t,i,s){s=s>2?s:3;const r=[],a=(o,c,u,d)=>(1-o)*(1-o)*c+2*o*(1-o)*u+o*o*d;for(let o=0;o<=s;o++)r.push(new T(a(o/s,e.x,t.x,i.x),a(o/s,e.y,t.y,i.y),a(o/s,e.z,t.z,i.z)));return new Zn(r)}static CreateCubicBezier(e,t,i,s,r){r=r>3?r:4;const a=[],o=(c,u,d,f,g)=>(1-c)*(1-c)*(1-c)*u+3*c*(1-c)*(1-c)*d+3*c*c*(1-c)*f+c*c*c*g;for(let c=0;c<=r;c++)a.push(new T(o(c/r,e.x,t.x,i.x,s.x),o(c/r,e.y,t.y,i.y,s.y),o(c/r,e.z,t.z,i.z,s.z)));return new Zn(a)}static CreateHermiteSpline(e,t,i,s,r){const a=[],o=1/r;for(let c=0;c<=r;c++)a.push(T.Hermite(e,t,i,s,c*o));return new Zn(a)}static CreateCatmullRomSpline(e,t,i){const s=[],r=1/t;let a=0;if(i){const o=e.length;for(let c=0;c<o;c++){a=0;for(let u=0;u<t;u++)s.push(T.CatmullRom(e[c%o],e[(c+1)%o],e[(c+2)%o],e[(c+3)%o],a)),a+=r}s.push(s[0])}else{const o=[];o.push(e[0].clone()),Array.prototype.push.apply(o,e),o.push(e[e.length-1].clone());let c=0;for(;c<o.length-3;c++){a=0;for(let u=0;u<t;u++)s.push(T.CatmullRom(o[c],o[c+1],o[c+2],o[c+3],a)),a+=r}c--,s.push(T.CatmullRom(o[c],o[c+1],o[c+2],o[c+3],a))}return new Zn(s)}static ArcThru3Points(e,t,i,s=32,r=!1,a=!1){const o=[],c=t.subtract(e),u=i.subtract(t),d=e.subtract(i),f=T.Cross(c,u),g=f.length();if(g<Math.pow(10,-8))return new Zn(o);const m=c.lengthSquared(),b=u.lengthSquared(),x=d.lengthSquared(),v=f.lengthSquared(),E=c.length(),A=u.length(),D=d.length(),I=.5*E*A*D/g,R=T.Dot(c,d),C=T.Dot(c,u),M=T.Dot(u,d),F=-.5*b*R/v,U=-.5*x*C/v,k=-.5*m*M/v,q=e.scale(F).add(t.scale(U)).add(i.scale(k)),ie=e.subtract(q).normalize(),$=T.Cross(f,ie).normalize();if(a){const ce=2*Math.PI/s;for(let G=0;G<=2*Math.PI;G+=ce)o.push(q.add(ie.scale(I*Math.cos(G)).add($.scale(I*Math.sin(G)))));o.push(e)}else{const ce=1/s;let G=0,K=T.Zero();do K=q.add(ie.scale(I*Math.cos(G)).add($.scale(I*Math.sin(G)))),o.push(K),G+=ce;while(!K.equalsWithEpsilon(i,I*ce*1.1));o.push(i),r&&o.push(e)}return new Zn(o)}constructor(e){this._length=0,this._points=e,this._length=this._computeLength(e)}getPoints(){return this._points}length(){return this._length}continue(e){const t=this._points[this._points.length-1],i=this._points.slice(),s=e.getPoints();for(let a=1;a<s.length;a++)i.push(s[a].subtract(s[0]).add(t));return new Zn(i)}_computeLength(e){let t=0;for(let i=1;i<e.length;i++)t+=e[i].subtract(e[i-1]).length();return t}}class er{constructor(e,t){this.width=e,this.height=t}toString(){return`{W: ${this.width}, H: ${this.height}}`}getClassName(){return"Size"}getHashCode(){let e=this.width|0;return e=e*397^(this.height|0),e}copyFrom(e){this.width=e.width,this.height=e.height}copyFromFloats(e,t){return this.width=e,this.height=t,this}set(e,t){return this.copyFromFloats(e,t)}multiplyByFloats(e,t){return new er(this.width*e,this.height*t)}clone(){return new er(this.width,this.height)}equals(e){return e?this.width===e.width&&this.height===e.height:!1}get surface(){return this.width*this.height}static Zero(){return new er(0,0)}add(e){return new er(this.width+e.width,this.height+e.height)}subtract(e){return new er(this.width-e.width,this.height-e.height)}scale(e){return new er(this.width*e,this.height*e)}static Lerp(e,t,i){const s=e.width+(t.width-e.width)*i,r=e.height+(t.height-e.height)*i;return new er(s,r)}}class Ja{constructor(e,t,i,s){this.x=e,this.y=t,this.width=i,this.height=s}toGlobal(e,t){return new Ja(this.x*e,this.y*t,this.width*e,this.height*t)}toGlobalToRef(e,t,i){return i.x=this.x*e,i.y=this.y*t,i.width=this.width*e,i.height=this.height*t,this}clone(){return new Ja(this.x,this.y,this.width,this.height)}}const fn=[Math.sqrt(1/(4*Math.PI)),-Math.sqrt(3/(4*Math.PI)),Math.sqrt(3/(4*Math.PI)),-Math.sqrt(3/(4*Math.PI)),Math.sqrt(15/(4*Math.PI)),-Math.sqrt(15/(4*Math.PI)),Math.sqrt(5/(16*Math.PI)),-Math.sqrt(15/(4*Math.PI)),Math.sqrt(15/(16*Math.PI))],ek=[()=>1,n=>n.y,n=>n.z,n=>n.x,n=>n.x*n.y,n=>n.y*n.z,n=>
vendor: 82,643 bytes, line 231
2313*n.z*n.z-1,n=>n.x*n.z,n=>n.x*n.x-n.y*n.y],Yn=(n,e)=>fn[n]*ek[n](e),Kn=[Math.PI,2*Math.PI/3,2*Math.PI/3,2*Math.PI/3,Math.PI/4,Math.PI/4,Math.PI/4,Math.PI/4,Math.PI/4];class tf{constructor(){this.preScaled=!1,this.l00=T.Zero(),this.l1_1=T.Zero(),this.l10=T.Zero(),this.l11=T.Zero(),this.l2_2=T.Zero(),this.l2_1=T.Zero(),this.l20=T.Zero(),this.l21=T.Zero(),this.l22=T.Zero()}addLight(e,t,i){te.Vector3[0].set(t.r,t.g,t.b);const s=te.Vector3[0],r=te.Vector3[1];s.scaleToRef(i,r),r.scaleToRef(Yn(0,e),te.Vector3[2]),this.l00.addInPlace(te.Vector3[2]),r.scaleToRef(Yn(1,e),te.Vector3[2]),this.l1_1.addInPlace(te.Vector3[2]),r.scaleToRef(Yn(2,e),te.Vector3[2]),this.l10.addInPlace(te.Vector3[2]),r.scaleToRef(Yn(3,e),te.Vector3[2]),this.l11.addInPlace(te.Vector3[2]),r.scaleToRef(Yn(4,e),te.Vector3[2]),this.l2_2.addInPlace(te.Vector3[2]),r.scaleToRef(Yn(5,e),te.Vector3[2]),this.l2_1.addInPlace(te.Vector3[2]),r.scaleToRef(Yn(6,e),te.Vector3[2]),this.l20.addInPlace(te.Vector3[2]),r.scaleToRef(Yn(7,e),te.Vector3[2]),this.l21.addInPlace(te.Vector3[2]),r.scaleToRef(Yn(8,e),te.Vector3[2]),this.l22.addInPlace(te.Vector3[2])}scaleInPlace(e){this.l00.scaleInPlace(e),this.l1_1.scaleInPlace(e),this.l10.scaleInPlace(e),this.l11.scaleInPlace(e),this.l2_2.scaleInPlace(e),this.l2_1.scaleInPlace(e),this.l20.scaleInPlace(e),this.l21.scaleInPlace(e),this.l22.scaleInPlace(e)}convertIncidentRadianceToIrradiance(){this.l00.scaleInPlace(Kn[0]),this.l1_1.scaleInPlace(Kn[1]),this.l10.scaleInPlace(Kn[2]),this.l11.scaleInPlace(Kn[3]),this.l2_2.scaleInPlace(Kn[4]),this.l2_1.scaleInPlace(Kn[5]),this.l20.scaleInPlace(Kn[6]),this.l21.scaleInPlace(Kn[7]),this.l22.scaleInPlace(Kn[8])}convertIrradianceToLambertianRadiance(){this.scaleInPlace(1/Math.PI)}preScaleForRendering(){this.preScaled=!0,this.l00.scaleInPlace(fn[0]),this.l1_1.scaleInPlace(fn[1]),this.l10.scaleInPlace(fn[2]),this.l11.scaleInPlace(fn[3]),this.l2_2.scaleInPlace(fn[4]),this.l2_1.scaleInPlace(fn[5]),this.l20.scaleInPlace(fn[6]),this.l21.scaleInPlace(fn[7]),this.l22.scaleInPlace(fn[8])}updateFromArray(e){return T.FromArrayToRef(e[0],0,this.l00),T.FromArrayToRef(e[1],0,this.l1_1),T.FromArrayToRef(e[2],0,this.l10),T.FromArrayToRef(e[3],0,this.l11),T.FromArrayToRef(e[4],0,this.l2_2),T.FromArrayToRef(e[5],0,this.l2_1),T.FromArrayToRef(e[6],0,this.l20),T.FromArrayToRef(e[7],0,this.l21),T.FromArrayToRef(e[8],0,this.l22),this}updateFromFloatsArray(e){return T.FromFloatsToRef(e[0],e[1],e[2],this.l00),T.FromFloatsToRef(e[3],e[4],e[5],this.l1_1),T.FromFloatsToRef(e[6],e[7],e[8],this.l10),T.FromFloatsToRef(e[9],e[10],e[11],this.l11),T.FromFloatsToRef(e[12],e[13],e[14],this.l2_2),T.FromFloatsToRef(e[15],e[16],e[17],this.l2_1),T.FromFloatsToRef(e[18],e[19],e[20],this.l20),T.FromFloatsToRef(e[21],e[22],e[23],this.l21),T.FromFloatsToRef(e[24],e[25],e[26],this.l22),this}static FromArray(e){return new tf().updateFromArray(e)}static FromPolynomial(e){const t=new tf;return t.l00=e.xx.scale(.376127).add(e.yy.scale(.376127)).add(e.zz.scale(.376126)),t.l1_1=e.y.scale(.977204),t.l10=e.z.scale(.977204),t.l11=e.x.scale(.977204),t.l2_2=e.xy.scale(1.16538),t.l2_1=e.yz.scale(1.16538),t.l20=e.zz.scale(1.34567).subtract(e.xx.scale(.672834)).subtract(e.yy.scale(.672834)),t.l21=e.zx.scale(1.16538),t.l22=e.xx.scale(1.16538).subtract(e.yy.scale(1.16538)),t.l1_1.scaleInPlace(-1),t.l11.scaleInPlace(-1),t.l2_1.scaleInPlace(-1),t.l21.scaleInPlace(-1),t.scaleInPlace(Math.PI),t}}class sf{constructor(){this.x=T.Zero(),this.y=T.Zero(),this.z=T.Zero(),this.xx=T.Zero(),this.yy=T.Zero(),this.zz=T.Zero(),this.xy=T.Zero(),this.yz=T.Zero(),this.zx=T.Zero()}get preScaledHarmonics(){return this._harmonics||(this._harmonics=tf.FromPolynomial(this)),this._harmonics.preScaled||this._harmonics.preScaleForRendering(),this._harmonics}addAmbient(e){te.Vector3[0].copyFromFloats(e.r,e.g,e.b);const t=te.Vector3[0];this.xx.addInPlace(t),this.yy.addInPlace(t),this.zz.addInPlace(t)}scaleInPlace(e){this.x.scaleInPlace(e),this.y.scaleInPlace(e),this.z.scaleInPlace(e),this.xx.scaleInPlace(e),this.yy.scaleInPlace(e),this.zz.scaleInPlace(e),this.yz.scaleInPlace(e),this.zx.scaleInPlace(e),this.xy.scaleInPlace(e)}updateFromHarmonics(e){return this._harmonics=e,this.x.copyFrom(e.l11),this.x.scaleInPlace(1.02333).scaleInPlace(-1),this.y.copyFrom(e.l1_1),this.y.scaleInPlace(1.02333).scaleInPlace(-1),this.z.copyFrom(e.l10),this.z.scaleInPlace(1.02333),this.xx.copyFrom(e.l00),te.Vector3[0].copyFrom(e.l20).scaleInPlace(.247708),te.Vector3[1].copyFrom(e.l22).scaleInPlace(.429043),this.xx.scaleInPlace(.886277).subtractInPlace(te.Vector3[0]).addInPlace(te.Vector3[1]),this.yy.copyFrom(e.l00),this.yy.scaleInPlace(.886277).subtractInPlace(te.Vector3[0]).subtractInPlace(te.Vector3[1]),this.zz.copyFrom(e.l00),te.Vector3[0].copyFrom(e.l20).scaleInPlace(.495417),this.zz.scaleInPlace(.886277).addInPlace(te.Vector3[0]),this.yz.copyFrom(e.l2_1),this.yz.scaleInPlace(.858086).scaleInPlace(-1),this.zx.copyFrom(e.l21),this.zx.scaleInPlace(.858086).scaleInPlace(-1),this.xy.copyFrom(e.l2_2),this.xy.scaleInPlace(.858086),this.scaleInPlace(1/Math.PI),this}static FromHarmonics(e){return new sf().updateFromHarmonics(e)}static FromArray(e){const t=new sf;return T.FromArrayToRef(e[0],0,t.x),T.FromArrayToRef(e[1],0,t.y),T.FromArrayToRef(e[2],0,t.z),T.FromArrayToRef(e[3],0,t.xx),T.FromArrayToRef(e[4],0,t.yy),T.FromArrayToRef(e[5],0,t.zz),T.FromArrayToRef(e[6],0,t.yz),T.FromArrayToRef(e[7],0,t.zx),T.FromArrayToRef(e[8],0,t.xy),t}}function N(n,e,t,i){var s=arguments.length,r=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,e,t,i);else for(var o=n.length-1;o>=0;o--)(a=n[o])&&(r=(s<3?a(r):s>3?a(e,t,r):a(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r}const Cd={},Ud={};function tk(n){const e=n.getClassName();return Ud[e]||(Ud[e]={}),Ud[e]}function Dm(n){const e=n.getClassName();if(Cd[e])return Cd[e];Cd[e]={};const t=Cd[e];let i=n,s=e;for(;s;){const r=Ud[s];for(const c in r)t[c]=r[c];let a,o=!1;do{if(a=Object.getPrototypeOf(i),!a.getClassName){o=!0;break}if(a.getClassName()!==s)break;i=a}while(a);if(o)break;s=a.getClassName(),i=a}return t}function $r(n,e){return(t,i)=>{const s=tk(t);s[i]||(s[i]={type:n,sourceName:e})}}function ik(n,e=null){return(t,i)=>{const s=e||"_"+i;Object.defineProperty(t,i,{get:function(){return this[s]},set:function(r){typeof this[s]?.equals=="function"&&this[s].equals(r)||this[s]!==r&&(this[s]=r,t[n].apply(this))},enumerable:!0,configurable:!0})}}function Dt(n,e=null){return ik(n,e)}function H(n){return $r(0,n)}function Lr(n){return $r(1,n)}function Yo(n){return $r(2,n)}function $h(n){return $r(3,n)}function mC(n){return $r(4,n)}function lr(n){return $r(5,n)}function bC(n){return $r(6,n)}function sk(n){return $r(7,n)}function yC(n){return $r(8,n)}function rk(n){return $r(9,n)}function nk(n){return $r(10,n)}function la(n,e,t,i){const s=t.value;t.value=(...r)=>{let a=s;if(typeof _native<"u"&&_native[e]){const o=_native[e];i?a=(...c)=>i(...c)?o(...c):s(...c):a=o}return n[e]=a,a(...r)}}la.filter=function(n){return(e,t,i)=>la(e,t,i,n)};function Tb(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)})}function ak(){return typeof _native<"u"&&_native.XMLHttpRequest?new _native.XMLHttpRequest:new XMLHttpRequest}class Ai{constructor(){this._xhr=ak(),this._requestURL=""}static get IsCustomRequestAvailable(){return Object.keys(Ai.CustomRequestHeaders).length>0||Ai.CustomRequestModifiers.length>0}get requestURL(){return this._requestURL}_injectCustomRequestHeaders(){if(!this._shouldSkipRequestModifications(this._requestURL))for(const e in Ai.CustomRequestHeaders){const t=Ai.CustomRequestHeaders[e];t&&this._xhr.setRequestHeader(e,t)}}_shouldSkipRequestModifications(e){return Ai.SkipRequestModificationForBabylonCDN&&(e.includes("preview.babylonjs.com")||e.includes("cdn.babylonjs.com"))}get onprogress(){return this._xhr.onprogress}set onprogress(e){this._xhr.onprogress=e}get readyState(){return this._xhr.readyState}get status(){return this._xhr.status}get statusText(){return this._xhr.statusText}get response(){return this._xhr.response}get responseURL(){return this._xhr.responseURL}get responseText(){return this._xhr.responseText}get responseType(){return this._xhr.responseType}set responseType(e){this._xhr.responseType=e}get timeout(){return this._xhr.timeout}set timeout(e){this._xhr.timeout=e}addEventListener(e,t,i){this._xhr.addEventListener(e,t,i)}removeEventListener(e,t,i){this._xhr.removeEventListener(e,t,i)}abort(){this._xhr.abort()}send(e){Ai.CustomRequestHeaders&&this._injectCustomRequestHeaders(),this._xhr.send(e)}open(e,t){for(const i of Ai.CustomRequestModifiers){if(this._shouldSkipRequestModifications(t))return;t=i(this._xhr,t)||t}t=t.replace("file:http:","http:"),t=t.replace("file:https:","https:"),this._requestURL=t,this._xhr.open(e,t,!0)}setRequestHeader(e,t){this._xhr.setRequestHeader(e,t)}getResponseHeader(e){return this._xhr.getResponseHeader(e)}}Ai.CustomRequestHeaders={};Ai.CustomRequestModifiers=new Array;Ai.SkipRequestModificationForBabylonCDN=!0;class yh{}yh.FilesToLoad={};class ok{static ExponentialBackoff(e=3,t=500){return(i,s,r)=>s.status!==0||r>=e||i.indexOf("file:")!==-1?-1:Math.pow(2,r)*t}}class nc extends Error{}nc._setPrototypeOf=Object.setPrototypeOf||((n,e)=>(n.__proto__=e,n));const Ko={MeshInvalidPositionsError:0,SceneLoaderError:3e3,LoadFileError:4e3,RequestFileError:4001,ReadFileError:4002};class ua extends nc{constructor(e,t,i){super(e),this.errorCode=t,this.innerError=i,this.name="RuntimeError",nc._setPrototypeOf(this,ua.prototype)}}const vC=n=>{const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let t="",i,s,r,a,o,c,u,d=0;const f=ArrayBuffer.isView(n)?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n);for(;d<f.length;)i=f[d++],s=d<f.length?f[d++]:Number.NaN,r=d<f.length?f[d++]:Number.NaN,a=i>>2,o=(i&3)<<4|s>>4,c=(s&15)<<2|r>>6,u=r&63,isNaN(s)?c=u=64:isNaN(r)&&(u=64),t+=e.charAt(a)+e.charAt(o)+e.charAt(c)+e.charAt(u);return t},xC=n=>atob(n),lk=n=>{const e=xC(n),t=e.length,i=new Uint8Array(new ArrayBuffer(t));for(let s=0;s<t;s++)i[s]=e.charCodeAt(s);return i.buffer},SC=new RegExp(/^data:([^,]+\/[^,]+)?;base64,/i);class rf extends ua{constructor(e,t){super(e,Ko.LoadFileError),this.name="LoadFileError",nc._setPrototypeOf(this,rf.prototype),t instanceof Ai?this.request=t:this.file=t}}class nf extends ua{constructor(e,t){super(e,Ko.RequestFileError),this.request=t,this.name="RequestFileError",nc._setPrototypeOf(this,nf.prototype)}}class Eb extends ua{constructor(e,t){super(e,Ko.ReadFileError),this.file=t,this.name="ReadFileError",nc._setPrototypeOf(this,Eb.prototype)}}const ck=n=>(n=n.replace(/#/gm,"%23"),n),ri={DefaultRetryStrategy:ok.ExponentialBackoff(),BaseUrl:"",CorsBehavior:"anonymous",PreprocessUrl:n=>n,ScriptBaseUrl:"",ScriptPreprocessUrl:n=>n,CleanUrl:ck},Ab=(n,e)=>{if(!(n&&n.indexOf("data:")===0)&&ri.CorsBehavior)if(typeof ri.CorsBehavior=="string"||ri.CorsBehavior instanceof String)e.crossOrigin=ri.CorsBehavior;else{const t=ri.CorsBehavior(n);t&&(e.crossOrigin=t)}},Rb=(n,e,t,i,s="",r,a=Ke.LastCreatedEngine)=>{if(typeof HTMLImageElement>"u"&&!a?._features.forceBitmapOverHTMLImageElement)return t("LoadImage is only supported in web or BabylonNative environments."),null;let o,c=!1;n instanceof ArrayBuffer||ArrayBuffer.isView(n)?typeof Blob<"u"&&typeof URL<"u"?(o=URL.createObjectURL(new Blob([n],{type:s})),c=!0):o=`data:${s};base64,`+vC(n):n instanceof Blob?(o=URL.createObjectURL(n),c=!0):(o=ri.CleanUrl(n),o=ri.PreprocessUrl(o));const u=R=>{if(t){const C=o||n.toString();t(`Error while trying to load image: ${C.indexOf("http")===0||C.length<=128?C:C.slice(0,128)+"..."}`,R)}};if(a?._features.forceBitmapOverHTMLImageElement)return eo(o,R=>{a.createImageBitmap(new Blob([R],{type:s}),{premultiplyAlpha:"none",...r}).then(C=>{e(C),c&&URL.revokeObjectURL(o)}).catch(C=>{t&&t("Error while trying to load image: "+n,C)})},void 0,i||void 0,!0,(R,C)=>{u(C)}),null;const d=new Image;Ab(o,d);const f=[],g=()=>{for(const R of f)R.target.addEventListener(R.name,R.handler)},m=()=>{for(const R of f)R.target.removeEventListener(R.name,R.handler);f.length=0},b=()=>{m(),e(d),c&&d.src&&URL.revokeObjectURL(d.src)},x=R=>{m(),u(R),c&&d.src&&URL.revokeObjectURL(d.src)},v=R=>{if(R.blockedURI!==d.src||R.disposition==="report")return;m();const C=new Error(`CSP violation of policy ${R.effectiveDirective} ${R.blockedURI}. Current policy is ${R.originalPolicy}`);Ke.UseFallbackTexture=!1,u(C),c&&d.src&&URL.revokeObjectURL(d.src),d.src=""};f.push({target:d,name:"load",handler:b}),f.push({target:d,name:"error",handler:x}),f.push({target:document,name:"securitypolicyviolation",handler:v}),g();const E=o.substring(0,5)==="blob:",A=o.substring(0,5)==="data:",D=()=>{E||A||!Ai.IsCustomRequestAvailable?d.src=o:eo(o,(R,C,M)=>{const F=!s&&M?M:s,U=new Blob([R],{type:F}),k=URL.createObjectURL(U);c=!0,d.src=k},void 0,i||void 0,!0,(R,C)=>{u(C)})},I=()=>{i&&i.loadImage(o,d)};if(!E&&!A&&i&&i.enableTexturesOffline)i.open(I,D);else{if(o.indexOf("file:")!==-1){const R=decodeURIComponent(o.substring(5).toLowerCase());if(yh.FilesToLoad[R]&&typeof URL<"u"){try{let C;try{C=URL.createObjectURL(yh.FilesToLoad[R])}catch{C=URL.createObjectURL(yh.FilesToLoad[R])}d.src=C,c=!0}catch{d.src=""}return d}}D()}return d},Lh=(n,e,t,i,s)=>{const r=new FileReader,a={onCompleteObservable:new le,abort:()=>r.abort()};return r.onloadend=()=>a.onCompleteObservable.notifyObservers(a),s&&(r.onerror=()=>{s(new Eb(`Unable to read ${n.name}`,n))}),r.onload=o=>{e(o.target.result)},t&&(r.onprogress=t),i?r.readAsArrayBuffer(n):r.readAsText(n),a},eo=(n,e,t,i,s,r,a)=>{if(n.name)return Lh(n,e,t,s,r?d=>{r(void 0,d)}:void 0);const o=n;if(o.indexOf("file:")!==-1){let d=decodeURIComponent(o.substring(5).toLowerCase());d.indexOf("./")===0&&(d=d.substring(2));const f=yh.FilesToLoad[d];if(f)return Lh(f,e,t,s,r?g=>r(void 0,new rf(g.message,g.file)):void 0)}const{match:c,type:u}=hk(o);if(c){const d={onCompleteObservable:new le,abort:()=>()=>{}};try{const f=s?Ib(o):EC(o);e(f,void 0,u)}catch(f){r?r(void 0,f):oe.Error(f.message||"Failed to parse the Data URL")}return zo.SetImmediate(()=>{d.onCompleteObservable.notifyObservers(d)}),d}return Mb(o,(d,f)=>{e(d,f?.responseURL,f?.getResponseHeader("content-type"))},t,i,s,r?d=>{r(d.request,new rf(d.message,d.request))}:void 0,a)},Mb=(n,e,t,i,s,r,a)=>{i!==null&&(i??(i=Ke.LastCreatedScene?.offlineProvider)),n=ri.CleanUrl(n),n=ri.PreprocessUrl(n);const o=ri.BaseUrl+n;let c=!1;const u={onCompleteObservable:new le,abort:()=>c=!0},d=()=>{let f=new Ai,g=null,m;const b=()=>{f&&(t&&f.removeEventListener("progress",t),m&&f.removeEventListener("readystatechange",m),f.removeEventListener("loadend",x))};let x=()=>{b(),u.onCompleteObservable.notifyObservers(u),u.onCompleteObservable.clear(),t=void 0,m=null,x=null,r=void 0,a=void 0,e=void 0};u.abort=()=>{c=!0,x&&x(),f&&f.readyState!==(XMLHttpRequest.DONE||4)&&f.abort(),g!==null&&(clearTimeout(g),g=null),f=null};const v=A=>{const D=A.message||"Unknown error";r&&f?r(new nf(D,f)):oe.Error(D)},E=A=>{if(f){if(f.open("GET",o),a)try{a(f)}catch(D){v(D);return}s&&(f.responseType="arraybuffer"),t&&f.addEventListener("progress",t),x&&f.addEventListener("loadend",x),m=()=>{if(!(c||!f)&&f.readyState===(XMLHttpRequest.DONE||4)){if(m&&f.removeEventListener("readystatechange",m),f.status>=200&&f.status<300||f.status===0&&(!Gi()||TC())){const R=s?f.response:f.responseText;if(R!==null){try{e&&e(R,f)}catch(C){v(C)}return}}const D=ri.DefaultRetryStrategy;if(D){const R=D(o,f,A);if(R!==-1){b(),f=new Ai,g=setTimeout(()=>E(A+1),R);return}}const I=new nf("Error status: "+f.status+" "+f.statusText+" - Unable to load "+o,f);r&&r(I)}},f.addEventListener("readystatechange",m),f.send()}};E(0)};if(i&&i.enableSceneOffline&&!n.startsWith("blob:")){const f=m=>{m&&m.status>400?r&&r(m):d()},g=()=>{i&&i.loadFile(ri.BaseUrl+n,m=>{!c&&e&&e(m),u.onCompleteObservable.notifyObservers(u)},t?m=>{!c&&t&&t(m)}:void 0,f,s)};i.open(g,f)}else d();return u},TC=()=>typeof location<"u"&&location.protocol==="file:",Cb=n=>SC.test(n),hk=n=>{const e=SC.exec(n);return e===null||e.length===0?{match:!1,type:""}:{match:!0,type:e[0].replace("data:","").replace(";base64,","")}};function Ib(n){return lk(n.split(",")[1])}const EC=n=>xC(n.split(",")[1]),uk=()=>{Ce._FileToolsLoadImage=Rb,qd.loadFile=eo,rC.loadFile=eo};uk();let fh;const dk=(n,e,t,i,s,r,a,o,c,u)=>{fh={DecodeBase64UrlToBinary:n,DecodeBase64UrlToString:e,DefaultRetryStrategy:t.DefaultRetryStrategy,BaseUrl:t.BaseUrl,CorsBehavior:t.CorsBehavior,PreprocessUrl:t.PreprocessUrl,IsBase64DataUrl:i,IsFileURL:s,LoadFile:r,LoadImage:a,ReadFile:o,RequestFile:c,SetCorsBehavior:u},Object.defineProperty(fh,"DefaultRetryStrategy",{get:function(){return t.DefaultRetryStrategy},set:function(d){t.DefaultRetryStrategy=d}}),Object.defineProperty(fh,"BaseUrl",{get:function(){return t.BaseUrl},set:function(d){t.BaseUrl=d}}),Object.defineProperty(fh,"PreprocessUrl",{get:function(){return t.PreprocessUrl},set:function(d){t.PreprocessUrl=d}}),Object.defineProperty(fh,"CorsBehavior",{get:function(){return t.CorsBehavior},set:function(d){t.CorsBehavior=d}})};dk(Ib,EC,ri,Cb,TC,eo,Rb,Lh,Mb,Ab);class Pb{get wrapU(){return this._wrapU}set wrapU(e){this._wrapU=e}get wrapV(){return this._wrapV}set wrapV(e){this._wrapV=e}get coordinatesMode(){return 0}get isCube(){return this._texture?this._texture.isCube:!1}set isCube(e){this._texture&&(this._texture.isCube=e)}get is3D(){return this._texture?this._texture.is3D:!1}set is3D(e){this._texture&&(this._texture.is3D=e)}get is2DArray(){return this._texture?this._texture.is2DArray:!1}set is2DArray(e){this._texture&&(this._texture.is2DArray=e)}getClassName(){return"ThinTexture"}static _IsRenderTargetWrapper(e){return e?.shareDepth!==void 0}constructor(e){this._wrapU=1,this._wrapV=1,this.wrapR=1,this.anisotropicFilteringLevel=4,this.delayLoadState=0,this._texture=null,this._engine=null,this._cachedSize=er.Zero(),this._cachedBaseSize=er.Zero(),this._initialSamplingMode=2,this._texture=Pb._IsRenderTargetWrapper(e)?e.texture:e,this._texture&&(this._engine=this._texture.getEngine(),this.wrapU=this._texture._cachedWrapU??this.wrapU,this.wrapV=this._texture._cachedWrapV??this.wrapV,this.wrapR=this._texture._cachedWrapR??this.wrapR)}isReady(){return this.delayLoadState===4?(this.delayLoad(),!1):this._texture?this._texture.isReady:!1}delayLoad(){}getInternalTexture(){return this._texture}getSize(){if(this._texture){if(this._texture.width)return this._cachedSize.width=this._texture.width,this._cachedSize.height=this._texture.height,this._cachedSize;if(this._texture._size)return this._cachedSize.width=this._texture._size,this._cachedSize.height=this._texture._size,this._cachedSize}return this._cachedSize}getBaseSize(){return!this.isReady()||!this._texture?(this._cachedBaseSize.width=0,this._cachedBaseSize.height=0,this._cachedBaseSize):this._texture._size?(this._cachedBaseSize.width=this._texture._size,this._cachedBaseSize.height=this._texture._size,this._cachedBaseSize):(this._cachedBaseSize.width=this._texture.baseWidth,this._cachedBaseSize.height=this._texture.baseHeight,this._cachedBaseSize)}get samplingMode(){return this._texture?this._texture.samplingMode:this._initialSamplingMode}updateSamplingMode(e,t=!1){this._texture&&this._engine&&this._engine.updateTextureSamplingMode(e,this._texture,this._texture.generateMipMaps&&t)}releaseInternalTexture(){this._texture&&(this._texture.dispose(),this._texture=null)}dispose(){this._texture&&(this.releaseInternalTexture(),this._engine=null)}}class Fo{static Eval(e,t){return e.match(/\([^()]*\)/g)?e=e.replace(/\([^()]*\)/g,i=>(i=i.slice(1,i.length-1),Fo._HandleParenthesisContent(i,t))):e=Fo._HandleParenthesisContent(e,t),e==="true"?!0:e==="false"?!1:Fo.Eval(e,t)}static _HandleParenthesisContent(e,t){t=t||(r=>r==="true");let i;const s=e.split("||");for(const r in s)if(Object.prototype.hasOwnProperty.call(s,r)){let a=Fo._SimplifyNegation(s[r].trim());const o=a.split("&&");if(o.length>1)for(let c=0;c<o.length;++c){const u=Fo._SimplifyNegation(o[c].trim());if(u!=="true"&&u!=="false"?u[0]==="!"?i=!t(u.substring(1)):i=t(u):i=u==="true",!i){a="false";break}}if(i||a==="true"){i=!0;break}a!=="true"&&a!=="false"?a[0]==="!"?i=!t(a.substring(1)):i=t(a):i=a==="true"}return i?"true":"false"}static _SimplifyNegation(e){return e=e.replace(/^[\s!]+/,t=>(t=t.replace(/[\s]/g,()=>""),t.length%2?"!":"")),e=e.trim(),e==="!true"?e="false":e==="!false"&&(e="true"),e}}class vt{static EnableFor(e){e._tags=e._tags||{},e.hasTags=()=>vt.HasTags(e),e.addTags=t=>vt.AddTagsTo(e,t),e.removeTags=t=>vt.RemoveTagsFrom(e,t),e.matchesTagsQuery=t=>vt.MatchesQuery(e,t)}static DisableFor(e){delete e._tags,delete e.hasTags,delete e.addTags,delete e.removeTags,delete e.matchesTagsQuery}static HasTags(e){if(!e._tags)return!1;const t=e._tags;for(const i in t)if(Object.prototype.hasOwnProperty.call(t,i))return!0;return!1}static GetTags(e,t=!0){if(!e._tags)return null;if(t){const i=[];for(const s in e._tags)Object.prototype.hasOwnProperty.call(e._tags,s)&&e._tags[s]===!0&&i.push(s);return i.join(" ")}else return e._tags}static AddTagsTo(e,t){if(!t||typeof t!="string")return;const i=t.split(" ");for(const s of i)vt._AddTagTo(e,s)}static _AddTagTo(e,t){t=t.trim(),!(t===""||t==="true"||t==="false")&&(t.match(/[\s]/)||t.match(/^([!]|([|]|[&]){2})/)||(vt.EnableFor(e),e._tags[t]=!0))}static RemoveTagsFrom(e,t){if(!vt.HasTags(e))return;const i=t.split(" ");for(const s in i)vt._RemoveTagFrom(e,i[s])}static _RemoveTagFrom(e,t){delete e._tags[t]}static MatchesQuery(e,t){return t===void 0?!0:t===""?vt.HasTags(e):Fo.Eval(t,i=>vt.HasTags(e)&&e._tags[i])}}const dT=function(n,e,t,i={}){const s=n();vt&&vt.HasTags(e)&&vt.AddTagsTo(s,vt.GetTags(e,!0));const r=Dm(s),a={};for(const o in r){const c=r[o],u=e[o],d=c.type;if(u!=null&&(o!=="uniqueId"||$e.AllowLoadingUniqueId))switch(d){case 0:case 6:case 9:case 11:s[o]=u;break;case 1:i.cloneTexturesOnlyOnce&&a[u.uniqueId]?s[o]=a[u.uniqueId]:(s[o]=t||u.isRenderTarget?u:u.clone(),a[u.uniqueId]=s[o]);break;case 2:case 3:case 4:case 5:case 7:case 8:case 10:case 12:s[o]=t?u:u.clone();break}}return s};class $e{static AppendSerializedAnimations(e,t){if(e.animations){t.animations=[];for(let i=0;i<e.animations.length;i++){const s=e.animations[i];t.animations.push(s.serialize())}}}static Serialize(e,t){t||(t={}),vt&&(t.tags=vt.GetTags(e));const i=Dm(e);for(const s in i){const r=i[s],a=r.sourceName||s,o=r.type,c=e[s];if(c!=null&&(s!=="uniqueId"||$e.AllowLoadingUniqueId))switch(o){case 0:Array.isArray(c)?t[a]=c.slice():t[a]=c;break;case 1:t[a]=c.serialize();break;case 2:t[a]=c.asArray();break;case 3:t[a]=c.serialize();break;case 4:t[a]=c.asArray();break;case 5:t[a]=c.asArray();break;case 6:t[a]=c.id;break;case 7:t[a]=c.serialize();break;case 8:t[a]=c.asArray();break;case 9:t[a]=c.serialize();break;case 10:t[a]=c.asArray();break;case 11:t[a]=c.id;break;case 12:t[a]=c.asArray();break}}return t}static ParseProperties(e,t,i,s){s||(s="");const r=Dm(t);for(const a in r){const o=r[a],c=e[o.sourceName||a],u=o.type;if(c!=null&&(a!=="uniqueId"||$e.AllowLoadingUniqueId)){const d=t;switch(u){case 0:d[a]=c;break;case 1:i&&(d[a]=$e._TextureParser(c,i,s));break;case 2:d[a]=Ne.FromArray(c);break;case 3:d[a]=$e._FresnelParametersParser(c);break;case 4:d[a]=Ie.FromArray(c);break;case 5:d[a]=T.FromArray(c);break;case 6:i&&(d[a]=i.getLastMeshById(c));break;case 7:d[a]=$e._ColorCurvesParser(c);break;case 8:d[a]=Ze.FromArray(c);break;case 9:d[a]=$e._ImageProcessingConfigurationParser(c);break;case 10:d[a]=Se.FromArray(c);break;case 11:i&&(d[a]=i.getCameraById(c));break;case 12:d[a]=W.FromArray(c);break}}}}static Parse(e,t,i,s=null){const r=e();return vt&&vt.AddTagsTo(r,t.tags),$e.ParseProperties(t,r,i,s),r}static Clone(e,t,i={}){return dT(e,t,!1,i)}static Instanciate(e,t){return dT(e,t,!0)}}$e.AllowLoadingUniqueId=!1;$e._ImageProcessingConfigurationParser=n=>{throw We("ImageProcessingConfiguration")};$e._FresnelParametersParser=n=>{throw We("FresnelParameters")};$e._ColorCurvesParser=n=>{throw We("ColorCurves")};$e._TextureParser=(n,e,t)=>{throw We("Texture")};class jt extends Pb{set hasAlpha(e){this._hasAlpha!==e&&(this._hasAlpha=e,this._scene&&this._scene.markAllMaterialsAsDirty(1,t=>t.hasTexture(this)))}get hasAlpha(){return this._hasAlpha}set getAlphaFromRGB(e){this._getAlphaFromRGB!==e&&(this._getAlphaFromRGB=e,this._scene&&this._scene.markAllMaterialsAsDirty(1,t=>t.hasTexture(this)))}get getAlphaFromRGB(){return this._getAlphaFromRGB}set coordinatesIndex(e){this._coordinatesIndex!==e&&(this._coordinatesIndex=e,this._scene&&this._scene.markAllMaterialsAsDirty(1,t=>t.hasTexture(this)))}get coordinatesIndex(){return this._coordinatesIndex}set coordinatesMode(e){this._coordinatesMode!==e&&(this._coordinatesMode=e,this._scene&&this._scene.markAllMaterialsAsDirty(1,t=>t.hasTexture(this)))}get coordinatesMode(){return this._coordinatesMode}get wrapU(){return this._wrapU}set wrapU(e){this._wrapU=e}get wrapV(){return this._wrapV}set wrapV(e){this._wrapV=e}get isCube(){return this._texture?this._texture.isCube:this._isCube}set isCube(e){this._texture?this._texture.isCube=e:this._isCube=e}get is3D(){return this._texture?this._texture.is3D:!1}set is3D(e){this._texture&&(this._texture.is3D=e)}get is2DArray(){return this._texture?this._texture.is2DArray:!1}set is2DArray(e){this._texture&&(this._texture.is2DArray=e)}get gammaSpace(){if(this._texture)this._texture._gammaSpace===null&&(this._texture._gammaSpace=this._gammaSpace);else return this._gammaSpace;return this._texture._gammaSpace&&!this._texture._useSRGBBuffer}set gammaSpace(e){if(this._texture){if(this._texture._gammaSpace===e)return;this._texture._gammaSpace=e}else{if(this._gammaSpace===e)return;this._gammaSpace=e}this.getScene()?.markAllMaterialsAsDirty(1,t=>t.hasTexture(this))}get isRGBD(){return this._texture!=null&&this._texture._isRGBD}set isRGBD(e){e!==this.isRGBD&&(this._texture&&(this._texture._isRGBD=e),this.getScene()?.markAllMaterialsAsDirty(1,t=>t.hasTexture(this)))}get noMipmap(){return!1}get lodGenerationOffset(){return this._texture?this._texture._lodGenerationOffset:0}set lodGenerationOffset(e){this._texture&&(this._texture._lodGenerationOffset=e)}get lodGenerationScale(){return this._texture?this._texture._lodGenerationScale:0}set lodGenerationScale(e){this._texture&&(this._texture._lodGenerationScale=e)}get linearSpecularLOD(){return this._texture?this._texture._linearSpecularLOD:!1}set linearSpecularLOD(e){this._texture&&(this._texture._linearSpecularLOD=e)}get irradianceTexture(){return this._texture?this._texture._irradianceTexture:null}set irradianceTexture(e){this._texture&&(this._texture._irradianceTexture=e)}get uid(){return this._uid||(this._uid=Tb()),this._uid}toString(){return this.name}getClassName(){return"BaseTexture"}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}get isBlocking(){return!0}get loadingError(){return this._loadingError}get errorObject(){return this._errorObject}constructor(e,t=null){super(null),this.metadata=null,this.reservedDataStore=null,this._hasAlpha=!1,this._getAlphaFromRGB=!1,this.level=1,this._coordinatesIndex=0,this.optimizeUVAllocation=!0,this._coordinatesMode=0,this.wrapR=1,this.anisotropicFilteringLevel=jt.DEFAULT_ANISOTROPIC_FILTERING_LEVEL,this._isCube=!1,this._gammaSpace=!0,this.invertZ=!1,this.lodLevelInAlpha=!1,this._dominantDirection=null,this.isRenderTarget=!1,this._prefiltered=!1,this._forceSerialize=!1,this.animations=[],this.onDisposeObservable=new le,this._onDisposeObserver=null,this._scene=null,this._uid=null,this._parentContainer=null,this._loadingError=!1,e?jt._IsScene(e)?this._scene=e:this._engine=e:this._scene=Ke.LastCreatedScene,this._scene&&(this.uniqueId=this._scene.getUniqueId(),this._scene.addTexture(this),this._engine=this._scene.getEngine()),this._texture=t,this._uid=null}getScene(){return this._scene}_getEngine(){return this._engine}getTextureMatrix(){return W.IdentityReadOnly}getReflectionTextureMatrix(){return W.IdentityReadOnly}getRefractionTextureMatrix(){return this.getReflectionTextureMatrix()}isReadyOrNotBlocking(){return!this.isBlocking||this.isReady()||this.loadingError}scale(e){}get canRescale(){return!1}_getFromCache(e,t,i,s,r,a){const o=this._getEngine();if(!o)return null;const c=o._getUseSRGBBuffer(!!r,t),u=o.getLoadedTexturesCache();for(let d=0;d<u.length;d++){const f=u[d];if((r===void 0||c===f._useSRGBBuffer)&&(s===void 0||s===f.invertY)&&f.url===e&&f.generateMipMaps===!t&&(!i||i===f.samplingMode)&&(a===void 0||a===f.isCube))return f.incrementReferences(),f}return null}_rebuild(e=!1){}clone(){return null}get textureType(){return this._texture&&this._texture.type!==void 0?this._texture.type:0}get textureFormat(){return this._texture&&this._texture.format!==void 0?this._texture.format:5}_markAllSubMeshesAsTexturesDirty(){const e=this.getScene();e&&e.markAllMaterialsAsDirty(1)}readPixels(e=0,t=0,i=null,s=!0,r=!1,a=0,o=0,c=Number.MAX_VALUE,u=Number.MAX_VALUE){if(!this._texture)return null;const d=this._getEngine();if(!d)return null;const f=this.getSize();let g=f.width,m=f.height;t!==0&&(g=g/Math.pow(2,t),m=m/Math.pow(2,t),g=Math.round(g),m=Math.round(m)),c=Math.min(g,c),u=Math.min(m,u);try{return this._texture.isCube?d._readTexturePixels(this._texture,c,u,e,t,i,s,r,a,o):d._readTexturePixels(this._texture,c,u,-1,t,i,s,r,a,o)}catch{return null}}_readPixelsSync(e=0,t=0,i=null,s=!0,r=!1){if(!this._texture)return null;const a=this.getSize();let o=a.width,c=a.height;const u=this._getEngine();if(!u)return null;t!=0&&(o=o/Math.pow(2,t),c=c/Math.pow(2,t),o=Math.round(o),c=Math.round(c));try{return this._texture.isCube?u._readTexturePixelsSync(this._texture,o,c,e,t,i,s,r):u._readTexturePixelsSync(this._texture,o,c,-1,t,i,s,r)}catch{return null}}get _lodTextureHigh(){return this._texture?this._texture._lodTextureHigh:null}get _lodTextureMid(){return this._texture?this._texture._lodTextureMid:null}get _lodTextureLow(){return this._texture?this._texture._lodTextureLow:null}dispose(){if(this._scene){this._scene.stopAnimation&&this._scene.stopAnimation(this),this._scene.removePendingData(this);const e=this._scene.textures.indexOf(this);if(e>=0&&this._scene.textures.splice(e,1),this._scene.onTextureRemovedObservable.notifyObservers(this),this._scene=null,this._parentContainer){const t=this._parentContainer.textures.indexOf(this);t>-1&&this._parentContainer.textures.splice(t,1),this._parentContainer=null}}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.metadata=null,super.dispose()}serialize(e=!1){if(!this.name&&!e)return null;const t=$e.Serialize(this);return $e.AppendSerializedAnimations(this,t),t}static WhenAllReady(e,t){let i=e.length;if(i===0){t();return}for(let s=0;s<e.length;s++){const r=e[s];if(r.isReady())--i===0&&t();else{const a=r.onLoadObservable;a?a.addOnce(()=>{--i===0&&t()}):--i===0&&t()}}}static _IsScene(e){return e.getClassName()==="Scene"}}jt.DEFAULT_ANISOTROPIC_FILTERING_LEVEL=4;N([H()],jt.prototype,"uniqueId",void 0);N([H()],jt.prototype,"name",void 0);N([H()],jt.prototype,"displayName",void 0);N([H()],jt.prototype,"metadata",void 0);N([H("hasAlpha")],jt.prototype,"_hasAlpha",void 0);N([H("getAlphaFromRGB")],jt.prototype,"_getAlphaFromRGB",void 0);N([H()],jt.prototype,"level",void 0);N([H("coordinatesIndex")],jt.prototype,"_coordinatesIndex",void 0);N([H()],jt.prototype,"optimizeUVAllocation",void 0);N([H("coordinatesMode")],jt.prototype,"_coordinatesMode",void 0);N([H()],jt.prototype,"wrapU",null);N([H()],jt.prototype,"wrapV",null);N([H()],jt.prototype,"wrapR",void 0);N([H()],jt.prototype,"anisotropicFilteringLevel",void 0);N([H()],jt.prototype,"isCube",null);N([H()],jt.prototype,"is3D",null);N([H()],jt.prototype,"is2DArray",null);N([H()],jt.prototype,"gammaSpace",null);N([H()],jt.prototype,"invertZ",void 0);N([H()],jt.prototype,"lodLevelInAlpha",void 0);N([H()],jt.prototype,"lodGenerationOffset",null);N([H()],jt.prototype,"lodGenerationScale",null);N([H()],jt.prototype,"linearSpecularLOD",null);N([Lr()],jt.prototype,"irradianceTexture",null);N([H()],jt.prototype,"isRenderTarget",void 0);ot.prototype.createPrefilteredCubeTexture=function(n,e,t,i,s=null,r=null,a,o=null,c=!0){const u=async d=>{if(!d){s&&s(null);return}const f=d.texture;if(c?d.info.sphericalPolynomial&&(f._sphericalPolynomial=d.info.sphericalPolynomial):f._sphericalPolynomial=new sf,f._source=9,this.getCaps().textureLOD){s&&s(f);return}const g=3,m=this._gl,b=d.width;if(!b)return;const{DDSTools:x}=await _t(async()=>{const{DDSTools:E}=await import("./dds-By3LClNY.js");return{DDSTools:E}},__vite__mapDeps([1,2])),v=[];for(let E=0;E<g;E++){const D=1-E/(g-1),I=i,R=Math.log2(b)*t+i,C=I+(R-I)*D,M=Math.round(Math.min(Math.max(C,0),R)),F=new Cs(this,2);if(F.type=f.type,F.format=f.format,F.width=Math.pow(2,Math.max(Math.log2(b)-M,0)),F.height=F.width,F.isCube=!0,F._cachedWrapU=0,F._cachedWrapV=0,this._bindTextureDirectly(m.TEXTURE_CUBE_MAP,F,!0),F.samplingMode=2,m.texParameteri(m.TEXTURE_CUBE_MAP,m.TEXTURE_MAG_FILTER,m.LINEAR),m.texParameteri(m.TEXTURE_CUBE_MAP,m.TEXTURE_MIN_FILTER,m.LINEAR),m.texParameteri(m.TEXTURE_CUBE_MAP,m.TEXTURE_WRAP_S,m.CLAMP_TO_EDGE),m.texParameteri(m.TEXTURE_CUBE_MAP,m.TEXTURE_WRAP_T,m.CLAMP_TO_EDGE),d.isDDS){const k=d.info,q=d.data;this._unpackFlipY(k.isCompressed),x.UploadDDSLevels(this,F,q,k,!0,6,M)}else oe.Warn("DDS is the only prefiltered cube map supported so far.");this._bindTextureDirectly(m.TEXTURE_CUBE_MAP,null);const U=new jt(e);U._isCube=!0,U._texture=F,F.isReady=!0,v.push(U)}f._lodTextureHigh=v[2],f._lodTextureMid=v[1],f._lodTextureLow=v[0],s&&s(f)};return this.createCubeTexture(n,e,null,!1,u,r,a,o,c,t,i)};ot.prototype.createUniformBuffer=function(n,e){const t=this._gl.createBuffer();if(!t)throw new Error("Unable to create uniform buffer");const i=new Dh(t);return this.bindUniformBuffer(i),n instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,n,this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(n),this._gl.STATIC_DRAW),this.bindUniformBuffer(null),i.references=1,i};ot.prototype.createDynamicUniformBuffer=function(n,e){const t=this._gl.createBuffer();if(!t)throw new Error("Unable to create dynamic uniform buffer");const i=new Dh(t);return this.bindUniformBuffer(i),n instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,n,this._gl.DYNAMIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(n),this._gl.DYNAMIC_DRAW),this.bindUniformBuffer(null),i.references=1,i};ot.prototype.updateUniformBuffer=function(n,e,t,i){this.bindUniformBuffer(n),t===void 0&&(t=0),i===void 0?e instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,t,e):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,t,new Float32Array(e)):e instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,e.subarray(t,t+i)):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,new Float32Array(e).subarray(t,t+i)),this.bindUniformBuffer(null)};ot.prototype.bindUniformBuffer=function(n){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,n?n.underlyingResource:null)};ot.prototype.bindUniformBufferBase=function(n,e,t){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,e,n?n.underlyingResource:null)};ot.prototype.bindUniformBlock=function(n,e,t){const i=n.program,s=this._gl.getUniformBlockIndex(i,e);s!==4294967295&&this._gl.uniformBlockBinding(i,s,t)};Ce.prototype.displayLoadingUI=function(){if(!Gi())return;const n=this.loadingScreen;n&&n.displayLoadingUI()};Ce.prototype.hideLoadingUI=function(){if(!Gi())return;const n=this._loadingScreen;n&&n.hideLoadingUI()};Object.defineProperty(Ce.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&this._renderingCanvas&&(this._loadingScreen=Ce.DefaultLoadingScreenFactory(this._renderingCanvas)),this._loadingScreen},set:function(n){this._loadingScreen=n},enumerable:!0,configurable:!0});Object.defineProperty(Ce.prototype,"loadingUIText",{set:function(n){this.loadingScreen.loadingUIText=n},enumerable:!0,configurable:!0});Object.defineProperty(Ce.prototype,"loadingUIBackgroundColor",{set:function(n){this.loadingScreen.loadingUIBackgroundColor=n},enumerable:!0,configurable:!0});Ce.prototype.getInputElement=function(){return this._renderingCanvas};Ce.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas?this._renderingCanvas.getBoundingClientRect():null};Ce.prototype.getInputElementClientRect=function(){return this._renderingCanvas?this.getInputElement().getBoundingClientRect():null};Ce.prototype.getAspectRatio=function(n,e=!1){const t=n.viewport;return this.getRenderWidth(e)*t.width/(this.getRenderHeight(e)*t.height)};Ce.prototype.getScreenAspectRatio=function(){return this.getRenderWidth(!0)/this.getRenderHeight(!0)};Ce.prototype._verifyPointerLock=function(){this._onPointerLockChange?.()};Ce.prototype.setAlphaEquation=function(n,e=0){if(this._alphaEquation[e]!==n){switch(n){case 0:this._alphaState.setAlphaEquationParameters(32774,32774,e);break;case 1:this._alphaState.setAlphaEquationParameters(32778,32778,e);break;case 2:this._alphaState.setAlphaEquationParameters(32779,32779,e);break;case 3:this._alphaState.setAlphaEquationParameters(32776,32776,e);break;case 4:this._alphaState.setAlphaEquationParameters(32775,32775,e);break;case 5:this._alphaState.setAlphaEquationParameters(32775,32774,e);break}this._alphaEquation[e]=n}};Ce.prototype.getInputElement=function(){return this._renderingCanvas};Ce.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc};Ce.prototype.setDepthFunction=function(n){this._depthCullingState.depthFunc=n};Ce.prototype.setDepthFunctionToGreater=function(){this.setDepthFunction(516)};Ce.prototype.setDepthFunctionToGreaterOrEqual=function(){this.setDepthFunction(518)};Ce.prototype.setDepthFunctionToLess=function(){this.setDepthFunction(513)};Ce.prototype.setDepthFunctionToLessOrEqual=function(){this.setDepthFunction(515)};Ce.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask};Ce.prototype.setDepthWrite=function(n){this._depthCullingState.depthMask=n};Ce.prototype.setAlphaConstants=function(n,e,t,i){this._alphaState.setAlphaBlendConstants(n,e,t,i)};Ce.prototype.getAlphaMode=function(n=0){return this._alphaMode[n]};Ce.prototype.getAlphaEquation=function(n=0){return this._alphaEquation[n]};Ce.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest};Ce.prototype.setStencilBuffer=function(n){this._stencilState.stencilTest=n};Ce.prototype.getStencilMask=function(){return this._stencilState.stencilMask};Ce.prototype.setStencilMask=function(n){this._stencilState.stencilMask=n};Ce.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc};Ce.prototype.getStencilBackFunction=function(){return this._stencilState.stencilBackFunc};Ce.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef};Ce.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask};Ce.prototype.setStencilFunction=function(n){this._stencilState.stencilFunc=n};Ce.prototype.setStencilBackFunction=function(n){this._stencilState.stencilBackFunc=n};Ce.prototype.setStencilFunctionReference=function(n){this._stencilState.stencilFuncRef=n};Ce.prototype.setStencilFunctionMask=function(n){this._stencilState.stencilFuncMask=n};Ce.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail};Ce.prototype.getStencilBackOperationFail=function(){return this._stencilState.stencilBackOpStencilFail};Ce.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail};Ce.prototype.getStencilBackOperationDepthFail=function(){return this._stencilState.stencilBackOpDepthFail};Ce.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass};Ce.prototype.getStencilBackOperationPass=function(){return this._stencilState.stencilBackOpStencilDepthPass};Ce.prototype.setStencilOperationFail=function(n){this._stencilState.stencilOpStencilFail=n};Ce.prototype.setStencilBackOperationFail=function(n){this._stencilState.stencilBackOpStencilFail=n};Ce.prototype.setStencilOperationDepthFail=function(n){this._stencilState.stencilOpDepthFail=n};Ce.prototype.setStencilBackOperationDepthFail=function(n){this._stencilState.stencilBackOpDepthFail=n};Ce.prototype.setStencilOperationPass=function(n){this._stencilState.stencilOpStencilDepthPass=n};Ce.prototype.setStencilBackOperationPass=function(n){this._stencilState.stencilBackOpStencilDepthPass=n};Ce.prototype.cacheStencilState=function(){this._cachedStencilBuffer=this.getStencilBuffer(),this._cachedStencilFunction=this.getStencilFunction(),this._cachedStencilMask=this.getStencilMask(),this._cachedStencilOperationPass=this.getStencilOperationPass(),this._cachedStencilOperationFail=this.getStencilOperationFail(),this._cachedStencilOperationDepthFail=this.getStencilOperationDepthFail(),this._cachedStencilReference=this.getStencilFunctionReference()};Ce.prototype.restoreStencilState=function(){this.setStencilFunction(this._cachedStencilFunction),this.setStencilMask(this._cachedStencilMask),this.setStencilBuffer(this._cachedStencilBuffer),this.setStencilOperationPass(this._cachedStencilOperationPass),this.setStencilOperationFail(this._cachedStencilOperationFail),this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail),this.setStencilFunctionReference(this._cachedStencilReference)};Ce.prototype.getRenderPassNames=function(){return this._renderPassNames};Ce.prototype.getCurrentRenderPassName=function(){return this._renderPassNames[this.currentRenderPassId]};Ce.prototype.createRenderPassId=function(n){const e=++Ce._RenderPassIdCounter;return this._renderPassNames[e]=n??"NONAME",e};Ce.prototype.releaseRenderPassId=function(n){this._renderPassNames[n]=void 0;for(let e=0;e<this.scenes.length;++e){const t=this.scenes[e];for(let i=0;i<t.meshes.length;++i){const s=t.meshes[i];if(s.subMeshes)for(let r=0;r<s.subMeshes.length;++r)s.subMeshes[r]._removeDrawWrapper(n)}}};function fk(n){!n||!n.setAttribute||(n.setAttribute("touch-action","none"),n.style.touchAction="none",n.style.webkitTapHighlightColor="transparent")}function pk(n,e,t){n._onCanvasFocus=()=>{n.onCanvasFocusObservable.notifyObservers(n)},n._onCanvasBlur=()=>{n.onCanvasBlurObservable.notifyObservers(n)},n._onCanvasContextMenu=s=>{n.disableContextMenu&&s.preventDefault()},e.addEventListener("focus",n._onCanvasFocus),e.addEventListener("blur",n._onCanvasBlur),e.addEventListener("contextmenu",n._onCanvasContextMenu),n._onBlur=()=>{n.disablePerformanceMonitorInBackground&&n.performanceMonitor.disable(),n._windowIsBackground=!0},n._onFocus=()=>{n.disablePerformanceMonitorInBackground&&n.performanceMonitor.enable(),n._windowIsBackground=!1},n._onCanvasPointerOut=s=>{document.elementFromPoint(s.clientX,s.clientY)!==e&&n.onCanvasPointerOutObservable.notifyObservers(s)};const i=n.getHostWindow();i&&typeof i.addEventListener=="function"&&(i.addEventListener("blur",n._onBlur),i.addEventListener("focus",n._onFocus)),e.addEventListener("pointerout",n._onCanvasPointerOut),t.doNotHandleTouchAction||fk(e),!Ce.audioEngine&&t.audioEngine&&Ce.AudioEngineFactory&&(Ce.audioEngine=Ce.AudioEngineFactory(n.getRenderingCanvas(),n.getAudioContext(),n.getAudioDestination())),bh()&&(n._onFullscreenChange=()=>{n.isFullscreen=!!document.fullscreenElement,n.isFullscreen&&n._pointerLockRequested&&e&&AC(e)},document.addEventListener("fullscreenchange",n._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",n._onFullscreenChange,!1),n._onPointerLockChange=()=>{n.isPointerLock=document.pointerLockElement===e},document.addEventListener("pointerlockchange",n._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",n._onPointerLockChange,!1)),n.enableOfflineSupport=Ce.OfflineProviderFactory!==void 0,n._deterministicLockstep=!!t.deterministicLockstep,n._lockstepMaxSteps=t.lockstepMaxSteps||0,n._timeStep=t.timeStep||1/60}function _k(n,e){Ke.Instances.length===1&&Ce.audioEngine&&(Ce.audioEngine.dispose(),Ce.audioEngine=null);const t=n.getHostWindow();t&&typeof t.removeEventListener=="function"&&(t.removeEventListener("blur",n._onBlur),t.removeEventListener("focus",n._onFocus)),e&&(e.removeEventListener("focus",n._onCanvasFocus),e.removeEventListener("blur",n._onCanvasBlur),e.removeEventListener("pointerout",n._onCanvasPointerOut),e.removeEventListener("contextmenu",n._onCanvasContextMenu)),bh()&&(document.removeEventListener("fullscreenchange",n._onFullscreenChange),document.removeEventListener("mozfullscreenchange",n._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",n._onFullscreenChange),document.removeEventListener("msfullscreenchange",n._onFullscreenChange),document.removeEventListener("pointerlockchange",n._onPointerLockChange),document.removeEventListener("mspointerlockchange",n._onPointerLockChange),document.removeEventListener("mozpointerlockchange",n._onPointerLockChange),document.removeEventListener("webkitpointerlockchange",n._onPointerLockChange))}function gk(n){const e=document.createElement("span");e.textContent="Hg",e.style.font=n;const t=document.createElement("div");t.style.display="inline-block",t.style.width="1px",t.style.height="0px",t.style.verticalAlign="bottom";const i=document.createElement("div");i.style.whiteSpace="nowrap",i.appendChild(e),i.appendChild(t),document.body.appendChild(i);let s=0,r=0;try{r=t.getBoundingClientRect().top-e.getBoundingClientRect().top,t.style.verticalAlign="baseline",s=t.getBoundingClientRect().top-e.getBoundingClientRect().top}finally{document.body.removeChild(i)}return{ascent:s,height:r,descent:r-s}}async function mk(n,e,t){return await new Promise((i,s)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{n.createImageBitmap(r,t).then(a=>{i(a)})})},r.onerror=()=>{s(`Error loading image ${r.src}`)},r.src=e})}function bk(n,e,t,i){const r=n.createCanvas(t,i).getContext("2d");if(!r)throw new Error("Unable to get 2d context for resizeImageBitmap");return r.drawImage(e,0,0),r.getImageData(0,0,t,i).data}function yk(n){const e=n.requestFullscreen||n.webkitRequestFullscreen;e&&e.call(n)}function vk(){const n=document;document.exitFullscreen?document.exitFullscreen():n.webkitCancelFullScreen&&n.webkitCancelFullScreen()}function AC(n){if(n.requestPointerLock){const e=n.requestPointerLock();e instanceof Promise?e.then(()=>{n.focus()}).catch(()=>{}):n.focus()}}function xk(){document.exitPointerLock&&document.exitPointerLock()}class yn{get min(){return this._min}get max(){return this._max}get average(){return this._average}get lastSecAverage(){return this._lastSecAverage}get current(){return this._current}get total(){return this._totalAccumulated}get count(){return this._totalValueCount}constructor(){this._startMonitoringTime=0,this._min=0,this._max=0,this._average=0,this._lastSecAverage=0,this._current=0,this._totalValueCount=0,this._totalAccumulated=0,this._lastSecAccumulated=0,this._lastSecTime=0,this._lastSecValueCount=0}fetchNewFrame(){this._totalValueCount++,this._current=0,this._lastSecValueCount++}addCount(e,t){yn.Enabled&&(this._current+=e,t&&this._fetchResult())}beginMonitoring(){yn.Enabled&&(this._startMonitoringTime=nr.Now)}endMonitoring(e=!0){if(!yn.Enabled)return;e&&this.fetchNewFrame();const t=nr.Now;this._current=t-this._startMonitoringTime,e&&this._fetchResult()}endFrame(){this._fetchResult()}_fetchResult(){this._totalAccumulated+=this._current,this._lastSecAccumulated+=this._current,this._min=Math.min(this._min,this._current),this._max=Math.max(this._max,this._current),this._average=this._totalAccumulated/this._totalValueCount;const e=nr.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)}}yn.Enabled=!0;class Pe extends ot{static get NpmPackage(){return Ce.NpmPackage}static get Version(){return Ce.Version}static get Instances(){return Ke.Instances}static get LastCreatedEngine(){return Ke.LastCreatedEngine}static get LastCreatedScene(){return Ke.LastCreatedScene}static DefaultLoadingScreenFactory(e){return Ce.DefaultLoadingScreenFactory(e)}get _supportsHardwareTextureRescaling(){return!!Pe._RescalePostProcessFactory}_measureFps(){this._performanceMonitor.sampleFrame(),this._fps=this._performanceMonitor.averageFPS,this._deltaTime=this._performanceMonitor.instantaneousFrameTime||0}get performanceMonitor(){return this._performanceMonitor}constructor(e,t,i,s=!1){super(e,t,i,s),this.customAnimationFrameRequester=null,this._performanceMonitor=new GU,this._drawCalls=new yn,e&&(this._features.supportRenderPasses=!0,i=this._creationOptions)}_initGLContext(){super._initGLContext(),this._rescalePostProcess=null}_sharedInit(e){super._sharedInit(e),pk(this,e,this._creationOptions)}resizeImageBitmap(e,t,i){return bk(this,e,t,i)}async _createImageBitmapFromSource(e,t){return await mk(this,e,t)}switchFullscreen(e){this.isFullscreen?this.exitFullscreen():this.enterFullscreen(e)}enterFullscreen(e){this.isFullscreen||(this._pointerLockRequested=e,this._renderingCanvas&&yk(this._renderingCanvas))}exitFullscreen(){this.isFullscreen&&vk()}setDitheringState(e){e?this._gl.enable(this._gl.DITHER):this._gl.disable(this._gl.DITHER)}setRasterizerState(e){e?this._gl.disable(this._gl.RASTERIZER_DISCARD):this._gl.enable(this._gl.RASTERIZER_DISCARD)}setDirectViewport(e,t,i,s){const r=this._cachedViewport;return this._cachedViewport=null,this._viewport(e,t,i,s),r}scissorClear(e,t,i,s,r){this.enableScissor(e,t,i,s),this.clear(r,!0,!0,!0),this.disableScissor()}enableScissor(e,t,i,s){const r=this._gl;r.enable(r.SCISSOR_TEST),r.scissor(e,t,i,s)}disableScissor(){const e=this._gl;e.disable(e.SCISSOR_TEST)}async _loadFileAsync(e,t,i){return await new Promise((s,r)=>{this._loadFile(e,a=>{s(a)},void 0,t,i,(a,o)=>{r(o)})})}getVertexShaderSource(e){const t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[0]):null}getFragmentShaderSource(e){const t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[1]):null}set framebufferDimensionsObject(e){this._framebufferDimensionsObject=e,this._framebufferDimensionsObject&&this.onResizeObservable.notifyObservers(this)}_rebuildBuffers(){for(const e of this.scenes)e.resetCachedMaterial(),e._rebuildGeometries();for(const e of this._virtualScenes)e.resetCachedMaterial(),e._rebuildGeometries();super._rebuildBuffers()}getFontOffset(e){return gk(e)}_cancelFrame(){if(this.customAnimationFrameRequester){if(this._frameHandler!==0){this._frameHandler=0;const{cancelAnimationFrame:e}=this.customAnimationFrameRequester;e&&e(this.customAnimationFrameRequester.requestID)}}else super._cancelFrame()}_renderLoop(e){this._processFrame(e),this._activeRenderLoops.length>0&&this._frameHandler===0&&(this.customAnimationFrameRequester?(this.customAnimationFrameRequester.requestID=this._queueNewFrame(this.customAnimationFrameRequester.renderFunction||this._boundRenderFunction,this.customAnimationFrameRequester),this._frameHandler=this.customAnimationFrameRequester.requestID):this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()))}enterPointerlock(){this._renderingCanvas&&AC(this._renderingCanvas)}exitPointerlock(){xk()}beginFrame(){this._measureFps(),super.beginFrame()}_deletePipelineContext(e){const t=e;t&&t.program&&t.transformFeedback&&(this.deleteTransformFeedback(t.transformFeedback),t.transformFeedback=null),super._deletePipelineContext(e)}createShaderProgram(e,t,i,s,r,a=null){r=r||this._gl,this.onBeforeShaderCompilationObservable.notifyObservers(this);const o=super.createShaderProgram(e,t,i,s,r,a);return this.onAfterShaderCompilationObservable.notifyObservers(this),o}_createShaderProgram(e,t,i,s,r=null){const a=s.createProgram();if(e.program=a,!a)throw new Error("Unable to create program");if(s.attachShader(a,t),s.attachShader(a,i),this.webGLVersion>1&&r){const o=this.createTransformFeedback();this.bindTransformFeedback(o),this.setTranformFeedbackVaryings(a,r),e.transformFeedback=o}return s.linkProgram(a),this.webGLVersion>1&&r&&this.bindTransformFeedback(null),e.context=s,e.vertexShader=t,e.fragmentShader=i,e.isParallelCompiled||this._finalizePipelineContext(e),a}_releaseTexture(e){super._releaseTexture(e)}_releaseRenderTargetWrapper(e){super._releaseRenderTargetWrapper(e);for(const t of this.scenes){for(const i of t.postProcesses)i._outputTexture===e&&(i._outputTexture=null);for(const i of t.cameras)for(const s of i._postProcesses)s&&s._outputTexture===e&&(s._outputTexture=null)}}_rescaleTexture(e,t,i,s,r){this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,this._gl.LINEAR),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_WRAP_S,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE);const a=this.createRenderTargetTexture({width:t.width,height:t.height},{generateMipMaps:!1,type:0,samplingMode:2,generateDepthBuffer:!1,generateStencilBuffer:!1});if(!this._rescalePostProcess&&Pe._RescalePostProcessFactory&&(this._rescalePostProcess=Pe._RescalePostProcessFactory(this)),this._rescalePostProcess){this._rescalePostProcess.externalTextureSamplerBinding=!0;const o=()=>{this._rescalePostProcess.onApply=function(d){d._bindTexture("textureSampler",e)};let u=i;u||(u=this.scenes[this.scenes.length-1]),u.postProcessManager.directRender([this._rescalePostProcess],a,!0),this._bindTextureDirectly(this._gl.TEXTURE_2D,t,!0),this._gl.copyTexImage2D(this._gl.TEXTURE_2D,0,s,0,0,t.width,t.height,0),this.unBindFramebuffer(a),a.dispose(),r&&r()},c=this._rescalePostProcess.getEffect();c?c.executeWhenCompiled(o):this._rescalePostProcess.onEffectCreatedObservable.addOnce(u=>{u.executeWhenCompiled(o)})}}wrapWebGLTexture(e,t=!1,i=3,s=0,r=0){const a=new lC(e,this._gl),o=new Cs(this,0,!0);return o._hardwareTexture=a,o.baseWidth=s,o.baseHeight=r,o.width=s,o.height=r,o.isReady=!0,o.useMipMaps=t,this.updateTextureSamplingMode(i,o),o}_uploadImageToTexture(e,t,i=0,s=0){const r=this._gl,a=this._getWebGLTextureType(e.type),o=this._getInternalFormat(e.format),c=this._getRGBABufferInternalSizedFormat(e.type,o),u=e.isCube?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D;this._bindTextureDirectly(u,e,!0),this._unpackFlipY(e.invertY);let d=r.TEXTURE_2D;e.isCube&&(d=r.TEXTURE_CUBE_MAP_POSITIVE_X+i),r.texImage2D(d,s,c,o,a,t),this._bindTextureDirectly(u,null,!0)}updateTextureComparisonFunction(e,t){if(this.webGLVersion===1){oe.Error("WebGL 1 does not support texture comparison.");return}const i=this._gl;e.isCube?(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,e,!0),t===0?(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,515),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,t),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),t===0?(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,515),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),e._comparisonFunction=t}createInstancesBuffer(e){const t=this._gl.createBuffer();if(!t)throw new Error("Unable to create instance buffer");const i=new Dh(t);return i.capacity=e,this.bindArrayBuffer(i),this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),i.references=1,i}deleteInstancesBuffer(e){this._gl.deleteBuffer(e)}async _clientWaitAsync(e,t=0,i=10){const s=this._gl;return await new Promise((r,a)=>{wf(()=>{const o=s.clientWaitSync(e,t,0);if(o==s.WAIT_FAILED)throw new Error("clientWaitSync failed");return o!=s.TIMEOUT_EXPIRED},r,a,i)})}_readPixelsAsync(e,t,i,s,r,a,o){if(this._webGLVersion<2)throw new Error("_readPixelsAsync only work on WebGL2+");const c=this._gl,u=c.createBuffer();c.bindBuffer(c.PIXEL_PACK_BUFFER,u),c.bufferData(c.PIXEL_PACK_BUFFER,o.byteLength,c.STREAM_READ),c.readPixels(e,t,i,s,r,a,0),c.bindBuffer(c.PIXEL_PACK_BUFFER,null);const d=c.fenceSync(c.SYNC_GPU_COMMANDS_COMPLETE,0);return d?(c.flush(),this._clientWaitAsync(d,0,10).then(()=>(c.deleteSync(d),c.bindBuffer(c.PIXEL_PACK_BUFFER,u),c.getBufferSubData(c.PIXEL_PACK_BUFFER,0,o),c.bindBuffer(c.PIXEL_PACK_BUFFER,null),c.deleteBuffer(u),o))):null}dispose(){this.hideLoadingUI(),this._rescalePostProcess&&this._rescalePostProcess.dispose(),_k(this,this._renderingCanvas),super.dispose()}}Pe.ALPHA_DISABLE=0;Pe.ALPHA_ADD=1;Pe.ALPHA_COMBINE=2;Pe.ALPHA_SUBTRACT=3;Pe.ALPHA_MULTIPLY=4;Pe.ALPHA_MAXIMIZED=5;Pe.ALPHA_ONEONE=6;Pe.ALPHA_PREMULTIPLIED=7;Pe.ALPHA_PREMULTIPLIED_PORTERDUFF=8;Pe.ALPHA_INTERPOLATE=9;Pe.ALPHA_SCREENMODE=10;Pe.DELAYLOADSTATE_NONE=0;Pe.DELAYLOADSTATE_LOADED=1;Pe.DELAYLOADSTATE_LOADING=2;Pe.DELAYLOADSTATE_NOTLOADED=4;Pe.NEVER=512;Pe.ALWAYS=519;Pe.LESS=513;Pe.EQUAL=514;Pe.LEQUAL=515;Pe.GREATER=516;Pe.GEQUAL=518;Pe.NOTEQUAL=517;Pe.KEEP=7680;Pe.REPLACE=7681;Pe.INCR=7682;Pe.DECR=7683;Pe.INVERT=5386;Pe.INCR_WRAP=34055;Pe.DECR_WRAP=34056;Pe.TEXTURE_CLAMP_ADDRESSMODE=0;Pe.TEXTURE_WRAP_ADDRESSMODE=1;Pe.TEXTURE_MIRROR_ADDRESSMODE=2;Pe.TEXTUREFORMAT_ALPHA=0;Pe.TEXTUREFORMAT_LUMINANCE=1;Pe.TEXTUREFORMAT_LUMINANCE_ALPHA=2;Pe.TEXTUREFORMAT_RGB=4;Pe.TEXTUREFORMAT_RGBA=5;Pe.TEXTUREFORMAT_RED=6;Pe.TEXTUREFORMAT_R=6;Pe.TEXTUREFORMAT_R16_UNORM=33322;Pe.TEXTUREFORMAT_RG16_UNORM=33324;Pe.TEXTUREFORMAT_RGB16_UNORM=32852;Pe.TEXTUREFORMAT_RGBA16_UNORM=32859;Pe.TEXTUREFORMAT_R16_SNORM=36760;Pe.TEXTUREFORMAT_RG16_SNORM=36761;Pe.TEXTUREFORMAT_RGB16_SNORM=36762;Pe.TEXTUREFORMAT_RGBA16_SNORM=36763;Pe.TEXTUREFORMAT_RG=7;Pe.TEXTUREFORMAT_RED_INTEGER=8;Pe.TEXTUREFORMAT_R_INTEGER=8;Pe.TEXTUREFORMAT_RG_INTEGER=9;Pe.TEXTUREFORMAT_RGB_INTEGER=10;Pe.TEXTUREFORMAT_RGBA_INTEGER=11;Pe.TEXTURETYPE_UNSIGNED_BYTE=0;Pe.TEXTURETYPE_UNSIGNED_INT=0;Pe.TEXTURETYPE_FLOAT=1;Pe.TEXTURETYPE_HALF_FLOAT=2;Pe.TEXTURETYPE_BYTE=3;Pe.TEXTURETYPE_SHORT=4;Pe.TEXTURETYPE_UNSIGNED_SHORT=5;Pe.TEXTURETYPE_INT=6;Pe.TEXTURETYPE_UNSIGNED_INTEGER=7;Pe.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8;Pe.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9;Pe.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10;Pe.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11;Pe.TEXTURETYPE_UNSIGNED_INT_24_8=12;Pe.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13;Pe.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14;Pe.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15;Pe.TEXTURE_NEAREST_SAMPLINGMODE=1;Pe.TEXTURE_BILINEAR_SAMPLINGMODE=2;Pe.TEXTURE_TRILINEAR_SAMPLINGMODE=3;Pe.TEXTURE_NEAREST_NEAREST_MIPLINEAR=8;Pe.TEXTURE_LINEAR_LINEAR_MIPNEAREST=11;Pe.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3;Pe.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4;Pe.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5;Pe.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6;Pe.TEXTURE_NEAREST_LINEAR=7;Pe.TEXTURE_NEAREST_NEAREST=1;Pe.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9;Pe.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10;Pe.TEXTURE_LINEAR_LINEAR=2;Pe.TEXTURE_LINEAR_NEAREST=12;Pe.TEXTURE_EXPLICIT_MODE=0;Pe.TEXTURE_SPHERICAL_MODE=1;Pe.TEXTURE_PLANAR_MODE=2;Pe.TEXTURE_CUBIC_MODE=3;Pe.TEXTURE_PROJECTION_MODE=4;Pe.TEXTURE_SKYBOX_MODE=5;Pe.TEXTURE_INVCUBIC_MODE=6;Pe.TEXTURE_EQUIRECTANGULAR_MODE=7;Pe.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8;Pe.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9;Pe.SCALEMODE_FLOOR=1;Pe.SCALEMODE_NEAREST=2;Pe.SCALEMODE_CEILING=3;class Sk{constructor(){this._doNotSerialize=!1,this._isDisposed=!1,this._sceneRootNodesIndex=-1,this._isEnabled=!0,this._isParentEnabled=!0,this._isReady=!0,this._onEnabledStateChangedObservable=new le,this._onClonedObservable=new le,this._inheritVisibility=!1,this._isVisible=!0}}let yi=class Om{static AddNodeConstructor(e,t){this._NodeConstructors[e]=t}static Construct(e,t,i,s){const r=this._NodeConstructors[e];return r?r(t,i,s):null}set accessibilityTag(e){this._accessibilityTag=e,this.onAccessibilityTagChangedObservable.notifyObservers(e)}get accessibilityTag(){return this._accessibilityTag}get doNotSerialize(){return this._nodeDataStorage._doNotSerialize?!0:this._parentNode?this._parentNode.doNotSerialize:!1}set doNotSerialize(e){this._nodeDataStorage._doNotSerialize=e}isDisposed(){return this._nodeDataStorage._isDisposed}set parent(e){if(this._parentNode===e)return;const t=this._parentNode;if(this._parentNode&&this._parentNode._children!==void 0&&this._parentNode._children!==null){const i=this._parentNode._children.indexOf(this);i!==-1&&this._parentNode._children.splice(i,1),!e&&!this._nodeDataStorage._isDisposed&&this._addToSceneRootNodes()}this._parentNode=e,this._isDirty=!0,this._parentNode&&((this._parentNode._children===void 0||this._parentNode._children===null)&&(this._parentNode._children=new Array),this._parentNode._children.push(this),t||this._removeFromSceneRootNodes()),this._syncParentEnabledState()}get parent(){return this._parentNode}get inheritVisibility(){return this._nodeDataStorage._inheritVisibility}set inheritVisibility(e){this._nodeDataStorage._inheritVisibility=e}get isVisible(){return this.inheritVisibility&&this._parentNode&&!this._parentNode.isVisible?!1:this._nodeDataStorage._isVisible}set isVisible(e){this._nodeDataStorage._isVisible=e}_serializeAsParent(e){e.parentId=this.uniqueId}_addToSceneRootNodes(){this._nodeDataStorage._sceneRootNodesIndex===-1&&(this._nodeDataStorage._sceneRootNodesIndex=this._scene.rootNodes.length,this._scene.rootNodes.push(this))}_removeFromSceneRootNodes(){if(this._nodeDataStorage._sceneRootNodesIndex!==-1){const e=this._scene.rootNodes,t=e.length-1;e[this._nodeDataStorage._sceneRootNodesIndex]=e[t],e[this._nodeDataStorage._sceneRootNodesIndex]._nodeDataStorage._sceneRootNodesIndex=this._nodeDataStorage._sceneRootNodesIndex,this._scene.rootNodes.pop(),this._nodeDataStorage._sceneRootNodesIndex=-1}}get animationPropertiesOverride(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride}set animationPropertiesOverride(e){this._animationPropertiesOverride=e}getClassName(){return"Node"}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}get onEnabledStateChangedObservable(){return this._nodeDataStorage._onEnabledStateChangedObservable}get onClonedObservable(){return this._nodeDataStorage._onClonedObservable}constructor(e,t=null,i=!0){this._isDirty=!1,this._nodeDataStorage=new Sk,this.state="",this.metadata=null,this.reservedDataStore=null,this._accessibilityTag=null,this.onAccessibilityTagChangedObservable=new le,this._parentContainer=null,this.animations=[],this._ranges={},this.onReady=null,this._currentRenderId=-1,this._parentUpdateId=-1,this._childUpdateId=-1,this._waitingParentId=null,this._waitingParentInstanceIndex=null,this._waitingParsedUniqueId=null,this._cache={},this._parentNode=null,this._children=null,this._worldMatrix=W.Identity(),this._worldMatrixDeterminant=0,this._worldMatrixDeterminantIsDirty=!0,this._animationPropertiesOverride=null,this._isNode=!0,this.onDisposeObservable=new le,this._onDisposeObserver=null,this._behaviors=new Array,this.name=e,this.id=e,this._scene=t||Ke.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._initCache(),i&&this._addToSceneRootNodes()}getScene(){return this._scene}getEngine(){return this._scene.getEngine()}addBehavior(e,t=!1){return this._behaviors.indexOf(e)!==-1?this:(e.init(),this._scene.isLoading&&!t?this._scene.onDataLoadedObservable.addOnce(()=>{this._behaviors.includes(e)&&e.attach(this)}):e.attach(this),this._behaviors.push(e),this)}removeBehavior(e){const t=this._behaviors.indexOf(e);return t===-1?this:(this._behaviors[t].detach(),this._behaviors.splice(t,1),this)}get behaviors(){return this._behaviors}getBehaviorByName(e){for(const t of this._behaviors)if(t.name===e)return t;return null}getWorldMatrix(){return this._currentRenderId!==this._scene.getRenderId()&&this.computeWorldMatrix(),this._worldMatrix}_getWorldMatrixDeterminant(){return this._worldMatrixDeterminantIsDirty&&(this._worldMatrixDeterminantIsDirty=!1,this._worldMatrixDeterminant=this._worldMatrix.determinant()),this._worldMatrixDeterminant}get worldMatrixFromCache(){return this._worldMatrix}_initCache(){this._cache={}}updateCache(e){!e&&this.isSynchronized()||this._updateCache()}_getActionManagerForTrigger(e,t=!0){return this.parent?this.parent._getActionManagerForTrigger(e,!1):null}_updateCache(e){}_isSynchronized(){return!0}_markSyncedWithParent(){this._parentNode&&(this._parentUpdateId=this._parentNode._childUpdateId)}isSynchronizedWithParent(){return this._parentNode?this._parentNode._isDirty||this._parentUpdateId!==this._parentNode._childUpdateId?!1:this._parentNode.isSynchronized():!0}isSynchronized(){return this._parentNode&&!this.isSynchronizedWithParent()?!1:this._isSynchronized()}isReady(e=!1){return this._nodeDataStorage._isReady}markAsDirty(e){return this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0,this}isEnabled(e=!0){return e===!1?this._nodeDataStorage._isEnabled:this._nodeDataStorage._isEnabled?this._nodeDataStorage._isParentEnabled:!1}_syncParentEnabledState(){if(this._nodeDataStorage._isParentEnabled=this._parentNode?this._parentNode.isEnabled():!0,this._children)for(const e of this._children)e._syncParentEnabledState()}setEnabled(e){this._nodeDataStorage._isEnabled!==e&&(this._nodeDataStorage._isEnabled=e,this._syncParentEnabledState(),this._nodeDataStorage._onEnabledStateChangedObservable.notifyObservers(e))}isDescendantOf(e){return this.parent?this.parent===e?!0:this.parent.isDescendantOf(e):!1}_getDescendants(e,t=!1,i){if(this._children)for(let s=0;s<this._children.length;s++){const r=this._children[s];(!i||i(r))&&e.push(r),t||r._getDescendants(e,!1,i)}}getDescendants(e,t){const i=[];return this._getDescendants(i,e,t),i}getChildMeshes(e,t){const i=[];return this._getDescendants(i,e,s=>(!t||t(s))&&s.cullingStrategy!==void 0),i}getChildren(e,t=!0){return this.getDescendants(t,e)}_setReady(e){if(e!==this._nodeDataStorage._isReady){if(!e){this._nodeDataStorage._isReady=!1;return}this.onReady&&this.onReady(this),this._nodeDataStorage._isReady=!0}}getAnimationByName(e){for(let t=0;t<this.animations.length;t++){const i=this.animations[t];if(i.name===e)return i}return null}createAnimationRange(e,t,i){if(!this._ranges[e]){this._ranges[e]=Om._AnimationRangeFactory(e,t,i);for(let s=0,r=this.animations.length;s<r;s++)this.animations[s]&&this.animations[s].createRange(e,t,i)}}deleteAnimationRange(e,t=!0){for(let i=0,s=this.animations.length;i<s;i++)this.animations[i]&&this.animations[i].deleteRange(e,t);this._ranges[e]=null}getAnimationRange(e){return this._ranges[e]||null}clone(e,t,i){const s=$e.Clone(()=>new Om(e,this.getScene()),this);if(t&&(s.parent=t),!i){const r=this.getDescendants(!0);for(let a=0;a<r.length;a++){const o=r[a];o.clone(e+"."+o.name,s)}}return s}getAnimationRanges(){const e=[];let t;for(t in this._ranges)e.push(this._ranges[t]);return e}beginAnimation(e,t,i,s){const r=this.getAnimationRange(e);return r?this._scene.beginAnimation(this,r.from,r.to,t,i,s):null}serializeAnimationRanges(){const e=[];for(const t in this._ranges){const i=this._ranges[t];if(!i)continue;const s={};s.name=t,s.from=i.from,s.to=i.to,e.push(s)}return e}computeWorldMatrix(e){return this._worldMatrix||(this._worldMatrix=W.Identity()),this._worldMatrix}dispose(e,t=!1){if(this._nodeDataStorage._isDisposed=!0,!e){const i=this.getDescendants(!0);for(const s of i)s.dispose(e,t)}this.parent?this.parent=null:this._removeFromSceneRootNodes(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onEnabledStateChangedObservable.clear(),this.onClonedObservable.clear();for(const i of this._behaviors)i.detach();this._behaviors.length=0,this.metadata=null}static ParseAnimationRanges(e,t,i){if(t.ranges)for(let s=0;s<t.ranges.length;s++){const r=t.ranges[s];e.createAnimationRange(r.name,r.from,r.to)}}getHierarchyBoundingVectors(e=!0,t=null){this.getScene().incrementRenderId(),this.computeWorldMatrix(!0);let i,s;const r=this;if(r.getBoundingInfo&&r.subMeshes){const a=r.getBoundingInfo();i=a.boundingBox.minimumWorld.clone(),s=a.boundingBox.maximumWorld.clone()}else i=new T(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),s=new T(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);if(e){const a=this.getDescendants(!1);for(const o of a){const c=o;if(c.computeWorldMatrix(!0),t&&!t(c)||!c.getBoundingInfo||c.getTotalVertices()===0)continue;const d=c.getBoundingInfo().boundingBox,f=d.minimumWorld,g=d.maximumWorld;T.CheckExtends(f,i,s),T.CheckExtends(g,i,s)}}return{min:i,max:s}}};yi._AnimationRangeFactory=(n,e,t)=>{throw We("AnimationRange")};yi._NodeConstructors={};N([H()],yi.prototype,"name",void 0);N([H()],yi.prototype,"id",void 0);N([H()],yi.prototype,"uniqueId",void 0);N([H()],yi.prototype,"state",void 0);N([H()],yi.prototype,"metadata",void 0);const fT=(n,e,t)=>!n||n.getClassName&&n.getClassName()==="Mesh"?null:n.getClassName&&(n.getClassName()==="SubMesh"||n.getClassName()==="PhysicsBody")?n.clone(e):n.clone?n.clone():Array.isArray(n)?n.slice():t&&typeof n=="object"?{...n}:null;function Tk(n){const e=[];do{const t=Object.getOwnPropertyNames(n);for(const i of t)e.indexOf(i)===-1&&e.push(i)}while(n=Object.getPrototypeOf(n));return e}class Db{static DeepCopy(e,t,i,s,r=!1){const a=Tk(e);for(const o of a){if(o[0]==="_"&&(!s||s.indexOf(o)===-1)||o.endsWith("Observable")||i&&i.indexOf(o)!==-1)continue;const c=e[o],u=typeof c;if(u!=="function")try{if(u==="object")if(c instanceof Uint8Array)t[o]=Uint8Array.from(c);else if(c instanceof Array){if(t[o]=[],c.length>0)if(typeof c[0]=="object")for(let d=0;d<c.length;d++){const f=fT(c[d],t,r);t[o].indexOf(f)===-1&&t[o].push(f)}else t[o]=c.slice(0)}else t[o]=fT(c,t,r);else t[o]=c}catch(d){oe.Warn(d.message)}}}}class vh{static Instantiate(e){if(this.RegisteredExternalClasses&&this.RegisteredExternalClasses[e])return this.RegisteredExternalClasses[e];const t=Kr(e);if(t)return t;oe.Warn(e+" not found, you may have missed an import.");const i=e.split(".");let s=window||this;for(let r=0,a=i.length;r<a;r++)s=s[i[r]];return typeof s!="function"?null:s}}vh.RegisteredExternalClasses={};class pe{static get BaseUrl(){return ri.BaseUrl}static set BaseUrl(e){ri.BaseUrl=e}static get CleanUrl(){return ri.CleanUrl}static set CleanUrl(e){ri.CleanUrl=e}static IsAbsoluteUrl(e){return e.indexOf("//")===0?!0:e.indexOf("://")===-1||e.indexOf(".")===-1||e.indexOf("/")===-1||e.indexOf(":")>e.indexOf("/")?!1:e.indexOf("://")<e.indexOf(".")||e.indexOf("data:")===0||e.indexOf("blob:")===0}static set ScriptBaseUrl(e){ri.ScriptBaseUrl=e}static get ScriptBaseUrl(){return ri.ScriptBaseUrl}static set CDNBaseUrl(e){pe.ScriptBaseUrl=e,pe.AssetBaseUrl=e}static set ScriptPreprocessUrl(e){ri.ScriptPreprocessUrl=e}static get ScriptPreprocessUrl(){return ri.ScriptPreprocessUrl}static get DefaultRetryStrategy(){return ri.DefaultRetryStrategy}static set DefaultRetryStrategy(e){ri.DefaultRetryStrategy=e}static get CorsBehavior(){return ri.CorsBehavior}static set CorsBehavior(e){ri.CorsBehavior=e}static get UseFallbackTexture(){return Ke.UseFallbackTexture}static set UseFallbackTexture(e){Ke.UseFallbackTexture=e}static get RegisteredExternalClasses(){return vh.RegisteredExternalClasses}static set RegisteredExternalClasses(e){vh.RegisteredExternalClasses=e}static get fallbackTexture(){return Ke.FallbackTexture}static set fallbackTexture(e){Ke.FallbackTexture=e}static FetchToRef(e,t,i,s,r,a){const o=Math.abs(e)*i%i|0,c=Math.abs(t)*s%s|0,u=(o+c*i)*4;a.r=r[u]/255,a.g=r[u+1]/255,a.b=r[u+2]/255,a.a=r[u+3]/255}static Mix(e,t,i){return 0}static Instantiate(e){return vh.Instantiate(e)}static SetImmediate(e){zo.SetImmediate(e)}static IsExponentOfTwo(e){return!0}static FloatRound(e){return Math.fround(e)}static GetFilename(e){const t=e.lastIndexOf("/");return t<0?e:e.substring(t+1)}static GetFolderPath(e,t=!1){const i=e.lastIndexOf("/");return i<0?t?e:"":e.substring(0,i+1)}static ToDegrees(e){return e*180/Math.PI}static ToRadians(e){return e*Math.PI/180}static SmoothAngleChange(e,t,i=.9){const s=this.ToRadians(e),r=this.ToRadians(t);return this.ToDegrees(Math.atan2((1-i)*Math.sin(r)+i*Math.sin(s),(1-i)*Math.cos(r)+i*Math.cos(s)))}static MakeArray(e,t){return t!==!0&&(e===void 0||e==null)?null:Array.isArray(e)?e:[e]}static GetPointerPrefix(e){return Gi()&&!window.PointerEvent?"mouse":"pointer"}static SetCorsBehavior(e,t){Ab(e,t)}static SetReferrerPolicyBehavior(e,t){t.referrerPolicy=e}static get PreprocessUrl(){return ri.PreprocessUrl}static set PreprocessUrl(e){ri.PreprocessUrl=e}static LoadImage(e,t,i,s,r,a){return Rb(e,t,i,s,r,a)}static LoadFile(e,t,i,s,r,a){return eo(e,t,i,s,r,a)}static async LoadFileAsync(e,t=!0){return await new Promise((i,s)=>{eo(e,r=>{i(r)},void 0,void 0,t,(r,a)=>{s(a)})})}static GetAssetUrl(e){if(!e)return"";if(pe.AssetBaseUrl&&e.startsWith(pe._DefaultAssetsUrl)){const t=pe.AssetBaseUrl[pe.AssetBaseUrl.length-1]==="/"?pe.AssetBaseUrl.substring(0,pe.AssetBaseUrl.length-1):pe.AssetBaseUrl;return e.replace(pe._DefaultAssetsUrl,t)}return e}static GetBabylonScriptURL(e,t){if(!e)return"";if(pe.ScriptBaseUrl&&e.startsWith(pe._DefaultCdnUrl)){const i=pe.ScriptBaseUrl[pe.ScriptBaseUrl.length-1]==="/"?pe.ScriptBaseUrl.substring(0,pe.ScriptBaseUrl.length-1):pe.ScriptBaseUrl;e=e.replace(pe._DefaultCdnUrl,i)}return e=pe.ScriptPreprocessUrl(e),t&&!pe.IsAbsoluteUrl(e)&&(e=pe.GetAbsoluteUrl(e)),e}static LoadBabylonScript(e,t,i,s){e=pe.GetBabylonScriptURL(e),pe.LoadScript(e,t,i)}static async LoadBabylonScriptAsync(e){return e=pe.GetBabylonScriptURL(e),await pe.LoadScriptAsync(e)}static LoadScript(e,t,i,s,r=!1){if(typeof importScripts=="function"){try{importScripts(e),t&&t()}catch(c){i?.(`Unable to load script '${e}' in worker`,c)}return}else if(!Gi()){i?.(`Cannot load script '${e}' outside of a window or a worker`);return}const a=document.getElementsByTagName("head")[0],o=document.createElement("script");r?(o.setAttribute("type","module"),o.innerText=e):(o.setAttribute("type","text/javascript"),o.setAttribute("src",e)),s&&(o.id=s),o.onload=()=>{t&&t()},o.onerror=c=>{i&&i(`Unable to load script '${e}'`,c)},a.appendChild(o)}static async LoadScriptAsync(e,t){return await new Promise((i,s)=>{this.LoadScript(e,()=>{i()},(r,a)=>{s(a||new Error(r))},t)})}static ReadFileAsDataURL(e,t,i){const s=new FileReader,r={onCompleteObservable:new le,abort:()=>s.abort()};return s.onloadend=()=>{r.onCompleteObservable.notifyObservers(r)},s.onload=a=>{t(a.target.result)},s.onprogress=i,s.readAsDataURL(e),r}static ReadFile(e,t,i,s,r){return Lh(e,t,i,s,r)}static FileAsURL(e){const t=new Blob([e]);return window.URL.createObjectURL(t)}static Format(e,t=2){return e.toFixed(t)}static DeepCopy(e,t,i,s){Db.DeepCopy(e,t,i,s)}static IsEmpty(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}static RegisterTopRootEvents(e,t){for(let i=0;i<t.length;i++){const s=t[i];e.addEventListener(s.name,s.handler,!1);try{window.parent&&window.parent.addEventListener(s.name,s.handler,!1)}catch{}}}static UnregisterTopRootEvents(e,t){for(let i=0;i<t.length;i++){const s=t[i];e.removeEventListener(s.name,s.handler);try{e.parent&&e.parent.removeEventListener(s.name,s.handler)}catch{}}}static async DumpFramebuffer(e,t,i,s,r="image/png",a,o){throw We("DumpTools")}static DumpData(e,t,i,s,r="image/png",a,o=!1,c=!1,u){throw We("DumpTools")}static async DumpDataAsync(e,t,i,s="image/png",r,a=!1,o=!1,c){throw We("DumpTools")}static _IsOffScreenCanvas(e){return e.convertToBlob!==void 0}static ToBlob(e,t,i="image/png",s){!pe._IsOffScreenCanvas(e)&&!e.toBlob&&(e.toBlob=function(r,a,o){setTimeout(()=>{const c=atob(this.toDataURL(a,o).split(",")[1]),u=c.length,d=new Uint8Array(u);for(let f=0;f<u;f++)d[f]=c.charCodeAt(f);r(new Blob([d]))})}),pe._IsOffScreenCanvas(e)?e.convertToBlob({type:i,quality:s}).then(r=>t(r)):e.toBlob(function(r){t(r)},i,s)}static DownloadBlob(e,t){if("download"in document.createElement("a")){if(!t){const i=new Date;t="screenshot_"+((i.getFullYear()+"-"+(i.getMonth()+1)).slice(2)+"-"+i.getDate()+"_"+i.getHours()+"-"+("0"+i.getMinutes()).slice(-2))+".png"}pe.Download(e,t)}else if(e&&typeof URL<"u"){const i=URL.createObjectURL(e),s=window.open("");if(!s)return;const r=s.document.createElement("img");r.onload=function(){URL.revokeObjectURL(i)},r.src=i,s.document.body.appendChild(r)}}static EncodeScreenshotCanvasData(e,t,i="image/png",s,r){if(typeof s=="string"||!t)this.ToBlob(e,function(a){a&&pe.DownloadBlob(a,s),t&&t("")},i,r);else if(t){if(pe._IsOffScreenCanvas(e)){e.convertToBlob({type:i,quality:r}).then(o=>{const c=new FileReader;c.readAsDataURL(o),c.onloadend=()=>{const u=c.result;t(u)}});return}const a=e.toDataURL(i,r);t(a)}}static Download(e,t){if(typeof URL>"u")return;const i=window.URL.createObjectURL(e),s=document.createElement("a");document.body.appendChild(s),s.style.display="none",s.href=i,s.download=t,s.addEventListener("click",()=>{s.parentElement&&s.parentElement.removeChild(s)}),s.click(),window.URL.revokeObjectURL(i)}static BackCompatCameraNoPreventDefault(e){return typeof e[0]=="boolean"?e[0]:typeof e[1]=="boolean"?e[1]:!1}static CreateScreenshot(e,t,i,s,r="image/png",a=!1,o){throw We("ScreenshotTools")}static async CreateScreenshotAsync(e,t,i,s="image/png",r){throw We("ScreenshotTools")}static CreateScreenshotUsingRenderTarget(e,t,i,s,r="image/png",a=1,o=!1,c,u=!1,d=!1,f=!0,g,m){throw We("ScreenshotTools")}static async CreateScreenshotUsingRenderTargetAsync(e,t,i,s="image/png",r=1,a=!1,o,c=!1,u=!1,d=!0,f,g){throw We("ScreenshotTools")}static RandomId(){return Tb()}static IsBase64(e){return Cb(e)}static DecodeBase64(e){return Ib(e)}static get errorsCount(){return oe.errorsCount}static Log(e){oe.Log(e)}static Warn(e){oe.Warn(e)}static Error(e){oe.Error(e)}static get LogCache(){return oe.LogCache}static ClearLogCache(){oe.ClearLogCache()}static set LogLevels(e){oe.LogLevels=e}static set PerformanceLogLevel(e){if((e&pe.PerformanceUserMarkLogLevel)===pe.PerformanceUserMarkLogLevel){_native?.enablePerformanceLogging?(_native.enablePerformanceLogging(1),pe.StartPerformanceCounter=pe._StartMarkNative,pe.EndPerformanceCounter=pe._EndMarkNative):(pe.StartPerformanceCounter=pe._StartUserMark,pe.EndPerformanceCounter=pe._EndUserMark);return}if((e&pe.PerformanceConsoleLogLevel)===pe.PerformanceConsoleLogLevel){_native?.enablePerformanceLogging?(_native.enablePerformanceLogging(2),pe.StartPerformanceCounter=pe._StartMarkNative,pe.EndPerformanceCounter=pe._EndMarkNative):(pe.StartPerformanceCounter=pe._StartPerformanceConsole,pe.EndPerformanceCounter=pe._EndPerformanceConsole);return}pe.StartPerformanceCounter=pe._StartPerformanceCounterDisabled,pe.EndPerformanceCounter=pe._EndPerformanceCounterDisabled,_native?.disablePerformanceLogging?.()}static _StartPerformanceCounterDisabled(e,t){}static _EndPerformanceCounterDisabled(e,t){}static _StartUserMark(e,t=!0){if(!pe._Performance){if(!Gi())return;pe._Performance=window.performance}!t||!pe._Performance.mark||pe._Performance.mark(e+"-Begin")}static _EndUserMark(e,t=!0){!t||!pe._Performance.mark||(pe._Performance.mark(e+"-End"),pe._Performance.measure(e,e+"-Begin",e+"-End"))}static _StartPerformanceConsole(e,t=!0){t&&(pe._StartUserMark(e,t),console.time&&console.time(e))}static _EndPerformanceConsole(e,t=!0){t&&(pe._EndUserMark(e,t),console.timeEnd(e))}static _StartMarkNative(e,t=!0){if(t&&_native?.startPerformanceCounter)if(pe._NativePerformanceCounterHandles.has(e))pe.Warn(`Performance counter with name ${e} is already started.`);else{const i=_native.startPerformanceCounter(e);pe._NativePerformanceCounterHandles.set(e,i)}}static _EndMarkNative(e,t=!0){if(t&&_native?.endPerformanceCounter){const i=pe._NativePerformanceCounterHandles.get(e);i?(_native.endPerformanceCounter(i),pe._NativePerformanceCounterHandles.delete(e)):pe.Warn(`Performance counter with name ${e} was not started.`)}}static get Now(){return nr.Now}static GetClassName(e,t=!1){let i=null;return!t&&e.getClassName?i=e.getClassName():(e instanceof Object&&(i=(t?e:Object.getPrototypeOf(e)).constructor.__bjsclassName__),i||(i=typeof e)),i}static First(e,t){for(const i of e)if(t(i))return i;return null}static getFullClassName(e,t=!1){let i=null,s=null;if(!t&&e.getClassName)i=e.getClassName();else{if(e instanceof Object){const r=t?e:Object.getPrototypeOf(e);i=r.constructor.__bjsclassName__,s=r.constructor.__bjsmoduleName__}i||(i=typeof e)}return i?(s!=null?s+".":"")+i:null}static async DelayAsync(e){await new Promise(t=>{setTimeout(()=>{t()},e)})}static IsSafari(){return Xl()?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}}pe.AssetBaseUrl="";pe.UseCustomRequestHeaders=!1;pe.CustomRequestHeaders=Ai.CustomRequestHeaders;pe.GetDOMTextContent=KM;pe._DefaultCdnUrl="https://cdn.babylonjs.com";pe._DefaultAssetsUrl="https://assets.babylonjs.com/core";pe.GetAbsoluteUrl=typeof document=="object"?n=>{const e=document.createElement("a");return e.href=n,e.href}:typeof URL=="function"&&typeof location=="object"?n=>new URL(n,location.origin).href:()=>{throw new Error("Unable to get absolute URL. Override BABYLON.Tools.GetAbsoluteUrl to a custom implementation for the current context.")};pe.NoneLogLevel=oe.NoneLogLevel;pe.MessageLogLevel=oe.MessageLogLevel;pe.WarningLogLevel=oe.WarningLogLevel;pe.ErrorLogLevel=oe.ErrorLogLevel;pe.AllLogLevel=oe.AllLogLevel;pe.IsWindowObjectExist=Gi;pe.PerformanceNoneLogLevel=0;pe.PerformanceUserMarkLogLevel=1;pe.PerformanceConsoleLogLevel=2;pe._NativePerformanceCounterHandles=new Map;pe.StartPerformanceCounter=pe._StartPerformanceCounterDisabled;pe.EndPerformanceCounter=pe._EndPerformanceCounterDisabled;class af{constructor(e,t,i,s=0){this.iterations=e,this.index=s-1,this._done=!1,this._fn=t,this._successCallback=i}executeNext(){this._done||(this.index+1<this.iterations?(++this.index,this._fn(this)):this.breakLoop())}breakLoop(){this._done=!0,this._successCallback()}static Run(e,t,i,s=0){const r=new af(e,t,i,s);return r.executeNext(),r}static SyncAsyncForLoop(e,t,i,s,r,a=0){return af.Run(Math.ceil(e/t),o=>{r&&r()?o.breakLoop():setTimeout(()=>{for(let c=0;c<t;++c){const u=o.index*t+c;if(u>=e)break;if(i(u),r&&r()){o.breakLoop();break}}o.executeNext()},a)},s)}}pe.Mix=Mm;pe.IsExponentOfTwo=Oh;Ke.FallbackTexture="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQ
231FCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/AABEIAQABAAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APH6KKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76P//Z";class Fe{constructor(e,t,i=!1,s,r=!1,a){this._uniformNames=[],this._valueCache={},this._engine=e,this._noUBO=!e.supportsUniformBuffers||r,this._dynamic=i,this._name=s??"no-name",this._data=t||[],this._uniformLocations={},this._uniformSizes={},this._uniformArraySizes={},this._uniformLocationPointer=0,this._needSync=!1,this._trackUBOsInFrame=!1,(a===void 0&&this._engine._features.trackUbosInFrame||a===!0)&&(this._buffers=[],this._bufferIndex=-1,this._createBufferOnWrite=!1,this._currentFrameId=0,this._trackUBOsInFrame=!0),this._noUBO?(this.updateMatrix3x3=this._updateMatrix3x3ForEffe
vendor: 48,451 bytes, line 231
231ct,this.updateMatrix2x2=this._updateMatrix2x2ForEffect,this.updateFloat=this._updateFloatForEffect,this.updateFloat2=this._updateFloat2ForEffect,this.updateFloat3=this._updateFloat3ForEffect,this.updateFloat4=this._updateFloat4ForEffect,this.updateFloatArray=this._updateFloatArrayForEffect,this.updateArray=this._updateArrayForEffect,this.updateIntArray=this._updateIntArrayForEffect,this.updateUIntArray=this._updateUIntArrayForEffect,this.updateMatrix=this._updateMatrixForEffect,this.updateMatrices=this._updateMatricesForEffect,this.updateVector3=this._updateVector3ForEffect,this.updateVector4=this._updateVector4ForEffect,this.updateColor3=this._updateColor3ForEffect,this.updateColor4=this._updateColor4ForEffect,this.updateDirectColor4=this._updateDirectColor4ForEffect,this.updateInt=this._updateIntForEffect,this.updateInt2=this._updateInt2ForEffect,this.updateInt3=this._updateInt3ForEffect,this.updateInt4=this._updateInt4ForEffect,this.updateUInt=this._updateUIntForEffect,this.updateUInt2=this._updateUInt2ForEffect,this.updateUInt3=this._updateUInt3ForEffect,this.updateUInt4=this._updateUInt4ForEffect):(this._engine._uniformBuffers.push(this),this.updateMatrix3x3=this._updateMatrix3x3ForUniform,this.updateMatrix2x2=this._updateMatrix2x2ForUniform,this.updateFloat=this._updateFloatForUniform,this.updateFloat2=this._updateFloat2ForUniform,this.updateFloat3=this._updateFloat3ForUniform,this.updateFloat4=this._updateFloat4ForUniform,this.updateFloatArray=this._updateFloatArrayForUniform,this.updateArray=this._updateArrayForUniform,this.updateIntArray=this._updateIntArrayForUniform,this.updateUIntArray=this._updateUIntArrayForUniform,this.updateMatrix=this._updateMatrixForUniform,this.updateMatrices=this._updateMatricesForUniform,this.updateVector3=this._updateVector3ForUniform,this.updateVector4=this._updateVector4ForUniform,this.updateColor3=this._updateColor3ForUniform,this.updateColor4=this._updateColor4ForUniform,this.updateDirectColor4=this._updateDirectColor4ForUniform,this.updateInt=this._updateIntForUniform,this.updateInt2=this._updateInt2ForUniform,this.updateInt3=this._updateInt3ForUniform,this.updateInt4=this._updateInt4ForUniform,this.updateUInt=this._updateUIntForUniform,this.updateUInt2=this._updateUInt2ForUniform,this.updateUInt3=this._updateUInt3ForUniform,this.updateUInt4=this._updateUInt4ForUniform)}get useUbo(){return!this._noUBO}get isSync(){return!this._needSync}isDynamic(){return this._dynamic}getData(){return this._bufferData}getBuffer(){return this._buffer}getUniformNames(){return this._uniformNames}_fillAlignment(e){let t;if(e<=2?t=e:t=4,this._uniformLocationPointer%t!==0){const i=this._uniformLocationPointer;this._uniformLocationPointer+=t-this._uniformLocationPointer%t;const s=this._uniformLocationPointer-i;for(let r=0;r<s;r++)this._data.push(0)}}addUniform(e,t,i=0){if(i>0&&typeof t=="number"&&(this._uniformArraySizes[e]={strideSize:t,arraySize:i}),this._uniformLocations[e]!==void 0||(this._uniformNames.push(e),this._noUBO))return;let s;if(i>0){if(t instanceof Array)throw"addUniform should not be use with Array in UBO: "+e;if(this._fillAlignment(4),t==16)t=t*i;else{const a=(4-t)*i;t=t*i+a}s=[];for(let r=0;r<t;r++)s.push(0)}else{if(t instanceof Array)s=t,t=s.length;else{s=[];for(let r=0;r<t;r++)s.push(0)}this._fillAlignment(t)}this._uniformSizes[e]=t,this._uniformLocations[e]=this._uniformLocationPointer,this._uniformLocationPointer+=t;for(let r=0;r<t;r++)this._data.push(s[r]);this._needSync=!0}addMatrix(e,t){this.addUniform(e,Array.prototype.slice.call(t.asArray()))}addFloat2(e,t,i){const s=[t,i];this.addUniform(e,s)}addFloat3(e,t,i,s){const r=[t,i,s];this.addUniform(e,r)}addColor3(e,t){const i=[t.r,t.g,t.b];this.addUniform(e,i)}addColor4(e,t,i){const s=[t.r,t.g,t.b,i];this.addUniform(e,s)}addVector3(e,t){const i=[t.x,t.y,t.z];this.addUniform(e,i)}addMatrix3x3(e){this.addUniform(e,12)}addMatrix2x2(e){this.addUniform(e,8)}create(){this._noUBO||this._buffer||(this._fillAlignment(4),this._bufferData=new Float32Array(this._data),this._rebuild(),this._needSync=!0)}_getNamesDebug(){const e=[];let t=0;for(const i in this._uniformLocations)if(e.push(i),++t===10)break;return e.join(",")}_rebuild(){this._noUBO||!this._bufferData||(this._dynamic?this._buffer=this._engine.createDynamicUniformBuffer(this._bufferData,this._name+"_UniformList:"+this._getNamesDebug()):this._buffer=this._engine.createUniformBuffer(this._bufferData,this._name+"_UniformList:"+this._getNamesDebug()),this._trackUBOsInFrame&&(this._buffers.push([this._buffer,this._engine._features.checkUbosContentBeforeUpload?this._bufferData.slice():void 0]),this._bufferIndex=this._buffers.length-1,this._createBufferOnWrite=!1))}_rebuildAfterContextLost(){this._trackUBOsInFrame&&(this._buffers=[],this._currentFrameId=0),this._rebuild()}get _numBuffers(){return this._buffers.length}get _indexBuffer(){return this._bufferIndex}get name(){return this._name}set name(e){this._name=e}get currentEffect(){return this._currentEffect}_buffersEqual(e,t){for(let i=0;i<e.length;++i)if(e[i]!==t[i])return!1;return!0}_copyBuffer(e,t){for(let i=0;i<e.length;++i)t[i]=e[i]}update(){if(!this._noUBO){if(this.bindUniformBuffer(),!this._buffer){this.create();return}if(!this._dynamic&&!this._needSync){this._createBufferOnWrite=this._trackUBOsInFrame;return}if(this._buffers&&this._buffers.length>1&&this._buffers[this._bufferIndex][1])if(this._buffersEqual(this._bufferData,this._buffers[this._bufferIndex][1])){this._needSync=!1,this._createBufferOnWrite=this._trackUBOsInFrame;return}else this._copyBuffer(this._bufferData,this._buffers[this._bufferIndex][1]);this._engine.updateUniformBuffer(this._buffer,this._bufferData),this._engine._features._collectUbosUpdatedInFrame&&(Fe._UpdatedUbosInFrame[this._name]||(Fe._UpdatedUbosInFrame[this._name]=0),Fe._UpdatedUbosInFrame[this._name]++),this._needSync=!1,this._createBufferOnWrite=this._trackUBOsInFrame}}_createNewBuffer(){this._bufferIndex+1<this._buffers.length?(this._bufferIndex++,this._buffer=this._buffers[this._bufferIndex][0],this._createBufferOnWrite=!1,this._needSync=!0):this._rebuild()}_checkNewFrame(){this._trackUBOsInFrame&&this._currentFrameId!==this._engine.frameId&&(this._currentFrameId=this._engine.frameId,this._createBufferOnWrite=!1,this._buffers&&this._buffers.length>0?(this._needSync=this._bufferIndex!==0,this._bufferIndex=0,this._buffer=this._buffers[this._bufferIndex][0]):this._bufferIndex=-1)}updateUniform(e,t,i){this._checkNewFrame();let s=this._uniformLocations[e];if(s===void 0){if(this._buffer){oe.Error("Cannot add an uniform after UBO has been created. uniformName="+e);return}this.addUniform(e,i),s=this._uniformLocations[e]}if(this._buffer||this.create(),this._dynamic)for(let r=0;r<i;r++)this._bufferData[s+r]=t[r];else{let r=!1;for(let a=0;a<i;a++)(i===16&&!this._engine._features.uniformBufferHardCheckMatrix||this._bufferData[s+a]!==Math.fround(t[a]))&&(r=!0,this._createBufferOnWrite&&this._createNewBuffer(),this._bufferData[s+a]=t[a]);this._needSync=this._needSync||r}}updateUniformArray(e,t,i){this._checkNewFrame();const s=this._uniformLocations[e];if(s===void 0){oe.Error("Cannot add an uniform Array dynamically. Please, add it using addUniform and make sure that uniform buffers are supported by the current engine.");return}this._buffer||this.create();const r=this._uniformArraySizes[e];if(this._dynamic)for(let a=0;a<i;a++)this._bufferData[s+a]=t[a];else{let a=!1,o=0,c=0;for(let u=0;u<i;u++)if(this._bufferData[s+c*4+o]!==pe.FloatRound(t[u])&&(a=!0,this._createBufferOnWrite&&this._createNewBuffer(),this._bufferData[s+c*4+o]=t[u]),o++,o===r.strideSize){for(;o<4;o++)this._bufferData[s+c*4+o]=0;o=0,c++}this._needSync=this._needSync||a}}_cacheMatrix(e,t){this._checkNewFrame();const i=this._valueCache[e],s=t.updateFlag;return i!==void 0&&i===s?!1:(this._valueCache[e]=s,!0)}_updateMatrix3x3ForUniform(e,t){for(let i=0;i<3;i++)Fe._TempBuffer[i*4]=t[i*3],Fe._TempBuffer[i*4+1]=t[i*3+1],Fe._TempBuffer[i*4+2]=t[i*3+2],Fe._TempBuffer[i*4+3]=0;this.updateUniform(e,Fe._TempBuffer,12)}_updateMatrix3x3ForEffect(e,t){this._currentEffect.setMatrix3x3(e,t)}_updateMatrix2x2ForEffect(e,t){this._currentEffect.setMatrix2x2(e,t)}_updateMatrix2x2ForUniform(e,t){for(let i=0;i<2;i++)Fe._TempBuffer[i*4]=t[i*2],Fe._TempBuffer[i*4+1]=t[i*2+1],Fe._TempBuffer[i*4+2]=0,Fe._TempBuffer[i*4+3]=0;this.updateUniform(e,Fe._TempBuffer,8)}_updateFloatForEffect(e,t,i=""){this._currentEffect.setFloat(e+i,t)}_updateFloatForUniform(e,t){Fe._TempBuffer[0]=t,this.updateUniform(e,Fe._TempBuffer,1)}_updateFloat2ForEffect(e,t,i,s=""){this._currentEffect.setFloat2(e+s,t,i)}_updateFloat2ForUniform(e,t,i){Fe._TempBuffer[0]=t,Fe._TempBuffer[1]=i,this.updateUniform(e,Fe._TempBuffer,2)}_updateFloat3ForEffect(e,t,i,s,r=""){this._currentEffect.setFloat3(e+r,t,i,s)}_updateFloat3ForUniform(e,t,i,s){Fe._TempBuffer[0]=t,Fe._TempBuffer[1]=i,Fe._TempBuffer[2]=s,this.updateUniform(e,Fe._TempBuffer,3)}_updateFloat4ForEffect(e,t,i,s,r,a=""){this._currentEffect.setFloat4(e+a,t,i,s,r)}_updateFloat4ForUniform(e,t,i,s,r){Fe._TempBuffer[0]=t,Fe._TempBuffer[1]=i,Fe._TempBuffer[2]=s,Fe._TempBuffer[3]=r,this.updateUniform(e,Fe._TempBuffer,4)}_updateFloatArrayForEffect(e,t,i=""){switch(this._uniformArraySizes[e]?.strideSize){case 2:this._currentEffect.setFloatArray2(e+i,t);break;case 3:this._currentEffect.setFloatArray3(e+i,t);break;case 4:this._currentEffect.setFloatArray4(e+i,t);break;default:this._currentEffect.setFloatArray(e+i,t);break}}_updateFloatArrayForUniform(e,t){this.updateUniformArray(e,t,t.length)}_updateArrayForEffect(e,t){this._currentEffect.setArray(e,t)}_updateArrayForUniform(e,t){this.updateUniformArray(e,t,t.length)}_updateIntArrayForEffect(e,t){this._currentEffect.setIntArray(e,t)}_updateIntArrayForUniform(e,t){Fe._TempBufferInt32View.set(t),this.updateUniformArray(e,Fe._TempBuffer,t.length)}_updateUIntArrayForEffect(e,t){this._currentEffect.setUIntArray(e,t)}_updateUIntArrayForUniform(e,t){Fe._TempBufferUInt32View.set(t),this.updateUniformArray(e,Fe._TempBuffer,t.length)}_updateMatrixForEffect(e,t){this._currentEffect.setMatrix(e,t)}_updateMatrixForUniform(e,t){this._cacheMatrix(e,t)&&this.updateUniform(e,t.asArray(),16)}_updateMatricesForEffect(e,t){this._currentEffect.setMatrices(e,t)}_updateMatricesForUniform(e,t){this.updateUniform(e,t,t.length)}_updateVector3ForEffect(e,t){this._currentEffect.setVector3(e,t)}_updateVector3ForUniform(e,t){Fe._TempBuffer[0]=t.x,Fe._TempBuffer[1]=t.y,Fe._TempBuffer[2]=t.z,this.updateUniform(e,Fe._TempBuffer,3)}_updateVector4ForEffect(e,t){this._currentEffect.setVector4(e,t)}_updateVector4ForUniform(e,t){Fe._TempBuffer[0]=t.x,Fe._TempBuffer[1]=t.y,Fe._TempBuffer[2]=t.z,Fe._TempBuffer[3]=t.w,this.updateUniform(e,Fe._TempBuffer,4)}_updateColor3ForEffect(e,t,i=""){this._currentEffect.setColor3(e+i,t)}_updateColor3ForUniform(e,t){Fe._TempBuffer[0]=t.r,Fe._TempBuffer[1]=t.g,Fe._TempBuffer[2]=t.b,this.updateUniform(e,Fe._TempBuffer,3)}_updateColor4ForEffect(e,t,i,s=""){this._currentEffect.setColor4(e+s,t,i)}_updateDirectColor4ForEffect(e,t,i=""){this._currentEffect.setDirectColor4(e+i,t)}_updateColor4ForUniform(e,t,i){Fe._TempBuffer[0]=t.r,Fe._TempBuffer[1]=t.g,Fe._TempBuffer[2]=t.b,Fe._TempBuffer[3]=i,this.updateUniform(e,Fe._TempBuffer,4)}_updateDirectColor4ForUniform(e,t){Fe._TempBuffer[0]=t.r,Fe._TempBuffer[1]=t.g,Fe._TempBuffer[2]=t.b,Fe._TempBuffer[3]=t.a,this.updateUniform(e,Fe._TempBuffer,4)}_updateIntForEffect(e,t,i=""){this._currentEffect.setInt(e+i,t)}_updateIntForUniform(e,t){Fe._TempBufferInt32View[0]=t,this.updateUniform(e,Fe._TempBuffer,1)}_updateInt2ForEffect(e,t,i,s=""){this._currentEffect.setInt2(e+s,t,i)}_updateInt2ForUniform(e,t,i){Fe._TempBufferInt32View[0]=t,Fe._TempBufferInt32View[1]=i,this.updateUniform(e,Fe._TempBuffer,2)}_updateInt3ForEffect(e,t,i,s,r=""){this._currentEffect.setInt3(e+r,t,i,s)}_updateInt3ForUniform(e,t,i,s){Fe._TempBufferInt32View[0]=t,Fe._TempBufferInt32View[1]=i,Fe._TempBufferInt32View[2]=s,this.updateUniform(e,Fe._TempBuffer,3)}_updateInt4ForEffect(e,t,i,s,r,a=""){this._currentEffect.setInt4(e+a,t,i,s,r)}_updateInt4ForUniform(e,t,i,s,r){Fe._TempBufferInt32View[0]=t,Fe._TempBufferInt32View[1]=i,Fe._TempBufferInt32View[2]=s,Fe._TempBufferInt32View[3]=r,this.updateUniform(e,Fe._TempBuffer,4)}_updateUIntForEffect(e,t,i=""){this._currentEffect.setUInt(e+i,t)}_updateUIntForUniform(e,t){Fe._TempBufferUInt32View[0]=t,this.updateUniform(e,Fe._TempBuffer,1)}_updateUInt2ForEffect(e,t,i,s=""){this._currentEffect.setUInt2(e+s,t,i)}_updateUInt2ForUniform(e,t,i){Fe._TempBufferUInt32View[0]=t,Fe._TempBufferUInt32View[1]=i,this.updateUniform(e,Fe._TempBuffer,2)}_updateUInt3ForEffect(e,t,i,s,r=""){this._currentEffect.setUInt3(e+r,t,i,s)}_updateUInt3ForUniform(e,t,i,s){Fe._TempBufferUInt32View[0]=t,Fe._TempBufferUInt32View[1]=i,Fe._TempBufferUInt32View[2]=s,this.updateUniform(e,Fe._TempBuffer,3)}_updateUInt4ForEffect(e,t,i,s,r,a=""){this._currentEffect.setUInt4(e+a,t,i,s,r)}_updateUInt4ForUniform(e,t,i,s,r){Fe._TempBufferUInt32View[0]=t,Fe._TempBufferUInt32View[1]=i,Fe._TempBufferUInt32View[2]=s,Fe._TempBufferUInt32View[3]=r,this.updateUniform(e,Fe._TempBuffer,4)}setTexture(e,t){this._currentEffect.setTexture(e,t)}setTextureArray(e,t){this._currentEffect.setTextureArray(e,t)}bindTexture(e,t){this._currentEffect._bindTexture(e,t)}updateUniformDirectly(e,t){this.updateUniform(e,t,t.length),this.update()}bindToEffect(e,t){this._currentEffect=e,this._currentEffectName=t}bindUniformBuffer(){!this._noUBO&&this._buffer&&this._currentEffect&&this._currentEffect.bindUniformBuffer(this._buffer,this._currentEffectName)}unbindEffect(){this._currentEffect=void 0,this._currentEffectName=void 0}setDataBuffer(e){if(!this._buffers)return this._buffer===e;for(let t=0;t<this._buffers.length;++t)if(this._buffers[t][0]===e)return this._bufferIndex=t,this._buffer=e,this._createBufferOnWrite=!1,this._currentEffect=void 0,this._buffers.length>1&&this._buffers[t][1]&&this._bufferData.set(this._buffers[t][1]),this._valueCache={},this._currentFrameId=this._engine.frameId,!0;return!1}has(e){return this._uniformLocations[e]!==void 0}dispose(){if(this._noUBO)return;const e=this._engine._uniformBuffers,t=e.indexOf(this);if(t!==-1&&(e[t]=e[e.length-1],e.pop()),this._trackUBOsInFrame&&this._buffers)for(let i=0;i<this._buffers.length;++i){const s=this._buffers[i][0];this._engine._releaseBuffer(s)}else this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._buffer=null)}}Fe._UpdatedUbosInFrame={};Fe._MAX_UNIFORM_SIZE=256;Fe._TempBuffer=new Float32Array(Fe._MAX_UNIFORM_SIZE);Fe._TempBufferInt32View=new Int32Array(Fe._TempBuffer.buffer);Fe._TempBufferUInt32View=new Uint32Array(Fe._TempBuffer.buffer);class xt{static CompareLightsPriority(e,t){return e.shadowEnabled!==t.shadowEnabled?(t.shadowEnabled?1:0)-(e.shadowEnabled?1:0):t.renderPriority-e.renderPriority}}xt.FALLOFF_DEFAULT=0;xt.FALLOFF_PHYSICAL=1;xt.FALLOFF_GLTF=2;xt.FALLOFF_STANDARD=3;xt.LIGHTMAP_DEFAULT=0;xt.LIGHTMAP_SPECULAR=1;xt.LIGHTMAP_SHADOWSONLY=2;xt.INTENSITYMODE_AUTOMATIC=0;xt.INTENSITYMODE_LUMINOUSPOWER=1;xt.INTENSITYMODE_LUMINOUSINTENSITY=2;xt.INTENSITYMODE_ILLUMINANCE=3;xt.INTENSITYMODE_LUMINANCE=4;xt.LIGHTTYPEID_POINTLIGHT=0;xt.LIGHTTYPEID_DIRECTIONALLIGHT=1;xt.LIGHTTYPEID_SPOTLIGHT=2;xt.LIGHTTYPEID_HEMISPHERICLIGHT=3;xt.LIGHTTYPEID_RECT_AREALIGHT=4;xt.LIGHTTYPEID_CLUSTERED_CONTAINER=5;class lt extends yi{get range(){return this._range}set range(e){this._range=e,this._inverseSquaredRange=1/(this.range*this.range)}get intensityMode(){return this._intensityMode}set intensityMode(e){this._intensityMode=e,this._computePhotometricScale()}get radius(){return this._radius}set radius(e){this._radius=e,this._computePhotometricScale()}get shadowEnabled(){return this._shadowEnabled}set shadowEnabled(e){this._shadowEnabled!==e&&(this._shadowEnabled=e,this._markMeshesAsLightDirty())}get includedOnlyMeshes(){return this._includedOnlyMeshes}set includedOnlyMeshes(e){this._includedOnlyMeshes=e,this._hookArrayForIncludedOnly(e)}get excludedMeshes(){return this._excludedMeshes}set excludedMeshes(e){this._excludedMeshes=e,this._hookArrayForExcluded(e)}get excludeWithLayerMask(){return this._excludeWithLayerMask}set excludeWithLayerMask(e){this._excludeWithLayerMask=e,this._resyncMeshes()}get includeOnlyWithLayerMask(){return this._includeOnlyWithLayerMask}set includeOnlyWithLayerMask(e){this._includeOnlyWithLayerMask=e,this._resyncMeshes()}get lightmapMode(){return this._lightmapMode}set lightmapMode(e){this._lightmapMode!==e&&(this._lightmapMode=e,this._markMeshesAsLightDirty())}getViewMatrix(e){return null}getProjectionMatrix(e,t){return null}constructor(e,t){super(e,t,!1),this.diffuse=new Ne(1,1,1),this.specular=new Ne(1,1,1),this.falloffType=lt.FALLOFF_DEFAULT,this.intensity=1,this._range=Number.MAX_VALUE,this._inverseSquaredRange=0,this._photometricScale=1,this._intensityMode=lt.INTENSITYMODE_AUTOMATIC,this._radius=1e-5,this.renderPriority=0,this._shadowEnabled=!0,this._excludeWithLayerMask=0,this._includeOnlyWithLayerMask=0,this._lightmapMode=0,this._shadowGenerators=null,this._excludedMeshesIds=new Array,this._includedOnlyMeshesIds=new Array,this._currentViewDepth=0,this._isLight=!0,this.getScene().addLight(this),this._uniformBuffer=new Fe(this.getScene().getEngine(),void 0,void 0,e),this._buildUniformLayout(),this.includedOnlyMeshes=[],this.excludedMeshes=[],this._resyncMeshes()}transferTexturesToEffect(e,t){return this}_bindLight(e,t,i,s,r=!0){const a=e.toString();let o=!1;if(this._uniformBuffer.bindToEffect(i,"Light"+a),this._renderId!==t.getRenderId()||this._lastUseSpecular!==s||!this._uniformBuffer.useUbo){this._renderId=t.getRenderId(),this._lastUseSpecular=s;const c=this.getScaledIntensity();this.transferToEffect(i,a),this.diffuse.scaleToRef(c,Ft.Color3[0]),this._uniformBuffer.updateColor4("vLightDiffuse",Ft.Color3[0],this.range,a),s&&(this.specular.scaleToRef(c,Ft.Color3[1]),this._uniformBuffer.updateColor4("vLightSpecular",Ft.Color3[1],this.radius,a)),o=!0}if(this.transferTexturesToEffect(i,a),t.shadowsEnabled&&this.shadowEnabled&&r){const c=this.getShadowGenerator(t.activeCamera)??this.getShadowGenerator();c&&(c.bindShadowLight(a,i),o=!0)}o?this._uniformBuffer.update():this._uniformBuffer.bindUniformBuffer()}getClassName(){return"Light"}toString(e){let t="Name: "+this.name;if(t+=", type: "+["Point","Directional","Spot","Hemispheric","Clustered"][this.getTypeID()],this.animations)for(let i=0;i<this.animations.length;i++)t+=", animation[0]: "+this.animations[i].toString(e);return t}_syncParentEnabledState(){super._syncParentEnabledState(),this.isDisposed()||this._resyncMeshes()}setEnabled(e){super.setEnabled(e),this._resyncMeshes()}getShadowGenerator(e=null){return this._shadowGenerators===null?null:this._shadowGenerators.get(e)??null}getShadowGenerators(){return this._shadowGenerators}getAbsolutePosition(){return T.Zero()}canAffectMesh(e){return e?!(this.includedOnlyMeshes&&this.includedOnlyMeshes.length>0&&this.includedOnlyMeshes.indexOf(e)===-1||this.excludedMeshes&&this.excludedMeshes.length>0&&this.excludedMeshes.indexOf(e)!==-1||this.includeOnlyWithLayerMask!==0&&(this.includeOnlyWithLayerMask&e.layerMask)===0||this.excludeWithLayerMask!==0&&this.excludeWithLayerMask&e.layerMask):!0}dispose(e,t=!1){if(this._shadowGenerators){const i=this._shadowGenerators.values();for(let s=i.next();s.done!==!0;s=i.next())s.value.dispose();this._shadowGenerators=null}if(this.getScene().stopAnimation(this),this._parentContainer){const i=this._parentContainer.lights.indexOf(this);i>-1&&this._parentContainer.lights.splice(i,1),this._parentContainer=null}for(const i of this.getScene().meshes)i._removeLightSource(this,!0);this._uniformBuffer.dispose(),this.getScene().removeLight(this),super.dispose(e,t)}getTypeID(){return 0}getScaledIntensity(){return this._photometricScale*this.intensity}clone(e,t=null){const i=lt.GetConstructorFromName(this.getTypeID(),e,this.getScene());if(!i)return null;const s=$e.Clone(i,this);return e&&(s.name=e),t&&(s.parent=t),s.setEnabled(this.isEnabled()),this.onClonedObservable.notifyObservers(s),s}serialize(){const e=$e.Serialize(this);if(e.uniqueId=this.uniqueId,e.type=this.getTypeID(),this.parent&&this.parent._serializeAsParent(e),this.excludedMeshes.length>0){e.excludedMeshesIds=[];for(const t of this.excludedMeshes)e.excludedMeshesIds.push(t.id)}if(this.includedOnlyMeshes.length>0){e.includedOnlyMeshesIds=[];for(const t of this.includedOnlyMeshes)e.includedOnlyMeshesIds.push(t.id)}return $e.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.isEnabled=this.isEnabled(),e}static GetConstructorFromName(e,t,i){const s=yi.Construct("Light_Type_"+e,t,i);return s||null}static Parse(e,t){const i=lt.GetConstructorFromName(e.type,e.name,t);if(!i)return null;const s=$e.Parse(i,e,t);if(e.excludedMeshesIds&&(s._excludedMeshesIds=e.excludedMeshesIds),e.includedOnlyMeshesIds&&(s._includedOnlyMeshesIds=e.includedOnlyMeshesIds),e.parentId!==void 0&&(s._waitingParentId=e.parentId),e.parentInstanceIndex!==void 0&&(s._waitingParentInstanceIndex=e.parentInstanceIndex),e.falloffType!==void 0&&(s.falloffType=e.falloffType),e.lightmapMode!==void 0&&(s.lightmapMode=e.lightmapMode),e.animations){for(let r=0;r<e.animations.length;r++){const a=e.animations[r],o=Kr("BABYLON.Animation");o&&s.animations.push(o.Parse(a))}yi.ParseAnimationRanges(s,e,t)}return e.autoAnimate&&t.beginAnimation(s,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),e.isEnabled!==void 0&&s.setEnabled(e.isEnabled),s}_hookArrayForExcluded(e){const t=e.push;e.push=(...s)=>{const r=t.apply(e,s);for(const a of s)a._resyncLightSource(this);return r};const i=e.splice;e.splice=(s,r)=>{const a=i.apply(e,[s,r]);for(const o of a)o._resyncLightSource(this);return a};for(const s of e)s._resyncLightSource(this)}_hookArrayForIncludedOnly(e){const t=e.push;e.push=(...s)=>{const r=t.apply(e,s);return this._resyncMeshes(),r};const i=e.splice;e.splice=(s,r)=>{const a=i.apply(e,[s,r]);return this._resyncMeshes(),a},this._resyncMeshes()}_resyncMeshes(){for(const e of this.getScene().meshes)e._resyncLightSource(this)}_markMeshesAsLightDirty(){for(const e of this.getScene().meshes)e.lightSources.indexOf(this)!==-1&&e._markSubMeshesAsLightDirty()}_computePhotometricScale(){this._photometricScale=this._getPhotometricScale(),this.getScene().resetCachedMaterial()}_getPhotometricScale(){let e=0;const t=this.getTypeID();let i=this.intensityMode;switch(i===lt.INTENSITYMODE_AUTOMATIC&&(t===lt.LIGHTTYPEID_DIRECTIONALLIGHT?i=lt.INTENSITYMODE_ILLUMINANCE:i=lt.INTENSITYMODE_LUMINOUSINTENSITY),t){case lt.LIGHTTYPEID_POINTLIGHT:case lt.LIGHTTYPEID_SPOTLIGHT:switch(i){case lt.INTENSITYMODE_LUMINOUSPOWER:e=1/(4*Math.PI);break;case lt.INTENSITYMODE_LUMINOUSINTENSITY:e=1;break;case lt.INTENSITYMODE_LUMINANCE:e=this.radius*this.radius;break}break;case lt.LIGHTTYPEID_DIRECTIONALLIGHT:switch(i){case lt.INTENSITYMODE_ILLUMINANCE:e=1;break;case lt.INTENSITYMODE_LUMINANCE:{let s=this.radius;s=Math.max(s,.001),e=2*Math.PI*(1-Math.cos(s));break}}break;case lt.LIGHTTYPEID_HEMISPHERICLIGHT:e=1;break}return e}_reorderLightsInScene(){const e=this.getScene();this._renderPriority!=0&&(e.requireLightSorting=!0),this.getScene().sortLightsByPriority()}_isReady(){return!0}}lt.FALLOFF_DEFAULT=xt.FALLOFF_DEFAULT;lt.FALLOFF_PHYSICAL=xt.FALLOFF_PHYSICAL;lt.FALLOFF_GLTF=xt.FALLOFF_GLTF;lt.FALLOFF_STANDARD=xt.FALLOFF_STANDARD;lt.LIGHTMAP_DEFAULT=xt.LIGHTMAP_DEFAULT;lt.LIGHTMAP_SPECULAR=xt.LIGHTMAP_SPECULAR;lt.LIGHTMAP_SHADOWSONLY=xt.LIGHTMAP_SHADOWSONLY;lt.INTENSITYMODE_AUTOMATIC=xt.INTENSITYMODE_AUTOMATIC;lt.INTENSITYMODE_LUMINOUSPOWER=xt.INTENSITYMODE_LUMINOUSPOWER;lt.INTENSITYMODE_LUMINOUSINTENSITY=xt.INTENSITYMODE_LUMINOUSINTENSITY;lt.INTENSITYMODE_ILLUMINANCE=xt.INTENSITYMODE_ILLUMINANCE;lt.INTENSITYMODE_LUMINANCE=xt.INTENSITYMODE_LUMINANCE;lt.LIGHTTYPEID_POINTLIGHT=xt.LIGHTTYPEID_POINTLIGHT;lt.LIGHTTYPEID_DIRECTIONALLIGHT=xt.LIGHTTYPEID_DIRECTIONALLIGHT;lt.LIGHTTYPEID_SPOTLIGHT=xt.LIGHTTYPEID_SPOTLIGHT;lt.LIGHTTYPEID_HEMISPHERICLIGHT=xt.LIGHTTYPEID_HEMISPHERICLIGHT;lt.LIGHTTYPEID_RECT_AREALIGHT=xt.LIGHTTYPEID_RECT_AREALIGHT;N([Yo()],lt.prototype,"diffuse",void 0);N([Yo()],lt.prototype,"specular",void 0);N([H()],lt.prototype,"falloffType",void 0);N([H()],lt.prototype,"intensity",void 0);N([H()],lt.prototype,"range",null);N([H()],lt.prototype,"intensityMode",null);N([H()],lt.prototype,"radius",null);N([H()],lt.prototype,"_renderPriority",void 0);N([Dt("_reorderLightsInScene")],lt.prototype,"renderPriority",void 0);N([H("shadowEnabled")],lt.prototype,"_shadowEnabled",void 0);N([H("excludeWithLayerMask")],lt.prototype,"_excludeWithLayerMask",void 0);N([H("includeOnlyWithLayerMask")],lt.prototype,"_includeOnlyWithLayerMask",void 0);N([H("lightmapMode")],lt.prototype,"_lightmapMode",void 0);yi.AddNodeConstructor("Light_Type_3",(n,e)=>()=>new _c(n,T.Zero(),e));class _c extends lt{constructor(e,t,i){super(e,i),this.groundColor=new Ne(0,0,0),this.direction=t||T.Up()}_buildUniformLayout(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("vLightGround",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()}getClassName(){return"HemisphericLight"}setDirectionToTarget(e){return this.direction=T.Normalize(e.subtract(T.Zero())),this.direction}getShadowGenerator(){return null}transferToEffect(e,t){const i=T.Normalize(this.direction);return this._uniformBuffer.updateFloat4("vLightData",i.x,i.y,i.z,0,t),this._uniformBuffer.updateColor3("vLightGround",this.groundColor.scale(this.intensity),t),this}transferToNodeMaterialEffect(e,t){const i=T.Normalize(this.direction);return e.setFloat3(t,i.x,i.y,i.z),this}computeWorldMatrix(){return this._worldMatrix||(this._worldMatrix=W.Identity()),this._worldMatrix}getTypeID(){return lt.LIGHTTYPEID_HEMISPHERICLIGHT}prepareLightSpecificDefines(e,t){e["HEMILIGHT"+t]=!0}}N([Yo()],_c.prototype,"groundColor",void 0);N([lr()],_c.prototype,"direction",void 0);Tt("BABYLON.HemisphericLight",_c);function wm(n,e,t){try{const i=n.next();i.done?e(i):i.value?i.value.then(()=>{i.value=void 0,e(i)},t):e(i)}catch(i){t(i)}}function Ek(n=25){let e;return(t,i,s)=>{const r=performance.now();e===void 0||r-e>n?(e=r,setTimeout(()=>{wm(t,i,s)},0)):wm(t,i,s)}}function RC(n,e,t,i,s){const r=()=>{let a;const o=c=>{c.done?t(c.value):a===void 0?a=!0:r()};do a=void 0,e(n,o,i),a===void 0&&(a=!1);while(a)};r()}function Ob(n,e){let t;return RC(n,wm,i=>t=i,i=>{throw i}),t}async function Ak(n,e,t){return await new Promise((i,s)=>{RC(n,e,i,s)})}function Rk(n,e){return(...t)=>Ob(n(...t))}class Yi{constructor(e){this.length=0,this.data=new Array(e),this._id=Yi._GlobalId++}push(e){this.data[this.length++]=e,this.length>this.data.length&&(this.data.length*=2)}forEach(e){for(let t=0;t<this.length;t++)e(this.data[t])}sort(e){this.data.sort(e)}reset(){this.length=0}dispose(){this.reset(),this.data&&(this.data.length=0)}concat(e){if(e.length!==0){this.length+e.length>this.data.length&&(this.data.length=(this.length+e.length)*2);for(let t=0;t<e.length;t++)this.data[this.length++]=(e.data||e)[t]}}indexOf(e){const t=this.data.indexOf(e);return t>=this.length?-1:t}contains(e){return this.indexOf(e)!==-1}}Yi._GlobalId=0;class Do extends Yi{constructor(){super(...arguments),this._duplicateId=0}push(e){super.push(e),e.__smartArrayFlags||(e.__smartArrayFlags={}),e.__smartArrayFlags[this._id]=this._duplicateId}pushNoDuplicate(e){return e.__smartArrayFlags&&e.__smartArrayFlags[this._id]===this._duplicateId?!1:(this.push(e),!0)}reset(){super.reset(),this._duplicateId++}concatWithNoDuplicate(e){if(e.length!==0){this.length+e.length>this.data.length&&(this.data.length=(this.length+e.length)*2);for(let t=0;t<e.length;t++){const i=(e.data||e)[t];this.pushNoDuplicate(i)}}}}class Ge extends yi{get position(){return this._position}set position(e){this._position=e}set upVector(e){this._upVector=e}get upVector(){return this._upVector}get screenArea(){let e=0,t=0;if(this.mode===Ge.PERSPECTIVE_CAMERA)this.fovMode===Ge.FOVMODE_VERTICAL_FIXED?(t=this.minZ*2*Math.tan(this.fov/2),e=this.getEngine().getAspectRatio(this)*t):(e=this.minZ*2*Math.tan(this.fov/2),t=e/this.getEngine().getAspectRatio(this));else{const i=this.getEngine().getRenderWidth()/2,s=this.getEngine().getRenderHeight()/2;e=(this.orthoRight??i)-(this.orthoLeft??-i),t=(this.orthoTop??s)-(this.orthoBottom??-s)}return e*t}set orthoLeft(e){this._orthoLeft=e;for(const t of this._rigCameras)t.orthoLeft=e}get orthoLeft(){return this._orthoLeft}set orthoRight(e){this._orthoRight=e;for(const t of this._rigCameras)t.orthoRight=e}get orthoRight(){return this._orthoRight}set orthoBottom(e){this._orthoBottom=e;for(const t of this._rigCameras)t.orthoBottom=e}get orthoBottom(){return this._orthoBottom}set orthoTop(e){this._orthoTop=e;for(const t of this._rigCameras)t.orthoTop=e}get orthoTop(){return this._orthoTop}setFocalLength(e,t=36){this.fov=2*Math.atan(t/(2*e))}set mode(e){this._mode=e;for(const t of this._rigCameras)t.mode=e}get mode(){return this._mode}get hasMoved(){return this._hasMoved}constructor(e,t,i,s=!0){super(e,i,!1),this._position=T.Zero(),this._upVector=T.Up(),this.oblique=null,this._orthoLeft=null,this._orthoRight=null,this._orthoBottom=null,this._orthoTop=null,this.fov=.8,this.projectionPlaneTilt=0,this.minZ=1,this.maxZ=1e4,this.inertia=.9,this._mode=Ge.PERSPECTIVE_CAMERA,this.isIntermediate=!1,this.viewport=new Ja(0,0,1,1),this.layerMask=268435455,this.fovMode=Ge.FOVMODE_VERTICAL_FIXED,this.cameraRigMode=Ge.RIG_MODE_NONE,this.ignoreCameraMaxZ=!1,this.customRenderTargets=[],this.outputRenderTarget=null,this.onViewMatrixChangedObservable=new le,this.onProjectionMatrixChangedObservable=new le,this.onAfterCheckInputsObservable=new le,this.onRestoreStateObservable=new le,this.isRigCamera=!1,this._hasMoved=!1,this._rigCameras=new Array,this._skipRendering=!1,this._projectionMatrix=new W,this._postProcesses=new Array,this._activeMeshes=new Yi(256),this._globalPosition=T.Zero(),this._computedViewMatrix=W.Identity(),this._doNotComputeProjectionMatrix=!1,this._transformMatrix=W.Zero(),this._refreshFrustumPlanes=!0,this._absoluteRotation=Se.Identity(),this._isCamera=!0,this._isLeftCamera=!1,this._isRightCamera=!1,this.getScene().addCamera(this),s&&!this.getScene().activeCamera&&(this.getScene().activeCamera=this),this.position=t,this.renderPassId=this.getScene().getEngine().createRenderPassId(`Camera ${e}`)}storeState(){return this._stateStored=!0,this._storedFov=this.fov,this}hasStateStored(){return!!this._stateStored}_restoreStateValues(){return this._stateStored?(this.fov=this._storedFov,!0):!1}restoreState(){return this._restoreStateValues()?(this.onRestoreStateObservable.notifyObservers(this),!0):!1}getClassName(){return"Camera"}toString(e){let t="Name: "+this.name;if(t+=", type: "+this.getClassName(),this.animations)for(let i=0;i<this.animations.length;i++)t+=", animation[0]: "+this.animations[i].toString(e);return t}applyVerticalCorrection(){const e=this.absoluteRotation.toEulerAngles();this.projectionPlaneTilt=this._scene.useRightHandedSystem?-e.x:e.x}get globalPosition(){return this._globalPosition}getActiveMeshes(){return this._activeMeshes}isActiveMesh(e){return this._activeMeshes.indexOf(e)!==-1}isReady(e=!1){if(e){for(const t of this._postProcesses)if(t&&!t.isReady())return!1}return super.isReady(e)}_initCache(){super._initCache(),this._cache.position=new T(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.upVector=new T(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.mode=void 0,this._cache.minZ=void 0,this._cache.maxZ=void 0,this._cache.fov=void 0,this._cache.fovMode=void 0,this._cache.aspectRatio=void 0,this._cache.orthoLeft=void 0,this._cache.orthoRight=void 0,this._cache.orthoBottom=void 0,this._cache.orthoTop=void 0,this._cache.obliqueAngle=void 0,this._cache.obliqueLength=void 0,this._cache.obliqueOffset=void 0,this._cache.renderWidth=void 0,this._cache.renderHeight=void 0}_updateCache(e){e||super._updateCache(),this._cache.position.copyFrom(this.position),this._cache.upVector.copyFrom(this.upVector)}_isSynchronized(){return this._isSynchronizedViewMatrix()&&this._isSynchronizedProjectionMatrix()}_isSynchronizedViewMatrix(){return super._isSynchronized()?this._cache.position.equals(this.position)&&this._cache.upVector.equals(this.upVector)&&this.isSynchronizedWithParent():!1}_isSynchronizedProjectionMatrix(){const e=this.ignoreCameraMaxZ?0:this.maxZ;let t=this._cache.mode===this.mode&&this._cache.minZ===this.minZ&&this._cache.maxZ===e;if(!t)return!1;const i=this.getEngine();return this.mode===Ge.PERSPECTIVE_CAMERA?t=this._cache.fov===this.fov&&this._cache.fovMode===this.fovMode&&this._cache.aspectRatio===i.getAspectRatio(this)&&this._cache.projectionPlaneTilt===this.projectionPlaneTilt:(t=this._cache.orthoLeft===this.orthoLeft&&this._cache.orthoRight===this.orthoRight&&this._cache.orthoBottom===this.orthoBottom&&this._cache.orthoTop===this.orthoTop&&this._cache.renderWidth===i.getRenderWidth()&&this._cache.renderHeight===i.getRenderHeight(),this.oblique&&(t=t&&this._cache.obliqueAngle===this.oblique.angle&&this._cache.obliqueLength===this.oblique.length&&this._cache.obliqueOffset===this.oblique.offset)),t}attachControl(e,t){}detachControl(e){}update(){this._hasMoved=!1,this._checkInputs(),this.cameraRigMode!==Ge.RIG_MODE_NONE&&this._updateRigCameras(),this.getViewMatrix(),this.getProjectionMatrix()}_checkInputs(){this.onAfterCheckInputsObservable.notifyObservers(this)}get rigCameras(){return this._rigCameras}get rigPostProcess(){return this._rigPostProcess}_getFirstPostProcess(){for(let e=0;e<this._postProcesses.length;e++)if(this._postProcesses[e]!==null)return this._postProcesses[e];return null}_cascadePostProcessesToRigCams(){const e=this._getFirstPostProcess();e&&e.markTextureDirty();for(let t=0,i=this._rigCameras.length;t<i;t++){const s=this._rigCameras[t],r=s._rigPostProcess;r?(r.getEffectName()==="pass"&&(s.isIntermediate=this._postProcesses.length===0),s._postProcesses=this._postProcesses.slice(0).concat(r),r.markTextureDirty()):s._postProcesses=this._postProcesses.slice(0)}}attachPostProcess(e,t=null){return!e.isReusable()&&this._postProcesses.indexOf(e)>-1?(oe.Error("You're trying to reuse a post process not defined as reusable."),0):(t==null||t<0?this._postProcesses.push(e):this._postProcesses[t]===null?this._postProcesses[t]=e:this._postProcesses.splice(t,0,e),this._cascadePostProcessesToRigCams(),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._postProcesses.indexOf(e))}detachPostProcess(e){const t=this._postProcesses.indexOf(e);t!==-1&&(this._postProcesses[t]=null),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._cascadePostProcessesToRigCams()}getWorldMatrix(){return this._isSynchronizedViewMatrix()?this._worldMatrix:(this.getViewMatrix(),this._worldMatrix)}_getViewMatrix(){return W.Identity()}getViewMatrix(e){return!e&&this._isSynchronizedViewMatrix()?this._computedViewMatrix:(this._hasMoved=!0,this.updateCache(),this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),this._childUpdateId++,this._refreshFrustumPlanes=!0,this._cameraRigParams&&this._cameraRigParams.vrPreViewMatrix&&this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix,this._computedViewMatrix),this.parent&&this.parent.onViewMatrixChangedObservable&&this.parent.onViewMatrixChangedObservable.notifyObservers(this.parent),this.onViewMatrixChangedObservable.notifyObservers(this),this._computedViewMatrix.invertToRef(this._worldMatrix),this._worldMatrix.getTranslationToRef(this._globalPosition),this._computedViewMatrix)}freezeProjectionMatrix(e){this._doNotComputeProjectionMatrix=!0,e!==void 0&&(this._projectionMatrix=e)}unfreezeProjectionMatrix(){this._doNotComputeProjectionMatrix=!1}getProjectionMatrix(e){if(this._doNotComputeProjectionMatrix||!e&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;const t=this.ignoreCameraMaxZ?0:this.maxZ;this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=t,this._refreshFrustumPlanes=!0;const i=this.getEngine(),s=this.getScene(),r=i.useReverseDepthBuffer;if(this.mode===Ge.PERSPECTIVE_CAMERA){this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=i.getAspectRatio(this),this._cache.projectionPlaneTilt=this.projectionPlaneTilt,this.minZ<=0&&(this.minZ=.1);let a;s.useRightHandedSystem?a=W.PerspectiveFovRHToRef:a=W.PerspectiveFovLHToRef,a(this.fov,i.getAspectRatio(this),r?t:this.minZ,r?this.minZ:t,this._projectionMatrix,this.fovMode===Ge.FOVMODE_VERTICAL_FIXED,i.isNDCHalfZRange,this.projectionPlaneTilt,r)}else{const a=i.getRenderWidth()/2,o=i.getRenderHeight()/2;s.useRightHandedSystem?this.oblique?W.ObliqueOffCenterRHToRef(this.orthoLeft??-a,this.orthoRight??a,this.orthoBottom??-o,this.orthoTop??o,r?t:this.minZ,r?this.minZ:t,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,i.isNDCHalfZRange):W.OrthoOffCenterRHToRef(this.orthoLeft??-a,this.orthoRight??a,this.orthoBottom??-o,this.orthoTop??o,r?t:this.minZ,r?this.minZ:t,this._projectionMatrix,i.isNDCHalfZRange):this.oblique?W.ObliqueOffCenterLHToRef(this.orthoLeft??-a,this.orthoRight??a,this.orthoBottom??-o,this.orthoTop??o,r?t:this.minZ,r?this.minZ:t,this.oblique.length,this.oblique.angle,this._computeObliqueDistance(this.oblique.offset),this._projectionMatrix,i.isNDCHalfZRange):W.OrthoOffCenterLHToRef(this.orthoLeft??-a,this.orthoRight??a,this.orthoBottom??-o,this.orthoTop??o,r?t:this.minZ,r?this.minZ:t,this._projectionMatrix,i.isNDCHalfZRange),this._cache.orthoLeft=this.orthoLeft,this._cache.orthoRight=this.orthoRight,this._cache.orthoBottom=this.orthoBottom,this._cache.orthoTop=this.orthoTop,this._cache.obliqueAngle=this.oblique?.angle,this._cache.obliqueLength=this.oblique?.length,this._cache.obliqueOffset=this.oblique?.offset,this._cache.renderWidth=i.getRenderWidth(),this._cache.renderHeight=i.getRenderHeight()}return this.onProjectionMatrixChangedObservable.notifyObservers(this),this._projectionMatrix}getTransformationMatrix(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix}_computeObliqueDistance(e){const t=this,i=this;return(t.radius||(i.target?T.Distance(this.position,i.target):this.position.length()))+e}_updateFrustumPlanes(){this._refreshFrustumPlanes&&(this.getTransformationMatrix(),this._frustumPlanes?Mr.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=Mr.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)}isInFrustum(e,t=!1){if(this._updateFrustumPlanes(),t&&this.rigCameras.length>0){let i=!1;for(const s of this.rigCameras)s._updateFrustumPlanes(),i=i||e.isInFrustum(s._frustumPlanes);return i}else return e.isInFrustum(this._frustumPlanes)}isCompletelyInFrustum(e){return this._updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)}getForwardRay(e=100,t,i){throw We("Ray")}getForwardRayToRef(e,t=100,i,s){throw We("Ray")}dispose(e,t=!1){for(this.onViewMatrixChangedObservable.clear(),this.onProjectionMatrixChangedObservable.clear(),this.onAfterCheckInputsObservable.clear(),this.onRestoreStateObservable.clear(),this.inputs&&this.inputs.clear(),this.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;){const s=this._rigCameras.pop();s&&s.dispose()}if(this._parentContainer){const s=this._parentContainer.cameras.indexOf(this);s>-1&&this._parentContainer.cameras.splice(s,1),this._parentContainer=null}if(this._rigPostProcess)this._rigPostProcess.dispose(this),this._rigPostProcess=null,this._postProcesses.length=0;else if(this.cameraRigMode!==Ge.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses.length=0;else{let s=this._postProcesses.length;for(;--s>=0;){const r=this._postProcesses[s];r&&r.dispose(this)}}let i=this.customRenderTargets.length;for(;--i>=0;)this.customRenderTargets[i].dispose();this.customRenderTargets.length=0,this._activeMeshes.dispose(),this.getScene().getEngine().releaseRenderPassId(this.renderPassId),super.dispose(e,t)}get isLeftCamera(){return this._isLeftCamera}get isRightCamera(){return this._isRightCamera}get leftCamera(){return this._rigCameras.length<1?null:this._rigCameras[0]}get rightCamera(){return this._rigCameras.length<2?null:this._rigCameras[1]}getLeftTarget(){return this._rigCameras.length<1?null:this._rigCameras[0].getTarget()}getRightTarget(){return this._rigCameras.length<2?null:this._rigCameras[1].getTarget()}setCameraRigMode(e,t){if(this.cameraRigMode!==e){for(;this._rigCameras.length>0;){const i=this._rigCameras.pop();i&&i.dispose()}if(this.cameraRigMode=e,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=t.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=pe.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==Ge.RIG_MODE_NONE){const i=this.createRigCamera(this.name+"_L",0);i&&(i._isLeftCamera=!0);const s=this.createRigCamera(this.name+"_R",1);s&&(s._isRightCamera=!0),i&&s&&(this._rigCameras.push(i),this._rigCameras.push(s))}this._setRigMode(t),this._cascadePostProcessesToRigCams(),this.update()}}_setRigMode(e){}_getVRProjectionMatrix(){return W.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.ignoreCameraMaxZ?0:this.maxZ,this._cameraRigParams.vrWorkMatrix,!0,this.getEngine().isNDCHalfZRange),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix,this._projectionMatrix),this._projectionMatrix}setCameraRigParameter(e,t){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[e]=t,e==="interaxialDistance"&&(this._cameraRigParams.stereoHalfAngle=pe.ToRadians(t/.0637))}createRigCamera(e,t){return null}_updateRigCameras(){for(let e=0;e<this._rigCameras.length;e++)this._rigCameras[e].minZ=this.minZ,this._rigCameras[e].maxZ=this.ignoreCameraMaxZ?0:this.maxZ,this._rigCameras[e].fov=this.fov,this._rigCameras[e].upVector.copyFrom(this.upVector);this.cameraRigMode===Ge.RIG_MODE_STEREOSCOPIC_ANAGLYPH&&(this._rigCameras[0].viewport=this._rigCameras[1].viewport=this.viewport)}_setupInputs(){}serialize(){const e=$e.Serialize(this);return e.uniqueId=this.uniqueId,e.type=this.getClassName(),this.parent&&this.parent._serializeAsParent(e),this.inputs&&this.inputs.serialize(e),$e.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.isEnabled=this.isEnabled(),e}clone(e,t=null){const i=$e.Clone(Ge.GetConstructorFromName(this.getClassName(),e,this.getScene(),this.interaxialDistance,this.isStereoscopicSideBySide),this);return i.name=e,i.parent=t,this.onClonedObservable.notifyObservers(i),i}getDirection(e){const t=T.Zero();return this.getDirectionToRef(e,t),t}get absoluteRotation(){return this.getWorldMatrix().decompose(void 0,this._absoluteRotation),this._absoluteRotation}getDirectionToRef(e,t){T.TransformNormalToRef(e,this.getWorldMatrix(),t)}static GetConstructorFromName(e,t,i,s=0,r=!0){const a=yi.Construct(e,t,i,{interaxial_distance:s,isStereoscopicSideBySide:r});return a||(()=>Ge._CreateDefaultParsedCamera(t,i))}computeWorldMatrix(){return this.getWorldMatrix()}static Parse(e,t){const i=e.type,s=Ge.GetConstructorFromName(i,e.name,t,e.interaxial_distance,e.isStereoscopicSideBySide),r=$e.Parse(s,e,t);if(e.parentId!==void 0&&(r._waitingParentId=e.parentId),e.parentInstanceIndex!==void 0&&(r._waitingParentInstanceIndex=e.parentInstanceIndex),r.inputs&&(r.inputs.parse(e),r._setupInputs()),e.upVector&&(r.upVector=T.FromArray(e.upVector)),r.setPosition&&(r.position.copyFromFloats(0,0,0),r.setPosition(T.FromArray(e.position))),e.target&&r.setTarget&&r.setTarget(T.FromArray(e.target)),e.cameraRigMode){const a=e.interaxial_distance?{interaxialDistance:e.interaxial_distance}:{};r.setCameraRigMode(e.cameraRigMode,a)}if(e.animations){for(let a=0;a<e.animations.length;a++){const o=e.animations[a],c=Kr("BABYLON.Animation");c&&r.animations.push(c.Parse(o))}yi.ParseAnimationRanges(r,e,t)}return e.autoAnimate&&t.beginAnimation(r,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),e.isEnabled!==void 0&&r.setEnabled(e.isEnabled),r}_calculateHandednessMultiplier(){let e=this.getScene().useRightHandedSystem?-1:1;return this.parent&&this.parent._getWorldMatrixDeterminant()<0&&(e*=-1),e}}Ge._CreateDefaultParsedCamera=(n,e)=>{throw We("UniversalCamera")};Ge.PERSPECTIVE_CAMERA=0;Ge.ORTHOGRAPHIC_CAMERA=1;Ge.FOVMODE_VERTICAL_FIXED=0;Ge.FOVMODE_HORIZONTAL_FIXED=1;Ge.RIG_MODE_NONE=0;Ge.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10;Ge.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11;Ge.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12;Ge.RIG_MODE_STEREOSCOPIC_OVERUNDER=13;Ge.RIG_MODE_STEREOSCOPIC_INTERLACED=14;Ge.RIG_MODE_VR=20;Ge.RIG_MODE_CUSTOM=22;Ge.ForceAttachControlToAlwaysPreventDefault=!1;N([lr("position")],Ge.prototype,"_position",void 0);N([lr("upVector")],Ge.prototype,"_upVector",void 0);N([H()],Ge.prototype,"orthoLeft",null);N([H()],Ge.prototype,"orthoRight",null);N([H()],Ge.prototype,"orthoBottom",null);N([H()],Ge.prototype,"orthoTop",null);N([H()],Ge.prototype,"fov",void 0);N([H()],Ge.prototype,"projectionPlaneTilt",void 0);N([H()],Ge.prototype,"minZ",void 0);N([H()],Ge.prototype,"maxZ",void 0);N([H()],Ge.prototype,"inertia",void 0);N([H()],Ge.prototype,"mode",null);N([H()],Ge.prototype,"layerMask",void 0);N([H()],Ge.prototype,"fovMode",void 0);N([H()],Ge.prototype,"cameraRigMode",void 0);N([H()],Ge.prototype,"interaxialDistance",void 0);N([H()],Ge.prototype,"isStereoscopicSideBySide",void 0);N([H()],Ge.prototype,"ignoreCameraMaxZ",void 0);function Mk(n,e,t,i){switch(e){case 5120:{let s=n.getInt8(t);return i&&(s=Math.max(s/127,-1)),s}case 5121:{let s=n.getUint8(t);return i&&(s=s/255),s}case 5122:{let s=n.getInt16(t,!0);return i&&(s=Math.max(s/32767,-1)),s}case 5123:{let s=n.getUint16(t,!0);return i&&(s=s/65535),s}case 5124:return n.getInt32(t,!0);case 5125:return n.getUint32(t,!0);case 5126:return n.getFloat32(t,!0);default:throw new Error(`Invalid component type ${e}`)}}function Ck(n,e,t,i,s){switch(e){case 5120:{i&&(s=Math.round(s*127)),n.setInt8(t,s);break}case 5121:{i&&(s=Math.round(s*255)),n.setUint8(t,s);break}case 5122:{i&&(s=Math.round(s*32767)),n.setInt16(t,s,!0);break}case 5123:{i&&(s=Math.round(s*65535)),n.setUint16(t,s,!0);break}case 5124:{n.setInt32(t,s,!0);break}case 5125:{n.setUint32(t,s,!0);break}case 5126:{n.setFloat32(t,s,!0);break}default:throw new Error(`Invalid component type ${e}`)}}function Jn(n){switch(n){case 5120:case 5121:return 1;case 5122:case 5123:return 2;case 5124:case 5125:case 5126:return 4;default:throw new Error(`Invalid type '${n}'`)}}function Ik(n){switch(n){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array;default:throw new Error(`Invalid component type '${n}'`)}}function ac(n,e,t,i,s,r,a,o){const c=new Array(i),u=new Array(i);if(n instanceof Array){let d=e/4;const f=t/4;for(let g=0;g<r;g+=i){for(let m=0;m<i;m++)c[m]=u[m]=n[d+m];o(u,g);for(let m=0;m<i;m++)c[m]!==u[m]&&(n[d+m]=u[m]);d+=f}}else{const d=ArrayBuffer.isView(n)?new DataView(n.buffer,n.byteOffset,n.byteLength):new DataView(n),f=Jn(s);for(let g=0;g<r;g+=i){for(let m=0,b=e;m<i;m++,b+=f)c[m]=u[m]=Mk(d,s,b,a);o(u,g);for(let m=0,b=e;m<i;m++,b+=f)c[m]!==u[m]&&Ck(d,s,b,a,u[m]);e+=t}}}function pT(n,e,t,i,s,r,a,o){const c=e*Jn(t),u=a*e;if(t!==5126||s!==c){const d=new Float32Array(u);return ac(n,i,s,e,t,u,r,(f,g)=>{for(let m=0;m<e;m++)d[g+m]=f[m]}),d}if(!(n instanceof Array||n instanceof Float32Array)||i!==0||n.length!==u)if(n instanceof Array){const d=i/4;return n.slice(d,d+u)}else{if(n instanceof ArrayBuffer)return new Float32Array(n,i,u);{const d=n.byteOffset+i;return(d&3)!==0&&(oe.Warn("Float array must be aligned to 4-bytes border"),o=!0),o?new Float32Array(n.buffer.slice(d,d+u*Float32Array.BYTES_PER_ELEMENT)):new Float32Array(n.buffer,d,u)}}return o?n.slice():n}function Pk(n,e,t,i,s,r,a){const o=Jn(t),c=Ik(t),u=r*e;if(Array.isArray(n)){if((i&3)!==0||(s&3)!==0)throw new Error("byteOffset and byteStride must be a multiple of 4 for number[] data.");const b=i/4,x=s/4;if(b+(r-1)*x+e>n.length)throw new Error("Last accessed index is out of bounds.");
231if(x<e)throw new Error("Data stride cannot be smaller than the component size.");if(x!==e){const E=new c(u);return ac(n,i,s,e,t,u,!1,(A,D)=>{for(let I=0;I<e;I++)E[D+I]=A[I]}),E}return new c(n.slice(b,b+u))}let d,f=i;if(n instanceof ArrayBuffer?d=n:(d=n.buffer,f+=n.byteOffset),f+(r-1)*s+e*o>d.byteLength)throw new Error("Last accessed byte is out of bounds.");const m=e*o;if(s<m)throw new Error("Byte stride cannot be smaller than the component's byte size.");if(s!==m){const b=new c(u);return ac(d,f,s,e,t,u,!1,(x,v)=>{for(let E=0;E<e;E++)b[v+E]=x[E]}),b}return o!==1&&(f&o-1)!==0&&(oe.Warn("Array must be aligned to border of element size. Data will be copied."),a=!0),a?new c(d.slice(f,f+u*o)):new c(d,f,u)}function Dk(n,e,t,i,s,r,a,o){const c=e*Jn(t),u=a*e;if(o.length!==u)throw new Error("Output length is not valid");if(t!==5126||s!==c){ac(n,i,s,e,t,u,r,(d,f)=>{for(let g=0;g<e;g++)o[f+g]=d[g]});return}if(n instanceof Array){const d=i/4;o.set(n,d)}else if(n instanceof ArrayBuffer){const d=new Float32Array(n,i,u);o.set(d)}else{const d=n.byteOffset+i;if((d&3)!==0){oe.Warn("Float array must be aligned to 4-bytes border"),o.set(new Float32Array(n.buffer.slice(d,d+u*Float32Array.BYTES_PER_ELEMENT)));return}const f=new Float32Array(n.buffer,d,u);o.set(f)}}class of{get isDisposed(){return this._isDisposed}constructor(e,t,i,s=0,r=!1,a=!1,o=!1,c,u){this._isAlreadyOwned=!1,this._isDisposed=!1,e&&e.getScene?this._engine=e.getScene().getEngine():this._engine=e,this._updatable=i,this._instanced=a,this._divisor=c||1,this._label=u,t instanceof qh?(this._data=null,this._buffer=t):(this._data=t,this._buffer=null),this.byteStride=o?s:s*Float32Array.BYTES_PER_ELEMENT,r||this.create()}createVertexBuffer(e,t,i,s,r,a=!1,o){const c=a?t:t*Float32Array.BYTES_PER_ELEMENT,u=s?a?s:s*Float32Array.BYTES_PER_ELEMENT:this.byteStride;return new O(this._engine,this,e,this._updatable,!0,u,r===void 0?this._instanced:r,c,i,void 0,void 0,!0,this._divisor||o)}isUpdatable(){return this._updatable}getData(){return this._data}getBuffer(){return this._buffer}getStrideSize(){return this.byteStride/Float32Array.BYTES_PER_ELEMENT}create(e=null){!e&&this._buffer||(e=e||this._data,e&&(this._buffer?this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e),this._data=e):this._updatable?(this._buffer=this._engine.createDynamicVertexBuffer(e,this._label),this._data=e):this._buffer=this._engine.createVertexBuffer(e,void 0,this._label)))}_rebuild(){if(this._data)this._buffer=null,this.create(this._data);else{if(!this._buffer)return;if(this._buffer.capacity>0){this._updatable?this._buffer=this._engine.createDynamicVertexBuffer(this._buffer.capacity,this._label):this._buffer=this._engine.createVertexBuffer(this._buffer.capacity,void 0,this._label);return}oe.Warn(`Missing data for buffer "${this._label}" ${this._buffer?"(uniqueId: "+this._buffer.uniqueId+")":""}. Buffer reconstruction failed.`),this._buffer=null}}update(e){this.create(e)}updateDirectly(e,t,i,s=!1){this._buffer&&this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e,s?t:t*Float32Array.BYTES_PER_ELEMENT,i?i*this.byteStride:void 0),t===0&&i===void 0?this._data=e:this._data=null)}_increaseReferences(){if(this._buffer){if(!this._isAlreadyOwned){this._isAlreadyOwned=!0;return}this._buffer.references++}}dispose(){this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._isDisposed=!0,this._data=null,this._buffer=null)}}class O{get isDisposed(){return this._isDisposed}get instanceDivisor(){return this._instanceDivisor}set instanceDivisor(e){const t=e!=0;this._instanceDivisor=e,t!==this._instanced&&(this._instanced=t,this._computeHashCode())}get _maxVerticesCount(){const e=this.getData();return e?Array.isArray(e)?e.length/(this.byteStride/4)-this.byteOffset/4:(e.byteLength-this.byteOffset)/this.byteStride:0}constructor(e,t,i,s,r,a,o,c,u,d,f=!1,g=!1,m=1,b=!1){this._isDisposed=!1;let x=!1;if(this.engine=e,typeof s=="object"&&s!==null?(x=s.updatable??!1,r=s.postponeInternalCreation,a=s.stride,o=s.instanced,c=s.offset,u=s.size,d=s.t
vendor: 61,896 bytes, line 231
231ype,f=s.normalized??!1,g=s.useBytes??!1,m=s.divisor??1,b=s.takeBufferOwnership??!1,this._label=s.label):x=!!s,t instanceof of?(this._buffer=t,this._ownsBuffer=b):(this._buffer=new of(e,t,x,a,r,o,g,m,this._label),this._ownsBuffer=!0),this.uniqueId=O._Counter++,this._kind=i,d===void 0){const E=this.getData();this.type=E?O.GetDataType(E):O.FLOAT}else this.type=d;const v=Jn(this.type);g?(this._size=u||(a?a/v:O.DeduceStride(i)),this.byteStride=a||this._buffer.byteStride||this._size*v,this.byteOffset=c||0):(this._size=u||a||O.DeduceStride(i),this.byteStride=a?a*v:this._buffer.byteStride||this._size*v,this.byteOffset=(c||0)*v),this.normalized=f,this._instanced=o!==void 0?o:!1,this._instanceDivisor=o?m:0,this._alignBuffer(),this._computeHashCode()}_computeHashCode(){this.hashCode=(this.type-5120<<0)+((this.normalized?1:0)<<3)+(this._size<<4)+((this._instanced?1:0)<<6)+(this.byteStride<<12)}_rebuild(){this._buffer?._rebuild()}getKind(){return this._kind}isUpdatable(){return this._buffer.isUpdatable()}getData(){return this._buffer.getData()}getFloatData(e,t){const i=this.getData();return i?pT(i,this._size,this.type,this.byteOffset,this.byteStride,this.normalized,e,t):null}getBuffer(){return this._buffer.getBuffer()}getWrapperBuffer(){return this._buffer}getStrideSize(){return this.byteStride/Jn(this.type)}getOffset(){return this.byteOffset/Jn(this.type)}getSize(e=!1){return e?this._size*Jn(this.type):this._size}getIsInstanced(){return this._instanced}getInstanceDivisor(){return this._instanceDivisor}create(e){this._buffer.create(e),this._alignBuffer()}update(e){this._buffer.update(e),this._alignBuffer()}updateDirectly(e,t,i=!1){this._buffer.updateDirectly(e,t,void 0,i),this._alignBuffer()}dispose(){this._ownsBuffer&&this._buffer.dispose(),this._isDisposed=!0}forEach(e,t){ac(this._buffer.getData(),this.byteOffset,this.byteStride,this._size,this.type,e,this.normalized,(i,s)=>{for(let r=0;r<this._size;r++)t(i[r],s+r)})}_alignBuffer(){}static DeduceStride(e){switch(e){case O.UVKind:case O.UV2Kind:case O.UV3Kind:case O.UV4Kind:case O.UV5Kind:case O.UV6Kind:return 2;case O.NormalKind:case O.PositionKind:return 3;case O.ColorKind:case O.ColorInstanceKind:case O.MatricesIndicesKind:case O.MatricesIndicesExtraKind:case O.MatricesWeightsKind:case O.MatricesWeightsExtraKind:case O.TangentKind:return 4;default:throw new Error("Invalid kind '"+e+"'")}}static GetDataType(e){return e instanceof Int8Array?O.BYTE:e instanceof Uint8Array?O.UNSIGNED_BYTE:e instanceof Int16Array?O.SHORT:e instanceof Uint16Array?O.UNSIGNED_SHORT:e instanceof Int32Array?O.INT:e instanceof Uint32Array?O.UNSIGNED_INT:O.FLOAT}static GetTypeByteLength(e){return Jn(e)}static ForEach(e,t,i,s,r,a,o,c){ac(e,t,i,s,r,a,o,(u,d)=>{for(let f=0;f<s;f++)c(u[f],d+f)})}static GetFloatData(e,t,i,s,r,a,o,c){return pT(e,t,i,s,r,a,o,c)}}O._Counter=0;O.BYTE=5120;O.UNSIGNED_BYTE=5121;O.SHORT=5122;O.UNSIGNED_SHORT=5123;O.INT=5124;O.UNSIGNED_INT=5125;O.FLOAT=5126;O.PositionKind="position";O.NormalKind="normal";O.TangentKind="tangent";O.UVKind="uv";O.UV2Kind="uv2";O.UV3Kind="uv3";O.UV4Kind="uv4";O.UV5Kind="uv5";O.UV6Kind="uv6";O.ColorKind="color";O.ColorInstanceKind="instanceColor";O.MatricesIndicesKind="matricesIndices";O.MatricesWeightsKind="matricesWeights";O.MatricesIndicesExtraKind="matricesIndicesExtra";O.MatricesWeightsExtraKind="matricesWeightsExtra";class Fm{constructor(e,t,i){this.bu=e,this.bv=t,this.distance=i,this.faceId=0,this.subMeshId=0,this._internalSubMeshId=0}}class ea{constructor(e,t,i){this.vectors=Xr(8,T.Zero),this.center=T.Zero(),this.centerWorld=T.Zero(),this.extendSize=T.Zero(),this.extendSizeWorld=T.Zero(),this.directions=Xr(3,T.Zero),this.vectorsWorld=Xr(8,T.Zero),this.minimumWorld=T.Zero(),this.maximumWorld=T.Zero(),this.minimum=T.Zero(),this.maximum=T.Zero(),this._drawWrapperFront=null,this._drawWrapperBack=null,this.reConstruct(e,t,i)}reConstruct(e,t,i){const s=e.x,r=e.y,a=e.z,o=t.x,c=t.y,u=t.z,d=this.vectors;this.minimum.copyFromFloats(s,r,a),this.maximum.copyFromFloats(o,c,u),d[0].copyFromFloats(s,r,a),d[1].copyFromFloats(o,c,u),d[2].copyFromFloats(o,r,a),d[3].copyFromFloats(s,c,a),d[4].copyFromFloats(s,r,u),d[5].copyFromFloats(o,c,a),d[6].copyFromFloats(s,c,u),d[7].copyFromFloats(o,r,u),t.addToRef(e,this.center).scaleInPlace(.5),t.subtractToRef(e,this.extendSize).scaleInPlace(.5),this._worldMatrix=i||W.IdentityReadOnly,this._update(this._worldMatrix)}scale(e){const t=ea._TmpVector3,i=this.maximum.subtractToRef(this.minimum,t[0]),s=i.length();i.normalizeFromLength(s);const r=s*e,a=i.scaleInPlace(r*.5),o=this.center.subtractToRef(a,t[1]),c=this.center.addToRef(a,t[2]);return this.reConstruct(o,c,this._worldMatrix),this}getWorldMatrix(){return this._worldMatrix}_update(e){const t=this.minimumWorld,i=this.maximumWorld,s=this.directions,r=this.vectorsWorld,a=this.vectors;if(e.isIdentity()){t.copyFrom(this.minimum),i.copyFrom(this.maximum);for(let o=0;o<8;++o)r[o].copyFrom(a[o]);this.extendSizeWorld.copyFrom(this.extendSize),this.centerWorld.copyFrom(this.center)}else{t.setAll(Number.MAX_VALUE),i.setAll(-Number.MAX_VALUE);for(let o=0;o<8;++o){const c=r[o];T.TransformCoordinatesToRef(a[o],e,c),t.minimizeInPlace(c),i.maximizeInPlace(c)}i.subtractToRef(t,this.extendSizeWorld).scaleInPlace(.5),i.addToRef(t,this.centerWorld).scaleInPlace(.5)}T.FromArrayToRef(e.m,0,s[0]),T.FromArrayToRef(e.m,4,s[1]),T.FromArrayToRef(e.m,8,s[2]),this._worldMatrix=e}isInFrustum(e){return ea.IsInFrustum(this.vectorsWorld,e)}isCompletelyInFrustum(e){return ea.IsCompletelyInFrustum(this.vectorsWorld,e)}intersectsPoint(e){const t=this.minimumWorld,i=this.maximumWorld,s=t.x,r=t.y,a=t.z,o=i.x,c=i.y,u=i.z,d=e.x,f=e.y,g=e.z,m=-bt;return!(o-d<m||m>d-s||c-f<m||m>f-r||u-g<m||m>g-a)}intersectsSphere(e){return ea.IntersectsSphere(this.minimumWorld,this.maximumWorld,e.centerWorld,e.radiusWorld)}intersectsMinMax(e,t){const i=this.minimumWorld,s=this.maximumWorld,r=i.x,a=i.y,o=i.z,c=s.x,u=s.y,d=s.z,f=e.x,g=e.y,m=e.z,b=t.x,x=t.y,v=t.z;return!(c<f||r>b||u<g||a>x||d<m||o>v)}dispose(){this._drawWrapperFront?.dispose(),this._drawWrapperBack?.dispose()}static Intersects(e,t){return e.intersectsMinMax(t.minimumWorld,t.maximumWorld)}static IntersectsSphere(e,t,i,s){const r=ea._TmpVector3[0];return T.ClampToRef(i,e,t,r),T.DistanceSquared(i,r)<=s*s}static IsCompletelyInFrustum(e,t){for(let i=0;i<6;++i){const s=t[i];for(let r=0;r<8;++r)if(s.dotCoordinate(e[r])<0)return!1}return!0}static IsInFrustum(e,t){for(let i=0;i<6;++i){let s=!0;const r=t[i];for(let a=0;a<8;++a)if(r.dotCoordinate(e[a])>=0){s=!1;break}if(s)return!1}return!0}}ea._TmpVector3=Xr(3,T.Zero);class sa{constructor(e,t,i){this.center=T.Zero(),this.centerWorld=T.Zero(),this.minimum=T.Zero(),this.maximum=T.Zero(),this.reConstruct(e,t,i)}reConstruct(e,t,i){this.minimum.copyFrom(e),this.maximum.copyFrom(t);const s=T.Distance(e,t);t.addToRef(e,this.center).scaleInPlace(.5),this.radius=s*.5,this._update(i||W.IdentityReadOnly)}scale(e){const t=this.radius*e,i=sa._TmpVector3,s=i[0].setAll(t),r=this.center.subtractToRef(s,i[1]),a=this.center.addToRef(s,i[2]);return this.reConstruct(r,a,this._worldMatrix),this}getWorldMatrix(){return this._worldMatrix}_update(e){if(e.isIdentity())this.centerWorld.copyFrom(this.center),this.radiusWorld=this.radius;else{T.TransformCoordinatesToRef(this.center,e,this.centerWorld);const t=sa._TmpVector3[0];T.TransformNormalFromFloatsToRef(1,1,1,e,t),this.radiusWorld=Math.max(Math.abs(t.x),Math.abs(t.y),Math.abs(t.z))*this.radius}}isInFrustum(e){const t=this.centerWorld,i=this.radiusWorld;for(let s=0;s<6;s++)if(e[s].dotCoordinate(t)<=-i)return!1;return!0}isCenterInFrustum(e){const t=this.centerWorld;for(let i=0;i<6;i++)if(e[i].dotCoordinate(t)<0)return!1;return!0}intersectsPoint(e){const t=T.DistanceSquared(this.centerWorld,e);return!(this.radiusWorld*this.radiusWorld<t)}static Intersects(e,t){const i=T.DistanceSquared(e.centerWorld,t.centerWorld),s=e.radiusWorld+t.radiusWorld;return!(s*s<i)}static CreateFromCenterAndRadius(e,t,i){this._TmpVector3[0].copyFrom(e),this._TmpVector3[1].copyFromFloats(0,0,t),this._TmpVector3[2].copyFrom(e),this._TmpVector3[0].addInPlace(this._TmpVector3[1]),this._TmpVector3[2].subtractInPlace(this._TmpVector3[1]);const s=new sa(this._TmpVector3[0],this._TmpVector3[2]);return i?s._worldMatrix=i:s._worldMatrix=W.Identity(),s}}sa._TmpVector3=Xr(3,T.Zero);const Lg={min:0,max:0},Ng={min:0,max:0},_T=(n,e,t)=>{const i=T.Dot(e.centerWorld,n),s=Math.abs(T.Dot(e.directions[0],n))*e.extendSize.x,r=Math.abs(T.Dot(e.directions[1],n))*e.extendSize.y,a=Math.abs(T.Dot(e.directions[2],n))*e.extendSize.z,o=s+r+a;t.min=i-o,t.max=i+o},ys=(n,e,t)=>(_T(n,e,Lg),_T(n,t,Ng),!(Lg.min>Ng.max||Ng.min>Lg.max));class Hs{constructor(e,t,i){this._isLocked=!1,this.boundingBox=new ea(e,t,i),this.boundingSphere=new sa(e,t,i)}reConstruct(e,t,i){this.boundingBox.reConstruct(e,t,i),this.boundingSphere.reConstruct(e,t,i)}get minimum(){return this.boundingBox.minimum}get maximum(){return this.boundingBox.maximum}get isLocked(){return this._isLocked}set isLocked(e){this._isLocked=e}update(e){this._isLocked||(this.boundingBox._update(e),this.boundingSphere._update(e))}centerOn(e,t){const i=Hs._TmpVector3[0].copyFrom(e).subtractInPlace(t),s=Hs._TmpVector3[1].copyFrom(e).addInPlace(t);return this.boundingBox.reConstruct(i,s,this.boundingBox.getWorldMatrix()),this.boundingSphere.reConstruct(i,s,this.boundingBox.getWorldMatrix()),this}encapsulate(e){const t=T.Minimize(this.minimum,e),i=T.Maximize(this.maximum,e);return this.reConstruct(t,i,this.boundingBox.getWorldMatrix()),this}encapsulateBoundingInfo(e){const t=te.Matrix[0];this.boundingBox.getWorldMatrix().invertToRef(t);const i=te.Vector3[0];return T.TransformCoordinatesToRef(e.boundingBox.minimumWorld,t,i),this.encapsulate(i),T.TransformCoordinatesToRef(e.boundingBox.maximumWorld,t,i),this.encapsulate(i),this}scale(e){return this.boundingBox.scale(e),this.boundingSphere.scale(e),this}isInFrustum(e,t=0){return(t===2||t===3)&&this.boundingSphere.isCenterInFrustum(e)?!0:this.boundingSphere.isInFrustum(e)?t===1||t===3?!0:this.boundingBox.isInFrustum(e):!1}get diagonalLength(){const e=this.boundingBox;return e.maximumWorld.subtractToRef(e.minimumWorld,Hs._TmpVector3[0]).length()}isCompletelyInFrustum(e){return this.boundingBox.isCompletelyInFrustum(e)}_checkCollision(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)}intersectsPoint(e){return!(!this.boundingSphere.centerWorld||!this.boundingSphere.intersectsPoint(e)||!this.boundingBox.intersectsPoint(e))}intersects(e,t){if(!sa.Intersects(this.boundingSphere,e.boundingSphere)||!ea.Intersects(this.boundingBox,e.boundingBox))return!1;if(!t)return!0;const i=this.boundingBox,s=e.boundingBox;return!(!ys(i.directions[0],i,s)||!ys(i.directions[1],i,s)||!ys(i.directions[2],i,s)||!ys(s.directions[0],i,s)||!ys(s.directions[1],i,s)||!ys(s.directions[2],i,s)||!ys(T.Cross(i.directions[0],s.directions[0]),i,s)||!ys(T.Cross(i.directions[0],s.directions[1]),i,s)||!ys(T.Cross(i.directions[0],s.directions[2]),i,s)||!ys(T.Cross(i.directions[1],s.directions[0]),i,s)||!ys(T.Cross(i.directions[1],s.directions[1]),i,s)||!ys(T.Cross(i.directions[1],s.directions[2]),i,s)||!ys(T.Cross(i.directions[2],s.directions[0]),i,s)||!ys(T.Cross(i.directions[2],s.directions[1]),i,s)||!ys(T.Cross(i.directions[2],s.directions[2]),i,s))}}Hs._TmpVector3=Xr(2,T.Zero);class Lf{static extractMinAndMaxIndexed(e,t,i,s,r,a){for(let o=i;o<i+s;o++){const c=t[o]*3,u=e[c],d=e[c+1],f=e[c+2];r.minimizeInPlaceFromFloats(u,d,f),a.maximizeInPlaceFromFloats(u,d,f)}}static extractMinAndMax(e,t,i,s,r,a){for(let o=t,c=t*s;o<t+i;o++,c+=s){const u=e[c],d=e[c+1],f=e[c+2];r.minimizeInPlaceFromFloats(u,d,f),a.maximizeInPlaceFromFloats(u,d,f)}}}N([la.filter((...[n,e])=>!Array.isArray(n)&&!Array.isArray(e))],Lf,"extractMinAndMaxIndexed",null);N([la.filter((...[n])=>!Array.isArray(n))],Lf,"extractMinAndMax",null);function Ok(n,e,t,i,s=null){const r=new T(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new T(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return Lf.extractMinAndMaxIndexed(n,e,t,i,r,a),s&&(r.x-=r.x*s.x+s.y,r.y-=r.y*s.x+s.y,r.z-=r.z*s.x+s.y,a.x+=a.x*s.x+s.y,a.y+=a.y*s.x+s.y,a.z+=a.z*s.x+s.y),{minimum:r,maximum:a}}function MC(n,e,t,i=null,s){const r=new T(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new T(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return s||(s=3),Lf.extractMinAndMax(n,e,t,s,r,a),i&&(r.x-=r.x*i.x+i.y,r.y-=r.y*i.x+i.y,r.z-=r.z*i.x+i.y,a.x+=a.x*i.x+i.y,a.y+=a.y*i.x+i.y,a.z+=a.z*i.x+i.y),{minimum:r,maximum:a}}class Qh{static GetEffect(e){return e.getPipelineContext===void 0?e.effect:e}constructor(e,t=!0){this._wasPreviouslyReady=!1,this._forceRebindOnNextCall=!0,this._wasPreviouslyUsingInstances=null,this.effect=null,this.defines=null,this.drawContext=e.createDrawContext(),t&&(this.materialContext=e.createMaterialContext())}setEffect(e,t,i=!0){this.effect=e,t!==void 0&&(this.defines=t),i&&this.drawContext?.reset()}dispose(e=!1){if(this.effect){const t=this.effect;e?t.dispose():zo.SetImmediate(()=>{t.getEngine().onEndFrameObservable.addOnce(()=>{t.dispose()})}),this.effect=null}this.drawContext?.dispose()}}class As{get materialDefines(){return this._mainDrawWrapperOverride?this._mainDrawWrapperOverride.defines:this._getDrawWrapper()?.defines}set materialDefines(e){const t=this._mainDrawWrapperOverride??this._getDrawWrapper(void 0,!0);t.defines=e}_getDrawWrapper(e,t=!1){e=e??this._engine.currentRenderPassId;let i=this._drawWrappers[e];return!i&&t&&(this._drawWrappers[e]=i=new Qh(this._mesh.getScene().getEngine())),i}_removeDrawWrapper(e,t=!0,i=!1){t&&this._drawWrappers[e]?.dispose(i),this._drawWrappers[e]=void 0}get effect(){return this._mainDrawWrapperOverride?this._mainDrawWrapperOverride.effect:this._getDrawWrapper()?.effect??null}get _drawWrapper(){return this._mainDrawWrapperOverride??this._getDrawWrapper(void 0,!0)}get _drawWrapperOverride(){return this._mainDrawWrapperOverride}_setMainDrawWrapperOverride(e){this._mainDrawWrapperOverride=e}setEffect(e,t=null,i,s=!0){const r=this._drawWrapper;r.setEffect(e,t,s),i!==void 0&&(r.materialContext=i),e||(r.defines=null,r.materialContext=void 0)}resetDrawCache(e,t=!1){if(this._drawWrappers)if(e!==void 0){this._removeDrawWrapper(e,!0,t);return}else for(const i of this._drawWrappers)i?.dispose(t);this._drawWrappers=[]}static AddToMesh(e,t,i,s,r,a,o,c=!0){return new As(e,t,i,s,r,a,o,c)}constructor(e,t,i,s,r,a,o,c=!0,u=!0){this.materialIndex=e,this.verticesStart=t,this.verticesCount=i,this.indexStart=s,this.indexCount=r,this._mainDrawWrapperOverride=null,this._linesIndexCount=0,this._linesIndexBuffer=null,this._lastColliderWorldVertices=null,this._lastColliderTransformMatrix=null,this._wasDispatched=!1,this._renderId=0,this._alphaIndex=0,this._distanceToCamera=0,this._currentMaterial=null,this._mesh=a,this._renderingMesh=o||a,u&&a.subMeshes.push(this),this._engine=this._mesh.getScene().getEngine(),this.resetDrawCache(),this._trianglePlanes=[],this._id=a.subMeshes.length-1,c&&(this.refreshBoundingInfo(),a.computeWorldMatrix(!0))}get IsGlobal(){return this.verticesStart===0&&this.verticesCount===this._mesh.getTotalVertices()&&this.indexStart===0&&this.indexCount===this._mesh.getTotalIndices()}getBoundingInfo(){return this.IsGlobal||this._mesh.hasThinInstances?this._mesh.getBoundingInfo():this._boundingInfo}setBoundingInfo(e){return this._boundingInfo=e,this}getMesh(){return this._mesh}getRenderingMesh(){return this._renderingMesh}getReplacementMesh(){return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null}getEffectiveMesh(){const e=this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null;return e||this._renderingMesh}getMaterial(e=!0){const t=this._renderingMesh.getMaterialForRenderPass(this._engine.currentRenderPassId)??this._renderingMesh.material;if(t){if(this._isMultiMaterial(t)){const i=t.getSubMaterial(this.materialIndex);return this._currentMaterial!==i&&(this._currentMaterial=i,this.resetDrawCache()),i}}else return e&&this._mesh.getScene()._hasDefaultMaterial?this._mesh.getScene().defaultMaterial:null;return t}_isMultiMaterial(e){return e.getSubMaterial!==void 0}refreshBoundingInfo(e=null){if(this._lastColliderWorldVertices=null,this.IsGlobal||!this._renderingMesh||!this._renderingMesh.geometry)return this;if(e||(e=this._renderingMesh.getVerticesData(O.PositionKind)),!e)return this._boundingInfo=this._mesh.getBoundingInfo(),this;const t=this._renderingMesh.getIndices();let i;if(this.indexStart===0&&this.indexCount===t.length){const s=this._renderingMesh.getBoundingInfo();i={minimum:s.minimum.clone(),maximum:s.maximum.clone()}}else i=Ok(e,t,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);return this._boundingInfo?this._boundingInfo.reConstruct(i.minimum,i.maximum):this._boundingInfo=new Hs(i.minimum,i.maximum),this}_checkCollision(e){return this.getBoundingInfo()._checkCollision(e)}updateBoundingInfo(e){let t=this.getBoundingInfo();return t||(this.refreshBoundingInfo(),t=this.getBoundingInfo()),t&&t.update(e),this}isInFrustum(e){const t=this.getBoundingInfo();return t?t.isInFrustum(e,this._mesh.cullingStrategy):!1}isCompletelyInFrustum(e){const t=this.getBoundingInfo();return t?t.isCompletelyInFrustum(e):!1}render(e){return this._renderingMesh.render(this,e,this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:void 0),this}_getLinesIndexBuffer(e,t){if(!this._linesIndexBuffer){const i=Math.floor(this.indexCount/3)*6,r=this.verticesStart+this.verticesCount>65535?new Uint32Array(i):new Uint16Array(i);let a=0;if(e.length===0)for(let o=this.indexStart;o<this.indexStart+this.indexCount;o+=3)r[a++]=o,r[a++]=o+1,r[a++]=o+1,r[a++]=o+2,r[a++]=o+2,r[a++]=o;else for(let o=this.indexStart;o<this.indexStart+this.indexCount;o+=3)r[a++]=e[o],r[a++]=e[o+1],r[a++]=e[o+1],r[a++]=e[o+2],r[a++]=e[o+2],r[a++]=e[o];this._linesIndexBuffer=t.createIndexBuffer(r),this._linesIndexCount=r.length}return this._linesIndexBuffer}canIntersects(e){const t=this.getBoundingInfo();return t?e.intersectsBox(t.boundingBox):!1}intersects(e,t,i,s,r){const a=this.getMaterial();if(!a)return null;let o=3,c=!1;switch(a.fillMode){case 3:case 5:case 6:case 8:return null;case 7:o=1,c=!0;break}return a.fillMode===4?i.length?this._intersectLines(e,t,i,this._mesh.intersectionThreshold,s):this._intersectUnIndexedLines(e,t,i,this._mesh.intersectionThreshold,s):!i.length&&this._mesh._unIndexed?this._intersectUnIndexedTriangles(e,t,i,s,r):this._intersectTriangles(e,t,i,o,c,s,r)}_intersectLines(e,t,i,s,r){let a=null;for(let o=this.indexStart;o<this.indexStart+this.indexCount;o+=2){const c=t[i[o]],u=t[i[o+1]],d=e.intersectionSegment(c,u,s);if(!(d<0)&&(r||!a||d<a.distance)&&(a=new Fm(null,null,d),a.faceId=o/2,r))break}return a}_intersectUnIndexedLines(e,t,i,s,r){let a=null;for(let o=this.verticesStart;o<this.verticesStart+this.verticesCount;o+=2){const c=t[o],u=t[o+1],d=e.intersectionSegment(c,u,s);if(!(d<0)&&(r||!a||d<a.distance)&&(a=new Fm(null,null,d),a.faceId=o/2,r))break}return a}_intersectTriangles(e,t,i,s,r,a,o){let c=null,u=-1;for(let d=this.indexStart;d<this.indexStart+this.indexCount-(3-s);d+=s){u++;const f=i[d],g=i[d+1],m=i[d+2];if(r&&m===4294967295){d+=2;continue}const b=t[f],x=t[g],v=t[m];if(!b||!x||!v||o&&!o(b,x,v,e,f,g,m))continue;const E=e.intersectsTriangle(b,x,v);if(E){if(E.distance<0)continue;if((a||!c||E.distance<c.distance)&&(c=E,c.faceId=u,a))break}}return c}_intersectUnIndexedTriangles(e,t,i,s,r){let a=null;for(let o=this.verticesStart;o<this.verticesStart+this.verticesCount;o+=3){const c=t[o],u=t[o+1],d=t[o+2];if(r&&!r(c,u,d,e,-1,-1,-1))continue;const f=e.intersectsTriangle(c,u,d);if(f){if(f.distance<0)continue;if((s||!a||f.distance<a.distance)&&(a=f,a.faceId=o/3,s))break}}return a}_rebuild(){this._linesIndexBuffer&&(this._linesIndexBuffer=null)}clone(e,t){const i=new As(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,e,t,!1);if(!this.IsGlobal){const s=this.getBoundingInfo();if(!s)return i;i._boundingInfo=new Hs(s.minimum,s.maximum)}return i}dispose(e=!1){this._linesIndexBuffer&&(this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer),this._linesIndexBuffer=null);const t=this._mesh.subMeshes.indexOf(this);this._mesh.subMeshes.splice(t,1),this.resetDrawCache(void 0,e)}getClassName(){return"SubMesh"}static CreateFromIndices(e,t,i,s,r,a=!0){let o=Number.MAX_VALUE,c=-Number.MAX_VALUE;const d=(r||s).getIndices();for(let f=t;f<t+i;f++){const g=d[f];g<o&&(o=g),g>c&&(c=g)}return new As(e,o,c-o+1,t,i,s,r,a)}}class Bg{}class ve{constructor(){this.uniqueId=0,this.metadata={},this._applyTo=Rk(this._applyToCoroutine.bind(this)),this.uniqueId=ve._UniqueIdGenerator,ve._UniqueIdGenerator++}set(e,t){switch(e.length||oe.Warn(`Setting vertex data kind '${t}' with an empty array`),t){case O.PositionKind:this.positions=e;break;case O.NormalKind:this.normals=e;break;case O.TangentKind:this.tangents=e;break;case O.UVKind:this.uvs=e;break;case O.UV2Kind:this.uvs2=e;break;case O.UV3Kind:this.uvs3=e;break;case O.UV4Kind:this.uvs4=e;break;case O.UV5Kind:this.uvs5=e;break;case O.UV6Kind:this.uvs6=e;break;case O.ColorKind:this.colors=e;break;case O.MatricesIndicesKind:this.matricesIndices=e;break;case O.MatricesWeightsKind:this.matricesWeights=e;break;case O.MatricesIndicesExtraKind:this.matricesIndicesExtra=e;break;case O.MatricesWeightsExtraKind:this.matricesWeightsExtra=e;break}}applyToMesh(e,t){return this._applyTo(e,t,!1),this}applyToGeometry(e,t){return this._applyTo(e,t,!1),this}updateMesh(e){return this._update(e),this}updateGeometry(e){return this._update(e),this}*_applyToCoroutine(e,t=!1,i){if(this.positions&&(e.setVerticesData(O.PositionKind,this.positions,t),i&&(yield)),this.normals&&(e.setVerticesData(O.NormalKind,this.normals,t),i&&(yield)),this.tangents&&(e.setVerticesData(O.TangentKind,this.tangents,t),i&&(yield)),this.uvs&&(e.setVerticesData(O.UVKind,this.uvs,t),i&&(yield)),this.uvs2&&(e.setVerticesData(O.UV2Kind,this.uvs2,t),i&&(yield)),this.uvs3&&(e.setVerticesData(O.UV3Kind,this.uvs3,t),i&&(yield)),this.uvs4&&(e.setVerticesData(O.UV4Kind,this.uvs4,t),i&&(yield)),this.uvs5&&(e.setVerticesData(O.UV5Kind,this.uvs5,t),i&&(yield)),this.uvs6&&(e.setVerticesData(O.UV6Kind,this.uvs6,t),i&&(yield)),this.colors){const s=this.positions&&this.colors.length===this.positions.length?3:4;e.setVerticesData(O.ColorKind,this.colors,t,s),this.hasVertexAlpha&&e.hasVertexAlpha!==void 0&&(e.hasVertexAlpha=!0),i&&(yield)}if(this.matricesIndices&&(e.setVerticesData(O.MatricesIndicesKind,this.matricesIndices,t),i&&(yield)),this.matricesWeights&&(e.setVerticesData(O.MatricesWeightsKind,this.matricesWeights,t),i&&(yield)),this.matricesIndicesExtra&&(e.setVerticesData(O.MatricesIndicesExtraKind,this.matricesIndicesExtra,t),i&&(yield)),this.matricesWeightsExtra&&(e.setVerticesData(O.MatricesWeightsExtraKind,this.matricesWeightsExtra,t),i&&(yield)),this.indices?(e.setIndices(this.indices,null,t),i&&(yield)):e.setIndices([],null),e.subMeshes&&this.materialInfos&&this.materialInfos.length>1){const s=e;s.subMeshes=[];for(const r of this.materialInfos)new As(r.materialIndex,r.verticesStart,r.verticesCount,r.indexStart,r.indexCount,s)}return this}_update(e,t,i){return this.positions&&e.updateVerticesData(O.PositionKind,this.positions,t,i),this.normals&&e.updateVerticesData(O.NormalKind,this.normals,t,i),this.tangents&&e.updateVerticesData(O.TangentKind,this.tangents,t,i),this.uvs&&e.updateVerticesData(O.UVKind,this.uvs,t,i),this.uvs2&&e.updateVerticesData(O.UV2Kind,this.uvs2,t,i),this.uvs3&&e.updateVerticesData(O.UV3Kind,this.uvs3,t,i),this.uvs4&&e.updateVerticesData(O.UV4Kind,this.uvs4,t,i),this.uvs5&&e.updateVerticesData(O.UV5Kind,this.uvs5,t,i),this.uvs6&&e.updateVerticesData(O.UV6Kind,this.uvs6,t,i),this.colors&&e.updateVerticesData(O.ColorKind,this.colors,t,i),this.matricesIndices&&e.updateVerticesData(O.MatricesIndicesKind,this.matricesIndices,t,i),this.matricesWeights&&e.updateVerticesData(O.MatricesWeightsKind,this.matricesWeights,t,i),this.matricesIndicesExtra&&e.updateVerticesData(O.MatricesIndicesExtraKind,this.matricesIndicesExtra,t,i),this.matricesWeightsExtra&&e.updateVerticesData(O.MatricesWeightsExtraKind,this.matricesWeightsExtra,t,i),this.indices&&e.setIndices(this.indices,null),this}static _TransformVector3Coordinates(e,t,i=0,s=e.length){const r=te.Vector3[0],a=te.Vector3[1];for(let o=i;o<i+s;o+=3)T.FromArrayToRef(e,o,r),T.TransformCoordinatesToRef(r,t,a),e[o]=a.x,e[o+1]=a.y,e[o+2]=a.z}static _TransformVector3Normals(e,t,i=0,s=e.length){const r=te.Vector3[0],a=te.Vector3[1];for(let o=i;o<i+s;o+=3)T.FromArrayToRef(e,o,r),T.TransformNormalToRef(r,t,a),e[o]=a.x,e[o+1]=a.y,e[o+2]=a.z}static _TransformVector4Normals(e,t,i=0,s=e.length){const r=te.Vector4[0],a=te.Vector4[1];for(let o=i;o<i+s;o+=4)rt.FromArrayToRef(e,o,r),rt.TransformNormalToRef(r,t,a),e[o]=a.x,e[o+1]=a.y,e[o+2]=a.z,e[o+3]=a.w}static _FlipFaces(e,t=0,i=e.length){for(let s=t;s<t+i;s+=3){const r=e[s+1];e[s+1]=e[s+2],e[s+2]=r}}transform(e){const t=e.determinant()<0;return this.positions&&ve._TransformVector3Coordinates(this.positions,e),this.normals&&ve._TransformVector3Normals(this.normals,e),this.tangents&&ve._TransformVector4Normals(this.tangents,e),t&&this.indices&&ve._FlipFaces(this.indices),this}splitBasedOnMaterialID(){if(!this.materialInfos||this.materialInfos.length<2)return[this];const e=[];for(const t of this.materialInfos){const i=new ve;if(this.positions&&(i.positions=this.positions.slice(t.verticesStart*3,(t.verticesCount+t.verticesStart)*3)),this.normals&&(i.normals=this.normals.slice(t.verticesStart*3,(t.verticesCount+t.verticesStart)*3)),this.tangents&&(i.tangents=this.tangents.slice(t.verticesStart*4,(t.verticesCount+t.verticesStart)*4)),this.colors&&(i.colors=this.colors.slice(t.verticesStart*4,(t.verticesCount+t.verticesStart)*4)),this.uvs&&(i.uvs=this.uvs.slice(t.verticesStart*2,(t.verticesCount+t.verticesStart)*2)),this.uvs2&&(i.uvs2=this.uvs2.slice(t.verticesStart*2,(t.verticesCount+t.verticesStart)*2)),this.uvs3&&(i.uvs3=this.uvs3.slice(t.verticesStart*2,(t.verticesCount+t.verticesStart)*2)),this.uvs4&&(i.uvs4=this.uvs4.slice(t.verticesStart*2,(t.verticesCount+t.verticesStart)*2)),this.uvs5&&(i.uvs5=this.uvs5.slice(t.verticesStart*2,(t.verticesCount+t.verticesStart)*2)),this.uvs6&&(i.uvs6=this.uvs6.slice(t.verticesStart*2,(t.verticesCount+t.verticesStart)*2)),this.matricesIndices&&(i.matricesIndices=this.matricesIndices.slice(t.verticesStart*4,(t.verticesCount+t.verticesStart)*4)),this.matricesIndicesExtra&&(i.matricesIndicesExtra=this.matricesIndicesExtra.slice(t.verticesStart*4,(t.verticesCount+t.verticesStart)*4)),this.matricesWeights&&(i.matricesWeights=this.matricesWeights.slice(t.verticesStart*4,(t.verticesCount+t.verticesStart)*4)),this.matricesWeightsExtra&&(i.matricesWeightsExtra=this.matricesWeightsExtra.slice(t.verticesStart*4,(t.verticesCount+t.verticesStart)*4)),this.indices){i.indices=[];for(let r=t.indexStart;r<t.indexStart+t.indexCount;r++)i.indices.push(this.indices[r]-t.verticesStart)}const s=new Bg;s.indexStart=0,s.indexCount=i.indices?i.indices.length:0,s.materialIndex=t.materialIndex,s.verticesStart=0,s.verticesCount=(i.positions?i.positions.length:0)/3,i.materialInfos=[s],e.push(i)}return e}merge(e,t=!1,i=!1,s=!1,r=!1){const a=Array.isArray(e)?e.map(o=>({vertexData:o})):[{vertexData:e}];return Ob(this._mergeCoroutine(void 0,a,t,!1,i,s,r))}*_mergeCoroutine(e,t,i=!1,s,r,a=!1,o=!1){this._validate();let c=t.map(m=>m.vertexData),u=this;if(o)for(const m of c)m&&(m._validate(),!this.normals&&m.normals&&(this.normals=new Float32Array(this.positions.length)),!this.tangents&&m.tangents&&(this.tangents=new Float32Array(this.positions.length/3*4)),!this.uvs&&m.uvs&&(this.uvs=new Float32Array(this.positions.length/3*2)),!this.uvs2&&m.uvs2&&(this.uvs2=new Float32Array(this.positions.length/3*2)),!this.uvs3&&m.uvs3&&(this.uvs3=new Float32Array(this.positions.length/3*2)),!this.uvs4&&m.uvs4&&(this.uvs4=new Float32Array(this.positions.length/3*2)),!this.uvs5&&m.uvs5&&(this.uvs5=new Float32Array(this.positions.length/3*2)),!this.uvs6&&m.uvs6&&(this.uvs6=new Float32Array(this.positions.length/3*2)),!this.colors&&m.colors&&(this.colors=new Float32Array(this.positions.length/3*4),this.colors.fill(1)),!this.matricesIndices&&m.matricesIndices&&(this.matricesIndices=new Float32Array(this.positions.length/3*4)),!this.matricesWeights&&m.matricesWeights&&(this.matricesWeights=new Float32Array(this.positions.length/3*4)),!this.matricesIndicesExtra&&m.matricesIndicesExtra&&(this.matricesIndicesExtra=new Float32Array(this.positions.length/3*4)),!this.matricesWeightsExtra&&m.matricesWeightsExtra&&(this.matricesWeightsExtra=new Float32Array(this.positions.length/3*4)));for(const m of c)if(m){if(o)this.normals&&!m.normals&&(m.normals=new Float32Array(m.positions.length)),this.tangents&&!m.tangents&&(m.tangents=new Float32Array(m.positions.length/3*4)),this.uvs&&!m.uvs&&(m.uvs=new Float32Array(m.positions.length/3*2)),this.uvs2&&!m.uvs2&&(m.uvs2=new Float32Array(m.positions.length/3*2)),this.uvs3&&!m.uvs3&&(m.uvs3=new Float32Array(m.positions.length/3*2)),this.uvs4&&!m.uvs4&&(m.uvs4=new Float32Array(m.positions.length/3*2)),this.uvs5&&!m.uvs5&&(m.uvs5=new Float32Array(m.positions.length/3*2)),this.uvs6&&!m.uvs6&&(m.uvs6=new Float32Array(m.positions.length/3*2)),this.colors&&!m.colors&&(m.colors=new Float32Array(m.positions.length/3*4),m.colors.fill(1)),this.matricesIndices&&!m.matricesIndices&&(m.matricesIndices=new Float32Array(m.positions.length/3*4)),this.matricesWeights&&!m.matricesWeights&&(m.matricesWeights=new Float32Array(m.positions.length/3*4)),this.matricesIndicesExtra&&!m.matricesIndicesExtra&&(m.matricesIndicesExtra=new Float32Array(m.positions.length/3*4)),this.matricesWeightsExtra&&!m.matricesWeightsExtra&&(m.matricesWeightsExtra=new Float32Array(m.positions.length/3*4));else if(m._validate(),!this.normals!=!m.normals||!this.tangents!=!m.tangents||!this.uvs!=!m.uvs||!this.uvs2!=!m.uvs2||!this.uvs3!=!m.uvs3||!this.uvs4!=!m.uvs4||!this.uvs5!=!m.uvs5||!this.uvs6!=!m.uvs6||!this.colors!=!m.colors||!this.matricesIndices!=!m.matricesIndices||!this.matricesWeights!=!m.matricesWeights||!this.matricesIndicesExtra!=!m.matricesIndicesExtra||!this.matricesWeightsExtra!=!m.matricesWeightsExtra)throw new Error("Cannot merge vertex data that do not have the same set of attributes")}if(a){let m=0,b=0,x=0;const v=[];let E=null;const A=[];for(const I of this.splitBasedOnMaterialID())A.push({vertexData:I,transform:e});for(const I of t)if(I.vertexData)for(const R of I.vertexData.splitBasedOnMaterialID())A.push({vertexData:R,transform:I.transform});A.sort((I,R)=>{const C=I.vertexData.materialInfos?I.vertexData.materialInfos[0].materialIndex:0,M=R.vertexData.materialInfos?R.vertexData.materialInfos[0].materialIndex:0;return C>M?1:C===M?0:-1});for(const I of A){const R=I.vertexData;if(R.materialInfos?m=R.materialInfos[0].materialIndex:m=0,E&&E.materialIndex===m)E.indexCount+=R.indices.length,E.verticesCount+=R.positions.length/3;else{const C=new Bg;C.materialIndex=m,C.indexStart=b,C.indexCount=R.indices.length,C.verticesStart=x,C.verticesCount=R.positions.length/3,v.push(C),E=C}b+=R.indices.length,x+=R.positions.length/3}const D=A.splice(0,1)[0];u=D.vertexData,e=D.transform,c=A.map(I=>I.vertexData),t=A,this.materialInfos=v}const d=c.reduce((m,b)=>m+(b.indices?.length??0),u.indices?.length??0);let g=r||c.some(m=>m.indices===u.indices)?u.indices?.slice():u.indices;if(d>0){let m=g?.length??0;if(g||(g=new Array(d)),g.length!==d){if(Array.isArray(g))g.length=d;else{const x=i||g instanceof Uint32Array?new Uint32Array(d):new Uint16Array(d);x.set(g),g=x}e&&e.determinant()<0&&ve._FlipFaces(g,0,m)}let b=u.positions?u.positions.length/3:0;for(const{vertexData:x,transform:v}of t)if(x.indices){for(let E=0;E<x.indices.length;E++)g[m+E]=x.indices[E]+b;v&&v.determinant()<0&&ve._FlipFaces(g,m,x.indices.length),b+=x.positions.length/3,m+=x.indices.length,s&&(yield)}}return this.indices=g,this.positions=ve._MergeElement(O.PositionKind,u.positions,e,t.map(m=>[m.vertexData.positions,m.transform])),s&&(yield),u.normals&&(this.normals=ve._MergeElement(O.NormalKind,u.normals,e,t.map(m=>[m.vertexData.normals,m.transform])),s&&(yield)),u.tangents&&(this.tangents=ve._MergeElement(O.TangentKind,u.tangents,e,t.map(m=>[m.vertexData.tangents,m.transform])),s&&(yield)),u.uvs&&(this.uvs=ve._MergeElement(O.UVKind,u.uvs,e,t.map(m=>[m.vertexData.uvs,m.transform])),s&&(yield)),u.uvs2&&(this.uvs2=ve._MergeElement(O.UV2Kind,u.uvs2,e,t.map(m=>[m.vertexData.uvs2,m.transform])),s&&(yield)),u.uvs3&&(this.uvs3=ve._MergeElement(O.UV3Kind,u.uvs3,e,t.map(m=>[m.vertexData.uvs3,m.transform])),s&&(yield)),u.uvs4&&(this.uvs4=ve._MergeElement(O.UV4Kind,u.uvs4,e,t.map(m=>[m.vertexData.uvs4,m.transform])),s&&(yield)),u.uvs5&&(this.uvs5=ve._MergeElement(O.UV5Kind,u.uvs5,e,t.map(m=>[m.vertexData.uvs5,m.transform])),s&&(yield)),u.uvs6&&(this.uvs6=ve._MergeElement(O.UV6Kind,u.uvs6,e,t.map(m=>[m.vertexData.uvs6,m.transform])),s&&(yield)),u.colors&&(this.colors=ve._MergeElement(O.ColorKind,u.colors,e,t.map(m=>[m.vertexData.colors,m.transform])),(u.hasVertexAlpha!==void 0||t.some(m=>m.vertexData.hasVertexAlpha!==void 0))&&(this.hasVertexAlpha=u.hasVertexAlpha||t.some(m=>m.vertexData.hasVertexAlpha)),s&&(yield)),u.matricesIndices&&(this.matricesIndices=ve._MergeElement(O.MatricesIndicesKind,u.matricesIndices,e,t.map(m=>[m.vertexData.matricesIndices,m.transform])),s&&(yield)),u.matricesWeights&&(this.matricesWeights=ve._MergeElement(O.MatricesWeightsKind,u.matricesWeights,e,t.map(m=>[m.vertexData.matricesWeights,m.transform])),s&&(yield)),u.matricesIndicesExtra&&(this.matricesIndicesExtra=ve._MergeElement(O.MatricesIndicesExtraKind,u.matricesIndicesExtra,e,t.map(m=>[m.vertexData.matricesIndicesExtra,m.transform])),s&&(yield)),u.matricesWeightsExtra&&(this.matricesWeightsExtra=ve._MergeElement(O.MatricesWeightsExtraKind,u.matricesWeightsExtra,e,t.map(m=>[m.vertexData.matricesWeightsExtra,m.transform]))),this}static _MergeElement(e,t,i,s){const r=s.filter(c=>c[0]!==null&&c[0]!==void 0);if(!t&&r.length==0)return t;if(!t)return this._MergeElement(e,r[0][0],r[0][1],r.slice(1));const a=r.reduce((c,u)=>c+u[0].length,t.length),o=e===O.PositionKind?ve._TransformVector3Coordinates:e===O.NormalKind?ve._TransformVector3Normals:e===O.TangentKind?ve._TransformVector4Normals:()=>{};if(t instanceof Float32Array){const c=new Float32Array(a);c.set(t),i&&o(c,i,0,t.length);let u=t.length;for(const[d,f]of r)c.set(d,u),f&&o(c,f,u,d.length),u+=d.length;return c}else{const c=new Array(a);for(let d=0;d<t.length;d++)c[d]=t[d];i&&o(c,i,0,t.length);let u=t.length;for(const[d,f]of r){for(let g=0;g<d.length;g++)c[u+g]=d[g];f&&o(c,f,u,d.length),u+=d.length}return c}}_validate(){if(!this.positions)throw new ua("Positions are required",Ko.MeshInvalidPositionsError);const e=(s,r)=>{const a=O.DeduceStride(s);if(r.length%a!==0)throw new Error("The "+s+"s array count must be a multiple of "+a);return r.length/a},t=e(O.PositionKind,this.positions),i=(s,r)=>{const a=e(s,r);if(a!==t)throw new Error("The "+s+"s element count ("+a+") does not match the positions count ("+t+")")};this.normals&&i(O.NormalKind,this.normals),this.tangents&&i(O.TangentKind,this.tangents),this.uvs&&i(O.UVKind,this.uvs),this.uvs2&&i(O.UV2Kind,this.uvs2),this.uvs3&&i(O.UV3Kind,this.uvs3),this.uvs4&&i(O.UV4Kind,this.uvs4),this.uvs5&&i(O.UV5Kind,this.uvs5),this.uvs6&&i(O.UV6Kind,this.uvs6),this.colors&&i(O.ColorKind,this.colors),this.matricesIndices&&i(O.MatricesIndicesKind,this.matricesIndices),this.matricesWeights&&i(O.MatricesWeightsKind,this.matricesWeights),this.matricesIndicesExtra&&i(O.MatricesIndicesExtraKind,this.matricesIndicesExtra),this.matricesWeightsExtra&&i(O.MatricesWeightsExtraKind,this.matricesWeightsExtra)}clone(){const e=this.serialize();return ve.Parse(e)}serialize(){const e={};if(this.positions&&(e.positions=Array.from(this.positions)),this.normals&&(e.normals=Array.from(this.normals)),this.tangents&&(e.tangents=Array.from(this.tangents)),this.uvs&&(e.uvs=Array.from(this.uvs)),this.uvs2&&(e.uvs2=Array.from(this.uvs2)),this.uvs3&&(e.uvs3=Array.from(this.uvs3)),this.uvs4&&(e.uvs4=Array.from(this.uvs4)),this.uvs5&&(e.uvs5=Array.from(this.uvs5)),this.uvs6&&(e.uvs6=Array.from(this.uvs6)),this.colors&&(e.colors=Array.from(this.colors),e.hasVertexAlpha=this.hasVertexAlpha),this.matricesIndices&&(e.matricesIndices=Array.from(this.matricesIndices),e.matricesIndicesExpanded=!0),this.matricesWeights&&(e.matricesWeights=Array.from(this.matricesWeights)),this.matricesIndicesExtra&&(e.matricesIndicesExtra=Array.from(this.matricesIndicesExtra),e.matricesIndicesExtraExpanded=!0),this.matricesWeightsExtra&&(e.matricesWeightsExtra=Array.from(this.matricesWeightsExtra)),e.indices=this.indices?Array.from(this.indices):[],this.materialInfos){e.materialInfos=[];for(const t of this.materialInfos){const i={indexStart:t.indexStart,indexCount:t.indexCount,materialIndex:t.materialIndex,verticesStart:t.verticesStart,verticesCount:t.verticesCount};e.materialInfos.push(i)}}return e}static ExtractFromMesh(e,t,i){return ve._ExtractFrom(e,t,i)}static ExtractFromGeometry(e,t,i){return ve._ExtractFrom(e,t,i)}static _ExtractFrom(e,t,i){const s=new ve;if(e.isVerticesDataPresent(O.PositionKind)&&(s.positions=e.getVerticesData(O.PositionKind,t,i)),e.isVerticesDataPresent(O.NormalKind)&&(s.normals=e.getVerticesData(O.NormalKind,t,i)),e.isVerticesDataPresent(O.TangentKind)&&(s.tangents=e.getVerticesData(O.TangentKind,t,i)),e.isVerticesDataPresent(O.UVKind)&&(s.uvs=e.getVerticesData(O.UVKind,t,i)),e.isVerticesDataPresent(O.UV2Kind)&&(s.uvs2=e.getVerticesData(O.UV2Kind,t,i)),e.isVerticesDataPresent(O.UV3Kind)&&(s.uvs3=e.getVerticesData(O.UV3Kind,t,i)),e.isVerticesDataPresent(O.UV4Kind)&&(s.uvs4=e.getVerticesData(O.UV4Kind,t,i)),e.isVerticesDataPresent(O.UV5Kind)&&(s.uvs5=e.getVerticesData(O.UV5Kind,t,i)),e.isVerticesDataPresent(O.UV6Kind)&&(s.uvs6=e.getVerticesData(O.UV6Kind,t,i)),e.isVerticesDataPresent(O.ColorKind)){const r=e.geometry||e,a=r.getVertexBuffer(O.ColorKind),o=r.getVerticesData(O.ColorKind,t,i);if(a.getSize()===3){const c=new Float32Array(o.length*4/3);for(let u=0,d=0;u<o.length;u+=3,d+=4)c[d]=o[u],c[d+1]=o[u+1],c[d+2]=o[u+2],c[d+3]=1;s.colors=c}else if(a.getSize()===4)s.colors=o;else throw new Error(`Unexpected number of color components: ${a.getSize()}`)}return e.isVerticesDataPresent(O.MatricesIndicesKind)&&(s.matricesIndices=e.getVerticesData(O.MatricesIndicesKind,t,i)),e.isVerticesDataPresent(O.MatricesWeightsKind)&&(s.matricesWeights=e.getVerticesData(O.MatricesWeightsKind,t,i)),e.isVerticesDataPresent(O.MatricesIndicesExtraKind)&&(s.matricesIndicesExtra=e.getVerticesData(O.MatricesIndicesExtraKind,t,i)),e.isVerticesDataPresent(O.MatricesWeightsExtraKind)&&(s.matricesWeightsExtra=e.getVerticesData(O.MatricesWeightsExtraKind,t,i)),s.indices=e.getIndices(t,i),s}static CreateRibbon(e){throw We("ribbonBuilder")}static CreateBox(e){throw We("boxBuilder")}static CreateTiledBox(e){throw We("tiledBoxBuilder")}static CreateTiledPlane(e){throw We("tiledPlaneBuilder")}static CreateSphere(e){throw We("sphereBuilder")}static CreateCylinder(e){throw We("cylinderBuilder")}static CreateTorus(e){throw We("torusBuilder")}static CreateLineSystem(e){throw We("linesBuilder")}static CreateDashedLines(e){throw We("linesBuilder")}static CreateGround(e){throw We("groundBuilder")}static CreateTiledGround(e){throw We("groundBuilder")}static CreateGroundFromHeightMap(e){throw We("groundBuilder")}static CreatePlane(e){throw We("planeBuilder")}static CreateDisc(e){throw We("discBuilder")}static CreatePolygon(e,t,i,s,r,a,o){throw We("polygonBuilder")}static CreateIcoSphere(e){throw We("icoSphereBuilder")}static CreatePolyhedron(e){throw We("polyhedronBuilder")}static CreateCapsule(e={orientation:T.Up(),subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6}){throw We("capsuleBuilder")}static CreateTorusKnot(e){throw We("torusKnotBuilder")}static ComputeNormals(e,t,i,s){let r=0,a=0,o=0,c=0,u=0,d=0,f=0,g=0,m=0,b=0,x=0,v=0,E=0,A=0,D=0,I=0,R=0,C=0,M=0,F=0,U=!1,k=!1,q=!1,Q=!1,ie=1,$=0,ce=null;s&&(U=!!s.facetNormals,k=!!s.facetPositions,q=!!s.facetPartitioning,ie=s.useRightHandedSystem===!0?-1:1,$=s.ratio||0,Q=!!s.depthSort,ce=s.distanceTo,Q&&ce===void 0&&(ce=T.Zero()));let G=0,K=0,X=0,J=0;for(q&&s&&s.bbSize&&(G=s.subDiv.X*$/s.bbSize.x,K=s.subDiv.Y*$/s.bbSize.y,X=s.subDiv.Z*$/s.bbSize.z,J=s.subDiv.max*s.subDiv.max,s.facetPartitioning.length=0),r=0;r<e.length;r++)i[r]=0;const se=t.length/3|0;for(r=0;r<se;r++){if(v=t[r*3]*3,E=v+1,A=v+2,D=t[r*3+1]*3,I=D+1,R=D+2,C=t[r*3+2]*3,M=C+1,F=C+2,a=e[v]-e[D],o=e[E]-e[I],c=e[A]-e[R],u=e[C]-e[D],d=e[M]-e[I],f=e[F]-e[R],g=ie*(o*f-c*d),m=ie*(c*u-a*f),b=ie*(a*d-o*u),x=Math.sqrt(g*g+m*m+b*b),x=x===0?1:x,g/=x,m/=x,b/=x,U&&s&&(s.facetNormals[r].x=g,s.facetNormals[r].y=m,s.facetNormals[r].z=b),k&&s&&(s.facetPositions[r].x=(e[v]+e[D]+e[C])/3,s.facetPositions[r].y=(e[E]+e[I]+e[M])/3,s.facetPositions[r].z=(e[A]+e[R]+e[F])/3),q&&s){const w=Math.floor((s.facetPositions[r].x-s.bInfo.minimum.x*$)*G),L=Math.floor((s.facetPositions[r].y-s.bInfo.minimum.y*$)*K),V=Math.floor((s.facetPositions[r].z-s.bInfo.minimum.z*$)*X),j=Math.floor((e[v]-s.bInfo.minimum.x*$)*G),ae=Math.floor((e[E]-s.bInfo.minimum.y*$)*K),he=Math.floor((e[A]-s.bInfo.minimum.z*$)*X),be=Math.floor((e[D]-s.bInfo.minimum.x*$)*G),Le=Math.floor((e[I]-s.bInfo.minimum.y*$)*K),Xe=Math.floor((e[R]-s.bInfo.minimum.z*$)*X),it=Math.floor((e[C]-s.bInfo.minimum.x*$)*G),ut=Math.floor((e[M]-s.bInfo.minimum.y*$)*K),Oe=Math.floor((e[F]-s.bInfo.minimum.z*$)*X),Qe=j+s.subDiv.max*ae+J*he,Be=be+s.subDiv.max*Le+J*Xe,Ot=it+s.subDiv.max*ut+J*Oe,Wt=w+s.subDiv.max*L+J*V;s.facetPartitioning[Wt]=s.facetPartitioning[Wt]?s.facetPartitioning[Wt]:[],s.facetPartitioning[Qe]=s.facetPartitioning[Qe]?s.facetPartitioning[Qe]:[],s.facetPartitioning[Be]=s.facetPartitioning[Be]?s.facetPartitioning[Be]:[],s.facetPartitioning[Ot]=s.facetPartitioning[Ot]?s.facetPartitioning[Ot]:[],s.facetPartitioning[Qe].push(r),Be!=Qe&&s.facetPartitioning[Be].push(r),Ot==Be||Ot==Qe||s.facetPartitioning[Ot].push(r),Wt==Qe||Wt==Be||Wt==Ot||s.facetPartitioning[Wt].push(r)}if(Q&&s&&s.facetPositions){const w=s.depthSortedFacets[r];w.ind=r*3,w.sqDistance=T.DistanceSquared(s.facetPositions[r],ce)}i[v]+=g,i[E]+=m,i[A]+=b,i[D]+=g,i[I]+=m,i[R]+=b,i[C]+=g,i[M]+=m,i[F]+=b}for(r=0;r<i.length/3;r++)g=i[r*3],m=i[r*3+1],b=i[r*3+2],x=Math.sqrt(g*g+m*m+b*b),x=x===0?1:x,g/=x,m/=x,b/=x,i[r*3]=g,i[r*3+1]=m,i[r*3+2]=b}static _ComputeSides(e,t,i,s,r,a,o){const c=i.length,u=s.length;let d,f;switch(e=e||ve.DEFAULTSIDE,e){case ve.FRONTSIDE:break;case ve.BACKSIDE:for(d=0;d<c;d+=3){const g=i[d];i[d]=i[d+2],i[d+2]=g}for(f=0;f<u;f++)s[f]=-s[f];break;case ve.DOUBLESIDE:{const g=t.length,m=g/3;for(let v=0;v<g;v++)t[g+v]=t[v];for(d=0;d<c;d+=3)i[d+c]=i[d+2]+m,i[d+1+c]=i[d+1]+m,i[d+2+c]=i[d]+m;for(f=0;f<u;f++)s[u+f]=-s[f];const b=r.length;let x=0;for(x=0;x<b;x++)r[x+b]=r[x];for(a=a||new rt(0,0,1,1),o=o||new rt(0,0,1,1),x=0,d=0;d<b/2;d++)r[x]=a.x+(a.z-a.x)*r[x],r[x+1]=a.y+(a.w-a.y)*r[x+1],r[x+b]=o.x+(o.z-o.x)*r[x+b],r[x+b+1]=o.y+(o.w-o.y)*r[x+b+1],x+=2;break}}}static Parse(e){const t=new ve,i=e.positions;i&&t.set(i,O.PositionKind);const s=e.normals;s&&t.set(s,O.NormalKind);const r=e.tangents;r&&t.set(r,O.TangentKind);const a=e.uvs;a&&t.set(a,O.UVKind);const o=e.uvs2;o&&t.set(o,O.UV2Kind);const c=e.uvs3;c&&t.set(c,O.UV3Kind);const u=e.uvs4;u&&t.set(u,O.UV4Kind);const d=e.uvs5;d&&t.set(d,O.UV5Kind);const f=e.uvs6;f&&t.set(f,O.UV6Kind);const g=e.colors;g&&(t.set(Ze.CheckColors4(g,i.length/3),O.ColorKind),e.hasVertexAlpha!==void 0&&(t.hasVertexAlpha=e.hasVertexAlpha));const m=e.matricesIndices;m&&t.set(m,O.MatricesIndicesKind);const b=e.matricesWeights;b&&t.set(b,O.MatricesWeightsKind);const x=e.indices;x&&(t.indices=x);const v=e.materialInfos;if(v){t.materialInfos=[];for(const E of v){const A=new Bg;A.indexCount=E.indexCount,A.indexStart=E.indexStart,A.verticesCount=E.verticesCount,A.verticesStart=E.verticesStart,A.materialIndex=E.materialIndex,t.materialInfos.push(A)}}return t}static ImportVertexData(e,t){const i=ve.Parse(e);t.setAllVerticesData(i,e.updatable)}}ve.FRONTSIDE=0;ve.BACKSIDE=1;ve.DOUBLESIDE=2;ve.DEFAULTSIDE=0;ve._UniqueIdGenerator=0;N([la.filter((...[n])=>!Array.isArray(n))],ve,"_TransformVector3Coordinates",null);N([la.filter((...[n])=>!Array.isArray(n))],ve,"_TransformVector3Normals",null);N([la.filter((...[n])=>!Array.isArray(n))],ve,"_TransformVector4Normals",null);N([la.filter((...[n])=>!Array.isArray(n))],ve,"_FlipFaces",null);class bi{static get ForceFullSceneLoadingForIncremental(){return bi._ForceFullSceneLoadingForIncremental}static set ForceFullSceneLoadingForIncremental(e){bi._ForceFullSceneLoadingForIncremental=e}static get ShowLoadingScreen(){return bi._ShowLoadingScreen}static set ShowLoadingScreen(e){bi._ShowLoadingScreen=e}static get loggingLevel(){return bi._LoggingLevel}static set loggingLevel(e){bi._LoggingLevel=e}static get CleanBoneMatrixWeights(){return bi._CleanBoneMatrixWeights}static set CleanBoneMatrixWeights(e){bi._CleanBoneMatrixWeights=e}}bi._ForceFullSceneLoadingForIncremental=!1;bi._ShowLoadingScreen=!0;bi._CleanBoneMatrixWeights=!1;bi._LoggingLevel=0;class ps{get boundingBias(){return this._boundingBias}set boundingBias(e){this._boundingBias?this._boundingBias.copyFrom(e):this._boundingBias=e.clone(),this._updateBoundingInfo(!0,null)}static CreateGeometryForMesh(e){const t=new ps(ps.RandomId(),e.getScene());return t.applyToMesh(e),t}get meshes(){return this._meshes}constructor(e,t,i,s=!1,r=null){this.delayLoadState=0,this._totalVertices=0,this._isDisposed=!1,this._extend={minimum:new T(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),maximum:new T(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},this._indexBufferIsUpdatable=!1,this._positionsCache=[],this._parentContainer=null,this.useBoundingInfoFromGeometry=!1,this._scene=t||Ke.LastCreatedScene,this._scene&&(this.id=e,this.uniqueId=this._scene.getUniqueId(),this._engine=this._scene.getEngine(),this._meshes=[],this._vertexBuffers={},this._indices=[],this._updatable=s,i?this.setAllVerticesData(i,s):this._totalVertices=0,this._engine.getCaps().vertexArrayObject&&(this._vertexArrayObjects={}),r&&(this.applyToMesh(r),r.computeWorldMatrix(!0)))}get extend(){return this._extend}getScene(){return this._scene}getEngine(){return this._engine}isReady(){return this.delayLoadState===1||this.delayLoadState===0}get doNotSerialize(){for(let e=0;e<this._meshes.length;e++)if(!this._meshes[e].doNotSerialize)return!1;return!0}_rebuild(){this._vertexArrayObjects&&(this._vertexArrayObjects={}),this._meshes.length!==0&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,this._updatable,"Geometry_"+this.id+"_IndexBuffer"));const e=new Set;for(const t in this._vertexBuffers)e.add(this._vertexBuffers[t].getWrapperBuffer());e.forEach(t=>{t._rebuild()})}setAllVerticesData(e,t){e.applyToGeometry(this,t),this._notifyUpdate()}setVerticesData(e,t,i=!1,s){i&&Array.isArray(t)&&(t=new Float32Array(t));const r=new O(this._engine,t,e,{updatable:i,postponeInternalCreation:this._meshes.length===0,stride:s,label:"Geometry_"+this.id+"_"+e});this.setVerticesBuffer(r)}removeVerticesData(e){this._vertexBuffers[e]&&(this._vertexBuffers[e].dispose(),delete this._vertexBuffers[e]),this._vertexArrayObjects&&this._disposeVertexArrayObjects()}setVerticesBuffer(e,t=null,i=!0){const s=e.getKind();this._vertexBuffers[s]&&i&&this._vertexBuffers[s].dispose(),e._buffer&&e._ownsBuffer&&e._buffer._increaseReferences(),this._vertexBuffers[s]=e;const r=this._meshes,a=r.length;if(s===O.PositionKind){this._totalVertices=t??e._maxVerticesCount,this._updateExtend(this.useBoundingInfoFromGeometry&&this._boundingInfo?null:e.getFloatData(this._totalVertices)),this._resetPointsArrayCache();const o=this._extend&&this._extend.minimum||new T(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),c=this._extend&&this._extend.maximum||new T(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE);for(let u=0;u<a;u++){const d=r[u];d.buildBoundingInfo(o,c),d._createGlobalSubMesh(d.isUnIndexed),d.computeWorldMatrix(!0),d.synchronizeInstances()}}this._notifyUpdate(s)}updateVerticesDataDirectly(e,t,i,s=!1){const r=this.getVertexBuffer(e);r&&(r.updateDirectly(t,i,s),this._notifyUpdate(e))}updateVerticesData(e,t,i=!1){const s=this.getVertexBuffer(e);s&&(s.update(t),e===O.PositionKind&&this._updateBoundingInfo(i,t),this._notifyUpdate(e))}_updateBoundingInfo(e,t){if(e&&this._updateExtend(t),this._resetPointsArrayCache(),e){const i=this._meshes;for(const s of i){s.hasBoundingInfo?s.getBoundingInfo().reConstruct(this._extend.minimum,this._extend.maximum):s.buildBoundingInfo(this._extend.minimum,this._extend.maximum);const r=s.subMeshes;for(const a of r)a.refreshBoundingInfo()}}}_bind(e,t,i,s){if(!e)return;t===void 0&&(t=this._indexBuffer);const r=this.getVertexBuffers();if(!r)return;if(t!=this._indexBuffer||!this._vertexArrayObjects&&!s){this._engine.bindBuffers(r,t,e,i);return}const a=s||this._vertexArrayObjects,o=this._engine;a[e.key]||(a[e.key]=o.recordVertexArrayObject(r,t,e,i)),o.bindVertexArrayObject(a[e.key],t)}getTotalVertices(){return this.isReady()?this._totalVertices:0}getVerticesData(e,t,i){const s=this.getVertexBuffer(e);return s?s.getFloatData(this._totalVertices,i||t&&this._meshes.length!==1):null}copyVerticesData(e,t){const i=this.getVertexBuffer(e);if(!i)return;t[e]||(t[e]=new Float32Array(this._totalVertices*i.getSize()));const s=i.getData();s&&Dk(s,i.getSize(),i.type,i.byteOffset,i.byteStride,i.normalized,this._totalVertices,t[e])}isVertexBufferUpdatable(e){const t=this._vertexBuffers[e];return t?t.isUpdatable():!1}getVertexBuffer(e){return this.isReady()?this._vertexBuffers[e]:null}getVertexBuffers(){return this.isReady()?this._vertexBuffers:null}isVerticesDataPresent(e){return this._vertexBuffers?this._vertexBuffers[e]!==void 0:this._delayInfo?this._delayInfo.indexOf(e)!==-1:!1}getVerticesDataKinds(){const e=[];let t;if(!this._vertexBuffers&&this._delayInfo)for(t in this._delayInfo)e.push(t);else for(t in this._vertexBuffers)e.push(t);return e}updateIndices(e,t,i=!1){if(this._indexBuffer)if(!this._indexBufferIsUpdatable)this.setIndices(e,null,!0);else{const s=e.length!==this._indices.length;if(i||(this._indices=e.slice()),this._engine.updateDynamicIndexBuffer(this._indexBuffer,e,t),s)for(const r of this._meshes)r._createGlobalSubMesh(!0)}}setIndexBuffer(e,t,i,s=null){this._indices=[],this._indexBufferIsUpdatable=!1,this._indexBuffer=e,this._totalVertices=t,this._totalIndices=i,s===null?e.is32Bits=t>65535:e.is32Bits=s;for(const r of this._meshes)r._createGlobalSubMesh(!0),r.synchronizeInstances();this._notifyUpdate()}setIndices(e,t=null,i=!1,s=!1){this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indices=e,this._indexBufferIsUpdatable=i,this._meshes.length!==0&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,i,"Geometry_"+this.id+"_IndexBuffer")),t!=null&&(this._totalVertices=t);for(const r of this._meshes)r._createGlobalSubMesh(!s),r.synchronizeInstances();this._notifyUpdate()}getTotalIndices(){return this.isReady()?this._totalIndices!==void 0?this._totalIndices:this._indices.length:0}getIndices(e,t){if(!this.isReady())return null;const i=this._indices;return!t&&(!e||this._meshes.length===1)?i:i.slice()}getIndexBuffer(){return this.isReady()?this._indexBuffer:null}_releaseVertexArrayObject(e=null){!e||!this._vertexArrayObjects||this._vertexArrayObjects[e.key]&&(this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e.key]),delete this._vertexArrayObjects[e.key])}releaseForMesh(e,t){const i=this._meshes,s=i.indexOf(e);s!==-1&&(i.splice(s,1),this._vertexArrayObjects&&e._invalidateInstanceVertexArrayObject(),e._geometry=null,i.length===0&&t&&this.dispose())}applyToMesh(e){if(e._geometry===this)return;const t=e._geometry;t&&t.releaseForMesh(e),this._vertexArrayObjects&&e._invalidateInstanceVertexArrayObject();const i=this._meshes;e._geometry=this,e._internalAbstractMeshDataInfo._positions=null,this._scene.pushGeometry(this),i.push(e),this.isReady()?this._applyToMesh(e):this._boundingInfo&&e.setBoundingInfo(this._boundingInfo)}_updateExtend(e=null){if(this.useBoundingInfoFromGeometry&&this._boundingInfo)this._extend={minimum:this._boundingInfo.minimum.clone(),maximum:this._boundingInfo.maximum.clone()};else{if(!e&&(e=this.getVerticesData(O.PositionKind),!e))return;this._extend=MC(e,0,this._totalVertices,this.boundingBias,3)}}_applyToMesh(e){for(const t in this._vertexBuffers){const i=this._vertexBuffers[t];i._buffer.getBuffer()||i.create(),t===O.PositionKind&&(this._extend||this._updateExtend(),e.buildBoundingInfo(this._extend.minimum,this._extend.maximum),e._createGlobalSubMesh(e.isUnIndexed),e._updateBoundingInfo())}!this._indexBuffer&&this._indices&&this._indices.length>0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,this._updatable,"Geometry_"+this.id+"_IndexBuffer")),e._syncGeometryWithMorphTargetManager(),e.synchronizeInstances()}_notifyUpdate(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e),this._vertexArrayObjects&&this._disposeVertexArrayObjects();for(const t of this._meshes)t._markSubMeshesAsAttributesDirty()}load(e,t){if(this.delayLoadState!==2){if(this.isReady()){t&&t();return}this.delayLoadState=2,this._queueLoad(e,t)}}_queueLoad(e,t){this.delayLoadingFile&&(e.addPendingData(this),e._loadFile(this.delayLoadingFile,i=>{if(!this._delayLoadingFunction)return;this._delayLoadingFunction(JSON.parse(i),this),this.delayLoadState=1,this._delayInfo=[],e.removePendingData(this);const s=this._meshes,r=s.length;for(let a=0;a<r;a++)this._applyToMesh(s[a]);t&&t()},void 0,!0))}toLeftHanded(){const e=this.getIndices(!1);if(e!=null&&e.length>0){for(let s=0;s<e.length;s+=3){const r=e[s+0];e[s+0]=e[s+2],e[s+2]=r}this.setIndices(e)}const t=this.getVerticesData(O.PositionKind,!1);if(t!=null&&t.length>0){for(let s=0;s<t.length;s+=3)t[s+2]=-t[s+2];this.setVerticesData(O.PositionKind,t,!1)}const i=this.getVerticesData(O.NormalKind,!1);if(i!=null&&i.length>0){for(let s=0;s<i.length;s+=3)i[s+2]=-i[s+2];this.setVerticesData(O.NormalKind,i,!1)}}_resetPointsArrayCache(){this._positions=null}_generatePointsArray(){if(this._positions)return!0;const e=this.getVerticesData(O.PositionKind);if(!e||e.length===0)return!1;for(let t=this._positionsCache.length*3,i=this._positionsCache.length;t<e.length;t+=3,++i)this._positionsCache[i]=T.FromArray(e,t);for(let t=0,i=0;t<e.length;t+=3,++i)this._positionsCache[i].set(e[0+t],e[1+t],e[2+t]);return this._positionsCache.length=e.length/3,this._positions=this._positionsCache,!0}isDisposed(){return this._isDisposed}_disposeVertexArrayObjects(){if(this._vertexArrayObjects){for(const i in this._vertexArrayObjects)this._engine.releaseVertexArrayObject(this._vertexArrayObjects[i]);this._vertexArrayObjects={};const e=this._meshes,t=e.length;for(let i=0;i<t;i++)e[i]._invalidateInstanceVertexArrayObject()}}dispose(){const e=this._meshes,t=e.length;let i;for(i=0;i<t;i++)this.releaseForMesh(e[i]);this._meshes.length=0,this._disposeVertexArrayObjects();for(const s in this._vertexBuffers)this._vertexBuffers[s].dispose();if(this._vertexBuffers={},this._totalVertices=0,this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null,this._indices=[],this.delayLoadState=0,this.delayLoadingFile=null,this._delayLoadingFunction=null,this._delayInfo=[],this._boundingInfo=null,this._scene.removeGeometry(this),this._parentContainer){const s=this._parentContainer.geometries.indexOf(this);s>-1&&this._parentContainer.geometries.splice(s,1),this._parentContainer=null}this._isDisposed=!0}copy(e){const t=new ps(e,this._scene),i=this.getIndices(void 0,!0);i&&t.setIndices(i);let s=!1,r;for(r in this._vertexBuffers){const a=this.getVertexBuffer(r),o=a.getData();if(!o)continue;const c=a.isUpdatable(),u=a.getSize(),{type:d,byteOffset:f,byteStride:g,normalized:m}=a;s=s||c;const b=Pk(o,u,d,f,g,this._totalVertices,!0),x=new O(this._engine,b,r,{updatable:c,useBytes:!1,stride:u,size:u,offset:0,type:d,normalized:m,takeBufferOwnership:!0});t.setVerticesBuffer(x,this._totalVertices)}t._updatable=s,t.delayLoadState=this.delayLoadState,t.delayLoadingFile=this.delayLoadingFile,t._delayLoadingFunction=this._delayLoadingFunction;for(r in this._delayInfo)t._delayInfo=t._delayInfo||[],t._delayInfo.push(r);return t._boundingInfo=new Hs(this._extend.minimum,this._extend.maximum),t}serialize(){const e={};return e.id=this.id,e.uniqueId=this.uniqueId,e.updatable=this._updatable,vt&&vt.HasTags(this)&&(e.tags=vt.GetTags(this)),e}_toNumberArray(e){return Array.isArray(e)?e:Array.prototype.slice.call(e)}clearCachedData(){this._indices=[],this._resetPointsArrayCache();for(const e in this._vertexBuffers)Object.prototype.hasOwnProperty.call(this._vertexBuffers,e)&&(this._vertexBuffers[e]._buffer._data=null)}serializeVerticeData(){const e=this.serialize();return this.isVerticesDataPresent(O.PositionKind)&&(e.positions=this._toNumberArray(this.getVerticesData(O.PositionKind)),this.isVertexBufferUpdatable(O.PositionKind)&&(e.positionsUpdatable=!0)),this.isVerticesDataPresent(O.NormalKind)&&(e.normals=this._toNumberArray(this.getVerticesData(O.NormalKind)),this.isVertexBufferUpdatable(O.NormalKind)&&(e.normalsUpdatable=!0)),this.isVerticesDataPresent(O.TangentKind)&&(e.tangents=this._toNumberArray(this.getVerticesData(O.TangentKind)),this.isVertexBufferUpdatable(O.TangentKind)&&(e.tangentsUpdatable=!0)),this.isVerticesDataPresent(O.UVKind)&&(e.uvs=this._toNumberArray(this.getVerticesData(O.UVKind)),this.isVertexBufferUpdatable(O.UVKind)&&(e.uvsUpdatable=!0)),this.isVerticesDataPresent(O.UV2Kind)&&(e.uvs2=this._toNumberArray(this.getVerticesData(O.UV2Kind)),this.isVertexBufferUpdatable(O.UV2Kind)&&(e.uvs2Updatable=!0)),this.isVerticesDataPresent(O.UV3Kind)&&(e.uvs3=this._toNumberArray(this.getVerticesData(O.UV3Kind)),this.isVertexBufferUpdatable(O.UV3Kind)&&(e.uvs3Updatable=!0)),this.isVerticesDataPresent(O.UV4Kind)&&(e.uvs4=this._toNumberArray(this.getVerticesData(O.UV4Kind)),this.isVertexBufferUpdatable(O.UV4Kind)&&(e.uvs4Updatable=!0)),this.isVerticesDataPresent(O.UV5Kind)&&(e.uvs5=this._toNumberArray(this.getVerticesData(O.UV5Kind)),this.isVertexBufferUpdatable(O.UV5Kind)&&(e.uvs5Updatable=!0)),this.isVerticesDataPresent(O.UV6Kind)&&(e.uvs6=this._toNumberArray(this.getVerticesData(O.UV6Kind)),this.isVertexBufferUpdatable(O.UV6Kind)&&(e.uvs6Updatable=!0)),this.isVerticesDataPresent(O.ColorKind)&&(e.colors=this._toNumberArray(this.getVerticesData(O.ColorKind)),this.isVertexBufferUpdatable(O.ColorKind)&&(e.colorsUpdatable=!0)),this.isVerticesDataPresent(O.MatricesIndicesKind)&&(e.matricesIndices=this._toNumberArray(this.getVerticesData(O.MatricesIndicesKind)),e.matricesIndicesExpanded=!0,this.isVertexBufferUpdatable(O.MatricesIndicesKind)&&(e.matricesIndicesUpdatable=!0)),this.isVerticesDataPresent(O.MatricesWeightsKind)&&(e.matricesWeights=this._toNumberArray(this.getVerticesData(O.MatricesWeightsKind)),this.isVertexBufferUpdatable(O.MatricesWeightsKind)&&(e.matricesWeightsUpdatable=!0)),e.indices=this._toNumberArray(this.getIndices()),e}static ExtractFromMesh(e,t){const i=e._geometry;return i?i.copy(t):null}static RandomId(){return pe.RandomId()}static _GetGeometryByLoadedUniqueId(e,t){for(let i=0;i<t.geometries.length;i++)if(t.geometries[i]._loadedUniqueId===e)return t.geometries[i];return null}static _ImportGeometry(e,t){const i=t.getScene(),s=e.geometryUniqueId,r=e.geometryId;if(s||r){const a=s?this._GetGeometryByLoadedUniqueId(s,i):i.getGeometryById(r);a&&a.applyToMesh(t)}else if(e instanceof ArrayBuffer){const a=t._binaryInfo;if(a.positionsAttrDesc&&a.positionsAttrDesc.count>0){const o=new Float32Array(e,a.positionsAttrDesc.offset,a.positionsAttrDesc.count);t.setVerticesData(O.PositionKind,o,!1)}if(a.normalsAttrDesc&&a.normalsAttrDesc.count>0){const o=new Float32Array(e,a.normalsAttrDesc.offset,a.normalsAttrDesc.count);t.setVerticesData(O.NormalKind,o,!1)}if(a.tangetsAttrDesc&&a.tangetsAttrDesc.count>0){const o=new Float32Array(e,a.tangetsAttrDesc.offset,a.tangetsAttrDesc.count);t.setVerticesData(O.TangentKind,o,!1)}if(a.uvsAttrDesc&&a.uvsAttrDesc.count>0){const o=new Float32Array(e,a.uvsAttrDesc.offset,a.uvsAttrDesc.count);t.setVerticesData(O.UVKind,o,!1)}if(a.uvs2AttrDesc&&a.uvs2AttrDesc.count>0){const o=new Float32Array(e,a.uvs2AttrDesc.offset,a.uvs2AttrDesc.count);t.setVerticesData(O.UV2Kind,o,!1)}if(a.uvs3AttrDesc&&a.uvs3AttrDesc.count>0){const o=new Float32Array(e,a.uvs3AttrDesc.offset,a.uvs3AttrDesc.count);t.setVerticesData(O.UV3Kind,o,!1)}if(a.uvs4AttrDesc&&a.uvs4AttrDesc.count>0){const o=new Float32Array(e,a.uvs4AttrDesc.offset,a.uvs4AttrDesc.count);t.setVerticesData(O.UV4Kind,o,!1)}if(a.uvs5AttrDesc&&a.uvs5AttrDesc.count>0){const o=new Float32Array(e,a.uvs5AttrDesc.offset,a.uvs5AttrDesc.count);t.setVerticesData(O.UV5Kind,o,!1)}if(a.uvs6AttrDesc&&a.uvs6AttrDesc.count>0){const o=new Float32Array(e,a.uvs6AttrDesc.offset,a.uvs6AttrDesc.count);t.setVerticesData(O.UV6Kind,o,!1)}if(a.colorsAttrDesc&&a.colorsAttrDesc.count>0){const o=new Float32Array(e,a.colorsAttrDesc.offset,a.colorsAttrDesc.count);t.setVerticesData(O.ColorKind,o,!1,a.colorsAttrDesc.stride)}if(a.matricesIndicesAttrDesc&&a.matricesIndicesAttrDesc.count>0){const o=new Int32Array(e,a.matricesIndicesAttrDesc.offset,a.matricesIndicesAttrDesc.count),c=[];for(let u=0;u<o.length;u++){const d=o[u];c.push(d&255),c.push((d&65280)>>8),c.push((d&16711680)>>16),c.push(d>>24&255)}t.setVerticesData(O.MatricesIndicesKind,c,!1)}if(a.matricesIndicesExtraAttrDesc&&a.matricesIndicesExtraAttrDesc.count>0){const o=new Int32Array(e,a.matricesIndicesExtraAttrDesc.offset,a.matricesIndicesExtraAttrDesc.count),c=[];for(let u=0;u<o.length;u++){const d=o[u];c.push(d&255),c.push((d&65280)>>8),c.push((d&16711680)>>16),c.push(d>>24&255)}
231t.setVerticesData(O.MatricesIndicesExtraKind,c,!1)}if(a.matricesWeightsAttrDesc&&a.matricesWeightsAttrDesc.count>0){const o=new Float32Array(e,a.matricesWeightsAttrDesc.offset,a.matricesWeightsAttrDesc.count);t.setVerticesData(O.MatricesWeightsKind,o,!1)}if(a.indicesAttrDesc&&a.indicesAttrDesc.count>0){const o=new Int32Array(e,a.indicesAttrDesc.offset,a.indicesAttrDesc.count);t.setIndices(o,null)}if(a.subMeshesAttrDesc&&a.subMeshesAttrDesc.count>0){const o=new Int32Array(e,a.subMeshesAttrDesc.offset,a.subMeshesAttrDesc.count*5);t.subMeshes=[];for(let c=0;c<a.subMeshesAttrDesc.count;c++){const u=o[c*5+0],d=o[c*5+1],f=o[c*5+2],g=o[c*5+3],m=o[c*5+4];As.AddToMesh(u,d,f,g,m,t)}}}else if(e.positions&&e.normals&&e.indices){if(t.setVerticesData(O.PositionKind,e.positions,e.positions._updatable||e.positionsUpdatable),t.setVerticesData(O.NormalKind,e.normals,e.normals._updatable||e.normalsUpdatable),e.tangents&&t.setVerticesData(O.TangentKind,e.tangents,e.tangents._updatable||e.tangentsUpdatable),e.uvs&&t.setVerticesData(O.UVKind,e.uvs,e.uvs._updatable||e.uvsUpdatable),e.uvs2&&t.setVerticesData(O.UV2Kind,e.uvs2,e.uvs2._updatable||e.uvs2Updatable),e.uvs3&&t.setVerticesData(O.UV3Kind,e.uvs3,e.uvs3._updatable||e.uvs3Updatable),e.uvs4&&t.setVerticesData(O.UV4Kind,e.uvs4,e.uvs4._updatable||e.uvs4Updatable),e.uvs5&&t.setVerticesData(O.UV5Kind,e.uvs5,e.uvs5._updatable||e.uvs5Updatable),e.uvs6&&t.setVerticesData(O.UV6Kind,e.uvs6,e.uvs6._updatable||e.uvs6Updatable),e.colors&&t.setVerticesData(O.ColorKind,Ze.CheckColors4(e.colors,e.positions.length/3),e.colors._updatable),e.matricesIndices)if(!e.matricesIndices._isExpanded&&!e.matricesIndicesExpanded){const a=[];for(let o=0;o<e.matricesIndices.length;o++){const c=e.matricesIndices[o];a.push(c&255),a.push((c&65280)>>8),a.push((c&16711680)>>16),a.push(c>>24&255)}t.setVerticesData(O.MatricesIndicesKind,a,e.matricesIndices._updatable||e.matricesIndicesUpdatable)}else delete e.matricesIndices._isExpanded,delete e.matricesIndicesExpanded,t.setVerticesData(O.MatricesIndicesKind,e.matricesIndices,e.matricesIndices._updatable||e.matricesIndicesUpdatable);if(e.matricesIndicesExtra)if(e.matricesIndicesExtraExpanded||e.matricesIndicesExtra._isExpanded)delete e.matricesIndices._isExpanded,delete e.matricesIndicesExtraExpanded,t.setVerticesData(O.MatricesIndicesExtraKind,e.matricesIndicesExtra,e.matricesIndicesExtra._updatable||e.matricesIndicesExtraUpdatable);else{const a=[];for(let o=0;o<e.matricesIndicesExtra.length;o++){const c=e.matricesIndicesExtra[o];a.push(c&255),a.push((c&65280)>>8),a.push((c&16711680)>>16),a.push(c>>24&255)}t.setVerticesData(O.MatricesIndicesExtraKind,a,e.matricesIndicesExtra._updatable||e.matricesIndicesExtraUpdatable)}e.matricesWeights&&(ps._CleanMatricesWeights(e,t),t.setVerticesData(O.MatricesWeightsKind,e.matricesWeights,e.matricesWeights._updatable)),e.matricesWeightsExtra&&t.setVerticesData(O.MatricesWeightsExtraKind,e.matricesWeightsExtra,e.matricesWeights._updatable),t.setIndices(e.indices,null)}if(e.subMeshes){t.subMeshes=[];for(let a=0;a<e.subMeshes.length;a++){const o=e.subMeshes[a];As.AddToMesh(o.materialIndex,o.verticesStart,o.verticesCount,o.indexStart,o.indexCount,t)}}t._shouldGenerateFlatShading&&(t.convertToFlatShadedMesh(),t._shouldGenerateFlatShading=!1),t.computeWorldMatrix(!0),i.onMeshImportedObservable.notifyObservers(t)}static _CleanMatricesWeights(e,t){if(!bi.CleanBoneMatrixWeights)return;let s=0;if(e.skeletonId>-1){const f=t.getScene().getLastSkeletonById(e.skeletonId);if(!f)return;s=f.bones.length}else return;const r=t.getVerticesData(O.MatricesIndicesKind),a=t.getVerticesData(O.MatricesIndicesExtraKind),o=e.matricesWeights,c=e.matricesWeightsExtra,u=e.numBoneInfluencer,d=o.length;for(let f=0;f<d;f+=4){let g=0,m=-1;for(let b=0;b<4;b++){const x=o[f+b];g+=x,x<.001&&m<0&&(m=b)}if(c)for(let b=0;b<4;b++){const x=c[f+b];g+=x,x<.001&&m<0&&(m=b+4)}if((m<0||m>u-1)&&(m=u-1),g>.001){const b=1/g;for(let x=0;x<4;x++)o[f+x]*=b;if(c)for(let x=0;x<4;x++)c[f+x]*=b}else m>=4?(c[f+m-4]=1-g,a[f+m-4]=s):(o[f+m]=1-g,r[f+m]=s)}t.setVerticesData(O.MatricesIndicesKind,r),e.matricesWeightsExtra&&t.setVerticesData(O.Matr
vendor: 15,432 bytes, line 231
231icesIndicesExtraKind,a)}static Parse(e,t,i){const s=new ps(e.id,t,void 0,e.updatable);return s._loadedUniqueId=e.uniqueId,vt&&vt.AddTagsTo(s,e.tags),e.delayLoadingFile?(s.delayLoadState=4,s.delayLoadingFile=i+e.delayLoadingFile,s._boundingInfo=new Hs(T.FromArray(e.boundingBoxMinimum),T.FromArray(e.boundingBoxMaximum)),s._delayInfo=[],e.hasUVs&&s._delayInfo.push(O.UVKind),e.hasUVs2&&s._delayInfo.push(O.UV2Kind),e.hasUVs3&&s._delayInfo.push(O.UV3Kind),e.hasUVs4&&s._delayInfo.push(O.UV4Kind),e.hasUVs5&&s._delayInfo.push(O.UV5Kind),e.hasUVs6&&s._delayInfo.push(O.UV6Kind),e.hasColors&&s._delayInfo.push(O.ColorKind),e.hasMatricesIndices&&s._delayInfo.push(O.MatricesIndicesKind),e.hasMatricesWeights&&s._delayInfo.push(O.MatricesWeightsKind),s._delayLoadingFunction=ve.ImportVertexData):ve.ImportVertexData(e,s),t.pushGeometry(s,!0),s}}class qe extends yi{get billboardMode(){return this._billboardMode}set billboardMode(e){this._billboardMode!==e&&(this._billboardMode=e,this._cache.useBillboardPosition=(this._billboardMode&qe.BILLBOARDMODE_USE_POSITION)!==0)}get infiniteDistance(){return this._infiniteDistance}set infiniteDistance(e){this._infiniteDistance!==e&&(this._infiniteDistance=e)}constructor(e,t=null,i=!0){super(e,t,!1),this._forward=new T(0,0,1),this._up=new T(0,1,0),this._right=new T(1,0,0),this._position=T.Zero(),this._rotation=T.Zero(),this._rotationQuaternion=null,this._scaling=T.One(),this._transformToBoneReferal=null,this._isAbsoluteSynced=!1,this._billboardMode=qe.BILLBOARDMODE_NONE,this.scalingDeterminant=1,this._infiniteDistance=!1,this.ignoreNonUniformScaling=!1,this.reIntegrateRotationIntoRotationQuaternion=!1,this._poseMatrix=null,this._localMatrix=W.Zero(),this._usePivotMatrix=!1,this._absolutePosition=T.Zero(),this._absoluteScaling=T.Zero(),this._absoluteRotationQuaternion=Se.Identity(),this._pivotMatrix=W.Identity(),this._postMultiplyPivotMatrix=!1,this._isWorldMatrixFrozen=!1,this._indexInSceneTransformNodesArray=-1,this.onAfterWorldMatrixUpdateObservable=new le,this._nonUniformScaling=!1,i&&this.getScene().addTransformNode(this)}getClassName(){return"TransformNode"}get position(){return this._position}set position(e){this._position=e,this._markAsDirtyInternal()}isUsingPivotMatrix(){return this._usePivotMatrix}isUsingPostMultiplyPivotMatrix(){return this._postMultiplyPivotMatrix}get rotation(){return this._rotation}set rotation(e){this._rotation=e,this._rotationQuaternion=null,this._markAsDirtyInternal()}get scaling(){return this._scaling}set scaling(e){this._scaling=e,this._markAsDirtyInternal()}get rotationQuaternion(){return this._rotationQuaternion}set rotationQuaternion(e){this._rotationQuaternion=e,e&&this._rotation.setAll(0),this._markAsDirtyInternal()}_markAsDirtyInternal(){this._isDirty||(this._isDirty=!0,this.customMarkAsDirty&&this.customMarkAsDirty())}get forward(){return T.TransformNormalFromFloatsToRef(0,0,this.getScene().useRightHandedSystem?-1:1,this.getWorldMatrix(),this._forward),this._forward.normalize()}get up(){return T.TransformNormalFromFloatsToRef(0,1,0,this.getWorldMatrix(),this._up),this._up.normalize()}get right(){return T.TransformNormalFromFloatsToRef(this.getScene().useRightHandedSystem?-1:1,0,0,this.getWorldMatrix(),this._right),this._right.normalize()}updatePoseMatrix(e){return this._poseMatrix?(this._poseMatrix.copyFrom(e),this):(this._poseMatrix=e.clone(),this)}getPoseMatrix(){return this._poseMatrix||(this._poseMatrix=W.Identity()),this._poseMatrix}_isSynchronized(){const e=this._cache;return!(this._billboardMode!==e.billboardMode||this._billboardMode!==qe.BILLBOARDMODE_NONE||e.pivotMatrixUpdated||this._infiniteDistance||this._position._isDirty||this._scaling._isDirty||this._rotationQuaternion&&this._rotationQuaternion._isDirty||this._rotation._isDirty)}_initCache(){super._initCache();const e=this._cache;e.localMatrixUpdated=!1,e.billboardMode=-1,e.infiniteDistance=!1,e.useBillboardPosition=!1}get absolutePosition(){return this.getAbsolutePosition()}get absoluteScaling(){return this._syncAbsoluteScalingAndRotation(),this._absoluteScaling}get absoluteRotationQuaternion(){return this._syncAbsoluteScalingAndRotation(),this._absoluteRotationQuaternion}setPreTransformMatrix(e){return this.setPivotMatrix(e,!1)}setPivotMatrix(e,t=!0){return this._pivotMatrix.copyFrom(e),this._usePivotMatrix=!this._pivotMatrix.isIdentity(),this._cache.pivotMatrixUpdated=!0,this._postMultiplyPivotMatrix=t,this._postMultiplyPivotMatrix&&(this._pivotMatrixInverse?this._pivotMatrix.invertToRef(this._pivotMatrixInverse):this._pivotMatrixInverse=W.Invert(this._pivotMatrix)),this}getPivotMatrix(){return this._pivotMatrix}instantiateHierarchy(e=null,t,i){const s=this.clone("Clone of "+(this.name||this.id),e||this.parent,!0);s&&i&&i(this,s);for(const r of this.getChildTransformNodes(!0))r.instantiateHierarchy(s,t,i);return s}freezeWorldMatrix(e=null,t=!1){return e?t?(this._rotation.setAll(0),this._rotationQuaternion=this._rotationQuaternion||Se.Identity(),e.decompose(this._scaling,this._rotationQuaternion,this._position),this.computeWorldMatrix(!0)):(this._worldMatrix=e,this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this._afterComputeWorldMatrix()):(this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0)),this._isDirty=!1,this._isWorldMatrixFrozen=!0,this}unfreezeWorldMatrix(){return this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this}get isWorldMatrixFrozen(){return this._isWorldMatrixFrozen}getAbsolutePosition(){return this.computeWorldMatrix(),this._absolutePosition}setAbsolutePosition(e){if(!e)return this;let t,i,s;if(e.x===void 0){if(arguments.length<3)return this;t=arguments[0],i=arguments[1],s=arguments[2]}else t=e.x,i=e.y,s=e.z;if(this.parent){const r=te.Matrix[0];this.parent.getWorldMatrix().invertToRef(r),T.TransformCoordinatesFromFloatsToRef(t,i,s,r,this.position)}else this.position.x=t,this.position.y=i,this.position.z=s;return this._absolutePosition.copyFrom(e),this}setPositionWithLocalVector(e){return this.computeWorldMatrix(),this.position=T.TransformNormal(e,this._localMatrix),this}getPositionExpressedInLocalSpace(){this.computeWorldMatrix();const e=te.Matrix[0];return this._localMatrix.invertToRef(e),T.TransformNormal(this.position,e)}locallyTranslate(e){return this.computeWorldMatrix(!0),this.position=T.TransformCoordinates(e,this._localMatrix),this}lookAt(e,t=0,i=0,s=0,r=0){const a=qe._LookAtVectorCache,o=r===0?this.position:this.getAbsolutePosition();if(e.subtractToRef(o,a),this.setDirection(a,t,i,s),r===1&&this.parent)if(this.rotationQuaternion){const c=te.Matrix[0];this.rotationQuaternion.toRotationMatrix(c);const u=te.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(u),u.invert(),c.multiplyToRef(u,c),this.rotationQuaternion.fromRotationMatrix(c)}else{const c=te.Quaternion[0];Se.FromEulerVectorToRef(this.rotation,c);const u=te.Matrix[0];c.toRotationMatrix(u);const d=te.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(d),d.invert(),u.multiplyToRef(d,u),c.fromRotationMatrix(u),c.toEulerAnglesToRef(this.rotation)}return this}getDirection(e){const t=T.Zero();return this.getDirectionToRef(e,t),t}getDirectionToRef(e,t){return T.TransformNormalToRef(e,this.getWorldMatrix(),t),this}setDirection(e,t=0,i=0,s=0){const r=-Math.atan2(e.z,e.x)+Math.PI/2,a=Math.sqrt(e.x*e.x+e.z*e.z),o=-Math.atan2(e.y,a);return this.rotationQuaternion?Se.RotationYawPitchRollToRef(r+t,o+i,s,this.rotationQuaternion):(this.rotation.x=o+i,this.rotation.y=r+t,this.rotation.z=s),this}setPivotPoint(e,t=0){this.getScene().getRenderId()==0&&this.computeWorldMatrix(!0);const i=this.getWorldMatrix();if(t==1){const s=te.Matrix[0];i.invertToRef(s),e=T.TransformCoordinates(e,s)}return this.setPivotMatrix(W.Translation(-e.x,-e.y,-e.z),!0)}getPivotPoint(){const e=T.Zero();return this.getPivotPointToRef(e),e}getPivotPointToRef(e){return e.x=-this._pivotMatrix.m[12],e.y=-this._pivotMatrix.m[13],e.z=-this._pivotMatrix.m[14],this}getAbsolutePivotPoint(){const e=T.Zero();return this.getAbsolutePivotPointToRef(e),e}getAbsolutePivotPointToRef(e){return this.getPivotPointToRef(e),T.TransformCoordinatesToRef(e,this.getWorldMatrix(),e),this}markAsDirty(e){if(this._isDirty)return this;if(this._children)for(const t of this._children)t.markAsDirty(e);return super.markAsDirty(e)}setParent(e,t=!1,i=!1){if(!e&&!this.parent)return this;const s=te.Quaternion[0],r=te.Vector3[0],a=te.Vector3[1],o=te.Matrix[1];W.IdentityToRef(o);const c=te.Matrix[0];this.computeWorldMatrix(!0);let u=this.rotationQuaternion;return u||(u=qe._TmpRotation,Se.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,u)),W.ComposeToRef(this.scaling,u,this.position,c),this.parent&&c.multiplyToRef(this.parent.computeWorldMatrix(!0),c),e&&(e.computeWorldMatrix(!0).invertToRef(o),c.multiplyToRef(o,c)),c.decompose(a,s,r,t?this:void 0),this.rotationQuaternion?this.rotationQuaternion.copyFrom(s):s.toEulerAnglesToRef(this.rotation),this.scaling.copyFrom(a),this.position.copyFrom(r),this.parent=e,i&&this.setPivotMatrix(W.Identity()),this}addChild(e,t=!1){return e.setParent(this,t),this}removeChild(e,t=!1){return e.parent!==this?this:(e.setParent(null,t),this)}get nonUniformScaling(){return this._nonUniformScaling}_updateNonUniformScalingState(e){return this._nonUniformScaling===e?!1:(this._nonUniformScaling=e,!0)}attachToBone(e,t){return this._currentParentWhenAttachingToBone=this.parent,this._transformToBoneReferal=t,this.parent=e,e.getSkeleton().prepare(!0),e.getFinalMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this}detachFromBone(e=!1){return this.parent?(this.parent.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this._transformToBoneReferal=null,e?this.parent=this._currentParentWhenAttachingToBone:this.parent=null,this):(e&&(this.parent=this._currentParentWhenAttachingToBone),this)}rotate(e,t,i){e.normalize(),this.rotationQuaternion||(this.rotationQuaternion=this.rotation.toQuaternion(),this.rotation.setAll(0));let s;if(!i||i===0)s=Se.RotationAxisToRef(e,t,qe._RotationAxisCache),this.rotationQuaternion.multiplyToRef(s,this.rotationQuaternion);else{if(this.parent){const r=this.parent.getWorldMatrix(),a=te.Matrix[0];r.invertToRef(a),e=T.TransformNormal(e,a),r.determinant()<0&&(t*=-1)}s=Se.RotationAxisToRef(e,t,qe._RotationAxisCache),s.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}return this}rotateAround(e,t,i){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=Se.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation.setAll(0));const s=te.Vector3[0],r=te.Vector3[1],a=te.Vector3[2],o=te.Quaternion[0],c=te.Matrix[0],u=te.Matrix[1],d=te.Matrix[2],f=te.Matrix[3];return e.subtractToRef(this.position,s),W.TranslationToRef(s.x,s.y,s.z,c),W.TranslationToRef(-s.x,-s.y,-s.z,u),W.RotationAxisToRef(t,i,d),u.multiplyToRef(d,f),f.multiplyToRef(c,f),f.decompose(r,o,a),this.position.addInPlace(a),o.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion),this}translate(e,t,i){const s=e.scale(t);if(!i||i===0){const r=this.getPositionExpressedInLocalSpace().add(s);this.setPositionWithLocalVector(r)}else this.setAbsolutePosition(this.getAbsolutePosition().add(s));return this}addRotation(e,t,i){let s;this.rotationQuaternion?s=this.rotationQuaternion:(s=te.Quaternion[1],Se.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,s));const r=te.Quaternion[0];return Se.RotationYawPitchRollToRef(t,e,i,r),s.multiplyInPlace(r),this.rotationQuaternion||s.toEulerAnglesToRef(this.rotation),this}_getEffectiveParent(){return this.parent}isWorldMatrixCameraDependent(){return this._infiniteDistance&&!this.parent||this._billboardMode!==qe.BILLBOARDMODE_NONE}computeWorldMatrix(e=!1,t=null){if(this._isWorldMatrixFrozen&&!this._isDirty)return this._worldMatrix;const i=this.getScene().getRenderId();if(!this._isDirty&&!e&&(this._currentRenderId===i||this.isSynchronized()))return this._currentRenderId=i,this._worldMatrix;t=t||this.getScene().activeCamera,this._updateCache();const s=this._cache;s.pivotMatrixUpdated=!1,s.billboardMode=this.billboardMode,s.infiniteDistance=this.infiniteDistance,s.parent=this._parentNode,this._currentRenderId=i,this._childUpdateId+=1,this._isDirty=!1,this._position._isDirty=!1,this._rotation._isDirty=!1,this._scaling._isDirty=!1;const r=this._getEffectiveParent(),a=qe._TmpScaling;let o=this._position;if(this._infiniteDistance&&!this.parent&&t){const u=t.getWorldMatrix(),d=new T(u.m[12],u.m[13],u.m[14]);o=qe._TmpTranslation,o.copyFromFloats(this._position.x+d.x,this._position.y+d.y,this._position.z+d.z)}a.copyFromFloats(this._scaling.x*this.scalingDeterminant,this._scaling.y*this.scalingDeterminant,this._scaling.z*this.scalingDeterminant);let c;if(this._rotationQuaternion?(this._rotationQuaternion._isDirty=!1,c=this._rotationQuaternion,this.reIntegrateRotationIntoRotationQuaternion&&this.rotation.lengthSquared()&&(this._rotationQuaternion.multiplyInPlace(Se.RotationYawPitchRoll(this._rotation.y,this._rotation.x,this._rotation.z)),this._rotation.copyFromFloats(0,0,0))):(c=qe._TmpRotation,Se.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,c)),this._usePivotMatrix){const u=te.Matrix[1];W.ScalingToRef(a.x,a.y,a.z,u);const d=te.Matrix[0];c.toRotationMatrix(d),this._pivotMatrix.multiplyToRef(u,te.Matrix[4]),te.Matrix[4].multiplyToRef(d,this._localMatrix),this._postMultiplyPivotMatrix&&this._localMatrix.multiplyToRef(this._pivotMatrixInverse,this._localMatrix),this._localMatrix.addTranslationFromFloats(o.x,o.y,o.z)}else W.ComposeToRef(a,c,o,this._localMatrix);if(r&&r.getWorldMatrix){if(e&&r.computeWorldMatrix(e),this.billboardMode){if(this._transformToBoneReferal){const g=this.parent;g.getSkeleton().prepare(),g.getFinalMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),te.Matrix[7])}else te.Matrix[7].copyFrom(r.getWorldMatrix());const u=te.Vector3[5],d=te.Vector3[6],f=te.Quaternion[0];te.Matrix[7].decompose(d,f,u),W.ScalingToRef(d.x,d.y,d.z,te.Matrix[7]),te.Matrix[7].setTranslation(u),qe.BillboardUseParentOrientation&&(this._position.applyRotationQuaternionToRef(f,u),this._localMatrix.setTranslation(u)),this._localMatrix.multiplyToRef(te.Matrix[7],this._worldMatrix)}else if(this._transformToBoneReferal){const u=this.parent;u.getSkeleton().prepare(),this._localMatrix.multiplyToRef(u.getFinalMatrix(),te.Matrix[6]),te.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),this._worldMatrix)}else this._localMatrix.multiplyToRef(r.getWorldMatrix(),this._worldMatrix);this._markSyncedWithParent()}else this._worldMatrix.copyFrom(this._localMatrix);if(t&&this.billboardMode)if(s.useBillboardPosition){const u=te.Vector3[0];this._worldMatrix.getTranslationToRef(u);const d=t.globalPosition;this._worldMatrix.invertToRef(te.Matrix[1]);const f=te.Vector3[1];T.TransformCoordinatesToRef(d,te.Matrix[1],f),f.normalize();const g=-Math.atan2(f.z,f.x)+Math.PI/2,m=Math.sqrt(f.x*f.x+f.z*f.z),b=-Math.atan2(f.y,m);if(Se.RotationYawPitchRollToRef(g,b,0,te.Quaternion[0]),(this.billboardMode&qe.BILLBOARDMODE_ALL)!==qe.BILLBOARDMODE_ALL){const x=te.Vector3[1];te.Quaternion[0].toEulerAnglesToRef(x),(this.billboardMode&qe.BILLBOARDMODE_X)!==qe.BILLBOARDMODE_X&&(x.x=0),(this.billboardMode&qe.BILLBOARDMODE_Y)!==qe.BILLBOARDMODE_Y&&(x.y=0),(this.billboardMode&qe.BILLBOARDMODE_Z)!==qe.BILLBOARDMODE_Z&&(x.z=0),W.RotationYawPitchRollToRef(x.y,x.x,x.z,te.Matrix[0])}
vendor: 4,173 bytes, line 231
231else W.FromQuaternionToRef(te.Quaternion[0],te.Matrix[0]);this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(te.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(te.Vector3[0])}else{const u=te.Vector3[0];this._worldMatrix.getTranslationToRef(u),te.Matrix[1].copyFrom(t.getViewMatrix());const d=this.getScene().useRightHandedSystem;if(d&&te.Matrix[1].multiplyToRef(qe._TmpRHRestore,te.Matrix[1]),te.Matrix[1].setTranslationFromFloats(0,0,0),te.Matrix[1].invertToRef(te.Matrix[0]),(this.billboardMode&qe.BILLBOARDMODE_ALL)!==qe.BILLBOARDMODE_ALL){te.Matrix[0].decompose(void 0,te.Quaternion[0],void 0);const f=te.Vector3[1];te.Quaternion[0].toEulerAnglesToRef(f),(this.billboardMode&qe.BILLBOARDMODE_X)!==qe.BILLBOARDMODE_X&&(f.x=0),(this.billboardMode&qe.BILLBOARDMODE_Y)!==qe.BILLBOARDMODE_Y&&(f.y=0),(this.billboardMode&qe.BILLBOARDMODE_Z)!==qe.BILLBOARDMODE_Z&&(f.z=0),d&&(f.y+=Math.PI),W.RotationYawPitchRollToRef(f.y,f.x,f.z,te.Matrix[0])}this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(te.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(te.Vector3[0])}return this.ignoreNonUniformScaling?this._updateNonUniformScalingState(!1):this._scaling.isNonUniformWithinEpsilon(1e-6)?this._updateNonUniformScalingState(!0):r&&r._nonUniformScaling?this._updateNonUniformScalingState(r._nonUniformScaling):this._updateNonUniformScalingState(!1),this._afterComputeWorldMatrix(),this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this._isAbsoluteSynced=!1,this.onAfterWorldMatrixUpdateObservable.notifyObservers(this),this._poseMatrix||(this._poseMatrix=W.Invert(this._worldMatrix)),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix}resetLocalMatrix(e=!0){if(this.computeWorldMatrix(),e){const t=this.getChildren();for(let i=0;i<t.length;++i){const s=t[i];if(s){s.computeWorldMatrix();const r=te.Matrix[0];s._localMatrix.multiplyToRef(this._localMatrix,r);const a=te.Quaternion[0];r.decompose(s.scaling,a,s.position),s.rotationQuaternion?s.rotationQuaternion.copyFrom(a):a.toEulerAnglesToRef(s.rotation)}}}this.scaling.copyFromFloats(1,1,1),this.position.copyFromFloats(0,0,0),this.rotation.copyFromFloats(0,0,0),this.rotationQuaternion&&(this.rotationQuaternion=Se.Identity()),this._worldMatrix=W.Identity()}_afterComputeWorldMatrix(){}registerAfterWorldMatrixUpdate(e){return this.onAfterWorldMatrixUpdateObservable.add(e),this}unregisterAfterWorldMatrixUpdate(e){return this.onAfterWorldMatrixUpdateObservable.removeCallback(e),this}getPositionInCameraSpace(e=null){return e||(e=this.getScene().activeCamera),T.TransformCoordinates(this.getAbsolutePosition(),e.getViewMatrix())}getDistanceToCamera(e=null){return e||(e=this.getScene().activeCamera),this.getAbsolutePosition().subtract(e.globalPosition).length()}clone(e,t,i){const s=$e.Clone(()=>new qe(e,this.getScene()),this);if(s.name=e,s.id=e,t&&(s.parent=t),!i){const r=this.getDescendants(!0);for(let a=0;a<r.length;a++){const o=r[a];o.clone&&o.clone(e+"."+o.name,s)}}return s}serialize(e){const t=$e.Serialize(this,e);return t.type=this.getClassName(),t.uniqueId=this.uniqueId,this.parent&&this.parent._serializeAsParent(t),t.localMatrix=this.getPivotMatrix().asArray(),t.isEnabled=this.isEnabled(),$e.AppendSerializedAnimations(this,t),t.ranges=this.serializeAnimationRanges(),t}static Parse(e,t,i){const s=$e.Parse(()=>new qe(e.name,t),e,t,i);if(e.localMatrix?s.setPreTransformMatrix(W.FromArray(e.localMatrix)):e.pivotMatrix&&s.setPivotMatrix(W.FromArray(e.pivotMatrix)),s.setEnabled(e.isEnabled),s._waitingParsedUniqueId=e.uniqueId,e.parentId!==void 0&&(s._waitingParentId=e.parentId),e.parentInstanceIndex!==void 0&&(s._waitingParentInstanceIndex=e.parentInstanceIndex),e.animations){for(let r=0;r<e.animations.length;r++){const a=e.animations[r],o=Kr("BABYLON.Animation");o&&s.animations.push(o.Parse(a))}yi.ParseAnimationRanges(s,e,t)}return e.autoAnimate&&t.beginAnimation(s,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),s}getChildTransformNodes(e,t){const i=[];return this._getDescendants(i,e,s=>(!t||t(s))&&s instanceof qe),i}
vendor: 41,262 bytes, line 231
231dispose(e,t=!1){if(this.getScene().stopAnimation(this),this.getScene().removeTransformNode(this),this._parentContainer){const i=this._parentContainer.transformNodes.indexOf(this);i>-1&&this._parentContainer.transformNodes.splice(i,1),this._parentContainer=null}if(this.onAfterWorldMatrixUpdateObservable.clear(),e){const i=this.getChildTransformNodes(!0);for(const s of i)s.parent=null,s.computeWorldMatrix(!0)}super.dispose(e,t)}normalizeToUnitCube(e=!0,t=!1,i){let s=null,r=null;t&&(this.rotationQuaternion?(r=this.rotationQuaternion.clone(),this.rotationQuaternion.copyFromFloats(0,0,0,1)):this.rotation&&(s=this.rotation.clone(),this.rotation.copyFromFloats(0,0,0)));const a=this.getHierarchyBoundingVectors(e,i),o=a.max.subtract(a.min),c=Math.max(o.x,o.y,o.z);if(c===0)return this;const u=1/c;return this.scaling.scaleInPlace(u),t&&(this.rotationQuaternion&&r?this.rotationQuaternion.copyFrom(r):this.rotation&&s&&this.rotation.copyFrom(s)),this}_syncAbsoluteScalingAndRotation(){this._isAbsoluteSynced||(this._worldMatrix.decompose(this._absoluteScaling,this._absoluteRotationQuaternion),this._isAbsoluteSynced=!0)}}qe.BILLBOARDMODE_NONE=0;qe.BILLBOARDMODE_X=1;qe.BILLBOARDMODE_Y=2;qe.BILLBOARDMODE_Z=4;qe.BILLBOARDMODE_ALL=7;qe.BILLBOARDMODE_USE_POSITION=128;qe.BillboardUseParentOrientation=!1;qe._TmpRotation=Se.Zero();qe._TmpScaling=T.Zero();qe._TmpTranslation=T.Zero();qe._TmpRHRestore=W.Scaling(1,1,-1);qe._LookAtVectorCache=new T(0,0,0);qe._RotationAxisCache=new Se;N([lr("position")],qe.prototype,"_position",void 0);N([lr("rotation")],qe.prototype,"_rotation",void 0);N([nk("rotationQuaternion")],qe.prototype,"_rotationQuaternion",void 0);N([lr("scaling")],qe.prototype,"_scaling",void 0);N([H("billboardMode")],qe.prototype,"_billboardMode",void 0);N([H()],qe.prototype,"scalingDeterminant",void 0);N([H("infiniteDistance")],qe.prototype,"_infiniteDistance",void 0);N([H()],qe.prototype,"ignoreNonUniformScaling",void 0);N([H()],qe.prototype,"reIntegrateRotationIntoRotationQuaternion",void 0);class as{constructor(){this.hit=!1,this.distance=0,this.pickedPoint=null,this.pickedMesh=null,this.bu=0,this.bv=0,this.faceId=-1,this.subMeshFaceId=-1,this.subMeshId=0,this.pickedSprite=null,this.thinInstanceIndex=-1,this.ray=null,this.originMesh=null,this.aimTransform=null,this.gripTransform=null}getNormal(e=!1,t=!0){if(!this.pickedMesh||t&&!this.pickedMesh.isVerticesDataPresent(O.NormalKind))return null;let i=this.pickedMesh.getIndices();i?.length===0&&(i=null);let s;const r=te.Vector3[0],a=te.Vector3[1],o=te.Vector3[2];if(t){const u=this.pickedMesh.getVerticesData(O.NormalKind);let d=i?T.FromArrayToRef(u,i[this.faceId*3]*3,r):r.copyFromFloats(u[this.faceId*3*3],u[this.faceId*3*3+1],u[this.faceId*3*3+2]),f=i?T.FromArrayToRef(u,i[this.faceId*3+1]*3,a):a.copyFromFloats(u[(this.faceId*3+1)*3],u[(this.faceId*3+1)*3+1],u[(this.faceId*3+1)*3+2]),g=i?T.FromArrayToRef(u,i[this.faceId*3+2]*3,o):o.copyFromFloats(u[(this.faceId*3+2)*3],u[(this.faceId*3+2)*3+1],u[(this.faceId*3+2)*3+2]);d=d.scale(this.bu),f=f.scale(this.bv),g=g.scale(1-this.bu-this.bv),s=new T(d.x+f.x+g.x,d.y+f.y+g.y,d.z+f.z+g.z)}else{const u=this.pickedMesh.getVerticesData(O.PositionKind),d=i?T.FromArrayToRef(u,i[this.faceId*3]*3,r):r.copyFromFloats(u[this.faceId*3*3],u[this.faceId*3*3+1],u[this.faceId*3*3+2]),f=i?T.FromArrayToRef(u,i[this.faceId*3+1]*3,a):a.copyFromFloats(u[(this.faceId*3+1)*3],u[(this.faceId*3+1)*3+1],u[(this.faceId*3+1)*3+2]),g=i?T.FromArrayToRef(u,i[this.faceId*3+2]*3,o):o.copyFromFloats(u[(this.faceId*3+2)*3],u[(this.faceId*3+2)*3+1],u[(this.faceId*3+2)*3+2]),m=d.subtract(f),b=g.subtract(f);s=T.Cross(m,b)}const c=(u,d)=>{if(this.thinInstanceIndex!==-1){const g=u.thinInstanceGetWorldMatrices()[this.thinInstanceIndex];g&&T.TransformNormalToRef(d,g,d)}let f=u.getWorldMatrix();u.nonUniformScaling&&(te.Matrix[0].copyFrom(f),f=te.Matrix[0],f.setTranslationFromFloats(0,0,0),f.invert(),f.transposeToRef(te.Matrix[1]),f=te.Matrix[1]),T.TransformNormalToRef(d,f,d)};if(e&&c(this.pickedMesh,s),this.ray){const u=te.Vector3[0].copyFrom(s);e||c(this.pickedMesh,u),T.Dot(u,this.ray.direction)>0&&s.negateInPlace()}return s.normalize(),s}getTextureCoordinates(e=O.UVKind){if(!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(e))return null;const t=this.pickedMesh.getIndices();if(!t)return null;const i=this.pickedMesh.getVerticesData(e);if(!i)return null;let s=Ie.FromArray(i,t[this.faceId*3]*2),r=Ie.FromArray(i,t[this.faceId*3+1]*2),a=Ie.FromArray(i,t[this.faceId*3+2]*2);return s=s.scale(this.bu),r=r.scale(this.bv),a=a.scale(1-this.bu-this.bv),new Ie(s.x+r.x+a.x,s.y+r.y+a.y)}}class wk{constructor(){this._checkCollisions=!1,this._collisionMask=-1,this._collisionGroup=-1,this._surroundingMeshes=null,this._collider=null,this._oldPositionForCollisions=new T(0,0,0),this._diffPositionForCollisions=new T(0,0,0),this._collisionResponse=!0}}function Fk(n,e,t){let i=null;switch(e){case O.PositionKind:i=s=>s.getPositions();break;case O.NormalKind:i=s=>s.getNormals();break;case O.TangentKind:i=s=>s.getTangents();break;case O.UVKind:i=s=>s.getUVs();break;case O.UV2Kind:i=s=>s.getUV2s();break;case O.ColorKind:i=s=>s.getColors();break;default:return}for(let s=0;s<n.length;s++){let r=n[s];for(let a=0;a<t.numTargets;a++){const o=t.getTarget(a),c=o.influence;if(c!==0){const u=i(o);u&&(r+=(u[s]-n[s])*c)}}n[s]=r}}function Lk(n,e,t,i,s,r,a){const o=te.Vector3[0],c=te.Matrix[0],u=te.Matrix[1],d=e===O.NormalKind?T.TransformNormalFromFloatsToRef:T.TransformCoordinatesFromFloatsToRef;for(let f=0,g=0;f<n.length;f+=3,g+=4){c.reset();let m,b;for(m=0;m<4;m++)b=s[g+m],b>0&&(W.FromFloat32ArrayToRefScaled(t,Math.floor(i[g+m]*16),b,u),c.addToSelf(u));if(r&&a)for(m=0;m<4;m++)b=a[g+m],b>0&&(W.FromFloat32ArrayToRefScaled(t,Math.floor(r[g+m]*16),b,u),c.addToSelf(u));d(n[f],n[f+1],n[f+2],c,o),o.toArray(n,f)}}class Nk{constructor(){this.facetNb=0,this.partitioningSubdivisions=10,this.partitioningBBoxRatio=1.01,this.facetDataEnabled=!1,this.facetParameters={},this.bbSize=T.Zero(),this.subDiv={max:1,X:1,Y:1,Z:1},this.facetDepthSort=!1,this.facetDepthSortEnabled=!1}}class Bk{constructor(){this._hasVertexAlpha=!1,this._useVertexColors=!0,this._numBoneInfluencers=4,this._applyFog=!0,this._receiveShadows=!1,this._facetData=new Nk,this._visibility=1,this._skeleton=null,this._layerMask=268435455,this._computeBonesUsingShaders=!0,this._isActive=!1,this._onlyForInstances=!1,this._isActiveIntermediate=!1,this._onlyForInstancesIntermediate=!1,this._actAsRegularMesh=!1,this._currentLOD=new Map,this._collisionRetryCount=3,this._morphTargetManager=null,this._renderingGroupId=0,this._bakedVertexAnimationManager=null,this._material=null,this._positions=null,this._pointerOverDisableMeshTesting=!1,this._meshCollisionData=new wk,this._enableDistantPicking=!1,this._rawBoundingInfo=null,this._sideOrientationHint=!1,this._wasActiveLastFrame=!1}}class os extends qe{static get BILLBOARDMODE_NONE(){return qe.BILLBOARDMODE_NONE}static get BILLBOARDMODE_X(){return qe.BILLBOARDMODE_X}static get BILLBOARDMODE_Y(){return qe.BILLBOARDMODE_Y}static get BILLBOARDMODE_Z(){return qe.BILLBOARDMODE_Z}static get BILLBOARDMODE_ALL(){return qe.BILLBOARDMODE_ALL}static get BILLBOARDMODE_USE_POSITION(){return qe.BILLBOARDMODE_USE_POSITION}get facetNb(){return this._internalAbstractMeshDataInfo._facetData.facetNb}get partitioningSubdivisions(){return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions}set partitioningSubdivisions(e){this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions=e}get partitioningBBoxRatio(){return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio}set partitioningBBoxRatio(e){this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio=e}get mustDepthSortFacets(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSort}set mustDepthSortFacets(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSort=e}get facetDepthSortFrom(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom}set facetDepthSortFrom(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom=e}get collisionRetryCount(){return this._internalAbstractMeshDataInfo._collisionRetryCount}set collisionRetryCount(e){this._internalAbstractMeshDataInfo._collisionRetryCount=e}get isFacetDataEnabled(){return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled}get morphTargetManager(){return this._internalAbstractMeshDataInfo._morphTargetManager}set morphTargetManager(e){this._internalAbstractMeshDataInfo._morphTargetManager!==e&&(this._internalAbstractMeshDataInfo._morphTargetManager=e,this._syncGeometryWithMorphTargetManager())}get bakedVertexAnimationManager(){return this._internalAbstractMeshDataInfo._bakedVertexAnimationManager}set bakedVertexAnimationManager(e){this._internalAbstractMeshDataInfo._bakedVertexAnimationManager!==e&&(this._internalAbstractMeshDataInfo._bakedVertexAnimationManager=e,this._markSubMeshesAsAttributesDirty())}_syncGeometryWithMorphTargetManager(){}_updateNonUniformScalingState(e){return super._updateNonUniformScalingState(e)?(this._markSubMeshesAsMiscDirty(),!0):!1}get rawBoundingInfo(){return this._internalAbstractMeshDataInfo._rawBoundingInfo}set rawBoundingInfo(e){this._internalAbstractMeshDataInfo._rawBoundingInfo=e}set onCollide(e){this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver&&this.onCollideObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver),this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver=this.onCollideObservable.add(e)}set onCollisionPositionChange(e){this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver),this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)}get visibility(){return this._internalAbstractMeshDataInfo._visibility}set visibility(e){if(this._internalAbstractMeshDataInfo._visibility===e)return;const t=this._internalAbstractMeshDataInfo._visibility;this._internalAbstractMeshDataInfo._visibility=e,(t===1&&e!==1||t!==1&&e===1)&&this._markSubMeshesAsDirty(i=>{i.markAsMiscDirty(),i.markAsPrePassDirty()})}get pointerOverDisableMeshTesting(){return this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting}set pointerOverDisableMeshTesting(e){this._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting=e}get renderingGroupId(){return this._internalAbstractMeshDataInfo._renderingGroupId}set renderingGroupId(e){this._internalAbstractMeshDataInfo._renderingGroupId=e}get material(){return this._internalAbstractMeshDataInfo._material}set material(e){this._setMaterial(e)}_setMaterial(e){this._internalAbstractMeshDataInfo._material!==e&&(this._internalAbstractMeshDataInfo._material&&this._internalAbstractMeshDataInfo._material.meshMap&&(this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId]=void 0),this._internalAbstractMeshDataInfo._material=e,e&&e.meshMap&&(e.meshMap[this.uniqueId]=this),this.onMaterialChangedObservable.hasObservers()&&this.onMaterialChangedObservable.notifyObservers(this),this.subMeshes&&(this.resetDrawCache(void 0,e==null),this._unBindEffect()))}getMaterialForRenderPass(e){return this._internalAbstractMeshDataInfo._materialForRenderPass?.[e]}setMaterialForRenderPass(e,t){this.resetDrawCache(e),this._internalAbstractMeshDataInfo._materialForRenderPass||(this._internalAbstractMeshDataInfo._materialForRenderPass=[]);const i=this._internalAbstractMeshDataInfo._materialForRenderPass[e];i?.meshMap?.[this.uniqueId]&&(i.meshMap[this.uniqueId]=void 0),this._internalAbstractMeshDataInfo._materialForRenderPass[e]=t,t&&t.meshMap&&(t.meshMap[this.uniqueId]=this)}get receiveShadows(){return this._internalAbstractMeshDataInfo._receiveShadows}set receiveShadows(e){this._internalAbstractMeshDataInfo._receiveShadows!==e&&(this._internalAbstractMeshDataInfo._receiveShadows=e,this._markSubMeshesAsLightDirty())}get hasVertexAlpha(){return this._internalAbstractMeshDataInfo._hasVertexAlpha}set hasVertexAlpha(e){this._internalAbstractMeshDataInfo._hasVertexAlpha!==e&&(this._internalAbstractMeshDataInfo._hasVertexAlpha=e,this._markSubMeshesAsAttributesDirty(),this._markSubMeshesAsMiscDirty())}get useVertexColors(){return this._internalAbstractMeshDataInfo._useVertexColors}set useVertexColors(e){this._internalAbstractMeshDataInfo._useVertexColors!==e&&(this._internalAbstractMeshDataInfo._useVertexColors=e,this._markSubMeshesAsAttributesDirty())}get computeBonesUsingShaders(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders}set computeBonesUsingShaders(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())}get numBoneInfluencers(){return this._internalAbstractMeshDataInfo._numBoneInfluencers}set numBoneInfluencers(e){this._internalAbstractMeshDataInfo._numBoneInfluencers!==e&&(this._internalAbstractMeshDataInfo._numBoneInfluencers=e,this._markSubMeshesAsAttributesDirty())}get applyFog(){return this._internalAbstractMeshDataInfo._applyFog}set applyFog(e){this._internalAbstractMeshDataInfo._applyFog!==e&&(this._internalAbstractMeshDataInfo._applyFog=e,this._markSubMeshesAsMiscDirty())}get enableDistantPicking(){return this._internalAbstractMeshDataInfo._enableDistantPicking}set enableDistantPicking(e){this._internalAbstractMeshDataInfo._enableDistantPicking=e}get layerMask(){return this._internalAbstractMeshDataInfo._layerMask}set layerMask(e){e!==this._internalAbstractMeshDataInfo._layerMask&&(this._internalAbstractMeshDataInfo._layerMask=e,this._resyncLightSources())}get collisionMask(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask}set collisionMask(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask=isNaN(e)?-1:e}get collisionResponse(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse}set collisionResponse(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse=e}get collisionGroup(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup}set collisionGroup(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup=isNaN(e)?-1:e}get surroundingMeshes(){return this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes}set surroundingMeshes(e){this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes=e}get lightSources(){return this._lightSources}set skeleton(e){const t=this._internalAbstractMeshDataInfo._skeleton;t&&t.needInitialSkinMatrix&&t._unregisterMeshWithPoseMatrix(this),e&&e.needInitialSkinMatrix&&e._registerMeshWithPoseMatrix(this),this._internalAbstractMeshDataInfo._skeleton=e,this._internalAbstractMeshDataInfo._skeleton||(this._bonesTransformMatrices=null),this._markSubMeshesAsAttributesDirty()}get skeleton(){return this._internalAbstractMeshDataInfo._skeleton}constructor(e,t=null){switch(super(e,t,!1),this._internalAbstractMeshDataInfo=new Bk,this._waitingMaterialId=null,this._waitingMorphTargetManagerId=null,this.cullingStrategy=os.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,this.onCollideObservable=new le,this.onCollisionPositionChangeObservable=new le,this.onMaterialChangedObservable=new le,this.definedFacingForward=!0,this._occlusionQuery=null,this._renderingGroup=null,this.alphaIndex=Number.MAX_VALUE,this.isPickable=!0,this.isNearPickable=!1,this.isNearGrabbable=!1,this.showSubMeshesBoundingBox=!1,this.isBlocker=!1,this.enablePointerMoveEvents=!1,this.outlineColor=Ne.Red(),this.outlineWidth=.02,this.overlayColor=Ne.Red(),this.overlayAlpha=.5,this.useOctreeForRenderingSelection=!0,this.useOctreeForPicking=!0,this.useOctreeForCollisions=!0,this.alwaysSelectAsActiveMesh=!1,this.doNotSyncBoundingInfo=!1,this.actionManager=null,this.ellipsoid=new T(.5,1,.5),this.ellipsoidOffset=new T(0,0,0),this.edgesWidth=1,this.edgesColor=new Ze(1,0,0,1),this._edgesRenderer=null,this._masterMesh=null,this._boundingInfo=null,this._boundingInfoIsDirty=!0,this._renderId=0,this._intersectionsInProgress=new Array,this._unIndexed=!1,this._lightSources=new Array,this._waitingData={lods:null,actions:null,freezeWorldMatrix:null},this._bonesTransformMatrices=null,this._transformMatrixTexture=null,this.onRebuildObservable=new le,this._onCollisionPositionChange=(i,s,r=null)=>{s.subtractToRef(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length()>Ce.CollisionsEpsilon&&this.position.addInPlace(this._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),r&&this.onCollideObservable.notifyObservers(r),this.onCollisionPositionChangeObservable.notifyObservers(this.position)},t=this.getScene(),t.addMesh(this),this._resyncLightSources(),this._uniformBuffer=new Fe(this.getScene().getEngine(),void 0,void 0,e,!this.getScene().getEngine().isWebGPU),this._buildUniformLayout(),t.performancePriority){case 2:this.doNotSyncBoundingInfo=!0;case 1:this.alwaysSelectAsActiveMesh=!0,this.isPickable=!1;break}}_buildUniformLayout(){this._uniformBuffer.addUniform("world",16),this._uniformBuffer.addUniform("visibility",1),this._uniformBuffer.create()}transferToEffect(e){const t=this._uniformBuffer;t.updateMatrix("world",e),t.updateFloat("visibility",this._internalAbstractMeshDataInfo._visibility),t.update()}getMeshUniformBuffer(){return this._uniformBuffer}getClassName(){return"AbstractMesh"}toString(e){let t="Name: "+this.name+", isInstance: "+(this.getClassName()==="InstancedMesh"?"YES":"NO");t+=", # of submeshes: "+(this.subMeshes?this.subMeshes.length:0);const i=this._internalAbstractMeshDataInfo._skeleton;return i&&(t+=", skeleton: "+i.name),e&&(t+=", billboard mode: "+["NONE","X","Y",null,"Z",null,null,"ALL"][this.billboardMode],t+=", freeze wrld mat: "+(this._isWorldMatrixFrozen||this._waitingData.freezeWorldMatrix?"YES":"NO")),t}_getEffectiveParent(){return this._masterMesh&&this.billboardMode!==qe.BILLBOARDMODE_NONE?this._masterMesh:super._getEffectiveParent()}_getActionManagerForTrigger(e,t=!0){if(this.actionManager&&(t||this.actionManager.isRecursive))if(e){if(this.actionManager.hasSpecificTrigger(e))return this.actionManager}else return this.actionManager;return this.parent?this.parent._getActionManagerForTrigger(e,!1):null}_rebuild(e=!1){if(this.onRebuildObservable.notifyObservers(this),this._occlusionQuery!==null&&(this._occlusionQuery=null),!!this.subMeshes){for(const t of this.subMeshes)t._rebuild();this.resetDrawCache()}}_resyncLightSources(){this._lightSources.length=0;for(const e of this.getScene().lights)e.isEnabled()&&e.canAffectMesh(this)&&this._lightSources.push(e);this._markSubMeshesAsLightDirty()}_resyncLightSource(e){const t=e.isEnabled()&&e.canAffectMesh(this),i=this._lightSources.indexOf(e);let s=!1;if(i===-1){if(!t)return;this._lightSources.push(e)}else{if(t)return;s=!0,this._lightSources.splice(i,1)}this._markSubMeshesAsLightDirty(s)}_unBindEffect(){for(const e of this.subMeshes)e.setEffect(null)}_removeLightSource(e,t){const i=this._lightSources.indexOf(e);i!==-1&&(this._lightSources.splice(i,1),this._markSubMeshesAsLightDirty(t))}_markSubMeshesAsDirty(e){if(this.subMeshes)for(const t of this.subMeshes)for(let i=0;i<t._drawWrappers.length;++i){const s=t._drawWrappers[i];!s||!s.defines||!s.defines.markAllAsDirty||e(s.defines)}}_markSubMeshesAsLightDirty(e=!1){this._markSubMeshesAsDirty(t=>t.markAsLightDirty(e))}_markSubMeshesAsAttributesDirty(){this._markSubMeshesAsDirty(e=>e.markAsAttributesDirty())}_markSubMeshesAsMiscDirty(){this._markSubMeshesAsDirty(e=>e.markAsMiscDirty())}markAsDirty(e){return this._currentRenderId=Number.MAX_VALUE,super.markAsDirty(e),this._isDirty=!0,this}resetDrawCache(e,t=!1){if(this.subMeshes)for(const i of this.subMeshes)i.resetDrawCache(e,t)}get isBlocked(){return!1}getLOD(e){return this}getTotalVertices(){return 0}getTotalIndices(){return 0}getIndices(){return null}getVerticesData(e){return null}setVerticesData(e,t,i,s){return this}updateVerticesData(e,t,i,s){return this}setIndices(e,t){return this}isVerticesDataPresent(e){return!1}getBoundingInfo(){return this._masterMesh?this._masterMesh.getBoundingInfo():(this._boundingInfoIsDirty&&(this._boundingInfoIsDirty=!1,this._updateBoundingInfo()),this._boundingInfo)}getRawBoundingInfo(){return this.rawBoundingInfo??this.getBoundingInfo()}setBoundingInfo(e){return this._boundingInfo=e,this}get hasBoundingInfo(){return this._boundingInfo!==null}buildBoundingInfo(e,t,i){return this._boundingInfo=new Hs(e,t,i),this._boundingInfo}normalizeToUnitCube(e=!0,t=!1,i){return super.normalizeToUnitCube(e,t,i)}get useBones(){return this.skeleton&&this.getScene().skeletonsEnabled&&this.isVerticesDataPresent(O.MatricesIndicesKind)&&this.isVerticesDataPresent(O.MatricesWeightsKind)}_preActivate(){}_preActivateForIntermediateRendering(e){}_activate(e,t){return this._renderId=e,!0}_postActivate(){}_freeze(){}_unFreeze(){}getWorldMatrix(){return this._masterMesh&&this.billboardMode===qe.BILLBOARDMODE_NONE?this._masterMesh.getWorldMatrix():super.getWorldMatrix()}_getWorldMatrixDeterminant(){return this._masterMesh?this._masterMesh._getWorldMatrixDeterminant():super._getWorldMatrixDeterminant()}get isAnInstance(){return!1}get hasInstances(){return!1}get hasThinInstances(){return!1}movePOV(e,t,i){return this.position.addInPlace(this.calcMovePOV(e,t,i)),this}calcMovePOV(e,t,i){const s=new W;(this.rotationQuaternion?this.rotationQuaternion:Se.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)).toRotationMatrix(s);const a=T.Zero(),o=this.definedFacingForward?-1:1;return T.TransformCoordinatesFromFloatsToRef(e*o,t,i*o,s,a),a}rotatePOV(e,t,i){return this.rotation.addInPlace(this.calcRotatePOV(e,t,i)),this}calcRotatePOV(e,t,i){const s=this.definedFacingForward?1:-1;return new T(e*s,t,i*s)}_refreshBoundingInfo(e,t){if(e){const i=MC(e,0,this.getTotalVertices(),t);this._boundingInfo?this._boundingInfo.reConstruct(i.minimum,i.maximum):this._boundingInfo=new Hs(i.minimum,i.maximum)}if(this.subMeshes)for(let i=0;i<this.subMeshes.length;i++)this.subMeshes[i].refreshBoundingInfo(e);this._updateBoundingInfo()}_refreshBoundingInfoDirect(e){if(this._boundingInfo?this._boundingInfo.reConstruct(e.minimum,e.maximum):this._boundingInfo=new Hs(e.minimum,e.maximum),this.subMeshes)for(let t=0;t<this.subMeshes.length;t++)this.subMeshes[t].refreshBoundingInfo(null);this._updateBoundingInfo()}static _ApplySkeleton(e,t,i,s,r,a,o){Lk(e,t,i,s,r,a,o)}_getData(e,t,i=O.PositionKind){const s=e.cache,r=a=>{if(s){const o=s._vertexData||(s._vertexData={});return o[a]||this.copyVerticesData(a,o),o[a]}return this.getVerticesData(a)};if(t||(t=r(i)),!t)return null;if(s?(s._outputData?s._outputData.set(t):s._outputData=new Float32Array(t),t=s._outputData):(e.applyMorph&&this.morphTargetManager||e.applySkeleton&&this.skeleton)&&(t=t.slice()),e.applyMorph&&this.morphTargetManager&&Fk(t,i,this.morphTargetManager),e.applySkeleton&&this.skeleton){const a=r(O.MatricesIndicesKind),o=r(O.MatricesWeightsKind);if(o&&a){const c=this.numBoneInfluencers>4,u=c?r(O.MatricesIndicesExtraKind):null,d=c?r(O.MatricesWeightsExtraKind):null,f=this.skeleton.getTransformMatrices(this);os._ApplySkeleton(t,i,f,a,o,u,d)}}if(e.updatePositionsArray!==!1&&i===O.PositionKind){const a=this._internalAbstractMeshDataInfo._positions||[],o=a.length;if(a.length=t.length/3,o<a.length)for(let c=o;c<a.length;c++)a[c]=new T;for(let c=0,u=0;c<a.length;c++,u+=3)a[c].copyFromFloats(t[u],t[u+1],t[u+2]);this._internalAbstractMeshDataInfo._positions=a}return t}getNormalsData(e=!1,t=!1){return this._getData({applySkeleton:e,applyMorph:t,updatePositionsArray:!1},null,O.NormalKind)}getPositionData(e=!1,t=!1,i=null){return this._getData({applySkeleton:e,applyMorph:t,updatePositionsArray:!1},i,O.PositionKind)}_updateBoundingInfo(){return this._boundingInfo?this._boundingInfo.update(this.worldMatrixFromCache):this._boundingInfo=new Hs(T.Zero(),T.Zero(),this.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache),this}_updateSubMeshesBoundingInfo(e){if(!this.subMeshes)return this;const t=this.subMeshes.length;for(let i=0;i<t;i++){const s=this.subMeshes[i];(t>1||!s.IsGlobal)&&s.updateBoundingInfo(e)}return this}_afterComputeWorldMatrix(){this.doNotSyncBoundingInfo||(this._boundingInfoIsDirty=!0)}isInFrustum(e){return this.getBoundingInfo().isInFrustum(e,this.cullingStrategy)}isCompletelyInFrustum(e){return this.getBoundingInfo().isCompletelyInFrustum(e)}intersectsMesh(e,t=!1,i){const s=this.getBoundingInfo(),r=e.getBoundingInfo();if(s.intersects(r,t))return!0;if(i){for(const a of this.getChildMeshes())if(a.intersectsMesh(e,t,!0))return!0}return!1}intersectsPoint(e){return this.getBoundingInfo().intersectsPoint(e)}get checkCollisions(){return this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions}set checkCollisions(e){this._internalAbstractMeshDataInfo._meshCollisionData._checkCollisions=e}get collider(){return this._internalAbstractMeshDataInfo._meshCollisionData._collider}moveWithCollisions(e,t=!0){this.getAbsolutePosition().addToRef(this.ellipsoidOffset,this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions);const s=this.getScene().collisionCoordinator;return this._internalAbstractMeshDataInfo._meshCollisionData._collider||(this._internalAbstractMeshDataInfo._meshCollisionData._collider=s.createCollider()),this._internalAbstractMeshDataInfo._meshCollisionData._collider._radius=this.ellipsoid,s.getNewPosition(this._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,e,this._internalAbstractMeshDataInfo._meshCollisionData._collider,this.collisionRetryCount,this,this._onCollisionPositionChange,this.uniqueId,t),this}_collideForSubMesh(e,t,i){if(this._generatePointsArray(),!this._positions)return this;if(!e._lastColliderWorldVertices||!e._lastColliderTransformMatrix.equals(t)){e._lastColliderTransformMatrix=t.clone(),e._lastColliderWorldVertices=[],e._trianglePlanes=[];const s=e.verticesStart,r=e.verticesStart+e.verticesCount;for(let a=s;a<r;a++)e._lastColliderWorldVertices.push(T.TransformCoordinates(this._positions[a],t))}return i._collide(e._trianglePlanes,e._lastColliderWorldVertices,this.getIndices(),e.indexStart,e.indexStart+e.indexCount,e.verticesStart,!!e.getMaterial(),this,this._shouldConvertRHS(),e.getMaterial()?.fillMode===7),this}_processCollisionsForSubMeshes(e,t){const i=this._scene.getCollidingSubMeshCandidates(this,e),s=i.length;for(let r=0;r<s;r++){const a=i.data[r];s>1&&!a._checkCollision(e)||this._collideForSubMesh(a,t,e)}return this}_shouldConvertRHS(){return!1}_checkCollision(e){if(!this.getBoundingInfo()._checkCollision(e))return this;const t=te.Matrix[0],i=te.Matrix[1];return W.ScalingToRef(1/e._radius.x,1/e._radius.y,1/e._radius.z,t),this.worldMatrixFromCache.multiplyToRef(t,i),this._processCollisionsForSubMeshes(e,i),this}_generatePointsArray(){return!1}intersects(e,t,i,s=!1,r,a=!1){const o=new as,c=this.getClassName(),u=c==="InstancedLinesMesh"||c==="LinesMesh"||c==="GreasedLineMesh"?this.intersectionThreshold:0,d=this.getBoundingInfo();if(!this.subMeshes||!a&&(!e.intersectsSphere(d.boundingSphere,u)||!e.intersectsBox(d.boundingBox,u)))return o;if(s)return o.hit=!a,o.pickedMesh=a?null:this,o.distance=a?0:T.Distance(e.origin,d.boundingSphere.center),o.subMeshId=0,o;if(!this._generatePointsArray())return o;let f=null;const g=this._scene.getIntersectingSubMeshCandidates(this,e),m=g.length;let b=!1;for(let x=0;x<m;x++){const E=g.data[x].getMaterial();if(E&&(E.fillMode==7||E.fillMode==0||E.fillMode==1||E.fillMode==2||E.fillMode==4)){b=!0;break}}if(!b)return o.hit=!0,o.pickedMesh=this,o.distance=T.Distance(e.origin,d.boundingSphere.center),o.subMeshId=-1,o;for(let x=0;x<m;x++){const v=g.data[x];if(m>1&&!a&&!v.canIntersects(e))continue;const E=v.intersects(e,this._positions,this.getIndices(),t,i);if(E&&(t||!f||E.distance<f.distance)&&(f=E,f.subMeshId=v._id,f._internalSubMeshId=x,t))break}if(f){const x=r??this.getWorldMatrix(),v=te.Vector3[0],E=te.Vector3[1];T.TransformCoordinatesToRef(e.origin,x,v),e.direction.scaleToRef(f.distance,E);const D=T.TransformNormal(E,x).addInPlace(v);return o.hit=!0,o.distance=T.Distance(v,D),o.pickedPoint=D,o.pickedMesh=this,o.bu=f.bu||0,o.bv=f.bv||0,o.subMeshFaceId=f.faceId,o.faceId=f.faceId+g.data[f._internalSubMeshId].indexStart/(this.getClassName().indexOf("LinesMesh")!==-1?2:3),o.subMeshId=f.subMeshId,o}return o}clone(e,t,i){return null}releaseSubMeshes(e=!1){if(this.subMeshes)for(;this.subMeshes.length;)this.subMeshes[0].dispose(e);else this.subMeshes=[];return this}dispose(e,t=!1){let i;const s=this.getScene();for(this._scene.useMaterialMeshMap&&this._internalAbstractMeshDataInfo._material&&this._internalAbstractMeshDataInfo._material.meshMap&&(this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId]=void 0),s.freeActiveMeshes(),s.freeRenderingGroups(),s.renderingManager.maintainStateBetweenFrames&&s.renderingManager.restoreDispachedFlags(),this.actionManager!==void 0&&this.actionManager!==null&&(this.actionManager.disposeWhenUnowned&&!this._scene.meshes.some(o=>o!==this&&o.actionManager===this.actionManager)&&this.actionManager.dispose(),this.actionManager=null),this._internalAbstractMeshDataInfo._skeleton=null,this._transformMatrixTexture&&(this._transformMatrixTexture.dispose(),this._transformMatrixTexture=null),i=0;i<this._intersectionsInProgress.length;i++){const o=this._intersectionsInProgress[i],c=o._intersectionsInProgress.indexOf(this);o._intersectionsInProgress.splice(c,1)}this._intersectionsInProgress.length=0;const r=s.lights;for(const o of r){let c=o.includedOnlyMeshes.indexOf(this);c!==-1&&o.includedOnlyMeshes.splice(c,1),c=o.excludedMeshes.indexOf(this),c!==-1&&o.excludedMeshes.splice(c,1);const u=o.getShadowGenerators();if(u){const d=u.values();for(let f=d.next();f.done!==!0;f=d.next()){const m=f.value.getShadowMap();m&&m.renderList&&(c=m.renderList.indexOf(this),c!==-1&&m.renderList.splice(c,1))}}}(this.getClassName()!=="InstancedMesh"||this.getClassName()!=="InstancedLinesMesh")&&this.releaseSubMeshes(!0);const a=s.getEngine();if(this._occlusionQuery!==null&&(this.isOcclusionQueryInProgress=!1,a.deleteQuery(this._occlusionQuery),this._occlusionQuery=null),a.wipeCaches(),s.removeMesh(this),this._parentContainer){const o=this._parentContainer.meshes.indexOf(this);o>-1&&this._parentContainer.meshes.splice(o,1),this._parentContainer=null}if(t&&this.material&&(this.material.getClassName()==="MultiMaterial"?this.material.dispose(!1,!0,!0):this.material.dispose(!1,!0)),!e)for(i=0;i<s.particleSystems.length;i++)s.particleSystems[i].emitter===this&&(s.particleSystems[i].dispose(),i--);this._internalAbstractMeshDataInfo._facetData.facetDataEnabled&&this.disableFacetData(),this._uniformBuffer.dispose(),this.onAfterWorldMatrixUpdateObservable.clear(),this.onCollideObservable.clear(),this.onCollisionPositionChangeObservable.clear(),this.onRebuildObservable.clear(),super.dispose(e,t)}_initFacetData(){const e=this._internalAbstractMeshDataInfo._facetData;e.facetNormals||(e.facetNormals=[]),e.facetPositions||(e.facetPositions=[]),e.facetPartitioning||(e.facetPartitioning=new Array),e.facetNb=this.getIndices().length/3|0,e.partitioningSubdivisions=e.partitioningSubdivisions?e.partitioningSubdivisions:10,e.partitioningBBoxRatio=e.partitioningBBoxRatio?e.partitioningBBoxRatio:1.01;for(let t=0;t<e.facetNb;t++)e.facetNormals[t]=T.Zero(),e.facetPositions[t]=T.Zero();return e.facetDataEnabled=!0,this}updateFacetData(){const e=this._internalAbstractMeshDataInfo._facetData;e.facetDataEnabled||this._initFacetData();const t=this.getVerticesData(O.PositionKind),i=this.getIndices(),s=this.getVerticesData(O.NormalKind),r=this.getBoundingInfo();if(e.facetDepthSort&&!e.facetDepthSortEnabled){if(e.facetDepthSortEnabled=!0,i instanceof Uint16Array)e.depthSortedIndices=new Uint16Array(i);else if(i instanceof Uint32Array)e.depthSortedIndices=new Uint32Array(i);else{let o=!1;for(let c=0;c<i.length;c++)if(i[c]>65535){o=!0;break}o?e.depthSortedIndices=new Uint32Array(i):e.depthSortedIndices=new Uint16Array(i)}if(e.facetDepthSortFunction=function(o,c){return c.sqDistance-o.sqDistance},!e.facetDepthSortFrom){const o=this.getScene().activeCamera;e.facetDepthSortFrom=o?o.position:T.Zero()}e.depthSortedFacets=[];for(let o=0;o<e.facetNb;o++){const c={ind:o*3,sqDistance:0};e.depthSortedFacets.push(c)}e.invertedMatrix=W.Identity(),e.facetDepthSortOrigin=T.Zero()}e.bbSize.x=r.maximum.x-r.minimum.x>bt?r.maximum.x-r.minimum.x:bt,e.bbSize.y=r.maximum.y-r.minimum.y>bt?r.maximum.y-r.minimum.y:bt,e.bbSize.z=r.maximum.z-r.minimum.z>bt?r.maximum.z-r.minimum.z:bt;let a=e.bbSize.x>e.bbSize.y?e.bbSize.x:e.bbSize.y;if(a=a>e.bbSize.z?a:e.bbSize.z,e.subDiv.max=e.partitioningSubdivisions,e.subDiv.X=Math.floor(e.subDiv.max*e.bbSize.x/a),e.subDiv.Y=Math.floor(e.subDiv.max*e.bbSize.y/a),e.subDiv.Z=Math.floor(e.subDiv.max*e.bbSize.z/a),e.subDiv.X=e.subDiv.X<1?1:e.subDiv.X,e.subDiv.Y=e.subDiv.Y<1?1:e.subDiv.Y,e.subDiv.Z=e.subDiv.Z<1?1:e.subDiv.Z,e.facetParameters.facetNormals=this.getFacetLocalNormals(),e.facetParameters.facetPositions=this.getFacetLocalPositions(),e.facetParameters.facetPartitioning=this.getFacetLocalPartitioning(),e.facetParameters.bInfo=r,e.facetParameters.bbSize=e.bbSize,e.facetParameters.subDiv=e.subDiv,e.facetParameters.ratio=this.partitioningBBoxRatio,e.facetParameters.depthSort=e.facetDepthSort,e.facetDepthSort&&e.facetDepthSortEnabled&&(this.computeWorldMatrix(!0),this._worldMatrix.invertToRef(e.invertedMatrix),T.TransformCoordinatesToRef(e.facetDepthSortFrom,e.invertedMatrix,e.facetDepthSortOrigin),e.facetParameters.distanceTo=e.facetDepthSortOrigin),e.facetParameters.depthSortedFacets=e.depthSortedFacets,s&&ve.ComputeNormals(t,i,s,e.facetParameters),e.facetDepthSort&&e.facetDepthSortEnabled){e.depthSortedFacets.sort(e.facetDepthSortFunction);const o=e.depthSortedIndices.length/3|0;for(let c=0;c<o;c++){const u=e.depthSortedFacets[c].ind;e.depthSortedIndices[c*3]=i[u],e.depthSortedIndices[c*3+1]=i[u+1],e.depthSortedIndices[c*3+2]=i[u+2]}this.updateIndices(e.depthSortedIndices,void 0,!0)}return this}getFacetLocalNormals(){const e=this._internalAbstractMeshDataInfo._facetData;return e.facetNormals||this.updateFacetData(),e.facetNormals}getFacetLocalPositions(){const e=this._internalAbstractMeshDataInfo._facetData;return e.facetPositions||this.updateFacetData(),e.facetPositions}getFacetLocalPartitioning(){const e=this._internalAbstractMeshDataInfo._facetData;return e.facetPartitioning||this.updateFacetData(),e.facetPartitioning}getFacetPosition(e){const t=T.Zero();return this.getFacetPositionToRef(e,t),t}getFacetPositionToRef(e,t){const i=this.getFacetLocalPositions()[e],s=this.getWorldMatrix();return T.TransformCoordinatesToRef(i,s,t),this}getFacetNormal(e){const t=T.Zero();return this.getFacetNormalToRef(e,t),t}getFacetNormalToRef(e,t){const i=this.getFacetLocalNormals()[e];return T.TransformNormalToRef(i,this.getWorldMatrix(),t),this}getFacetsAtLocalCoordinates(e,t,i){const s=this.getBoundingInfo(),r=this._internalAbstractMeshDataInfo._facetData,a=Math.floor((e-s.minimum.x*r.partitioningBBoxRatio)*r.subDiv.X*r.partitioningBBoxRatio/r.bbSize.x),o=Math.floor((t-s.minimum.y*r.partitioningBBoxRatio)*r.subDiv.Y*r.partitioningBBoxRatio/r.bbSize.y),c=Math.floor((i-s.minimum.z*r.partitioningBBoxRatio)*r.subDiv.Z*r.partitioningBBoxRatio/r.bbSize.z);return a<0||a>r.subDiv.max||o<0||o>r.subDiv.max||c<0||c>r.subDiv.max?null:r.facetPartitioning[a+r.subDiv.max*o+r.subDiv.max*r.subDiv.max*c]}getClosestFacetAtCoordinates(e,t,i,s,r=!1,a=!0){const o=this.getWorldMatrix(),c=te.Matrix[5];o.invertToRef(c);const u=te.Vector3[8];T.TransformCoordinatesFromFloatsToRef(e,t,i,c,u);const d=this.getClosestFacetAtLocalCoordinates(u.x,u.y,u.z,s,r,a);return s&&T.TransformCoordinatesFromFloatsToRef(s.x,s.y,s.z,o,s),d}getClosestFacetAtLocalCoordinates(e,t,i,s,r=!1,a=!0){let o=null,c=0,u=0,d=0,f=0,g=0,m=0,b=0,x=0;const v=this.getFacetLocalPositions(),E=this.getFacetLocalNormals(),A=this.getFacetsAtLocalCoordinates(e,t,i);if(!A)return null;let D=Number.MAX_VALUE,I=D,R,C,M;for(let F=0;F<A.length;F++)R=A[F],C=E[R],M=v[R],f=(e-M.x)*C.x+(t-M.y)*C.y+(i-M.z)*C.z,(!r||r&&a&&f>=0||r&&!a&&f<=0)&&(f=C.x*M.x+C.y*M.y+C.z*M.z,g=-(C.x*e+C.y*t+C.z*i-f)/(C.x*C.x+C.y*C.y+C.z*C.z),m=e+C.x*g,b=t+C.y*g,x=i+C.z*g,c=m-e,u=b-t,d=x-i,I=c*c+u*u+d*d,I<D&&(D=I,o=R,s&&(s.x=m,s.y=b,s.z=x)));return o}getFacetDataParameters(){return this._internalAbstractMeshDataInfo._facetData.facetParameters}disableFacetData(){const e=this._internalAbstractMeshDataInfo._facetData;return e.facetDataEnabled&&(e.facetDataEnabled=!1,e.facetPositions=[],e.facetNormals=[],e.facetPartitioning=new Array,e.facetParameters={},e.depthSortedIndices=new Uint32Array(0)),this}updateIndices(e,t,i=!1){return this}createNormals(e){const t=this.getVerticesData(O.PositionKind),i=this.getIndices();let s;return this.isVerticesDataPresent(O.NormalKind)?s=this.getVerticesData(O.NormalKind):s=[],ve.ComputeNormals(t,i,s,{useRightHandedSystem:this.getScene().useRightHandedSystem}),this.setVerticesData(O.NormalKind,s,e),this}async optimizeIndicesAsync(){const e=this.getIndices();if(!e)return this;const{OptimizeIndices:t}=await _t(async()=>{const{OptimizeIndices:i}=await import("./mesh.vertexData.functions-ayNlGC5K.js");return{OptimizeIndices:i}},[]);return t(e),this.setIndices(e,this.getTotalVertices()),this}alignWithNormal(e,t){t||(t=wr.Y);const i=te.Vector3[0],s=te.Vector3[1];return T.CrossToRef(t,e,s),T.CrossToRef(e,s,i),this.rotationQuaternion?Se.RotationQuaternionFromAxisToRef(i,e,s,this.rotationQuaternion):T.RotationFromAxisToRef(i,e,s,this.rotation),this}_checkOcclusionQuery(){return!1}disableEdgesRendering(){throw We("EdgesRenderer")}enableEdgesRendering(e,t,i){throw We("EdgesRenderer")}getConnectedParticleSystems(){return this._scene.particleSystems.filter(e=>e.emitter===this)}}os.OCCLUSION_TYPE_NONE=0;os.OCCLUSION_TYPE_OPTIMISTIC=1;os.OCCLUSION_TYPE_STRICT=2;os.OCCLUSION_ALGORITHM_TYPE_ACCURATE=0;os.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE=1;os.CULLINGSTRATEGY_STANDARD=0;os.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1;os.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2;os.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3;N([la.filter((...[n,e,t,i,s])=>!Array.isArray(n)&&!Array.isArray(e)&&!Array.isArray(t)&&!Array.isArray(i)&&!Array.isArray(s))],os,"_ApplySkeleton",null);Tt("BABYLON.AbstractMesh",os);class cr{constructor(){this.reset()}reset(){this.enabled=!1,this.mask=255,this.funcRef=1,this.funcMask=255,this.func=519,this.opStencilFail=7680,this.opDepthFail=7680,this.opStencilDepthPass=7681,this.backFunc=519,this.backOpStencilFail=7680,this.backOpDepthFail=7680,this.backOpStencilDepthPass=7681}get func(){return this._func}set func(e){this._func=e}get backFunc(){return this._backFunc}set backFunc(e){this._backFunc=e}get funcRef(){return this._funcRef}set funcRef(e){this._funcRef=e}get funcMask(){return this._funcMask}set funcMask(e){this._funcMask=e}get opStencilFail(){return this._opStencilFail}set opStencilFail(e){this._opStencilFail=e}get opDepthFail(){return this._opDepthFail}set opDepthFail(e){this._opDepthFail=e}get opStencilDepthPass(){return this._opStencilDepthPass}set opStencilDepthPass(e){this._opStencilDepthPass=e}get backOpStencilFail(){return this._backOpStencilFail}set backOpStencilFail(e){this._backOpStencilFail=e}get backOpDepthFail(){return this._backOpDepthFail}set backOpDepthFail(e){this._backOpDepthFail=e}get backOpStencilDepthPass(){return this._backOpStencilDepthPass}set backOpStencilDepthPass(e){this._backOpStencilDepthPass=e}get mask(){return this._mask}set mask(e){this._mask=e}get enabled(){return this._enabled}set enabled(e){this._enabled=e}getClassName(){return"MaterialStencilState"}copyTo(e){$e.Clone(()=>e,this)}serialize(){return $e.Serialize(this)}parse(e,t,i){$e.Parse(()=>this,e,t,i)}}N([H()],cr.prototype,"func",null);N([H()],cr.prototype,"backFunc",null);N([H()],cr.prototype,"funcRef",null);N([H()],cr.prototype,"funcMask",null);N([H()],cr.prototype,"opStencilFail",null);N([H()],cr.prototype,"opDepthFail",null);N([H()],cr.prototype,"opStencilDepthPass",null);N([H()],cr.prototype,"backOpStencilFail",null);N([H()],cr.prototype,"backOpDepthFail",null);N([H()],cr.prototype,"backOpStencilDepthPass",null);N([H()],cr.prototype,"mask",null);N([H()],cr.prototype,"enabled",null);const Tr=new W,Ir=new W,Pr=new W,Go={getScene:()=>{},eyeAtCamera:!0};function Nh(n,e,t){const i=t.asArray(),s=e.asArray();for(let r=0;r<16;r++)i[r]=s[r];return i[12]-=n.x,i[13]-=n.y,i[14]-=n.z,t.markAsUpdated(),t}function CC(n,e,t){return ef(e,Ir),Nh(n,Ir,Pr),ef(Pr,t),t}function lf(n,e,t){if(!Go.eyeAtCamera)return CC(n,e,t);const i=t.asArray(),s=e.asArray();for(let r=0;r<16;r++)i[r]=s[r];return i[12]=0,i[13]=0,i[14]=0,t.markAsUpdated(),t}function Lm(n,e,t,i){return rc(lf(n,e,i),t,i),i}function Uk(n,e,t,i,s){for(let r=0;r<i;++r)IC(n,e[r],t[r],Ir),Ir.copyToArray(s,r*16);return s}function gT(n,e,t,i){return ef(t,Ir),rc(e,Ir,Pr),Nh(n,Pr,I
vendor: 1,097 bytes, line 231
231r),lf(n,t,Pr),rc(Ir,Pr,i),i}function IC(n,e,t,i){return CC(n,e,Pr),rc(Pr,t,i),i}function mT(n,e,t,i,s,r){return ef(t,Ir),rc(e,Ir,Pr),Nh(n,Pr,Ir),Lm(n,i,s,Pr),rc(Ir,Pr,r),r}function bT(n,e){const t=Go.getScene();if(!t||Tr===e)return e;Tr.updateFlag=e.updateFlag;const i=t.floatingOriginOffset;switch(n){case"world":return Nh(i,e,Tr);case"view":return lf(i,e,Tr);case"worldView":return gT(i,e,t.getViewMatrix(),Tr);case"viewProjection":return Lm(i,t.getViewMatrix(),t.getProjectionMatrix(),Tr);case"worldViewProjection":return mT(i,e,t.getTransformMatrix(),t.getViewMatrix(),t.getProjectionMatrix(),Tr);default:if(n.startsWith("u_")){if(n.startsWith("u_WorldViewProjection"))return mT(i,e,t.getTransformMatrix(),t.getViewMatrix(),t.getProjectionMatrix(),Tr);if(n.startsWith("u_ViewProjection"))return Lm(i,t.getViewMatrix(),t.getProjectionMatrix(),Tr);if(n.startsWith("u_WorldView"))return gT(i,e,t.getViewMatrix(),Tr);if(n.startsWith("u_World"))return Nh(i,e,Tr);if(n.startsWith("u_View"))return lf(i,e,Tr)}return e}}const Bh=Fe,Nm=At,PC=Bh.prototype._updateMatrixForUniform,DC=At.prototype.setMatr
231ix;function kk(){At.prototype.setMatrix=DC,Nm._setMatrixOverride=void 0,Bh.prototype._updateMatrixForUniform=PC,Bh.prototype._updateMatrixForUniformOverride=void 0}function Vk(){Nm.prototype._setMatrixOverride=DC,Nm.prototype.setMatrix=function(n,e){return this._setMatrixOverride(n,bT(n,e)),this},Bh.prototype._updateMatrixForUniformOverride=PC,Bh.prototype._updateMatrixForUniform=function(n,e){this._updateMatrixForUniformOverride(n,bT(n,e))}}function Nf(n){n.indexOf("vClipPlane")===-1&&n.push("vClipPlane"),n.indexOf("vClipPlane2")===-1&&n.push("vClipPlane2"),n.indexOf("vClipPlane3")===-1&&n.push("vClipPlane3"),n.indexOf("vClipPlane4")===-1&&n.push("vClipPlane4"),n.indexOf("vClipPlane5")===-1&&n.push("vClipPlane5"),n.indexOf("vClipPlane6")===-1&&n.push("vClipPlane6")}function wb(n,e,t){const i=!!(n.clipPlane??e.clipPlane),s=!!(n.clipPlane2??e.clipPlane2),r=!!(n.clipPlane3??e.clipPlane3),a=!!(n.clipPlane4??e.clipPlane4),o=!!(n.clipPlane5??e.clipPlane5),c=!!(n.clipPlane6??e.clipPlane6);i&&t.push("#define CLIPPLANE"),s&&t.push("#define CLIPPLANE2"),r&&t.push("#define CLIPPLANE3"),a&&t.push("#define CLIPPLANE4"),o&&t.push("#define CLIPPLANE5"),c&&t.push("#define CLIPPLANE6")}function zk(n,e,t){let i=!1;const s=!!(n.clipPlane??e.clipPlane),r=!!(n.clipPlane2??e.clipPlane2),a=!!(n.clipPlane3??e.clipPlane3),o=!!(n.clipPlane4??e.clipPlane4),c=!!(n.clipPlane5??e.clipPlane5),u=!!(n.clipPlane6??e.clipPlane6);return t.CLIPPLANE!==s&&(t.CLIPPLANE=s,i=!0),t.CLIPPLANE2!==r&&(t.CLIPPLANE2=r,i=!0),t.CLIPPLANE3!==a&&(t.CLIPPLANE3=a,i=!0),t.CLIPPLANE4!==o&&(t.CLIPPLANE4=o,i=!0),t.CLIPPLANE5!==c&&(t.CLIPPLANE5=c,i=!0),t.CLIPPLANE6!==u&&(t.CLIPPLANE6=u,i=!0),i}function Bf(n,e,t){let i=e.clipPlane??t.clipPlane;zl(n,"vClipPlane",i),i=e.clipPlane2??t.clipPlane2,zl(n,"vClipPlane2",i),i=e.clipPlane3??t.clipPlane3,zl(n,"vClipPlane3",i),i=e.clipPlane4??t.clipPlane4,zl(n,"vClipPlane4",i),i=e.clipPlane5??t.clipPlane5,zl(n,"vClipPlane5",i),i=e.clipPlane6??t.clipPlane6,zl(n,"vClipPlane6",i)}function zl(n,e,t){if(t){const i=Go.getScene()?.floatingOriginOffset||T.ZeroReadOnly;n.setFloat4(e,t.normal.x,t.normal.y,t.normal.z,t.d+T.Dot(t.normal,i))}}class at{static get DiffuseTextureEnabled(){return this._DiffuseTextureEnabled}static set DiffuseTextureEnabled(e){this._DiffuseTextureEnabled!==e&&(this._DiffuseTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get BaseWeightTextureEnabled(){return this._BaseWeightTextureEnabled}static set BaseWeightTextureEnabled(e){this._BaseWeightTextureEnabled!==e&&(this._BaseWeightTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get BaseDiffuseRoughnessTextureEnabled(){return this._BaseDiffuseRoughnessTextureEnabled}static set BaseDiffuseRoughnessTextureEnabled(e){this._BaseDiffuseRoughnessTextureEnabled!==e&&(this._BaseDiffuseRoughnessTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get DetailTextureEnabled(){return this._DetailTextureEnabled}static set DetailTextureEnabled(e){this._DetailTextureEnabled!==e&&(this._DetailTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get DecalMapEnabled(){return this._DecalMapEnabled}static set DecalMapEnabled(e){this._DecalMapEnabled!==e&&(this._DecalMapEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get AmbientTextureEnabled(){return this._AmbientTextureEnabled}static set AmbientTextureEnabled(e){this._AmbientTextureEnabled!==e&&(this._AmbientTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get OpacityTextureEnabled(){return this._OpacityTextureEnabled}static set OpacityTextureEnabled(e){this._OpacityTextureEnabled!==e&&(this._OpacityTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get ReflectionTextureEnabled(){return this._ReflectionTextureEnabled}static set ReflectionTextureEnabled(e){this._ReflectionTextureEnabled!==e&&(this._ReflectionTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get EmissiveTextureEnabled(){return this._EmissiveTextureEnabled}static set EmissiveTextureEnabled(e){this._EmissiveTextureEnabled!==e&&(this._EmissiveTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get SpecularTextureEnabled(){return this._SpecularTextureEnabled}static set SpecularTextureEnabled(e){this._SpecularTextureEnabled!==e&&(this._SpecularTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get BumpTextureEnabled(){return this._BumpTextureEnabled}static set BumpTextureEnabled(e){this._BumpTextureEnabled!==e&&(this._BumpTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get LightmapTextureEnabled(){return this._LightmapTextureEnabled}static set LightmapTextureEnabled(e){this._LightmapTextureEnabled!==e&&(this._LightmapTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get RefractionTextureEnabled(){return this._RefractionTextureEnabled}static set RefractionTextureEnabled(e){this._RefractionTextureEnabled!==e&&(this._RefractionTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get ColorGradingTextureEnabled(){return this._ColorGradingTextureEnabled}static set ColorGradingTextureEnabled(e){this._ColorGradingTextureEnabled!==e&&(this._ColorGradingTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get FresnelEnabled(){return this._FresnelEnabled}static set FresnelEnabled(e){this._FresnelEnabled!==e&&(this._FresnelEnabled=e,Ce.MarkAllMaterialsAsDirty(4))}static get ClearCoatTextureEnabled(){return this._ClearCoatTextureEnabled}static set ClearCoatTextureEnabled(e){this._ClearCoatTextureEnabled!==e&&(this._ClearCoatTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get ClearCoatBumpTextureEnabled(){return this._ClearCoatBumpTextureEnabled}static set ClearCoatBumpTextureEnabled(e){this._ClearCoatBumpTextureEnabled!==e&&(this._ClearCoatBumpTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get ClearCoatTintTextureEnabled(){return this._ClearCoatTintTextureEnabled}static set ClearCoatTintTextureEnabled(e){this._ClearCoatTintTextureEnabled!==e&&(this._ClearCoatTintTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get SheenTextureEnabled(){return this._SheenTextureEnabled}static set SheenTextureEnabled(e){this._SheenTextureEnabled!==e&&(this._SheenTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get AnisotropicTextureEnabled(){return this._AnisotropicTextureEnabled}static set AnisotropicTextureEnabled(e){this._AnisotropicTextureEnabled!==e&&(this._AnisotropicTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get ThicknessTextureEnabled(){return this._ThicknessTextureEnabled}static set ThicknessTextureEnabled(e){this._ThicknessTextureEnabled!==e&&(this._ThicknessTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get RefractionIntensityTextureEnabled(){return this._ThicknessTextureEnabled}static set RefractionIntensityTextureEnabled(e){this._RefractionIntensityTextureEnabled!==e&&(this._RefractionIntensityTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get TranslucencyIntensityTextureEnabled(){return this._TranslucencyIntensityTextureEnabled}static set TranslucencyIntensityTextureEnabled(e){this._TranslucencyIntensityTextureEnabled!==e&&(this._TranslucencyIntensityTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get TranslucencyColorTextureEnabled(){return this._TranslucencyColorTextureEnabled}static set TranslucencyColorTextureEnabled(e){this._TranslucencyColorTextureEnabled!==e&&(this._TranslucencyColorTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}static get IridescenceTextureEnabled(){return this._IridescenceTextureEnabled}static set IridescenceTextureEnabled(e){this._IridescenceTextureEnabled!==e&&(this._IridescenceTextureEnabled=e,Ce.MarkAllMaterialsAsDirty(1))}}at._DiffuseTextureEnabled=!0;at._BaseWeightTextureEnabled=!0;at._BaseDiffuseRoughnessTextureEnabled=!0;at._DetailTextureEnabled=!0;at._DecalMapEnabled=!0;at._AmbientTextureEnabled=!0;at._OpacityTextureEnabled=!0;at._ReflectionTextureEnabled=!0;at._EmissiveTextureEnabled=!0;at._SpecularTextureEnabled=!0;at._BumpTextureEnabled=!0;at._LightmapTextureEnabled=!0;at._RefractionTextureEnabled=!0;at._ColorGradingTextureEnabled=!0;at._FresnelEnabled=!0;at._ClearCoatTextureEnabled=!0;at._ClearCoatBumpTextureEnabled=!0;at._ClearCoatTintTextureEnabled=!0;at._SheenTextureEnabled=!0;at._AnisotropicTextureEnabled=!0;at._ThicknessTextureEnabled=!0;at._RefractionIntensityTextureEnabled=!0;at._TranslucencyIntensityTextureEnabled=!0;at._TranslucencyColorTextureEnabled=!0;at._IridescenceTextureEnabled=!0;
vendor: 4,667 bytes, line 231
231function OC(n,e,t=!1){const i=e.width,s=e.height;if(n instanceof Float32Array){let u=n.byteLength/n.BYTES_PER_ELEMENT;const d=new Uint8Array(u);for(;--u>=0;){let f=n[u];f<0?f=0:f>1&&(f=1),d[u]=f*255}n=d}const r=document.createElement("canvas");r.width=i,r.height=s;const a=r.getContext("2d");if(!a)return null;const o=a.createImageData(i,s);if(o.data.set(n),a.putImageData(o,0,0),t){const u=document.createElement("canvas");u.width=i,u.height=s;const d=u.getContext("2d");return d?(d.translate(0,s),d.scale(1,-1),d.drawImage(r,0,0),u.toDataURL("image/png")):null}return r.toDataURL("image/png")}function Gk(n,e=0,t=0){const i=n.getInternalTexture();if(!i)return null;const s=n._readPixelsSync(e,t);return s?OC(s,n.getSize(),i.invertY):null}async function Hk(n,e=0,t=0){const i=n.getInternalTexture();if(!i)return null;const s=await n.readPixels(e,t);return s?OC(s,n.getSize(),i.invertY):null}class Te extends jt{static _CreateVideoTexture(e,t,i,s=!1,r=!1,a=Te.TRILINEAR_SAMPLINGMODE,o={},c,u=5){throw We("VideoTexture")}get noMipmap(){return this._noMipmap}get mimeType(){return this._mimeType}set isBlocking(e){this._isBlocking=e}get isBlocking(){return this._isBlocking}get invertY(){return this._invertY}constructor(e,t,i,s,r=Te.TRILINEAR_SAMPLINGMODE,a=null,o=null,c=null,u=!1,d,f,g,m,b){super(t),this.url=null,this.uOffset=0,this.vOffset=0,this.uScale=1,this.vScale=1,this.uAng=0,this.vAng=0,this.wAng=0,this.uRotationCenter=.5,this.vRotationCenter=.5,this.wRotationCenter=.5,this.homogeneousRotationInUVTransform=!1,this.inspectableCustomProperties=null,this._noMipmap=!1,this._invertY=!1,this._rowGenerationMatrix=null,this._cachedTextureMatrix=null,this._projectionModeMatrix=null,this._t0=null,this._t1=null,this._t2=null,this._cachedUOffset=-1,this._cachedVOffset=-1,this._cachedUScale=0,this._cachedVScale=0,this._cachedUAng=-1,this._cachedVAng=-1,this._cachedWAng=-1,this._cachedReflectionProjectionMatrixId=-1,this._cachedURotationCenter=-1,this._cachedVRotationCenter=-1,this._cachedWRotationCenter=-1,this._cachedHomogeneousRotationInUVTransform=!1,this._cachedIdentity3x2=!0,this._cachedReflectionTextureMatrix=null,this._cachedReflectionUOffset=-1,this._cachedReflectionVOffset=-1,this._cachedReflectionUScale=0,this._cachedReflectionVScale=0,this._cachedReflectionCoordinatesMode=-1,this._buffer=null,this._deleteBuffer=!1,this._format=null,this._delayedOnLoad=null,this._delayedOnError=null,this.onLoadObservable=new le,this._isBlocking=!0,this.name=e||"",this.url=e;let x,v=!1,E=null,A=!0;typeof i=="object"&&i!==null?(x=i.noMipmap??!1,s=i.invertY??!0,r=i.samplingMode??Te.TRILINEAR_SAMPLINGMODE,a=i.onLoad??null,o=i.onError??null,c=i.buffer??null,u=i.deleteBuffer??!1,d=i.format,f=i.mimeType,g=i.loaderOptions,m=i.creationFlags,v=i.useSRGBBuffer??!1,E=i.internalTexture??null,A=i.gammaSpace??A,b=i.forcedExtension??b):x=!!i,this._gammaSpace=A,this._noMipmap=x,this._invertY=s===void 0?!0:s,this._initialSamplingMode=r,this._buffer=c,this._deleteBuffer=u,this._mimeType=f,this._loaderOptions=g,this._creationFlags=m,this._useSRGBBuffer=v,this._forcedExtension=b,d!==void 0&&(this._format=d);const D=this.getScene(),I=this._getEngine();if(!I)return;I.onBeforeTextureInitObservable.notifyObservers(this);const R=()=>{this._texture&&(this._texture._invertVScale&&(this.vScale*=-1,this.vOffset+=1),this._texture._cachedWrapU!==null&&(this.wrapU=this._texture._cachedWrapU,this._texture._cachedWrapU=null),this._texture._cachedWrapV!==null&&(this.wrapV=this._texture._cachedWrapV,this._texture._cachedWrapV=null),this._texture._cachedWrapR!==null&&(this.wrapR=this._texture._cachedWrapR,this._texture._cachedWrapR=null)),this.onLoadObservable.hasObservers()&&this.onLoadObservable.notifyObservers(this),a&&a(),!this.isBlocking&&D&&D.resetCachedMaterial()},C=(M,F)=>{this._loadingError=!0,this._errorObject={message:M,exception:F},o&&o(M,F),Te.OnTextureLoadErrorObservable.notifyObservers(this)};if(!this.url&&!E){this._delayedOnLoad=R,this._delayedOnError=C;return}if(this._texture=E??this._getFromCache(this.url,x,r,this._invertY,v,this.isCube),this._texture)if(this._texture.isReady)zo.SetImmediate(()=>R());else{const M=this._texture.onLoadedObservable.add(R);this._texture.onErrorObservable.add(F=>{C(F.message,F.exception),this._texture?.onLoadedObservable.remove(M)})}else if(!D||!D.useDelayedTextureLoading){try{this._texture=I.createTexture(this.url,x,this._invertY,D,r,R,C,this._buffer,void 0,this._format,this._forcedExtension,f,g,m,v)}catch(M){throw C("error loading",M),M}u&&(this._buffer=null)}else this.delayLoadState=4,this._delayedOnLoad=R,this._delayedOnError=C}updateURL(e,t=null,i,s){this.url&&(this.releaseInternalTexture(),this.get
vendor: 4,287 bytes, line 231
231Scene().markAllMaterialsAsDirty(1,o=>o.hasTexture(this))),(!this.name||this.name.startsWith("data:"))&&(this.name=e),this.url=e,this._buffer=t,this._forcedExtension=s,this.delayLoadState=4;const r=this._delayedOnLoad,a=()=>{r?r():this.onLoadObservable.hasObservers()&&this.onLoadObservable.notifyObservers(this),i&&i()};this._delayedOnLoad=a,this.delayLoad()}delayLoad(){if(this.delayLoadState!==4)return;const e=this.getScene();if(!e)return;let t=this.url;!t&&(this.name.indexOf("://")>0||this.name.startsWith("data:"))&&(t=this.name),this.delayLoadState=1,this._texture=this._getFromCache(t,this._noMipmap,this.samplingMode,this._invertY,this._useSRGBBuffer,this.isCube),this._texture?this._delayedOnLoad&&(this._texture.isReady?zo.SetImmediate(this._delayedOnLoad):this._texture.onLoadedObservable.add(this._delayedOnLoad)):(this._texture=e.getEngine().createTexture(t,this._noMipmap,this._invertY,e,this.samplingMode,this._delayedOnLoad,this._delayedOnError,this._buffer,null,this._format,this._forcedExtension,this._mimeType,this._loaderOptions,this._creationFlags,this._useSRGBBuffer),this._deleteBuffer&&(this._buffer=null)),this._delayedOnLoad=null,this._delayedOnError=null}_prepareRowForTextureGeneration(e,t,i,s){e*=this._cachedUScale,t*=this._cachedVScale,e-=this.uRotationCenter*this._cachedUScale,t-=this.vRotationCenter*this._cachedVScale,i-=this.wRotationCenter,T.TransformCoordinatesFromFloatsToRef(e,t,i,this._rowGenerationMatrix,s),s.x+=this.uRotationCenter*this._cachedUScale+this._cachedUOffset,s.y+=this.vRotationCenter*this._cachedVScale+this._cachedVOffset,s.z+=this.wRotationCenter}getTextureMatrix(e=1){if(this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale*e===this._cachedUScale&&this.vScale===this._cachedVScale&&this.uAng===this._cachedUAng&&this.vAng===this._cachedVAng&&this.wAng===this._cachedWAng&&this.uRotationCenter===this._cachedURotationCenter&&this.vRotationCenter===this._cachedVRotationCenter&&this.wRotationCenter===this._cachedWRotationCenter&&this.homogeneousRotationInUVTransform===this._cachedHomogeneousRotationInUVTransform)return this._cachedTextureMatrix;this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale*e,this._cachedVScale=this.vScale,this._cachedUAng=this.uAng,this._cachedVAng=this.vAng,this._cachedWAng=this.wAng,this._cachedURotationCenter=this.uRotationCenter,this._cachedVRotationCenter=this.vRotationCenter,this._cachedWRotationCenter=this.wRotationCenter,this._cachedHomogeneousRotationInUVTransform=this.homogeneousRotationInUVTransform,(!this._cachedTextureMatrix||!this._rowGenerationMatrix)&&(this._cachedTextureMatrix=W.Zero(),this._rowGenerationMatrix=new W,this._t0=T.Zero(),this._t1=T.Zero(),this._t2=T.Zero()),W.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this.homogeneousRotationInUVTransform?(W.TranslationToRef(-this._cachedURotationCenter,-this._cachedVRotationCenter,-this._cachedWRotationCenter,te.Matrix[0]),W.TranslationToRef(this._cachedURotationCenter,this._cachedVRotationCenter,this._cachedWRotationCenter,te.Matrix[1]),W.ScalingToRef(this._cachedUScale,this._cachedVScale,0,te.Matrix[2]),W.TranslationToRef(this._cachedUOffset,this._cachedVOffset,0,te.Matrix[3]),te.Matrix[0].multiplyToRef(this._rowGenerationMatrix,this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(te.Matrix[1],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(te.Matrix[2],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(te.Matrix[3],this._cachedTextureMatrix),this._cachedTextureMatrix.setRowFromFloats(2,this._cachedTextureMatrix.m[12],this._cachedTextureMatrix.m[13],this._cachedTextureMatrix.m[14],1)):(this._prepareRowForTextureGeneration(0,0,0,this._t0),this._prepareRowForTextureGeneration(1,0,0,this._t1),this._prepareRowForTextureGeneration(0,1,0,this._t2),this._t1.subtractInPlace(this._t0),this._t2.subtractInPlace(this._t0),W.FromValuesToRef(this._t1.x,this._t1.y,this._t1.z,0,this._t2.x,this._t2.y,this._t2.z,0,this._t0.x,this._t0.y,this._t0.z,0,0,0,0,1,this._cachedTextureMatrix));const t=this.getScene();if(!t)return this._cachedTextureMatrix;const i=this._cachedIdentity3x2;return this._cachedIdentity3x2=this._cachedTextureMatrix.isIdentityAs3x2(
vendor: 6,963 bytes, line 231
231),this.optimizeUVAllocation&&i!==this._cachedIdentity3x2&&t.markAllMaterialsAsDirty(1,s=>s.hasTexture(this)),this._cachedTextureMatrix}getReflectionTextureMatrix(){const e=this.getScene();if(!e)return this._cachedReflectionTextureMatrix;if(this.uOffset===this._cachedReflectionUOffset&&this.vOffset===this._cachedReflectionVOffset&&this.uScale===this._cachedReflectionUScale&&this.vScale===this._cachedReflectionVScale&&this.coordinatesMode===this._cachedReflectionCoordinatesMode)if(this.coordinatesMode===Te.PROJECTION_MODE){if(this._cachedReflectionProjectionMatrixId===e.getProjectionMatrix().updateFlag)return this._cachedReflectionTextureMatrix}else return this._cachedReflectionTextureMatrix;this._cachedReflectionTextureMatrix||(this._cachedReflectionTextureMatrix=W.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=W.Zero());const t=this._cachedReflectionCoordinatesMode!==this.coordinatesMode;switch(this._cachedReflectionUOffset=this.uOffset,this._cachedReflectionVOffset=this.vOffset,this._cachedReflectionUScale=this.uScale,this._cachedReflectionVScale=this.vScale,this._cachedReflectionCoordinatesMode=this.coordinatesMode,this.coordinatesMode){case Te.PLANAR_MODE:{W.IdentityToRef(this._cachedReflectionTextureMatrix),this._cachedReflectionTextureMatrix[0]=this.uScale,this._cachedReflectionTextureMatrix[5]=this.vScale,this._cachedReflectionTextureMatrix[12]=this.uOffset,this._cachedReflectionTextureMatrix[13]=this.vOffset;break}case Te.PROJECTION_MODE:{W.FromValuesToRef(.5,0,0,0,0,-.5,0,0,0,0,0,0,.5,.5,1,1,this._projectionModeMatrix);const i=e.getProjectionMatrix();this._cachedReflectionProjectionMatrixId=i.updateFlag,i.multiplyToRef(this._projectionModeMatrix,this._cachedReflectionTextureMatrix);break}default:W.IdentityToRef(this._cachedReflectionTextureMatrix);break}return t&&e.markAllMaterialsAsDirty(1,i=>i.hasTexture(this)),this._cachedReflectionTextureMatrix}clone(){const e={noMipmap:this._noMipmap,invertY:this._invertY,samplingMode:this.samplingMode,onLoad:void 0,onError:void 0,buffer:this._texture?this._texture._buffer:void 0,deleteBuffer:this._deleteBuffer,format:this.textureFormat,mimeType:this.mimeType,loaderOptions:this._loaderOptions,creationFlags:this._creationFlags,useSRGBBuffer:this._useSRGBBuffer};return $e.Clone(()=>new Te(this._texture?this._texture.url:null,this.getScene(),e),this)}serialize(){const e=this.name;Te.SerializeBuffers||this.name.startsWith("data:")&&(this.name=""),this.name.startsWith("data:")&&this.url===this.name&&(this.url="");const t=super.serialize(Te._SerializeInternalTextureUniqueId);if(!t)return null;if(Te.SerializeBuffers||Te.ForceSerializeBuffers)if(typeof this._buffer=="string"&&this._buffer.startsWith("data:"))t.base64String=this._buffer,t.name=t.name.replace("data:","");else if(this.url&&this.url.startsWith("data:")&&this._buffer instanceof Uint8Array){const i=this.mimeType||"image/png";t.base64String=`data:${i};base64,${vC(this._buffer)}`}else(Te.ForceSerializeBuffers||this.url&&this.url.startsWith("blob:")||this._forceSerialize)&&(t.base64String=!this._engine||this._engine._features.supportSyncTextureRead?Gk(this):Hk(this));return t.invertY=this._invertY,t.samplingMode=this.samplingMode,t._creationFlags=this._creationFlags,t._useSRGBBuffer=this._useSRGBBuffer,Te._SerializeInternalTextureUniqueId&&(t.internalTextureUniqueId=this._texture?.uniqueId),t.internalTextureLabel=this._texture?.label,t.noMipmap=this._noMipmap,this.name=e,t}getClassName(){return"Texture"}dispose(){super.dispose(),this.onLoadObservable.clear(),this._delayedOnLoad=null,this._delayedOnError=null,this._buffer=null}static Parse(e,t,i){if(e.customType){const u=vh.Instantiate(e.customType).Parse(e,t,i);return e.samplingMode&&u.updateSamplingMode&&u._samplingMode&&u._samplingMode!==e.samplingMode&&u.updateSamplingMode(e.samplingMode),u}if(e.isCube&&!e.isRenderTarget)return Te._CubeTextureParser(e,t,i);const s=e.internalTextureUniqueId!==void 0;if(!e.name&&!e.isRenderTarget&&!s)return null;let r;if(s){const c=t.getEngine().getLoadedTexturesCache();for(const u of c)if(u.uniqueId===e.internalTextureUniqueId){r=u;break}}const a=c=>{if(c&&c._texture&&(c._texture._cachedWrapU=null,c._texture._cachedWrapV=null,c._texture._cachedWrapR=null),e.samplingMode){const u=e.samplingMode;c&&c.samplingMode!==u&&c.updateSamplingMode(u)}if(c&&e.animations)for(let u=0;u<e.animations.length;u++){const d=e.animations[u],f=Kr("BABYLON.Animation");f&&c.animations.push(f.Parse(d))}c&&c._texture&&(s&&!r&&c._texture._setUniqueId(e.internalTextureUniqueId),c._texture.label=e.internalTextureLabel)};return $e.Parse(()=>{let c=!0;if(e.noMipmap&&(c=!1),e.mirrorPlane){const u=Te._CreateMirror(e.name,e.renderTargetSize,t,c);return u._waitingRenderList=e.renderList,u.mirrorPlane=Cr.FromArray(e.mirrorPlane),a(u),u}else if(e.isRenderTarget&&!e.base64String){let u=null;if(e.isCube){if(t.reflectionProbes)for(let d=0;d<t.reflectionProbes.length;d++){const f=t.reflectionProbes[d];if(f.name===e.name)return f.cubeTexture}}else u=Te._CreateRenderTargetTexture(e.name,e.renderTargetSize,t,c,e._creationFlags??0),u._waitingRenderList=e.renderList;return a(u),u}else if(e.isVideo){const u=Te._CreateVideoTexture(i+(e.url||e.name),i+(e.src||e.url),t,c,e.invertY,e.samplingMode,e.settings||{});return a(u),u}else{let u;if(e.base64String&&!r)u=Te.CreateFromBase64String(e.base64String,e.base64String,t,!c,e.invertY,e.samplingMode,()=>{a(u)},e._creationFlags??0,e._useSRGBBuffer??!1),u.name=e.name;else{let d;e.name&&(e.name.indexOf("://")>0||e.name.startsWith("data:"))?d=e.name:d=i+e.name,e.url&&(e.url.startsWith("data:")||Te.UseSerializedUrlIfAny)&&(d=e.url);const f={noMipmap:!c,invertY:e.invertY,samplingMode:e.samplingMode,onLoad:()=>{a(u)},internalTexture:r};u=new Te(d,t,f)}return u}},e,t)}static CreateFromBase64String(e,t,i,s,r,a=Te.TRILINEAR_SAMPLINGMODE,o=null,c=null,u=5,d,f){return new Te("data:"+t,i,s,r,a,o,c,e,!1,u,void 0,void 0,d,f)}static LoadFromDataString(e,t,i,s=!1,r,a=!0,o=Te.TRILINEAR_SAMPLINGMODE,c=null,u=null,d=5,f,g){return e.substring(0,5)!=="data:"&&(e="data:"+e),new Te(e,i,r,a,o,c,u,t,s,d,void 0,void 0,f,g)}}Te.SerializeBuffers=!0;Te.ForceSerializeBuffers=!1;Te.OnTextureLoadErrorObservable=new le;Te._SerializeInternalTextureUniqueId=!1;Te._CubeTextureParser=(n,e,t)=>{throw We("CubeTexture")};Te._CreateMirror=(n,e,t,i)=>{throw We("MirrorTexture")};Te._CreateRenderTargetTexture=(n,e,t,i,s)=>{throw We("RenderTargetTexture")};Te.NEAREST_SAMPLINGMODE=1;Te.NEAREST_NEAREST_MIPLINEAR=8;Te.BILINEAR_SAMPLINGMODE=2;Te.LINEAR_LINEAR_MIPNEAREST=11;Te.TRILINEAR_SAMPLINGMODE=3;Te.LINEAR_LINEAR_MIPLINEAR=3;Te.NEAREST_NEAREST_MIPNEAREST=4;Te.NEAREST_LINEAR_MIPNEAREST=5;Te.NEAREST_LINEAR_MIPLINEAR=6;Te.NEAREST_LINEAR=7;Te.NEAREST_NEAREST=1;Te.LINEAR_NEAREST_MIPNEAREST=9;Te.LINEAR_NEAREST_MIPLINEAR=10;Te.LINEAR_LINEAR=2;Te.LINEAR_NEAREST=12;Te.EXPLICIT_MODE=0;Te.SPHERICAL_MODE=1;Te.PLANAR_MODE=2;Te.CUBIC_MODE=3;Te.PROJECTION_MODE=4;Te.SKYBOX_MODE=5;Te.INVCUBIC_MODE=6;
231Te.EQUIRECTANGULAR_MODE=7;Te.FIXED_EQUIRECTANGULAR_MODE=8;Te.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9;Te.CLAMP_ADDRESSMODE=0;Te.WRAP_ADDRESSMODE=1;Te.MIRROR_ADDRESSMODE=2;Te.UseSerializedUrlIfAny=!1;N([H()],Te.prototype,"url",void 0);N([H()],Te.prototype,"uOffset",void 0);N([H()],Te.prototype,"vOffset",void 0);N([H()],Te.prototype,"uScale",void 0);N([H()],Te.prototype,"vScale",void 0);N([H()],Te.prototype,"uAng",void 0);N([H()],Te.prototype,"vAng",void 0);N([H()],Te.prototype,"wAng",void 0);N([H()],Te.prototype,"uRotationCenter",void 0);N([H()],Te.prototype,"vRotationCenter",void 0);N([H()],Te.prototype,"wRotationCenter",void 0);N([H()],Te.prototype,"homogeneousRotationInUVTransform",void 0);N([H()],Te.prototype,"isBlocking",null);Tt("BABYLON.Texture",Te);$e._TextureParser=Te.Parse;function Fb(n,e,t){if(!n||n.LOGARITHMICDEPTH||n.indexOf&&n.indexOf("LOGARITHMICDEPTH")>=0){const i=t.activeCamera;i.mode===1&&oe.Error("Logarithmic depth is not compatible with orthographic cameras!",20),e.setFloat("logarithmicDepthConstant",2/(Math.log(i.maxZ+1)/Math.LN2))}}const yT={r:0,g:0,b:0},Io={NUM_MORPH_INFLUENCERS:0,NORMAL:!1,TANGENT:!1,UV:!1,UV2:!1,COLOR:!1};function wC(n,e,t,i=!1){t&&n.fogEnabled&&(!e||e.applyFog)&&n.fogMode!==0&&(t.setFloat4("vFogInfos",n.fogMode,n.fogStart,n.fogEnd,n.fogDensity),i?(n.fogColor.toLinearSpaceToRef(yT,n.getEngine().useExactSrgbConversions),t.setColor3("vFogColor",yT)):t.setColor3("vFogColor",n.fogColor))}function Lb(n,e,t,i,s,r,a,o,c,u){const d=n.numMaxInfluencers||n.numInfluencers;return d<=0?0:(e.push("#define MORPHTARGETS"),n.hasPositions&&e.push("#define MORPHTARGETTEXTURE_HASPOSITIONS"),n.hasNormals&&e.push("#define MORPHTARGETTEXTURE_HASNORMALS"),n.hasTangents&&e.push("#define MORPHTARGETTEXTURE_HASTANGENTS"),n.hasUVs&&e.push("#define MORPHTARGETTEXTURE_HASUVS"),n.hasUV2s&&e.push("#define MORPHTARGETTEXTURE_HASUV2S"),n.hasColors&&e.push("#define MORPHTARGETTEXTURE_HASCOLORS"),n.supportsPositions&&s&&e.push("#define MORPHTARGETS_POSITION"),n.supportsNormals&&r&&e.push("#define MORPHTARGETS_NORMAL"),n.supportsTangents&&a&&e.push("#define MORPHTARGETS_TANGENT"),n.supportsUVs&&o&&e.push("#define MORPHTARGETS_UV"),n.supportsUV2s&&c&&e.push("#define MORPHTARGETS_UV2"),n.supportsColors&&u&&e.push("#define MORPHTARGETS_COLOR"),e.push("#define NUM_MORPH_INFLUENCERS "+d),n.isUsingTextureForTargets&&e.push("#define MORPHTARGETS_TEXTURE"),Io.NUM_MORPH_INFLUENCERS=d,Io.NORMAL=r,Io.TANGENT=a,Io.UV=o,Io.UV2=c,Io.COLOR=u,FC(t,i,Io,s),d)}function FC(n,e,t,i=!0){const s=t.NUM_MORPH_INFLUENCERS;if(s>0&&Ke.LastCreatedEngine){const r=Ke.LastCreatedEngine.getCaps().maxVertexAttribs,a=e.morphTargetManager;if(a?.isUsingTextureForTargets)return;const o=a&&a.supportsPositions&&i,c=a&&a.supportsNormals&&t.NORMAL,u=a&&a.supportsTangents&&t.TANGENT,d=a&&a.supportsUVs&&t.UV1,f=a&&a.supportsUV2s&&t.UV2,g=a&&a.supportsColors&&t.VERTEXCOLOR;for(let m=0;m<s;m++)o&&n.push("position"+m),c&&n.push("normal"+m),u&&n.push("tangent"+m),d&&n.push("uv_"+m),f&&n.push("uv2_"+m),g&&n.push("color"+m),n.length>r&&oe.Error("Cannot add more vertex attributes for mesh "+e.name)}}function Uf(n,e=!1){n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"),e&&(n.push("previousWorld0"),n.push("previousWorld1"),n.push("previousWorld2"),n.push("previousWorld3"))}function kf(n,e){const t=n.morphTargetManager;!n||!t||e.setFloatArray("morphTargetInfluences",t.influences)}function Nb(n,e){e.bindToEffect(n,"Scene")}function Wk(n,e,t,i,s=null,r=!1,a=!1,o=!1,c=!1,u=!1,d=!1,f=0){if(n.texturesEnabled&&s&&at.ReflectionTextureEnabled){if(t.updateMatrix("reflectionMatrix",s.getReflectionTextureMatrix()),t.updateFloat2("vReflectionInfos",s.level*n.iblIntensity,f),o&&s.boundingBoxSize){const g=s;t.updateVector3("vReflectionPosition",g.boundingBoxPosition),t.updateVector3("vReflectionSize",g.boundingBoxSize)}if(r){const g=s.getSize().width;t.updateFloat2("vReflectionFilteringInfo",g,Math.log2(g))}if(u&&!e.USEIRRADIANCEMAP){const g=s.sphericalPolynomial;if(e.USESPHERICALFROMREFLECTIONMAP&&g)if(e.SPHERICAL_HARMONICS){const m=g.preScaledHarmonics;t.updateVector3("vSphericalL00",m.l00),t.updateVector3("vSphericalL1_1",m.l1_1),t.updateVector3("vSphericalL10",m.l10),t.updateVector3("vSphericalL11",m.l11),t.updateVector3("vSphericalL2_2",m.l2_2),t.updateVector3("vSphericalL2_1",m.l2_1),t.updateVector3("vSphericalL20",m.l20),t.updateVector3("vSphericalL21",m.l21),t.updateVector3("vSphericalL22",m.l22)}else t.updateFloat3("vSphericalX",g.x.x,g.x.y,g.x.z),t.updateFloat3("vSphericalY",g.y.x,g.y.y,g.y.z),t.updateFloat3("vSphericalZ",g.z.x,g.z.y,g.z.z),t.updateFloat3("vSphericalXX_ZZ",g.xx.x-g.zz.x,g.xx.y-g.zz.y,g.xx.z-g.zz.z),t.updateFloat3("vSphericalYY_ZZ",g.yy.x-g.zz.x,g.yy.y-g.zz.y,g.yy.z-g.zz.z),t.updateFloat3("vSphericalZZ",g.zz.x,g.zz.y,g.zz.z),t.updateFloat3("vSphericalXY",g.xy.x,g.xy.y,g.xy.z),t.updateFloat3("vSphericalYZ",g.yz.x,g.yz.y,g.yz.z),t.updateFloat3("vSphericalZX",g.zx.x,g.zx.y,g.zx.z)}else c&&e.USEIRRADIANCEMAP&&e.USE_IRRADIANCE_DOMINANT_DIRECTION&&t.updateVector3("vReflectionDominantDirection",s.irradianceTexture._dominantDirection);a&&t.updateFloat3("vReflectionMicrosurfaceInfos",s.getSize().width,s.lodGenerationScale,s.lodGenerationOffset)}d&&t.updateColor3("vReflectionColor",i)}function Ga(n,e,t){e._needUVs=!0,e[t]=!0,n.optimizeUVAllocation&&n.getTextureMatrix().isIdentityAs3x2(
231)?(e[t+"DIRECTUV"]=n.coordinatesIndex+1,e["MAINUV"+(n.coordinatesIndex+1)]=!0):e[t+"DIRECTUV"]=0}function Ha(n,e,t){const i=n.getTextureMatrix();e.updateMatrix(t+"Matrix",i)}function Xk(n,e,t){t.BAKED_VERTEX_ANIMATION_TEXTURE&&t.INSTANCES&&n.push("bakedVertexAnimationSettingsInstanced")}function Bb(n,e,t){if(!(!e||!n)&&(n.computeBonesUsingShaders&&e._bonesComputationForcedToCPU&&(n.computeBonesUsingShaders=!1),n.useBones&&n.computeBonesUsingShaders&&n.skeleton)){const i=n.skeleton;if(i.isUsingTextureForMatrices&&e.getUniformIndex("boneTextureWidth")>-1){const s=i.getTransformMatrixTexture(n);e.setTexture("boneSampler",s),e.setFloat("boneTextureWidth",4*(i.bones.length+1))}else{const s=i.getTransformMatrices(n);s&&e.setMatrices("mBones",s)}}}function jk(n,e,t,i,s,r=!0){n._bindLight(e,t,i,s,r)}function Yk(n,e,t,i,s=4){const r=Math.min(e.lightSources.length,s);for(let a=0;a<r;a++){const o=e.lightSources[a];jk(o,a,n,t,typeof i=="boolean"?i:i.SPECULARTERM,e.receiveShadows)}}function Kk(n,e,t,i){t.NUM_BONE_INFLUENCERS>0&&(i.addCPUSkinningFallback(0,e),n.push("matricesIndices"),n.push("matricesWeights"),t.NUM_BONE_INFLUENCERS>4&&(n.push("matricesIndicesExtra"),n.push("matricesWeightsExtra")))}function qk(n,e){(e.INSTANCES||e.THIN_INSTANCES)&&Uf(n,!!e.PREPASS_VELOCITY),e.INSTANCESCOLOR&&n.push("instanceColor")}function Zk(n,e,t=4,i=0){let s=0;for(let r=0;r<t&&n["LIGHT"+r];r++)r>0&&(s=i+r,e.addFallback(s,"LIGHT"+r)),n.SHADOWS||(n["SHADOW"+r]&&e.addFallback(i,"SHADOW"+r),n["SHADOWPCF"+r]&&e.addFallback(i,"SHADOWPCF"+r),n["SHADOWPCSS"+r]&&e.addFallback(i,"SHADOWPCSS"+r),n["SHADOWPOISSON"+r]&&e.addFallback(i,"SHADOWPOISSON"+r),n["SHADOWESM"+r]&&e.addFallback(i,"SHADOWESM"+r),n["SHADOWCLOSEESM"+r]&&e.addFallback(i,"SHADOWCLOSEESM"+r));return s++}function $k(n,e){return e.fogEnabled&&n.applyFog&&e.fogMode!==0}function Qk(n,e,t,i,s,r,a,o=!1,c=!1,u,d){if(a._areMiscDirty){a.LOGARITHMICDEPTH=t,a.POINTSIZE=i,a.FOG=s&&$k(n,e),a.NONUNIFORMSCALING=n.nonUniformScaling,a.ALPHATEST=r,a.DECAL_AFTER_DETAIL=o,a.USE_VERTEX_PULLING=c;const f=u?.geometry?.getIndexBuffer();a.VERTEX_PULLING_USE_INDEX_BUFFER=!!f,a.VERTEX_PULLING_INDEX_BUFFER_32BITS=f?f.is32Bits:!1,a.VERTEXOUTPUT_INVARIANT=!!d}}function Jk(n,e,t,i,s=4,r=!1){if(!t._areLightsDirty)return t._needNormals;let a=0;const o={needNormals:t._needNormals,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};if(n.lightsEnabled&&!r){for(const d of e.lightSources)if(t3(n,e,d,a,t,i,o),a++,a===s)break}t.SPECULARTERM=o.specularEnabled,t.SHADOWS=o.shadowEnabled;const c=Math.max(s,t.MAXLIGHTCOUNT||0);for(let d=a;d<c;d++)t["LIGHT"+d]!==void 0&&(t["LIGHT"+d]=!1,t["HEMILIGHT"+d]=!1,t["POINTLIGHT"+d]=!1,t["DIRLIGHT"+d]=!1,t["SPOTLIGHT"+d]=!1,t["AREALIGHT"+d]=!1,t["CLUSTLIGHT"+d]=!1,t["SHADOW"+d]=!1,t["SHADOWCSM"+d]=!1,t["SHADOWCSMDEBUG"+d]=!1,t["SHADOWCSMNUM_CASCADES"+d]=!1,t["SHADOWCSMUSESHADOWMAXZ"+d]=!1,t["SHADOWCSMNOBLEND"+d]=!1,t["SHADOWCSM_RIGHTHANDED"+d]=!1,t["SHADOWPCF"+d]=!1,t["SHADOWPCSS"+d]=!1,t["SHADOWPOISSON"+d]=!1,t["SHADOWESM"+d]=!1,t["SHADOWCLOSEESM"+d]=!1,t["SHADOWCUBE"+d]=!1,t["SHADOWLOWQUALITY"+d]=!1,t["SHADOWMEDIUMQUALITY"+d]=!1);t.MAXLIGHTCOUNT=s;const u=n.getEngine().getCaps();return t.SHADOWFLOAT===void 0&&(o.needRebuild=!0),t.SHADOWFLOAT=o.shadowEnabled&&(u.textureFloatRender&&u.textureFloatLinearFiltering||u.textureHalfFloatRender&&u.textureHalfFloatLinearFiltering),t.LIGHTMAPEXCLUDED=o.lightmapMode,o.needRebuild&&t.rebuild(),o.needNormals}function e3(n,e,t,i=!1,s=8,r=!1){if(e&&at.ReflectionTextureEnabled){if(!e.isReadyOrNotBlocking())return!1;t._needNormals=!0,t.REFLECTION=!0,t.GAMMAREFLECTION=e.gammaSpace,t.RGBDREFLECTION=e.isRGBD,t.LODINREFLECTIONALPHA=e.lodLevelInAlpha,t.LINEARSPECULARREFLECTION=e.linearSpecularLOD,t.USEIRRADIANCEMAP=!1;const a=n.getEngine();switch(i&&s>0?(t.NUM_SAMPLES=""+s,a._features.needTypeSuffixInShaderConstants&&(t.NUM_SAMPLES=t.NUM_SAMPLES+"u"),t.REALTIME_FILTERING=!0,n.iblCdfGenerator&&(t.IBL_CDF_FILTERING=!0)):t.REALTIME_FILTERING=!1,t.INVERTCUBICMAP=e.coordinatesMode===Te.INVCUBIC_MODE,t.REFLECTIONMAP_3D=e.isCube,t.REFLECTIONMAP_OPPOSITEZ=t.REFLECTIONMAP_3D&&n.useRightHandedSystem?!e.invertZ:e.invertZ,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,e.coordinatesMode){case Te.EXPLICIT_MODE:t.REFLECTIONMAP_EXPLICIT=!0;break;case Te.PLANAR_MODE:t.REFLECTIONMAP_PLANAR=!0;break;case Te.PROJECTION_MODE:t.REFLECTIONMAP_PROJECTION=!0;break;case Te.SKYBOX_MODE:t.REFLECTIONMAP_SKYBOX=!0;break;case Te.SPHERICAL_MODE:t.REFLECTIONMAP_SPHERICAL=!0;break;case Te.EQUIRECTANGULAR_MODE:t.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Te.FIXED_EQUIRECTANGULAR_MODE:t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Te.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Te.CUBIC_MODE:case Te.INVCUBIC_MODE:default:t.REFLECTIONMAP_CUBIC=!0,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!!e.boundingBoxSize;break}e.coordinatesMode!==Te.SKYBOX_MODE&&(e.irradianceTexture?(t.USEIRRADIANCEMAP=!0,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USESPHERICALINVERTEX=!1,e.irradianceTexture._dominantDirection&&(t.USE_IRRADIANCE_DOMINANT_DIRECTION=!0)):e.isCube&&(t.USESPHERICALFROMREFLECTIONMAP=!0,t.USEIRRADIANCEMAP=!1,t.USE_IRRADIANCE_DOMINANT_DIRECTION=!1,t.USESPHERICALINVERTEX=r))}else t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USEIRRADIANCEMAP=!1,t.USE_IRRADIANCE_DOMINANT_DIRECTION=!1,t.USESPHERICALINVERTEX=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.RGBDRE
vendor: 4,413 bytes, line 231
231FLECTION=!1,t.LINEARSPECULARREFLECTION=!1;return!0}function t3(n,e,t,i,s,r,a){switch(a.needNormals=!0,s["LIGHT"+i]===void 0&&(a.needRebuild=!0),s["LIGHT"+i]=!0,s["SPOTLIGHT"+i]=!1,s["HEMILIGHT"+i]=!1,s["POINTLIGHT"+i]=!1,s["DIRLIGHT"+i]=!1,s["AREALIGHT"+i]=!1,s["CLUSTLIGHT"+i]=!1,t.prepareLightSpecificDefines(s,i),s["LIGHT_FALLOFF_PHYSICAL"+i]=!1,s["LIGHT_FALLOFF_GLTF"+i]=!1,s["LIGHT_FALLOFF_STANDARD"+i]=!1,t.falloffType){case xt.FALLOFF_GLTF:s["LIGHT_FALLOFF_GLTF"+i]=!0;break;case xt.FALLOFF_PHYSICAL:s["LIGHT_FALLOFF_PHYSICAL"+i]=!0;break;case xt.FALLOFF_STANDARD:s["LIGHT_FALLOFF_STANDARD"+i]=!0;break}if(t.specular.equalsFloats(0,0,0)||(a.specularEnabled=!0),s["SHADOW"+i]=!1,s["SHADOWCSM"+i]=!1,s["SHADOWCSMDEBUG"+i]=!1,s["SHADOWCSMNUM_CASCADES"+i]=!1,s["SHADOWCSMUSESHADOWMAXZ"+i]=!1,s["SHADOWCSMNOBLEND"+i]=!1,s["SHADOWCSM_RIGHTHANDED"+i]=!1,s["SHADOWPCF"+i]=!1,s["SHADOWPCSS"+i]=!1,s["SHADOWPOISSON"+i]=!1,s["SHADOWESM"+i]=!1,s["SHADOWCLOSEESM"+i]=!1,s["SHADOWCUBE"+i]=!1,s["SHADOWLOWQUALITY"+i]=!1,s["SHADOWMEDIUMQUALITY"+i]=!1,e&&e.receiveShadows&&n.shadowsEnabled&&t.shadowEnabled){const o=t.getShadowGenerator(n.activeCamera)??t.getShadowGenerator();if(o){const c=o.getShadowMap();c&&c.renderList&&c.renderList.length>0&&(a.shadowEnabled=!0,o.prepareDefines(s,i))}}t.lightmapMode!=xt.LIGHTMAP_DEFAULT?(a.lightmapMode=!0,s["LIGHTMAPEXCLUDED"+i]=!0,s["LIGHTMAPNOSPECULAR"+i]=t.lightmapMode==xt.LIGHTMAP_SHADOWSONLY):(s["LIGHTMAPEXCLUDED"+i]=!1,s["LIGHTMAPNOSPECULAR"+i]=!1)}function i3(n,e,t,i,s,r=null,a=!1){let o=NC(n,i);r!==!1&&(o=zk(t,n,i)),i.DEPTHPREPASS!==!e.getColorWrite()&&(i.DEPTHPREPASS=!i.DEPTHPREPASS,o=!0),i.INSTANCES!==s&&(i.INSTANCES=s,o=!0),i.THIN_INSTANCES!==a&&(i.THIN_INSTANCES=a,o=!0),o&&i.markAsUnprocessed()}function s3(n,e){if(n.useBones&&n.computeBonesUsingShaders&&n.skeleton){e.NUM_BONE_INFLUENCERS=n.numBoneInfluencers;const t=e.BONETEXTURE!==void 0;if(n.skeleton.isUsingTextureForMatrices&&t)e.BONETEXTURE=!0;else{e.BonesPerMesh=n.skeleton.bones.length+1,e.BONETEXTURE=t?!1:void 0;const i=n.getScene().prePassRenderer;if(i&&i.enabled){const s=i.excludedSkinnedMesh.indexOf(n)===-1;e.BONES_VELOCITY_ENABLED=s}}}else e.NUM_BONE_INFLUENCERS=0,e.BonesPerMesh=0,e.BONETEXTURE!==void 0&&(e.BONETEXTURE=!1)}function r3(n,e){const t=n.morphTargetManager;t?(e.MORPHTARGETS_UV=t.supportsUVs&&e.UV1,e.MORPHTARGETS_UV2=t.supportsUV2s&&e.UV2,e.MORPHTARGETS_TANGENT=t.supportsTangents&&e.TANGENT,e.MORPHTARGETS_NORMAL=t.supportsNormals&&e.NORMAL,e.MORPHTARGETS_POSITION=t.supportsPositions,e.MORPHTARGETS_COLOR=t.supportsColors,e.MORPHTARGETTEXTURE_HASUVS=t.hasUVs,e.MORPHTARGETTEXTURE_HASUV2S=t.hasUV2s,e.MORPHTARGETTEXTURE_HASTANGENTS=t.hasTangents,e.MORPHTARGETTEXTURE_HASNORMALS=t.hasNormals,e.MORPHTARGETTEXTURE_HASPOSITIONS=t.hasPositions,e.MORPHTARGETTEXTURE_HASCOLORS=t.hasColors,e.NUM_MORPH_INFLUENCERS=t.numMaxInfluencers||t.numInfluencers,e.MORPHTARGETS=e.NUM_MORPH_INFLUENCERS>0,e.MORPHTARGETS_TEXTURE=t.isUsingTextureForTargets):(e.MORPHTARGETS_UV=!1,e.MORPHTARGETS_UV2=!1,e.MORPHTARGETS_TANGENT=!1,e.MORPHTARGETS_NORMAL=!1,e.MORPHTARGETS_POSITION=!1,e.MORPHTARGETS_COLOR=!1,e.MORPHTARGETTEXTURE_HASUVS=!1,e.MORPHTARGETTEXTURE_HASUV2S=!1,e.MORPHTARGETTEXTURE_HASTANGENTS=!1,e.MORPHTARGETTEXTURE_HASNORMALS=!1,e.MORPHTARGETTEXTURE_HASPOSITIONS=!1,e.MORPHTARGETTEXTURE_HAS_COLORS=!1,e.MORPHTARGETS=!1,e.NUM_MORPH_INFLUENCERS=0)}function n3(n,e){const t=n.bakedVertexAnimationManager;e.BAKED_VERTEX_ANIMATION_TEXTURE=!!(t&&t.isEnabled)}function a3(n,e,t,i,s=!1,r=!0,a=!0){if(!e._areAttributesDirty&&e._needNormals===e._normals&&e._needUVs===e._uvs)return!1;e._normals=e._needNormals,e._uvs=e._needUVs,e.NORMAL=e._needNormals&&n.isVerticesDataPresent("normal"),e._needNormals&&n.isVerticesDataPresent("tangent")&&(e.TANGENT=!0);for(let o=1;o<=6;++o)e["UV"+o]=e._needUVs?n.isVerticesDataPresent(`uv${o===1?"":o}`):!1;{const o=n.useVertexColors&&n.isVerticesDataPresent("color");e.VERTEXCOLOR=o,e.VERTEXALPHA=n.hasVertexAlpha&&o&&r}return n.isVerticesDataPresent("instanceColor")&&(n.hasInstances||n.hasThinInstances)&&(e.INSTANCESCOLOR=!0),s3(n,e),s&&r3(n,e),a&&n3(n,e),!0}function o3(n,e){if(n.activeCamera){const t=e.MULTIVIEW;e.MULTIVIEW=n.activeCamera.outputRenderTarget!==null&&n.activeCamera.outputRenderTarget.getViewCount()>1,e.MULTIVIEW!=t&&e.markAsUnprocessed()}}function l3(n,e,t){const i=e.ORDER_INDEPENDENT_TRANSPARENCY,s=e.ORDER_INDEPENDENT_TRANSPARENCY_16BITS;
231e.ORDER_INDEPENDENT_TRANSPARENCY=n.useOrderIndependentTransparency&&t,e.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!n.getEngine().getCaps().textureFloatLinearFiltering,(i!==e.ORDER_INDEPENDENT_TRANSPARENCY||s!==e.ORDER_INDEPENDENT_TRANSPARENCY_16BITS)&&e.markAsUnprocessed()}function LC(n,e,t){const i=e.PREPASS;if(!e._arePrePassDirty)return;const s=[{type:1,define:"PREPASS_POSITION",index:"PREPASS_POSITION_INDEX"},{type:9,define:"PREPASS_LOCAL_POSITION",index:"PREPASS_LOCAL_POSITION_INDEX"},{type:2,define:"PREPASS_VELOCITY",index:"PREPASS_VELOCITY_INDEX"},{type:11,define:"PREPASS_VELOCITY_LINEAR",index:"PREPASS_VELOCITY_LINEAR_INDEX"},{type:3,define:"PREPASS_REFLECTIVITY",index:"PREPASS_REFLECTIVITY_INDEX"},{type:0,define:"PREPASS_IRRADIANCE",index:"PREPASS_IRRADIANCE_INDEX"},{type:7,define:"PREPASS_ALBEDO_SQRT",index:"PREPASS_ALBEDO_SQRT_INDEX"},{type:5,define:"PREPASS_DEPTH",index:"PREPASS_DEPTH_INDEX"},{type:10,define:"PREPASS_SCREENSPACE_DEPTH",index:"PREPASS_SCREENSPACE_DEPTH_INDEX"},{type:6,define:"PREPASS_NORMAL",index:"PREPASS_NORMAL_INDEX"},{type:8,define:"PREPASS_WORLD_NORMAL",index:"PREPASS_WORLD_NORMAL_INDEX"}];if(n.prePassRenderer&&n.prePassRenderer.enabled&&t){e.PREPASS=!0,e.SCENE_MRT_COUNT=n.prePassRenderer.mrtCount,e.PREPASS_NORMAL_WORLDSPACE=n.prePassRenderer.generateNormalsInWorldSpace,e.PREPASS_COLOR=!0,e.PREPASS_COLOR_INDEX=0;for(let r=0;r<s.length;r++){const a=n.prePassRenderer.getIndex(s[r].type);a!==-1?(e[s[r].define]=!0,e[s[r].index]=a):e[s[r].define]=!1}}else{e.PREPASS=!1;for(let r=0;r<s.length;r++)e[s[r].define]=!1}e.PREPASS!=i&&(e.markAsUnprocessed(),e.markAsImageProcessingDirty())}function NC(n,e){let t=!1;if(n.activeCamera){const i=e.CAMERA_ORTHOGRAPHIC?1:0,s=e.CAMERA_PERSPECTIVE?1:0,r=n.activeCamera.mode===1?1:0,a=n.activeCamera.mode===0?1:0;(i^r||s^a)&&(e.CAMERA_ORTHOGRAPHIC=r===1,e.CAMERA_PERSPECTIVE=a===1,t=!0)}return t}function c3(n,e,t,i,s=null,r=!1,a=!1,o=!1){s&&s.push("Light"+n),!r&&(e.push("vLightData"+n,"vLightDiffuse"+n,"vLightSpecular"+n,"vLightDirection"+n,"vLightWidth"+n,"vLightHeight"+n,"vLightFalloff"+n,"vLightGround"+n,"vSliceData"+n,"vSliceRanges"+n,"lightMatrix"+n,"shadowsInfo"+n,"depthValues"+n),t.push("shadowTexture"+n),t.push("depthTexture"+n),e.push("viewFrustumZ"+n,"cascadeBlendFactor"+n,"lightSizeUVCorrection"+n,"depthCorrection"+n,"penumbraDarkness"+n,"frustumLengths"+n),i&&(t.push("projectionLightTexture"+n),e.push("textureProjectionMatrix"+n)),a&&t.push("iesLightTexture"+n),o&&(t.push("lightDataTexture"+n),t.push("tileMaskTexture"+n)))}function h3(n,e,t){const i=["vReflectionMicrosurfaceInfos","vReflectionDominantDirection","reflectionMatrix","vReflectionInfos","vReflectionPosition","vReflectionSize","vReflectionColor","vReflectionFilteringInfo"];n.push(...i);const s=["reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","irradianceSampler","icdfSampler"];e.push(...s)}function u3(n,e,t,i=4){let s,r;if(n.uniformsNames){const a=n;s=a.uniformsNames,r=a.uniformBuffersNames,e=a.samplers,t=a.defines,i=a.maxSimultaneousLights||0}else s=n,e||(e=[]);for(let a=0;a<i&&t["LIGHT"+a];a++)c3(a,s,e,t["PROJECTEDLIGHTTEXTURE"+a],r,!1,t["IESLIGHTTEXTURE"+a],t["CLUSTLIGHT"+a]);t.NUM_MORPH_INFLUENCERS&&(s.push("morphTargetInfluences"),s.push("morphTargetCount")),t.BAKED_VERTEX_ANIMATION_TEXTURE&&(s.push("bakedVertexAnimationSettings"),s.push("bakedVertexAnimationTextureSizeInverted"),s.push("bakedVertexAnimationTime"),e.push("bakedVertexAnimationTexture"))}function d3(n,e=!1,t=!1,i=!1,s=!1,r=!1){n.addUniform("vReflectionInfos",2),n.addUniform("reflectionMatrix",16),e&&n.addUniform("vReflectionMicrosurfaceInfos",3),t&&(n.addUniform("vReflectionPosition",3),n.addUniform("vReflectionSize",3)),i&&(n.addUniform("vReflectionFilteringInfo",2),n.addUniform("vReflectionDominantDirection",3)),r&&n.addUniform("vReflectionColor",3),s&&(n.addUniform("vSphericalL00",3),n.addUniform("vSphericalL1_1",3),n.addUniform("vSphericalL10",3),n.addUniform("vSphericalL11",3),n.addUniform("vSphericalL2_2",3),n.addUniform("vSphericalL2_1",3),n.addUniform("vSphericalL20",3),n.addUniform("vSphericalL21",3),n.addUniform("vSphericalL22",3),n.addUniform("vSphericalX",3),n.addUniform("vSphericalY",3),n.addUniform("vSphericalZ",3),n.addUniform("vSphericalXX_ZZ",3),n.addUniform("vSphericalYY_ZZ",3),n.addUniform("vSphericalZZ",3),n.addUniform("vSphericalXY",3),n.addUniform("vSphericalYZ",3),n.addUniform("vSphericalZX",3))}class fe{get useVertexPulling(){return this._useVertexPulling}set useVertexPulling(e){this._useVertexPulling!==e&&(this._useVertexPulling=e,this.markAsDirty(fe.MiscDirtyFlag))}get _supportGlowLayer(){return!1}set _glowModeEnabled(e){}get shaderLanguage(){return this._shaderLanguage}get canRenderToMRT(){return!1}set alpha(e){if(this._alpha===e)return;const t=this._alpha;this._alpha=e,(t===1||e===1)&&this.markAsDirty(fe.MiscDirtyFlag+fe.PrePassDirtyFlag)}get alpha(){return this._alpha}set backFaceCulling(e){this._backFaceCulling!==e&&(this._backFaceCulling=e,this.markAsDirty(fe.TextureDirtyFlag))}
vendor: 4,783 bytes, line 231
231get backFaceCulling(){return this._backFaceCulling}set cullBackFaces(e){this._cullBackFaces!==e&&(this._cullBackFaces=e,this.markAsDirty(fe.TextureDirtyFlag))}get cullBackFaces(){return this._cullBackFaces}get blockDirtyMechanism(){return this._blockDirtyMechanism}set blockDirtyMechanism(e){this._blockDirtyMechanism!==e&&(this._blockDirtyMechanism=e,e||this.markDirty())}atomicMaterialsUpdate(e){this.blockDirtyMechanism=!0;try{e(this)}finally{this.blockDirtyMechanism=!1}}get hasRenderTargetTextures(){return this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._eventInfo.hasRenderTargetTextures}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}get onBindObservable(){return this._onBindObservable||(this._onBindObservable=new le),this._onBindObservable}set onBind(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)}get onUnBindObservable(){return this._onUnBindObservable||(this._onUnBindObservable=new le),this._onUnBindObservable}get onEffectCreatedObservable(){return this._onEffectCreatedObservable||(this._onEffectCreatedObservable=new le),this._onEffectCreatedObservable}set alphaMode(e){this._alphaMode[0]!==e&&(this._alphaMode[0]=e,this.markAsDirty(fe.TextureDirtyFlag))}get alphaMode(){return this._alphaMode[0]}get alphaModes(){return this._alphaMode}setAlphaMode(e,t=0){this._alphaMode[t]!==e&&(this._alphaMode[t]=e,this.markAsDirty(fe.TextureDirtyFlag))}set needDepthPrePass(e){this._needDepthPrePass!==e&&(this._needDepthPrePass=e,this._needDepthPrePass&&(this.checkReadyOnEveryCall=!0))}get needDepthPrePass(){return this._needDepthPrePass}get isPrePassCapable(){return!1}set fogEnabled(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAsDirty(fe.MiscDirtyFlag))}get fogEnabled(){return this._fogEnabled}get wireframe(){switch(this._fillMode){case fe.WireFrameFillMode:case fe.LineListDrawMode:case fe.LineLoopDrawMode:case fe.LineStripDrawMode:return!0}return this._scene.forceWireframe}set wireframe(e){this.fillMode=e?fe.WireFrameFillMode:fe.TriangleFillMode}get pointsCloud(){switch(this._fillMode){case fe.PointFillMode:case fe.PointListDrawMode:return!0}return this._scene.forcePointsCloud}set pointsCloud(e){this.fillMode=e?fe.PointFillMode:fe.TriangleFillMode}get fillMode(){return this._fillMode}set fillMode(e){this._fillMode!==e&&(this._fillMode=e,this.markAsDirty(fe.MiscDirtyFlag))}get useLogarithmicDepth(){return this._useLogarithmicDepth}set useLogarithmicDepth(e){const t=this.getScene().getEngine().getCaps().fragmentDepthSupported;e&&!t&&oe.Warn("Logarithmic depth has been requested for a material on a device that doesn't support it."),this._useLogarithmicDepth=e&&t,this._markAllSubMeshesAsMiscDirty()}get isVertexOutputInvariant(){return this._isVertexOutputInvariant}set isVertexOutputInvariant(e){this._isVertexOutputInvariant!==e&&(this._isVertexOutputInvariant=e,this._markAllSubMeshesAsMiscDirty())}_getDrawWrapper(){return this._drawWrapper}_setDrawWrapper(e){this._drawWrapper=e}constructor(e,t,i,s=!1){this.shadowDepthWrapper=null,this.allowShaderHotSwapping=!0,this._shaderLanguage=0,this._forceGLSL=!1,this._useVertexPulling=!1,this.metadata=null,this.reservedDataStore=null,this.checkReadyOnEveryCall=!1,this.checkReadyOnlyOnce=!1,this.state="",this._alpha=1,this._backFaceCulling=!0,this._cullBackFaces=!0,this._blockDirtyMechanism=!1,this.sideOrientation=null,this.onCompiled=null,this.onError=null,this.getRenderTargetTextures=null,this.doNotSerialize=!1,this._storeEffectOnSubMeshes=!1,this.animations=null,this.onDisposeObservable=new le,this._onDisposeObserver=null,this._onUnBindObservable=null,this._onBindObserver=null,this._alphaMode=[2],this._needDepthPrePass=!1,this.disableDepthWrite=!1,this.disableColorWrite=!1,this.forceDepthWrite=!1,this.depthFunction=0,this.separateCullingPass=!1,this._fogEnabled=!0,this.pointSize=1,this.zOffset=0,this.zOffsetUnits=0,this.stencil=new cr,this._isVertexOutputInvariant=fe.ForceVertexOutputInvariant,this._useUBO=!1,this._fillMode=fe.TriangleFillMode,this._cachedDepthWriteState=!1,this._cachedColorWriteState=!1,this._cachedDepthFunctionState=0,this._indexInSceneMaterialArray=-1,this.meshMap=null,this._parentContainer=null,this._uniformBufferLayoutBuilt=!1,this._eventInfo={},this._callbackPluginEventGeneric=()=>{},this._callbackPluginEventIsReadyForSubMesh=()=>{},this._callbackPluginEventPrepareDefines=()=>{},this._callbackPluginEventPrepareDefinesBeforeAttributes=()=>{},this._callbackPluginEventHardBindForSubMesh=()=>{},this._callbackPluginEventBindForSubMesh=()=>{},this._callbackPluginEventHasRenderTargetTextures=()=>{}
vendor: 44,628 bytes, line 231
231,this._callbackPluginEventFillRenderTargetTextures=()=>{},this._transparencyMode=null,this.name=e;const r=t||Ke.LastCreatedScene;r&&(this._scene=r,this._dirtyCallbacks={},this._forceGLSL=s,this._dirtyCallbacks[1]=this._markAllSubMeshesAsTexturesDirty.bind(this),this._dirtyCallbacks[2]=this._markAllSubMeshesAsLightsDirty.bind(this),this._dirtyCallbacks[4]=this._markAllSubMeshesAsFresnelDirty.bind(this),this._dirtyCallbacks[8]=this._markAllSubMeshesAsAttributesDirty.bind(this),this._dirtyCallbacks[16]=this._markAllSubMeshesAsMiscDirty.bind(this),this._dirtyCallbacks[32]=this._markAllSubMeshesAsPrePassDirty.bind(this),this._dirtyCallbacks[127]=this._markAllSubMeshesAsAllDirty.bind(this),this.id=e||pe.RandomId(),this.uniqueId=this._scene.getUniqueId(),this._materialContext=this._scene.getEngine().createMaterialContext(),this._drawWrapper=new Qh(this._scene.getEngine(),!1),this._drawWrapper.materialContext=this._materialContext,this._uniformBuffer=new Fe(this._scene.getEngine(),void 0,void 0,e),this._useUBO=this.getScene().getEngine().supportsUniformBuffers,this._createUniformBuffer(),i||this._scene.addMaterial(this),this._scene.useMaterialMeshMap&&(this.meshMap={}),fe.OnEventObservable.notifyObservers(this,1))}_createUniformBuffer(){const e=this.getScene().getEngine();this._uniformBuffer?.dispose(),e.isWebGPU&&!this._forceGLSL?(this._uniformBuffer=new Fe(e,void 0,void 0,this.name,!0),this._shaderLanguage=1):this._uniformBuffer=new Fe(this._scene.getEngine(),void 0,void 0,this.name),this._uniformBufferLayoutBuilt=!1}toString(e){return"Name: "+this.name}getClassName(){return"Material"}get _isMaterial(){return!0}get isFrozen(){return this.checkReadyOnlyOnce}freeze(){this.markDirty(),this.checkReadyOnlyOnce=!0}unfreeze(){this.markDirty(),this.checkReadyOnlyOnce=!1}isReady(e,t){return!0}isReadyForSubMesh(e,t,i){const s=t.materialDefines;return s?(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=s,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),this._eventInfo.isReadyForSubMesh):!1}getEffect(){return this._drawWrapper.effect}getScene(){return this._scene}_getEffectiveOrientation(e){return this.sideOrientation!==null?this.sideOrientation:e.sideOrientation}get transparencyMode(){return this._transparencyMode}set transparencyMode(e){this._transparencyMode!==e&&(this._transparencyMode=e,this._markAllSubMeshesAsTexturesAndMiscDirty())}get _hasTransparencyMode(){return this._transparencyMode!=null}get _transparencyModeIsBlend(){return this._transparencyMode===fe.MATERIAL_ALPHABLEND||this._transparencyMode===fe.MATERIAL_ALPHATESTANDBLEND}get _transparencyModeIsTest(){return this._transparencyMode===fe.MATERIAL_ALPHATEST||this._transparencyMode===fe.MATERIAL_ALPHATESTANDBLEND}get _disableAlphaBlending(){return this._transparencyMode===fe.MATERIAL_OPAQUE||this._transparencyMode===fe.MATERIAL_ALPHATEST}needAlphaBlending(){return this._hasTransparencyMode?this._transparencyModeIsBlend:this._disableAlphaBlending?!1:this.alpha<1}needAlphaBlendingForMesh(e){return this._hasTransparencyMode?this._transparencyModeIsBlend:e.visibility<1?!0:this._disableAlphaBlending?!1:e.hasVertexAlpha||this.needAlphaBlending()}needAlphaTesting(){return this._hasTransparencyMode?this._transparencyModeIsTest:!1}needAlphaTestingForMesh(e){return this._hasTransparencyMode?this._transparencyModeIsTest:!this.needAlphaBlendingForMesh(e)&&this.needAlphaTesting()}getAlphaTestTexture(){return null}markDirty(e=!1){const t=this.getScene().meshes;for(const i of t)if(i.subMeshes){for(const s of i.subMeshes)if(s.getMaterial()===this)for(const r of s._drawWrappers)r&&this._materialContext===r.materialContext&&(r._wasPreviouslyReady=!1,r._wasPreviouslyUsingInstances=null,r._forceRebindOnNextCall=e)}e&&this.markAsDirty(fe.AllDirtyFlag)}_preBind(e,t=null){const i=this._scene.getEngine(),r=(t??this.sideOrientation)===fe.ClockWiseSideOrientation,a=e||this._getDrawWrapper();return eC(a)&&a.materialContext&&(a.materialContext.useVertexPulling=this.useVertexPulling),i.enableEffect(a),i.setState(this.backFaceCulling,this.zOffset,!1,r,this._scene._mirroredCameraPosition?!this.cullBackFaces:this.cullBackFaces,this.stencil,this.zOffsetUnits),r}bind(e,t){}buildUniformLayout(){const e=this._uniformBuffer;this._eventInfo.ubo=e,this._callbackPluginEventGeneric(8,this._eventInfo),e.create(),this._uniformBufferLayoutBuilt=!0}bindForSubMesh(e,t,i){const s=i._drawWrapper;this._eventInfo.subMesh=i,this._callbackPluginEventBindForSubMesh(this._eventInfo),s._forceRebindOnNextCall=!1}bindOnlyWorldMatrix(e){}bindView(e){this._useUBO?this._needToBindSceneUbo=!0:e.setMatrix("view",this.getScene().getViewMatrix())}bindViewProjection(e){this._useUBO?this._needToBindSceneUbo=!0:(e.setMatrix("viewProjection",this.getScene().getTransformMatrix()),e.setMatrix("projection",this.getScene().getProjectionMatrix()))}bindEyePosition(e,t){this._useUBO?this._needToBindSceneUbo=!0:this._scene.bindEyePosition(e,t)}_afterBind(e,t=null,i){if(this._scene._cachedMaterial=this,this._needToBindSceneUbo&&t&&(this._needToBindSceneUbo=!1,Nb(t,this.getScene().getSceneUniformBuffer()),this._scene.finalizeSceneUbo()),e?this._scene._cachedVisibility=e.visibility:this._scene._cachedVisibility=1,this._onBindObservable&&e&&this._onBindObservable.notifyObservers(e),this.disableDepthWrite){const s=this._scene.getEngine();this._cachedDepthWriteState=s.getDepthWrite(),s.setDepthWrite(!1)}if(this.disableColorWrite){const s=this._scene.getEngine();this._cachedColorWriteState=s.getColorWrite(),s.setColorWrite(!1)}if(this.depthFunction!==0){const s=this._scene.getEngine();this._cachedDepthFunctionState=s.getDepthFunction()||0,s.setDepthFunction(this.depthFunction)}}unbind(){this._scene.getSceneUniformBuffer().unbindEffect(),this._onUnBindObservable&&this._onUnBindObservable.notifyObservers(this),this.depthFunction!==0&&this._scene.getEngine().setDepthFunction(this._cachedDepthFunctionState),this.disableDepthWrite&&this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState),this.disableColorWrite&&this._scene.getEngine().setColorWrite(this._cachedColorWriteState)}getAnimatables(){return this._eventInfo.animatables=[],this._callbackPluginEventGeneric(256,this._eventInfo),this._eventInfo.animatables}getActiveTextures(){return this._eventInfo.activeTextures=[],this._callbackPluginEventGeneric(512,this._eventInfo),this._eventInfo.activeTextures}hasTexture(e){return this._eventInfo.hasTexture=!1,this._eventInfo.texture=e,this._callbackPluginEventGeneric(1024,this._eventInfo),this._eventInfo.hasTexture}clone(e){return null}_clonePlugins(e,t){const i={};if(this._serializePlugins(i),fe._ParsePlugins(i,e,this._scene,t),this.pluginManager)for(const s of this.pluginManager._plugins){const r=e.pluginManager.getPlugin(s.name);r&&s.copyTo(r)}}getBindedMeshes(){if(this.meshMap){const e=[];for(const t in this.meshMap){const i=this.meshMap[t];i&&e.push(i)}return e}else return this._scene.meshes.filter(t=>t.material===this)}forceCompilation(e,t,i,s){const r={clipPlane:!1,useInstances:!1,...i},a=this.getScene(),o=this.allowShaderHotSwapping;this.allowShaderHotSwapping=!1;const c=()=>{if(!this._scene||!this._scene.getEngine())return;const u=a.clipPlane;if(r.clipPlane&&(a.clipPlane=new Cr(0,0,0,1)),this._storeEffectOnSubMeshes){let d=!0,f=null;if(e.subMeshes){const g=new As(0,0,0,0,0,e,void 0,!1,!1);g.materialDefines&&(g.materialDefines._renderId=-1),this.isReadyForSubMesh(e,g,r.useInstances)||(g.effect&&g.effect.getCompilationError()&&g.effect.allFallbacksProcessed()?f=g.effect.getCompilationError():(d=!1,setTimeout(c,16)))}d&&(this.allowShaderHotSwapping=o,f&&s&&s(f),t&&t(this))}else this.isReady()?(this.allowShaderHotSwapping=o,t&&t(this)):setTimeout(c,16);r.clipPlane&&(a.clipPlane=u)};c()}async forceCompilationAsync(e,t){return await new Promise((i,s)=>{this.forceCompilation(e,()=>{i()},t,r=>{s(r)})})}markAsDirty(e){this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism||(fe._DirtyCallbackArray.length=0,e&fe.ImageProcessingDirtyFlag&&fe._DirtyCallbackArray.push(fe._ImageProcessingDirtyCallBack),e&fe.TextureDirtyFlag&&fe._DirtyCallbackArray.push(fe._TextureDirtyCallBack),e&fe.LightDirtyFlag&&fe._DirtyCallbackArray.push(fe._LightsDirtyCallBack),e&fe.FresnelDirtyFlag&&fe._DirtyCallbackArray.push(fe._FresnelDirtyCallBack),e&fe.AttributesDirtyFlag&&fe._DirtyCallbackArray.push(fe._AttributeDirtyCallBack),e&fe.MiscDirtyFlag&&fe._DirtyCallbackArray.push(fe._MiscDirtyCallBack),e&fe.PrePassDirtyFlag&&fe._DirtyCallbackArray.push(fe._PrePassDirtyCallBack),fe._DirtyCallbackArray.length&&this._markAllSubMeshesAsDirty(fe._RunDirtyCallBacks),this.getScene().resetCachedMaterial())}resetDrawCache(){const e=this.getScene().meshes;for(const t of e)if(t.subMeshes)for(const i of t.subMeshes)i.getMaterial()===this&&i.resetDrawCache()}_markAllSubMeshesAsDirty(e){const t=this.getScene();if(t.blockMaterialDirtyMechanism||this._blockDirtyMechanism)return;const i=t.meshes;for(const s of i)if(s.subMeshes){for(const r of s.subMeshes)if((r.getMaterial()||(t._hasDefaultMaterial?t.defaultMaterial:null))===this)for(const o of r._drawWrappers)!o||!o.defines||!o.defines.markAllAsDirty||this._materialContext===o.materialContext&&e(o.defines)}}_markScenePrePassDirty(){if(this.getScene().blockMaterialDirtyMechanism||this._blockDirtyMechanism)return;const e=this.getScene().enablePrePassRenderer();e&&e.markAsDirty()}_markAllSubMeshesAsAllDirty(){this._markAllSubMeshesAsDirty(fe._AllDirtyCallBack)}_markAllSubMeshesAsImageProcessingDirty(){this._markAllSubMeshesAsDirty(fe._ImageProcessingDirtyCallBack)}_markAllSubMeshesAsTexturesDirty(){this._markAllSubMeshesAsDirty(fe._TextureDirtyCallBack)}_markAllSubMeshesAsFresnelDirty(){this._markAllSubMeshesAsDirty(fe._FresnelDirtyCallBack)}_markAllSubMeshesAsFresnelAndMiscDirty(){this._markAllSubMeshesAsDirty(fe._FresnelAndMiscDirtyCallBack)}_markAllSubMeshesAsLightsDirty(){this._markAllSubMeshesAsDirty(fe._LightsDirtyCallBack)}_markAllSubMeshesAsAttributesDirty(){this._markAllSubMeshesAsDirty(fe._AttributeDirtyCallBack)}_markAllSubMeshesAsMiscDirty(){this._markAllSubMeshesAsDirty(fe._MiscDirtyCallBack)}_markAllSubMeshesAsPrePassDirty(){this._markAllSubMeshesAsDirty(fe._PrePassDirtyCallBack)}_markAllSubMeshesAsTexturesAndMiscDirty(){this._markAllSubMeshesAsDirty(fe._TextureAndMiscDirtyCallBack)}_checkScenePerformancePriority(){if(this._scene.performancePriority!==0){this.checkReadyOnlyOnce=!0;const e=this._scene.onScenePerformancePriorityChangedObservable.addOnce(()=>{this.checkReadyOnlyOnce=!1});this.onDisposeObservable.add(()=>{this._scene.onScenePerformancePriorityChangedObservable.remove(e)})}}setPrePassRenderer(e){return!1}dispose(e,t,i){const s=this.getScene();if(s.stopAnimation(this),s.freeProcessedMaterials(),s.removeMaterial(this),this._eventInfo.forceDisposeTextures=t,this._callbackPluginEventGeneric(2,this._eventInfo),this._parentContainer){const r=this._parentContainer.materials.indexOf(this);r>-1&&this._parentContainer.materials.splice(r,1),this._parentContainer=null}if(i!==!0)if(this.meshMap)for(const r in this.meshMap){const a=this.meshMap[r];this._disposeMeshResources(a)}else{const r=s.meshes;for(const a of r)this._disposeMeshResources(a)}this._uniformBuffer.dispose(),this._drawWrapper.effect&&(this._storeEffectOnSubMeshes||this._drawWrapper.effect.dispose(),this._drawWrapper.effect=null),this.metadata=null,this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this._onBindObservable&&this._onBindObservable.clear(),this._onUnBindObservable&&this._onUnBindObservable.clear(),this._onEffectCreatedObservable&&this._onEffectCreatedObservable.clear(),this._eventInfo&&(this._eventInfo={})}_disposeMeshResources(e){if(!e)return;const t=e.geometry,i=e._internalAbstractMeshDataInfo._materialForRenderPass;if(this._storeEffectOnSubMeshes){if(e.subMeshes&&i)for(const s of e.subMeshes){const r=s._drawWrappers;for(let a=0;a<r.length;a++){const o=r[a]?.effect;if(!o)continue;i[a]===this&&(t?._releaseVertexArrayObject(o),s._removeDrawWrapper(a,!0,!0))}}}else t?._releaseVertexArrayObject(this._drawWrapper.effect);e.material===this&&!e.sourceMesh&&(e.material=null)}serialize(){const e=$e.Serialize(this);return e.stencil=this.stencil.serialize(),e.uniqueId=this.uniqueId,this._serializePlugins(e),e}_serializePlugins(e){if(e.plugins={},this.pluginManager)for(const t of this.pluginManager._plugins)t.doNotSerialize||(e.plugins[t.getClassName()]=t.serialize())}static ParseAlphaMode(e,t){e._alphaMode!==void 0?t._alphaMode=Array.isArray(e._alphaMode)?e._alphaMode:[e._alphaMode]:e.alphaMode!==void 0?t._alphaMode=Array.isArray(e.alphaMode)?e.alphaMode:[e.alphaMode]:t._alphaMode=[2]}static Parse(e,t,i){if(!e.customType)e.customType="BABYLON.StandardMaterial";else if(e.customType==="BABYLON.PBRMaterial"&&e.overloadedAlbedo&&(e.customType="BABYLON.LegacyPBRMaterial",!BABYLON.LegacyPBRMaterial))return oe.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."),null;const r=pe.Instantiate(e.customType).Parse(e,t,i);return r._loadedUniqueId=e.uniqueId,fe.ParseAlphaMode(e,r),r}static _ParsePlugins(e,t,i,s){if(e.plugins)for(const r in e.plugins){const a=e.plugins[r];let o=t.pluginManager?.getPlugin(a.name);if(!o){const c=pe.Instantiate("BABYLON."+r);c&&(o=new c(t))}o?.parse(a,i,s)}}}fe.TriangleFillMode=0;fe.WireFrameFillMode=1;fe.PointFillMode=2;fe.PointListDrawMode=3;fe.LineListDrawMode=4;fe.LineLoopDrawMode=5;fe.LineStripDrawMode=6;fe.TriangleStripDrawMode=7;fe.TriangleFanDrawMode=8;fe.ClockWiseSideOrientation=0;fe.CounterClockWiseSideOrientation=1;fe.ImageProcessingDirtyFlag=64;fe.TextureDirtyFlag=1;fe.LightDirtyFlag=2;fe.FresnelDirtyFlag=4;fe.AttributesDirtyFlag=8;fe.MiscDirtyFlag=16;fe.PrePassDirtyFlag=32;fe.AllDirtyFlag=127;fe.MATERIAL_OPAQUE=0;fe.MATERIAL_ALPHATEST=1;fe.MATERIAL_ALPHABLEND=2;fe.MATERIAL_ALPHATESTANDBLEND=3;fe.MATERIAL_NORMALBLENDMETHOD_WHITEOUT=0;fe.MATERIAL_NORMALBLENDMETHOD_RNM=1;fe.LIGHTFALLOFF_PHYSICAL=0;fe.LIGHTFALLOFF_GLTF=1;fe.LIGHTFALLOFF_STANDARD=2;fe.OnEventObservable=new le;fe.ForceVertexOutputInvariant=!1;fe._AllDirtyCallBack=n=>n.markAllAsDirty();fe._ImageProcessingDirtyCallBack=n=>n.markAsImageProcessingDirty();fe._TextureDirtyCallBack=n=>n.markAsTexturesDirty();fe._FresnelDirtyCallBack=n=>n.markAsFresnelDirty();fe._MiscDirtyCallBack=n=>n.markAsMiscDirty();fe._PrePassDirtyCallBack=n=>n.markAsPrePassDirty();fe._LightsDirtyCallBack=n=>n.markAsLightDirty();fe._AttributeDirtyCallBack=n=>n.markAsAttributesDirty();fe._FresnelAndMiscDirtyCallBack=n=>{fe._FresnelDirtyCallBack(n),fe._MiscDirtyCallBack(n)};fe._TextureAndMiscDirtyCallBack=n=>{fe._TextureDirtyCallBack(n),fe._MiscDirtyCallBack(n)};fe._DirtyCallbackArray=[];fe._RunDirtyCallBacks=n=>{for(const e of fe._DirtyCallbackArray)e(n)};N([H()],fe.prototype,"id",void 0);N([H()],fe.prototype,"uniqueId",void 0);N([H()],fe.prototype,"name",void 0);N([H()],fe.prototype,"metadata",void 0);N([H()],fe.prototype,"checkReadyOnEveryCall",void 0);N([H()],fe.prototype,"checkReadyOnlyOnce",void 0);N([H()],fe.prototype,"state",void 0);N([H("alpha")],fe.prototype,"_alpha",void 0);N([H("backFaceCulling")],fe.prototype,"_backFaceCulling",void 0);N([H("cullBackFaces")],fe.prototype,"_cullBackFaces",void 0);N([H()],fe.prototype,"sideOrientation",void 0);N([H()],fe.prototype,"_alphaMode",void 0);N([H()],fe.prototype,"_needDepthPrePass",void 0);N([H()],fe.prototype,"disableDepthWrite",void 0);N([H()],fe.prototype,"disableColorWrite",void 0);N([H()],fe.prototype,"forceDepthWrite",void 0);N([H()],fe.prototype,"depthFunction",void 0);N([H()],fe.prototype,"separateCullingPass",void 0);N([H("fogEnabled")],fe.prototype,"_fogEnabled",void 0);N([H()],fe.prototype,"pointSize",void 0);N([H()],fe.prototype,"zOffset",void 0);N([H()],fe.prototype,"zOffsetUnits",void 0);N([H()],fe.prototype,"pointsCloud",null);N([H()],fe.prototype,"fillMode",null);N([H()],fe.prototype,"useLogarithmicDepth",null);N([H()],fe.prototype,"_isVertexOutputInvariant",void 0);N([H()],fe.prototype,"transparencyMode",null);class oc extends fe{get subMaterials(){return this._subMaterials}set subMaterials(e){this._subMaterials=e,this._hookArray(e)}getChildren(){return this.subMaterials}constructor(e,t){super(e,t,!0),this._waitingSubMaterialsUniqueIds=[],this.getScene().addMultiMaterial(this),this.subMaterials=[],this._storeEffectOnSubMeshes=!0}_hookArray(e){const t=e.push;e.push=(...s)=>{const r=t.apply(e,s);return this._markAllSubMeshesAsTexturesDirty(),r};const i=e.splice;e.splice=(s,r)=>{const a=i.apply(e,[s,r]);return this._markAllSubMeshesAsTexturesDirty(),a}}getSubMaterial(e){return e<0||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]}getActiveTextures(){return super.getActiveTextures().concat(...this.subMaterials.map(e=>e?e.getActiveTextures():[]))}hasTexture(e){if(super.hasTexture(e))return!0;for(let t=0;t<this.subMaterials.length;t++)if(this.subMaterials[t]?.hasTexture(e))return!0;return!1}getClassName(){return"MultiMaterial"}isReadyForSubMesh(e,t,i){for(let s=0;s<this.subMaterials.length;s++){const r=this.subMaterials[s];if(r){if(r._storeEffectOnSubMeshes){if(!r.isReadyForSubMesh(e,t,i))return!1;continue}if(!r.isReady(e))return!1}}return!0}clone(e,t){const i=new oc(e,this.getScene());for(let s=0;s<this.subMaterials.length;s++){let r=null;const a=this.subMaterials[s];t&&a?r=a.clone(e+"-"+a.name):r=this.subMaterials[s],i.subMaterials.push(r)}return i}serialize(){const e={};e.name=this.name,e.id=this.id,e.uniqueId=this.uniqueId,vt&&(e.tags=vt.GetTags(this)),e.materialsUniqueIds=[],e.materials=[];for(let t=0;t<this.subMaterials.length;t++){const i=this.subMaterials[t];i?(e.materialsUniqueIds.push(i.uniqueId),e.materials.push(i.id)):(e.materialsUniqueIds.push(null),e.materials.push(null))}return e}dispose(e,t,i){const s=this.getScene();if(!s)return;if(i)for(let a=0;a<this.subMaterials.length;a++){const o=this.subMaterials[a];o&&o.dispose(e,t)}const r=s.multiMaterials.indexOf(this);r>=0&&s.multiMaterials.splice(r,1),super.dispose(e,t)}static ParseMultiMaterial(e,t){const i=new oc(e.name,t);if(i.id=e.id,i._loadedUniqueId=e.uniqueId,vt&&vt.AddTagsTo(i,e.tags),e.materialsUniqueIds)i._waitingSubMaterialsUniqueIds=e.materialsUniqueIds;else for(const s of e.materials)i.subMaterials.push(t.getLastMaterialById(s));return i}}Tt("BABYLON.MultiMaterial",oc);class Ye{}Ye.NAME_EFFECTLAYER="EffectLayer";Ye.NAME_LAYER="Layer";Ye.NAME_LENSFLARESYSTEM="LensFlareSystem";Ye.NAME_BOUNDINGBOXRENDERER="BoundingBoxRenderer";Ye.NAME_PARTICLESYSTEM="ParticleSystem";Ye.NAME_GAMEPAD="Gamepad";Ye.NAME_SIMPLIFICATIONQUEUE="SimplificationQueue";Ye.NAME_GEOMETRYBUFFERRENDERER="GeometryBufferRenderer";Ye.NAME_PREPASSRENDERER="PrePassRenderer";Ye.NAME_DEPTHRENDERER="DepthRenderer";Ye.NAME_DEPTHPEELINGRENDERER="DepthPeelingRenderer";Ye.NAME_POSTPROCESSRENDERPIPELINEMANAGER="PostProcessRenderPipelineManager";Ye.NAME_SPRITE="Sprite";Ye.NAME_SUBSURFACE="SubSurface";Ye.NAME_OUTLINERENDERER="Outline";Ye.NAME_PROCEDURALTEXTURE="ProceduralTexture";Ye.NAME_SHADOWGENERATOR="ShadowGenerator";Ye.NAME_OCTREE="Octree";Ye.NAME_PHYSICSENGINE="PhysicsEngine";Ye.NAME_AUDIO="Audio";Ye.NAME_FLUIDRENDERER="FluidRenderer";Ye.NAME_IBLCDFGENERATOR="iblCDFGenerator";Ye.NAME_CLUSTEREDLIGHTING="ClusteredLighting";Ye.STEP_ISREADYFORMESH_EFFECTLAYER=0;Ye.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER=0;Ye.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER=0;Ye.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER=0;Ye.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER=1;Ye.STEP_BEFORECAMERADRAW_PREPASS=0;Ye.STEP_BEFORECAMERADRAW_EFFECTLAYER=1;Ye.STEP_BEFORECAMERADRAW_LAYER=2;Ye.STEP_BEFORERENDERTARGETDRAW_PREPASS=0;Ye.STEP_BEFORERENDERTARGETDRAW_LAYER=1;Ye.STEP_BEFORERENDERINGMESH_PREPASS=0;Ye.STEP_BEFORERENDERINGMESH_OUTLINE=1;Ye.STEP_AFTERRENDERINGMESH_PREPASS=0;Ye.STEP_AFTERRENDERINGMESH_OUTLINE=1;Ye.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW=0;Ye.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER=1;Ye.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE=0;Ye.STEP_BEFORECLEAR_PROCEDURALTEXTURE=0;Ye.STEP_BEFORECLEAR_PREPASS=1;Ye.STEP_BEFORERENDERTARGETCLEAR_PREPASS=0;Ye.STEP_AFTERRENDERTARGETDRAW_PREPASS=0;Ye.STEP_AFTERRENDERTARGETDRAW_LAYER=1;Ye.STEP_AFTERCAMERADRAW_PREPASS=0;Ye.STEP_AFTERCAMERADRAW_EFFECTLAYER=1;Ye.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM=2;Ye.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW=3;Ye.STEP_AFTERCAMERADRAW_LAYER=4;Ye.STEP_AFTERCAMERADRAW_FLUIDRENDERER=5;Ye.STEP_AFTERCAMERAPOSTPROCESS_LAYER=0;Ye.STEP_AFTERRENDERTARGETPOSTPROCESS_LAYER=0;Ye.STEP_AFTERRENDER_AUDIO=0;Ye.STEP_GATHERRENDERTARGETS_DEPTHRENDERER=0;Ye.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER=1;Ye.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR=2;Ye.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER=3;Ye.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER=0;Ye.STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER=1;Ye.STEP_GATHERACTIVECAMERARENDERTARGETS_CLUSTEREDLIGHTING=2;Ye.STEP_POINTERMOVE_SPRITE=0;Ye.STEP_POINTERDOWN_SPRITE=0;Ye.STEP_POINTERUP_SPRITE=0;class ni extends Array{constructor(e){super(...e)}static Create(){return Object.create(ni.prototype)}registerStep(e,t,i){let s=0,r=Number.MAX_VALUE;for(;s<this.length&&(r=this[s].index,!(e<r));s++);this.splice(s,0,{index:e,component:t,action:i.bind(t)})}clear(){this.length=0}}class f3{constructor(e,t){this.distanceOrScreenCoverage=e,this.mesh=t}}class BC{}class p3{constructor(){this.batchCache=new vT(this),this.batchCacheReplacementModeInFrozenMode=new vT(this),this.instancesBufferSize=512*4}}class _3{constructor(){this.renderPasses={}}}class vT{constructor(e){this.parent=e,this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=[],this.hardwareInstancedRendering=[]}}class g3{constructor(){this.instancesCount=0,this.matrixBuffer=null,this.previousMatrixBuffer=null,this.matrixBufferSize=512,this.matrixData=null,this.boundingVectors=[],this.worldMatrices=null}}class m3{constructor(){this._areNormalsFrozen=!1,this._source=null,this.meshMap=null,this._preActivateId=-1,this._LODLevels=new Array,this._useLODScreenCoverage=!1,this._effectiveMaterial=null,this._forcedInstanceCount=0,this._overrideRenderingFillMode=null}}const dn={source:null,parent:null,doNotCloneChildren:!1,clonePhysicsImpostor:!0,cloneThinInstances:!1};class Z extends os{static _GetDefaultSideOrientation(e){return e||Z.FRONTSIDE}get useLODScreenCoverage(){return this._internalMeshDataInfo._useLODScreenCoverage}set useLODScreenCoverage(e){this._internalMeshDataInfo._useLODScreenCoverage=e,this._sortLODLevels()}get computeBonesUsingShaders(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders}set computeBonesUsingShaders(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(e&&this._internalMeshDataInfo._sourcePositions&&(this.setVerticesData(O.PositionKind,this._internalMeshDataInfo._sourcePositions,!0),this._internalMeshDataInfo._sourceNormals&&this.setVerticesData(O.NormalKind,this._internalMeshDataInfo._sourceNormals,!0),this._internalMeshDataInfo._sourcePositions=null,this._internalMeshDataInfo._sourceNormals=null),this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())}get onBeforeRenderObservable(){return this._internalMeshDataInfo._onBeforeRenderObservable||(this._internalMeshDataInfo._onBeforeRenderObservable=new le),this._internalMeshDataInfo._onBeforeRenderObservable}get onBeforeBindObservable(){return this._internalMeshDataInfo._onBeforeBindObservable||(this._internalMeshDataInfo._onBeforeBindObservable=new le),this._internalMeshDataInfo._onBeforeBindObservable}get onAfterRenderObservable(){return this._internalMeshDataInfo._onAfterRenderObservable||(this._internalMeshDataInfo._onAfterRenderObservable=new le),this._internalMeshDataInfo._onAfterRenderObservable}get onBetweenPassObservable(){return this._internalMeshDataInfo._onBetweenPassObservable||(this._internalMeshDataInfo._onBetweenPassObservable=new le),this._internalMeshDataInfo._onBetweenPassObservable}get onBeforeDrawObservable(){return this._internalMeshDataInfo._onBeforeDrawObservable||(this._internalMeshDataInfo._onBeforeDrawObservable=new le),this._internalMeshDataInfo._onBeforeDrawObservable}set onBeforeDraw(e){this._onBeforeDrawObserver&&this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),this._onBeforeDrawObserver=this.onBeforeDrawObservable.add(e)}get hasInstances(){return this.instances.length>0}get hasThinInstances(){return(this.forcedInstanceCount||this._thinInstanceDataStorage.instancesCount||0)>0}get forcedInstanceCount(){return this._internalMeshDataInfo._forcedInstanceCount}set forcedInstanceCount(e){this._internalMeshDataInfo._forcedInstanceCount=e}get sideOrientation(){return this._internalMeshDataInfo._sideOrientation}set sideOrientation(e){this._internalMeshDataInfo._sideOrientation=e,this._internalAbstractMeshDataInfo._sideOrientationHint=this._scene.useRightHandedSystem&&e===1||!this._scene.useRightHandedSystem&&e===0}get _effectiveSideOrientation(){return this._internalMeshDataInfo._effectiveSideOrientation}get overrideMaterialSideOrientation(){return this.sideOrientation}set overrideMaterialSideOrientation(e){this.sideOrientation=e,this.material&&(this.material.sideOrientation=null)}get overrideRenderingFillMode(){return this._internalMeshDataInfo._overrideRenderingFillMode}set overrideRenderingFillMode(e){this._internalMeshDataInfo._overrideRenderingFillMode=e}get material(){return this._internalAbstractMeshDataInfo._material}set material(e){e&&(this.material&&this.material.sideOrientation===null||this._internalAbstractMeshDataInfo._sideOrientationHint)&&(e.sideOrientation=null),this._setMaterial(e)}get source(){return this._internalMeshDataInfo._source}get cloneMeshMap(){return this._internalMeshDataInfo.meshMap}get isUnIndexed(){return this._unIndexed}set isUnIndexed(e){this._unIndexed!==e&&(this._unIndexed=e,this._markSubMeshesAsAttributesDirty())}get worldMatrixInstancedBuffer(){const e=this._instanceDataStorage.renderPasses[this._instanceDataStorage.engine.isWebGPU?this._instanceDataStorage.engine.currentRenderPassId:0];return e?e.instancesData:void 0}get previousWorldMatrixInstancedBuffer(){const e=this._instanceDataStorage.renderPasses[this._instanceDataStorage.engine.isWebGPU?this._instanceDataStorage.engine.currentRenderPassId:0];return e?e.instancesPreviousData:void 0}get manualUpdateOfWorldMatrixInstancedBuffer(){return this._instanceDataStorage.manualUpdate}set manualUpdateOfWorldMatrixInstancedBuffer(e){this._instanceDataStorage.manualUpdate=e}get manualUpdateOfPreviousWorldMatrixInstancedBuffer(){return this._instanceDataStorage.previousManualUpdate}set manualUpdateOfPreviousWorldMatrixInstancedBuffer(e){this._instanceDataStorage.previousManualUpdate=e}get forceWorldMatrixInstancedBufferUpdate(){return this._instanceDataStorage.forceMatrixUpdates}set forceWorldMatrixInstancedBufferUpdate(e){this._instanceDataStorage.forceMatrixUpdates=e}_copySource(e,t,i=!0,s=!1){const r=this.getScene();if(e._geometry&&e._geometry.applyToMesh(this),Db.DeepCopy(e,this,["name","material","skeleton","instances","parent","uniqueId","source","metadata","morphTargetManager","hasInstances","worldMatrixInstancedBuffer","previousWorldMatrixInstancedBuffer","hasLODLevels","geometry","isBlocked","areNormalsFrozen","facetNb","isFacetDataEnabled","lightSources","useBones","isAnInstance","collider","edgesRenderer","forward","up","right","absolutePosition","absoluteScaling","absoluteRotationQuaternion","isWorldMatrixFrozen","nonUniformScaling","behaviors","worldMatrixFromCache","hasThinInstances","cloneMeshMap","hasBoundingInfo","physicsBody","physicsImpostor"],["_poseMatrix"]),this._internalMeshDataInfo._source=e,r.useClonedMeshMap&&(e._internalMeshDataInfo.meshMap||(e._internalMeshDataInfo.meshMap={}),e._internalMeshDataInfo.meshMap[this.uniqueId]=this),this._originalBuilderSideOrientation=e._originalBuilderSideOrientation,this._creationDataStorage=e._creationDataStorage,e._ranges){const a=e._ranges;for(const o in a)Object.prototype.hasOwnProperty.call(a,o)&&a[o]&&this.createAnimationRange(o,a[o].from,a[o].to)}if(e.metadata&&e.metadata.clone?this.metadata=e.metadata.clone():this.metadata=e.metadata,this._internalMetadata=e._internalMetadata,vt&&vt.HasTags(e)&&vt.AddTagsTo(this,vt.GetTags(e,!0)),this.setEnabled(e.isEnabled(!1)),this.parent=e.parent,this.setPivotMatrix(e.getPivotMatrix(),this._postMultiplyPivotMatrix),this.id=this.name+"."+e.id,this.material=e.material,!t){const a=e.getDescendants(!0);for(let o=0;o<a.length;o++){const c=a[o];c._isMesh?(dn.parent=this,dn.doNotCloneChildren=t,dn.clonePhysicsImpostor=i,dn.cloneThinInstances=s,c.clone(this.name+"."+c.name,dn)):c.clone&&c.clone(this.name+"."+c.name,this)}}if(e.morphTargetManager&&(this.morphTargetManager=e.morphTargetManager),r.getPhysicsEngine){const a=r.getPhysicsEngine();if(i&&a)if(a.getPluginVersion()===1){const o=a.getImpostorForPhysicsObject(e);o&&(this.physicsImpostor=o.clone(this))}else a.getPluginVersion()===2&&e.physicsBody&&e.physicsBody.clone(this)}for(let a=0;a<r.particleSystems.length;a++){const o=r.particleSystems[a];o.emitter===e&&o.clone(o.name,this)}if(this.skeleton=e.skeleton,s&&(e._thinInstanceDataStorage.matrixData?(this.thinInstanceSetBuffer("matrix",new Float32Array(e._thinInstanceDataStorage.matrixData),16,!e._thinInstanceDataStorage.matrixBuffer.isUpdatable()),this._thinInstanceDataStorage.matrixBufferSize=e._thinInstanceDataStorage.matrixBufferSize,this._thinInstanceDataStorage.instancesCount=e._thinInstanceDataStorage.instancesCount):this._thinInstanceDataStorage.matrixBufferSize=e._thinInstanceDataStorage.matrixBufferSize,e._userThinInstanceBuffersStorage)){const a=e._userThinInstanceBuffersStorage;for(const o in a.data)this.thinInstanceSetBuffer(o,new Float32Array(a.data[o]),a.strides[o],!a.vertexBuffers?.[o]?.isUpdatable()),this._userThinInstanceBuffersStorage.sizes[o]=a.sizes[o]}this.refreshBoundingInfo(!0,!0),this.computeWorldMatrix(!0)}constructor(e,t=null,i=null,s=null,r,a=!0){super(e,t),this._internalMeshDataInfo=new m3,this.delayLoadState=0,this.instances=[],this._creationDataStorage=null,this._geometry=null,this._thinInstanceDataStorage=new g3,this._shouldGenerateFlatShading=!1,this._originalBuilderSideOrientation=Z.DEFAULTSIDE,this.ignoreCameraMaxZ=!1,t=this.getScene(),this._instanceDataStorage=new _3,this._instanceDataStorage.engine=t.getEngine(),this._scene.useRightHandedSystem?this.sideOrientation=0:this.sideOrientation=1,this._onBeforeDraw=(u,d,f)=>{u&&f&&(this._uniformBuffer?this.transferToEffect(d):f.bindOnlyWorldMatrix(d))};let o=null,c=!1;if(i&&i._addToSceneRootNodes===void 0){const u=i;o=u.parent??null,s=u.source??null,r=u.doNotCloneChildren??!1,a=u.clonePhysicsImpostor??!0,c=u.cloneThinInstances??!1}else o=i;s&&this._copySource(s,r,a,c),o!==null&&(this.parent=o),this._instanceDataStorage.hardwareInstancedRendering=this.getEngine().getCaps().instancedArrays,this._internalMeshDataInfo._onMeshReadyObserverAdded=u=>{u.unregisterOnNextCall=!0,this.isReady(!0)?this.onMeshReadyObservable.notifyObservers(this):this._internalMeshDataInfo._checkReadinessObserver||(this._internalMeshDataInfo._checkReadinessObserver=this._scene.onBeforeRenderObservable.add(()=>{this.isReady(!0)&&(this._scene.onBeforeRenderObservable.remove(this._internalMeshDataInfo._checkReadinessObserver),this._internalMeshDataInfo._checkReadinessObserver=null,this.onMeshReadyObservable.notifyObservers(this))}))},this.onMeshReadyObservable=new le(this._internalMeshDataInfo._onMeshReadyObserverAdded),s&&s.onClonedObservable.notifyObservers(this)}instantiateHierarchy(e=null,t,i){const s=this.getTotalVertices()===0||t&&t.doNotInstantiate&&(t.doNotInstantiate===!0||t.doNotInstantiate(this))?this.clone("Clone of "+(this.name||this.id),e||this.parent,!0):this.createInstance("instance of "+(this.name||this.id));s.parent=e||this.parent,s.position=this.position.clone(),s.scaling=this.scaling.clone(),this.rotationQuaternion?s.rotationQuaternion=this.rotationQuaternion.clone():s.rotation=this.rotation.clone(),i&&i(this,s);for(const r of this.getChildTransformNodes(!0))r.getClassName()==="InstancedMesh"&&s.getClassName()==="Mesh"&&r.sourceMesh===this?r.instantiateHierarchy(s,{doNotInstantiate:t&&t.doNotInstantiate||!1,newSourcedMesh:s},i):r.instantiateHierarchy(s,t,i);return s}getClassName(){return"Mesh"}get _isMesh(){return!0}toString(e){let t=super.toString(e);if(t+=", n vertices: "+this.getTotalVertices(),t+=", parent: "+(this._waitingParentId?this._waitingParentId:this.parent?this.parent.name:"NONE"),this.animations)for(let i=0;i<this.animations.length;i++)t+=", animation[0]: "+this.animations[i].toString(e);if(e)if(this._geometry){const i=this.getIndices(),s=this.getVerticesData(O.PositionKind);s&&i&&(t+=", flat shading: "+(s.length/3===i.length?"YES":"NO"))}else t+=", flat shading: UNKNOWN";return t}_unBindEffect(){super._unBindEffect();for(const e of this.instances)e._unBindEffect()}get hasLODLevels(){return this._internalMeshDataInfo._LODLevels.length>0}getLODLevels(){return this._internalMeshDataInfo._LODLevels}_sortLODLevels(){const e=this._internalMeshDataInfo._useLODScreenCoverage?-1:1;this._internalMeshDataInfo._LODLevels.sort((t,i)=>t.distanceOrScreenCoverage<i.distanceOrScreenCoverage?e:t.distanceOrScreenCoverage>i.distanceOrScreenCoverage?-e:0)}addLODLevel(e,t){if(t&&t._masterMesh)return oe.Warn("You cannot use a mesh as LOD level twice"),this;const i=new f3(e,t);return this._internalMeshDataInfo._LODLevels.push(i),t&&(t._masterMesh=this),this._sortLODLevels(),this}getLODLevelAtDistance(e){const t=this._internalMeshDataInfo;for(let i=0;i<t._LODLevels.length;i++){const s=t._LODLevels[i];if(s.distanceOrScreenCoverage===e)return s.mesh}return null}removeLODLevel(e){const t=this._internalMeshDataInfo;for(let i=0;i<t._LODLevels.length;i++)t._LODLevels[i].mesh===e&&(t._LODLevels.splice(i,1),e&&(e._masterMesh=null));return this._sortLODLevels(),this}getLOD(e,t){const i=this._internalMeshDataInfo;if(!i._LODLevels||i._LODLevels.length===0)return this;const s=t||this.getBoundingInfo().boundingSphere,r=e.mode===Ge.ORTHOGRAPHIC_CAMERA?e.minZ:s.centerWorld.subtract(e.globalPosition).length();let a=r,o=1;if(i._useLODScreenCoverage){const c=e.screenArea;let u=s.radiusWorld*e.minZ/r;u=u*u*Math.PI,a=u/c,o=-1}if(o*i._LODLevels[i._LODLevels.length-1].distanceOrScreenCoverage>o*a)return this.onLODLevelSelection&&this.onLODLevelSelection(a,this,this),this;for(let c=0;c<i._LODLevels.length;c++){const u=i._LODLevels[c];if(o*u.distanceOrScreenCoverage<o*a){if(u.mesh){if(u.mesh.delayLoadState===4)return u.mesh._checkDelayState(),this;if(u.mesh.delayLoadState===2)return this;u.mesh._preActivate(),u.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)}return this.onLODLevelSelection&&this.onLODLevelSelection(a,this,u.mesh),u.mesh}}return this.onLODLevelSelection&&this.onLODLevelSelection(a,this,this),this}get geometry(){return this._geometry}getTotalVertices(){return this._geometry===null||this._geometry===void 0?0:this._geometry.getTotalVertices()}getVerticesData(e,t,i,s){if(!this._geometry)return null;let r=s?void 0:this._userInstancedBuffersStorage?.vertexBuffers[e]?.getFloatData(this.instances.length+1,i||t&&this._geometry.meshes.length!==1);return r||(r=this._geometry.getVerticesData(e,t,i)),r}copyVerticesData(e,t){this._geometry&&this._geometry.copyVerticesData(e,t)}getVertexBuffer(e,t){return this._geometry?(t?void 0:this._userInstancedBuffersStorage?.vertexBuffers[e])??this._geometry.getVertexBuffer(e):null}isVerticesDataPresent(e,t){return this._geometry?!t&&this._userInstancedBuffersStorage?.vertexBuffers[e]!==void 0||this._geometry.isVerticesDataPresent(e):this._delayInfo?this._delayInfo.indexOf(e)!==-1:!1}isVertexBufferUpdatable(e,t){if(!this._geometry)return this._delayInfo?this._delayInfo.indexOf(e)!==-1:!1;if(!t){const i=this._userInstancedBuffersStorage?.vertexBuffers[e];if(i)return i.isUpdatable()}return this._geometry.isVertexBufferUpdatable(e)}getVerticesDataKinds(e){if(!this._geometry){const i=[];if(this._delayInfo)for(const s of this._delayInfo)i.push(s);return i}const t=this._geometry.getVerticesDataKinds();if(!e&&this._userInstancedBuffersStorage)for(const i in this._userInstancedBuffersStorage.vertexBuffers)t.indexOf(i)===-1&&t.push(i);return t}getTotalIndices(){return this._geometry?this._geometry.getTotalIndices():0}getIndices(e,t){return this._geometry?this._geometry.getIndices(e,t):[]}get isBlocked(){return this._masterMesh!==null&&this._masterMesh!==void 0}isReady(e=!1,t=!1){if(this.delayLoadState===2||!super.isReady(e))return!1;if(!this.subMeshes||this.subMeshes.length===0||!e)return!0;const i=this.getEngine(),s=this.getScene(),r=t||i.getCaps().instancedArrays&&(this.instances.length>0||this.hasThinInstances);this.computeWorldMatrix();const a=this.material||s.defaultMaterial;if(a){if(a._storeEffectOnSubMeshes)for(const c of this.subMeshes){const u=c.getMaterial();if(u){if(u._storeEffectOnSubMeshes){if(!u.isReadyForSubMesh(this,c,r))return!1}else if(!u.isReady(this,r))return!1}}else if(!a.isReady(this,r))return!1}const o=i.currentRenderPassId;for(const c of this.lightSources){const u=c.getShadowGenerators();if(!u)continue;const d=u.values();for(let f=d.next();f.done!==!0;f=d.next()){const g=f.value;if(g&&(!g.getShadowMap()?.renderList||g.getShadowMap()?.renderList&&g.getShadowMap()?.renderList?.indexOf(this)!==-1)){const b=g.getShadowMap().renderPassIds??[i.currentRenderPassId];for(let x=0;x<b.length;++x){i.currentRenderPassId=b[x];for(const v of this.subMeshes)if(!g.isReady(v,r,v.getMaterial()?.needAlphaBlendingForMesh(this)??!1))return i.currentRenderPassId=o,!1}i.currentRenderPassId=o}}}for(const c of this._internalMeshDataInfo._LODLevels)if(c.mesh&&!c.mesh.isReady(r))return!1;return!0}get areNormalsFrozen(){return this._internalMeshDataInfo._areNormalsFrozen}freezeNormals(){return this._internalMeshDataInfo._areNormalsFrozen=!0,this}unfreezeNormals(){return this._internalMeshDataInfo._areNormalsFrozen=!1,this}set overridenInstanceCount(e){this._instanceDataStorage.overridenInstanceCount=e}_getInstanceDataStorage(){const e=this._instanceDataStorage.engine.isWebGPU?this._instanceDataStorage.engine.currentRenderPassId:0;let t=this._instanceDataStorage.renderPasses[e];return t||(t=new p3,this._instanceDataStorage.renderPasses[e]=t),t}_preActivate(){const e=this._internalMeshDataInfo,t=this.getScene().getRenderId();return e._preActivateId===t?this:(e._preActivateId=t,this._getInstanceDataStorage().visibleInstances=null,this)}_preActivateForIntermediateRendering(e){const t=this._getInstanceDataStorage();return t.visibleInstances&&(t.visibleInstances.intermediateDefaultRenderId=e),this}_registerInstanceForRenderId(e,t){const i=this._getInstanceDataStorage();return i.visibleInstances||(i.visibleInstances={defaultRenderId:t,selfDefaultRenderId:this._renderId,intermediateDefaultRenderId:-1}),i.visibleInstances[t]||(i.previousRenderId!==void 0&&this._instanceDataStorage.isFrozen&&(i.visibleInstances[i.previousRenderId]=null),i.previousRenderId=t,i.visibleInstances[t]=new Array),i.visibleInstances[t].push(e),this}_afterComputeWorldMatrix(){super._afterComputeWorldMatrix(),this.hasThinInstances&&(this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1))}_postActivate(){this.edgesShareWithInstances&&this.edgesRenderer&&this.edgesRenderer.isEnabled&&this._renderingGroup&&(this._renderingGroup._edgesRenderers.pushNoDuplicate(this.edgesRenderer),this.edgesRenderer.customInstances.push(this.getWorldMatrix()))}refreshBoundingInfo(e=!1,t=!1){if(this.hasBoundingInfo&&this.getBoundingInfo().isLocked)return this;let i;typeof e=="object"?i=e:i={applySkeleton:e,applyMorph:t};const s=this.geometry?this.geometry.boundingBias:null;return this._refreshBoundingInfo(this._getData(i,null,O.PositionKind),s),this}_createGlobalSubMesh(e){const t=this.getTotalVertices();if(!t||!this.getIndices())return null;if(this.subMeshes&&this.subMeshes.length>0){const i=this.getIndices();if(!i)return null;const s=i.length;let r=!1;if(e)r=!0;else for(const a of this.subMeshes){if(a.indexStart+a.indexCount>s){r=!0;break}if(a.verticesStart+a.verticesCount>t){r=!0;break}}if(!r)return this.subMeshes[0]}return this.releaseSubMeshes(),new As(0,0,t,0,this.getTotalIndices()||(this.isUnIndexed?t:0),this)}subdivide(e){if(e<1)return;const t=this.getTotalIndices();let i=t/e|0,s=0;for(;i%3!==0;)i++;this.releaseSubMeshes();for(let r=0;r<e&&!(s>=t);r++)As.CreateFromIndices(0,s,r===e-1?t-s:i,this,void 0,!1),s+=i;this.refreshBoundingInfo(),this.synchronizeInstances()}setVerticesData(e,t,i=!1,s){if(this._geometry)this._geometry.setVerticesData(e,t,i,s);else{const r=new ve;r.set(t,e);const a=this.getScene();new ps(ps.RandomId(),a,r,i,this)}return this}removeVerticesData(e){this._geometry&&this._geometry.removeVerticesData(e)}markVerticesDataAsUpdatable(e,t=!0){const i=this.getVertexBuffer(e);!i||i.isUpdatable()===t||this.setVerticesData(e,this.getVerticesData(e),t)}setVerticesBuffer(e,t=!0){return this._geometry||(this._geometry=ps.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e,null,t),this}updateVerticesData(e,t,i,s){return this._geometry?(s?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i),this):this}updateMeshPositions(e,t=!0){const i=this.getVerticesData(O.PositionKind);if(!i)return this;if(e(i),this.updateVerticesData(O.PositionKind,i,!1,!1),t){const s=this.getIndices(),r=this.getVerticesData(O.NormalKind);if(!r)return this;ve.ComputeNormals(i,s,r),this.updateVerticesData(O.NormalKind,r,!1,!1)}return this}makeGeometryUnique(){if(!this._geometry)return this;if(this._geometry.meshes.length===1)return this;const e=this._geometry,t=this._geometry.copy(ps.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this}setIndexBuffer(e,t,i,s=null){let r=this._geometry;r||(r=new ps(ps.RandomId(),this.getScene(),void 0,void 0,this)),r.setIndexBuffer(e,t,i,s)}setIndices(e,t=null,i=!1,s=!1){if(this._geometry)this._geometry.setIndices(e,t,i,s);else{const r=new ve;r.indices=e;const a=this.getScene();new ps(ps.RandomId(),a,r,i,this)}return this}updateIndices(e,t,i=!1){return this._geometry?(this._geometry.updateIndices(e,t,i),this):this}toLeftHanded(){return this._geometry?(this._geometry.toLeftHanded(),this):this}_bind(e,t,i,s=!0){if(!this._geometry)return this;const r=this.getScene().getEngine();let a;if(this._unIndexed)switch(this._getRenderingFillMode(i)){case fe.WireFrameFillMode:a=e._getLinesIndexBuffer(this.getIndices(),r);break;default:a=null;break}else switch(this._getRenderingFillMode(i)){case fe.PointFillMode:a=null;break;case fe.WireFrameFillMode:a=e._getLinesIndexBuffer(this.getIndices(),r);break;default:case fe.TriangleFillMode:a=this._geometry.getIndexBuffer();break}return this._bindDirect(t,a,s)}_bindDirect(e,t,i=!0){if(!this._geometry)return this;if(this.morphTargetManager&&this.morphTargetManager.isUsingTextureForTargets&&this.morphTargetManager._bind(e),!i||!this._userInstancedBuffersStorage||this.hasThinInstances)this._geometry._bind(e,t);else{if(this._instanceDataStorage.engine.isWebGPU&&this._userInstancedBuffersStorage.renderPasses&&this._userInstancedBuffersStorage.renderPasses[this._instanceDataStorage.engine.currentRenderPassId]){const s=this._userInstancedBuffersStorage.renderPasses[this._instanceDataStorage.engine.currentRenderPassId];for(const r in s)this._userInstancedBuffersStorage.vertexBuffers[r]=s[r]}this._geometry._bind(e,t,this._userInstancedBuffersStorage.vertexBuffers,this._userInstancedBuffersStorage.vertexArrayObjects)}return this}_draw(e,t,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeDrawObservable&&this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);const r=this.getScene().getEngine(),a=r._currentMaterialContext,o=a&&a.useVertexPulling;return this._unIndexed&&t!==fe.WireFrameFillMode||t==fe.PointFillMode?r.drawArraysType(t,e.verticesStart,e.verticesCount,this.forcedInstanceCount||i):t==fe.WireFrameFillMode?r.drawElementsType(t,0,e._linesIndexCount,this.forcedInstanceCount||i):o?r.drawArraysType(t,e.indexStart,e.indexCount,this.forcedInstanceCount||i):r.drawElementsType(t,e.indexStart,e.indexCount,this.forcedInstanceCount||i),this}registerBeforeRender(e){return this.onBeforeRenderObservable.add(e),this}unregisterBeforeRender(e){return this.onBeforeRenderObservable.removeCallback(e),this}registerAfterRender(e){return this.onAfterRenderObservable.add(e),this}unregisterAfterRender(e){return this.onAfterRenderObservable.removeCallback(e),this}_getInstancesRenderList(e,t=!1){const i=this._getInstanceDataStorage();
231if(this._instanceDataStorage.isFrozen){if(t)return i.batchCacheReplacementModeInFrozenMode.hardwareInstancedRendering[e]=!1,i.batchCacheReplacementModeInFrozenMode.renderSelf[e]=!0,i.batchCacheReplacementModeInFrozenMode;if(i.previousBatch)return i.previousBatch}const s=this.getScene(),r=s._isInIntermediateRendering(),a=r?this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate:this._internalAbstractMeshDataInfo._onlyForInstances,o=i.batchCache;if(o.mustReturn=!1,o.renderSelf[e]=t||!a&&this.isEnabled()&&this.isVisible,o.visibleInstances[e]=null,i.visibleInstances&&!t){const c=i.visibleInstances,u=s.getRenderId(),d=r?c.intermediateDefaultRenderId:c.defaultRenderId;o.visibleInstances[e]=c[u],!o.visibleInstances[e]&&d&&(o.visibleInstances[e]=c[d])}return o.hardwareInstancedRendering[e]=!t&&this._instanceDataStorage.hardwareInstancedRendering&&o.visibleInstances[e]!==null&&o.visibleInstances[e]!==void 0,i.previousBatch=o,o}_updateInstancedBuffers(e,t,i,s,r,a){const o=t.visibleInstances[e._id],c=o?o.length:0,u=t.parent,d=this._instanceDataStorage;let f=u.instancesBuffer,g=u.instancesPreviousBuffer,m=0,b=0;
231const x=t.renderSelf[e._id],v=this._scene.floatingOriginOffset,E=!f||i!==u.instancesBufferSize||this._scene.needsPreviousWorldMatrices&&!u.instancesPreviousBuffer;if(!this._instanceDataStorage.manualUpdate&&(!d.isFrozen||E)){const A=this.getWorldMatrix();if(x&&(this._scene.needsPreviousWorldMatrices&&(d.masterMeshPreviousWorldMatrix?(d.masterMeshPreviousWorldMatrix.copyToArray(u.instancesPreviousData,m),d.masterMeshPreviousWorldMatrix.copyFrom(A)):(d.masterMeshPreviousWorldMatrix=A.clone(),d.masterMeshPreviousWorldMatrix.copyToArray(u.instancesPreviousData,m))),A.copyToArray(u.instancesData,m),u.instancesData[m+12]-=v.x,u.instancesData[m+13]-=v.y,u.instancesData[m+14]-=v.z,m+=16,b++),o){if(Z.INSTANCEDMESH_SORT_TRANSPARENT&&this._scene.activeCamera&&e.getMaterial()?.needAlphaBlendingForMesh(e.getRenderingMesh())){const D=this._scene.activeCamera.globalPosition;for(let I=0;I<o.length;I++){const R=o[I];R._distanceToCamera=T.Distance(R.getBoundingInfo().boundingSphere.centerWorld,D)}o.sort((I,R)=>I._distanceToCamera>R._distanceToCamera?-1:I._distanceToCamera<R._distanceToCamera?1:0)}for(let D=0;D<o.length;D++){const I=o[D],R=I.getWorldMatrix();R.copyToArray(u.instancesData,m),this._scene.needsPreviousWorldMatrices&&(I._previousWorldMatrix?(I._previousWorldMatrix.copyToArray(u.instancesPreviousData,m),I._previousWorldMatrix.copyFrom(R)):(I._previousWorldMatrix=R.clone(),I._previousWorldMatrix.copyToArray(u.instancesPreviousData,m))),u.instancesData[m+12]-=v.x,u.instancesData[m+13]-=v.y,u.instancesData[m+14]-=v.z,m+=16,b++}}}else b=(x?1:0)+c;if(E){f&&f.dispose(),g&&g.dispose(),f=new of(s,u.instancesData,!0,16,!1,!0),u.instancesBuffer=f,this._userInstancedBuffersStorage||(this._userInstancedBuffersStorage={data:{},vertexBuffers:{},strides:{},sizes:{},vertexArrayObjects:this.getEngine().getCaps().vertexArrayObject?{}:void 0});let A;if(this._instanceDataStorage.engine.isWebGPU){this._userInstancedBuffersStorage.renderPasses||(this._userInstancedBuffersStorage.renderPasses={});const D=this._instanceDataStorage.engine.currentRenderPassId;A=this._userInstancedBuffersStorage.renderPasses[D],A||(this._userInstancedBuffersStorage.renderPasses[D]=A={})}else A=this._userInstancedBuffersStorage.vertexBuffers;A.world0=f.createVertexBuffer("world0",0,4),A.world1=f.createVertexBuffer("world1",4,4),A.world2=f.createVertexBuffer("world2",8,4),A.world3=f.createVertexBuffer("world3",12,4),this._scene.needsPreviousWorldMatrices&&(g=new of(s,u.instancesPreviousData,!0,16,!1,!0),u.instancesPreviousBuffer=g,A.previousWorld0=g.createVertexBuffer("previousWorld0",0,4),A.previousWorld1=g.createVertexBuffer("previousWorld1",4,4),A.previousWorld2=g.createVertexBuffer("previousWorld2",8,4),A.previousWorld3=g.createVertexBuffer("previousWorld3",12,4)),this._invalidateInstanceVertexArrayObject()}else(!this._instanceDataStorage.isFrozen||this._instanceDataStorage.forceMatrixUpdates)&&(f.updateDirectly(u.instancesData,0,b),this._scene.needsPreviousWorldMatrices&&(!this._instanceDataStorage.manualUpdate||this._instanceDataStorage.previousManualUpdate)&&g.updateDirectly(u.instancesPreviousData,0,b));this._processInstancedBuffers(o,x),a&&r!==void 0&&(this.getScene()._activeIndices.addCount(e.indexCount*b,!1),s._currentDrawContext&&(s._currentDrawContext.useInstancing=!0),this._bind(e,a,r),this._draw(e,r,b)),this._scene.needsPreviousWorldMatrices&&!E&&this._instanceDataStorage.manualUpdate&&(!this._instanceDataStorage.isFrozen||this._instanceDataStorage.forceMatrixUpdates)&&!this._instanceDataStorage.previousManualUpdate&&g.updateDirectly(u.instancesData,0,b)}_renderWithInstances(e,t,i,s,r){const a=i.visibleInstances[e._id],o=a?a.length:0,c=i.parent,u=c.instancesBufferSize,f=(o+1)*16*4;for(;c.instancesBufferSize<f;)c.instancesBufferSize*=2;return(!c.instancesData||u!=c.instancesBufferSize)&&(c.instancesData=new Float32Array(c.instancesBufferSize/4)),(this._scene.needsPreviousWorldMatrices&&!c.instancesPreviousData||u!=c.instancesBufferSize)&&(c.instancesPreviousData=new Float32Array(c.instancesBufferSize/4)),this._updateInstancedBuffers(e,i,u,r,t,s),r.unbindInstanceAttributes(),this}_renderWithThinInstances(e,t,i,s){const r=this._thinInstanceDataStorage?.instancesCount??0;
vendor: 37,440 bytes, lines 231-238
231this.getScene()._activeIndices.addCount(e.indexCount*r,!1),s._currentDrawContext&&(s._currentDrawContext.useInstancing=!0),this._bind(e,i,t),this._draw(e,t,r),this._scene.needsPreviousWorldMatrices&&!this._thinInstanceDataStorage.previousMatrixData&&this._thinInstanceDataStorage.matrixData&&(this._thinInstanceDataStorage.previousMatrixBuffer?this._thinInstanceDataStorage.previousMatrixBuffer.updateDirectly(this._thinInstanceDataStorage.matrixData,0,r):this._thinInstanceDataStorage.previousMatrixBuffer=this._thinInstanceCreateMatrixBuffer("previousWorld",this._thinInstanceDataStorage.matrixData,!1)),s.unbindInstanceAttributes()}_processInstancedBuffers(e,t){}_processRendering(e,t,i,s,r,a,o,c){const u=this.getScene(),d=u.getEngine();if(s=this._getRenderingFillMode(s),a&&t.getRenderingMesh().hasThinInstances)return this._renderWithThinInstances(t,s,i,d),this;if(a)this._renderWithInstances(t,s,r,i,d);else{d._currentDrawContext&&(d._currentDrawContext.useInstancing=!1);let f=0;r.renderSelf[t._id]&&(o&&o(!1,e.getWorldMatrix(),c),f++,this._draw(t,s,this._instanceDataStorage.overridenInstanceCount));const g=r.visibleInstances[t._id];if(g){const m=g.length;f+=m;for(let b=0;b<m;b++){const v=g[b].getWorldMatrix();o&&o(!0,v,c),this._draw(t,s)}}u._activeIndices.addCount(t.indexCount*f,!1)}return this}_rebuild(e=!1){for(const t in this._instanceDataStorage.renderPasses){const i=this._instanceDataStorage.renderPasses[t];i.instancesBuffer&&(e&&i.instancesBuffer.dispose(),i.instancesBuffer=null)}if(this._userInstancedBuffersStorage){for(const t in this._userInstancedBuffersStorage.vertexBuffers){const i=this._userInstancedBuffersStorage.vertexBuffers[t];i&&(e&&i.dispose(),this._userInstancedBuffersStorage.vertexBuffers[t]=null)}this._userInstancedBuffersStorage.vertexArrayObjects&&(this._userInstancedBuffersStorage.vertexArrayObjects={})}this._internalMeshDataInfo._effectiveMaterial=null,super._rebuild(e)}_freeze(){if(this.subMeshes){for(let e=0;e<this.subMeshes.length;e++)this._getInstancesRenderList(e);this._internalMeshDataInfo._effectiveMaterial=null,this._instanceDataStorage.isFrozen=!0}}_unFreeze(){this._instanceDataStorage.isFrozen=!1;for(const e in this._instanceDataStorage.renderPasses){const t=this._instanceDataStorage.renderPasses[e];t.previousBatch=null}}renderWithRenderPassId(e,t,i,s,r=!0){const a=this._scene.getEngine(),o=a.currentRenderPassId;if(e!==void 0&&(a.currentRenderPassId=e),s)(!r||r&&s.isInFrustum(this._scene._frustumPlanes))&&this.render(s,!!t,i);else for(let c=0;c<this.subMeshes.length;c++){const u=this.subMeshes[c];(!r||r&&u.isInFrustum(this._scene._frustumPlanes))&&this.render(u,!!t,i)}return e!==void 0&&(a.currentRenderPassId=o),this}directRender(){if(!this.subMeshes)return this;for(const e of this.subMeshes)this.render(e,!1);return this}render(e,t,i){const s=this.getScene();this._internalAbstractMeshDataInfo._isActiveIntermediate?this._internalAbstractMeshDataInfo._isActiveIntermediate=!1:this._internalAbstractMeshDataInfo._isActive=!1;const r=s.activeCameras?.length??0;if((r>1&&s.activeCamera===s.activeCameras[0]||r<=1)&&this._checkOcclusionQuery()&&!this._occlusionDataStorage.forceRenderingWhenOccluded)return this;const o=this._getInstancesRenderList(e._id,!!i);if(o.mustReturn)return this;if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;const c=s.getEngine();let u=0,d=null;this.ignoreCameraMaxZ&&s.activeCamera&&!s._isInIntermediateRendering()&&(u=s.activeCamera.maxZ,d=s.activeCamera,s.activeCamera.maxZ=0,s.updateTransformMatrix(!0)),this._internalMeshDataInfo._onBeforeRenderObservable&&this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);const f=e.getRenderingMesh(),g=o.hardwareInstancedRendering[e._id]||f.hasThinInstances||!!this._userInstancedBuffersStorage&&!e.getMesh()._internalAbstractMeshDataInfo._actAsRegularMesh,m=this._instanceDataStorage,b=e.getMaterial();if(!b)return d&&(d.maxZ=u,s.updateTransformMatrix(!0)),this;if(!m.isFrozen||!this._internalMeshDataInfo._effectiveMaterial||this._internalMeshDataInfo._effectiveMaterial!==b){if(b._storeEffectOnSubMeshes){if(!b.isReadyForSubMesh(this,e,g))return d&&(d.maxZ=u,s.updateTransformMatrix(!0)),this}else if(!b.isReady(this,g))return d&&(d.maxZ=u,s.updateTransformMatrix(!0)),this;this._internalMeshDataInfo._effectiveMaterial=b}else if(b._storeEffectOnSubMeshes&&!e._drawWrapper?._wasPreviouslyReady||!b._storeEffectOnSubMeshes&&!b._getDrawWrapper()._wasPreviouslyReady)return d&&(d.maxZ=u,s.updateTransformMatrix(!0)),this;if(t){const M=this._internalMeshDataInfo._effectiveMaterial;if(M.alphaModes.length===1)c.setAlphaMode(M.alphaMode);else for(let F=0;F<M.alphaModes.length;F++){const U=M.alphaModes[F];c.setAlphaMode(U!==void 0?U:2,!1,F)}}let x;this._internalMeshDataInfo._effectiveMaterial._storeEffectOnSubMeshes?x=e._drawWrapper:x=this._internalMeshDataInfo._effectiveMaterial._getDrawWrapper();const v=x?.effect??null;for(const M of s._beforeRenderingMeshStage)M.action(this,e,o,v);if(!x||!v)return d&&(d.maxZ=u,s.updateTransformMatrix(!0)),this;const E=i||this;let A;if(!m.isFrozen&&(this._internalMeshDataInfo._effectiveMaterial.backFaceCulling||this._internalMeshDataInfo._effectiveMaterial.sideOrientation!==null||this._internalMeshDataInfo._effectiveMaterial._twoSidedLighting)){const M=E._getWorldMatrixDeterminant();A=this._internalMeshDataInfo._effectiveMaterial._getEffectiveOrientation(this),M<0&&(A=A===fe.ClockWiseSideOrientation?fe.CounterClockWiseSideOrientation:fe.ClockWiseSideOrientation),this._internalMeshDataInfo._effectiveSideOrientation=A}else A=this._internalMeshDataInfo._effectiveSideOrientation;const D=this._internalMeshDataInfo._effectiveMaterial._preBind(x,this._internalMeshDataInfo._effectiveSideOrientation);this._internalMeshDataInfo._effectiveMaterial.forceDepthWrite&&c.setDepthWrite(!0);const I=this._internalMeshDataInfo._effectiveMaterial,R=I.fillMode;this._internalMeshDataInfo._onBeforeBindObservable&&this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this),g||this._bind(e,v,R,!1);const C=E.getWorldMatrix();I._storeEffectOnSubMeshes?I.bindForSubMesh(C,this,e):I.bind(C,this),!I.backFaceCulling&&I.separateCullingPass&&(c.setState(!0,I.zOffset,!1,!D,I.cullBackFaces,I.stencil,I.zOffsetUnits),this._processRendering(this,e,v,R,o,g,this._onBeforeDraw,this._internalMeshDataInfo._effectiveMaterial),c.setState(!0,I.zOffset,!1,D,I.cullBackFaces,I.stencil,I.zOffsetUnits),this._internalMeshDataInfo._onBetweenPassObservable&&this._internalMeshDataInfo._onBetweenPassObservable.notifyObservers(e)),this._processRendering(this,e,v,R,o,g,this._onBeforeDraw,this._internalMeshDataInfo._effectiveMaterial),this._internalMeshDataInfo._effectiveMaterial.unbind();for(const M of s._afterRenderingMeshStage)M.action(this,e,o,v);return this._internalMeshDataInfo._onAfterRenderObservable&&this._internalMeshDataInfo._onAfterRenderObservable.notifyObservers(this),d&&(d.maxZ=u,s.updateTransformMatrix(!0)),s.performancePriority===2&&!m.isFrozen&&this._freeze(),this}cleanMatrixWeights(){this.isVerticesDataPresent(O.MatricesWeightsKind)&&(this.isVerticesDataPresent(O.MatricesWeightsExtraKind)?this._normalizeSkinWeightsAndExtra():this._normalizeSkinFourWeights())}_normalizeSkinFourWeights(){const e=this.getVerticesData(O.MatricesWeightsKind),t=e.length;for(let i=0;i<t;i+=4){const s=e[i]+e[i+1]+e[i+2]+e[i+3];if(s===0)e[i]=1;else{const r=1/s;e[i]*=r,e[i+1]*=r,e[i+2]*=r,e[i+3]*=r}}this.setVerticesData(O.MatricesWeightsKind,e)}_normalizeSkinWeightsAndExtra(){const e=this.getVerticesData(O.MatricesWeightsExtraKind),t=this.getVerticesData(O.MatricesWeightsKind),i=t.length;for(let s=0;s<i;s+=4){let r=t[s]+t[s+1]+t[s+2]+t[s+3];if(r+=e[s]+e[s+1]+e[s+2]+e[s+3],r===0)t[s]=1;else{const a=1/r;t[s]*=a,t[s+1]*=a,t[s+2]*=a,t[s+3]*=a,e[s]*=a,e[s+1]*=a,e[s+2]*=a,e[s+3]*=a}}this.setVerticesData(O.MatricesWeightsKind,t),this.setVerticesData(O.MatricesWeightsKind,e)}validateSkinning(){const e=this.getVerticesData(O.MatricesWeightsExtraKind),t=this.getVerticesData(O.MatricesWeightsKind);if(t===null||this.skeleton==null)return{skinned:!1,valid:!0,report:"not skinned"};const i=t.length;let s=0,r=0,a=0,o=0;const c=e===null?4:8,u=[];for(let v=0;v<=c;v++)u[v]=0;const d=.001;for(let v=0;v<i;v+=4){let E=t[v],A=E,D=A===0?0:1;for(let I=1;I<c;I++){const R=I<4?t[v+I]:e[v+I-4];R>E&&s++,R!==0&&D++,A+=R,E=R}if(u[D]++,D>a&&(a=D),A===0)r++;else{const I=1/A;let R=0;for(let C=0;C<c;C++)C<4?R+=Math.abs(t[v+C]-t[v+C]*I):R+=Math.abs(e[v+C-4]-e[v+C-4]*I);R>d&&o++}}const f=this.skeleton.bones.length,g=this.getVerticesData(O.MatricesIndicesKind),m=this.getVerticesData(O.MatricesIndicesExtraKind);let b=0;for(let v=0;v<i;v+=4)for(let E=0;E<c;E++){const A=E<4?g[v+E]:m[v+E-4];(A>=f||A<0)&&b++}const x="Number of Weights = "+i/4+` 232Maximum influences = `+a+` 233Missing Weights = `+r+` 234Not Sorted = `+s+` 235Not Normalized = `+o+` 236WeightCounts = [`+u+`] 237Number of bones = `+f+` 238Bad Bone Indices = `+b;return{skinned:!0,valid:r===0&&o===0&&b===0,report:x}}_checkDelayState(){const e=this.getScene();return this._geometry?this._geometry.load(e):this.delayLoadState===4&&(this.delayLoadState=2,this._queueLoad(e)),this}_queueLoad(e){e.addPendingData(this);const t=this.delayLoadingFile.indexOf(".babylonbinarymeshdata")!==-1;return pe.LoadFile(this.delayLoadingFile,i=>{i instanceof ArrayBuffer?this._delayLoadingFunction(i,this):this._delayLoadingFunction(JSON.parse(i),this);for(const s of this.instances)s.refreshBoundingInfo(),s._syncSubMeshes();this.delayLoadState=1,e.removePendingData(this)},()=>{},e.offlineProvider,t),this}isInFrustum(e){return this.delayLoadState===2||!super.isInFrustum(e)?!1:(this._checkDelayState(),!0)}setMaterialById(e){const t=this.getScene().materials;let i;for(i=t.length-1;i>-1;i--)if(t[i].id===e)return this.material=t[i],this;const s=this.getScene().multiMaterials;for(i=s.length-1;i>-1;i--)if(s[i].id===e)return this.material=s[i],this;return this}getAnimatables(){const e=[];return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e}bakeTransformIntoVertices(e){if(!this.isVerticesDataPresent(O.PositionKind))return this;const t=this.subMeshes.splice(0);this._resetPointsArrayCache();let i=this.getVerticesData(O.PositionKind);const s=T.Zero();let r;for(r=0;r<i.length;r+=3)T.TransformCoordinatesFromFloatsToRef(i[r],i[r+1],i[r+2],e,s).toArray(i,r);if(this.setVerticesData(O.PositionKind,i,this.getVertexBuffer(O.PositionKind).isUpdatable()),this.isVerticesDataPresent(O.NormalKind)){for(i=this.getVerticesData(O.NormalKind),r=0;r<i.length;r+=3)T.TransformNormalFromFloatsToRef(i[r],i[r+1],i[r+2],e,s).normalize().toArray(i,r);this.setVerticesData(O.NormalKind,i,this.getVertexBuffer(O.NormalKind).isUpdatable())}if(this.isVerticesDataPresent(O.TangentKind)){for(i=this.getVerticesData(O.TangentKind),r=0;r<i.length;r+=4)T.TransformNormalFromFloatsToRef(i[r],i[r+1],i[r+2],e,s).normalize().toArray(i,r);this.setVerticesData(O.TangentKind,i,this.getVertexBuffer(O.TangentKind).isUpdatable())}return e.determinant()<0&&this.flipFaces(),this.releaseSubMeshes(),this.subMeshes=t,this}bakeCurrentTransformIntoVertices(e=!0,t=!1){return t&&this.makeGeometryUnique(),this.bakeTransformIntoVertices(this.computeWorldMatrix(!0)),this.resetLocalMatrix(e),this}get _positions(){return this._internalAbstractMeshDataInfo._positions||this._geometry&&this._geometry._positions||null}_resetPointsArrayCache(){return this._geometry&&this._geometry._resetPointsArrayCache(),this}_generatePointsArray(){return this._geometry?this._geometry._generatePointsArray():!1}clone(e="",t=null,i,s=!0){if(t&&t._addToSceneRootNodes===void 0){const r=t;return dn.source=this,dn.doNotCloneChildren=r.doNotCloneChildren,dn.clonePhysicsImpostor=r.clonePhysicsImpostor,dn.cloneThinInstances=r.cloneThinInstances,new Z(e,this.getScene(),dn)}return new Z(e,this.getScene(),t,this,i,s)}dispose(e,t=!1){this.morphTargetManager=null,this._geometry&&this._geometry.releaseForMesh(this,!0);const i=this._internalMeshDataInfo;if(i._onBeforeDrawObservable&&i._onBeforeDrawObservable.clear(),i._onBeforeBindObservable&&i._onBeforeBindObservable.clear(),i._onBeforeRenderObservable&&i._onBeforeRenderObservable.clear(),i._onAfterRenderObservable&&i._onAfterRenderObservable.clear(),i._onBetweenPassObservable&&i._onBetweenPassObservable.clear(),this._scene.useClonedMeshMap){if(i.meshMap)for(const s in i.meshMap){const r=i.meshMap[s];r&&(r._internalMeshDataInfo._source=null,i.meshMap[s]=void 0)}i._source&&i._source._internalMeshDataInfo.meshMap&&(i._source._internalMeshDataInfo.meshMap[this.uniqueId]=void 0)}else{const s=this.getScene().meshes;for(const r of s){const a=r;a._internalMeshDataInfo&&a._internalMeshDataInfo._source&&a._internalMeshDataInfo._source===this&&(a._internalMeshDataInfo._source=null)}}i._source=null,this._disposeInstanceSpecificData(),this._disposeThinInstanceSpecificData(),this._internalMeshDataInfo._checkReadinessObserver&&this._scene.onBeforeRenderObservable.remove(this._internalMeshDataInfo._checkReadinessObserver),super.dispose(e,t)}_disposeInstanceSpecificData(){}_disposeThinInstanceSpecificData(){}_invalidateInstanceVertexArrayObject(){}applyDisplacementMap(e,t,i,s,r,a,o=!1,c){const u=this.getScene(),d=f=>{const g=f.width,m=f.height,x=this.getEngine().createCanvas(g,m).getContext("2d");x.drawImage(f,0,0);const v=x.getImageData(0,0,g,m).data;this.applyDisplacementMapFromBuffer(v,g,m,t,i,r,a,o),s&&s(this)};return pe.LoadImage(e,d,c||(()=>{}),u.offlineProvider),this}applyDisplacementMapFromBuffer(e,t,i,s,r,a,o,c=!1){if(!this.isVerticesDataPresent(O.PositionKind)||!this.isVerticesDataPresent(O.NormalKind)||!this.isVerticesDataPresent(O.UVKind))return oe.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),this;const u=this.getVerticesData(O.PositionKind,!0,!0),d=this.getVerticesData(O.NormalKind),f=this.getVerticesData(O.UVKind);let g=T.Zero();const m=T.Zero(),b=Ie.Zero();a=a||Ie.Zero(),o=o||new Ie(1,1);for(let x=0;x<u.length;x+=3){T.FromArrayToRef(u,x,g),T.FromArrayToRef(d,x,m),Ie.FromArrayToRef(f,x/3*2,b);const v=Math.abs(b.x*o.x+a.x%1)*(t-1)%t|0,E=Math.abs(b.y*o.y+a.y%1)*(i-1)%i|0,A=(v+E*t)*4,D=e[A]/255,I=e[A+1]/255,R=e[A+2]/255,C=D*.3+I*.59+R*.11;m.normalize(),m.scaleInPlace(s+(r-s)*C),g=g.add(m),g.toArray(u,x)}return ve.ComputeNormals(u,this.getIndices(),d),c?(this.setVerticesData(O.PositionKind,u),this.setVerticesData(O.NormalKind,d),this.setVerticesData(O.UVKind,f)):(this.updateVerticesData(O.PositionKind,u),this.updateVerticesData(O.NormalKind,d)),this}_getFlattenedNormals(e,t){const i=new Float32Array(e.length*3);let s=0;const r=this.sideOrientation===(this._scene.useRightHandedSystem?1:0);for(let a=0;a<e.length;a+=3){const o=T.FromArray(t,e[a]*3),c=T.FromArray(t,e[a+1]*3),u=T.FromArray(t,e[a+2]*3),d=o.subtract(c),f=u.subtract(c),g=T.Normalize(T.Cross(d,f));r&&g.scaleInPlace(-1);for(let m=0;m<3;m++)i[s++]=g.x,i[s++]=g.y,i[s++]=g.z}return i}_convertToUnIndexedMesh(e=!1){const t=this.getVerticesDataKinds().filter(c=>!this.getVertexBuffer(c)?.getIsInstanced()),i=this.getIndices(),s={},r=(c,u)=>{const d=new Float32Array(i.length*u);let f=0;for(let g=0;g<i.length;g++)for(let m=0;m<u;m++)d[f++]=c[i[g]*u+m];return d},a=this.getBoundingInfo(),o=this.geometry?this.subMeshes.slice(0):[];for(const c of t)s[c]=this.getVerticesData(c);for(const c of t){const u=this.getVertexBuffer(c),d=u.getSize();if(e&&c===O.NormalKind){const f=this._getFlattenedNormals(i,s[O.PositionKind]);this.setVerticesData(O.NormalKind,f,u.isUpdatable(),d)}else this.setVerticesData(c,r(s[c],d),u.isUpdatable(),d)}if(this.morphTargetManager){for(let c=0;c<this.morphTargetManager.numTargets;c++){const u=this.morphTargetManager.getTarget(c),d=u.getPositions();u.setPositions(r(d,3));const f=u.getNormals();f&&u.setNormals(e?this._getFlattenedNormals(i,d):r(f,3));const g=u.getTangents();g&&u.setTangents(r(g,3));const m=u.getUVs();m&&u.setUVs(r(m,2));const b=u.getColors();b&&u.setColors(r(b,4))}this.morphTargetManager.synchronize()}for(let c=0;c<i.length;c++)i[c]=c;this.setIndices(i),this._unIndexed=!0,this.releaseSubMeshes();for(const c of o){const u=c.getBoundingInfo();As.AddToMesh(c.materialIndex,c.indexStart,c.indexCount,c.indexStart,c.indexCount,this).setBoundingInfo(u)}return this.setBoundingInfo(a),this.synchronizeInstances(),this}convertToFlatShadedMesh(){return this._convertToUnIndexedMesh(!0)}convertToUnIndexedMesh(){return this._convertToUnIndexedMesh()}flipFaces(e=!1){const t=ve.ExtractFromMesh(this);let i;if(e&&this.isVerticesDataPresent(O.NormalKind)&&t.normals){for(i=0;i<t.normals.length;i++)t.normals[i]*=-1;this.setVerticesData(O.NormalKind,t.normals,this.isVertexBufferUpdatable(O.NormalKind))}if(t.indices){let s;for(i=0;i<t.indices.length;i+=3)s=t.indices[i+1],t.indices[i+1]=t.indices[i+2],t.indices[i+2]=s;this.setIndices(t.indices,null,this.isVertexBufferUpdatable(O.PositionKind),!0)}return this}increaseVertices(e=1){const t=ve.ExtractFromMesh(this),i=t.indices&&!Array.isArray(t.indices)&&Array.from?Array.from(t.indices):t.indices,s=t.positions&&!Array.isArray(t.positions)&&Array.from?Array.from(t.positions):t.positions,r=t.uvs&&!Array.isArray(t.uvs)&&Array.from?Array.from(t.uvs):t.uvs,a=t.normals&&!Array.isArray(t.normals)&&Array.from?Array.from(t.normals):t.normals;if(!i||!s)oe.Warn("Couldn't increase number of vertices : VertexData must contain at least indices and positions");else{t.indices=i,t.positions=s,r&&(t.uvs=r),a&&(t.normals=a);const o=e+1,c=[];for(let R=0;R<o+1;R++)c[R]=[];let u,d;const f=new T(0,0,0),g=new T(0,0,0),m=new Ie(0,0),b=[],x=[],v=[];let E,A=s.length,D;r&&(D=r.length);let I;a&&(I=a.length);for(let R=0;R<i.length;R+=3){x[0]=i[R],x[1]=i[R+1],x[2]=i[R+2];for(let C=0;C<3;C++)if(u=x[C],d=x[(C+1)%3],v[u]===void 0&&v[d]===void 0?(v[u]=[],v[d]=[]):(v[u]===void 0&&(v[u]=[]),v[d]===void 0&&(v[d]=[])),v[u][d]===void 0&&v[d][u]===void 0){v[u][d]=[],f.x=(s[3*d]-s[3*u])/o,f.y=(s[3*d+1]-s[3*u+1])/o,f.z=(s[3*d+2]-s[3*u+2])/o,a&&(g.x=(a[3*d]-a[3*u])/o,g.y=(a[3*d+1]-a[3*u+1])/o,g.z=(a[3*d+2]-a[3*u+2])/o),r&&(m.x=(r[2*d]-r[2*u])/o,m.y=(r[2*d+1]-r[2*u+1])/o),v[u][d].push(u);for(let M=1;M<o;M++)v[u][d].push(s.length/3),s[A++]=s[3*u]+M*f.x,s[A++]=s[3*u+1]+M*f.y,s[A++]=s[3*u+2]+M*f.z,a&&(a[I++]=a[3*u]+M*g.x,a[I++]=a[3*u+1]+M*g.y,a[I++]=a[3*u+2]+M*g.z),r&&(r[D++]=r[2*u]+M*m.x,r[D++]=r[2*u+1]+M*m.y);v[u][d].push(d),v[d][u]=[],E=v[u][d].length;for(let M=0;M<E;M++)v[d][u][M]=v[u][d][E-1-M]}c[0][0]=i[R],c[1][0]=v[i[R]][i[R+1]][1],c[1][1]=v[i[R]][i[R+2]][1];for(let C=2;C<o;C++){c[C][0]=v[i[R]][i[R+1]][C],c[C][C]=v[i[R]][i[R+2]][C],f.x=(s[3*c[C][C]]-s[3*c[C][0]])/C,f.y=(s[3*c[C][C]+1]-s[3*c[C][0]+1])/C,f.z=(s[3*c[C][C]+2]-s[3*c[C][0]+2])/C,a&&(g.x=(a[3*c[C][C]]-a[3*c[C][0]])/C,g.y=(a[3*c[C][C]+1]-a[3*c[C][0]+1])/C,g.z=(a[3*c[C][C]+2]-a[3*c[C][0]+2])/C),r&&(m.x=(r[2*c[C][C]]-r[2*c[C][0]])/C,m.y=(r[2*c[C][C]+1]-r[2*c[C][0]+1])/C);for(let M=1;M<C;M++)c[C][M]=s.length/3,s[A++]=s[3*c[C][0]]+M*f.x,s[A++]=s[3*c[C][0]+1]+M*f.y,s[A++]=s[3*c[C][0]+2]+M*f.z,a&&(a[I++]=a[3*c[C][0]]+M*g.x,a[I++]=a[3*c[C][0]+1]+M*g.y,a[I++]=a[3*c[C][0]+2]+M*g.z),r&&(r[D++]=r[2*c[C][0]]+M*m.x,r[D++]=r[2*c[C][0]+1]+M*m.y)}c[o]=v[i[R+1]][i[R+2]],b.push(c[0][0],c[1][0],c[1][1]);for(let C=1;C<o;C++){let M;for(M=0;M<C;M++)b.push(c[C][M],c[C+1][M],c[C+1][M+1]),b.push(c[C][M],c[C+1][M+1],c[C][M+1]);b.push(c[C][M],c[C+1][M],c[C+1][M+1])}}t.indices=b,t.applyToMesh(this,this.isVertexBufferUpdatable(O.PositionKind))}}forceSharedVertices(){const e=ve.ExtractFromMesh(this),t=e.uvs,i=e.indices,s=e.positions,r=e.colors,a=e.matricesIndices,o=e.matricesWeights,c=e.matricesIndicesExtra,u=e.matricesWeightsExtra;if(i===void 0||s===void 0||i===null||s===null)oe.Warn("VertexData contains empty entries");else{const d=[],f=[],g=[],m=[],b=[],x=[],v=[],E=[];let A=[],D=0;const I={};let R,C;for(let F=0;F<i.length;F+=3){C=[i[F],i[F+1],i[F+2]],A=[];for(let U=0;U<3;U++){A[U]="";for(let k=0;k<3;k++)Math.abs(s[3*C[U]+k])<1e-8&&(s[3*C[U]+k]=0),A[U]+=s[3*C[U]+k]+"|"}if(!(A[0]==A[1]||A[0]==A[2]||A[1]==A[2]))for(let U=0;U<3;U++){if(R=I[A[U]],R===void 0){I[A[U]]=D,R=D++;for(let k=0;k<3;k++)d.push(s[3*C[U]+k]);if(r!=null)for(let k=0;k<4;k++)m.push(r[4*C[U]+k]);if(t!=null)for(let k=0;k<2;k++)g.push(t[2*C[U]+k]);if(a!=null)for(let k=0;k<4;k++)b.push(a[4*C[U]+k]);if(o!=null)for(let k=0;k<4;k++)x.push(o[4*C[U]+k]);if(c!=null)for(let k=0;k<4;k++)v.push(c[4*C[U]+k]);if(u!=null)for(let k=0;k<4;k++)E.push(u[4*C[U]+k])}f.push(R)}}const M=[];ve.ComputeNormals(d,f,M),e.positions=d,e.indices=f,e.normals=M,t!=null&&(e.uvs=g),r!=null&&(e.colors=m),a!=null&&(e.matricesIndices=b),o!=null&&(e.matricesWeights=x),c!=null&&(e.matricesIndicesExtra=v),o!=null&&(e.matricesWeightsExtra=E),e.applyToMesh(this,this.isVertexBufferUpdatable(O.PositionKind))}}static _instancedMeshFactory(e,t){throw We("InstancedMesh")}static _PhysicsImpostorParser(e,t,i){throw We("PhysicsImpostor")}createInstance(e){const t=Z._instancedMeshFactory(e,this);return t.parent=this.parent,t}synchronizeInstances(){for(let e=0;e<this.instances.length;e++)this.instances[e]._syncSubMeshes();return this}optimizeIndices(e){const t=this.getIndices(),i=this.getVerticesData(O.PositionKind);if(!i||!t)return this;const s=[];for(let a=0;a<i.length;a=a+3)s.push(T.FromArray(i,a));const r=[];return af.SyncAsyncForLoop(s.length,40,a=>{const o=s.length-1-a,c=s[o];for(let u=0;u<o;++u){const d=s[u];if(c.equals(d)){r[o]=u;break}}},()=>{for(let o=0;o<t.length;++o)t[o]=r[t[o]]||t[o];const a=this.subMeshes.slice(0);this.setIndices(t),this.subMeshes=a,e&&e(this)}),this}serialize(e={}){e.name=this.name,e.id=this.id,e.uniqueId=this.uniqueId,e.type=this.getClassName(),vt&&vt.HasTags(this)&&(e.tags=vt.GetTags(this)),e.position=this.position.asArray(),this.rotationQuaternion?e.rotationQuaternion=this.rotationQuaternion.asArray():this.rotation&&(e.rotation=this.rotation.asArray()),e.scaling=this.scaling.asArray(),this._postMultiplyPivotMatrix?e.pivotMatrix=this.getPivotMatrix().asArray():e.localMatrix=this.getPivotMatrix().asArray(),e.isEnabled=this.isEnabled(!1),e.isVisible=this.isVisible,e.infiniteDistance=this.infiniteDistance,e.pickable=this.isPickable,e.receiveShadows=this.receiveShadows,e.billboardMode=this.billboardMode,e.visibility=this.visibility,e.alwaysSelectAsActiveMesh=this.alwaysSelectAsActiveMesh,e.checkCollisions=this.checkCollisions,e.ellipsoid=this.ellipsoid.asArray(),e.ellipsoidOffset=this.ellipsoidOffset.asArray(),e.doNotSyncBoundingInfo=this.doNotSyncBoundingInfo,e.isBlocker=this.isBlocker,e.sideOrientation=this.sideOrientation,this.parent&&this.parent._serializeAsParent(e),e.isUnIndexed=this.isUnIndexed;const t=this._geometry;if(t&&this.subMeshes){e.geometryUniqueId=t.uniqueId,e.geometryId=t.id,e.subMeshes=[];for(let i=0;i<this.subMeshes.length;i++){const s=this.subMeshes[i];e.subMeshes.push({materialIndex:s.materialIndex,verticesStart:s.verticesStart,verticesCount:s.verticesCount,indexStart:s.indexStart,indexCount:s.indexCount})}}if(this.material?this.material.doNotSerialize||(e.materialUniqueId=this.material.uniqueId,e.materialId=this.material.id):(this.material=null,e.materialUniqueId=this._scene.defaultMaterial.uniqueId,e.materialId=this._scene.defaultMaterial.id),this.morphTargetManager&&(e.morphTargetManagerId=this.morphTargetManager.uniqueId),this.skeleton&&(e.skeletonId=this.skeleton.id,e.numBoneInfluencers=this.numBoneInfluencers),this.getScene()._getComponent(Ye.NAME_PHYSICSENGINE)){const i=this.getPhysicsImpostor();i&&(e.physicsMass=i.getParam("mass"),e.physicsFriction=i.getParam("friction"),e.physicsRestitution=i.getParam("mass"),e.physicsImpostor=i.type)}this.metadata&&(e.metadata=this.metadata),e.instances=[];for(let i=0;i<this.instances.length;i++){const s=this.instances[i];if(s.doNotSerialize)continue;const r={name:s.name,id:s.id,isEnabled:s.isEnabled(!1),isVisible:s.isVisible,isPickable:s.isPickable,checkCollisions:s.checkCollisions,position:s.position.asArray(),scaling:s.scaling.asArray()};if(s.parent&&s.parent._serializeAsParent(r),s.rotationQuaternion?r.rotationQuaternion=s.rotationQuaternion.asArray():s.rotation&&(r.rotation=s.rotation.asArray()),this.getScene()._getComponent(Ye.NAME_PHYSICSENGINE)){const a=s.getPhysicsImpostor();a&&(r.physicsMass=a.getParam("mass"),r.physicsFriction=a.getParam("friction"),r.physicsRestitution=a.getParam("mass"),r.physicsImpostor=a.type)}s.metadata&&(r.metadata=s.metadata),s.actionManager&&(r.actions=s.actionManager.serialize(s.name)),e.instances.push(r),$e.AppendSerializedAnimations(s,r),r.ranges=s.serializeAnimationRanges()}if(this._thinInstanceDataStorage.instancesCount&&this._thinInstanceDataStorage.matrixData&&(e.thinInstances={instancesCount:this._thinInstanceDataStorage.instancesCount,matrixData:Array.from(this._thinInstanceDataStorage.matrixData),matrixBufferSize:this._thinInstanceDataStorage.matrixBufferSize,enablePicking:this.thinInstanceEnablePicking},this._userThinInstanceBuffersStorage)){const i={data:{},sizes:{},strides:{}};for(const s in this._userThinInstanceBuffersStorage.data)i.data[s]=Array.from(this._userThinInstanceBuffersStorage.data[s]),i.sizes[s]=this._userThinInstanceBuffersStorage.sizes[s],i.strides[s]=this._userThinInstanceBuffersStorage.strides[s];e.thinInstances.userThinInstance=i}return $e.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.layerMask=this.layerMask,e.alphaIndex=this.alphaIndex,e.hasVertexAlpha=this.hasVertexAlpha,e.overlayAlpha=this.overlayAlpha,e.overlayColor=this.overlayColor.asArray(),e.renderOverlay=this.renderOverlay,e.applyFog=this.applyFog,this.actionManager&&(e.actions=this.actionManager.serialize(this.name)),e}_syncGeometryWithMorphTargetManager(){if(!this.geometry)return;this._markSubMeshesAsAttributesDirty();const e=this._internalAbstractMeshDataInfo._morphTargetManager;if(e&&e.vertexCount){if(e.vertexCount!==this.getTotalVertices()){oe.Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count."),this.morphTargetManager=null;return}if(e.isUsingTextureForTargets)return;for(let t=0;t<e.numInfluencers;t++){const i=e.getActiveTarget(t),s=i.getPositions();if(!s){oe.Error("Invalid morph target. Target must have positions.");return}this.geometry.setVerticesData(O.PositionKind+t,s,!1,3);const r=i.getNormals();r&&this.geometry.setVerticesData(O.NormalKind+t,r,!1,3);const a=i.getTangents();a&&this.geometry.setVerticesData(O.TangentKind+t,a,!1,3);const o=i.getUVs();o&&this.geometry.setVerticesData(O.UVKind+"_"+t,o,!1,2);const c=i.getUV2s();c&&this.geometry.setVerticesData(O.UV2Kind+"_"+t,c,!1,2);const u=i.getColors();u&&this.geometry.setVerticesData(O.ColorKind+t,u,!1,4)}}else{let t=0;for(;this.geometry.isVerticesDataPresent(O.PositionKind+t);)this.geometry.removeVerticesData(O.PositionKind+t),this.geometry.isVerticesDataPresent(O.NormalKind+t)&&this.geometry.removeVerticesData(O.NormalKind+t),this.geometry.isVerticesDataPresent(O.TangentKind+t)&&this.geometry.removeVerticesData(O.TangentKind+t),this.geometry.isVerticesDataPresent(O.UVKind+t)&&this.geometry.removeVerticesData(O.UVKind+"_"+t),this.geometry.isVerticesDataPresent(O.UV2Kind+t)&&this.geometry.removeVerticesData(O.UV2Kind+"_"+t),this.geometry.isVerticesDataPresent(O.ColorKind+t)&&this.geometry.removeVerticesData(O.ColorKind+t),t++}}static Parse(e,t,i){let s;if(e.type&&e.type==="LinesMesh"?s=Z._LinesMeshParser(e,t):e.type&&e.type==="GroundMesh"?s=Z._GroundMeshParser(e,t):e.type&&e.type==="GoldbergMesh"?s=Z._GoldbergMeshParser(e,t):e.type&&e.type==="GreasedLineMesh"?s=Z._GreasedLineMeshParser(e,t):e.type&&e.type==="TrailMesh"?s=Z._TrailMeshParser(e,t):s=new Z(e.name,t),s.id=e.id,s._waitingParsedUniqueId=e.uniqueId,vt&&vt.AddTagsTo(s,e.tags),s.position=T.FromArray(e.position),e.metadata!==void 0&&(s.metadata=e.metadata),e.rotationQuaternion?s.rotationQuaternion=Se.FromArray(e.rotationQuaternion):e.rotation&&(s.rotation=T.FromArray(e.rotation)),s.scaling=T.FromArray(e.scaling),e.localMatrix?s.setPreTransformMatrix(W.FromArray(e.localMatrix)):e.pivotMatrix&&s.setPivotMatrix(W.FromArray(e.pivotMatrix)),s.setEnabled(e.isEnabled),s.isVisible=e.isVisible,s.infiniteDistance=e.infiniteDistance,s.alwaysSelectAsActiveMesh=!!e.alwaysSelectAsActiveMesh,s.showBoundingBox=e.showBoundingBox,s.showSubMeshesBoundingBox=e.showSubMeshesBoundingBox,e.applyFog!==void 0&&(s.applyFog=e.applyFog),e.pickable!==void 0&&(s.isPickable=e.pickable),e.alphaIndex!==void 0&&(s.alphaIndex=e.alphaIndex),s.receiveShadows=e.receiveShadows,e.billboardMode!==void 0&&(s.billboardMode=e.billboardMode),e.visibility!==void 0&&(s.visibility=e.visibility),s.checkCollisions=e.checkCollisions,s.doNotSyncBoundingInfo=!!e.doNotSyncBoundingInfo,e.ellipsoid&&(s.ellipsoid=T.FromArray(e.ellipsoid)),e.ellipsoidOffset&&(s.ellipsoidOffset=T.FromArray(e.ellipsoidOffset)),e.overrideMaterialSideOrientation!=null&&(s.sideOrientation=e.overrideMaterialSideOrientation),e.sideOrientation!==void 0&&(s.sideOrientation=e.sideOrientation),e.isBlocker!==void 0&&(s.isBlocker=e.isBlocker),s._shouldGenerateFlatShading=e.useFlatShading,e.freezeWorldMatrix&&(s._waitingData.freezeWorldMatrix=e.freezeWorldMatrix),e.parentId!==void 0&&(s._waitingParentId=e.parentId),e.parentInstanceIndex!==void 0&&(s._waitingParentInstanceIndex=e.parentInstanceIndex),e.actions!==void 0&&(s._waitingData.actions=e.actions),e.overlayAlpha!==void 0&&(s.overlayAlpha=e.overlayAlpha),e.overlayColor!==void 0&&(s.overlayColor=Ne.FromArray(e.overlayColor)),e.renderOverlay!==void 0&&(s.renderOverlay=e.renderOverlay),s.isUnIndexed=!!e.isUnIndexed,s.hasVertexAlpha=e.hasVertexAlpha,e.delayLoadingFile?(s.delayLoadState=4,s.delayLoadingFile=i+e.delayLoadingFile,s.buildBoundingInfo(T.FromArray(e.boundingBoxMinimum),T.FromArray(e.boundingBoxMaximum)),e._binaryInfo&&(s._binaryInfo=e._binaryInfo),s._delayInfo=[],e.hasUVs&&s._delayInfo.push(O.UVKind),e.hasUVs2&&s._delayInfo.push(O.UV2Kind),e.hasUVs3&&s._delayInfo.push(O.UV3Kind),e.hasUVs4&&s._delayInfo.push(O.UV4Kind),e.hasUVs5&&s._delayInfo.push(O.UV5Kind),e.hasUVs6&&s._delayInfo.push(O.UV6Kind),e.hasColors&&s._delayInfo.push(O.ColorKind),e.hasMatricesIndices&&s._delayInfo.push(O.MatricesIndicesKind),e.hasMatricesWeights&&s._delayInfo.push(O.MatricesWeightsKind),s._delayLoadingFunction=ps._ImportGeometry,bi.ForceFullSceneLoadingForIncremental&&s._checkDelayState()):ps._ImportGeometry(e,s),e.materialUniqueId?s._waitingMaterialId=e.materialUniqueId:e.materialId&&(s._waitingMaterialId=e.materialId),e.morphTargetManagerId>-1&&(s._waitingMorphTargetManagerId=e.morphTargetManagerId),e.skeletonId!==void 0&&e.skeletonId!==null&&(s.skeleton=t.getLastSkeletonById(e.skeletonId),e.numBoneInfluencers&&(s.numBoneInfluencers=e.numBoneInfluencers)),e.animations){for(let r=0;r<e.animations.length;r++){const a=e.animations[r],o=Kr("BABYLON.Animation");o&&s.animations.push(o.Parse(a))}yi.ParseAnimationRanges(s,e,t)}if(e.autoAnimate&&t.beginAnimation(s,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),e.layerMask&&!isNaN(e.layerMask)?s.layerMask=Math.abs(parseInt(e.layerMask)):s.layerMask=268435455,e.physicsImpostor&&(s.physicsImpostor=Z._PhysicsImpostorParser(t,s,e)),e.lodMeshIds&&(s._waitingData.lods={ids:e.lodMeshIds,distances:e.lodDistances?e.lodDistances:null,coverages:e.lodCoverages?e.lodCoverages:null}),e.instances)for(let r=0;r<e.instances.length;r++){const a=e.instances[r],o=s.createInstance(a.name);if(a.id&&(o.id=a.id),vt&&(a.tags?vt.AddTagsTo(o,a.tags):vt.AddTagsTo(o,e.tags)),o.position=T.FromArray(a.position),a.metadata!==void 0&&(o.metadata=a.metadata),a.parentId!==void 0&&(o._waitingParentId=a.parentId),a.parentInstanceIndex!==void 0&&(o._waitingParentInstanceIndex=a.parentInstanceIndex),a.isEnabled!==void 0&&a.isEnabled!==null&&o.setEnabled(a.isEnabled),a.isVisible!==void 0&&a.isVisible!==null&&(o.isVisible=a.isVisible),a.isPickable!==void 0&&a.isPickable!==null&&(o.isPickable=a.isPickable),a.rotationQuaternion?o.rotationQuaternion=Se.FromArray(a.rotationQuaternion):a.rotation&&(o.rotation=T.FromArray(a.rotation)),o.scaling=T.FromArray(a.scaling),a.checkCollisions!=null&&a.checkCollisions!=null&&(o.checkCollisions=a.checkCollisions),a.pickable!=null&&a.pickable!=null&&(o.isPickable=a.pickable),a.showBoundingBox!=null&&a.showBoundingBox!=null&&(o.showBoundingBox=a.showBoundingBox),a.showSubMeshesBoundingBox!=null&&a.showSubMeshesBoundingBox!=null&&(o.showSubMeshesBoundingBox=a.showSubMeshesBoundingBox),a.alphaIndex!=null&&a.showSubMeshesBoundingBox!=null&&(o.alphaIndex=a.alphaIndex),a.physicsImpostor&&(o.physicsImpostor=Z._PhysicsImpostorParser(t,o,a)),a.actions!==void 0&&(o._waitingData.actions=a.actions),a.animations){for(let c=0;c<a.animations.length;c++){const u=a.animations[c],d=Kr("BABYLON.Animation");d&&o.animations.push(d.Parse(u))}yi.ParseAnimationRanges(o,a,t),a.autoAnimate&&t.beginAnimation(o,a.autoAnimateFrom,a.autoAnimateTo,a.autoAnimateLoop,a.autoAnimateSpeed||1)}}if(e.thinInstances){const r=e.thinInstances;if(s.thinInstanceEnablePicking=!!r.enablePicking,r.matrixData?(s.thinInstanceSetBuffer("matrix",new Float32Array(r.matrixData),16,!1),s._thinInstanceDataStorage.matrixBufferSize=r.matrixBufferSize,s._thinInstanceDataStorage.instancesCount=r.instancesCount):s._thinInstanceDataStorage.matrixBufferSize=r.matrixBufferSize,e.thinInstances.userThinInstance){const a=e.thinInstances.userThinInstance;for(const o in a.data)s.thinInstanceSetBuffer(o,new Float32Array(a.data[o]),a.strides[o],!1),s._userThinInstanceBuffersStorage.sizes[o]=a.sizes[o]}}return s}setPositionsForCPUSkinning(){const e=this._internalMeshDataInfo;if(!e._sourcePositions){const t=this.getVerticesData(O.PositionKind);if(!t)return e._sourcePositions;e._sourcePositions=new Float32Array(t),this.isVertexBufferUpdatable(O.PositionKind)||this.setVerticesData(O.PositionKind,t,!0)}return e._sourcePositions}setNormalsForCPUSkinning(){const e=this._internalMeshDataInfo;if(!e._sourceNormals){const t=this.getVerticesData(O.NormalKind);if(!t)return e._sourceNormals;e._sourceNormals=new Float32Array(t),this.isVertexBufferUpdatable(O.NormalKind)||this.setVerticesData(O.NormalKind,t,!0)}return e._sourceNormals}applySkeleton(e){if(!this.geometry)return this;if(this.geometry._softwareSkinningFrameId==this.getScene().getFrameId())return this;if(this.geometry._softwareSkinningFrameId=this.getScene().getFrameId(),!this.isVerticesDataPresent(O.PositionKind))return this;if(!this.isVerticesDataPresent(O.MatricesIndicesKind))return this;if(!this.isVerticesDataPresent(O.MatricesWeightsKind))return this;const t=this.isVerticesDataPresent(O.NormalKind),i=this._internalMeshDataInfo;if(!i._sourcePositions){const E=this.subMeshes.slice();this.setPositionsForCPUSkinning(),this.subMeshes=E}t&&!i._sourceNormals&&this.setNormalsForCPUSkinning();let s=this.getVerticesData(O.PositionKind);if(!s)return this;s instanceof Float32Array||(s=new Float32Array(s));let r=this.getVerticesData(O.NormalKind);if(t){if(!r)return this;r instanceof Float32Array||(r=new Float32Array(r))}const a=this.getVerticesData(O.MatricesIndicesKind),o=this.getVerticesData(O.MatricesWeightsKind);if(!o||!a)return this;const c=this.numBoneInfluencers>4,u=c?this.getVerticesData(O.MatricesIndicesExtraKind):null,d=c?this.getVerticesData(O.MatricesWeightsExtraKind):null,f=e.getTransformMatrices(this),g=T.Zero(),m=new W,b=new W;let x=0,v;for(let E=0;E<s.length;E+=3,x+=4){let A;for(v=0;v<4;v++)A=o[x+v],A>0&&(W.FromFloat32ArrayToRefScaled(f,Math.floor(a[x+v]*16),A,b),m.addToSelf(b));if(c)for(v=0;v<4;v++)A=d[x+v],A>0&&(W.FromFloat32ArrayToRefScaled(f,Math.floor(u[x+v]*16),A,b),m.addToSelf(b));T.TransformCoordinatesFromFloatsToRef(i._sourcePositions[E],i._sourcePositions[E+1],i._sourcePositions[E+2],m,g),g.toArray(s,E),t&&(T.TransformNormalFromFloatsToRef(i._sourceNormals[E],i._sourceNormals[E+1],i._sourceNormals[E+2],m,g),g.toArray(r,E)),m.reset()}return this.updateVerticesData(O.PositionKind,s),t&&this.updateVerticesData(O.NormalKind,r),this}static MinMax(e){let t=null,i=null;for(const s of e){const a=s.getBoundingInfo().boundingBox;!t||!i?(t=a.minimumWorld.clone(),i=a.maximumWorld.clone()):(t.minimizeInPlace(a.minimumWorld),i.maximizeInPlace(a.maximumWorld))}return!t||!i?{min:T.Zero(),max:T.Zero()}:{min:t,max:i}}static Center(e){const t=e instanceof Array?Z.MinMax(e):e;return T.Center(t.min,t.max)}static MergeMeshes(e,t=!0,i,s,r,a){return Ob(Z._MergeMeshesCoroutine(e,t,i,s,r,a,!1))}static async MergeMeshesAsync(e,t=!0,i,s,r,a){return await Ak(Z._MergeMeshesCoroutine(e,t,i,s,r,a,!0),Ek())}static*_MergeMeshesCoroutine(e,t=!0,i,s,r,a,o){if(e=e.filter(Boolean),e.length===0)return null;let c;if(!i){let M=0;for(c=0;c<e.length;c++)if(M+=e[c].getTotalVertices(),M>=65536)return oe.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}a&&(r=!1);const u=new Array,d=new Array,f=new Array,g=e[0].sideOrientation;for(c=0;c<e.length;c++){const M=e[c];if(M.isAnInstance)return oe.Warn("Cannot merge instance meshes."),null;if(g!==M.sideOrientation)return oe.Warn("Cannot merge meshes with different sideOrientation values."),null;if(r&&f.push({start:0,count:M.getTotalIndices()}),a){const F=f.reduce((U,k)=>Math.max(U,k.start+k.count),0);if(M.material){const U=M.material;if(U instanceof oc){for(let k=0;k<U.subMaterials.length;k++)u.indexOf(U.subMaterials[k])<0&&u.push(U.subMaterials[k]);for(let k=0;k<M.subMeshes.length;k++)d.push(u.indexOf(U.subMaterials[M.subMeshes[k].materialIndex])),f.pu
vendor: 1,337 bytes, line 238
238sh({start:F+M.subMeshes[k].indexStart,count:M.subMeshes[k].indexCount})}else{u.indexOf(U)<0&&u.push(U);for(let k=0;k<M.subMeshes.length;k++)d.push(u.indexOf(U)),f.push({start:F+M.subMeshes[k].indexStart,count:M.subMeshes[k].indexCount})}}else for(let U=0;U<M.subMeshes.length;U++)d.push(0),f.push({start:F+M.subMeshes[U].indexStart,count:M.subMeshes[U].indexCount})}}const m=e[0],b=M=>{const F=M.computeWorldMatrix(!0);return{vertexData:ve.ExtractFromMesh(M,!1,!1),transform:F}},{vertexData:x,transform:v}=b(m);o&&(yield);const E=new Array(e.length-1);for(let M=1;M<e.length;M++)E[M-1]=b(e[M]),o&&(yield);const A=x._mergeCoroutine(v,E,i,o,!t);let D=A.next();for(;!D.done;)o&&(yield),D=A.next();const I=D.value;s||(s=new Z(m.name+"_merged",m.getScene()));const R=I._applyToCoroutine(s,void 0,o);let C=R.next();for(;!C.done;)o&&(yield),C=R.next();if(s.checkCollisions=m.checkCollisions,s.sideOrientation=m.sideOrientation,t)for(c=0;c<e.length;c++)e[c].dispose();if(r||a){for(s.releaseSubMeshes(),c=0;c<f.length;)As.CreateFromIndices(0,f[c].start,f[c].count,s,void 0,!1),c++;for(const M of s.subMeshes)M.refreshBoundingInfo();s.computeWorldMatrix(!0)}if(a){const M=new oc(m.name+"_merged",m.getScene());M.subMaterials=u;for(let F=0;F<s.subMeshes.length;F++)s.subMeshes[F].materialIndex=d[F];s.material=M}else s.material=m.material;return s}
238addInstance(e){e._indexInSourceMeshInstanceArray=this.instances.length,this.instances.push(e)}removeInstance(e){const t=e._indexInSourceMeshInstanceArray;if(t!=-1){if(t!==this.instances.length-1){const i=this.instances[this.instances.length-1];this.instances[t]=i,i._indexInSourceMeshInstanceArray=t}e._indexInSourceMeshInstanceArray=-1,this.instances.pop()}}_shouldConvertRHS(){return this._scene.useRightHandedSystem&&this.sideOrientation===fe.CounterClockWiseSideOrientation}_getRenderingFillMode(e){const t=this.getScene();return t.forcePointsCloud?fe.PointFillMode:t.forceWireframe?fe.WireFrameFillMode:this.overrideRenderingFillMode??e}setMaterialByID(e){return this.setMaterialById(e)}static CreateRibbon(e,t,i,s,r,a,o,c,u){throw new Error("Import MeshBuilder to populate this function")}static CreateDisc(e,t,i,s,r,a){throw new Error("Import MeshBuilder to populate this function")}static CreateBox(e,t,i,s,r){throw new Error("Import MeshBuilder to populate this function")}static CreateSphere(e,t,i,s,r,a){throw new Error("Import MeshBuilder to populate this function")}static CreateHemisphere(e,t,i,s){throw new Error("Import MeshBuilder to populate this function")}static CreateCylinder(e,t,i,s,r,a,o,c,u){throw new Error("Import MeshBuilder to populate this function")}static CreateTorus(e,t,i,s,r,a,o){throw new Error("Import MeshBuilder to populate this function")}static CreateTorusKnot(e,t,i,s,r,a,o,c,u,d){throw new Error("Import MeshBuilder to populate this function")}static CreateLines(e,t,i,s,r){throw new Error("Import MeshBuilder to populate this function")}static CreateDashedLines(e,t,i,s,r,a,o,c){throw new Error("Import MeshBuilder to populate this function")}static CreatePolygon(e,t,i,s,r,a,o){throw new Error("Import MeshBuilder to populate this function")}static ExtrudePolygon(e,t,i,s,r,a,o,c){throw new Error("Import MeshBuilder to populate this function")}static ExtrudeShape(e,t,i,s,r,a,o,c,u,d){throw new Error("Import MeshBuilder to populate this function")}static ExtrudeShapeCustom(e,t,i,s,r,a,o,c,u,d,f,g){throw new Error("Import MeshBuilder to populate this function")}static CreateLathe(e,t,i,s,r,a,o){throw new Error("Import MeshBuilder to populate this function")}static CreatePlane(e,t,i,s,r){throw new Error("Import MeshBuilder to populate this function")}static CreateGround(e,t,i,s,r,a){throw new Error("Import MeshBuilder to populate this function")}static CreateTiledGround(e,t,i,s,r,a,o,c,u){throw new Error("Import MeshBuilder to populate this function")}static CreateGroundFromHeightMap(e,t,i,s,r,a,o,c,u,d,f){throw new Error("Import MeshBuilder to populate this function")}static CreateTube(e,t,i,s,r,a,o,c,u,d){throw new Error("Import MeshBuilder to populate this function")}static CreatePolyhedron(e,t,i){throw new Error("Import MeshBuilder to populate this function")}static CreateIcoSphere(e,t,i){throw new Error("Import MeshBuilder to populate this function")}static CreateDecal(e,t,i,s,r,a){throw new Error("Import MeshBuilder to populate this function")}static CreateCapsule(e,t,i){throw new Error("Import MeshBuilder to populate this function")}static ExtendToGoldberg(e){throw new Error("Import MeshBuilder to populate this function")}}Z.FRONTSIDE=ve.FRONTSIDE;Z.BACKSIDE=ve.BACKSIDE;Z.DOUBLESIDE=ve.DOUBLESIDE;Z.DEFAULTSIDE=ve.DEFAULTSIDE;Z.NO_CAP=0;Z.CAP_START=1;Z.CAP_END=2;Z.CAP_ALL=3;Z.NO_FLIP=0;Z.FLIP_TILE=1;Z.ROTATE_TILE=2;Z.FLIP_ROW=3;Z.ROTATE_ROW=4;Z.FLIP_N_ROTATE_TILE=5;Z.FLIP_N_ROTATE_ROW=6;Z.CENTER=0;Z.LEFT=1;Z.RIGHT=2;Z.TOP=3;Z.BOTTOM=4;Z.INSTANCEDMESH_SORT_TRANSPARENT=!1;Z._GroundMeshParser=(n,e)=>{throw We("GroundMesh")};Z._GoldbergMeshParser=(n,e)=>{throw We("GoldbergMesh")};Z._LinesMeshParser=(n,e)=>{throw We("LinesMesh")};Z._GreasedLineMeshParser=(n,e)=>{throw We("GreasedLineMesh")};Z._GreasedLineRibbonMeshParser=(n,e)=>{throw We("GreasedLineRibbonMesh")};Z._TrailMeshParser=(n,e)=>{throw We("TrailMesh")};Tt("BABYLON.Mesh",Z);function UC(n){let e=n.pathArray;const t=n.closeArray||!1,i=n.closePath||!1,s=n.invertUV||!1,r=Math.floor(e[0].length/2);let a=n.offset||r;a=a>r?r:Math.floor(a);const o=n.sideOrientation===0?0:n.sideOrientation||ve.DEFAULTSIDE,c=n.uvs,u=n.colors,d=[],f=[],g=[],m=[],b=[],x=[],v=[],E=[];let A;const D=[],I=[];let R,C,M;if(e.length<2){const Oe=[],Qe=[];for(C=0;C<e[0].length-a;C++)Oe.push(e[0][C]),Qe.push(e[0][C+a]);e=[Oe,Qe]}let F=0;const U=i?1:0,k=t?1:0;let q,Q;A=e[0].length;let ie,$;for(R=0;R<e.length+k;R++){for(v[R]=0,b[R]=[0],q=R===e.length?e[0]:e[R],Q=q.length,A=A<Q?A:Q,M=0;M<Q;)d.push(q[M].x,q[M].y,q[M].z),M>0&&(ie=q[M].subtract(q[M-1]).length(),$=ie+v[R],b[R].push($),v[R]=$),M++;i&&(M--,d.push(q[0].x,q[0].y,q[0].z),ie=q[M].subtract(q[0]).length(),$=ie+v[R],b[R].push($),v[R]=$),D[R]=Q+U,I[R]=F,F+=Q+U}let ce,G,K=null,X=null;for(C=0;C<A+U;C++)for(E[C]=0,x[C]=[0],R=0;R<e.length-1+k;R++)ce=e[R],G=R===e.length-1?e[0]:e[R+1],C===A?(K=ce[0],X=G[0]):(K=ce[C],X=G[C]),ie=X.subtract(K).length(),$=ie+E[C],x[C].push($),E[C]=$;let J,se;if(c)for(R=0;R<c.length;R++)m.push(c[R].x,c[R].y);else for(R=0;R<e.length+k;R++)for(C=0;C<A+U;C++)J=v[R]!=0?b[R][C]/v[R]:0,se=E[C]!=0?x[C][R]/E[C]:0,s?m.push(se,J):m.push(J,se);R=0;let w=0,L=D[R]-1,V=D[R+1]-1,j=L<V?L:V,ae=I[1]-I[0];const he=D.length-1;for(;w<=j&&R<he;)f.push(w,w+ae,w+1),f.push(w+ae+1,w+1,w+ae),w+=1,w===j&&(R++,ae=I[R+1]-I[R],L=D[R]-1,V=D[R+1]-1,w=I[R],j=L<V?L+w:V+w);if(ve.ComputeNormals(d,f,g),i){let Oe=0,Qe=0;for(R=0;R<e.length;R++){Oe=I[R]*3,R+1<e.length?Qe=(I[R+1]-1)*3:Qe=g.length-3,g[Oe]=(g[Oe]+g[Qe])*.5,g[Oe+1]=(g[Oe+1]+g[Qe+1])*.5,g[Oe+2]=(g[Oe+2]+g[Qe+2])*.5;const Be=Math.sqrt(g[Oe]*g[Oe]+g[Oe+1]*g[Oe+1]+g[Oe+2]*g[Oe+2]);g[Oe]/=Be,g[Oe+1]/=Be,g[Oe+2]/=Be,g[Qe]=g[Oe],g[Qe+1]=g[Oe+1],g[Qe+2]=g[Oe+2]}}if(t){let Oe=I[0]*3,Qe=I[e.length]*3;for(C=0;C<A+U;C++){g[Oe]=(g[Oe]+g[Qe])*.5,g[Oe+1]=(g[Oe+1]+g[Qe+1])*.5,g[Oe+2]=(g[Oe+2]+g[Qe+2])*.5;const Be=Math.sqrt(g[Oe]*g[Oe]+g[Oe+1]*g[Oe+1]+g[Oe+2]*g[Oe+2]);g[Oe]/=Be,g[Oe+1]/=Be,g[Oe+2]/=Be,g[Qe]=g[Oe],g[Qe+1]=g[Oe+1],g[Qe+2]=g[Oe+2],Oe+=3,Qe+=3}}ve._ComputeSides(o,d,f,g,m,n.frontUVs,n.backUVs);let be=null;
238if(u){be=new Float32Array(u.length*4);for(let Oe=0;Oe<u.length;Oe++)be[Oe*4]=u[Oe].r,be[Oe*4+1]=u[Oe].g,be[Oe*4+2]=u[Oe].b,be[Oe*4+3]=u[Oe].a}const Le=new ve,Xe=new Float32Array(d),it=new Float32Array(g),ut=new Float32Array(m);return Le.indices=f,Le.positions=Xe,Le.normals=it,Le.uvs=ut,be&&Le.set(be,O.ColorKind),i&&(Le._idx=I),Le}function Ho(n,e,t=null){const i=e.pathArray,s=e.closeArray,r=e.closePath,a=Z._GetDefaultSideOrientation(e.sideOrientation),o=e.instance,c=e.updatable;if(o){const u=te.Vector3[0].setAll(Number.MAX_VALUE),d=te.Vector3[1].setAll(-Number.MAX_VALUE),f=m=>{let b=i[0].length;const x=o;let v=0;const E=x._originalBuilderSideOrientation===Z.DOUBLESIDE?2:1;for(let A=1;A<=E;++A)for(let D=0;D<i.length;++D){const I=i[D],R=I.length;b=b<R?b:R;for(let C=0;C<b;++C){const M=I[C];m[v]=M.x,m[v+1]=M.y,m[v+2]=M.z,u.minimizeInPlaceFromFloats(M.x,M.y,M.z),d.maximizeInPlaceFromFloats(M.x,M.y,M.z),v+=3}if(x._creationDataStorage&&x._creationDataStorage.closePath){const C=I[0];m[v]=C.x,m[v+1]=C.y,m[v+2]=C.z,v+=3}}},g=o.getVerticesData(O.PositionKind);if(f(g),o.hasBoundingInfo?o.getBoundingInfo().reConstruct(u,d,o._worldMatrix):o.buildBoundingInfo(u,d,o._worldMatrix),o.updateVerticesData(O.PositionKind,g,!1,!1),e.colors){const m=o.getVerticesData(O.ColorKind);for(let b=0,x=0;b<e.colors.length;b++,x+=4){const v=e.colors[b];m[x]=v.r,m[x+1]=v.g,m[x+2]=v.b,m[x+3]=v.a}o.updateVerticesData(O.ColorKind,m,!1,!1)}if(e.uvs){const m=o.getVerticesData(O.UVKind);for(let b=0;b<e.uvs.length;b++)m[b*2]=e.uvs[b].x,m[b*2+1]=e.uvs[b].y;o.updateVerticesData(O.UVKind,m,!1,!1)}if(!o.areNormalsFrozen||o.isFacetDataEnabled){const m=o.getIndices(),b=o.getVerticesData(O.NormalKind),x=o.isFacetDataEnabled?o.getFacetDataParameters():null;if(ve.ComputeNormals(g,m,b,x),o._creationDataStorage&&o._creationDataStorage.closePath){let v=0,E=0;for(let A=0;A<i.length;A++)v=o._creationDataStorage.idx[A]*3,A+1<i.length?E=(o._creationDataStorage.idx[A+1]-1)*3:E=b.length-3,b[v]=(b[v]+b[E])*.5,b[v+1]=(b[v+1]+b[E+1])*.5,b[v+2]=(b[v+2]+b[E+2])*.5,b[E]=b[v],b[E+1]=b[v+1],b[E+2]=b[v+2]}o.areNormalsFrozen||o.updateVerticesData(O.NormalKind,b,!1,!1)}return o}else{const u=new Z(n,t);u._originalBuilderSideOrientation=a,u._creationDataStorage=new BC;const d=UC(e);return r&&(u._creationDataStorage.idx=d._idx),u._creationDataStorage.closePath=r,u._creationDataStorage.closeArray=s,d.applyToMesh(u,c),u}}ve.CreateRibbon=UC;Z.CreateRibbon=(n,e,t=!1,i,s,r,a=!1,o,c)=>Ho(n,{pathArray:e,closeArray:t,closePath:i,offset:s,updatable:a,sideOrientation:o,instance:c},r);function kC(n){const e=[],t=[],i=[],s=[],r=n.radius||.5,a=n.tessellation||64,o=n.arc&&(n.arc<=0||n.arc>1)?1:n.arc||1,c=n.sideOrientation===0?0:n.sideOrientation||ve.DEFAULTSIDE;e.push(0,0,0),s.push(.5,.5);const u=Math.PI*2*o,d=o===1?u/a:u/(a-1);let f=0;for(let b=0;b<a;b++){const x=Math.cos(f),v=Math.sin(f),E=(x+1)/2,A=(1-v)/2;e.push(r*x,r*v,0),s.push(E,A),f+=d}o===1&&(e.push(e[3],e[4],e[5]),s.push(s[2],s[3]));const g=e.length/3;for(let b=1;b<g-1;b++)t.push(b+1,0,b);ve.ComputeNormals(e,t,i),ve._ComputeSides(c,e,t,i,s,n.frontUVs,n.backUVs);const m=new ve;return m.indices=t,m.positions=e,m.normals=i,m.uvs=s,m}function VC(n,e={},t=null){const i=new Z(n,t);return e.sideOrientation=Z._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,kC(e).applyToMesh(i,e.updatable),i}ve.CreateDisc=kC;Z.CreateDisc=(n,e,t,i=null,s,r)=>VC(n,{radius:e,tessellation:t,sideOrientation:r,updatable:s},i);Z._GroundMeshParser=(n,e)=>Jh.Parse(n,e);class Jh extends Z{constructor(e,t){super(e,t),this.generateOctree=!1}getClassName(){return"GroundMesh"}get subdivisions(){return Math.min(this._subdivisionsX,this._subdivisionsY)}get subdivisionsX(){return this._subdivisionsX}get subdivisionsY(){return this._subdivisionsY}optimize(e,t=32){this._subdivisionsX=e,this._subdivisionsY=e,this.subdivide(e);const i=this;i.createOrUpdateSubmeshesOctree&&i.createOrUpdateSubmeshesOctree(t)}getHeightAtCoordinates(e,t){const i=this.getWorldMatrix(),s=te.Matrix[5];i.invertToRef(s);const r=te.Vector3[8];if(T.TransformCoordinatesFromFloatsToRef(e,0,t,s,r),e=r.x,t=r.z,e<this._minX||e>=this._maxX||t<=this._minZ||t>this._maxZ)return this.position.y;(!this._heightQuads||this._heightQuads.length==0)&&(this._initHeightQuads(),this._computeHeightQuads());const a=this._getFacetAt(e,t),o=-(a.x*e+a.z*t+a.w)/a.y;return T.TransformCoordinatesFromFloatsToRef(0,o,0,i,r),r.y}getNormalAtCoordinates(e,t){const i=new T(0,1,0);return this.getNormalAtCoordinatesToRef(e,t,i),i}getNormalAtCoordinatesToRef(e,t,i){const s=this.getWorldMatrix(),r=te.Matrix[5];s.invertToRef(r);const a=te.Vector3[8];if(T.TransformCoordinatesFromFloatsToRef(e,0,t,r,a),e=a.x,t=a.z,e<this._minX||e>this._maxX||t<this._minZ||t>this._maxZ)return this;(!this._heightQuads||this._heightQuads.length==0)&&(this._initHeightQuads(),this._computeHeightQuads());const o=this._getFacetAt(e,t);return T.TransformNormalFromFloatsToRef(o.x,o.y,o.z,s,i),this}updateCoordinateHeights(){return(!this._heightQuads||this._heightQuads.length==0)&&this._initHeightQuads(),this._computeHeightQuads(),this}_getFacetAt(e,t){const i=Math.floor((e+this._maxX)*this._subdivisionsX/this._width),s=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),r=this._heightQuads[s*this._subdivisionsX+i];let a;return t<r.slope.x*e+r.slope.y?a=r.facet1:a=r.facet2,a}_initHeightQuads(){const e=this._subdivisionsX,t=this._subdivisionsY;this._heightQuads=[];for(let i=0;i<t;i++)for(let s=0;s<e;s++){const r={slope:Ie.Zero(),facet1:new rt(0,0,0,0),facet2:new rt(0,0,0,0)};this._heightQuads[i*e+s]=r}return this}_computeHeightQuads(){const e=this.getVerticesData(O.PositionKind);if(!e)return this;const t=te.Vector3[3],i=te.Vector3[2],s=te.Vector3[1],r=te.Vector3[0],a=te.Vector3[4],o=te.Vector3[5],c=te.Vector3[6],u=te.Vector3[7],d=te.Vector3[8];let f=0,g=0,m=0,b=0,x=0,v=0,E=0;const A=this._subdivisionsX,D=this._subdivisionsY;for(let I=0;I<D;I++)for(let R=0;R<A;R++){f=R*3,g=I*(A+1)*3,m=(I+1)*(A+1)*3,t.x=e[g+f],t.y=e[g+f+1],t.z=e[g+f+2],i.x=e[g+f+3],i.y=e[g+f+4],i.z=e[g+f+5],s.x=e[m+f],s.y=e[m+f+1],s.z=e[m+f+2],r.x=e[m+f+3],r.y=e[m+f+4],r.z=e[m+f+5],b=(r.z-t.z)/(r.x-t.x),x=t.z-b*t.x,i.subtractToRef(t,a),s.subtractToRef(t,o),r.subtractToRef(t,c),T.CrossToRef(c,o,u),T.CrossToRef(a,c,d),u.normalize(),d.normalize(),v=-(u.x*t.x+u.y*t.y+u.z*t.z),E=-(d.x*i.x+d.y*i.y+d.z*i.z);const C=this._heightQuads[I*A+R];C.slope.copyFromFloats(b,x),C.facet1.copyFromFloats(u.x,u.y,u.z,v),C.facet2.copyFromFloats(d.x,d.y,d.z,E)}return this}serialize(e){super.serialize(e),e.subdivisionsX=this._subdivisionsX,e.subdivisionsY=this._subdivisionsY,e.minX=this._minX,e.maxX=this._maxX,e.minZ=this._minZ,e.maxZ=this._maxZ,e.width=this._width,e.height=this._height}static Parse(e,t){const i=new Jh(e.name,t);return i._subdivisionsX=e.subdivisionsX||1,i._subdivisionsY=e.subdivisionsY||1,i._minX=e.minX,i._maxX=e.maxX,i._minZ=e.minZ,i._maxZ=e.maxZ,i._width=e.width,i._height=e.height,i}}function zC(n){const e=[],t=[],i=[],s=[];let r,a;const o=n.width||n.size||1,c=n.height||n.size||1,u=(n.subdivisionsX||n.subdivisions||1)|0,d=(n.subdivisionsY||n.subdivisions||1)|0;for(r=0;r<=d;r++)for(a=0;a<=u;a++){const g=new T(a*o/u-o/2,0,(d-r)*c/d-c/2),m=new T(0,1,0);t.push(g.x,g.y,g.z),i.push(m.x,m.y,m.z),s.push(a/u,1-r/d)}for(r=0;r<d;r++)for(a=0;a<u;
vendor: 5,081 bytes, line 238
238a++)e.push(a+1+(r+1)*(u+1)),e.push(a+1+r*(u+1)),e.push(a+r*(u+1)),e.push(a+(r+1)*(u+1)),e.push(a+1+(r+1)*(u+1)),e.push(a+r*(u+1));const f=new ve;return f.indices=e,f.positions=t,f.normals=i,f.uvs=s,f}function GC(n){const e=n.xmin!==void 0&&n.xmin!==null?n.xmin:-1,t=n.zmin!==void 0&&n.zmin!==null?n.zmin:-1,i=n.xmax!==void 0&&n.xmax!==null?n.xmax:1,s=n.zmax!==void 0&&n.zmax!==null?n.zmax:1,r=n.subdivisions||{w:1,h:1},a=n.precision||{w:1,h:1},o=[],c=[],u=[],d=[];let f,g,m,b;r.h=r.h<1?1:r.h,r.w=r.w<1?1:r.w,a.w=a.w<1?1:a.w,a.h=a.h<1?1:a.h;const x={w:(i-e)/r.w,h:(s-t)/r.h};function v(A,D,I,R){const C=c.length/3,M=a.w+1;for(f=0;f<a.h;f++)for(g=0;g<a.w;g++){const k=[C+g+f*M,C+(g+1)+f*M,C+(g+1)+(f+1)*M,C+g+(f+1)*M];o.push(k[1]),o.push(k[2]),o.push(k[3]),o.push(k[0]),o.push(k[1]),o.push(k[3])}const F=T.Zero(),U=new T(0,1,0);for(f=0;f<=a.h;f++)for(F.z=f*(R-D)/a.h+D,g=0;g<=a.w;g++)F.x=g*(I-A)/a.w+A,F.y=0,c.push(F.x,F.y,F.z),u.push(U.x,U.y,U.z),d.push(g/a.w,f/a.h)}for(m=0;m<r.h;m++)for(b=0;b<r.w;b++)v(e+b*x.w,t+m*x.h,e+(b+1)*x.w,t+(m+1)*x.h);const E=new ve;return E.indices=o,E.positions=c,E.normals=u,E.uvs=d,E}function HC(n){const e=[],t=[],i=[],s=[];let r,a;const o=n.colorFilter||new Ne(.3,.59,.11),c=n.alphaFilter||0;let u=!1;if(n.minHeight>n.maxHeight){u=!0;const f=n.maxHeight;n.maxHeight=n.minHeight,n.minHeight=f}for(r=0;r<=n.subdivisions;r++)for(a=0;a<=n.subdivisions;a++){const f=new T(a*n.width/n.subdivisions-n.width/2,0,(n.subdivisions-r)*n.height/n.subdivisions-n.height/2),g=(f.x+n.width/2)/n.width*(n.bufferWidth-1)|0,m=(1-(f.z+n.height/2)/n.height)*(n.bufferHeight-1)|0,b=(g+m*n.bufferWidth)*4;let x=n.buffer[b]/255,v=n.buffer[b+1]/255,E=n.buffer[b+2]/255;const A=n.buffer[b+3]/255;u&&(x=1-x,v=1-v,E=1-E);const D=x*o.r+v*o.g+E*o.b;A>=c?f.y=n.minHeight+(n.maxHeight-n.minHeight)*D:f.y=n.minHeight-bt,n.heightBuffer&&(n.heightBuffer[r*(n.subdivisions+1)+a]=f.y),t.push(f.x,f.y,f.z),i.push(0,0,0),s.push(a/n.subdivisions,1-r/n.subdivisions)}for(r=0;r<n.subdivisions;r++)for(a=0;a<n.subdivisions;a++){const f=a+1+(r+1)*(n.subdivisions+1),g=a+1+r*(n.subdivisions+1),m=a+r*(n.subdivisions+1),b=a+(r+1)*(n.subdivisions+1),x=t[f*3+1]>=n.minHeight,v=t[g*3+1]>=n.minHeight,E=t[m*3+1]>=n.minHeight;x&&v&&E&&(e.push(f),e.push(g),e.push(m)),t[b*3+1]>=n.minHeight&&x&&E&&(e.push(b),e.push(f),e.push(m))}ve.ComputeNormals(t,e,i);const d=new ve;return d.indices=e,d.positions=t,d.normals=i,d.uvs=s,d}function Ub(n,e={},t){const i=new Jh(n,t);return i._setReady(!1),i._subdivisionsX=e.subdivisionsX||e.subdivisions||1,i._subdivisionsY=e.subdivisionsY||e.subdivisions||1,i._width=e.width||1,i._height=e.height||1,i._maxX=i._width/2,i._maxZ=i._height/2,i._minX=-i._maxX,i._minZ=-i._maxZ,zC(e).applyToMesh(i,e.updatable),i._setReady(!0),i}function WC(n,e,t=null){const i=new Z(n,t);return GC(e).applyToMesh(i,e.updatable),i}function XC(n,e,t={},i=null){const s=t.width||10,r=t.height||10,a=t.subdivisions||1,o=t.minHeight||0,c=t.maxHeight||1,u=t.colorFilter||new Ne(.3,.59,.11),d=t.alphaFilter||0,f=t.updatable,g=t.onReady;i=i||Ke.LastCreatedScene;const m=new Jh(n,i);m._subdivisionsX=a,m._subdivisionsY=a,m._width=s,m._height=r,m._maxX=m._width/2,m._maxZ=m._height/2,m._minX=-m._maxX,m._minZ=-m._maxZ,m._setReady(!1);let b;t.passHeightBufferInCallback&&(b=new Float32Array((a+1)*(a+1)));const x=(v,E,A)=>{HC({width:s,height:r,subdivisions:a,minHeight:o,maxHeight:c,colorFilter:u,buffer:v,bufferWidth:E,bufferHeight:A,alphaFilter:d,heightBuffer:b}).applyToMesh(m,f),g&&g(m,b),m._setReady(!0)};if(typeof e=="string"){const v=E=>{const A=E.width,D=E.height;if(i.isDisposed)return;const I=i?.getEngine().resizeImageBitmap(E,A,D);x(I,A,D)};pe.LoadImage(e,v,t.onError?t.onError:()=>{},i.offlineProvider)}else x(e.data,e.width,e.height);return m}ve.CreateGround=zC;ve.CreateTiledGround=GC;ve.CreateGroundFromHeightMap=HC;Z.CreateGround=(n,e,t,i,s,r)=>Ub(n,{width:e,height:t,subdivisions:i,updatable:r},s);Z.CreateTiledGround=(n,e,t,i,s,r,a,o,c)=>WC(n,{xmin:e,zmin:t,xmax:i,zmax:s,subdivisions:r,precision:a,updatable:c},o);Z.CreateGroundFromHeightMap=(n,e,t,i,s,r,a,o,c,u,d)=>XC(n,e,{width:t,height:i,subdivisions:s,minHeight:r,maxHeight:a,updatable:c,onReady:u,alphaFilter:d},o);function jC(n){let t=[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23];const i=[0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0],s=[];let r=[];const a=n.width||n.size||1,o=n.height||n.size||1,c=n.depth||n.size||1,u=n.wrap||!1;let d=n.topBaseAt===void 0?1:n.topBaseAt,f=n.bottomBaseAt===void 0?0:n.bottomBaseAt;d=(d+4)%4,f=(f+4)%4;const g=[2,0,3,1],m=[2,0,1,3];let b=g[d],x=m[f],v=[1,-1,1,-1,-1,1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,-1,-1,-1,1];if(u){t=[2,3,0,2,0,1,4,5,6,4,6,7,9,10,11,9,11,8,12,14,15,12,13,14],v=[-1,1,1,1,1,1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,1,1,1,-1,1,-1,-1,1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,-1];
238let M=[[1,1,1],[-1,1,1],[-1,1,-1],[1,1,-1]],F=[[-1,-1,1],[1,-1,1],[1,-1,-1],[-1,-1,-1]];const U=[17,18,19,16],k=[22,23,20,21];for(;b>0;)M.unshift(M.pop()),U.unshift(U.pop()),b--;for(;x>0;)F.unshift(F.pop()),k.unshift(k.pop()),x--;M=M.flat(),F=F.flat(),v=v.concat(M).concat(F),t.push(U[0],U[2],U[3],U[0],U[1],U[2]),t.push(k[0],k[2],k[3],k[0],k[1],k[2])}const E=[a/2,o/2,c/2];r=v.reduce((M,F,U)=>M.concat(F*E[U%3]),[]);const A=n.sideOrientation===0?0:n.sideOrientation||ve.DEFAULTSIDE,D=n.faceUV||new Array(6),I=n.faceColors,R=[];for(let M=0;M<6;M++)D[M]===void 0&&(D[M]=new rt(0,0,1,1)),I&&I[M]===void 0&&(I[M]=new Ze(1,1,1,1));for(let M=0;M<6;M++)if(s.push(D[M].z,D[M].w),s.push(D[M].x,D[M].w),s.push(D[M].x,D[M].y),s.push(D[M].z,D[M].y),I)for(let F=0;F<4;F++)R.push(I[M].r,I[M].g,I[M].b,I[M].a);ve._ComputeSides(A,r,t,i,s,n.frontUVs,n.backUVs);const C=new ve;if(C.indices=t,C.positions=r,C.normals=i,C.uvs=s,I){const M=A===ve.DOUBLESIDE?R.concat(R):R;C.colors=M}return C}function YC(n,e={},t=null){const i=new Z(n,t);return e.sideOrientation=Z._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,jC(e).applyToMesh(i,e.updatable),i}ve.CreateBox=jC;Z.CreateBox=(n,e,t=null,i,s)=>YC(n,{size:e,sideOrientation:s,updatable:i},t);function xh(n){const e=n.pattern||Z.NO_FLIP,t=n.tileWidth||n.tileSize||1,i=n.tileHeight||n.tileSize||1,s=n.alignHorizontal||0,r=n.alignVertical||0,a=n.width||n.size||1,o=Math.floor(a/t);let c=a-o*t;const u=n.height||n.size||1,d=Math.floor(u/i);let f=u-d*i;const g=t*o/2,m=i*d/2;let b=0,x=0,v=0,E=0,A=0,D=0;if(c>0||f>0){switch(v=-g,E=-m,A=g,D=m,s){case Z.CENTER:c/=2,v-=c,A+=c;break;case Z.LEFT:A+=c,b=-c/2;break;case Z.RIGHT:v-=c,b=c/2;break}switch(r){case Z.CENTER:f/=2,E-=f,D+=f;break;case Z.BOTTOM:D+=f,x=-f/2;break;case Z.TOP:E-=f,x=f/2;break}}const I=[],R=[],C=[];C[0]=[0,0,1,0,1,1,0,1],C[1]=[0,0,1,0,1,1,0,1],(e===Z.ROTATE_TILE||e===Z.ROTATE_ROW)&&(C[1]=[1,1,0,1,0,0,1,0]),(e===Z.FLIP_TILE||e===Z.FLIP_ROW)&&(C[1]=[1,0,0,0,0,1,1,1]),(e===Z.FLIP_N_ROTATE_TILE||e===Z.FLIP_N_ROTATE_ROW)&&(C[1]=[0,1,1,1,1,0,0,0]);let M=[];const F=[],U=[];let k=0;for(let $=0;$<d;$++)for(let ce=0;ce<o;ce++)I.push(-g+ce*t+b,-m+$*i+x,0),I.push(-g+(ce+1)*t+b,-m+$*i+x,0),I.push(-g+(ce+1)*t+b,-m+($+1)*i+x,0),I.push(-g+ce*t+b,-m+($+1)*i+x,0),U.push(k,k+1,k+3,k+1,k+2,k+3),e===Z.FLIP_TILE||e===Z.ROTATE_TILE||e===Z.FLIP_N_ROTATE_TILE?M=M.concat(C[(ce%2+$%2)%2]):e===Z.FLIP_ROW||e===Z.ROTATE_ROW||e===Z.FLIP_N_ROTATE_ROW?M=M.concat(C[$%2]):M=M.concat(C[0]),F.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),R.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1),k+=4;if(c>0||f>0){const $=f>0&&(r===Z.CENTER||r===Z.TOP),ce=f>0&&(r===Z.CENTER||r===Z.BOTTOM),G=c>0&&(s===Z.CENTER||s===Z.RIGHT),K=c>0&&(s===Z.CENTER||s===Z.LEFT);let X=[],J,se,w,L;if($&&G&&(I.push(v+b,E+x,0),I.push(-g+b,E+x,0),I.push(-g+b,E+f+x,0),I.push(v+b,E+f+x,0),U.push(k,k+1,k+3,k+1,k+2,k+3),k+=4,J=1-c/t,se=1-f/i,w=1,L=1,X=[J,se,w,se,w,L,J,L],e===Z.ROTATE_ROW&&(X=[1-J,1-se,1-w,1-se,1-w,1-L,1-J,1-L]),e===Z.FLIP_ROW&&(X=[1-J,se,1-w,se,1-w,L,1-J,L]),e===Z.FLIP_N_ROTATE_ROW&&(X=[J,1-se,w,1-se,w,1-L,J,1-L]),M=M.concat(X),F.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),R.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),$&&K&&(I.push(g+b,E+x,0),I.push(A+b,E+x,0),I.push(A+b,E+f+x,0),I.push(g+b,E+f+x,0),U.push(k,k+1,k+3,k+1,k+2,k+3),k+=4,J=0,se=1-f/i,w=c/t,L=1,X=[J,se,w,se,w,L,J,L],(e===Z.ROTATE_ROW||e===Z.ROTATE_TILE&&o%2===0)&&(X=[1-J,1-se,1-w,1-se,1-w,1-L,1-J,1-L]),(e===Z.FLIP_ROW||e===Z.FLIP_TILE&&o%2===0)&&(X=[1-J,se,1-w,se,1-w,L,1-J,L]),(e===Z.FLIP_N_ROTATE_ROW||e===Z.FLIP_N_ROTATE_TILE&&o%2===0)&&(X=[J,1-se,w,1-se,w,1-L,J,1-L]),M=M.concat(X),F.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),R.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),ce&&G&&(I.push(v+b,m+x,0),I.push(-g+b,m+x,0),I.push(-g+b,D+x,0),I.push(v+b,D+x,0),U.push(k,k+1,k+3,k+1,k+2,k+3),k+=4,J=1-c/t,se=0,w=1,L=f/i,X=[J,se,w,se,w,L,J,L],(e===Z.ROTATE_ROW&&d%2===1||e===Z.ROTATE_TILE&&d%1===0)&&(X=[1-J,1-se,1-w,1-se,1-w,1-L,1-J,1-L]),(e===Z.FLIP_ROW&&d%2===1||e===Z.FLIP_TILE&&d%2===0)&&(X=[1-J,se,1-w,se,1-w,L,1-J,L]),(e===Z.FLIP_N_ROTATE_ROW&&d%2===1||e===Z.FLIP_N_ROTATE_TILE&&d%2===0)&&(X=[J,1-se,w,1-se,w,1-L,J,1-L]),M=M.concat(X),F.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),R.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),ce&&K&&(I.push(g+b,m+x,0),I.push(A+b,m+x,0),I.push(A+b,D+x,0
238),I.push(g+b,D+x,0),U.push(k,k+1,k+3,k+1,k+2,k+3),k+=4,J=0,se=0,w=c/t,L=f/i,X=[J,se,w,se,w,L,J,L],(e===Z.ROTATE_ROW&&d%2===1||e===Z.ROTATE_TILE&&(d+o)%2===1)&&(X=[1-J,1-se,1-w,1-se,1-w,1-L,1-J,1-L]),(e===Z.FLIP_ROW&&d%2===1||e===Z.FLIP_TILE&&(d+o)%2===1)&&(X=[1-J,se,1-w,se,1-w,L,1-J,L]),(e===Z.FLIP_N_ROTATE_ROW&&d%2===1||e===Z.FLIP_N_ROTATE_TILE&&(d+o)%2===1)&&(X=[J,1-se,w,1-se,w,1-L,J,1-L]),M=M.concat(X),F.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),R.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),$){const V=[];J=0,se=1-f/i,w=1,L=1,V[0]=[J,se,w,se,w,L,J,L],V[1]=[J,se,w,se,w,L,J,L],(e===Z.ROTATE_TILE||e===Z.ROTATE_ROW)&&(V[1]=[1-J,1-se,1-w,1-se,1-w,1-L,1-J,1-L]),(e===Z.FLIP_TILE||e===Z.FLIP_ROW)&&(V[1]=[1-J,se,1-w,se,1-w,L,1-J,L]),(e===Z.FLIP_N_ROTATE_TILE||e===Z.FLIP_N_ROTATE_ROW)&&(V[1]=[J,1-se,w,1-se,w,1-L,J,1-L]);for(let j=0;j<o;j++)I.push(-g+j*t+b,E+x,0),I.push(-g+(j+1)*t+b,E+x,0),I.push(-g+(j+1)*t+b,E+f+x,0),I.push(-g+j*t+b,E+f+x,0),U.push(k,k+1,k+3,k+1,k+2,k+3),k+=4,e===Z.FLIP_TILE||e===Z.ROTATE_TILE||e===Z.FLIP_N_ROTATE_TILE?M=M.concat(V[(j+1)%2]):e===Z.FLIP_ROW||e===Z.ROTATE_ROW||e===Z.FLIP_N_ROTATE_ROW?M=M.concat(V[1]):M=M.concat(V[0]),F.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),R.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}if(ce){const V=[];J=0,se=0,w=1,L=f/i,V[0]=[J,se,w,se,w,L,J,L],V[1]=[J,se,w,se,w,L,J,L],(e===Z.ROTATE_TILE||e===Z.ROTATE_ROW)&&(V[1]=[1-J,1-se,1-w,1-se,1-w,1-L,1-J,1-L]),(e===Z.FLIP_TILE||e===Z.FLIP_ROW)&&(V[1]=[1-J,se,1-w,se,1-w,L,1-J,L]),(e===Z.FLIP_N_ROTATE_TILE||e===Z.FLIP_N_ROTATE_ROW)&&(V[1]=[J,1-se,w,1-se,w,1-L,J,1-L]);for(let j=0;j<o;j++)I.push(-g+j*t+b,D-f+x,0),I.push(-g+(j+1)*t+b,D-f+x,0),I.push(-g+(j+1)*t+b,D+x,0),I.push(-g+j*t+b,D+x,0),U.push(k,k+1,k+3,k+1,k+2,k+3),k+=4,e===Z.FLIP_TILE||e===Z.ROTATE_TILE||e===Z.FLIP_N_ROTATE_TILE?M=M.concat(V[(j+d)%2]):e===Z.FLIP_ROW||e===Z.ROTATE_ROW||e===Z.FLIP_N_ROTATE_ROW?M=M.concat(V[d%2]):M=M.concat(V[0]),F.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),R.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}if(G){const V=[];J=1-c/t,se=0,w=1,L=1,V[0]=[J,se,w,se,w,L,J,L],V[1]=[J,se,w,se,w,L,J,L],(e===Z.ROTATE_TILE||e===Z.ROTATE_ROW)&&(V[1]=[1-J,1-se,1-w,1-se,1-w,1-L,1-J,1-L]),(e===Z.FLIP_TILE||e===Z.FLIP_ROW)&&(V[1]=[1-J,se,1-w,se,1-w,L,1-J,L]),(e===Z.FLIP_N_ROTATE_TILE||e===Z.FLIP_N_ROTATE_ROW)&&(V[1]=[J,1-se,w,1-se,w,1-L,J,1-L]);for(let j=0;j<d;j++)I.push(v+b,-m+j*i+x,0),I.push(v+c+b,-m+j*i+x,0),I.push(v+c+b,-m+(j+1)*i+x,0),I.push(v+b,-m+(j+1)*i+x,0),U.push(k,k+1,k+3,k+1,k+2,k+3),k+=4,e===Z.FLIP_TILE||e===Z.ROTATE_TILE||e===Z.FLIP_N_ROTATE_TILE?M=M.concat(V[(j+1)%2]):e===Z.FLIP_ROW||e===Z.ROTATE_ROW||e===Z.FLIP_N_ROTATE_ROW?M=M.concat(V[j%2]):M=M.concat(V[0]),F.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),R.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}if(K){const V=[];J=0,se=0,w=c/i,L=1,V[0]=[J,se,w,se,w,L,J,L],V[1]=[J,se,w,se,w,L,J,L],(e===Z.ROTATE_TILE||e===Z.ROTATE_ROW)&&(V[1]=[1-J,1-se,1-w,1-se,1-w,1-L,1-J,1-L]),(e===Z.FLIP_TILE||e===Z.FLIP_ROW)&&(V[1]=[1-J,se,1-w,se,1-w,L,1-J,L]),(e===Z.FLIP_N_ROTATE_TILE||e===Z.FLIP_N_ROTATE_ROW)&&(V[1]=[J,1-se,w,1-se,w,1-L,J,1-L]);for(let j=0;j<d;j++)I.push(A-c+b,-m+j*i+x,0),I.push(A+b,-m+j*i+x,0),I.push(A+b,-m+(j+1)*i+x,0),I.push(A-c+b,-m+(j+1)*i+x,0),U.push(k,k+1,k+3,k+1,k+2,k+3),k+=4,e===Z.FLIP_TILE||e===Z.ROTATE_TILE||e===Z.FLIP_N_ROTATE_TILE?M=M.concat(V[(j+o)%2]):e===Z.FLIP_ROW||e===Z.ROTATE_ROW||e===Z.FLIP_N_ROTATE_ROW?M=M.concat(V[j%2]):M=M.concat(V[0]),F.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),R.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}}const q=n.sideOrientation===0?0:n.sideOrientation||ve.DEFAULTSIDE;ve._ComputeSides(q,I,U,R,M,n.frontUVs,n.backUVs);const Q=new ve;Q.indices=U,Q.positions=I,Q.normals=R,Q.uvs=M;const ie=q===ve.DOUBLESIDE?F.concat(F):F;return Q.colors=ie,Q}function b3(n,e,t=null){const i=new Z(n,t);return e.sideOrientation=Z._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,xh(e).applyToMesh(i,e.updatable),i}ve.CreateTiledPlane=xh;const Id=1,Ug=-1;function KC(n){const t=n.faceUV||new Array(6),i=n.faceColors,s=n.pattern||Z.NO_FLIP,r=n.width||n.size||1,a=n.height||n.size||1,o=n.depth||n.size||1,c=n.tileWidth||n.tileSize||1,u=n.tileHeight||n.tileSize||1,d=n.alignHorizontal||0,f=n.alignVertical||0,g=n.sideOrientation===0?0:n.sideOrientation||ve.DEFAULTSIDE;for(let $=0;$<6;$++)t[$]===void 0&&(t[$]=new rt(0,0,1,1)),i&&i[$]===void 0&&(i[$]=new Ze(1,1,1,1));const m=r/2,b=a/2,x=o/2,v=[];for(let $=0;$<2;$++)v[$]=xh({pattern:s,tileWidth:c,tileHeight:u,width:r,height:a,alignVertical:f,alignHorizontal:d,sideOrientation:g});for(let $=2;$<4;$++)v[$]=xh({pattern:s,tileWidth:c,tileHeight:u,width:o,height:a,alignVertical:f,alignHorizontal:d,sideOrientation:g});let E=f;f===Z.BOTTOM?E=Z.TOP:f===Z.TOP&&(E=Z.BOTTOM);for(let $=4;$<6;$++)v[$]=xh({pattern:s,tileWidth:c,tileHeight:u,width:r,height:o,alignVertical:E,alignHorizontal:d,sideOrientation:g});const A=[],D=[];let I=[],R=[];const C=[],M=[],F=[],U=[];let k=0,q=0;for(let $=0;$<6;$++){const ce=v[$].positions.length;M[$]=[],F[$]=[];for(let G=0;G<ce/3;G++)M[$].push(new T(v[$].positions[3*G],v[$].positions[3*G+1],v[$].positions[3*G+2])),F[$].push(new T(v[$].normals[3*G],v[$].normals[3*G+1],v[$].normals[3*G+2]));k=v[$].uvs.length,U[$]=[];for(let G=0;G<k;G+=2)U[$][G]=t[$].x+(t[$].z-t[$].x)*v[$].uvs[G],U[$][G+1]=t[$].y+(t[$].w-t[$].y)*v[$].uvs[G+1];if(I=I.concat(U[$]),R=R.concat(v[$].indices.map(G=>G+q)),q+=M[$].length,i){const G=i[$];for(let K=0;K<M[$].length;K++)C.push(G.r,G.g,G.b,G.a)}}const Q=[{m:W.RotationY(Math.PI),t:new T(0,0,x),op:Id},{m:W.Identity(),t:new T(0,0,x),op:Ug},{m:W.RotationY(-Math.PI/2),t:new T(m,0,0),op:Id},{m:W.RotationY(Math.PI/2),t:new T(m,0,0),op:Ug},{m:W.RotationX(Math.PI/2),t:new T(0,b,0),op:Id},{m:W.RotationX(-Math.PI/2),t:new T(0,b,0),op:Ug}];for(let $=0;$<6;$++){const{m:ce,t:G,op:K}=Q[$];for(const X of M[$]){const J=T.TransformCoordinates(X,ce),se=K===Id?J.add(G):J.subtract(G);A.push(se.x,se.y,se.z)}for(const X of F[$]){const J=T.TransformNormal(X,ce);D.push(J.x,J.y,J.z)}}const ie=new ve;if(ie.indices=R,ie.positions=A,ie.normals=D,ie.uvs=I,i){const $=g===ve.DOUBLESIDE?C.concat(C):C;ie.colors=$}return ie}function y3(n,e,t=null){const i=new Z(n,t);return e.sideOrientation=Z._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,KC(e).applyToMesh(i,e.updatable),i}ve.CreateTiledBox=KC;function qC(n){const e=(n.segments||32)|0,t=n.diameterX||n.diameter||1,i=n.diameterY||n.diameter||1,s=n.diameterZ||n.diameter||1,r=n.arc&&(n.arc<=0||n.arc>1)?1:n.arc||1,a=n.slice&&n.slice<=0?1:n.slice||1,o=n.sideOrientation===0?0:n.sideOrientation||ve.DEFAULTSIDE,c=!!n.dedupTopBottomIndices,u=new T(t/2,i/2,s/2),d=2+e,f=2*d,g=[],m=[],b=[],x=[];for(let E=0;E<=d;E++){const A=E/d,D=A*Math.PI*a;for(let I=0;I<=f;
238I++){const R=I/f,C=R*Math.PI*2*r,M=W.RotationZ(-D),F=W.RotationY(C),U=T.TransformCoordinates(T.Up(),M),k=T.TransformCoordinates(U,F),q=k.multiply(u),Q=k.divide(u).normalize();m.push(q.x,q.y,q.z),b.push(Q.x,Q.y,Q.z),x.push(R,A)}if(E>0){const I=m.length/3;for(let R=I-2*(f+1);R+f+2<I;R++)c?(E>1&&(g.push(R),g.push(R+1),g.push(R+f+1)),(E<d||a<1)&&(g.push(R+f+1),g.push(R+1),g.push(R+f+2))):(g.push(R),g.push(R+1),g.push(R+f+1),g.push(R+f+1),g.push(R+1),g.push(R+f+2))}}ve._ComputeSides(o,m,g,b,x,n.frontUVs,n.backUVs);const v=new ve;return v.indices=g,v.positions=m,v.normals=b,v.uvs=x,v}function Uh(n,e={},t=null){const i=new Z(n,t);return e.sideOrientation=Z._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,qC(e).applyToMesh(i,e.updatable),i}ve.CreateSphere=qC;Z.CreateSphere=(n,e,t,i,s,r)=>Uh(n,{segments:e,diameterX:t,diameterY:t,diameterZ:t,sideOrientation:r,updatable:s},i);class xT{constructor(){this._count=0,this._data={}}copyFrom(e){this.clear(),e.forEach((t,i)=>this.add(t,i))}get(e){const t=this._data[e];if(t!==void 0)return t}getOrAddWithFactory(e,t){let i=this.get(e);return i!==void 0||(i=t(e),i&&this.add(e,i)),i}getOrAdd(e,t){const i=this.get(e);return i!==void 0?i:(this.add(e,t),t)}contains(e){return this._data[e]!==void 0}add(e,t){return this._data[e]!==void 0?!1:(this._data[e]=t,++this._count,!0)}set(e,t){return this._data[e]===void 0?!1:(this._data[e]=t,!0)}getAndRemove(e){const t=this.get(e);return t!==void 0?(delete this._data[e],--this._count,t):null}remove(e){return this.contains(e)?(delete this._data[e],--this._count,!0):!1}clear(){this._data={},this._count=0}get count(){return this._count}forEach(e){for(const t in this._data){const i=this._data[t];e(t,i)}}first(e){for(const t in this._data){const i=this._data[t],s=e(t,i);if(s)return s}return null}}function ZC(n){n.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")}class $t{constructor(){this._dirty=!0,this._tempColor=new Ze(0,0,0,0),this._globalCurve=new Ze(0,0,0,0),this._highlightsCurve=new Ze(0,0,0,0),this._midtonesCurve=new Ze(0,0,0,0),this._shadowsCurve=new Ze(0,0,0,0),this._positiveCurve=new Ze(0,0,0,0),this._negativeCurve=new Ze(0,0,0,0),this._globalHue=30,this._globalDensity=0,this._globalSaturation=0,this._globalExposure=0,this._highlightsHue=30,this._highlightsDensity=0,this._highlightsSaturation=0,this._highlightsExposure=0,this._midtonesHue=30,this._midtonesDensity=0,this._midtonesSaturation=0,this._midtonesExposure=0,this._shadowsHue=30,this._shadowsDensity=0,this._shadowsSaturation=0,this._shadowsExposure=0}get globalHue(){return this._globalHue}set globalHue(e){this._globalHue=e,this._dirty=!0}get globalDensity(){return this._globalDensity}set globalDensity(e){this._globalDensity=e,this._dirty=!0}get globalSaturation(){return this._globalSaturation}set globalSaturation(e){this._globalSaturation=e,this._dirty=!0}get globalExposure(){return this._globalExposure}set globalExposure(e){this._globalExposure=e,this._dirty=!0}get highlightsHue(){return this._highlightsHue}set highlightsHue(e){this._highlightsHue=e,this._dirty=!0}get highlightsDensity(){return this._highlightsDensity}set highlightsDensity(e){this._highlightsDensity=e,this._dirty=!0}get highlightsSaturation(){return this._highlightsSaturation}set highlightsSaturation(e){this._highlightsSaturation=e,this._dirty=!0}get highlightsExposure(){return this._highlightsExposure}set highlightsExposure(e){this._highlightsExposure=e,this._dirty=!0}get midtonesHue(){return this._midtonesHue}set midtonesHue(e){this._midtonesHue=e,this._dirty=!0}get midtonesDensity(){return this._midtonesDensity}set midtonesDensity(e){this._midtonesDensity=e,this._dirty=!0}get midtonesSaturation(){return this._midtonesSaturation}set midtonesSaturation(e){this._midtonesSaturation=e,this._dirty=!0}get midtonesExposure(){return this._midtonesExposure}set midtonesExposure(e){this._midtonesExposure=e,this._dirty=!0}get shadowsHue(){return this._shadowsHue}set shadowsHue(e){this._shadowsHue=e,this._dirty=!0}get shadowsDensity(){return this._shadowsDensity}set shadowsDensity(e){this._shadowsDensity=e,this._dirty=!0}get shadowsSaturation(){return this._shadowsSaturation}set shadowsSaturation(e){this._shadowsSaturation=e,this._dirty=!0}get shadowsExposure(){return this._shadowsExposure}set shadowsExposure(e){this._shadowsExposure=e,this._dirty=!0}getClassName(){return"ColorCurves"}static Bind(e,t,i="vCameraColorCurvePositive",s="vCameraColorCurveNeutral",r="vCameraColorCurveNegative"){e._dirty&&(e._dirty=!1,e._getColorGradingDataToRef(e._globalHue,e._globalDensity,e._globalSaturation,e._globalExposure,e._globalCurve),e._getColorGradingDataToRef(e._highlightsHue,e._highlightsDensity,e._highlightsSaturation,e._highlightsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._highlightsCurve),e._getColorGradingDataToRef(e._midtonesHue,e._midtonesDensity,e._midtonesSaturation,e._midtonesExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._midtonesCurve),e._getColorGradingDataToRef(e._shadows
vendor: 64,468 bytes, line 238
238Hue,e._shadowsDensity,e._shadowsSaturation,e._shadowsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._shadowsCurve),e._highlightsCurve.subtractToRef(e._midtonesCurve,e._positiveCurve),e._midtonesCurve.subtractToRef(e._shadowsCurve,e._negativeCurve)),t&&(t.setFloat4(i,e._positiveCurve.r,e._positiveCurve.g,e._positiveCurve.b,e._positiveCurve.a),t.setFloat4(s,e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a),t.setFloat4(r,e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a))}_getColorGradingDataToRef(e,t,i,s,r){e!=null&&(e=$t._Clamp(e,0,360),t=$t._Clamp(t,-100,100),i=$t._Clamp(i,-100,100),s=$t._Clamp(s,-100,100),t=$t._ApplyColorGradingSliderNonlinear(t),t*=.5,s=$t._ApplyColorGradingSliderNonlinear(s),t<0&&(t*=-1,e=(e+180)%360),$t._FromHSBToRef(e,t,50+.25*s,r),r.scaleToRef(2,r),r.a=1+.01*i)}static _ApplyColorGradingSliderNonlinear(e){e/=100;let t=Math.abs(e);return t=Math.pow(t,2),e<0&&(t*=-1),t*=100,t}static _FromHSBToRef(e,t,i,s){let r=$t._Clamp(e,0,360);const a=$t._Clamp(t/100,0,1),o=$t._Clamp(i/100,0,1);if(a===0)s.r=o,s.g=o,s.b=o;else{r/=60;const c=Math.floor(r),u=r-c,d=o*(1-a),f=o*(1-a*u),g=o*(1-a*(1-u));switch(c){case 0:s.r=o,s.g=g,s.b=d;break;case 1:s.r=f,s.g=o,s.b=d;break;case 2:s.r=d,s.g=o,s.b=g;break;case 3:s.r=d,s.g=f,s.b=o;break;case 4:s.r=g,s.g=d,s.b=o;break;default:s.r=o,s.g=d,s.b=f;break}}s.a=1}static _Clamp(e,t,i){return Math.min(Math.max(e,t),i)}clone(){return $e.Clone(()=>new $t,this)}serialize(){return $e.Serialize(this)}static Parse(e){return $e.Parse(()=>new $t,e,null,null)}}$t.PrepareUniforms=ZC;N([H()],$t.prototype,"_globalHue",void 0);N([H()],$t.prototype,"_globalDensity",void 0);N([H()],$t.prototype,"_globalSaturation",void 0);N([H()],$t.prototype,"_globalExposure",void 0);N([H()],$t.prototype,"_highlightsHue",void 0);N([H()],$t.prototype,"_highlightsDensity",void 0);N([H()],$t.prototype,"_highlightsSaturation",void 0);N([H()],$t.prototype,"_highlightsExposure",void 0);N([H()],$t.prototype,"_midtonesHue",void 0);N([H()],$t.prototype,"_midtonesDensity",void 0);N([H()],$t.prototype,"_midtonesSaturation",void 0);N([H()],$t.prototype,"_midtonesExposure",void 0);$e._ColorCurvesParser=$t.Parse;function v3(n,e){e.EXPOSURE&&n.push("exposureLinear"),e.CONTRAST&&n.push("contrast"),e.COLORGRADING&&n.push("colorTransformSettings"),(e.VIGNETTE||e.DITHER)&&n.push("vInverseScreenSize"),e.VIGNETTE&&(n.push("vignetteSettings1"),n.push("vignetteSettings2")),e.COLORCURVES&&ZC(n),e.DITHER&&n.push("ditherIntensity")}function x3(n,e){e.COLORGRADING&&n.push("txColorTransform")}class ft{constructor(){this.colorCurves=new $t,this._colorCurvesEnabled=!1,this._colorGradingEnabled=!1,this._colorGradingWithGreenDepth=!0,this._colorGradingBGR=!0,this._exposure=1,this._toneMappingEnabled=!1,this._toneMappingType=ft.TONEMAPPING_STANDARD,this._contrast=1,this.vignetteStretch=0,this.vignetteCenterX=0,this.vignetteCenterY=0,this.vignetteWeight=1.5,this.vignetteColor=new Ze(0,0,0,0),this.vignetteCameraFov=.5,this._vignetteBlendMode=ft.VIGNETTEMODE_MULTIPLY,this._vignetteEnabled=!1,this._ditheringEnabled=!1,this._ditheringIntensity=1/255,this._skipFinalColorClamp=!1,this._applyByPostProcess=!1,this._isEnabled=!0,this.outputTextureWidth=0,this.outputTextureHeight=0,this.onUpdateParameters=new le}get colorCurvesEnabled(){return this._colorCurvesEnabled}set colorCurvesEnabled(e){this._colorCurvesEnabled!==e&&(this._colorCurvesEnabled=e,this._updateParameters())}get colorGradingTexture(){return this._colorGradingTexture}set colorGradingTexture(e){this._colorGradingTexture!==e&&(this._colorGradingTexture=e,this._updateParameters())}get colorGradingEnabled(){return this._colorGradingEnabled}set colorGradingEnabled(e){this._colorGradingEnabled!==e&&(this._colorGradingEnabled=e,this._updateParameters())}get colorGradingWithGreenDepth(){return this._colorGradingWithGreenDepth}set colorGradingWithGreenDepth(e){this._colorGradingWithGreenDepth!==e&&(this._colorGradingWithGreenDepth=e,this._updateParameters())}get colorGradingBGR(){return this._colorGradingBGR}set colorGradingBGR(e){this._colorGradingBGR!==e&&(this._colorGradingBGR=e,this._updateParameters())}get exposure(){return this._exposure}set exposure(e){this._exposure!==e&&(this._exposure=e,this._updateParameters())}get toneMappingEnabled(){return this._toneMappingEnabled}set toneMappingEnabled(e){this._toneMappingEnabled!==e&&(this._toneMappingEnabled=e,this._updateParameters())}get toneMappingType(){return this._toneMappingType}set toneMappingType(e){this._toneMappingType!==e&&(this._toneMappingType=e,this._updateParameters())}get contrast(){return this._contrast}set contrast(e){this._contrast!==e&&(this._contrast=e,this._updateParameters())}get vignetteCentreY(){return this.vignetteCenterY}set vignetteCentreY(e){this.vignetteCenterY=e}get vignetteCentreX(){return this.vignetteCenterX}set vignetteCentreX(e){this.vignetteCenterX=e}get vignetteBlendMode(){return this._vignetteBlendMode}set vignetteBlendMode(e){this._vignetteBlendMode!==e&&(this._vignetteBlendMode=e,this._updateParameters())}get vignetteEnabled(){return this._vignetteEnabled}set vignetteEnabled(e){this._vignetteEnabled!==e&&(this._vignetteEnabled=e,this._updateParameters())}get ditheringEnabled(){return this._ditheringEnabled}set ditheringEnabled(e){this._ditheringEnabled!==e&&(this._ditheringEnabled=e,this._updateParameters())}get ditheringIntensity(){return this._ditheringIntensity}set ditheringIntensity(e){this._ditheringIntensity!==e&&(this._ditheringIntensity=e,this._updateParameters())}get skipFinalColorClamp(){return this._skipFinalColorClamp}set skipFinalColorClamp(e){this._skipFinalColorClamp!==e&&(this._skipFinalColorClamp=e,this._updateParameters())}get applyByPostProcess(){return this._applyByPostProcess}set applyByPostProcess(e){this._applyByPostProcess!==e&&(this._applyByPostProcess=e,this._updateParameters())}get isEnabled(){return this._isEnabled}set isEnabled(e){this._isEnabled!==e&&(this._isEnabled=e,this._updateParameters())}_updateParameters(){this.onUpdateParameters.notifyObservers(this)}getClassName(){return"ImageProcessingConfiguration"}prepareDefines(e,t=!1){if(t!==this.applyByPostProcess||!this._isEnabled){e.VIGNETTE=!1,e.TONEMAPPING=0,e.CONTRAST=!1,e.EXPOSURE=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.DITHER=!1,e.IMAGEPROCESSING=!1,e.SKIPFINALCOLORCLAMP=this.skipFinalColorClamp,e.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess&&this._isEnabled;return}if(e.VIGNETTE=this.vignetteEnabled,e.VIGNETTEBLENDMODEMULTIPLY=this.vignetteBlendMode===ft._VIGNETTEMODE_MULTIPLY,e.VIGNETTEBLENDMODEOPAQUE=!e.VIGNETTEBLENDMODEMULTIPLY,!this._toneMappingEnabled)e.TONEMAPPING=0;else switch(this._toneMappingType){case ft.TONEMAPPING_KHR_PBR_NEUTRAL:e.TONEMAPPING=3;break;case ft.TONEMAPPING_ACES:e.TONEMAPPING=2;break;default:e.TONEMAPPING=1;break}e.CONTRAST=this.contrast!==1,e.EXPOSURE=this.exposure!==1,e.COLORCURVES=this.colorCurvesEnabled&&!!this.colorCurves,e.COLORGRADING=this.colorGradingEnabled&&!!this.colorGradingTexture,e.COLORGRADING?e.COLORGRADING3D=this.colorGradingTexture.is3D:e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=this.colorGradingWithGreenDepth,e.SAMPLER3DBGRMAP=this.colorGradingBGR,e.DITHER=this._ditheringEnabled,e.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess,e.SKIPFINALCOLORCLAMP=this.skipFinalColorClamp,e.IMAGEPROCESSING=e.VIGNETTE||!!e.TONEMAPPING||e.CONTRAST||e.EXPOSURE||e.COLORCURVES||e.COLORGRADING||e.DITHER}isReady(){return!this.colorGradingEnabled||!this.colorGradingTexture||this.colorGradingTexture.isReady()}bind(e,t){if(this._colorCurvesEnabled&&this.colorCurves&&$t.Bind(this.colorCurves,e),this._vignetteEnabled||this._ditheringEnabled){const i=1/(this.outputTextureWidth||e.getEngine().getRenderWidth()),s=1/(this.outputTextureHeight||e.getEngine().getRenderHeight());if(e.setFloat2("vInverseScreenSize",i,s),this._ditheringEnabled&&e.setFloat("ditherIntensity",.5*this._ditheringIntensity),this._vignetteEnabled){const r=t??s/i;let a=Math.tan(this.vignetteCameraFov*.5),o=a*r;const c=Math.sqrt(o*a);o=Mm(o,c,this.vignetteStretch),a=Mm(a,c,this.vignetteStretch),e.setFloat4("vignetteSettings1",o,a,-o*this.vignetteCenterX,-a*this.vignetteCenterY);const u=-2*this.vignetteWeight;e.setFloat4("vignetteSettings2",this.vignetteColor.r,this.vignetteColor.g,this.vignetteColor.b,u)}}if(e.setFloat("exposureLinear",this.exposure),e.setFloat("contrast",this.contrast),this.colorGradingTexture){e.setTexture("txColorTransform",this.colorGradingTexture);const i=this.colorGradingTexture.getSize().height;e.setFloat4("colorTransformSettings",(i-1)/i,.5/i,i,this.colorGradingTexture.level)}}clone(){return $e.Clone(()=>new ft,this)}serialize(){return $e.Serialize(this)}static Parse(e){const t=$e.Parse(()=>new ft,e,null,null);return e.vignetteCentreX!==void 0&&(t.vignetteCenterX=e.vignetteCentreX),e.vignetteCentreY!==void 0&&(t.vignetteCenterY=e.vignetteCentreY),t}static get VIGNETTEMODE_MULTIPLY(){return this._VIGNETTEMODE_MULTIPLY}static get VIGNETTEMODE_OPAQUE(){return this._VIGNETTEMODE_OPAQUE}}ft.TONEMAPPING_STANDARD=0;ft.TONEMAPPING_ACES=1;ft.TONEMAPPING_KHR_PBR_NEUTRAL=2;ft.PrepareUniforms=v3;ft.PrepareSamplers=x3;ft._VIGNETTEMODE_MULTIPLY=0;ft._VIGNETTEMODE_OPAQUE=1;N([sk()],ft.prototype,"colorCurves",void 0);N([H()],ft.prototype,"_colorCurvesEnabled",void 0);N([Lr("colorGradingTexture")],ft.prototype,"_colorGradingTexture",void 0);N([H()],ft.prototype,"_colorGradingEnabled",void 0);N([H()],ft.prototype,"_colorGradingWithGreenDepth",void 0);N([H()],ft.prototype,"_colorGradingBGR",void 0);N([H()],ft.prototype,"_exposure",void 0);N([H()],ft.prototype,"_toneMappingEnabled",void 0);N([H()],ft.prototype,"_toneMappingType",void 0);N([H()],ft.prototype,"_contrast",void 0);N([H()],ft.prototype,"vignetteStretch",void 0);N([H()],ft.prototype,"vignetteCenterX",void 0);N([H()],ft.prototype,"vignetteCenterY",void 0);N([H()],ft.prototype,"vignetteWeight",void 0);N([yC()],ft.prototype,"vignetteColor",void 0);N([H()],ft.prototype,"vignetteCameraFov",void 0);N([H()],ft.prototype,"_vignetteBlendMode",void 0);N([H()],ft.prototype,"_vignetteEnabled",void 0);N([H()],ft.prototype,"_ditheringEnabled",void 0);N([H()],ft.prototype,"_ditheringIntensity",void 0);N([H()],ft.prototype,"_skipFinalColorClamp",void 0);N([H()],ft.prototype,"_applyByPostProcess",void 0);N([H()],ft.prototype,"_isEnabled",void 0);N([H()],ft.prototype,"outputTextureWidth",void 0);N([H()],ft.prototype,"outputTextureHeight",void 0);$e._ImageProcessingConfigurationParser=ft.Parse;Tt("BABYLON.ImageProcessingConfiguration",ft);class Vi{constructor(e,t,i,s,r,a){this.source=e,this.pointerX=t,this.pointerY=i,this.meshUnderPointer=s,this.sourceEvent=r,this.additionalData=a}static CreateNew(e,t,i){const s=e.getScene();return new Vi(e,s.pointerX,s.pointerY,s.meshUnderPointer||e,t,i)}static CreateNewFromSprite(e,t,i,s){return new Vi(e,t.pointerX,t.pointerY,t.meshUnderPointer,i,s)}static CreateNewFromScene(e,t){return new Vi(null,e.pointerX,e.pointerY,e.meshUnderPointer,t)}static CreateNewFromPrimitive(e,t,i,s){return new Vi(e,t.x,t.y,null,i,s)}}class cf{constructor(e){this._vertexBuffers={},this.onBeforeRenderObservable=new le,this._scene=e}_prepareBuffers(){if(this._vertexBuffers[O.PositionKind])return;const e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1),this._vertexBuffers[O.PositionKind]=new O(this._scene.getEngine(),e,O.PositionKind,!1,!1,2),this._buildIndexBuffer()}_buildIndexBuffer(){const e=[];e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(e)}_rebuild(){const e=this._vertexBuffers[O.PositionKind];e&&(e._rebuild(),this._buildIndexBuffer())}_prepareFrame(e=null,t=null){const i=this._scene.activeCamera;return!i||(t=t||i._postProcesses.filter(s=>s!=null),!t||t.length===0||!this._scene.postProcessesEnabled)?!1:(t[0].activate(i,e,t!=null),!0)}directRender(e,t=null,i=!1,s=0,r=0,a=!1,o=e.length){const c=this._scene.getEngine();for(let u=0;u<o;u++){u<e.length-1?e[u+1].activate(this._scene.activeCamera||this._scene,t?.texture):(t?c.bindFramebuffer(t,s,void 0,void 0,i,r):a||c.restoreDefaultFramebuffer(),c._debugInsertMarker?.(`post process ${e[u].name} output`));const d=e[u],f=d.apply();f&&(d.onBeforeRenderObservable.notifyObservers(f),this._prepareBuffers(),c.bindBuffers(this._vertexBuffers,this._indexBuffer,f),c.drawElementsType(0,0,6),d.onAfterRenderObservable.notifyObservers(f))}c.setDepthBuffer(!0),c.setDepthWrite(!0)}_finalizeFrame(e,t,i,s,r=!1){const a=this._scene.activeCamera;if(!a||(this.onBeforeRenderObservable.notifyObservers(this),s=s||a._postProcesses.filter(c=>c!=null),s.length===0||!this._scene.postProcessesEnabled))return;const o=this._scene.getEngine();for(let c=0,u=s.length;c<u;c++){const d=s[c];if(c<u-1?d._outputTexture=s[c+1].activate(a,t?.texture):(t?(o.bindFramebuffer(t,i,void 0,void 0,r),d._outputTexture=t):(o.restoreDefaultFramebuffer(),d._outputTexture=null),o._debugInsertMarker?.(`post process ${s[c].name} output`)),e)break;const f=d.apply();f&&(d.onBeforeRenderObservable.notifyObservers(f),this._prepareBuffers(),o.bindBuffers(this._vertexBuffers,this._indexBuffer,f),o.drawElementsType(0,0,6),d.onAfterRenderObservable.notifyObservers(f))}o.setDepthBuffer(!0),o.setDepthWrite(!0),o.setAlphaMode(0)}dispose(){const e=this._vertexBuffers[O.PositionKind];e&&(e.dispose(),this._vertexBuffers[O.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null)}}class Wr{set opaqueSortCompareFn(e){e?this._opaqueSortCompareFn=e:this._opaqueSortCompareFn=Wr.PainterSortCompare,this._renderOpaque=this._renderOpaqueSorted}set alphaTestSortCompareFn(e){e?this._alphaTestSortCompareFn=e:this._alphaTestSortCompareFn=Wr.PainterSortCompare,this._renderAlphaTest=this._renderAlphaTestSorted}set transparentSortCompareFn(e){e?this._transparentSortCompareFn=e:this._transparentSortCompareFn=Wr.defaultTransparentSortCompare,this._renderTransparent=this._renderTransparentSorted}constructor(e,t,i=null,s=null,r=null){this.index=e,this._opaqueSubMeshes=new Yi(256),this._transparentSubMeshes=new Yi(256),this._alphaTestSubMeshes=new Yi(256),this._depthOnlySubMeshes=new Yi(256),this._particleSystems=new Yi(256),this._spriteManagers=new Yi(256),this._empty=!0,this._edgesRenderers=new Do(16),this.disableDepthPrePass=!1,this._scene=t,this.opaqueSortCompareFn=i,this.alphaTestSortCompareFn=s,this.transparentSortCompareFn=r}render(e,t,i,s){if(e){e(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes,this._depthOnlySubMeshes);return}const r=this._scene.getEngine();this._depthOnlySubMeshes.length!==0&&(r.setColorWrite(!1),this._renderAlphaTest(this._depthOnlySubMeshes),r.setColorWrite(!0)),this._opaqueSubMeshes.length!==0&&this._renderOpaque(this._opaqueSubMeshes),this._alphaTestSubMeshes.length!==0&&this._renderAlphaTest(this._alphaTestSubMeshes);const a=r.getStencilBuffer();if(r.setStencilBuffer(!1),t&&this._renderSprites(),i&&this._renderParticles(s),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),this._transparentSubMeshes.length!==0||this._scene.useOrderIndependentTransparency){if(r.setStencilBuffer(a),this._scene.useOrderIndependentTransparency){const o=this._scene.depthPeelingRenderer.render(this._transparentSubMeshes);o.length&&this._renderTransparent(o)}else this._renderTransparent(this._transparentSubMeshes);r.setAlphaMode(0)}if(r.setStencilBuffer(!1),this._edgesRenderers.length){for(let o=0;o<this._edgesRenderers.length;o++)this._edgesRenderers.data[o].render();r.setAlphaMode(0)}r.setStencilBuffer(a)}_renderOpaqueSorted(e){Wr._RenderSorted(e,this._opaqueSortCompareFn,this._scene.activeCamera,!1,this.disableDepthPrePass)}_renderAlphaTestSorted(e){Wr._RenderSorted(e,this._alphaTestSortCompareFn,this._scene.activeCamera,!1,this.disableDepthPrePass)}_renderTransparentSorted(e){Wr._RenderSorted(e,this._transparentSortCompareFn,this._scene.activeCamera,!0,this.disableDepthPrePass)}static _RenderSorted(e,t,i,s,r){let a=0,o;const c=i?i.globalPosition:Wr._ZeroVector;if(s)for(;a<e.length;a++)o=e.data[a],o._alphaIndex=o.getMesh().alphaIndex,o._distanceToCamera=T.Distance(o.getBoundingInfo().boundingSphere.centerWorld,c);const u=e.length===e.data.length?e.data:e.data.slice(0,e.length);t&&u.sort(t);const d=u[0].getMesh().getScene();for(a=0;a<u.length;a++)if(o=u[a],!(d._activeMeshesFrozenButKeepClipping&&!o.isInFrustum(d._frustumPlanes))){if(s){const f=o.getMaterial();if(f&&f.needDepthPrePass&&!r){const g=f.getScene().getEngine();g.setColorWrite(!1),g.setAlphaMode(0),o.render(!1),g.setColorWrite(!0)}}o.render(s)}}static defaultTransparentSortCompare(e,t){return e._alphaIndex>t._alphaIndex?1:e._alphaIndex<t._alphaIndex?-1:Wr.backToFrontSortCompare(e,t)}static backToFrontSortCompare(e,t){return e._distanceToCamera<t._distanceToCamera?1:e._distanceToCamera>t._distanceToCamera?-1:0}static frontToBackSortCompare(e,t){return e._distanceToCamera<t._distanceToCamera?-1:e._distanceToCamera>t._distanceToCamera?1:0}static PainterSortCompare(e,t){const i=e.getMesh(),s=t.getMesh();return i.material&&s.material?i.material.uniqueId-s.material.uniqueId:i.uniqueId-s.uniqueId}prepare(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._depthOnlySubMeshes.reset(),this._particleSystems.reset(),this.prepareSprites(),this._edgesRenderers.reset(),this._empty=!0}prepareSprites(){this._spriteManagers.reset()}dispose(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._depthOnlySubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()}dispatch(e,t,i){t===void 0&&(t=e.getMesh()),i===void 0&&(i=e.getMaterial()),i!=null&&(i.needAlphaBlendingForMesh(t)?this._transparentSubMeshes.push(e):i.needAlphaTestingForMesh(t)?(i.needDepthPrePass&&!this.disableDepthPrePass&&this._depthOnlySubMeshes.push(e),this._alphaTestSubMeshes.push(e)):(i.needDepthPrePass&&!this.disableDepthPrePass&&this._depthOnlySubMeshes.push(e),this._opaqueSubMeshes.push(e)),t._renderingGroup=this,t._edgesRenderer&&t.isEnabled()&&t.isVisible&&t._edgesRenderer.isEnabled&&this._edgesRenderers.pushNoDuplicate(t._edgesRenderer),this._empty=!1)}dispatchSprites(e){this._spriteManagers.push(e),this._empty=!1}dispatchParticles(e){this._particleSystems.push(e),this._empty=!1}_renderParticles(e){if(this._particleSystems.length===0)return;const t=this._scene.activeCamera;this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);for(let i=0;i<this._particleSystems.length;i++){const s=this._particleSystems.data[i];if((t&&t.layerMask&s.layerMask)===0)continue;const r=s.emitter;(!r.position||!e||e.indexOf(r)!==-1)&&this._scene._activeParticles.addCount(s.render(),!1)}this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene)}_renderSprites(){if(!this._scene.spritesEnabled||this._spriteManagers.length===0)return;const e=this._scene.activeCamera;this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);for(let t=0;t<this._spriteManagers.length;t++){const i=this._spriteManagers.data[t];(e&&e.layerMask&i.layerMask)!==0&&i.render()}this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene)}}Wr._ZeroVector=T.Zero();class S3{}class zi{get disableDepthPrePass(){return this._disableDepthPrePass}set disableDepthPrePass(e){this._disableDepthPrePass=e;for(const t of this._renderingGroups)t.disableDepthPrePass=e}get maintainStateBetweenFrames(){return this._maintainStateBetweenFrames}set maintainStateBetweenFrames(e){e!==this._maintainStateBetweenFrames&&(this._maintainStateBetweenFrames=e,this._maintainStateBetweenFrames||this.restoreDispachedFlags())}restoreDispachedFlags(){for(const e of this._scene.meshes)if(e.subMeshes)for(const t of e.subMeshes)t._wasDispatched=!1;if(this._scene.spriteManagers)for(const e of this._scene.spriteManagers)e._wasDispatched=!1;for(const e of this._scene.particleSystems)e._wasDispatched=!1}constructor(e){this._useSceneAutoClearSetup=!1,this._disableDepthPrePass=!1,this._renderingGroups=new Array,this._autoClearDepthStencil={},this._customOpaqueSortCompareFn={},this._customAlphaTestSortCompareFn={},this._customTransparentSortCompareFn={},this._renderingGroupInfo=new S3,this._maintainStateBetweenFrames=!1,this._scene=e;for(let t=zi.MIN_RENDERINGGROUPS;t<zi.MAX_RENDERINGGROUPS;t++)this._autoClearDepthStencil[t]={autoClear:!0,depth:!0,stencil:!0}}getRenderingGroup(e){const t=e||0;return this._prepareRenderingGroup(t),this._renderingGroups[t]}_clearDepthStencilBuffer(e=!0,t=!0){this._depthStencilBufferAlreadyCleaned||(this._scene.getEngine().clear(null,!1,e,t),this._depthStencilBufferAlreadyCleaned=!0)}render(e,t,i,s){const r=this._renderingGroupInfo;if(r.scene=this._scene,r.camera=this._scene.activeCamera,r.renderingManager=this,this._scene.spriteManagers&&s)for(let a=0;a<this._scene.spriteManagers.length;a++){const o=this._scene.spriteManagers[a];this.dispatchSprites(o)}for(let a=zi.MIN_RENDERINGGROUPS;a<zi.MAX_RENDERINGGROUPS;a++){this._depthStencilBufferAlreadyCleaned=a===zi.MIN_RENDERINGGROUPS;const o=this._renderingGroups[a];if(!o||o._empty)continue;const c=1<<a;if(r.renderingGroupId=a,this._scene.onBeforeRenderingGroupObservable.notifyObservers(r,c),zi.AUTOCLEAR){const u=this._useSceneAutoClearSetup?this._scene.getAutoClearDepthStencilSetup(a):this._autoClearDepthStencil[a];u&&u.autoClear&&this._clearDepthStencilBuffer(u.depth,u.stencil)}for(const u of this._scene._beforeRenderingGroupDrawStage)u.action(a);o.render(e,s,i,t);for(const u of this._scene._afterRenderingGroupDrawStage)u.action(a);this._scene.onAfterRenderingGroupObservable.notifyObservers(r,c)}}reset(){if(!this.maintainStateBetweenFrames)for(let e=zi.MIN_RENDERINGGROUPS;e<zi.MAX_RENDERINGGROUPS;e++){const t=this._renderingGroups[e];t&&t.prepare()}}resetSprites(){if(!this.maintainStateBetweenFrames)for(let e=zi.MIN_RENDERINGGROUPS;e<zi.MAX_RENDERINGGROUPS;e++){const t=this._renderingGroups[e];t&&t.prepareSprites()}}dispose(){this.freeRenderingGroups(),this._renderingGroups.length=0,this._renderingGroupInfo=null}freeRenderingGroups(){for(let e=zi.MIN_RENDERINGGROUPS;e<zi.MAX_RENDERINGGROUPS;e++){const t=this._renderingGroups[e];t&&t.dispose()}}_prepareRenderingGroup(e){this._renderingGroups[e]===void 0&&(this._renderingGroups[e]=new Wr(e,this._scene,this._customOpaqueSortCompareFn[e],this._customAlphaTestSortCompareFn[e],this._customTransparentSortCompareFn[e]),this._renderingGroups[e].disableDepthPrePass=this._disableDepthPrePass)}dispatchSprites(e){this.maintainStateBetweenFrames&&e._wasDispatched||(e._wasDispatched=!0,this.getRenderingGroup(e.renderingGroupId).dispatchSprites(e))}dispatchParticles(e){this.maintainStateBetweenFrames&&e._wasDispatched||(e._wasDispatched=!0,this.getRenderingGroup(e.renderingGroupId).dispatchParticles(e))}dispatch(e,t,i){t===void 0&&(t=e.getMesh()),!(this.maintainStateBetweenFrames&&e._wasDispatched)&&(e._wasDispatched=!0,this.getRenderingGroup(t.renderingGroupId).dispatch(e,t,i))}setRenderingOrder(e,t=null,i=null,s=null){if(this._customOpaqueSortCompareFn[e]=t,this._customAlphaTestSortCompareFn[e]=i,this._customTransparentSortCompareFn[e]=s,this._renderingGroups[e]){const r=this._renderingGroups[e];r.opaqueSortCompareFn=this._customOpaqueSortCompareFn[e],r.alphaTestSortCompareFn=this._customAlphaTestSortCompareFn[e],r.transparentSortCompareFn=this._customTransparentSortCompareFn[e]}}setRenderingAutoClearDepthStencil(e,t,i=!0,s=!0){this._autoClearDepthStencil[e]={autoClear:t,depth:i,stencil:s}}getAutoClearDepthStencilSetup(e){return this._autoClearDepthStencil[e]}}zi.MAX_RENDERINGGROUPS=4;zi.MIN_RENDERINGGROUPS=0;zi.AUTOCLEAR=!0;class Ve{}Ve.POINTERDOWN=1;Ve.POINTERUP=2;Ve.POINTERMOVE=4;Ve.POINTERWHEEL=8;Ve.POINTERPICK=16;Ve.POINTERTAP=32;Ve.POINTERDOUBLETAP=64;class $C{constructor(e,t){this.type=e,this.event=t}}class T3 extends $C{constructor(e,t,i,s){super(e,t),this.ray=null,this.originalPickingInfo=null,this.skipOnPointerObservable=!1,this.localPosition=new Ie(i,s)}}class Ar extends $C{get pickInfo(){return this._pickInfo||this._generatePickInfo(),this._pickInfo}constructor(e,t,i,s=null){super(e,t),this._pickInfo=i,this._inputManager=s}_generatePickInfo(){this._inputManager&&(this._pickInfo=this._inputManager._pickMove(this.event),this._inputManager._setRayOnPointerInfo(this._pickInfo,this.event),this._inputManager=null)}}class ir{constructor(){this.hoverCursor="",this.actions=[],this.isRecursive=!1,this.disposeWhenUnowned=!0}static get HasTriggers(){for(const e in ir.Triggers)if(Object.prototype.hasOwnProperty.call(ir.Triggers,e))return!0;return!1}static get HasPickTriggers(){for(const e in ir.Triggers)if(Object.prototype.hasOwnProperty.call(ir.Triggers,e)){const t=parseInt(e);if(t>=1&&t<=7)return!0}return!1}static HasSpecificTrigger(e){for(const t in ir.Triggers)if(Object.prototype.hasOwnProperty.call(ir.Triggers,t)&&parseInt(t)===e)return!0;return!1}}ir.Triggers={};class lc{}lc.KEYDOWN=1;lc.KEYUP=2;class Bm{constructor(e,t){this.type=e,this.event=t}}class ST extends Bm{get skipOnPointerObservable(){return this.skipOnKeyboardObservable}set skipOnPointerObservable(e){this.skipOnKeyboardObservable=e}constructor(e,t){super(e,t),this.type=e,this.event=t,this.skipOnKeyboardObservable=!1}}var ke;(function(n){n[n.Generic=0]="Generic",n[n.Keyboard=1]="Keyboard",n[n.Mouse=2]="Mouse",n[n.Touch=3]="Touch",n[n.DualShock=4]="DualShock",n[n.Xbox=5]="Xbox",n[n.Switch=6]="Switch",n[n.DualSense=7]="DualSense"})(ke||(ke={}));var je;(function(n){n[n.Horizontal=0]="Horizontal",n[n.Vertical=1]="Vertical",n[n.LeftClick=2]="LeftClick",n[n.MiddleClick=3]="MiddleClick",n[n.RightClick=4]="RightClick",n[n.BrowserBack=5]="BrowserBack",n[n.BrowserForward=6]="BrowserForward",n[n.MouseWheelX=7]="MouseWheelX",n[n.MouseWheelY=8]="MouseWheelY",n[n.MouseWheelZ=9]="MouseWheelZ",n[n.Move=12]="Move"})(je||(je={}));var TT;(function(n){n[n.Horizontal=0]="Horizontal",n[n.Vertical=1]="Vertical",n[n.LeftClick=2]="LeftClick",n[n.MiddleClick=3]="MiddleClick",n[n.RightClick=4]="RightClick",n[n.BrowserBack=5]="BrowserBack",n[n.BrowserForward=6]="BrowserForward",n[n.MouseWheelX=7]="MouseWheelX",n[n.MouseWheelY=8]="MouseWheelY",n[n.MouseWheelZ=9]="MouseWheelZ",n[n.DeltaHorizontal=10]="DeltaHorizontal",n[n.DeltaVertical=11]="DeltaVertical"})(TT||(TT={}));var ET;(function(n){n[n.Cross=0]="Cross",n[n.Circle=1]="Circle",n[n.Square=2]="Square",n[n.Triangle=3]="Triangle",n[n.L1=4]="L1",n[n.R1=5]="R1",n[n.L2=6]="L2",n[n.R2=7]="R2",n[n.Share=8]="Share",n[n.Options=9]="Options",n[n.L3=10]="L3",n[n.R3=11]="R3",n[n.DPadUp=12]="DPadUp",n[n.DPadDown=13]="DPadDown",n[n.DPadLeft=14]="DPadLeft",n[n.DPadRight=15]="DPadRight",n[n.Home=16]="Home",n[n.TouchPad=17]="TouchPad",n[n.LStickXAxis=18]="LStickXAxis",n[n.LStickYAxis=19]="LStickYAxis",n[n.RStickXAxis=20]="RStickXAxis",n[n.RStickYAxis=21]="RStickYAxis"})(ET||(ET={}));var AT;(function(n){n[n.Cross=0]="Cross",n[n.Circle=1]="Circle",n[n.Square=2]="Square",n[n.Triangle=3]="Triangle",n[n.L1=4]="L1",n[n.R1=5]="R1",n[n.L2=6]="L2",n[n.R2=7]="R2",n[n.Create=8]="Create",n[n.Options=9]="Options",n[n.L3=10]="L3",n[n.R3=11]="R3",n[n.DPadUp=12]="DPadUp",n[n.DPadDown=13]="DPadDown",n[n.DPadLeft=14]="DPadLeft",n[n.DPadRight=15]="DPadRight",n[n.Home=16]="Home",n[n.TouchPad=17]="TouchPad",n[n.LStickXAxis=18]="LStickXAxis",n[n.LStickYAxis=19]="LStickYAxis",n[n.RStickXAxis=20]="RStickXAxis",n[n.RStickYAxis=21]="RStickYAxis"})(AT||(AT={}));var RT;(function(n){n[n.A=0]="A",n[n.B=1]="B",n[n.X=2]="X",n[n.Y=3]="Y",n[n.LB=4]="LB",n[n.RB=5]="RB",n[n.LT=6]="LT",n[n.RT=7]="RT",n[n.Back=8]="Back",n[n.Start=9]="Start",n[n.LS=10]="LS",n[n.RS=11]="RS",n[n.DPadUp=12]="DPadUp",n[n.DPadDown=13]="DPadDown",n[n.DPadLeft=14]="DPadLeft",n[n.DPadRight=15]="DPadRight",n[n.Home=16]="Home",n[n.LStickXAxis=17]="LStickXAxis",n[n.LStickYAxis=18]="LStickYAxis",n[n.RStickXAxis=19]="RStickXAxis",n[n.RStickYAxis=20]="RStickYAxis"})(RT||(RT={}));var MT;(function(n){n[n.B=0]="B",n[n.A=1]="A",n[n.Y=2]="Y",n[n.X=3]="X",n[n.L=4]="L",n[n.R=5]="R",n[n.ZL=6]="ZL",n[n.ZR=7]="ZR",n[n.Minus=8]="Minus",n[n.Plus=9]="Plus",n[n.LS=10]="LS",n[n.RS=11]="RS",n[n.DPadUp=12]="DPadUp",n[n.DPadDown=13]="DPadDown",n[n.DPadLeft=14]="DPadLeft",n[n.DPadRight=15]="DPadRight",n[n.Home=16]="Home",n[n.Capture=17]="Capture",n[n.LStickXAxis=18]="LStickXAxis",n[n.LStickYAxis=19]="LStickYAxis",n[n.RStickXAxis=20]="RStickXAxis",n[n.RStickYAxis=21]="RStickYAxis"})(MT||(MT={}));var CT;(function(n){n[n.PointerMove=0]="PointerMove",n[n.PointerDown=1]="PointerDown",n[n.PointerUp=2]="PointerUp"})(CT||(CT={}));class gc{}gc.DOM_DELTA_PIXEL=0;gc.DOM_DELTA_LINE=1;gc.DOM_DELTA_PAGE=2;class Oo{static CreateDeviceEvent(e,t,i,s,r,a,o){switch(e){case ke.Keyboard:return this._CreateKeyboardEvent(i,s,r,a);case ke.Mouse:if(i===je.MouseWheelX||i===je.MouseWheelY||i===je.MouseWheelZ)return this._CreateWheelEvent(e,t,i,s,r,a);case ke.Touch:return this._CreatePointerEvent(e,t,i,s,r,a,o);default:throw`Unable to generate event for device ${ke[e]}`}}static _CreatePointerEvent(e,t,i,s,r,a,o){const c=this._CreateMouseEvent(e,t,i,s,r,a);e===ke.Mouse?(c.deviceType=ke.Mouse,c.pointerId=1,c.pointerType="mouse"):(c.deviceType=ke.Touch,c.pointerId=o??t,c.pointerType="touch");let u=0;return u+=r.pollInput(e,t,je.LeftClick),u+=r.pollInput(e,t,je.RightClick)*2,u+=r.pollInput(e,t,je.MiddleClick)*4,c.buttons=u,i===je.Move?c.type="pointermove":i>=je.LeftClick&&i<=je.RightClick&&(c.type=s===1?"pointerdown":"pointerup",c.button=i-2),c}static _CreateWheelEvent(e,t,i,s,r,a){const o=this._CreateMouseEvent(e,t,i,s,r,a);switch(o.pointerId=1,o.type="wheel",o.deltaMode=gc.DOM_DELTA_PIXEL,o.deltaX=0,o.deltaY=0,o.deltaZ=0,i){case je.MouseWheelX:o.deltaX=s;break;case je.MouseWheelY:o.deltaY=s;break;case je.MouseWheelZ:o.deltaZ=s;break}return o}static _CreateMouseEvent(e,t,i,s,r,a){const o=this._CreateEvent(a),c=r.pollInput(e,t,je.Horizontal),u=r.pollInput(e,t,je.Vertical);return a?(o.movementX=0,o.movementY=0,o.offsetX=o.movementX-a.getBoundingClientRect().x,o.offsetY=o.movementY-a.getBoundingClientRect().y):(o.movementX=r.pollInput(e,t,10),o.movementY=r.pollInput(e,t,11),o.offsetX=0,o.offsetY=0),this._CheckNonCharacterKeys(o,r),o.clientX=c,o.clientY=u,o.x=c,o.y=u,o.deviceType=e,o.deviceSlot=t,o.inputIndex=i,o}static _CreateKeyboardEvent(e,t,i,s){const r=this._CreateEvent(s);return this._CheckNonCharacterKeys(r,i),r.deviceType=ke.Keyboard,r.deviceSlot=0,r.inputIndex=e,r.type=t===1?"keydown":"keyup",r.key=String.fromCharCode(e),r.keyCode=e,r}static _CheckNonCharacterKeys(e,t){const i=t.isDeviceAvailable(ke.Keyboard),s=i&&t.pollInput(ke.Keyboard,0,18)===1,r=i&&t.pollInput(ke.Keyboard,0,17)===1,a=i&&(t.pollInput(ke.Keyboard,0,91)===1||t.pollInput(ke.Keyboard,0,92)===1||t.pollInput(ke.Keyboard,0,93)===1),o=i&&t.pollInput(ke.Keyboard,0,16)===1;e.altKey=s,e.ctrlKey=r,e.metaKey=a,e.shiftKey=o}static _CreateEvent(e){const t={};return t.preventDefault=()=>{},t.target=e,t}}class E3{constructor(e,t,i){this._nativeInput=_native.DeviceInputSystem?new _native.DeviceInputSystem(e,t,(s,r,a,o)=>{const c=Oo.CreateDeviceEvent(s,r,a,o,this);i(s,r,c)}):this._createDummyNativeInput()}pollInput(e,t,i){return this._nativeInput.pollInput(e,t,i)}isDeviceAvailable(e){return e===ke.Mouse||e===ke.Touch}dispose(){this._nativeInput.dispose()}_createDummyNativeInput(){return{pollInput:()=>0,isDeviceAvailable:()=>!1,dispose:()=>{}}}}const IT=255,PT=Object.keys(je).length/2;class A3{constructor(e,t,i,s){this._inputs=[],this._keyboardActive=!1,this._pointerActive=!1,this._usingSafari=pe.IsSafari(),this._usingMacOs=Xl()&&/(Mac|iPhone|iPod|iPad)/i.test(navigator.platform),this._keyboardDownEvent=r=>{},this._keyboardUpEvent=r=>{},this._keyboardBlurEvent=r=>{},this._pointerMoveEvent=r=>{},this._pointerDownEvent=r=>{},this._pointerUpEvent=r=>{},this._pointerCancelEvent=r=>{},this._pointerCancelTouch=r=>{},this._pointerLeaveEvent=r=>{},this._pointerWheelEvent=r=>{},this._pointerBlurEvent=r=>{},this._pointerMacOsChromeOutEvent=r=>{},this._eventsAttached=!1,this._mouseId=-1,this._isUsingFirefox=Xl()&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox")!==-1,this._isUsingChromium=Xl()&&navigator.userAgent&&navigator.userAgent.indexOf("Chrome")!==-1,this._maxTouchPoints=0,this._pointerInputClearObserver=null,this._gamepadConnectedEvent=r=>{},this._gamepadDisconnectedEvent=r=>{},this._eventPrefix=pe.GetPointerPrefix(e),this._engine=e,this._onDeviceConnected=t,this._onDeviceDisconnected=i,this._onInputChanged=s,this._mouseId=this._isUsingFirefox?0:1,this._enableEvents(),this._usingMacOs&&(this._metaKeys=[]),this._engine._onEngineViewChanged||(this._engine._onEngineViewChanged=()=>{this._enableEvents()})}pollInput(e,t,i){const s=this._inputs[e][t];if(!s)throw`Unable to find device ${ke[e]}`;e>=ke.DualShock&&e<=ke.DualSense&&this._updateDevice(e,t,i);const r=s[i];if(r===void 0)throw`Unable to find input ${i} for device ${ke[e]} in slot ${t}`;return i===je.Move&&pe.Warn("Unable to provide information for PointerInput.Move. Try using PointerInput.Horizontal or PointerInput.Vertical for move data."),r}isDeviceAvailable(e){return this._inputs[e]!==void 0}dispose(){this._onDeviceConnected=()=>{},this._onDeviceDisconnected=()=>{},this._onInputChanged=()=>{},delete this._engine._onEngineViewChanged,this._elementToAttachTo&&this._disableEvents()}_enableEvents(){const e=this?._engine.getInputElement();if(e&&(!this._eventsAttached||this._elementToAttachTo!==e)){if(this._disableEvents(),this._inputs){for(const t of this._inputs)if(t)for(const i in t){const s=+i,r=t[s];if(r)for(let a=0;a<r.length;a++)r[a]=0}}this._elementToAttachTo=e,this._elementToAttachTo.tabIndex=this._elementToAttachTo.tabIndex!==-1?this._elementToAttachTo.tabIndex:this._engine.canvasTabIndex,this._handleKeyActions(),this._handlePointerActions(),this._handleGamepadActions(),this._eventsAttached=!0,this._checkForConnectedDevices()}}_disableEvents(){this._elementToAttachTo&&(this._elementToAttachTo.removeEventListener("blur",this._keyboardBlurEvent),this._elementToAttachTo.removeEventListener("blur",this._pointerBlurEvent),this._elementToAttachTo.removeEventListener("keydown",this._keyboardDownEvent),this._elementToAttachTo.removeEventListener("keyup",this._keyboardUpEvent),this._elementToAttachTo.removeEventListener(this._eventPrefix+"move",this._pointerMoveEvent),this._elementToAttachTo.removeEventListener(this._eventPrefix+"down",this._pointerDownEvent),this._elementToAttachTo.removeEventListener(this._eventPrefix+"up",this._pointerUpEvent),this._elementToAttachTo.removeEventListener(this._eventPrefix+"cancel",this._pointerCancelEvent),this._elementToAttachTo.removeEventListener(this._eventPrefix+"leave",this._pointerLeaveEvent),this._elementToAttachTo.removeEventListener(this._wheelEventName,this._pointerWheelEvent),this._usingMacOs&&this._isUsingChromium&&this._elementToAttachTo.removeEventListener("lostpointercapture",this._pointerMacOsChromeOutEvent),window.removeEventListener("gamepadconnected",this._gamepadConnectedEvent),window.removeEventListener("gamepaddisconnected",this._gamepadDisconnectedEvent)),this._pointerInputClearObserver&&this._engine.onEndFrameObservable.remove(this._pointerInputClearObserver),this._eventsAttached=!1}_checkForConnectedDevices(){if(navigator.getGamepads){const e=navigator.getGamepads();for(const t of e)t&&this._addGamePad(t)}typeof matchMedia=="function"&&matchMedia("(pointer:fine)").matches&&this._addPointerDevice(ke.Mouse,0,0,0)}_addGamePad(e){const t=this._getGamepadDeviceType(e.id),i=e.index;this._gamepads=this._gamepads||new Array(e.index+1),this._registerDevice(t,i,e.buttons.length+e.axes.length),this._gamepads[i]=t}_addPointerDevice(e,t,i,s){this._pointerActive||(this._pointerActive=!0),this._registerDevice(e,t,PT);const r=this._inputs[e][t];r[0]=i,r[1]=s}_registerDevice(e,t,i){if(t===void 0)throw`Unable to register device ${ke[e]} to undefined slot.`;if(this._inputs[e]||(this._inputs[e]={}),!this._inputs[e][t]){const s=new Array(i);s.fill(0),this._inputs[e][t]=s,this._onDeviceConnected(e,t)}}_unregisterDevice(e,t){this._inputs[e][t]&&(delete this._inputs[e][t],this._onDeviceDisconnected(e,t))}_handleKeyActions(){this._keyboardDownEvent=e=>{this._keyboardActive||(this._keyboardActive=!0,this._registerDevice(ke.Keyboard,0,IT));const t=this._inputs[ke.Keyboard][0];if(t){t[e.keyCode]=1;const i=e;i.inputIndex=e.keyCode,this._usingMacOs&&e.metaKey&&e.key!=="Meta"&&(this._metaKeys.includes(e.keyCode)||this._metaKeys.push(e.keyCode)),this._onInputChanged(ke.Keyboard,0,i)}},this._keyboardUpEvent=e=>{this._keyboardActive||(this._keyboardActive=!0,this._registerDevice(ke.Keyboard,0,IT));const t=this._inputs[ke.Keyboard][0];if(t){t[e.keyCode]=0;const i=e;if(i.inputIndex=e.keyCode,this._usingMacOs&&e.key==="Meta"&&this._metaKeys.length>0){for(const s of this._metaKeys){const r=Oo.CreateDeviceEvent(ke.Keyboard,0,s,0,this,this._elementToAttachTo);t[s]=0,this._onInputChanged(ke.Keyboard,0,r)}this._metaKeys.splice(0,this._metaKeys.length)}this._onInputChanged(ke.Keyboard,0,i)}},this._keyboardBlurEvent=()=>{if(this._keyboardActive){const e=this._inputs[ke.Keyboard][0];for(let t=0;t<e.length;t++)if(e[t]!==0){e[t]=0;const i=Oo.CreateDeviceEvent(ke.Keyboard,0,t,0,this,this._elementToAttachTo);this._onInputChanged(ke.Keyboard,0,i)}this._usingMacOs&&this._metaKeys.splice(0,this._metaKeys.length)}},this._elementToAttachTo.addEventListener("keydown",this._keyboardDownEvent),this._elementToAttachTo.addEventListener("keyup",this._keyboardUpEvent),this._elementToAttachTo.addEventListener("blur",this._keyboardBlurEvent)}_handlePointerActions(){this._maxTouchPoints=Xl()&&navigator.maxTouchPoints||2,this._activeTouchIds||(this._activeTouchIds=new Array(this._maxTouchPoints));for(let i=0;i<this._maxTouchPoints;i++)this._activeTouchIds[i]=-1;this._pointerMoveEvent=i=>{const s=this._getPointerType(i);let r=s===ke.Mouse?0:this._activeTouchIds.indexOf(i.pointerId);if(s===ke.Touch&&r===-1){const o=this._activeTouchIds.indexOf(-1);if(o>=0)r=o,this._activeTouchIds[o]=i.pointerId,this._onDeviceConnected(s,r);else{pe.Warn(`Max number of touches exceeded. Ignoring touches in excess of ${this._maxTouchPoints}`);return}}this._inputs[s]||(this._inputs[s]={}),this._inputs[s][r]||this._addPointerDevice(s,r,i.clientX,i.clientY);const a=this._inputs[s][r];if(a){const o=i;o.inputIndex=je.Move,a[je.Horizontal]=i.clientX,a[je.Vertical]=i.clientY,s===ke.Touch&&a[je.LeftClick]===0&&(a[je.LeftClick]=1),i.pointerId===void 0&&(i.pointerId=this._mouseId),this._onInputChanged(s,r,o),!this._usingSafari&&i.button!==-1&&(o.inputIndex=i.button+2,a[i.button+2]=a[i.button+2]?0:1,this._onInputChanged(s,r,o))}},this._pointerDownEvent=i=>{const s=this._getPointerType(i);let r=s===ke.Mouse?0:i.pointerId;if(s===ke.Touch){let o=this._activeTouchIds.indexOf(i.pointerId);if(o===-1&&(o=this._activeTouchIds.indexOf(-1)),o>=0)r=o,this._activeTouchIds[o]=i.pointerId;else{pe.Warn(`Max number of touches exceeded. Ignoring touches in excess of ${this._maxTouchPoints}`);return}}this._inputs[s]||(this._inputs[s]={}),this._inputs[s][r]?s===ke.Touch&&this._onDeviceConnected(s,r):this._addPointerDevice(s,r,i.clientX,i.clientY);const a=this._inputs[s][r];if(a){const o=a[je.Horizontal],c=a[je.Vertical];if(s===ke.Mouse){if(i.pointerId===void 0&&(i.pointerId=this._mouseId),!document.pointerLockElement)try{this._elementToAttachTo.setPointerCapture(this._mouseId)}catch{}}else if(i.pointerId&&!document.pointerLockElement)try{this._elementToAttachTo.setPointerCapture(i.pointerId)}catch{}a[je.Horizontal]=i.clientX,a[je.Vertical]=i.clientY,a[i.button+2]=1;const u=i;u.inputIndex=i.button+2,this._onInputChanged(s,r,u),(o!==i.clientX||c!==i.clientY)&&(u.inputIndex=je.Move,this._onInputChanged(s,r,u))}},this._pointerUpEvent=i=>{const s=this._getPointerType(i),r=s===ke.Mouse?0:this._activeTouchIds.indexOf(i.pointerId);if(s===ke.Touch){if(r===-1)return;this._activeTouchIds[r]=-1}const a=this._inputs[s]?.[r];let o=i.button,c=a&&a[o+2]!==0;if(!c&&this._isUsingFirefox&&this._usingMacOs&&a&&(o=o===2?0:2,c=a[o+2]!==0),c){const u=a[je.Horizontal],d=a[je.Vertical];a[je.Horizontal]=i.clientX,a[je.Vertical]=i.clientY,a[o+2]=0;const f=i;i.pointerId===void 0&&(i.pointerId=this._mouseId),(u!==i.clientX||d!==i.clientY)&&(f.inputIndex=je.Move,this._onInputChanged(s,r,f)),f.inputIndex=o+2,s===ke.Mouse&&this._mouseId>=0&&this._elementToAttachTo.hasPointerCapture?.(this._mouseId)?this._elementToAttachTo.releasePointerCapture(this._mouseId):i.pointerId&&this._elementToAttachTo.hasPointerCapture?.(i.pointerId)&&this._elementToAttachTo.releasePointerCapture(i.pointerId),this._onInputChanged(s,r,f),s===ke.Touch&&this._onDeviceDisconnected(s,r)}},this._pointerCancelTouch=i=>{const s=this._activeTouchIds.indexOf(i);if(s===-1)return;this._elementToAttachTo.hasPointerCapture?.(i)&&this._elementToAttachTo.releasePointerCapture(i),this._inputs[ke.Touch][s][je.LeftClick]=0;const r=Oo.CreateDeviceEvent(ke.Touch,s,je.LeftClick,0,this,this._elementToAttachTo,i);this._onInputChanged(ke.Touch,s,r),this._activeTouchIds[s]=-1,this._onDeviceDisconnected(ke.Touch,s)},this._pointerCancelEvent=i=>{if(i.pointerType==="mouse"){const s=this._inputs[ke.Mouse][0];this._mouseId>=0&&this._elementToAttachTo.hasPointerCapture?.(this._mouseId)&&this._elementToAttachTo.releasePointerCapture(this._mouseId);for(let r=je.LeftClick;r<=je.BrowserForward;r++)if(s[r]===1){s[r]=0;const a=Oo.CreateDeviceEvent(ke.Mouse,0,r,0,this,this._elementToAttachTo);this._onInputChanged(ke.Mouse,0,a)}}else this._pointerCancelTouch(i.pointerId)},this._pointerLeaveEvent=i=>{i.pointerType==="pen"&&this._pointerCancelTouch(i.pointerId)},this._wheelEventName="onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll";let e=!1;const t=function(){};try{const i=Object.defineProperty({},"passive",{get:function(){e=!0}});this._elementToAttachTo.addEventListener("test",t,i),this._elementToAttachTo.removeEventListener("test",t,i)}catch{}this._pointerBlurEvent=()=>{if(this.isDeviceAvailable(ke.Mouse)){const i=this._inputs[ke.Mouse][0];this._mouseId>=0&&this._elementToAttachTo.hasPointerCapture?.(this._mouseId)&&this._elementToAttachTo.releasePointerCapture(this._mouseId);for(let s=je.LeftClick;s<=je.BrowserForward;s++)if(i[s]===1){i[s]=0;const r=Oo.CreateDeviceEvent(ke.Mouse,0,s,0,this,this._elementToAttachTo);this._onInputChanged(ke.Mouse,0,r)}}if(this.isDeviceAvailable(ke.Touch)){const i=this._inputs[ke.Touch];for(let s=0;s<this._activeTouchIds.length;s++){const r=this._activeTouchIds[s];if(this._elementToAttachTo.hasPointerCapture?.(r)&&this._elementToAttachTo.releasePointerCapture(r),r!==-1&&i[s]?.[je.LeftClick]===1){i[s][je.LeftClick]=0;const a=Oo.CreateDeviceEvent(ke.Touch,s,je.LeftClick,0,this,this._elementToAttachTo,r);this._onInputChanged(ke.Touch,s,a),this._activeTouchIds[s]=-1,this._onDeviceDisconnected(ke.Touch,s)}}}},this._pointerWheelEvent=i=>{const s=ke.Mouse,r=0;this._inputs[s]||(this._inputs[s]=[]),this._inputs[s][r]||(this._pointerActive=!0,this._registerDevice(s,r,PT));const a=this._inputs[s][r];if(a){a[je.MouseWheelX]=i.deltaX||0,a[je.MouseWheelY]=i.deltaY||i.wheelDelta||0,a[je.MouseWheelZ]=i.deltaZ||0;const o=i;i.pointerId===void 0&&(i.pointerId=this._mouseId),a[je.MouseWheelX]!==0&&(o.inputIndex=je.MouseWheelX,this._onInputChanged(s,r,o)),a[je.MouseWheelY]!==0&&(o.inputIndex=je.MouseWheelY,this._onInputChanged(s,r,o)),a[je.MouseWheelZ]!==0&&(o.inputIndex=je.MouseWheelZ,this._onInputChanged(s,r,o))}},this._usingMacOs&&this._isUsingChromium&&(this._pointerMacOsChromeOutEvent=i=>{i.buttons>1&&this._pointerCancelEvent(i)},this._elementToAttachTo.addEventListener("lostpointercapture",this._pointerMacOsChromeOutEvent)),this._elementToAttachTo.addEventListener(this._eventPrefix+"move",this._pointerMoveEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"down",this._pointerDownEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"up",this._pointerUpEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"cancel",this._pointerCancelEvent),this._elementToAttachTo.addEventListener(this._eventPrefix+"leave",this._pointerLeaveEvent),this._elementToAttachTo.addEventListener("blur",this._pointerBlurEvent),this._elementToAttachTo.addEventListener(this._wheelEventName,this._pointerWheelEvent,e?{passive:!1}:!1),this._pointerInputClearObserver=this._engine.onEndFrameObservable.add(()=>{if(this.isDeviceAvailable(ke.Mouse)){const i=this._inputs[ke.Mouse][0];i[je.MouseWheelX]=0,i[je.MouseWheelY]=0,i[je.MouseWheelZ]=0}})}_handleGamepadActions(){this._gamepadConnectedEvent=e=>{this._addGamePad(e.gamepad)},this._gamepadDisconnectedEvent=e=>{if(this._gamepads){const t=this._getGamepadDeviceType(e.gamepad.id),i=e.gamepad.index;this._unregisterDevice(t,i),delete this._gamepads[i]}},window.addEventListener("gamepadconnected",this._gamepadConnectedEvent),window.addEventListener("gamepaddisconnected",this._gamepadDisconnectedEvent)}_updateDevice(e,t,i){const s=navigator.getGamepads()[t];if(s&&e===this._gamepads[t]){const r=this._inputs[e][t];i>=s.buttons.length?r[i]=s.axes[i-s.buttons.length].valueOf():r[i]=s.buttons[i].value}}_getGamepadDeviceType(e){return e.indexOf("054c")!==-1?e.indexOf("0ce6")!==-1?ke.DualSense:ke.DualShock:e.indexOf("Xbox One")!==-1||e.search("Xbox 360")!==-1||e.search("xinput")!==-1?ke.Xbox:e.indexOf("057e")!==-1?ke.Switch:ke.Generic}_getPointerType(e){let t=ke.Mouse;return(e.pointerType==="touch"||e.pointerType==="pen"||e.touches)&&(t=ke.Touch),t}}class DT{constructor(e,t,i=0){this.deviceType=t,this.deviceSlot=i,this.onInputChangedObservable=new le,this._deviceInputSystem=e}getInput(e){return this._deviceInputSystem.pollInput(this.deviceType,this.deviceSlot,e)}}class R3{constructor(e){this._registeredManagers=new Array,this._refCount=0,this.registerManager=a=>{for(let o=0;o<this._devices.length;o++){const c=this._devices[o];for(const u in c){const d=+u;a._addDevice(new DT(this._deviceInputSystem,o,d))}}this._registeredManagers.push(a)},this.unregisterManager=a=>{const o=this._registeredManagers.indexOf(a);o>-1&&this._registeredManagers.splice(o,1)};const t=Object.keys(ke).length/2;this._devices=new Array(t);const i=(a,o)=>{this._devices[a]||(this._devices[a]=new Array),this._devices[a][o]||(this._devices[a][o]=o);for(const c of this._registeredManagers){const u=new DT(this._deviceInputSystem,a,o);c._addDevice(u)}},s=(a,o)=>{this._devices[a]?.[o]&&delete this._devices[a][o];for(const c of this._registeredManagers)c._removeDevice(a,o)},r=(a,o,c)=>{if(c)for(const u of this._registeredManagers)u._onInputChanged(a,o,c)};typeof _native<"u"?this._deviceInputSystem=new E3(i,s,r):this._deviceInputSystem=new A3(e,i,s,r)}dispose(){this._deviceInputSystem.dispose()}}class M3{getDeviceSource(e,t){if(t===void 0){if(this._firstDevice[e]===void 0)return null;t=this._firstDevice[e]}return!this._devices[e]||this._devices[e][t]===void 0?null:this._devices[e][t]}getDeviceSources(e){return this._devices[e]?this._devices[e].filter(t=>!!t):[]}constructor(e){const t=Object.keys(ke).length/2;this._devices=new Array(t),this._firstDevice=new Array(t),this._engine=e,this._engine._deviceSourceManager||(this._engine._deviceSourceManager=new R3(e)),this._engine._deviceSourceManager._refCount++,this.onDeviceConnectedObservable=new le(i=>{for(const s of this._devices)if(s)for(const r of s)r&&this.onDeviceConnectedObservable.notifyObserver(i,r)}),this.onDeviceDisconnectedObservable=new le,this._engine._deviceSourceManager.registerManager(this),this._onDisposeObserver=e.onDisposeObservable.add(()=>{this.dispose()})}dispose(){this.onDeviceConnectedObservable.clear(),this.onDeviceDisconnectedObservable.clear(),this._engine._deviceSourceManager&&(this._engine._deviceSourceManager.unregisterManager(this),--this._engine._deviceSourceManager._refCount<1&&(this._engine._deviceSourceManager.dispose(),delete this._engine._deviceSourceManager)),this._engine.onDisposeObservable.remove(this._onDisposeObserver)}_addDevice(e){this._devices[e.deviceType]||(this._devices[e.deviceType]=[]),this._devices[e.deviceType][e.deviceSlot]||(this._devices[e.deviceType][e.deviceSlot]=e,this._updateFirstDevices(e.deviceType)),this.onDeviceConnectedObservable.notifyObservers(e)}_removeDevice(e,t){const i=this._devices[e]?.[t];this.onDeviceDisconnectedObservable.notifyObservers(i),this._devices[e]?.[t]&&delete this._devices[e][t],this._updateFirstDevices(e)}_onInputChanged(e,t,i){this._devices[e]?.[t]?.onInputChangedObservable.notifyObservers(i)}_updateFirstDevices(e){switch(e){case ke.Keyboard:case ke.Mouse:this._firstDevice[e]=0;break;case ke.Touch:case ke.DualSense:case ke.DualShock:case ke.Xbox:case ke.Switch:case ke.Generic:{delete this._firstDevice[e];const t=this._devices[e];if(t){for(let i=0;i<t.length;i++)if(t[i]){this._firstDevice[e]=i;break}}break}}}}class kb{}kb._IsPickingAvailable=!1;class OT{constructor(){this._singleClick=!1,this._doubleClick=!1,this._hasSwiped=!1,this._ignore=!1}get singleClick(){return this._singleClick}get doubleClick(){return this._doubleClick}get hasSwiped(){return this._hasSwiped}get ignore(){return this._ignore}set singleClick(e){this._singleClick=e}set doubleClick(e){this._doubleClick=e}set hasSwiped(e){this._hasSwiped=e}set ignore(e){this._ignore=e}}class oi{constructor(e){this._alreadyAttached=!1,this._meshPickProceed=!1,this._currentPickResult=null,this._previousPickResult=null,this._activePointerIds=new Array,this._activePointerIdsCount=0,this._doubleClickOccured=!1,this._isSwiping=!1,this._swipeButtonPressed=-1,this._skipPointerTap=!1,this._isMultiTouchGesture=!1,this._pointerX=0,this._pointerY=0,this._startingPointerPosition=new Ie(0,0),this._previousStartingPointerPosition=new Ie(0,0),this._startingPointerTime=0,this._previousStartingPointerTime=0,this._pointerCaptures={},this._meshUnderPointerId={},this._movePointerInfo=null,this._cameraObserverCount=0,this._delayedClicks=[null,null,null,null,null],this._deviceSourceManager=null,this._scene=e||Ke.LastCreatedScene,this._scene}get meshUnderPointer(){return this._movePointerInfo&&(this._movePointerInfo._generatePickInfo(),this._movePointerInfo=null),this._pointerOverMesh}getMeshUnderPointerByPointerId(e){return this._meshUnderPointerId[e]||null}get unTranslatedPointer(){return new Ie(this._unTranslatedPointerX,this._unTranslatedPointerY)}get pointerX(){return this._pointerX}set pointerX(e){this._pointerX=e}get pointerY(){return this._pointerY}set pointerY(e){this._pointerY=e}_updatePointerPosition(e){const t=this._scene.getEngine().getInputElementClientRect();t&&(this._pointerX=e.clientX-t.left,this._pointerY=e.clientY-t.top,this._unTranslatedPointerX=this._pointerX,this._unTranslatedPointerY=this._pointerY)}_processPointerMove(e,t){const i=this._scene,s=i.getEngine(),r=s.getInputElement();r&&(r.tabIndex=s.canvasTabIndex,i.doNotHandleCursors||(r.style.cursor=i.defaultCursor)),this._setCursorAndPointerOverMesh(e,t,i);for(const c of i._pointerMoveStage){e=e||this._pickMove(t);const u=!!e?.pickedMesh;e=c.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,u,r)}const a=t.inputIndex>=je.MouseWheelX&&t.inputIndex<=je.MouseWheelZ?Ve.POINTERWHEEL:Ve.POINTERMOVE;i.onPointerMove&&(e=e||this._pickMove(t),i.onPointerMove(t,e,a));let o;e?(o=new Ar(a,t,e),this._setRayOnPointerInfo(e,t)):(o=new Ar(a,t,null,this),this._movePointerInfo=o),i.onPointerObservable.hasObservers()&&i.onPointerObservable.notifyObservers(o,a)}_setRayOnPointerInfo(e,t){const i=this._scene;e&&kb._IsPickingAvailable&&(e.ray||(e.ray=i.createPickingRay(t.offsetX,t.offsetY,W.Identity(),i.activeCamera)))}_addCameraPointerObserver(e,t){return this._cameraObserverCount++,this._scene.onPointerObservable.add(e,t)}_removeCameraPointerObserver(e){return this._cameraObserverCount--,this._scene.onPointerObservable.remove(e)}_checkForPicking(){return!!(this._scene.onPointerObservable.observers.length>this._cameraObserverCount||this._scene.onPointerPick)}_checkPrePointerObservable(e,t,i){const s=this._scene,r=new T3(i,t,this._unTranslatedPointerX,this._unTranslatedPointerY);return e&&(r.originalPickingInfo=e,r.ray=e.ray,t.pointerType==="xr-near"&&e.originMesh&&(r.nearInteractionPickingInfo=e)),s.onPrePointerObservable.notifyObservers(r,i),!!r.skipOnPointerObservable}_pickMove(e){const t=this._scene,i=t.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,t.pointerMovePredicate,t.pointerMoveFastCheck,t.cameraToUseForPointers,t.pointerMoveTrianglePredicate);return this._setCursorAndPointerOverMesh(i,e,t),i}_setCursorAndPointerOverMesh(e,t,i){const r=i.getEngine().getInputElement();if(e?.pickedMesh){if(this.setPointerOverMesh(e.pickedMesh,t.pointerId,e,t),!i.doNotHandleCursors&&r&&this._pointerOverMesh){const a=this._pointerOverMesh._getActionManagerForTrigger();a&&a.hasPointerTriggers&&(r.style.cursor=a.hoverCursor||i.hoverCursor)}}else this.setPointerOverMesh(null,t.pointerId,e,t)}simulatePointerMove(e,t){const i=new PointerEvent("pointermove",t);i.inputIndex=je.Move,!this._checkPrePointerObservable(e,i,Ve.POINTERMOVE)&&this._processPointerMove(e,i)}simulatePointerDown(e,t){const i=new PointerEvent("pointerdown",t);i.inputIndex=i.button+2,!this._checkPrePointerObservable(e,i,Ve.POINTERDOWN)&&this._processPointerDown(e,i)}_processPointerDown(e,t){const i=this._scene;if(e?.pickedMesh){this._pickedDownMesh=e.pickedMesh;const a=e.pickedMesh._getActionManagerForTrigger();if(a){if(a.hasPickTriggers)switch(a.processTrigger(5,new Vi(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e)),t.button){case 0:a.processTrigger(2,new Vi(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e));break;case 1:a.processTrigger(4,new Vi(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e));break;case 2:a.processTrigger(3,new Vi(e.pickedMesh,i.pointerX,i.pointerY,e.pickedMesh,t,e));break}a.hasSpecificTrigger(8)&&window.setTimeout(()=>{const o=i.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,c=>c.isPickable&&c.isVisible&&c.isReady()&&c.actionManager&&c.actionManager.hasSpecificTrigger(8)&&c===this._pickedDownMesh,!1,i.cameraToUseForPointers);o?.pickedMesh&&a&&this._activePointerIdsCount!==0&&Date.now()-this._startingPointerTime>oi.LongPressDelay&&!this._isPointerSwiping()&&(this._startingPointerTime=0,a.processTrigger(8,Vi.CreateNew(o.pickedMesh,t)))},oi.LongPressDelay)}}else for(const a of i._pointerDownStage)e=a.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t,!1);let s;const r=Ve.POINTERDOWN;e?(i.onPointerDown&&i.onPointerDown(t,e,r),s=new Ar(r,t,e),this._setRayOnPointerInfo(e,t)):s=new Ar(r,t,null,this),i.onPointerObservable.hasObservers()&&i.onPointerObservable.notifyObservers(s,r)}_isPointerSwiping(){return this._isSwiping}simulatePointerUp(e,t,i){const s=new PointerEvent("pointerup",t);s.inputIndex=je.Move;const r=new OT;i?r.doubleClick=!0:r.singleClick=!0,!this._checkPrePointerObservable(e,s,Ve.POINTERUP)&&this._processPointerUp(e,s,r)}_processPointerUp(e,t,i){const s=this._scene;if(e?.pickedMesh){if(this._pickedUpMesh=e.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(s.onPointerPick&&s.onPointerPick(t,e),i.singleClick&&!i.ignore&&s.onPointerObservable.observers.length>this._cameraObserverCount)){const a=Ve.POINTERPICK,o=new Ar(a,t,e);this._setRayOnPointerInfo(e,t),s.onPointerObservable.notifyObservers(o,a)}const r=e.pickedMesh._getActionManagerForTrigger();if(r&&!i.ignore){r.processTrigger(7,Vi.CreateNew(e.pickedMesh,t,e)),!i.hasSwiped&&i.singleClick&&r.processTrigger(1,Vi.CreateNew(e.pickedMesh,t,e));const a=e.pickedMesh._getActionManagerForTrigger(6);i.doubleClick&&a&&a.processTrigger(6,Vi.CreateNew(e.pickedMesh,t,e))}}else if(!i.ignore)for(const r of s._pointerUpStage)e=r.action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t,i.doubleClick);if(this._pickedDownMesh&&this._pickedDownMesh!==this._pickedUpMesh){const r=this._pickedDownMesh._getActionManagerForTrigger(16);r&&r.processTrigger(16,Vi.CreateNew(this._pickedDownMesh,t))}if(!i.ignore){const r=new Ar(Ve.POINTERUP,t,e);if(this._setRayOnPointerInfo(e,t),s.onPointerObservable.notifyObservers(r,Ve.POINTERUP),s.onPointerUp&&s.onPointerUp(t,e,Ve.POINTERUP),!i.hasSwiped&&!this._skipPointerTap&&!this._isMultiTouchGesture){let a=0;if(i.singleClick?a=Ve.POINTERTAP:i.doubleClick&&(a=Ve.POINTERDOUBLETAP),a){const o=new Ar(a,t,e);s.onPointerObservable.hasObservers()&&s.onPointerObservable.hasSpecificMask(a)&&s.onPointerObservable.notifyObservers(o,a)}}}}isPointerCaptured(e=0){return this._pointerCaptures[e]}attachControl(e=!0,t=!0,i=!0,s=null){const r=this._scene,a=r.getEngine();s||(s=a.getInputElement()),this._alreadyAttached&&this.detachControl(),s&&(this._alreadyAttachedTo=s),this._deviceSourceManager=new M3(a),this._initActionManager=o=>{if(!this._meshPickProceed){const c=r.skipPointerUpPicking||r._registeredActions===0&&!this._checkForPicking()&&!r.onPointerUp?null:r.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,r.pointerUpPredicate,r.pointerUpFastCheck,r.cameraToUseForPointers,r.pointerUpTrianglePredicate);this._currentPickResult=c,c&&(o=c.hit&&c.pickedMesh?c.pickedMesh._getActionManagerForTrigger():null),this._meshPickProceed=!0}return o},this._delayedSimpleClick=(o,c,u)=>{if((Date.now()-this._previousStartingPointerTime>oi.DoubleClickDelay&&!this._doubleClickOccured||o!==this._previousButtonPressed)&&(this._doubleClickOccured=!1,c.singleClick=!0,c.ignore=!1,this._delayedClicks[o])){const d=this._delayedClicks[o].evt,f=Ve.POINTERTAP,g=new Ar(f,d,this._currentPickResult);r.onPointerObservable.hasObservers()&&r.onPointerObservable.hasSpecificMask(f)&&r.onPointerObservable.notifyObservers(g,f),this._delayedClicks[o]=null}},this._initClickEvent=(o,c,u,d)=>{const f=new OT;this._currentPickResult=null;let g=null,m=o.hasSpecificMask(Ve.POINTERPICK)||c.hasSpecificMask(Ve.POINTERPICK)||o.hasSpecificMask(Ve.POINTERTAP)||c.hasSpecificMask(Ve.POINTERTAP)||o.hasSpecificMask(Ve.POINTERDOUBLETAP)||c.hasSpecificMask(Ve.POINTERDOUBLETAP);!m&&ir&&(g=this._initActionManager(g,f),g&&(m=g.hasPickTriggers));let b=!1;if(m=m&&!this._isMultiTouchGesture,m){const x=u.button;if(f.hasSwiped=this._isPointerSwiping(),!f.hasSwiped){let v=!oi.ExclusiveDoubleClickMode;if(v||(v=!o.hasSpecificMask(Ve.POINTERDOUBLETAP)&&!c.hasSpecificMask(Ve.POINTERDOUBLETAP),v&&!ir.HasSpecificTrigger(6)&&(g=this._initActionManager(g,f),g&&(v=!g.hasSpecificTrigger(6)))),v)(Date.now()-this._previousStartingPointerTime>oi.DoubleClickDelay||x!==this._previousButtonPressed)&&(f.singleClick=!0,d(f,this._currentPickResult),b=!0);else{const A={evt:u,clickInfo:f,timeoutId:window.setTimeout(this._delayedSimpleClick.bind(this,x,f,d),oi.DoubleClickDelay)};this._delayedClicks[x]=A}let E=o.hasSpecificMask(Ve.POINTERDOUBLETAP)||c.hasSpecificMask(Ve.POINTERDOUBLETAP);!E&&ir.HasSpecificTrigger(6)&&(g=this._initActionManager(g,f),g&&(E=g.hasSpecificTrigger(6))),E&&(x===this._previousButtonPressed&&Date.now()-this._previousStartingPointerTime<oi.DoubleClickDelay&&!this._doubleClickOccured?(!f.hasSwiped&&!this._isPointerSwiping()?(this._previousStartingPointerTime=0,this._doubleClickOccured=!0,f.doubleClick=!0,f.ignore=!1,oi.ExclusiveDoubleClickMode&&this._delayedClicks[x]&&(clearTimeout(this._delayedClicks[x]?.timeoutId),this._delayedClicks[x]=null),d(f,this._currentPickResult)):(this._doubleClickOccured=!1,this._previousStartingPointerTime=this._startingPointerTime,this._previousStartingPointerPosition.x=this._startingPointerPosition.x,this._previousStartingPointerPosition.y=this._startingPointerPosition.y,this._previousButtonPressed=x,oi.ExclusiveDoubleClickMode?(this._delayedClicks[x]&&(clearTimeout(this._delayedClicks[x]?.timeoutId),this._delayedClicks[x]=null),d(f,this._previousPickResult)):d(f,this._currentPickResult)),b=!0):(this._doubleClickOccured=!1,this._previousStartingPointerTime=this._startingPointerTime,this._previousStartingPointerPosition.x=this._startingPointerPosition.x,this._previousStartingPointerPosition.y=this._startingPointerPosition.y,this._previousButtonPressed=x))}}b||d(f,this._currentPickResult)},this._onPointerMove=o=>{if(this._updatePointerPosition(o),!this._isSwiping&&this._swipeButtonPressed!==-1&&(this._isSwiping=Math.abs(this._startingPointerPosition.x-this._pointerX)>oi.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>oi.DragMovementThreshold),a.isPointerLock&&a._verifyPointerLock(),this._checkPrePointerObservable(null,o,o.inputIndex>=je.MouseWheelX&&o.inputIndex<=je.MouseWheelZ?Ve.POINTERWHEEL:Ve.POINTERMOVE)||!r.cameraToUseForPointers&&!r.activeCamera)return;if(r.skipPointerMovePicking){this._processPointerMove(new as,o);return}r.pointerMovePredicate||(r.pointerMovePredicate=u=>u.isPickable&&u.isVisible&&u.isReady()&&u.isEnabled()&&(u.enablePointerMoveEvents||r.constantlyUpdateMeshUnderPointer||u._getActionManagerForTrigger()!==null)&&(!r.cameraToUseForPointers||(r.cameraToUseForPointers.layerMask&u.layerMask)!==0));const c=r._registeredActions>0||r.constantlyUpdateMeshUnderPointer?this._pickMove(o):null;this._processPointerMove(c,o)},this._onPointerDown=o=>{const c=this._activePointerIds.indexOf(-1);if(c===-1?this._activePointerIds.push(o.pointerId):this._activePointerIds[c]=o.pointerId,this._activePointerIdsCount++,this._pickedDownMesh=null,this._meshPickProceed=!1,oi.ExclusiveDoubleClickMode){for(let d=0;d<this._delayedClicks.length;d++)if(this._delayedClicks[d])if(o.button===d)clearTimeout(this._delayedClicks[d]?.timeoutId);else{const f=this._delayedClicks[d].clickInfo;this._doubleClickOccured=!1,f.singleClick=!0,f.ignore=!1;const g=this._delayedClicks[d].evt,m=Ve.POINTERTAP,b=new Ar(m,g,this._currentPickResult);r.onPointerObservable.hasObservers()&&r.onPointerObservable.hasSpecificMask(m)&&r.onPointerObservable.notifyObservers(b,m),this._delayedClicks[d]=null}}if(this._updatePointerPosition(o),this._swipeButtonPressed===-1&&(this._swipeButtonPressed=o.button),r.preventDefaultOnPointerDown&&s&&(o.preventDefault(),s.focus()),this._startingPointerPosition.x=this._pointerX,this._startingPointerPosition.y=this._pointerY,this._startingPointerTime=Date.now(),this._checkPrePointerObservable(null,o,Ve.POINTERDOWN)||!r.cameraToUseForPointers&&!r.activeCamera)return;this._pointerCaptures[o.pointerId]=!0,r.pointerDownPredicate||(r.pointerDownPredicate=d=>d.isPickable&&d.isVisible&&d.isReady()&&d.isEnabled()&&(!r.cameraToUseForPointers||(r.cameraToUseForPointers.layerMask&d.layerMask)!==0)),this._pickedDownMesh=null;let u;r.skipPointerDownPicking||r._registeredActions===0&&!this._checkForPicking()&&!r.onPointerDown?u=new as:u=r.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,r.pointerDownPredicate,r.pointerDownFastCheck,r.cameraToUseForPointers,r.pointerDownTrianglePredicate),this._processPointerDown(u,o)},this._onPointerUp=o=>{const c=this._activePointerIds.indexOf(o.pointerId);c!==-1&&(this._activePointerIds[c]=-1,this._activePointerIdsCount--,this._pickedUpMesh=null,this._meshPickProceed=!1,this._updatePointerPosition(o),r.preventDefaultOnPointerUp&&s&&(o.preventDefault(),s.focus()),this._initClickEvent(r.onPrePointerObservable,r.onPointerObservable,o,(u,d)=>{if(r.onPrePointerObservable.hasObservers()&&(this._skipPointerTap=!1,!u.ignore)){if(this._checkPrePointerObservable(null,o,Ve.POINTERUP)){this._swipeButtonPressed===o.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1),o.buttons===0&&(this._pointerCaptures[o.pointerId]=!1);return}u.hasSwiped||(u.singleClick&&r.onPrePointerObservable.hasSpecificMask(Ve.POINTERTAP)&&this._checkPrePointerObservable(null,o,Ve.POINTERTAP)&&(this._skipPointerTap=!0),u.doubleClick&&r.onPrePointerObservable.hasSpecificMask(Ve.POINTERDOUBLETAP)&&this._checkPrePointerObservable(null,o,Ve.POINTERDOUBLETAP)&&(this._skipPointerTap=!0))}if(!this._pointerCaptures[o.pointerId]){this._swipeButtonPressed===o.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1);return}o.buttons===0&&(this._pointerCaptures[o.pointerId]=!1),!(!r.cameraToUseForPointers&&!r.activeCamera)&&(r.pointerUpPredicate||(r.pointerUpPredicate=f=>f.isPickable&&f.isVisible&&f.isReady()&&f.isEnabled()&&(!r.cameraToUseForPointers||(r.cameraToUseForPointers.layerMask&f.layerMask)!==0)),!this._meshPickProceed&&(ir&&ir.HasTriggers||this._checkForPicking()||r.onPointerUp)&&this._initActionManager(null,u),d||(d=this._currentPickResult),this._processPointerUp(d,o,u),this._previousPickResult=this._currentPickResult,this._swipeButtonPressed===o.button&&(this._isSwiping=!1,this._swipeButtonPressed=-1))}))},this._onKeyDown=o=>{const c=lc.KEYDOWN;
238if(r.onPreKeyboardObservable.hasObservers()){const u=new ST(c,o);if(r.onPreKeyboardObservable.notifyObservers(u,c),u.skipOnKeyboardObservable)return}if(r.onKeyboardObservable.hasObservers()){const u=new Bm(c,o);r.onKeyboardObservable.notifyObservers(u,c)}r.actionManager&&r.actionManager.processTrigger(14,Vi.CreateNewFromScene(r,o))},this._onKeyUp=o=>{const c=lc.KEYUP;if(r.onPreKeyboardObservable.hasObservers()){const u=new ST(c,o);if(r.onPreKeyboardObservable.notifyObservers(u,c),u.skipOnKeyboardObservable)return}if(r.onKeyboardObservable.hasObservers()){const u=new Bm(c,o);r.onKeyboardObservable.notifyObservers(u,c)}r.actionManager&&r.actionManager.processTrigger(15,Vi.CreateNewFromScene(r,o))},this._deviceSourceManager.onDeviceConnectedObservable.add(o=>{o.deviceType===ke.Mouse?o.onInputChangedObservable.add(c=>{this._originMouseEvent=c,c.inputIndex===je.LeftClick||c.inputIndex===je.MiddleClick||c.inputIndex===je.RightClick||c.inputIndex===je.BrowserBack||c.inputIndex===je.BrowserForward?t&&o.getInput(c.inputIndex)===1?this._onPointerDown(c):e&&o.getInput(c.inputIndex)===0&&this._onPointerUp(c):i&&(c.inputIndex===je.Move?this._onPointerMove(c):(c.inputIndex===je.MouseWheelX||c.inputIndex===je.MouseWheelY||c.inputIndex===je.MouseWheelZ)&&this._onPointerMove(c))}):o.deviceType===ke.Touch?o.onInputChangedObservable.add(c=>{c.inputIndex===je.LeftClick&&(t&&o.getInput(c.inputIndex)===1?(this._onPointerDown(c),this._activePointerIdsCount>1&&(this._isMultiTouchGesture=!0)):e&&o.getInput(c.inputIndex)===0&&(this._onPointerUp(c),this._activePointerIdsCount===0&&(this._isMultiTouchGesture=!1))),i&&c.inputIndex===je.Move&&this._onPointerMove(c)}):o.deviceType===ke.Keyboard&&o.onInputChangedObservable.add(c=>{c.type==="keydown"?this._onKeyDown(c):c.type==="keyup"&&this._onKeyUp(c)})}),this._alreadyAttached=!0}detachControl(){this._alreadyAttached&&(this._deviceSourceManager.dispose(),this._deviceSourceManager=null,this._alreadyAttachedTo&&!this._scene.doNotHandleCursors&&(this._alreadyAttachedTo.style.cursor=this._scene.defaultCursor),this._alreadyAttached=!1,this._alreadyAttachedTo=null)}setPointerOverMesh(e,t=0,i,s){if(this._meshUnderPointerId[t]===e&&(!e||!e._internalAbstractMeshDataInfo._pointerOverDisableMeshTesting))return;const r=this._meshUnderPointerId[t];let a;r&&(a=r._getActionManagerForTrigger(10),a&&a.processTrigger(10,new Vi(r,this._pointerX,this._pointerY,e,s,{pointerId:t}))),e?(this._meshUnderPointerId[t]=e,this._pointerOverMesh=e,a=e._getActionManagerForTrigger(9),a&&a.processTrigger(9,new Vi(e,this._pointerX,this._pointerY,e,s,{pointerId:t,pickResult:i}))):(delete this._meshUnderPointerId[t],this._pointerOverMesh=null),this._scene.onMeshUnderPointerUpdatedObservable.hasObservers()&&this._scene.onMeshUnderPointerUpdatedObservable.notifyObservers({mesh:e,pointerId:t})}getPointerOverMesh(){return this.meshUnderPointer}_invalidateMesh(e){this._pointerOverMesh===e&&(this._pointerOverMesh=null),this._pickedDownMesh===e&&(this._pickedDownMesh=null),this._pickedUpMesh===e&&(this._pickedUpMesh=null);for(const t in this._meshUnderPointerId)this._meshUnderPointerId[t]===e&&delete this._meshUnderPointerId[t]}}oi.DragMovementThreshold=10;oi.LongPressDelay=500;oi.DoubleClickDelay=300;oi.ExclusiveDoubleClickMode=!1;class Vb{static get UniqueId(){const e=this._UniqueIdCounter;return this._UniqueIdCounter++,e}}Vb._UniqueIdCounter=1;class C3{constructor(){this.pointerDownFastCheck=!1,this.pointerUpFastCheck=!1,this.pointerMoveFastCheck=!1,this.skipPointerMovePicking=!1,this.skipPointerDownPicking=!1,this.skipPointerUpPicking=!1}}const wT=0,FT=1;class QC{constructor(e,t,i){this.name=e,this._parentTask=t,this._context=i,this.disabled=!1}setExecuteFunc(e){this._executeFunc=e}_execute(){this.disabled||this._executeFunc(this._context)}_isValid(){return this._executeFunc!==void 0?null:"Execute function is not set (call setExecuteFunc to set it)"}}class LT extends QC{static IsObjectListPass(e){return e.setObjectList!==void 0}get objectList(){return this._objectList}setObjectList(e){this._objectList=e}constructor(e,t,i,s){super(e,t,i),this._engine=s}_isValid(){const e=super._isValid();return e||(this._objectList!==void 0?null:"Object list is not set (call setObjectList to set it)")}}class NT extends QC{static IsRenderPass(e){return e.setRenderTarget!==void 0}get renderTarget(){return this._renderTarget}get renderTargetDepth(){return this._renderTargetDepth}get frameGraphRenderTarget(){return this._frameGraphRenderTarget}constructor(e,t,i,s){super(e,t,i),this._dependencies=new Set,this.depthReadOnly=!1,this.stencilReadOnly=!1,this._engine=s}setRenderTarget(e){this._renderTarget=e}setRenderTargetDepth(e){this._renderTargetDepth=e}addDependencies(e){if(e!==void 0)if(Array.isArray(e))for(const t of e)this._dependencies.add(t);else this._dependencies.add(e)}collectDependencies(e){const t=this._dependencies.keys();for(let i=t.next();i.done!==!0;i=t.next())e.add(i.value);if(this._renderTarget!==void 0)if(Array.isArray(this._renderTarget))for(const i of this._renderTarget)i!==void 0&&e.add(i);else e.add(this._renderTarget);this._renderTargetDepth!==void 0&&e.add(this._renderTargetDepth)}_execute(){this._frameGraphRenderTarget=this._frameGraphRenderTarget||this._context.createRenderTarget(this.name,this._renderTarget,this._renderTargetDepth,this.depthReadOnly,this.stencilReadOnly),this._context.bindRenderTarget(this._frameGraphRenderTarget,`frame graph render pass - ${this.name}`),super._execute(),this._context._flushDebugMessages();const e=this._frameGraphRenderTarget.renderTargetWrapper;e&&(e.resolveMSAAColors||e.resolveMSAADepth||e.resolveMSAAStencil)&&(this._context.bindRenderTarget(void 0,`frame graph render pass - ${this.name} - resolve MSAA`,!0),this._context._flushDebugMessages())}_isValid(){const e=super._isValid();return e||(this._renderTarget!==void 0||this.renderTargetDepth!==void 0?null:"Render target and render target depth cannot both be undefined.")}}class zb{get name(){return this._name}set name(e){this._name=e}get disabled(){return this._disabled}set disabled(e){this._disabled=e}get passes(){return this._passes}get passesDisabled(){return this._passesDisabled}isReady(){return!0}dispose(){this._reset(),this.onTexturesAllocatedObservable.clear(),this.onBeforeTaskExecute.clear(),this.onAfterTaskExecute.clear()}constructor(e,t){this._passes=[],this._passesDisabled=[],this._disabled=!1,this.onTexturesAllocatedObservable=new le,this.onBeforeTaskExecute=new le,this.onAfterTaskExecute=new le,this.name=e,this._frameGraph=t,this._reset()}_reset(){this._passes.length=0,this._passesDisabled.length=0}_addPass(e,t){t?this._passesDisabled.push(e):this._passes.push(e)}_checkTask(){let e=null,t=null,i;for(const c of this._passes){const u=c._isValid();if(u)throw new Error(`Pass "${c.name}
238" is not valid. ${u}`);if(NT.IsRenderPass(c)){const d=Array.isArray(c.renderTarget)?c.renderTarget:[c.renderTarget];e=[];for(const f of d)f!==void 0&&e.push(this._frameGraph.textureManager.getTextureFromHandle(f));t=c.renderTargetDepth!==void 0?this._frameGraph.textureManager.getTextureFromHandle(c.renderTargetDepth):null}else LT.IsObjectListPass(c)&&(i=c.objectList)}let s=null,r=[],a=null,o;for(const c of this._passesDisabled){const u=c._isValid();if(u)throw new Error(`Pass "${c.name}" is not valid. ${u}`);if(NT.IsRenderPass(c)){const d=Array.isArray(c.renderTarget)?c.renderTarget:[c.renderTarget];s=[];for(const f of d)f!==void 0&&s.push(this._frameGraph.textureManager.getTextureFromHandle(f));r=d,a=c.renderTargetDepth!==void 0?this._frameGraph.textureManager.getTextureFromHandle(c.renderTargetDepth):null}else LT.IsObjectListPass(c)&&(o=c.objectList)}if(this._passesDisabled.length>0){if(!this._checkSameRenderTarget(e,s)){let c=!0;for(const u of r)if(u!==void 0&&!this._frameGraph.textureManager.isHistoryTexture(u)){c=!1;break}if(!c)throw new Error(`The output texture of the task "${this.name}" is different when it is enabled or disabled.`)}if(t!==a)throw new Error(`The output depth texture of the task "${this.name}" is different when it is enabled or disabled.`);if(i!==o)throw new Error(`The output object list of the task "${this.name}" is different when it is enabled or disabled.`)}}_execute(){const e=this._disabled&&this._passesDisabled.length>0?this._passesDisabled:this._passes;this.onBeforeTaskExecute.notifyObservers(this);for(const t of e)t._execute();this.onAfterTaskExecute.notifyObservers(this)}_checkSameRenderTarget(e,t){if(e===null||t===null)return e===t;if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}}class Or{get renderList(){return this._renderList}set renderList(e){this._renderList!==e&&(this._unObserveRenderList&&(this._unObserveRenderList(),this._unObserveRenderList=null),e&&(this._unObserveRenderList=dC(e,this._renderListHasChanged)),this._renderList=e)}get disableImageProcessing(){return this._disableImageProcessing}set disableImageProcessing(e){e!==this._disableImageProcessing&&(this._disableImageProcessing=e,this._scene.markAllMaterialsAsDirty(64))}get disableDepthPrePass(){return this._disableDepthPrePass}set disableDepthPrePass(e){this._disableDepthPrePass=e,this._renderingManager.disableDepthPrePass=e}get name(){return this._name}set name(e){if(this._name!==e){if(this._name=e,this._sceneUBOs)for(let t=0;t<this._sceneUBOs.length;++t)this._sceneUBOs[t].name=`Scene ubo #${t} for ${this.name}`;if(this._scene)for(let t=0;t<this._renderPassIds.length;++t){const i=this._renderPassIds[t];this._engine._renderPassNames[i]=`${this._name}#${t}`}}}get renderPassIds(){return this._renderPassIds}get currentRefreshId(){return this._currentRefreshId}getActiveMeshes(){return this._activeMeshes}setMaterialForRendering(e,t){let i;Array.isArray(e)?i=e:i=[e];for(let s=0;s<i.length;++s)for(let r=0;r<this.options.numPasses;++r){let a=i[s];i[s].isAnInstance&&(a=i[s].sourceMesh),a.setMaterialForRenderPass(this._renderPassIds[r],t!==void 0?Array.isArray(t)?t[r]:t:void 0)}}_freezeActiveMeshes(e){this._freezeActiveMeshesCancel=wf(()=>this._checkReadiness(),()=>{if(this._freezeActiveMeshesCancel=null,e)for(let t=0;t<this._activeMeshes.length;t++)this._activeMeshes.data[t]._freeze();this._prepareRenderingManager(0,!0),this._isFrozen=!0},(t,i)=>{this._freezeActiveMeshesCancel=null,i?(oe.Error("ObjectRenderer: Timeout while waiting for the renderer to be ready."),t&&oe.Error(t)):(oe.Error("ObjectRenderer: An unexpected error occurred while waiting for the renderer to be ready."),t&&(oe.Error(t),t.stack&&oe.Error(t.stack)))})}_unfreezeActiveMeshes(){this._freezeActiveMeshesCancel?.(),this._freezeActiveMeshesCancel=null;for(let e=0;e<this._activeMeshes.length;e++)this._activeMeshes.data[e]._unFreeze();this._isFrozen=!1}constructor(e,t,i){this._unObserveRenderList=null,this._renderListHasChanged=(s,r)=>{const a=this._renderList?this._renderList.length:0;if(r===0&&a>0||a===0)for(const o of this._scene.meshes)o._markSubMeshesAsLightDirty()},this.particleSystemList=null,this.getCustomRenderList=null,this.renderParticles=!0,this.renderSprites=!1,this.forceLayerMaskCheck=!1,this.enableBoundingBoxRendering=!1,this.enableOutlineRendering=!0,this._disableImageProcessing=!1,this.dontSetTransformationMatrix=!1,this._disableDepthPrePass=!1,this.onBeforeRenderObservable=new le,this.onAfterRenderObservable=new le,this.onBeforeRenderingManagerRenderObservable=new le,this.onAfterRenderingManagerRenderObservable=new le,this.onInitRenderingObservable=new le,this.onFinishRenderingObservable=new le,this.onFastPathRenderObservable=new le,this._currentRefresh
238Id=-1,this._refreshRate=1,this._currentApplyByPostProcessSetting=!1,this._activeMeshes=new Yi(256),this._activeBoundingBoxes=new Yi(32),this._currentFrameId=-1,this._currentSceneUBOIndex=0,this._isFrozen=!1,this._freezeActiveMeshesCancel=null,this._currentSceneCamera=null,this.name=e,this._scene=t,this._engine=this._scene.getEngine(),this._useUBO=this._engine.supportsUniformBuffers,this._useUBO&&(this._sceneUBOs=[],this._createSceneUBO()),this.renderList=[],this._renderPassIds=[],this.options={numPasses:1,doNotChangeAspectRatio:!0,enableClusteredLights:!1,...i},this._createRenderPassId(),this.renderPassId=this._renderPassIds[0],this._renderingManager=new zi(t),this._renderingManager._useSceneAutoClearSetup=!0,this.options.enableClusteredLights&&this.onInitRenderingObservable.add(()=>{for(const s of this._scene.lights)s.getTypeID()===xt.LIGHTTYPEID_CLUSTERED_CONTAINER&&s.isSupported&&s._updateBatches(this.activeCamera).render()}),this._scene.addObjectRenderer(this)}_releaseRenderPassId(){for(let e=0;e<this.options.numPasses;++e)this._engine.releaseRenderPassId(this._renderPassIds[e]);this._renderPassIds.length=0}_createRenderPassId(){this._releaseRenderPassId();for(let e=0;e<this.options.numPasses;++e)this._renderPassIds[e]=this._engine.createRenderPassId(`${this.name}#${e}`)}_createSceneUBO(){const e=this._sceneUBOs.length;this._sceneUBOs.push(this._scene.createSceneUniformBuffer(`Scene ubo #${e} for ${this.name}`,!1))}_getSceneUBO(){this._currentFrameId!==this._engine.frameId&&(this._currentSceneUBOIndex=0,this._currentFrameId=this._engine.frameId),this._currentSceneUBOIndex>=this._sceneUBOs.length&&this._createSceneUBO();const e=this._sceneUBOs[this._currentSceneUBOIndex++];return e.unbindEffect(),e}resetRefreshCounter(){this._currentRefreshId=-1}get refreshRate(){return this._refreshRate}set refreshRate(e){this._refreshRate=e,this.resetRefreshCounter()}shouldRender(){return this._currentRefreshId===-1?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)}isReadyForRendering(e,t){this.prepareRenderList(),this.initRender(e,t);const i=this._checkReadiness();return this.finishRender(),i}prepareRenderList(){const e=this._scene;if(this._waitingRenderList){if(!this.renderListPredicate){this.renderList=[];for(let t=0;t<this._waitingRenderList.length;t++){const i=this._waitingRenderList[t],s=e.getMeshById(i);s&&this.renderList.push(s)}}this._waitingRenderList=void 0}if(this.renderListPredicate){this.renderList?this.renderList.length=0:this.renderList=[];const t=this._scene.meshes;for(let i=0;i<t.length;i++){const s=t[i];this.renderListPredicate(s)&&this.renderList.push(s)}}this._currentApplyByPostProcessSetting=this._scene.imageProcessingConfiguration.applyByPostProcess,this._disableImageProcessing&&(this._scene.imageProcessingConfiguration._applyByPostProcess=this._disableImageProcessing)}initRender(e,t){const i=this.activeCamera??this._scene.activeCamera;this._currentSceneCamera=this._scene.activeCamera,this._useUBO&&(this._currentSceneUBO=this._scene.getSceneUniformBuffer(),this._currentSceneUBO.unbindEffect(),this._scene.setSceneUniformBuffer(this._getSceneUBO())),this.onInitRenderingObservable.notifyObservers(this),i&&(this.dontSetTransformationMatrix||this._scene.setTransformMatrix(i.getViewMatrix(),i.getProjectionMatrix(!0)),this._scene.activeCamera=i,this._engine.setViewport(i.rigParent?i.rigParent.viewport:i.viewport,e,t)),this._useUBO&&this._scene.finalizeSceneUbo(),this._defaultRenderListPrepared=!1}finishRender(){const e=this._scene;this._useUBO&&this._scene.setSceneUniformBuffer(this._currentSceneUBO),this._disableImageProcessing&&(e.imageProcessingConfiguration._applyByPostProcess=this._currentApplyByPostProcessSetting),e.activeCamera=this._currentSceneCamera,this._currentSceneCamera&&(this.activeCamera&&this.activeCamera!==e.activeCamera&&e.setTransformMatrix(this._currentSceneCamera.getViewMatrix(),this._currentSceneCamera.getProjectionMatrix(!0)),this._engine.setViewport(this._currentSceneCamera.viewport)),e.resetCachedMaterial(),this.onFinishRenderingObservable.notifyObservers(this)}render(e=0,t=!1){const i=this._engine.currentRenderPassId;if(this._engine.currentRenderPassId=this._renderPassIds[e],this.onBeforeRenderObservable.notifyObservers(e),this._engine.snapshotRendering&&this._engine.snapshotRenderingMode===1)this.onFastPathRenderObservable.notifyObservers(e);else{const r=this._prepareRenderingManager(e),a=this._scene.getOutlineRenderer?.(),o=a?.enabled;a&&(a.enabled=this.enableOutlineRendering),this.onBeforeRenderingManagerRenderObservable.notifyObservers(e),this._renderingManager.render(this.customRenderFunction,r,this.renderParticles,this.renderSprites),this.onAfterRenderingManagerRenderObservable.notifyObservers(e),a&&(a.enabled=o)}t||this.onAfterRenderObservable.notifyObservers(e),this._engine.currentRenderPassId=i}_checkReadiness(){const e=this._scene,t=this._engine.currentRenderPassId;let i=!0;e.getViewMatrix()||e.updateTransformMatrix();const s=this.options.numPasses;for(let a=0;a<s&&i;a++){let o=null;const c=this.renderList?this.renderList:e.frameGraph?e.meshes:e.getActiveMeshes().data,u=this.renderList?this.renderList.length:e.frameGraph?e.meshes.length:e.getActiveMeshes().length;this._engine.currentRenderPassId=this._renderPassIds[a],this.onBeforeRenderObservable.notifyObservers(a),this.getCustomRenderList&&(o=this.getCustomRenderList(a,c,u)),o||(o=c),this.options.doNotChangeAspectRatio||e.updateTransformMatrix(!0);for(let d=0;d<o.length&&i;++d){const f=o[d];if(!(!f.isEnabled()||f.isBlocked||!f.isVisible||!f.subMeshes)){if(this.customIsReadyFunction){if(!this.customIsReadyFunction(f,this.refreshRate,!0)){i=!1;continue}}else if(!f.isReady(!0)){i=!1;continue}}}this.onAfterRenderObservable.notifyObservers(a),s>1&&(e.incrementRenderId(),e.resetCachedMaterial())}const r=this.particleSystemList||e.particleSystems;for(const a of r)a.isReady()||(i=!1);return this._engine.currentRenderPassId=t,i}_prepareRenderingManager(e=0,t=!1){const i=this._scene;let s=null,r=0,a=!1;const o=this.renderList?this.renderList:i.frameGraph?i.meshes:i.getActiveMeshes().data,c=this.renderList?this.renderList.length:i.frameGraph?i.meshes.length:i.getActiveMeshes().length;if(this.getCustomRenderList&&(s=this.getCustomRenderList(e,o,c)),s)r=s.length,a=this.forceLayerMaskCheck;else{if(this._defaultRenderListPrepared&&!t)return o;this._defaultRenderListPrepared=!0,s=o,r=c,a=!this.renderList||this.forceLayerMaskCheck}const u=i.activeCamera,d=this.cameraForLOD??u,f=i.getBoundingBoxRenderer?.();if(i._activeMeshesFrozen&&this._isFrozen){if(this._renderingManager.resetSprites(),this.enableBoundingBoxRendering&&f){f.reset();for(let b=0;b<this._activeBoundingBoxes.length;b++){const x=this._activeBoundingBoxes.data[b];f.renderList.push(x)}}return s}this._renderingManager.reset(),this._activeMeshes.reset(),this._activeBoundingBoxes.reset(),f&&f.reset();const g=i.getRenderId(),m=i.getFrameId();for(let b=0;b<r;b++){const x=s[b];if(x&&!x.isBlocked){if(this.customIsReadyFunction){if(!this.customIsReadyFunction(x,this.refreshRate,!1)){this.resetRefreshCounter();continue}}else if(!x.isReady(this.refreshRate===0)){this.resetRefreshCounter();continue}let v=null;if(d){const A=x._internalAbstractMeshDataInfo._currentLOD.get(d);!A||A[1]!==m?(v=i.customLODSelector?i.customLODSelector(x,d):x.getLOD(d),A?(A[0]=v,A[1]=m):x._internalAbstractMeshDataInfo._currentLOD.set(d,[v,m])):v=A[0]}else v=x;if(!v)continue;v!==x&&v.billboardMode!==0&&v.computeWorldMatrix(),v._preActivateForIntermediateRendering(g);let E;if(a&&u?E=(x.layerMask&u.layerMask)===0:E=!1,x.isEnabled()&&x.isVisible&&x.subMeshes&&!E){if(this._activeMeshes.push(x),v._internalAbstractMeshDataInfo._wasActiveLastFrame=!0,v!==x&&v._activate(g,!0),this.enableBoundingBoxRendering&&f&&f._preActiveMesh(x),x._activate(g,!0)&&x.subMeshes.length){x.isAnInstance?x._internalAbstractMeshDataInfo._actAsRegularMesh&&(v=x):v._internalAbstractMeshDataInfo._onlyForInstancesIntermediate=!1,v._internalAbstractMeshDataInfo._isActiveIntermediate=!0,i._prepareSkeleton(v);for(let A=0;A<v.subMeshes.length;A++){const D=v.subMeshes[A];this.enableBoundingBoxRendering&&f&&f._evaluateSubMesh(x,D),this._renderingManager.dispatch(D,v)}}x._postActivate()}}}if(this.enableBoundingBoxRendering&&f&&t)for(let b=0;b<f.renderList.length;b++){const x=f.renderList.data[b];this._activeBoundingBoxes.push(x)}if(this._scene.particlesEnabled){this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);const b=this.particleSystemList||i.particleSystems;for(let x=0;x<b.length;x++){const v=b[x],E=v.emitter;!v.isStarted()||!E||E.position&&!E.isEnabled()||this._renderingManager.dispatchParticles(v)}this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene)}return s}get renderingManager(){return this._renderingManager}
238setRenderingOrder(e,t=null,i=null,s=null){this._renderingManager.setRenderingOrder(e,t,i,s)}setRenderingAutoClearDepthStencil(e,t,i=!0,s=!0){this._renderingManager.setRenderingAutoClearDepthStencil(e,t,i,s),this._renderingManager._useSceneAutoClearSetup=!1}clone(){const e=new Or(this.name,this._scene,this.options);return this.renderList&&(e.renderList=this.renderList.slice(0)),e}dispose(){const e=this.renderList?this.renderList:this._scene.getActiveMeshes().data,t=this.renderList?this.renderList.length:this._scene.getActiveMeshes().length;for(let i=0;i<t;i++){const s=e[i];s&&s.getMaterialForRenderPass(this.renderPassId)!==void 0&&s.setMaterialForRenderPass(this.renderPassId,void 0)}if(this.onInitRenderingObservable.clear(),this.onFinishRenderingObservable.clear(),this.onBeforeRenderObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderingManagerRenderObservable.clear(),this.onAfterRenderingManagerRenderObservable.clear(),this.onFastPathRenderObservable.clear(),this._releaseRenderPassId(),this.renderList=null,this._sceneUBOs)for(const i of this._sceneUBOs)i.dispose();this._sceneUBOs=void 0,this._scene.removeObjectRenderer(this)}_rebuild(){this.refreshRate===Or.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=Or.REFRESHRATE_RENDER_ONCE)}freeRenderingGroups(){this._renderingManager&&this._renderingManager.freeRenderingGroups()}}Or.REFRESHRATE_RENDER_ONCE=0;Or.REFRESHRATE_RENDER_ONEVERYFRAME=1;Or.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2;At.prototype.setDepthStencilTexture=function(n,e){this._engine.setDepthStencilTexture(this._samplers[n],this._uniforms[n],e,n)};class ar extends Te{get renderListPredicate(){return this._objectRenderer.renderListPredicate}set renderListPredicate(e){this._objectRenderer.renderListPredicate=e}get renderList(){return this._objectRenderer.renderList}set renderList(e){this._objectRenderer.renderList=e}get particleSystemList(){return this._objectRenderer.particleSystemList}set particleSystemList(e){this._objectRenderer.particleSystemList=e}get getCustomRenderList(){return this._objectRenderer.getCustomRenderList}set getCustomRenderList(e){this._objectRenderer.getCustomRenderList=e}get renderParticles(){return this._objectRenderer.renderParticles}set renderParticles(e){this._objectRenderer.renderParticles=e}get renderSprites(){return this._objectRenderer.renderSprites}set renderSprites(e){this._objectRenderer.renderSprites=e}get enableBoundingBoxRendering(){return this._objectRenderer.enableBoundingBoxRendering}set enableBoundingBoxRendering(e){this._objectRenderer.enableBoundingBoxRendering=e}get enableOutlineRendering(){return this._objectRenderer.enableOutlineRendering}set enableOutlineRendering(e){this._objectRenderer.enableOutlineRendering=e}get forceLayerMaskCheck(){return this._objectRenderer.forceLayerMaskCheck}set forceLayerMaskCheck(e){this._objectRenderer.forceLayerMaskCheck=e}get activeCamera(){return this._objectRenderer.activeCamera}set activeCamera(e){this._objectRenderer.activeCamera=e}get cameraForLOD(){return this._objectRenderer.cameraForLOD}set cameraForLOD(e){this._objectRenderer.cameraForLOD=e}get disableImageProcessing(){return this._objectRenderer.disableImageProcessing}set disableImageProcessing(e){this._objectRenderer.disableImageProcessing=e}get customIsReadyFunction(){return this._objectRenderer.customIsReadyFunction}set customIsReadyFunction(e){this._objectRenderer.customIsReadyFunction=e}get customRenderFunction(){return this._objectRenderer.customRenderFunction}set customRenderFunction(e){this._objectRenderer.customRenderFunction=e}get postProcesses(){return this._postProcesses}get _prePassEnabled(){return!!this._prePassRenderTarget&&this._prePassRenderTarget.enabled}set onAfterUnbind(e){this._onAfterUnbindObserver&&this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=this.onAfterUnbindObservable.add(e)}get onBeforeRenderObservable(){return this._objectRenderer.onBeforeRenderObservable}set onBeforeRender(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)}get onAfterRenderObservable(){return this._objectRenderer.onAfterRenderObservable}set onAfterRender(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)}set onClear(e){this._onClearObserver&&this.onClearObservable.remove(this._onClearObserver),this._onClearObserver=this.onClearObservable.add(e)}get _waitingRenderList(){return this._objectRenderer._waitingRenderList}set _waitingRenderList(e){this._objectRenderer._waitingRenderList=e}get renderPassId(){return this._objectRenderer.renderPassId}get renderPassIds(){return this._objectRenderer.renderPassIds}
vendor: 35,339 bytes, lines 238-247
238get currentRefreshId(){return this._objectRenderer.currentRefreshId}setMaterialForRendering(e,t){this._objectRenderer.setMaterialForRendering(e,t)}get isMulti(){return this._renderTarget?.isMulti??!1}get renderTargetOptions(){return this._renderTargetOptions}get renderTarget(){return this._renderTarget}_onRatioRescale(){this._sizeRatio&&this.resize(this._initialSizeParameter)}set boundingBoxSize(e){if(this._boundingBoxSize&&this._boundingBoxSize.equals(e))return;this._boundingBoxSize=e;const t=this.getScene();t&&t.markAllMaterialsAsDirty(1)}get boundingBoxSize(){return this._boundingBoxSize}get depthStencilTexture(){return this._renderTarget?._depthStencilTexture??null}constructor(e,t,i,s=!1,r=!0,a=0,o=!1,c=Te.TRILINEAR_SAMPLINGMODE,u=!0,d=!1,f=!1,g=5,m=!1,b,x,v=!1,E=!1){let A,D=!0,I,R=!1;if(typeof s=="object"){const M=s;s=!!M.generateMipMaps,r=M.doNotChangeAspectRatio??!0,a=M.type??0,o=!!M.isCube,c=M.samplingMode??Te.TRILINEAR_SAMPLINGMODE,u=M.generateDepthBuffer??!0,d=!!M.generateStencilBuffer,f=!!M.isMulti,g=M.format??5,m=!!M.delayAllocation,b=M.samples,x=M.creationFlags,v=!!M.noColorAttachment,E=!!M.useSRGBBuffer,A=M.colorAttachment,D=M.gammaSpace??D,I=M.existingObjectRenderer,R=!!M.enableClusteredLights}if(super(null,i,!s,void 0,c,void 0,void 0,void 0,void 0,g),this.ignoreCameraViewport=!1,this.onBeforeBindObservable=new le,this.onAfterUnbindObservable=new le,this.onClearObservable=new le,this.onResizeObservable=new le,this._cleared=!1,this.skipInitialClear=!1,this._samples=1,this._canRescale=!0,this._renderTarget=null,this._dontDisposeObjectRenderer=!1,this.boundingBoxPosition=T.Zero(),this._disableEngineStages=!1,this._dumpToolsLoading=!1,i=this.getScene(),!i)return;const C=this.getScene().getEngine();this._gammaSpace=D,this._coordinatesMode=Te.PROJECTION_MODE,this.name=e,this.isRenderTarget=!0,this._initialSizeParameter=t,this._dontDisposeObjectRenderer=!!I,this._processSizeParameter(t),this._objectRenderer=I??new Or(e,i,{numPasses:o?6:this.getRenderLayers()||1,doNotChangeAspectRatio:r,enableClusteredLights:R}),this._onBeforeRenderingManagerRenderObserver=this._objectRenderer.onBeforeRenderingManagerRenderObservable.add(()=>{if(!this._disableEngineStages)for(const M of this._scene._beforeRenderTargetClearStage)M.action(this,this._currentFaceIndex,this._currentLayer);if(this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(C):this.skipInitialClear||C.clear(this.clearColor||this._scene.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||this._scene.updateTransformMatrix(!0),!this._disableEngineStages)for(const M of this._scene._beforeRenderTargetDrawStage)M.action(this,this._currentFaceIndex,this._currentLayer)}),this._onAfterRenderingManagerRenderObserver=this._objectRenderer.onAfterRenderingManagerRenderObservable.add(()=>{if(!this._disableEngineStages)for(const F of this._scene._afterRenderTargetDrawStage)F.action(this,this._currentFaceIndex,this._currentLayer);const M=this._texture?.generateMipMaps??!1;if(this._texture&&(this._texture.generateMipMaps=!1),this._postProcessManager?this._postProcessManager._finalizeFrame(!1,this._renderTarget??void 0,this._currentFaceIndex,this._postProcesses,this.ignoreCameraViewport):this._currentUseCameraPostProcess&&this._scene.postProcessManager._finalizeFrame(!1,this._renderTarget??void 0,this._currentFaceIndex),!this._disableEngineStages)for(const F of this._scene._afterRenderTargetPostProcessStage)F.action(this,this._currentFaceIndex,this._currentLayer);this._texture&&(this._texture.generateMipMaps=M),this._doNotChangeAspectRatio||this._scene.updateTransformMatrix(!0),this._currentDumpForDebug&&(this._dumpTools?this._dumpTools.DumpFramebuffer(this.getRenderWidth(),this.getRenderHeight(),C):oe.Error("dumpTools module is still being loaded. To speed up the process import dump tools directly in your project"))}),this._onFastPathRenderObserver=this._objectRenderer.onFastPathRenderObservable.add(()=>{this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(C):this.skipInitialClear||C.clear(this.clearColor||this._scene.clearColor,!0,!0,!0)}),this._resizeObserver=C.onResizeObservable.add(()=>{}),this._generateMipMaps=!!s,this._doNotChangeAspectRatio=r,!f&&(this._renderTargetOptions={generateMipMaps:s,type:a,format:this._format??void 0,samplingMode:this.samplingMode,generateDepthBuffer:u,generateStencilBuffer:d,samples:b,creationFlags:x,noColorAttachment:v,useSRGBBuffer:E,colorAttachment:A,label:this.name},this.samplingMode===Te.NEAREST_SAMPLINGMODE&&(this.wrapU=Te.CLAMP_ADDRESSMODE,this.wrapV=Te.CLAMP_ADDRESSMODE),m||(o?(this._renderTarget=i.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions),this.coordinatesMode=Te.INVCUBIC_MODE,this._textureMatrix=W.Identity()):this._renderTarget=i.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this._texture=this._renderTarget.texture,b!==void 0&&(this.samples=b)))}createDepthStencilTexture(e=0,t=!0,i=!1,s=1,r=14,a){this._renderTarget?.createDepthStencilTexture(e,t,i,s,r,a)}_processSizeParameter(e){if(e.ratio){this._sizeRatio=e.ratio;const t=this._getEngine();this._size={width:this._bestReflectionRenderTargetDimension(t.getRenderWidth(),this._sizeRatio),height:this._bestReflectionRenderTargetDimension(t.getRenderHeight(),this._sizeRatio)}}else this._size=e}get samples(){return this._renderTarget?.samples??this._samples}set samples(e){this._renderTarget&&(this._samples=this._renderTarget.setSamples(e))}addPostProcess(e){if(!this._postProcessManager){const t=this.getScene();if(!t)return;this._postProcessManager=new cf(t),this._postProcesses=new Array}this._postProcesses.push(e),this._postProcesses[0].autoClear=!1}clearPostProcesses(e=!1){if(this._postProcesses){if(e)for(const t of this._postProcesses)t.dispose();this._postProcesses=[]}}removePostProcess(e){if(!this._postProcesses)return;const t=this._postProcesses.indexOf(e);t!==-1&&(this._postProcesses.splice(t,1),this._postProcesses.length>0&&(this._postProcesses[0].autoClear=!1))}resetRefreshCounter(){this._objectRenderer.resetRefreshCounter()}get refreshRate(){return this._objectRenderer.refreshRate}set refreshRate(e){this._objectRenderer.refreshRate=e}_shouldRender(){return this._objectRenderer.shouldRender()}getRenderSize(){return this.getRenderWidth()}getRenderWidth(){return this._size.width?this._size.width:this._size}getRenderHeight(){return this._size.width?this._size.height:this._size}getRenderLayers(){const e=this._size.layers;if(e)return e;const t=this._size.depth;return t||0}disableRescaling(){this._canRescale=!1}get canRescale(){return this._canRescale}scale(e){const t=Math.max(1,this.getRenderSize()*e);this.resize(t)}getReflectionTextureMatrix(){return this.isCube?this._textureMatrix:super.getReflectionTextureMatrix()}resize(e){const t=this.isCube;this._renderTarget?.dispose(),this._renderTarget=null;const i=this.getScene();i&&(this._processSizeParameter(e),t?this._renderTarget=i.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions):this._renderTarget=i.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this._texture=this._renderTarget.texture,this._renderTargetOptions.samples!==void 0&&(this.samples=this._renderTargetOptions.samples),this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this))}render(e=!1,t=!1){this._render(e,t)}isReadyForRendering(){this._dumpToolsLoading||(this._dumpToolsLoading=!0,_t(()=>import("./dumpTools-DqSCTfgH.js"),[]).then(t=>this._dumpTools=t)),this._objectRenderer.prepareRenderList(),this.onBeforeBindObservable.notifyObservers(this),this._objectRenderer.initRender(this.getRenderWidth(),this.getRenderHeight());const e=this._objectRenderer._checkReadiness();return this.onAfterUnbindObservable.notifyObservers(this),this._objectRenderer.finishRender(),e}_render(e=!1,t=!1){const i=this.getScene();if(i){if(this.useCameraPostProcesses!==void 0&&(e=this.useCameraPostProcesses),this._objectRenderer.prepareRenderList(),this.onBeforeBindObservable.notifyObservers(this),this._objectRenderer.initRender(this.getRenderWidth(),this.getRenderHeight()),(this.is2DArray||this.is3D)&&!this.isMulti)for(let s=0;s<this.getRenderLayers();s++)this._renderToTarget(0,e,t,s),i.incrementRenderId(),i.resetCachedMaterial();else if(this.isCube&&!this.isMulti)for(let s=0;s<6;s++)this._renderToTarget(s,e,t),i.incrementRenderId(),i.resetCachedMaterial();else this._renderToTarget(0,e,t);this.onAfterUnbindObservable.notifyObservers(this),this._objectRenderer.finishRender()}}_bestReflectionRenderTargetDimension(e,t){const s=e*t,r=iC(s+16384/(128+s));return Math.min(xb(e),r)}_bindFrameBuffer(e=0,t=0){const i=this.getScene();if(!i)return;const s=i.getEngine();this._renderTarget&&s.bindFramebuffer(this._renderTarget,this.isCube?e:void 0,void 0,void 0,this.ignoreCameraViewport,0,t)}_unbindFrameBuffer(e,t){this._renderTarget&&e.unBindFramebuffer(this._renderTarget,this.isCube,()=>{this.onAfterRenderObservable.notifyObservers(t)})}_prepareFrame(e,t,i,s){this._postProcessManager?this._prePassEnabled||this._postProcessManager._prepareFrame(this._texture,this._postProcesses)||this._bindFrameBuffer(t,i):(!s||!e.postProcessManager._prepareFrame(this._texture))&&this._bindFrameBuffer(t,i)}_renderToTarget(e,t,i,s=0){const r=this.getScene();if(!r)return;const a=r.getEngine();this._currentFaceIndex=e,this._currentLayer=s,this._currentUseCameraPostProcess=t,this._currentDumpForDebug=i,this._prepareFrame(r,e,s,t),a._debugPushGroup?.(`render to face #${e} layer #${s}`,2),this._objectRenderer.render(e+s,!0),a._debugPopGroup?.(2),this._unbindFrameBuffer(a,e),this._texture&&this.isCube&&e===5&&a.generateMipMapsForCubemap(this._texture,!0)}setRenderingOrder(e,t=null,i=null,s=null){this._objectRenderer.setRenderingOrder(e,t,i,s)}setRenderingAutoClearDepthStencil(e,t){this._objectRenderer.setRenderingAutoClearDepthStencil(e,t)}clone(){const e=this.getSize(),t=new ar(this.name,e,this.getScene(),this._renderTargetOptions.generateMipMaps,this._doNotChangeAspectRatio,this._renderTargetOptions.type,this.isCube,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer,this._renderTargetOptions.generateStencilBuffer,void 0,this._renderTargetOptions.format,void 0,this._renderTargetOptions.samples);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,this.renderList&&(t.renderList=this.renderList.slice(0)),t}serialize(){if(!this.name)return null;const e=super.serialize();if(e.renderTargetSize=this.getRenderSize(),e.renderList=[],this.renderList)for(let t=0;t<this.renderList.length;t++)e.renderList.push(this.renderList[t].id);return e}disposeFramebufferObjects(){this._renderTarget?.dispose(!0)}releaseInternalTexture(){this._renderTarget?.releaseTextures(),this._texture=null}dispose(){this.onResizeObservable.clear(),this.onClearObservable.clear(),this.onAfterUnbindObservable.clear(),this.onBeforeBindObservable.clear(),this._postProcessManager&&(this._postProcessManager.dispose(),this._postProcessManager=null),this._prePassRenderTarget&&this._prePassRenderTarget.dispose(),this._objectRenderer.onBeforeRenderingManagerRenderObservable.remove(this._onBeforeRenderingManagerRenderObserver),this._objectRenderer.onAfterRenderingManagerRenderObservable.remove(this._onAfterRenderingManagerRenderObserver),this._objectRenderer.onFastPathRenderObservable.remove(this._onFastPathRenderObserver),this._dontDisposeObjectRenderer||this._objectRenderer.dispose(),this.clearPostProcesses(!0),this._resizeObserver&&(this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null);const e=this.getScene();if(!e)return;let t=e.customRenderTargets.indexOf(this);t>=0&&e.customRenderTargets.splice(t,1);for(const i of e.cameras)t=i.customRenderTargets.indexOf(this),t>=0&&i.customRenderTargets.splice(t,1);this._renderTarget?.dispose(),this._renderTarget=null,this._texture=null,super.dispose()}_rebuild(){this._objectRenderer._rebuild(),this._postProcessManager&&this._postProcessManager._rebuild()}freeRenderingGroups(){this._objectRenderer.freeRenderingGroups()}getViewCount(){return 1}}ar.REFRESHRATE_RENDER_ONCE=Or.REFRESHRATE_RENDER_ONCE;ar.REFRESHRATE_RENDER_ONEVERYFRAME=Or.REFRESHRATE_RENDER_ONEVERYFRAME;ar.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=Or.REFRESHRATE_RENDER_ONEVERYTWOFRAMES;Te._CreateRenderTargetTexture=(n,e,t,i,s)=>new ar(n,e,t,i);const Um="postprocessVertexShader",JC=`attribute vec2 position;uniform vec2 scale;varying vec2 vUV;const vec2 madd=vec2(0.5,0.5); 239#define CUSTOM_VERTEX_DEFINITIONS 240void main(void) { 241#define CUSTOM_VERTEX_MAIN_BEGIN 242vUV=(position*madd+madd)*scale;gl_Position=vec4(position,0.0,1.0); 243#define CUSTOM_VERTEX_MAIN_END 244}`;de.ShadersStore[Um]||(de.ShadersStore[Um]=JC);const I3={name:Um,shader:JC},eI=Object.freeze(Object.defineProperty({__proto__:null,postprocessVertexShader:I3},Symbol.toStringTag,{value:"Module"})),kg={positions:[1,1,-1,1,-1,-1,1,-1],indices:[0,1,2,0,2,3]};class eG{constructor(e,t=kg){this._fullscreenViewport=new Ja(0,0,1,1);const i=t.positions??kg.positions,s=t.indices??kg.indices;this.engine=e,this._vertexBuffers={[O.PositionKind]:new O(e,i,O.PositionKind,!1,!1,2)},this._indexBuffer=e.createIndexBuffer(s),this._indexBufferLength=s.length,this._onContextRestoredObserver=e.onContextRestoredObservable.add(()=>{this._indexBuffer=e.createIndexBuffer(s);for(const r in this._vertexBuffers)this._vertexBuffers[r]._rebuild()})}setViewport(e=this._fullscreenViewport){this.engine.setViewport(e)}bindBuffers(e){this.engine.bindBuffers(this._vertexBuffers,this._indexBuffer,e)}applyEffectWrapper(e,t=!1,i=!1){this.engine.setState(!0),this.engine.depthCullingState.depthTest=t,this.engine.stencilState.stencilTest=i,this.engine.enableEffect(e.drawWrapper),this.bindBuffers(e.effect),e.onApplyObservable.notifyObservers({})}saveStates(){this._savedStateDepthTest=this.engine.depthCullingState.depthTest,this._savedStateStencilTest=this.engine.stencilState.stencilTest}restoreStates(){this.engine.depthCullingState.depthTest=this._savedStateDepthTest,this.engine.stencilState.stencilTest=this._savedStateStencilTest}draw(){this.engine.drawElementsType(0,0,this._indexBufferLength)}_isRenderTargetTexture(e){return e.renderTarget!==void 0}render(e,t=null){if(!e.effect.isReady())return;this.saveStates(),this.setViewport();const i=t===null?null:this._isRenderTargetTexture(t)?t.renderTarget:t;i&&this.engine.bindFramebuffer(i),this.applyEffectWrapper(e),this.draw(),i&&this.engine.unBindFramebuffer(i),this.restoreStates()}dispose(){const e=this._vertexBuffers[O.PositionKind];e&&(e.dispose(),delete this._vertexBuffers[O.PositionKind]),this._indexBuffer&&this.engine._releaseBuffer(this._indexBuffer),this._onContextRestoredObserver&&(this.engine.onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)}}class gs{static RegisterShaderCodeProcessing(e,t){if(!t){delete gs._CustomShaderCodeProcessing[e??""];return}gs._CustomShaderCodeProcessing[e??""]=t}static _GetShaderCodeProcessing(e){return gs._CustomShaderCodeProcessing[e]??gs._CustomShaderCodeProcessing[""]}get name(){return this.options.name}set name(e){this.options.name=e}isReady(){return this._drawWrapper.effect?.isReady()??!1}get drawWrapper(){return this._drawWrapper}get effect(){return this._drawWrapper.effect}set effect(e){this._drawWrapper.effect=e}constructor(e){this.alphaMode=0,this.onEffectCreatedObservable=new le(void 0,!0),this.onApplyObservable=new le,this._shadersLoaded=!1,this._webGPUReady=!1,this._importPromises=[],this.options={...e,name:e.name||"effectWrapper",engine:e.engine,uniforms:e.uniforms||e.uniformNames||[],uniformNames:void 0,samplers:e.samplers||e.samplerNames||[],samplerNames:void 0,attributeNames:e.attributeNames||["position"],uniformBuffers:e.uniformBuffers||[],defines:e.defines||"",useShaderStore:e.useShaderStore||!1,vertexUrl:e.vertexUrl||e.vertexShader||"postprocess",vertexShader:void 0,fragmentShader:e.fragmentShader||"pass",indexParameters:e.indexParameters,blockCompilation:e.blockCompilation||!1,shaderLanguage:e.shaderLanguage||0,onCompiled:e.onCompiled||void 0,extraInitializations:e.extraInitializations||void 0,extraInitializationsAsync:e.extraInitializationsAsync||void 0,useAsPostProcess:e.useAsPostProcess??!1,allowEmptySourceTexture:e.allowEmptySourceTexture??!1},this.options.uniformNames=this.options.uniforms,this.options.samplerNames=this.options.samplers,this.options.vertexShader=this.options.vertexUrl,this.options.useAsPostProcess&&(!this.options.allowEmptySourceTexture&&this.options.samplers.indexOf("textureSampler")===-1&&this.options.samplers.push("textureSampler"),this.options.uniforms.indexOf("scale")===-1&&this.options.uniforms.push("scale")),e.vertexUrl||e.vertexShader?this._shaderPath={vertexSource:this.options.vertexShader}:(this.options.useAsPostProcess||(this.options.uniforms.push("scale"),this.onApplyObservable.add(()=>{this.effect.setFloat2("scale",1,1)})),this._shaderPath={vertex:this.options.vertexShader}),this._shaderPath.fragmentSource=this.options.fragmentShader,this._shaderPath.spectorName=this.options.name,this.options.useShaderStore&&(this._shaderPath.fragment=this._shaderPath.fragmentSource,this._shaderPath.vertex||(this._shaderPath.vertex=this._shaderPath.vertexSource),delete this._shaderPath.fragmentSource,delete this._shaderPath.vertexSource),this.onApplyObservable.add(()=>{this.bind()}),this.options.useShaderStore||(this._onContextRestoredObserver=this.options.engine.onContextRestoredObservable.add(()=>{this.effect._pipelineContext=null,this.effect._prepareEffect()})),this._drawWrapper=new Qh(this.options.engine),this._webGPUReady=this.options.shaderLanguage===1;const t=Array.isArray(this.options.defines)?this.options.defines.join(` 245`):this.options.defines;this._postConstructor(this.options.blockCompilation,t,this.options.extraInitializations)}_gatherImports(e=!1,t){this.options.useAsPostProcess&&(e&&this._webGPUReady?t.push(Promise.all([_t(()=>import("./postprocess.vertex-9VqeHBLm.js"),[])])):t.push(Promise.all([_t(()=>Promise.resolve().then(()=>eI),void 0)])))}_postConstructor(e,t=null,i,s){this._importPromises.length=0,s&&this._importPromises.push(...s);const r=this.options.engine.isWebGPU&&!gs.ForceGLSL;this._gatherImports(r,this._importPromises),i!==void 0&&i(r,this._importPromises),r&&this._webGPUReady&&(this.options.shaderLanguage=1),e||this.updateEffect(t)}updateEffect(e=null,t=null,i=null,s,r,a,o,c){const u=gs._GetShaderCodeProcessing(this.name);if(u?.defineCustomBindings){const g=t?.slice()??[];g.push(...this.options.uniforms);const m=i?.slice()??[];m.push(...this.options.samplers),e=u.defineCustomBindings(this.name,e,g,m),t=g,i=m}this.options.defines=e||"";const d=this._shadersLoaded||this._importPromises.length===0?void 0:async()=>{await Promise.all(this._importPromises),this._shadersLoaded=!0};let f;this.options.extraInitializationsAsync?f=async()=>{d?.(),await this.options.extraInitializationsAsync()}:f=d,this.options.useShaderStore?this._drawWrapper.effect=this.options.engine.createEffect({vertex:o??this._shaderPath.vertex,fragment:c??this._shaderPath.fragment},{attributes:this.options.attributeNames,uniformsNames:t||this.options.uniforms,uniformBuffersNames:this.options.uniformBuffers,samplers:i||this.options.samplers,defines:e!==null?e:"",fallbacks:null,onCompiled:r??this.options.onCompiled,onError:a??null,indexParameters:s||this.options.indexParameters,processCodeAfterIncludes:u?.processCodeAfterIncludes?(g,m)=>u.processCodeAfterIncludes(this.name,g,m):null,processFinalCode:u?.processFinalCode?(g,m)=>u.processFinalCode(this.name,g,m):null,shaderLanguage:this.options.shaderLanguage,extraInitializationsAsync:f},this.options.engine):this._drawWrapper.effect=new At(this._shaderPath,this.options.attributeNames,t||this.options.uniforms,i||this.options.samplerNames,this.options.engine,e,void 0,r||this.options.onCompiled,void 0,void 0,void 0,this.options.shaderLanguage,f),this.onEffectCreatedObservable.notifyObservers(this._drawWrapper.effect)}bind(e=!1){this.options.useAsPostProcess&&!e&&(this.options.engine.setAlphaMode(this.alphaMode),this.drawWrapper.effect.setFloat2("scale",1,1)),gs._GetShaderCodeProcessing(this.name)?.bindCustomBindings?.(this.name,this._drawWrapper.effect)}dispose(e=!1){this._onContextRestoredObserver&&(this.effect.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null),this.onEffectCreatedObservable.clear(),this._drawWrapper.dispose(!0)}}gs.ForceGLSL=!1;gs._CustomShaderCodeProcessing={};Ce.prototype.setTextureFromPostProcess=function(n,e,t){let i=null;e&&(e._forcedOutputTexture?i=e._forcedOutputTexture:e._textures.data[e._currentRenderTextureInd]&&(i=e._textures.data[e._currentRenderTextureInd])),this._bindTexture(n,i?.texture??null,t)};Ce.prototype.setTextureFromPostProcessOutput=function(n,e,t){this._bindTexture(n,e?._outputTexture?.texture??null,t)};At.prototype.setTextureFromPostProcess=function(n,e){this._engine.setTextureFromPostProcess(this._samplers[n],e,n)};At.prototype.setTextureFromPostProcessOutput=function(n,e){this._engine.setTextureFromPostProcessOutput(this._samplers[n],e,n)};class di{static get ForceGLSL(){return gs.ForceGLSL}static set ForceGLSL(e){gs.ForceGLSL=e}static RegisterShaderCodeProcessing(e,t){gs.RegisterShaderCodeProcessing(e,t)}get name(){return this._effectWrapper.name}set name(e){this._effectWrapper.name=e}get alphaMode(){return this._effectWrapper.alphaMode}set alphaMode(e){this._effectWrapper.alphaMode=e}get samples(){return this._samples}set samples(e){this._samples=Math.min(e,this._engine.getCaps().maxMSAASamples),this._textures.forEach(t=>{t.setSamples(this._samples)})}get shaderLanguage(){return this._shaderLanguage}getEffectName(){return this._fragmentUrl}set onActivate(e){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),e&&(this._onActivateObserver=this.onActivateObservable.add(e))}set onSizeChanged(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)}set onApply(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)}set onBeforeRender(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)}set onAfterRender(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)}get inputTexture(){return this._textures.data[this._currentRenderTextureInd]}set inputTexture(e){this._forcedOutputTexture=e}restoreDefaultInputTexture(){this._forcedOutputTexture&&(this._forcedOutputTexture=null,this.markTextureDirty())}getCamera(){return this._camera}get texelSize(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.texelSize:(this._forcedOutputTexture&&this._texelSize.copyFromFloats(1/this._forcedOutputTexture.width,1/this._forcedOutputTexture.height),this._texelSize)}constructor(e,t,i,s,r,a,o=1,c,u,d=null,f=0,g="postprocess",m,b=!1,x=5,v,E){this._parentContainer=null,this.width=-1,this.height=-1,this.nodeMaterialSource=null,this._outputTexture=null,this.autoClear=!0,this.forceAutoClearInAlphaMode=!1,this.animations=[],this.enablePixelPerfectMode=!1,this.forceFullscreenViewport=!0,this.scaleMode=1,this.alwaysForcePOT=!1,this._samples=1,this.adaptScaleToCurrentViewport=!1,this.doNotSerialize=!1,this._webGPUReady=!1,this._reusable=!1,this._renderId=0,this.externalTextureSamplerBinding=!1,this._textures=new Yi(2),this._textureCache=[],this._currentRenderTextureInd=0,this._scaleRatio=new Ie(1,1),this._texelSize=Ie.Zero(),this.onActivateObservable=new le,this.onSizeChangedObservable=new le,this.onApplyObservable=new le,this.onBeforeRenderObservable=new le,this.onAfterRenderObservable=new le,this.onDisposeObservable=new le;let A=1,D=null,I;if(i&&!Array.isArray(i)){const R=i;i=R.uniforms??null,s=R.samplers??null,A=R.size??1,a=R.camera??null,o=R.samplingMode??1,c=R.engine,u=R.reusable,d=Array.isArray(R.defines)?R.defines.join(` 246`):R.defines??null,f=R.textureType??0,g=R.vertexUrl??"postprocess",m=R.indexParameters,b=R.blockCompilation??!1,x=R.textureFormat??5,v=R.shaderLanguage??0,D=R.uniformBuffers??null,E=R.extraInitializations,I=R.effectWrapper}else r&&(typeof r=="number"?A=r:A={width:r.width,height:r.height});if(this._useExistingThinPostProcess=!!I,this._effectWrapper=I??new gs({name:e,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:t,engine:c||a?.getScene().getEngine(),uniforms:i,samplers:s,uniformBuffers:D,defines:d,vertexUrl:g,indexParameters:m,blockCompilation:!0,shaderLanguage:v,extraInitializations:void 0}),this.name=e,this.onEffectCreatedObservable=this._effectWrapper.onEffectCreatedObservable,a!=null?(this._camera=a,this._scene=a.getScene(),a.attachPostProcess(this),this._engine=this._scene.getEngine(),this._scene.addPostProcess(this),this.uniqueId=this._scene.getUniqueId()):c&&(this._engine=c,this._engine.postProcesses.push(this)),this._options=A,this.renderTargetSamplingMode=o||1,this._reusable=u||!1,this._textureType=f,this._textureFormat=x,this._shaderLanguage=v||0,this._samplers=s||[],this._samplers.indexOf("textureSampler")===-1&&this._samplers.push("textureSampler"),this._fragmentUrl=t,this._vertexUrl=g,this._parameters=i||[],this._parameters.indexOf("scale")===-1&&this._parameters.push("scale"),this._uniformBuffers=D||[],this._indexParameters=m,!this._useExistingThinPostProcess){this._webGPUReady=this._shaderLanguage===1;const R=[];this._gatherImports(this._engine.isWebGPU&&!di.ForceGLSL,R),this._effectWrapper._webGPUReady=this._webGPUReady,this._effectWrapper._postConstructor(b,d,E,R)}}_gatherImports(e=!1,t){e&&this._webGPUReady?t.push(Promise.all([_t(()=>import("./postprocess.vertex-9VqeHBLm.js"),[])])):t.push(Promise.all([_t(()=>Promise.resolve().then(()=>eI),void 0)]))}getClassName(){return"PostProcess"}getEngine(){return this._engine}getEffect(){return this._effectWrapper.drawWrapper.effect}shareOutputWith(e){return this._disposeTextures(),this._shareOutputWithPostProcess=e,this}useOwnOutput(){this._textures.length==0&&(this._textures=new Yi(2)),this._shareOutputWithPostProcess=null}updateEffect(e=null,t=null,i=null,s,r,a,o,c){this._effectWrapper.updateEffect(e,t,i,s,r,a,o,c),this._postProcessDefines=Array.isArray(this._effectWrapper.options.defines)?this._effectWrapper.options.defines.join(` 247`):this._effectWrapper.options.defines}isReusable(){return this._reusable}markTextureDirty(){this.width=-1}_createRenderTargetTexture(e,t,i=0){for(let r=0;r<this._textureCache.length;r++)if(this._textureCache[r].texture.width===e.width&&this._textureCache[r].texture.height===e.height&&this._textureCache[r].postProcessChannel===i&&this._textureCache[r].texture._generateDepthBuffer===t.generateDepthBuffer&&this._textureCache[r].texture.samples===t.samples)return this._textureCache[r].texture;const s=this._engine.createRenderTargetTexture(e,t);return this._textureCache.push({texture:s,postProcessChannel:i,lastUsedRenderId:-1}),s}_flushTextureCache(){const e=this._renderId;for(let t=this._textureCache.length-1;t>=0;t--)if(e-this._textureCache[t].lastUsedRenderId>100){let i=!1;for(let s=0;s<this._textures.length;s++)if(this._textures.data[s]===this._textureCache[t].texture){i=!0;break}i||(this._textureCache[t].texture.dispose(),this._textureCache.splice(t,1))}}resize(e,t,i=null,s=!1,r=!1){this._textures.length>0&&this._textures.reset(),this.width=e,this.height=t;let a=null;if(i){for(let u=0;u<i._postProcesses.length;u++)if(i._postProcesses[u]!==null){a=i._postProcesses[u];break}}const o={width:this.width,height:this.height},c={generateMipMaps:s,generateDepthBuffer:r||a===this,generateStencilBuffer:(r||a===this)&&this._engine.isStencilEnable,samplingMode:this.renderTargetSamplingMode,type:this._textureType,format:this._textureFormat,samples:this._samples,label:"PostProcessRTT-"+this.name};this._textures.push(this._createRenderTargetTexture(o,c,0)),this._reusable&&this._textures.push(this._createRenderTargetTexture(o,c,1)),this._texelSize.copyFromFloats(1/this.width,1/this.height),this.onSizeChangedObservable.notifyObservers(this)}_getTarget(){let e;if(this._shareOutputWithPostProcess)e=this._shareOutputWithPostProcess.inputTexture;else if(this._forcedOutputTexture)e=this._forcedOutputTexture,this.width=this._forcedOutputTexture.width,this.height=this._forcedOutputTexture.height;else{e=this.inputTexture;let t;for(let i=0;i<this._textureCache.length;i++)if(this._textureCache[i].texture===e){t=this._textureCache[i];break}t&&(t.lastUsedRenderId=this._renderId)}return e}activate(e,t=null,i){const s=e===null||e.cameraRigMode!==void 0?e||this._camera:null,r=s?.getScene()??e,a=r.getEngine(),o=a.getCaps().maxTextureSize,c=(t?t.width:this._engine.getRenderWidth(!0))*this._options|0,u=(t?t.height:this._engine.getRenderHeight(!0))*this._options|0;let d=this._options.width||c,f=this._options.height||u;const g=this.renderTargetSamplingMode!==7&&this.renderTargetSamplingMode!==1&&this.renderTargetSamplingMode!==2;let m=null;if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){if(this.adaptScaleToCurrentViewport){const b=a.currentViewport;b&&(d*=b.width,f*=b.height)}(g||this.alwaysForcePOT)&&(this._options.width||(d=a.needPOTTextures?Vo(d,o,this.scaleMode):d),this._options.height||(f=a.needPOTTextures?Vo(f,o,this.scaleMode):f)),(this.width!==d||this.height!==f||!(m=this._getTarget()))&&this.resize(d,f,s,g,i),this._textures.forEach(b=>{b.samples!==this.samples&&this._engine.updateRenderTargetTextureSampleCount(b,this.samples)}),this._flushTextureCache(),this._renderId++}return m||(m=this._getTarget()),this.enablePixelPerfectMode?(this._scaleRatio.copyFromFloats(c/d,u/f),this._engine.bindFramebuffer(m,0,c,u,this.forceFullscreenViewport)):(this._scaleRatio.copyFromFloats(1,1),this._engine.bindFramebuffer(m,0,void 0,void 0,this.forceFullscreenViewport)),this._engine._debugInsertMarker?.(`post process ${this.name} input`),this.onActivateObservable.notifyObservers(s),this.autoClear&&(this.alphaMode===0||this.forceAutoClearInAlphaMode)&&this._engine.clear(this.clearColor?this.clearColor:r.clearColor,r._allowPostProcessClearColor,!0,!0),this._reusable&&(this._currentRenderTextureInd=(this._currentRenderTextureInd+1)%2),m}get isSupported(){return this._effectWrapper.drawWrapper.effect.isSupported}get aspectRatio(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.aspectRatio:this._forcedOutputTexture?this._forcedOutputTexture.width/this._forcedOutputTexture.height:this.width/this.height}isReady(){return this._effectWrapper.isReady()}apply(){if(!this._effectWrapper.isReady())return null;this._engine.enableEffect(this._effectWrapper.drawWrapper),this._engine.setState(!1),this._engine.setDepthBuffer(!1),this._engine.setDepthWrite(!1),this.alphaConstants&&this.getEngine().setAlphaConstants(this.alphaConstants.r,this.alphaConstants.g,this.alphaConstants.b,this.alphaConstants.a),this._engine.setAlphaMode(this.alphaMode);let e;return this._shareOutputWithPostProcess?e=this._shareOutputWithPostProcess.inputTexture:this._forcedOutputTexture?e=this._forcedOutputTexture:e=this.inputTexture,this.externalTextureSamplerBinding||this._effectWrapper.drawWrapper.effect._bindTexture("textureSampler",e?.texture),this._effectWrapper.drawWrapper.effect.setVector2("scale",this._scaleRatio),this.onApplyObservable.notifyObservers(this._effectWrapper.drawWrapper.effect),this._effectWrapper.bind(!0),this._effectWrapper.drawWrapper.effect}_disposeTextures(){if(this._shareOutputWithPostProcess||this._forcedOutputTexture){this._disposeTextureCache();return}this._disposeTextureCache(),this._textures.dispose()}_disposeTextureCache(){for(let e=this._textureCache.length-1;e>=0;e--)this._textureCache[e].texture.dispose();this._textureCache.length=0}setPrePassRenderer(e){return this._prePassEffectConfiguration?(this._prePassEffectConfiguration=e.addEffectConfiguration(this._prePassEffectConfiguration),this._prePassEffectConfiguration.enabled=!0,!0):!1}dispose(e){e=e||this._camera,this._useExistingThinPostProcess||this._effectWrapper.dispose(),this._disposeTextures();let t;if(this._scene&&(t=this._scene.removePostProcess(this)),this._parentContainer){const i=this._parentContainer.postProcesses.indexOf(this);i>-1&&this._parentContainer.postProcesses.splice(i,1),this._parentContainer=null}if(t=this._engine.postProcesses.indexOf(this),t!==-1&&this._engine.postProcesses.splice(t,1),this.onDisposeObservable.notifyObservers(),!!e){if(e.detachPostProcess(this),t=e._postProcesses.indexOf(this),t===0&&e._postProcesses.length>0){const i=this._camera._getFirstPostProcess();i&&i.markTextureDirty()}this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear(),this.onEffectCreatedObservable.clear()}}serialize(){const e=$e.Serialize(this),t=this.getCamera()||this._scene&&this._scene.activeCamera;return e.customType="BABYLON."+this.getClassName(),e.cameraId=t?t.id:null,e.reusable=this._reusable,e.textureType=this._textureType,e.fragmentUrl=this._fragmentUrl,e.parameters=this._parameters,e.samplers=this._samplers,e.uniformBuffers=this._uniformBuffers,e.options=this._options,e.defines=this._postProcessDefines,e.textureFormat=this._textureFormat,e.vertexUrl=this._vertexUrl,e.indexParameters=this._indexParameters,e}clone(){const e=this.serialize();e._engine=this._engine,e.cameraId=null;const t=di.Parse(e,this._scene,"");return t?(t.onActivateObservable=this.onActivateObservable.clone(),t.onSizeChangedObservable=this.onSizeChangedObservable.clone(),t.onApplyObservable=this.onApplyObservable.clone(),t.onBeforeRenderObservable=this.onBeforeRenderObservable.clone(),t.onAfterRenderObservable=this.onAfterRenderObservable.clone(),t._prePassEffectConfiguration=this._prePassEffectConfiguration,t):null}static Parse(e,t,i){const s=Kr(e.customType);if(!s||!s._Parse)return null;const r=t?t.getCameraById(e.cameraId):null;return s._Parse(e,r,t,i)}static _Parse(e,t,i,s){return $e.Parse(()=>new di(e.name,e.fragmentUrl,e.parameters,e.samplers,e.options,t,e.renderTargetSamplingMode,e._engine,e.reusable,e.defines,e.textureType,e.vertexUrl,e.indexParameters,!1,e.textureFormat),e,i,s)}}N([H()],di.prototype,"uniqueId",void 0);N([H()],di.prototype,"name",null);N([H()],di.prototype,"width",void 0);N([H()],di.prototype,"height",void 0);N([H()],di.prototype,"renderTargetSamplingMode",void 0);N([yC()],di.prototype,"clearColor",void 0);N([H()],di.prototype,"autoClear",void 0);N([H()],di.prototype,"forceAutoClearInAlphaMode",void 0);N([H()],di.prototype,"alphaMode",null);N([H()],di.prototype,"alphaConstants",void 0);N([H()],di.prototype,"enablePixelPerfectMode",void 0);N([H()],di.prototype,"forceFullscreenViewport",void 0);N([H()],di.prototype,"scaleMode",void 0);N([H()],di.prototype,"alwaysForcePOT",void 0);N([H("samples")],di.prototype,"_samples",void 0);N([H()],di.prototype,"adaptScaleToCurrentViewport",void 0);Tt("BABYLON.PostProcess",di);class Gs extends gs{_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(Prom
247ise.all([_t(()=>import("./kernelBlur.fragment-6KL_RhP4.js"),__vite__mapDeps([5,6,7])),_t(()=>import("./kernelBlur.vertex-DM3d8DeT.js"),__vite__mapDeps([8,6]))]))):t.push(Promise.all([_t(()=>import("./kernelBlur.fragment-HBFz0pEB.js"),__vite__mapDeps([9,10])),_t(()=>import("./kernelBlur.vertex--iz_TC9N.js"),__vite__mapDeps([11,10]))]))}constructor(e,t=null,i,s,r){const a=!!r?.blockCompilation;super({...r,name:e,engine:t||Pe.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:Gs.FragmentUrl,uniforms:Gs.Uniforms,samplers:Gs.Samplers,vertexUrl:Gs.VertexUrl,blockCompilation:!0}),this._packedFloat=!1,this._staticDefines="",this.textureWidth=0,this.textureHeight=0,this._staticDefines=r?Array.isArray(r.defines)?r.defines.join(` 248`):r.defines||"":"",this.options.blockCompilation=a,i!==void 0&&(this.direction=i),s!==void 0&&(this.kernel=s)}set kernel(e){this._idealKernel!==e&&(e=Math.max(e,1),this._idealKernel=e,this._kernel=this._nearestBestKernel(e),this.options.blockCompilation||this._updateParameters())}get kernel(){return this._idealKernel}set packedFloat(e){this._packedFloat!==e&&(this._packedFloat=e,this.options.blockCompilation||this._updateParameters())}get packedFloat(){return this._packedFloat}bind(e=!1){super.bind(e),this._drawWrapper.effect.setFloat2("delta",1/this.textureWidth*this.direction.x,
2481/this.textureHeight*this.direction.y)}_updateParameters(e,t){const i=this._kernel,s=(i-1)/2;let r=[],a=[],o=0;for(let v=0;v<i;v++){const E=v/(i-1),A=this._gaussianWeight(E*2-1);r[v]=v-s,a[v]=A,o+=A}for(let v=0;v<a.length;v++)a[v]/=o;const c=[],u=[],d=[];for(let v=0;v<=s;v+=2){const E=Math.min(v+1,Math.floor(s));if(v===E)d.push({o:r[v],w:a[v]});else{const D=E===s,I=a[v]+a[E]*(D?.5:1),R=r[v]+1/(1+a[v]/a[E]);R===0?(d.push({o:r[v],w:a[v]}),d.push({o:r[v+1],w:a[v+1]})):(d.push({o:R,w:I}),d.push({o:-R,w:I}))}}for(let v=0;v<d.length;v++)u[v]=d[v].o,c[v]=d[v].w;r=u,a=c;const f=this.options.engine.getCaps().maxVaryingVectors-(this.options.shaderLanguage===1?1:0),g=Math.max(f,0)-1;let m=Math.min(r.length,g),b="";b+=this._staticDefines,this._staticDefines.indexOf("DOF")!=-1&&(b+=`#define CENTER_WEIGHT ${this._glslFloat(a[m-1])} 249`,m--);for(let v=0;v<m;v++)b+=`#define KERNEL_OFFSET${v} ${this._glslFloat(r[v])} 250`,b+=`#define KERNEL_WEIGHT${v} ${this._glslFloat(a[v])} 251`;let x=0;for(let v=g;v<r.length;v++)b+=`#define KERNEL_DEP_OFFSET${x} ${this._glslFloat(r[v])} 252`,b+=`#define KERNEL_DEP_WEIGHT${x} ${this._glslFloat(a[v])} 253`,x++;this.packedFloat&&(b+="#define PACKEDFLOAT 1"),this.options.blockCompilation=!1,this.updateEffect(b,null,null,{varyingCount:m,depCount:x},e,t)}_nearestBestKernel(e){const t=Math.round(e);for(const i of[t,t-1,t+1,t-2,t+2])if(i%2!==0&&Math.floor(i/2)%2===0&&i>0)return Math.max(i,3);return Math.max(t,3)}_gaussianWeight(e){const t=.3333333333333333,i=Math.sqrt(2*Math.PI)*t,s=-(e*e/(2*t*t));return 1/i*Math.exp(s)}_glslFloat(e,t=8){return e.toFixed(t).replace(/0+$/,"")}}Gs.VertexUrl="kernelBlur";Gs.FragmentUrl="kernelBlur";Gs.Uniforms=["delta","direction"];Gs.Samplers=["circleOfConfusionSampler"];class to extends di{get direction(){return this._effectWrapper.direction}set direction(e){this._effectWrapper.direction=e}set kernel(e){this._effectWrapper.kernel=e}get kernel(){return this._effectWrapper.kernel}set packedFloat(e){this._effectWrapper.packedFloat=e}get packedFloat(){return this._effectWrapper.packedFloat}getClassName(){return"BlurPostProcess"}constructor(e,t,i,s,r=null,a=Te.BILINEAR_SAMPLINGMODE,o,c,u=0,d="",f=!1,g=5){const m=typeof s=="number"?f:!!s.blockCompilation,b={uniforms:Gs.Uniforms,samplers:Gs.Samplers,size:typeof s=="number"?s:void 0,camera:r,samplingMode:a,engine:o,reusable:c,textureType:u,vertexUrl:Gs.VertexUrl,indexParameters:{varyingCount:0,depCount:0},textureFormat:g,defines:d,...s,blockCompilation:!0};super(e,Gs.FragmentUrl,{effectWrapper:typeof s=="number"||!s.effectWrapper?new Gs(e,o,void 0,void 0,b):void 0,...b}),this._effectWrapper.options.blockCompilation=m,this.direction=t,this.onApplyObservable.add(()=>{this._effectWrapper.textureWidth=this._outputTexture?this._outputTexture.width:this.width,this._effectWrapper.textureHeight=this._outputTexture?this._outputTexture.height:this.height}),this.kernel=i}updateEffect(e=null,t=null,i=null,s,r,a){this._effectWrapper._updateParameters(r,a)}static _Parse(e,t,i,s){return $e.Parse(()=>new to(e.name,e.direction,e.kernel,e.options,t,e.renderTargetSamplingMode,i.getEngine(),e.reusable,e.textureType,void 0,!1),e,i,s)}}N([mC()],to.prototype,"direction",null);N([H()],to.prototype,"kernel",null);N([H()],to.prototype,"packedFloat",null);Tt("BABYLON.BlurPostProcess",to);class eu{constructor(){this._defines={},this._currentRank=32,this._maxRank=-1,this._mesh=null}unBindMesh(){this._mesh=null}addFallback(e,t){this._defines[e]||(e<this._currentRank&&(this._currentRank=e),e>this._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)}addCPUSkinningFallback(e,t){this._mesh=t,e<this._currentRank&&(this._currentRank=e),e>this._maxRank&&(this._maxRank=e)}get hasMoreFallbacks(){return this._currentRank<=this._maxRank}reduce(e,t){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,e=e.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),t._bonesComputationForcedToCPU=!0;const i=this._mesh.getScene();for(let s=0;s<i.meshes.length;s++){const r=i.meshes[s];if(!r.material){!this._mesh.material&&r.computeBonesUsingShaders&&r.numBoneInfluencers>0&&(r.computeBonesUsingShaders=!1);continue}if(!(!r.computeBonesUsingShaders||r.numBoneInfluencers===0)){if(r.material.getEffect()===t)r.computeBonesUsingShaders=!1;else if(r.subMeshes){for(const a of r.subMeshes)if(a.effect===t){r.computeBonesUsingShaders=!1;break}}}}}else{const i=this._defines[this._currentRank];if(i)for(let s=0;s<i.length;s++)e=e.replace("#define "+i[s],"");this._currentRank++}return e}}class ze{get bias(){return this._bias}set bias(e){this._bias=e}get normalBias(){return this._normalBias}set normalBias(e){this._normalBias=e}get blurBoxOffset(){return this._blurBoxOffset}set blurBoxOffset(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())}get blurScale(){return this._blurScale}set blurScale(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())}get blurKernel(){return this._blurKernel}set blurKernel(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())}get useKernelBlur(){return this._useKernelBlur}set useKernelBlur(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())}get depthScale(){return this._depthScale!==void 0?this._depthScale:this._light.getDepthScale()}set depthScale(e){this._depthScale=e}_validateFilter(e){return e}get filter(){return this._filter}
253set filter(e){if(e=this._validateFilter(e),this._light.needCube()){if(e===ze.FILTER_BLUREXPONENTIALSHADOWMAP){this.useExponentialShadowMap=!0;return}else if(e===ze.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP){this.useCloseExponentialShadowMap=!0;return}else if(e===ze.FILTER_PCF||e===ze.FILTER_PCSS){this.usePoissonSampling=!0;return}}if((e===ze.FILTER_PCF||e===ze.FILTER_PCSS)&&!this._scene.getEngine()._features.supportShadowSamplers){this.usePoissonSampling=!0;return}this._filter!==e&&(this._filter=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())}get usePoissonSampling(){return this.filter===ze.FILTER_POISSONSAMPLING}set usePoissonSampling(e){const t=this._validateFilter(ze.FILTER_POISSONSAMPLING);!e&&this.filter!==ze.FILTER_POISSONSAMPLING||(this.filter=e?t:ze.FILTER_NONE)}get useExponentialShadowMap(){return this.filter===ze.FILTER_EXPONENTIALSHADOWMAP}set useExponentialShadowMap(e){const t=this._validateFilter(ze.FILTER_EXPONENTIALSHADOWMAP);!e&&this.filter!==ze.FILTER_EXPONENTIALSHADOWMAP||(this.filter=e?t:ze.FILTER_NONE)}get useBlurExponentialShadowMap(){return this.filter===ze.FILTER_BLUREXPONENTIALSHADOWMAP}set useBlurExponentialShadowMap(e){const t=this._validateFilter(ze.FILTER_BLUREXPONENTIALSHADOWMAP);!e&&this.filter!==ze.FILTER_BLUREXPONENTIALSHADOWMAP||(this.filter=e?t:ze.FILTER_NONE)}get useCloseExponentialShadowMap(){return this.filter===ze.FILTER_CLOSEEXPONENTIALSHADOWMAP}set useCloseExponentialShadowMap(e){const t=this._validateFilter(ze.FILTER_CLOSEEXPONENTIALSHADOWMAP);!e&&this.filter!==ze.FILTER_CLOSEEXPONENTIALSHADOWMAP||(this.filter=e?t:ze.FILTER_NONE)}get useBlurCloseExponentialShadowMap(){return this.filter===ze.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP}set useBlurCloseExponentialShadowMap(e){const t=this._validateFilter(ze.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);!e&&this.filter!==ze.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP||(this.filter=e?t:ze.FILTER_NONE)}get usePercentageCloserFiltering(){return this.filter===ze.FILTER_PCF}set usePercentageCloserFiltering(e){const t=this._validateFilter(ze.FILTER_PCF);!e&&this.filter!==ze.FILTER_PCF||(this.filter=e?t:ze.FILTER_NONE)}get filteringQuality(){return this._filteringQuality}set filteringQuality(e){this._filteringQuality!==e&&(this._filteringQuality=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())}get useContactHardeningShadow(){return this.filter===ze.FILTER_PCSS}set useContactHardeningShadow(e){const t=this._validateFilter(ze.FILTER_PCSS);!e&&this.filter!==ze.FILTER_PCSS||(this.filter=e?t:ze.FILTER_NONE)}get contactHardeningLightSizeUVRatio(){return this._contactHardeningLightSizeUVRatio}set contactHardeningLightSizeUVRatio(e){this._contactHardeningLightSizeUVRatio=e}get darkness(){return this._darkness}set darkness(e){this.setDarkness(e)}getDarkness(){return this._darkness}setDarkness(e){return e>=1?this._darkness=1:e<=0?this._darkness=0:this._darkness=e,this}get transparencyShadow(){return this._transparencyShadow}set transparencyShadow(e){this.setTransparencyShadow(e)}setTransparencyShadow(e){return this._transparencyShadow=e,this}getShadowMap(){return this._shadowMap}getShadowMapForRendering(){return this._shadowMap2?this._shadowMap2:this._shadowMap}getClassName(){return ze.CLASSNAME}addShadowCaster(e,t=!0){if(!this._shadowMap)return this;if(this._shadowMap.renderList||(this._shadowMap.renderList=[]),this._shadowMap.renderList.indexOf(e)===-1&&this._shadowMap.renderList.push(e),t)for(const i of e.getChildMeshes())this._shadowMap.renderList.indexOf(i)===-1&&this._shadowMap.renderList.push(i);return this}removeShadowCaster(e,t=!0){if(!this._shadowMap||!this._shadowMap.renderList)return this;const i=this._shadowMap.renderList.indexOf(e);if(i!==-1&&this._shadowMap.renderList.splice(i,1),t)for(const s of e.getChildren())this.removeShadowCaster(s);return this}getLight(){return this._light}get shaderLanguage(){return this._shaderLanguage}_getCamera(){return this._camera??this._scene.activeCamera}get mapSize(){return this._mapSize}set mapSize(e){this._mapSize=e,this._light._markMeshesAsLightDirty(),this.recreateShadowMap()}constructor(e,t,i,s,r,a=!1){this.onBeforeShadowMapRenderObservable=new le,this.onAfterShadowMapRenderObservable=new le,this.onBeforeShadowMapRenderMeshObservable=new le,this.onAfterShadowMapRenderMeshObservable=new le,this.doNotSerialize=!1,this._bias=5e-5,this._normalBias=0,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=ze.FILTER_NONE,this._filteringQuality=ze.QUALITY_HIGH,this._contactHardeningLightSizeUVRatio=.1,this._darkness=0,this._transparencyShadow=!1,this.enableSoftTransparentShadow=!1,this.useOpacityTextureForTransparentShadow=!1,this.frustumEdgeFalloff=0,this._shaderLanguage=0,this.forceBackFacesOnly=!1,this._lightDirection=T.Zero(),this._viewMatrix=W.Zero(),this._projectionMatrix=W.Zero(),this._transformMatrix=W.Zero(),this._cachedPosition=new T(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cachedDirection=new T(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._defaultTextureMatrix=W.Identity(),this._shadersLoaded=!1,this._mapSize=e,this._light=t,this._scene=t.getSce
253ne(),this._camera=s??null,this._useRedTextureType=!!r,this._initShaderSourceAsync(a);let o=t._shadowGenerators;o||(o=t._shadowGenerators=new Map),o.set(this._camera,this),this.id=t.id,this._useUBO=this._scene.getEngine().supportsUniformBuffers,this._useUBO&&(this._sceneUBOs=[],this._sceneUBOs.push(this._scene.createSceneUniformBuffer(`Scene for Shadow Generator (light "${this._light.name}")`))),ze._SceneComponentInitialization(this._scene);const c=this._scene.getEngine().getCaps();i?c.textureFloatRender&&c.textureFloatLinearFiltering?this._textureType=1:c.textureHalfFloatRender&&c.textureHalfFloatLinearFiltering?this._textureType=2:this._textureType=0:c.textureHalfFloatRender&&c.textureHalfFloatLinearFiltering?this._textureType=2:c.textureFloatRender&&c.textureFloatLinearFiltering?this._textureType=1:this._textureType=0,this._initializeGenerator(),this._applyFilterValues()}_initializeGenerator(){this._light._markMeshesAsLightDirty(),this._initializeShadowMap()}_createTargetRenderTexture(){const e=this._scene.getEngine();this._shadowMap?.dispose(),e._features.supportDepthStencilTexture?(this._shadowMap=new ar(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube(),void 0,!1,!1,void 0,this._useRedTextureType?6:5),this._shadowMap.createDepthStencilTexture(e.useReverseDepthBuffer?516:513,!0,void 0,void 0,void 0,`DepthStencilForShadowGenerator-${this._light.name}`)):this._shadowMap=new ar(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube()),this._shadowMap.noPrePassRenderer=!0}_initializeShadowMap(){if(this._createTargetRenderTexture(),this._shadowMap===null)return;this._shadowMap.wrapU=Te.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=Te.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(Te.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.ignoreCameraViewport=!0,this._storedUniqueId&&(this._shadowMap.uniqueId=this._storedUniqueId),this._shadowMap.customRenderFunction=(s,r,a,o)=>this._renderForShadowMap(s,r,a,o),this._shadowMap.customIsReadyFunction=(s,r,a)=>{if(!a||!s.subMeshes)return!0;let o=!0;for(const c of s.subMeshes){const u=c.getRenderingMesh(),f=this._scene.getEngine(),g=c.getMaterial();if(!g||c.verticesCount===0||this.customAllowRendering&&!this.customAllowRendering(c))continue;const m=u._getInstancesRenderList(c._id,!!c.getReplacementMesh());if(m.mustReturn)continue;const b=f.getCaps().instancedArrays&&(m.visibleInstances[c._id]!==null&&m.visibleInstances[c._id]!==void 0||u.hasThinInstances),x=g.needAlphaBlendingForMesh(u);o=this.isReady(c,b,x)&&o}return o};const e=this._scene.getEngine();this._shadowMap.onBeforeBindObservable.add(()=>{this._currentSceneUBO=this._scene.getSceneUniformBuffer(),e._debugPushGroup?.(`shadow map generation for pass id ${e.currentRenderPassId}`,1)}),this._shadowMap.onBeforeRenderObservable.add(s=>{this._sceneUBOs&&this._scene.setSceneUniformBuffer(this._sceneUBOs[0]),this._currentFaceIndex=s,this._filter===ze.FILTER_PCF&&e.setColorWrite(!1),this.getTransformMatrix(),Go.eyeAtCamera=!1,this._scene.setTransformMatrix(this._viewMatrix,this._projectionMatrix),this._useUBO&&(this._scene.getSceneUniformBuffer().unbindEffect(),this._scene.finalizeSceneUbo())}),this._shadowMap.onAfterUnbindObservable.add(()=>{if(this._sceneUBOs&&this._scene.setSceneUniformBuffer(this._currentSceneUBO),Go.eyeAtCamera=!0,this._scene.updateTransformMatrix(),this._filter===ze.FILTER_PCF&&e.setColorWrite(!0),!this.useBlurExponentialShadowMap&&!this.useBlurCloseExponentialShadowMap){e._debugPopGroup?.(1);return}const s=this.getShadowMapForRendering();s&&(this._scene.postProcessManager.directRender(this._blurPostProcesses,s.renderTarget,!0),e.unBindFramebuffer(s.renderTarget,!0)),e._debugPopGroup?.(1)});const t=new Ze(0,0,0,0),i=new Ze(1,1,1,1);this._shadowMap.onClearObservable.add(s=>{this._filter===ze.FILTER_PCF?s.clear(i,!1,!0,!1):this.useExponentialShadowMap||this.useBlurExponentialShadowMap?s.clear(t,!0,!0,!1):s.clear(i,!0,!0,!1)}),this._shadowMap.onResizeObservable.add(s=>{this._storedUniqueId=this._shadowMap.uniqueId,this._mapSize=s.getRenderSize(),this._light._markMeshesAsLightDirty(),this.recreateShadowMap()});for(let s=zi.MIN_RENDERINGGROUPS;s<zi.MAX_RENDERINGGROUPS;s++)this._shadowMap.setRenderingAutoClearDepthStencil(s,!1)}async _initShaderSourceAsync(e=!1){this._scene.getEngine().isWebGPU&&!e&&!ze.ForceGLSL?(this._shaderLanguage=1,await Promise.all([_t(()=>import("./shadowMap.fragment-D8YKWezw.js"),__vite__mapDeps([12,7,13])),_t(()=>import("./shadowMap.vertex-Cae3rOL3.js"),__vite__mapDeps([14,15,16,17,18])),_t(()=>import("./depthBoxBlur.fragment-CrlnJwQT.js"),[]),_t(()=>import("./shadowMapFragmentSoftTransparentShadow-CFhSoztv.js"),[])])):await Promise.all([_t(()=>import("./shadowMap.fragment-DA1KouTo.js"),[]),_t(()=>import("./shadowMap.vertex-DVqiYOJH.js"),[]),_t(()=>import("./depthBoxBlur.fragment-B2TpV_ob.js"),[]),_t(()=>import("./shadowMapFragmentSoftTransparentShadow-Cseu5n3V.js"),[])]),this._shadersLoaded=!0}_initializeBlurRTTAndPostProcesses(){const e=this._scene.getEngine(),t=this._mapSize/this.blurScale;(!this.useKernelBlur||this.blurScale!==1)&&(this._shadowMap2=new ar(this._light.name+"_shadowMap2",t,this._scene,!1,!0,this._textureType,void 0,void 0,!1),this._shadowMap2.wrapU=Te.CLAMP_ADDRESSMODE,this._shadowMap2.wrapV=Te.CLAMP_ADDRESSMODE,this._shadowMap2.updateSamplingMode(Te.BILINEAR_SAMPLINGMODE)),this.useKernelBlur?(this._kernelBlurXPostprocess=new to(this._light.name+"KernelBlurX",new Ie(1,0),this.blurKernel,1,null,Te.BILINEAR_SAMPLINGMODE,e,!1,this._textureType),this._kernelBlurXPostprocess.width=t,this._kernelBlurXPostprocess.height=t,this._kernelBlurXPostprocess.externalTextureSamplerBinding=!0,this._kernelBlurXPostprocess.onApplyObservable.add(i=>{i.setTexture("textureSampler",this._shadowMap)}),this._kernelBlurYPostprocess=new to(this._light.name+"KernelBlurY",new Ie(0,1),this.blurKernel,1,null,Te.BILINEAR_SAMPLINGMODE,e,!1,this._textureType),this._kernelBlurXPostprocess.autoClear=!1,this._kernelBlurYPostprocess.autoClear=!1,this._textureType===0&&(this._kernelBlurXPostprocess.packedFloat=!0,this._kernelBlurYPostprocess.packedFloat=!0),this._blurPostProcesses=[this._kernelBlurXPostprocess,this._kernelBlurYPostprocess]):(this._boxBlurPostprocess=new di(this._light.name+"DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1,null,Te.BILINEAR_SAMPLINGMODE,e,!1,"#define OFFSET "+this._blurBoxOffset,this._textureType,void 0,void 0,void 0,void 0,this._shaderLanguage),this._boxBlurPostprocess.externalTextureSamplerBinding=!0,this._boxBlurPostprocess.onApplyObservable.add(i=>{i.setFloat2("screenSize",t,t),i.setTexture("textureSampler",this._shadowMap)}),this._boxBlurPostprocess.autoClear=!1,this._blurPostProcesses=[this._boxBlurPostprocess])}_renderForShadowMap(e,t,i,s){let r;if(s.length)for(r=0;r<s.length;r++)this._renderSubMeshForShadowMap(s.data[r]);for(r=0;r<e.length;r++)this._renderSubMeshForShadowMap(e.data[r]);for(r=0;r<t.length;r++)this._renderSubMeshForShadowMap(t.data[r]);if(this._transparencyShadow)for(r=0;r<i.length;r++)this._renderSubMeshForShadowMap(i.data[r],!0);else for(r=0;r<i.length;r++)i.data[r].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate=!1}
253_bindCustomEffectForRenderSubMeshForShadowMap(e,t,i){t.setMatrix("viewProjection",this.getTransformMatrix())}_renderSubMeshForShadowMap(e,t=!1){const i=e.getRenderingMesh(),s=e.getEffectiveMesh(),r=this._scene,a=r.getEngine(),o=e.getMaterial();if(s._internalAbstractMeshDataInfo._isActiveIntermediate=!1,!o||e.verticesCount===0||e._renderId===r.getRenderId())return;const c=r.useRightHandedSystem,u=s._getWorldMatrixDeterminant()<0;let d=o._getEffectiveOrientation(i);(u&&!c||!u&&c)&&(d=d===0?1:0);const f=d===0;a.setState(o.backFaceCulling,void 0,void 0,f,o.cullBackFaces);const g=i._getInstancesRenderList(e._id,!!e.getReplacementMesh());if(g.mustReturn)return;const m=a.getCaps().instancedArrays&&(g.visibleInstances[e._id]!==null&&g.visibleInstances[e._id]!==void 0||i.hasThinInstances);if(!(this.customAllowRendering&&!this.customAllowRendering(e)))if(this.isReady(e,m,t)){e._renderId=r.getRenderId();const b=o.shadowDepthWrapper,x=b?.getEffect(e,this,a.currentRenderPassId)??e._getDrawWrapper(),v=Qh.GetEffect(x);a.enableEffect(x),m||i._bind(e,v,o.fillMode),this.getTransformMatrix(),v.setFloat3("biasAndScaleSM",this.bias,this.normalBias,this.depthScale),this.getLight().getTypeID()===lt.LIGHTTYPEID_DIRECTIONALLIGHT?v.setVector3("lightDataSM",this._cachedDirection):v.setVector3("lightDataSM",this._cachedPosition.subtractToRef(this._scene.floatingOriginOffset,te.Vector3[0]));const E=this._getCamera();if(v.setFloat2("depthValuesSM",this.getLight().getDepthMinZ(E),this.getLight().getDepthMinZ(E)+this.getLight().getDepthMaxZ(E)),t&&this.enableSoftTransparentShadow&&v.setFloat2("softTransparentShadowSM",s.visibility*o.alpha,this._opacityTexture?.getAlphaFromRGB?1:0),b)e._setMainDrawWrapperOverride(x),b.standalone?b.baseMaterial.bindForSubMesh(s.getWorldMatrix(),i,e):o.bindForSubMesh(s.getWorldMatrix(),i,e),e._setMainDrawWrapperOverride(null);else{if(this._opacityTexture&&(v.setTexture("diffuseSampler",this._opacityTexture),v.setMatrix("diffuseMatrix",this._opacityTexture.getTextureMatrix()||this._defaultTextureMatrix)),i.useBones&&i.computeBonesUsingShaders&&i.skeleton){const I=i.skeleton;if(I.isUsingTextureForMatrices){const R=I.getTransformMatrixTexture(i);if(!R)return;v.setTexture("boneSampler",R),v.setFloat("boneTextureWidth",4*(I.bones.length+1))}else v.setMatrices("mBones",I.getTransformMatrices(i))}kf(i,v),i.morphTargetManager&&i.morphTargetManager.isUsingTextureForTargets&&i.morphTargetManager._bind(v);const D=e.getMesh().bakedVertexAnimationManager;D&&D.isEnabled&&D.bind(v,m),Bf(v,o,r)}!this._useUBO&&!b&&this._bindCustomEffectForRenderSubMeshForShadowMap(e,v,s),Nb(v,this._scene.getSceneUniformBuffer()),this._scene.getSceneUniformBuffer().bindUniformBuffer();const A=s.getWorldMatrix();m&&(s.getMeshUniformBuffer().bindToEffect(v,"Mesh"),s.transferToEffect(A)),this.forceBackFacesOnly&&a.setState(!0,0,!1,!0,o.cullBackFaces),this.onBeforeShadowMapRenderMeshObservable.notifyObservers(i),this.onBeforeShadowMapRenderObservable.notifyObservers(v),i._processRendering(s,e,v,o.fillMode,g,m,(D,I)=>{s!==i&&!D?(i.getMeshUniformBuffer().bindToEffect(v,"Mesh"),i.transferToEffect(I)):(s.getMeshUniformBuffer().bindToEffect(v,"Mesh"),s.transferToEffect(D?I:A))}),this.forceBackFacesOnly&&a.setState(!0,0,!1,!1,o.cullBackFaces),this.onAfterShadowMapRenderObservable.notifyObservers(v),this.onAfterShadowMapRenderMeshObservable.notifyObservers(i)}else this._shadowMap&&this._shadowMap.resetRefreshCounter()}_applyFilterValues(){this._shadowMap&&(this.filter===ze.FILTER_NONE||this.filter===ze.FILTER_PCSS?this._shadowMap.updateSamplingMode(Te.NEAREST_SAMPLINGMODE):this._shadowMap.updateSamplingMode(Te.BILINEAR_SAMPLINGMODE))}forceCompilation(e,t){const i={useInstances:!1,...t},s=this.getShadowMap();if(!s){e&&e(this);return}const r=s.renderList;if(!r){e&&e(this);return}const a=[];for(const u of r)a.push(...u.subMeshes);if(a.length===0){e&&e(this);return}let o=0;const c=()=>{if(!(!this._scene||!this._scene.getEngine())){for(;this.isReady(a[o],i.useInstances,a[o].getMaterial()?.needAlphaBlendingForMesh(a[o].getMesh())??!1);)if(o++,o>=a.length){e&&e(this);return}setTimeout(c,16)}};c()}async forceCompilationAsync(e){return await new Promise(t=>{this.forceCompilation(()=>{t()},e)})}_isReadyCustomDefines(e,t,i){}_prepareShadowDefines(e,t,i,s){i.push("#define SM_LIGHTTYPE_"+this._light.getClassName().toUpperCase()),i.push("#define SM_FLOAT "+(this._textureType!==0?"1":"0")),i.push("#define SM_ESM "+(this.useExponentialShadowMap||this.useBlurExponentialShadowMap?"1":"0")),i.push("#define SM_DEPTHTEXTURE "+(this.usePercentageCloserFiltering||this.useContactHardeningShadow?"1":"0"));const r=e.getMesh();return i.push("#define SM_NORMALBIAS "+(this.normalBias&&r.isVerticesDataPresent(O.NormalKind)?"1":"0")),i.push("#define SM_DIRECTIONINLIGHTDATA "+(this.getLight().getTypeID()===lt.LIGHTTYPEID_DIRECTIONALLIGHT?"1":"0")),i.push("#define SM_USEDISTANCE "+(this._light.needCube()?"1":"0")),i.push("#define SM_SOFTTRANSPARENTSHADOW "+(this.enableSoftTransparentShadow&&s?"1":"0")),this._isReadyCustomDefines(i,e,t),i}isReady(e,t,i){if(!this._shadersLoaded)return!1;const s=e.getMaterial(),r=s?.shadowDepthWrapper;if(this._opacityTexture=null,!s)return!1;const a=[];if(this._prepareShadowDefines(e,t,a,i),r){if(!r.isReadyForSubMesh(e,a,this,t,this._scene.getEngine().currentRenderPassId))return!1}else{const o=e._getDrawWrapper(void 0,!0);let c=o.effect,u=o.defines;const d=[O.PositionKind],f=e.getMesh();let g=!1,m=!1,b=!1;const x=!1;this.normalBias&&f.isVerticesDataPresent(O.NormalKind)&&(d.push(O.NormalKind),a.push("#define NORMAL"),g=!0,f.nonUniformScaling&&a.push("#define NONUNIFORMSCALING"));const v=s.needAlphaTestingForMesh(f);if((v||s.needAlphaBlendingForMesh(f))&&(this.useOpacityTextureForTransparentShadow?this._opacityTexture=s.opacityTexture:this._opacityTexture=s.getAlphaTestTexture(),this._opacityTexture)){if(!this._opacityTexture.isReady())return!1;const R=s.alphaCutOff??ze.DEFAULT_ALPHA_CUTOFF;a.push("#define ALPHATEXTURE"),v&&a.push(`#define ALPHATESTVALUE ${R}${R%1===0?".":""}`),f.isVerticesDataPresent(O.UVKind)&&(d.push(O.UVKind),a.push("#define UV1"),m=!0),f.isVerticesDataPresent(O.UV2Kind)&&this._opacityTexture.coordinatesIndex===1&&(d.push(O.UV2Kind),a.push("#define UV2"),b=!0)}const E=new eu;if(f.useBones&&f.computeBonesUsingShaders&&f.skeleton){d.push(O.MatricesIndicesKind),d.push(O.MatricesWeightsKind),f.numBoneInfluencers>4&&(d.push(O.MatricesIndicesExtraKind),d.push(O.MatricesWeightsExtraKind)
vendor: 6,595 bytes, lines 253-254
253);const R=f.skeleton;a.push("#define NUM_BONE_INFLUENCERS "+f.numBoneInfluencers),f.numBoneInfluencers>0&&E.addCPUSkinningFallback(0,f),R.isUsingTextureForMatrices?a.push("#define BONETEXTURE"):a.push("#define BonesPerMesh "+(R.bones.length+1))}else a.push("#define NUM_BONE_INFLUENCERS 0");const A=f.morphTargetManager?Lb(f.morphTargetManager,a,d,f,!0,g,!1,m,b,x):0;if(wb(s,this._scene,a),t&&(a.push("#define INSTANCES"),Uf(d),e.getRenderingMesh().hasThinInstances&&a.push("#define THIN_INSTANCES")),this.customShaderOptions&&this.customShaderOptions.defines)for(const R of this.customShaderOptions.defines)a.indexOf(R)===-1&&a.push(R);const D=f.bakedVertexAnimationManager;D&&D.isEnabled&&(a.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),t&&d.push("bakedVertexAnimationSettingsInstanced"));const I=a.join(` 254`);if(u!==I){u=I;let R="shadowMap";const C=["world","mBones","viewProjection","diffuseMatrix","lightDataSM","depthValuesSM","biasAndScaleSM","morphTargetInfluences","morphTargetCount","boneTextureWidth","softTransparentShadowSM","morphTargetTextureInfo","morphTargetTextureIndices","bakedVertexAnimationSettings","bakedVertexAnimationTextureSizeInverted","bakedVertexAnimationTime","bakedVertexAnimationTexture"],M=["diffuseSampler","boneSampler","morphTargets","bakedVertexAnimationTexture"],F=["Scene","Mesh"];if(Nf(C),this.customShaderOptions){if(R=this.customShaderOptions.shaderName,this.customShaderOptions.attributes)for(const k of this.customShaderOptions.attributes)d.indexOf(k)===-1&&d.push(k);if(this.customShaderOptions.uniforms)for(const k of this.customShaderOptions.uniforms)C.indexOf(k)===-1&&C.push(k);if(this.customShaderOptions.samplers)for(const k of this.customShaderOptions.samplers)M.indexOf(k)===-1&&M.push(k)}const U=this._scene.getEngine();c=U.createEffect(R,{attributes:d,uniformsNames:C,uniformBuffersNames:F,samplers:M,defines:I,fallbacks:E,onCompiled:null,onError:null,indexParameters:{maxSimultaneousMorphTargets:A},shaderLanguage:this._shaderLanguage},U),o.setEffect(c,u)}if(!c.isReady())return!1}return(this.useBlurExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(!this._blurPostProcesses||!this._blurPostProcesses.length)&&this._initializeBlurRTTAndPostProcesses(),!(this._kernelBlurXPostprocess&&!this._kernelBlurXPostprocess.isReady()||this._kernelBlurYPostprocess&&!this._kernelBlurYPostprocess.isReady()||this._boxBlurPostprocess&&!this._boxBlurPostprocess.isReady())}prepareDefines(e,t){const i=this._scene,s=this._light;!i.shadowsEnabled||!s.shadowEnabled||(e["SHADOW"+t]=!0,this.useContactHardeningShadow?(e["SHADOWPCSS"+t]=!0,this._filteringQuality===ze.QUALITY_LOW?e["SHADOWLOWQUALITY"+t]=!0:this._filteringQuality===ze.QUALITY_MEDIUM&&(e["SHADOWMEDIUMQUALITY"+t]=!0)):this.usePercentageCloserFiltering?(e["SHADOWPCF"+t]=!0,this._filteringQuality===ze.QUALITY_LOW?e["SHADOWLOWQUALITY"+t]=!0:this._filteringQuality===ze.QUALITY_MEDIUM&&(e["SHADOWMEDIUMQUALITY"+t]=!0)):this.usePoissonSampling?e["SHADOWPOISSON"+t]=!0:this.useExponentialShadowMap||this.useBlurExponentialShadowMap?e["SHADOWESM"+t]=!0:(this.useCloseExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(e["SHADOWCLOSEESM"+t]=!0),s.needCube()&&(e["SHADOWCUBE"+t]=!0))}bindShadowLight(e,t){const i=this._light,s=this._scene;if(!s.shadowsEnabled||!i.shadowEnabled)return;const r=this._getCamera(),a=this.getShadowMap();if(!a)return;if(!i.needCube()){const c=s.floatingOriginOffset,u=this.getTransformMatrix(),d=s.floatingOriginMode?IC(c,this._viewMatrix,this._projectionMatrix,te.Matrix[0]):u;t.setMatrix("lightMatrix"+e,d)}const o=this.getShadowMapForRendering();this._filter===ze.FILTER_PCF?(t.setDepthStencilTexture("shadowTexture"+e,o),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),a.getSize().width,1/a.getSize().width,this.frustumEdgeFalloff,e)):this._filter===ze.FILTER_PCSS?(t.setDepthStencilTexture("shadowTexture"+e,o),t.setTexture("depthTexture"+e,o),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),1/a.getSize().width,this._contactHardeningLightSizeUVRatio*a.getSize().width,this.frustumEdgeFalloff,e)):(t.setTexture("shadowTexture"+e,o),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),this.blurScale/a.getSize().width,this.depthScale,this.frustumEdgeFalloff,e)),i._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(r),this.getLight().getDepthMinZ(r)+this.getLight().getDepthMaxZ(r),e)}get viewMatrix(){return this._viewMatrix}get projectionMatrix(){return this._projectionMatrix}getTransformMatrix(){const e=this._scene;if(this._currentRenderId===e.getRenderId()&&this._currentFaceIndexCache===this._currentFaceIndex)return this._transformMatrix;this._currentRenderId=e.getRenderId(),this._currentFaceIndexCache=this._currentFaceIndex;let t=this._light.position;if(this._light.computeTransformedInformation()&&(t=this._light.transformedPosition),T.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex),this._lightDirection),Math.abs(T.Dot(this._lightDirection,T.Up()))===1&&(this._lightDirection.z=1e-13),this._light.needProjectionMatrixCompute()||!this._cachedPosition||!this._cachedDirection||!t.equals(this._cachedPosition)||!this._lightDirection.equals(this._cachedDirection)){this._cachedPosition.copyFrom(t),this._cachedDirection.copyFrom(this._lightDirection),W.LookAtLHToRef(t,t.add(this._lightDirection),T.Up(),this._viewMatrix);const i=this.getShadowMap();if(i){const s=i.renderList;s&&this._light.setShadowProjectionMatrix(this._projectionMatrix,this._viewMatrix,s)}this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)}return this._transformMatrix}recreateShadowMap(){const e=this._shadowMap;if(!e)return;const t=e.renderList;if(this._disposeRTTandPostProcesses(),this._initializeGenerator(),this.filter=this._filter,this._applyFilterValues(),t){this._shadowMap.renderList||(this._shadowMap.renderList=[]);for(const i of t)this._shadowMap.renderList.push(i)}else this._shadowMap.renderList=null}_disposeBlurPostProcesses(){this._shadowMap2&&(this._shadowMap2.dispose(),this._shadowMap2=null),this._boxBlurPostprocess&&(this._boxBlurPostprocess.dispose(),this._boxBlurPostprocess=null),this._kernelBlurXPostprocess&&(this._kernelBlurXPostprocess.dispose(),this._kernelBlurXPostprocess=null),this._kernelBlurYPostprocess&&(this._kernelBlurYPostprocess.dispose(),this._kernelBlurYPostprocess=null),this._blurPostProcesses=[]}_disposeRTTandPostProcesses(){this._shadowMap&&(this._shadowMap.dispose(),this._shadowMap=null),this._disposeBlurPostProcesses()}_disposeSceneUBOs(){if(this._sceneUBOs){for(const e of this._sceneUBOs)e.dis
254pose();this._sceneUBOs=[]}}dispose(){if(this._disposeRTTandPostProcesses(),this._disposeSceneUBOs(),this._light){if(this._light._shadowGenerators){const e=this._light._shadowGenerators.entries();for(let t=e.next();t.done!==!0;t=e.next()){const[i,s]=t.value;s===this&&this._light._shadowGenerators.delete(i)}this._light._shadowGenerators.size===0&&(this._light._shadowGenerators=null)}this._light._markMeshesAsLightDirty()}this.onBeforeShadowMapRenderMeshObservable.clear(),this.onBeforeShadowMapRenderObservable.clear(),this.onAfterShadowMapRenderMeshObservable.clear(),this.onAfterShadowMapRenderObservable.clear()}serialize(){const e={},t=this.getShadowMap();if(!t)return e;if(e.className=this.getClassName(),e.lightId=this._light.id,e.cameraId=this._camera?.id,e.id=this.id,e.mapSize=t.getRenderSize(),e.forceBackFacesOnly=this.forceBackFacesOnly,e.darkness=this.getDarkness(),e.transparencyShadow=this._transparencyShadow,e.frustumEdgeFalloff=this.frustumEdgeFalloff,e.bias=this.bias,e.normalBias=this.normalBias,e.usePercentageCloserFiltering=this.usePercentageCloserFiltering,e.useContactHardeningShadow=this.useContactHardeningShadow,e.contactHardeningLightSizeUVRatio=this.contactHardeningLightSizeUVRatio,e.filteringQuality=this.filteringQuality,e.useExponentialShadowMap=this.useExponentialShadowMap,e.useBlurExponentialShadowMap=this.useBlurExponentialShadowMap,e.useCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.useBlurCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.usePoissonSampling=this.usePoissonSampling,e.depthScale=this.depthScale,e.blurBoxOffset=this.blurBoxOffset,e.blurKernel=this.blurKernel,e.blurScale=this.blurScale,e.useKernelBlur=this.useKernelBlur,e.renderList=[],t.renderList)for(let i=0;i<t.renderList.length;i++){const s=t.renderList[i];e.renderList.push(s.id)}return e}static Parse(e,t,i){const s=t.getLightById(e.lightId),r=e.cameraId!==void 0?t.getCameraById(e.cameraId):null,a=i?i(e.mapSize,s,r):new ze(e.mapSize,s,void 0,r),o=a.getShadowMap();if(e.renderList.length&&o){const c=new Set(e.renderList);let u=o.renderList;u||(u=o.renderList=[]);const d=t.meshes;for(const f of d)c.has(f.id)&&u.push(f)}return e.id!==void 0&&(a.id=e.id),a.forceBackFacesOnly=!!e.forceBackFacesOnly,e.darkness!==void 0&&a.setDarkness(e.darkness),e.transparencyShadow&&a.setTransparencyShadow(!0),e.frustumEdgeFalloff!==void 0&&(a.frustumEdgeFalloff=e.frustumEdgeFalloff),e.bias!==void 0&&(a.bias=e.bias),e.normalBias!==void 0&&(a.normalBias=e.normalBias),e.usePercentageCloserFiltering?a.usePercentageCloserFiltering=!0:e.useContactHardeningShadow?a.useContactHardeningShadow=!0:e.usePoissonSampling?a.usePoissonSampling=!0:e.useExponentialShadowMap?a.useExponentialShadowMap=!0:e.useBlurExponentialShadowMap?a.useBlurExponentialShadowMap=!0:e.useCloseExponentialShadowMap?a.useCloseExponentialShadowMap=!0:e.useBlurCloseExponentialShadowMap?a.useBlurCloseExponentialShadowMap=!0:e.useVarianceShadowMap?a.useExponentialShadowMap=!0:e.useBlurVarianceShadowMap&&(a.useBlurExponentialShadowMap=!0),e.contactHardeningLightSizeUVRatio!==void 0&&(a.contactHardeningLightSizeUVRatio=e.contactHardeningLightSizeUVRatio),e.filteringQuality!==void 0&&(a.filteringQuality=e.filteringQuality),e.depthScale&&(a.depthScale=e.depthScale),e.blurScale&&(a.blurScale=e.blurScale),e.blurBoxOffset&&(a.blurBoxOffset=e.blurBoxOffset),e.useKernelBlur&&(a.useKernelBlur=e.useKernelBlur),e.blurKernel&&(a.blurKernel=e.blurKernel),a}}ze.CLASSNAME="ShadowGenerator";ze.ForceGLSL=!1;ze.FILTER_NONE=0;ze.FILTER_EXPONENTIALSHADOWMAP=1;ze.FILTER_POISSONSAMPLING=2;ze.FILTER_BLUREXPONENTIALSHADOWMAP=3;ze.FILTER_CLOSEEXPONENTIALSHADOWMAP=4;ze.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP=5;ze.FILTER_PCF=6;ze.FILTER_PCSS=7;ze.QUALITY_HIGH=0;ze.QUALITY_MEDIUM=1;ze.QUALITY_LOW=2;ze.DEFAULT_ALPHA_CUTOFF=.5;ze._SceneComponentInitialization=n=>{throw We("ShadowGeneratorSceneComponent")};const BT="clipPlaneFragmentDeclaration",P3=`#ifdef CLIPPLANE 255varying float fClipDistance; 256#endif 257#ifdef CLIPPLANE2 258varying float fClipDistance2; 259#endif 260#ifdef CLIPPLANE3 261varying float fClipDistance3; 262#endif 263#ifdef CLIPPLANE4 264varying float fClipDistance4; 265#endif 266#ifdef CLIPPLANE5 267varying float fClipDistance5; 268#endif 269#ifdef CLIPPLANE6 270varying float fClipDistance6; 271#endif 272`;de.IncludesShadersStore[BT]||(de.IncludesShadersStore[BT]=P3);const UT="packingFunctions",D3=`vec4 pack(float depth) 273{const vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;} 274float unpack(vec4 color) 275{const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(color,bit_shift);}`;de.IncludesShadersStore[UT]||(de.IncludesShadersStore[UT]=D3);const kT="clipPlaneFragment",O3=`#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6) 276if (false) {} 277#endif 278#ifdef CLIPPLANE 279else if (fClipDistance>0.0) 280{discard;} 281#endif 282#ifdef CLIPPLANE2 283else if (fClipDistance2>0.0) 284{discard;} 285#endif 286#ifdef CLIPPLANE3 287else if (fClipDistance3>0.0) 288{discard;} 289#endif 290#ifdef CLIPPLANE4 291else if (fClipDistance4>0.0) 292{discard;} 293#endif 294#ifdef CLIPPLANE5 295else if (fClipDistance5>0.0) 296{discard;} 297#endif 298#ifdef CLIPPLANE6 299else if (fClipDistance6>0.0) 300{discard;} 301#endif 302`;de.IncludesShadersStore[kT]||(de.IncludesShadersStore[kT]=O3);const km="depthPixelShader",tI=`#ifdef ALPHATEST 303varying vec2 vUV;uniform sampler2D diffuseSampler; 304#endif 305#include<clipPlaneFragmentDeclaration> 306varying float vDepthMetric; 307#ifdef PACKED 308#include<packingFunctions> 309#endif 310#ifdef STORE_CAMERASPACE_Z 311varying vec4 vViewPos; 312#endif 313#define CUSTOM_FRAGMENT_DEFINITIONS 314void main(void) 315{ 316#include<clipPlaneFragment> 317#ifdef ALPHATEST 318if (texture2D(diffuseSampler,vUV).a<0.4) 319discard; 320#endif 321#ifdef STORE_CAMERASPACE_Z 322#ifdef PACKED 323gl_FragColor=pack(vViewPos.z); 324#else 325gl_FragColor=vec4(vViewPos.z,0.0,0.0,1.0); 326#endif 327#else 328#ifdef NONLINEARDEPTH 329#ifdef PACKED 330gl_FragColor=pack(gl_FragCoord.z); 331#else 332gl_FragColor=vec4(gl_FragCoord.z,0.0,0.0,0.0); 333#endif 334#else 335#ifdef PACKED 336gl_FragColor=pack(vDepthMetric); 337#else 338gl_FragColor=vec4(vDepthMetric,0.0,0.0,1.0); 339#endif 340#endif 341#endif 342}`;de.ShadersStore[km]||(de.ShadersStore[km]=tI);const w3={name:km,shader:tI},F3=Object.freeze(Object.defineProperty({__proto__:null,depthPixelShader:w3},Symbol.toStringTag,{value:"Module"})),VT="bonesDeclaration",L3=`#if NUM_BONE_INFLUENCERS>0 343attribute vec4 matricesIndices;attribute vec4 matricesWeights; 344#if NUM_BONE_INFLUENCERS>4 345attribute vec4 matricesIndicesExtra;attribute vec4 matricesWeightsExtra; 346#endif 347#ifndef BAKED_VERTEX_ANIMATION_TEXTURE 348#ifdef BONETEXTURE 349uniform highp sampler2D boneSampler;uniform float boneTextureWidth; 350#else 351uniform mat4 mBones[BonesPerMesh]; 352#endif 353#ifdef BONES_VELOCITY_ENABLED 354uniform mat4 mPreviousBones[BonesPerMesh]; 355#endif 356#ifdef BONETEXTURE 357#define inline 358mat4 readMatrixFromRawSampler(sampler2D smp,float index) 359{float offset=index *4.0;float dx=1.0/boneTextureWidth;vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),0.));vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),0.));vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),0.));vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),0.));return mat4(m0,m1,m2,m3);} 360#endif 361#endif 362#endif 363`;de.IncludesShadersStore[VT]||(de.IncludesShadersStore[VT]=L3);const zT="bakedVertexAnimationDeclaration",N3=`#ifdef BAKED_VERTEX_ANIMATION_TEXTURE 364uniform float bakedVertexAnimationTime;uniform vec2 bakedVertexAnimationTextureSizeInverted;uniform vec4 bakedVertexAnimationSettings;uniform sampler2D bakedVertexAnimationTexture; 365#ifdef INSTANCES 366attribute vec4 bakedVertexAnimationSettingsInstanced; 367#endif 368#define inline 369mat4 readMatrixFromRawSamplerVAT(sampler2D smp,float index,float frame) 370{float offset=index*4.0;float frameUV=(frame+0.5)*bakedVertexAnimationTextureSizeInverted.y;float dx=bakedVertexAnimationTextureSizeInverted.x;vec4 m0=texture2D(smp,vec2(dx*(offset+0.5),frameUV));vec4 m1=texture2D(smp,vec2(dx*(offset+1.5),frameUV));vec4 m2=texture2D(smp,vec2(dx*(offset+2.5),frameUV));vec4 m3=texture2D(smp,vec2(dx*(offset+3.5),frameUV));return mat4(m0,m1,m2,m3);} 371#endif 372`;de.IncludesShadersStore[zT]||(de.IncludesShadersStore[zT]=N3);const GT="morphTargetsVertexGlobalDeclaration",B3=`#ifdef MORPHTARGETS 373uniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS]; 374#ifdef MORPHTARGETS_TEXTURE 375uniform float morphTargetTextureIndices[NUM_MORPH_INFLUENCERS];uniform vec3 morphTargetTextureInfo;uniform highp sampler2DArray morphTargets;vec3 readVector3FromRawSampler(int targetIndex,float vertexIndex) 376{ 377float y=floor(vertexIndex/morphTargetTextureInfo.y);float x=vertexIndex-y*morphTargetTextureInfo.y;vec3 textureUV=vec3((x+0.5)/morphTargetTextureInfo.y,(y+0.5)/morphTargetTextureInfo.z,morphTargetTextureIndices[targetIndex]);return texture(morphTargets,textureUV).xyz;} 378vec4 readVector4FromRawSampler(int targetIndex,float vertexIndex) 379{ 380float y=floor(vertexIndex/morphTargetTextureInfo.y);float x=vertexIndex-y*morphTargetTextureInfo.y;vec3 textureUV=vec3((x+0.5)/morphTargetTextureInfo.y,(y+0.5)/morphTargetTextureInfo.z,morphTargetTextureIndices[targetIndex]);return texture(morphTargets,textureUV);} 381#endif 382#endif 383`;de.IncludesShadersStore[GT]||(de.IncludesShadersStore[GT]=B3);const HT="morphTargetsVertexDeclaration",U3=`#ifdef MORPHTARGETS 384#ifndef MORPHTARGETS_TEXTURE 385#ifdef MORPHTARGETS_POSITION 386attribute vec3 position{X}; 387#endif 388#ifdef MORPHTARGETS_NORMAL 389attribute vec3 normal{X}; 390#endif 391#ifdef MORPHTARGETS_TANGENT 392attribute vec3 tangent{X}; 393#endif
394#ifdef MORPHTARGETS_UV 395attribute vec2 uv_{X}; 396#endif 397#ifdef MORPHTARGETS_UV2 398attribute vec2 uv2_{X}; 399#endif 400#ifdef MORPHTARGETS_COLOR 401attribute vec4 color{X}; 402#endif 403#elif {X}==0 404uniform float morphTargetCount; 405#endif 406#endif 407`;de.IncludesShadersStore[HT]||(de.IncludesShadersStore[HT]=U3);const WT="clipPlaneVertexDeclaration",k3=`#ifdef CLIPPLANE 408uniform vec4 vClipPlane;varying float fClipDistance; 409#endif 410#ifdef CLIPPLANE2 411uniform vec4 vClipPlane2;varying float fClipDistance2; 412#endif 413#ifdef CLIPPLANE3 414uniform vec4 vClipPlane3;varying float fClipDistance3; 415#endif 416#ifdef CLIPPLANE4 417uniform vec4 vClipPlane4;varying float fClipDistance4; 418#endif 419#ifdef CLIPPLANE5 420uniform vec4 vClipPlane5;varying float fClipDistance5; 421#endif 422#ifdef CLIPPLANE6 423uniform vec4 vClipPlane6;varying float fClipDistance6; 424#endif 425`;de.IncludesShadersStore[WT]||(de.IncludesShadersStore[WT]=k3);const XT="instancesDeclaration",V3=`#ifdef INSTANCES 426attribute vec4 world0;attribute vec4 world1;attribute vec4 world2;attribute vec4 world3; 427#ifdef INSTANCESCOLOR 428attribute vec4 instanceColor; 429#endif 430#if defined(THIN_INSTANCES) && !defined(WORLD_UBO) 431uniform mat4 world; 432#endif 433#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR) 434attribute vec4 previousWorld0;attribute vec4 previousWorld1;attribute vec4 previousWorld2;attribute vec4 previousWorld3; 435#ifdef THIN_INSTANCES 436uniform mat4 previousWorld; 437#endif 438#endif 439#else 440#if !defined(WORLD_UBO) 441uniform mat4 world; 442#endif 443#if defined(VELOCITY) || defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR) 444uniform mat4 previousWorld; 445#endif 446#endif 447`;de.IncludesShadersStore[XT]||(de.IncludesShadersStore[XT]=V3);const jT="pointCloudVertexDeclaration",z3=`#ifdef POINTSIZE 448uniform float pointSize; 449#endif 450`;de.IncludesShadersStore[jT]||(de.IncludesShadersStore[jT]=z3);const YT="morphTargetsVertexGlobal",G3=`#ifdef MORPHTARGETS 451#ifdef MORPHTARGETS_TEXTURE 452float vertexID; 453#endif 454#endif 455`;de.IncludesShadersStore[YT]||(de.IncludesShadersStore[YT]=G3);const KT="morphTargetsVertex",H3=`#ifdef MORPHTARGETS 456#ifdef MORPHTARGETS_TEXTURE 457#if {X}==0 458for (int i=0; i<NUM_MORPH_INFLUENCERS; i++) {if (float(i)>=morphTargetCount) break;vertexID=float(gl_VertexID)*morphTargetTextureInfo.x; 459#ifdef MORPHTARGETS_POSITION 460positionUpdated+=(readVector3FromRawSampler(i,vertexID)-position)*morphTargetInfluences[i]; 461#endif 462#ifdef MORPHTARGETTEXTURE_HASPOSITIONS 463vertexID+=1.0; 464#endif 465#ifdef MORPHTARGETS_NORMAL 466normalUpdated+=(readVector3FromRawSampler(i,vertexID) -normal)*morphTargetInfluences[i]; 467#endif 468#ifdef MORPHTARGETTEXTURE_HASNORMALS 469vertexID+=1.0; 470#endif 471#ifdef MORPHTARGETS_UV 472uvUpdated+=(readVector3FromRawSampler(i,vertexID).xy-uv)*morphTargetInfluences[i]; 473#endif 474#ifdef MORPHTARGETTEXTURE_HASUVS 475vertexID+=1.0; 476#endif 477#ifdef MORPHTARGETS_TANGENT 478tangentUpdated.xyz+=(readVector3FromRawSampler(i,vertexID) -tangent.xyz)*morphTargetInfluences[i]; 479#endif 480#ifdef MORPHTARGETTEXTURE_HASTANGENTS 481vertexID+=1.0; 482#endif 483#ifdef MORPHTARGETS_UV2 484uv2Updated+=(readVector3FromRawSampler(i,vertexID).xy-uv2)*morphTargetInfluences[i]; 485#endif 486#ifdef MORPHTARGETTEXTURE_HASUV2S 487vertexID+=1.0; 488#endif 489#ifdef MORPHTARGETS_COLOR 490colorUpdated+=(readVector4FromRawSampler(i,vertexID)-color)*morphTargetInfluences[i]; 491#endif 492} 493#endif 494#else 495#ifdef MORPHTARGETS_POSITION 496positionUpdated+=(position{X}-position)*morphTargetInfluences[{X}]; 497#endif 498#ifdef MORPHTARGETS_NORMAL 499normalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}]; 500#endif 501#ifdef MORPHTARGETS_TANGENT 502tangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}]; 503#endif 504#ifdef MORPHTARGETS_UV 505uvUpdated+=(uv_{X}-uv)*morphTargetInfluences[{X}]; 506#endif 507#ifdef MORPHTARGETS_UV2 508uv2Updated+=(uv2_{X}-uv2)*morphTargetInfluences[{X}]; 509#endif 510#ifdef MORPHTARGETS_COLOR 511colorUpdated+=(color{X}-color)*morphTargetInfluences[{X}]; 512#endif 513#endif 514#endif 515`;de.IncludesShadersStore[KT]||(de.IncludesShadersStore[KT]=H3);const qT="instancesVertex",W3=`#ifdef INSTANCES 516mat4 finalWorld=mat4(world0,world1,world2,world3); 517#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR) 518mat4 finalPreviousWorld=mat4(previousWorld0,previousWorld1, 519previousWorld2,previousWorld3); 520#endif 521#ifdef THIN_INSTANCES 522finalWorld=world*finalWorld; 523#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR) 524finalPreviousWorld=previousWorld*finalPreviousWorld; 525#endif 526#endif 527#else 528mat4 finalWorld=world; 529#if defined(PREPASS_VELOCITY) || defined(VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) || defined(VELOCITY_LINEAR) 530mat4 finalPreviousWorld=previousWorld; 531#endif 532#endif 533`;de.IncludesShadersStore[qT]||(de.IncludesShadersStore[qT]=W3);const ZT="bonesVertex",X3=`#ifndef BAKED_VERTEX_ANIMATION_TEXTURE 534#if NUM_BONE_INFLUENCERS>0 535mat4 influence; 536#ifdef BONETEXTURE
537influence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0]; 538#if NUM_BONE_INFLUENCERS>1 539influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1]; 540#endif 541#if NUM_BONE_INFLUENCERS>2 542influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2]; 543#endif 544#if NUM_BONE_INFLUENCERS>3 545influence+=readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3]; 546#endif 547#if NUM_BONE_INFLUENCERS>4 548influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0]; 549#endif 550#if NUM_BONE_INFLUENCERS>5 551influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1]; 552#endif 553#if NUM_BONE_INFLUENCERS>6 554influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2]; 555#endif 556#if NUM_BONE_INFLUENCERS>7 557influence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3]; 558#endif 559#else 560influence=mBones[int(matricesIndices[0])]*matricesWeights[0]; 561#if NUM_BONE_INFLUENCERS>1 562influence+=mBones[int(matricesIndices[1])]*matricesWeights[1]; 563#endif 564#if NUM_BONE_INFLUENCERS>2 565influence+=mBones[int(matricesIndices[2])]*matricesWeights[2]; 566#endif 567#if NUM_BONE_INFLUENCERS>3 568influence+=mBones[int(matricesIndices[3])]*matricesWeights[3]; 569#endif 570#if NUM_BONE_INFLUENCERS>4 571influence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0]; 572#endif 573#if NUM_BONE_INFLUENCERS>5 574influence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1]; 575#endif 576#if NUM_BONE_INFLUENCERS>6 577influence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2]; 578#endif 579#if NUM_BONE_INFLUENCERS>7 580influence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3]; 581#endif 582#endif 583finalWorld=finalWorld*influence; 584#endif 585#endif 586`;de.IncludesShadersStore[ZT]||(de.IncludesShadersStore[ZT]=X3);const $T="bakedVertexAnimation",j3=`#ifdef BAKED_VERTEX_ANIMATION_TEXTURE 587{ 588#ifdef INSTANCES 589#define BVASNAME bakedVertexAnimationSettingsInstanced 590#else 591#define BVASNAME bakedVertexAnimationSettings 592#endif 593float VATStartFrame=BVASNAME.x;float VATEndFrame=BVASNAME.y;float VATOffsetFrame=BVASNAME.z;float VATSpeed=BVASNAME.w;float totalFrames=VATEndFrame-VATStartFrame+1.0;float time=bakedVertexAnimationTime*VATSpeed/totalFrames;float frameCorrection=time<1.0 ? 0.0 : 1.0;float numOfFrames=totalFrames-frameCorrection;float VATFrameNum=fract(time)*numOfFrames;VATFrameNum=mod(VATFrameNum+VATOffsetFrame,numOfFrames);VATFrameNum=floor(VATFrameNum);VATFrameNum+=VATStartFrame+frameCorrection;mat4 VATInfluence;VATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[0],VATFrameNum)*matricesWeights[0]; 594#if NUM_BONE_INFLUENCERS>1 595VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[1],VATFrameNum)*matricesWeights[1]; 596#endif 597#if NUM_BONE_INFLUENCERS>2 598VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[2],VATFrameNum)*matricesWeights[2]; 599#endif 600#if NUM_BONE_INFLUENCERS>3 601VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[3],VATFrameNum)*matricesWeights[3]; 602#endif 603#if NUM_BONE_INFLUENCERS>4 604VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[0],VATFrameNum)*matricesWeightsExtra[0]; 605#endif 606#if NUM_BONE_INFLUENCERS>5 607VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[1],VATFrameNum)*matricesWeightsExtra[1]; 608#endif 609#if NUM_BONE_INFLUENCERS>6 610VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[2],VATFrameNum)*matricesWeightsExtra[2]; 611#endif 612#if NUM_BONE_INFLUENCERS>7 613VATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[3],VATFrameNum)*matricesWeightsExtra[3]; 614#endif 615finalWorld=finalWorld*VATInfluence;} 616#endif 617`;de.IncludesShadersStore[$T]||(de.IncludesShadersStore[$T]=j3);const QT="clipPlaneVertex",Y3=`#ifdef CLIPPLANE 618fClipDistance=dot(worldPos,vClipPlane); 619#endif 620#ifdef CLIPPLANE2 621fClipDistance2=dot(worldPos,vClipPlane2); 622#endif 623#ifdef CLIPPLANE3 624fClipDistance3=dot(worldPos,vClipPlane3); 625#endif 626#ifdef CLIPPLANE4 627fClipDistance4=dot(worldPos,vClipPlane4); 628#endif 629#ifdef CLIPPLANE5 630fClipDistance5=dot(worldPos,vClipPlane5); 631#endif 632#ifdef CLIPPLANE6 633fClipDistance6=dot(worldPos,vClipPlane6); 634#endif 635`;
635de.IncludesShadersStore[QT]||(de.IncludesShadersStore[QT]=Y3);const JT="pointCloudVertex",K3=`#if defined(POINTSIZE) && !defined(WEBGPU) 636gl_PointSize=pointSize; 637#endif 638`;de.IncludesShadersStore[JT]||(de.IncludesShadersStore[JT]=K3);const Vm="depthVertexShader",iI=`attribute vec3 position; 639#include<bonesDeclaration> 640#include<bakedVertexAnimationDeclaration> 641#include<morphTargetsVertexGlobalDeclaration> 642#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets] 643#include<clipPlaneVertexDeclaration> 644#include<instancesDeclaration> 645uniform mat4 viewProjection;uniform vec2 depthValues; 646#if defined(ALPHATEST) || defined(NEED_UV) 647varying vec2 vUV;uniform mat4 diffuseMatrix; 648#ifdef UV1 649attribute vec2 uv; 650#endif 651#ifdef UV2 652attribute vec2 uv2; 653#endif 654#endif 655#ifdef STORE_CAMERASPACE_Z 656uniform mat4 view;varying vec4 vViewPos; 657#endif 658#include<pointCloudVertexDeclaration> 659varying float vDepthMetric; 660#define CUSTOM_VERTEX_DEFINITIONS 661void main(void) 662{vec3 positionUpdated=position; 663#ifdef UV1 664vec2 uvUpdated=uv; 665#endif 666#ifdef UV2 667vec2 uv2Updated=uv2; 668#endif 669#include<morphTargetsVertexGlobal> 670#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets] 671#include<instancesVertex> 672#include<bonesVertex> 673#include<bakedVertexAnimation> 674vec4 worldPos=finalWorld*vec4(positionUpdated,1.0); 675#include<clipPlaneVertex> 676gl_Position=viewProjection*worldPos; 677#ifdef STORE_CAMERASPACE_Z 678vViewPos=view*worldPos; 679#else 680#ifdef USE_REVERSE_DEPTHBUFFER 681vDepthMetric=((-gl_Position.z+depthValues.x)/(depthValues.y)); 682#else 683vDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y)); 684#endif 685#endif 686#if defined(ALPHATEST) || defined(BASIC_RENDER) 687#ifdef UV1 688vUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0)); 689#endif 690#ifdef UV2 691vUV=vec2(diffuseMatrix*vec4(uv2Updated,1.0,0.0)); 692#endif 693#endif 694#include<pointCloudVertex> 695} 696`;de.ShadersStore[Vm]||(de.ShadersStore[Vm]=iI);const q3={name:Vm,shader:iI},Z3=Object.freeze(Object.defineProperty({__proto__:null,depthVertexShader:q3},Symbol.toStringTag,{value:"Module"}));class cc{get shaderLanguage(){return this._shaderLanguage}setMaterialForRendering(e,t){this._depthMap.setMaterialForRendering(e,t)}constructor(e,t=1,i=null,s=!1,r=Te.TRILINEAR_SAMPLINGMODE,a=!1,o,c){this._shaderLanguage=0,this.enabled=!0,this.forceDepthWriteTransparentMeshes=!1,this.useOnlyInActiveCamera=!1,this.reverseCulling=!1,this._shadersLoaded=!1,this._scene=e,this._storeNonLinearDepth=s,this._storeCameraSpaceZ=a,this.isPacked=t===0,this.isPacked?this.clearColor=new Ze(1,1,1,1):this.clearColor=new Ze(a?0:1,0,0,1),this._initShaderSourceAsync(),cc._SceneComponentInitialization(this._scene);const u=e.getEngine();this._camera=i,r!==Te.NEAREST_SAMPLINGMODE&&(t===1&&!u._caps.textureFloatLinearFiltering&&(r=Te.NEAREST_SAMPLINGMODE),t===2&&!u._caps.textureHalfFloatLinearFiltering&&(r=Te.NEAREST_SAMPLINGMODE));const d=this.isPacked||!u._features.supportExtendedTextureFormats?5:6;this._depthMap=c??new ar(o??"DepthRenderer",{width:u.getRenderWidth(),height:u.getRenderHeight()},this._scene,!1,!0,t,!1,r,void 0,void 0,void 0,d),this._depthMap.wrapU=Te.CLAMP_ADDRESSMODE,this._depthMap.wrapV=Te.CLAMP_ADDRESSMODE,this._depthMap.refreshRate=1,this._depthMap.renderParticles=!1,this._depthMap.renderList=null,this._depthMap.noPrePassRenderer=!0,this._depthMap.activeCamera=this._camera,this._depthMap.ignoreCameraViewport=!0,this._depthMap.useCameraPostProcesses=!1,this._depthMap.onClearObservable.add(g=>{g.clear(this.clearColor,!0,!0,!0)}),this._depthMap.onBeforeBindObservable.add(()=>{u._debugPushGroup?.("depth renderer",1)}),this._depthMap.onAfterUnbindObservable.add(()=>{u._debugPopGroup?.(1)}),this._depthMap.customIsReadyFunction=(g,m,b)=>{if((b||m===0)&&g.subMeshes)for(let x=0;x<g.subMeshes.length;++x){const v=g.subMeshes[x],E=v.getRenderingMesh(),A=E._getInstancesRenderList(v._id,!!v.getReplacementMesh()),D=u.getCaps().instancedArrays&&(A.visibleInstances[v._id]!==null&&A.visibleInstances[v._id]!==void 0||E.hasThinInstances);if(!this.isReady(v,D))return!1}return!0};const f=g=>{const m=g.getRenderingMesh(),b=g.getEffectiveMesh(),x=this._scene,v=x.getEngine(),E=g.getMaterial();if(b._internalAbstractMeshDataInfo._isActiveIntermediate=!1,!E||b.infiniteDistance||E.disableDepthWrite||g.verticesCount===0||g._renderId===x.getRenderId())return;const A=b._getWorldMatrixDeterminant()<0;let D=E._getEffectiveOrientation(m);A&&(D=D===0?1:0);const I=D===0;v.setState(E.backFaceCulling,0,!1,I,this.reverseCulling?!E.cullBackFaces:E.cullBackFaces);const R=m._getInstancesRenderList(g._id,!!g.getReplacementMesh());if(R.mustReturn)return;const C=v.getCaps().instancedArrays&&(R.visibleInstances[g._id]!==null&&R.visibleInstances[g._id]!==void 0||m.hasThinInstances),M=this._camera||x.activeCamera;if(this.isReady(g,C)&&M){g._renderId=x.getRenderId();const F=b._internalAbstractMeshDataInfo._materialForRenderPass?.[v.currentRenderPassId];let U=g._getDrawWrapper();!U&&F&&(U=F._getDrawWrapper());const k=M.mode===Ge.ORTHOGRAPHIC_CAMERA;if(!U)return;const q=U.effect;v.enableEffect(U),C||m._bind(g,q,E.fillMode),F?F.bindForSubMesh(b.getWorldMatrix(),b,g):(q.setMatr
696ix("viewProjection",x.getTransformMatrix()),q.setMatrix("world",b.getWorldMatrix()),this._storeCameraSpaceZ&&q.setMatrix("view",x.getViewMatrix()));let Q,ie;if(k?(Q=!v.useReverseDepthBuffer&&v.isNDCHalfZRange?0:1,ie=v.useReverseDepthBuffer&&v.isNDCHalfZRange?0:1):(Q=v.useReverseDepthBuffer&&v.isNDCHalfZRange?M.minZ:v.isNDCHalfZRange?0:M.minZ,ie=v.useReverseDepthBuffer&&v.isNDCHalfZRange?0:M.maxZ),q.setFloat2("depthValues",Q,Q+ie),!F){if(E.needAlphaTestingForMesh(b)){const ce=E.getAlphaTestTexture();ce&&(q.setTexture("diffuseSampler",ce),q.setMatrix("diffuseMatrix",ce.getTextureMatrix()))}Bb(m,q),Bf(q,E,x),kf(m,q),m.morphTargetManager&&m.morphTargetManager.isUsingTextureForTargets&&m.morphTargetManager._bind(q);const $=g.getMesh().bakedVertexAnimationManager;$&&$.isEnabled&&$.bind(q,C),E.pointsCloud&&q.setFloat("pointSize",E.pointSize)}m._processRendering(b,g,q,E.fillMode,R,C,($,ce)=>q.setMatrix("world",ce))}};this._depthMap.customRenderFunction=(g,m,b,x)=>{let v;if(x.length)for(v=0;v<x.length;v++)f(x.data[v]);for(v=0;v<g.length;v++)f(g.data[v]);for(v=0;v<m.length;v++)f(m.data[v]);if(this.forceDepthWriteTransparentMeshes)for(v=0;v<b.length;v++)f(b.data[v]);else for(v=0;v<b.length;v++)b.data[v].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate=!1}}async _initShaderSourceAsync(e=!1){this._scene.getEngine().isWebGPU&&!e&&!cc.ForceGLSL?(this._shaderLanguage=1,await Promise.all([_t(()=>import("./depth.vertex-BxJAezBI.js"),__vite__mapDeps([19,15,16,20])),_t(()=>import("./depth.fragment-DM1noNGy.js"),__vite__mapDeps([21,13,7]))])):await Promise.all([_t(()=>Promise.resolve().then(()=>Z3),void 0),_t(()=>Promise.resolve().then(()=>F3),void 0)]),this._shadersLoaded=!0}isReady(e,t){if(!this._shadersLoaded)return!1;const i=this._scene.getEngine(),s=e.getMesh(),r=s.getScene(),a=s._internalAbstractMeshDataInfo._materialForRenderPass?.[i.currentRenderPassId];if(a)return a.isReadyForSubMesh(s,e,t);const o=e.getMaterial();if(!o||o.disableDepthWrite)return!1;const c=[],u=[O.PositionKind];let d=!1,f=!1;const g=!1;o.needAlphaTestingForMesh(s)&&o.getAlphaTestTexture()&&(c.push("#define ALPHATEST"),s.isVerticesDataPresent(O.UVKind)&&(u.push(O.UVKind),c.push("#define UV1"),d=!0),s.isVerticesDataPresent(O.UV2Kind)&&(u.push(O.UV2Kind),c.push("#define UV2"),f=!0));const m=new eu;if(s.useBones&&s.computeBonesUsingShaders&&s.skeleton){u.push(O.MatricesIndicesKind),u.push(O.MatricesWeightsKind),s.numBoneInfluencers>4&&(u.push(O.MatricesIndicesExtraKind),u.push(O.MatricesWeightsExtraKind)),c.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),s.numBoneInfluencers>0&&m.addCPUSkinningFallback(0,s);const D=s.skeleton;D.isUsingTextureForMatrices?c.push("#define BONETEXTURE"):c.push("#define BonesPerMesh "+(D.bones.length+1))}else c.push("#define NUM_BONE_INFLUENCERS 0");const b=s.morphTargetManager?Lb(s.morphTargetManager,c,u,s,!0,!1,!1,d,f,g):0;o.pointsCloud&&c.push("#define POINTSIZE"),t&&(c.push("#define INSTANCES"),Uf(u),e.getRenderingMesh().hasThinInstances&&c.push("#define THIN_INSTANCES"));const x=s.bakedVertexAnimationManager;x&&x.isEnabled&&(c.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),t&&u.push("bakedVertexAnimationSettingsInstanced")),this._storeNonLinearDepth&&c.push("#define NONLINEARDEPTH"),this._storeCameraSpaceZ&&c.push("#define STORE_CAMERASPACE_Z"),this.isPacked&&c.push("#define PACKED"),wb(o,r,c);const v=e._getDrawWrapper(void 0,!0),E=v.defines,A=c.join(` 697`);if(E!==A){const D=["world","mBones","boneTextureWidth","pointSize","viewProjection","view","diffuseMatrix","depthValues","morphTargetInfluences","morphTargetCount","morphTargetTextureInfo","morphTargetTextureIndices","bakedVertexAnimationSettings","bakedVertexAnimationTextureSizeInverted","bakedVertexAnimationTime","bakedVertexAnimationTexture"],I=["diffuseSampler","morphTargets","boneSampler","bakedVertexAnimationTexture"];Nf(D),v.setEffect(i.createEffect("depth",{attributes:u,uniformsNames:D,uniformBuffersNames:[],samplers:I,defines:A,fallbacks:m,onCompiled:null,onError:null,indexParameters:{maxSimultaneousMorphTargets:b},shaderLanguage:this._shaderLanguage},i),A)}return v.effect.isReady()}getDepthMap(){return this._depthMap}dispose(){const e=[];for(const t in this._scene._depthRenderer)this._scene._depthRenderer[t]===this&&e.push(t);if(e.length>0){this._depthMap.dispose();for(const t of e)delete this._scene._depthRenderer[t]}}}cc.ForceGLSL=!1;cc._SceneComponentInitialization=n=>
697{throw We("DepthRendererSceneComponent")};var eE;(function(n){n[n.NormalizedViewDepth=0]="NormalizedViewDepth",n[n.ViewDepth=1]="ViewDepth",n[n.ScreenDepth=2]="ScreenDepth"})(eE||(eE={}));class io extends gs{_gatherImports(e,t){e?(this._webGPUReady=!0,t.push(_t(()=>Promise.resolve().then(()=>iV),void 0))):t.push(_t(()=>Promise.resolve().then(()=>eV),void 0))}constructor(e,t=null,i="",s){super({...s,name:e,engine:t||Pe.LastCreatedEngine,useShaderStore:!0,useAsPostProcess:!0,fragmentShader:io.FragmentUrl,uniforms:io.Uniforms,defines:i}),this.textureWidth=0,this.textureHeight=0}bind(e=!1){super.bind(e);const t=this.drawWrapper.effect;this.textureWidth===1||this.textureHeight===1?t.setInt2("texSize",this.textureWidth,this.textureHeight):t.setFloat2("texSize",this.textureWidth,this.textureHeight)}}io.FragmentUrl="minmaxRedux";io.Uniforms=["texSize"];const $3=new Float32Array(4),Q3=new Uint8Array(4),Gr={min:0,max:0};class sI{get depthRedux(){return this._depthRedux}set depthRedux(e){this._depthRedux!==e&&(this._depthRedux=e,this._recreatePostProcesses())}get textureWidth(){return this._textureWidth}get textureHeight(){return this._textureHeight}constructor(e,t=!0){this.onAfterReductionPerformed=new le,this._textureWidth=0,this._textureHeight=0,this._scene=e,this._depthRedux=t,this.reductionSteps=[]}setTextureDimensions(e,t,i=0){return e===this._textureWidth&&t===this._textureHeight&&i===this._depthTextureType?!1:(this._textureWidth=e,this._textureHeight=t,this._depthTextureType=i,this._recreatePostProcesses(),!0)}readMinMax(e){const t=e.type===Pe.TEXTURETYPE_FLOAT||e.type===Pe.TEXTURETYPE_HALF_FLOAT,i=t?$3:Q3;this._scene.getEngine()._readTexturePixels(e,1,1,-1,0,i,!1),Gr.min=i[0],Gr.max=i[1],t||(Gr.min=Gr.min/255,Gr.max=Gr.max/255),Gr.min>=Gr.max&&(Gr.min=0,Gr.max=1),this.onAfterReductionPerformed.notifyObservers(Gr)}dispose(e=!0){e&&(this.onAfterReductionPerformed.clear(),this._textureWidth=0,this._textureHeight=0);for(let t=0;t<this.reductionSteps.length;++t)this.reductionSteps[t].dispose();this.reductionSteps.length=0}_recreatePostProcesses(){this.dispose(!1);const e=this._scene;let t=this.textureWidth,i=this.textureHeight;const s=new io("Initial reduction phase",e.getEngine(),"#define INITIAL"+(this._depthRedux?` 698#define DEPTH_REDUX`:"")+(this._depthTextureType===1?` 699#define VIEW_DEPTH`:""));s.textureWidth=t,s.textureHeight=i,this.reductionSteps.push(s);let r=1;for(;t>1||i>1;){t=Math.max(Math.round(t/2),1),i=Math.max(Math.round(i/2),1);const a=new io("Reduction phase "+r,e.getEngine(),"#define "+(t==1&&i==1?"LAST":t==1||i==1?"ONEBEFORELAST":"MAIN"));a.textureWidth=t,a.textureHeight=i,this.reductionSteps.push(a),r++}}}const zm="minmaxReduxPixelShader",rI=`varying vec2 vUV;uniform sampler2D textureSampler; 700#if defined(INITIAL) 701uniform vec2 texSize;void main(void) 702{ivec2 coord=ivec2(vUV*(texSize-1.0));float f1=texelFetch(textureSampler,coord,0).r;float f2=texelFetch(textureSampler,coord+ivec2(1,0),0).r;float f3=texelFetch(textureSampler,coord+ivec2(1,1),0).r;float f4=texelFetch(textureSampler,coord+ivec2(0,1),0).r; 703#ifdef DEPTH_REDUX 704#ifdef VIEW_DEPTH 705float minz=3.4e38;if (f1 != 0.0) { minz=f1; } 706if (f2 != 0.0) { minz=min(minz,f2); } 707if (f3 != 0.0) { minz=min(minz,f3); } 708if (f4 != 0.0) { minz=min(minz,f4); } 709float maxz=max(max(max(f1,f2),f3),f4); 710#else 711float minz=min(min(min(f1,f2),f3),f4);float maxz=max(max(max(sign(1.0-f1)*f1,sign(1.0-f2)*f2),sign(1.0-f3)*f3),sign(1.0-f4)*f4); 712#endif 713#else 714float minz=min(min(min(f1,f2),f3),f4);float maxz=max(max(max(f1,f2),f3),f4); 715#endif 716glFragColor=vec4(minz,maxz,0.,0.);} 717#elif defined(MAIN) 718uniform vec2 texSize;void main(void) 719{ivec2 coord=ivec2(vUV*(texSize-1.0));vec2 f1=texelFetch(textureSampler,coord,0).rg;vec2 f2=texelFetch(textureSampler,coord+ivec2(1,0),0).rg;vec2 f3=texelFetch(textureSampler,coord+ivec2(1,1),0).rg;vec2 f4=texelFetch(textureSampler,coord+ivec2(0,1),0).rg;float minz=min(min(min(f1.x,f2.x),f3.x),f4.x);float maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);glFragColor=vec4(minz,maxz,0.,0.);} 720#elif defined(ONEBEFORELAST) 721uniform ivec2 texSize;void main(void) 722{ivec2 coord=ivec2(vUV*vec2(texSize-1));vec2 f1=texelFetch(textureSampler,coord % texSize,0).rg;vec2 f2=texelFetch(textureSampler,(coord+ivec2(1,0)) % texSize,0).rg;vec2 f3=texelFetch(textureSampler,(coord+ivec2(1,1)) % texSize,0).rg;vec2 f4=texelFetch(textureSampler,(coord+ivec2(0,1)) % texSize,0).rg;float minz=min(min(min(f1.x,f2.x),f3.x),f4.x);float maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);glFragColor=vec4(minz,maxz,0.,0.);} 723#elif defined(LAST) 724void main(void) 725{glFragColor=vec4(0.);if (true) { 726discard;}} 727#endif 728`;de.ShadersStore[zm]||(de.ShadersStore[zm]=rI);const J3={name:zm,shader:rI},eV=Object.freeze(Object.defineProperty({__proto__:null,minmaxReduxPixelShader:J3},Symbol.toStringTag,{value:"Module"})),Gm="minmaxReduxPixelShader",nI=`varying vUV: vec2f;var textureSampler: texture_2d<f32>; 729#if defined(INITIAL) 730uniform texSize: vec2f;@fragment 731fn main(input: FragmentInputs)->FragmentOutputs {let coord=vec2i(fragmentInputs.vUV*(uniforms.texSize-1.0));let f1=textureLoad(textureSampler,coord,0).r;let f2=textureLoad(textureSampler,coord+vec2i(1,0),0).r;let f3=textureLoad(textureSampler,coord+vec2i(1,1),0).r;let f4=textureLoad(textureSampler,coord+vec2i(0,1),0).r; 732#ifdef DEPTH_REDUX 733#ifdef VIEW_DEPTH 734var minz=3.4e38;if (f1 != 0.0) { minz=f1; } 735if (f2 != 0.0) { minz=min(minz,f2); } 736if (f3 != 0.0) { minz=min(minz,f3); } 737if (f4 != 0.0) { minz=min(minz,f4); } 738let maxz=max(max(max(f1,f2),f3),f4); 739#else 740let minz=min(min(min(f1,f2),f3),f4);let maxz=max(max(max(sign(1.0-f1)*f1,sign(1.0-f2)*f2),sign(1.0-f3)*f3),sign(1.0-f4)*f4); 741#endif 742#else 743let minz=min(min(min(f1,f2),f3),f4);let maxz=max(max(max(f1,f2),f3),f4); 744#endif 745fragmentOutputs.color=vec4f(minz,maxz,0.,0.);} 746#elif defined(MAIN) 747uniform texSize: vec2f;@fragment 748fn main(input: FragmentInputs)->FragmentOutputs {let coord=vec2i(fragmentInputs.vUV*(uniforms.texSize-1.0));let f1=textureLoad(textureSampler,coord,0).rg;let f2=textureLoad(textureSampler,coord+vec2i(1,0),0).rg;let f3=textureLoad(textureSampler,coord+vec2i(1,1),0).rg;let f4=textureLoad(textureSampler,coord+vec2i(0,1),0).rg;let minz=min(min(min(f1.x,f2.x),f3.x),f4.x);let maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);fragmentOutputs.color=vec4(minz,maxz,0.,0.);} 749#elif defined(ONEBEFORELAST) 750uniform texSize: vec2i;@fragment 751fn main(input: FragmentInputs)->FragmentOutputs {let coord=vec2i(fragmentInputs.vUV*vec2f(uniforms.texSize-1));let f1=textureLoad(textureSampler,coord % uniforms.texSize,0).rg;let f2=textureLoad(textureSampler,(coord+vec2i(1,0)) % uniforms.texSize,0).rg;let f3=textureLoad(textureSampler,(coord+vec2i(1,1)) % uniforms.texSize,0).rg;let f4=textureLoad(textureSampler,(coord+vec2i(0,1)) % uniforms.texSize,0).rg;let minz=min(min(min(f1.x,f2.x),f3.x),f4.x);let maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);fragmentOutputs.color=vec4(minz,maxz,0.,0.);} 752#elif defined(LAST) 753@fragment 754fn main(input: FragmentInputs)->FragmentOutputs {fragmentOutputs.color=vec4f(0.);if (true) { 755discard;}} 756#endif 757`;de.ShadersStoreWGSL[Gm]||(de.ShadersStoreWGSL[Gm]=nI);const tV={name:Gm,shader:nI},iV=Object.freeze(Object.defineProperty({__proto__:null,minmaxReduxPixelShaderWGSL:tV},Symbol.toStringTag,{value:"Module"}));class sV{get onAfterReductionPerformed(){return this._thinMinMaxReducer.onAfterReductionPerformed}constructor(e){this._onAfterUnbindObserver=null,this._forceFullscreenViewport=!0,this._activated=!1,this._camera=e,this._postProcessManager=new cf(e.getScene()),this._thinMinMaxReducer=new sI(e.getScene()),this._reductionSteps=[],this._onContextRestoredObserver=e.getEngine().onContextRestoredObservable.add(()=>{this._postProcessManager._rebuild()})}get sourceTexture(){return this._sourceTexture}setSourceTexture(e,t,i=2,s=!0){if(e!==this._sourceTexture&&(this._thinMinMaxReducer.depthRedux=t,this.deactivate(),this._sourceTexture=e,this._forceFullscreenViewport=s,this._thinMinMaxReducer.setTextureDimensions(e.getRenderWidth(),e.getRenderHeight()))){this._disposePostProcesses();const r=this._thinMinMaxReducer.reductionSteps;for(let a=0;a<r.length;++a){const o=r[a],c=new di(o.name,io.FragmentUrl,{effectWrapper:o,samplingMode:1,engine:this._camera.getScene().getEngine(),textureType:i,textureFormat:7,size:{
757width:o.textureWidth,height:o.textureHeight}});this._reductionSteps.push(c),c.autoClear=!1,c.forceFullscreenViewport=s,a===0&&(c.externalTextureSamplerBinding=!0,c.onApplyObservable.add(u=>{u.setTexture("textureSampler",this._sourceTexture)})),a===r.length-1&&this._reductionSteps[a-1].onAfterRenderObservable.add(()=>{this._thinMinMaxReducer.readMinMax(c.inputTexture.texture)})}}}get refreshRate(){return this._sourceTexture?this._sourceTexture.refreshRate:-1}set refreshRate(e){this._sourceTexture&&(this._sourceTexture.refreshRate=e)}get activated(){return this._activated}activate(){this._onAfterUnbindObserver||!this._sourceTexture||(this._onAfterUnbindObserver=this._sourceTexture.onAfterUnbindObservable.add(()=>{const e=this._camera.getScene().getEngine();e._debugPushGroup?.("min max reduction",1),this._reductionSteps[0].activate(this._camera),this._postProcessManager.directRender(this._reductionSteps,this._reductionSteps[0].inputTexture,this._forceFullscreenViewport,0,0,!0,this._reductionSteps.length-1),e.unBindFramebuffer(this._reductionSteps[this._reductionSteps.length-1].inputTexture,!1),e._debugPopGroup?.(1)}),this._activated=!0)}deactivate(){!this._onAfterUnbindObserver||!this._sourceTexture||(this._sourceTexture.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=null,this._activated=!1)}dispose(e=!0){e&&(this.onAfterReductionPerformed.clear(),this._camera.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=void 0,this._disposePostProcesses(),this._postProcessManager.dispose(),this._postProcessManager=void 0,this._thinMinMaxReducer.dispose(),this._thinMinMaxReducer=void 0,this._sourceTexture=null)}_disposePostProcesses(){for(let e=0;e<this._reductionSteps.length;++e)this._reductionSteps[e].dispose();this._reductionSteps.length=0}}class rV extends sV{get depthRenderer(){return this._depthRenderer}constructor(e){super(e)}setDepthRenderer(e=null,t=2,i=!0){const s=this._camera.getScene();this._depthRenderer&&(delete s._depthRenderer[this._depthRendererId],this._depthRenderer.dispose(),this._depthRenderer=null),e===null&&(s._depthRenderer||(s._depthRenderer={}),this._depthRendererId="minmax_"+this._camera.id,e=this._depthRenderer=new cc(s,t,this._camera,!1,1,!1,`DepthRenderer ${this._depthRendererId}`),e.enabled=!1,s._depthRenderer[this._depthRendererId]=e),super.setSourceTexture(e.getDepthMap(),!0,t,i)}setSourceTexture(e,t,i=2,s=!0){super.setSourceTexture(e,t,i,s)}activate(){this._depthRenderer&&(this._depthRenderer.enabled=!0),super.activate()}deactivate(){super.deactivate(),this._depthRenderer&&(this._depthRenderer.enabled=!1)}dispose(e=!0){super.dispose(e),this._depthRenderer&&e&&(this._depthRenderer.dispose(),this._depthRenderer=null)}}const tE=T.Up(),nV=T.Zero(),Si=new T,Gl=new T,Pd=new W;class Di extends ze{_validateFilter(e){return e===ze.FILTER_NONE||e===ze.FILTER_PCF||e===ze.FILTER_PCSS?e:(oe.Error('Unsupported filter "'+e+'"!'),ze.FILTER_NONE)}get numCascades(){return this._numCascades}set numCascades(e){e=Math.min(Math.max(e,Di.MIN_CASCADES_COUNT),Di.MAX_CASCADES_COUNT),e!==this._numCascades&&(this._numCascades=e,this.recreateShadowMap(),this._recreateSceneUBOs())}get freezeShadowCastersBoundingInfo(){return this._freezeShadowCastersBoundingInfo}set freezeShadowCastersBoundingInfo(e){this._freezeShadowCastersBoundingInfoObservable&&e&&(this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable),this._freezeShadowCastersBoundingInfoObservable=null),!this._freezeShadowCastersBoundingInfoObservable&&!e&&(this._freezeShadowCastersBoundingInfoObservable=this._scene.onBeforeRenderObservable.add(()=>this._computeShadowCastersBoundingInfo())),this._freezeShadowCastersBoundingInfo=e,e&&this._computeShadowCastersBoundingInfo()}_computeShadowCastersBoundingInfo(){if(this._scbiMin.copyFromFloats(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._scbiMax.copyFromFloats(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),this._shadowMap&&this._shadowMap.renderList){const e=this._shadowMap.renderList;for(let t=0;t<e.length;t++){const i=e[t];if(!i)continue;const s=i.getBoundingInfo(),r=s.boundingBox;this._scbiMin.minimizeInPlace(r.minimumWorld),this._scbiMax.maximizeInPlace(r.maximumWorld)}}
757this._shadowCastersBoundingInfo.reConstruct(this._scbiMin,this._scbiMax)}get shadowCastersBoundingInfo(){return this._shadowCastersBoundingInfo}set shadowCastersBoundingInfo(e){this._shadowCastersBoundingInfo=e}setMinMaxDistance(e,t){this._minDistance===e&&this._maxDistance===t||(e>t&&(e=0,t=1),e<0&&(e=0),t>1&&(t=1),this._minDistance=e,this._maxDistance=t,this._breaksAreDirty=!0)}get minDistance(){return this._minDistance}get maxDistance(){return this._maxDistance}getClassName(){return Di.CLASSNAME}getCascadeMinExtents(e){return e>=0&&e<this._numCascades?this._cascadeMinExtents[e]:null}getCascadeMaxExtents(e){return e>=0&&e<this._numCascades?this._cascadeMaxExtents[e]:null}get shadowMaxZ(){return this._getCamera()?this._shadowMaxZ:0}set shadowMaxZ(e){const t=this._getCamera();if(!t){this._shadowMaxZ=e;return}this._shadowMaxZ===e||e<t.minZ||e>t.maxZ&&t.maxZ!==0||(this._shadowMaxZ=e,this._light._markMeshesAsLightDirty(),this._breaksAreDirty=!0)}get debug(){return this._debug}set debug(e){this._debug=e,this._light._markMeshesAsLightDirty()}get depthClamp(){return this._depthClamp}set depthClamp(e){this._depthClamp=e}get cascadeBlendPercentage(){return this._cascadeBlendPercentage}set cascadeBlendPercentage(e){this._cascadeBlendPercentage=e,this._light._markMeshesAsLightDirty()}get lambda(){return this._lambda}set lambda(e){const t=Math.min(Math.max(e,0),1);this._lambda!=t&&(this._lambda=t,this._breaksAreDirty=!0)}getCascadeViewMatrix(e){return e>=0&&e<this._numCascades?this._viewMatrices[e]:null}getCascadeProjectionMatrix(e){return e>=0&&e<this._numCascades?this._projectionMatrices[e]:null}getCascadeTransformMatrix(e){return e>=0&&e<this._numCascades?this._transformMatrices[e]:null}setDepthRenderer(e){this._depthRenderer=e,this._depthReducer&&this._depthReducer.setDepthRenderer(this._depthRenderer)}get autoCalcDepthBounds(){return this._autoCalcDepthBounds}set autoCalcDepthBounds(e){const t=this._getCamera();if(t){if(this._autoCalcDepthBounds=e,!e){this._depthReducer&&this._depthReducer.deactivate(),this.setMinMaxDistance(0,1);return}this._depthReducer||(this._depthReducer=new rV(t),this._depthReducer.onAfterReductionPerformed.add(i=>{let s=i.min,r=i.max;s>=r&&(s=0,r=1),(s!=this._minDistance||r!=this._maxDistance)&&this.setMinMaxDistance(s,r)}),this._depthReducer.setDepthRenderer(this._depthRenderer)),this._depthReducer.activate()}}get autoCalcDepthBoundsRefreshRate(){return this._depthReducer?.depthRenderer?.getDepthMap().refreshRate??-1}set autoCalcDepthBoundsRefreshRate(e){this._depthReducer?.depthRenderer&&(this._depthReducer.depthRenderer.getDepthMap().refreshRate=e)}splitFrustum(){this._breaksAreDirty=!0}_splitFrustum(){const e=this._getCamera();if(!e)return;const t=e.minZ,i=e.maxZ||this._shadowMaxZ,s=i-t,r=this._minDistance,a=this._shadowMaxZ<i&&this._shadowMaxZ>=t?Math.min((this._shadowMaxZ-t)/(i-t),this._maxDistance):this._maxDistance,o=t+r*s,c=t+a*s,u=c-o,d=c/o;for(let f=0;f<this._cascades.length;++f){const g=(f+1)/this._numCascades,m=o*d**g,b=o+u*g,x=this._lambda*(m-b)+b;this._cascades[f].prevBreakDistance=f===0?r:this._cascades[f-1].breakDistance,this._cascades[f].breakDistance=(x-t)/s,this._viewSpaceFrustumsZ[f]=x,this._frustumLengths[f]=(this._cascades[f].breakDistance-this._cascades[f].prevBreakDistance)*s}this._breaksAreDirty=!1}_computeMatrices(){const e=this._scene;if(!this._getCamera())return;T.NormalizeToRef(this._light.getShadowDirection(0),this._lightDirection),Math.abs(T.Dot(this._lightDirection,T.Up()))===1&&(this._lightDirection.z=1e-13),this._cachedDirection.copyFrom(this._lightDirection);const i=e.getEngine().useReverseDepthBuffer;for(let s=0;s<this._numCascades;++s){this._computeFrustumInWorldSpace(s),this._computeCascadeFrustum(s),this._cascadeMaxExtents[s].subtractToRef(this._cascadeMinExtents[s],Si),this._frustumCenter[s].addToRef(this._lightDirection.scale(this._cascadeMinExtents[s].z),this._shadowCameraPos[s]),W.LookAtLHToRef(this._shadowCameraPos[s],this._frustumCenter[s],tE,this._viewMatrices[s]);let r=0,a=Si.z;const o=this._shadowCastersBoundingInfo;o.update(this._viewMatrices[s]);const c=o.boundingBox.minimumWorld.z,u=o.boundingBox.maximumWorld.z;c>a||(!this._depthClamp||this.filter===ze.FILTER_PCSS?(r=Math.min(r,c),this.filter!==ze.FILTER_PCSS&&(a=Math.min(a,u))):(a=Math.min(a,u),r=Math.max(r,c),a=Math.max(r+1,a))),W.OrthoOffCenterLHToRef(this._cascadeMinExtents[s].x,this._cascadeMaxExtents[s].x,this._cascadeMinExtents[s].y,this._cascadeMaxExtents[s].y,i?a:r,i?r:a,this._projectionMatrices[s],e.getEngine().isNDCHalfZRange),this._cascadeMinExtents[s].z=r,this._cascadeMaxExtents[s].z=a,this._viewMatrices[s].multiplyToRef(this._projectionMatrices[s],this._transformMatrices[s]),T.TransformCoordinatesToRef(nV,this._transformMatrices[s],Si),Si.scaleInPlace(this._mapSize/2),Gl.copyFromFloats(Math.round(Si.x),Math.round(Si.y),Math.round(Si.z)),Gl.subtractInPlace(Si).scaleInPlace(2/this._mapSize),W.TranslationToRef(Gl.x,Gl.y,0,Pd),this._projectionMatrices[s].multiplyToRef(Pd,this._projectionMatrices[s]),this._viewMatrices[s].multiplyToRef(this._projectionMatrices[s],this._transformMatrices[s]),this._transformMatrices[s].copyToArray(this._transformMatricesAsArray,s*16)}}_computeFrustumInWorldSpace(e){const t=this._getCamera();if(!t)return;const i=this._cascades[e].prevBreakDistance,s=this._cascades[e].breakDistance,r=this._scene.getEngine().isNDCHalfZRange;t.getViewMatrix();const a=t.maxZ===0,o=t.maxZ;a&&(t.maxZ=this._shadowMaxZ,t.getProjectionMatrix(!0));const c=W.Invert(t.getTransformationMatrix());a&&(t.maxZ=o,t.getProjectionMatrix(!0));const u=this._scene.getEngine().useReverseDepthBuffer?4:0;for(let d=0;d<Di._FrustumCornersNdcSpace.length;++d)Si.copyFrom(Di._FrustumCornersNdcSpace[(d+u)%Di._FrustumCornersNdcSpace.length]),r&&Si.z===-1&&(Si.z=0),T.TransformCoordinatesToRef(Si,c,this._frustumCornersWorldSpace[e][d]
757);for(let d=0;d<Di._FrustumCornersNdcSpace.length/2;++d)Si.copyFrom(this._frustumCornersWorldSpace[e][d+4]).subtractInPlace(this._frustumCornersWorldSpace[e][d]),Gl.copyFrom(Si).scaleInPlace(i),Si.scaleInPlace(s),Si.addInPlace(this._frustumCornersWorldSpace[e][d]),this._frustumCornersWorldSpace[e][d+4].copyFrom(Si),this._frustumCornersWorldSpace[e][d].addInPlace(Gl)}_computeCascadeFrustum(e){if(this._cascadeMinExtents[e].copyFromFloats(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cascadeMaxExtents[e].copyFromFloats(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),this._frustumCenter[e].copyFromFloats(0,0,0),!!this._getCamera()){for(let i=0;i<this._frustumCornersWorldSpace[e].length;++i)this._frustumCenter[e].addInPlace(this._frustumCornersWorldSpace[e][i]);if(this._frustumCenter[e].scaleInPlace(1/this._frustumCornersWorldSpace[e].length),this.stabilizeCascades){let i=0;for(let s=0;s<this._frustumCornersWorldSpace[e].length;++s){const r=this._frustumCornersWorldSpace[e][s].subtractToRef(this._frustumCenter[e],Si).length();i=Math.max(i,r)}i=Math.ceil(i*16)/16,this._cascadeMaxExtents[e].copyFromFloats(i,i,i),this._cascadeMinExtents[e].copyFromFloats(-i,-i,-i)}else{const i=this._frustumCenter[e];this._frustumCenter[e].addToRef(this._lightDirection,Si),W.LookAtLHToRef(i,Si,tE,Pd);for(let s=0;s<this._frustumCornersWorldSpace[e].length;++s)T.TransformCoordinatesToRef(this._frustumCornersWorldSpace[e][s],Pd,Si),this._cascadeMinExtents[e].minimizeInPlace(Si),this._cascadeMaxExtents[e].maximizeInPlace(Si)}}}_recreateSceneUBOs(){if(this._disposeSceneUBOs(),this._sceneUBOs)for(let e=0;e<this._numCascades;++e)this._sceneUBOs.push(this._scene.createSceneUniformBuffer(`Scene for CSM Shadow Generator (light "${this._light.name}" cascade #${e})`))}static get IsSupported(){const e=Ke.LastCreatedEngine;return e?e._features.supportCSM:!1}constructor(e,t,i,s,r=!0){if(!Di.IsSupported){oe.Error("CascadedShadowMap is not supported by the current engine.");return}super(e,t,i,s,r),this.usePercentageCloserFiltering=!0}_initializeGenerator(){this.penumbraDarkness=this.penumbraDarkness??1,this._numCascades=this._numCascades??Di.DEFAULT_CASCADES_COUNT,this.stabilizeCascades=this.stabilizeCascades??!1,this._freezeShadowCastersBoundingInfoObservable=this._freezeShadowCastersBoundingInfoObservable??null,this.freezeShadowCastersBoundingInfo=this.freezeShadowCastersBoundingInfo??!1,this._scbiMin=this._scbiMin??new T(0,0,0),this._scbiMax=this._scbiMax??new T(0,0,0),this._shadowCastersBoundingInfo=this._shadowCastersBoundingInfo??new Hs(new T(0,0,0),new T(0,0,0)),this._breaksAreDirty=this._breaksAreDirty??!0,this._minDistance=this._minDistance??0,this._maxDistance=this._maxDistance??1,this._currentLayer=this._currentLayer??0,this._shadowMaxZ=this._shadowMaxZ??this._getCamera()?.maxZ??1e4,this._debug=this._debug??!1,this._depthClamp=this._depthClamp??!0,this._cascadeBlendPercentage=this._cascadeBlendPercentage??.1,this._lambda=this._lambda??.5,this._autoCalcDepthBounds=this._autoCalcDepthBounds??!1,this._recreateSceneUBOs(),super._initializeGenerator()}_createTargetRenderTexture(){const e=this._scene.getEngine();this._shadowMap?.dispose();const t={width:this._mapSize,height:this._mapSize,layers:this.numCascades};this._shadowMap=new ar(this._light.name+"_CSMShadowMap",t,this._scene,!1,!0,this._textureType,!1,void 0,!1,!1,void 0,this._useRedTextureType?6:5),this._shadowMap.createDepthStencilTexture(e.useReverseDepthBuffer?516:513,!0,void 0,void 0,void 0,`DepthStencilForCSMShadowGenerator-${this._light.name}`),this._shadowMap.noPrePassRenderer=!0}_initializeShadowMap(){if(super._initializeShadowMap(),this._shadowMap===null)return;this._transformMatricesAsArray=new Float32Array(this._numCascades*16),this._tempTransformMatricesAsArray=new Float32Array(this._numCascades*16),this._viewSpaceFrustumsZ=new Array(this._numCascades),this._frustumLengths=new Array(this._numCascades),this._lightSizeUVCorrection=new Array(this._numCascades*2),this._depthCorrection=new Array(this._numCascades),this._cascades=[],this._viewMatrices=[],this._projectionMatrices=[],this._transformMatrices=[],this._cascadeMinExtents=[],this._cascadeMaxExtents=[],this._frustumCenter=[],this._shadowCameraPos=[],this._frustumCornersWorldSpace=[];for(let t=0;t<this._numCascades;++t){this._cascades[t]={prevBreakDistance:0,breakDistance:0},this._viewMatrices[t]=W.Zero(),this._projectionMatrices[t]=W.Zero(),this._transformMatrices[t]=W.Zero(),this._cascadeMinExtents[t]=new T,this._cascadeMaxExtents[t]=new T,this._frustumCenter[t]=new T,this._shadowCameraPos[t]=new T,this._frustumCornersWorldSpace[t]=new Array(Di._FrustumCornersNdcSpace.length);for(let i=0;i<Di._FrustumCornersNdcSpace.length;++i)this._frustumCornersWorldSpace[t][i]=new T}const e=this._scene.getEngine();this._shadowMap.onBeforeBindObservable.clear(),this._shadowMap.onBeforeRenderObservable.clear(),this._shadowMap.onBeforeRenderObservable.add(t=>{this._sceneUBOs&&this._scene.setSceneUniformBuffer(this._sceneUBOs[t]),this._currentLayer=t,this._filter===ze.FILTER_PCF&&e.setColorWrite(!1),Go.eyeAtCamera=!1,this._scene.setTransformMatrix(this.getCascadeViewMatrix(t),this.getCascadeProjectionMatrix(t)),this._useUBO&&(this._scene.getSceneUniformBuffer().unbindEffect(),this._scene.finalizeSceneUbo())}),this._shadowMap.onBeforeBindObservable.add(()=>{this._currentSceneUBO=this._scene.getSceneUniformBuffer(),e._debugPushGroup?.(`cascaded shadow map generation for pass id ${e.currentRenderPassId}`,1),this._breaksAreDirty&&this._splitFrustum(),this._computeMatrices()}),this._splitFrustum()}
757_bindCustomEffectForRenderSubMeshForShadowMap(e,t){t.setMatrix("viewProjection",this.getCascadeTransformMatrix(this._currentLayer))}_isReadyCustomDefines(e){e.push("#define SM_DEPTHCLAMP "+(this._depthClamp&&this._filter!==ze.FILTER_PCSS?"1":"0"))}prepareDefines(e,t){super.prepareDefines(e,t);const i=this._scene,s=this._light;if(!i.shadowsEnabled||!s.shadowEnabled)return;e["SHADOWCSM"+t]=!0,e["SHADOWCSMDEBUG"+t]=this.debug,e["SHADOWCSMNUM_CASCADES"+t]=this.numCascades,e["SHADOWCSM_RIGHTHANDED"+t]=i.useRightHandedSystem;const r=this._getCamera();r&&this._shadowMaxZ<=(r.maxZ||this._shadowMaxZ)&&(e["SHADOWCSMUSESHADOWMAXZ"+t]=!0),this.cascadeBlendPercentage===0&&(e["SHADOWCSMNOBLEND"+t]=!0)}bindShadowLight(e,t){const i=this._light,s=this._scene;if(!s.shadowsEnabled||!i.shadowEnabled)return;const r=this._getCamera();if(!r)return;const a=this.getShadowMap();if(!a)return;const o=a.getSize().width,c=this._transformMatricesAsArray,u=s.floatingOriginMode?Uk(this._scene.floatingOriginOffset,this._viewMatrices,this._projectionMatrices,this._numCascades,this._tempTransformMatricesAsArray):c;if(t.setMatrices("lightMatrix"+e,u),t.setArray("viewFrustumZ"+e,this._viewSpaceFrustumsZ),t.setFloat("cascadeBlendFactor"+e,this.cascadeBlendPercentage===0?1e4:1/this.cascadeBlendPercentage),t.setArray("frustumLengths"+e,this._frustumLengths),this._filter===ze.FILTER_PCF)t.setDepthStencilTexture("shadowTexture"+e,a),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),o,1/o,this.frustumEdgeFalloff,e);else if(this._filter===ze.FILTER_PCSS){for(let d=0;d<this._numCascades;++d)this._lightSizeUVCorrection[d*2+0]=d===0?1:(this._cascadeMaxExtents[0].x-this._cascadeMinExtents[0].x)/(this._cascadeMaxExtents[d].x-this._cascadeMinExtents[d].x),this._lightSizeUVCorrection[d*2+1]=d===0?1:(this._cascadeMaxExtents[0].y-this._cascadeMinExtents[0].y)/(this._cascadeMaxExtents[d].y-this._cascadeMinExtents[d].y),this._depthCorrection[d]=d===0?1:(this._cascadeMaxExtents[d].z-this._cascadeMinExtents[d].z)/(this._cascadeMaxExtents[0].z-this._cascadeMinExtents[0].z);t.setDepthStencilTexture("shadowTexture"+e,a),t.setTexture("depthTexture"+e,a),t.setArray2("lightSizeUVCorrection"+e,this._lightSizeUVCorrection),t.setArray("depthCorrection"+e,this._depthCorrection),t.setFloat("penumbraDarkness"+e,this.penumbraDarkness),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),1/o,this._contactHardeningLightSizeUVRatio*o,this.frustumEdgeFalloff,e)}else t.setTexture("shadowTexture"+e,a),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),o,1/o,this.frustumEdgeFalloff,e);i._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(r),this.getLight().getDepthMinZ(r)+this.getLight().getDepthMaxZ(r),e)}getTransformMatrix(){return this.getCascadeTransformMatrix(0)}dispose(){super.dispose(),this._freezeShadowCastersBoundingInfoObservable&&(this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable),this._freezeShadowCastersBoundingInfoObservable=null),this._depthReducer&&(this._depthReducer.dispose(),this._depthReducer=null)}serialize(){const e=super.serialize(),t=this.getShadowMap();if(!t)return e;if(e.numCascades=this._numCascades,e.debug=this._debug,e.stabilizeCascades=this.stabilizeCascades,e.lambda=this._lambda,e.cascadeBlendPercentage=this.cascadeBlendPercentage,e.depthClamp=this._depthClamp,e.autoCalcDepthBounds=this.autoCalcDepthBounds,e.shadowMaxZ=this._shadowMaxZ,e.penumbraDarkness=this.penumbraDarkness,e.freezeShadowCastersBoundingInfo=this._freezeShadowCastersBoundingInfo,e.minDistance=this.minDistance,e.maxDistance=this.maxDistance,e.renderList=[],t.renderList)for(let i=0;i<t.renderList.length;i++){const s=t.renderList[i];e.renderList.push(s.id)}return e}static Parse(e,t){const i=ze.Parse(e,t,(s,r,a)=>new Di(s,r,void 0,a));return e.numCascades!==void 0&&(i.numCascades=e.numCascades),e.debug!==void 0&&(i.debug=e.debug),e.stabilizeCascades!==void 0&&(i.stabilizeCascades=e.stabilizeCascades),e.lambda!==void 0&&(i.lambda=e.lambda),e.cascadeBlendPercentage!==void 0&&(i.cascadeBlendPercentage=e.cascadeBlendPercentage),e.depthClamp!==void 0&&(i.depthClamp=e.depthClamp),e.autoCalcDepthBounds!==void 0&&(i.autoCalcDepthBounds=e.autoCalcDepthBounds),e.shadowMaxZ!==void 0&&(i.shadowMaxZ=e.shadowMaxZ),e.penumbraDarkness!==void 0&&(i.penumbraDarkness=e.penumbraDarkness),e.freezeShadowCastersBoundingInfo!==void 0&&(i.freezeShadowCastersBoundingInfo=e.freezeShadowCastersBoundingInfo),e.minDistance!==void 0&&e.maxDistance!==void 0&&i.setMinMaxDistance(e.minDistance,e.maxDistance),i}}Di._FrustumCornersNdcSpace=[new T(-1,1,-1),new T(1,1,-1),new T(1,-1,-1),new T(-1,-1,-1),new T(-1,1,1),new T(1,1,1),new T(1,-1,1),new T(-1,-1,1)];Di.CLASSNAME="CascadedShadowGenerator";
757Di.DEFAULT_CASCADES_COUNT=4;Di.MIN_CASCADES_COUNT=2;Di.MAX_CASCADES_COUNT=4;Di._SceneComponentInitialization=n=>{throw We("ShadowGeneratorSceneComponent")};class aV extends zb{get light(){return this._light}set light(e){e!==this._light&&(this._light=e,this._setupShadowGenerator())}get camera(){return this._camera}set camera(e){this._camera=e,this._setupShadowGenerator()}get mapSize(){return this._mapSize}set mapSize(e){e!==this._mapSize&&(this._mapSize=e,this._setupShadowGenerator())}get useFloat32TextureType(){return this._useFloat32TextureType}set useFloat32TextureType(e){e!==this._useFloat32TextureType&&(this._useFloat32TextureType=e,this._setupShadowGenerator())}get useRedTextureFormat(){return this._useRedTextureFormat}set useRedTextureFormat(e){e!==this._useRedTextureFormat&&(this._useRedTextureFormat=e,this._setupShadowGenerator())}get bias(){return this._bias}set bias(e){e!==this._bias&&(this._bias=e,this._shadowGenerator&&(this._shadowGenerator.bias=e))}get normalBias(){return this._normalBias}set normalBias(e){e!==this._normalBias&&(this._normalBias=e,this._shadowGenerator&&(this._shadowGenerator.normalBias=e))}get darkness(){return this._darkness}set darkness(e){e!==this._darkness&&(this._darkness=e,this._shadowGenerator&&(this._shadowGenerator.darkness=e))}get transparencyShadow(){return this._transparencyShadow}set transparencyShadow(e){e!==this._transparencyShadow&&(this._transparencyShadow=e,this._shadowGenerator&&(this._shadowGenerator.transparencyShadow=e))}get enableSoftTransparentShadow(){return this._enableSoftTransparentShadow}set enableSoftTransparentShadow(e){e!==this._enableSoftTransparentShadow&&(this._enableSoftTransparentShadow=e,this._shadowGenerator&&(this._shadowGenerator.enableSoftTransparentShadow=e))}get useOpacityTextureForTransparentShadow(){return this._useOpacityTextureForTransparentShadow}set useOpacityTextureForTransparentShadow(e){e!==this._useOpacityTextureForTransparentShadow&&(this._useOpacityTextureForTransparentShadow=e,this._shadowGenerator&&(this._shadowGenerator.useOpacityTextureForTransparentShadow=e))}get filter(){return this._filter}set filter(e){e!==this._filter&&(this._filter=e,this._shadowGenerator&&(this._shadowGenerator.filter=e))}get filteringQuality(){return this._filteringQuality}set filteringQuality(e){e!==this._filteringQuality&&(this._filteringQuality=e,this._shadowGenerator&&(this._shadowGenerator.filteringQuality=e))}_createShadowGenerator(){this._shadowGenerator=new ze(this._mapSize,this._light,this._useFloat32TextureType,void 0,this._useRedTextureFormat)}_setupShadowGenerator(){if(this._shadowGenerator?.dispose(),this._shadowGenerator=void 0,this._light!==void 0){this._createShadowGenerator();const e=this._shadowGenerator;if(e===void 0)return;e.bias=this._bias,e.normalBias=this._normalBias,e.darkness=this._darkness,e.transparencyShadow=this._transparencyShadow,e.enableSoftTransparentShadow=this._enableSoftTransparentShadow,e.useOpacityTextureForTransparentShadow=this._useOpacityTextureForTransparentShadow,e.filter=this._filter,e.filteringQuality=this._filteringQuality;const t=e.getShadowMap();t._disableEngineStages=!0,t.cameraForLOD=this._camera,this.shadowGenerator=e}}isReady(){return!!this._shadowGenerator&&!!this._shadowGenerator.getShadowMap()?.isReadyForRendering()}constructor(e,t){super(e,t),this._mapSize=1024,this._useFloat32TextureType=!1,this._useRedTextureFormat=!0,this._bias=.01,this._normalBias=0,this._darkness=0,this._transparencyShadow=!1,this._enableSoftTransparentShadow=!1,this._useOpacityTextureForTransparentShadow=!1,this._filter=ze.FILTER_PCF,this._filteringQuality=ze.QUALITY_HIGH,this.outputTexture=this._frameGraph.textureManager.createDanglingHandle()}record(){if(this.light===void 0||this.objectList===void 0||this.camera===void 0)throw new Error(`FrameGraphShadowGeneratorTask ${this.name}: light, objectList and camera are required`);const e=this._shadowGenerator.getShadowMap();e.renderList=this.objectList.meshes,e.particleSystemList=this.objectList.particleSystems;const t=this._frameGraph.textureManager.importTexture(`${this.name} shadowmap`,this._shadowGenerator.getShadowMap().getInternalTexture());this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture,t),this._frameGraph.addPass(this.name).setExecuteFunc(r=>{if(!this.light.isEnabled()||!this.light.shadowEnabled)return;const a=this._shadowGenerator.getShadowMap();a.renderList=this.objectList.meshes,a.particleSystemList=this.objectList.particleSystems,r.saveDepthStates(),r.setDepthStates(!0,!0),r.renderUnmanaged(a),r.restoreDepthStates()}),this._frameGraph.addPass(this.name+"_disabled",!0).setExecuteFunc(r=>{})}dispose(){this._shadowGenerator?.dispose(),this._shadowGenerator=void 0}}class tu extends lt{constructor(){super(...arguments),this._needProjectionMatrixCompute=!0,this._viewMatrix=W.Identity(),this._projectionMatrix=W.Identity()}_setPosition(e){this._position=e}get position(){return this._position}set position(e){this._setPosition(e)}_setDirection(e){this._direction=e}get direction(){return this._direction}set direction(e){this._setDirection(e)}get shadowMinZ(){return this._shadowMinZ}set shadowMinZ(e){this._shadowMinZ=e,this.forceProjectionMatrixCompute()}get shadowMaxZ(){return this._shadowMaxZ}set shadowMaxZ(e){this._shadowMaxZ=e,this.forceProjectionMatrixCompute()}computeTransformedInformation(){return this.parent&&this.parent.getWorldMatrix?(this.transformedPosition||(this.transformedPosition=T.Zero()),T.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=T.Zero()),T.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this.transformedDirection)),!0):!1}getDepthScale(){return 50}getShadowDirection(e){return this.transformedDirection?this.transformedDirection:this.direction}getAbsolutePosition(){return this.transformedPosition?this.transformedPosition:this.position}setDirectionToTarget(e){return this.direction=T.Normalize(e.subtract(this.position)),this.direction}getRotation(){this.direction.normalize();const e=T.Cross(this.direction,wr.Y),t=T.Cross(e,this.direction);return T.RotationFromAxis(e,t,this.direction)}needCube(){return!1}needProjectionMatrixCompute(){return this._needProjectionMatrixCompute}forceProjectionMatrixCompute(){this._needProjectionMatrixCompute=!0}_initCache(){super._initCache(),this._cache.position=T.Zero()}_isSynchronized(){return!!this._cache.position.equals(this.position)}computeWorldMatrix(e){return!e&&this.isSynchronized()?(this._currentRenderId=this.getScene().getRenderId(),this._worldMatrix):(this._updateCache(),this._cache.position.copyFrom(this.position),this._worldMatrix||(this._worldMatrix=W.Identity()),W.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this.parent&&this.parent.getWorldMatrix&&(this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(),this._worldMatrix),this._markSyncedWithParent()),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix)}getDepthMinZ(e){return this.shadowMinZ!==void 0?this.shadowMinZ:e?.minZ||0}getDepthMaxZ(e){return this.shadowMaxZ!==void 0?this.shadowMaxZ:e?.maxZ||1e4}setShadowProjectionMatrix(e,t,i){return this.customProjectionMatrixBuilder?this.customProjectionMatrixBuilder(t,i,e):this._setDefaultShadowProjectionMatrix(e,t,i),this}_syncParentEnabledState(){super._syncParentEnabledState(),(!this.parent||!this.parent.getWorldMatrix)&&(this.transformedPosition=null,this.transformedDirection=null)}getViewMatrix(e){const t=te.Vector3[0];let i=this.position;this.computeTransformedInformation()&&(i=this.transformedPosition),T.NormalizeToRef(this.getShadowDirection(e),t),Math.abs(T.Dot(t,T.Up()))===1&&(t.z=1e-13);const s=te.Vector3[1];return i.addToRef(t,s),W.LookAtLHToRef(i,s,T.Up(),this._viewMatrix),this._viewMatrix}getProjectionMatrix(e,t){return this.setShadowProjectionMatrix(this._projectionMatrix,e??this._viewMatrix,t??[]),this._projectionMatrix}}N([lr()],tu.prototype,"position",null);N([lr()],tu.prototype,"direction",null);N([H()],tu.prototype,"shadowMinZ",null);N([H()],tu.prototype,"shadowMaxZ",null);yi.AddNodeConstructor("Light_Type_1",(n,e)=>()=>new Qr(n,T.Zero(),e));class Qr extends tu{get shadowFrustumSize(){return this._shadowFrustumSize}set shadowFrustumSize(e){this._shadowFrustumSize=e,this.forceProjectionMatrixCompute()}get shadowOrthoScale(){return this._shadowOrthoScale}set shadowOrthoScale(e){this._shadowOrthoScale=e,this.forceProjectionMatrixCompute()}get orthoLeft(){return this._orthoLeft}set orthoLeft(e){this._orthoLeft=e}get orthoRight(){return this._orthoRight}set orthoRight(e){this._orthoRight=e}get orthoTop(){return this._orthoTop}set orthoTop(e){this._orthoTop=e}get orthoBottom(){return this._orthoBottom}set orthoBottom(e){this._orthoBottom=e}constructor(e,t,i){super(e,i),this._shadowFrustumSize=0,this._shadowOrthoScale=.1,this.autoUpdateExtends=!0,this.autoCalcShadowZBounds=!1,this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE,this.position=t.scale(-1),this.direction=t}getClassName(){return"DirectionalLight"}getTypeID(){return lt.LIGHTTYPEID_DIRECTIONALLIGHT}_setDefaultShadowProjectionMatrix(e,t,i){this.shadowFrustumSize>0?this._setDefaultFixedFrustumShadowProjectionMatrix(e):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,i)}_setDefaultFixedFrustumShadowProjectionMatrix(e){const t=this.getScene().activeCamera;W.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,this.shadowMinZ!==void 0?this.shadowMinZ:t?t.minZ:0,this.shadowMaxZ!==void 0?this.shadowMaxZ:t?t.maxZ:1e4,e,this.get
757Scene().getEngine().isNDCHalfZRange)}_setDefaultAutoExtendShadowProjectionMatrix(e,t,i){const s=this.getScene().activeCamera;if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){const d=T.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=-Number.MAX_VALUE,this._orthoTop=-Number.MAX_VALUE,this._orthoBottom=Number.MAX_VALUE;let f=Number.MAX_VALUE,g=-Number.MAX_VALUE;for(let m=0;m<i.length;m++){const b=i[m];if(!b)continue;const v=b.getBoundingInfo().boundingBox;for(let E=0;E<v.vectorsWorld.length;E++)T.TransformCoordinatesToRef(v.vectorsWorld[E],t,d),d.x<this._orthoLeft&&(this._orthoLeft=d.x),d.y<this._orthoBottom&&(this._orthoBottom=d.y),d.x>this._orthoRight&&(this._orthoRight=d.x),d.y>this._orthoTop&&(this._orthoTop=d.y),this.autoCalcShadowZBounds&&(d.z<f&&(f=d.z),d.z>g&&(g=d.z))}this.autoCalcShadowZBounds&&(this._shadowMinZ=f,this._shadowMaxZ=g)}const r=this._orthoRight-this._orthoLeft,a=this._orthoTop-this._orthoBottom,o=this.shadowMinZ!==void 0?this.shadowMinZ:s?.minZ||0,c=this.shadowMaxZ!==void 0?this.shadowMaxZ:s?.maxZ||1e4,u=this.getScene().getEngine().useReverseDepthBuffer;W.OrthoOffCenterLHToRef(this._orthoLeft-r*this.shadowOrthoScale,this._orthoRight+r*this.shadowOrthoScale,this._orthoBottom-a*this.shadowOrthoScale,this._orthoTop+a*this.shadowOrthoScale,u?c:o,u?o:c,e,this.getScene().getEngine().isNDCHalfZRange)}_buildUniformLayout(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()}transferToEffect(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,t),this)}transferToNodeMaterialEffect(e,t){return this.computeTransformedInformation()?(e.setFloat3(t,this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z),this):(e.setFloat3(t,this.direction.x,this.direction.y,this.direction.z),this)}getDepthMinZ(e){const t=this._scene.getEngine();return!t.useReverseDepthBuffer&&t.isNDCHalfZRange?0:1}getDepthMaxZ(e){const t=this._scene.getEngine();return t.useReverseDepthBuffer&&t.isNDCHalfZRange?0:1}prepareLightSpecificDefines(e,t){e["DIRLIGHT"+t]=!0}}N([H()],Qr.prototype,"shadowFrustumSize",null);N([H()],Qr.prototype,"shadowOrthoScale",null);N([H()],Qr.prototype,"autoUpdateExtends",void 0);N([H()],Qr.prototype,"autoCalcShadowZBounds",void 0);N([H("orthoLeft")],Qr.prototype,"_orthoLeft",void 0);N([H("orthoRight")],Qr.prototype,"_orthoRight",void 0);N([H("orthoTop")],Qr.prototype,"_orthoTop",void 0);N([H("orthoBottom")],Qr.prototype,"_orthoBottom",void 0);Tt("BABYLON.DirectionalLight",Qr);class oV extends zb{get drawWrapper(){return this._postProcessDrawWrapper}constructor(e,t,i){super(e,t),this.sourceSamplingMode=2,this.depthReadOnly=!1,this.stencilReadOnly=!1,this.disableColorWrite=!1,this.drawBackFace=!1,this.depthTest=!0,this.postProcess=i,this._postProcessDrawWrapper=this.postProcess.drawWrapper,this.outputTexture=this._frameGraph.textureManager.createDanglingHandle(),this.outputDepthAttachmentTexture=this._frameGraph.textureManager.createDanglingHandle()}isReady(){return this.postProcess.isReady()}record(e=!1,t,i){if(this.sourceTexture===void 0&&this.targetTexture===void 0)throw new Error(`FrameGraphPostProcessTask "${this.name}": sourceTexture or targetTexture is required`);const s=this.sourceTexture!==void 0?this._frameGraph.textureManager.getTextureCreationOptions(this.sourceTexture):void 0;if(s&&(s.options.samples=1),this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture,this.targetTexture,this.name,s),this.depthAttachmentTexture!==void 0&&this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthAttachmentTexture,this.depthAttachmentTexture),s){const o=this._frameGraph.textureManager.getTextureAbsoluteDimensions(s);this._sourceWidth=o.width,this._sourceHeight=o.height}const r=this._frameGraph.textureManager.getTextureDescription(this.outputTexture);this._outputWidth=r.size.width,this._outputHeight=r.size.height;const a=this._frameGraph.addRenderPass(this.name);if(a.depthReadOnly=this.depthReadOnly,a.stencilReadOnly=this.stencilReadOnly,a.addDependencies(this.sourceTexture),a.setRenderTarget(this.outputTexture),a.setRenderTargetDepth(this.depthAttachmentTexture),a.setExecuteFunc(o=>{this.sourceTexture!==void 0&&o.setTextureSamplingMode(this.sourceTexture,this.sourceSamplingMode),t?.(o),this.viewport&&o.setViewport(this.viewport),o.applyFullScreenEffect(this._postProcessDrawWrapper,()=>{this.sourceTexture!==void 0&&o.bindTextureHandle(this._postProcessDrawWrapper.effect,"textureSampler",this.sourceTexture),i?.(o),this.postProcess.bind()},this.stencilState,this.disableColorWrite,this.drawBackFace,this.depthTest,this.viewport!==void 0)}),!e){const o=this._frameGraph.addRenderPass(this.name+"_disabled",!0);o.depthReadOnly=this.depthReadOnly,o.stencilReadOnly=this.stencilReadOnly,o.addDependencies(this.sourceTexture),o.setRenderTarget(this.outputTexture),o.setRenderTargetDepth(this.depthAttachmentTexture),o.setExecuteFunc(c=>
757{this.sourceTexture!==void 0&&(this.viewport&&c.setViewport(this.viewport),c.copyTexture(this.sourceTexture,void 0,this.viewport!==void 0))})}return a}dispose(){this.postProcess.dispose(),super.dispose()}}function lV(n){return n.width!==void 0}class cV extends aV{static IsCascadedShadowGenerator(e){return e.numCascades!==void 0}get numCascades(){return this._numCascades}set numCascades(e){e!==this._numCascades&&(this._numCascades=e,this._setupShadowGenerator())}get debug(){return this._debug}set debug(e){e!==this._debug&&(this._debug=e,this._shadowGenerator&&(this._shadowGenerator.debug=e))}get stabilizeCascades(){return this._stabilizeCascades}set stabilizeCascades(e){e!==this._stabilizeCascades&&(this._stabilizeCascades=e,this._shadowGenerator&&(this._shadowGenerator.stabilizeCascades=e))}get lambda(){return this._lambda}set lambda(e){e!==this._lambda&&(this._lambda=e,this._shadowGenerator&&(this._shadowGenerator.lambda=e))}get cascadeBlendPercentage(){return this._cascadeBlendPercentage}set cascadeBlendPercentage(e){e!==this._cascadeBlendPercentage&&(this._cascadeBlendPercentage=e,this._shadowGenerator&&(this._shadowGenerator.cascadeBlendPercentage=e))}get depthClamp(){return this._depthClamp}set depthClamp(e){e!==this._depthClamp&&(this._depthClamp=e,this._shadowGenerator&&(this._shadowGenerator.depthClamp=e))}get autoCalcDepthBounds(){return this._autoCalcDepthBounds}set autoCalcDepthBounds(e){if(e===this._autoCalcDepthBounds)return;this._autoCalcDepthBounds=e,this._currentAutoCalcDepthBoundsCounter=this._autoCalcDepthBoundsRefreshRate,e||this._shadowGenerator?.setMinMaxDistance(0,1);const t=this.passes;for(let i=0;i<t.length-1;++i)t[i].disabled=!e}get autoCalcDepthBoundsRefreshRate(){return this._autoCalcDepthBoundsRefreshRate}set autoCalcDepthBoundsRefreshRate(e){this._autoCalcDepthBoundsRefreshRate=e,this._currentAutoCalcDepthBoundsCounter=this._autoCalcDepthBoundsRefreshRate}get shadowMaxZ(){return this._shadowMaxZ}set shadowMaxZ(e){e!==this._shadowMaxZ&&(this._shadowMaxZ=e,this._shadowGenerator&&(this._shadowGenerator.shadowMaxZ=e))}constructor(e,t){super(e,t),this.depthTextureType=0,this._numCascades=Di.DEFAULT_CASCADES_COUNT,this._debug=!1,this._stabilizeCascades=!1,this._lambda=.5,this._cascadeBlendPercentage=.1,this._depthClamp=!0,this._autoCalcDepthBounds=!1,this._currentAutoCalcDepthBoundsCounter=0,this._autoCalcDepthBoundsRefreshRate=1,this._shadowMaxZ=1e4,this._thinMinMaxReducer=new sI(t.scene),this._thinMinMaxReducer.onAfterReductionPerformed.add(i=>{if(!this._shadowGenerator)return;const s=this.camera;let r=i.min,a=i.max;if(r>=a)r=0,a=1;else if(s&&this.depthTextureType!==0){if(this.depthTextureType===2){const u=this._frameGraph.engine,d=s.getProjectionMatrix(),f=d.m[10],g=d.m[14];u.isNDCHalfZRange||(r=r*2-1,a=a*2-1),r=g/(r-f),a=g/(a-f)}const o=s.minZ,c=s.maxZ;r=(r-o)/(c-o),a=(a-o)/(c-o)}(r!==this._shadowGenerator.minDistance||a!==this._shadowGenerator.maxDistance)&&this._shadowGenerator.setMinMaxDistance(r,a)})}_createShadowGenerator(){if(!(this.light instanceof Qr))throw new Error(`FrameGraphCascadedShadowGeneratorTask ${this.name}: the CSM shadow generator only supports directional lights.`);this._shadowGenerator=new Di(this.mapSize,this.light,this.useFloat32TextureType,this.camera,this.useRedTextureFormat),this._shadowGenerator.numCascades=this._numCascades}_setupShadowGenerator(){super._setupShadowGenerator();const e=this._shadowGenerator;e!==void 0&&(e.debug=this._debug,e.stabilizeCascades=this._stabilizeCascades,e.lambda=this._lambda,e.cascadeBlendPercentage=this._cascadeBlendPercentage,e.depthClamp=this._depthClamp,e.shadowMaxZ=this._shadowMaxZ)}record(){if(this.light===void 0||this.objectList===void 0||this.camera===void 0)throw new Error(`FrameGraphCascadedShadowGeneratorTask ${this.name}: light, objectList and camera are required`);if(this.depthTexture!==void 0){const e=this._frameGraph.textureManager.getTextureCreationOptions(this.depthTexture),t=e.sizeIsPercentage?this._frameGraph.textureManager.getAbsoluteDimensions(e.size):lV(e.size)?e.size:{width:e.size,height:e.size},i=t.width,s=t.height;e.sizeIsPercentage=!1,e.options.formats=[7],e.options.samples=1,this._thinMinMaxReducer.setTextureDimensions(i,s,this.depthTextureType);const r=this._thinMinMaxReducer.reductionSteps;let a;this._frameGraph.addPass(`${this.name}
757 Before Min Max Reduction`).setExecuteFunc(o=>{o.pushDebugGroup("Min Max Reduction")});for(let o=0;o<r.length-1;++o){const c=r[o];e.size={width:r[o+1].textureWidth,height:r[o+1].textureHeight};const u=new oV(c.name,this._frameGraph,c);u.sourceTexture=o==0?this.depthTexture:a,u.sourceSamplingMode=1,u.targetTexture=this._frameGraph.textureManager.createRenderTargetTexture(`${this.name} ${c.name}`,e),u.record(!0),a=u.outputTexture}this._frameGraph.addPass(`${this.name} After Min Max Reduction`).setExecuteFunc(o=>{if(o.popDebugGroup(),this._autoCalcDepthBounds&&this._currentAutoCalcDepthBoundsCounter>=0){if(++this._currentAutoCalcDepthBoundsCounter>=this._autoCalcDepthBoundsRefreshRate){const c=o.getTextureFromHandle(a);c&&this._thinMinMaxReducer.readMinMax(c)}this._currentAutoCalcDepthBoundsCounter%=this._autoCalcDepthBoundsRefreshRate,this._autoCalcDepthBoundsRefreshRate===0&&(this._currentAutoCalcDepthBoundsCounter=-1)}})}super.record()}dispose(){super.dispose(),this._thinMinMaxReducer.dispose()}}class iE extends zb{get camera(){return this._camera}set camera(e){this._camera=e,this._renderer.activeCamera=this.camera}get disableImageProcessing(){return this._disableImageProcessing}set disableImageProcessing(e){e!==this._disableImageProcessing&&(this._disableImageProcessing=e,this._renderer.disableImageProcessing=e)}get renderParticles(){return this._renderParticles}set renderParticles(e){e!==this._renderParticles&&(this._renderParticles=e,this._renderer.renderParticles=e)}get renderSprites(){return this._renderSprites}set renderSprites(e){e!==this._renderSprites&&(this._renderSprites=e,this._renderer.renderSprites=e)}get forceLayerMaskCheck(){return this._forceLayerMaskCheck}set forceLayerMaskCheck(e){e!==this._forceLayerMaskCheck&&(this._forceLayerMaskCheck=e,this._renderer.forceLayerMaskCheck=e)}get enableBoundingBoxRendering(){return this._enableBoundingBoxRendering}set enableBoundingBoxRendering(e){e!==this._enableBoundingBoxRendering&&(this._enableBoundingBoxRendering=e,this._renderer.enableBoundingBoxRendering=e)}get enableOutlineRendering(){return this._enableOutlineRendering}set enableOutlineRendering(e){e!==this._enableOutlineRendering&&(this._enableOutlineRendering=e,this._renderer.enableOutlineRendering=e)}get objectRenderer(){return this._renderer}get name(){return this._name}set name(e){this._name=e,this._renderer&&(this._renderer.name=e)}constructor(e,t,i,s,r){super(e,t),this.shadowGenerators=[],this.depthTest=!0,this.depthWrite=!0,this.disableShadows=!1,this._disableImageProcessing=!1,this.isMainObjectRenderer=!1,this._renderParticles=!0,this._renderSprites=!0,this._forceLayerMaskCheck=!0,this._enableBoundingBoxRendering=!0,this._enableOutlineRendering=!0,this.resolveMSAAColors=!0,this.resolveMSAADepth=!1,this._onBeforeRenderObservable=null,this._onAfterRenderObservable=null,this._externalObjectRenderer=!1,this._scene=i,this._engine=i.getEngine(),this._externalObjectRenderer=!!r,this._renderer=r??new Or(e,i,s),this.name=e,this._renderer.disableImageProcessing=this._disableImageProcessing,this._renderer.renderParticles=this._renderParticles,this._renderer.renderSprites=this._renderSprites,this._renderer.enableBoundingBoxRendering=this._enableBoundingBoxRendering,this._renderer.forceLayerMaskCheck=this._forceLayerMaskCheck,this._externalObjectRenderer||this._renderer.onBeforeRenderingManagerRenderObservable.add(()=>{this._renderer.options.doNotChangeAspectRatio||i.updateTransformMatrix(!0)}),this.outputTexture=this._frameGraph.textureManager.createDanglingHandle(),this.outputDepthTexture=this._frameGraph.textureManager.createDanglingHandle()}isReady(){return this._renderer.isReadyForRendering(this._textureWidth,this._textureHeight)}record(e=!1,t){if(this.targetTexture===void 0||this.objectList===void 0)throw new Error(`FrameGraphObjectRendererTask ${this.name}: targetTexture and objectList are required`);this._renderer.renderList=this.objectList.meshes,this._renderer.particleSystemList=this.objectList.particleSystems;const i=Array.isArray(this.targetTexture)?this.targetTexture:[this.targetTexture],s=this._frameGraph.textureManager.getTextureDescription(i[0]);let r=!1;if(this.depthTexture!==void 0){if(this.depthTexture===FT&&(i[0]!==wT||i.length>1))throw new Error(`FrameGraphObjectRendererTask ${this.name}: the back buffer color texture is the only color texture allowed when the depth is the back buffer depth/stencil`);if(this.depthTexture!==FT&&i[0]===wT)throw new Error(`FrameGraphObjectRendererTask ${this.name}: the back buffer depth/stencil texture is the only depth texture allowed when the target is the back buffer color`);if(this._frameGraph.textureManager.getTextureDescription(this.depthTexture).options.samples!==s.options.samples)throw new Error(`FrameGraphObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);r=!0}this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture,i[0]),this.depthTexture!==void 0&&this._frameGraph.textureManager.resolveDanglingHandle(this.outputDepthTexture,this.depthTexture),this._textureWidth=s.size.width,this._textureHeight=s.size.height,this._setLightsForShadow();const a=this._frameGraph.addRenderPass(this.name);if(a.setRenderTarget(i),a.setRenderTargetDepth(this.depthTexture),a.setExecuteFunc(o=>{this._renderer.renderList=this.objectList.meshes,this._renderer.particleSystemList=this.objectList.particleSystems;const c=a.frameGraphRenderTarget.renderTargetWrapper;c&&(c.resolveMSAAColors=this.resolveMSAAColors,c.resolveMSAADepth=this.resolveMSAADepth);const u=this.getBoundingBoxRenderer?.(),d=u&&u.renderList.length>0?u.renderList.data.slice():[];u&&(d.length=u.renderList.length),o.setDepthStates(this.depthTest&&r,this.depthWrite&&r);const f=this._renderer.activeCamera;if(f&&f.cameraRigMode!==0&&!f._renderingMultiview){for(let g=0;g<f._rigCameras.length;g++){const m=f._rigCameras[g];m.rigParent=void 0,this._renderer.activeCamera=m,o.render(this._renderer,this._textureWidth,this._textureHeight),m.rigParent=f}this._renderer.activeCamera=f}else o.render(this._renderer,this._textureWidth,this._textureHeight);t?.(o),u&&(u.renderList.data=d,u.renderList.length=d.length)}),!e){const o=this._frameGraph.addRenderPass(this.name+"_disabled",!0);o.setRenderTarget(i),o.setRenderTargetDepth(this.depthTexture),o.setExecuteFunc(c=>{})}return a}dispose(){this._renderer.onBeforeRenderObservable.remove(this._onBeforeRenderObservable),this._renderer.onAfterRenderObservable.remove(this._onAfterRenderObservable),this._externalObjectRenderer||this._renderer.dispose(),super.dispose()}_setLightsForShadow(){const e=new Set,t=new Map;if(this.shadowGenerators)for(const i of this.shadowGenerators){const s=i.shadowGenerator,r=s.getLight();r.isEnabled()&&r.shadowEnabled&&(e.add(r),cV.IsCascadedShadowGenerator(i)?r._shadowGenerators.set(i.camera,s):r._shadowGenerators.set(null,s))}this._renderer.onBeforeRenderObservable.remove(this._onBeforeRenderObservable),this._onBeforeRenderObservable=this._renderer.onBeforeRenderObservable.add(()=>{for(let i=0;i<this._scene.lights.length;i++){const s=this._scene.lights[i];s.setShadowProjectionMatrix&&(t.set(s,s.shadowEnabled),s.shadowEnabled=!this.disableShadows&&e.has(s))}}),this._renderer.onAfterRenderObservable.remove(this._onAfterRenderObservable),this._onAfterRenderObservable=this._renderer.onAfterRenderObservable.add(()=>{for(let i=0;i<this._scene.lights.length;i++){const s=this._scene.lights[i];s.setShadowProjectionMatrix&&(s.shadowEnabled=t.get(s))}})}}const hV=new rt,uV=new rt;var sE;(function(n){n[n.BackwardCompatible=0]="BackwardCompatible",n[n.Intermediate=1]="Intermediate",n[n.Aggressive=2]="Aggressive"})(sE||(sE={}));class Pt{static DefaultMaterialFactory(e){throw We("StandardMaterial")}static CollisionCoordinatorFactory(){throw We("DefaultCollisionCoordinator")}get clearColor(){return this._clearColor}set clearColor(e){e!==this._clearColor&&(this._clearColor=e,this.onClearColorChangedObservable.notifyObservers(this._clearColor))}get imageProcessingConfiguration(){return this._imageProcessingConfiguration}get performancePriority(){return this._performancePriority}set performancePriority(e){if(e!==this._performancePriority){switch(this._performancePriority=e,e){case 0:this.skipFrustumClipping=!1,this._renderingManager.maintainStateBetweenFrames=!1,this.skipPointerMovePicking=!1,this.autoClear=!0;break;case 1:this.skipFrustumClipping=!1,this._renderingManager.maintainStateBetweenFrames=!1,this.skipPointerMovePicking=!0,this.autoClear=!1;break;case 2:this.skipFrustumClipping=!0,this._renderingManager.maintainStateBetweenFrames=!0,this.skipPointerMovePicking=!0,this.autoClear=!1;break}this.onScenePerformancePriorityChangedObservable.notifyObservers(e)}}set forceWireframe(e){this._forceWireframe!==e&&(this._forceWireframe=e,this.markAllMaterialsAsDirty(16))}get forceWireframe(){return this._forceWireframe}set skipFrustumClipping(e){this._skipFrustumClipping!==e&&(this._skipFrustumClipping=e)}get skipFrustumClipping(){return this._skipFrustumClipping}set forcePointsCloud(e){this._forcePointsCloud!==e&&(this._forcePointsCloud=e,this.markAllMaterialsAsDirty(16))}get forcePointsCloud(){return this._forcePointsCloud}get environmentTexture(){return this._environmentTexture}set environmentTexture(e){this._environmentTexture!==e&&(this._environmentTexture=e,this.onEnvironmentTextureChangedObservable.notifyObservers(e),this.markAllMaterialsAsDirty(1))}getNodes(){let e=[];e=e.concat(this.meshes),e=e.concat(this.lights),e=e.concat(this.cameras),e=e.concat(this.transformNodes);for(const t of this.skeletons)e=e.concat(t.bones);return e}get animationPropertiesOverride(){return this._animationPropertiesOverride}set animationPropertiesOverride(e){this._animationPropertiesOverride=e}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}set beforeRender(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),e&&(this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e))}set afterRender(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),e&&(this._onAfterRenderObserver=this.onAfterRenderObservable.add(e))}set beforeCameraRender(e){this._onBeforeCameraRenderObserver&&this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=this.onBeforeCameraRenderObservable.add(e)}set afterCameraRender(e){this._onAfterCameraRenderObserver&&this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=this.onAfterCameraRenderObservable.add(e)}get pointerDownPredicate(){return this._pointerPickingConfiguration.pointerDownPredicate}set pointerDownPredicate(e){this._pointerPickingConfiguration.pointerDownPredicate=e}get pointerUpPredicate(){return this._pointerPickingConfiguration.pointerUpPredicate}set pointerUpPredicate(e){this._pointerPickingConfiguration.pointerUpPredicate=e}get pointerMovePredicate(){return this._pointerPickingConfiguration.pointerMovePredicate}set pointerMovePredicate(e){this._pointerPickingConfiguration.pointerMovePredicate=e}get pointerDownFastCheck(){return this._pointerPickingConfiguration.pointerDownFastCheck}set pointerDownFastCheck(e){this._pointerPickingConfiguration.pointerDownFastCheck=e}get pointerUpFastCheck(){return this._pointerPickingConfiguration.pointerUpFastCheck}set pointerUpFastCheck(e){this._pointerPickingConfiguration.pointerUpFastCheck=e}get pointerMoveFastCheck(){return this._pointerPickingConfiguration.pointerMoveFastCheck}set pointerMoveFastCheck(e){this._pointerPickingConfiguration.pointerMoveFastCheck=e}get skipPointerMovePicking(){return this._pointerPickingConfiguration.skipPointerMovePicking}set skipPointerMovePicking(e){this._pointerPickingConfiguration.skipPointerMovePicking=e}get skipPointerDownPicking(){return this._pointerPickingConfiguration.skipPointerDownPicking}set skipPointerDownPicking(e){this._pointerPickingConfiguration.skipPointerDownPicking=e}get skipPointerUpPicking(){return this._pointerPickingConfiguration.skipPointerUpPicking}set skipPointerUpPicking(e){this._pointerPickingConfiguration.skipPointerUpPicking=e}get unTranslatedPointer(){return this._inputManager.unTranslatedPointer}static get DragMovementThreshold(){return oi.DragMovementThreshold}static set DragMovementThreshold(e){oi.DragMovementThreshold=e}static get LongPressDelay(){return oi.LongPressDelay}static set LongPressDelay(e){oi.LongPressDelay=e}static get DoubleClickDelay(){return oi.DoubleClickDelay}static set DoubleClickDelay(e){oi.DoubleClickDelay=e}static get ExclusiveDoubleClickMode(){return oi.ExclusiveDoubleClickMode}static set ExclusiveDoubleClickMode(e){oi.ExclusiveDoubleClickMode=e}get _eyePosition(){return this._forcedViewPosition??this.activeCamera?.globalPosition??T.ZeroReadOnly}bindEyePosition(e,t="vEyePosition",i=!1){const s=this._eyePosition,r=this.useRightHandedSystem===(this._mirroredCameraPosition!=null),a=this.floatingOriginOffset,o=hV.set(s.x,s.y,s.z,r?-1:1),c=o.subtractFromFloatsToRef(a.x,a.y,a.z,0,uV);return e&&(i?e.setFloat3(t,c.x,c.y,c.z):e.setVector4(t,c)),o}finalizeSceneUbo(){const e=this.getSceneUniformBuffer(),t=this.bindEyePosition(null),i=this.floatingOriginOffset;return e.updateFloat4("vEyePosition",t.x-i.x,t.y-i.y,t.z-i.z,t.w),e.update(
vendor: 4,193 bytes, line 757
757),e}set useRightHandedSystem(e){this._useRightHandedSystem!==e&&(this._useRightHandedSystem=e,this.markAllMaterialsAsDirty(16))}get useRightHandedSystem(){return this._useRightHandedSystem}setStepId(e){this._currentStepId=e}getStepId(){return this._currentStepId}getInternalStep(){return this._currentInternalStep}set fogEnabled(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAllMaterialsAsDirty(16))}get fogEnabled(){return this._fogEnabled}set fogMode(e){this._fogMode!==e&&(this._fogMode=e,this.markAllMaterialsAsDirty(16))}get fogMode(){return this._fogMode}get prePass(){return!!this.prePassRenderer&&this.prePassRenderer.defaultRT.enabled}set shadowsEnabled(e){this._shadowsEnabled!==e&&(this._shadowsEnabled=e,this.markAllMaterialsAsDirty(2))}get shadowsEnabled(){return this._shadowsEnabled}set lightsEnabled(e){this._lightsEnabled!==e&&(this._lightsEnabled=e,this.markAllMaterialsAsDirty(2))}get lightsEnabled(){return this._lightsEnabled}get activeCameras(){return this._activeCameras}set activeCameras(e){this._unObserveActiveCameras&&(this._unObserveActiveCameras(),this._unObserveActiveCameras=null),e&&(this._unObserveActiveCameras=dC(e,()=>{this.onActiveCamerasChanged.notifyObservers(this)})),this._activeCameras=e}get activeCamera(){return this._activeCamera}set activeCamera(e){e!==this._activeCamera&&(this._activeCamera=e,this.onActiveCameraChanged.notifyObservers(this))}get _hasDefaultMaterial(){return Pt.DefaultMaterialFactory!==Pt._OriginalDefaultMaterialFactory}get defaultMaterial(){return this._defaultMaterial||(this._defaultMaterial=Pt.DefaultMaterialFactory(this)),this._defaultMaterial}set defaultMaterial(e){this._defaultMaterial=e}set texturesEnabled(e){this._texturesEnabled!==e&&(this._texturesEnabled=e,this.markAllMaterialsAsDirty(1))}get texturesEnabled(){return this._texturesEnabled}get frameGraph(){return this._frameGraph}set frameGraph(e){if(this._frameGraph){this._frameGraph=e,e||(this.customRenderFunction=this._currentCustomRenderFunction);return}this._frameGraph=e,e&&(this._currentCustomRenderFunction=this.customRenderFunction,this.customRenderFunction=this._renderWithFrameGraph,this.activeCamera=null)}set skeletonsEnabled(e){this._skeletonsEnabled!==e&&(this._skeletonsEnabled=e,this.markAllMaterialsAsDirty(8))}get skeletonsEnabled(){return this._skeletonsEnabled}get collisionCoordinator(){return this._collisionCoordinator||(this._collisionCoordinator=Pt.CollisionCoordinatorFactory(),this._collisionCoordinator.init(this)),this._collisionCoordinator}get renderingManager(){return this._renderingManager}get frustumPlanes(){return this._frustumPlanes}_registerTransientComponents(){if(this._transientComponents.length>0){for(const e of this._transientComponents)e.register();this._transientComponents.length=0}}_addComponent(e){this._components.push(e),this._transientComponents.push(e);const t=e;t.addFromContainer&&t.serialize&&this._serializableComponents.push(t)}_getComponent(e){for(const t of this._components)if(t.name===e)return t;return null}get uniqueId(){return this._uniqueId}constructor(e,t){this._inputManager=new oi(this),this.cameraToUseForPointers=null,this._isScene=!0,this._blockEntityCollection=!1,this.autoClear=!0,this.autoClearDepthAndStencil=!0,this._clearColor=new Ze(.2,.2,.3,1),this.onClearColorChangedObservable=new le,this.ambientColor=new Ne(0,0,0),this.environmentIntensity=1,this.iblIntensity=1,this._performancePriority=0,this.onScenePerformancePriorityChangedObservable=new le,this._forceWireframe=!1,this._skipFrustumClipping=!1,this._forcePointsCloud=!1,this.rootNodes=[],this.cameras=[],this.lights=[],this.meshes=[],this.skeletons=[],this.particleSystems=[],this.animations=[],this.animationGroups=[],this.multiMaterials=[],this.materials=[],this.morphTargetManagers=[],this.geometries=[],this.transformNodes=[],this.actionManagers=[],this.objectRenderers=[],this.textures=[],this._environmentTexture=null,this.postProcesses=[],this.effectLayers=[],this.sounds=null,this.layers=[],this.lensFlareSystems=[],this.proceduralTextures=[],this.animationsEnabled=!0,this._animationPropertiesOverride=null,this.useConstantAnimationDeltaTime=!1,this.constantlyUpdateMeshUnderPointer=!1,this.hoverCurs
vendor: 9,919 bytes, line 757
757or="pointer",this.defaultCursor="",this.doNotHandleCursors=!1,this.preventDefaultOnPointerDown=!0,this.preventDefaultOnPointerUp=!0,this.metadata=null,this.reservedDataStore=null,this.disableOfflineSupportExceptionRules=[],this.onDisposeObservable=new le,this._onDisposeObserver=null,this.onBeforeRenderObservable=new le,this._onBeforeRenderObserver=null,this.onAfterRenderObservable=new le,this.onAfterRenderCameraObservable=new le,this._onAfterRenderObserver=null,this.onBeforeAnimationsObservable=new le,this.onAfterAnimationsObservable=new le,this.onBeforeDrawPhaseObservable=new le,this.onAfterDrawPhaseObservable=new le,this.onReadyObservable=new le,this.onBeforeCameraRenderObservable=new le,this._onBeforeCameraRenderObserver=null,this.onAfterCameraRenderObservable=new le,this._onAfterCameraRenderObserver=null,this.onBeforeActiveMeshesEvaluationObservable=new le,this.onAfterActiveMeshesEvaluationObservable=new le,this.onBeforeParticlesRenderingObservable=new le,this.onAfterParticlesRenderingObservable=new le,this.onDataLoadedObservable=new le,this.onNewCameraAddedObservable=new le,this.onCameraRemovedObservable=new le,this.onNewLightAddedObservable=new le,this.onLightRemovedObservable=new le,this.onNewGeometryAddedObservable=new le,this.onGeometryRemovedObservable=new le,this.onNewTransformNodeAddedObservable=new le,this.onTransformNodeRemovedObservable=new le,this.onNewMeshAddedObservable=new le,this.onMeshRemovedObservable=new le,this.onNewSkeletonAddedObservable=new le,this.onSkeletonRemovedObservable=new le,this.onNewParticleSystemAddedObservable=new le,this.onParticleSystemRemovedObservable=new le,this.onNewAnimationGroupAddedObservable=new le,this.onAnimationGroupRemovedObservable=new le,this.onNewMaterialAddedObservable=new le,this.onNewMultiMaterialAddedObservable=new le,this.onMaterialRemovedObservable=new le,this.onMultiMaterialRemovedObservable=new le,this.onNewTextureAddedObservable=new le,this.onTextureRemovedObservable=new le,this.onNewFrameGraphAddedObservable=new le,this.onFrameGraphRemovedObservable=new le,this.onNewObjectRendererAddedObservable=new le,this.onObjectRendererRemovedObservable=new le,this.onNewPostProcessAddedObservable=new le,this.onPostProcessRemovedObservable=new le,this.onNewEffectLayerAddedObservable=new le,this.onEffectLayerRemovedObservable=new le,this.onBeforeRenderTargetsRenderObservable=new le,this.onAfterRenderTargetsRenderObservable=new le,this.onBeforeStepObservable=new le,this.onAfterStepObservable=new le,this.onActiveCameraChanged=new le,this.onActiveCamerasChanged=new le,this.onBeforeRenderingGroupObservable=new le,this.onAfterRenderingGroupObservable=new le,this.onMeshImportedObservable=new le,this.onAnimationFileImportedObservable=new le,this.onEnvironmentTextureChangedObservable=new le,this.onMeshUnderPointerUpdatedObservable=new le,this._registeredForLateAnimationBindings=new Do(256),this._pointerPickingConfiguration=new C3,this.onPrePointerObservable=new le,this.onPointerObservable=new le,this.onPreKeyboardObservable=new le,this.onKeyboardObservable=new le,this._useRightHandedSystem=!1,this._timeAccumulator=0,this._currentStepId=0,this._currentInternalStep=0,this._fogEnabled=!0,this._fogMode=Pt.FOGMODE_NONE,this.fogColor=new Ne(.2,.2,.3),this.fogDensity=.1,this.fogStart=0,this.fogEnd=1e3,this.needsPreviousWorldMatrices=!1,this._shadowsEnabled=!0,this._lightsEnabled=!0,this._unObserveActiveCameras=null,this._texturesEnabled=!0,this._frameGraph=null,this.frameGraphs=[],this.physicsEnabled=!0,this.particlesEnabled=!0,this.spritesEnabled=!0,this._skeletonsEnabled=!0,this.lensFlaresEnabled=!0,this.collisionsEnabled=!0,this.gravity=new T(0,-9.807,0),this.postProcessesEnabled=!0,this.renderTargetsEnabled=!0,this.dumpNextRenderTargets=!1,this.customRenderTargets=[],this.importedMeshesFiles=[],this.probesEnabled=!0,this._meshesForIntersections=new Do(256),this.proceduralTexturesEnabled=!0,this._totalVertices=new yn,this._activeIndices=new yn,this._activeParticles=new yn,this._activeBones=new yn,this._animationTime=0,this.animationTimeScale=1,this._renderId=0,this._frameId=0,this._executeWhenReadyTimeoutId=null,this._intermediateRendering=!1,this._defaultFrameBufferCleared=!1,this._viewUpdateFlag=-1,this._projectionUpdateFlag=-1,this._toBeDisposed=new Array(256),this._activeRequests=new Array,this._pendingData=[],this._isDisposed=!1,this.dispatchAllSubMeshesOfActiveMeshes=!1,this._activeMeshes=new Yi(256),this._processedMaterials=new Yi(256),this._renderTargets=new Do(256),this._materialsRenderTargets=new Do(256),this._activeParticleSystems=new Yi(256),this._activeSkeletons=new Do(32),this._softwareSkinnedMeshes=new Do(32),this._activeAnimatables=new Array,this._transformMatrix=W.Zero(),this.requireLightSorting=!1,this._components=[],this._serializableComponents=[],this._transientComponents=[],this._beforeCameraUpdateStage=ni.Create(),this._beforeClearStage=ni.Create(),this._beforeRenderTargetClearStage=ni.Create(),this._gatherRenderTargetsStage=ni.Create(),this._gatherActiveCameraRenderTargetsStage=ni.Create(),this._isReadyForMeshStage=ni.Create(),this._beforeEvaluateActiveMeshStage=ni.Create(),this._evaluateSubMeshStage=ni.Create(),this._preActiveMeshStage=ni.Create(),this._cameraDrawRenderTargetStage=ni.Create(),this._beforeCameraDrawStage=ni.Create(),this._beforeRenderTargetDrawStage=ni.Create(),this._beforeRenderingGroupDrawStage=ni.Create(),this._beforeRenderingMeshStage=ni.Create(),this._afterRenderingMeshStage=ni.Create(),this._afterRenderingGroupDrawStage=ni.Create(),this._afterCameraDrawStage=ni.Create(),this._afterCameraPostProcessStage=ni.Create(),this._afterRenderTargetDrawStage=ni.Create(),this._afterRenderTargetPostProcessStage=ni.Create(),this._afterRenderStage=ni.Create(),this._pointerMoveStage=ni.Create(),this._pointerDownStage=ni.Create(),this._pointerUpStage=ni.Create(),this._geometriesByUniqueId=null,this._uniqueId=0,this._defaultMeshCandidates={data:[],length:0},this._defaultSubMeshCandidates={data:[],length:0},this._floatingOriginScene=void 0,this._preventFreeActiveMeshesAndRenderingGroups=!1,this._activeMeshesFrozen=!1,this._activeMeshesFrozenButKeepClipping=!1,this._skipEvaluateActiveMeshesCompletely=!1,this._freezeActiveMeshesCancel=null,this._useCurrentFrameBuffer=!1,this._allowPostProcessClearColor=!0,this.getDeterministicFrameTime=()=>this._engine.getTimeStep(),this._getFloatingOriginScene=()=>this._floatingOriginScene,this._registeredActions=0,this._blockMaterialDirtyMechanism=!1,this._perfCollector=null,this.activeCameras=[],this._uniqueId=this.getUniqueId();const i={useGeometryUniqueIdsMap:!0,useMaterialMeshMap:!0,useClonedMeshMap:!0,virtual:!1,...t};e=this._engine=e||Ke.LastCreatedEngine,i.virtual?e._virtualScenes.push(this):(Ke._LastCreatedScene=this,e.scenes.push(this)),(e.getCreationOptions().useLargeWorldRendering||t?.useFloatingOrigin)&&(Vk(),this._floatingOriginScene=this),this._uid=null,this._renderingManager=new zi(this),cf&&(this.postProcessManager=new cf(this)),Gi()&&this.attachControl(),this._createUbo(),ft&&(this._imageProcessingConfiguration=new ft),this.setDefaultCandidateProviders(),i.useGeometryUniqueIdsMap&&(this._geometriesByUniqueId={}),this.useMaterialMeshMap=i.useMaterialMeshMap,this.useClonedMeshMap=i.useClonedMeshMap,(!t||!t.virtual)&&e.onNewSceneAddedObservable.notifyObservers(this)}getClassName(){return"Scene"}_getDefaultMeshCandidates(){return this._defaultMeshCandidates.data=this.meshes,this._defaultMeshCandidates.length=this.meshes.length,this._defaultMeshCandidates}_getDefaultSubMeshCandidates(e){return this._defaultSubMeshCandidates.data=e.subMeshes,this._defaultSubMeshCandidates.length=e.subMeshes.length,this._defaultSubMeshCandidates}setDefaultCandidateProviders(){this.getActiveMeshCandidates=()=>this._getDefaultMeshCandidates(),this.getActiveSubMeshCandidates=e=>this._getDefaultSubMeshCandidates(e),this.getIntersectingSubMeshCandidates=(e,t)=>this._getDefaultSubMeshCandidates(e),this.getCollidingSubMeshCandidates=(e,t)=>this._getDefaultSubMeshCandidates(e)}get meshUnderPointer(){return this._inputManager.meshUnderPointer}get pointerX(){return this._inputManager.pointerX}set pointerX(e){this._inputManager.pointerX=e}get pointerY(){return this._inputManager.pointerY}set pointerY(e){this._inputManager.pointerY=e}getCachedMaterial(){return this._cachedMaterial}getCachedEffect(){return this._cachedEffect}getCachedVisibility(){return this._cachedVisibility}isCachedMaterialInvalid(e,t,i=1){return this._cachedEffect!==t||this._cachedMaterial!==e||this._cachedVisibility!==i}getEngine(){return this._engine}getTotalVertices(){return this._totalVertices.current}get totalVerticesPerfCounter(){return this._totalVertices}getActiveIndices(){return this._activeIndices.current}get totalActiveIndicesPerfCounter(){return this._activeIndices}getActiveParticles(){return this._activeParticles.current}get activeParticlesPerfCounter(){return this._activeParticles}getActiveBones(){return this._activeBones.current}get activeBonesPerfCounter(){return this._activeBones}getActiveMeshes(){return this._activeMeshes}getAnimationRatio(){return this._animationRatio!==void 0?this._animationRatio:1}getRenderId(){return this._renderId}getFrameId(){return this._frameId}incrementRenderId(){this._renderId++}_createUbo(){this.setSceneUniformBuffer(this.createSceneUniformBuffer())}simulatePointerMove(e,t){return this._inputManager.simulatePointerMove(e,t),this}simulatePointerDown(e,t){return this._inputManager.simulatePointerDown(e,t),this}simulatePointerUp(e,t,i){return this._inputManager.simulatePointerUp(e,t,i),this}isPointerCaptured(e=0){return this._inputManager.isPointerCaptured(e)}attachControl(e=!0,t=!0,i=!0){this._inputManager.attachControl(e,t,i)}detachControl(){this._inputManager.detachControl()}isReady(e=!0){if(this._isDisposed)return!1;let t;const i=this.getEngine(),s=i.currentRenderPassId;i.currentRenderPassId=this.activeCamera?.renderPassId??s;let r=!0;
vendor: 17,330 bytes, line 757
757for(this._pendingData.length>0&&(r=!1),this.prePassRenderer?.update(),this.useOrderIndependentTransparency&&this.depthPeelingRenderer&&r&&(r=this.depthPeelingRenderer.isReady()),e&&(this._processedMaterials.reset(),this._materialsRenderTargets.reset()),t=0;t<this.meshes.length;t++){const a=this.meshes[t];if(!a.subMeshes||a.subMeshes.length===0)continue;if(!a.isReady(!0)){r=!1;continue}const o=a.hasThinInstances||a.getClassName()==="InstancedMesh"||a.getClassName()==="InstancedLinesMesh"||i.getCaps().instancedArrays&&a.instances.length>0;for(const u of this._isReadyForMeshStage)u.action(a,o)||(r=!1);if(!e)continue;const c=a.material||this.defaultMaterial;if(c)if(c._storeEffectOnSubMeshes)for(const u of a.subMeshes){const d=u.getMaterial();d&&d.hasRenderTargetTextures&&d.getRenderTargetTextures!=null&&this._processedMaterials.indexOf(d)===-1&&(this._processedMaterials.push(d),this._materialsRenderTargets.concatWithNoDuplicate(d.getRenderTargetTextures()))}else c.hasRenderTargetTextures&&c.getRenderTargetTextures!=null&&this._processedMaterials.indexOf(c)===-1&&(this._processedMaterials.push(c),this._materialsRenderTargets.concatWithNoDuplicate(c.getRenderTargetTextures()))}if(e)for(t=0;t<this._materialsRenderTargets.length;++t)this._materialsRenderTargets.data[t].isReadyForRendering()||(r=!1);for(t=0;t<this.geometries.length;t++)this.geometries[t].delayLoadState===2&&(r=!1);if(this.activeCameras&&this.activeCameras.length>0)for(const a of this.activeCameras)a.isReady(!0)||(r=!1);else this.activeCamera&&(this.activeCamera.isReady(!0)||(r=!1));for(const a of this.particleSystems)a.isReady()||(r=!1);if(this.layers)for(const a of this.layers)a.isReady()||(r=!1);if(this.effectLayers)for(const a of this.effectLayers)a.isLayerReady()||(r=!1);return i.areAllEffectsReady()||(r=!1),i.currentRenderPassId=s,r}resetCachedMaterial(){this._cachedMaterial=null,this._cachedEffect=null,this._cachedVisibility=null}registerBeforeRender(e){this.onBeforeRenderObservable.add(e)}unregisterBeforeRender(e){this.onBeforeRenderObservable.removeCallback(e)}registerAfterRender(e){this.onAfterRenderObservable.add(e)}unregisterAfterRender(e){this.onAfterRenderObservable.removeCallback(e)}_executeOnceBeforeRender(e){const t=()=>{e(),setTimeout(()=>{this.unregisterBeforeRender(t)})};this.registerBeforeRender(t)}executeOnceBeforeRender(e,t){t!==void 0?setTimeout(()=>{this._executeOnceBeforeRender(e)},t):this._executeOnceBeforeRender(e)}addPendingData(e){this._pendingData.push(e)}removePendingData(e){const t=this.isLoading,i=this._pendingData.indexOf(e);i!==-1&&this._pendingData.splice(i,1),t&&!this.isLoading&&this.onDataLoadedObservable.notifyObservers(this)}getWaitingItemsCount(){return this._pendingData.length}get isLoading(){return this._pendingData.length>0}executeWhenReady(e,t=!1){this.onReadyObservable.addOnce(e),this._executeWhenReadyTimeoutId===null&&this._checkIsReady(t)}async whenReadyAsync(e=!1){return await new Promise(t=>{this.executeWhenReady(()=>{t()},e)})}_checkIsReady(e=!1){if(this._registerTransientComponents(),this.isReady(e)){this.onReadyObservable.notifyObservers(this),this.onReadyObservable.clear(),this._executeWhenReadyTimeoutId=null;return}if(this._isDisposed){this.onReadyObservable.clear(),this._executeWhenReadyTimeoutId=null;return}this._executeWhenReadyTimeoutId=setTimeout(()=>{this.incrementRenderId(),this._checkIsReady(e)},100)}get animatables(){return this._activeAnimatables}resetLastAnimationTimeFrame(){this._animationTimeLast=nr.Now}getViewMatrix(){return this._viewMatrix}getProjectionMatrix(){return this._projectionMatrix}getTransformMatrix(){return this._transformMatrix}setTransformMatrix(e,t,i,s){!i&&!s&&this._multiviewSceneUbo&&(this._multiviewSceneUbo.dispose(),this._multiviewSceneUbo=null),!(this._viewUpdateFlag===e.updateFlag&&this._projectionUpdateFlag===t.updateFlag)&&(this._viewUpdateFlag=e.updateFlag,this._projectionUpdateFlag=t.updateFlag,this._viewMatrix=e,this._projectionMatrix=t,this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._frustumPlanes?Mr.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=Mr.GetPlanes(this._transformMatrix),this._multiviewSceneUbo&&this._multiviewSceneUbo.useUbo?this._updateMultiviewUbo(i,s):this._sceneUbo.useUbo&&(this._sceneUbo.updateMatrix("viewProjection",this._transformMatrix),this._sceneUbo.updateMatrix("view",this._viewMatrix),this._sceneUbo.updateMatrix("projection",this._projectionMatrix)))}getSceneUniformBuffer(){return this._multiviewSceneUbo?this._multiviewSceneUbo:this._sceneUbo}createSceneUniformBuffer(e,t){const i=new Fe(this._engine,void 0,!1,e??"scene",void 0,t);return i.addUniform("viewProjection",16),i.addUniform("view",16),i.addUniform("projection",16),i.addUniform("vEyePosition",4),i}setSceneUniformBuffer(e){this._sceneUbo=e,this._viewUpdateFlag=-1,this._projectionUpdateFlag=-1}get floatingOriginMode(){return this._floatingOriginScene!==void 0}get floatingOriginOffset(){return this.floatingOriginMode?this._eyePosition:T.ZeroReadOnly}getUniqueId(){return Vb.UniqueId}addMesh(e,t=!1){if(!this._blockEntityCollection&&(this.meshes.push(e),e._resyncLightSources(),e.parent||e._addToSceneRootNodes(),pe.SetImmediate(()=>{this.onNewMeshAddedObservable.notifyObservers(e)}),t)){const i=e.getChildMeshes();for(const s of i)this.addMesh(s)}}removeMesh(e,t=!1){const i=this.meshes.indexOf(e);if(i!==-1&&(this.meshes.splice(i,1),e.parent||e._removeFromSceneRootNodes()),this._inputManager._invalidateMesh(e),this.onMeshRemovedObservable.notifyObservers(e),t){const s=e.getChildMeshes();for(const r of s)this.removeMesh(r)}return i}addTransformNode(e){this._blockEntityCollection||e.getScene()===this&&e._indexInSceneTransformNodesArray!==-1||(e._indexInSceneTransformNodesArray=this.transformNodes.length,this.transformNodes.push(e),e.parent||e._addToSceneRootNodes(),this.onNewTransformNodeAddedObservable.notifyObservers(e))}removeTransformNode(e){const t=e._indexInSceneTransformNodesArray;if(t!==-1){if(t!==this.transformNodes.length-1){const i=this.transformNodes[this.transformNodes.length-1];this.transformNodes[t]=i,i._indexInSceneTransformNodesArray=t}e._indexInSceneTransformNodesArray=-1,this.transformNodes.pop(),e.parent||e._removeFromSceneRootNodes()}return this.onTransformNodeRemovedObservable.notifyObservers(e),t}removeSkeleton(e){const t=this.skeletons.indexOf(e);return t!==-1&&(this.skeletons.splice(t,1),this.onSkeletonRemovedObservable.notifyObservers(e),this._executeActiveContainerCleanup(this._activeSkeletons)),t}removeMorphTargetManager(e){const t=this.morphTargetManagers.indexOf(e);return t!==-1&&this.morphTargetManagers.splice(t,1),t}removeLight(e){const t=this.lights.indexOf(e);if(t!==-1){for(const i of this.meshes)i._removeLightSource(e,!1);this.lights.splice(t,1),this.sortLightsByPriority(),e.parent||e._removeFromSceneRootNodes()}return this.onLightRemovedObservable.notifyObservers(e),t}removeCamera(e){const t=this.cameras.indexOf(e);if(t!==-1&&(this.cameras.splice(t,1),e.parent||e._removeFromSceneRootNodes()),this.activeCameras){const i=this.activeCameras.indexOf(e);i!==-1&&this.activeCameras.splice(i,1)}return this.activeCamera===e&&(this.cameras.length>0?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(e),t}removeParticleSystem(e){const t=this.particleSystems.indexOf(e);return t!==-1&&(this.particleSystems.splice(t,1),this._executeActiveContainerCleanup(this._activeParticleSystems)),this.onParticleSystemRemovedObservable.notifyObservers(e),t}removeAnimation(e){const t=this.animations.indexOf(e);return t!==-1&&this.animations.splice(t,1),t}stopAnimation(e,t,i){}removeAnimationGroup(e){const t=this.animationGroups.indexOf(e);return t!==-1&&this.animationGroups.splice(t,1),this.onAnimationGroupRemovedObservable.notifyObservers(e),t}removeMultiMaterial(e){const t=this.multiMaterials.indexOf(e);return t!==-1&&this.multiMaterials.splice(t,1),this.onMultiMaterialRemovedObservable.notifyObservers(e),t}removeMaterial(e){const t=e._indexInSceneMaterialArray;if(t!==-1&&t<this.materials.length){if(t!==this.materials.length-1){const i=this.materials[this.materials.length-1];this.materials[t]=i,i._indexInSceneMaterialArray=t}e._indexInSceneMaterialArray=-1,this.materials.pop()}return this.onMaterialRemovedObservable.notifyObservers(e),t}removeActionManager(e){const t=this.actionManagers.indexOf(e);return t!==-1&&this.actionManagers.splice(t,1),t}removeTexture(e){const t=this.textures.indexOf(e);return t!==-1&&this.textures.splice(t,1),this.onTextureRemovedObservable.notifyObservers(e),t}removeFrameGraph(e){const t=this.frameGraphs.indexOf(e);return t!==-1&&this.frameGraphs.splice(t,1),this.onFrameGraphRemovedObservable.notifyObservers(e),t}removeObjectRenderer(e){const t=this.objectRenderers.indexOf(e);return t!==-1&&this.objectRenderers.splice(t,1),this.onObjectRendererRemovedObservable.notifyObservers(e),t}removePostProcess(e){const t=this.postProcesses.indexOf(e);return t!==-1&&this.postProcesses.splice(t,1),this.onPostProcessRemovedObservable.notifyObservers(e),t}removeEffectLayer(e){const t=this.effectLayers.indexOf(e);return t!==-1&&this.effectLayers.splice(t,1),this.onEffectLayerRemovedObservable.notifyObservers(e),t}addLight(e){if(!this._blockEntityCollection){this.lights.push(e),this.sortLightsByPriority(),e.parent||e._addToSceneRootNodes();for(const t of this.meshes)t.lightSources.indexOf(e)===-1&&(t.lightSources.push(e),t._resyncLightSources());pe.SetImmediate(()=>{this.onNewLightAddedObservable.notifyObservers(e)})}}sortLightsByPriority(){this.requireLightSorting&&this.lights.sort(xt.CompareLightsPriority)}addCamera(e){this._blockEntityCollection||(this.cameras.push(e),pe.SetImmediate(()=>{this.onNewCameraAddedObservable.notifyObservers(e)}),e.parent||e._addToSceneRootNodes())}addSkeleton(e){this._blockEntityCollection||(this.skeletons.push(e),pe.SetImmediate(()=>{this.onNewSkeletonAddedObservable.notifyObservers(e)}))}addParticleSystem(e){this._blockEntityCollection||(this.particleSystems.push(e),pe.SetImmediate(()=>{this.onNewParticleSystemAddedObservable.notifyObservers(e)}))}addAnimation(e){this._blockEntityCollection||this.animations.push(e)}addAnimationGroup(e){this._blockEntityCollection||(this.animationGroups.push(e),pe.SetImmediate(()=>{this.onNewAnimationGroupAddedObservable.notifyObservers(e)}))}addMultiMaterial(e){this._blockEntityCollection||(this.multiMaterials.push(e),pe.SetImmediate(()=>{this.onNewMultiMaterialAddedObservable.notifyObservers(e)}))}addMaterial(e){this._blockEntityCollection||e.getScene()===this&&e._indexInSceneMaterialArray!==-1||(e._indexInSceneMaterialArray=this.materials.length,this.materials.push(e),pe.SetImmediate(()=>{this.onNewMaterialAddedObservable.notifyObservers(e)}))}addMorphTargetManager(e){this._blockEntityCollection||this.morphTargetManagers.push(e)}addGeometry(e){this._blockEntityCollection||(this._geometriesByUniqueId&&(this._geometriesByUniqueId[e.uniqueId]=this.geometries.length),this.geometries.push(e))}addActionManager(e){this.actionManagers.push(e)}addTexture(e){this._blockEntityCollection||(this.textures.push(e),this.onNewTextureAddedObservable.notifyObservers(e))}addFrameGraph(e){this.frameGraphs.push(e),pe.SetImmediate(()=>{this.onNewFrameGraphAddedObservable.notifyObservers(e)})}addObjectRenderer(e){this.objectRenderers.push(e),pe.SetImmediate(()=>{this.onNewObjectRendererAddedObservable.notifyObservers(e)})}addPostProcess(e){this._blockEntityCollection||(this.postProcesses.push(e),pe.SetImmediate(()=>{this.onNewPostProcessAddedObservable.notifyObservers(e)}))}addEffectLayer(e){this._blockEntityCollection||(this.effectLayers.push(e),pe.SetImmediate(()=>{this.onNewEffectLayerAddedObservable.notifyObservers(e)}))}switchActiveCamera(e,t=!0){this._engine.getInputElement()&&(this.activeCamera&&this.activeCamera.detachControl(),this.activeCamera=e,t&&e.attachControl())}setActiveCameraById(e){const t=this.getCameraById(e);return t?(this.activeCamera=t,t):null}setActiveCameraByName(e){const t=this.getCameraByName(e);return t?(this.activeCamera=t,t):null}getAnimationGroupByName(e){for(let t=0;t<this.animationGroups.length;t++)if(this.animationGroups[t].name===e)return this.animationGroups[t];return null}_getMaterial(e,t){for(let i=0;i<this.materials.length;i++){const s=this.materials[i];if(t(s))return s}if(e)for(let i=0;i<this.multiMaterials.length;i++){const s=this.multiMaterials[i];if(t(s))return s}return null}getMaterialByUniqueID(e,t=!1){return this.getMaterialByUniqueId(e,t)}getMaterialByUniqueId(e,t=!1){return this._getMaterial(t,i=>i.uniqueId===e)}getMaterialById(e,t=!1){return this._getMaterial(t,i=>i.id===e)}getMaterialByName(e,t=!1){return this._getMaterial(t,i=>i.name===e)}getLastMaterialById(e,t=!1){for(let i=this.materials.length-1;i>=0;i--)if(this.materials[i].id===e)return this.materials[i];if(t){for(let i=this.multiMaterials.length-1;i>=0;i--)if(this.multiMaterials[i].id===e)return this.multiMaterials[i]}return null}getTextureByUniqueId(e){for(let t=0;t<this.textures.length;t++)if(this.textures[t].uniqueId===e)return this.textures[t];return null}getTextureByName(e){for(let t=0;t<this.textures.length;t++)if(this.textures[t].name===e)return this.textures[t];return null}getCameraById(e){for(let t=0;t<this.cameras.length;t++)if(this.cameras[t].id===e)return this.cameras[t];return null}getCameraByUniqueId(e){for(let t=0;t<this.cameras.length;t++)if(this.cameras[t].uniqueId===e)return this.cameras[t];return null}getCameraByName(e){for(let t=0;t<this.cameras.length;t++)if(this.cameras[t].name===e)return this.cameras[t];return null}getBoneById(e){for(let t=0;t<this.skeletons.length;t++){const i=this.skeletons[t];for(let s=0;s<i.bones.length;s++)if(i.bones[s].id===e)return i.bones[s]}return null}getBoneByName(e){for(let t=0;t<this.skeletons.length;t++){const i=this.skeletons[t];for(let s=0;s<i.bones.length;s++)if(i.bones[s].name===e)return i.bones[s]}return null}getLightByName(e){for(let t=0;t<this.lights.length;t++)if(this.lights[t].name===e)return this.lights[t];return null}getLightById(e){for(let t=0;t<this.lights.length;t++)if(this.lights[t].id===e)return this.lights[t];return null}getLightByUniqueId(e){for(let t=0;t<this.lights.length;t++)if(this.lights[t].uniqueId===e)return this.lights[t];return null}getParticleSystemById(e){for(let t=0;t<this.particleSystems.length;t++)if(this.particleSystems[t].id===e)return this.particleSystems[t];return null}getGeometryById(e){for(let t=0;t<this.geometries.length;t++)if(this.geometries[t].id===e)return this.geometries[t];return null}_getGeometryByUniqueId(e){if(this._geometriesByUniqueId){const t=this._geometriesByUniqueId[e];if(t!==void 0)return this.geometries[t]}else for(let t=0;t<this.geometries.length;t++)if(this.geometries[t].uniqueId===e)return this.geometries[t];return null}getFrameGraphByName(e){for(let t=0;t<this.frameGraphs.length;t++)if(this.frameGraphs[t].name===e)return this.frameGraphs[t];return null}pushGeometry(e,t){return!t&&this._getGeometryByUniqueId(e.uniqueId)?!1:(this.addGeometry(e),pe.SetImmediate(()=>{this.onNewGeometryAddedObservable.notifyObservers(e)}),!0)}removeGeometry(e){let t;if(this._geometriesByUniqueId){if(t=this._geometriesByUniqueId[e.uniqueId],t===void 0)return!1}else if(t=this.geometries.indexOf(e),t<0)return!1;if(t!==this.geometries.length-1){const i=this.geometries[this.geometries.length-1];i&&(this.geometries[t]=i,this._geometriesByUniqueId&&(this._geometriesByUniqueId[i.uniqueId]=t))}return this._geometriesByUniqueId&&(this._geometriesByUniqueId[e.uniqueId]=void 0),this.geometries.pop(),this.onGeometryRemovedObservable.notifyObservers(e),!0}getGeometries(){return this.geometries}getMeshById(e){for(let t=0;t<this.meshes.length;t++)if(this.meshes[t].id===e)return this.meshes[t];return null}getMeshesById(e){return this.meshes.filter(function(t){return t.id===e})}getTransformNodeById(e){for(let t=0;t<this.transformNodes.length;t++)if(this.transformNodes[t].id===e)return this.transformNodes[t];return null}getTransformNodeByUniqueId(e){for(let t=0;t<this.transformNodes.length;t++)if(this.transformNodes[t].uniqueId===e)return this.transformNodes[t];return null}getTransformNodesById(e){return this.transformNodes.filter(function(t){return t.id===e})}getMeshByUniqueId(e){for(let t=0;t<this.meshes.length;t++)if(this.meshes[t].uniqueId===e)return this.meshes[t];return null}getLastMeshById(e){for(let t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];return null}getLastTransformNodeById(e){for(let t=this.transformNodes.length-1;t>=0;t--)if(this.transformNodes[t].id===e)return this.transformNodes[t];return null}getLastEntryById(e){let t;for(t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];for(t=this.transformNodes.length-1;t>=0;t--)if(this.transformNodes[t].id===e)return this.transformNodes[t];for(t=this.cameras.length-1;t>=0;t--)if(this.cameras[t].id===e)return this.cameras[t];for(t=this.lights.length-1;t>=0;t--)if(this.lights[t].id===e)return this.lights[t];return null}getNodeById(e){const t=this.getMeshById(e);if(t)return t;const i=this.getTransformNodeById(e);if(i)return i;const s=this.getLightById(e);if(s)return s;const r=this.getCameraById(e);if(r)return r;const a=this.getBoneById(e);return a||null}getNodeByName(e){const t=this.getMeshByName(e);
vendor: 4,617 bytes, line 757
757if(t)return t;const i=this.getTransformNodeByName(e);if(i)return i;const s=this.getLightByName(e);if(s)return s;const r=this.getCameraByName(e);if(r)return r;const a=this.getBoneByName(e);return a||null}getMeshByName(e){for(let t=0;t<this.meshes.length;t++)if(this.meshes[t].name===e)return this.meshes[t];return null}getTransformNodeByName(e){for(let t=0;t<this.transformNodes.length;t++)if(this.transformNodes[t].name===e)return this.transformNodes[t];return null}getLastSkeletonById(e){for(let t=this.skeletons.length-1;t>=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null}getSkeletonByUniqueId(e){for(let t=0;t<this.skeletons.length;t++)if(this.skeletons[t].uniqueId===e)return this.skeletons[t];return null}getSkeletonById(e){for(let t=0;t<this.skeletons.length;t++)if(this.skeletons[t].id===e)return this.skeletons[t];return null}getSkeletonByName(e){for(let t=0;t<this.skeletons.length;t++)if(this.skeletons[t].name===e)return this.skeletons[t];return null}getMorphTargetManagerById(e){for(let t=0;t<this.morphTargetManagers.length;t++)if(this.morphTargetManagers[t].uniqueId===e)return this.morphTargetManagers[t];return null}getMorphTargetById(e){for(let t=0;t<this.morphTargetManagers.length;++t){const i=this.morphTargetManagers[t];for(let s=0;s<i.numTargets;++s){const r=i.getTarget(s);if(r.id===e)return r}}return null}getMorphTargetByName(e){for(let t=0;t<this.morphTargetManagers.length;++t){const i=this.morphTargetManagers[t];for(let s=0;s<i.numTargets;++s){const r=i.getTarget(s);if(r.name===e)return r}}return null}getPostProcessByName(e){for(let t=0;t<this.postProcesses.length;++t){const i=this.postProcesses[t];if(i.name===e)return i}return null}isActiveMesh(e){return this._activeMeshes.indexOf(e)!==-1}get uid(){return this._uid||(this._uid=pe.RandomId()),this._uid}addExternalData(e,t){return this._externalData||(this._externalData=new xT),this._externalData.add(e,t)}getExternalData(e){return this._externalData?this._externalData.get(e):null}getOrAddExternalDataWithFactory(e,t){return this._externalData||(this._externalData=new xT),this._externalData.getOrAddWithFactory(e,t)}removeExternalData(e){return this._externalData.remove(e)}_evaluateSubMesh(e,t,i,s){if(s||e.isInFrustum(this._frustumPlanes)){for(const a of this._evaluateSubMeshStage)a.action(t,e);const r=e.getMaterial();r!=null&&(r.hasRenderTargetTextures&&r.getRenderTargetTextures!=null&&this._processedMaterials.indexOf(r)===-1&&(this._processedMaterials.push(r),this._materialsRenderTargets.concatWithNoDuplicate(r.getRenderTargetTextures())),this._renderingManager.dispatch(e,t,r))}}freeProcessedMaterials(){this._processedMaterials.dispose()}get blockfreeActiveMeshesAndRenderingGroups(){return this._preventFreeActiveMeshesAndRenderingGroups}set blockfreeActiveMeshesAndRenderingGroups(e){this._preventFreeActiveMeshesAndRenderingGroups!==e&&(e&&(this.freeActiveMeshes(),this.freeRenderingGroups()),this._preventFreeActiveMeshesAndRenderingGroups=e)}freeActiveMeshes(){if(!this.blockfreeActiveMeshesAndRenderingGroups&&(this._activeMeshes.dispose(),this.activeCamera&&this.activeCamera._activeMeshes&&this.activeCamera._activeMeshes.dispose(),this.activeCameras))for(let e=0;e<this.activeCameras.length;e++){const t=this.activeCameras[e];t&&t._activeMeshes&&t._activeMeshes.dispose()}}freeRenderingGroups(){if(!this.blockfreeActiveMeshesAndRenderingGroups&&(this._renderingManager&&this._renderingManager.freeRenderingGroups(),this.textures))for(let e=0;e<this.textures.length;e++){const t=this.textures[e];t&&t.renderList&&t.freeRenderingGroups()}}_isInIntermediateRendering(){return this._intermediateRendering}freezeActiveMeshes(e=!1,t,i,s=!0,r=!1){if(this.frameGraph){this._renderWithFrameGraph(!0,!1,!0);const a=this.frameGraph.getTasksByType(iE);for(const o of a)o.objectRenderer._freezeActiveMeshes(s);return this._freezeActiveMeshesCancel=wf(()=>{let o=!0,c=!0;for(const u of a)o&&(o=u.objectRenderer._isFrozen),c&&(c=u.objectRenderer._freezeActiveMeshesCancel!==null);if(o)return!0;if(!c)throw new Error("Freezing active meshes was cancelled");return!1},()=>{this._freezeActiveMeshesCancel=null,this._activeMeshesFrozen=!0,this._activeMeshesFrozenButKeepClipping=r,this._skipEvaluateActiveMeshesCompletely=e,t?.()},(o,c)=>{if(this._freezeActiveMeshesCancel=null,this.unfreezeActiveMeshes(),c){const u="Scene: Timeout while waiting for meshes to be frozen.";i?i(u):(oe.Error(u),o&&oe.Error(o))}else{const u="Scene: An unexpected error occurred while trying to freeze active meshes.";i?i(u):(oe.Error(u),o&&(oe.Error(o),o.stack&&oe.Error(o.stack)))}}),this}return this.executeWhenReady(()=>
vendor: 13,260 bytes, line 757
757{if(!this.activeCamera){i&&i("No active camera found");return}if(this._frustumPlanes||this.updateTransformMatrix(),this._evaluateActiveMeshes(),this._activeMeshesFrozen=!0,this._activeMeshesFrozenButKeepClipping=r,this._skipEvaluateActiveMeshesCompletely=e,s)for(let a=0;a<this._activeMeshes.length;a++)this._activeMeshes.data[a]._freeze();t&&t()}),this}unfreezeActiveMeshes(){for(let e=0;e<this.meshes.length;e++){const t=this.meshes[e];t._internalAbstractMeshDataInfo&&(t._internalAbstractMeshDataInfo._isActive=!1)}if(this._freezeActiveMeshesCancel?.(),this._freezeActiveMeshesCancel=null,this.frameGraph){const e=this.frameGraph.getTasksByType(iE);for(const t of e)t.objectRenderer._unfreezeActiveMeshes()}else for(let e=0;e<this._activeMeshes.length;e++)this._activeMeshes.data[e]._unFreeze();return this._activeMeshesFrozen=!1,this}_executeActiveContainerCleanup(e){!(this._engine.snapshotRendering&&this._engine.snapshotRenderingMode===1)&&this._activeMeshesFrozen&&this._activeMeshes.length||this.onBeforeRenderObservable.addOnce(()=>e.dispose())}_evaluateActiveMeshes(){if(this._engine.snapshotRendering&&this._engine.snapshotRenderingMode===1){this._activeMeshes.length>0&&(this.activeCamera?._activeMeshes.reset(),this._activeMeshes.reset(),this._renderingManager.reset(),this._processedMaterials.reset(),this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset());return}if(this._activeMeshesFrozen&&this._activeMeshes.length){if(!this._skipEvaluateActiveMeshesCompletely){const i=this._activeMeshes.length;for(let s=0;s<i;s++)this._activeMeshes.data[s].computeWorldMatrix()}if(this._activeParticleSystems){const i=this._activeParticleSystems.length;for(let s=0;s<i;s++)this._activeParticleSystems.data[s].animate()}this._renderingManager.resetSprites();return}if(!this.activeCamera)return;this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this),this.activeCamera._activeMeshes.reset(),this._activeMeshes.reset(),this._renderingManager.reset(),this._processedMaterials.reset(),this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset(),this._materialsRenderTargets.reset();for(const i of this._beforeEvaluateActiveMeshStage)i.action();const e=this.getActiveMeshCandidates(),t=e.length;for(let i=0;i<t;i++){const s=e.data[i];let r=s._internalAbstractMeshDataInfo._currentLOD.get(this.activeCamera);if(r?r[1]=-1:(r=[s,-1],s._internalAbstractMeshDataInfo._currentLOD.set(this.activeCamera,r)),s.isBlocked||(this._totalVertices.addCount(s.getTotalVertices(),!1),!s.isReady()||!s.isEnabled()||s.scaling.hasAZeroComponent))continue;s.computeWorldMatrix(),s.actionManager&&s.actionManager.hasSpecificTriggers2(12,13)&&this._meshesForIntersections.pushNoDuplicate(s);let a=this.customLODSelector?this.customLODSelector(s,this.activeCamera):s.getLOD(this.activeCamera);if(r[0]=a,r[1]=this._frameId,a!=null&&(a!==s&&a.billboardMode!==0&&a.computeWorldMatrix(),s._preActivate(),s.isVisible&&s.visibility>0&&(s.layerMask&this.activeCamera.layerMask)!==0&&(this._skipFrustumClipping||s.alwaysSelectAsActiveMesh||s.isInFrustum(this._frustumPlanes)))){this._activeMeshes.push(s),this.activeCamera._activeMeshes.push(s),a!==s&&a._activate(this._renderId,!1);for(const o of this._preActiveMeshStage)o.action(s);s._activate(this._renderId,!1)&&(s.isAnInstance?s._internalAbstractMeshDataInfo._actAsRegularMesh&&(a=s):a._internalAbstractMeshDataInfo._onlyForInstances=!1,a._internalAbstractMeshDataInfo._isActive=!0,this._activeMesh(s,a)),s._postActivate()}}if(this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),this.particlesEnabled){this.onBeforeParticlesRenderingObservable.notifyObservers(this);for(let i=0;i<this.particleSystems.length;i++){const s=this.particleSystems[i];if(!s.isStarted()||!s.emitter)continue;const r=s.emitter;(!r.position||r.isEnabled())&&(this._activeParticleSystems.push(s),s.animate(),this._renderingManager.dispatchParticles(s))}this.onAfterParticlesRenderingObservable.notifyObservers(this)}}_prepareSkeleton(e){!this._skeletonsEnabled||!e.skeleton||(this._activeSkeletons.pushNoDuplicate(e.skeleton)&&(e.skeleton.prepare(),this._activeBones.addCount(e.skeleton.bones.length,!1)),e.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(e)&&this.frameGraph&&e.applySkeleton(e.skeleton))}_activeMesh(e,t){this._prepareSkeleton(t);let i=e.hasInstances||e.isAnInstance||this.dispatchAllSubMeshesOfActiveMeshes||this._skipFrustumClipping||t.alwaysSelectAsActiveMesh;if(t&&t.subMeshes&&t.subMeshes.length>0){const s=this.getActiveSubMeshCandidates(t),r=s.length;i=i||r===1;for(let a=0;a<r;a++){const o=s.data[a];this._evaluateSubMesh(o,t,e,i)}}}updateTransformMatrix(e){const t=this.activeCamera;if(t)if(t._renderingMultiview){const i=t._rigCameras[0],s=t._rigCameras[1];this.setTransformMatrix(i.getViewMatrix(),i.getProjectionMatrix(e),s.getViewMatrix(),s.getProjectionMatrix(e))}else this.setTransformMatrix(t.getViewMatrix(),t.getProjectionMatrix(e))}_bindFrameBuffer(e,t=!0){this._useCurrentFrameBuffer||(e&&e._multiviewTexture?e._multiviewTexture._bindFrameBuffer():e&&e.outputRenderTarget?e.outputRenderTarget._bindFrameBuffer():this._engine._currentFrameBufferIsDefaultFrameBuffer()||this._engine.restoreDefaultFramebuffer()),t&&this._clearFrameBuffer(e)}_clearFrameBuffer(e){if(!(e&&e._multiviewTexture))if(e&&e.outputRenderTarget&&!e._renderingMultiview){const t=e.outputRenderTarget;t.onClearObservable.hasObservers()?t.onClearObservable.notifyObservers(this._engine):!t.skipInitialClear&&!e.isRightCamera&&(this.autoClear&&this._engine.clear(t.clearColor||this._clearColor,!t._cleared,!0,!0),t._cleared=!0)}else this._defaultFrameBufferCleared?this._engine.clear(null,!1,!0,!0):(this._defaultFrameBufferCleared=!0,this._clear())}_renderForCamera(e,t,i=!0){if(e&&e._skipRendering)return;const s=this._engine;if(this._activeCamera=e,!this.activeCamera)throw new Error("Active camera not set");if(s.setViewport(this.activeCamera.viewport),this.resetCachedMaterial(),this._renderId++,!this.prePass&&i){let o=!0;e._renderingMultiview&&e.outputRenderTarget&&(o=e.outputRenderTarget.skipInitialClear,this.autoClear&&(this._defaultFrameBufferCleared=!1,e.outputRenderTarget.skipInitialClear=!1)),this._bindFrameBuffer(this._activeCamera),e._renderingMultiview&&e.outputRenderTarget&&(e.outputRenderTarget.skipInitialClear=o)}this.updateTransformMatrix(),this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),this._evaluateActiveMeshes();for(let o=0;o<this._softwareSkinnedMeshes.length;o++){const c=this._softwareSkinnedMeshes.data[o];c.applySkeleton(c.skeleton)}this.onBeforeRenderTargetsRenderObservable.notifyObservers(this),this._renderTargets.concatWithNoDuplicate(this._materialsRenderTargets),e.customRenderTargets&&e.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(e.customRenderTargets),t&&t.customRenderTargets&&t.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets),this.environmentTexture&&this.environmentTexture.isRenderTarget&&this._renderTargets.pushNoDuplicate(this.environmentTexture);for(const o of this._gatherActiveCameraRenderTargetsStage)o.action(this._renderTargets);let r=!1;if(this.renderTargetsEnabled){if(this._intermediateRendering=!0,this._renderTargets.length>0){pe.StartPerformanceCounter("Render targets",this._renderTargets.length>0);const o=this.getBoundingBoxRenderer?.();let c;for(let u=0;u<this._renderTargets.length;u++){const d=this._renderTargets.data[u];if(d._shouldRender()){this._renderId++;const f=d.activeCamera&&d.activeCamera!==this.activeCamera;o&&!c&&(c=o.renderList.length>0?o.renderList.data.slice():[],c.length=o.renderList.length),d.render(f,this.dumpNextRenderTargets),r=!0}}o&&c&&(o.renderList.data=c,o.renderList.length=c.length),pe.EndPerformanceCounter("Render targets",this._renderTargets.length>0),this._renderId++}for(const o of this._cameraDrawRenderTargetStage)r=o.action(this.activeCamera)||r;this._intermediateRendering=!1}this._engine.currentRenderPassId=e.outputRenderTarget?.renderPassId??e.renderPassId??0,r&&!this.prePass&&(this._bindFrameBuffer(this._activeCamera,!1),this.updateTransformMatrix()),this.onAfterRenderTargetsRenderObservable.notifyObservers(this),this.postProcessManager&&!e._multiviewTexture&&!this.prePass&&this.postProcessManager._prepareFrame();for(const o of this._beforeCameraDrawStage)o.action(this.activeCamera);this.onBeforeDrawPhaseObservable.notifyObservers(this);const a=s.snapshotRendering&&s.snapshotRenderingMode===1;a&&this.finalizeSceneUbo(),this._renderingManager.render(null,null,!0,!a),this.onAfterDrawPhaseObservable.notifyObservers(this);for(const o of this._afterCameraDrawStage)o.action(this.activeCamera);if(this.postProcessManager&&!e._multiviewTexture){const o=e.outputRenderTarget?e.outputRenderTarget.renderTarget:void 0;this.postProcessManager._finalizeFrame(e.isIntermediate,o)}for(const o of this._afterCameraPostProcessStage)o.action(this.activeCamera);this._renderTargets.reset(),this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera)}_processSubCameras(e,t=!0){if(e.cameraRigMode===0||e._renderingMultiview){e._renderingMultiview&&!this._multiviewSceneUbo&&this._createMultiviewUbo(),this._renderForCamera(e,void 0,t),this.onAfterRenderCameraObservable.notifyObservers(e);return}if(e._useMultiviewToSingleView)this._renderMultiviewToSingleView(e);else{this.onBeforeCameraRenderObservable.notifyObservers(e);for(let i=0;i<e._rigCameras.length;i++)this._renderForCamera(e._rigCameras[i],e)}this._activeCamera=e,this.updateTransformMatrix(),this.onAfterRenderCameraObservable.notifyObservers(e)}_checkIntersections(){for(let e=0;e<this._meshesForIntersections.length;e++){const t=this._meshesForIntersections.data[e];if(t.actionManager)for(let i=0;t.actionManager&&i<t.actionManager.actions.length;i++){const s=t.actionManager.actions[i];if(s.trigger===12||s.trigger===13){const r=s.getTriggerParameter(),a=r.mesh?r.mesh:r,o=a.intersectsMesh(t,r.usePreciseIntersection),c=t._intersectionsInProgress.indexOf(a);o&&c===-1?s.trigger===12?(s._executeCurrent(Vi.CreateNew(t,void 0,a)),t._intersectionsInProgress.push(a)):s.trigger===13&&t._intersectionsInProgress.push(a):!o&&c>-1&&(s.trigger===13&&s._executeCurrent(Vi.CreateNew(t,void 0,a)),(!t.actionManager.hasSpecificTrigger(13,u=>{const d=u.mesh?u.mesh:u;return a===d})||s.trigger===13)&&t._intersectionsInProgress.splice(c,1))}}}}_advancePhysicsEngineStep(e){}_animate(e){}animate(){if(this._engine.isDeterministicLockStep()){let e=Math.max(Pt.MinDeltaTime,Math.min(this._engine.getDeltaTime(),Pt.MaxDeltaTime))+this._timeAccumulator;const t=this._engine.getTimeStep(),i=1e3/t/1e3;let s=0;const r=this._engine.getLockstepMaxSteps();let a=Math.floor(e/t);for(a=Math.min(a,r);e>0&&s<a;)this.onBeforeStepObservable.notifyObservers(this),this._animationRatio=t*i,this._animate(t),this.onAfterAnimationsObservable.notifyObservers(this),this.physicsEnabled&&this._advancePhysicsEngineStep(t),this.onAfterStepObservable.notifyObservers(this),this._currentStepId++,s++,e-=t;this._timeAccumulator=e<0?0:e}else{const e=this.useConstantAnimationDeltaTime?16:Math.max(Pt.MinDeltaTime,Math.min(this._engine.getDeltaTime(),Pt.MaxDeltaTime));this._animationRatio=e*(60/1e3),this._animate(),this.onAfterAnimationsObservable.notifyObservers(this),this.physicsEnabled&&this._advancePhysicsEngineStep(e)}}_clear(){(this.autoClearDepthAndStencil||this.autoClear)&&this._engine.clear(this._clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,this.autoClearDepthAndStencil,this.autoClearDepthAndStencil)}_checkCameraRenderTarget(e){if(e?.outputRenderTarget&&!e?.isRigCamera&&(e.outputRenderTarget._cleared=!1),e?.rigCameras?.length)for(let t=0;t<e.rigCameras.length;++t){const i=e.rigCameras[t].outputRenderTarget;i&&(i._cleared=!1)}}resetDrawCache(e){if(this.meshes)for(const t of this.meshes)t.resetDrawCache(e)}_renderWithFrameGraph(e=!0,t=!1,i=!1){if(this.activeCamera=null,this.activeCameras=null,e){for(const s of this.cameras)if(s.update(),s.cameraRigMode!==0)for(let r=0;r<s._rigCameras.length;r++)s._rigCameras[r].update()}this.onBeforeRenderObservable.notifyObservers(this);for(const s of this._beforeClearStage)s.action();if(this._engine.snapshotRendering&&this._engine.snapshotRenderingMode===1)this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset();else{const s=this.getActiveMeshCandidates(),r=s.length;if(this._activeMeshesFrozen){if(!this._skipEvaluateActiveMeshesCompletely)for(let a=0;a<r;a++){const o=s.data[a];o._internalAbstractMeshDataInfo._wasActiveLastFrame&&o.computeWorldMatrix()}if(this.particlesEnabled){const a=this._activeParticleSystems.length;for(let o=0;o<a;o++)this._activeParticleSystems.data[o].animate()}}else{this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset();for(let a=0;a<r;a++){const o=s.data[a];o._internalAbstractMeshDataInfo._wasActiveLastFrame=!1,!o.isBlocked&&(this._totalVertices.addCount(o.getTotalVertices(),!1),!(!o.isReady()||!o.isEnabled()||o.scaling.hasAZeroComponent)&&(o.computeWorldMatrix(i),o.actionManager&&o.actionManager.hasSpecificTriggers2(12,13)&&this._meshesForIntersections.pushNo
vendor: 9,476 bytes, line 757
757Duplicate(o)))}if(this.particlesEnabled)for(let a=0;a<this.particleSystems.length;a++){const o=this.particleSystems[a];if(!o.isStarted()||!o.emitter)continue;const c=o.emitter;(!c.position||c.isEnabled())&&(this._activeParticleSystems.push(o),o.animate())}}}this.frameGraph?.execute()}_renderRenderTarget(e,t,i=!1,s=!1){if(this._intermediateRendering=!0,e._shouldRender()){if(this._renderId++,this.activeCamera=t,!this.activeCamera)throw new Error("Active camera not set");this._engine.setViewport(this.activeCamera.viewport),this.updateTransformMatrix(),e.render(i,s)}this._intermediateRendering=!1}render(e=!0,t=!1){if(!this.isDisposed){if(this.onReadyObservable.hasObservers()&&this._executeWhenReadyTimeoutId===null&&this._checkIsReady(),Go.getScene=this._getFloatingOriginScene,this._frameId++,this._defaultFrameBufferCleared=!1,this._checkCameraRenderTarget(this.activeCamera),this.activeCameras?.length)for(const i of this.activeCameras)this._checkCameraRenderTarget(i);this._registerTransientComponents(),this._activeParticles.fetchNewFrame(),this._totalVertices.fetchNewFrame(),this._activeIndices.fetchNewFrame(),this._activeBones.fetchNewFrame(),this._meshesForIntersections.reset(),this.resetCachedMaterial(),this.onBeforeAnimationsObservable.notifyObservers(this),this.actionManager&&this.actionManager.processTrigger(11),t||this.animate();for(const i of this._beforeCameraUpdateStage)i.action();if(e){if(this.activeCameras&&this.activeCameras.length>0)for(let i=0;i<this.activeCameras.length;i++){const s=this.activeCameras[i];if(s.update(),s.cameraRigMode!==0)for(let r=0;r<s._rigCameras.length;r++)s._rigCameras[r].update()}else if(this.activeCamera&&(this.activeCamera.update(),this.activeCamera.cameraRigMode!==0))for(let i=0;i<this.activeCamera._rigCameras.length;i++)this.activeCamera._rigCameras[i].update()}if(this.customRenderFunction)this._renderId++,this._engine.currentRenderPassId=0,this.customRenderFunction(e,t);else{this.onBeforeRenderObservable.notifyObservers(this),this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);const i=this.activeCameras?.length?this.activeCameras[0]:this.activeCamera;if(this.renderTargetsEnabled){pe.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0);for(let s=0;s<this.customRenderTargets.length;s++){const r=this.customRenderTargets[s],a=r.activeCamera||this.activeCamera;this._renderRenderTarget(r,a,i!==a,this.dumpNextRenderTargets)}pe.EndPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._renderId++}this._engine.currentRenderPassId=i?.renderPassId??0,this.activeCamera=i,this._activeCamera&&this._activeCamera.cameraRigMode!==22&&!this.prePass&&this._bindFrameBuffer(this._activeCamera,!1),this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(const s of this._beforeClearStage)s.action();this._clearFrameBuffer(this.activeCamera);for(const s of this._gatherRenderTargetsStage)s.action(this._renderTargets);if(this.activeCameras&&this.activeCameras.length>0)for(let s=0;s<this.activeCameras.length;s++)this._processSubCameras(this.activeCameras[s],s>0);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera,!!this.activeCamera.outputRenderTarget)}}this._checkIntersections();for(const i of this._afterRenderStage)i.action();if(this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this),this._toBeDisposed.length){for(let i=0;i<this._toBeDisposed.length;i++){const s=this._toBeDisposed[i];s&&s.dispose()}this._toBeDisposed.length=0}this.dumpNextRenderTargets&&(this.dumpNextRenderTargets=!1),this._activeBones.addCount(0,!0),this._activeIndices.addCount(0,!0),this._activeParticles.addCount(0,!0),this._engine.restoreDefaultFramebuffer()}}freezeMaterials(){for(let e=0;e<this.materials.length;e++)this.materials[e].freeze()}unfreezeMaterials(){for(let e=0;e<this.materials.length;e++)this.materials[e].unfreeze()}dispose(){if(this.isDisposed)return;if(this.beforeRender=null,this.afterRender=null,this.metadata=null,this.skeletons.length=0,this.morphTargetManagers.length=0,this._transientComponents.length=0,this._isReadyForMeshStage.clear(),this._beforeEvaluateActiveMeshStage.clear(),this._evaluateSubMeshStage.clear(),this._preActiveMeshStage.clear(),this._cameraDrawRenderTargetStage.clear(),this._beforeCameraDrawStage.clear(),this._beforeRenderTargetDrawStage.clear(),this._beforeRenderingGroupDrawStage.clear(),this._beforeRenderingMeshStage.clear(),this._afterRenderingMeshStage.clear(),this._afterRenderingGroupDrawStage.clear(),this._afterCameraDrawStage.clear(),this._afterRenderTargetDrawStage.clear(),this._afterRenderStage.clear(),this._beforeCameraUpdateStage.clear(),this._beforeClearStage.clear(),this._gatherRenderTargetsStage.clear(),this._gatherActiveCameraRenderTargetsStage.clear(),this._pointerMoveStage.clear(),this._pointerDownStage.clear(),this._pointerUpStage.clear(),this.importedMeshesFiles=[],this._activeAnimatables&&this.stopAllAnimations){for(const r of this._activeAnimatables)r.onAnimationEndObservable.clear(),r.onAnimationEnd=null;this.stopAllAnimations()}this.resetCachedMaterial(),this.activeCamera&&(this.activeCamera._activeMeshes.dispose(),this.activeCamera=null),this.activeCameras=null,this._activeMeshes.dispose(),this._renderingManager.dispose(),this._processedMaterials.dispose(),this._activeParticleSystems.dispose(),this._activeSkeletons.dispose(),this._softwareSkinnedMeshes.dispose(),this._renderTargets.dispose(),this._materialsRenderTargets.dispose(),this._registeredForLateAnimationBindings.dispose(),this._meshesForIntersections.dispose(),this._toBeDisposed.length=0;const e=this._activeRequests.slice();for(const r of e)r.abort();this._activeRequests.length=0;try{this.onDisposeObservable.notifyObservers(this)}catch(r){oe.Error("An error occurred while calling onDisposeObservable!",r)}if(this.detachControl(),this._engine.getInputElement())for(let r=0;r<this.cameras.length;r++)this.cameras[r].detachControl();this._disposeList(this.animationGroups),this._disposeList(this.lights),this._defaultMaterial&&this._defaultMaterial.dispose(),this._disposeList(this.multiMaterials),this._disposeList(this.materials),this._disposeList(this.meshes,r=>r.dispose(!0)),this._disposeList(this.transformNodes,r=>r.dispose(!0));const i=this.cameras;this._disposeList(i),this._disposeList(this.particleSystems),this._disposeList(this.postProcesses),this._disposeList(this.textures),this._disposeList(this.morphTargetManagers),this._disposeList(this.frameGraphs),this._sceneUbo.dispose(),this._multiviewSceneUbo&&this._multiviewSceneUbo.dispose(),this.postProcessManager.dispose(),this._disposeList(this._components);let s=this._engine.scenes.indexOf(this);if(s>-1&&this._engine.scenes.splice(s,1),this._floatingOriginScene=void 0,this._engine.scenes.length===0&&kk(),Ke._LastCreatedScene===this){Ke._LastCreatedScene=null;let r=Ke.Instances.length-1;for(;r>=0;){const a=Ke.Instances[r];if(a.scenes.length>0){Ke._LastCreatedScene=a.scenes[this._engine.scenes.length-1];break}r--}}s=this._engine._virtualScenes.indexOf(this),s>-1&&this._engine._virtualScenes.splice(s,1),this._engine.wipeCaches(!0),this.onDisposeObservable.clear(),this.onBeforeRenderObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderTargetsRenderObservable.clear(),this.onAfterRenderTargetsRenderObservable.clear(),this.onAfterStepObservable.clear(),this.onBeforeStepObservable.clear(),this.onBeforeActiveMeshesEvaluationObservable.clear(),this.onAfterActiveMeshesEvaluationObservable.clear(),this.onBeforeParticlesRenderingObservable.clear(),this.onAfterParticlesRenderingObservable.clear(),this.onBeforeDrawPhaseObservable.clear(),this.onAfterDrawPhaseObservable.clear(),this.onBeforeAnimationsObservable.clear(),this.onAfterAnimationsObservable.clear(),this.onDataLoadedObservable.clear(),this.onBeforeRenderingGroupObservable.clear(),this.onAfterRenderingGroupObservable.clear(),this.onMeshImportedObservable.clear(),this.onBeforeCameraRenderObservable.clear(),this.onAfterCameraRenderObservable.clear(),this.onAfterRenderCameraObservable.clear(),this.onReadyObservable.clear(),this.onNewCameraAddedObservable.clear(),this.onCameraRemovedObservable.clear(),this.onNewLightAddedObservable.clear(),this.onLightRemovedObservable.clear(),this.onNewGeometryAddedObservable.clear(),this.onGeometryRemovedObservable.clear(),this.onNewTransformNodeAddedObservable.clear(),this.onTransformNodeRemovedObservable.clear(),this.onNewMeshAddedObservable.clear(),this.onMeshRemovedObservable.clear(),this.onNewSkeletonAddedObservable.clear(),this.onSkeletonRemovedObservable.clear(),this.onNewMaterialAddedObservable.clear(),this.onNewMultiMaterialAddedObservable.clear(),this.onMaterialRemovedObservable.clear(),this.onMultiMaterialRemovedObservable.clear(),this.onNewTextureAddedObservable.clear(),this.onTextureRemovedObservable.clear(),this.onNewFrameGraphAddedObservable.clear(),this.onFrameGraphRemovedObservable.clear(),this.onNewObjectRendererAddedObservable.clear(),this.onObjectRendererRemovedObservable.clear(),this.onPrePointerObservable.clear(),this.onPointerObservable.clear(),this.onPreKeyboardObservable.clear(),this.onKeyboardObservable.clear(),this.onActiveCameraChanged.clear(),this.onScenePerformancePriorityChangedObservable.clear(),this.onClearColorChangedObservable.clear(),this.onEnvironmentTextureChangedObservable.clear(),this.onMeshUnderPointerUpdatedObservable.clear(),this._isDisposed=!0}
757_disposeList(e,t){const i=e.slice(0);t=t??(s=>s.dispose());for(const s of i)t(s);e.length=0}get isDisposed(){return this._isDisposed}clearCachedVertexData(){for(let e=0;e<this.meshes.length;e++){const i=this.meshes[e].geometry;i&&i.clearCachedData()}}cleanCachedTextureBuffer(){for(const e of this.textures)e._buffer&&(e._buffer=null)}getWorldExtends(e){const t=new T(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),i=new T(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);e=e||(()=>!0);const s=this.meshes.filter(e);for(const r of s){if(r.computeWorldMatrix(!0),!r.subMeshes||r.subMeshes.length===0||r.infiniteDistance)continue;const a=r.getBoundingInfo(),o=a.boundingBox.minimumWorld,c=a.boundingBox.maximumWorld;T.CheckExtends(o,t,i),T.CheckExtends(c,t,i)}return{min:t,max:i}}createPickingRay(e,t,i,s,r=!1){throw We("Ray")}createPickingRayToRef(e,t,i,s,r,a=!1,o=!1){throw We("Ray")}createPickingRayInCameraSpace(e,t,i){throw We("Ray")}createPickingRayInCameraSpaceToRef(e,t,i,s){throw We("Ray")}pick(e,t,i,s,r,a){const o=We("Ray",!0);return o&&oe.Warn(o),new as}pickWithBoundingInfo(e,t,i,s,r){const a=We("Ray",!0);return a&&oe.Warn(a),new as}pickWithRay(e,t,i,s){throw We("Ray")}multiPick(e,t,i,s,r){throw We("Ray")}multiPickWithRay(e,t,i){throw We("Ray")}setPointerOverMesh(e,t,i){this._inputManager.setPointerOverMesh(e,t,i)}getPointerOverMesh(){return this._inputManager.getPointerOverMesh()}_rebuildGeometries(){for(const e of this.geometries)e._rebuild();for(const e of this.meshes)e._rebuild();this.postProcessManager&&this.postProcessManager._rebuild();for(const e of this._components)e.rebuild();for(const e of this.particleSystems)e.rebuild();if(this.spriteManagers)for(const e of this.spriteManagers)e.rebuild()}_rebuildTextures(){for(const e of this.textures)e._rebuild(!0);this.markAllMaterialsAsDirty(1)}_getByTags(e,t,i){if(t===void 0)return e;const s=[];for(const r in e){const a=e[r];vt&&vt.MatchesQuery(a,t)&&(!i||i(a))&&s.push(a)}return s}getMeshesByTags(e,t){return this._getByTags(this.meshes,e,t)}getCamerasByTags(e,t){return this._getByTags(this.cameras,e,t)}getLightsByTags(e,t){return this._getByTags(this.lights,e,t)}getMaterialByTags(e,t){return this._getByTags(this.materials,e,t).concat(this._getByTags(this.multiMaterials,e,t))}getTransformNodesByTags(e,t){return this._getByTags(this.transformNodes,e,t)}setRenderingOrder(e,t=null,i=null,s=null){this._renderingManager.setRenderingOrder(e,t,i,s)}setRenderingAutoClearDepthStencil(e,t,i=!0,s=!0){this._renderingManager.setRenderingAutoClearDepthStencil(e,t,i,s)}getAutoClearDepthStencilSetup(e){return this._renderingManager.getAutoClearDepthStencilSetup(e)}_forceBlockMaterialDirtyMechanism(e){this._blockMaterialDirtyMechanism=e}get blockMaterialDirtyMechanism(){return this._blockMaterialDirtyMechanism}set blockMaterialDirtyMechanism(e){this._blockMaterialDirtyMechanism!==e&&(this._blockMaterialDirtyMechanism=e,e||this.markAllMaterialsAsDirty(127))}markAllMaterialsAsDirty(e,t){if(!this._blockMaterialDirtyMechanism)for(const i of this.materials)t&&!t(i)||i.markAsDirty(e)}_loadFile(e,t,i,s,r,a,o){const c=eo(e,t,i,s?this.offlineProvider:void 0,r,a,o);return this._activeRequests.push(c),c.onCompleteObservable.add(u=>{this._activeRequests.splice(this._activeRequests.indexOf(u),1)}),c}async _loadFileAsync(e,t,i,s,r){return await new Promise((a,o)=>{this._loadFile(e,c=>{a(c)},t,i,s,(c,u)=>{o(u)},r)})}_requestFile(e,t,i,s,r,a,o){const c=Mb(e,t,i,s?this.offlineProvider:void 0,r,a,o);return this._activeRequests.push(c),c.onCompleteObservable.add(u=>{this._activeRequests.splice(this._activeRequests.indexOf(u),1)}),c}async _requestFileAsync(e,t,i,s,r){return await new Promise((a,o)=>{this._requestFile(e,c=>{a(c)},t,i,s,c=>{o(c)},r)})}_readFile(e,t,i,s,r){const a=Lh(e,t,i,s,r);return this._activeRequests.push(a),a.onCompleteObservable.add(o=>{this._activeRequests.splice(this._activeRequests.indexOf(o),1)}),a}async _readFileAsync(e,t,i){return await new Promise((s,r)=>{this._readFile(e,a=>{s(a)},t,i,a=>{r(a)})})}getPerfCollector(){throw We("performanceViewerSceneExtension")}setActiveCameraByID(e){return this.setActiveCameraById(e)}getMaterialByID(e){return this.getMaterialById(e)}getLastMaterialByID(e){return this.getLastMaterialById(e)}getTextureByUniqueID(e){return this.getTextureByUniqueId(e)}getCameraByID(e){return this.getCameraById(e)}getCameraByUniqueID(e){return this.getCameraByUniqueId(e)}getBoneByID(e){return this.getBoneById(e)}getLightByID(e){return this.getLightById(e)}getLightByUniqueID(e){return this.getLightByUniqueId(e)}getParticleSystemByID(e){return this.getParticleSystemById(e)}getGeometryByID(e){return this.getGeometryById(e)}getMeshByID(e){return this.getMeshById(e)}getMeshByUniqueID(e){return this.getMeshByUniqueId(e)}getLastMeshByID(e){return this.getLastMeshById(e)}getMeshesByID(e){return this.getMeshesById(e)}getTransformNodeByID(e){return this.getTransformNodeById(e)}getTransformNodeByUniqueID(e){return this.getTransformNodeByUniqueId(e)}getTransformNodesByID(e){return this.getTransformNodesById(e)}getNodeByID(e){return this.getNodeById(e)}getLastEntryByID(e){return this.getLastEntryById(e)}getLastSkeletonByID(e){return this.getLastSkeletonById(e)}}Pt.FOGMODE_NONE=0;Pt.FOGMODE_EXP=1;Pt.FOGMODE_EXP2=2;Pt.FOGMODE_LINEAR=3;Pt.MinDeltaTime=1;Pt.MaxDeltaTime=1e3;Pt._OriginalDefaultMaterialFactory=Pt.DefaultMaterialFactory;Tt("BABYLON.Scene",Pt);function aI(n){const e=n.height||2;let t=n.diameterTop===0?0:n.diameterTop||n.diameter||1,i=n.diameterBottom===0?0:n.diameterBottom||n.diameter||1;t=t||1e-5,i=i||1e-5;const s=(n.tessellation||24)|0,r=(n.subdivisions||1)|0,a=!!n.hasRings,o=!!n.enclose,c=n.cap===0?0:n.cap||Z.CAP_ALL,u=n.arc&&(n.arc<=0||n.arc>1)?1:n.arc||1,d=n.sideOrientation===0?0:n.sideOrientation||ve.DEFAULTSIDE,f=n.faceUV||new Array(3),g=n.faceColors,m=u!==1&&o?2:0,b=a?r:1,x=2+(1+m)*b;let v;for(v=0;v<x;v++)g&&g[v]===void 0&&(g[v]=new Ze(1,1,1,1));for(v=0;v<x;v++)f&&f[v]===void 0&&(f[v]=new rt(0,0,1,1));const E=[],A=[],D=[],I=[],R=[],C=Math.PI*2*u/s;let M,F,U;const k=(i-t)/2/e,q=T.Zero(),Q=T.Zero(),ie=T.Zero(),$=T.Zero(),ce=T.Zero(),G=wr.Y;let K,X,J,se=1,w=1,L=0,V=0;for(K=0;K<=r;K++)for(F=K/r,U=(F*(t-i)+i)/2,se=a&&K!==0&&K!==r?2:1,J=0;J<se;J++){for(a&&(w+=J),o&&(w+=2*J),X=0;X<=s;X++)M=X*C,q.x=Math.cos(-M)*U,q.y=-e/2+F*e,q.z=Math.sin(-M)*U,t===0&&K===r?(Q.x=D[D.length-(s+1)*3],Q.y=D[D.length-(s+1)*3+1],Q.z=D[D.length-(s+1)*3+2]):(Q.x=q.x,Q.z=q.z,Q.y=Math.sqrt(Q.x*Q.x+Q.z*Q.z)*k,Q.normalize()),X===0&&(ie.copyFrom(q),$.copyFrom(Q)),A.push(q.x,q.y,q.z),D.push(Q.x,Q.y,Q.z),a?V=L!==w?f[w].y:f[w].w:V=f[w].y+(f[w].w-f[w].y)*F,I.push(f[w].x+(f[w].z-f[w].x)*X/s,V),g&&R.push(g[w].r,g[w].g,g[w].b,g[w].a);
757u!==1&&o&&(A.push(q.x,q.y,q.z),A.push(0,q.y,0),A.push(0,q.y,0),A.push(ie.x,ie.y,ie.z),T.CrossToRef(G,Q,ce),ce.normalize(),D.push(ce.x,ce.y,ce.z,ce.x,ce.y,ce.z),T.CrossToRef($,G,ce),ce.normalize(),D.push(ce.x,ce.y,ce.z,ce.x,ce.y,ce.z),a?V=L!==w?f[w+1].y:f[w+1].w:V=f[w+1].y+(f[w+1].w-f[w+1].y)*F,I.push(f[w+1].x,V),I.push(f[w+1].z,V),a?V=L!==w?f[w+2].y:f[w+2].w:V=f[w+2].y+(f[w+2].w-f[w+2].y)*F,I.push(f[w+2].x,V),I.push(f[w+2].z,V),g&&(R.push(g[w+1].r,g[w+1].g,g[w+1].b,g[w+1].a),R.push(g[w+1].r,g[w+1].g,g[w+1].b,g[w+1].a),R.push(g[w+2].r,g[w+2].g,g[w+2].b,g[w+2].a),R.push(g[w+2].r,g[w+2].g,g[w+2].b,g[w+2].a))),L!==w&&(L=w)}const j=u!==1&&o?s+4:s;for(K=0,w=0;w<r;w++){let be=0,Le=0,Xe=0,it=0;for(X=0;X<s;X++)be=K*(j+1)+X,Le=(K+1)*(j+1)+X,Xe=K*(j+1)+(X+1),it=(K+1)*(j+1)+(X+1),E.push(be,Le,Xe),E.push(it,Xe,Le);u!==1&&o&&(E.push(be+2,Le+2,Xe+2),E.push(it+2,Xe+2,Le+2),E.push(be+4,Le+4,Xe+4),E.push(it+4,Xe+4,Le+4)),K=a?K+2:K+1}const ae=be=>{const Le=be?t/2:i/2;if(Le===0)return;let Xe,it,ut;const Oe=be?f[x-1]:f[0];let Qe=null;g&&(Qe=be?g[x-1]:g[0]);const Be=A.length/3,Ot=be?e/2:-e/2,Wt=new T(0,Ot,0);A.push(Wt.x,Wt.y,Wt.z),D.push(0,be?1:-1,0);const vi=Oe.y+(Oe.w-Oe.y)*.5;I.push(Oe.x+(Oe.z-Oe.x)*.5,vi),Qe&&R.push(Qe.r,Qe.g,Qe.b,Qe.a);const Wi=new Ie(.5,.5);for(ut=0;ut<=s;ut++){Xe=Math.PI*2*ut*u/s;const Fi=Math.cos(-Xe),ls=Math.sin(-Xe);it=new T(Fi*Le,Ot,ls*Le);const ur=new Ie(Fi*Wi.x+.5,ls*Wi.y+.5);A.push(it.x,it.y,it.z),D.push(0,be?1:-1,0);const Mi=Oe.y+(Oe.w-Oe.y)*ur.y;I.push(Oe.x+(Oe.z-Oe.x)*ur.x,Mi),Qe&&R.push(Qe.r,Qe.g,Qe.b,Qe.a)}for(ut=0;ut<s;ut++)be?(E.push(Be),E.push(Be+(ut+2)),E.push(Be+(ut+1))):(E.push(Be),E.push(Be+(ut+1)),E.push(Be+(ut+2)))};(c===Z.CAP_START||c===Z.CAP_ALL)&&ae(!1),(c===Z.CAP_END||c===Z.CAP_ALL)&&ae(!0),ve._ComputeSides(d,A,E,D,I,n.frontUVs,n.backUVs);const he=new ve;return he.indices=E,he.positions=A,he.normals=D,he.uvs=I,g&&(he.colors=R),he}function Vf(n,e={},t){const i=new Z(n,t);return e.sideOrientation=Z._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,aI(e).applyToMesh(i,e.updatable),i}ve.CreateCylinder=aI;Z.CreateCylinder=(n,e,t,i,s,r,a,o,c)=>((a===void 0||!(a instanceof Pt))&&(a!==void 0&&(c=o||Z.DEFAULTSIDE,o=a),a=r,r=1),Vf(n,{height:e,diameterTop:t,diameterBottom:i,tessellation:s,subdivisions:r,sideOrientation:c,updatable:o},a));function oI(n){const e=[],t=[],i=[],s=[],r=n.diameter||1,a=n.thickness||.5,o=(n.tessellation||16)|0,c=n.sideOrientation===0?0:n.sideOrientation||ve.DEFAULTSIDE,u=o+1;for(let f=0;f<=o;f++){const g=f/o,m=f*Math.PI*2/o-Math.PI/2,b=W.Translation(r/2,0,0).multiply(W.RotationY(m));for(let x=0;x<=o;x++){const v=1-x/o,E=x*Math.PI*2/o+Math.PI,A=Math.cos(E),D=Math.sin(E);let I=new T(A,D,0),R=I.scale(a/2);const C=new Ie(g,v);R=T.TransformCoordinates(R,b),I=T.TransformNormal(I,b),t.push(R.x,R.y,R.z),i.push(I.x,I.y,I.z),s.push(C.x,C.y);const M=(f+1)%u,F=(x+1)%u;e.push(f*u+x),e.push(f*u+F),e.push(M*u+x),e.push(f*u+F),e.push(M*u+F),e.push(M*u+x)}}ve._ComputeSides(c,t,e,i,s,n.frontUVs,n.backUVs);const d=new ve;return d.indices=e,d.positions=t,d.normals=i,d.uvs=s,d}function kh(n,e={},t){const i=new Z(n,t);return e.sideOrientation=Z._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,oI(e).applyToMesh(i,e.updatable),i}ve.CreateTorus=oI;Z.CreateTorus=(n,e,t,i,s,r,a)=>kh(n,{diameter:e,thickness:t,tessellation:i,sideOrientation:a,updatable:r},s);function lI(n){const e=[],t=[],i=[],s=[],r=n.radius||2,a=n.tube||.5,o=n.radialSegments||32,c=n.tubularSegments||32,u=n.p||2,d=n.q||3,f=n.sideOrientation===0?0:n.sideOrientation||ve.DEFAULTSIDE,g=v=>{const E=Math.cos(v),A=Math.sin(v),D=d/u*v,I=Math.cos(D),R=r*(2+I)*.5*E,C=r*(2+I)*A*.5,M=r*Math.sin(D)*.5;return new T(R,C,M)};let m,b;for(m=0;m<=o;m++){const E=m%o/o*2*u*Math.PI,A=g(E),D=g(E+.01),I=D.subtract(A);let R=D.add(A);const C=T.Cross(I,R);for(R=T.Cross(C,I),C.normalize(),R.normalize(),b=0;b<c;b++){const F=b%c/c*2*Math.PI,U=-a*Math.cos(F),k=a*Math.sin(F);t.push(A.x+U*R.x+k*C.x),t.push(A.y+U*R.y+k*C.y),t.push(A.z+U*R.z+k*C.z),s.push(m/o),s.push(b/c)}}for(m=0;m<o;m++)for(b=0;b<c;b++){const v=(b+1)%c,E=m*c+b,A=(m+1)*c+b,D=(m+1)*c+v,I=m*c+v;e.push(I),e.push(A),e.push(E),e.push(I),e.push(D),e.push(A)}ve.ComputeNormals(t,e,i),ve._ComputeSides(f,t,e,i,s,n.frontUVs,n.backUVs);const x=new ve;return x.indices=e,x.positions=t,x.normals=i,x.uvs=s,x}function cI(n,e={},t){const i=new Z(n,t);return e.sideOrientation=Z._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,lI(e).applyToMesh(i,e.updatable),i}ve.CreateTorusKnot=lI;Z.CreateTorusKnot=(n,e,t,i,s,r,a,o,c,u)=>cI(n,{radius:e,tube:t,radialSegments:i,tubularSegments:s,p:r,q:a,sideOrientation:u,updatable:c},o);Z._instancedMeshFactory=(n,e)=>{const t=new Gb(n,e);if(e.instancedBuffers){t.instancedBuffers={};for(const i in e.instancedBuffers)t.instancedBuffers[i]=e.instancedBuffers[i]}return t};class Gb extends os{constructor(e,t){super(e,t.getScene()),this._indexInSourceMe
vendor: 6,917 bytes, line 757
757shInstanceArray=-1,this._distanceToCamera=0,t.addInstance(this),this._sourceMesh=t,this._unIndexed=t._unIndexed,this.position.copyFrom(t.position),this.rotation.copyFrom(t.rotation),this.scaling.copyFrom(t.scaling),t.rotationQuaternion&&(this.rotationQuaternion=t.rotationQuaternion.clone()),this.animations=t.animations.slice();for(const i of t.getAnimationRanges())i!=null&&this.createAnimationRange(i.name,i.from,i.to);if(this.infiniteDistance=t.infiniteDistance,this.setPivotMatrix(t.getPivotMatrix()),!t.skeleton&&!t.morphTargetManager&&t.hasBoundingInfo){const i=t.getBoundingInfo();this.buildBoundingInfo(i.minimum,i.maximum)}else this.refreshBoundingInfo(!0,!0);this._syncSubMeshes()}getClassName(){return"InstancedMesh"}get lightSources(){return this._sourceMesh._lightSources}_resyncLightSources(){}_resyncLightSource(){}_removeLightSource(){}get receiveShadows(){return this._sourceMesh.receiveShadows}set receiveShadows(e){this._sourceMesh?.receiveShadows!==e&&pe.Warn("Setting receiveShadows on an instanced mesh has no effect")}get material(){return this._sourceMesh.material}set material(e){this._sourceMesh?.material!==e&&pe.Warn("Setting material on an instanced mesh has no effect")}get visibility(){return this._sourceMesh.visibility}set visibility(e){this._sourceMesh?.visibility!==e&&pe.Warn("Setting visibility on an instanced mesh has no effect")}get skeleton(){return this._sourceMesh.skeleton}set skeleton(e){this._sourceMesh?.skeleton!==e&&pe.Warn("Setting skeleton on an instanced mesh has no effect")}get renderingGroupId(){return this._sourceMesh.renderingGroupId}set renderingGroupId(e){!this._sourceMesh||e===this._sourceMesh.renderingGroupId||oe.Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene")}getTotalVertices(){return this._sourceMesh?this._sourceMesh.getTotalVertices():0}getTotalIndices(){return this._sourceMesh.getTotalIndices()}get sourceMesh(){return this._sourceMesh}get geometry(){return this._sourceMesh._geometry}createInstance(e){return this._sourceMesh.createInstance(e)}isReady(e=!1){return this._sourceMesh.isReady(e,!0)}getVerticesData(e,t,i){return this._sourceMesh.getVerticesData(e,t,i)}copyVerticesData(e,t){this._sourceMesh.copyVerticesData(e,t)}getVertexBuffer(e,t){return this._sourceMesh.getVertexBuffer(e,t)}setVerticesData(e,t,i,s){return this.sourceMesh&&this.sourceMesh.setVerticesData(e,t,i,s),this.sourceMesh}updateVerticesData(e,t,i,s){return this.sourceMesh&&this.sourceMesh.updateVerticesData(e,t,i,s),this.sourceMesh}setIndices(e,t=null){return this.sourceMesh&&this.sourceMesh.setIndices(e,t),this.sourceMesh}isVerticesDataPresent(e){return this._sourceMesh.isVerticesDataPresent(e)}getIndices(){return this._sourceMesh.getIndices()}get _positions(){return this._sourceMesh._positions}refreshBoundingInfo(e=!1,t=!1){if(this.hasBoundingInfo&&this.getBoundingInfo().isLocked)return this;let i;typeof e=="object"?i=e:i={applySkeleton:e,applyMorph:t};const s=this._sourceMesh.geometry?this._sourceMesh.geometry.boundingBias:null;return this._refreshBoundingInfo(this._sourceMesh._getData(i,null,O.PositionKind),s),this}_preActivate(){return this._currentLOD&&this._currentLOD._preActivate(),this}_activate(e,t){if(super._activate(e,t),this._sourceMesh.subMeshes||oe.Warn("Instances should only be created for meshes with geometry."),this._currentLOD){if(this._currentLOD._getWorldMatrixDeterminant()>=0!=this._getWorldMatrixDeterminant()>=0)return this._internalAbstractMeshDataInfo._actAsRegularMesh=!0,!0;if(this._internalAbstractMeshDataInfo._actAsRegularMesh=!1,this._currentLOD._registerInstanceForRenderId(this,e),t){if(!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate)return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate=!0,!0}else if(!this._currentLOD._internalAbstractMeshDataInfo._isActive)return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances=!0,!0}return!1}_postActivate(){this._sourceMesh.edgesShareWithInstances&&this._sourceMesh._edgesRenderer&&this._sourceMesh._edgesRenderer.isEnabled&&this._sourceMesh._renderingGroup?(this._sourceMesh._renderingGroup._edgesRenderers.pushNoDuplicate(this._sourceMesh._edgesRenderer),this._sourceMesh._edgesRenderer.customInstances.push(this.getWorldMatrix())):this._edgesRenderer&&this._edgesRenderer.isEnabled&&this._sourceMesh._renderingGroup&&this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer)}getWorldMatrix(){if(this._currentLOD&&this._currentLOD!==this._sourceMesh&&this._currentLOD.billboardMode!==qe.BILLBOARDMODE_NONE&&this._currentLOD._masterMesh!==this){this._billboardWorldMatrix||(this._billboardWorldMatrix=new W);const e=this._currentLOD._masterMesh;return this._currentLOD._masterMesh=this,te.Vector3[7].copyFrom(this._currentLOD.position),this._currentLOD.position.set(0,0,0),this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(!0)),this._currentLOD.position.copyFrom(te.Vector3[7]),this._currentLOD._masterMesh=e,this._billboardWorldMatrix}return super.getWorldMatrix()}get isAnInstance(){return!0}getLOD(e){if(!e)return this;const t=this.sourceMesh.getLODLevels();if(!t||t.length===0)this._currentLOD=this.sourceMesh;else{const i=this.getBoundingInfo();this._currentLOD=this.sourceMesh.getLOD(e,i.boundingSphere)}return this._currentLOD}_preActivateForIntermediateRendering(e){return this.sourceMesh._preActivateForIntermediateRendering(e)}_syncSubMeshes(){if(this.releaseSubMeshes(),this._sourceMesh.subMeshes)for(let e=0;e<this._sourceMesh.subMeshes.length;e++)this._sourceMesh.subMeshes[e].clone(this,this._sourceMesh);return this}_generatePointsArray(){return this._sourceMesh._generatePointsArray()}_updateBoundingInfo(){return this.hasBoundingInfo?this.getBoundingInfo().update(this.worldMatrixFromCache):this.buildBoundingInfo(this.absolutePosition,this.absolutePosition,this.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache),this}clone(e,t=null,i,s){const r=(s||this._sourceMesh).createInstance(e);if(Db.DeepCopy(this,r,["name","subMeshes","uniqueId","parent","lightSources","receiveShadows","material","visibility","skeleton","sourceMesh","isAnInstance","facetNb","isFacetDataEnabled","isBlocked","useBones","hasInstances","collider","edgesRenderer","forward","up","right","absolutePosition","absoluteScaling","absoluteRotationQuaternion","isWorldMatrixFrozen","nonUniformScaling","behaviors","worldMatrixFromCache","hasThinInstances","hasBoundingInfo","geometry"],[]),t&&(r.parent=t),!i)for(let a=0;a<this.getScene().meshes.length;a++){const o=this.getScene().meshes[a];o.parent===this&&o.clone(o.name,r)}return r.computeWorldMatrix(!0),this.onClonedObservable.notifyObservers(r),r}dispose(e,t=!1){this._sourceMesh.removeInstance(this),super.dispose(e,t)}_serializeAsParent(e){super._serializeAsParent(e),e.parentId=this._sourceMesh.uniqueId,e.parentInstanceIndex=this._indexInSourceMe
757shInstanceArray}instantiateHierarchy(e=null,t,i){const s=this.clone("Clone of "+(this.name||this.id),e||this.parent,!0,t&&t.newSourcedMesh);s&&i&&i(this,s);for(const r of this.getChildTransformNodes(!0))r.instantiateHierarchy(s,t,i);return s}}Z.prototype.registerInstancedBuffer=function(n,e){if(this._userInstancedBuffersStorage?.vertexBuffers[n]?.dispose(),!this.instancedBuffers){this.instancedBuffers={};for(const t of this.instances)t.instancedBuffers={}}this._userInstancedBuffersStorage||(this._userInstancedBuffersStorage={data:{},vertexBuffers:{},strides:{},sizes:{},vertexArrayObjects:this.getEngine().getCaps().vertexArrayObject?{}:void 0}),this.instancedBuffers[n]=null,this._userInstancedBuffersStorage.strides[n]=e,this._userInstancedBuffersStorage.sizes[n]=e*32,this._userInstancedBuffersStorage.data[n]=new Float32Array(this._userInstancedBuffersStorage.sizes[n]),this._userInstancedBuffersStorage.vertexBuffers[n]=new O(this.getEngine(),this._userInstancedBuffersStorage.data[n],n,!0,!1,e,!0);for(const t of this.instances)t.instancedBuffers[n]=null;this._invalidateInstanceVertexArrayObject(),this._markSubMeshesAsAttributesDirty()};Z.prototype._processInstancedBuffers=function(n,e){const t=n?n.length:0;for(const i in this.instancedBuffers){let s=this._userInstancedBuffersStorage.sizes[i];const r=this._userInstancedBuffersStorage.strides[i],a=(t+1)*r;for(;s<a;)s*=2;this._userInstancedBuffersStorage.data[i].length!=s&&(this._userInstancedBuffersStorage.data[i]=new Float32Array(s),this._userInstancedBuffersStorage.sizes[i]=s,this._userInstancedBuffersStorage.vertexBuffers[i]&&(this._userInstancedBuffersStorage.vertexBuffers[i].dispose(),this._userInstancedBuffersStorage.vertexBuffers[i]=null));const o=this._userInstancedBuffersStorage.data[i];let c=0;if(e){const u=this.instancedBuffers[i];u.toArray?u.toArray(o,c):u.copyToArray?u.copyToArray(o,c):o[c]=u,c+=r}for(let u=0;u<t;u++){const f=n[u].instancedBuffers[i];f.toArray?f.toArray(o,c):f.copyToArray?f.copyToArray(o,c):o[c]=f,c+=r}this._userInstancedBuffersStorage.vertexBuffers[i]?this._userInstancedBuffersStorage.vertexBuffers[i].updateDirectly(o,0):(this._userInstancedBuffersStorage.vertexBuffers[i]=new O(this.getEngine(),this._userInstancedBuffersStorage.data[i],i,!0,!1,r,!0),this._invalidateInstanceVertexArrayObject())}};Z.prototype._invalidateInstanceVertexArrayObject=function(){if(!(!this._userInstancedBuffersStorage||this._userInstancedBuffersStorage.vertexArrayObjects===void 0)){for(const n in this._userInstancedBuffersStorage.vertexArrayObjects)this.getEngine().releaseVertexArrayObject(this._userInstancedBuffersStorage.vertexArrayObjects[n]);this._userInstancedBuffersStorage.vertexArrayObjects={}}};Z.prototype._disposeInstanceSpecificData=function(){for(const n in this._instanceDataStorage.renderPasses)this._instanceDataStorage.renderPasses[n].instancesBuffer?.dispose();for(this._instanceDataStorage.renderPasses={};this.instances.length;)this.instances[0].dispose();for(const n in this.instancedBuffers)this._userInstancedBuffersStorage.vertexBuffers[n]&&this._userInstancedBuffersStorage.vertexBuffers[n].dispose();this._invalidateInstanceVertexArrayObject(),this.instancedBuffers={}};Tt("BABYLON.InstancedMesh",Gb);class Hb extends fe{constructor(e,t,i=!0,s=!1){super(e,t,void 0,s),this._normalMatrix=new W,this._storeEffectOnSubMeshes=i}getEffect(){return this._storeEffectOnSubMeshes?this._activeEffect:super.getEffect()}isReady(e,t){return e?!this._storeEffectOnSubMeshes||!e.subMeshes||e.subMeshes.length===0?!0:this.isReadyForSubMesh(e,e.subMeshes[0],t):!1}_isReadyForSubMesh(e){const t=e.materialDefines;return!!(!this.checkReadyOnEveryCall&&e.effect&&t&&t._renderId===this.getScene().getRenderId())}bindOnlyWorldMatrix(e){this._activeEffect.setMatrix("world",e)}bindOnlyNormalMatrix(e){this._activeEffect.setMatrix("normalMatrix",e)}bind(e,t){t&&this.bindForSubMesh(e,t,t.subMeshes[0])}_afterBind(e,t=null,i){super._afterBind(e,t,i),this.getScene()._cachedEffect=t,i?i._drawWrapper._forceRebindOnNextCall=!1:this._drawWrapper._forceRebindOnNextCall=!1}_mustRebind(e,t,i,s=1){return i._drawWrapper._forceRebindOnNextCall||e.isCachedMaterialInvalid(this,t,s)}dispose(e,t,i){this._activeEffect=void 0,super.dispose(e,t,i)}}const Vg={effect:null,subMesh:null};
757class so extends Hb{constructor(e,t,i,s={},r=!0){super(e,t,r),this._textures={},this._internalTextures={},this._textureArrays={},this._externalTextures={},this._floats={},this._ints={},this._uints={},this._floatsArrays={},this._colors3={},this._colors3Arrays={},this._colors4={},this._colors4Arrays={},this._vectors2={},this._vectors3={},this._vectors4={},this._quaternions={},this._quaternionsArrays={},this._matrices={},this._matrixArrays={},this._matrices3x3={},this._matrices2x2={},this._vectors2Arrays={},this._vectors3Arrays={},this._vectors4Arrays={},this._uniformBuffers={},this._textureSamplers={},this._storageBuffers={},this._cachedWorldViewMatrix=new W,this._cachedWorldViewProjectionMatrix=new W,this._multiview=!1,this._materialHelperNeedsPreviousMatrices=!1,this._shaderPath=i,this._options={needAlphaBlending:!1,needAlphaTesting:!1,attributes:["position","normal","uv"],uniforms:["worldViewProjection"],uniformBuffers:[],samplers:[],externalTextures:[],samplerObjects:[],storageBuffers:[],defines:[],useClipPlane:!1,...s}}get shaderPath(){return this._shaderPath}set shaderPath(e){this._shaderPath=e}get options(){return this._options}get isMultiview(){return this._multiview}getClassName(){return"ShaderMaterial"}needAlphaBlending(){return this.alpha<1||this._options.needAlphaBlending}needAlphaTesting(){return this._options.needAlphaTesting}_checkUniform(e){this._options.uniforms.indexOf(e)===-1&&this._options.uniforms.push(e)}setTexture(e,t){return this._options.samplers.indexOf(e)===-1&&this._options.samplers.push(e),this._textures[e]=t,this}setInternalTexture(e,t){return this._options.samplers.indexOf(e)===-1&&this._options.samplers.push(e),this._internalTextures[e]=t,this}removeTexture(e){delete this._textures[e]}setTextureArray(e,t){return this._options.samplers.indexOf(e)===-1&&this._options.samplers.push(e),this._checkUniform(e),this._textureArrays[e]=t,this}setExternalTexture(e,t){return this._options.externalTextures.indexOf(e)===-1&&this._options.externalTextures.push(e),this._externalTextures[e]=t,this}setFloat(e,t){return this._checkUniform(e),this._floats[e]=t,this}setInt(e,t){return this._checkUniform(e),this._ints[e]=t,this}setUInt(e,t){return this._checkUniform(e),this._uints[e]=t,this}setFloats(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this}setColor3(e,t){return this._checkUniform(e),this._colors3[e]=t,this}setColor3Array(e,t){return this._checkUniform(e),this._colors3Arrays[e]=t.reduce((i,s)=>(i.push(s.r,s.g,s.b),i),[]),this}setColor4(e,t){return this._checkUniform(e),this._colors4[e]=t,this}setColor4Array(e,t){return this._checkUniform(e),this._colors4Arrays[e]=t.reduce((i,s)=>(i.push(s.r,s.g,s.b,s.a),i),[]),this}setVector2(e,t){return this._checkUniform(e),this._vectors2[e]=t,this}setVector3(e,t){return this._checkUniform(e),this._vectors3[e]=t,this}setVector4(e,t){return this._checkUniform(e),this._vectors4[e]=t,this}setQuaternion(e,t){return this._checkUniform(e),this._quaternions[e]=t,this}setQuaternionArray(e,t){return this._checkUniform(e),this._quaternionsArrays[e]=t.reduce((i,s)=>(s.toArray(i,i.length),i),[]),this}setMatrix(e,t){return this._checkUniform(e),this._matrices[e]=t,this}setMatrices(e,t){this._checkUniform(e);const i=new Float32Array(t.length*16);for(let s=0;s<t.length;s++)t[s].copyToArray(i,s*16);return this._matrixArrays[e]=i,this}setMatrix3x3(e,t){return this._checkUniform(e),this._matrices3x3[e]=t,this}setMatrix2x2(e,t){return this._checkUniform(e),this._matrices2x2[e]=t,this}setArray2(e,t){return this._checkUniform(e),this._vectors2Arrays[e]=t,this}setArray3(e,t){return this._checkUniform(e),this._vectors3Arrays[e]=t,this}setArray4(e,t){return this._checkUniform(e),this._vectors4Arrays[e]=t,this}setUniformBuffer(e,t){return this._options.uniformBuffers.indexOf(e)===-1&&this._options.uniformBuffers.push(e),this._uniformBuffers[e]=t,this}setTextureSampler(e,t){return this._options.samplerObjects.indexOf(e)===-1&&this._options.samplerObjects.push(e),this._textureSamplers[e]=t,this}setStorageBuffer(e,t){return this._options.storageBuffers.indexOf(e)===-1&&this._options.storageBuffers.push(e),this._storageBuffers[e]=t,this}setDefine(e,t){const i=e.trimEnd()+" ",s=this.options.defines.findIndex(r=>r===e||r.startsWith(i));return s>=0&&this.options.defines.splice(s,1),(typeof t!="boolean"||t)&&this.options.defines.push(i+t),this}isReadyForSubMesh(e,t,i){return this.isReady(e,i,t)}isReady(e,t,i){const s=i&&this._storeEffectOnSubMeshes;if(this.isFrozen){const C=s?i._drawWrapper:this._drawWrapper;if(C.effect&&C._wasPreviouslyReady&&C._wasPreviouslyUsingInstances===t)return!0}const r=this.getScene(),a=r.getEngine(),o=[],c=[];let u=null,d=this._shaderPath,f=this._options.uniforms,g=this._options.uniformBuffers,m=this._options.samplers;a.getCaps().multiview&&r.activeCamera&&r.activeCamera.outputRenderTarget&&r.activeCamera.outputRenderTarget.getViewCount()>1&&(this._multiview=!0,o.push("#define MULTIVIEW"),f.indexOf("viewProjection")!==-1&&f.indexOf("viewProjectionR")===-1&&f.push("viewProjectionR"));for(let C=0;C<this._options.defines.length;C++){const M=this._options.defines[C].indexOf("#define")===0?this._options.defines[C]:`#define ${this._options.defines[C]}`;o.push(M)}for(let C=0;C<this._options.attributes.length;C++)c.push(this._options.attributes[C]);if(e&&e.isVerticesDataPresent(O.ColorKind)&&(c.indexOf(O.ColorKind)===-1&&c.push(O.ColorKind),o.push("#define VERTEXCOLOR")),t&&(o.push("#define INSTANCES"),Uf(c,this._materialHelperNeedsPreviousMatrices),e?.hasThinInstances&&(o.push("#define THIN_INSTANCES"),e&&e.isVerticesDataPresent(O.ColorInstanceKind)&&(c.push(O.ColorInstanceKind),o.push("#define INSTANCESCOLOR")))),e&&e.useBones&&e.computeBonesUsingShaders&&e.skeleton){c.push(O.MatricesIndicesKind),c.push(O.MatricesWeightsKind),e.numBoneInfluencers>4&&(c.push(O.MatricesIndicesExtraKind),c.push(O.MatricesWeightsExtraKind)
757);const C=e.skeleton;o.push("#define NUM_BONE_INFLUENCERS "+e.numBoneInfluencers),u=new eu,u.addCPUSkinningFallback(0,e),C.isUsingTextureForMatrices?(o.push("#define BONETEXTURE"),f.indexOf("boneTextureWidth")===-1&&f.push("boneTextureWidth"),this._options.samplers.indexOf("boneSampler")===-1&&this._options.samplers.push("boneSampler")):(o.push("#define BonesPerMesh "+(C.bones.length+1)),f.indexOf("mBones")===-1&&f.push("mBones"))}else o.push("#define NUM_BONE_INFLUENCERS 0");let b=0;const x=e?e.morphTargetManager:null;if(x){const C=o.indexOf("#define UV1")!==-1,M=o.indexOf("#define UV2")!==-1,F=o.indexOf("#define TANGENT")!==-1,U=o.indexOf("#define NORMAL")!==-1,k=o.indexOf("#define VERTEXCOLOR")!==-1;b=Lb(x,o,c,e,!0,U,F,C,M,k),x.isUsingTextureForTargets&&(f.indexOf("morphTargetTextureIndices")===-1&&f.push("morphTargetTextureIndices"),this._options.samplers.indexOf("morphTargets")===-1&&this._options.samplers.push("morphTargets")),b>0&&(f=f.slice(),f.push("morphTargetInfluences"),f.push("morphTargetCount"),f.push("morphTargetTextureInfo"),f.push("morphTargetTextureIndices"))}else o.push("#define NUM_MORPH_INFLUENCERS 0");if(e){const C=e.bakedVertexAnimationManager;C&&C.isEnabled&&(o.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),f.indexOf("bakedVertexAnimationSettings")===-1&&f.push("bakedVertexAnimationSettings"),f.indexOf("bakedVertexAnimationTextureSizeInverted")===-1&&f.push("bakedVertexAnimationTextureSizeInverted"),f.indexOf("bakedVertexAnimationTime")===-1&&f.push("bakedVertexAnimationTime"),this._options.samplers.indexOf("bakedVertexAnimationTexture")===-1&&this._options.samplers.push("bakedVertexAnimationTexture"),t&&c.push("bakedVertexAnimationSettingsInstanced"))}for(const C in this._textures)if(!this._textures[C].isReady())return!1;for(const C in this._internalTextures)if(!this._internalTextures[C].isReady)return!1;e&&this.needAlphaTestingForMesh(e)&&o.push("#define ALPHATEST"),this._options.useClipPlane!==!1&&(Nf(f),wb(this,r,o)),r.fogEnabled&&e?.applyFog&&r.fogMode!==Pt.FOGMODE_NONE&&(o.push("#define FOG"),f.indexOf("view")===-1&&f.push("view"),f.indexOf("vFogInfos")===-1&&f.push("vFogInfos"),f.indexOf("vFogColor")===-1&&f.push("vFogColor")),this._useLogarithmicDepth&&(o.push("#define LOGARITHMICDEPTH"),f.indexOf("logarithmicDepthConstant")===-1&&f.push("logarithmicDepthConstant")),this.customShaderNameResolve&&(f=f.slice(),g=g.slice(),m=m.slice(),d=this.customShaderNameResolve(this.name,f,g,m,o,c));const v=i?i.getRenderingMesh():e;if(v&&this.useVertexPulling){o.push("#define USE_VERTEX_PULLING");const C=v.geometry?.getIndexBuffer();C&&(o.push("#define VERTEX_PULLING_USE_INDEX_BUFFER"),C.is32Bits&&o.push("#define VERTEX_PULLING_INDEX_BUFFER_32BITS"))}const E=s?i._getDrawWrapper(void 0,!0):this._drawWrapper,A=E?.effect??null,D=E?.defines??null,I=o.join(` 758`);let R=A;return D!==I&&(R=a.createEffect(d,{attributes:c,uniformsNames:f,uniformBuffersNames:g,samplers:m,defines:I,fallbacks:u,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousMorphTargets:b},shaderLanguage:this._options.shaderLanguage,extraInitializationsAsync:this._options.extraInitializationsAsync},a),s?i.setEffect(R,I,this._materialContext):E&&E.setEffect(R,I),this._onEffectCreatedObservable&&(Vg.effect=R,Vg.subMesh=i??e?.subMeshes[0]??null,this._onEffectCreatedObservable.notifyObservers(Vg))),E._wasPreviouslyUsingInstances=!!t,R?.isReady()?(A!==R&&r.resetCachedMaterial(),E._wasPreviouslyReady=!0,!0):!1}bindOnlyWorldMatrix(e,t){const i=t??this.getEffect();if(!i)return;const s=this._options.uniforms;s.indexOf("world")!==-1&&i.setMatrix("world",e);const r=this.getScene();s.indexOf("worldView")!==-1&&(e.multiplyToRef(r.getViewMatrix(),this._cachedWorldViewMatrix),i.setMatrix("worldView",this._cachedWorldViewMatrix)),s.indexOf("worldViewProjection")!==-1&&(e.multiplyToRef(r.getTransformMatrix(),this._cachedWorldViewProjectionMatrix),i.setMatrix("worldViewProjection",this._cachedWorldViewProjectionMatrix)),s.indexOf("view")!==-1&&i.setMatrix("view",r.getViewMatrix())}bindForSubMesh(e,t,i){this.bind(e,t,i._drawWrapperOverride?.effect,i)}bind(e,t,i,s){const r=s&&this._storeEffectOnSubMeshes,a=i??(r?s.effect:this.getEffect());if(!a)return;const o=this.getScene();this._activeEffect=a,this.bindOnlyWorldMatrix(e,i);const c=this._options.uniformBuffers;let u=!1;if(a&&c&&c.length>0&&o.getEngine().supportsUniformBuffers)for(let f=0;f<c.length;++f)switch(c[f]){case"Mesh":t&&(t.getMeshUniformBuffer().bindToEffect(a,"Mesh"),t.transferToEffect(e));break;case"Scene":Nb(a,o.getSceneUniformBuffer()),o.finalizeSceneUbo(),u=!0;break}const d=t&&r?this._mustRebind(o,a,s,t.visibility):o.getCachedMaterial()!==this;if(a&&d){!u&&this._options.uniforms.indexOf("view")!==-1&&a.setMatrix("view",o.getViewMatrix()),!u&&this._options.uniforms.indexOf("projection")!==-1&&a.setMatrix("projection",o.getProjectionMatrix()),!u&&this._options.uniforms.indexOf("viewProjection")!==-1&&(a.setMatrix("viewProjection",o.getTransformMatrix()),this._multiview&&a.setMatrix("viewProjectionR",o._transformMatrixR)),o.activeCamera&&this._options.uniforms.indexOf("cameraPosition")!==-1&&a.setVector3("cameraPosition",o.activeCamera.globalPosition),Bb(t,a),Bf(a,this,o),this._useLogarithmicDepth&&Fb(r?s.materialDefines:a.defines,a,o),t&&wC(o,t,a);let f;for(f in this._textures)a.setTexture(f,this._textures[f]);for(f in this._internalTextures)a._bindTexture(f,this._internalTextures[f]);for(f in this._textureArrays)a.setTextureArray(f,this._textureArrays[f]);
vendor: 5,362 bytes, line 758
758for(f in this._ints)a.setInt(f,this._ints[f]);for(f in this._uints)a.setUInt(f,this._uints[f]);for(f in this._floats)a.setFloat(f,this._floats[f]);for(f in this._floatsArrays)a.setArray(f,this._floatsArrays[f]);for(f in this._colors3)a.setColor3(f,this._colors3[f]);for(f in this._colors3Arrays)a.setArray3(f,this._colors3Arrays[f]);for(f in this._colors4){const v=this._colors4[f];a.setFloat4(f,v.r,v.g,v.b,v.a)}for(f in this._colors4Arrays)a.setArray4(f,this._colors4Arrays[f]);for(f in this._vectors2)a.setVector2(f,this._vectors2[f]);for(f in this._vectors3)a.setVector3(f,this._vectors3[f]);for(f in this._vectors4)a.setVector4(f,this._vectors4[f]);for(f in this._quaternions)a.setQuaternion(f,this._quaternions[f]);for(f in this._matrices)a.setMatrix(f,this._matrices[f]);for(f in this._matrixArrays)a.setMatrices(f,this._matrixArrays[f]);for(f in this._matrices3x3)a.setMatrix3x3(f,this._matrices3x3[f]);for(f in this._matrices2x2)a.setMatrix2x2(f,this._matrices2x2[f]);for(f in this._vectors2Arrays)a.setArray2(f,this._vectors2Arrays[f]);for(f in this._vectors3Arrays)a.setArray3(f,this._vectors3Arrays[f]);for(f in this._vectors4Arrays)a.setArray4(f,this._vectors4Arrays[f]);for(f in this._quaternionsArrays)a.setArray4(f,this._quaternionsArrays[f]);for(f in this._uniformBuffers){const v=this._uniformBuffers[f].getBuffer();v&&a.bindUniformBuffer(v,f)}const g=o.getEngine(),m=g.setExternalTexture;if(m)for(f in this._externalTextures)m.call(g,f,this._externalTextures[f]);const b=g.setTextureSampler;if(b)for(f in this._textureSamplers)b.call(g,f,this._textureSamplers[f]);const x=g.setStorageBuffer;if(x)for(f in this._storageBuffers)x.call(g,f,this._storageBuffers[f])}if(a&&t&&(d||!this.isFrozen)){kf(t,a),t.morphTargetManager&&t.morphTargetManager.isUsingTextureForTargets&&t.morphTargetManager._bind(a);const f=t.bakedVertexAnimationManager;if(f&&f.isEnabled){const g=r?s._drawWrapper:this._drawWrapper;t.bakedVertexAnimationManager?.bind(a,!!g._wasPreviouslyUsingInstances)}}this._afterBind(t,a,s)}getActiveTextures(){const e=super.getActiveTextures();for(const t in this._textures)e.push(this._textures[t]);for(const t in this._textureArrays){const i=this._textureArrays[t];for(let s=0;s<i.length;s++)e.push(i[s])}return e}hasTexture(e){if(super.hasTexture(e))return!0;for(const i in this._textures)if(this._textures[i]===e)return!0;const t=e.getInternalTexture();for(const i in this._internalTextures)if(this._internalTextures[i]===t)return!0;for(const i in this._textureArrays){const s=this._textureArrays[i];for(let r=0;r<s.length;r++)if(s[r]===e)return!0}return!1}clone(e){const t=$e.Clone(()=>new so(e,this.getScene(),this._shaderPath,this._options,this._storeEffectOnSubMeshes),this);t.name=e,t.id=e,typeof t._shaderPath=="object"&&(t._shaderPath={...t._shaderPath}),this._options={...this._options};const i=Object.keys(this._options);for(const s of i){const r=this._options[s];Array.isArray(r)&&(this._options[s]=r.slice(0))}this.stencil.copyTo(t.stencil);for(const s in this._textures)t.setTexture(s,this._textures[s]);for(const s in this._internalTextures)t.setInternalTexture(s,this._internalTextures[s]);for(const s in this._textureArrays)t.setTextureArray(s,this._textureArrays[s]);for(const s in this._externalTextures)t.setExternalTexture(s,this._externalTextures[s]);for(const s in this._ints)t.setInt(s,this._ints[s]);for(const s in this._uints)t.setUInt(s,this._uints[s]);for(const s in this._floats)t.setFloat(s,this._floats[s]);for(const s in this._floatsArrays)t.setFloats(s,this._floatsArrays[s]);for(const s in this._colors3)t.setColor3(s,this._colors3[s]);for(const s in this._colors3Arrays)t._colors3Arrays[s]=this._colors3Arrays[s];for(const s in this._colors4)t.setColor4(s,this._colors4[s]);for(const s in this._colors4Arrays)t._colors4Arrays[s]=this._colors4Arrays[s];for(const s in this._vectors2)t.setVector2(s,this._vectors2[s]);for(const s in this._vectors3)t.setVector3(s,this._vectors3[s]);for(const s in this._vectors4)t.setVector4(s,this._vectors4[s]);for(const s in this._quaternions)t.setQuaternion(s,this._quaternions[s]);for(const s in this._quaternionsArrays)t._quaternionsArrays[s]=this._quaternionsArrays[s];for(const s in this._matrices)t.setMatrix(s,this._matrices[s]);for(const s in this._matrixArrays)t._matrixArrays[s]=this._matrixArrays[s].slice();for(const s in this._matrices3x3)t.setMatrix3x3(s,this._matrices3x3[s]);for(const s in this._matrices2x2)t.setMatrix2x2(s,this._matrices2x2[s]);for(const s in this._vectors2Arrays)t.setArray2(s,this._vectors2Arrays[s]);for(const s in this._vectors3Arrays)t.setArray3(s,this._vectors3Arrays[s]);for(const s in this._vectors4Arrays)t.setArray4(s,this._vectors4Arrays[s]);for(const s in this._uniformBuffers)t.setUniformBuffer(s,this._uniformBuffers[s]);for(const s in this._textureSamplers)t.setTextureSampler(s,this._textureSamplers[s]);for(const s in this._storageBuffers)t.setStorageBuffer(s,this._storageBuffers[s]);return t}dispose(e,t,i){if(t){let s;for(s in this._textures)this._textures[s].dispose();for(s in this._internalTextures)this._internalTextures[s].dispose();for(s in this._textureArrays){const r=this._textureArrays[s];for(let a=0;a<r.length;a++)r[a].dispose()}}this._textures={},this._internalTextures={},super.dispose(e,t,i)}serialize(){const e=$e.Serialize(this);e.customType="BABYLON.ShaderMaterial",e.uniqueId=this.uniqueId,e.o
758ptions=this._options,e.shaderPath=this._shaderPath,e.storeEffectOnSubMeshes=this._storeEffectOnSubMeshes;let t;e.stencil=this.stencil.serialize(),e.textures={};for(t in this._textures)e.textures[t]=this._textures[t].serialize();e.textureArrays={};for(t in this._textureArrays){e.textureArrays[t]=[];const i=this._textureArrays[t];for(let s=0;s<i.length;s++)e.textureArrays[t].push(i[s].serialize())}e.ints={};for(t in this._ints)e.ints[t]=this._ints[t];e.uints={};for(t in this._uints)e.uints[t]=this._uints[t];e.floats={};for(t in this._floats)e.floats[t]=this._floats[t];e.floatsArrays={};for(t in this._floatsArrays)e.floatsArrays[t]=this._floatsArrays[t];e.colors3={};for(t in this._colors3){const i=this._colors3[t];e.colors3[t]=[i.r,i.g,i.b]}e.colors3Arrays={};for(t in this._colors3Arrays)e.colors3Arrays[t]=this._colors3Arrays[t];e.colors4={};for(t in this._colors4){const i=this._colors4[t];e.colors4[t]=[i.r,i.g,i.b,i.a]}e.colors4Arrays={};for(t in this._colors4Arrays)e.colors4Arrays[t]=this._colors4Arrays[t];e.vectors2={};for(t in this._vectors2){const i=this._vectors2[t];e.vectors2[t]=[i.x,i.y]}e.vectors3={};for(t in this._vectors3){const i=this._vectors3[t];e.vectors3[t]=[i.x,i.y,i.z]}e.vectors4={};for(t in this._vectors4){const i=this._vectors4[t];e.vectors4[t]=[i.x,i.y,i.z,i.w]}e.quaternions={};for(t in this._quaternions)e.quaternions[t]=this._quaternions[t].asArray();e.matrices={};for(t in this._matrices)e.matrices[t]=this._matrices[t].asArray();e.matrixArray={};for(t in this._matrixArrays)e.matrixArray[t]=this._matrixArrays[t];e.matrices3x3={};for(t in this._matrices3x3)e.matrices3x3[t]=this._matrices3x3[t];e.matrices2x2={};for(t in this._matrices2x2)e.matrices2x2[t]=this._matrices2x2[t];e.vectors2Arrays={};for(t in this._vectors2Arrays)e.vectors2Arrays[t]=this._vectors2Arrays[t];e.vectors3Arrays={};for(t in this._vectors3Arrays)e.vectors3Arrays[t]=this._vectors3Arrays[t];e.vectors4Arrays={};for(t in this._vectors4Arrays)e.vectors4Arrays[t]=this._vectors4Arrays[t];e.quaternionsArrays={};for(t in this._quaternionsArrays)e.quaternionsArrays[t]=this._quaternionsArrays[t];return e}static Parse(e,t,i){const s=$e.Parse(()=>new so(e.name,t,e.shaderPath,e.options,e.storeEffectOnSubMeshes),e,t,i);let r;e.stencil&&s.stencil.parse(e.stencil,t,i);for(r in e.textures)s.setTexture(r,Te.Parse(e.textures[r],t,i));for(r in e.textureArrays){const a=e.textureArrays[r],o=[];for(let c=0;c<a.length;c++)o.push(Te.Parse(a[c],t,i));s.setTextureArray(r,o)}for(r in e.ints)s.setInt(r,e.ints[r]);for(r in e.uints)s.setUInt(r,e.uints[r]);for(r in e.floats)s.setFloat(r,e.floats[r]);for(r in e.floatsArrays)s.setFloats(r,e.floatsArrays[r]);for(r in e.colors3){const a=e.colors3[r];s.setColor3(r,{r:a[0],g:a[1],b:a[2]})}for(r in e.colors3Arrays){const a=e.colors3Arrays[r].reduce((o,c,u)=>(u%3===0?o.push([c]):o[o.length-1].push(c),o),[]).map(o=>({r:o[0],g:o[1],b:o[2]}));s.setColor3Array(r,a)}for(r in e.colors4){const a=e.colors4[r];s.setColor4(r,{r:a[0],g:a[1],b:a[2],a:a[3]})}for(r in e.colors4Arrays){const a=e.colors4Arrays[r].reduce((o,c,u)=>(u%4===0?o.push([c]):o[o.length-1].push(c),o),[]).map(o=>({r:o[0],g:o[1],b:o[2],a:o[3]}));s.setColor4Array(r,a)}for(r in e.vectors2){const a=e.vectors2[r];s.setVector2(r,{x:a[0],y:a[1]})}for(r in e.vectors3){const a=e.vectors3[r];s.setVector3(r,{x:a[0],y:a[1],z:a[2]})}for(r in e.vectors4){const a=e.vectors4[r];s.setVector4(r,{x:a[0],y:a[1],z:a[2],w:a[3]})}for(r in e.quaternions)s.setQuaternion(r,Se.FromArray(e.quaternions[r]));for(r in e.matrices)s.setMatrix(r,W.FromArray(e.matrices[r]));for(r in e.matrixArray)s._matrixArrays[r]=new Float32Array(e.matrixArray[r]);for(r in e.matrices3x3)s.setMatrix3x3(r,e.matrices3x3[r]);for(r in e.matrices2x2)s.setMatrix2x2(r,e.matrices2x2[r]);for(r in e.vectors2Arrays)s.setArray2(r,e.vectors2Arrays[r]);for(r in e.vectors3Arrays)s.setArray3(r,e.vectors3Arrays[r]);for(r in e.vectors4Arrays)s.setArray4(r,e.vectors4Arrays[r]);for(r in e.quaternionsArrays)s.setArray4(r,e.quaternionsArrays[r]);return s}static async ParseFromFileAsync(e,t,i,s=""){return await new Promise((r,a)=>{const o=new Ai;o.addEventListener("readystatechange",()=>{if(o.readyState==4)if(o.status==200){const c=JSON.parse(o.responseText),u=this.Parse(c,i||Ke.L
758astCreatedScene,s);e&&(u.name=e),r(u)}else a("Unable to load the ShaderMaterial")}),o.open("GET",t),o.send()})}static async ParseFromSnippetAsync(e,t,i=""){return await new Promise((s,r)=>{const a=new Ai;a.addEventListener("readystatechange",()=>{if(a.readyState==4)if(a.status==200){const o=JSON.parse(JSON.parse(a.responseText).jsonPayload),c=JSON.parse(o.shaderMaterial),u=this.Parse(c,t||Ke.LastCreatedScene,i);u.snippetId=e,s(u)}else r("Unable to load the snippet "+e)}),a.open("GET",this.SnippetUrl+"/"+e.replace(/#/g,"/")),a.send()})}}so.SnippetUrl="https://snippet.babylonjs.com";so.CreateFromSnippetAsync=so.ParseFromSnippetAsync;Tt("BABYLON.ShaderMaterial",so);Z._LinesMeshParser=(n,e)=>ta.Parse(n,e);class ta extends Z{_isShaderMaterial(e){return e?e.getClassName()==="ShaderMaterial":!1}constructor(e,t=null,i=null,s=null,r,a,o,c){super(e,t,i,s,r),this.useVertexColor=a,this.useVertexAlpha=o,this.color=new Ne(1,1,1),this.alpha=1,this._shaderLanguage=0,this._ownsMaterial=!1,s&&(this.color=s.color.clone(),this.alpha=s.alpha,this.useVertexColor=s.useVertexColor,this.useVertexAlpha=s.useVertexAlpha),this.intersectionThreshold=.1;const u=[],d={attributes:[O.PositionKind],uniforms:["world","viewProjection"],needAlphaBlending:!0,defines:u,useClipPlane:null,shaderLanguage:0};if(this.useVertexAlpha?d.defines.push("#define VERTEXALPHA"):d.needAlphaBlending=!1,this.useVertexColor?(d.defines.push("#define VERTEXCOLOR"),d.attributes.push(O.ColorKind)):(d.uniforms.push("color"),this._color4=new Ze),c)this.material=c;else{this.getScene().getEngine().isWebGPU&&!ta.ForceGLSL&&(this._shaderLanguage=1),d.shaderLanguage=this._shaderLanguage,d.extraInitializationsAsync=async()=>{this._shaderLanguage===1?await Promise.all([_t(()=>import("./color.vertex-BSgtbXOA.js"),__vite__mapDeps([22,15,23,20])),_t(()=>import("./color.fragment-B8wxVUHr.js"),__vite__mapDeps([24,13,25]))]):await Promise.all([_t(()=>import("./color.vertex-9w8zoa9W.js"),[]),_t(()=>import("./color.fragment-XElLe57Y.js"),[])])};const g=new so("colorShader",this.getScene(),"color",d,!1);g.doNotSerialize=!0,this._ownsMaterial=!0,this._setInternalMaterial(g)}}getClassName(){return"LinesMesh"}get material(){return this._internalAbstractMeshDataInfo._material}set material(e){const t=this.material;if(t===e)return;const i=t&&this._ownsMaterial;this._ownsMaterial=!1,this._setInternalMaterial(e),i&&t?.dispose()}_setInternalMaterial(e){this._setMaterial(e),this.material&&(this.material.fillMode=fe.LineListDrawMode,this.material.disableLighting=!0)}get checkCollisions(){return!1}set checkCollisions(e){}_bind(e,t){if(!this._geometry)return this;const i=this.isUnIndexed?null:this._geometry.getIndexBuffer();if(!this._userInstancedBuffersStorage||this.hasThinInstances?this._geometry._bind(t,i):this._geometry._bind(t,i,this._userInstancedBuffersStorage.vertexBuffers,this._userInstancedBuffersStorage.vertexArrayObjects),!this.useVertexColor&&this._isShaderMaterial(this.material)){const{r:s,g:r,b:a}=this.color;this._color4.set(s,r,a,this.alpha),this.material.setColor4("color",this._color4)}return this}_draw(e,t,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;const s=this.getScene().getEngine();return this._unIndexed?s.drawArraysType(fe.LineListDrawMode,e.verticesStart,e.verticesCount,i):s.drawElementsType(fe.LineListDrawMode,e.indexStart,e.indexCount,i),this}dispose(e,t=!1,i){i||(this._ownsMaterial?this.material?.dispose(!1,!1,!0):t&&this.material?.dispose(!1,!1,!0)),super.dispose(e)}clone(e,t=null,i){if(t&&t._addToSceneRootNodes===void 0){const s=t;return s.source=this,new ta(e,this.getScene(),s.parent,s.source,s.doNotCloneChildren)}return new ta(e,this.getScene(),t,this,i)}createInstance(e){const t=new dV(e,this);if(this.instancedBuffers){t.instancedBuffers={};for(const i in this.instancedBuffers)t.instancedBuffers[i]=this.instancedBuffers[i]}return t}serialize(e){super.serialize(e),e.color=this.color.asArray(),e.alpha=this.alpha}static Parse(e,t){const i=new ta(e.name,t);return i.color=Ne.FromArray(e.color),i.alpha=e.alpha,i}}ta.ForceGLSL=!1;class dV extends Gb{constructor(e,t){super(e,t),this.intersectionThreshold=t.intersectionThreshold}getClassName(){return"InstancedLinesMesh"}}function hI(n){const e=[],t=[],i=n.lines,s=n.colors,r=[];let a=0;for(let c=0;c<i.length;c++){const u=i[c];for(let d=0;d<u.length;d++){const{x:f,y:g,z:m}=u[d];if(t.push(f,g,m),s){const b=s[c],{r:x,g:v,b:E,a:A}=b[d];r.push(x,v,E,A)}d>0&&(e.push(a-1),e.push(a)),a++}}const o=new ve;return o.indices=e,o.positions=t,s&&(o.colors=r),o}function uI(n){const e=n.dashSize||3,t=n.gapSize||1,i=n.dashNb||200,s=n.points,r=[],a=[],o=T.Zero();let c=0,u=0,d=0,f=0,g=0,m=0,b=0;for(b=0;b<s.length-1;b++)s[b+1].subtractToRef(s[b],o),c+=o.length();for(d=c/i,f=e*d/(e+t),b=0;b<s.length-1;b++){s[b+1].subtractToRef(s[b],o),u=Math.floor(o.length()/d),o.normalize();for(let v=0;v<u;v++)g=d*v,r.push(s[b].x+g*o.x,s[b].y+g*o.y,s[b].z+g*o.z),r.push(s[b].x+(g+f)*o.x,s[b].y+(g+f)*o.y,s[b].z+(g+f)*o.z),a.push(m,m+1),m+=2}const x=new ve;return x.positions=r,x.indices=a,x}function dI(n,e,t=null){const i=e.instance,s=e.lines,r=e.colors;if(i){const u=i.getVerticesData(O.PositionKind);let d,f;r&&(d=i.getVerticesData(O.ColorKind));let g=0,m=0;for(let b=0;b<s.length;b++){const x=s[b];for(let v=0;v<x.length;v++)u[g]=x[v].x,u[g+1]=x[v].y,u[g+2]=x[v].z,r&&d&&(f=r[b],d[m]=f[v].r,d[m+1]=f[v].g,d[m+2]=f[v].b,d[m+3]=f[v].a,m+=4),g+=3}return i.updateVerticesData(O.PositionKind,u,!1,!1),r&&d&&i.updateVerticesData(O.ColorKind,d,!1,!1),i.refreshBoundingInfo(),i}const a=!!r,o=new ta(n,t,null,void 0,void 0,a,e.useVertexAlpha,e.material);return hI(e).applyToMesh(o,e.updatable),o}function Wb(n,e,t=null){const i=e.colors?[e.colors]:null;return dI(n,{lines:[e.points],updatable:e.updatable,instance:e.instance,colors:i,useVertexAlpha:e.useVertexAlpha,material:e.material},t)}function fI(n,e,t=null){const i=e.points,s=e.instance,r=e.gapSize||1,a=e.dashSize||3;if(s){const u=d=>{const f=T.Zero(),g=d.length/6;let m=0,b=0,x=0,v=0,E=0,A=0,D=0,I=0;for(D=0;D<i.length-1;D++)i[D+1].subtractToRef(i[D],f),m+=f.length();x=m/g;const R=s._creationDataStorage.dashSize,C=s._creationDataStorage.gapSize;for(v=R*x/(R+C),D=0;D<i.length-1;D++)for(i[D+1].subtractToRef(i[D],f),b=Math.floor(f.length()/x),f.normalize(),I=0;I<b&&A<d.length;)E=x*I,d[A]=i[D].x+E*f.x,d[A+1]=i[D].y+E*f.y,d[A+2]=i[D].z+E*f.z,d[A+3]=i[D].x+(E+v)*f.x,d[A+4]=i[D].y+(E+v)*f.y,d[A+5]=i[D].z+(E+v)*f.z,A+=6,I++;for(;A<d.length;)d[A]=i[D].x,d[A+1]=i[D].y,d[A+2]=i[D].z,A+=3};return(e.dashNb||e.dashSize||e.gapSize||e.useVertexAlpha||e.material)&&oe.Warn("You have used an option other than points with the instance option. Please be aware that these other options will be ignored."),s.updateMeshPositions(u,!1),s}const o=new ta(n,t,null,void 0,void 0,void 0,e.useVertexAlpha,e.material);return uI(e).applyToMesh(o,e.updatable),o._creationDataStorage=new BC,o._creationDataStorage.dashSize=a,o._creationDataStorage.gapSize=r,o}ve.CreateLineSystem=hI;ve.CreateDashedLines=uI;Z.CreateLines=(n,e,t=null,i=!1,s=null)=>Wb(n,{points:e,updatable:i,instance:s},t);Z.CreateDashedLines=(n,e,t,i,s,r=null,a,o)=>fI(n,{points:e,dashSize:t,gapSize:i,dashNb:s,updatable:a,instance:o},r);class fV extends Ie{constructor(e,t){super(e.x,e.y),this.index=t}}class zg{constructor(){this.elements=[]}add(e){const t=[];for(const i of e){const s=new fV(i,this.elements.length);t.push(s),this.elements.push(s)}return t}computeBounds(){const e=new Ie(this.elements[0].x,this.elements[0].y),t=new Ie(this.elements[0].x,this.elements[0].y);for(const i of this.elements)i.x<e.x?e.x=i.x:i.x>t.x&&(t.x=i.x),i.y<e.y?e.y=i.y:i.y>t.y&&(t.y=i.y);return{min:e,max:t,width:t.x-e.x,height:t.y-e.y}}}class pV{_addToepoint(e){for(const t of e)this._epoints.push(t.x,t.y)}constructor(e,t,i,s=earcut){this._points=new zg,this._outlinepoints=new zg,this._holes=new Array,this._epoints=new Array,this._eholes=new Array,this.bjsEarcut=s,this._name=e,this._scene=i||Ke.LastCreatedScene;let r;t instanceof Ff?r=t.getPoints():r=t,this._addToepoint(r),this._points.add(r),this._outlinepoints.add(r),typeof this.bjsEarcut>"u"&&oe.Warn("Earcut was not found, the polygon will not be built.")}addHole(e){this._points.add(e);const t=new zg;return t.add(e),this._holes.push(t),this._eholes.push(this._epoints.length/2),this._addToepoint(e),this}build(e=!1,t=0,i=2){const s=new Z(this._name,this._scene),r=this.buildVertexData(t,i);return s.setVerticesData(O.PositionKind,r.positions,e),s.setVerticesData(O.NormalKind,r.normals,e),s.setVerticesData(O.UVKind,r.uvs,e),s.setIndices(r.indices),s}buildVertexData(e=0,t=2){const i=new ve,s=[],r=[],a=[],o=this._points.computeBounds();for(const d of this._points.elements)s.push(0,1,0),r.push(d.x,0,d.y),a.push((d.x-o.min.x)/o.width,(d.y-o.min.y)/o.height);const c=[],u=this.bjsEarcut(this._epoints,this._eholes,2);for(let d=0;d<u.length;d++)c.push(u[d]);if(e>0){const d=r.length/3;for(const g of this._points.elements)s.push(0,-1,0),r.push(g.x,-e,g.y),a.push(1-(g.x-o.min.x)/o.width,1-(g.y-o.min.y)/o.height);const f=c.length;for(let g=0;g<f;g+=3){const m=c[g+0],b=c[g+1],x=c[g+2];c.push(x+d),c.push(b+d),c.push(m+d)}this._addSide(r,s,a,c,o,this._outlinepoints,e,!1,t);for(const g of this._holes)this._addSide(r,s,a,c,o,g,e,!0,t)}return i.indices=c,i.positions=r,i.normals=s,i.uvs=a,i}_addSide(e,t,i,s,r,a,o,c,u){let d=e.length/3,f=0;for(let g=0;g<a.elements.length;g++){const m=a.elements[g],b=a.elements[(g+1)%a.elements.length];e.push(m.x,0,m.y),e.push(m.x,-o,m.y),e.push(b.x,0,b.y),e.push(b.x,-o,b.y);const x=a.elements[(g+a.elements.length-1)%a.elements.length],v=a.elements[(g+2)%a.elements.length];let E=new T(-(b.y-m.y),0,b.x-m.x),A=new T(-(m.y-x.y),0,m.x-x.x),D=new T(-(v.y-b.y),0,v.x-b.x);c||(E=E.scale(-1),A=A.scale(-1),D=D.scale(-1));const I=E.normalizeToNew();let R=A.normalizeToNew(),C=D.normalizeToNew();const M=T.Dot(R,I);M>u?M<bt-1?R=new T(m.x,0,m.y).subtract(new T(b.x,0,b.y)).normalize():R=A.add(E).normalize():R=I;const F=T.Dot(D,E);F>u?F<bt-1?C=new T(b.x,0,b.y).subtract(new T(m.x,0,m.y)).normalize():C=D.add(E).normalize():C=I,i.push(f/r.width,0),i.push(f/r.width,1),f+=E.length(),i.push(f/r.width,0),i.push(f/r.width,1),t.push(R.x,R.y,R.z),t.pu
758sh(R.x,R.y,R.z),t.push(C.x,C.y,C.z),t.push(C.x,C.y,C.z),c?(s.push(d),s.push(d+2),s.push(d+1),s.push(d+1),s.push(d+2),s.push(d+3)):(s.push(d),s.push(d+1),s.push(d+2),s.push(d+1),s.push(d+3),s.push(d+2)),d+=4}}}function pI(n,e,t,i,s,r,a){const o=t||new Array(3),c=i,u=[],d=a||!1;for(let U=0;U<3;U++)o[U]===void 0&&(o[U]=new rt(0,0,1,1)),c&&c[U]===void 0&&(c[U]=new Ze(1,1,1,1));const f=n.getVerticesData(O.PositionKind),g=n.getVerticesData(O.NormalKind),m=n.getVerticesData(O.UVKind),b=n.getIndices(),x=f.length/9;let v=0,E=0,A=0,D=0,I=0;const R=[0];if(d)for(let U=x;U<f.length/3;U+=4)E=f[3*(U+2)]-f[3*U],A=f[3*(U+2)+2]-f[3*U+2],D=Math.sqrt(E*E+A*A),I+=D,R.push(I);let C=0,M=0;for(let U=0;U<g.length;U+=3)Math.abs(g[U+1])<.001&&(M=1),Math.abs(g[U+1]-1)<.001&&(M=0),Math.abs(g[U+1]+1)<.001&&(M=2),C=U/3,M===1?(v=C-x,v%4<1.5?d?m[2*C]=o[M].x+(o[M].z-o[M].x)*R[Math.floor(v/4)]/I:m[2*C]=o[M].x:d?m[2*C]=o[M].x+(o[M].z-o[M].x)*R[Math.floor(v/4)+1]/I:m[2*C]=o[M].z,v%2===0?m[2*C+1]=o[M].w:m[2*C+1]=o[M].y):(m[2*C]=(1-m[2*C])*o[M].x+m[2*C]*o[M].z,m[2*C+1]=(1-m[2*C+1])*o[M].y+m[2*C+1]*o[M].w),c&&u.push(c[M].r,c[M].g,c[M].b,c[M].a);ve._ComputeSides(e,f,b,g,m,s,r);const F=new ve;if(F.indices=b,F.positions=f,F.normals=g,F.uvs=m,c){const U=e===ve.DOUBLESIDE?u.concat(u):u;F.colors=U}return F}function Xb(n,e,t=null,i=earcut){e.sideOrientation=Z._GetDefaultSideOrientation(e.sideOrientation);const s=e.shape,r=e.holes||[],a=e.depth||0,o=e.smoothingThreshold||2,c=[];let u=[];for(let b=0;b<s.length;b++)c[b]=new Ie(s[b].x,s[b].z);c[0].equalsWithEpsilon(c[c.length-1],1e-8)&&c.pop();const f=new pV(n,c,t||Ke.LastCreatedScene,i);for(let b=0;b<r.length;b++){u=[];for(let x=0;x<r[b].length;x++)u.push(new Ie(r[b][x].x,r[b][x].z));f.addHole(u)}const g=f.build(!1,a,o);return g._originalBuilderSideOrientation=e.sideOrientation,pI(g,e.sideOrientation,e.faceUV,e.faceColors,e.frontUVs,e.backUVs,e.wrap).applyToMesh(g,e.updatable),g}function jb(n,e,t=null,i=earcut){return Xb(n,e,t,i)}ve.CreatePolygon=pI;Z.CreatePolygon=(n,e,t,i,s,r,a=earcut)=>Xb(n,{shape:e,holes:i,updatable:s,sideOrientation:r},t,a);Z.ExtrudePolygon=(n,e,t,i,s,r,a,o=earcut)=>jb(n,{shape:e,holes:s,depth:t,updatable:r,sideOrientation:a},i,o);function _I(n,e,t=null){const i=e.path,s=e.shape,r=e.scale||1,a=e.rotation||0,o=e.cap===0?0:e.cap||Z.NO_CAP,c=e.updatable,u=Z._GetDefaultSideOrientation(e.sideOrientation),d=e.instance||null,f=e.invertUV||!1,g=e.closeShape||!1,m=e.closePath||!1,b=e.capFunction||null;return mI(n,s,i,r,a,null,null,m,g,o,!1,t,!!c,u,d,f,e.frontUVs||null,e.backUVs||null,e.firstNormal||null,!!e.adjustFrame,b)}function gI(n,e,t=null){const i=e.path,s=e.shape,r=e.scaleFunction||(()=>1),a=e.rotationFunction||(()=>0),o=e.closePath||e.ribbonCloseArray||!1,c=e.closeShape||e.ribbonClosePath||!1,u=e.cap===0?0:e.cap||Z.NO_CAP,d=e.updatable,f=e.firstNormal||null,g=e.adjustFrame||!1,m=Z._GetDefaultSideOrientation(e.sideOrientation),b=e.instance,x=e.invertUV||!1,v=e.capFunction||null;return mI(n,s,i,null,null,r,a,o,c,u,!0,t,!!d,m,b||null,x,e.frontUVs||null,e.backUVs||null,f,g,v||null)}function mI(n,e,t,i,s,r,a,o,c,u,d,f,g,m,b,x,v,E,A,D,I){const R=(k,q,Q,ie,$,ce,G,K,X,J,se)=>{const w=Q.getTangents(),L=Q.getNormals(),V=Q.getBinormals(),j=Q.getDistances();if(se){for(let Be=0;Be<w.length;Be++)if(w[Be].x==0&&w[Be].y==0&&w[Be].z==0&&w[Be].copyFrom(w[Be-1]),L[Be].x==0&&L[Be].y==0&&L[Be].z==0&&L[Be].copyFrom(L[Be-1]),V[Be].x==0&&V[Be].y==0&&V[Be].z==0&&V[Be].copyFrom(V[Be-1]),Be>0){let Ot=w[Be-1];T.Dot(Ot,w[Be])<0&&w[Be].scaleInPlace(-1),Ot=L[Be-1],T.Dot(Ot,L[Be])<0&&L[Be].scaleInPlace(-1),Ot=V[Be-1],T.Dot(Ot,V[Be])<0&&V[Be].scaleInPlace(-1)}}let ae=0;const he=()=>$!==null?$:1,Le=J&&K?K:()=>ce!==null?ce:0,Xe=J&&G?G:he;let it=X===Z.NO_CAP||X===Z.CAP_END?0:2;const ut=te.Matrix[0];for(let Be=0;Be<q.length;Be++){const Ot=[],Wt=Le(Be,j[Be]),vi=Xe(Be,j[Be]);W.RotationAxisToRef(w[Be],ae,ut);for(let Wi=0;Wi<k.length;Wi++){const Fi=w[Be].scale(k[Wi].z).add(L[Be].scale(k[Wi].x)).add(V[Be].scale(k[Wi].y)),ls=T.Zero();T.TransformCoordinatesToRef(Fi,ut,ls),ls.scaleInPlace(vi).addInPlace(q[Be]),Ot[Wi]=ls}ie[it]=Ot,ae+=Wt,it++}const Qe=I||(Be=>{const Ot=Array(),Wt=T.Zero();let vi;for(vi=0;vi<Be.length;vi++)Wt.addInPlace(Be[vi]);for(Wt.scaleInPlace(1/Be.length),vi=0;vi<Be.length;vi++)Ot.push(Wt);return Ot});switch(X){case Z.NO_CAP:break;case Z.CAP_START:ie[0]=Qe(ie[2]),ie[1]=ie[2];break;case Z.CAP_END:ie[it]=ie[it-1],ie[it+1]=Qe(ie[it-1]);break;case Z.CAP_ALL:ie[0]=Qe(ie[2]),ie[1]=ie[2],ie[it]=ie[it-1],ie[it+1]=Qe(ie[it-1]);break}return ie};let C,M;if(b){const k=b._creationDataStorage;return C=A?k.path3D.update(t,A):k.path3D.update(t),M=R(e,t,k.path3D,k.pathArray,i,s,r,a,k.cap,d,D),b=Ho("",{pathArray:M,closeArray:!1,closePath:!1,offset:0,updatable:!1,sideOrientation:0,instance:b},f||void 0),b}C=A?new Fh(t,A):new Fh(t);const F=new Array;u=u<0||u>3?0:u,M=R(e,t,C,F,i,s,r,a,u,d,D);const U=Ho(n,{pathArray:M,closeArray:o,closePath:c,updatable:g,sideOrientation:m,invertUV:x,frontUVs:v||void 0,backUVs:E||void 0},f);return U._creationDataStorage.pathArray=M,U._creationDataStorage.path3D=C,U._creationDataStorage.cap=u,U}Z.ExtrudeShape=(n,e,t,i,s,r,a=null,o,c,u)=>{const d={shape:e,path:t,scale:i,rotation:s,cap:r===0?0:r||Z.NO_CAP,sideOrientation:c,instance:u,updatable:o};return _I(n,d,a)};Z.ExtrudeShapeCustom=(n,e,t,i,s,r,a,o,c,u,d,f)=>{const g={shape:e,path:t,scaleFunction:i,rotationFunction:s,ribbonCloseArray:r,ribbonClosePath:a,cap:o===0?0:o||Z.NO_CAP,sideOrientation:d,instance:f,updatable:u};return gI(n,g,c)};function bI(n,e,t=null){const i=e.arc?e.arc<=0||e.arc>1?1:e.arc:1,s=e.closed===void 0?!0:e.closed,r=e.shape,a=e.radius||1,o=e.tessellation||64,c=e.clip||0,u=e.updatable,d=Z._GetDefaultSideOrientation(e.sideOrientation),f=e.cap||Z.NO_CAP,g=Math.PI*2,m=[],b=e.invertUV||!1;let x=0,v=0;const E=g/o*i;let A,D;for(x=0;x<=o-c;x++){for(D=[],(f==Z.CAP_START||f==Z.CAP_ALL)&&(D.push(new T(0,r[0].y,0)),D.push(new T(Math.cos(x*E)*r[0].x*a,r[0].y,Math.sin(x*E)*r[0].x*a))),v=0;v<r.length;
758v++)A=new T(Math.cos(x*E)*r[v].x*a,r[v].y,Math.sin(x*E)*r[v].x*a),D.push(A);(f==Z.CAP_END||f==Z.CAP_ALL)&&(D.push(new T(Math.cos(x*E)*r[r.length-1].x*a,r[r.length-1].y,Math.sin(x*E)*r[r.length-1].x*a)),D.push(new T(0,r[r.length-1].y,0))),m.push(D)}return Ho(n,{pathArray:m,closeArray:s,sideOrientation:d,updatable:u,invertUV:b,frontUVs:e.frontUVs,backUVs:e.backUVs},t)}Z.CreateLathe=(n,e,t,i,s,r,a)=>bI(n,{shape:e,radius:t,tessellation:i,sideOrientation:a,updatable:r},s);function yI(n){const e=[],t=[],i=[],s=[],r=n.width!==void 0?n.width:n.size!==void 0?n.size:1,a=n.height!==void 0?n.height:n.size!==void 0?n.size:1,o=n.sideOrientation===0?0:n.sideOrientation||ve.DEFAULTSIDE,c=r/2,u=a/2;t.push(-c,-u,0),i.push(0,0,-1),s.push(0,0),t.push(c,-u,0),i.push(0,0,-1),s.push(1,0),t.push(c,u,0),i.push(0,0,-1),s.push(1,1),t.push(-c,u,0),i.push(0,0,-1),s.push(0,1),e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),ve._ComputeSides(o,t,e,i,s,n.frontUVs,n.backUVs);const d=new ve;return d.indices=e,d.positions=t,d.normals=i,d.uvs=s,d}function vI(n,e={},t=null){const i=new Z(n,t);return e.sideOrientation=Z._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,yI(e).applyToMesh(i,e.updatable),e.sourcePlane&&(i.translate(e.sourcePlane.normal,-e.sourcePlane.d),i.setDirection(e.sourcePlane.normal.scale(-1))),i}ve.CreatePlane=yI;Z.CreatePlane=(n,e,t,i,s)=>vI(n,{size:e,width:e,height:e,sideOrientation:s,updatable:i},t);function xI(n,e,t=null){const i=e.path;let s=e.instance,r=1;e.radius!==void 0?r=e.radius:s&&(r=s._creationDataStorage.radius);const a=e.tessellation||64,o=e.radiusFunction||null;let c=e.cap||Z.NO_CAP;const u=e.invertUV||!1,d=e.updatable,f=Z._GetDefaultSideOrientation(e.sideOrientation);e.arc=e.arc&&(e.arc<=0||e.arc>1)?1:e.arc||1;const g=(E,A,D,I,R,C,M,F)=>{const U=A.getTangents(),k=A.getNormals(),q=A.getDistances(),ie=Math.PI*2/R*F,ce=C||(()=>I);let G,K,X,J;const se=te.Matrix[0];let w=M===Z.NO_CAP||M===Z.CAP_END?0:2;for(let V=0;V<E.length;V++){K=ce(V,q[V]),G=Array(),X=k[V];for(let j=0;j<R;j++)W.RotationAxisToRef(U[V],ie*j,se),J=G[j]?G[j]:T.Zero(),T.TransformCoordinatesToRef(X,se,J),J.scaleInPlace(K).addInPlace(E[V]),G[j]=J;D[w]=G,w++}const L=(V,j)=>{const ae=Array();for(let he=0;he<V;he++)ae.push(E[j]);return ae};switch(M){case Z.NO_CAP:break;case Z.CAP_START:D[0]=L(R,0),D[1]=D[2].slice(0);break;case Z.CAP_END:D[w]=D[w-1].slice(0),D[w+1]=L(R,E.length-1);break;case Z.CAP_ALL:D[0]=L(R,0),D[1]=D[2].slice(0),D[w]=D[w-1].slice(0),D[w+1]=L(R,E.length-1);break}return D};let m,b;if(s){const E=s._creationDataStorage,A=e.arc||E.arc;return m=E.path3D.update(i),b=g(i,m,E.pathArray,r,E.tessellation,o,E.cap,A),s=Ho("",{pathArray:b,instance:s}),E.path3D=m,E.pathArray=b,E.arc=A,E.radius=r,s}m=new Fh(i);const x=new Array;c=c<0||c>3?0:c,b=g(i,m,x,r,a,o,c,e.arc);const v=Ho(n,{pathArray:b,closePath:!0,closeArray:!1,updatable:d,sideOrientation:f,invertUV:u,frontUVs:e.frontUVs,backUVs:e.backUVs},t);return v._creationDataStorage.pathArray=b,v._creationDataStorage.path3D=m,v._creationDataStorage.tessellation=a,v._creationDataStorage.cap=c,v._creationDataStorage.arc=e.arc,v._creationDataStorage.radius=r,v}Z.CreateTube=(n,e,t,i,s,r,a,o,c,u)=>xI(n,{path:e,radius:t,tessellation:i,radiusFunction:s,arc:1,cap:r,updatable:o,sideOrientation:c,instance:u},a);function SI(n){const e=[];e[0]={vertex:[[0,0,1.732051],[1.632993,0,-.5773503],[-.8164966,1.414214,-.5773503],[-.8164966,-1.414214,-.5773503]],face:[[0,1,2],[0,2,3],[0,3,1],[1,3,2]]},e[1]={vertex:[[0,0,1.414214],[1.414214,0,0],[0,1.414214,0],[-1.414214,0,0],[0,-1.414214,0],[0,0,-1.414214]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,1],[1,4,5],[1,5,2],[2,5,3],[3,5,4]]},e[2]={vertex:[[0,0,1.070466],[.7136442,0,.7978784],[-.3568221,.618034,.7978784],[-.3568221,-.618034,.7978784],[.7978784,.618034,.3568221],[.7978784,-.618034,.3568221],[-.9341724,.381966,.3568221],[.1362939,1,.3568221],[.1362939,-1,.3568221],[-.9341724,-.381966,.3568221],[.9341724,.381966,-.3568221],[.9341724,-.381966,-.3568221],[-.7978784,.618034,-.3568221],[-.1362939,1,-.3568221],[-.1362939,-1,-.3568221],[-.7978784,-.618034,-.3568221],[.3568221,.618034,-.7978784],[.3568221,-.618034,-.7978784],[-.7136442,0,-.7978784],[0,0,-1.070466]],face:[[0,1,4,7,2],[0,2,6,9,3],[0,3,8,5,1],[1,5,11,10,4],[2,7,13,12,6],[3,9,15,14,8],[4,10,16,13,7],[5,8,14,17,11],[6,12,18,15,9],[10,11,17,19,16],[12,13,16,19,18],[14,15,18,19,17]]},e[3]={vertex:[[0,0,1.175571],[1.051462,0,.5257311],[.3249197,1,.5257311],[-.8506508,.618034,.5257311],[-.8506508,-.618034,.5257311],[.3249197,-1,.5257311],[.8506508,.618034,-.5257311],[.8506508,-.618034,-.5257311],[-.3249197,1,-.5257311],[-1.051462,0,-.5257311],[-.3249197,-1,-.5257311],[0,0,-1.175571]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,5],[0,5,1],[1,5,7],[1,7,6],[1,6,2],[2,6,8],[2,8,3],[3,8,9],[3,9,4],[4,9,10],[4,10,5],[5,10,7],[6,7,11],[6,11,8],[7,10,11],[8,11,9],[9,11,10]]}
758,e[4]={vertex:[[0,0,1.070722],[.7148135,0,.7971752],[-.104682,.7071068,.7971752],[-.6841528,.2071068,.7971752],[-.104682,-.7071068,.7971752],[.6101315,.7071068,.5236279],[1.04156,.2071068,.1367736],[.6101315,-.7071068,.5236279],[-.3574067,1,.1367736],[-.7888348,-.5,.5236279],[-.9368776,.5,.1367736],[-.3574067,-1,.1367736],[.3574067,1,-.1367736],[.9368776,-.5,-.1367736],[.7888348,.5,-.5236279],[.3574067,-1,-.1367736],[-.6101315,.7071068,-.5236279],[-1.04156,-.2071068,-.1367736],[-.6101315,-.7071068,-.5236279],[.104682,.7071068,-.7971752],[.6841528,-.2071068,-.7971752],[.104682,-.7071068,-.7971752],[-.7148135,0,-.7971752],[0,0,-1.070722]],face:[[0,2,3],[1,6,5],[4,9,11],[7,15,13],[8,16,10],[12,14,19],[17,22,18],[20,21,23],[0,1,5,2],[0,3,9,4],[0,4,7,1],[1,7,13,6],[2,5,12,8],[2,8,10,3],[3,10,17,9],[4,11,15,7],[5,6,14,12],[6,13,20,14],[8,12,19,16],[9,17,18,11],[10,16,22,17],[11,18,21,15],[13,15,21,20],[14,20,23,19],[16,19,23,22],[18,22,23,21]]},e[5]={vertex:[[0,0,1.322876],[1.309307,0,.1889822],[-.9819805,.8660254,.1889822],[.1636634,-1.299038,.1889822],[.3273268,.8660254,-.9449112],[-.8183171,-.4330127,-.9449112]],face:[[0,3,1],[2,4,5],[0,1,4,2],[0,2,5,3],[1,3,5,4]]},e[6]={vertex:[[0,0,1.159953],[1.013464,0,.5642542],[-.3501431,.9510565,.5642542],[-.7715208,-.6571639,.5642542],[.6633206,.9510565,-.03144481],[.8682979,-.6571639,-.3996071],[-1.121664,.2938926,-.03144481],[-.2348831,-1.063314,-.3996071],[.5181548,.2938926,-.9953061],[-.5850262,-.112257,-.9953061]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,9,7],[5,7,9,8],[0,3,7,5,1],[2,4,8,9,6]]},e[7]={vertex:[[0,0,1.118034],[.8944272,0,.6708204],[-.2236068,.8660254,.6708204],[-.7826238,-.4330127,.6708204],[.6708204,.8660254,.2236068],[1.006231,-.4330127,-.2236068],[-1.006231,.4330127,.2236068],[-.6708204,-.8660254,-.2236068],[.7826238,.4330127,-.6708204],[.2236068,-.8660254,-.6708204],[-.8944272,0,-.6708204],[0,0,-1.118034]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,10,7],[5,9,11,8],[7,10,11,9],[0,3,7,9,5,1],[2,4,8,11,10,6]]},e[8]={vertex:[[-.729665,.670121,.319155],[-.655235,-.29213,-.754096],[-.093922,-.607123,.537818],[.702196,.595691,.485187],[.776626,-.36656,-.588064]],face:[[1,4,2],[0,1,2],[3,0,2],[4,3,2],[4,1,0,3]]},e[9]={vertex:[[-.868849,-.100041,.61257],[-.329458,.976099,.28078],[-.26629,-.013796,-.477654],[-.13392,-1.034115,.229829],[.738834,.707117,-.307018],[.859683,-.535264,-.338508]],face:[[3,0,2],[5,3,2],[4,5,2],[1,4,2],[0,1,2],[0,3,5,4,1]]},e[10]={vertex:[[-.610389,.243975,.531213],[-.187812,-.48795,-.664016],[-.187812,.9759,-.664016],[.187812,-.9759,.664016],[.798201,.243975,.132803]],face:[[1,3,0],[3,4,0],[3,1,4],[0,2,1],[0,4,2],[2,4,1]]},e[11]={vertex:[[-1.028778,.392027,-.048786],[-.640503,-.646161,.621837],[-.125162,-.395663,-.540059],[.004683,.888447,-.651988],[.125161,.395663,.540059],[.632925,-.791376,.433102],[1.031672,.157063,-.354165]],face:[[3,2,0],[2,1,0],[2,5,1],[0,4,3],[0,1,4],[4,1,5],[2,3,6],[3,4,6],[5,2,6],[4,5,6]]},e[12]={vertex:[[-.669867,.334933,-.529576],[-.669867,.334933,.529577],[-.4043,1.212901,0],[-.334933,-.669867,-.529576],[-.334933,-.669867,.529577],[.334933,.669867,-.529576],[.334933,.669867,.529577],[.4043,-1.212901,0],[.669867,-.334933,-.529576],[.669867,-.334933,.529577]],face:[[8,9,7],[6,5,2],[3,8,7],[5,0,2],[4,3,7],[0,1,2],[9,4,7],[1,6,2],[9,8,5,6],[8,3,0,5],[3,4,1,0],[4,9,6,1]]},e[13]={vertex:[[-.931836,.219976,-.264632],[-.636706,.318353,.692816],[-.613483,-.735083,-.264632],[-.326545,.979634,0],[-.318353,-.636706,.692816],[-.159176,.477529,-.856368],[.159176,-.477529,-.856368],[.318353,.636706,.692816],[.326545,-.979634,0],[.613482,.735082,-.264632],[.636706,-.318353,.692816],[.931835,-.219977,-.264632]],face:[[11,10,8],[7,9,3],[6,11,8],[9,5,3],[2,6,8],[5,0,3],[4,2,8],[0,1,3],[10,4,8],[1,7,3],[10,11,9,7],[11,6,5,9],[6,2,0,5],[2,4,1,0],[4,10,7,1]]},e[14]={vertex:[[-.93465,.300459,-.271185],[-.838689,-.260219,-.516017],[-.711319,.717591,.128359],[-.710334,-.156922,.080946],[-.599799,.556003,-.725148],[-.503838,-.004675,-.969981],[-.487004,.26021,.48049],[-.460089,-.750282,-.512622],[-.376468,.973135,-.325605],[-.331735,-.646985,.084342],[-.254001,.831847,.530001],[-.125239,-.494738,-.966586],[.029622,.027949,.730817],[.056536,-.982543,-.262295],[.08085,1.087391,.076037],[.125583,-.532729,.485984],[.262625,.599586,.780328],[.391387,-.726999,-.716259],[.513854,-.868287,.139347],[.597475,.85513,.326364],[.641224,.109523,.783723],[.737185,-.451155,.538891],[.848705,-.612742,-.314616],[.976075,.365067,.32976],[1.072036,-.19561,.084927]],face:[[15,18,21],[12,20,16],[6,10,2],[3,0,1],[9,7,13],[2,8,4,0],[0,4,5,1],[1,5,11,7],[7,11,17,13],[13,17,22,18],[18,22,24,21],[21,24,23,20],[20,23,19,16],[16,19,14,10],[10,14,8,2],[15,9,13,18],[12,15,21,20],[6,12,16,10],[3,6,2,0],[9,3,1,7],[9,15,12,6,3],[22,17,11,5,4,8,14,19,23,24]]};const t=n.type&&(n.type<0||n.type>=e.length)?0:n.type||0,i=n.size,s=n.sizeX||i||1,r=n.sizeY||i||1,a=n.sizeZ||i||1,o=n.custom||e[t],c=o.face.length,u=n.faceUV||new Array(c),d=n.faceColors,f=n.flat===void 0?!0:n.flat,g=n.sideOrientation===0?0:n.sideOrientation||ve.DEFAULTSIDE,m=[],b=[],x=[],v=[],E=[];let A=0,D=0;const I=[];let R=0,C=0,M,F,U,k,q,Q;if(f)for(C=0;C<c;C++)d&&d[C]===void 0&&(d[C]=new Ze(1,1,1,1)),u&&u[C]===void 0&&(u[C]=new rt(0,0,1,1));if(f)for(C=0;C<c;C++){const $=o.face[C].length;for(U=2*Math.PI/$,k=.5*Math.tan(U/2),q=.5,R=0;R<$;R++)m.push(o.vertex[o.face[C][R]][0]*s,o.vertex[o.face[C][R]][1]*r,o.vertex[o.face[C][R]][2]*a),I.push(A),A++,M=u[C].x+(u[C].z-u[C].x)*(.5+k),F=u[C].y+(u[C].w-u[C].y)*(q-.5),v.push(M,F),Q=k*Math.cos(U)-q*Math.sin(U),q=k*Math.sin(U)+q*Math.cos(U),
758k=Q,d&&E.push(d[C].r,d[C].g,d[C].b,d[C].a);for(R=0;R<$-2;R++)b.push(I[0+D],I[R+2+D],I[R+1+D]);D+=$}else{for(R=0;R<o.vertex.length;R++)m.push(o.vertex[R][0]*s,o.vertex[R][1]*r,o.vertex[R][2]*a),v.push(0,0);for(C=0;C<c;C++)for(R=0;R<o.face[C].length-2;R++)b.push(o.face[C][0],o.face[C][R+2],o.face[C][R+1])}ve.ComputeNormals(m,b,x),ve._ComputeSides(g,m,b,x,v,n.frontUVs,n.backUVs);const ie=new ve;return ie.positions=m,ie.indices=b,ie.normals=x,ie.uvs=v,d&&f&&(ie.colors=E),ie}function Yb(n,e={},t=null){const i=new Z(n,t);return e.sideOrientation=Z._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,SI(e).applyToMesh(i,e.updatable),i}ve.CreatePolyhedron=SI;Z.CreatePolyhedron=(n,e,t)=>Yb(n,e,t);function TI(n){const e=n.sideOrientation||ve.DEFAULTSIDE,t=n.radius||1,i=n.flat===void 0?!0:n.flat,s=(n.subdivisions||4)|0,r=n.radiusX||t,a=n.radiusY||t,o=n.radiusZ||t,c=(1+Math.sqrt(5))/2,u=[-1,c,-0,1,c,0,-1,-c,0,1,-c,0,0,-1,-c,0,1,-c,0,-1,c,0,1,c,c,0,1,c,0,-1,-c,0,1,-c,0,-1],d=[0,11,5,0,5,1,0,1,7,0,7,10,12,22,23,1,5,20,5,11,4,23,22,13,22,18,6,7,1,8,14,21,4,14,4,2,16,13,6,15,6,19,3,8,9,4,21,5,13,17,23,6,13,22,19,6,18,9,8,1],f=[0,1,2,3,4,5,6,7,8,9,10,11,0,2,3,3,3,4,7,8,9,9,10,11],g=[5,1,3,1,6,4,0,0,5,3,4,2,2,2,4,0,2,0,1,1,6,0,6,2,0,4,3,3,4,4,3,1,4,2,4,4,0,2,1,1,2,2,3,3,1,3,2,4],m=138/1024,b=239/1024,x=60/1024,v=26/1024,E=-40/1024,A=20/1024,D=[0,0,0,0,1,0,0,1,1,0,0,0,1,1,0,0,1,1,1,0],I=[],R=[],C=[],M=[];let F=0;const U=new Array(3),k=new Array(3);let q;for(q=0;q<3;q++)U[q]=T.Zero(),k[q]=Ie.Zero();for(let ie=0;ie<20;ie++){for(q=0;q<3;q++){const ce=d[3*ie+q];U[q].copyFromFloats(u[3*f[ce]],u[3*f[ce]+1],u[3*f[ce]+2]),U[q].normalize(),k[q].copyFromFloats(g[2*ce]*m+x+D[ie]*E,g[2*ce+1]*b+v+D[ie]*A)}const $=(ce,G,K,X)=>{const J=T.Lerp(U[0],U[2],G/s),se=T.Lerp(U[1],U[2],G/s),w=s===G?U[2]:T.Lerp(J,se,ce/(s-G));w.normalize();let L;if(i){const he=T.Lerp(U[0],U[2],X/s),be=T.Lerp(U[1],U[2],X/s);L=T.Lerp(he,be,K/(s-X))}else L=new T(w.x,w.y,w.z);L.x/=r,L.y/=a,L.z/=o,L.normalize();const V=Ie.Lerp(k[0],k[2],G/s),j=Ie.Lerp(k[1],k[2],G/s),ae=s===G?k[2]:Ie.Lerp(V,j,ce/(s-G));R.push(w.x*r,w.y*a,w.z*o),C.push(L.x,L.y,L.z),M.push(ae.x,ae.y),I.push(F),F++};for(let ce=0;ce<s;ce++)for(let G=0;G+ce<s;G++)$(G,ce,G+1/3,ce+1/3),$(G+1,ce,G+1/3,ce+1/3),$(G,ce+1,G+1/3,ce+1/3),G+ce+1<s&&($(G+1,ce,G+2/3,ce+2/3),$(G+1,ce+1,G+2/3,ce+2/3),$(G,ce+1,G+2/3,ce+2/3))}ve._ComputeSides(e,R,I,C,M,n.frontUVs,n.backUVs);const Q=new ve;return Q.indices=I,Q.positions=R,Q.normals=C,Q.uvs=M,Q}function hf(n,e={},t=null){const i=new Z(n,t);return e.sideOrientation=Z._GetDefaultSideOrientation(e.sideOrientation),i._originalBuilderSideOrientation=e.sideOrientation,TI(e).applyToMesh(i,e.updatable),i}ve.CreateIcoSphere=TI;Z.CreateIcoSphere=(n,e,t)=>hf(n,e,t);const _V=new T(1,0,0),gV=new T(-1,0,0),mV=new T(0,1,0),bV=new T(0,-1,0),yV=new T(0,0,1),vV=new T(0,0,-1);class uf{constructor(e=T.Zero(),t=T.Up(),i=Ie.Zero(),s=0,r=0,a=null,o=null,c=null,u=null){this.position=e,this.normal=t,this.uv=i,this.vertexIdx=s,this.vertexIdxForBones=r,this.localPositionOverride=a,this.localNormalOverride=o,this.matrixIndicesOverride=c,this.matrixWeightsOverride=u}clone(){return new uf(this.position.clone(),this.normal.clone(),this.uv.clone(),this.vertexIdx,this.vertexIdxForBones,this.localPositionOverride?.slice(),this.localNormalOverride?.slice(),this.matrixIndicesOverride?.slice(),this.matrixWeightsOverride?.slice())}}function EI(n,e,t){const i=!!e.skeleton,s=!!e.morphTargetManager?.numTargets,r=t.localMode||i,a=e.getIndices(),o=i||s?e.getPositionData(!0,!0):e.getVerticesData(O.PositionKind),c=i||s?e.getNormalsData(!0,!0):e.getVerticesData(O.NormalKind),u=r?i?e.getVerticesData(O.PositionKind):o:null,d=r?i?e.getVerticesData(O.NormalKind):c:null,f=e.getVerticesData(O.UVKind),g=i?e.getVerticesData(O.MatricesIndicesKind):null,m=i?e.getVerticesData(O.MatricesWeightsKind):null,b=i?e.getVerticesData(O.MatricesIndicesExtraKind):null,x=i?e.getVerticesData(O.MatricesWeightsExtraKind):null,v=t.position||T.Zero();let E=t.normal||T.Up();const A=t.size||T.One(),D=t.angle||0;if(!E){const K=new T(0,0,1),X=e.getScene().activeCamera,J=T.TransformCoordinates(K,X.getWorldMatrix());E=X.globalPosition.subtract(J)}const I=-Math.atan2(E.z,E.x)-Math.PI/2,R=Math.sqrt(E.x*E.x+E.z*E.z),C=Math.atan2(E.y,R),M=new ve;M.indices=[],M.positions=[],M.normals=[],M.uvs=[],M.matricesIndices=i?[]:null,M.matricesWeights=i?[]:null,M.matricesIndicesExtra=b?[]:null,M.matricesWeightsExtra=x?[]:null;let F=0;const U=(K,X)=>{const J=new uf;if(!a||!o||!c)return J;const se=a[K];if(J.vertexIdx=se*3,J.vertexIdxForBones=se*4,J.position=new T(o[se*3],o[se*3+1],o[se*3+2]),T.TransformCoordinatesToRef(J.position,
758X,J.position),J.normal=new T(c[se*3],c[se*3+1],c[se*3+2]),T.TransformNormalToRef(J.normal,X,J.normal),t.captureUVS&&f){const w=f[se*2+1];J.uv=new Ie(f[se*2],w)}return J},k=[0,0,0,0],q=(K,X)=>{if(K.length===0)return K;const J=.5*Math.abs(T.Dot(A,X)),se=(V,j,ae,he)=>{for(let be=0;be<he;++be)if(V[ae+be]===j)return ae+be;return-1},w=(V,j)=>{const ae=T.GetClipFactor(V.position,j.position,X,J);let he=k,be=k;if(g&&m){const Ci=V.matrixIndicesOverride?0:V.vertexIdxForBones,ao=V.matrixIndicesOverride??g,tn=V.matrixWeightsOverride??m,pa=j.matrixIndicesOverride?0:j.vertexIdxForBones,sn=j.matrixIndicesOverride??g,_a=j.matrixWeightsOverride??m;he=[0,0,0,0],be=[0,0,0,0];let Qi=0;for(let Li=0;Li<4;++Li)if(tn[Ci+Li]>0){const Xs=se(sn,ao[Ci+Li],pa,4);he[Qi]=ao[Ci+Li],be[Qi]=Jd(tn[Ci+Li],Xs>=0?_a[Xs]:0,ae),Qi++}for(let Li=0;Li<4&&Qi<4;++Li){const Xs=sn[pa+Li];se(ao,Xs,Ci,4)===-1&&(he[Qi]=Xs,be[Qi]=Jd(0,_a[pa+Li],ae),Qi++)}const Rn=be[0]+be[1]+be[2]+be[3];be[0]/=Rn,be[1]/=Rn,be[2]/=Rn,be[3]/=Rn}const Le=V.localPositionOverride?V.localPositionOverride[0]:u?.[V.vertexIdx]??0,Xe=V.localPositionOverride?V.localPositionOverride[1]:u?.[V.vertexIdx+1]??0,it=V.localPositionOverride?V.localPositionOverride[2]:u?.[V.vertexIdx+2]??0,ut=j.localPositionOverride?j.localPositionOverride[0]:u?.[j.vertexIdx]??0,Oe=j.localPositionOverride?j.localPositionOverride[1]:u?.[j.vertexIdx+1]??0,Qe=j.localPositionOverride?j.localPositionOverride[2]:u?.[j.vertexIdx+2]??0,Be=V.localNormalOverride?V.localNormalOverride[0]:d?.[V.vertexIdx]??0,Ot=V.localNormalOverride?V.localNormalOverride[1]:d?.[V.vertexIdx+1]??0,Wt=V.localNormalOverride?V.localNormalOverride[2]:d?.[V.vertexIdx+2]??0,vi=j.localNormalOverride?j.localNormalOverride[0]:d?.[j.vertexIdx]??0,Wi=j.localNormalOverride?j.localNormalOverride[1]:d?.[j.vertexIdx+1]??0,Fi=j.localNormalOverride?j.localNormalOverride[2]:d?.[j.vertexIdx+2]??0,ls=Be+(vi-Be)*ae,ur=Ot+(Wi-Ot)*ae,Mi=Wt+(Fi-Wt)*ae,dr=Math.sqrt(ls*ls+ur*ur+Mi*Mi);return new uf(T.Lerp(V.position,j.position,ae),T.Lerp(V.normal,j.normal,ae).normalize(),Ie.Lerp(V.uv,j.uv,ae),-1,-1,u?[Le+(ut-Le)*ae,Xe+(Oe-Xe)*ae,it+(Qe-it)*ae]:null,d?[ls/dr,ur/dr,Mi/dr]:null,he,be)};let L=null;K.length>3&&(L=[]);for(let V=0;V<K.length;V+=3){let j=0,ae=null,he=null,be=null,Le=null;const Xe=T.Dot(K[V].position,X)-J,it=T.Dot(K[V+1].position,X)-J,ut=T.Dot(K[V+2].position,X)-J,Oe=Xe>0,Qe=it>0,Be=ut>0;switch(j=(Oe?1:0)+(Qe?1:0)+(Be?1:0),j){case 0:K.length>3?(L.push(K[V]),L.push(K[V+1]),L.push(K[V+2])):L=K;break;case 1:if(L=L??new Array,Oe&&(ae=K[V+1],he=K[V+2],be=w(K[V],ae),Le=w(K[V],he)),Qe){ae=K[V],he=K[V+2],be=w(K[V+1],ae),Le=w(K[V+1],he),L.push(be),L.push(he.clone()),L.push(ae.clone()),L.push(he.clone()),L.push(be.clone()),L.push(Le);break}Be&&(ae=K[V],he=K[V+1],be=w(K[V+2],ae),Le=w(K[V+2],he)),ae&&he&&be&&Le&&(L.push(ae.clone()),L.push(he.clone()),L.push(be),L.push(Le),L.push(be.clone()),L.push(he.clone()));break;case 2:L=L??new Array,Oe||(ae=K[V].clone(),he=w(ae,K[V+1]),be=w(ae,K[V+2]),L.push(ae),L.push(he),L.push(be)),Qe||(ae=K[V+1].clone(),he=w(ae,K[V+2]),be=w(ae,K[V]),L.push(ae),L.push(he),L.push(be)),Be||(ae=K[V+2].clone(),he=w(ae,K[V]),be=w(ae,K[V+1]),L.push(ae),L.push(he),L.push(be));break}}return L},Q=e instanceof Z?e:null,ie=Q?._thinInstanceDataStorage.matrixData,$=Q?.thinInstanceCount||1,ce=te.Matrix[0];ce.copyFrom(W.IdentityReadOnly);for(let K=0;K<$;++K){if(Q?.hasThinInstances&&ie){const V=K*16;ce.setRowFromFloats(0,ie[V+0],ie[V+1],ie[V+2],ie[V+3]),ce.setRowFromFloats(1,ie[V+4],ie[V+5],ie[V+6],ie[V+7]),ce.setRowFromFloats(2,ie[V+8],ie[V+9],ie[V+10],ie[V+11]),ce.setRowFromFloats(3,ie[V+12],ie[V+13],ie[V+14],ie[V+15])}const X=W.RotationYawPitchRoll(I,C,D).multiply(W.Translation(v.x,v.y,v.z)),J=W.Invert(X),se=e.getWorldMatrix(),w=ce.multiply(se).multiply(J),L=new Array(3);for(let V=0;V<a.length;V+=3){let j=L;if(j[0]=U(V,w),j[1]=U(V+1,w),j[2]=U(V+2,w),!(t.cullBackFaces&&-j[0].normal.z<=0&&-j[1].normal.z<=0&&-j[2].normal.z<=0)&&(j=q(j,_V),!!j&&(j=q(j,gV),!!j&&(j=q(j,mV),!!j&&(j=q(j,bV),!!j&&(j=q(j,yV),!!j&&(j=q(j,vV),!!j)))))))for(let ae=0;ae<j.length;ae++){const he=j[ae];if(M.indices.push(F),r?(he.localPositionOverride?(M.positions[F*3]=he.localPositionOverride[0],M.positions[F*3+1]=he.localPositionOverride[1],M.positions[F*3+2]=he.localPositionOverride[2]):u&&(M.positions[F*3]=u[he.vertexIdx],M.positions[F*3+1]=u[he.vertexIdx+1],M.positions[F*3+2]=u[he.vertexIdx+2]),he.localNormalOverride?(M.normals[F*3]=he.localNormalOverride[0],M.normals[F*3+1]=he.localNormalOverride[1],M.normals[F*3+2]=he.localNormalOverride[2]):d&&(M.normals[F*3]=d[he.vertexIdx],M.normals[F*3+1]=d[he.vertexIdx+1],M.normals[F*3+2]=d[he.vertexIdx+2])):(he.position.toArray(M.positions,F*3),he.normal.toArray(M.normals,F*3)),M.matricesIndices&&M.matricesWeights&&(he.matrixIndicesOverride?(M.matricesIndices[F*4]=he.matrixIndicesOverride[0],M.matricesIndices[F*4+1]=he.matrixIndicesOverride[1],M.matricesIndices[F*4+2]=he.matrixIndicesOverride[2],M.matricesIndices[F*4+3]=he.matrixIndicesOverride[3]):(g&&(M.matricesIndices[F*4]=g[he.vertexIdxForBones],M.matricesIndices[F*4+1]=g[he.vertexIdxForBones+1],M.matricesIndices[F*4+2]=g[he.vertexIdxForBones+2],M.matricesIndices[F*4+3]=g[he.vertexIdxForBones+3]),b&&M.matricesIndicesExtra&&(M.matricesIndicesExtra[F*4]=b[he.vertexIdxForBones],M.matricesIndicesExtra[F*4+1]=b[he.vertexIdxForBones+1],M.matricesIndicesExtra[F*4+2]=b[he.vertexIdxForBones+2],M.matricesIndicesExtra[F*4+3]=b[he.vertexIdxForBones+3])),he.matrixWeightsOverride?(M.matricesWeights[F*4]=he.matrixWeightsOverride[0],M.matricesWeights[F*4+1]=he.matrixWeightsOverride[1],M.matricesWeights[F*4+2]=he.matrixWeightsOverride[2],M.matricesWeights[F*4+3]=he.matrixWeightsOverride[3]):(m&&(M.matricesWeights[F*4]=m[he.vertexIdxForBones],M.matricesWeights[F*4+1]=m[he.vertexIdxForBones+1],M.matricesWeights[F*4+2]=m[he.vertexIdxForBones+2],M.matricesWeights[F*4+3]=m[he.vertexIdxForBones+3]),x&&M.matricesWeightsExtra&&(M.matricesWeightsExtra[F*4]=x[he.vertexIdxForBones],M.matricesWeightsExtra[F*4+1]=x[he.vertexIdxForBones+1],M.matricesWeightsExtra[F*4+2]=x[he.vertexIdxForBones+2],M.matricesWeightsExtra[F*4+3]=x[he.vertexIdxForBones+3]))),t.captureUVS)he.uv.toArray(M.uvs,F*2);else{M.uvs.push(.5+he.position.x/A.x);const be=.5+he.position.y/A.y;M.uvs.push(be)}F++}}}M.indices.length===0&&(M.indices=null),M.positions.length===0&&(M.positions=null),M.normals.length===0&&(M.normals=null),M.uvs.length===0&&(M.uvs=null),M.matricesIndices?.length===0&&(M.matricesIndices=null),M.matricesWeights?.length===0&&(M.matricesWeights=null),M.matricesIndicesExtra?.length===0&&(M.matricesIndicesExtra=null),M.matricesWeightsExtra?.length===0&&(M.matricesWeightsExtra=null);
758const G=new Z(n,e.getScene());return M.applyToMesh(G),r?(G.skeleton=e.skeleton,G.parent=e):(G.position=v.clone(),G.rotation=new T(C,I,D)),G.computeWorldMatrix(!0),G.refreshBoundingInfo(!0,!0),G}Z.CreateDecal=(n,e,t,i,s,r)=>EI(n,e,{position:t,normal:i,size:s,angle:r});function AI(n={subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6}){const e=Math.max(n.subdivisions?n.subdivisions:2,1)|0,t=Math.max(n.tessellation?n.tessellation:16,3)|0,i=Math.max(n.height?n.height:1,0),s=Math.max(n.radius?n.radius:.25,0),r=Math.max(n.capSubdivisions?n.capSubdivisions:6,1)|0,a=t,o=e,c=Math.max(n.radiusTop?n.radiusTop:s,0),u=Math.max(n.radiusBottom?n.radiusBottom:s,0),d=i-(c+u),f=0,g=2*Math.PI,m=Math.max(n.topCapSubdivisions?n.topCapSubdivisions:r,1),b=Math.max(n.bottomCapSubdivisions?n.bottomCapSubdivisions:r,1),x=Math.acos((u-c)/i);let v=[];const E=[],A=[],D=[];let I=0;const R=[],C=d*.5,M=Math.PI*.5;let F,U;const k=T.Zero(),q=T.Zero(),Q=Math.cos(x),ie=Math.sin(x),$=new Ie(c*ie,C+c*Q).subtract(new Ie(u*ie,-C+u*Q)).length(),ce=c*x+$+u*(M-x);let G=0;for(U=0;U<=m;U++){const se=[],w=M-x*(U/m);G+=c*x/m;const L=Math.cos(w),V=Math.sin(w),j=L*c;for(F=0;F<=a;F++){const ae=F/a,he=ae*g+f,be=Math.sin(he),Le=Math.cos(he);q.x=j*be,q.y=C+V*c,q.z=j*Le,E.push(q.x,q.y,q.z),k.set(L*be,V,L*Le),A.push(k.x,k.y,k.z),D.push(ae,1-G/ce),se.push(I),I++}R.push(se)}const K=i-c-u+Q*c-Q*u,X=ie*(u-c)/K;for(U=1;U<=o;U++){const se=[];G+=$/o;const w=ie*(U*(u-c)/o+c);for(F=0;F<=a;F++){const L=F/a,V=L*g+f,j=Math.sin(V),ae=Math.cos(V);q.x=w*j,q.y=C+Q*c-U*K/o,q.z=w*ae,E.push(q.x,q.y,q.z),k.set(j,X,ae).normalize(),A.push(k.x,k.y,k.z),D.push(L,1-G/ce),se.push(I),I++}R.push(se)}for(U=1;U<=b;U++){const se=[],w=M-x-(Math.PI-x)*(U/b);G+=u*x/b;const L=Math.cos(w),V=Math.sin(w),j=L*u;for(F=0;F<=a;F++){const ae=F/a,he=ae*g+f,be=Math.sin(he),Le=Math.cos(he);q.x=j*be,q.y=-C+V*u,q.z=j*Le,E.push(q.x,q.y,q.z),k.set(L*be,V,L*Le),A.push(k.x,k.y,k.z),D.push(ae,1-G/ce),se.push(I),I++}R.push(se)}for(F=0;F<a;F++)for(U=0;U<m+o+b;U++){const se=R[U][F],w=R[U+1][F],L=R[U+1][F+1],V=R[U][F+1];v.push(se),v.push(w),v.push(V),v.push(w),v.push(L),v.push(V)}if(v=v.reverse(),n.orientation&&!n.orientation.equals(T.Up())){const se=new W;n.orientation.clone().scale(Math.PI*.5).cross(T.Up()).toQuaternion().toRotationMatrix(se);const w=T.Zero();for(let L=0;L<E.length;L+=3)w.set(E[L],E[L+1],E[L+2]),T.TransformCoordinatesToRef(w.clone(),se,w),E[L]=w.x,E[L+1]=w.y,E[L+2]=w.z}const J=new ve;return J.positions=E,J.normals=A,J.uvs=D,J.indices=v,J}function RI(n,e={orientation:T.Up(),subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6,updatable:!1},t=null){const i=new Z(n,t);return AI(e).applyToMesh(i,e.updatable),i}Z.CreateCapsule=(n,e,t)=>RI(n,e,t);ve.CreateCapsule=AI;class Zt{constructor(e=0,t=0){this.x=e,this.y=t,e!==Math.floor(e)&&(e=Math.floor(e),oe.Warn("x is not an integer, floor(x) used")),t!==Math.floor(t)&&(t=Math.floor(t),oe.Warn("y is not an integer, floor(y) used"))}clone(){return new Zt(this.x,this.y)}rotate60About(e){const t=this.x;return this.x=e.x+e.y-this.y,this.y=t+this.y-e.x,this}rotateNeg60About(e){const t=this.x;return this.x=t+this.y-e.y,this.y=e.x+e.y-t,this}rotate120(e,t){e!==Math.floor(e)&&(e=Math.floor(e),oe.Warn("m not an integer only floor(m) used")),t!==Math.floor(t)&&(t=Math.floor(t),oe.Warn("n not an integer only floor(n) used"));const i=this.x;return this.x=e-i-this.y,this.y=t+i,this}rotateNeg120(e,t){e!==Math.floor(e)&&(e=Math.floor(e),oe.Warn("m is not an integer, floor(m) used")),t!==Math.floor(t)&&(t=Math.floor(t),oe.Warn("n is not an integer, floor(n) used"));const i=this.x;return this.x=this.y-t,this.y=e+t-i-this.y,this}toCartesianOrigin(e,t){const i=T.Zero();return i.x=e.x+2*this.x*t+this.y*t,i.y=e.y+Math.sqrt(3)*this.y*t,i}static Zero(){return new Zt(0,0)}}class MI{constructor(){this.cartesian=[],this.vertices=[],this.max=[],this.min=[],this.closestTo=[],this.innerFacets=[],this.isoVecsABOB=[],this.isoVecsOBOA=[],this.isoVecsBAOA=[],this.vertexTypes=[],this.IDATA=new Hm("icosahedron","Regular",[[0,gi,-1],[-gi,1,0],[-1,0,-gi],[1,0,-gi],[gi,1,0],[0,gi,1],[-1,0,gi],[-gi,-1,0],[0,-gi,-1],[gi,-1,0],[1,0,gi],[0,-gi,1]],[[0,2,1],[0,3,2],[0,4,3],[0,5,4],[0,1,5],[7,6,1],[8,7,2],[9,8,3],[10,9,4],[6,10,5],[2,7,1],[3,8,2],[4,9,3],[5,10,4],[1,6,5],[11,6,7],[11,7,8],[11,8,9],[11,9,10],[11,10,
7586]])}setIndices(){let e=12;const t={},i=this.m,s=this.n;let r=i,a=1,o=0;s!==0&&(r=Pm(i,s)),a=i/r,o=s/r;let c,u,d,f,g;const m=Zt.Zero(),b=new Zt(i,s),x=new Zt(-s,i+s),v=Zt.Zero(),E=Zt.Zero(),A=Zt.Zero();let D=[],I,R,C,M;const F=[],U=this.vertByDist,k=(q,Q,ie,$)=>{I=q+"|"+ie,R=Q+"|"+$,I in t||R in t?I in t&&!(R in t)?t[R]=t[I]:R in t&&!(I in t)&&(t[I]=t[R]):(t[I]=e,t[R]=e,e++),U[ie][0]>2?F[t[I]]=[-U[ie][0],U[ie][1],t[I]]:F[t[I]]=[D[U[ie][0]],U[ie][1],t[I]]};this.IDATA.edgematch=[[1,"B"],[2,"B"],[3,"B"],[4,"B"],[0,"B"],[10,"O",14,"A"],[11,"O",10,"A"],[12,"O",11,"A"],[13,"O",12,"A"],[14,"O",13,"A"],[0,"O"],[1,"O"],[2,"O"],[3,"O"],[4,"O"],[19,"B",5,"A"],[15,"B",6,"A"],[16,"B",7,"A"],[17,"B",8,"A"],[18,"B",9,"A"]];for(let q=0;q<20;q++){if(D=this.IDATA.face[q],d=D[2],f=D[1],g=D[0],C=m.x+"|"+m.y,I=q+"|"+C,I in t||(t[I]=d,F[d]=[D[U[C][0]],U[C][1]]),C=b.x+"|"+b.y,I=q+"|"+C,I in t||(t[I]=f,F[f]=[D[U[C][0]],U[C][1]]),C=x.x+"|"+x.y,I=q+"|"+C,I in t||(t[I]=g,F[g]=[D[U[C][0]],U[C][1]]),c=this.IDATA.edgematch[q][0],u=this.IDATA.edgematch[q][1],u==="B")for(let Q=1;Q<r;Q++)E.x=i-Q*(a+o),E.y=s+Q*a,A.x=-Q*o,A.y=Q*(a+o),C=E.x+"|"+E.y,M=A.x+"|"+A.y,k(q,c,C,M);if(u==="O")for(let Q=1;Q<r;Q++)A.x=-Q*o,A.y=Q*(a+o),v.x=Q*a,v.y=Q*o,C=A.x+"|"+A.y,M=v.x+"|"+v.y,k(q,c,C,M);if(c=this.IDATA.edgematch[q][2],u=this.IDATA.edgematch[q][3],u&&u==="A")for(let Q=1;Q<r;Q++)v.x=Q*a,v.y=Q*o,E.x=i-(r-Q)*(a+o),E.y=s+(r-Q)*a,C=v.x+"|"+v.y,M=E.x+"|"+E.y,k(q,c,C,M);for(let Q=0;Q<this.vertices.length;Q++)C=this.vertices[Q].x+"|"+this.vertices[Q].y,I=q+"|"+C,I in t||(t[I]=e++,U[C][0]>2?F[t[I]]=[-U[C][0],U[C][1],t[I]]:F[t[I]]=[D[U[C][0]],U[C][1],t[I]])}this.closestTo=F,this.vecToidx=t}calcCoeffs(){const e=this.m,t=this.n,i=Math.sqrt(3)/3,s=e*e+t*t+e*t;this.coau=(e+t)/s,this.cobu=-t/s,this.coav=-i*(e-t)/s,this.cobv=i*(2*e+t)/s}createInnerFacets(){const e=this.m,t=this.n;for(let i=0;i<t+e+1;i++)for(let s=this.min[i];s<this.max[i]+1;s++)s<this.max[i]&&s<this.max[i+1]+1&&this.innerFacets.push(["|"+s+"|"+i,"|"+s+"|"+(i+1),"|"+(s+1)+"|"+i]),i>0&&s<this.max[i-1]&&s+1<this.max[i]+1&&this.innerFacets.push(["|"+s+"|"+i,"|"+(s+1)+"|"+i,"|"+(s+1)+"|"+(i-1)])}edgeVecsABOB(){const e=this.m,t=this.n,i=new Zt(-t,e+t);for(let s=1;s<e+t;s++){const r=new Zt(this.min[s],s),a=new Zt(this.min[s-1],s-1),o=new Zt(this.min[s+1],s+1),c=r.clone(),u=a.clone(),d=o.clone();c.rotate60About(i),u.rotate60About(i),d.rotate60About(i);const f=new Zt(this.max[c.y],c.y),g=new Zt(this.max[c.y-1],c.y-1),m=new Zt(this.max[c.y-1]-1,c.y-1);(c.x!==f.x||c.y!==f.y)&&(c.x!==g.x?(this.vertexTypes.push([1,0,0]),this.isoVecsABOB.push([r,g,m]),this.vertexTypes.push([1,0,0]),this.isoVecsABOB.push([r,m,f])):c.y===d.y?(this.vertexTypes.push([1,1,0]),this.isoVecsABOB.push([r,a,g]),this.vertexTypes.push([1,0,1]),this.isoVecsABOB.push([r,g,o])):(this.vertexTypes.push([1,1,0]),this.isoVecsABOB.push([r,a,g]),this.vertexTypes.push([1,0,0]),this.isoVecsABOB.push([r,g,f])))}}mapABOBtoOBOA(){const e=new Zt(0,0);for(let t=0;t<this.isoVecsABOB.length;t++){const i=[];for(let s=0;s<3;s++)e.x=this.isoVecsABOB[t][s].x,e.y=this.isoVecsABOB[t][s].y,this.vertexTypes[t][s]===0&&e.rotateNeg120(this.m,this.n),i.push(e.clone());this.isoVecsOBOA.push(i)}}mapABOBtoBAOA(){const e=new Zt(0,0);for(let t=0;t<this.isoVecsABOB.length;t++){const i=[];for(let s=0;s<3;s++)e.x=this.isoVecsABOB[t][s].x,e.y=this.isoVecsABOB[t][s].y,this.vertexTypes[t][s]===1&&e.rotate120(this.m,this.n),i.push(e.clone());this.isoVecsBAOA.push(i)}}MapToFace(e,t){const i=this.IDATA.face[e],s=i[2],r=i[1],a=i[0],o=T.FromArray(this.IDATA.vertex[s]),c=T.FromArray(this.IDATA.vertex[r]),u=T.FromArray(this.IDATA.vertex[a]),d=c.subtract(o),f=u.subtract(o),g=d.scale(this.coau).add(f.scale(this.cobu)),m=d.scale(this.coav).add(f.scale(this.cobv));let b,x=te.Vector3[0];for(let v=0;v<this.cartesian.length;v++)x=g.scale(this.cartesian[v].x).add(m.scale(this.cartesian[v].y)).add(o),x.x,x.y,x.z,b=e+"|"+this.vertices[v].x+"|"+this.vertices[v].y,t.vertex[this.vecToidx[b]]=[x.x,x.y,x.z]}build(e,t){const i=[],s=Zt.Zero(),r=new Zt(e,t),a=new Zt(-t,e+t);i.push(s,r,a);for(let R=t;R<e+1;R++)for(let C=0;C<e+1-R;C++)i.push(new Zt(C,R));if(t>0){const R=Pm(e,t),C=e/R,M=t/R;for(let U=1;U<R;U++)i.push(new Zt(U*C,U*M)),i.push(new Zt(-U*M,U*(C+M))),i.push(new Zt(e-U*(C+M),t+U*C));const F=e/t;for(let U=1;U<t;U++)for(let k=0;k<U*F;k++)i.push(new Zt(k,U)),i.push(new Zt(k,U).rotate120(e,t)),i.push(new Zt(k,U).rotateNeg120(e,t))}i.sort((R,C)=>R.x-C.x),i.sort((R,C)=>R.y-C.y);const o=new Array(e+t+1),c=new Array(e+t+1);for(let R=0;R<o.length;R++)o[R]=1/0,c[R]=-1/0;let u=0,d=0;const f=i.length;for(let R=0;R<f;R++)d=i[R].x,u=i[R].y,o[u]=Math.min(d,o[u]),c[u]=Math.max(d,c[u]);const g=(R,C)=>{const M=R.clone();return C==="A"&&M.rotateNeg120(e,t),C==="B"&&M.rotate120(e,t),M.x<0?M.y:M.x+M.y},m=[],b=[],x=[],v=[],E={},A=[];let D=-1,I=-1;for(let R=0;R<f;R++)m[R]=i[R].toCartesianOrigin(new Zt(0,0),.5),b[R]=g(i[R],"O"),x[R]=g(i[R],"A"),v[R]=g(i[R],"B"),b[R]===x[R]&&x[R]===v[R]?(D=3,I=b[R]):b[R]===x[R]?(D=4,I=b[R]):x[R]===v[R]?(D=5,I=x[R]):v[R]===b[R]&&(D=6,I=b[R]),b[R]<x[R]&&b[R]<v[R]&&
758(D=2,I=b[R]),x[R]<b[R]&&x[R]<v[R]&&(D=1,I=x[R]),v[R]<x[R]&&v[R]<b[R]&&(D=0,I=v[R]),A.push([D,I,i[R].x,i[R].y]);A.sort((R,C)=>R[2]-C[2]),A.sort((R,C)=>R[3]-C[3]),A.sort((R,C)=>R[1]-C[1]),A.sort((R,C)=>R[0]-C[0]);for(let R=0;R<A.length;R++)E[A[R][2]+"|"+A[R][3]]=[A[R][0],A[R][1],R];return this.m=e,this.n=t,this.vertices=i,this.vertByDist=E,this.cartesian=m,this.min=o,this.max=c,this}}class Hm{constructor(e,t,i,s){this.name=e,this.category=t,this.vertex=i,this.face=s}}class zf extends Hm{innerToData(e,t){for(let i=0;i<t.innerFacets.length;i++)this.face.push(t.innerFacets[i].map(s=>t.vecToidx[e+s]))}mapABOBtoDATA(e,t){const i=t.IDATA.edgematch[e][0];for(let s=0;s<t.isoVecsABOB.length;s++){const r=[];for(let a=0;a<3;a++)t.vertexTypes[s][a]===0?r.push(e+"|"+t.isoVecsABOB[s][a].x+"|"+t.isoVecsABOB[s][a].y):r.push(i+"|"+t.isoVecsABOB[s][a].x+"|"+t.isoVecsABOB[s][a].y);this.face.push([t.vecToidx[r[0]],t.vecToidx[r[1]],t.vecToidx[r[2]]])}}mapOBOAtoDATA(e,t){const i=t.IDATA.edgematch[e][0];for(let s=0;s<t.isoVecsOBOA.length;s++){const r=[];for(let a=0;a<3;a++)t.vertexTypes[s][a]===1?r.push(e+"|"+t.isoVecsOBOA[s][a].x+"|"+t.isoVecsOBOA[s][a].y):r.push(i+"|"+t.isoVecsOBOA[s][a].x+"|"+t.isoVecsOBOA[s][a].y);this.face.push([t.vecToidx[r[0]],t.vecToidx[r[1]],t.vecToidx[r[2]]])}}mapBAOAtoDATA(e,t){const i=t.IDATA.edgematch[e][2];for(let s=0;s<t.isoVecsBAOA.length;s++){const r=[];for(let a=0;a<3;a++)t.vertexTypes[s][a]===1?r.push(e+"|"+t.isoVecsBAOA[s][a].x+"|"+t.isoVecsBAOA[s][a].y):r.push(i+"|"+t.isoVecsBAOA[s][a].x+"|"+t.isoVecsBAOA[s][a].y);this.face.push([t.vecToidx[r[0]],t.vecToidx[r[1]],t.vecToidx[r[2]]])}}orderData(e){const t=[];for(let a=0;a<13;a++)t[a]=[];const i=e.closestTo;for(let a=0;a<i.length;a++)i[a][0]>-1?i[a][1]>0&&t[i[a][0]].push([a,i[a][1]]):t[12].push([a,i[a][0]]);const s=[];for(let a=0;a<12;a++)s[a]=a;let r=12;for(let a=0;a<12;a++){t[a].sort((o,c)=>o[1]-c[1]);for(let o=0;o<t[a].length;o++)s[t[a][o][0]]=r++}for(let a=0;a<t[12].length;a++)s[t[12][a][0]]=r++;for(let a=0;a<this.vertex.length;a++)this.vertex[a].push(s[a]);this.vertex.sort((a,o)=>a[3]-o[3]);for(let a=0;a<this.vertex.length;a++)this.vertex[a].pop();for(let a=0;a<this.face.length;a++)for(let o=0;o<this.face[a].length;o++)this.face[a][o]=s[this.face[a][o]];this.sharedNodes=t[12].length,this.poleNodes=this.vertex.length-this.sharedNodes}setOrder(e,t){const i=[],s=[];let r=t.pop();s.push(r);let a=this.face[r].indexOf(e);a=(a+2)%3;let o=this.face[r][a];i.push(o);let c=0;for(;t.length>0;)r=t[c],this.face[r].indexOf(o)>-1?(a=(this.face[r].indexOf(o)+1)%3,o=this.face[r][a],i.push(o),s.push(r),t.splice(c,1),c=0):c++;return this.adjacentFaces.push(i),s}toGoldbergPolyhedronData(){const e=new Hm("GeoDual","Goldberg",[],[]);e.name="GD dual";const t=this.vertex.length,i=new Array(t);for(let u=0;u<t;u++)i[u]=[];for(let u=0;u<this.face.length;u++)for(let d=0;d<3;d++)i[this.face[u][d]].push(u);let s=0,r=0,a=0,o=[],c=[];this.adjacentFaces=[];for(let u=0;u<i.length;u++){e.face[u]=this.setOrder(u,i[u].concat([]));for(const d of i[u]){s=0,r=0,a=0,o=this.face[d];for(let f=0;f<3;f++)c=this.vertex[o[f]],s+=c[0],r+=c[1],a+=c[2];e.vertex[d]=[s/3,r/3,a/3]}}return e}static BuildGeodesicData(e){const t=new zf("Geodesic-m-n","Geodesic",[[0,gi,-1],[-gi,1,0],[-1,0,-gi],[1,0,-gi],[gi,1,0],[0,gi,1],[-1,0,gi],[-gi,-1,0],[0,-gi,-1],[gi,-1,0],[1,0,gi],[0,-gi,1]],[]);e.setIndices(),e.calcCoeffs(),e.createInnerFacets(),e.edgeVecsABOB(),e.mapABOBtoOBOA(),e.mapABOBtoBAOA();for(let s=0;s<e.IDATA.face.length;s++)e.MapToFace(s,t),t.innerToData(s,e),e.IDATA.edgematch[s][1]==="B"&&t.mapABOBtoDATA(s,e),e.IDATA.edgematch[s][1]==="O"&&t.mapOBOAtoDATA(s,e),e.IDATA.edgematch[s][3]==="A"&&t.mapBAOAtoDATA(s,e);t.orderData(e);const i=1;return t.vertex=t.vertex.map(function(s){const r=s[0],a=s[1],o=s[2],c=Math.sqrt(r*r+a*a+o*o);return s[0]*=i/c,s[1]*=i/c,s[2]*=i/c,s}),t}}function xV(n,e,t=null){let i=e.m||1;i!==Math.floor(i)&&(i=Math.floor(i),oe.Warn("m not an integer only floor(m) used"));let s=e.n||0;if(s!==Math.floor(s)&&(s=Math.floor(s),oe.Warn("n not an integer only floor(n) used")),s>i){const u=s;s=i,i=u,oe.Warn("n > m therefore m and n swapped")}const r=new MI;r.build(i,s);const o={custom:zf.BuildGeodesicData(r),size:e.size,sizeX:e.sizeX,sizeY:e.sizeY,sizeZ:e.sizeZ,faceUV:e.faceUV,faceColors:e.faceColors,flat:e.flat,updatable:e.updatable,sideOrientation:e.sideOrientation,frontUVs:e.frontUVs,backUVs:e.backUVs};return Yb(n,o,t)}Z._GoldbergMeshParser=(n,e)=>Gf.Parse(n,e);class Gf extends Z{constructor(){super(...arguments),this.goldbergData={faceColors:[],faceCenters:[],faceZaxis:[],faceXaxis:[],faceYaxis:[],nbSharedFaces:0,nbUnsharedFaces:0,nbFaces:0,nbFacesAtPole:0,adjacentFaces:[]}}relatedGoldbergFace(e,t){return t===void 0?(e>this.goldbergData.nbUnsharedFaces-1&&(oe.Warn("Maximum number of unshared faces used"),e=this.goldbergData.nbUnsharedFaces-1),this.goldbergData.nbUnsharedFaces+e):(e>11&&(oe.Warn("Last pole used"),e=11),t>this.goldbergData.nbFacesAtPole-1&&(oe.Warn("Maximum number of faces at a pole used"),t=this.goldbergData.nbFacesAtPole-1),12+e*this.goldbergData.nbFacesAtPole+t)}_changeGoldbergFaceColors(e){for(let i=0;i<e.length;i++){const s=e[i][0],r=e[i][1],a=e[i][2];for(let o=s;o<r+1;o++)this.goldbergData.faceColors[o]=a}const t=[];for(let i=0;i<12;i++)for(let s=0;s<5;s++)t.push(this.goldbergData.faceColors[i].r,this.goldbergData.faceColors[i].g,this.goldbergData.faceColors[i].b,this.goldbergData.faceColors[i].a);for(let i=12;i<this.goldbergData.faceColors.length;i++)for(let s=0;s<6;s++)t.push(this.goldbergData.faceColors[i].r,this.goldbergData.faceColors[i].g,this.goldbergData.faceColors[i].b,this.goldbergData.faceColors[i].a);return t}setGoldbergFaceColors(e){const t=this._changeGoldbergFaceColors(e);this.setVerticesData(O.ColorKind,t)}updateGoldbergFaceColors(e){const t=this._changeGoldbergFaceColors(e);this.updateVerticesData(O.ColorKind,t)}_changeGoldbergFaceUVs(e){const t=this.getVerticesData(O.UVKind);for(let i=0;i<e.length;i++){const s=e[i][0],r=e[i][1],a=e[i][2],o=e[i][3],c=e[i][4],u=[],d=[];let f,g;for(let m=0;m<5;
758m++)f=a.x+o*Math.cos(c+m*Math.PI/2.5),g=a.y+o*Math.sin(c+m*Math.PI/2.5),f<0&&(f=0),f>1&&(f=1),u.push(f,g);for(let m=0;m<6;m++)f=a.x+o*Math.cos(c+m*Math.PI/3),g=a.y+o*Math.sin(c+m*Math.PI/3),f<0&&(f=0),f>1&&(f=1),d.push(f,g);for(let m=s;m<Math.min(12,r+1);m++)for(let b=0;b<5;b++)t[10*m+2*b]=u[2*b],t[10*m+2*b+1]=u[2*b+1];for(let m=Math.max(12,s);m<r+1;m++)for(let b=0;b<6;b++)t[12*m-24+2*b]=d[2*b],t[12*m-23+2*b]=d[2*b+1]}return t}setGoldbergFaceUVs(e){const t=this._changeGoldbergFaceUVs(e);this.setVerticesData(O.UVKind,t)}updateGoldbergFaceUVs(e){const t=this._changeGoldbergFaceUVs(e);this.updateVerticesData(O.UVKind,t)}placeOnGoldbergFaceAt(e,t,i){const s=T.RotationFromAxis(this.goldbergData.faceXaxis[t],this.goldbergData.faceYaxis[t],this.goldbergData.faceZaxis[t]);e.rotation=s,e.position=this.goldbergData.faceCenters[t].add(this.goldbergData.faceXaxis[t].scale(i.x)).add(this.goldbergData.faceYaxis[t].scale(i.y)).add(this.goldbergData.faceZaxis[t].scale(i.z))}serialize(e){super.serialize(e),e.type="GoldbergMesh";const t={};if(t.adjacentFaces=this.goldbergData.adjacentFaces,t.nbSharedFaces=this.goldbergData.nbSharedFaces,t.nbUnsharedFaces=this.goldbergData.nbUnsharedFaces,t.nbFaces=this.goldbergData.nbFaces,t.nbFacesAtPole=this.goldbergData.nbFacesAtPole,this.goldbergData.faceColors){t.faceColors=[];for(const i of this.goldbergData.faceColors)t.faceColors.push(i.asArray())}if(this.goldbergData.faceCenters){t.faceCenters=[];for(const i of this.goldbergData.faceCenters)t.faceCenters.push(i.asArray())}if(this.goldbergData.faceZaxis){t.faceZaxis=[];for(const i of this.goldbergData.faceZaxis)t.faceZaxis.push(i.asArray())}if(this.goldbergData.faceYaxis){t.faceYaxis=[];for(const i of this.goldbergData.faceYaxis)t.faceYaxis.push(i.asArray())}if(this.goldbergData.faceXaxis){t.faceXaxis=[];for(const i of this.goldbergData.faceXaxis)t.faceXaxis.push(i.asArray())}e.goldbergData=t}static Parse(e,t){const i=e.goldbergData;i.faceColors=i.faceColors.map(r=>Ze.FromArray(r)),i.faceCenters=i.faceCenters.map(r=>T.FromArray(r)),i.faceZaxis=i.faceZaxis.map(r=>T.FromArray(r)),i.faceXaxis=i.faceXaxis.map(r=>T.FromArray(r)),i.faceYaxis=i.faceYaxis.map(r=>T.FromArray(r));const s=new Gf(e.name,t);return s.goldbergData=i,s}}function SV(n,e){const t=n.size,i=n.sizeX||t||1,s=n.sizeY||t||1,r=n.sizeZ||t||1,a=n.sideOrientation===0?0:n.sideOrientation||ve.DEFAULTSIDE,o=[],c=[],u=[],d=[];let f=1/0,g=-1/0,m=1/0,b=-1/0;for(let E=0;E<e.vertex.length;E++)f=Math.min(f,e.vertex[E][0]*i),g=Math.max(g,e.vertex[E][0]*i),m=Math.min(m,e.vertex[E][1]*s),b=Math.max(b,e.vertex[E][1]*s);let x=0;for(let E=0;E<e.face.length;E++){const A=e.face[E],D=T.FromArray(e.vertex[A[0]]),I=T.FromArray(e.vertex[A[2]]),R=T.FromArray(e.vertex[A[1]]),C=I.subtract(D),M=R.subtract(D),F=T.Cross(M,C).normalize();for(let U=0;U<A.length;U++){u.push(F.x,F.y,F.z);const k=e.vertex[A[U]];o.push(k[0]*i,k[1]*s,k[2]*r);const q=(k[1]*s-m)/(b-m);d.push((k[0]*i-f)/(g-f),q)}for(let U=0;U<A.length-2;U++)c.push(x,x+U+2,x+U+1);x+=A.length}ve._ComputeSides(a,o,c,u,d);const v=new ve;return v.positions=o,v.indices=c,v.normals=u,v.uvs=d,v}function TV(n,e,t=null){const i=e.size,s=e.sizeX||i||1,r=e.sizeY||i||1,a=e.sizeZ||i||1;let o=e.m||1;o!==Math.floor(o)&&(o=Math.floor(o),oe.Warn("m not an integer only floor(m) used"));let c=e.n||0;if(c!==Math.floor(c)&&(c=Math.floor(c),oe.Warn("n not an integer only floor(n) used")),c>o){const b=c;c=o,o=b,oe.Warn("n > m therefore m and n swapped")}const u=new MI;u.build(o,c);const d=zf.BuildGeodesicData(u),f=d.toGoldbergPolyhedronData(),g=new Gf(n,t);e.sideOrientation=Z._GetDefaultSideOrientation(e.sideOrientation),g._originalBuilderSideOrientation=e.sideOrientation,SV(e,f).applyToMesh(g,e.updatable),g.goldbergData.nbSharedFaces=d.sharedNodes,g.goldbergData.nbUnsharedFaces=d.poleNodes,g.goldbergData.adjacentFaces=d.adjacentFaces,g.goldbergData.nbFaces=g.goldbergData.nbSharedFaces+g.goldbergData.nbUnsharedFaces,g.goldbergData.nbFacesAtPole=(g.goldbergData.nbUnsharedFaces-12)/12;for(let b=0;b<d.vertex.length;b++)g.goldbergData.faceCenters.push(T.FromArray(d.vertex[b])),g.goldbergData.faceCenters[b].x*=s,g.goldbergData.faceCenters[b].y*=r,g.goldbergData.faceCenters[b].z*=a,g.goldbergData.faceColors.push(new Ze(1,1,1,1));for(let b=0;b<f.face.length;b++){const x=f.face[b],v=T.FromArray(f.vertex[x[0]]),E=T.FromArray(f.vertex[x[2]]),A=T.FromArray(f.vertex[x[1]]),D=E.subtract(v),I=A.subtract(v),R=T.Cross(I,D).normalize(),C=T.Cross(I,R).normalize();g.goldbergData.faceXaxis.push(I.normalize()),g.goldbergData.faceYaxis.push(R),g.goldbergData.faceZaxis.push(C)}return g}class EV{constructor(e){this._paths=[],this._tempPaths=[],this._holes=[],this._resolution=e}moveTo(e,t){this._currentPath=new Ff(e,t),this._tempPaths.push(this._currentPath)}lineTo(e,t){this._currentPath.addLineTo(e,t)}quadraticCurveTo(e,t,i,s){this._currentPath.addQuadraticCurveTo(e,t,i,s,this._resolution)}bezierCurveTo(e,t,i,s,r,a){this._currentPath.addBezierCurveTo(e,t,i,s,r,a,this._resolution)}extractHoles(){for(const e of this._tempPaths)e.area()>0?this._holes.push(e):this._paths.push(e);if(!this._paths.length&&this._holes.length){const e=this._holes;this._holes=this._paths,this._paths=e}this._tempPaths.length=0}get paths(){return this._paths}get holes(){return this._holes}}function AV(n,e,t,i,s,r){const a=r.glyphs[n]||r.glyphs["?"];if(!a)return null;const o=new EV(s);if(a.o){const c=a.o.split(" ");for(let u=0,d=c.length;u<d;)switch(c[u++]){case"m":{const g=parseInt(c[u++])*e+t,m=parseInt(c[u++])*e+i;o.moveTo(g,m);break}case"l":{const g=parseInt(c[u++])*e+t,m=parseInt(c[u++])*e+i;o.lineTo(g,m);break}case"q":{const g=parseInt(c[u++])*e+t,m=parseInt(c[u++])*e+i,b=parseInt(c[u++])*e+t,x=parseInt(c[u++])*e+i;o.quadraticCurveTo(b,x,g,m);break}case"b":{const g=parseInt(c[u++])*e+t,m=parseInt(c[u++])*e+i,b=parseInt(c[u++])*e+t,x=parseInt(c[u++])*e+i,v=parseInt(c[u++])*e+t,E=parseInt(c[u++])*e+i;o.bezierCurveTo(b,x,v,E,g,m);break}}}return o.extractHoles(),{offsetX:a.ha*e,shapePath:o}}function RV(n,e,t,i){const s=Array.from(n),r=e/i.resolution,a=(i.boundingBox.yMax-i.boundingBox.yMin+i.underlineThickness)*r,o=[];let c=0,u=0;for(let d=0;d<s.length;d++){const f=s[d];if(f===` 759`)c=0,u-=a;else{const g=AV(f,r,c,u,t,i);g&&(c+=g.offsetX,o.push(g.shapePath))}}return o}function MV(n,e,t,i={size:50,resolution:8,depth:1},s=null,r=earcut){const a=RV(e,i.size||50,i.resolution||8,t),o=[];let c=0;for(const d of a){if(!d.paths.length)continue;const f=d.holes.slice();for(const g of d.paths){const m=[],b=[],x=g.getPoints();for(const A of x)b.push(new T(A.x,0,A.y));const v=f.slice();for(const A of v){const D=A.getPoints();let I=!1;for(const C of D)if(g.isPointInside(C)){I=!0;break}if(!I)continue;const R=[];for(const C of D)R.push(new T(C.x,0,C.y));m.push(R),f.splice(f.indexOf(A),1)}if(!m.length&&f.length)for(const A of f){const D=A.getPoints(),I=[];for(const R of D)I.push(new T(R.x,0,R.y));m.push(I)}const E=jb(n,{shape:b,holes:m.length?m:void 0,depth:i.depth||1,faceUV:i.faceUV||i.perLetterFaceUV?.(c),faceColors:i.faceColors||i.perLetterFaceColors?.(c),sideOrientation:Z._GetDefaultSideOrientation(i.sideOrientation||Z.DOU
759BLESIDE)},s,r);o.push(E),c++}}const u=Z.MergeMeshes(o,!0,!0);if(u){const d=u.getBoundingInfo().boundingBox;u.position.x+=-(d.minimumWorld.x+d.maximumWorld.x)/2,u.position.y+=-(d.minimumWorld.y+d.maximumWorld.y)/2,u.position.z+=-(d.minimumWorld.z+d.maximumWorld.z)/2+d.extendSize.z,u.name=n;const f=new qe("pivot",s);f.rotation.x=-Math.PI/2,u.parent=f,u.bakeCurrentTransformIntoVertices(),u.parent=null,f.dispose()}return u}const qn={CreateBox:YC,CreateTiledBox:y3,CreateSphere:Uh,CreateDisc:VC,CreateIcoSphere:hf,CreateRibbon:Ho,CreateCylinder:Vf,CreateTorus:kh,CreateTorusKnot:cI,CreateLineSystem:dI,CreateLines:Wb,CreateDashedLines:fI,ExtrudeShape:_I,ExtrudeShapeCustom:gI,CreateLathe:bI,CreateTiledPlane:b3,CreatePlane:vI,CreateGround:Ub,CreateTiledGround:WC,CreateGroundFromHeightMap:XC,CreatePolygon:Xb,ExtrudePolygon:jb,CreateTube:xI,CreatePolyhedron:Yb,CreateGeodesic:xV,CreateGoldberg:TV,CreateDecal:EI,CreateCapsule:RI,CreateText:MV};class rE{constructor(){this.previousWorldMatrices={},this.previousBones={}}static AddUniforms(e){e.push("previousWorld","previousViewProjection","mPreviousBones")}static AddSamplers(e){}bindForSubMesh(e,t,i,s,r){if(t.prePassRenderer&&t.prePassRenderer.enabled&&t.prePassRenderer.currentRTisSceneRT&&(t.prePassRenderer.getIndex(2)!==-1||t.prePassRenderer.getIndex(11)!==-1)){this.previousWorldMatrices[i.uniqueId]||(this.previousWorldMatrices[i.uniqueId]=s.clone()),this.previousViewProjection||(this.previousViewProjection=t.getTransformMatrix().clone(),this.currentViewProjection=t.getTransformMatrix().clone());const a=t.getEngine();this.currentViewProjection.updateFlag!==t.getTransformMatrix().updateFlag?(this._lastUpdateFrameId=a.frameId,this.previousViewProjection.copyFrom(this.currentViewProjection),this.currentViewProjection.copyFrom(t.getTransformMatrix())):this._lastUpdateFrameId!==a.frameId&&(this._lastUpdateFrameId=a.frameId,this.previousViewProjection.copyFrom(this.currentViewProjection)),e.setMatrix("previousWorld",this.previousWorldMatrices[i.uniqueId]),e.setMatrix("previousViewProjection",this.previousViewProjection),this.previousWorldMatrices[i.uniqueId]=s.clone()}}}class Hf{constructor(e){if(this.VERTEXOUTPUT_INVARIANT=!1,this._keys=[],this._isDirty=!0,this._areLightsDirty=!0,this._areLightsDisposed=!1,this._areAttributesDirty=!0,this._areTexturesDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._arePrePassDirty=!0,this._areImageProcessingDirty=!0,this._normals=!1,this._uvs=!1,this._needNormals=!1,this._needUVs=!1,this._externalProperties=e,e)for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&this._setDefaultValue(t)}get isDirty(){return this._isDirty}markAsProcessed(){this._isDirty=!1,this._areAttributesDirty=!1,this._areTexturesDirty=!1,this._areFresnelDirty=!1,this._areLightsDirty=!1,this._areLightsDisposed=!1,this._areMiscDirty=!1,this._arePrePassDirty=!1,this._areImageProcessingDirty=!1}markAsUnprocessed(){this._isDirty=!0}markAllAsDirty(){this._areTexturesDirty=!0,this._areAttributesDirty=!0,this._areLightsDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._arePrePassDirty=!0,this._areImageProcessingDirty=!0,this._isDirty=!0}markAsImageProcessingDirty(){this._areImageProcessingDirty=!0,this._isDirty=!0}markAsLightDirty(e=!1){this._areLightsDirty=!0,this._areLightsDisposed=this._areLightsDisposed||e,this._isDirty=!0}markAsAttributesDirty(){this._areAttributesDirty=!0,this._isDirty=!0}markAsTexturesDirty(){this._areTexturesDirty=!0,this._isDirty=!0}markAsFresnelDirty(){this._areFresnelDirty=!0,this._isDirty=!0}markAsMiscDirty(){this._areMiscDirty=!0,this._isDirty=!0}markAsPrePassDirty(){this._arePrePassDirty=!0,this._isDirty=!0}rebuild(){this._keys.length=0;for(const e of Object.keys(this))e[0]!=="_"&&this._keys.push(e);if(this._externalProperties)for(const e in this._externalProperties)this._keys.indexOf(e)===-1&&this._keys.push(e)}isEqual(e){if(this._keys.length!==e._keys.length)return!1;for(let t=0;t<this._keys.length;t++){const i=this._keys[t];if(this[i]!==e[i])return!1}return!0}cloneTo(e){this._keys.length!==e._keys.length&&(e._keys=this._keys.slice(0));for(let t=0;t<this._keys.length;t++){const i=this._keys[t];e[i]=this[i]}}reset(){for(const e of this._keys)this._setDefaultValue(e)}_setDefaultValue(e){const t=this._externalProperties?.[e]?.type??typeof this[e],i=this._externalProperties?.[e]?.default;switch(t){case"number":this[e]=i??0;break;case"string":this[e]=i??"";break;default:this[e]=i??!1;break}}toString(){let e="";for(let t=0;t<this._keys.length;t++){const i=this._keys[t],s=this[i];switch(typeof s){case"number":case"string":e+="#define "+i+" "+s+` 760`;break;default:s&&(e+="#define "+i+` 761`);break}}return e}}function CI(n){return class extends n{constructor(){super(...arguments),this.IMAGEPROCESSING=!1,this.VIGNETTE=!1,this.VIGNETTEBLENDMODEMULTIPLY=!1,this.VIGNETTEBLENDMODEOPAQUE=!1,this.TONEMAPPING=0,this.CONTRAST=!1,this.COLORCURVES=!1,this.COLORGRADING=!1,this.COLORGRADING3D=!1,this.SAMPLER3DGREENDEPTH=!1,this.SAMPLER3DBGRMAP=!1,this.DITHER=!1,this.IMAGEPROCESSINGPOSTPROCESS=!1,this.SKIPFINALCOLORCLAMP=!1,this.EXPOSURE=!1}}}class CV extends Hf{constructor(){super(),this.IMAGEPROCESSING=!1,this.VIGNETTE=!1,this.VIGNETTEBLENDMODEMULTIPLY=!1,this.VIGNETTEBLENDMODEOPAQUE=!1,this.TONEMAPPING=0,this.CONTRAST=!1,this.COLORCURVES=!1,this.COLORGRADING=!1,this.COLORGRADING3D=!1,this.SAMPLER3DGREENDEPTH=!1,this.SAMPLER3DBGRMAP=!1,this.DITHER=!1,this.IMAGEPROCESSINGPOSTPROCESS=!1,this.EXPOSURE=!1,this.SKIPFINALCOLORCLAMP=!1,this.rebuild()}}const IV=new RegExp("^([gimus]+)!");class Xa{constructor(e){this._plugins=[],this._activePlugins=[],this._activePluginsForExtraEvents=[],this._material=e,this._scene=e.getScene(),this._engine=this._scene.getEngine()}_addPlugin(e){for(let s=0;s<this._plugins.length;++s)if(this._plugins[s].name===e.name)return!1;if(this._material._uniformBufferLayoutBuilt&&(this._material.resetDrawCache(),this._material._createUniformBuffer()),!e.isCompatible(this._material.shaderLanguage))throw`The plugin "${e.name}" can't be added to the material "${this._material.name}" because the plugin is not compatible with the shader language of the material.`;const t=e.getClassName();Xa._MaterialPluginClassToMainDefine[t]||(Xa._MaterialPluginClassToMainDefine[t]="MATERIALPLUGIN_"+ ++Xa._MaterialPluginCounter),this._material._callbackPluginEventGeneric=(s,r)=>this._handlePluginEvent(s,r),this._plugins.push(e),this._plugins.sort((s,r)=>s.priority-r.priority),this._codeInjectionPoints={};const i={};i[Xa._MaterialPluginClassToMainDefine[t]]={type:"boolean",default:!0};for(const s of this._plugins)s.collectDefines(i),this._collectPointNames("vertex",s.getCustomCode("vertex",this._material.shaderLanguage)),this._collectPointNames("fragment",s.getCustomCode("fragment",this._material.shaderLanguage));return this._defineNamesFromPlugins=i,!0}_activatePlugin(e){this._activePlugins.indexOf(e)===-1&&(this._activePlugins.push(e),this._activePlugins.sort((t,i)=>t.priority-i.priority),this._material._callbackPluginEventIsReadyForSubMesh=this._handlePluginEventIsReadyForSubMesh.bind(this),this._material._callbackPluginEventPrepareDefinesBeforeAttributes=this._handlePluginEventPrepareDefinesBeforeAttributes.bind(this),this._material._callbackPluginEventPrepareDefines=this._handlePluginEventPrepareDefines.bind(this),this._material._callbackPluginEventBindForSubMesh=this._handlePluginEventBindForSubMesh.bind(this),e.registerForExtraEvents&&(this._activePluginsForExtraEvents.push(e),this._activePluginsForExtraEvents.sort((t,i)=>t.priority-i.priority),this._material._callbackPluginEventHasRenderTargetTextures=this._handlePluginEventHasRenderTargetTextures.bind(this),this._material._callbackPluginEventFillRen
vendor: 11,410 bytes, lines 761-769
761derTargetTextures=this._handlePluginEventFillRenderTargetTextures.bind(this),this._material._callbackPluginEventHardBindForSubMesh=this._handlePluginEventHardBindForSubMesh.bind(this)))}getPlugin(e){for(let t=0;t<this._plugins.length;++t)if(this._plugins[t].name===e)return this._plugins[t];return null}_handlePluginEventIsReadyForSubMesh(e){let t=!0;for(const i of this._activePlugins)t=t&&i.isReadyForSubMesh(e.defines,this._scene,this._engine,e.subMesh);e.isReadyForSubMesh=t}_handlePluginEventPrepareDefinesBeforeAttributes(e){for(const t of this._activePlugins)t.prepareDefinesBeforeAttributes(e.defines,this._scene,e.mesh)}_handlePluginEventPrepareDefines(e){for(const t of this._activePlugins)t.prepareDefines(e.defines,this._scene,e.mesh)}_handlePluginEventHardBindForSubMesh(e){for(const t of this._activePluginsForExtraEvents)t.hardBindForSubMesh(this._material._uniformBuffer,this._scene,this._engine,e.subMesh)}_handlePluginEventBindForSubMesh(e){for(const t of this._activePlugins)t.bindForSubMesh(this._material._uniformBuffer,this._scene,this._engine,e.subMesh)}_handlePluginEventHasRenderTargetTextures(e){let t=!1;for(const i of this._activePluginsForExtraEvents)if(t=i.hasRenderTargetTextures(),t)break;e.hasRenderTargetTextures=t}_handlePluginEventFillRenderTargetTextures(e){for(const t of this._activePluginsForExtraEvents)t.fillRenderTargetTextures(e.renderTargets)}_handlePluginEvent(e,t){switch(e){case 512:{const i=t;for(const s of this._activePlugins)s.getActiveTextures(i.activeTextures);break}case 256:{const i=t;for(const s of this._activePlugins)s.getAnimatables(i.animatables);break}case 1024:{const i=t;let s=!1;for(const r of this._activePlugins)if(s=r.hasTexture(i.texture),s)break;i.hasTexture=s;break}case 2:{const i=t;for(const s of this._plugins)s.dispose(i.forceDisposeTextures);break}case 4:{const i=t;i.defineNames=this._defineNamesFromPlugins;break}case 128:{const i=t;for(const s of this._activePlugins)i.fallbackRank=s.addFallbacks(i.defines,i.fallbacks,i.fallbackRank),s.getAttributes(i.attributes,this._scene,i.mesh);this._uniformList.length>0&&i.uniforms.push(...this._uniformList),this._samplerList.length>0&&i.samplers.push(...this._samplerList),this._uboList.length>0&&i.uniformBuffersNames.push(...this._uboList),i.customCode=this._injectCustomCode(i,i.customCode);break}case 8:{const i=t;this._uboDeclaration="",this._vertexDeclaration="",this._fragmentDeclaration="",this._uniformList=[],this._samplerList=[],this._uboList=[];const s=this._material.shaderLanguage===1;for(const r of this._plugins){const a=r.getUniforms(this._material.shaderLanguage);if(a){if(a.ubo)for(const o of a.ubo){if(o.size&&o.type){const c=o.arraySize??0;if(i.ubo.addUniform(o.name,o.size,c),s){let u;switch(o.type){case"mat4":u="mat4x4f";break;case"float":u="f32";break;default:u=`${o.type}f`;break}c>0?this._uboDeclaration+=`uniform ${o.name}: array<${u}, ${c}>; 762`:this._uboDeclaration+=`uniform ${o.name}: ${u}; 763`}else this._uboDeclaration+=`${o.type} ${o.name}${c>0?`[${c}]`:""}; 764`}this._uniformList.push(o.name)}a.vertex&&(this._vertexDeclaration+=a.vertex+` 765`),a.fragment&&(this._fragmentDeclaration+=a.fragment+` 766`),a.externalUniforms&&this._uniformList.push(...a.externalUniforms)}r.getSamplers(this._samplerList),r.getUniformBuffersNames(this._uboList)}break}}}_collectPointNames(e,t){if(t)for(const i in t)this._codeInjectionPoints[e]||(this._codeInjectionPoints[e]={}),this._codeInjectionPoints[e][i]=!0}_injectCustomCode(e,t){return(i,s)=>{t&&(s=t(i,s)),this._uboDeclaration&&(s=s.replace("#define ADDITIONAL_UBO_DECLARATION",this._uboDeclaration)),this._vertexDeclaration&&(s=s.replace("#define ADDITIONAL_VERTEX_DECLARATION",this._vertexDeclaration)),this._fragmentDeclaration&&(s=s.replace("#define ADDITIONAL_FRAGMENT_DECLARATION",this._fragmentDeclaration));const r=this._codeInjectionPoints?.[i];if(!r)return s;let a=null;for(let o in r){let c="";for(const u of this._activePlugins){let d=u.getCustomCode(i,this._material.shaderLanguage)?.[o];d&&(u.resolveIncludes&&(a===null&&(a={defines:[],indexParameters:e.indexParameters,isFragment:!1,shouldUseHighPrecisionShader:this._engine._shouldUseHighPrecisionShader,processor:void 0,supportsUniformBuffers:this._engine.supportsUniformBuffers,shadersRepository:de.GetShadersRepository(0),includesShadersStore:de.GetIncludesShadersStore(0),version:void 0,platformName:this._engine.shaderPlatformName,processingContext:void 0,isNDCHalfZRange:this._engine.isNDCHalfZRange,useReverseDepthBuffer:this._engine.useReverseDepthBuffer,processCodeAfterIncludes:void 0}),a.isFragment=i==="fragment",$d(d,a,f=>d=f)),c+=d+` 767`)}if(c.length>0)if(o.charAt(0)==="!"){o=o.substring(1);let u="g";if(o.charAt(0)==="!")u="",o=o.substring(1);else{const m=IV.exec(o);m&&m.length>=2&&(u=m[1],o=o.substring(u.length+1))}u.indexOf("g")<0&&(u+="g");const d=s,f=new RegExp(o,u);let g=f.exec(d);for(;g!==null;){let m=c;for(let b=0;b<g.length;++b)m=m.replace("$"+b,g[b]);s=s.replace(g[0],m),g=f.exec(d)}}else{const u="#define "+o;s=s.replace(u,` 768`+c+` 769`+u)}}return s}}}Xa._MaterialPluginClassToMainDefine={};Xa._MaterialPluginCounter=0;Ke.OnEnginesDisposedObservable.add(()=>{DV()});const PV=[];let nE=null;function DV(){PV.length=0,fe.OnEventObservable.remove(nE),nE=null}class mc{isCompatible(e){switch(e){case 0:return!0;default:return!1}}_enable(e){e&&this._pluginManager._activatePlugin(this)}constructor(e,t,i,s,r=!0,a=!1,o=!1){this.priority=500,this.resolveIncludes=!1,this.registerForExtraEvents=!1,this.doNotSerialize=!1,this._material=e,this.name=t,this.priority=i,this.resolveIncludes=o,e.pluginManager||(e.pluginManager=new Xa(e),e.onDisposeObservable.add(()=>{e.pluginManager=void 0})),this._pluginDefineNames=s,this._pluginManager=e.pluginManager,r&&this._pluginManager._addPlugin(this),a&&this._enable(!0),this.markAllDefinesAsDirty=e._dirtyCallbacks[127]}getClassName(){return"MaterialPluginBase"}isReadyForSubMesh(e,t,i,s){return!0}hardBindForSubMesh(e,t,i,s){}bindForSubMesh(e,t,i,s){}dispose(e){}getCustomCode(e,t=0){return null}collectDefines(e){if(this._pluginDefineNames)for(const t of Object.keys(this._pluginDefineNames)){if(t[0]==="_")continue;const i=typeof this._pluginDefineNames[t];e[t]={type:i==="number"?"number":i==="string"?"string":i==="boolean"?"boolean":"object",default:this._pluginDefineNames[t]}}}prepareDefinesBeforeAttributes(e,t,i){}prepareDefines(e,t,i){}hasTexture(e){return!1}hasRenderTargetTextures(){return!1}fillRenderTargetTextures(e){}getActiveTextures(e){}getAnimatables(e){}addFallbacks(e,t,i){return i}getSamplers(e){}getAttributes(e,t,i){}getUniformBuffersNames(e){}getUniforms(e=0){return{}}copyTo(e){$e.Clone(()=>e,this)}serialize(){return $e.Serialize(this)}parse(e,t,i){$e.Parse(()=>this,e,t,i)}}N([H()],mc.prototype,"name",void 0);N([H()],mc.prototype,"priority",void 0);N([H()],mc.prototype,"resolveIncludes",void 0);N([H()],mc.prototype,"registerForExtraEvents",void 0);Tt("BABYLON.MaterialPluginBase",mc);class OV extends Hf{constructor(){super(...arguments),this.DETAIL=!1,this.DETAILDIRECTUV=0,this.DETAIL_NORMALBLENDMETHOD=0}}class qo extends mc{_markAllSubMeshesAsTexturesDirty(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()}isCompatible(){return!0}constructor(e,t=!0){super(e,"DetailMap",140,new OV,t),this._texture=null,this.diffuseBlendLevel=1,this.roughnessBlendLevel=1,this.bumpLevel=1,this._normalBlendMethod=fe.MATERIAL_NORMALBLENDMETHOD_WHITEOUT,this._isEnabled=!1,this.isEnabled=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e._dirtyCallbacks[1]}isReadyForSubMesh(e,t,i){return this._isEnabled?!(e._areTexturesDirty&&t.texturesEnabled&&i.getCaps().standardDerivatives&&this._texture&&at.DetailTextureEnabled&&!this._texture.isReady()):!0}prepareDefines(e,t){if(this._isEnabled){e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod;const i=t.getEngine();e._areTexturesDirty&&(i.getCaps().standardDerivatives&&this._texture&&at.DetailTextureEnabled&&this._isEnabled?(Ga(this._texture,e,"DETAIL"),e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod):e.DETAIL=!1)}else e.DETAIL=!1}bindForSubMesh(e,t){if(!this._isEnabled)return;const i=this._material.isFrozen;(!e.useUbo||!i||!e.isSync)&&this._texture&&at.DetailTextureEnabled&&(e.updateFloat4("vDetailInfos",this._texture.coordinatesIndex,this.diffuseBlendLevel,this.bumpLevel,this.roughnessBlendLevel),Ha(this._texture,e,"detail")),t.texturesEnabled&&this._texture&&at.DetailTextureEnabled&&e.setTexture("detailSampler",this._texture)}hasTexture(e){return this._texture===e}getActiveTextures(e){this._texture&&e.push(this._texture)}getAnimatables(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)}dispose(e){e&&this._texture?.dispose()}getClassName(){return"DetailMapConfiguration"}getSamplers(e){e.push("detailSampler")}getUniforms(){return{ubo:[{name:"vDetailInfos",size:4,type:"vec4"},{name:"detailMatrix",size:16,type:"mat4"}]}}}N([Lr("detailTexture"),Dt("_markAllSubMeshesAsTexturesDirty")],qo.prototype,"texture",void 0);N([H()],qo.prototype,"diffuseBlendLevel",void 0);N([H()],qo.prototype,"roughnessBlendLevel",void 0);N([H()],qo.prototype,"bumpLevel",void 0);N([H(),Dt("_markAllSubMeshesAsTexturesDirty")],qo.prototype,"normalBlendMethod",void 0);N([H(),Dt("_markAllSubMeshesAsTexturesDirty")],qo.prototype,"isEnabled",void 0);var aE;(function(n){n[n.Zero=0]="Zero",n[n.One=1]="One",n[n.MaxViewZ=2]="MaxViewZ"})(aE||(aE={}));class Ss{static CreateConfiguration(e){return Ss._Configurations[e]={defines:{},previousWorldMatrices:{},previousViewProjection:W.Zero(),currentViewProjection:W.Zero(),previousBones:{},lastUpdateFrameId:-1,excludedSkinnedMesh:[],reverseCulling:!1},Ss._Configurations[e]}static DeleteConfiguration(e){delete Ss._Configurations[e]}static GetConfiguration(e){return Ss._Configurations[e]}static AddUniformsAndSamplers(e,t){e.push("previousWorld","previousViewProjection","mPreviousBones")}static MarkAsDirty(e,t){for(const i of t)if(i.subMeshes)for(const s of i.subMeshes)s._removeDrawWrapper(e)}static PrepareDefines(e,t,i){if(!i._arePrePassDirty)return;const s=Ss._Configurations[e];if(!s)return;i.PREPASS=!0,i.PREPASS_COLOR=!1,i.PREPASS_COLOR_INDEX=-1;let r=0;for(let a=0;a<Ss.GeometryTextureDescriptions.length;a++){const o=Ss.GeometryTextureDescriptions[a],c=o.define,u=o.defineIndex,d=s.defines[u];d!==void 0?(i[c]=!0,i[u]=d,r++):(i[c]=!1,delete i[u])}i.SCENE_MRT_COUNT=r,i.BONES_VELOCITY_ENABLED=t.useBones&&t.computeBonesUsingShaders&&t.skeleton&&!t.skeleton.isUsingTextureForMatrices&&s.excludedSkinnedMesh.indexOf(t)===-1}static Bind(e,t,i,s,r){const a=Ss._Configurations[e];if(!a)return;const o=i.getScene(),c=o.getEngine();if(a.reverseCulling&&c.setStateCullFaceType(o._mirroredCameraPosition?r.cullBackFaces:!r.cullBackFaces),(a.defines.PREPASS_VELOCITY_INDEX!==void 0||a.defines.PREPASS_VELOCITY_LINEAR_INDEX!==void 0)&&(a.previousWorldMatrices[i.uniqueId]||(a.previousWorldMatrices[i.uniqueId]=s.clone()),a.previousViewProjection||(a.previousViewProjection=o.getTransformMatrix().clone(),a.currentViewProjection=o.getTransformMatrix().clone()),a.currentViewProjection.updateFlag!==o.getTransformMatrix().updateFlag?(a.lastUpdateFrameId=c.frameId,a.previousViewProjection.copyFrom(a.currentViewProjection),a.currentViewProjection.copyFrom(o.getTransformMatrix())):a.lastUpdateFrameId!==c.frameId&&(a.lastUpdateFrameId=c.frameId,a.previousViewProjection.copyFrom(a.currentViewProjection)),t.setMatr
769ix("previousWorld",a.previousWorldMatrices[i.uniqueId]),t.setMatrix("previousViewProjection",a.previousViewProjection),a.previousWorldMatrices[i.uniqueId]=s.clone(),i.useBones&&i.computeBonesUsingShaders&&i.skeleton)){const u=i.skeleton;if(!u.isUsingTextureForMatrices||t.getUniformIndex("boneTextureWidth")===-1){const d=u.getTransformMatrices(i);d&&(a.previousBones[i.uniqueId]||(a.previousBones[i.uniqueId]=d.slice()),t.setMatrices("mPreviousBones",a.previousBones[i.uniqueId]),a.previousBones[i.uniqueId].set(d))}}}}Ss.GeometryTextureDescriptions=[{type:0,name:"Irradiance",clearType:0,define:"PREPASS_IRRADIANCE",defineIndex:"PREPASS_IRRADIANCE_INDEX"},{type:1,name:"WorldPosition",clearType:0,define:"PREPASS_POSITION",defineIndex:"PREPASS_POSITION_INDEX"},{type:2,name:"Velocity",clearType:0,define:"PREPASS_VELOCITY",defineIndex:"PREPASS_VELOCITY_INDEX"},{type:3,name:"Reflectivity",clearType:0,define:"PREPASS_REFLECTIVITY",defineIndex:"PREPASS_REFLECTIVITY_INDEX"},{type:5,name:"ViewDepth",clearType:2,define:"PREPASS_DEPTH",defineIndex:"PREPASS_DEPTH_INDEX"},{type:6,name:"ViewNormal",clearType:0,define:"PREPASS_NORMAL",defineIndex:"PREPASS_NORMAL_INDEX"},{type:7,name:"AlbedoSqrt",clearType:0,define:"PREPASS_ALBEDO_SQRT",defineIndex:"PREPASS_ALBEDO_SQRT_INDEX"},{type:8,name:"WorldNormal",clearType:0,define:"PREPASS_WORLD_NORMAL",defineIndex:"PREPASS_WORLD_NORMAL_INDEX"},{type:9,name:"LocalPosition",clearType:0,define:"PREPASS_LOCAL_POSITION",defineIndex:"PREPASS_LOCAL_POSITION_INDEX"},{type:10,name:"ScreenDepth",clearType:1,define:"PREPASS_SCREENSPACE_DEPTH",defineIndex:"PREPASS_SCREENSPACE_DEPTH_INDEX"},{type:11,name:"LinearVelocity",clearType:0,define:"PREPASS_VELOCITY_LINEAR",defineIndex:"PREPASS_VELOCITY_LINEAR_INDEX"},{type:12,name:"Albedo",clearType:0,define:"PREPASS_ALBEDO",defineIndex:"PREPASS_ALBEDO_INDEX"},{type:13,name:"NormalizedViewDepth",clearType:1,define:"PREPASS_NORMALIZED_VIEW_DEPTH",defineIndex:"PREPASS_NORMALIZED_VIEW_DEPTH_INDEX"}];Ss._Configurations={};function II(n){return class extends n{constructor(){super(...arguments),this.MAINUV1=!1,this.MAINUV2=!1,this.MAINUV3=!1,this.MAINUV4=!1,this.MAINUV5=!1,this.MAINUV6=!1,this.UV1=!1,this.UV2=!1,this.UV3=!1,this.UV4=!1,this.UV5=!1,this.UV6=!1}}}function PI(n){return class extends n{constructor(...e){super(...e),rk.call(this,this,"_imageProcessingConfiguration")}get imageProcessingConfiguration(){return this._imageProcessingConfiguration}set imageProcessingConfiguration(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsImageProcessingDirty&&this._markAllSubMeshesAsImageProcessingDirty()}_attachImageProcessingConfiguration(e){e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),
769!e&&this.getScene?this._imageProcessingConfiguration=this.getScene().imageProcessingConfiguration:e&&(this._imageProcessingConfiguration=e),this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(()=>{this._markAllSubMeshesAsImageProcessingDirty&&this._markAllSubMeshesAsImageProcessingDirty()})))}get cameraColorCurvesEnabled(){return this.imageProcessingConfiguration.colorCurvesEnabled}set cameraColorCurvesEnabled(e){this.imageProcessingConfiguration.colorCurvesEnabled=e}get cameraColorGradingEnabled(){return this.imageProcessingConfiguration.colorGradingEnabled}set cameraColorGradingEnabled(e){this.imageProcessingConfiguration.colorGradingEnabled=e}get cameraToneMappingEnabled(){return this._imageProcessingConfiguration.toneMappingEnabled}set cameraToneMappingEnabled(e){this._imageProcessingConfiguration.toneMappingEnabled=e}get cameraExposure(){return this._imageProcessingConfiguration.exposure}set cameraExposure(e){this._imageProcessingConfiguration.exposure=e}get cameraContrast(){return this._imageProcessingConfiguration.contrast}set cameraContrast(e){this._imageProcessingConfiguration.contrast=e}get cameraColorGradingTexture(){return this._imageProcessingConfiguration.colorGradingTexture}set cameraColorGradingTexture(e){this._imageProcessingConfiguration.colorGradingTexture=e}get cameraColorCurves(){return this._imageProcessingConfiguration.colorCurves}set cameraColorCurves(e){this._imageProcessingConfiguration.colorCurves=e}}}const Gg={effect:null,subMesh:null};class wV extends II(Hf){}class FV extends CI(wV){constructor(e){super(e),this.DIFFUSE=!1,this.DIFFUSEDIRECTUV=0,this.BAKED_VERTEX_ANIMATION_TEXTURE=!1,this.AMBIENT=!1,this.AMBIENTDIRECTUV=0,this.OPACITY=!1,this.OPACITYDIRECTUV=0,this.OPACITYRGB=!1,this.REFLECTION=!1,this.EMISSIVE=!1,this.EMISSIVEDIRECTUV=0,this.SPECULAR=!1,this.SPECULARDIRECTUV=0,this.BUMP=!1,this.BUMPDIRECTUV=0,this.PARALLAX=!1,this.PARALLAX_RHS=!1,this.PARALLAXOCCLUSION=!1,this.SPECULAROVERALPHA=!1,this.CLIPPLANE=!1,this.CLIPPLANE2=!1,this.CLIPPLANE3=!1,this.CLIPPLANE4=!1,this.CLIPPLANE5=!1,this.CLIPPLANE6=!1,this.ALPHATEST=!1,this.DEPTHPREPASS=!1,this.ALPHAFROMDIFFUSE=!1,this.POINTSIZE=!1,this.FOG=!1,this.SPECULARTERM=!1,this.DIFFUSEFRESNEL=!1,this.OPACITYFRESNEL=!1,this.REFLECTIONFRESNEL=!1,this.REFRACTIONFRESNEL=!1,this.EMISSIVEFRESNEL=!1,this.FRESNEL=!1,this.NORMAL=!1,this.TANGENT=!1,this.VERTEXCOLOR=!1,this.VERTEXALPHA=!1,this.NUM_BONE_INFLUENCERS=0,this.BonesPerMesh=0,this.BONETEXTURE=!1,this.BONES_VELOCITY_ENABLED=!1,this.INSTANCES=!1,this.THIN_INSTANCES=!1,this.INSTANCESCOLOR=!1,this.GLOSSINESS=!1,this.ROUGHNESS=!1,this.EMISSIVEASILLUMINATION=!1,this.LINKEMISSIVEWITHDIFFUSE=!1,this.REFLECTIONFRESNELFROMSPECULAR=!1,this.LIGHTMAP=!1,this.LIGHTMAPDIRECTUV=0,this.OBJECTSPACE_NORMALMAP=!1,this.USELIGHTMAPASSHADOWMAP=!1,this.REFLECTIONMAP_3D=!1,this.REFLECTIONMAP_SPHERICAL=!1,this.REFLECTIONMAP_PLANAR=!1,this.REFLECTIONMAP_CUBIC=!1,this.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,this.USE_LOCAL_REFRACTIONMAP_CUBIC=!1,this.REFLECTIONMAP_PROJECTION=!1,this.REFLECTIONMAP_SKYBOX=!1,this.REFLECTIONMAP_EXPLICIT=!1,this.REFLECTIONMAP_EQUIRECTANGULAR=!1,this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,this.REFLECTIONMAP_OPPOSITEZ=!1,this.INVERTCUBICMAP=!1,this.LOGARITHMICDEPTH=!1,this.REFRACTION=!1,this.REFRACTIONMAP_3D=!1,this.REFLECTIONOVERALPHA=!1,this.TWOSIDEDLIGHTING=!1,this.SHADOWFLOAT=!1,this.MORPHTARGETS=!1,this.MORPHTARGETS_POSITION=!1,this.MORPHTARGETS_NORMAL=!1,this.MORPHTARGETS_TANGENT=!1,this.MORPHTARGETS_UV=!1,this.MORPHTARGETS_UV2=!1,this.MORPHTARGETS_COLOR=!1,this.MORPHTARGETTEXTURE_HASPOSITIONS=!1,this.MORPHTARGETTEXTURE_HASNORMALS=!1,this.MORPHTARGETTEXTURE_HASTANGENTS=!1,this.MORPHTARGETTEXTURE_HASUVS=!1,this.MORPHTARGETTEXTURE_HASUV2S=!1,this.MORPHTARGETTEXTURE_HASCOLORS=!1,this.NUM_MORPH_INFLUENCERS=0,this.MORPHTARGETS_TEXTURE=!1,this.NONUNIFORMSCALING=!1,this.PREMULTIPLYALPHA=!1,this.ALPHATEST_AFTERALLALPHACOMPUTATIONS=!1,this.ALPHABLEND=!0,this.PREPASS=!1,this.PREPASS_COLOR=!1,this.PREPASS_COLOR_INDEX=-1,this.PREPASS_IRRADIANCE=!1,this.PREPASS_IRRADIANCE_INDEX=-1,this.PREPASS_ALBEDO=!1,this.PREPASS_ALBEDO_INDEX=-1,this.PREPASS_ALBEDO_SQRT=!1,this.PREPASS_ALBEDO_SQRT_INDEX=-1,this.PREPASS_DEPTH=!1,this.PREPASS_DEPTH_INDEX=-1,this.PREPASS_SCREENSPACE_DEPTH=!1,this.PREPASS_SCREENSPACE_DEPTH_INDEX=-1,this.PREPASS_NORMALIZED_VIEW_DEPTH=!1,this.PREPASS_NORMALIZED_VIEW_DEPTH_INDEX=-1,this.PREPASS_NORMAL=!1,this.PREPASS_NORMAL_INDEX=-1,this.PREPASS_NORMAL_WORLDSPACE=!1,this.PREPASS_WORLD_NORMAL=!1,this.PREPASS_WORLD_NORMAL_INDEX=-1,this.PREPASS_POSITION=!1,this.PREPASS_POSITION_INDEX=-1,this.PREPASS_LOCAL_POSITION=!1,this.PREPASS_LOCAL_POSITION_INDEX=-1,this.PREPASS_VELOCITY=!1,this.PREPASS_VELOCITY_INDEX=-1,this.PREPASS_VELOCITY_LINEAR=!1,this.PREPASS_VELOCITY_LINEAR_INDEX=-1,this.PREPASS_REFLECTIVITY=!1,this.PREPASS_REFLECTIVITY_INDEX=-1,this.SCENE_MRT_COUNT=0,this.RGBDLIGHTMAP=!1,this.RGBDREFLECTION=!1,this.RGBDREFRACTION=!1,this.MULTIVIEW=!1,this.ORDER_INDEPENDENT_TRANSPARENCY=!1,this.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!1,this.CAMERA_ORTHOGRAPHIC=!1,this.CAMERA_PERSPECTIVE=!1,this.AREALIGHTSUPPORTED=!0,this.USE_VERTEX_PULLING=!1,this.CLUSTLIGHT_SLICES=0,this.CLUSTLIGHT_BATCH=0,this.IS_REFLECTION_LINEAR=!1,this.IS_REFRACTION_LINEAR=!1,this.DECAL_AFTER_DETAIL=!1,this.rebuild()}}class LV extends PI(Hb){}class Ae extends LV{get isPrePassCapable(){return!this.disableDepthWrite}get canRenderToMRT(){return!0}constructor(e,t,i=!1){super(e,t,void 0,i||Ae.ForceGLSL),this._diffuseTexture=null,this._ambientTexture=null,this._opacityTexture=null,this._reflectionTexture=null,this._emissiveTexture=null,this._specularTexture=null,this._bumpTexture=null,this._lightmapTexture=null,this._refractionTexture=null,this.ambientColor=new Ne(0,0,0),this.diffuseColor=new Ne(1,1,1),this.specularColor=new Ne(1,1,1),this.emissiveColor=new Ne(0,0,0),this.specularPower=64,this._useAlphaFromDiffuseTexture=!1,this._useEmissiveAsIllumination=!1,this._linkEmissiveWithDiffuse=!1,this._useSpecularOverAlpha=!1,this._useReflectionOverAlpha=!1,this._disableLighting=!1,this._useObjectSpaceNormalMap=!1,this._useParallax=!1,this._useParallaxOcclusion=!1,this.parallaxScaleBias=.05,this._roughness=0,this.indexOfRefraction=.98,this.invertRefractionY=!0,this.alphaCutOff=.4,this._useLightmapAsShadowmap=!1,this._useReflectionFresnelFromSpecular=!1,this._useGlossinessFromSpecularMapAlpha=!1,this._maxSimultaneousLights=4,this._invertNormalMapX=!1,this._invertNormalMapY=!1,this._twoSidedLighting=!1,this._applyDecalMapAfterDetailMap=!1,this._shadersLoaded=!1,this._renderTargets=new Yi(16),this._globalAmbientColor=new Ne(0,0,0),this._cacheHasRenderTargetTextures=!1,this.detailMap=new qo(this),this._attachImageProcessingConfiguration(null),this.prePassConfiguration=new rE,this.getRenderTargetTextures=()=>(this._renderTargets.reset(),Ae.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._renderTargets.push(this._reflectionTexture),Ae.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._renderTargets.push(this._refractionTexture),this._eventInfo.renderTargets=this._renderTargets,this._callbackPluginEventFillRen
vendor: 10,173 bytes, line 769
769derTargetTextures(this._eventInfo),this._renderTargets)}get hasRenderTargetTextures(){return Ae.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget||Ae.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget?!0:this._cacheHasRenderTargetTextures}getClassName(){return"StandardMaterial"}needAlphaBlending(){return this._hasTransparencyMode?this._transparencyModeIsBlend:this._disableAlphaBlending?!1:this.alpha<1||this._opacityTexture!=null||this._shouldUseAlphaFromDiffuseTexture()||this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled}needAlphaTesting(){return this._hasTransparencyMode?this._transparencyModeIsTest:this._hasAlphaChannel()&&(this._transparencyMode==null||this._transparencyMode===fe.MATERIAL_ALPHATEST)}_shouldUseAlphaFromDiffuseTexture(){return this._diffuseTexture!=null&&this._diffuseTexture.hasAlpha&&this._useAlphaFromDiffuseTexture&&this._transparencyMode!==fe.MATERIAL_OPAQUE}_hasAlphaChannel(){return this._diffuseTexture!=null&&this._diffuseTexture.hasAlpha||this._opacityTexture!=null}getAlphaTestTexture(){return this._diffuseTexture}isReadyForSubMesh(e,t,i=!1){this._uniformBufferLayoutBuilt||this.buildUniformLayout();const s=t._drawWrapper;if(s.effect&&this.isFrozen&&s._wasPreviouslyReady&&s._wasPreviouslyUsingInstances===i)return!0;t.materialDefines||(this._callbackPluginEventGeneric(4,this._eventInfo),t.materialDefines=new FV(this._eventInfo.defineNames));const r=this.getScene(),a=t.materialDefines;if(this._isReadyForSubMesh(t))return!0;const o=r.getEngine();a._needNormals=Jk(r,e,a,!0,this._maxSimultaneousLights,this._disableLighting),o3(r,a);const c=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;if(LC(r,a,this.canRenderToMRT&&!c),l3(r,a,c),Ss.PrepareDefines(o.currentRenderPassId,e,a),a._areTexturesDirty){this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._cacheHasRenderTargetTextures=this._eventInfo.hasRenderTargetTextures,a._needUVs=!1;for(let d=1;d<=6;++d)a["MAINUV"+d]=!1;if(r.texturesEnabled){if(a.DIFFUSEDIRECTUV=0,a.BUMPDIRECTUV=0,a.AMBIENTDIRECTUV=0,a.OPACITYDIRECTUV=0,a.EMISSIVEDIRECTUV=0,a.SPECULARDIRECTUV=0,a.LIGHTMAPDIRECTUV=0,this._diffuseTexture&&Ae.DiffuseTextureEnabled)if(this._diffuseTexture.isReadyOrNotBlocking())Ga(this._diffuseTexture,a,"DIFFUSE");else return!1;else a.DIFFUSE=!1;if(this._ambientTexture&&Ae.AmbientTextureEnabled)if(this._ambientTexture.isReadyOrNotBlocking())Ga(this._ambientTexture,a,"AMBIENT");else return!1;else a.AMBIENT=!1;if(this._opacityTexture&&Ae.OpacityTextureEnabled)if(this._opacityTexture.isReadyOrNotBlocking())Ga(this._opacityTexture,a,"OPACITY"),a.OPACITYRGB=this._opacityTexture.getAlphaFromRGB;else return!1;else a.OPACITY=!1;if(this._reflectionTexture&&Ae.ReflectionTextureEnabled?(a.ROUGHNESS=this._roughness>0,a.REFLECTIONOVERALPHA=this._useReflectionOverAlpha):(a.ROUGHNESS=!1,a.REFLECTIONOVERALPHA=!1),!e3(r,this._reflectionTexture,a))return!1;if(this._emissiveTexture&&Ae.EmissiveTextureEnabled)if(this._emissiveTexture.isReadyOrNotBlocking())Ga(this._emissiveTexture,a,"EMISSIVE");else return!1;else a.EMISSIVE=!1;if(this._lightmapTexture&&Ae.LightmapTextureEnabled)if(this._lightmapTexture.isReadyOrNotBlocking())Ga(this._lightmapTexture,a,"LIGHTMAP"),a.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,a.RGBDLIGHTMAP=this._lightmapTexture.isRGBD;else return!1;else a.LIGHTMAP=!1;if(this._specularTexture&&Ae.SpecularTextureEnabled)if(this._specularTexture.isReadyOrNotBlocking())Ga(this._specularTexture,a,"SPECULAR"),a.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha;else return!1;else a.SPECULAR=!1;if(r.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&Ae.BumpTextureEnabled){if(this._bumpTexture.isReady())Ga(this._bumpTexture,a,"BUMP"),a.PARALLAX=this._useParallax,a.PARALLAX_RHS=r.useRightHandedSystem,a.PARALLAXOCCLUSION=this._useParallaxOcclusion;else return!1;a.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap}else a.BUMP=!1,a.PARALLAX=!1,a.PARALLAX_RHS=!1,a.PARALLAXOCCLUSION=!1;if(this._refractionTexture&&Ae.RefractionTextureEnabled)if(this._refractionTexture.isReadyOrNotBlocking())a._needUVs=!0,a.REFRACTION=!0,a.REFRACTIONMAP_3D=this._refractionTexture.isCube,a.RGBDREFRACTION=this._refractionTexture.isRGBD,a.USE_LOCAL_REFRACTIONMAP_CUBIC=!!this._refractionTexture.boundingBoxSize;else return!1;else a.REFRACTION=!1;a.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else a.DIFFUSE=!1,a.AMBIENT=!1,a.OPACITY=!1,a.REFLECTION=!1,a.EMISSIVE=!1,a.LIGHTMAP=!1,a.BUMP=!1,a.REFRACTION=!1;a.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),a.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,a.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,a.SPECULAROVERALPHA=this._useSpecularOverAlpha,a.PREMULTIPLYALPHA=this.alphaMode===7||this.alphaMode===8,a.ALPHATEST_AFTERALLALPHACOMPUTATIONS=this.transparencyMode!==null,a.ALPHABLEND=this.transparencyMode===null||this.needAlphaBlendingForMesh(e)}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=a,this._eventInfo.subMesh=t,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh)return!1;if(a._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(a),a.IS_REFLECTION_LINEAR=this.reflectionTexture!=null&&!this.reflectionTexture.gammaSpace,a.IS_REFRACTION_LINEAR=this.refractionTexture!=null&&!this.refractionTexture.gammaSpace}if(a._areFresnelDirty&&(Ae.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(a.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,a.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,a.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,a.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,a.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,a.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,a._needNormals=!0,a.FRESNEL=!0):a.FRESNEL=!1),a.AREALIGHTUSED||a.CLUSTLIGHT_BATCH){for(let d=0;d<e.lightSources.length;d++)if(!e.lightSources[d]._isReady())return!1}Qk(e,r,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this.needAlphaTestingForMesh(e),a,this._applyDecalMapAfterDetailMap,this._useVertexPulling,t.getRenderingMesh(),this._isVertexOutputInvariant),i3(r,o,this,a,i,null,t.getRenderingMesh().hasThinInstances),this._eventInfo.defines=a,this._eventInfo.mesh=e,this._callbackPluginEventPrepareDefinesBeforeAttributes(this._eventInfo),a3(e,a,!0,!0,!0),this._callbackPluginEventPrepareDefines(this._eventInfo);let u=!1;if(a.isDirty){const d=a._areLightsDisposed;a.markAsProcessed();const f=new eu;a.REFLECTION&&f.addFallback(0,"REFLECTION"),a.SPECULAR&&f.addFallback(0,"SPECULAR"),a.BUMP&&f.addFallback(0,"BUMP"),a.PARALLAX&&f.addFallback(1,"PARALLAX"),a.PARALLAX_RHS&&f.addFallback(1,"PARALLAX_RHS"),a.PARALLAXOCCLUSION&&f.addFallback(0,"PARALLAXOCCLUSION"),a.SPECULAROVERALPHA&&f.addFallback(0,"SPECULAROVERALPHA"),a.FOG&&f.addFallback(1,"FOG"),a.POINTSIZE&&f.addFallback(0,"POINTSIZE"),a.LOGARITHMICDEPTH&&f.addFallback(0,"LOGARITHMICDEPTH"),Zk(a,f,this._maxSimultaneousLights),a.SPECULARTERM&&f.addFallback(0,"SPECULARTERM"),a.DIFFUSEFRESNEL&&f.addFallback(1,"DIFFUSEFRESNEL"),a.OPACITYFRESNEL&&f.addFallback(2,"OPACITYFRESNEL"),a.REFLECTIONFRESNEL&&f.addFallback(3,"REFLECTIONFRESNEL"),a.EMISSIVEFRESNEL&&f.addFallback(4,"EMISSIVEFRESNEL"),a.FRESNEL&&f.addFallback(4,"FRESNEL"),a.MULTIVIEW&&f.addFallback(0,"MULTIVIEW");const g=[O.PositionKind];a.NORMAL&&g.push(O.NormalKind),a.TANGENT&&g.push(O.TangentKind);for(let C=1;C<=6;++C)a["UV"+C]&&g.push(`uv${C===1?"":C}`);a.VERTEXCOLOR&&g.push(O.ColorKind),Kk(g,e,a,f),qk(g,a),FC(g,e,a),Xk(g,e,a);let m="default";const b=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","visibility","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","diffuseMatrix","ambientMatrix","opacityMatrix","emissiveMatrix","specularMatrix","bumpMatrix","normalMatrix","lightmapMatrix","refractionMatrix","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","vRefractionPosition","vRefractionSize","logarithmicDepthConstant","vTangentSpaceParams","alphaCutOff","boneTextureWidth","morphTargetTextureInfo","morphTargetTextureIndices","cameraInfo"],x=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler","boneSampler","morphTargets","oitDepthSampler","oitFrontColorSampler","areaLightsLTC1Sampler","areaLightsLTC2Sampler"];h3(b,x);const v=["Material","Scene","Mesh"],E={maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:a.NUM_MORPH_INFLUENCERS};this._eventInfo.fallbacks=f,this._eventInfo.fallbackRank=0,this._eventInfo.defines=a,this._eventInfo.uniforms=b,this._eventInfo.attributes=g,this._eventInfo.samplers=x,this._eventInfo.uniformBuffersNames=v,this._eventInfo.customCode=void 0,this._eventInfo.mesh=e,this._eventInfo.indexParameters=E,this._callbackPluginEventGeneric(128,this._eventInfo),Ss.AddUniformsAndSamplers(b,x),rE.AddUniforms(b),ft&&(ft.PrepareUniforms(b,a),ft.PrepareSamplers(x,a)),u3({uniformsNames:b,uniformBuffersNames:v,samplers:x,defines:a,maxSimultaneousLights:this._maxSimultaneousLights}),Nf(b);const A={};this.customShaderNameResolve&&(m=this.customShaderNameResolve(m,b,v,x,a,g,A));const D=a.toString(),I=t.effect;
769let R=r.getEngine().createEffect(m,{attributes:g,uniformsNames:b,uniformBuffersNames:v,samplers:x,defines:D,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:E,processFinalCode:A.processFinalCode,processCodeAfterIncludes:this._eventInfo.customCode,multiTarget:a.PREPASS,shaderLanguage:this._shaderLanguage,extraInitializationsAsync:this._shadersLoaded?void 0:async()=>{this._shaderLanguage===1?await Promise.all([_t(()=>import("./default.vertex-BwMGLOQH.js"),__vite__mapDeps([26,27,18,17,15,20,23,16])),_t(()=>import("./default.fragment-B1Enzn3Y.js"),__vite__mapDeps([28,27,18,17,13,25]))]):await Promise.all([_t(()=>Promise.resolve().then(()=>vz),void 0),_t(()=>Promise.resolve().then(()=>Yz),void 0)]),this._shadersLoaded=!0}},o);if(this._eventInfo.customCode=void 0,R)if(this._onEffectCreatedObservable&&(Gg.effect=R,Gg.subMesh=t,this._onEffectCreatedObservable.notifyObservers(Gg)),this.allowShaderHotSwapping&&I&&!R.isReady()){if(R=I,a.markAsUnprocessed(),u=this.isFrozen,d)return a._areLightsDisposed=!0,!1}else r.resetCachedMaterial(),t.setEffect(R,a,this._materialContext)}return!t.effect||!t.effect.isReady()?!1:(a._renderId=r.getRenderId(),s._wasPreviouslyReady=!u,s._wasPreviouslyUsingInstances=i,this._checkScenePerformancePriority(),!0)}buildUniformLayout(){const e=this._uniformBuffer;e.addUniform("diffuseLeftColor",4),e.addUniform("diffuseRightColor",4),e.addUniform("opacityParts",4),e.addUniform("reflectionLeftColor",4),e.addUniform("reflectionRightColor",4),e.addUniform("refractionLeftColor",4),e.addUniform("refractionRightColor",4),e.addUniform("emissiveLeftColor",4),e.addUniform("emissiveRightColor",4),e.addUniform("vDiffuseInfos",2),e.addUniform("vAmbientInfos",2),e.addUniform("vOpacityInfos",2),e.addUniform("vEmissiveInfos",2),e.addUniform("vLightmapInfos",2),e.addUniform("vSpecularInfos",2),e.addUniform("vBumpInfos",3),e.addUniform("diffuseMatrix",16),e.addUniform("ambientMatrix",16),e.addUniform("opacityMatrix",16),e.addUniform("emissiveMatrix",16),e.addUniform("lightmapMatrix",16),e.addUniform("specularMatrix",16),e.addUniform("bumpMatrix",16),e.addUniform("vTangentSpaceParams",2),e.addUniform("pointSize",1),e.addUniform("alphaCutOff",1),e.addUniform("refractionMatrix",16),e.addUniform("vRefractionInfos",4),e.addUniform("vRefractionPosition",3),e.addUniform("vRefractionSize",3),e.addUniform("vSpecularColor",4),e.addUniform("vEmissiveColor",3),e.addUniform("vDiffuseColor",4),e.addUniform("vAmbientColor",3),e.addUniform("cameraInfo",4),d3(e,!1,!0),super.buildUniformLayout()}bindForSubMesh(e,t,i){const s=this.getScene(),r=i.materialDefines;if(!r)return;const a=i.effect;if(!a)return;this._activeEffect=a,t.getMeshUniformBuffer().bindToEffect(a,"Mesh"),t.transferToEffect(e),this._uniformBuffer.bindToEffect(a,"Material"),this.prePassConfiguration.bindForSubMesh(this._activeEffect,s,t,e,this.isFrozen),Ss.Bind(s.getEngine().currentRenderPassId,this._activeEffect,t,e,this);const o=s.activeCamera;o?this._uniformBuffer.updateFloat4("cameraInfo",o.minZ,o.maxZ,0,0):this._uniformBuffer.updateFloat4("cameraInfo",0,0,0,0),this._eventInfo.subMesh=i,this._callbackPluginEventHardBindForSubMesh(this._eventInfo),r.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));const c=this._mustRebind(s,a,i,t.visibility);Bb(t,a);const u=this._uniformBuffer;if(c){if(this.bindViewProjection(a),!u.useUbo||!this.isFrozen||!u.isSync||i._drawWrapper._forceRebindOnNextCall){if(Ae.FresnelEnabled&&r.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(u.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),u.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&u.updateColor4("opacityParts",new Ne(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(u.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),u.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(u.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),u.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(u.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),u.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),s.texturesEnabled&&(this._diffuseTexture&&Ae.DiffuseTextureEnabled&&(u.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),Ha(this._diffuseTexture,u,"diffuse")),this._ambientTexture&&Ae.AmbientTextureEnabled&&(u.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),Ha(this._ambientTexture,u,"ambient")),this._opacityTexture&&Ae.OpacityTextureEnabled&&(u.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),Ha(this._opacityTexture,u,"opacity")),this._hasAlphaChannel()&&u.updateFloat("alphaCutOff",this.alphaCutOff),Wk(s,r,u,Ne.White(),this._reflectionTexture,!1,!1,!0,!1,!1,!1,this.roughness),(!this._reflectionTexture||!Ae.ReflectionTextureEnabled)&&u.updateFloat2("vReflectionInfos",0,this.roughness),this._emissiveTexture&&Ae.EmissiveTextureEnabled&&(u.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),Ha(this._emissiveTexture,u,"emissive")),this._lightmapTexture&&Ae.LightmapTextureEnabled&&(u.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),Ha(this._lightmapTexture,u,"lightmap")),this._specularTexture&&Ae.SpecularTextureEnabled&&(u.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),Ha(this._specularTexture,u,"specular")),this._bumpTexture&&s.getEngine().getCaps().standardDerivatives&&Ae.BumpTextureEnabled&&(u.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),Ha(this._bumpTexture,u,"bump"),s._mirroredCameraPosition?u.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):u.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),this._refractionTexture&&Ae.RefractionTextureEnabled)){let d=1;if(this._refractionTexture.isCube||(u.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(d=this._refractionTexture.depth)),u.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,d,this.invertRefractionY?-1:1),this._refractionTexture.boundingBoxSize){const f=this._refractionTexture;u.updateVector3("vRefractionPosition",f.boundingBoxPosition),u.updateVector3("vRefractionSize",f.boundingBoxSize)}}this.pointsCloud&&u.updateFloat("pointSize",this.pointSize),u.updateColor4("vSpecularColor",this.specularColor,this.specularPower),u.updateColor3("vEmissiveColor",Ae.EmissiveTextureEnabled?this.emissiveColor:Ne.BlackReadOnly),u.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha),s.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),u.updateColor3("vAmbientColor",this._globalAmbientColor)}s.texturesEnabled&&(this._diffuseTexture&&Ae.DiffuseTextureEnabled&&a.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&Ae.AmbientTextureEnabled&&a.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&Ae.OpacityTextureEnabled&&a.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&Ae.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?a.setTexture("reflectionCubeSampler",this._reflectionTexture):a.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&Ae.EmissiveTextureEnabled&&a.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&Ae.LightmapTextureEnabled&&a.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&Ae.SpecularTextureEnabled&&a.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&s.getEngine().getCaps().standardDerivatives&&Ae.BumpTextureEnabled&&a.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&Ae.RefractionTextureEnabled&&(this._refractionTexture.isCube?a.setTexture("refractionCubeSampler",this._refractionTexture):a.setTexture("refraction2DSampler",this._refractionTexture))),this.get
vendor: 7,939 bytes, line 769
769Scene().useOrderIndependentTransparency&&this.needAlphaBlendingForMesh(t)&&this.getScene().depthPeelingRenderer.bind(a),this._eventInfo.subMesh=i,this._callbackPluginEventBindForSubMesh(this._eventInfo),Bf(a,this,s),this.bindEyePosition(a)}else s.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._needToBindSceneUbo=!0);(c||!this.isFrozen)&&(s.lightsEnabled&&!this._disableLighting&&Yk(s,t,a,r,this._maxSimultaneousLights),(s.fogEnabled&&t.applyFog&&s.fogMode!==Pt.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture||t.receiveShadows||r.PREPASS||r.CLUSTLIGHT_BATCH)&&this.bindView(a),wC(s,t,a),r.NUM_MORPH_INFLUENCERS&&kf(t,a),r.BAKED_VERTEX_ANIMATION_TEXTURE&&t.bakedVertexAnimationManager?.bind(a,r.INSTANCES),this.useLogarithmicDepth&&Fb(r,a,s),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._afterBind(t,this._activeEffect,i),u.update()}getAnimatables(){const e=super.getAnimatables();return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e}getActiveTextures(){const e=super.getActiveTextures();return this._diffuseTexture&&e.push(this._diffuseTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._specularTexture&&e.push(this._specularTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e}hasTexture(e){return!!(super.hasTexture(e)||this._diffuseTexture===e||this._ambientTexture===e||this._opacityTexture===e||this._reflectionTexture===e||this._emissiveTexture===e||this._specularTexture===e||this._bumpTexture===e||this._lightmapTexture===e||this._refractionTexture===e)}dispose(e,t){t&&(this._diffuseTexture?.dispose(),this._ambientTexture?.dispose(),this._opacityTexture?.dispose(),this._reflectionTexture?.dispose(),this._emissiveTexture?.dispose(),this._specularTexture?.dispose(),this._bumpTexture?.dispose(),this._lightmapTexture?.dispose(),this._refractionTexture?.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),super.dispose(e,t)}clone(e,t=!0,i=""){const s=$e.Clone(()=>new Ae(e,this.getScene()),this,{cloneTexturesOnlyOnce:t});return s.name=e,s.id=e,this.stencil.copyTo(s.stencil),this._clonePlugins(s,i),s}static Parse(e,t,i){const s=$e.Parse(()=>new Ae(e.name,t),e,t,i);return e.stencil&&s.stencil.parse(e.stencil,t,i),fe._ParsePlugins(e,s,t,i),s}static get DiffuseTextureEnabled(){return at.DiffuseTextureEnabled}static set DiffuseTextureEnabled(e){at.DiffuseTextureEnabled=e}static get DetailTextureEnabled(){return at.DetailTextureEnabled}static set DetailTextureEnabled(e){at.DetailTextureEnabled=e}static get AmbientTextureEnabled(){return at.AmbientTextureEnabled}static set AmbientTextureEnabled(e){at.AmbientTextureEnabled=e}static get OpacityTextureEnabled(){return at.OpacityTextureEnabled}static set OpacityTextureEnabled(e){at.OpacityTextureEnabled=e}static get ReflectionTextureEnabled(){return at.ReflectionTextureEnabled}static set ReflectionTextureEnabled(e){at.ReflectionTextureEnabled=e}static get EmissiveTextureEnabled(){return at.EmissiveTextureEnabled}static set EmissiveTextureEnabled(e){at.EmissiveTextureEnabled=e}static get SpecularTextureEnabled(){return at.SpecularTextureEnabled}static set SpecularTextureEnabled(e){at.SpecularTextureEnabled=e}static get BumpTextureEnabled(){return at.BumpTextureEnabled}static set BumpTextureEnabled(e){at.BumpTextureEnabled=e}static get LightmapTextureEnabled(){return at.LightmapTextureEnabled}static set LightmapTextureEnabled(e){at.LightmapTextureEnabled=e}static get RefractionTextureEnabled(){return at.RefractionTextureEnabled}static set RefractionTextureEnabled(e){at.RefractionTextureEnabled=e}static get ColorGradingTextureEnabled(){return at.ColorGradingTextureEnabled}static set ColorGradingTextureEnabled(e){at.ColorGradingTextureEnabled=e}static get FresnelEnabled(){return at.FresnelEnabled}static set FresnelEnabled(e){at.FresnelEnabled=e}}Ae.ForceGLSL=!1;N([Lr("diffuseTexture")],Ae.prototype,"_diffuseTexture",void 0);N([Dt("_markAllSubMeshesAsTexturesAndMiscDirty")],Ae.prototype,"diffuseTexture",void 0);N([Lr("ambientTexture")],Ae.prototype,"_ambientTexture",void 0);N([Dt("_markAllSubMeshesAsTexturesDirty")],Ae.prototype,"ambientTexture",void 0);N([Lr("opacityTexture")],Ae.prototype,"_opacityTexture",void 0);N([Dt("_markAllSubMeshesAsTexturesAndMiscDirty")],Ae.prototype,"opacityTexture",void 0);N([Lr("reflectionTexture")],Ae.prototype,"_reflectionTexture",void 0);N([Dt("_markAllSubMeshesAsTexturesDirty")],Ae.prototype,"reflectionTexture",void 0);N([Lr("emissiveTexture")],Ae.prototype,"_emissiveTexture",void 0);N([Dt("_markAllSubMeshesAsTexturesDirty")],Ae.prototype,"emissiveTexture",void 0);N([Lr("specularTexture")],Ae.prototype,"_specularTexture",void 0);N([Dt("_markAllSubMeshesAsTexturesDirty")],Ae.prototype,"specularTexture",void 0);N([Lr("bumpTexture")],Ae.prototype,"_bumpTexture",void 0);N([Dt("_markAllSubMeshesAsTexturesDirty")],Ae.prototype,"bumpTexture",void 0);N([Lr("lightmapTexture")],Ae.prototype,"_lightmapTexture",void 0);N([Dt("_markAllSubMeshesAsTexturesDirty")],Ae.prototype,"lightmapTexture",void 0);N([Lr("refractionTexture")],Ae.prototype,"_refractionTexture",void 0);N([Dt("_markAllSubMeshesAsTexturesDirty")],Ae.prototype,"refractionTexture",void 0);N([Yo("ambient")],Ae.prototype,"ambientColor",void 0);N([Yo("diffuse")],Ae.prototype,"diffuseColor",void 0);N([Yo("specular")],Ae.prototype,"specularColor",void 0);N([Yo("emissive")],Ae.prototype,"emissiveColor",void 0);N([H()],Ae.prototype,"specularPower",void 0);N([H("useAlphaFromDiffuseTexture")],Ae.prototype,"_useAlphaFromDiffuseTexture",void 0);N([Dt("_markAllSubMeshesAsTexturesAndMiscDirty")],Ae.prototype,"useAlphaFromDiffuseTexture",void 0);N([H("useEmissiveAsIllumination")],Ae.prototype,"_useEmissiveAsIllumination",void 0);N([Dt("_markAllSubMeshesAsTexturesDirty")],Ae.prototype,"useEmissiveAsIllumination",void 0);N([H("linkEmissiveWithDiffuse")],Ae.prototype,"_linkEmissiveWithDiffuse",void 0);N([Dt("_markAllSubMeshesAsTexturesDirty")],Ae.prototype,"linkEmissiveWithDiffuse",void 0);N([H("useSpecularOverAlpha")],Ae.prototype,"_useSpecularOverAlpha",void 0);N([Dt("_markAllSubMeshesAsTexturesDirty")],Ae.prototype,"useSpecularOverAlpha",void 0);N([H("useReflectionOverAlpha")],Ae.prototype,"_useReflectionOverAlpha",void 0);N([Dt("_markAllSubMeshesAsTexturesDirty")],Ae.prototype,"useReflectionOverAlpha",void 0);N([H("disableLighting")],Ae.prototype,"_disableLighting",void 0);
vendor: 84,678 bytes, lines 769-843
769N([Dt("_markAllSubMeshesAsLightsDirty")],Ae.prototype,"disableLighting",void 0);N([H("useObjectSpaceNormalMap")],Ae.prototype,"_useObjectSpaceNormalMap",void 0);N([Dt("_markAllSubMeshesAsTexturesDirty")],Ae.prototype,"useObjectSpaceNormalMap",void 0);N([H("useParallax")],Ae.prototype,"_useParallax",void 0);N([Dt("_markAllSubMeshesAsTexturesDirty")],Ae.prototype,"useParallax",void 0);N([H("useParallaxOcclusion")],Ae.prototype,"_useParallaxOcclusion",void 0);N([Dt("_markAllSubMeshesAsTexturesDirty")],Ae.prototype,"useParallaxOcclusion",void 0);N([H()],Ae.prototype,"parallaxScaleBias",void 0);N([H("roughness")],Ae.prototype,"_roughness",void 0);N([Dt("_markAllSubMeshesAsTexturesDirty")],Ae.prototype,"roughness",void 0);N([H()],Ae.prototype,"indexOfRefraction",void 0);N([H()],Ae.prototype,"invertRefractionY",void 0);N([H()],Ae.prototype,"alphaCutOff",void 0);N([H("useLightmapAsShadowmap")],Ae.prototype,"_useLightmapAsShadowmap",void 0);N([Dt("_markAllSubMeshesAsTexturesDirty")],Ae.prototype,"useLightmapAsShadowmap",void 0);N([$h("diffuseFresnelParameters")],Ae.prototype,"_diffuseFresnelParameters",void 0);N([Dt("_markAllSubMeshesAsFresnelDirty")],Ae.prototype,"diffuseFresnelParameters",void 0);N([$h("opacityFresnelParameters")],Ae.prototype,"_opacityFresnelParameters",void 0);N([Dt("_markAllSubMeshesAsFresnelAndMiscDirty")],Ae.prototype,"opacityFresnelParameters",void 0);N([$h("reflectionFresnelParameters")],Ae.prototype,"_reflectionFresnelParameters",void 0);N([Dt("_markAllSubMeshesAsFresnelDirty")],Ae.prototype,"reflectionFresnelParameters",void 0);N([$h("refractionFresnelParameters")],Ae.prototype,"_refractionFresnelParameters",void 0);N([Dt("_markAllSubMeshesAsFresnelDirty")],Ae.prototype,"refractionFresnelParameters",void 0);N([$h("emissiveFresnelParameters")],Ae.prototype,"_emissiveFresnelParameters",void 0);N([Dt("_markAllSubMeshesAsFresnelDirty")],Ae.prototype,"emissiveFresnelParameters",void 0);N([H("useReflectionFresnelFromSpecular")],Ae.prototype,"_useReflectionFresnelFromSpecular",void 0);N([Dt("_markAllSubMeshesAsFresnelDirty")],Ae.prototype,"useReflectionFresnelFromSpecular",void 0);N([H("useGlossinessFromSpecularMapAlpha")],Ae.prototype,"_useGlossinessFromSpecularMapAlpha",void 0);N([Dt("_markAllSubMeshesAsTexturesDirty")],Ae.prototype,"useGlossinessFromSpecularMapAlpha",void 0);N([H("maxSimultaneousLights")],Ae.prototype,"_maxSimultaneousLights",void 0);N([Dt("_markAllSubMeshesAsLightsDirty")],Ae.prototype,"maxSimultaneousLights",void 0);N([H("invertNormalMapX")],Ae.prototype,"_invertNormalMapX",void 0);N([Dt("_markAllSubMeshesAsTexturesDirty")],Ae.prototype,"invertNormalMapX",void 0);N([H("invertNormalMapY")],Ae.prototype,"_invertNormalMapY",void 0);N([Dt("_markAllSubMeshesAsTexturesDirty")],Ae.prototype,"invertNormalMapY",void 0);N([H("twoSidedLighting")],Ae.prototype,"_twoSidedLighting",void 0);N([Dt("_markAllSubMeshesAsTexturesDirty")],Ae.prototype,"twoSidedLighting",void 0);N([H("applyDecalMapAfterDetailMap")],Ae.prototype,"_applyDecalMapAfterDetailMap",void 0);N([Dt("_markAllSubMeshesAsMiscDirty")],Ae.prototype,"applyDecalMapAfterDetailMap",void 0);Tt("BABYLON.StandardMaterial",Ae);Pt.DefaultMaterialFactory=n=>new Ae("default material",n);class NV{constructor(){this._zoomStopsAnimation=!1,this._idleRotationSpeed=.05,this._idleRotationWaitTime=2e3,this._idleRotationSpinupTime=2e3,this.targetAlpha=null,this._isPointerDown=!1,this._lastFrameTime=null,this._lastInteractionTime=-1/0,this._cameraRotationSpeed=0,this._lastFrameRadius=0}get name(){return"AutoRotation"}set zoomStopsAnimation(e){this._zoomStopsAnimation=e}get zoomStopsAnimation(){return this._zoomStopsAnimation}set idleRotationSpeed(e){this._idleRotationSpeed=e}get idleRotationSpeed(){return this._idleRotationSpeed}set idleRotationWaitTime(e){this._idleRotationWaitTime=e}get idleRotationWaitTime(){return this._idleRotationWaitTime}set idleRotationSpinupTime(e){this._idleRotationSpinupTime=e}get idleRotationSpinupTime(){return this._idleRotationSpinupTime}get rotationInProgress(){return Math.abs(this._cameraRotationSpeed)>0}init(){}attach(e){this._attachedCamera=e;const t=this._attachedCamera.getScene();this._onPrePointerObservableObserver=t.onPrePointerObservable.add(i=>{if(i.type===Ve.POINTERDOWN){this._isPointerDown=!0;return}i.type===Ve.POINTERUP&&(this._isPointerDown=!1)}),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add(()=>{if(this._reachTargetAlpha())return;const i=nr.Now;let s=0;this._lastFrameTime!=null&&(s=i-this._lastFrameTime),this._lastFrameTime=i,this._applyUserInteraction();const r=i-this._lastInteractionTime-this._idleRotationWaitTime,a=Math.max(Math.min(r/this._idleRotationSpinupTime,1),0);this._cameraRotationSpeed=this._idleRotationSpeed*a,this._attachedCamera&&(this._attachedCamera.alpha-=this._cameraRotationSpeed*(s/1e3))})}detach(){if(!this._attachedCamera)return;const e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._attachedCamera=null,this._lastFrameTime=null}resetLastInteractionTime(e){this._lastInteractionTime=e??nr.Now}_reachTargetAlpha(){return this._attachedCamera&&this.targetAlpha?Math.abs(this._attachedCamera.alpha-this.targetAlpha)<bt:!1}_userIsZooming(){return this._attachedCamera?this._attachedCamera.inertialRadiusOffset!==0:!1}_shouldAnimationStopForInteraction(){if(!this._attachedCamera)return!1;let e=!1;return this._lastFrameRadius===this._attachedCamera.radius&&this._attachedCamera.inertialRadiusOffset!==0&&(e=!0),this._lastFrameRadius=this._attachedCamera.radius,this._zoomStopsAnimation?e:this._userIsZooming()}_applyUserInteraction(){this._userIsMoving()&&!this._shouldAnimationStopForInteraction()&&(this._lastInteractionTime=nr.Now)}_userIsMoving(){return this._attachedCamera?this._attachedCamera.inertialAlphaOffset!==0||this._attachedCamera.inertialBetaOffset!==0||this._attachedCamera.inertialRadiusOffset!==0||this._attachedCamera.inertialPanningX!==0||this._attachedCamera.inertialPanningY!==0||this._isPointerDown:!1}}class Rs{constructor(){this._easingMode=Rs.EASINGMODE_EASEIN}setEasingMode(e){const t=Math.min(Math.max(e,0),2);this._easingMode=t}getEasingMode(){return this._easingMode}easeInCore(e){throw new Error("You must implement this method")}ease(e){switch(this._easingMode){case Rs.EASINGMODE_EASEIN:return this.easeInCore(e);case Rs.EASINGMODE_EASEOUT:return 1-this.easeInCore(1-e)}return e>=.5?(1-this.easeInCore((1-e)*2))*.5+.5:this.easeInCore(e*2)*.5}}Rs.EASINGMODE_EASEIN=0;Rs.EASINGMODE_EASEOUT=1;Rs.EASINGMODE_EASEINOUT=2;class BV extends Rs{constructor(e=1){super(),this.amplitude=e}easeInCore(e){const t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)}}class UV extends Rs{constructor(e=2){super(),this.exponent=e}easeInCore(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)}}class kV extends Rs{easeInCore(e){return e*e}}class VV extends Rs{easeInCore(e){return 1-Math.sin(1.5707963267948966*(1-e))}}class Wf{constructor(e,t,i){this.name=e,this.from=t,this.to=i}clone(){return new Wf(this.name,this.from,this.to)}}const zV=Object.freeze(new Se(0,0,0,0)),GV=Object.freeze(T.Zero()),HV=Object.freeze(Ie.Zero()),WV=Object.freeze(er.Zero()),XV=Object.freeze(Ne.Black()),jV=Object.freeze(new Ze(0,0,0,0)),Hr={key:0,repeatCount:0,loopMode:2};class xe{static _PrepareAnimation(e,t,i,s,r,a,o,c){let u;if(!isNaN(parseFloat(r))&&isFinite(r)?u=xe.ANIMATIONTYPE_FLOAT:r instanceof Se?u=xe.ANIMATIONTYPE_QUATERNION:r instanceof T?u=xe.ANIMATIONTYPE_VECTOR3:r instanceof Ie?u=xe.ANIMATIONTYPE_VECTOR2:r instanceof Ne?u=xe.ANIMATIONTYPE_COLOR3:r instanceof Ze?u=xe.ANIMATIONTYPE_COLOR4:r instanceof er&&(u=xe.ANIMATIONTYPE_SIZE),u==null)return null;const d=new xe(e,t,i,u,o),f=[{frame:0,value:r},{frame:s,value:a}];return d.setKeys(f),c!==void 0&&d.setEasingFunction(c),d}static CreateAnimation(e,t,i,s){const r=new xe(e+"Animation",e,i,t,xe.ANIMATIONLOOPMODE_CONSTANT);return r.setEasingFunction(s),r}static CreateAndStartAnimation(e,t,i,s,r,a,o,c,u,d,f){const g=xe._PrepareAnimation(e,i,s,r,a,o,c,u);return!g||(t.getScene&&(f=t.getScene()),!f)?null:f.beginDirectAnimation(t,[g],0,r,g.loopMode!==xe.ANIMATIONLOOPMODE_CONSTANT,1,d)}static CreateAndStartHierarchyAnimation(e,t,i,s,r,a,o,c,u,d,f){const g=xe._PrepareAnimation(e,s,r,a,o,c,u,d);return g?t.getScene().beginDirectHierarchyAnimation(t,i,[g],0,a,g.loopMode===1,1,f):null}static CreateMergeAndStartAnimation(e,t,i,s,r,a,o,c,u,d){const f=xe._PrepareAnimation(e,i,s,r,a,o,c,u);return f?(t.animations.push(f),t.getScene().beginAnimation(t,0,r,f.loopMode===1,1,d)):null}static MakeAnimationAdditive(e,t,i,s=!1,r){let a;typeof t=="object"?a=t:a={referenceFrame:t??0,range:i,cloneOriginalAnimation:s,clonedAnimationName:r};let o=e;if(a.cloneOriginalAnimation&&(o=e.clone(),o.name=a.clonedAnimationName||o.name),!o._keys.length)return o;const c=a.referenceFrame&&a.referenceFrame>=0?a.referenceFrame:0;let u=0;const d=o._keys[0];let f=o._keys.length-1;const g=o._keys[f],m={referenceValue:d.value,referencePosition:te.Vector3[0],referenceQuaternion:te.Quaternion[0],referenceScaling:te.Vector3[1],keyPosition:te.Vector3[2],keyQuaternion:te.Quaternion[1],keyScaling:te.Vector3[3]};let b=d.frame,x=g.frame;if(a.range){const A=o.getRange(a.range);A&&(b=A.from,x=A.to)}else b=a.fromFrame??b,x=a.toFrame??x;if(b!==d.frame&&(u=o.createKeyForFrame(b)),x!==g.frame&&(f=o.createKeyForFrame(x)),o._keys.length===1){const A=o._getKeyValue(o._keys[0]);m.referenceValue=A.clone?A.clone():A}else if(c<=d.frame){const A=o._getKeyValue(d.value);m.referenceValue=A.clone?A.clone():A}else if(c>=g.frame){const A=o._getKeyValue(g.value);m.referenceValue=A.clone?A.clone():A}else{Hr.key=0;const A=o._interpolate(c,Hr);m.referenceValue=A.clone?A.clone():A}o.dataType===xe.ANIMATIONTYPE_QUATERNION?m.referenceValue.normalize().conjugateInPlace():o.dataType===xe.ANIMATIONTYPE_MATRIX&&(m.referenceValue.decompose(m.referenceScaling,m.referenceQuaternion,m.referencePosition),m.referenceQuaternion.normalize().conjugateInPlace());let v=Number.MAX_VALUE;const E=a.clipKeys?[]:null;for(let A=u;A<=f;A++){let D=o._keys[A];if((E||a.cloneOriginalAnimation)&&(D={frame:D.frame,value:D.value.clone?D.value.clone():D.value,inTangent:D.inTangent,outTangent:D.outTangent,interpolation:D.interpolation,lockedTangent:D.lockedTangent},E&&(v===Number.MAX_VALUE&&(v=D.frame),D.frame-=v,E.push(D))),!(A&&o.dataType!==xe.ANIMATIONTYPE_FLOAT&&D.value===d.value))switch(o.dataType){case xe.ANIMATIONTYPE_MATRIX:D.value.decompose(m.keyScaling,m.keyQuaternion,m.keyPosition),m.keyPosition.subtractInPlace(m.referencePosition),m.keyScaling.divideInPlace(m.referenceScaling),m.referenceQuaternion.multiplyToRef(m.keyQuaternion,m.keyQuaternion),W.ComposeToRef(m.keyScaling,m.keyQuaternion,m.keyPosition,D.value);break;case xe.ANIMATIONTYPE_QUATERNION:m.referenceValue.multiplyToRef(D.value,D.value);break;case xe.ANIMATIONTYPE_VECTOR2:case xe.ANIMATIONTYPE_VECTOR3:case xe.ANIMATIONTYPE_COLOR3:case xe.ANIMATIONTYPE_COLOR4:D.value.subtractToRef(m.referenceValue,D.value);break;case xe.ANIMATIONTYPE_SIZE:D.value.width-=m.referenceValue.width,D.value.height-=m.referenceValue.height;break;default:D.value-=m.referenceValue}}return E&&o.setKeys(E,!0),o}static TransitionTo(e,t,i,s,r,a,o,c=null,u=!0){if(o<=0)return i[e]=t,c&&c(),null;const d=r*(o/1e3);return a.setKeys([{frame:0,value:i[e].clone?i[e].clone():i[e]},{frame:d,value:t}]),i.animations||(i.animations=[]),i.animations.push(a),s.beginAnimation(i,0,d,!1,1,c??void 0,void 0,u)}get runtimeAnimations(){return this._runtimeAnimations}get hasRunningRuntimeAnimations(){for(const e of this._runtimeAnimations)if(!e.isStopped())return!0;return!1}constructor(e,t,i,s,r,a){this.name=e,this.targetProperty=t,this.framePerSecond=i,this.dataType=s,this.loopMode=r,this.enableBlending=a,this._easingFunction=null,this._runtimeAnimations=new Array,this._events=new Array,this.blendingSpeed=.01,this._ranges={},this._coreAnimation=null,this.targetPropertyPath=t.split("."),this.dataType=s,this.loopMode=r===void 0?xe.ANIMATIONLOOPMODE_CYCLE:r,this.uniqueId=xe._UniqueIdGenerator++}toString(e){let t="Name: "+this.name+", property: "+this.targetProperty;if(t+=", datatype: "+["Float","Vector3","Quaternion","Matrix","Color3","Vector2"][this.dataType],t+=", nKeys: "+(this._keys?this._keys.length:"none"),t+=", nRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";let i=!0;for(const s in this._ranges)i&&(t+=", ",i=!1),t+=s;t+="}"}return t}addEvent(e){this._events.push(e),this._events.sort((t,i)=>t.frame-i.frame)}removeEvents(e){for(let t=0;t<this._events.length;t++)this._events[t].frame===e&&(this._events.splice(t,1),t--)}getEvents(){return this._events}createRange(e,t,i){this._ranges[e]||(this._ranges[e]=new Wf(e,t,i))}deleteRange(e,t=!0){const i=this._ranges[e];if(i){if(t){const s=i.from,r=i.to;for(let a=this._keys.length-1;a>=0;a--)this._keys[a].frame>=s&&this._keys[a].frame<=r&&this._keys.splice(a,1)}this._ranges[e]=null}}getRange(e){return this._ranges[e]}getKeys(){return this._keys}getHighestFrame(){let e=0;for(let t=0,i=this._keys.length;t<i;t++)e<this._keys[t].frame&&(e=this._keys[t].frame);return e}getEasingFunction(){return this._easingFunction}setEasingFunction(e){this._easingFunction=e}floatInterpolateFunction(e,t,i){return Jd(e,t,i)}floatInterpolateFunctionWithTangents(e,t,i,s,r){return ZU(e,t,i,s,r)}quaternionInterpolateFunction(e,t,i){return Se.Slerp(e,t,i)}quaternionInterpolateFunctionWithTangents(e,t,i,s,r){return Se.Hermite(e,t,i,s,r).normalize()}vector3InterpolateFunction(e,t,i){return T.Lerp(e,t,i)}vector3InterpolateFunctionWithTangents(e,t,i,s,r){return T.Hermite(e,t,i,s,r)}vector2InterpolateFunction(e,t,i){return Ie.Lerp(e,t,i)}vector2InterpolateFunctionWithTangents(e,t,i,s,r){return Ie.Hermite(e,t,i,s,r)}sizeInterpolateFunction(e,t,i){return er.Lerp(e,t,i)}color3InterpolateFunction(e,t,i){return Ne.Lerp(e,t,i)}color3InterpolateFunctionWithTangents(e,t,i,s,r){return Ne.Hermite(e,t,i,s,r)}color4InterpolateFunction(e,t,i){return Ze.Lerp(e,t,i)}color4InterpolateFunctionWithTangents(e,t,i,s,r){return Ze.Hermite(e,t,i,s,r)}_getKeyValue(e){return typeof e=="function"?e():e}evaluate(e){return Hr.key=0,this._interpolate(e,Hr)}_interpolate(e,t,i=!1){if(t.loopMode===xe.ANIMATIONLOOPMODE_CONSTANT&&t.repeatCount>0)return t.highLimitValue.clone?t.highLimitValue.clone():t.highLimitValue;const s=this._keys;let r;if(this._coreAnimation)r=this._coreAnimation._key;else{const b=s.length;for(r=t.key;r>=0&&e<s[r].frame;)--r;for(;r+1<=b-1&&e>=s[r+1].frame;)++r;if(t.key=r,r<0)return i?void 0:this._getKeyValue(s[0].value);if(r+1>b-1)return i?void 0:this._getKeyValue(s[b-1].value);this._key=r}const a=s[r],o=s[r+1];if(i&&(e===a.frame||e===o.frame))return;const c=this._getKeyValue(a.value),u=this._getKeyValue(o.value);if(a.interpolation===1)return o.frame>e?c:u;const d=a.outTangent!==void 0&&o.inTangent!==void 0,f=o.frame-a.frame;let g=(e-a.frame)/f;const m=a.easingFunction||this.getEasingFunction();switch(m&&(g=m.ease(g)),this.dataType){case xe.ANIMATIONTYPE_FLOAT:{const b=d?this.floatInterpolateFunctionWithTangents(c,a.outTangent*f,u,o.inTangent*f,g):this.floatInterpolateFunction(c,u,g);switch(t.loopMode){case xe.ANIMATIONLOOPMODE_CYCLE:case xe.ANIMATIONLOOPMODE_CONSTANT:case xe.ANIMATIONLOOPMODE_YOYO:return b;case xe.ANIMATIONLOOPMODE_RELATIVE:case xe.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return(t.offsetValue??0)*t.repeatCount+b}break}case xe.ANIMATIONTYPE_QUATERNION:{const b=d?this.quaternionInterpolateFunctionWithTangents(c,a.outTangent.scale(f),u,o.inTangent.scale(f),g):this.quaternionInterpolateFunction(c,u,g);switch(t.loopMode){case xe.ANIMATIONLOOPMODE_CYCLE:case xe.ANIMATIONLOOPMODE_CONSTANT:case xe.ANIMATIONLOOPMODE_YOYO:return b;case xe.ANIMATIONLOOPMODE_RELATIVE:case xe.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return b.addInPlace((t.offsetValue||zV).scale(t.repeatCount))}return b}case xe.ANIMATIONTYPE_VECTOR3:{const b=d?this.vector3InterpolateFunctionWithTangents(c,a.outTangent.scale(f),u,o.inTangent.scale(f),g):this.vector3InterpolateFunction(c,u,g);switch(t.loopMode){case xe.ANIMATIONLOOPMODE_CYCLE:case xe.ANIMATIONLOOPMODE_CONSTANT:case xe.ANIMATIONLOOPMODE_YOYO:return b;case xe.ANIMATIONLOOPMODE_RELATIVE:case xe.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return b.add((t.offsetValue||GV).scale(t.repeatCount))}break}case xe.ANIMATIONTYPE_VECTOR2:{const b=d?this.vector2InterpolateFunctionWithTangents(c,a.outTangent.scale(f),u,o.inTangent.scale(f),g):this.vector2InterpolateFunction(c,u,g);switch(t.loopMode){case xe.ANIMATIONLOOPMODE_CYCLE:case xe.ANIMATIONLOOPMODE_CONSTANT:case xe.ANIMATIONLOOPMODE_YOYO:return b;case xe.ANIMATIONLOOPMODE_RELATIVE:case xe.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return b.add((t.offsetValue||HV).scale(t.repeatCount))}break}case xe.ANIMATIONTYPE_SIZE:{switch(t.loopMode){case xe.ANIMATIONLOOPMODE_CYCLE:case xe.ANIMATIONLOOPMODE_CONSTANT:case xe.ANIMATIONLOOPMODE_YOYO:return this.sizeInterpolateFunction(c,u,g);case xe.ANIMATIONLOOPMODE_RELATIVE:case xe.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return this.sizeInterpolateFunction(c,u,g).add((t.offsetValue||WV).scale(t.repeatCount))}break}case xe.ANIMATIONTYPE_COLOR3:{const b=d?this.color3InterpolateFunctionWithTangents(c,a.outTangent.scale(f),u,o.inTangent.scale(f),g):this.color3InterpolateFunction(c,u,g);switch(t.loopMode){case xe.ANIMATIONLOOPMODE_CYCLE:case xe.ANIMATIONLOOPMODE_CONSTANT:case xe.ANIMATIONLOOPMODE_YOYO:return b;case xe.ANIMATIONLOOPMODE_RELATIVE:case xe.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return b.add((t.offsetValue||XV).scale(t.repeatCount))}break}case xe.ANIMATIONTYPE_COLOR4:{const b=d?this.color4InterpolateFunctionWithTangents(c,a.outTangent.scale(f),u,o.inTangent.scale(f),g):this.color4InterpolateFunction(c,u,g);switch(t.loopMode){case xe.ANIMATIONLOOPMODE_CYCLE:case xe.ANIMATIONLOOPMODE_CONSTANT:case xe.ANIMATIONLOOPMODE_YOYO:return b;case xe.ANIMATIONLOOPMODE_RELATIVE:case xe.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return b.add((t.offsetValue||jV).scale(t.repeatCount))}break}case xe.ANIMATIONTYPE_MATRIX:{switch(t.loopMode){case xe.ANIMATIONLOOPMODE_CYCLE:case xe.ANIMATIONLOOPMODE_CONSTANT:case xe.ANIMATIONLOOPMODE_YOYO:return xe.AllowMatricesInterpolation?this.matrixInterpolateFunction(c,u,g,t.workValue):c;case xe.ANIMATIONLOOPMODE_RELATIVE:case xe.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT:return c}break}}return 0}matrixInterpolateFunction(e,t,i,s){return xe.AllowMatrixDecomposeForInterpolation?s?(W.DecomposeLerpToRef(e,t,i,s),s):W.DecomposeLerp(e,t,i):s?(W.LerpToRef(e,t,i,s),s):W.Lerp(e,t,i)}clone(){const e=new xe(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);if(e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed,this._keys&&e.setKeys(this._keys),this._ranges){e._ranges={};for(const t in this._ranges){const i=this._ranges[t];i&&(e._ranges[t]=i.clone())}}return e}setKeys(e,t=!1){this._keys=t?e:e.slice(0)}createKeyForFrame(e){Hr.key=0;const t=this._interpolate(e,Hr,!0);if(!t)return this._keys[Hr.key].frame===e?Hr.key:Hr.key+1;const i={frame:e,value:t.clone?t.clone():t};return this._keys.splice(Hr.key+1,0,i),Hr.key+1}serialize(){const e={};e.name=this.name,e.property=this.targetProperty,e.framePerSecond=this.framePerSecond,e.dataType=this.dataType,e.loopBehavior=this.loopMode,e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed;const t=this.dataType;e.keys=[];const i=this.getKeys();for(let s=0;s<i.length;s++){const r=i[s],a={};switch(a.frame=r.frame,t){case xe.ANIMATIONTYPE_FLOAT:a.values=[r.value],r.inTangent!==void 0&&a.values.push(r.inTangent),r.outTangent!==void 0&&(r.inTangent===void 0&&a.values.push(void 0),a.values.push(r.outTangent)),r.interpolation!==void 0&&(r.inTangent===void 0&&a.values.push(void 0),r.outTangent===void 0&&a.values.push(void 0),a.values.push(r.interpolation));break;case xe.ANIMATIONTYPE_QUATERNION:case xe.ANIMATIONTYPE_MATRIX:case xe.ANIMATIONTYPE_VECTOR3:case xe.ANIMATIONTYPE_COLOR3:case xe.ANIMATIONTYPE_COLOR4:a.values=r.value.asArray(),r.inTangent!=null&&a.values.push(r.inTangent.asArray()),r.outTangent!=null&&(r.inTangent===void 0&&a.values.push(void 0),a.values.push(r.outTangent.asArray())),r.interpolation!==void 0&&(r.inTangent===void 0&&a.values.push(void 0),r.outTangent===void 0&&a.values.push(void 0),a.values.push(r.interpolation));break}e.keys.push(a)}e.ranges=[];for(const s in this._ranges){const r=this._ranges[s];if(!r)continue;const a={};a.name=s,a.from=r.from,a.to=r.to,e.ranges.push(a)}return e}static _UniversalLerp(e,t,i){const s=e.constructor;return s.Lerp?s.Lerp(e,t,i):s.Slerp?s.Slerp(e,t,i):e.toFixed?e*(1-i)+i*t:t}static Parse(e){const t=new xe(e.name,e.property,e.framePerSecond,e.dataType,e.loopBehavior),i=e.dataType,s=[];let r,a;for(e.enableBlending&&(t.enableBlending=e.enableBlending),e.blendingSpeed&&(t.blendingSpeed=e.blendingSpeed),a=0;a<e.keys.length;a++){const o=e.keys[a];let c,u,d;switch(i){case xe.ANIMATIONTYPE_FLOAT:r=o.values[0],o.values.length>=2&&(c=o.values[1]),o.values.length>=3&&(u=o.values[2]),o.values.length>=4&&(d=o.values[3]);break;case xe.ANIMATIONTYPE_QUATERNION:if(r=Se.FromArray(o.values),o.values.length>=8){const g=Se.FromArray(o.values.slice(4,8));g.equals(Se.Zero())||(c=g)}if(o.values.length>=12){const g=Se.FromArray(o.values.slice(8,12));g.equals(Se.Zero())||(u=g)}o.values.length>=13&&(d=o.values[12]);break;case xe.ANIMATIONTYPE_MATRIX:r=W.FromArray(o.values),o.values.length>=17&&(d=o.values[16]);break;case xe.ANIMATIONTYPE_COLOR3:r=Ne.FromArray(o.values),o.values[3]&&(c=Ne.FromArray(o.values[3])),o.values[4]&&(u=Ne.FromArray(o.values[4])),o.values[5]&&(d=o.values[5]);break;case xe.ANIMATIONTYPE_COLOR4:r=Ze.FromArray(o.values),o.values[4]&&(c=Ze.FromArray(o.values[4])),o.values[5]&&(u=Ze.FromArray(o.values[5])),o.values[6]&&(d=Ze.FromArray(o.values[6]));break;case xe.ANIMATIONTYPE_VECTOR3:default:r=T.FromArray(o.values),o.values[3]&&(c=T.FromArray(o.values[3])),o.values[4]&&(u=T.FromArray(o.values[4])),o.values[5]&&(d=o.values[5]);break}const f={};f.frame=o.frame,f.value=r,c!=null&&(f.inTangent=c),u!=null&&(f.outTangent=u),d!=null&&(f.interpolation=d),s.push(f)}if(t.setKeys(s),e.ranges)for(a=0;a<e.ranges.length;a++)r=e.ranges[a],t.createRange(r.name,r.from,r.to);return t}static AppendSerializedAnimations(e,t){$e.AppendSerializedAnimations(e,t)}static async ParseFromFileAsync(e,t){return await new Promise((i,s)=>{const r=new Ai;r.addEventListener("readystatechange",()=>{if(r.readyState==4)if(r.status==200){let a=JSON.parse(r.responseText);if(a.animations&&(a=a.animations),a.length){const o=[];for(const c of a)o.push(this.Parse(c));i(o)}else{const o=this.Parse(a);e&&(o.name=e),i(o)}}else s("Unable to load the animation")}),r.open("GET",t),r.send()})}static async ParseFromSnippetAsync(e){return await new Promise((t,i)=>{const s=new Ai;s.addEventListener("readystatechange",()=>{if(s.readyState==4)if(s.status==200){const r=JSON.parse(JSON.parse(s.responseText).jsonPayload);if(r.animations){const a=JSON.parse(r.animations),o=[];for(const c of a.animations){const u=this.Parse(c);u.snippetId=e,o.push(u)}t(o)}else{const a=JSON.parse(r.animation),o=this.Parse(a);o.snippetId=e,t(o)}}else i("Unable to load the snippet "+e)}),s.open("GET",this.SnippetUrl+"/"+e.replace(/#/g,"/")),s.send()})}}xe._UniqueIdGenerator=0;xe.AllowMatricesInterpolation=!1;xe.AllowMatrixDecomposeForInterpolation=!0;xe.SnippetUrl="https://snippet.babylonjs.com";xe.ANIMATIONTYPE_FLOAT=0;xe.ANIMATIONTYPE_VECTOR3=1;xe.ANIMATIONTYPE_QUATERNION=2;xe.ANIMATIONTYPE_MATRIX=3;xe.ANIMATIONTYPE_COLOR3=4;xe.ANIMATIONTYPE_COLOR4=7;xe.ANIMATIONTYPE_VECTOR2=5;xe.ANIMATIONTYPE_SIZE=6;xe.ANIMATIONLOOPMODE_RELATIVE=0;xe.ANIMATIONLOOPMODE_CYCLE=1;xe.ANIMATIONLOOPMODE_CONSTANT=2;xe.ANIMATIONLOOPMODE_YOYO=4;xe.ANIMATIONLOOPMODE_RELATIVE_FROM_CURRENT=5;xe.CreateFromSnippetAsync=xe.ParseFromSnippetAsync;Tt("BABYLON.Animation",xe);yi._AnimationRangeFactory=(n,e,t)=>new Wf(n,e,t);class No{constructor(){this.transitionDuration=450,this.lowerRadiusTransitionRange=2,this.upperRadiusTransitionRange=-2,this._autoTransitionRange=!1,this._radiusIsAnimating=!1,this._radiusBounceTransition=null,this._animatables=new Array}get name(){return"Bouncing"}get autoTransitionRange(){return this._autoTransitionRange}set autoTransitionRange(e){if(this._autoTransitionRange===e)return;this._autoTransitionRange=e;const t=this._attachedCamera;t&&(e?this._onMeshTargetChangedObserver=t.onMeshTargetChangedObservable.add(i=>{if(i&&(i.computeWorldMatrix(!0),i.getBoundingInfo)){const s=i.getBoundingInfo().diagonalLength;this.lowerRadiusTransitionRange=s*.05,this.upperRadiusTransitionRange=s*.05}}):this._onMeshTargetChangedObserver&&t.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))}init(){}attach(e){this._attachedCamera=e,this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add(()=>{this._attachedCamera&&(this._isRadiusAtLimit(this._attachedCamera.lowerRadiusLimit)&&this._applyBoundRadiusAnimation(this.lowerRadiusTransitionRange),this._isRadiusAtLimit(this._attachedCamera.upperRadiusLimit)&&this._applyBoundRadiusAnimation(this.upperRadiusTransitionRange))})}detach(){this._attachedCamera&&(this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null)}_isRadiusAtLimit(e){return this._attachedCamera?this._attachedCamera.radius===e&&!this._radiusIsAnimating:!1}_applyBoundRadiusAnimation(e){if(!this._attachedCamera)return;this._radiusBounceTransition||(No.EasingFunction.setEasingMode(No.EasingMode),this._radiusBounceTransition=xe.CreateAnimation("radius",xe.ANIMATIONTYPE_FLOAT,60,No.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;const t=xe.TransitionTo("radius",this._attachedCamera.radius+e,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusBounceTransition,this.transitionDuration,()=>this._clearAnimationLocks());t&&this._animatables.push(t)}_clearAnimationLocks(){this._radiusIsAnimating=!1,this._attachedCamera&&(this._attachedCamera.wheelPrecision=this._cachedWheelPrecision)}stopAllAnimations(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0].onAnimationEnd=null,this._animatables[0].stop(),this._animatables.shift()}}No.EasingFunction=new BV(.3);No.EasingMode=Rs.EASINGMODE_EASEOUT;class vs{constructor(){this.onTargetFramingAnimationEndObservable=new le,this._mode=vs.FitFrustumSidesMode,this._radiusScale=1,this._positionScale=.5,this._defaultElevation=.3,this._elevationReturnTime=1500,this._elevationReturnWaitTime=1e3,this._zoomStopsAnimation=!1,this._framingTime=1500,this.autoCorrectCameraLimitsAndSensibility=!0,this._isPointerDown=!1,this._lastInteractionTime=-1/0,this._animatables=new Array,this._betaIsAnimating=!1}get name(){return"Framing"}set mode(e){this._mode=e}get mode(){return this._mode}set radiusScale(e){this._radiusScale=e}get radiusScale(){return this._radiusScale}set positionScale(e){this._positionScale=e}get positionScale(){return this._positionScale}set defaultElevation(e){this._defaultElevation=e}get defaultElevation(){return this._defaultElevation}set elevationReturnTime(e){this._elevationReturnTime=e}get elevationReturnTime(){return this._elevationReturnTime}set elevationReturnWaitTime(e){this._elevationReturnWaitTime=e}get elevationReturnWaitTime(){return this._elevationReturnWaitTime}set zoomStopsAnimation(e){this._zoomStopsAnimation=e}get zoomStopsAnimation(){return this._zoomStopsAnimation}set framingTime(e){this._framingTime=e}get framingTime(){return this._framingTime}init(){}attach(e){this._attachedCamera=e;const t=this._attachedCamera.getScene();vs.EasingFunction.setEasingMode(vs.EasingMode),this._onPrePointerObservableObserver=t.onPrePointerObservable.add(i=>{if(i.type===Ve.POINTERDOWN){this._isPointerDown=!0;return}i.type===Ve.POINTERUP&&(this._isPointerDown=!1)}),this._onMeshTargetChangedObserver=e.onMeshTargetChangedObservable.add(i=>{i&&i.getBoundingInfo&&this.zoomOnMesh(i,void 0,()=>{this.onTargetFramingAnimationEndObservable.notifyObservers()})}),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add(()=>{this._applyUserInteraction(),this._maintainCameraAboveGround()})}detach(){if(!this._attachedCamera)return;const e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null}zoomOnMesh(e,t=!1,i=null){e.computeWorldMatrix(!0);const s=e.getBoundingInfo().boundingBox;this.zoomOnBoundingInfo(s.minimumWorld,s.maximumWorld,t,i)}zoomOnMeshHierarchy(e,t=!1,i=null){e.computeWorldMatrix(!0);const s=e.getHierarchyBoundingVectors(!0);this.zoomOnBoundingInfo(s.min,s.max,t,i)}zoomOnMeshesHierarchy(e,t=!1,i=null){const s=new T(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),r=new T(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(let a=0;a<e.length;a++){const o=e[a].getHierarchyBoundingVectors(!0);T.CheckExtends(o.min,s,r),T.CheckExtends(o.max,s,r)}this.zoomOnBoundingInfo(s,r,t,i)}zoomOnBoundingInfo(e,t,i=!1,s=null){let r;if(!this._attachedCamera)return!1;const a=e.y,o=t.y,c=a+(o-a)*this._positionScale,u=t.subtract(e).scale(.5);if(!isFinite(c))return!1;if(i)r=new T(0,c,0);else{const g=e.add(u);r=new T(g.x,c,g.z)}this._vectorTransition||(this._vectorTransition=xe.CreateAnimation("target",xe.ANIMATIONTYPE_VECTOR3,60,vs.EasingFunction)),this._betaIsAnimating=!0;let d=xe.TransitionTo("target",r,this._attachedCamera,this._attachedCamera.getScene(),60,this._vectorTransition,this._framingTime);d&&this._animatables.push(d);let f=0;if(this._mode===vs.FitFrustumSidesMode){const g=this._calculateLowerRadiusFromModelBoundingSphere(e,t);this.autoCorrectCameraLimitsAndSensibility&&(this._attachedCamera.lowerRadiusLimit=u.length()+this._attachedCamera.minZ),f=g}else this._mode===vs.IgnoreBoundsSizeMode&&(f=this._calculateLowerRadiusFromModelBoundingSphere(e,t),this.autoCorrectCameraLimitsAndSensibility&&this._attachedCamera.lowerRadiusLimit===null&&(this._attachedCamera.lowerRadiusLimit=this._attachedCamera.minZ));if(this.autoCorrectCameraLimitsAndSensibility){const g=t.subtract(e).length();this._attachedCamera.panningSensibility=5e3/g,this._attachedCamera.wheelPrecision=100/f}return this._radiusTransition||(this._radiusTransition=xe.CreateAnimation("radius",xe.ANIMATIONTYPE_FLOAT,60,vs.EasingFunction)),d=xe.TransitionTo("radius",f,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusTransition,this._framingTime,()=>{this.stopAllAnimations(),s&&s(),this._attachedCamera&&this._attachedCamera.useInputToRestoreState&&this._attachedCamera.storeState()}),d&&this._animatables.push(d),!0}_calculateLowerRadiusFromModelBoundingSphere(e,t){const i=this._attachedCamera;if(!i)return 0;let s=i._calculateLowerRadiusFromModelBoundingSphere(e,t,this._radiusScale);return i.lowerRadiusLimit&&this._mode===vs.IgnoreBoundsSizeMode&&(s=s<i.lowerRadiusLimit?i.lowerRadiusLimit:s),i.upperRadiusLimit&&(s=s>i.upperRadiusLimit?i.upperRadiusLimit:s),s}_maintainCameraAboveGround(){if(this._elevationReturnTime<0)return;const e=nr.Now-this._lastInteractionTime,t=Math.PI*.5-this._defaultElevation,i=Math.PI*.5;if(this._attachedCamera&&!this._betaIsAnimating&&this._attachedCamera.beta>i&&e>=this._elevationReturnWaitTime){this._betaIsAnimating=!0,this.stopAllAnimations(),this._betaTransition||(this._betaTransition=xe.CreateAnimation("beta",xe.ANIMATIONTYPE_FLOAT,60,vs.EasingFunction));const s=xe.TransitionTo("beta",t,this._attachedCamera,this._attachedCamera.getScene(),60,this._betaTransition,this._elevationReturnTime,()=>{this._clearAnimationLocks(),this.stopAllAnimations()});s&&this._animatables.push(s)}}_clearAnimationLocks(){this._betaIsAnimating=!1}_applyUserInteraction(){this.isUserIsMoving&&(this._lastInteractionTime=nr.Now,this.stopAllAnimations(),this._clearAnimationLocks())}stopAllAnimations(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0]&&(this._animatables[0].onAnimationEnd=null,this._animatables[0].stop()),this._animatables.shift()}get isUserIsMoving(){return this._attachedCamera?this._attachedCamera.inertialAlphaOffset!==0||this._attachedCamera.inertialBetaOffset!==0||this._attachedCamera.inertialRadiusOffset!==0||this._attachedCamera.inertialPanningX!==0||this._attachedCamera.inertialPanningY!==0||this._isPointerDown:!1}}vs.EasingFunction=new UV;vs.EasingMode=Rs.EASINGMODE_EASEINOUT;vs.IgnoreBoundsSizeMode=0;vs.FitFrustumSidesMode=1;yi.AddNodeConstructor("TargetCamera",(n,e)=>()=>new mi(n,T.Zero(),e));const Dd=W.Zero(),Hg=Se.Identity();class mi extends Ge{constructor(e,t,i,s=!0){super(e,t,i,s),this.cameraDirection=new T(0,0,0),this.cameraRotation=new Ie(0,0),this.updateUpVectorFromRotation=!1,this.speed=2,this.noRotationConstraint=!1,this.invertRotation=!1,this.inverseRotationSpeed=.2,this._panningEpsilon=bt,this._rotationEpsilon=bt,this.lockedTarget=null,this._currentTarget=T.Zero(),this._initialFocalDistance=1,this._viewMatrix=W.Zero(),this._cameraTransformMatrix=W.Zero(),this._cameraRotationMatrix=W.Zero(),this._transformedReferencePoint=T.Zero(),this._deferredPositionUpdate=new T,this._deferredRotationQuaternionUpdate=new Se,this._deferredRotationUpdate=new T,this._deferredUpdated=!1,this._deferOnly=!1,this._cachedRotationZ=0,this._cachedQuaternionRotationZ=0,this._referencePoint=T.Forward(this.getScene().useRightHandedSystem),this.rotation=new T(0,this.getScene().useRightHandedSystem?Math.PI:0,0)}getFrontPosition(e){this.getWorldMatrix();const t=te.Vector3[0],i=te.Vector3[1];return i.set(0,0,this._scene.useRightHandedSystem?-1:1),this.getDirectionToRef(i,t),t.scaleInPlace(e),this.globalPosition.add(t)}_getLockedTargetPosition(){if(!this.lockedTarget)return null;if(this.lockedTarget.absolutePosition){const e=this.lockedTarget;e.computeWorldMatrix().getTranslationToRef(e.absolutePosition)}return this.lockedTarget.absolutePosition||this.lockedTarget}storeState(){return this._storedPosition=this.position.clone(),this._storedRotation=this.rotation.clone(),this.rotationQuaternion&&(this._storedRotationQuaternion=this.rotationQuaternion.clone()),super.storeState()}_restoreStateValues(){return super._restoreStateValues()?(this.position=this._storedPosition.clone(),this.rotation=this._storedRotation.clone(),this.rotationQuaternion&&this._storedRotationQuaternion&&(this.rotationQuaternion=this._storedRotationQuaternion.clone()),this.cameraDirection.copyFromFloats(0,0,0),this.cameraRotation.copyFromFloats(0,0),!0):!1}_initCache(){super._initCache(),this._cache.lockedTarget=new T(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new T(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotationQuaternion=new Se(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)}_updateCache(e){e||super._updateCache();const t=this._getLockedTargetPosition();t?this._cache.lockedTarget?this._cache.lockedTarget.copyFrom(t):this._cache.lockedTarget=t.clone():this._cache.lockedTarget=null,this._cache.rotation.copyFrom(this.rotation),this.rotationQuaternion&&this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)}_isSynchronizedViewMatrix(){if(!super._isSynchronizedViewMatrix())return!1;const e=this._getLockedTargetPosition();return(this._cache.lockedTarget?this._cache.lockedTarget.equals(e):!e)&&(this.rotationQuaternion?this.rotationQuaternion.equals(this._cache.rotationQuaternion):this._cache.rotation.equals(this.rotation))}_computeLocalCameraSpeed(){const e=this.getEngine();return this.speed*Math.sqrt(e.getDeltaTime()/(e.getFps()*100))}setTarget(e){this.upVector.normalize(),this._initialFocalDistance=e.subtract(this.position).length(),this.position.z===e.z&&(this.position.z+=bt),this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance),this.getScene().useRightHandedSystem?W.LookAtRHToRef(this.position,e,T.UpReadOnly,Dd):W.LookAtLHToRef(this.position,e,T.UpReadOnly,Dd),Dd.invert();const t=this.rotationQuaternion||Hg;Se.FromRotationMatrixToRef(Dd,t),t.toEulerAnglesToRef(this.rotation),this.rotation.z=0}get target(){return this.getTarget()}set target(e){this.setTarget(e)}getTarget(){return this._currentTarget}_decideIfNeedsToMove(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0}_updatePosition(){if(this.parent){this.parent.getWorldMatrix().invertToRef(te.Matrix[0]),T.TransformNormalToRef(this.cameraDirection,te.Matrix[0],te.Vector3[0]),this._deferredPositionUpdate.addInPlace(te.Vector3[0]),this._deferOnly?this._deferredUpdated=!0:this.position.copyFrom(this._deferredPositionUpdate);return}this._deferredPositionUpdate.addInPlace(this.cameraDirection),this._deferOnly?this._deferredUpdated=!0:this.position.copyFrom(this._deferredPositionUpdate)}_checkInputs(){const e=this.invertRotation?-this.inverseRotationSpeed:1,t=this._decideIfNeedsToMove(),i=this.cameraRotation.x||this.cameraRotation.y;this._deferredUpdated=!1,this._deferredRotationUpdate.copyFrom(this.rotation),this._deferredPositionUpdate.copyFrom(this.position),this.rotationQuaternion&&this._deferredRotationQuaternionUpdate.copyFrom(this.rotationQuaternion),t&&this._updatePosition(),i&&(this.rotationQuaternion&&this.rotationQuaternion.toEulerAnglesToRef(this._deferredRotationUpdate),this._deferredRotationUpdate.x+=this.cameraRotation.x*e,this._deferredRotationUpdate.y+=this.cameraRotation.y*e,this.noRotationConstraint||(this._deferredRotationUpdate.x>1.570796&&(this._deferredRotationUpdate.x=1.570796),this._deferredRotationUpdate.x<-1.570796&&(this._deferredRotationUpdate.x=-1.570796)),this._deferOnly?this._deferredUpdated=!0:this.rotation.copyFrom(this._deferredRotationUpdate),this.rotationQuaternion&&this._deferredRotationUpdate.lengthSquared()&&(Se.RotationYawPitchRollToRef(this._deferredRotationUpdate.y,this._deferredRotationUpdate.x,this._deferredRotationUpdate.z,this._deferredRotationQuaternionUpdate),this._deferOnly?this._deferredUpdated=!0:this.rotationQuaternion.copyFrom(this._deferredRotationQuaternionUpdate)));const s=this.speed*this._panningEpsilon,r=this.speed*this._rotationEpsilon;t&&(Math.abs(this.cameraDirection.x)<s&&(this.cameraDirection.x=0),Math.abs(this.cameraDirection.y)<s&&(this.cameraDirection.y=0),Math.abs(this.cameraDirection.z)<s&&(this.cameraDirection.z=0),this.cameraDirection.scaleInPlace(this.inertia)),i&&(Math.abs(this.cameraRotation.x)<r&&(this.cameraRotation.x=0),Math.abs(this.cameraRotation.y)<r&&(this.cameraRotation.y=0),this.cameraRotation.scaleInPlace(this.inertia)),super._checkInputs()}_updateCameraRotationMatrix(){this.rotationQuaternion?this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix):W.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._cameraRotationMatrix)}_rotateUpVectorWithCameraRotationMatrix(){return T.TransformNormalToRef(T.UpReadOnly,this._cameraRotationMatrix,this.upVector),this}_getViewMatrix(){return this.lockedTarget&&this.setTarget(this._getLockedTargetPosition()),this._updateCameraRotationMatrix(),this.rotationQuaternion&&this._cachedQuaternionRotationZ!=this.rotationQuaternion.z?(this._rotateUpVectorWithCameraRotationMatrix(),this._cachedQuaternionRotationZ=this.rotationQuaternion.z):this._cachedRotationZ!==this.rotation.z&&(this._rotateUpVectorWithCameraRotationMatrix(),this._cachedRotationZ=this.rotation.z),T.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget),this.updateUpVectorFromRotation&&(this.rotationQuaternion?wr.Y.rotateByQuaternionToRef(this.rotationQuaternion,this.upVector):(Se.FromEulerVectorToRef(this.rotation,Hg),wr.Y.rotateByQuaternionToRef(Hg,this.upVector))),this._computeViewMatrix(this.position,this._currentTarget,this.upVector),this._viewMatrix}_computeViewMatrix(e,t,i){if(this.getScene().useRightHandedSystem?W.LookAtRHToRef(e,t,i,this._viewMatrix):W.LookAtLHToRef(e,t,i,this._viewMatrix),this.parent){const s=this.parent.getWorldMatrix();this._viewMatrix.invert(),this._viewMatrix.multiplyToRef(s,this._viewMatrix),this._viewMatrix.invert(),this._markSyncedWithParent()}}createRigCamera(e,t){if(this.cameraRigMode!==Ge.RIG_MODE_NONE){const i=new mi(e,this.position.clone(),this.getScene());return i.isRigCamera=!0,i.rigParent=this,this.cameraRigMode===Ge.RIG_MODE_VR&&(this.rotationQuaternion||(this.rotationQuaternion=new Se),i._cameraRigParams={},i.rotationQuaternion=new Se),i.mode=this.mode,i.orthoLeft=this.orthoLeft,i.orthoRight=this.orthoRight,i.orthoTop=this.orthoTop,i.orthoBottom=this.orthoBottom,i}return null}_updateRigCameras(){const e=this._rigCameras[0],t=this._rigCameras[1];switch(this.computeWorldMatrix(),this.cameraRigMode){case Ge.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Ge.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Ge.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case Ge.RIG_MODE_STEREOSCOPIC_OVERUNDER:case Ge.RIG_MODE_STEREOSCOPIC_INTERLACED:{const i=this.cameraRigMode===Ge.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?1:-1,s=this.cameraRigMode===Ge.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?-1:1;this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*i,e),this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*s,t);break}case Ge.RIG_MODE_VR:e.rotationQuaternion&&t.rotationQuaternion&&this.rotationQuaternion?(e.rotationQuaternion.copyFrom(this.rotationQuaternion),t.rotationQuaternion.copyFrom(this.rotationQuaternion)):(e.rotation.copyFrom(this.rotation),t.rotation.copyFrom(this.rotation)),e.position.copyFrom(this.position),t.position.copyFrom(this.position);break}super._updateRigCameras()}_getRigCamPositionAndTarget(e,t){this.getTarget().subtractToRef(this.position,mi._TargetFocalPoint),mi._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);const s=mi._TargetFocalPoint.addInPlace(this.position);W.TranslationToRef(-s.x,-s.y,-s.z,mi._TargetTransformMatrix),mi._TargetTransformMatrix.multiplyToRef(W.RotationAxis(t.upVector,e),mi._RigCamTransformMatrix),W.TranslationToRef(s.x,s.y,s.z,mi._TargetTransformMatrix),mi._RigCamTransformMatrix.multiplyToRef(mi._TargetTransformMatrix,mi._RigCamTransformMatrix),T.TransformCoordinatesToRef(this.position,mi._RigCamTransformMatrix,t.position),t.setTarget(s)}getClassName(){return"TargetCamera"}}mi._RigCamTransformMatrix=new W;mi._TargetTransformMatrix=new W;mi._TargetFocalPoint=new T;N([H()],mi.prototype,"updateUpVectorFromRotation",void 0);N([lr()],mi.prototype,"rotation",void 0);N([H()],mi.prototype,"speed",void 0);N([bC("lockedTargetId")],mi.prototype,"lockedTarget",void 0);var qr={};class DI{constructor(e){this.attachedToElement=!1,this.attached={},this.camera=e,this.checkInputs=()=>{}}add(e){const t=e.getSimpleName();if(this.attached[t]){oe.Warn("camera input of type "+t+" already exists on camera");return}this.attached[t]=e,e.camera=this.camera,e.checkInputs&&(this.checkInputs=this._addCheckInputs(e.checkInputs.bind(e))),this.attachedToElement&&e.attachControl(this.noPreventDefault)}remove(e){for(const t in this.attached){const i=this.attached[t];if(i===e){i.detachControl(),i.camera=null,delete this.attached[t],this.rebuildInputCheck();return}}}removeByType(e){for(const t in this.attached){const i=this.attached[t];i.getClassName()===e&&(i.detachControl(),i.camera=null,delete this.attached[t],this.rebuildInputCheck())}}_addCheckInputs(e){const t=this.checkInputs;return()=>{t(),e()}}attachInput(e){this.attachedToElement&&e.attachControl(this.noPreventDefault)}attachElement(e=!1){if(!this.attachedToElement){e=Ge.ForceAttachControlToAlwaysPreventDefault?!1:e,this.attachedToElement=!0,this.noPreventDefault=e;for(const t in this.attached)this.attached[t].attachControl(e)}}detachElement(e=!1){for(const t in this.attached)this.attached[t].detachControl(),e&&(this.attached[t].camera=null);this.attachedToElement=!1}rebuildInputCheck(){this.checkInputs=()=>{};for(const e in this.attached){const t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}}clear(){this.attachedToElement&&this.detachElement(!0),this.attached={},this.attachedToElement=!1,this.checkInputs=()=>{}}serialize(e){const t={};for(const i in this.attached){const s=this.attached[i],r=$e.Serialize(s);t[s.getClassName()]=r}e.inputsmgr=t}parse(e){const t=e.inputsmgr;if(t){this.clear();for(const i in t){const s=qr[i];if(s){const r=t[i],a=$e.Parse(()=>new s,r,null);this.add(a)}}}else for(const i in this.attached){const s=qr[this.attached[i].getClassName()];if(s){const r=$e.Parse(()=>new s,e,null);this.remove(this.attached[i]),this.add(r)}}}}class OI{constructor(){this._currentMousePointerIdDown=-1,this.buttons=[0,1,2]}attachControl(e){e=pe.BackCompatCameraNoPreventDefault(arguments);const t=this.camera.getEngine(),i=t.getInputElement();let s=0,r=null;this._pointA=null,this._pointB=null,this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0,this._pointerInput=o=>{const c=o.event,u=c.pointerType==="touch";if(o.type!==Ve.POINTERMOVE&&this.buttons.indexOf(c.button)===-1)return;const d=c.target;if(this._altKey=c.altKey,this._ctrlKey=c.ctrlKey,this._metaKey=c.metaKey,this._shiftKey=c.shiftKey,this._buttonsPressed=c.buttons,t.isPointerLock){const f=c.movementX,g=c.movementY;this.onTouch(null,f,g),this._pointA=null,this._pointB=null}else{if(o.type!==Ve.POINTERDOWN&&o.type!==Ve.POINTERDOUBLETAP&&u&&this._pointA?.pointerId!==c.pointerId&&this._pointB?.pointerId!==c.pointerId)return;if(o.type===Ve.POINTERDOWN&&(this._currentMousePointerIdDown===-1||u)){try{d?.setPointerCapture(c.pointerId)}catch{}if(this._pointA===null)this._pointA={x:c.clientX,y:c.clientY,pointerId:c.pointerId,type:c.pointerType,button:c.button};else if(this._pointB===null)this._pointB={x:c.clientX,y:c.clientY,pointerId:c.pointerId,type:c.pointerType,button:c.button};else return;this._currentMousePointerIdDown===-1&&!u&&(this._currentMousePointerIdDown=c.pointerId),this.onButtonDown(c),e||(c.preventDefault(),i&&i.focus())}else if(o.type===Ve.POINTERDOUBLETAP)this.onDoubleTap(c.pointerType);else if(o.type===Ve.POINTERUP&&(this._currentMousePointerIdDown===c.pointerId||u)){try{d?.releasePointerCapture(c.pointerId)}catch{}u||(this._pointB=null),t._badOS?this._pointA=this._pointB=null:this._pointB&&this._pointA&&this._pointA.pointerId==c.pointerId?(this._pointA=this._pointB,this._pointB=null):this._pointA&&this._pointB&&this._pointB.pointerId==c.pointerId?this._pointB=null:this._pointA=this._pointB=null,(s!==0||r)&&(this.onMultiTouch(this._pointA,this._pointB,s,0,r,null),s=0,r=null),this._currentMousePointerIdDown=-1,this.onButtonUp(c),e||c.preventDefault()}else if(o.type===Ve.POINTERMOVE){if(e||c.preventDefault(),this._pointA&&this._pointB===null){const f=c.clientX-this._pointA.x,g=c.clientY-this._pointA.y;this._pointA.x=c.clientX,this._pointA.y=c.clientY,this.onTouch(this._pointA,f,g)}else if(this._pointA&&this._pointB){const f=this._pointA.pointerId===c.pointerId?this._pointA:this._pointB;f.x=c.clientX,f.y=c.clientY;const g=this._pointA.x-this._pointB.x,m=this._pointA.y-this._pointB.y,b=g*g+m*m,x={x:(this._pointA.x+this._pointB.x)/2,y:(this._pointA.y+this._pointB.y)/2,pointerId:c.pointerId,type:o.type};this.onMultiTouch(this._pointA,this._pointB,s,b,r,x),r=x,s=b}}}},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,Ve.POINTERDOWN|Ve.POINTERUP|Ve.POINTERMOVE|Ve.POINTERDOUBLETAP),this._onLostFocus=()=>{this._pointA=this._pointB=null,s=0,r=null,this.onLostFocus()},this._contextMenuBind=o=>this.onContextMenu(o),i&&i.addEventListener("contextmenu",this._contextMenuBind,!1);const a=this.camera.getScene().getEngine().getHostWindow();a&&pe.RegisterTopRootEvents(a,[{name:"blur",handler:this._onLostFocus}])}detachControl(){if(this._onLostFocus){const e=this.camera.getScene().getEngine().getHostWindow();e&&pe.UnregisterTopRootEvents(e,[{name:"blur",handler:this._onLostFocus}])}if(this._observer){if(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._contextMenuBind){const e=this.camera.getScene().getEngine().getInputElement();e&&e.removeEventListener("contextmenu",this._contextMenuBind)}this._onLostFocus=null}this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0,this._currentMousePointerIdDown=-1}getClassName(){return"BaseCameraPointersInput"}getSimpleName(){return"pointers"}onDoubleTap(e){}onTouch(e,t,i){}onMultiTouch(e,t,i,s,r,a){}onContextMenu(e){e.preventDefault()}onButtonDown(e){}onButtonUp(e){}onLostFocus(){}}N([H()],OI.prototype,"buttons",void 0);class Xf extends OI{constructor(){super(...arguments),this.pinchZoom=!0,this.multiTouchPanning=!0,this.multiTouchPanAndZoom=!0,this._isPinching=!1,this._twoFingerActivityCount=0,this._shouldStartPinchZoom=!1}_computePinchZoom(e,t){}_computeMultiTouchPanning(e,t){}onMultiTouch(e,t,i,s,r,a){i===0&&r===null||s===0&&a===null||(this.multiTouchPanAndZoom?(this._computePinchZoom(i,s),this._computeMultiTouchPanning(r,a)):this.multiTouchPanning&&this.pinchZoom?(this._twoFingerActivityCount++,this._isPinching||this._shouldStartPinchZoom?(this._computePinchZoom(i,s),this._isPinching=!0):this._computeMultiTouchPanning(r,a)):this.multiTouchPanning?this._computeMultiTouchPanning(r,a):this.pinchZoom&&this._computePinchZoom(i,s))}onButtonUp(e){this._twoFingerActivityCount=0,this._isPinching=!1}onLostFocus(){this._twoFingerActivityCount=0,this._isPinching=!1}}N([H()],Xf.prototype,"pinchZoom",void 0);N([H()],Xf.prototype,"multiTouchPanning",void 0);N([H()],Xf.prototype,"multiTouchPanAndZoom",void 0);class Nr extends Xf{constructor(){super(...arguments),this.buttons=[0,1,2],this.angularSensibilityX=1e3,this.angularSensibilityY=1e3,this.pinchPrecision=12,this.pinchDeltaPercentage=0,this.useNaturalPinchZoom=!1,this.panningSensibility=1e3,this.pinchInwards=!0,this._isPanClick=!1}getClassName(){return"ArcRotateCameraPointersInput"}_computeMultiTouchPanning(e,t){if(this.panningSensibility!==0&&e&&t){const i=t.x-e.x,s=t.y-e.y;this.camera.inertialPanningX+=-i/this.panningSensibility,this.camera.inertialPanningY+=s/this.panningSensibility}}_computePinchZoom(e,t){const i=this.camera.radius||Nr.MinimumRadiusForPinch;this.useNaturalPinchZoom?this.camera.radius=i*Math.sqrt(e)/Math.sqrt(t):this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=(t-e)*.001*i*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(t-e)/(this.pinchPrecision*(this.pinchInwards?1:-1)*(this.angularSensibilityX+this.angularSensibilityY)/2)}onTouch(e,t,i){this.panningSensibility!==0&&(this._ctrlKey&&this.camera._useCtrlForPanning||this._isPanClick)?(this.camera.inertialPanningX+=-t/this.panningSensibility,this.camera.inertialPanningY+=i/this.panningSensibility):(this.camera.inertialAlphaOffset-=t/this.angularSensibilityX,this.camera.inertialBetaOffset-=i/this.angularSensibilityY)}onDoubleTap(){this.camera.useInputToRestoreState&&this.camera.restoreState()}onMultiTouch(e,t,i,s,r,a){this._shouldStartPinchZoom=this._twoFingerActivityCount<20&&Math.abs(Math.sqrt(s)-Math.sqrt(i))>this.camera.pinchToPanMaxDistance,super.onMultiTouch(e,t,i,s,r,a)}onButtonDown(e){this._isPanClick=e.button===this.camera._panningMouseButton,super.onButtonDown(e)}onButtonUp(e){super.onButtonUp(e)}onLostFocus(){this._isPanClick=!1,super.onLostFocus()}}Nr.MinimumRadiusForPinch=.001;N([H()],Nr.prototype,"buttons",void 0);N([H()],Nr.prototype,"angularSensibilityX",void 0);N([H()],Nr.prototype,"angularSensibilityY",void 0);N([H()],Nr.prototype,"pinchPrecision",void 0);N([H()],Nr.prototype,"pinchDeltaPercentage",void 0);N([H()],Nr.prototype,"useNaturalPinchZoom",void 0);N([H()],Nr.prototype,"panningSensibility",void 0);qr.ArcRotateCameraPointersInput=Nr;class Jr{constructor(){this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39],this.keysReset=[220],this.panningSensibility=50,this.zoomingSensibility=25,this.useAltToZoom=!0,this.angularSpeed=.01,this._keys=new Array}attachControl(e){e=pe.BackCompatCameraNoPreventDefault(arguments),!this._onCanvasBlurObserver&&(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add(()=>{this._keys.length=0}),this._onKeyboardObserver=this._scene.onKeyboardObservable.add(t=>{const i=t.event;if(!i.metaKey){if(t.type===lc.KEYDOWN)this._ctrlPressed=i.ctrlKey,this._altPressed=i.altKey,(this.keysUp.indexOf(i.keyCode)!==-1||this.keysDown.indexOf(i.keyCode)!==-1||this.keysLeft.indexOf(i.keyCode)!==-1||this.keysRight.indexOf(i.keyCode)!==-1||this.keysReset.indexOf(i.keyCode)!==-1)&&(this._keys.indexOf(i.keyCode)===-1&&this._keys.push(i.keyCode),i.preventDefault&&(e||i.preventDefault()));else if(this.keysUp.indexOf(i.keyCode)!==-1||this.keysDown.indexOf(i.keyCode)!==-1||this.keysLeft.indexOf(i.keyCode)!==-1||this.keysRight.indexOf(i.keyCode)!==-1||this.keysReset.indexOf(i.keyCode)!==-1){const s=this._keys.indexOf(i.keyCode);s>=0&&this._keys.splice(s,1),i.preventDefault&&(e||i.preventDefault())}}}))}detachControl(){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys.length=0}checkInputs(){if(this._onKeyboardObserver){const e=this.camera;for(let t=0;t<this._keys.length;t++){const i=this._keys[t];this.keysLeft.indexOf(i)!==-1?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningX-=1/this.panningSensibility:e.inertialAlphaOffset-=this.angularSpeed:this.keysUp.indexOf(i)!==-1?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningY+=1/this.panningSensibility:this._altPressed&&this.useAltToZoom?e.inertialRadiusOffset+=1/this.zoomingSensibility:e.inertialBetaOffset-=this.angularSpeed:this.keysRight.indexOf(i)!==-1?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningX+=1/this.panningSensibility:e.inertialAlphaOffset+=this.angularSpeed:this.keysDown.indexOf(i)!==-1?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningY-=1/this.panningSensibility:this._altPressed&&this.useAltToZoom?e.inertialRadiusOffset-=1/this.zoomingSensibility:e.inertialBetaOffset+=this.angularSpeed:this.keysReset.indexOf(i)!==-1&&e.useInputToRestoreState&&e.restoreState()}}}getClassName(){return"ArcRotateCameraKeyboardMoveInput"}getSimpleName(){return"keyboard"}}N([H()],Jr.prototype,"keysUp",void 0);N([H()],Jr.prototype,"keysDown",void 0);N([H()],Jr.prototype,"keysLeft",void 0);N([H()],Jr.prototype,"keysRight",void 0);N([H()],Jr.prototype,"keysReset",void 0);N([H()],Jr.prototype,"panningSensibility",void 0);N([H()],Jr.prototype,"zoomingSensibility",void 0);N([H()],Jr.prototype,"useAltToZoom",void 0);N([H()],Jr.prototype,"angularSpeed",void 0);qr.ArcRotateCameraKeyboardMoveInput=Jr;const YV=40;class iu{constructor(){this.wheelPrecision=3,this.zoomToMouseLocation=!1,this.wheelDeltaPercentage=0,this.customComputeDeltaFromMouseWheel=null,this._viewOffset=new T(0,0,0),this._globalOffset=new T(0,0,0),this._inertialPanning=T.Zero()}_computeDeltaFromMouseWheelLegacyEvent(e,t){let i=0;const s=e*.01*this.wheelDeltaPercentage*t;return e>0?i=s/(1+this.wheelDeltaPercentage):i=s*(1+this.wheelDeltaPercentage),i}attachControl(e){e=pe.BackCompatCameraNoPreventDefault(arguments),this._wheel=t=>{if(t.type!==Ve.POINTERWHEEL)return;const i=t.event;let s=0;const r=i.deltaMode===gc.DOM_DELTA_LINE?YV:1,a=-(i.deltaY*r);if(this.customComputeDeltaFromMouseWheel)s=this.customComputeDeltaFromMouseWheel(a,this,i);else if(this.wheelDeltaPercentage){if(s=this._computeDeltaFromMouseWheelLegacyEvent(a,this.camera.radius),s>0){let o=this.camera.radius,c=this.camera.inertialRadiusOffset+s;for(let u=0;u<20&&!(o<=c||Math.abs(c*this.camera.inertia)<.001);u++)o-=c,c*=this.camera.inertia;o=Qt(o,0,Number.MAX_VALUE),s=this._computeDeltaFromMouseWheelLegacyEvent(a,o)}}else s=a/(this.wheelPrecision*40);s&&(this.zoomToMouseLocation?(this._hitPlane||this._updateHitPlane(),this._zoomToMouse(s)):this.camera.inertialRadiusOffset+=s),i.preventDefault&&(e||i.preventDefault())},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel,Ve.POINTERWHEEL),this.zoomToMouseLocation&&this._inertialPanning.setAll(0)}detachControl(){this._observer&&(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._wheel=null)}checkInputs(){if(!this.zoomToMouseLocation)return;const e=this.camera;0+e.inertialAlphaOffset+e.inertialBetaOffset+e.inertialRadiusOffset&&(this._updateHitPlane(),e.target.addInPlace(this._inertialPanning),this._inertialPanning.scaleInPlace(e.inertia),this._zeroIfClose(this._inertialPanning))}getClassName(){return"ArcRotateCameraMouseWheelInput"}getSimpleName(){return"mousewheel"}_updateHitPlane(){const e=this.camera,t=e.target.subtract(e.position);this._hitPlane=Cr.FromPositionAndNormal(e.target,t)}_getPosition(){const e=this.camera,t=e.getScene(),i=t.createPickingRay(t.pointerX,t.pointerY,W.Identity(),e,!1);(e.targetScreenOffset.x!==0||e.targetScreenOffset.y!==0)&&(this._viewOffset.set(e.targetScreenOffset.x,e.targetScreenOffset.y,0),e.getViewMatrix().invertToRef(e._cameraTransformMatrix),this._globalOffset=T.TransformNormal(this._viewOffset,e._cameraTransformMatrix),i.origin.addInPlace(this._globalOffset));let s=0;return this._hitPlane&&(s=i.intersectsPlane(this._hitPlane)??0),i.origin.addInPlace(i.direction.scaleInPlace(s))}_zoomToMouse(e){const t=this.camera,i=1-t.inertia;if(t.lowerRadiusLimit){const c=t.lowerRadiusLimit??0;t.radius-(t.inertialRadiusOffset+e)/i<c&&(e=(t.radius-c)*i-t.inertialRadiusOffset)}if(t.upperRadiusLimit){const c=t.upperRadiusLimit??0;t.radius-(t.inertialRadiusOffset+e)/i>c&&(e=(t.radius-c)*i-t.inertialRadiusOffset)}const r=e/i/t.radius,a=this._getPosition(),o=te.Vector3[6];a.subtractToRef(t.target,o),o.scaleInPlace(r),o.scaleInPlace(i),this._inertialPanning.addInPlace(o),t.inertialRadiusOffset+=e}_zeroIfClose(e){Math.abs(e.x)<bt&&(e.x=0),Math.abs(e.y)<bt&&(e.y=0),Math.abs(e.z)<bt&&(e.z=0)}}N([H()],iu.prototype,"wheelPrecision",void 0);N([H()],iu.prototype,"zoomToMouseLocation",void 0);N([H()],iu.prototype,"wheelDeltaPercentage",void 0);qr.ArcRotateCameraMouseWheelInput=iu;class wI extends DI{constructor(e){super(e)}addMouseWheel(){return this.add(new iu),this}addPointers(){return this.add(new Nr),this}addKeyboard(){return this.add(new Jr),this}}yi.AddNodeConstructor("ArcRotateCamera",(n,e)=>()=>new kt(n,0,0,1,T.Zero(),e));function KV(n){let e=Math.PI/2;return n.x===0&&n.z===0||(e=Math.acos(n.x/Math.sqrt(Math.pow(n.x,2)+Math.pow(n.z,2)))),n.z<0&&(e=2*Math.PI-e),e}function qV(n,e){return Math.acos(n/e)}function ds(n,e){return isNaN(n)?e:n}class kt extends mi{get target(){return this._target}set target(e){this.setTarget(e)}get targetHost(){return this._targetHost}set targetHost(e){e&&this.setTarget(e)}getTarget(){return this.target}get position(){return this._position}set position(e){this.setPosition(e)}set upVector(e){this._upToYMatrix||(this._yToUpMatrix=new W,this._upToYMatrix=new W,this._upVector=T.Zero()),e.normalize(),this._upVector.copyFrom(e),this.setMatUp()}get upVector(){return this._upVector}setMatUp(){W.RotationAlignToRef(T.UpReadOnly,this._upVector,this._yToUpMatrix),W.RotationAlignToRef(this._upVector,T.UpReadOnly,this._upToYMatrix)}get angularSensibilityX(){const e=this.inputs.attached.pointers;return e?e.angularSensibilityX:0}set angularSensibilityX(e){const t=this.inputs.attached.pointers;t&&(t.angularSensibilityX=e)}get angularSensibilityY(){const e=this.inputs.attached.pointers;return e?e.angularSensibilityY:0}set angularSensibilityY(e){const t=this.inputs.attached.pointers;t&&(t.angularSensibilityY=e)}get pinchPrecision(){const e=this.inputs.attached.pointers;return e?e.pinchPrecision:0}set pinchPrecision(e){const t=this.inputs.attached.pointers;t&&(t.pinchPrecision=e)}get pinchDeltaPercentage(){const e=this.inputs.attached.pointers;return e?e.pinchDeltaPercentage:0}set pinchDeltaPercentage(e){const t=this.inputs.attached.pointers;t&&(t.pinchDeltaPercentage=e)}get useNaturalPinchZoom(){const e=this.inputs.attached.pointers;return e?e.useNaturalPinchZoom:!1}set useNaturalPinchZoom(e){const t=this.inputs.attached.pointers;t&&(t.useNaturalPinchZoom=e)}get panningSensibility(){const e=this.inputs.attached.pointers;return e?e.panningSensibility:0}set panningSensibility(e){const t=this.inputs.attached.pointers;t&&(t.panningSensibility=e)}get keysUp(){const e=this.inputs.attached.keyboard;return e?e.keysUp:[]}set keysUp(e){const t=this.inputs.attached.keyboard;t&&(t.keysUp=e)}get keysDown(){const e=this.inputs.attached.keyboard;return e?e.keysDown:[]}set keysDown(e){const t=this.inputs.attached.keyboard;t&&(t.keysDown=e)}get keysLeft(){const e=this.inputs.attached.keyboard;return e?e.keysLeft:[]}set keysLeft(e){const t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)}get keysRight(){const e=this.inputs.attached.keyboard;return e?e.keysRight:[]}set keysRight(e){const t=this.inputs.attached.keyboard;t&&(t.keysRight=e)}get wheelPrecision(){const e=this.inputs.attached.mousewheel;return e?e.wheelPrecision:0}set wheelPrecision(e){const t=this.inputs.attached.mousewheel;t&&(t.wheelPrecision=e)}get zoomToMouseLocation(){const e=this.inputs.attached.mousewheel;return e?e.zoomToMouseLocation:!1}set zoomToMouseLocation(e){const t=this.inputs.attached.mousewheel;t&&(t.zoomToMouseLocation=e)}get wheelDeltaPercentage(){const e=this.inputs.attached.mousewheel;return e?e.wheelDeltaPercentage:0}set wheelDeltaPercentage(e){const t=this.inputs.attached.mousewheel;t&&(t.wheelDeltaPercentage=e)}get isInterpolating(){return this._isInterpolating}get bouncingBehavior(){return this._bouncingBehavior}get useBouncingBehavior(){return this._bouncingBehavior!=null}set useBouncingBehavior(e){e!==this.useBouncingBehavior&&(e?(this._bouncingBehavior=new No,this.addBehavior(this._bouncingBehavior)):this._bouncingBehavior&&(this.removeBehavior(this._bouncingBehavior),this._bouncingBehavior=null))}get framingBehavior(){return this._framingBehavior}get useFramingBehavior(){return this._framingBehavior!=null}set useFramingBehavior(e){e!==this.useFramingBehavior&&(e?(this._framingBehavior=new vs,this.addBehavior(this._framingBehavior)):this._framingBehavior&&(this.removeBehavior(this._framingBehavior),this._framingBehavior=null))}get autoRotationBehavior(){return this._autoRotationBehavior}get useAutoRotationBehavior(){return this._autoRotationBehavior!=null}set useAutoRotationBehavior(e){e!==this.useAutoRotationBehavior&&(e?(this._autoRotationBehavior=new NV,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))}constructor(e,t,i,s,r,a,o=!0){super(e,T.Zero(),a,o),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.lowerAlphaLimit=null,this.upperAlphaLimit=null,this.lowerBetaLimit=.01,this.upperBetaLimit=Math.PI-.01,this.lowerRadiusLimit=null,this.upperRadiusLimit=null,this.lowerTargetYLimit=-1/0,this.inertialPanningX=0,this.inertialPanningY=0,this.pinchToPanMaxDistance=20,this.panningDistanceLimit=null,this.panningOriginTarget=T.Zero(),this.panningInertia=.9,this.zoomOnFactor=1,this.targetScreenOffset=Ie.Zero(),this.allowUpsideDown=!0,this.useInputToRestoreState=!0,this.restoreStateInterpolationFactor=0,this._currentInterpolationFactor=0,this._viewMatrix=new W,this.panningAxis=new T(1,1,0),this._transformedDirection=new T,this.mapPanning=!1,this._isInterpolating=!1,this.onMeshTargetChangedObservable=new le,this.checkCollisions=!1,this.collisionRadius=new T(.5,.5,.5),this._previousPosition=T.Zero(),this._collisionVelocity=T.Zero(),this._newPosition=T.Zero(),this._computationVector=T.Zero(),this._goalAlpha=NaN,this._goalBeta=NaN,this._goalRadius=NaN,this._goalTarget=new T(NaN,NaN,NaN),this._goalTargetScreenOffset=new Ie(NaN,NaN),this._onCollisionPositionChange=(c,u,d=null)=>{d?(this.setPosition(u),this.onCollide&&this.onCollide(d)):this._previousPosition.copyFrom(this._position);const f=Math.cos(this.alpha),g=Math.sin(this.alpha),m=Math.cos(this.beta);let b=Math.sin(this.beta);b===0&&(b=1e-4);const x=this._getTargetPosition();this._computationVector.copyFromFloats(this.radius*f*b,this.radius*m,this.radius*g*b),x.addToRef(this._computationVector,this._newPosition),this._position.copyFrom(this._newPosition);let v=this.upVector;this.allowUpsideDown&&this.beta<0&&(v=v.clone(),v=v.negate()),this._computeViewMatrix(this._position,x,v),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y),this._collisionTriggered=!1},this._target=T.Zero(),r&&this.setTarget(r),this.alpha=t,this.beta=i,this.radius=s,this.getViewMatrix(),this.inputs=new wI(this),this.inputs.addKeyboard().addMouseWheel().addPointers()}_initCache(){super._initCache(),this._cache._target=new T(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.alpha=void 0,this._cache.beta=void 0,this._cache.radius=void 0,this._cache.targetScreenOffset=Ie.Zero()}_updateCache(e){e||super._updateCache(),this._cache._target.copyFrom(this._getTargetPosition()),this._cache.alpha=this.alpha,this._cache.beta=this.beta,this._cache.radius=this.radius,this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset)}_getTargetPosition(){if(this._targetHost&&this._targetHost.getAbsolutePosition){const t=this._targetHost.getAbsolutePosition();this._targetBoundingCenter?t.addToRef(this._targetBoundingCenter,this._target):this._target.copyFrom(t)}const e=this._getLockedTargetPosition();return e||this._target}storeState(){return this._storedAlpha=this.alpha,this._storedBeta=this.beta,this._storedRadius=this.radius,this._storedTarget=this._getTargetPosition().clone(),this._storedTargetScreenOffset=this.targetScreenOffset.clone(),super.storeState()}_restoreStateValues(){return this.hasStateStored()&&this.restoreStateInterpolationFactor>bt&&this.restoreStateInterpolationFactor<1?(this.interpolateTo(this._storedAlpha,this._storedBeta,this._storedRadius,this._storedTarget,this._storedTargetScreenOffset,this.restoreStateInterpolationFactor),!0):super._restoreStateValues()?(this.setTarget(this._storedTarget.clone()),this.alpha=this._storedAlpha,this.beta=this._storedBeta,this.radius=this._storedRadius,this.targetScreenOffset=this._storedTargetScreenOffset.clone(),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,!0):!1}stopInterpolation(){this._goalAlpha=NaN,this._goalBeta=NaN,this._goalRadius=NaN,this._goalTarget.set(NaN,NaN,NaN),this._goalTargetScreenOffset.set(NaN,NaN)}interpolateTo(e=this.alpha,t=this.beta,i=this.radius,s=this.target,r=this.targetScreenOffset,a){this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,a!=null?this._currentInterpolationFactor=a:this.restoreStateInterpolationFactor!==0?this._currentInterpolationFactor=this.restoreStateInterpolationFactor:this._currentInterpolationFactor=.1,this._goalAlpha=ds(e,this._goalAlpha),this._goalBeta=ds(t,this._goalBeta),this._goalRadius=ds(i,this._goalRadius),this._goalTarget.set(ds(s.x,this._goalTarget.x),ds(s.y,this._goalTarget.y),ds(s.z,this._goalTarget.z)),this._goalTargetScreenOffset.set(ds(r.x,this._goalTargetScreenOffset.x),ds(r.y,this._goalTargetScreenOffset.y)),this._goalAlpha=Qt(this._goalAlpha,this.lowerAlphaLimit??-1/0,this.upperAlphaLimit??1/0),this._goalBeta=Qt(this._goalBeta,this.lowerBetaLimit??-1/0,this.upperBetaLimit??1/0),this._goalRadius=Qt(this._goalRadius,this.lowerRadiusLimit??-1/0,this.upperRadiusLimit??1/0),this._goalTarget.y=Qt(this._goalTarget.y,this.lowerTargetYLimit??-1/0,1/0),this._isInterpolating=!0}_isSynchronizedViewMatrix(){return super._isSynchronizedViewMatrix()?this._cache._target.equals(this._getTargetPosition())&&this._cache.alpha===this.alpha&&this._cache.beta===this.beta&&this._cache.radius===this.radius&&this._cache.targetScreenOffset.equals(this.targetScreenOffset):!1}attachControl(e,t,i=!0,s=2){const r=arguments;t=pe.BackCompatCameraNoPreventDefault(r),this._useCtrlForPanning=i,this._panningMouseButton=s,typeof r[0]=="boolean"&&(r.length>1&&(this._useCtrlForPanning=r[1]),r.length>2&&(this._panningMouseButton=r[2])),this.inputs.attachElement(t),this._reset=()=>{this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0}}detachControl(){this.inputs.detachElement(),this._reset&&this._reset()}_checkInputs(){if(this._collisionTriggered)return;this.inputs.checkInputs();let e=!1;const t=this.speed*this._panningEpsilon,i=this.speed*this._rotationEpsilon;if(this.inertialAlphaOffset!==0||this.inertialBetaOffset!==0||this.inertialRadiusOffset!==0){e=!0;const s=this.invertRotation?-1:1,r=this._calculateHandednessMultiplier();let a=this.inertialAlphaOffset*r;this.beta<0&&(a*=-1),this.alpha+=a*s,this.beta+=this.inertialBetaOffset*s,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)<i&&(this.inertialAlphaOffset=0),Math.abs(this.inertialBetaOffset)<i&&(this.inertialBetaOffset=0),Math.abs(this.inertialRadiusOffset)<i&&(this.inertialRadiusOffset=0)}if(this.inertialPanningX!==0||this.inertialPanningY!==0){e=!0;const s=new T(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY);if(this._viewMatrix.invertToRef(this._cameraTransformMatrix),s.multiplyInPlace(this.panningAxis),T.TransformNormalToRef(s,this._cameraTransformMatrix,this._transformedDirection),this.mapPanning){const r=this.upVector,a=T.CrossToRef(this._transformedDirection,r,this._transformedDirection);T.CrossToRef(r,a,this._transformedDirection)}else this.panningAxis.y||(this._transformedDirection.y=0);if(!this._targetHost)if(this.panningDistanceLimit)this._transformedDirection.addInPlace(this._target),T.DistanceSquared(this._transformedDirection,this.panningOriginTarget)<=this.panningDistanceLimit*this.panningDistanceLimit&&this._target.copyFrom(this._transformedDirection);else{if(this.parent){const r=te.Matrix[0];this.parent.getWorldMatrix().getRotationMatrixToRef(r),r.transposeToRef(r),T.TransformCoordinatesToRef(this._transformedDirection,r,this._transformedDirection)}this._target.addInPlace(this._transformedDirection)}this.inertialPanningX*=this.panningInertia,this.inertialPanningY*=this.panningInertia,Math.abs(this.inertialPanningX)<t&&(this.inertialPanningX=0),Math.abs(this.inertialPanningY)<t&&(this.inertialPanningY=0)}if(e)this.stopInterpolation();else if(this._isInterpolating){let s=!1;const r=this._scene.getEngine().getDeltaTime()/1e3,a=1-Math.pow(2,-r/this._currentInterpolationFactor),o=ds(this._goalRadius,this.radius);if(!isNaN(this._goalTarget.x)||!isNaN(this._goalTarget.y)||!isNaN(this._goalTarget.z)){const c=te.Vector3[0].set(ds(this._goalTarget.x,this._target.x),ds(this._goalTarget.y,this._target.y),ds(this._goalTarget.z,this._target.z));T.LerpToRef(this.target,c,a,this._target),T.Distance(this.target,c)*10/o<bt?(this._goalTarget.set(NaN,NaN,NaN),this.target.copyFrom(c),this.setTarget(this.target,!1,!0,!0)):s=!0}if(!isNaN(this._goalAlpha)||!isNaN(this._goalBeta)){const c=Se.RotationAlphaBetaGammaToRef(ds(this._goalAlpha,this.alpha),ds(this._goalBeta,this.beta),0,te.Quaternion[0]),u=Se.RotationAlphaBetaGammaToRef(this.alpha,this.beta,0,te.Quaternion[1]),d=Se.SlerpToRef(u,c,a,te.Quaternion[2]);d.normalize();const f=d.toAlphaBetaGammaToRef(te.Vector3[0]);if(this.alpha=f.x,this.beta=f.y,d.isApprox(c,bt/5)){this._goalAlpha=NaN,this._goalBeta=NaN;const g=c.toAlphaBetaGammaToRef(te.Vector3[0]);this.alpha=g.x,this.beta=g.y}else s=!0}if(isNaN(this._goalRadius)||(this.radius+=(o-this.radius)*a,Math.abs(o/this.radius-1)<bt?(this._goalRadius=NaN,this.radius=o):s=!0),!isNaN(this._goalTargetScreenOffset.x)||!isNaN(this._goalTargetScreenOffset.y)){const c=te.Vector2[0].set(ds(this._goalTargetScreenOffset.x,this.targetScreenOffset.x),ds(this._goalTargetScreenOffset.y,this.targetScreenOffset.y));Ie.LerpToRef(this.targetScreenOffset,c,a,this.targetScreenOffset),Ie.Distance(this.targetScreenOffset,c)<bt?(this._goalTargetScreenOffset.set(NaN,NaN),this.targetScreenOffset.copyFrom(c)):s=!0}this._isInterpolating=s}this._checkLimits(),super._checkInputs()}_checkLimits(){this.lowerBetaLimit===null||this.lowerBetaLimit===void 0?this.allowUpsideDown&&this.beta>Math.PI&&(this.beta=this.beta-2*Math.PI):this.beta<this.lowerBetaLimit&&(this.beta=this.lowerBetaLimit),this.upperBetaLimit===null||this.upperBetaLimit===void 0?this.allowUpsideDown&&this.beta<-Math.PI&&(this.beta=this.beta+2*Math.PI):this.beta>this.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit!==null&&this.alpha<this.lowerAlphaLimit&&(this.alpha=this.lowerAlphaLimit),this.upperAlphaLimit!==null&&this.alpha>this.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit!==null&&this.radius<this.lowerRadiusLimit&&(this.radius=this.lowerRadiusLimit,this.inertialRadiusOffset=0),this.upperRadiusLimit!==null&&this.radius>this.upperRadiusLimit&&(this.radius=this.upperRadiusLimit,this.inertialRadiusOffset=0),this.target.y=Math.max(this.target.y,this.lowerTargetYLimit)}rebuildAnglesAndRadius(){this._position.subtractToRef(this._getTargetPosition(),this._computationVector),(this._upVector.x!==0||this._upVector.y!==1||this._upVector.z!==0)&&T.TransformCoordinatesToRef(this._computationVector,this._upToYMatrix,this._computationVector),this.radius=this._computationVector.length(),this.radius===0&&(this.radius=1e-4);const e=this.alpha;this.alpha=KV(this._computationVector),this.beta=qV(this._computationVector.y,this.radius);const t=Math.round((e-this.alpha)/(2*Math.PI));this.alpha+=t*2*Math.PI,this._checkLimits()}setPosition(e){this._position.equals(e)||(this._position.copyFrom(e),this.rebuildAnglesAndRadius())}setTarget(e,t=!1,i=!1,s=!1){if(s=this.overrideCloneAlphaBetaRadius??s,e.computeWorldMatrix)t&&e.getBoundingInfo?this._targetBoundingCenter=e.getBoundingInfo().boundingBox.centerWorld.clone():this._targetBoundingCenter=null,e.computeWorldMatrix(),this._targetHost=e,this._target=this._getTargetPosition(),this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);else{const r=e,a=this._getTargetPosition();if(a&&!i&&a.equals(r))return;this._targetHost=null,this._target=r,this._targetBoundingCenter=null,this.onMeshTargetChangedObservable.notifyObservers(null)}s||this.rebuildAnglesAndRadius()}_getViewMatrix(){const e=Math.cos(this.alpha),t=Math.sin(this.alpha),i=Math.cos(this.beta);let s=Math.sin(this.beta);s===0&&(s=1e-4),this.radius===0&&(this.radius=1e-4);const r=this._getTargetPosition();if(this._computationVector.copyFromFloats(this.radius*e*s,this.radius*i,this.radius*t*s),(this._upVector.x!==0||this._upVector.y!==1||this._upVector.z!==0)&&T.TransformCoordinatesToRef(this._computationVector,this._yToUpMatrix,this._computationVector),r.addToRef(this._computationVector,this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions){const a=this.getScene().collisionCoordinator;this._collider||(this._collider=a.createCollider()),this._collider._radius=this.collisionRadius,this._newPosition.subtractToRef(this._position,this._collisionVelocity),this._collisionTriggered=!0,a.getNewPosition(this._position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}else{this._position.copyFrom(this._newPosition);let a=this.upVector;this.allowUpsideDown&&s<0&&(a=a.negate()),this._computeViewMatrix(this._position,r,a),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y)}return this._currentTarget.copyFrom(r),this._viewMatrix}zoomOn(e,t=!1){e=e||this.getScene().meshes;const i=Z.MinMax(e);let s=this._calculateLowerRadiusFromModelBoundingSphere(i.min,i.max);if(s=Math.max(Math.min(s,this.upperRadiusLimit||Number.MAX_VALUE),this.lowerRadiusLimit||0),this.radius=s*this.zoomOnFactor,this.mode===Ge.ORTHOGRAPHIC_CAMERA){const r=this.getScene().getEngine().getAspectRatio(this),a=s*this.zoomOnFactor/2;this.orthoLeft=-a*r,this.orthoRight=a*r,this.orthoBottom=-a,this.orthoTop=a}this.focusOn({min:i.min,max:i.max,distance:s},t)}focusOn(e,t=!1){let i,s;if(e.min===void 0){const r=e||this.getScene().meshes;i=Z.MinMax(r),s=T.Distance(i.min,i.max)}else{const r=e;i=r,s=r.distance}this._target=Z.Center(i),t||(this.maxZ=s*2)}createRigCamera(e,t){let i=0;switch(this.cameraRigMode){case Ge.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Ge.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Ge.RIG_MODE_STEREOSCOPIC_OVERUNDER:case Ge.RIG_MODE_STEREOSCOPIC_INTERLACED:case Ge.RIG_MODE_VR:i=this._cameraRigParams.stereoHalfAngle*(t===0?1:-1);break;case Ge.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:i=this._cameraRigParams.stereoHalfAngle*(t===0?-1:1);break}const s=new kt(e,this.alpha+i,this.beta,this.radius,this._target,this.getScene());return s._cameraRigParams={},s.isRigCamera=!0,s.rigParent=this,s.upVector=this.upVector,s.mode=this.mode,s.orthoLeft=this.orthoLeft,s.orthoRight=this.orthoRight,s.orthoBottom=this.orthoBottom,s.orthoTop=this.orthoTop,s}_updateRigCameras(){const e=this._rigCameras[0],t=this._rigCameras[1];switch(e.beta=t.beta=this.beta,this.cameraRigMode){case Ge.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Ge.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Ge.RIG_MODE_STEREOSCOPIC_OVERUNDER:case Ge.RIG_MODE_STEREOSCOPIC_INTERLACED:case Ge.RIG_MODE_VR:e.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,t.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case Ge.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:e.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,t.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle;break}super._updateRigCameras()}_calculateLowerRadiusFromModelBoundingSphere(e,t,i=1){const s=T.Distance(e,t),a=this.getScene().getEngine().getAspectRatio(this),o=Math.tan(this.fov/2),c=o*a,d=s*.5*i,f=d*Math.sqrt(1+1/(c*c)),g=d*Math.sqrt(1+1/(o*o));return Math.max(f,g)}dispose(){this.inputs.clear(),super.dispose()}getClassName(){return"ArcRotateCamera"}}N([H()],kt.prototype,"alpha",void 0);N([H()],kt.prototype,"beta",void 0);N([H()],kt.prototype,"radius",void 0);N([H()],kt.prototype,"overrideCloneAlphaBetaRadius",void 0);N([lr("target")],kt.prototype,"_target",void 0);N([bC("targetHost")],kt.prototype,"_targetHost",void 0);N([H()],kt.prototype,"inertialAlphaOffset",void 0);N([H()],kt.prototype,"inertialBetaOffset",void 0);N([H()],kt.prototype,"inertialRadiusOffset",void 0);N([H()],kt.prototype,"lowerAlphaLimit",void 0);N([H()],kt.prototype,"upperAlphaLimit",void 0);N([H()],kt.prototype,"lowerBetaLimit",void 0);N([H()],kt.prototype,"upperBetaLimit",void 0);N([H()],kt.prototype,"lowerRadiusLimit",void 0);N([H()],kt.prototype,"upperRadiusLimit",void 0);N([H()],kt.prototype,"lowerTargetYLimit",void 0);N([H()],kt.prototype,"inertialPanningX",void 0);N([H()],kt.prototype,"inertialPanningY",void 0);N([H()],kt.prototype,"pinchToPanMaxDistance",void 0);N([H()],kt.prototype,"panningDistanceLimit",void 0);N([lr()],kt.prototype,"panningOriginTarget",void 0);N([H()],kt.prototype,"panningInertia",void 0);N([H()],kt.prototype,"zoomToMouseLocation",null);N([H()],kt.prototype,"zoomOnFactor",void 0);N([mC()],kt.prototype,"targetScreenOffset",void 0);N([H()],kt.prototype,"allowUpsideDown",void 0);N([H()],kt.prototype,"useInputToRestoreState",void 0);N([H()],kt.prototype,"restoreStateInterpolationFactor",void 0);Tt("BABYLON.ArcRotateCamera",kt);const oE="decalVertexDeclaration",ZV=`#ifdef DECAL 770uniform vec4 vDecalInfos;uniform mat4 decalMatrix; 771#endif 772`;de.IncludesShadersStore[oE]||(de.IncludesShadersStore[oE]=ZV);const lE="defaultVertexDeclaration",$V=`uniform mat4 viewProjection; 773#ifdef MULTIVIEW 774mat4 viewProjectionR; 775#endif 776uniform mat4 view; 777#ifdef DIFFUSE 778uniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos; 779#endif 780#ifdef AMBIENT 781uniform mat4 ambientMatrix;uniform vec2 vAmbientInfos; 782#endif 783#ifdef OPACITY 784uniform mat4 opacityMatrix;uniform vec2 vOpacityInfos; 785#endif 786#ifdef EMISSIVE 787uniform vec2 vEmissiveInfos;uniform mat4 emissiveMatrix; 788#endif 789#ifdef LIGHTMAP 790uniform vec2 vLightmapInfos;uniform mat4 lightmapMatrix; 791#endif 792#if defined(SPECULAR) && defined(SPECULARTERM) 793uniform vec2 vSpecularInfos;uniform mat4 specularMatrix; 794#endif 795#ifdef BUMP 796uniform vec3 vBumpInfos;uniform mat4 bumpMatrix; 797#endif 798#ifdef REFLECTION 799uniform mat4 reflectionMatrix; 800#endif 801#ifdef POINTSIZE 802uniform float pointSize; 803#endif 804#ifdef DETAIL 805uniform vec4 vDetailInfos;uniform mat4 detailMatrix; 806#endif 807uniform vec4 cameraInfo; 808#include<decalVertexDeclaration> 809#define ADDITIONAL_VERTEX_DECLARATION 810`;de.IncludesShadersStore[lE]||(de.IncludesShadersStore[lE]=$V);const cE="sceneUboDeclaration",QV=`layout(std140,column_major) uniform;uniform Scene {mat4 viewProjection; 811#ifdef MULTIVIEW 812mat4 viewProjectionR; 813#endif 814mat4 view;mat4 projection;vec4 vEyePosition;}; 815`;de.IncludesShadersStore[cE]||(de.IncludesShadersStore[cE]=QV);const hE="meshUboDeclaration",JV=`#ifdef WEBGL2 816uniform mat4 world;uniform float visibility; 817#else 818layout(std140,column_major) uniform;uniform Mesh 819{mat4 world;float visibility;}; 820#endif 821#define WORLD_UBO 822`;de.IncludesShadersStore[hE]||(de.IncludesShadersStore[hE]=JV);const uE="defaultUboDeclaration",ez=`layout(std140,column_major) uniform;uniform Material 823{vec4 diffuseLeftColor;vec4 diffuseRightColor;vec4 opacityParts;vec4 reflectionLeftColor;vec4 reflectionRightColor;vec4 refractionLeftColor;vec4 refractionRightColor;vec4 emissiveLeftColor;vec4 emissiveRightColor;vec2 vDiffuseInfos;vec2 vAmbientInfos;vec2 vOpacityInfos;vec2 vEmissiveInfos;vec2 vLightmapInfos;vec2 vSpecularInfos;vec3 vBumpInfos;mat4 diffuseMatrix;mat4 ambientMatrix;mat4 opacityMatrix;mat4 emissiveMatrix;mat4 lightmapMatrix;mat4 specularMatrix;mat4 bumpMatrix;vec2 vTangentSpaceParams;float pointSize;float alphaCutOff;mat4 refractionMatrix;vec4 vRefractionInfos;vec3 vRefractionPosition;vec3 vRefractionSize;vec4 vSpecularColor;vec3 vEmissiveColor;vec4 vDiffuseColor;vec3 vAmbientColor;vec4 cameraInfo;vec2 vReflectionInfos;mat4 reflectionMatrix;vec3 vReflectionPosition;vec3 vReflectionSize; 824#define ADDITIONAL_UBO_DECLARATION 825}; 826#include<sceneUboDeclaration> 827#include<meshUboDeclaration> 828`;de.IncludesShadersStore[uE]||(de.IncludesShadersStore[uE]=ez);const dE="uvAttributeDeclaration",tz=`#ifdef UV{X} 829attribute vec2 uv{X}; 830#endif 831`;de.IncludesShadersStore[dE]||(de.IncludesShadersStore[dE]=tz);const fE="helperFunctions",iz=`const float PI=3.1415926535897932384626433832795;const float TWO_PI=6.283185307179586;const float HALF_PI=1.5707963267948966;const float RECIPROCAL_PI=0.3183098861837907;const float RECIPROCAL_PI2=0.15915494309189535;const float RECIPROCAL_PI4=0.07957747154594767;const float HALF_MIN=5.96046448e-08; 832const float LinearEncodePowerApprox=2.2;const float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;const vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);const float Epsilon=0.0000001; 833#define saturate(x) clamp(x,0.0,1.0) 834#define absEps(x) abs(x)+Epsilon 835#define maxEps(x) max(x,Epsilon) 836#define saturateEps(x) clamp(x,Epsilon,1.0) 837mat3 transposeMat3(mat3 inMatrix) {vec3 i0=inMatrix[0];vec3 i1=inMatrix[1];vec3 i2=inMatrix[2];mat3 outMatrix=mat3( 838vec3(i0.x,i1.x,i2.x), 839vec3(i0.y,i1.y,i2.y), 840vec3(i0.z,i1.z,i2.z) 841);return outMatrix;} 842mat3 inverseMat3(mat3 inMatrix) {float a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];float a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];float a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11), 843b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),
844b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;} 845#if USE_EXACT_SRGB_CONVERSIONS 846vec3 toLinearSpaceExact(vec3 color) 847{vec3 nearZeroSection=0.0773993808*color;vec3 remainingSection=pow(0.947867299*(color+vec3(0.055)),vec3(2.4)); 848#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE) 849return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.04045))); 850#else 851return 852vec3( 853color.r<=0.04045 ? nearZeroSection.r : remainingSection.r, 854color.g<=0.04045 ? nearZeroSection.g : remainingSection.g, 855color.b<=0.04045 ? nearZeroSection.b : remainingSection.b); 856#endif 857} 858vec3 toGammaSpaceExact(vec3 color) 859{vec3 nearZeroSection=12.92*color;vec3 remainingSection=1.055*pow(color,vec3(0.41666))-vec3(0.055); 860#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE) 861return mix(remainingSection,nearZeroSection,lessThanEqual(color,vec3(0.0031308))); 862#else 863return 864vec3( 865color.r<=0.0031308 ? nearZeroSection.r : remainingSection.r, 866color.g<=0.0031308 ? nearZeroSection.g : remainingSection.g, 867color.b<=0.0031308 ? nearZeroSection.b : remainingSection.b); 868#endif 869} 870#endif 871float toLinearSpace(float color) 872{ 873#if USE_EXACT_SRGB_CONVERSIONS 874float nearZeroSection=0.0773993808*color;float remainingSection=pow(0.947867299*(color+0.055),2.4);return color<=0.04045 ? nearZeroSection : remainingSection; 875#else 876return pow(color,LinearEncodePowerApprox); 877#endif 878} 879vec3 toLinearSpace(vec3 color) 880{ 881#if USE_EXACT_SRGB_CONVERSIONS 882return toLinearSpaceExact(color); 883#else 884return pow(color,vec3(LinearEncodePowerApprox)); 885#endif 886} 887vec4 toLinearSpace(vec4 color) 888{ 889#if USE_EXACT_SRGB_CONVERSIONS 890return vec4(toLinearSpaceExact(color.rgb),color.a); 891#else 892return vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a); 893#endif 894} 895float toGammaSpace(float color) 896{ 897#if USE_EXACT_SRGB_CONVERSIONS 898float nearZeroSection=12.92*color;float remainingSection=1.055*pow(color,0.41666)-0.055;return color<=0.0031308 ? nearZeroSection : remainingSection; 899#else 900return pow(color,GammaEncodePowerApprox); 901#endif 902} 903vec3 toGammaSpace(vec3 color) 904{ 905#if USE_EXACT_SRGB_CONVERSIONS 906return toGammaSpaceExact(color); 907#else 908return pow(color,vec3(GammaEncodePowerApprox)); 909#endif 910} 911vec4 toGammaSpace(vec4 color) 912{ 913#if USE_EXACT_SRGB_CONVERSIONS 914return vec4(toGammaSpaceExact(color.rgb),color.a); 915#else 916return vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a); 917#endif 918} 919float square(float value) 920{return value*value;} 921vec3 square(vec3 value) 922{return value*value;} 923float pow5(float value) {float sq=value*value;return sq*sq*value;} 924float getLuminance(vec3 color) 925{return saturate(dot(color,LuminanceEncodeApprox));} 926float getRand(vec2 seed) {return fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);} 927float dither(vec2 seed,float varianceAmount) {float rand=getRand(seed);float normVariance=varianceAmount/255.0;float dither=mix(-normVariance,normVariance,rand);return dither;} 928const float rgbdMaxRange=255.;vec4 toRGBD(vec3 color) {float maxRGB=maxEps(max(color.r,max(color.g,color.b)));float D =max(rgbdMaxRange/maxRGB,1.);D =saturate(floor(D)/255.);vec3 rgb=color.rgb*D;rgb=toGammaSpace(rgb);return vec4(saturate(rgb),D);} 929vec3 fromRGBD(vec4 rgbd) {rgbd.rgb=toLinearSpace(rgbd.rgb);return rgbd.rgb/rgbd.a;} 930vec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {vec3 invOrigVec=vec3(1.)/origVec;vec3 halfSize=cubeSize*0.5;vec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;vec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;vec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);float distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);vec3 intersectPositionWS=vertexPos+origVec*distance;return intersectPositionWS-cubePos;} 931vec3 equirectangularToCubemapDirection(vec2 uv) {float longitude=uv.x*TWO_PI-PI;float latitude=HALF_PI-uv.y*PI;vec3 direction;direction.x=cos(latitude)*sin(longitude);direction.y=sin(latitude);direction.z=cos(latitude)*cos(longitude);return direction;} 932float sqrtClamped(float value) {return sqrt(max(value,0.));} 933float avg(vec3 value) {return dot(value,vec3(0.333333333));} 934#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE) 935uint extractBits(uint value,int offset,int width) {return (value>>offset) & ((1u<<width)-1u);} 936int onlyBitPosition(uint value) {return (floatBitsToInt(float(value))>>23)-0x7f;} 937#endif 938`;de.IncludesShadersStore[fE]||(de.IncludesShadersStore[fE]=iz);const pE="prePassVertexDeclaration",sz=`#ifdef PREPASS 939#ifdef PREPASS_LOCAL_POSITION 940varying vec3 vPosition; 941#endif 942#ifdef PREPASS_DEPTH 943varying vec3 vViewPos; 944#endif 945#ifdef PREPASS_NORMALIZED_VIEW_DEPTH 946varying float vNormViewDepth; 947#endif 948#if defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) 949uniform mat4 previousViewProjection;varying vec4 vCurrentPosition;varying vec4 vPreviousPosition; 950#endif 951#endif 952`;de.IncludesShadersStore[pE]||(de.IncludesShadersStore[pE]=sz);const _E="mainUVVaryingDeclaration",rz=`#ifdef MAINUV{X} 953varying vec2 vMainUV{X}; 954#endif 955`;de.IncludesShadersStore[_E]||(de.IncludesShadersStore[_E]=rz);const gE="samplerVertexDeclaration",nz=`#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0 956varying vec2 v_VARYINGNAME_UV; 957#endif 958`;de.IncludesShadersStore[gE]||(de.IncludesShadersStore[gE]=nz);const mE="bumpVertexDeclaration",az=`#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) 959#if defined(TANGENT) && defined(NORMAL) 960varying mat3 vTBN; 961#endif 962#endif 963`;de.IncludesShadersStore[mE]||(de.IncludesShadersStore[mE]=az);const bE="fogVertexDeclaration",oz=`#ifdef FOG 964varying vec3 vFogDistance; 965#endif 966`;de.IncludesShadersStore[bE]||(de.IncludesShadersStore[bE]=oz);const yE="lightVxFragmentDeclaration",lz=`#ifdef LIGHT{X} 967uniform vec4 vLightData{X};uniform vec4 vLightDiffuse{X}; 968#ifdef SPECULARTERM 969uniform vec4 vLightSpecular{X}; 970#else 971vec4 vLightSpecular{X}=vec4(0.); 972#endif 973#ifdef SHADOW{X} 974#ifdef SHADOWCSM{X} 975uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X}; 976#elif defined(SHADOWCUBE{X}) 977#else 978varying vec4 vPositionFromLight{X};varying float vDepthMetric{X};uniform mat4 lightMatrix{X}; 979#endif 980uniform vec4 shadowsInfo{X};uniform vec2 depthValues{X}; 981#endif 982#ifdef SPOTLIGHT{X} 983uniform vec4 vLightDirection{X};uniform vec4 vLightFalloff{X}; 984#elif defined(POINTLIGHT{X}) 985uniform vec4 vLightFalloff{X};
986#elif defined(HEMILIGHT{X}) 987uniform vec3 vLightGround{X}; 988#endif 989#if defined(AREALIGHT{X}) 990uniform vec4 vLightWidth{X};uniform vec4 vLightHeight{X}; 991#endif 992#endif 993`;de.IncludesShadersStore[yE]||(de.IncludesShadersStore[yE]=lz);const vE="lightVxUboDeclaration",cz=`#ifdef LIGHT{X} 994uniform Light{X} 995{vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular; 996#ifdef SPOTLIGHT{X} 997vec4 vLightDirection;vec4 vLightFalloff; 998#elif defined(POINTLIGHT{X}) 999vec4 vLightFalloff; 1000#elif defined(HEMILIGHT{X}) 1001vec3 vLightGround; 1002#elif defined(CLUSTLIGHT{X}) 1003vec2 vSliceData;vec2 vSliceRanges[CLUSTLIGHT_SLICES]; 1004#endif 1005#if defined(AREALIGHT{X}) 1006vec4 vLightWidth;vec4 vLightHeight; 1007#endif 1008vec4 shadowsInfo;vec2 depthValues;} light{X}; 1009#ifdef SHADOW{X} 1010#ifdef SHADOWCSM{X} 1011uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X}; 1012#elif defined(SHADOWCUBE{X}) 1013#else 1014varying vec4 vPositionFromLight{X};varying float vDepthMetric{X};uniform mat4 lightMatrix{X}; 1015#endif 1016#endif 1017#endif 1018`;de.IncludesShadersStore[vE]||(de.IncludesShadersStore[vE]=cz);const xE="logDepthDeclaration",hz=`#ifdef LOGARITHMICDEPTH 1019uniform float logarithmicDepthConstant;varying float vFragmentDepth; 1020#endif 1021`;de.IncludesShadersStore[xE]||(de.IncludesShadersStore[xE]=hz);const SE="prePassVertex",uz=`#ifdef PREPASS_DEPTH 1022vViewPos=(view*worldPos).rgb; 1023#endif 1024#ifdef PREPASS_NORMALIZED_VIEW_DEPTH 1025vNormViewDepth=((view*worldPos).z-cameraInfo.x)/(cameraInfo.y-cameraInfo.x); 1026#endif 1027#ifdef PREPASS_LOCAL_POSITION 1028vPosition=positionUpdated.xyz; 1029#endif 1030#if (defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)) && defined(BONES_VELOCITY_ENABLED) 1031vCurrentPosition=viewProjection*worldPos; 1032#if NUM_BONE_INFLUENCERS>0 1033mat4 previousInfluence;previousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0]; 1034#if NUM_BONE_INFLUENCERS>1 1035previousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1]; 1036#endif 1037#if NUM_BONE_INFLUENCERS>2 1038previousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2]; 1039#endif 1040#if NUM_BONE_INFLUENCERS>3 1041previousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3]; 1042#endif 1043#if NUM_BONE_INFLUENCERS>4 1044previousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0]; 1045#endif 1046#if NUM_BONE_INFLUENCERS>5 1047previousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1]; 1048#endif 1049#if NUM_BONE_INFLUENCERS>6 1050previousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2]; 1051#endif 1052#if NUM_BONE_INFLUENCERS>7 1053previousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3]; 1054#endif 1055vPreviousPosition=previousViewProjection*finalPreviousWorld*previousInfluence*vec4(positionUpdated,1.0); 1056#else 1057vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0); 1058#endif 1059#endif 1060`;de.IncludesShadersStore[SE]||(de.IncludesShadersStore[SE]=uz);const TE="uvVariableDeclaration",dz=`#if !defined(UV{X}) && defined(MAINUV{X}) 1061vec2 uv{X}=vec2(0.,0.); 1062#endif 1063#ifdef MAINUV{X} 1064vMainUV{X}=uv{X}; 1065#endif 1066`;de.IncludesShadersStore[TE]||(de.IncludesShadersStore[TE]=dz);const EE="samplerVertexImplementation",fz=`#if defined(_DEFINENAME_) && _DEFINENAME_DIRECTUV==0 1067if (v_INFONAME_==0.) 1068{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uvUpdated,1.0,0.0));} 1069#ifdef UV2 1070else if (v_INFONAME_==1.) 1071{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv2Updated,1.0,0.0));} 1072#endif 1073#ifdef UV3 1074else if (v_INFONAME_==2.) 1075{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv3,1.0,0.0));} 1076#endif 1077#ifdef UV4 1078else if (v_INFONAME_==3.) 1079{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv4,1.0,0.0));} 1080#endif 1081#ifdef UV5 1082else if (v_INFONAME_==4.) 1083{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv5,1.0,0.0));} 1084#endif 1085#ifdef UV6 1086else if (v_INFONAME_==5.) 1087{v_VARYINGNAME_UV=vec2(_MATRIXNAME_Matrix*vec4(uv6,1.0,0.0));} 1088#endif 1089#endif 1090`;de.IncludesShadersStore[EE]||(de.IncludesShadersStore[EE]=fz);const AE="bumpVertex",pz=`#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) 1091#if defined(TANGENT) && defined(NORMAL) 1092vec3 tbnNormal=normalize(normalUpdated);vec3 tbnTangent=normalize(tangentUpdated.xyz);vec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;vTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal); 1093#endif 1094#endif 1095`;de.IncludesShadersStore[AE]||(de.IncludesShadersStore[AE]=pz);const RE="fogVertex",_z=`#ifdef FOG 1096vFogDistance=(view*worldPos).xyz; 1097#endif 1098`;de.IncludesShadersStore[RE]||(de.IncludesShadersStore[RE]=_z);const ME="shadowsVertex",gz=`#ifdef SHADOWS 1099#if defined(SHADOWCSM{X}) 1100vPositionFromCamera{X}
1100=view*worldPos;for (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++) {vPositionFromLight{X}[i]=lightMatrix{X}[i]*worldPos; 1101#ifdef USE_REVERSE_DEPTHBUFFER 1102vDepthMetric{X}[i]=(-vPositionFromLight{X}[i].z+light{X}.depthValues.x)/light{X}.depthValues.y; 1103#else 1104vDepthMetric{X}[i]=(vPositionFromLight{X}[i].z+light{X}.depthValues.x)/light{X}.depthValues.y; 1105#endif 1106} 1107#elif defined(SHADOW{X}) && !defined(SHADOWCUBE{X}) 1108vPositionFromLight{X}=lightMatrix{X}*worldPos; 1109#ifdef USE_REVERSE_DEPTHBUFFER 1110vDepthMetric{X}=(-vPositionFromLight{X}.z+light{X}.depthValues.x)/light{X}.depthValues.y; 1111#else 1112vDepthMetric{X}=(vPositionFromLight{X}.z+light{X}.depthValues.x)/light{X}.depthValues.y; 1113#endif 1114#endif 1115#endif 1116`;de.IncludesShadersStore[ME]||(de.IncludesShadersStore[ME]=gz);const CE="vertexColorMixing",mz=`#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) 1117vColor=vec4(1.0); 1118#ifdef VERTEXCOLOR 1119#ifdef VERTEXALPHA 1120vColor*=colorUpdated; 1121#else 1122vColor.rgb*=colorUpdated.rgb; 1123#endif 1124#endif 1125#ifdef INSTANCESCOLOR 1126vColor*=instanceColor; 1127#endif 1128#endif 1129`;de.IncludesShadersStore[CE]||(de.IncludesShadersStore[CE]=mz);const IE="logDepthVertex",bz=`#ifdef LOGARITHMICDEPTH 1130vFragmentDepth=1.0+gl_Position.w;gl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant; 1131#endif 1132`;de.IncludesShadersStore[IE]||(de.IncludesShadersStore[IE]=bz);const Wm="defaultVertexShader",FI=`#define CUSTOM_VERTEX_EXTENSION 1133#include<__decl__defaultVertex> 1134#define CUSTOM_VERTEX_BEGIN 1135attribute vec3 position; 1136#ifdef NORMAL 1137attribute vec3 normal; 1138#endif 1139#ifdef TANGENT 1140attribute vec4 tangent; 1141#endif 1142#ifdef UV1 1143attribute vec2 uv; 1144#endif 1145#include<uvAttributeDeclaration>[2..7] 1146#ifdef VERTEXCOLOR 1147attribute vec4 color; 1148#endif 1149#include<helperFunctions> 1150#include<bonesDeclaration> 1151#include<bakedVertexAnimationDeclaration> 1152#include<instancesDeclaration> 1153#include<prePassVertexDeclaration> 1154#include<mainUVVaryingDeclaration>[1..7] 1155#include<samplerVertexDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse) 1156#include<samplerVertexDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail) 1157#include<samplerVertexDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient) 1158#include<samplerVertexDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity) 1159#include<samplerVertexDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive) 1160#include<samplerVertexDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap) 1161#if defined(SPECULARTERM) 1162#include<samplerVertexDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular) 1163#endif 1164#include<samplerVertexDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump) 1165#include<samplerVertexDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal) 1166varying vec3 vPositionW; 1167#ifdef NORMAL 1168varying vec3 vNormalW; 1169#endif 1170#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) 1171varying vec4 vColor; 1172#endif 1173#include<bumpVertexDeclaration> 1174#include<clipPlaneVertexDeclaration> 1175#include<fogVertexDeclaration> 1176#include<__decl__lightVxFragment>[0..maxSimultaneousLights] 1177#include<morphTargetsVertexGlobalDeclaration> 1178#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets] 1179#ifdef REFLECTIONMAP_SKYBOX 1180varying vec3 vPositionUVW; 1181#endif 1182#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) 1183varying vec3 vDirectionW; 1184#endif 1185#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 1186varying float vViewDepth; 1187#endif 1188#include<logDepthDeclaration> 1189#define CUSTOM_VERTEX_DEFINITIONS 1190void main(void) { 1191#define CUSTOM_VERTEX_MAIN_BEGIN 1192vec3 positionUpdated=position; 1193#ifdef NORMAL 1194vec3 normalUpdated=normal; 1195#endif 1196#ifdef TANGENT 1197vec4 tangentUpdated=tangent; 1198#endif 1199#ifdef UV1 1200vec2 uvUpdated=uv; 1201#endif 1202#ifdef UV2 1203vec2 uv2Updated=uv2; 1204#endif 1205#ifdef VERTEXCOLOR 1206vec4 colorUpdated=color; 1207#endif 1208#include<morphTargetsVertexGlobal> 1209#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets] 1210#ifdef REFLECTIONMAP_SKYBOX 1211vPositionUVW=positionUpdated; 1212#endif 1213#define CUSTOM_VERTEX_UPDATE_POSITION 1214#define CUSTOM_VERTEX_UPDATE_NORMAL 1215#include<instancesVertex> 1216#if defined(PREPASS) && ((defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)) && !defined(BONES_VELOCITY_ENABLED) 1217vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,
12171.0);vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0); 1218#endif 1219#include<bonesVertex> 1220#include<bakedVertexAnimation> 1221vec4 worldPos=finalWorld*vec4(positionUpdated,1.0); 1222#ifdef NORMAL 1223mat3 normalWorld=mat3(finalWorld); 1224#if defined(INSTANCES) && defined(THIN_INSTANCES) 1225vNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));vNormalW=normalize(normalWorld*vNormalW); 1226#else 1227#ifdef NONUNIFORMSCALING 1228normalWorld=transposeMat3(inverseMat3(normalWorld)); 1229#endif 1230vNormalW=normalize(normalWorld*normalUpdated); 1231#endif 1232#endif 1233#define CUSTOM_VERTEX_UPDATE_WORLDPOS 1234#ifdef MULTIVIEW 1235if (gl_ViewID_OVR==0u) {gl_Position=viewProjection*worldPos;} else {gl_Position=viewProjectionR*worldPos;} 1236#else 1237gl_Position=viewProjection*worldPos; 1238#endif 1239vPositionW=vec3(worldPos); 1240#ifdef PREPASS 1241#include<prePassVertex> 1242#endif 1243#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) 1244vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0))); 1245#endif 1246#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 1247vViewDepth=(view*worldPos).z; 1248#endif 1249#ifndef UV1 1250vec2 uvUpdated=vec2(0.,0.); 1251#endif 1252#ifndef UV2 1253vec2 uv2Updated=vec2(0.,0.); 1254#endif 1255#ifdef MAINUV1 1256vMainUV1=uvUpdated; 1257#endif 1258#ifdef MAINUV2 1259vMainUV2=uv2Updated; 1260#endif 1261#include<uvVariableDeclaration>[3..7] 1262#include<samplerVertexImplementation>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_MATRIXNAME_,diffuse,_INFONAME_,DiffuseInfos.x) 1263#include<samplerVertexImplementation>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x) 1264#include<samplerVertexImplementation>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x) 1265#include<samplerVertexImplementation>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x) 1266#include<samplerVertexImplementation>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x) 1267#include<samplerVertexImplementation>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x) 1268#if defined(SPECULARTERM) 1269#include<samplerVertexImplementation>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_MATRIXNAME_,specular,_INFONAME_,SpecularInfos.x) 1270#endif 1271#include<samplerVertexImplementation>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x) 1272#include<samplerVertexImplementation>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_MATRIXNAME_,decal,_INFONAME_,DecalInfos.x) 1273#include<bumpVertex> 1274#include<clipPlaneVertex> 1275#include<fogVertex> 1276#include<shadowsVertex>[0..maxSimultaneousLights] 1277#include<vertexColorMixing> 1278#include<pointCloudVertex> 1279#include<logDepthVertex> 1280#define CUSTOM_VERTEX_MAIN_END 1281} 1282`;de.ShadersStore[Wm]||(de.ShadersStore[Wm]=FI);const yz={name:Wm,shader:FI},vz=Object.freeze(Object.defineProperty({__proto__:null,defaultVertexShader:yz},Symbol.toStringTag,{value:"Module"})),PE="decalFragmentDeclaration",xz=`#ifdef DECAL 1283uniform vec4 vDecalInfos; 1284#endif 1285`;de.IncludesShadersStore[PE]||(de.IncludesShadersStore[PE]=xz);const DE="defaultFragmentDeclaration",Sz=`uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;uniform vec4 vSpecularColor;uniform vec3 vEmissiveColor;uniform vec3 vAmbientColor;uniform float visibility; 1286#ifdef DIFFUSE 1287uniform vec2 vDiffuseInfos; 1288#endif 1289#ifdef AMBIENT 1290uniform vec2 vAmbientInfos; 1291#endif 1292#ifdef OPACITY 1293uniform vec2 vOpacityInfos; 1294#endif 1295#ifdef EMISSIVE 1296uniform vec2 vEmissiveInfos; 1297#endif 1298#ifdef LIGHTMAP 1299uniform vec2 vLightmapInfos; 1300#endif 1301#ifdef BUMP 1302uniform vec3 vBumpInfos;uniform vec2 vTangentSpaceParams; 1303#endif 1304#ifdef ALPHATEST 1305uniform float alphaCutOff; 1306#endif 1307#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION) || defined(PREPASS) 1308uniform mat4 view; 1309#endif 1310#ifdef REFRACTION 1311uniform vec4 vRefractionInfos; 1312#ifndef REFRACTIONMAP_3D 1313uniform mat4 refractionMatrix; 1314#endif 1315#ifdef REFRACTIONFRESNEL 1316uniform vec4 refractionLeftColor;uniform vec4 refractionRightColor; 1317#endif 1318#if defined(USE_LOCAL_REFRACTIONMAP_CUBIC) && defined(REFRACTIONMAP_3D) 1319uniform vec3 vRefractionPosition;uniform vec3 vRefractionSize; 1320#endif 1321#endif 1322#if defined(SPECULAR) && defined(SPECULARTERM) 1323uniform vec2 vSpecularInfos; 1324#endif 1325#ifdef DIFFUSEFRESNEL 1326uniform vec4 diffuseLeftColor;uniform vec4 diffuseRightColor; 1327#endif 1328#ifdef OPACITYFRESNEL 1329uniform vec4 opacityParts; 1330#endif 1331#ifdef EMISSIVEFRESNEL 1332uniform vec4 emissiveLeftColor;uniform vec4 emissiveRightColor; 1333#endif 1334#if defined(REFLECTION) || (defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED)) 1335uniform vec2 vReflectionInfos; 1336#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX) 1337uniform mat4 reflectionMatrix; 1338#endif 1339#ifndef REFLECTIONMAP_SKYBOX 1340#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC) 1341uniform vec3 vReflectionPosition;uniform vec3 vReflectionSize; 1342#endif 1343#endif 1344#ifdef REFLECTIONFRESNEL 1345uniform vec4 reflectionLeftColor;uniform vec4 reflectionRightColor; 1346#endif 1347#endif 1348#ifdef DETAIL 1349uniform vec4 vDetailInfos; 1350#endif 1351#include<decalFragmentDeclaration> 1352#define ADDITIONAL_FRAGMENT_DECLARATION 1353`;de.IncludesShadersStore[DE]||(de.IncludesShadersStore[DE]=Sz);const OE="prePassDeclaration",Tz=`#ifdef PREPASS 1354#extension GL_EXT_draw_buffers : require 1355layout(location=0) out highp vec4 glFragData[{X}];highp vec4 gl_FragColor; 1356#ifdef PREPASS_LOCAL_POSITION 1357varying highp vec3 vPosition; 1358#endif 1359#ifdef PREPASS_DEPTH 1360varying highp vec3 vViewPos; 1361#endif 1362#ifdef PREPASS_NORMALIZED_VIEW_DEPTH 1363varying highp float vNormViewDepth; 1364#endif 1365#if defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR) 1366varying highp vec4 vCurrentPosition;varying highp vec4 vPreviousPosition; 1367#endif 1368#endif 1369`;de.IncludesShadersStore[OE]||(de.IncludesShadersStore[OE]=Tz);const wE="oitDeclaration",Ez=`#ifdef ORDER_INDEPENDENT_TRANSPARENCY 1370#extension GL_EXT_draw_buffers : require 1371layout(location=0) out vec2 depth; 1372layout(location=1) out vec4 frontColor;layout(location=2) out vec4 backColor; 1373#define MAX_DEPTH 99999.0 1374highp vec4 gl_FragColor;uniform sampler2D oitDepthSampler;uniform sampler2D oitFrontColorSampler; 1375#endif 1376`;de.IncludesShadersStore[wE]||(de.IncludesShadersStore[wE]=Ez);const FE="lightFragmentDeclaration",Az=`#ifdef LIGHT{X} 1377uniform vec4 vLightData{X};uniform vec4 vLightDiffuse{X}; 1378#ifdef SPECULARTERM 1379uniform vec4 vLightSpecular{X}; 1380#else 1381vec4 vLightSpecular{X}=vec4(0.); 1382#endif 1383#ifdef SHADOW{X} 1384#ifdef SHADOWCSM{X} 1385uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];uniform float cascadeBlendFactor{X};varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X}; 1386#if defined(SHADOWPCSS{X}) 1387uniform highp sampler2DArrayShadow shadowTexture{X};uniform highp sampler2DArray depthTexture{X};uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float penumbraDarkness{X}; 1388#elif defined(SHADOWPCF{X}) 1389uniform highp sampler2DArrayShadow shadowTexture{X}; 1390#else 1391uniform highp sampler2DArray shadowTexture{X}; 1392#endif 1393#ifdef SHADOWCSMDEBUG{X} 1394const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8] 1395( 1396vec3 ( 1.5,0.0,0.0 ), 1397vec3 ( 0.0,1.5,0.0 ), 1398vec3 ( 0.0,0.0,5.5 ), 1399vec3 ( 1.5,0.0,5.5 ), 1400vec3 ( 1.5,1.5,0.0 ), 1401vec3 ( 1.0,1.0,1.0 ), 1402vec3 ( 0.0,1.0,5.5 ), 1403vec3 ( 0.5,3.5,0.75 ) 1404);vec3 shadowDebug{X}; 1405#endif 1406#ifdef SHADOWCSMUSESHADOWMAXZ{X} 1407int index{X}=-1; 1408#else 1409int index{X}=SHADOWCSMNUM_CASCADES{X}-1; 1410#endif 1411float diff{X}=0.; 1412#elif defined(SHADOWCUBE{X}) 1413uniform samplerCube shadowTexture{X}; 1414#else 1415varying vec4 vPositionFromLight{X};varying float vDepthMetric{X}; 1416#if defined(SHADOWPCSS{X}) 1417uniform highp sampler2DShadow shadowTexture{X};uniform highp sampler2D depthTexture{X}; 1418#elif defined(SHADOWPCF{X}) 1419uniform highp sampler2DShadow shadowTexture{X}; 1420#else 1421uniform sampler2D shadowTexture{X}; 1422#endif 1423uniform mat4 lightMatrix{X}; 1424#endif 1425uniform vec4 shadowsInfo{X};uniform vec2 depthValues{X}; 1426#endif 1427#ifdef SPOTLIGHT{X} 1428uniform vec4 vLightDirection{X};uniform vec4 vLightFalloff{X}; 1429#elif defined(POINTLIGHT{X}) 1430uniform vec4 vLightFalloff{X};
1431#elif defined(HEMILIGHT{X}) 1432uniform vec3 vLightGround{X}; 1433#endif 1434#ifdef AREALIGHT{X} 1435uniform vec4 vLightWidth{X};uniform vec4 vLightHeight{X}; 1436#endif 1437#ifdef IESLIGHTTEXTURE{X} 1438uniform sampler2D iesLightTexture{X}; 1439#endif 1440#ifdef PROJECTEDLIGHTTEXTURE{X} 1441uniform mat4 textureProjectionMatrix{X};uniform sampler2D projectionLightTexture{X}; 1442#endif 1443#ifdef CLUSTLIGHT{X} 1444uniform vec2 vSliceData{X};uniform vec2 vSliceRanges{X}[CLUSTLIGHT_SLICES];uniform sampler2D lightDataTexture{X};uniform highp sampler2D tileMaskTexture{X}; 1445#endif 1446#endif 1447`;de.IncludesShadersStore[FE]||(de.IncludesShadersStore[FE]=Az);const LE="lightUboDeclaration",Rz=`#ifdef LIGHT{X} 1448uniform Light{X} 1449{vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular; 1450#ifdef SPOTLIGHT{X} 1451vec4 vLightDirection;vec4 vLightFalloff; 1452#elif defined(POINTLIGHT{X}) 1453vec4 vLightFalloff; 1454#elif defined(HEMILIGHT{X}) 1455vec3 vLightGround; 1456#elif defined(CLUSTLIGHT{X}) 1457vec2 vSliceData;vec2 vSliceRanges[CLUSTLIGHT_SLICES]; 1458#endif 1459#if defined(AREALIGHT{X}) 1460vec4 vLightWidth;vec4 vLightHeight; 1461#endif 1462vec4 shadowsInfo;vec2 depthValues;} light{X}; 1463#ifdef IESLIGHTTEXTURE{X} 1464uniform sampler2D iesLightTexture{X}; 1465#endif 1466#ifdef PROJECTEDLIGHTTEXTURE{X} 1467uniform mat4 textureProjectionMatrix{X};uniform sampler2D projectionLightTexture{X}; 1468#endif 1469#ifdef CLUSTLIGHT{X} 1470uniform sampler2D lightDataTexture{X};uniform highp sampler2D tileMaskTexture{X}; 1471#endif 1472#ifdef SHADOW{X} 1473#ifdef SHADOWCSM{X} 1474uniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];uniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];uniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];uniform float cascadeBlendFactor{X};varying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];varying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];varying vec4 vPositionFromCamera{X}; 1475#if defined(SHADOWPCSS{X}) 1476uniform highp sampler2DArrayShadow shadowTexture{X};uniform highp sampler2DArray depthTexture{X};uniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];uniform float penumbraDarkness{X}; 1477#elif defined(SHADOWPCF{X}) 1478uniform highp sampler2DArrayShadow shadowTexture{X}; 1479#else 1480uniform highp sampler2DArray shadowTexture{X}; 1481#endif 1482#ifdef SHADOWCSMDEBUG{X} 1483const vec3 vCascadeColorsMultiplier{X}[8]=vec3[8] 1484( 1485vec3 ( 1.5,0.0,0.0 ), 1486vec3 ( 0.0,1.5,0.0 ), 1487vec3 ( 0.0,0.0,5.5 ), 1488vec3 ( 1.5,0.0,5.5 ), 1489vec3 ( 1.5,1.5,0.0 ), 1490vec3 ( 1.0,1.0,1.0 ), 1491vec3 ( 0.0,1.0,5.5 ), 1492vec3 ( 0.5,3.5,0.75 ) 1493);vec3 shadowDebug{X}; 1494#endif 1495#ifdef SHADOWCSMUSESHADOWMAXZ{X} 1496int index{X}=-1; 1497#else 1498int index{X}=SHADOWCSMNUM_CASCADES{X}-1; 1499#endif 1500float diff{X}=0.; 1501#elif defined(SHADOWCUBE{X}) 1502uniform samplerCube shadowTexture{X}; 1503#else 1504varying vec4 vPositionFromLight{X};varying float vDepthMetric{X}; 1505#if defined(SHADOWPCSS{X}) 1506uniform highp sampler2DShadow shadowTexture{X};uniform highp sampler2D depthTexture{X}; 1507#elif defined(SHADOWPCF{X}) 1508uniform highp sampler2DShadow shadowTexture{X}; 1509#else 1510uniform sampler2D shadowTexture{X}; 1511#endif 1512uniform mat4 lightMatrix{X}; 1513#endif 1514#endif 1515#endif 1516`;de.IncludesShadersStore[LE]||(de.IncludesShadersStore[LE]=Rz);const NE="ltcHelperFunctions",Mz=`vec2 LTCUv( const in vec3 N,const in vec3 V,const in float roughness ) {const float LUTSIZE=64.0;const float LUTSCALE=( LUTSIZE-1.0 )/LUTSIZE;const float LUTBIAS=0.5/LUTSIZE;float dotNV=saturate( dot( N,V ) );vec2 uv=vec2( roughness,sqrt( 1.0-dotNV ) );uv=uv*LUTSCALE+LUTBIAS;return uv;} 1517float LTCClippedSphereFormFactor( const in vec3 f ) {float l=length( f );return max( ( l*l+f.z )/( l+1.0 ),0.0 );} 1518vec3 LTCEdgeVectorFormFactor( const in vec3 v1,const in vec3 v2 ) {float x=dot( v1,v2 );float y=abs( x );float a=0.8543985+( 0.4965155+0.0145206*y )*y;float b=3.4175940+( 4.1616724+y )*y;float v=a/b;float thetaSintheta=0.0;if( x>0.0 ) 1519{thetaSintheta=v;} 1520else 1521{thetaSintheta=0.5*inversesqrt( max( 1.0-x*x,1e-7 ) )-v;} 1522return cross( v1,v2 )*thetaSintheta;} 1523vec3 LTCEvaluate( const in vec3 N,const in vec3 V,const in vec3 P,const in mat3 mInv,const in vec3 rectCoords[ 4 ] ) {vec3 v1=rectCoords[ 1 ]-rectCoords[ 0 ];vec3 v2=rectCoords[ 3 ]-rectCoords[ 0 ];vec3 lightNormal=cross( v1,v2 );if( dot( lightNormal,P-rectCoords[ 0 ] )<0.0 ) return vec3( 0.0 );vec3 T1,T2;T1=normalize( V-N*dot( V,N ) );T2=- cross( N,T1 ); 1524mat3 mat=mInv*transposeMat3( mat3( T1,T2,N ) );vec3 coords[ 4 ];coords[ 0 ]=mat*( rectCoords[ 0 ]-P );coords[ 1 ]=mat*( rectCoords[ 1 ]-P );coords[ 2 ]=mat*( rectCoords[ 2 ]-P );coords[ 3 ]=mat*( rectCoords[ 3 ]-P );coords[ 0 ]=normalize( coords[ 0 ] );coords[ 1 ]=normalize( coords[ 1 ] );coords[ 2 ]=normalize( coords[ 2 ] );coords[ 3 ]=normalize( coords[ 3 ] );vec3 vectorFormFactor=vec3( 0.0 );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 0 ],coords[ 1 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 1 ],coords[ 2 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 2 ],coords[ 3 ] );vectorFormFactor+=LTCEdgeVectorFormFactor( coords[ 3 ],coords[ 0 ] );float result=LTCClippedSphereFormFactor( vectorFormFactor );return vec3( result );} 1525struct areaLightData 1526{vec3 Diffuse;vec3 Specular;vec4 Fresnel;}; 1527#define inline 1528areaLightData computeAreaLightSpecularDiffuseFresnel(const in sampler2D ltc1,const in sampler2D ltc2,const in vec3 viewDir,const in vec3 normal,const in vec3 position,const in vec3 lightPos,const in vec3 halfWidth,const in vec3 halfHeight,const in float roughness) 1529{areaLightData result;vec3 rectCoords[ 4 ];rectCoords[ 0 ]=lightPos+halfWidth-halfHeight; 1530rectCoords[ 1 ]=lightPos-halfWidth-halfHeight;
1530rectCoords[ 2 ]=lightPos-halfWidth+halfHeight;rectCoords[ 3 ]=lightPos+halfWidth+halfHeight; 1531#ifdef SPECULARTERM 1532vec2 uv=LTCUv( normal,viewDir,roughness );vec4 t1=texture2D( ltc1,uv );vec4 t2=texture2D( ltc2,uv );mat3 mInv=mat3( 1533vec3( t1.x,0,t1.y ), 1534vec3( 0,1, 0 ), 1535vec3( t1.z,0,t1.w ) 1536);result.Specular=LTCEvaluate( normal,viewDir,position,mInv,rectCoords );result.Fresnel=t2; 1537#endif 1538result.Diffuse=LTCEvaluate( normal,viewDir,position,mat3( 1.0 ),rectCoords );return result;}`;de.IncludesShadersStore[NE]||(de.IncludesShadersStore[NE]=Mz);const BE="clusteredLightingFunctions",Cz=`struct ClusteredLight {vec4 vLightData;vec4 vLightDiffuse;vec4 vLightSpecular;vec4 vLightDirection;vec4 vLightFalloff;}; 1539#define inline 1540ClusteredLight getClusteredLight(sampler2D lightDataTexture,int index) {return ClusteredLight( 1541texelFetch(lightDataTexture,ivec2(0,index),0), 1542texelFetch(lightDataTexture,ivec2(1,index),0), 1543texelFetch(lightDataTexture,ivec2(2,index),0), 1544texelFetch(lightDataTexture,ivec2(3,index),0), 1545texelFetch(lightDataTexture,ivec2(4,index),0) 1546);} 1547int getClusteredSliceIndex(vec2 sliceData,float viewDepth) {return int(log(viewDepth)*sliceData.x+sliceData.y);} 1548`;de.IncludesShadersStore[BE]||(de.IncludesShadersStore[BE]=Cz);const UE="lightsFragmentFunctions",Iz=`struct lightingInfo 1549{vec3 diffuse; 1550#ifdef SPECULARTERM 1551vec3 specular; 1552#endif 1553#ifdef NDOTL 1554float ndl; 1555#endif 1556};lightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {lightingInfo result;vec3 lightVectorW;float attenuation=1.0;if (lightData.w==0.) 1557{vec3 direction=lightData.xyz-vPositionW;attenuation=max(0.,1.0-length(direction)/range);lightVectorW=normalize(direction);} 1558else 1559{lightVectorW=normalize(-lightData.xyz);} 1560float ndl=max(0.,dot(vNormal,lightVectorW)); 1561#ifdef NDOTL 1562result.ndl=ndl; 1563#endif 1564result.diffuse=ndl*diffuseColor*attenuation; 1565#ifdef SPECULARTERM 1566vec3 angleW=normalize(viewDirectionW+lightVectorW);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation; 1567#endif 1568return result;} 1569float getAttenuation(float cosAngle,float exponent) {return max(0.,pow(cosAngle,exponent));} 1570float getIESAttenuation(float cosAngle,sampler2D iesLightSampler) {float angle=acos(cosAngle)/PI;return texture2D(iesLightSampler,vec2(angle,0.)).r;} 1571lightingInfo basicSpotLighting(vec3 viewDirectionW,vec3 lightVectorW,vec3 vNormal,float attenuation,vec3 diffuseColor,vec3 specularColor,float glossiness) {lightingInfo result; 1572float ndl=max(0.,dot(vNormal,lightVectorW)); 1573#ifdef NDOTL 1574result.ndl=ndl; 1575#endif 1576result.diffuse=ndl*diffuseColor*attenuation; 1577#ifdef SPECULARTERM 1578vec3 angleW=normalize(viewDirectionW+lightVectorW);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor*attenuation; 1579#endif 1580return result;} 1581lightingInfo computeIESSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness,sampler2D iesLightSampler) { 1582vec3 direction=lightData.xyz-vPositionW;vec3 lightVectorW=normalize(direction);float attenuation=max(0.,1.0-length(direction)/range);float dotProduct=dot(lightDirection.xyz,-lightVectorW);float cosAngle=max(0.,dotProduct);if (cosAngle>=lightDirection.w) 1583{ 1584attenuation*=getIESAttenuation(dotProduct,iesLightSampler);return basicSpotLighting(viewDirectionW,lightVectorW,vNormal,attenuation,diffuseColor,specularColor,glossiness);} 1585lightingInfo result;result.diffuse=vec3(0.); 1586#ifdef SPECULARTERM 1587result.specular=vec3(0.); 1588#endif 1589#ifdef NDOTL 1590result.ndl=0.; 1591#endif 1592return result;} 1593lightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {vec3 direction=lightData.xyz-vPositionW;vec3 lightVectorW=normalize(direction);float attenuation=max(0.,1.0-length(direction)/range);float cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));if (cosAngle>=lightDirection.w) 1594{ 1595attenuation*=getAttenuation(cosAngle,lightData.w);return basicSpotLighting(viewDirectionW,lightVectorW,vNormal,attenuation,diffuseColor,specularColor,glossiness);} 1596lightingInfo result;result.diffuse=vec3(0.); 1597#ifdef SPECULARTERM 1598result.specular=vec3(0.); 1599#endif 1600#ifdef NDOTL 1601result.ndl=0.; 1602#endif 1603return result;} 1604lightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {lightingInfo result;float ndl=dot(vNormal,lightData.xyz)*0.5+0.5; 1605#ifdef NDOTL 1606result.ndl=ndl; 1607#endif 1608result.diffuse=mix(groundColor,diffuseColor,ndl); 1609#ifdef SPECULARTERM 1610vec3 angleW=normalize(viewDirectionW+lightData.xyz);float specComp=max(0.,dot(vNormal,angleW));specComp=pow(specComp,max(1.,glossiness));result.specular=specComp*specularColor; 1611#endif 1612return result;} 1613#define inline 1614vec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix,vec3 posW){vec4 strq=textureProjectionMatrix*vec4(posW,1.0);strq/=strq.w;vec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;return textureColor;} 1615#if defined(AREALIGHTUSED) && defined(AREALIGHTSUPPORTED) 1616#include<ltcHelperFunctions> 1617uniform sampler2D areaLightsLTC1Sampler;uniform sampler2D areaLightsLTC2Sampler; 1618#define inline 1619lightingInfo computeAreaLighting(sampler2D ltc1,sampler2D ltc2,vec3 viewDirectionW,vec3 vNormal,vec3 vPosition,vec3 lightPosition,vec3 halfWidth,vec3 halfHeight,vec3 diffuseColor,vec3 specularColor,float roughness) 1620{lightingInfo result;areaLightData data=computeAreaLightSpecularDiffuseFresnel(ltc1,ltc2,viewDirectionW,vNormal,vPosition,lightPosition,halfWidth,halfHeight,roughness); 1621#ifdef SPECULARTERM 1622vec3 fresnel=( specularColor*data.Fresnel.x+( vec3( 1.0 )-specularColor )*data.Fresnel.y );result.specular+=specularColor*fresnel*data.Specular; 1623#endif 1624result.diffuse+=diffuseColor*data.Diffuse;return result;} 1625#endif 1626#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 1627#include<clusteredLightingFunctions> 1628#define inline 1629lightingInfo computeClusteredLighting( 1630sampler2D lightDataTexture, 1631sampler2D tileMaskTexture, 1632vec3 viewDirectionW, 1633vec3 vNormal, 1634vec4 lightData, 1635ivec2 sliceRange, 1636float glossiness 1637) {lightingInfo result;ivec2 tilePosition=ivec2(gl_FragCoord.xy*lightData.xy);int maskHeight=int(lightData.z);tilePosition.y=min(tilePosition.y,maskHeight-1);ivec2 batchRange=sliceRange/CLUSTLIGHT_BATCH;int batchOffset=batchRange.x*CLUSTLIGHT_BATCH;tilePosition.y+=maskHeight*batchRange.x;for (int i=batchRange.x; i<=batchRange.y; i+=1) {uint mask=uint(texelFetch(tileMaskTexture,tilePosition,0).r);tilePosition.y+=maskHeight;int maskOffset=max(sliceRange.x-batchOffset,0);int maskWidth=min(sliceRange.y-batchOffset+1,CLUSTLIGHT_BATCH);mask=extractBits(mask,maskOffset,maskWidth);while (mask != 0u) {uint bit=mask & -mask;mask ^= bit;int position=onlyBitPosition(bit);ClusteredLight light=getClusteredLight(lightDataTexture,batchOffset+maskOffset+position);lightingInfo info;if (light.vLightDirection.w<0.0) {info=computeLighting(viewDirectionW,vNormal,light.vLightData,light.vLightDiffuse.rgb,light.vLightSpecular.rgb,light.vLightDiffuse.a,glossiness);} else {info=computeSpotLighting(viewDirectionW,vNormal,light.vLightData,light.vLightDirection,light.vLightDiffuse.rgb,light.vLightSpecular.rgb,light.vLightDiffuse.a,glossiness);} 1638result.diffuse+=info.diffuse; 1639#ifdef SPECULARTERM 1640result.specular+=info.specular; 1641#endif 1642} 1643batchOffset+=CLUSTLIGHT_BATCH;} 1644return result;} 1645#endif 1646`;de.IncludesShadersStore[UE]||(de.IncludesShadersStore[UE]=Iz);const kE="shadowsFragmentFunctions",Pz
vendor: 8,264 bytes, lines 1646-1759
1646=`#ifdef SHADOWS 1647#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE) 1648#define TEXTUREFUNC(s,c,l) texture2DLodEXT(s,c,l) 1649#else 1650#define TEXTUREFUNC(s,c,b) texture2D(s,c,b) 1651#endif 1652#ifndef SHADOWFLOAT 1653float unpack(vec4 color) 1654{const vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(color,bit_shift);} 1655#endif 1656float computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff) 1657{float mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));return mix(value,1.0,mask);} 1658#define inline 1659float computeShadowCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues) 1660{vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y; 1661#ifndef SHADOWFLOAT 1662float shadow=unpack(textureCube(shadowSampler,directionToLight)); 1663#else 1664float shadow=textureCube(shadowSampler,directionToLight).x; 1665#endif 1666return depth>shadow ? darkness : 1.0;} 1667#define inline 1668float computeShadowWithPoissonSamplingCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues) 1669{vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;float visibility=1.;vec3 poissonDisk[4];poissonDisk[0]=vec3(-1.0,1.0,-1.0);poissonDisk[1]=vec3(1.0,-1.0,-1.0);poissonDisk[2]=vec3(-1.0,-1.0,-1.0);poissonDisk[3]=vec3(1.0,-1.0,1.0); 1670#ifndef SHADOWFLOAT 1671if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;if (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25; 1672#else 1673if (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;if (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;if (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;if (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25; 1674#endif 1675return min(1.0,visibility+darkness);} 1676#define inline 1677float computeShadowWithESMCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues) 1678{vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);float shadowPixelDepth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y; 1679#ifndef SHADOWFLOAT 1680float shadowMapSample=unpack(textureCube(shadowSampler,directionToLight)); 1681#else 1682float shadowMapSample=textureCube(shadowSampler,directionToLight).x; 1683#endif 1684float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return esm;} 1685#define inline 1686float computeShadowWithCloseESMCube(vec3 worldPos,vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues) 1687{vec3 directionToLight=worldPos-lightPosition;float depth=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);float shadowPixelDepth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y; 1688#ifndef SHADOWFLOAT 1689float shadowMapSample=unpack(textureCube(shadowSampler,directionToLight)); 1690#else 1691float shadowMapSample=textureCube(shadowSampler,directionToLight).x; 1692#endif 1693float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return esm;} 1694#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE) 1695#define inline 1696float computeShadowCSM(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray shadowSampler,float darkness,float frustumEdgeFalloff) 1697{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);vec3 uvLayer=vec3(uv.x,uv.y,layer);float shadowPixelDepth=clamp(depthMetric,0.,1.0); 1698#ifndef SHADOWFLOAT 1699float shadow=unpack(texture2D(shadowSampler,uvLayer)); 1700#else 1701float shadow=texture2D(shadowSampler,uvLayer).x; 1702#endif 1703return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;} 1704#endif 1705#define inline 1706float computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff) 1707{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0) 1708{return 1.0;} 1709else 1710{float shadowPixelDepth=clamp(depthMetric,0.,1.0); 1711#ifndef SHADOWFLOAT 1712float shadow=unpack(TEXTUREFUNC(shadowSampler,uv,0.)); 1713#else 1714float shadow=TEXTUREFUNC(shadowSampler,uv,0.).x; 1715#endif 1716return shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;}} 1717#define inline 1718float computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff) 1719{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0) 1720{return 1.0;} 1721else 1722{float shadowPixelDepth=clamp(depthMetric,0.,1.0);float visibility=1.;vec2 poissonDisk[4];poissonDisk[0]=vec2(-0.94201624,-0.39906216);poissonDisk[1]=vec2(0.94558609,-0.76890725);poissonDisk[2]=vec2(-0.094184101,-0.92938870);poissonDisk[3]=vec2(0.34495938,0.29387760); 1723#ifndef SHADOWFLOAT 1724if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[0]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[1]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[2]*mapSize,0.))<shadowPixelDepth) visibility-=0.25;if (unpack(TEXTUREFUNC(shadowSampler,uv+poissonDisk[3]*mapSize,0.))<shadowPixelDepth) visibility-=0.25; 1725#else 1726if (TEXTUREFUNC(shadowSampler,uv+poissonDisk[0]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;if (TEXTUREFUNC(shadowSampler,uv+poissonDisk[1]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;if (TEXTUREFUNC(shadowSampler,uv+poissonDisk[2]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25;if (TEXTUREFUNC(shadowSampler,uv+poissonDisk[3]*mapSize,0.).x<shadowPixelDepth) visibility-=0.25; 1727#endif 1728return computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);}} 1729#define inline 1730float computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff) 1731{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0) 1732{return 1.0;} 1733else 1734{float shadowPixelDepth=clamp(depthMetric,0.,1.0); 1735#ifndef SHADOWFLOAT 1736float shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.)); 1737#else 1738float shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x; 1739#endif 1740float esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}} 1741#define inline 1742float computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff) 1743{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec2 uv=0.5*clipSpace.xy+vec2(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0) 1744{return 1.0;} 1745else 1746{float shadowPixelDepth=clamp(depthMetric,0.,1.0); 1747#ifndef SHADOWFLOAT 1748float shadowMapSample=unpack(TEXTUREFUNC(shadowSampler,uv,0.)); 1749#else 1750float shadowMapSample=TEXTUREFUNC(shadowSampler,uv,0.).x; 1751#endif 1752float esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}} 1753#ifdef IS_NDC_HALF_ZRANGE 1754#define ZINCLIP clipSpace.z 1755#else 1756#define ZINCLIP uvDepth.z 1757#endif 1758#if defined(WEBGL2) || defined(WEBGPU) || defined(NATIVE) 1759#define
1759SMALLEST_ABOVE_ZERO 1.1754943508e-38 1760#define GREATEST_LESS_THAN_ONE 0.99999994 1761#define DISABLE_UNIFORMITY_ANALYSIS 1762#define inline 1763float computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff) 1764{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5)); 1765#ifdef USE_REVERSE_DEPTHBUFFER 1766uvDepth.z=clamp(ZINCLIP,SMALLEST_ABOVE_ZERO,1.); 1767#else 1768uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE); 1769#endif 1770vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);float shadow=texture2D(shadowSampler,uvDepthLayer);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);} 1771#define inline 1772float computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff) 1773{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5)); 1774#ifdef USE_REVERSE_DEPTHBUFFER 1775uvDepth.z=clamp(ZINCLIP,SMALLEST_ABOVE_ZERO,1.); 1776#else 1777uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE); 1778#endif 1779vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; 1780uv+=0.5; 1781vec2 st=fract(uv); 1782vec2 base_uv=floor(uv)-0.5; 1783base_uv*=shadowMapSizeAndInverse.y; 1784vec2 uvw0=3.-2.*st;vec2 uvw1=1.+2.*st;vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);} 1785#define inline 1786float computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff) 1787{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5)); 1788#ifdef USE_REVERSE_DEPTHBUFFER 1789uvDepth.z=clamp(ZINCLIP,SMALLEST_ABOVE_ZERO,1.); 1790#else 1791uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE); 1792#endif
vendor: 8,597 bytes, lines 1793-1957
1793vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; 1794uv+=0.5; 1795vec2 st=fract(uv); 1796vec2 base_uv=floor(uv)-0.5; 1797base_uv*=shadowMapSizeAndInverse.y; 1798vec2 uvw0=4.-3.*st;vec2 uvw1=vec2(7.);vec2 uvw2=1.+3.*st;vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));shadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));shadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));shadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));shadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));shadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));shadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));shadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));shadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);} 1799#define inline 1800float computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff) 1801{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;} 1802else 1803{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;float shadow=TEXTUREFUNC(shadowSampler,uvDepth,0.);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}} 1804#define inline 1805float computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff) 1806{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;} 1807else 1808{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; 1809uv+=0.5; 1810vec2 st=fract(uv); 1811vec2 base_uv=floor(uv)-0.5; 1812base_uv*=shadowMapSizeAndInverse.y; 1813vec2 uvw0=3.-2.*st;vec2 uvw1=1.+2.*st;vec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;vec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z),0.);shadow+=uvw1.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z),0.);shadow+=uvw0.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z),0.);shadow+=uvw1.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z),0.);shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}} 1814#define inline 1815float computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,highp sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff) 1816{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;} 1817else 1818{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;vec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; 1819uv+=0.5; 1820vec2 st=fract(uv); 1821vec2 base_uv=floor(uv)-0.5; 1822base_uv*=shadowMapSizeAndInverse.y; 1823vec2 uvw0=4.-3.*st;vec2 uvw1=vec2(7.);vec2 uvw2=1.+3.*st;vec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;vec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;float shadow=0.;shadow+=uvw0.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z),0.);shadow+=uvw1.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z),0.);shadow+=uvw2.x*uvw0.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z),0.);shadow+=uvw0.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z),0.);shadow+=uvw1.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z),0.);shadow+=uvw2.x*uvw1.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z),0.);shadow+=uvw0.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z),0.);shadow+=uvw1.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z),0.);shadow+=uvw2.x*uvw2.y*TEXTUREFUNC(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z),0.);shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}} 1824const vec3 PoissonSamplers32[64]=vec3[64]( 1825vec3(0.06407013,0.05409927,0.), 1826vec3(0.7366577,0.5789394,0.), 1827vec3(-0.6270542,-0.5320278,0.), 1828vec3(-0.4096107,0.8411095,0.), 1829vec3(0.6849564,-0.4990818,0.), 1830vec3(-0.874181,-0.04579735,0.), 1831vec3(0.9989998,0.0009880066,0.), 1832vec3(-0.004920578,-0.9151649,0.), 1833vec3(0.1805763,0.9747483,0.), 1834vec3(-0.2138451,0.2635818,0.), 1835vec3(0.109845,0.3884785,0.), 1836vec3(0.06876755,-0.3581074,0.), 1837vec3(0.374073,-0.7661266,0.), 1838vec3(0.3079132,-0.1216763,0.), 1839vec3(-0.3794335,-0.8271583,0.), 1840vec3(-0.203878,-0.07715034,0.), 1841vec3(0.5912697,0.1469799,0.), 1842vec3(-0.88069,0.3031784,0.), 1843vec3(0.5040108,0.8283722,0.), 1844vec3(-0.5844124,0.5494877,0.), 1845vec3(0.6017799,-0.1726654,0.), 1846vec3(-0.5554981,0.1559997,0.), 1847vec3(-0.3016369,-0.3900928,0.), 1848vec3(-0.5550632,-0.1723762,0.), 1849vec3(0.925029,0.2995041,0.), 1850vec3(-0.2473137,0.5538505,0.), 1851vec3(0.9183037,-0.2862392,0.), 1852vec3(0.2469421,0.6718712,0.), 1853vec3(0.3916397,-0.4328209,0.), 1854vec3(-0.03576927,-0.6220032,0.), 1855vec3(-0.04661255,0.7995201,0.), 1856vec3(0.4402924,0.3640312,0.), 1857vec3(0.), 1858vec3(0.), 1859vec3(0.), 1860vec3(0.), 1861vec3(0.), 1862vec3(0.), 1863vec3(0.), 1864vec3(0.), 1865vec3(0.), 1866vec3(0.), 1867vec3(0.), 1868vec3(0.), 1869vec3(0.), 1870vec3(0.), 1871vec3(0.), 1872vec3(0.), 1873vec3(0.), 1874vec3(0.), 1875vec3(0.), 1876vec3(0.), 1877vec3(0.), 1878vec3(0.), 1879vec3(0.), 1880vec3(0.), 1881vec3(0.), 1882vec3(0.), 1883vec3(0.), 1884vec3(0.), 1885vec3(0.), 1886vec3(0.), 1887vec3(0.), 1888vec3(0.) 1889);const vec3 PoissonSamplers64[64]=vec3[64]( 1890vec3(-0.613392,0.617481,0.), 1891vec3(0.170019,-0.040254,0.), 1892vec3(-0.299417,0.791925,0.), 1893vec3(0.645680,0.493210,0.), 1894vec3(-0.651784,0.717887,0.), 1895vec3(0.421003,0.027070,0.), 1896vec3(-0.817194,-0.271096,0.), 1897vec3(-0.705374,-0.668203,0.), 1898vec3(0.977050,-0.108615,0.), 1899vec3(0.063326,0.142369,0.), 1900vec3(0.203528,0.214331,0.), 1901vec3(-0.667531,0.326090,0.), 1902vec3(-0.098422,-0.295755,0.), 1903vec3(-0.885922,0.215369,0.), 1904vec3(0.566637,0.605213,0.), 1905vec3(0.039766,-0.396100,0.), 1906vec3(0.751946,0.453352,0.), 1907vec3(0.078707,-0.715323,0.), 1908vec3(-0.075838,-0.529344,0.), 1909vec3(0.724479,-0.580798,0.), 1910vec3(0.222999,-0.215125,0.), 1911vec3(-0.467574,-0.405438,0.), 1912vec3(-0.248268,-0.814753,0.), 1913vec3(0.354411,-0.887570,0.), 1914vec3(0.175817,0.382366,0.), 1915vec3(0.487472,-0.063082,0.), 1916vec3(-0.084078,0.898312,0.), 1917vec3(0.488876,-0.783441,0.), 1918vec3(0.470016,0.217933,0.), 1919vec3(-0.696890,-0.549791,0.), 1920vec3(-0.149693,0.605762,0.), 1921vec3(0.034211,0.979980,0.), 1922vec3(0.503098,-0.308878,0.), 1923vec3(-0.016205,-0.872921,0.), 1924vec3(0.385784,-0.393902,0.), 1925vec3(-0.146886,-0.859249,0.), 1926vec3(0.643361,0.164098,0.), 1927vec3(0.634388,-0.049471,0.), 1928vec3(-0.688894,0.007843,0.), 1929vec3(0.464034,-0.188818,0.), 1930vec3(-0.440840,0.137486,0.), 1931vec3(0.364483,0.511704,0.), 1932vec3(0.034028,0.325968,0.), 1933vec3(0.099094,-0.308023,0.), 1934vec3(0.693960,-0.366253,0.), 1935vec3(0.678884,-0.204688,0.), 1936vec3(0.001801,0.780328,0.), 1937vec3(0.145177,-0.898984,0.), 1938vec3(0.062655,-0.611866,0.), 1939vec3(0.315226,-0.604297,0.), 1940vec3(-0.780145,0.486251,0.), 1941vec3(-0.371868,0.882138,0.), 1942vec3(0.200476,0.494430,0.), 1943vec3(-0.494552,-0.711051,0.), 1944vec3(0.612476,0.705252,0.), 1945vec3(-0.578845,-0.768792,0.), 1946vec3(-0.772454,-0.090976,0.), 1947vec3(0.504440,0.372295,0.), 1948vec3(0.155736,0.065157,0.), 1949vec3(0.391522,0.849605,0.), 1950vec3(-0.620106,-0.328104,0.), 1951vec3(0.789239,-0.419965,0.), 1952vec3(-0.545396,0.538133,0.), 1953vec3(-0.178564,-0.596057,0.) 1954); 1955#define inline 1956float computeShadowWithCSMPCSS(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness) 1957{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));
1957 1958#ifdef USE_REVERSE_DEPTHBUFFER 1959uvDepth.z=clamp(ZINCLIP,SMALLEST_ABOVE_ZERO,1.); 1960#else 1961uvDepth.z=clamp(ZINCLIP,0.,GREATEST_LESS_THAN_ONE); 1962#endif 1963vec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);float blockerDepth=0.0;float sumBlockerDepth=0.0;float numBlocker=0.0;for (int i=0; i<searchTapCount; i ++) {blockerDepth=texture2D(depthSampler,vec3(uvDepth.xy+(lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse*PoissonSamplers32[i].xy),layer)).r;if (blockerDepth<depthMetric) {sumBlockerDepth+=blockerDepth;numBlocker++;}} 1964float avgBlockerDepth=sumBlockerDepth/numBlocker;float AAOffset=shadowMapSizeInverse*10.;float penumbraRatio=((depthMetric-avgBlockerDepth)*depthCorrection+AAOffset);vec4 filterRadius=vec4(penumbraRatio*lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse,0.,0.);float random=getRand(vPositionFromLight.xy);float rotationAngle=random*3.1415926;vec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));float shadow=0.;for (int i=0; i<pcfTapCount; i++) {vec4 offset=vec4(poissonSamplers[i],0.);offset=vec4(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.,0.);shadow+=texture2D(shadowSampler,uvDepthLayer+offset*filterRadius);} 1965shadow/=float(pcfTapCount);shadow=mix(shadow,1.,min((depthMetric-avgBlockerDepth)*depthCorrection*penumbraDarkness,1.));shadow=mix(darkness,1.,shadow);if (numBlocker<1.0) {return 1.0;} 1966else 1967{return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}} 1968#define inline 1969float computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers) 1970{if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;} 1971else 1972{vec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;vec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));uvDepth.z=ZINCLIP;float blockerDepth=0.0;float sumBlockerDepth=0.0;float numBlocker=0.0;for (int i=0; i<searchTapCount; i ++) {blockerDepth=TEXTUREFUNC(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy),0.).r;if (blockerDepth<depthMetric) {sumBlockerDepth+=blockerDepth;numBlocker++;}} 1973if (numBlocker<1.0) {return 1.0;} 1974else 1975{float avgBlockerDepth=sumBlockerDepth/numBlocker;float AAOffset=shadowMapSizeInverse*10.;float penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);float filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;float random=getRand(vPositionFromLight.xy);float rotationAngle=random*3.1415926;vec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));float shadow=0.;for (int i=0; i<pcfTapCount; i++) {vec3 offset=poissonSamplers[i];offset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);shadow+=TEXTUREFUNC(shadowSampler,uvDepth+offset*filterRadius,0.);} 1976shadow/=float(pcfTapCount);shadow=mix(shadow,1.,depthMetric-avgBlockerDepth);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}} 1977#define inline 1978float computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff) 1979{return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);} 1980#define inline 1981float computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff) 1982{return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);} 1983#define inline 1984float computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,highp sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff) 1985{return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);} 1986#define inline
1987float computeShadowWithCSMPCSS16(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness) 1988{return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);} 1989#define inline 1990float computeShadowWithCSMPCSS32(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness) 1991{return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);} 1992#define inline 1993float computeShadowWithCSMPCSS64(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness) 1994{return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64,lightSizeUVCorrection,depthCorrection,penumbraDarkness);} 1995#endif 1996#endif 1997`;de.IncludesShadersStore[kE]||(de.IncludesShadersStore[kE]=Pz);const VE="samplerFragmentDeclaration",Dz=`#ifdef _DEFINENAME_ 1998#if _DEFINENAME_DIRECTUV==1 1999#define v_VARYINGNAME_UV vMainUV1 2000#elif _DEFINENAME_DIRECTUV==2 2001#define v_VARYINGNAME_UV vMainUV2 2002#elif _DEFINENAME_DIRECTUV==3 2003#define v_VARYINGNAME_UV vMainUV3 2004#elif _DEFINENAME_DIRECTUV==4 2005#define v_VARYINGNAME_UV vMainUV4 2006#elif _DEFINENAME_DIRECTUV==5 2007#define v_VARYINGNAME_UV vMainUV5 2008#elif _DEFINENAME_DIRECTUV==6 2009#define v_VARYINGNAME_UV vMainUV6 2010#else 2011varying vec2 v_VARYINGNAME_UV; 2012#endif 2013uniform sampler2D _SAMPLERNAME_Sampler; 2014#endif 2015`;de.IncludesShadersStore[VE]||(de.IncludesShadersStore[VE]=Dz);const zE="fresnelFunction",Oz=`#ifdef FRESNEL 2016float computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power) 2017{float fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power);return clamp(fresnelTerm,0.,1.);} 2018#endif 2019`;de.IncludesShadersStore[zE]||(de.IncludesShadersStore[zE]=Oz);const GE="reflectionFunction",wz=`vec3 computeFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction) 2020{float lon=atan(direction.z,direction.x);float lat=acos(direction.y);vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;float s=sphereCoords.x*0.5+0.5;float t=sphereCoords.y;return vec3(s,t,0); } 2021vec3 computeMirroredFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction) 2022{float lon=atan(direction.z,direction.x);float lat=acos(direction.y);vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;float s=sphereCoords.x*0.5+0.5;float t=sphereCoords.y;return vec3(1.0-s,t,0); } 2023vec3 computeEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix) 2024{vec3 cameraToVertex=normalize(worldPos.xyz-eyePosition);vec3 r=normalize(reflect(cameraToVertex,worldNormal));r=vec3(reflectionMatrix*vec4(r,0));float lon=atan(r.z,r.x);float lat=acos(r.y);vec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;float s=sphereCoords.x*0.5+0.5;float t=sphereCoords.y;return vec3(s,t,0);} 2025vec3 computeSphericalCoords(vec4 worldPos,vec3 worldNormal,mat4 view,mat4 reflectionMatrix) 2026{vec3 viewDir=normalize(vec3(view*worldPos));vec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));vec3 r=reflect(viewDir,viewNormal);r=vec3(reflectionMatrix*vec4(r,0));r.z=r.z-1.0;float m=2.0*length(r);return vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);} 2027vec3 computePlanarCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix) 2028{vec3 viewDir=worldPos.xyz-eyePosition;vec3 coords=normalize(reflect(viewDir,worldNormal));return vec3(reflectionMatrix*vec4(coords,1));} 2029vec3 computeCubicCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix) 2030{vec3 viewDir=normalize(worldPos.xyz-eyePosition);vec3 coords=reflect(viewDir,worldNormal);coords=vec3(reflectionMatrix*vec4(coords,0)); 2031#ifdef INVERTCUBICMAP 2032coords.y*=-1.0; 2033#endif 2034return coords;} 2035vec3 computeCubicLocalCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix,vec3 reflectionSize,vec3 reflectionPosition) 2036{vec3 viewDir=normalize(worldPos.xyz-eyePosition);vec3 coords=reflect(viewDir,worldNormal);coords=parallaxCorrectNormal(worldPos.xyz,coords,reflectionSize,reflectionPosition);coords=vec3(reflectionMatrix*vec4(coords,0)); 2037#ifdef INVERTCUBICMAP 2038coords.y*=-1.0; 2039#endif 2040return coords;} 2041vec3 computeProjectionCoords(vec4 worldPos,mat4 view,mat4 reflectionMatrix) 2042{return vec3(reflectionMatrix*(view*worldPos));} 2043vec3 computeSkyBoxCoords(vec3 positionW,mat4 reflectionMatrix) 2044{return vec3(reflectionMatrix*vec4(positionW,1.));} 2045#ifdef REFLECTION 2046vec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal) 2047{ 2048#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED 2049vec3 direction=normalize(vDirectionW);return computeMirroredFixedEquirectangularCoords(worldPos,worldNormal,direction); 2050#endif 2051#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED 2052vec3 direction=normalize(vDirectionW);return computeFixedEquirectangularCoords(worldPos,worldNormal,direction); 2053#endif 2054#ifdef REFLECTIONMAP_EQUIRECTANGULAR 2055return computeEquirectangularCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix); 2056#endif 2057#ifdef REFLECTIONMAP_SPHERICAL 2058return computeSphericalCoords(worldPos,worldNormal,view,reflectionMatrix); 2059#endif 2060#ifdef REFLECTIONMAP_PLANAR 2061return computePlanarCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix); 2062#endif 2063#ifdef REFLECTIONMAP_CUBIC 2064#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC 2065return computeCubicLocalCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix,vReflectionSize,vReflectionPosition); 2066#else 2067return computeCubicCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix); 2068#endif 2069#endif 2070#ifdef REFLECTIONMAP_PROJECTION 2071return computeProjectionCoords(worldPos,view,reflectionMatrix); 2072#endif 2073#ifdef REFLECTIONMAP_SKYBOX 2074return computeSkyBoxCoords(vPositionUVW,reflectionMatrix); 2075#endif 2076#ifdef REFLECTIONMAP_EXPLICIT 2077return vec3(0,0,0); 2078#endif 2079} 2080#endif 2081`;de.IncludesShadersStore[GE]||(de.IncludesShadersStore[GE]=wz);const HE="imageProcessingDeclaration",Fz=`#ifdef EXPOSURE 2082uniform float exposureLinear; 2083#endif 2084#ifdef CONTRAST 2085uniform float contrast; 2086#endif 2087#if defined(VIGNETTE) || defined(DITHER) 2088uniform vec2 vInverseScreenSize; 2089#endif 2090#ifdef VIGNETTE 2091uniform vec4 vignetteSettings1;uniform vec4 vignetteSettings2; 2092#endif 2093#ifdef COLORCURVES 2094uniform vec4 vCameraColorCurveNegative;uniform vec4 vCameraColorCurveNeutral;uniform vec4 vCameraColorCurvePositive; 2095#endif 2096#ifdef COLORGRADING 2097#ifdef COLORGRADING3D 2098uniform highp sampler3D txColorTransform; 2099#else 2100uniform sampler2D txColorTransform; 2101#endif 2102uniform vec4 colorTransformSettings; 2103#endif 2104#ifdef DITHER 2105uniform float ditherIntensity; 2106#endif 2107`;de.IncludesShadersStore[HE]||(de.IncludesShadersStore[HE]=Fz);const WE="imageProcessingFunctions",Lz=`#if defined(COLORGRADING) && !defined(COLORGRADING3D) 2108/** 2109* Polyfill for SAMPLE_TEXTURE_3D,which is unsupported in WebGL. 2110* sampler3dSetting.x=textureOffset (0.5/textureSize).
2111* sampler3dSetting.y=textureSize. 2112*/ 2113#define inline 2114vec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting) 2115{float sliceSize=2.0*sampler3dSetting.x; 2116#ifdef SAMPLER3DGREENDEPTH 2117float sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y; 2118#else 2119float sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y; 2120#endif 2121float sliceInteger=floor(sliceContinuous);float sliceFraction=sliceContinuous-sliceInteger; 2122#ifdef SAMPLER3DGREENDEPTH 2123vec2 sliceUV=color.rb; 2124#else 2125vec2 sliceUV=color.rg; 2126#endif 2127sliceUV.x*=sliceSize;sliceUV.x+=sliceInteger*sliceSize;sliceUV=saturate(sliceUV);vec4 slice0Color=texture2D(colorTransform,sliceUV);sliceUV.x+=sliceSize;sliceUV=saturate(sliceUV);vec4 slice1Color=texture2D(colorTransform,sliceUV);vec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction); 2128#ifdef SAMPLER3DBGRMAP 2129color.rgb=result.rgb; 2130#else 2131color.rgb=result.bgr; 2132#endif 2133return color;} 2134#endif 2135#if TONEMAPPING==3 2136const float PBRNeutralStartCompression=0.8-0.04;const float PBRNeutralDesaturation=0.15;vec3 PBRNeutralToneMapping( vec3 color ) {float x=min(color.r,min(color.g,color.b));float offset=x<0.08 ? x-6.25*x*x : 0.04;color-=offset;float peak=max(color.r,max(color.g,color.b));if (peak<PBRNeutralStartCompression) return color;float d=1.-PBRNeutralStartCompression;float newPeak=1.-d*d/(peak+d-PBRNeutralStartCompression);color*=newPeak/peak;float g=1.-1./(PBRNeutralDesaturation*(peak-newPeak)+1.);return mix(color,newPeak*vec3(1,1,1),g);} 2137#endif 2138#if TONEMAPPING==2 2139const mat3 ACESInputMat=mat3( 2140vec3(0.59719,0.07600,0.02840), 2141vec3(0.35458,0.90834,0.13383), 2142vec3(0.04823,0.01566,0.83777) 2143);const mat3 ACESOutputMat=mat3( 2144vec3( 1.60475,-0.10208,-0.00327), 2145vec3(-0.53108, 1.10813,-0.07276), 2146vec3(-0.07367,-0.00605, 1.07602) 2147);vec3 RRTAndODTFit(vec3 v) 2148{vec3 a=v*(v+0.0245786)-0.000090537;vec3 b=v*(0.983729*v+0.4329510)+0.238081;return a/b;} 2149vec3 ACESFitted(vec3 color) 2150{color=ACESInputMat*color;color=RRTAndODTFit(color);color=ACESOutputMat*color;color=saturate(color);return color;} 2151#endif 2152#define CUSTOM_IMAGEPROCESSINGFUNCTIONS_DEFINITIONS 2153vec4 applyImageProcessing(vec4 result) { 2154#define CUSTOM_IMAGEPROCESSINGFUNCTIONS_UPDATERESULT_ATSTART 2155#ifdef EXPOSURE 2156result.rgb*=exposureLinear; 2157#endif 2158#ifdef VIGNETTE 2159vec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;viewportXY=viewportXY*2.0-1.0;vec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);float vignetteTerm=dot(vignetteXY1,vignetteXY1);float vignette=pow(vignetteTerm,vignetteSettings2.w);vec3 vignetteColor=vignetteSettings2.rgb; 2160#ifdef VIGNETTEBLENDMODEMULTIPLY 2161vec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);result.rgb*=vignetteColorMultiplier; 2162#endif 2163#ifdef VIGNETTEBLENDMODEOPAQUE 2164result.rgb=mix(vignetteColor,result.rgb,vignette); 2165#endif 2166#endif 2167#if TONEMAPPING==3 2168result.rgb=PBRNeutralToneMapping(result.rgb); 2169#elif TONEMAPPING==2 2170result.rgb=ACESFitted(result.rgb); 2171#elif TONEMAPPING==1 2172const float tonemappingCalibration=1.590579;result.rgb=1.0-exp2(-tonemappingCalibration*result.rgb); 2173#endif 2174result.rgb=toGammaSpace(result.rgb);result.rgb=saturate(result.rgb); 2175#ifdef CONTRAST 2176vec3 resultHighContrast=result.rgb*result.rgb*(3.0-2.0*result.rgb);if (contrast<1.0) {result.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);} else {result.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);} 2177result.rgb=max(result.rgb,0.); 2178#endif 2179#ifdef COLORGRADING 2180vec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy; 2181#ifdef COLORGRADING3D 2182vec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb; 2183#else 2184vec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb; 2185#endif 2186result.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www); 2187#endif 2188#ifdef COLORCURVES 2189float luma=getLuminance(result.rgb);vec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));vec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;result.rgb*=colorCurve.rgb;result.rgb=mix(vec3(luma),result.rgb,colorCurve.a); 2190#endif 2191#ifdef DITHER 2192float rand=getRand(gl_FragCoord.xy*vInverseScreenSize);float dither=mix(-ditherIntensity,ditherIntensity,rand);result.rgb=saturate(result.rgb+vec3(dither)); 2193#endif 2194#define CUSTOM_IMAGEPROCESSINGFUNCTIONS_UPDATERESULT_ATEND 2195return result;}`;de.IncludesShadersStore[WE]||(de.IncludesShadersStore[WE]=Lz);const XE="bumpFragmentMainFunctions",Nz=`#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL) 2196#if defined(TANGENT) && defined(NORMAL) 2197varying mat3 vTBN; 2198#endif 2199#ifdef OBJECTSPACE_NORMALMAP 2200uniform mat4 normalMatrix; 2201#if defined(WEBGL2) || defined(WEBGPU) 2202mat4 toNormalMatrix(mat4 wMatrix) 2203{mat4 ret=inverse(wMatrix);ret=transpose(ret);ret[0][3]=0.;ret[1][3]=0.;ret[2][3]=0.;ret[3]=vec4(0.,0.,0.,1.);return ret;} 2204#else 2205mat4 toNormalMatrix(mat4 m) 2206{float 2207a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3], 2208a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3], 2209a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3], 2210a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3], 2211b00=a00*a11-a01*a10, 2212b01=a00*a12-a02*a10, 2213b02=a00*a13-a03*a10, 2214b03=a01*a12-a02*a11, 2215b04=a01*a13-a03*a11, 2216b05=a02*a13-a03*a12, 2217b06=a20*a31-a21*a30, 2218b07=a20*a32-a22*a30, 2219b08=a20*a33-a23*a30, 2220b09=a21*a32-a22*a31, 2221b10=a21*a33-a23*a31, 2222b11=a22*a33-a23*a32, 2223det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;mat4 mi=mat4( 2224a11*b11-a12*b10+a13*b09, 2225a02*b10-a01*b11-a03*b09, 2226a31*b05-a32*b04+a33*b03,
2227a22*b04-a21*b05-a23*b03, 2228a12*b08-a10*b11-a13*b07, 2229a00*b11-a02*b08+a03*b07, 2230a32*b02-a30*b05-a33*b01, 2231a20*b05-a22*b02+a23*b01, 2232a10*b10-a11*b08+a13*b06, 2233a01*b08-a00*b10-a03*b06, 2234a30*b04-a31*b02+a33*b00, 2235a21*b02-a20*b04-a23*b00, 2236a11*b07-a10*b09-a12*b06, 2237a00*b09-a01*b07+a02*b06, 2238a31*b01-a30*b03-a32*b00, 2239a20*b03-a21*b01+a22*b00)/det;return mat4(mi[0][0],mi[1][0],mi[2][0],mi[3][0], 2240mi[0][1],mi[1][1],mi[2][1],mi[3][1], 2241mi[0][2],mi[1][2],mi[2][2],mi[3][2], 2242mi[0][3],mi[1][3],mi[2][3],mi[3][3]);} 2243#endif 2244#endif 2245vec3 perturbNormalBase(mat3 cotangentFrame,vec3 normal,float scale) 2246{ 2247#ifdef NORMALXYSCALE 2248normal=normalize(normal*vec3(scale,scale,1.0)); 2249#endif 2250return normalize(cotangentFrame*normal);} 2251vec3 perturbNormal(mat3 cotangentFrame,vec3 textureSample,float scale) 2252{return perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);} 2253mat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams) 2254{vec3 dp1=dFdx(p);vec3 dp2=dFdy(p);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;tangent*=tangentSpaceParams.x;bitangent*=tangentSpaceParams.y;float det=max(dot(tangent,tangent),dot(bitangent,bitangent));float invmax=det==0.0 ? 0.0 : inversesqrt(det);return mat3(tangent*invmax,bitangent*invmax,normal);} 2255#endif 2256`;de.IncludesShadersStore[XE]||(de.IncludesShadersStore[XE]=Nz);const jE="bumpFragmentFunctions",Bz=`#if defined(BUMP) 2257#include<samplerFragmentDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump) 2258#endif 2259#if defined(DETAIL) 2260#include<samplerFragmentDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail) 2261#endif 2262#if defined(BUMP) && defined(PARALLAX) 2263const float minSamples=4.;const float maxSamples=15.;const int iMaxSamples=15;vec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {float parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;parallaxLimit*=parallaxScale;vec2 vOffsetDir=normalize(vViewDirCoT.xy);vec2 vMaxOffset=vOffsetDir*parallaxLimit;float numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));float stepSize=1.0/numSamples;float currRayHeight=1.0;vec2 vCurrOffset=vec2(0,0);vec2 vLastOffset=vec2(0,0);float lastSampledHeight=1.0;float currSampledHeight=1.0;bool keepWorking=true;for (int i=0; i<iMaxSamples; i++) 2264{currSampledHeight=texture2D(bumpSampler,texCoord+vCurrOffset).w;if (!keepWorking) 2265{} 2266else if (currSampledHeight>currRayHeight) 2267{float delta1=currSampledHeight-currRayHeight;float delta2=(currRayHeight+stepSize)-lastSampledHeight;float ratio=delta1/(delta1+delta2);vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;keepWorking=false;} 2268else 2269{currRayHeight-=stepSize;vLastOffset=vCurrOffset; 2270#ifdef PARALLAX_RHS 2271vCurrOffset-=stepSize*vMaxOffset; 2272#else 2273vCurrOffset+=stepSize*vMaxOffset; 2274#endif 2275lastSampledHeight=currSampledHeight;}} 2276return vCurrOffset;} 2277vec2 parallaxOffset(vec3 viewDir,float heightScale) 2278{float height=texture2D(bumpSampler,vBumpUV).w;vec2 texCoordOffset=heightScale*viewDir.xy*height; 2279#ifdef PARALLAX_RHS 2280return texCoordOffset; 2281#else 2282return -texCoordOffset; 2283#endif 2284} 2285#endif 2286`;de.IncludesShadersStore[jE]||(de.IncludesShadersStore[jE]=Bz);const YE="fogFragmentDeclaration",Uz=`#ifdef FOG 2287#define FOGMODE_NONE 0. 2288#define FOGMODE_EXP 1. 2289#define FOGMODE_EXP2 2. 2290#define FOGMODE_LINEAR 3. 2291#define E 2.71828 2292uniform vec4 vFogInfos;uniform vec3 vFogColor;varying vec3 vFogDistance;float CalcFogFactor() 2293{float fogCoeff=1.0;float fogStart=vFogInfos.y;float fogEnd=vFogInfos.z;float fogDensity=vFogInfos.w;float fogDistance=length(vFogDistance);if (FOGMODE_LINEAR==vFogInfos.x) 2294{fogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);} 2295else if (FOGMODE_EXP==vFogInfos.x) 2296{fogCoeff=1.0/pow(E,fogDistance*fogDensity);} 2297else if (FOGMODE_EXP2==vFogInfos.x) 2298{fogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);} 2299return clamp(fogCoeff,0.0,1.0);} 2300#endif 2301`;de.IncludesShadersStore[YE]||(de.IncludesShadersStore[YE]=Uz);const KE="bumpFragment",kz=`vec2 uvOffset=vec2(0.0,0.0); 2302#if defined(BUMP) || defined(PARALLAX) || defined(DETAIL) 2303#ifdef NORMALXYSCALE 2304float normalScale=1.0; 2305#elif defined(BUMP) 2306float normalScale=vBumpInfos.y; 2307#else 2308float normalScale=1.0; 2309#endif 2310#if defined(TANGENT) && defined(NORMAL) 2311mat3 TBN=vTBN; 2312#elif defined(BUMP) 2313vec2 TBNUV=gl_FrontFacing ? vBumpUV : -vBumpUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vTangentSpaceParams); 2314#else 2315vec2 TBNUV=gl_FrontFacing ? vDetailUV : -vDetailUV;mat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vec2(1.,1.)); 2316#endif 2317#elif defined(ANISOTROPIC) 2318#if defined(TANGENT) && defined(NORMAL) 2319mat3 TBN=vTBN; 2320#else 2321vec2 TBNUV=gl_FrontFacing ? vMainUV1 : -vMainUV1;mat3 TBN=cotangent_frame(normalW,vPositionW,TBNUV,vec2(1.,1.)); 2322#endif 2323#endif 2324#ifdef PARALLAX 2325mat3 invTBN=transposeMat3(TBN); 2326#ifdef PARALLAXOCCLUSION 2327uvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z); 2328#else 2329uvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z); 2330#endif 2331#endif 2332#ifdef DETAIL 2333vec4 detailColor=texture2D(detailSampler,vDetailUV+uvOffset);vec2 detailNormalRG=detailColor.wy*2.0-1.0;float detailNormalB=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));vec3 detailNormal=vec3(detailNormalRG,detailNormalB); 2334#endif 2335#ifdef BUMP 2336#ifdef OBJECTSPACE_NORMALMAP 2337#define CUSTOM_FRAGMENT_BUMP_FRAGMENT 2338normalW=normalize(texture2D(bumpSampler,vBumpUV).xyz *2.0-1.0);normalW=normalize(mat3(normalMatrix)*normalW); 2339#elif !defined(DETAIL) 2340normalW=perturbNormal(TBN,texture2D(bumpSampler,vBumpUV+uvOffset).xyz,vBumpInfos.y); 2341#else 2342vec3 bumpNormal=texture2D(bumpSampler,vBumpUV+uvOffset).xyz*2.0-1.0; 2343#if DETAIL_NORMALBLENDMETHOD==0 2344detailNormal.xy*=vDetailInfos.z;vec3 blendedNormal=normalize(vec3(bumpNormal.xy+detailNormal.xy,bumpNormal.z*detailNormal.z)); 2345#elif DETAIL_NORMALBLENDMETHOD==1 2346detailNormal.xy*=vDetailInfos.z;bumpNormal+=vec3(0.0,0.0,1.0);detailNormal*=vec3(-1.0,-1.0,1.0);vec3 blendedNormal=bumpNormal*dot(bumpNormal,detailNormal)/bumpNormal.z-detailNormal; 2347#endif 2348normalW=perturbNormalBase(TBN,blendedNormal,vBumpInfos.y); 2349#endif 2350#elif defined(DETAIL) 2351detailNormal.xy*=vDetailInfos.z;normalW=perturbNormalBase(TBN,detailNormal,vDetailInfos.z); 2352#endif 2353`;de.IncludesShadersStore[KE]||(de.IncludesShadersStore[KE]=kz);const qE="decalFragment",Vz=`#ifdef DECAL 2354#ifdef GAMMADECAL 2355decalColor.rgb=toLinearSpace(decalColor.rgb); 2356#endif 2357#ifdef DECAL_SMOOTHALPHA 2358decalColor.a*=decalColor.a; 2359#endif 2360surfaceAlbedo.rgb=mix(surfaceAlbedo.rgb,decalColor.rgb,decalColor.a); 2361#endif 2362`;de.IncludesShadersStore[qE]||(de.IncludesShadersStore[qE]=Vz);const ZE="depthPrePass",zz=`#ifdef DEPTHPREPASS 2363gl_FragColor=vec4(0.,0.,0.,1.0);return; 2364#endif 2365`;de.IncludesShadersStore[ZE]||(de.IncludesShadersStore[ZE]=zz);const $E="lightFragment",Gz=`#ifdef LIGHT{X} 2366#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}) 2367#else 2368vec4 diffuse{X}=light{X}.vLightDiffuse; 2369#define CUSTOM_LIGHT{X}_COLOR 2370#if defined(PBR) && defined(CLUSTLIGHT{X}) && defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 2371{int sliceIndex=min(getClusteredSliceIndex(light{X}.vSliceData,vViewDepth),CLUSTLIGHT_SLICES-1);info=computeClusteredLighting( 2372lightDataTexture{X}, 2373tileMaskTexture{X}, 2374light{X}.vLightData, 2375ivec2(light{X}.vSliceRanges[sliceIndex]), 2376viewDirectionW, 2377normalW, 2378vPositionW, 2379surfaceAlbedo, 2380reflectivityOut 2381#ifdef IRIDESCENCE 2382,iridescenceIntensity 2383#endif 2384#ifdef SS_TRANSLUCENCY 2385,subSurfaceOut 2386#endif 2387#ifdef SPECULARTERM 2388,AARoughnessFactors.x 2389#endif 2390#ifdef ANISOTROPIC 2391,anisotropicOut 2392#endif 2393#ifdef SHEEN 2394,sheenOut 2395#endif 2396#ifdef CLEARCOAT 2397,clearcoatOut 2398#endif 2399);} 2400#elif defined(PBR) 2401#ifdef SPOTLIGHT{X} 2402preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW); 2403#elif defined(POINTLIGHT{X}) 2404preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,vPositionW);
2405#elif defined(HEMILIGHT{X}) 2406preInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW); 2407#elif defined(DIRLIGHT{X}) 2408preInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW); 2409#elif defined(AREALIGHT{X}) && defined(AREALIGHTSUPPORTED) 2410preInfo=computeAreaPreLightingInfo(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,normalW,vPositionW,light{X}.vLightData,light{X}.vLightWidth.xyz,light{X}.vLightHeight.xyz,roughness); 2411#endif 2412preInfo.NdotV=NdotV; 2413#ifdef SPOTLIGHT{X} 2414#ifdef LIGHT_FALLOFF_GLTF{X} 2415preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y); 2416#ifdef IESLIGHTTEXTURE{X} 2417preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X}); 2418#else 2419preInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w); 2420#endif 2421#elif defined(LIGHT_FALLOFF_PHYSICAL{X}) 2422preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared); 2423#ifdef IESLIGHTTEXTURE{X} 2424preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X}); 2425#else 2426preInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w); 2427#endif 2428#elif defined(LIGHT_FALLOFF_STANDARD{X}) 2429preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x); 2430#ifdef IESLIGHTTEXTURE{X} 2431preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X}); 2432#else 2433preInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w); 2434#endif 2435#else 2436preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y); 2437#ifdef IESLIGHTTEXTURE{X} 2438preInfo.attenuation*=computeDirectionalLightFalloff_IES(light{X}.vLightDirection.xyz,preInfo.L,iesLightTexture{X}); 2439#else 2440preInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w); 2441#endif 2442#endif 2443#elif defined(POINTLIGHT{X}) 2444#ifdef LIGHT_FALLOFF_GLTF{X} 2445preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y); 2446#elif defined(LIGHT_FALLOFF_PHYSICAL{X}) 2447preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared); 2448#elif defined(LIGHT_FALLOFF_STANDARD{X}) 2449preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x); 2450#else 2451preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y); 2452#endif 2453#else 2454preInfo.attenuation=1.0; 2455#endif 2456#if defined(HEMILIGHT{X}) || defined(AREALIGHT{X}) 2457preInfo.roughness=roughness; 2458#else 2459preInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance); 2460#endif 2461preInfo.diffuseRoughness=diffuseRoughness;preInfo.surfaceAlbedo=surfaceAlbedo; 2462#ifdef IRIDESCENCE 2463preInfo.iridescenceIntensity=iridescenceIntensity; 2464#endif 2465#ifdef SS_TRANSLUCENCY 2466info.diffuseTransmission=vec3(0.0); 2467#endif 2468#ifdef HEMILIGHT{X} 2469info.diffuse=computeHemisphericDiffuseLighting(preInfo,diffuse{X}.rgb,light{X}.vLightGround); 2470#elif defined(AREALIGHT{X}) 2471info.diffuse=computeAreaDiffuseLighting(preInfo,diffuse{X}.rgb); 2472#elif defined(SS_TRANSLUCENCY) 2473#ifndef SS_TRANSLUCENCY_LEGACY 2474info.diffuse=computeDiffuseLighting(preInfo,diffuse{X}.rgb)*(1.0-subSurfaceOut.translucencyIntensity);info.diffuseTransmission=computeDiffuseTransmittedLighting(preInfo,diffuse{X}.rgb,subSurfaceOut.transmittance); 2475#else 2476info.diffuse=computeDiffuseTransmittedLighting(preInfo,diffuse{X}.rgb,subSurfaceOut.transmittance); 2477#endif 2478#else 2479info.diffuse=computeDiffuseLighting(preInfo,diffuse{X}.rgb); 2480#endif 2481#ifdef SPECULARTERM 2482#if AREALIGHT{X} 2483info.specular=computeAreaSpecularLighting(preInfo,light{X}.vLightSpecular.rgb,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90); 2484#else 2485#if (CONDUCTOR_SPECULAR_MODEL==CONDUCTOR_SPECULAR_MODEL_OPENPBR) 2486{vec3 metalFresnel=reflectivityOut.specularWeight*getF82Specular(preInfo.VdotH,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90,reflectivityOut.roughness);vec3 dielectricFresnel=fresnelSchlickGGX(preInfo.VdotH,reflectivityOut.dielectricColorF0,reflectivityOut.colorReflectanceF90);coloredFresnel=mix(dielectricFresnel,metalFresnel,reflectivityOut.metallic);} 2487#else 2488coloredFresnel=fresnelSchlickGGX(preInfo.VdotH,clearcoatOut.specularEnvironmentR0,reflectivityOut.colorReflectanceF90); 2489#endif 2490#ifndef LEGACY_SPECULAR_ENERGY_CONSERVATION 2491{float NdotH=dot(normalW,preInfo.H);vec3 fresnel=fresnelSchlickGGX(NdotH,vec3(reflectanceF0),specularEnvironmentR90);info.diffuse*=(vec3(1.0)-fresnel);} 2492#endif 2493#ifdef ANISOTROPIC 2494info.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,diffuse{X}.rgb); 2495#else 2496info.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,coloredFresnel,AARoughnessFactors.x,diffuse{X}.rgb); 2497#endif 2498#endif 2499#endif 2500#ifndef AREALIGHT{X} 2501#ifdef SHEEN 2502#ifdef SHEEN_LINKWITHALBEDO 2503preInfo.roughness=sheenOut.sheenIntensity; 2504#else 2505#ifdef HEMILIGHT{X} 2506preInfo.roughness=sheenOut.sheenRoughness; 2507#else 2508preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance); 2509#endif 2510#endif 2511info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,diffuse{X}.rgb); 2512#endif 2513#ifdef CLEARCOAT 2514#ifdef HEMILIGHT{X} 2515preInfo.roughness=clearcoatOut.clearCoatRoughness; 2516#else 2517preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance); 2518#endif 2519info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,diffuse{X}.rgb); 2520#ifdef CLEARCOAT_TINT 2521absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);info.diffuse*=absorption; 2522#ifdef SS_TRANSLUCENCY 2523info.diffuseTransmission*=absorption; 2524#endif 2525#ifdef SPECULARTERM 2526info.specular*=absorption; 2527#endif 2528#endif 2529info.diffuse*=info.clearCoat.w; 2530#ifdef SS_TRANSLUCENCY 2531info.diffuseTransmission*=info.clearCoat.w; 2532#endif 2533#ifdef SPECULARTERM 2534info.specular*=info.clearCoat.w; 2535#endif 2536#ifdef SHEEN 2537info.sheen*=info.clearCoat.w; 2538#endif 2539#endif 2540#endif 2541#else 2542#ifdef SPOTLIGHT{X} 2543#ifdef IESLIGHTTEXTURE{X} 2544info=computeIESSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness,iesLightTexture{X}); 2545#else 2546info=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness); 2547#endif
2548#elif defined(HEMILIGHT{X}) 2549info=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightGround,glossiness); 2550#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X}) 2551info=computeLighting(viewDirectionW,normalW,light{X}.vLightData,diffuse{X}.rgb,light{X}.vLightSpecular.rgb,diffuse{X}.a,glossiness); 2552#elif defined(AREALIGHT{X}) && defined(AREALIGHTSUPPORTED) 2553info=computeAreaLighting(areaLightsLTC1Sampler,areaLightsLTC2Sampler,viewDirectionW,normalW,vPositionW,light{X}.vLightData.xyz,light{X}.vLightWidth.rgb,light{X}.vLightHeight.rgb,diffuse{X}.rgb,light{X}.vLightSpecular.rgb, 2554#ifdef AREALIGHTNOROUGHTNESS 25550.5 2556#else 2557vReflectionInfos.y 2558#endif 2559); 2560#elif defined(CLUSTLIGHT{X}) && CLUSTLIGHT_BATCH>0 2561{int sliceIndex=min(getClusteredSliceIndex(light{X}.vSliceData,vViewDepth),CLUSTLIGHT_SLICES-1);info=computeClusteredLighting(lightDataTexture{X},tileMaskTexture{X},viewDirectionW,normalW,light{X}.vLightData,ivec2(light{X}.vSliceRanges[sliceIndex]),glossiness);} 2562#endif 2563#endif 2564#ifdef PROJECTEDLIGHTTEXTURE{X} 2565info.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},textureProjectionMatrix{X},vPositionW); 2566#endif 2567#endif 2568#ifdef SHADOW{X} 2569#ifdef SHADOWCSM{X} 2570for (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++) 2571{ 2572#ifdef SHADOWCSM_RIGHTHANDED{X} 2573diff{X}=viewFrustumZ{X}[i]+vPositionFromCamera{X}.z; 2574#else 2575diff{X}=viewFrustumZ{X}[i]-vPositionFromCamera{X}.z; 2576#endif 2577if (diff{X}>=0.) {index{X}=i;break;}} 2578#ifdef SHADOWCSMUSESHADOWMAXZ{X} 2579if (index{X}>=0) 2580#endif 2581{ 2582#if defined(SHADOWPCF{X}) 2583#if defined(SHADOWLOWQUALITY{X}) 2584shadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); 2585#elif defined(SHADOWMEDIUMQUALITY{X}) 2586shadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); 2587#else 2588shadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); 2589#endif 2590#elif defined(SHADOWPCSS{X}) 2591#if defined(SHADOWLOWQUALITY{X}) 2592shadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X}); 2593#elif defined(SHADOWMEDIUMQUALITY{X}) 2594shadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X}); 2595#else 2596shadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X}); 2597#endif 2598#else 2599shadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); 2600#endif 2601#ifdef SHADOWCSMDEBUG{X} 2602shadowDebug{X}=vec3(shadow)*vCascadeColorsMultiplier{X}[index{X}]; 2603#endif 2604#ifndef SHADOWCSMNOBLEND{X} 2605float frustumLength=frustumLengths{X}[index{X}];float diffRatio=clamp(diff{X}/frustumLength,0.,1.)*cascadeBlendFactor{X};if (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.) 2606{index{X}+=1;float nextShadow=0.; 2607#if defined(SHADOWPCF{X}) 2608#if defined(SHADOWLOWQUALITY{X}) 2609nextShadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); 2610#elif defined(SHADOWMEDIUMQUALITY{X}) 2611nextShadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); 2612#else 2613nextShadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); 2614#endif 2615#elif defined(SHADOWPCSS{X}) 2616#if defined(SHADOWLOWQUALITY{X}) 2617nextShadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X}); 2618#elif defined(SHADOWMEDIUMQUALITY{X}) 2619nextShadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X}); 2620#else 2621nextShadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X}); 2622#endif 2623#else 2624nextShadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); 2625#endif
2626shadow=mix(nextShadow,shadow,diffRatio); 2627#ifdef SHADOWCSMDEBUG{X} 2628shadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio); 2629#endif 2630} 2631#endif 2632} 2633#elif defined(SHADOWCLOSEESM{X}) 2634#if defined(SHADOWCUBE{X}) 2635shadow=computeShadowWithCloseESMCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues); 2636#else 2637shadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w); 2638#endif 2639#elif defined(SHADOWESM{X}) 2640#if defined(SHADOWCUBE{X}) 2641shadow=computeShadowWithESMCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues); 2642#else 2643shadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w); 2644#endif 2645#elif defined(SHADOWPOISSON{X}) 2646#if defined(SHADOWCUBE{X}) 2647shadow=computeShadowWithPoissonSamplingCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues); 2648#else 2649shadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); 2650#endif 2651#elif defined(SHADOWPCF{X}) 2652#if defined(SHADOWLOWQUALITY{X}) 2653shadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); 2654#elif defined(SHADOWMEDIUMQUALITY{X}) 2655shadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); 2656#else 2657shadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); 2658#endif 2659#elif defined(SHADOWPCSS{X}) 2660#if defined(SHADOWLOWQUALITY{X}) 2661shadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); 2662#elif defined(SHADOWMEDIUMQUALITY{X}) 2663shadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); 2664#else 2665shadow=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthTexture{X},shadowTexture{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); 2666#endif 2667#else 2668#if defined(SHADOWCUBE{X}) 2669shadow=computeShadowCube(vPositionW,light{X}.vLightData.xyz,shadowTexture{X},light{X}.shadowsInfo.x,light{X}.depthValues); 2670#else 2671shadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowTexture{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w); 2672#endif 2673#endif 2674#ifdef SHADOWONLY 2675#ifndef SHADOWINUSE 2676#define SHADOWINUSE 2677#endif 2678globalShadow+=shadow;shadowLightCount+=1.0; 2679#endif 2680#else 2681shadow=1.; 2682#endif 2683aggShadow+=shadow;numLights+=1.0; 2684#ifndef SHADOWONLY 2685#ifdef CUSTOMUSERLIGHTING 2686diffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow); 2687#ifdef SPECULARTERM 2688specularBase+=computeCustomSpecularLighting(info,specularBase,shadow); 2689#endif 2690#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) 2691diffuseBase+=lightmapColor.rgb*shadow; 2692#ifdef SPECULARTERM 2693#ifndef LIGHTMAPNOSPECULAR{X} 2694specularBase+=info.specular*shadow*lightmapColor.rgb; 2695#endif 2696#endif 2697#ifdef CLEARCOAT 2698#ifndef LIGHTMAPNOSPECULAR{X} 2699clearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb; 2700#endif 2701#endif 2702#ifdef SHEEN 2703#ifndef LIGHTMAPNOSPECULAR{X} 2704sheenBase+=info.sheen.rgb*shadow; 2705#endif 2706#endif 2707#else 2708#ifdef SHADOWCSMDEBUG{X} 2709diffuseBase+=info.diffuse*shadowDebug{X}; 2710#else 2711diffuseBase+=info.diffuse*shadow; 2712#endif 2713#ifdef SS_TRANSLUCENCY 2714diffuseTransmissionBase+=info.diffuseTransmission*shadow; 2715#endif 2716#ifdef SPECULARTERM 2717specularBase+=info.specular*shadow; 2718#endif 2719#ifdef CLEARCOAT 2720clearCoatBase+=info.clearCoat.rgb*shadow; 2721#endif 2722#ifdef SHEEN 2723sheenBase+=info.sheen.rgb*shadow; 2724#endif 2725#endif 2726#endif 2727#endif 2728`;de.IncludesShadersStore[$E]||(de.IncludesShadersStore[$E]=Gz);const QE="logDepthFragment",Hz=`#ifdef LOGARITHMICDEPTH 2729gl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5; 2730#endif 2731`;de.IncludesShadersStore[QE]||(de.IncludesShadersStore[QE]=Hz);const JE="fogFragment",Wz=`#ifdef FOG 2732float fog=CalcFogFactor(); 2733#ifdef PBR 2734fog=toLinearSpace(fog); 2735#endif 2736color.rgb=mix(vFogColor,color.rgb,fog); 2737#endif 2738`;de.IncludesShadersStore[JE]||(de.IncludesShadersStore[JE]=Wz);const eA="oitFragment",Xz=`#ifdef ORDER_INDEPENDENT_TRANSPARENCY 2739float fragDepth=gl_FragCoord.z; 2740#ifdef ORDER_INDEPENDENT_TRANSPARENCY_16BITS 2741uint halfFloat=packHalf2x16(vec2(fragDepth));vec2 full=unpackHalf2x16(halfFloat);fragDepth=full.x; 2742#endif 2743ivec2 fragCoord=ivec2(gl_FragCoord.xy);vec2 lastDepth=texelFetch(oitDepthSampler,fragCoord,0).rg;vec4 lastFrontColor=texelFetch(oitFrontColorSampler,fragCoord,0);depth.rg=vec2(-MAX_DEPTH);frontColor=lastFrontColor;backColor=vec4(0.0); 2744#ifdef USE_REVERSE_DEPTHBUFFER 2745float furthestDepth=-lastDepth.x;float nearestDepth=lastDepth.y; 2746#else 2747float nearestDepth=-lastDepth.x;float furthestDepth=lastDepth.y; 2748#endif 2749float alphaMultiplier=1.0-lastFrontColor.a; 2750#ifdef USE_REVERSE_DEPTHBUFFER 2751if (fragDepth>nearestDepth || fragDepth<furthestDepth) { 2752#else 2753if (fragDepth<nearestDepth || fragDepth>furthestDepth) { 2754#endif 2755return;} 2756#ifdef USE_REVERSE_DEPTHBUFFER 2757if (fragDepth<nearestDepth && fragDepth>furthestDepth) { 2758#else 2759if (fragDepth>nearestDepth && fragDepth<furthestDepth) { 2760#endif 2761depth.rg=vec2(-fragDepth,fragDepth);return;} 2762#endif 2763`;de.IncludesShadersStore[eA]||(de.IncludesShadersStore[eA]=Xz);const Xm="defaultPixelShader",LI=`#define CUSTOM_FRAGMENT_EXTENSION 2764#include<__decl__defaultFragment> 2765#if defined(BUMP) || !defined(NORMAL) 2766#extension GL_OES_standard_derivatives : enable 2767#endif 2768#include<prePassDeclaration>[SCENE_MRT_COUNT] 2769#include<oitDeclaration> 2770#define CUSTOM_FRAGMENT_BEGIN 2771#ifdef LOGARITHMICDEPTH 2772#extension GL_EXT_frag_depth : enable 2773#endif 2774varying vec3 vPositionW; 2775#ifdef NORMAL 2776varying vec3 vNormalW; 2777#endif 2778#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) 2779varying vec4 vColor; 2780#endif 2781#if defined(CLUSTLIGHT_BATCH) && CLUSTLIGHT_BATCH>0 2782varying float vViewDepth; 2783#endif 2784#include<mainUVVaryingDeclaration>
2784[1..7] 2785#include<helperFunctions> 2786#include<__decl__lightFragment>[0..maxSimultaneousLights] 2787#include<lightsFragmentFunctions> 2788#include<shadowsFragmentFunctions> 2789#include<samplerFragmentDeclaration>(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_SAMPLERNAME_,diffuse) 2790#include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient) 2791#include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity) 2792#include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive) 2793#include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap) 2794#include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal) 2795#ifdef REFRACTION 2796#ifdef REFRACTIONMAP_3D 2797uniform samplerCube refractionCubeSampler; 2798#else 2799uniform sampler2D refraction2DSampler; 2800#endif 2801#endif 2802#if defined(SPECULARTERM) 2803#include<samplerFragmentDeclaration>(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_SAMPLERNAME_,specular) 2804#endif 2805#include<fresnelFunction> 2806#ifdef REFLECTION 2807#ifdef REFLECTIONMAP_3D 2808uniform samplerCube reflectionCubeSampler; 2809#else 2810uniform sampler2D reflection2DSampler; 2811#endif 2812#ifdef REFLECTIONMAP_SKYBOX 2813varying vec3 vPositionUVW; 2814#else 2815#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED) 2816varying vec3 vDirectionW; 2817#endif 2818#endif 2819#include<reflectionFunction> 2820#endif 2821#include<imageProcessingDeclaration> 2822#include<imageProcessingFunctions> 2823#include<bumpFragmentMainFunctions> 2824#include<bumpFragmentFunctions> 2825#include<clipPlaneFragmentDeclaration> 2826#include<logDepthDeclaration> 2827#include<fogFragmentDeclaration> 2828#define CUSTOM_FRAGMENT_DEFINITIONS 2829void main(void) { 2830#define CUSTOM_FRAGMENT_MAIN_BEGIN 2831#include<clipPlaneFragment> 2832vec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float alpha=vDiffuseColor.a; 2833#ifdef NORMAL 2834vec3 normalW=normalize(vNormalW); 2835#else 2836vec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w; 2837#endif 2838#include<bumpFragment> 2839#ifdef TWOSIDEDLIGHTING 2840normalW=gl_FrontFacing ? normalW : -normalW; 2841#endif 2842#ifdef DIFFUSE 2843baseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset); 2844#if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS) 2845if (baseColor.a<alphaCutOff) 2846discard; 2847#endif 2848#ifdef ALPHAFROMDIFFUSE 2849alpha*=baseColor.a; 2850#endif 2851#define CUSTOM_FRAGMENT_UPDATE_ALPHA 2852baseColor.rgb*=vDiffuseInfos.y; 2853#endif 2854#if defined(DECAL) && !defined(DECAL_AFTER_DETAIL) 2855vec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset); 2856#include<decalFragment>(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_) 2857#endif 2858#include<depthPrePass> 2859#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES) 2860baseColor.rgb*=vColor.rgb; 2861#endif 2862#ifdef DETAIL 2863baseColor.rgb=baseColor.rgb*2.0*mix(0.5,detailColor.r,vDetailInfos.y); 2864#endif 2865#if defined(DECAL) && defined(DECAL_AFTER_DETAIL) 2866vec4 decalColor=texture2D(decalSampler,vDecalUV+uvOffset); 2867#include<decalFragment>(surfaceAlbedo,baseColor,GAMMADECAL,_GAMMADECAL_NOTUSED_) 2868#endif 2869#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE 2870vec3 baseAmbientColor=vec3(1.,1.,1.); 2871#ifdef AMBIENT 2872baseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y; 2873#endif 2874#define CUSTOM_FRAGMENT_BEFORE_LIGHTS 2875float glossiness=vSpecularColor.a;vec3 specularColor=vSpecularColor.rgb; 2876#ifdef SPECULARTERM 2877#ifdef SPECULAR 2878vec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);specularColor=specularMapColor.rgb; 2879#ifdef GLOSSINESS 2880glossiness=glossiness*specularMapColor.a; 2881#endif 2882#endif 2883#endif 2884vec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info; 2885#ifdef SPECULARTERM 2886vec3 specularBase=vec3(0.,0.,0.); 2887#endif 2888float shadow=1.;float aggShadow=0.;float numLights=0.; 2889#ifdef LIGHTMAP 2890vec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset); 2891#ifdef RGBDLIGHTMAP 2892lightmapColor.rgb=fromRGBD(lightmapColor); 2893#endif 2894lightmapColor.rgb*=vLightmapInfos.y; 2895#endif 2896#include<lightFragment>[0..maxSimultaneousLights] 2897aggShadow=aggShadow/numLights;vec4 refractionColor=vec4(0.,0.,0.,1.); 2898#ifdef REFRACTION 2899vec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y)); 2900#ifdef REFRACTIONMAP_3D 2901#ifdef USE_LOCAL_REFRACTIONMAP_CUBIC 2902refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,vRefractionSize,vRefractionPosition); 2903#endif 2904refractionVector.y=refractionVector.y*vRefractionInfos.w;vec4 refractionLookup=textureCube(refractionCubeSampler,refractionVector);if (dot(refractionVector,viewDirectionW)<1.0) {refractionColor=refractionLookup;} 2905#else 2906vec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));vec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;refractionColor=texture2D(refraction2DSampler,refractionCoords); 2907#endif 2908#ifdef RGBDREFRACTION 2909refractionColor.rgb=fromRGBD(refractionColor); 2910#endif 2911#ifdef IS_REFRACTION_LINEAR 2912refractionColor.rgb=toGammaSpace(refractionColor.rgb); 2913#endif 2914refractionColor.rgb*=vRefractionInfos.x; 2915#endif 2916vec4 reflectionColor=vec4(0.,0.,0.,1.); 2917#ifdef REFLECTION 2918vec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW); 2919#ifdef REFLECTIONMAP_OPPOSITEZ 2920vReflectionUVW.z*=-1.0; 2921#endif 2922#ifdef REFLECTIONMAP_3D 2923#ifdef ROUGHNESS 2924float bias=vReflectionInfos.y; 2925#ifdef SPECULARTERM 2926#ifdef SPECULAR 2927#ifdef GLOSSINESS 2928bias*=(1.0-specularMapColor.a); 2929#endif 2930#endif 2931#endif 2932reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias); 2933#else 2934reflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW); 2935#endif 2936#else 2937vec2 coords=vReflectionUVW.xy; 2938#ifdef REFLECTIONMAP_PROJECTION 2939coords/=vReflectionUVW.z; 2940#endif 2941coords.y=1.0-coords.y;reflectionColor=texture2D(reflection2DSampler,coords); 2942#endif 2943#ifdef RGBDREFLECTION 2944reflectionColor.rgb=fromRGBD(reflectionColor); 2945#endif 2946#ifdef IS_REFLECTION_LINEAR 2947reflectionColor.rgb=toGammaSpace(reflectionColor.rgb); 2948#endif 2949reflectionColor.rgb*=vReflectionInfos.x; 2950#ifdef REFLECTIONFRESNEL 2951float reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a); 2952#ifdef REFLECTIONFRESNELFROMSPECULAR 2953#ifdef SPECULARTERM 2954reflectionColor.rgb*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb; 2955#else 2956reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb; 2957#endif 2958#else 2959reflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb; 2960#endif 2961#endif 2962#endif 2963#ifdef REFRACTIONFRESNEL 2964float refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);refractionColor.rgb*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb; 2965#endif 2966#ifdef OPACITY 2967vec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset); 2968#ifdef OPACITYRGB 2969opacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);alpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y; 2970#else 2971alpha*=opacityMap.a*vOpacityInfos.y; 2972#endif 2973#endif 2974#if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES) 2975alpha*=vColor.a; 2976#endif 2977#ifdef OPACITYFRESNEL 2978float opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);alpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y; 2979#endif 2980#ifdef ALPHATEST 2981#ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS 2982if (alpha<alphaCutOff) 2983discard; 2984#endif 2985#ifndef ALPHABLEND 2986alpha=1.0; 2987#endif 2988#endif 2989vec3 emissiveColor=vEmissiveColor; 2990#ifdef EMISSIVE 2991emissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y; 2992#endif 2993#ifdef EMISSIVEFRESNEL 2994float emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);emissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb; 2995#endif 2996#ifdef DIFFUSEFRESNEL 2997float diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);diffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb; 2998#endif 2999#ifdef EMISSIVEASILLUMINATION 3000vec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb; 3001#else 3002#ifdef LINKEMISSIVEWITHDIFFUSE 3003vec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb; 3004#else 3005vec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb; 3006#endif 3007#endif 3008#ifdef SPECULARTERM 3009vec3 finalSpecular=specularBase*specularColor; 3010#ifdef SPECULAROVERALPHA 3011alpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.); 3012#endif 3013#else 3014vec3 finalSpecular=vec3(0.0); 3015#endif 3016#ifdef REFLECTIONOVERALPHA 3017alpha=clamp(alpha+dot(reflectionColor.rgb,vec3(0.3,0.59,0.11)),0.,1.); 3018#endif 3019#ifdef EMISSIVEASILLUMINATION 3020vec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+emissiveColor+refractionColor.rgb,0.0,1.0),alpha); 3021#else 3022vec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+refractionColor.rgb,alpha); 3023#endif 3024#ifdef LIGHTMAP 3025#ifndef LIGHTMAPEXCLUDED 3026#ifdef USELIGHTMAPASSHADOWMAP 3027color.rgb*=lightmapColor.rgb; 3028#else 3029color.rgb+=lightmapColor.rgb; 3030#endif 3031#endif 3032#endif 3033#define CUSTOM_FRAGMENT_BEFORE_FOG 3034color.rgb=max(color.rgb,0.); 3035#include<logDepthFragment> 3036#include<fogFragment> 3037#ifdef IMAGEPROCESSINGPOSTPROCESS 3038color.rgb=toLinearSpace(color.rgb); 3039#else 3040#ifdef IMAGEPROCESSING 3041color.rgb=toLinearSpace(color.rgb);color=applyImageProcessing(color); 3042#endif 3043#endif 3044color.a*=visibility; 3045#ifdef PREMULTIPLYALPHA 3046color.rgb*=color.a; 3047#endif 3048#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR 3049#ifdef PREPASS 3050#if SCENE_MRT_COUNT>0 3051float writeGeometryInfo=color.a>0.4 ? 1.0 : 0.0; 3052#ifdef PREPASS_COLOR 3053gl_FragData[PREPASS_COLOR_INDEX]=color; 3054#endif 3055#ifdef PREPASS_POSITION 3056gl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo); 3057#endif 3058#ifdef PREPASS_LOCAL_POSITION 3059gl_FragData[PREPASS_LOCAL_POSITION_INDEX]=vec4(vPosition,writeGeometryInfo); 3060#endif 3061#if defined(PREPASS_VELOCITY) 3062vec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;vec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;vec2 velocity=abs(a-b);velocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;gl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,writeGeometryInfo); 3063#elif defined(PREPASS_VELOCITY_LINEAR) 3064vec2 velocity=vec2(0.5)*((vPreviousPosition.xy/vPreviousPosition.w)-(vCurrentPosition.xy/vCurrentPosition.w));gl_FragData[PREPASS_VELOCITY_LINEAR_INDEX]=vec4(velocity,0.0,writeGeometryInfo); 3065#endif 3066#ifdef PREPASS_IRRADIANCE 3067gl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo); 3068#endif 3069#ifdef PREPASS_DEPTH 3070gl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo); 3071#endif 3072#ifdef PREPASS_SCREENSPACE_DEPTH 3073gl_FragData[PREPASS_SCREENSPACE_DEPTH_INDEX]=vec4(gl_FragCoord.z,0.0,0.0,writeGeometryInfo); 3074#endif 3075#ifdef PREPASS_NORMALIZED_VIEW_DEPTH 3076gl_FragData[PREPASS_NORMALIZED_VIEW_DEPTH_INDEX]=vec4(vNormViewDepth,0.0,0.0,writeGeometryInfo); 3077#endif 3078#ifdef PREPASS_NORMAL 3079#ifdef PREPASS_NORMAL_WORLDSPACE 3080gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalW,writeGeometryInfo); 3081#else 3082gl_FragData[PREPASS_NORMAL_INDEX]=vec4(normalize((view*vec4(normalW,0.0)).rgb),writeGeometryInfo); 3083#endif 3084#endif 3085#ifdef PREPASS_WORLD_NORMAL 3086gl_FragData[PREPASS_WORLD_NORMAL_INDEX]=vec4(normalW*0.5+0.5,writeGeometryInfo); 3087#endif 3088#ifdef PREPASS_ALBEDO 3089gl_FragData[PREPASS_ALBEDO_INDEX]=vec4(baseColor.rgb,writeGeometryInfo); 3090#endif 3091#ifdef PREPASS_ALBEDO_SQRT 3092gl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(sqrt(baseColor.rgb),writeGeometryInfo); 3093#endif 3094#ifdef PREPASS_REFLECTIVITY 3095#if defined(SPECULAR) 3096gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(toLinearSpace(specularMapColor))*writeGeometryInfo; 3097#else 3098gl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(toLinearSpace(specularColor),1.0)*writeGeometryInfo; 3099#endif 3100#endif 3101#endif 3102#endif 3103#if !defined(PREPASS) || defined(WEBGL2) 3104gl_FragColor=color; 3105#endif 3106#include<oitFragment> 3107#if ORDER_INDEPENDENT_TRANSPARENCY 3108if (fragDepth==nearestDepth) {frontColor.rgb+=color.rgb*color.a*alphaMultiplier;frontColor.a=1.0-alphaMultiplier*(1.0-color.a);} else {backColor+=color;} 3109#endif 3110#define CUSTOM_FRAGMENT_MAIN_END 3111} 3112`;de.ShadersStore[Xm]||(de.ShadersStore[Xm]=LI);const jz={name:Xm,shader:LI},Yz=Object.freeze(Object.defineProperty({__proto__:null,defaultPixelShader:jz},Symbol.toStringTag,{value:"Module"}));class hr{constructor(){this.keysUp=[38],this.keysUpward=[33],this.keysDown=[40],this.keysDownward=[34],this.keysLeft=[37],this.keysRight=[39],this.rotationSpeed=.5,this.keysRotateLeft=[],this.keysRotateRight=[],this.keysRotateUp=[],this.keysRotateDown=[],this._keys=new Array}attachControl(e){e=pe.BackCompatCameraNoPreventDefault(arguments),!this._onCanvasBlurObserver&&(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add(()=>{this._keys.length=0}),this._onKeyboardObserver=this._scene.onKeyboardObservable.add(t=>{const i=t.event;if(!i.metaKey){if(t.type===lc.KEYDOWN)(this.keysUp.indexOf(i.keyCode)!==-1||this.keysDown.indexOf(i.keyCode)!==-1||this.keysLeft.indexOf(i.keyCode)!==-1||this.keysRight.indexOf(i.keyCode)!==-1||this.keysUpward.indexOf(i.keyCode)!==-1||this.keysDownward.indexOf(i.keyCode)!==-1||this.keysRotateLeft.indexOf(i.keyCode)!==-1||this.keysRotateRight.indexOf(i.keyCode)!==-1||this.keysRotateUp.indexOf(i.keyCode)!==-1||this.keysRotateDown.indexOf(i.keyCode)!==-1)&&(this._keys.indexOf(i.keyCode)===-1&&this._keys.push(i.keyCode),e||i.preventDefault());else if(this.keysUp.indexOf(i.keyCode)!==-1||this.keysDown.indexOf(i.keyCode)!==-1||this.keysLeft.indexOf(i.keyCode)!==-1||this.keysRight.indexOf(i.keyCode)!==-1||this.keysUpward.indexOf(i.keyCode)!==-1||this.keysDownward.indexOf(i.keyCode)!==-1||this.keysRotateLeft.indexOf(i.keyCode)!==-1||this.keysRotateRight.indexOf(i.keyCode)!==-1||this.keysRotateUp.indexOf(i.keyCode)!==-1||this.keysRotateDown.indexOf(i.keyCode)!==-1){const s=this._keys.indexOf(i.keyCode);s>=0&&this._keys.splice(s,1),e||i.preventDefault()}}}))}detachControl(){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys.length=0}
vendor: 14,437 bytes, line 3112
3112checkInputs(){if(this._onKeyboardObserver){const e=this.camera;for(let t=0;t<this._keys.length;t++){const i=this._keys[t],s=e._computeLocalCameraSpeed();this.keysLeft.indexOf(i)!==-1?e._localDirection.copyFromFloats(-s,0,0):this.keysUp.indexOf(i)!==-1?e._localDirection.copyFromFloats(0,0,s):this.keysRight.indexOf(i)!==-1?e._localDirection.copyFromFloats(s,0,0):this.keysDown.indexOf(i)!==-1?e._localDirection.copyFromFloats(0,0,-s):this.keysUpward.indexOf(i)!==-1?e._localDirection.copyFromFloats(0,s,0):this.keysDownward.indexOf(i)!==-1?e._localDirection.copyFromFloats(0,-s,0):this.keysRotateLeft.indexOf(i)!==-1?(e._localDirection.copyFromFloats(0,0,0),e.cameraRotation.y-=this._getLocalRotation()):this.keysRotateRight.indexOf(i)!==-1?(e._localDirection.copyFromFloats(0,0,0),e.cameraRotation.y+=this._getLocalRotation()):this.keysRotateUp.indexOf(i)!==-1?(e._localDirection.copyFromFloats(0,0,0),e.cameraRotation.x-=this._getLocalRotation()):this.keysRotateDown.indexOf(i)!==-1&&(e._localDirection.copyFromFloats(0,0,0),e.cameraRotation.x+=this._getLocalRotation()),e.getScene().useRightHandedSystem&&(e._localDirection.z*=-1),e.getViewMatrix().invertToRef(e._cameraTransformMatrix),T.TransformNormalToRef(e._localDirection,e._cameraTransformMatrix,e._transformedDirection),e.cameraDirection.addInPlace(e._transformedDirection)}}}getClassName(){return"FreeCameraKeyboardMoveInput"}_onLostFocus(){this._keys.length=0}getSimpleName(){return"keyboard"}_getLocalRotation(){const e=this.camera._calculateHandednessMultiplier();return this.rotationSpeed*this._engine.getDeltaTime()/1e3*e}}N([H()],hr.prototype,"keysUp",void 0);N([H()],hr.prototype,"keysUpward",void 0);N([H()],hr.prototype,"keysDown",void 0);N([H()],hr.prototype,"keysDownward",void 0);N([H()],hr.prototype,"keysLeft",void 0);N([H()],hr.prototype,"keysRight",void 0);N([H()],hr.prototype,"rotationSpeed",void 0);N([H()],hr.prototype,"keysRotateLeft",void 0);N([H()],hr.prototype,"keysRotateRight",void 0);N([H()],hr.prototype,"keysRotateUp",void 0);N([H()],hr.prototype,"keysRotateDown",void 0);qr.FreeCameraKeyboardMoveInput=hr;class jf{constructor(e=!0){this.touchEnabled=e,this.buttons=[0,1,2],this.angularSensibility=2e3,this._previousPosition=null,this.onPointerMovedObservable=new le,this._allowCameraRotation=!0,this._currentActiveButton=-1,this._activePointerId=-1}attachControl(e){e=pe.BackCompatCameraNoPreventDefault(arguments);const t=this.camera.getEngine(),i=t.getInputElement();this._pointerInput||(this._pointerInput=s=>{const r=s.event,a=r.pointerType==="touch";if(!this.touchEnabled&&a||s.type!==Ve.POINTERMOVE&&this.buttons.indexOf(r.button)===-1)return;const o=r.target;if(s.type===Ve.POINTERDOWN){if(a&&this._activePointerId!==-1||!a&&this._currentActiveButton!==-1)return;this._activePointerId=r.pointerId;try{o?.setPointerCapture(r.pointerId)}catch{}this._currentActiveButton===-1&&(this._currentActiveButton=r.button),this._previousPosition={x:r.clientX,y:r.clientY},e||(r.preventDefault(),i&&i.focus()),t.isPointerLock&&this._onMouseMove&&this._onMouseMove(s.event)}else if(s.type===Ve.POINTERUP){if(a&&this._activePointerId!==r.pointerId||!a&&this._currentActiveButton!==r.button)return;try{o?.releasePointerCapture(r.pointerId)}catch{}this._currentActiveButton=-1,this._previousPosition=null,e||r.preventDefault(),this._activePointerId=-1}else if(s.type===Ve.POINTERMOVE&&(this._activePointerId===r.pointerId||!a)){if(t.isPointerLock&&this._onMouseMove)this._onMouseMove(s.event);else if(this._previousPosition){const c=this.camera._calculateHandednessMultiplier(),u=(r.clientX-this._previousPosition.x)*c,d=(r.clientY-this._previousPosition.y)*c;this._allowCameraRotation&&(this.camera.cameraRotation.y+=u/this.angularSensibility,this.camera.cameraRotation.x+=d/this.angularSensibility),this.onPointerMovedObservable.notifyObservers({offsetX:u,offsetY:d}),this._previousPosition={x:r.clientX,y:r.clientY},e||r.preventDefault()}}}),this._onMouseMove=s=>{if(!t.isPointerLock)return;const r=this.camera._calculateHandednessMultiplier();this.camera.cameraRotation.y+=s.movementX*r/this.angularSensibility,this.camera.cameraRotation.x+=s.movementY*r/this.angularSensibility,this._previousPosition=null,e||s.preventDefault()},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,Ve.POINTERDOWN|Ve.POINTERUP|Ve.POINTERMOVE),i&&(this._contextMenuBind=s=>this.onContextMenu(s),i.addEventListener("contextmenu",this._contextMenuBind,!1))}onContextMenu(e){e.preventDefault()}detachControl(){if(this._observer){if(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._contextMenuBind){const t=this.camera.getEngine().getInputElement();t&&t.removeEventListener("contextmenu",this._contextMenuBind)}this.onPointerMovedObservable&&this.onPointerMovedObservable.clear(),this._observer=null,this._onMouseMove=null,this._previousPosition=null}this._activePointerId=-1,this._currentActiveButton=-1}getClassName(){return"FreeCameraMouseInput"}getSimpleName(){return"mouse"}}N([H()],jf.prototype,"buttons",void 0);N([H()],jf.prototype,"angularSensibility",void 0);qr.FreeCameraMouseInput=jf;class Yf{constructor(){this.wheelPrecisionX=3,this.wheelPrecisionY=3,this.wheelPrecisionZ=3,this.onChangedObservable=new le,this._wheelDeltaX=0,this._wheelDeltaY=0,this._wheelDeltaZ=0,this._ffMultiplier=12,this._normalize=120}attachControl(e){e=pe.BackCompatCameraNoPreventDefault(arguments),this._wheel=t=>{if(t.type!==Ve.POINTERWHEEL)return;const i=t.event,s=i.deltaMode===gc.DOM_DELTA_LINE?this._ffMultiplier:1;this._wheelDeltaX+=this.wheelPrecisionX*s*i.deltaX/this._normalize,this._wheelDeltaY-=this.wheelPrecisionY*s*i.deltaY/this._normalize,this._wheelDeltaZ+=this.wheelPrecisionZ*s*i.deltaZ/this._normalize,i.preventDefault&&(e||i.preventDefault())},this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._wheel,Ve.POINTERWHEEL)}detachControl(){this._observer&&(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null,this._wheel=null),this.onChangedObservable&&this.onChangedObservable.clear()}checkInputs(){this.onChangedObservable.notifyObservers({wheelDeltaX:this._wheelDeltaX,wheelDeltaY:this._wheelDeltaY,wheelDeltaZ:this._wheelDeltaZ}),this._wheelDeltaX=0,this._wheelDeltaY=0,this._wheelDeltaZ=0}getClassName(){return"BaseCameraMouseWheelInput"}getSimpleName(){return"mousewheel"}}N([H()],Yf.prototype,"wheelPrecisionX",void 0);N([H()],Yf.prototype,"wheelPrecisionY",void 0);N([H()],Yf.prototype,"wheelPrecisionZ",void 0);var Nt;(function(n){n[n.MoveRelative=0]="MoveRelative",n[n.RotateRelative=1]="RotateRelative",n[n.MoveScene=2]="MoveScene"})(Nt||(Nt={}));class en extends Yf{constructor(){super(...arguments),this._moveRelative=T.Zero(),this._rotateRelative=T.Zero(),this._moveScene=T.Zero(),this._wheelXAction=Nt.MoveRelative,this._wheelXActionCoordinate=0,this._wheelYAction=Nt.MoveRelative,this._wheelYActionCoordinate=2,this._wheelZAction=null,this._wheelZActionCoordinate=null}getClassName(){return"FreeCameraMouseWheelInput"}set wheelXMoveRelative(e){e===null&&this._wheelXAction!==Nt.MoveRelative||(this._wheelXAction=Nt.MoveRelative,this._wheelXActionCoordinate=e)}get wheelXMoveRelative(){return this._wheelXAction!==Nt.MoveRelative?null:this._wheelXActionCoordinate}set wheelYMoveRelative(e){e===null&&this._wheelYAction!==Nt.MoveRelative||(this._wheelYAction=Nt.MoveRelative,this._wheelYActionCoordinate=e)}get wheelYMoveRelative(){return this._wheelYAction!==Nt.MoveRelative?null:this._wheelYActionCoordinate}set wheelZMoveRelative(e){e===null&&this._wheelZAction!==Nt.MoveRelative||(this._wheelZAction=Nt.MoveRelative,this._wheelZActionCoordinate=e)}get wheelZMoveRelative(){return this._wheelZAction!==Nt.MoveRelative?null:this._wheelZActionCoordinate}set wheelXRotateRelative(e){e===null&&this._wheelXAction!==Nt.RotateRelative||(this._wheelXAction=Nt.RotateRelative,this._wheelXActionCoordinate=e)}get wheelXRotateRelative(){return this._wheelXAction!==Nt.RotateRelative?null:this._wheelXActionCoordinate}set wheelYRotateRelative(e){e===null&&this._wheelYAction!==Nt.RotateRelative||(this._wheelYAction=Nt.RotateRelative,this._wheelYActionCoordinate=e)}get wheelYRotateRelative(){return this._wheelYAction!==Nt.RotateRelative?null:this._wheelYActionCoordinate}set wheelZRotateRelative(e){e===null&&this._wheelZAction!==Nt.RotateRelative||(this._wheelZAction=Nt.RotateRelative,this._wheelZActionCoordinate=e)}get wheelZRotateRelative(){return this._wheelZAction!==Nt.RotateRelative?null:this._wheelZActionCoordinate}set wheelXMoveScene(e){e===null&&this._wheelXAction!==Nt.MoveScene||(this._wheelXAction=Nt.MoveScene,this._wheelXActionCoordinate=e)}get wheelXMoveScene(){return this._wheelXAction!==Nt.MoveScene?null:this._wheelXActionCoordinate}set wheelYMoveScene(e){e===null&&this._wheelYAction!==Nt.MoveScene||(this._wheelYAction=Nt.MoveScene,this._wheelYActionCoordinate=e)}get wheelYMoveScene(){return this._wheelYAction!==Nt.MoveScene?null:this._wheelYActionCoordinate}set wheelZMoveScene(e){e===null&&this._wheelZAction!==Nt.MoveScene||(this._wheelZAction=Nt.MoveScene,this._wheelZActionCoordinate=e)}get wheelZMoveScene(){return this._wheelZAction!==Nt.MoveScene?null:this._wheelZActionCoordinate}checkInputs(){if(this._wheelDeltaX===0&&this._wheelDeltaY===0&&this._wheelDeltaZ==0)return;this._moveRelative.setAll(0),this._rotateRelative.setAll(0),this._moveScene.setAll(0),this._updateCamera(),this.camera.getScene().useRightHandedSystem&&(this._moveRelative.z*=-1);const e=W.Zero();this.camera.getViewMatrix().invertToRef(e);const t=T.Zero();T.TransformNormalToRef(this._moveRelative,e,t),this.camera.cameraRotation.x+=this._rotateRelative.x/200,this.camera.cameraRotation.y+=this._rotateRelative.y/200,this.camera.cameraDirection.addInPlace(t),this.camera.cameraDirection.addInPlace(this._moveScene),super.checkInputs()}_updateCamera(){this._updateCameraProperty(this._wheelDeltaX,this._wheelXAction,this._wheelXActionCoordinate),this._updateCameraProperty(this._wheelDeltaY,this._wheelYAction,this._wheelYActionCoordinate),this._updateCameraProperty(this._wheelDeltaZ,this._wheelZAction,this._wheelZActionCoordinate)}_updateCameraProperty(e,t,i){if(e===0||t===null||i===null)return;let s=null;switch(t){case Nt.MoveRelative:s=this._moveRelative;break;case Nt.RotateRelative:s=this._rotateRelative;break;case Nt.MoveScene:s=this._moveScene;break}switch(i){case 0:s.set(e,0,0);break;case 1:s.set(0,e,0);break;case 2:s.set(0,0,e);break}}}N([H()],en.prototype,"wheelXMoveRelative",null);N([H()],en.prototype,"wheelYMoveRelative",null);N([H()],en.prototype,"wheelZMoveRelative",null);N([H()],en.prototype,"wheelXRotateRelative",null);N([H()],en.prototype,"wheelYRotateRelative",null);N([H()],en.prototype,"wheelZRotateRelative",null);N([H()],en.prototype,"wheelXMoveScene",null);N([H()],en.prototype,"wheelYMoveScene",null);N([H()],en.prototype,"wheelZMoveScene",null);qr.FreeCameraMouseWheelInput=en;class Kf{constructor(e=!1){this.allowMouse=e,this.touchAngularSensibility=2e5,this.touchMoveSensibility=250,this.singleFingerRotate=!1,this._offsetX=null,this._offsetY=null,this._pointerPressed=new Array,this._isSafari=pe.IsSafari()}attachControl(e){e=pe.BackCompatCameraNoPreventDefault(arguments);let t=null;if(this._pointerInput===void 0&&(this._onLostFocus=()=>{this._offsetX=null,this._offsetY=null},this._pointerInput=i=>{const s=i.event,r=s.pointerType==="mouse"||this._isSafari&&typeof s.pointerType>"u";if(!(!this.allowMouse&&r)){if(i.type===Ve.POINTERDOWN){if(e||s.preventDefault(),this._pointerPressed.push(s.pointerId),this._pointerPressed.length!==1)return;t={x:s.clientX,y:s.clientY}}else if(i.type===Ve.POINTERUP){e||s.preventDefault();const a=this._pointerPressed.indexOf(s.pointerId);if(a===-1||(this._pointerPressed.splice(a,1),a!=0))return;t=null,this._offsetX=null,this._offsetY=null}else if(i.type===Ve.POINTERMOVE){if(e||s.preventDefault(),!t||this._pointerPressed.indexOf(s.pointerId)!=0)return;this._offsetX=s.clientX-t.x,this._offsetY=-(s.clientY-t.y)}}}),this._observer=this.camera.getScene()._inputManager._addCameraPointerObserver(this._pointerInput,Ve.POINTERDOWN|Ve.POINTERUP|Ve.POINTERMOVE),this._onLostFocus){const s=this.camera.getEngine().getInputElement();s&&s.addEventListener("blur",this._onLostFocus)}}detachControl(){if(this._pointerInput){if(this._observer&&(this.camera.getScene()._inputManager._removeCameraPointerObserver(this._observer),this._observer=null),this._onLostFocus){const t=this.camera.getEngine().getInputElement();t&&t.removeEventListener("blur",this._onLostFocus),this._onLostFocus=null}this._pointerPressed.length=0,this._offsetX=null,this._offsetY=null}}checkInputs(){if(this._offsetX===null||this._offsetY===null||this._offsetX===0&&this._offsetY===0)return;const e=this.camera,t=e._calculateHandednessMultiplier();if(e.cameraRotation.y=this._offsetX*t/this.touchAngularSensibility,this.singleFingerRotate&&this._pointerPressed.length===1||!this.singleFingerRotate&&this._pointerPressed.length>1)e.cameraRotation.x=-(this._offsetY*t)/this.touchAngularSensibility;else{const s=e._computeLocalCameraSpeed(),r=new T(0,0,this.touchMoveSensibility!==0?s*this._offsetY/this.touchMoveSensibility:0);W.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,e._cameraRotationMatrix),e.cameraDirection.addInPlace(T.TransformCoordinates(r,e._cameraRotationMatrix))}}getClassName(){return"FreeCameraTouchInput"}getSimpleName(){return"touch"}}N([H()],Kf.prototype,"touchAngularSensibility",void 0);N([H()],Kf.prototype,"touchMoveSensibility",void 0);qr.FreeCameraTouchInput=Kf;class NI extends DI{constructor(e){super(e),this._mouseInput=null,this._mouseWheelInput=null}addKeyboard(){return this.add(new hr),this}addMouse(e=!0){return this._mouseInput||(this._mouseInput=new jf(e),this.add(this._mouseInput)),this}removeMouse(){return this._mouseInput&&this.remove(this._mouseInput),this}addMouseWheel(){return this._mouseWheelInput||(this._mouseWheelInput=new en,this.add(this._mouseWheelInput)),this}removeMouseWheel(){return this._mouseWheelInput&&this.remove(this._mouseWheelInput),this}addTouch(){return this.add(new Kf),this}clear(){super.clear(),this._mouseInput=null}}class Zo extends mi{get angularSensibility(){const e=this.inputs.attached.mouse;return e?e.angularSensibility:0}set angularSensibility(e){const t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)}get keysUp(){const e=this.inputs.attached.keyboard;
3112return e?e.keysUp:[]}set keysUp(e){const t=this.inputs.attached.keyboard;t&&(t.keysUp=e)}get keysUpward(){const e=this.inputs.attached.keyboard;return e?e.keysUpward:[]}set keysUpward(e){const t=this.inputs.attached.keyboard;t&&(t.keysUpward=e)}get keysDown(){const e=this.inputs.attached.keyboard;return e?e.keysDown:[]}set keysDown(e){const t=this.inputs.attached.keyboard;t&&(t.keysDown=e)}get keysDownward(){const e=this.inputs.attached.keyboard;return e?e.keysDownward:[]}set keysDownward(e){const t=this.inputs.attached.keyboard;t&&(t.keysDownward=e)}get keysLeft(){const e=this.inputs.attached.keyboard;return e?e.keysLeft:[]}set keysLeft(e){const t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)}get keysRight(){const e=this.inputs.attached.keyboard;return e?e.keysRight:[]}set keysRight(e){const t=this.inputs.attached.keyboard;t&&(t.keysRight=e)}get keysRotateLeft(){const e=this.inputs.attached.keyboard;return e?e.keysRotateLeft:[]}set keysRotateLeft(e){const t=this.inputs.attached.keyboard;t&&(t.keysRotateLeft=e)}get keysRotateRight(){const e=this.inputs.attached.keyboard;return e?e.keysRotateRight:[]}set keysRotateRight(e){const t=this.inputs.attached.keyboard;t&&(t.keysRotateRight=e)}get keysRotateUp(){const e=this.inputs.attached.keyboard;return e?e.keysRotateUp:[]}set keysRotateUp(e){const t=this.inputs.attached.keyboard;t&&(t.keysRotateUp=e)}get keysRotateDown(){const e=this.inputs.attached.keyboard;return e?e.keysRotateDown:[]}set keysRotateDown(e){const t=this.inputs.attached.keyboard;t&&(t.keysRotateDown=e)}constructor(e,t,i,s=!0){super(e,t,i,s),this.ellipsoid=new T(.5,1,.5),this.ellipsoidOffset=new T(0,0,0),this.checkCollisions=!1,this.applyGravity=!1,this._needMoveForGravity=!1,this._oldPosition=T.Zero(),this._diffPosition=T.Zero(),this._newPosition=T.Zero(),this._collisionMask=-1,this._onCollisionPositionChange=(r,a,o=null)=>{this._newPosition.copyFrom(a),this._newPosition.subtractToRef(this._oldPosition,this._diffPosition),this._diffPosition.length()>Ce.CollisionsEpsilon&&(this.position.addToRef(this._diffPosition,this._deferredPositionUpdate),this._deferOnly?this._deferredUpdated=!0:this.position.copyFrom(this._deferredPositionUpdate),this.onCollide&&o&&this.onCollide(o))},this.inputs=new NI(this),this.inputs.addKeyboard().addMouse()}attachControl(e,t){t=pe.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(t)}detachControl(){this.inputs.detachElement(),this.cameraDirection=new T(0,0,0),this.cameraRotation=new Ie(0,0)}get collisionMask(){return this._collisionMask}set collisionMask(e){this._collisionMask=isNaN(e)?-1:e}_collideWithWorld(e){let t;this.parent?t=T.TransformCoordinates(this.position,this.parent.getWorldMatrix()):t=this.position,t.subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._oldPosition.addInPlace(this.ellipsoidOffset);const i=this.getScene().collisionCoordinator;this._collider||(this._collider=i.createCollider()),this._collider._radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;let s=e;this.applyGravity&&(s=e.add(this.getScene().gravity)),i.getNewPosition(this._oldPosition,s,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}_checkInputs(){this._localDirection||(this._localDirection=T.Zero(),this._transformedDirection=T.Zero()),this.inputs.checkInputs(),super._checkInputs()}set needMoveForGravity(e){this._needMoveForGravity=e}get needMoveForGravity(){return this._needMoveForGravity}_decideIfNeedsToMove(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0}_updatePosition(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):super._updatePosition()}dispose(){this.inputs.clear(),super.dispose()}getClassName(){return"FreeCamera"}}N([lr()],Zo.prototype,"ellipsoid",void 0);N([lr()],Zo.prototype,"ellipsoidOffset",void 0);N([H()],Zo.prototype,"checkCollisions",void 0);N([H()],Zo.prototype,"applyGravity",void 0);Tt("BABYLON.FreeCamera",Zo);class df extends Zo{constructor(e,t,i){super(e,T.Zero(),t),this._xrSessionManager=i,this._firstFrame=!1,this._referenceQuaternion=Se.Identity(),this._referencedPosition=new T,this._trackingState=0,this.onXRCameraInitializedObservable=new le,this.onBeforeCameraTeleport=new le,this.onAfterCameraTeleport=new le,this.onTrackingStateChanged=new le,this.compensateOnFirstFrame=!0,this.minZ=.1,this.rotationQuaternion=new Se,this.cameraRigMode=Ge.RIG_MODE_CUSTOM,this.updateUpVectorFromRotation=!0,this._updateNumberOfRigCameras(1),this.freezeProjectionMatrix(),this._deferOnly=!0,this._xrSessionManager.onXRSessionInit.add(()=>{this._referencedPosition.copyFromFloats(0,0,0),this._referenceQuaternion.copyFromFloats(0,0,0,1),this._firstFrame=this.compensateOnFirstFrame,this._xrSessionManager.onWorldScaleFactorChangedObservable.add(()=>{this._xrSessionManager.currentFrame&&this._updateDepthNearFar()})}),this._xrSessionManager.onXRFrameObservable.add(()=>{this._firstFrame&&this._updateFromXRSession(),this.onXRCameraInitializedObservable.hasObservers()&&(this.onXRCameraInitializedObservable.notifyObservers(this),this.onXRCameraInitializedObservable.clear()),this._deferredUpdated&&(this.position.copyFrom(this._deferredPositionUpdate),this.rotationQuaternion.copyFrom(this._deferredRotationQuaternionUpdate)),this._updateReferenceSpace(),this._updateFromXRSession()},void 0,!0)}get trackingState(){return this._trackingState}_setTrackingState(e){this._trackingState!==e&&(this._trackingState=e,this.onTrackingStateChanged.notifyObservers(e))}get realWorldHeight(){const e=this._xrSessionManager.currentFrame&&this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.baseReferenceSpace);return e&&e.transform?e.transform.position.y*this._xrSessionManager.worldScalingFactor:0}_updateForDualEyeDebugging(){this._updateNumberOfRigCameras(2),this.rigCameras[0].viewport=new Ja(0,0,.5,1),this.rigCameras[0].outputRenderTarget=null,this.rigCameras[1].viewport=new Ja(.5,0,.5,1),this.rigCameras[1].outputRenderTarget=null}setTransformationFromNonVRCamera(e=this.getScene().activeCamera,t=!0){if(!e||e===this)return;e.computeWorldMatrix().decompose(void 0,this.rotationQuaternion,this.position),this.position.y=0,Se.FromEulerAnglesToRef(0,this.rotationQuaternion.toEulerAngles().y,0,this.rotationQuaternion),this._firstFrame=!0,t&&this._xrSessionManager.resetReferenceSpace()}getClassName(){return"WebXRCamera"}setTarget(e){const t=te.Vector3[1];e.subtractToRef(this.position,t),t.y=0,t.normalize();const i=Math.atan2(t.x,t.z)+(this._scene.useRightHandedSystem?Math.PI:0);this.rotationQuaternion.toEulerAnglesToRef(t),Se.FromEulerAnglesToRef(t.x,i,t.z,this.rotationQuaternion)}dispose(){super.dispose(),this._lastXRViewerPose=void 0,this.onTrackingStateChanged.clear()}_updateDepthNearFar(){const e=(this.maxZ||1e4)*this._xrSessionManager.worldScalingFactor,t={depthFar:e,depthNear:this.minZ};this._xrSessionManager.updateRenderState(t),this._cache.minZ=this.minZ,this._cache.maxZ=e}_updateFromXRSession(){const e=this._xrSessionManager.currentFrame&&this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.referenceSpace);if(this._lastXRViewerPose=e||void 0,!e){this._setTrackingState(0);return}const t=e.emulatedPosition?1:2;if(this._setTrackingState(t),(this.minZ!==this._cache.minZ||this.maxZ!==this._cache.maxZ)&&this._updateDepthNearFar(),e.transform){const i=e.transform.orientation;if(e.transform.orientation.x===void 0)return;const s=e.transform.position;this._referencedPosition.set(s.x,s.y,s.z).scaleInPlace(this._xrSessionManager.worldScalingFactor),this._referenceQuaternion.set(i.x,i.y,i.z,i.w),this._scene.useRightHandedSystem||(this._referencedPosition.z*=-1,this._referenceQuaternion.z*=-1,this._referenceQuaternion.w*=-1),this._firstFrame?(this._firstFrame=!1,this.position.y+=this._referencedPosition.y,this._referenceQuaternion.copyFromFloats(0,0,0,1)):(this.rotationQuaternion.copyFrom(this._referenceQuaternion),this.position.copyFrom(this._referencedPosition))}this.rigCameras.length!==e.views.length&&this._updateNumberOfRigCameras(e.views.length);for(let i=0;i<e.views.length;i++){const s=e.views[i],r=this.rigCameras[i];!r.isLeftCamera&&!r.isRightCamera&&(s.eye==="right"?r._isRightCamera=!0:s.eye==="left"&&(r._isLeftCamera=!0));const a=this.getScene().customRenderTargets;for(let f=0;f<a.length;f++){const g=a[f];r.customRenderTargets.indexOf(g)===-1&&r.customRenderTargets.push(g)}const o=s.transform.position,c=s.transform.orientation;r.parent=this.parent,r.position.set(o.x,o.y,o.z).scaleInPlace(this._xrSessionManager.worldScalingFactor),r.rotationQuaternion?.set(c.x,c.y,c.z,c.w),!this._scene.useRightHandedSystem&&r.rotationQuaternion&&(r.position.z*=-1,r.rotationQuaternion.z*=-1,r.rotationQuaternion.w*=-1),W.FromFloat32ArrayToRefScaled(s.projectionMatrix,0,1,r._projectionMatrix),this._scene.useRightHandedSystem||r._projectionMatrix.toggleProjectionMatrixHandInPlace();const u=Math.atan2(1,s.projectionMatrix[5])*2;r.fov=u,i===0&&(this.fov=u,this._projectionMatrix.copyFrom(r._projectionMatrix));const d=this._xrSessionManager.getRenderTargetTextureForView(s);this._renderingMultiview=d?._texture?.isMultiview||!1,this._renderingMultiview?i==0&&(this._xrSessionManager.trySetViewportForView(this.viewport,s),this.outputRenderTarget=d):(this._xrSessionManager.trySetViewportForView(r.viewport,s),r.outputRenderTarget=d||this._xrSessionManager.getRenderTargetTextureForView(s)),r.layerMask=this.layerMask}}_updateNumberOfRigCameras(e=1){for(;this.rigCameras.length<e;){const t=new mi("XR-RigCamera: "+this.rigCameras.length,T.Zero(),this.get
3112Scene());t.minZ=.1,t.rotationQuaternion=new Se,t.updateUpVectorFromRotation=!0,t.isRigCamera=!0,t.rigParent=this,t.freezeProjectionMatrix(),this.rigCameras.push(t)}for(;this.rigCameras.length>e;){const t=this.rigCameras.pop();t&&t.dispose()}}_updateReferenceSpace(){if(!this.position.equals(this._referencedPosition)||!this.rotationQuaternion.equals(this._referenceQuaternion)){const e=te.Matrix[0],t=te.Matrix[1],i=te.Matrix[2];W.ComposeToRef(df._ScaleReadOnly,this._referenceQuaternion,this._referencedPosition,e),W.ComposeToRef(df._ScaleReadOnly,this.rotationQuaternion,this.position,t),e.invert().multiplyToRef(t,i),i.invert(),this._scene.useRightHandedSystem||i.toggleModelMatrixHandInPlace(),i.decompose(void 0,this._referenceQuaternion,this._referencedPosition);const s=new XRRigidTransform({x:this._referencedPosition.x/this._xrSessionManager.worldScalingFactor,y:this._referencedPosition.y/this._xrSessionManager.worldScalingFactor,z:this._referencedPosition.z/this._xrSessionManager.worldScalingFactor,w:1},{x:this._referenceQuaternion.x,y:this._referenceQuaternion.y,z:this._referenceQuaternion.z,w:this._referenceQuaternion.w});this._xrSessionManager.referenceSpace=this._xrSessionManager.referenceSpace.getOffsetReferenceSpace(s)}}}df._ScaleReadOnly=T.One();class Yt{}Yt.ANCHOR_SYSTEM="xr-anchor-system";Yt.BACKGROUND_REMOVER="xr-background-remover";Yt.HIT_TEST="xr-hit-test";Yt.MESH_DETECTION="xr-mesh-detection";Yt.PHYSICS_CONTROLLERS="xr-physics-controller";Yt.PLANE_DETECTION="xr-plane-detection";Yt.POINTER_SELECTION="xr-controller-pointer-selection";Yt.TELEPORTATION="xr-controller-teleportation";Yt.FEATURE_POINTS="xr-feature-points";Yt.HAND_TRACKING="xr-hand-tracking";Yt.IMAGE_TRACKING="xr-image-tracking";Yt.NEAR_INTERACTION="xr-near-interaction";Yt.DOM_OVERLAY="xr-dom-overlay";Yt.MOVEMENT="xr-controller-movement";Yt.LIGHT_ESTIMATION="xr-light-estimation";Yt.EYE_TRACKING="xr-eye-tracking";Yt.WALKING_LOCOMOTION="xr-walking-locomotion";Yt.LAYERS="xr-layers";Yt.DEPTH_SENSING="xr-depth-sensing";Yt.SPACE_WARP="xr-space-warp";Yt.RAW_CAMERA_ACCESS="xr-raw-camera-access";class Dr{constructor(e){this._xrSessionManager=e,this._features={},this._xrSessionManager.onXRSessionInit.add(()=>{const t=this.getEnabledFeatures();for(const i of t){const s=this._features[i];s.enabled&&!s.featureImplementation.attached&&!s.featureImplementation.disableAutoAttach&&this.attachFeature(i)}}),this._xrSessionManager.onXRSessionEnded.add(()=>{const t=this.getEnabledFeatures();for(const i of t){const s=this._features[i];s.enabled&&s.featureImplementation.attached&&this.detachFeature(i)}})}static AddWebXRFeature(e,t,i=1,s=!1){this._AvailableFeatures[e]=this._AvailableFeatures[e]||{latest:i},i>this._AvailableFeatures[e].latest&&(this._AvailableFeatures[e].latest=i),s&&(this._AvailableFeatures[e].stable=i),this._AvailableFeatures[e][i]=t}static ConstructFeature(e,t=1,i,s){const r=this._AvailableFeatures[e][t];if(!r)throw new Error("feature not found");return r(i,s)}static GetAvailableFeatures(){return Object.keys(this._AvailableFeatures)}static GetAvailableVersions(e){return Object.keys(this._AvailableFeatures[e])}static GetLatestVersionOfFeature(e){return this._AvailableFeatures[e]&&this._AvailableFeatures[e].latest||-1}static GetStableVersionOfFeature(e){return this._AvailableFeatures[e]&&this._AvailableFeatures[e].stable||-1}attachFeature(e){const t=this._features[e];t&&t.enabled&&!t.featureImplementation.attached&&(t.featureImplementation.attach()||pe.Warn(`Feature ${e} failed to attach`))}detachFeature(e){const t=this._features[e];t&&t.featureImplementation.attached&&(t.featureImplementation.detach()||pe.Warn(`Feature ${e} failed to detach`))}disableFeature(e){const t=typeof e=="string"?e:e.Name,i=this._features[t];return i&&i.enabled?(i.enabled=!1,this.detachFeature(t),i.featureImplementation.dispose(),delete this._features[t],!0):!1}dispose(){const e=this.getEnabledFeatures();for(const t of e)this.disableFeature(t)}enableFeature(e,t="latest",i={},s=!0,r=!0){const a=typeof e=="string"?e:e.Name;let o=0;if(typeof t=="string"){if(!t)throw new Error(`Error in provided version - ${a} (${t})`);if(t==="stable"?o=Dr.GetStableVersionOfFeature(a):t==="latest"?o=Dr.GetLatestVersionOfFeature(a):o=+t,o===-1||isNaN(o))throw new Error(`feature not found - ${a} (${t})`)}else o=t;const c=Dr._ConflictingFeatures[a];if(c!==void 0&&this.getEnabledFeatures().indexOf(c)!==-1)throw new Error(`Feature ${a} cannot be enabled while ${c} is enabled.`);
3112const u=this._features[a],d=Dr.ConstructFeature(a,o,this._xrSessionManager,i);if(!d)throw new Error(`feature not found - ${a}`);u&&this.disableFeature(a);const f=d();if(f.dependsOn&&!f.dependsOn.every(m=>!!this._features[m]))throw new Error(`Dependant features missing. Make sure the following features are enabled - ${f.dependsOn.join(", ")}`);if(f.isCompatible())return this._features[a]={featureImplementation:f,enabled:!0,version:o,required:r},s?this._xrSessionManager.session&&!this._features[a].featureImplementation.attached&&this.attachFeature(a):this._features[a].featureImplementation.disableAutoAttach=!0,this._features[a].featureImplementation;if(r)throw new Error("required feature not compatible");return pe.Warn(`Feature ${a} not compatible with the current environment/browser and was not enabled.`),f}getEnabledFeature(e){return this._features[e]&&this._features[e].featureImplementation}getEnabledFeatures(){return Object.keys(this._features)}async _extendXRSessionInitObject(e){const t=this.getEnabledFeatures();for(const i of t){const s=this._features[i],r=s.featureImplementation.xrNativeFeatureName;if(r&&(s.required?(e.requiredFeatures=e.requiredFeatures||[],e.requiredFeatures.indexOf(r)===-1&&e.requiredFeatures.push(r)):(e.optionalFeatures=e.optionalFeatures||[],e.optionalFeatures.indexOf(r)===-1&&e.optionalFeatures.push(r))),s.featureImplementation.getXRSessionInitExtension){const a=await s.featureImplementation.getXRSessionInitExtension();e={...e,...a}}}return e}}Dr._AvailableFeatures={};Dr._ConflictingFeatures={[Yt.TELEPORTATION]:Yt.MOVEMENT,[Yt.MOVEMENT]:Yt.TELEPORTATION};yi.AddNodeConstructor("TouchCamera",(n,e)=>()=>new BI(n,T.Zero(),e));class BI extends Zo{get touchAngularSensibility(){const e=this.inputs.attached.touch;return e?e.touchAngularSensibility:0}set touchAngularSensibility(e){const t=this.inputs.attached.touch;t&&(t.touchAngularSensibility=e)}get touchMoveSensibility(){const e=this.inputs.attached.touch;return e?e.touchMoveSensibility:0}set touchMoveSensibility(e){const t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)}constructor(e,t,i){super(e,t,i),this.inputs.addTouch(),this._setupInputs()}getClassName(){return"TouchCamera"}_setupInputs(){const e=this.inputs.attached.touch,t=this.inputs.attached.mouse;t?t.touchEnabled=!e:e.allowMouse=!t}}class Hi{get isConnected(){return this._isConnected}constructor(e,t,i,s=0,r=1,a=2,o=3){this.id=e,this.index=t,this.browserGamepad=i,this._leftStick={x:0,y:0},this._rightStick={x:0,y:0},this._isConnected=!0,this._invertLeftStickY=!1,this.type=Hi.GAMEPAD,this._leftStickAxisX=s,this._leftStickAxisY=r,this._rightStickAxisX=a,this._rightStickAxisY=o,this.browserGamepad.axes.length>=2&&(this._leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})}onleftstickchanged(e){this._onleftstickchanged=e}onrightstickchanged(e){this._onrightstickchanged=e}get leftStick(){return this._leftStick}set leftStick(e){this._onleftstickchanged&&(this._leftStick.x!==e.x||this._leftStick.y!==e.y)&&this._onleftstickchanged(e),this._leftStick=e}get rightStick(){return this._rightStick}set rightStick(e){this._onrightstickchanged&&(this._rightStick.x!==e.x||this._rightStick.y!==e.y)&&this._onrightstickchanged(e),this._rightStick=e}update(){this._leftStick&&(this.leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]},this._invertLeftStickY&&(this.leftStick.y*=-1)),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})}dispose(){}}Hi.GAMEPAD=0;Hi.GENERIC=1;Hi.XBOX=2;Hi.POSE_ENABLED=3;Hi.DUALSHOCK=4;class Kz extends Hi{onbuttondown(e){this._onbuttondown=e}onbuttonup(e){this._onbuttonup=e}constructor(e,t,i){super(e,t,i),this.onButtonDownObservable=new le,this.onButtonUpObservable=new le,this.type=Hi.GENERIC,this._buttons=new Array(i.buttons.length)}_setButtonValue(e,t,i){return e!==t&&(e===1&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),e===0&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e}
3112update(){super.update();for(let e=0;e<this._buttons.length;e++)this._buttons[e]=this._setButtonValue(this.browserGamepad.buttons[e].value,this._buttons[e],e)}dispose(){super.dispose(),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear()}}var tA;(function(n){n[n.A=0]="A",n[n.B=1]="B",n[n.X=2]="X",n[n.Y=3]="Y",n[n.LB=4]="LB",n[n.RB=5]="RB",n[n.Back=8]="Back",n[n.Start=9]="Start",n[n.LeftStick=10]="LeftStick",n[n.RightStick=11]="RightStick"})(tA||(tA={}));var iA;(function(n){n[n.Up=12]="Up",n[n.Down=13]="Down",n[n.Left=14]="Left",n[n.Right=15]="Right"})(iA||(iA={}));class qz extends Hi{constructor(e,t,i,s=!1){super(e,t,i,0,1,2,3),this._leftTrigger=0,this._rightTrigger=0,this.onButtonDownObservable=new le,this.onButtonUpObservable=new le,this.onPadDownObservable=new le,this.onPadUpObservable=new le,this._buttonA=0,this._buttonB=0,this._buttonX=0,this._buttonY=0,this._buttonBack=0,this._buttonStart=0,this._buttonLb=0,this._buttonRb=0,this._buttonLeftStick=0,this._buttonRightStick=0,this._dPadUp=0,this._dPadDown=0,this._dPadLeft=0,this._dPadRight=0,this._isXboxOnePad=!1,this.type=Hi.XBOX,this._isXboxOnePad=s}onlefttriggerchanged(e){this._onlefttriggerchanged=e}onrighttriggerchanged(e){this._onrighttriggerchanged=e}get leftTrigger(){return this._leftTrigger}set leftTrigger(e){this._onlefttriggerchanged&&this._leftTrigger!==e&&this._onlefttriggerchanged(e),this._leftTrigger=e}get rightTrigger(){return this._rightTrigger}set rightTrigger(e){this._onrighttriggerchanged&&this._rightTrigger!==e&&this._onrighttriggerchanged(e),this._rightTrigger=e}onbuttondown(e){this._onbuttondown=e}onbuttonup(e){this._onbuttonup=e}ondpaddown(e){this._ondpaddown=e}ondpadup(e){this._ondpadup=e}_setButtonValue(e,t,i){return e!==t&&(e===1&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),e===0&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e}_setDpadValue(e,t,i){return e!==t&&(e===1&&(this._ondpaddown&&this._ondpaddown(i),this.onPadDownObservable.notifyObservers(i)),e===0&&(this._ondpadup&&this._ondpadup(i),this.onPadUpObservable.notifyObservers(i))),e}get buttonA(){return this._buttonA}set buttonA(e){this._buttonA=this._setButtonValue(e,this._buttonA,0)}get buttonB(){return this._buttonB}set buttonB(e){this._buttonB=this._setButtonValue(e,this._buttonB,1)}get buttonX(){return this._buttonX}set buttonX(e){this._buttonX=this._setButtonValue(e,this._buttonX,2)}get buttonY(){return this._buttonY}set buttonY(e){this._buttonY=this._setButtonValue(e,this._buttonY,3)}get buttonStart(){return this._buttonStart}set buttonStart(e){this._buttonStart=this._setButtonValue(e,this._buttonStart,9)}get buttonBack(){return this._buttonBack}set buttonBack(e){this._buttonBack=this._setButtonValue(e,this._buttonBack,8)}get buttonLB(){return this._buttonLb}set buttonLB(e){this._buttonLb=this._setButtonValue(e,this._buttonLb,4)}get buttonRB(){return this._buttonRb}set buttonRB(e){this._buttonRb=this._setButtonValue(e,this._buttonRb,5)}get buttonLeftStick(){return this._buttonLeftStick}set buttonLeftStick(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,10)}get buttonRightStick(){return this._buttonRightStick}set buttonRightStick(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,11)}get dPadUp(){return this._dPadUp}set dPadUp(e){this._dPadUp=this._setDpadValue(e,this._dPadUp,12)}get dPadDown(){return this._dPadDown}set dPadDown(e){this._dPadDown=this._setDpadValue(e,this._dPadDown,13)}get dPadLeft(){return this._dPadLeft}set dPadLeft(e){this._dPadLeft=this._setDpadValue(e,this._dPadLeft,14)}get dPadRight(){return this._dPadRight}set dPadRight(e){this._dPadRight=this._setDpadValue(e,this._dPadRight,15)}update(){super.update(),this._isXboxOnePad?(this.buttonA=this.browserGamepad.buttons[0].value,this.buttonB=this.browserGamepad.buttons[1].value,this.buttonX=this.browserGamepad.buttons[2].value,this.buttonY=this.browserGamepad.buttons[3].value,this.buttonLB=this.browserGamepad.buttons[4].value,this.buttonRB=this.browserGamepad.buttons[5].value,this.leftTrigger=this.browserGamepad.buttons[6].value,this.rightTrigger=this.browserGamepad.buttons[7].value,this.buttonBack=this.browserGamepad.buttons[8].value,this.buttonStart=this.browserGamepad.buttons[9].value,this.buttonLeftStick=this.browserGamepad.buttons[10].value,this.buttonRightStick=this.browserGamepad.buttons[11].value,this.dPadUp=this.browserGamepad.buttons[12].value,this.dPadDown=this.browserGamepad.buttons[13].value,this.dPadLeft=this.browserGamepad.buttons[14].value,this.dPadRight=this.browserGamepad.buttons[15].value):(this.buttonA=this.browserGamepad.buttons[0].value,this.buttonB=this.browserGamepad.buttons[1].value,this.buttonX=this.browserGamepad.buttons[2].value,this.buttonY=this.browserGamepad.buttons[3].value,this.buttonLB=this.browserGamepad.buttons[4].value,this.buttonRB=this.browserGamepad.buttons[5].value,this.leftTrigger=this.browserGamepad.buttons[6].value,this.rightTrigger=this.browserGamepad.buttons[7].value,this.buttonBack=this.browserGamepad.buttons[8].value,this.buttonStart=this.browserGamepad.buttons[9].value,this.buttonLeftStick=this.browserGamepad.buttons[10].value,this.buttonRightStick=this.browserGamepad.buttons[11].value,this.dPadUp=this.browserGamepad.buttons[12].value,this.dPadDown=this.browserGamepad.buttons[13].value,this.dPadLeft=this.browserGamepad.buttons[14].value,this.dPadRight=this.browserGamepad.buttons[15].value)}dispose(){super.dispose(),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear(),this.onPadDownObservable.clear(),this.onPadUpObservable.clear()}}var sA;(function(n){n[n.Cross=0]="Cross",n[n.Circle=1]="Circle",n[n.Square=2]="Square",n[n.Triangle=3]="Triangle",n[n.L1=4]="L1",n[n.R1=5]="R1",n[n.Share=8]="Share",n[n.Options=9]="Options",n[n.LeftStick=10]="LeftStick",n[n.RightStick=11]="RightStick"})(sA||(sA={}));var rA;(function(n){n[n.Up=12]="Up",n[n.Down=13]="Down",n[n.Left=14]="Left",n[n.Right=15]="Right"})(rA||(rA={}));class Zz extends Hi{constructor(e,t,i){super(e.replace("STANDARD GAMEPAD","SONY PLAYSTATION DUALSHOCK"),t,i,0,1,2,3),this._leftTrigger=0,this._rightTrigger=0,this.onButtonDownObservable=new le,this.onButtonUpObservable=new le,this.onPadDownObservable=new le,this.onPadUpObservable=new le,this._buttonCross=0,this._buttonCircle=0,this._buttonSquare=0,this._buttonTriangle=0,this._buttonShare=0,this._buttonOptions=0,this._buttonL1=0,this._buttonR1=0,this._buttonLeftStick=0,this._buttonRightStick=0,this._dPadUp=0,this._dPadDown=0,this._dPadLeft=0,this._dPadRight=0,this.type=Hi.DUALSHOCK}onlefttriggerchanged(e){this._onlefttriggerchanged=e}onrighttriggerchanged(e){this._onrighttriggerchanged=e}get leftTrigger(){return this._leftTrigger}set leftTrigger(e){this._onlefttriggerchanged&&this._leftTrigger!==e&&this._onlefttriggerchanged(e),this._leftTrigger=e}get rightTrigger(){return this._rightTrigger}set rightTrigger(e){this._onrighttriggerchanged&&this._rightTrigger!==e&&this._onrighttriggerchanged(e),this._rightTrigger=e}onbuttondown(e){this._onbuttondown=e}onbuttonup(e){this._onbuttonup=e}ondpaddown(e){this._ondpaddown=e}ondpadup(e){this._ondpadup=e}_setButtonValue(e,t,i){return e!==t&&(e===1&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),e===0&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e}_setDpadValue(e,t,i){return e!==t&&(e===1&&(this._ondpaddown&&this._ondpaddown(i),this.onPadDownObservable.notifyObservers(i)),e===0&&(this._ondpadup&&this._ondpadup(i),this.onPadUpObservable.notifyObservers(i))),e}get buttonCross(){return this._buttonCross}set buttonCross(e){this._buttonCross=this._setButtonValue(e,this._buttonCross,0)}get buttonCircle(){return this._buttonCircle}set buttonCircle(e){this._buttonCircle=this._setButtonValue(e,this._buttonCircle,1)}
3112get buttonSquare(){return this._buttonSquare}set buttonSquare(e){this._buttonSquare=this._setButtonValue(e,this._buttonSquare,2)}get buttonTriangle(){return this._buttonTriangle}set buttonTriangle(e){this._buttonTriangle=this._setButtonValue(e,this._buttonTriangle,3)}get buttonOptions(){return this._buttonOptions}set buttonOptions(e){this._buttonOptions=this._setButtonValue(e,this._buttonOptions,9)}get buttonShare(){return this._buttonShare}set buttonShare(e){this._buttonShare=this._setButtonValue(e,this._buttonShare,8)}get buttonL1(){return this._buttonL1}set buttonL1(e){this._buttonL1=this._setButtonValue(e,this._buttonL1,4)}get buttonR1(){return this._buttonR1}set buttonR1(e){this._buttonR1=this._setButtonValue(e,this._buttonR1,5)}get buttonLeftStick(){return this._buttonLeftStick}set buttonLeftStick(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,10)}get buttonRightStick(){return this._buttonRightStick}set buttonRightStick(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,11)}get dPadUp(){return this._dPadUp}set dPadUp(e){this._dPadUp=this._setDpadValue(e,this._dPadUp,12)}get dPadDown(){return this._dPadDown}set dPadDown(e){this._dPadDown=this._setDpadValue(e,this._dPadDown,13)}get dPadLeft(){return this._dPadLeft}set dPadLeft(e){this._dPadLeft=this._setDpadValue(e,this._dPadLeft,14)}get dPadRight(){return this._dPadRight}set dPadRight(e){this._dPadRight=this._setDpadValue(e,this._dPadRight,15)}update(){super.update(),this.buttonCross=this.browserGamepad.buttons[0].value,this.buttonCircle=this.browserGamepad.buttons[1].value,this.buttonSquare=this.browserGamepad.buttons[2].value,this.buttonTriangle=this.browserGamepad.buttons[3].value,this.buttonL1=this.browserGamepad.buttons[4].value,this.buttonR1=this.browserGamepad.buttons[5].value,this.leftTrigger=this.browserGamepad.buttons[6].value,this.rightTrigger=this.browserGamepad.buttons[7].value,this.buttonShare=this.browserGamepad.buttons[8].value,this.buttonOptions=this.browserGamepad.buttons[9].value,this.buttonLeftStick=this.browserGamepad.buttons[10].value,this.buttonRightStick=this.browserGamepad.buttons[11].value,this.dPadUp=this.browserGamepad.buttons[12].value,this.dPadDown=this.browserGamepad.buttons[13].value,this.dPadLeft=this.browserGamepad.buttons[14].value,this.dPadRight=this.browserGamepad.buttons[15].value}dispose(){super.dispose(),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear(),this.onPadDownObservable.clear(),this.onPadUpObservable.clear()}}class $z{constructor(e){if(this._scene=e,this._babylonGamepads=[],this._oneGamepadConnected=!1,this._isMonitoring=!1,this.onGamepadDisconnectedObservable=new le,Gi()?(this._gamepadEventSupported="GamepadEvent"in window,this._gamepadSupport=navigator&&navigator.getGamepads):this._gamepadEventSupported=!1,this.onGamepadConnectedObservable=new le(t=>{for(const i in this._babylonGamepads){const s=this._babylonGamepads[i];s&&s._isConnected&&this.onGamepadConnectedObservable.notifyObserver(t,s)}}),this._onGamepadConnectedEvent=t=>{const i=t.gamepad;if(i.index in this._babylonGamepads&&this._babylonGamepads[i.index].isConnected)return;let s;this._babylonGamepads[i.index]?(s=this._babylonGamepads[i.index],s.browserGamepad=i,s._isConnected=!0):s=this._addNewGamepad(i),this.onGamepadConnectedObservable.notifyObservers(s),this._startMonitoringGamepads()},this._onGamepadDisconnectedEvent=t=>{const i=t.gamepad;for(const s in this._babylonGamepads)if(this._babylonGamepads[s].index===i.index){const r=this._babylonGamepads[s];r._isConnected=!1,this.onGamepadDisconnectedObservable.notifyObservers(r),r.dispose&&r.dispose();break}},this._gamepadSupport)if(this._updateGamepadObjects(),this._babylonGamepads.length&&this._startMonitoringGamepads(),this._gamepadEventSupported){const t=this._scene?this._scene.getEngine().getHostWindow():window;t&&(t.addEventListener("gamepadconnected",this._onGamepadConnectedEvent,!1),t.addEventListener("gamepaddisconnected",this._onGamepadDisconnectedEvent,!1))}else this._startMonitoringGamepads()}get gamepads(){return this._babylonGamepads}getGamepadByType(e=Hi.XBOX){for(const t of this._babylonGamepads)if(t&&t.type===e)return t;return null}dispose(){this._gamepadEventSupported&&(this._onGamepadConnectedEvent&&window.removeEventListener("gamepadconnected",this._onGamepadConnectedEvent),this._onGamepadDisconnectedEvent&&window.removeEventListener("gamepaddisconnected",this._onGamepadDisconnectedEvent),this._onGamepadConnectedEvent=null,this._onGamepadDisconnectedEvent=null);for(const e of this._babylonGamepads)e.dispose();this.onGamepadConnectedObservable.clear(),this.onGamepadDisconnectedObservable.clear(),this._oneGamepadConnected=!1,this._stopMonitoringGamepads(),this._babylonGamepads=[]}_addNewGamepad(e){this._oneGamepadConnected||(this._oneGamepadConnected=!0);let t;const i=e.id.search("054c")!==-1&&e.id.search("0ce6")===-1,s=e.id.search("Xbox One")!==-1;return s||e.id.search("Xbox 360")!==-1||e.id.search("xinput")!==-1||e.id.search("045e")!==-1&&e.id.search("Surface Dock")===-1?t=new qz(e.id,e.index,e,s):i?t=new Zz(e.id,e.index,e):t=new Kz(e.id,e.index,e),this._babylonGamepads[t.index]=t,t}_startMonitoringGamepads(){this._isMonitoring||(this._isMonitoring=!0,this._checkGamepadsStatus())}_stopMonitoringGamepads(){this._isMonitoring=!1}_checkGamepadsStatus(){this._updateGamepadObjects();for(const e in this._babylonGamepads){const t=this._babylonGamepads[e];
3112if(!(!t||!t.isConnected))try{t.update()}catch{this._loggedErrors.indexOf(t.index)===-1&&(pe.Warn(`Error updating gamepad ${t.id}`),this._loggedErrors.push(t.index))}}this._isMonitoring&&Ce.QueueNewFrame(()=>{this._checkGamepadsStatus()})}_updateGamepadObjects(){const e=navigator.getGamepads?navigator.getGamepads():[];for(let t=0;t<e.length;t++){const i=e[t];if(i)if(this._babylonGamepads[i.index])this._babylonGamepads[t].browserGamepad=i,this._babylonGamepads[t].isConnected||(this._babylonGamepads[t]._isConnected=!0,this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[t]));else{const s=this._addNewGamepad(i);this.onGamepadConnectedObservable.notifyObservers(s)}}}}class qf{constructor(){this.gamepadAngularSensibility=200,this.gamepadMoveSensibility=40,this.deadzoneDelta=.1,this._yAxisScale=1,this._cameraTransform=W.Identity(),this._deltaTransform=T.Zero(),this._vector3=T.Zero(),this._vector2=Ie.Zero()}get invertYAxis(){return this._yAxisScale!==1}set invertYAxis(e){this._yAxisScale=e?-1:1}attachControl(){const e=this.camera.getScene().gamepadManager;this._onGamepadConnectedObserver=e.onGamepadConnectedObservable.add(t=>{t.type!==Hi.POSE_ENABLED&&(!this.gamepad||t.type===Hi.XBOX)&&(this.gamepad=t)}),this._onGamepadDisconnectedObserver=e.onGamepadDisconnectedObservable.add(t=>{this.gamepad===t&&(this.gamepad=null)}),this.gamepad=e.getGamepadByType(Hi.XBOX),!this.gamepad&&e.gamepads.length&&(this.gamepad=e.gamepads[0])}detachControl(){this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),this.gamepad=null}checkInputs(){if(this.gamepad&&this.gamepad.leftStick){const e=this.camera,t=this.gamepad.leftStick;this.gamepadMoveSensibility!==0&&(t.x=Math.abs(t.x)>this.deadzoneDelta?t.x/this.gamepadMoveSensibility:0,t.y=Math.abs(t.y)>this.deadzoneDelta?t.y/this.gamepadMoveSensibility:0);let i=this.gamepad.rightStick;i&&this.gamepadAngularSensibility!==0?(i.x=Math.abs(i.x)>this.deadzoneDelta?i.x/this.gamepadAngularSensibility:0,i.y=(Math.abs(i.y)>this.deadzoneDelta?i.y/this.gamepadAngularSensibility:0)*this._yAxisScale):i={x:0,y:0},e.rotationQuaternion?e.rotationQuaternion.toRotationMatrix(this._cameraTransform):W.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,this._cameraTransform);const s=e._computeLocalCameraSpeed()*50;this._vector3.copyFromFloats(t.x*s,0,-t.y*s),T.TransformCoordinatesToRef(this._vector3,this._cameraTransform,this._deltaTransform),e.cameraDirection.addInPlace(this._deltaTransform),this._vector2.copyFromFloats(i.y,i.x),e.cameraRotation.addInPlace(this._vector2)}}getClassName(){return"FreeCameraGamepadInput"}getSimpleName(){return"gamepad"}}N([H()],qf.prototype,"gamepadAngularSensibility",void 0);N([H()],qf.prototype,"gamepadMoveSensibility",void 0);qr.FreeCameraGamepadInput=qf;class Zf{constructor(){this.gamepadRotationSensibility=80,this.gamepadMoveSensibility=40,this._yAxisScale=1}get invertYAxis(){return this._yAxisScale!==1}set invertYAxis(e){this._yAxisScale=e?-1:1}attachControl(){const e=this.camera.getScene().gamepadManager;this._onGamepadConnectedObserver=e.onGamepadConnectedObservable.add(t=>{t.type!==Hi.POSE_ENABLED&&(!this.gamepad||t.type===Hi.XBOX)&&(this.gamepad=t)}),this._onGamepadDisconnectedObserver=e.onGamepadDisconnectedObservable.add(t=>{this.gamepad===t&&(this.gamepad=null)}),this.gamepad=e.getGamepadByType(Hi.XBOX),!this.gamepad&&e.gamepads.length&&(this.gamepad=e.gamepads[0])}detachControl(){this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),this.gamepad=null}checkInputs(){if(this.gamepad){const e=this.camera,t=this.gamepad.rightStick;if(t){if(t.x!=0){const s=t.x/this.gamepadRotationSensibility;s!=0&&Math.abs(s)>.005&&(e.inertialAlphaOffset+=s)}if(t.y!=0){const s=t.y/this.gamepadRotationSensibility*this._yAxisScale;s!=0&&Math.abs(s)>.005&&(e.inertialBetaOffset+=s)}}const i=this.gamepad.leftStick;if(i&&i.y!=0){const s=i.y/this.gamepadMoveSensibility;s!=0&&Math.abs(s)>.005&&(this.camera.inertialRadiusOffset-=s)}}}getClassName(){return"ArcRotateCameraGamepadInput"}getSimpleName(){return"gamepad"}}
3112N([H()],Zf.prototype,"gamepadRotationSensibility",void 0);N([H()],Zf.prototype,"gamepadMoveSensibility",void 0);qr.ArcRotateCameraGamepadInput=Zf;Object.defineProperty(Pt.prototype,"gamepadManager",{get:function(){if(!this._gamepadManager){this._gamepadManager=new $z(this);let n=this._getComponent(Ye.NAME_GAMEPAD);n||(n=new Qz(this),this._addComponent(n))}return this._gamepadManager},enumerable:!0,configurable:!0});NI.prototype.addGamepad=function(){return this.add(new qf),this};wI.prototype.addGamepad=function(){return this.add(new Zf),this};class Qz{constructor(e){this.name=Ye.NAME_GAMEPAD,this.scene=e}register(){}rebuild(){}dispose(){const e=this.scene._gamepadManager;e&&(e.dispose(),this.scene._gamepadManager=null)}}yi.AddNodeConstructor("FreeCamera",(n,e)=>()=>new UI(n,T.Zero(),e));class UI extends BI{get gamepadAngularSensibility(){const e=this.inputs.attached.gamepad;return e?e.gamepadAngularSensibility:0}set gamepadAngularSensibility(e){const t=this.inputs.attached.gamepad;t&&(t.gamepadAngularSensibility=e)}get gamepadMoveSensibility(){const e=this.inputs.attached.gamepad;return e?e.gamepadMoveSensibility:0}set gamepadMoveSensibility(e){const t=this.inputs.attached.gamepad;t&&(t.gamepadMoveSensibility=e)}constructor(e,t,i){super(e,t,i),this.inputs.addGamepad()}getClassName(){return"UniversalCamera"}}Ge._CreateDefaultParsedCamera=(n,e)=>new UI(n,T.Zero(),e);class Tn{constructor(e,t,i=-1,s=[]){this.id=e,this.type=t,this._buttonIndex=i,this._axesIndices=s,this._axes={x:0,y:0},this._changes={},this._currentValue=0,this._hasChanges=!1,this._pressed=!1,this._touched=!1,this.onAxisValueChangedObservable=new le,this.onButtonStateChangedObservable=new le}get axes(){return this._axes}get changes(){return this._changes}get hasChanges(){return this._hasChanges}get pressed(){return this._pressed}get touched(){return this._touched}get value(){return this._currentValue}dispose(){this.onAxisValueChangedObservable.clear(),this.onButtonStateChangedObservable.clear()}isAxes(){return this._axesIndices.length!==0}isButton(){return this._buttonIndex!==-1}update(e){let t=!1,i=!1;if(this._hasChanges=!1,this._changes={},this.isButton()){const s=e.buttons[this._buttonIndex];if(!s)return;this._currentValue!==s.value&&(this.changes.value={current:s.value,previous:this._currentValue},t=!0,this._currentValue=s.value),this._touched!==s.touched&&(this.changes.touched={current:s.touched,previous:this._touched},t=!0,this._touched=s.touched),this._pressed!==s.pressed&&(this.changes.pressed={current:s.pressed,previous:this._pressed},t=!0,this._pressed=s.pressed)}this.isAxes()&&(this._axes.x!==e.axes[this._axesIndices[0]]&&(this.changes.axes={current:{x:e.axes[this._axesIndices[0]],y:this._axes.y},previous:{x:this._axes.x,y:this._axes.y}},this._axes.x=e.axes[this._axesIndices[0]],i=!0),this._axes.y!==e.axes[this._axesIndices[1]]&&(this.changes.axes?this.changes.axes.current.y=e.axes[this._axesIndices[1]]:this.changes.axes={current:{x:this._axes.x,y:e.axes[this._axesIndices[1]]},previous:{x:this._axes.x,y:this._axes.y}},this._axes.y=e.axes[this._axesIndices[1]],i=!0)),t&&(this._hasChanges=!0,this.onButtonStateChangedObservable.notifyObservers(this)),i&&(this._hasChanges=!0,this.onAxisValueChangedObservable.notifyObservers(this._axes))}}Tn.BUTTON_TYPE="button";Tn.SQUEEZE_TYPE="squeeze";Tn.THUMBSTICK_TYPE="thumbstick";Tn.TOUCHPAD_TYPE="touchpad";Tn.TRIGGER_TYPE="trigger";async function Jz(n,e){const t=e.method||"GET";return await new Promise((i,s)=>{const r=new Ai;r.addEventListener("readystatechange",()=>{if(r.readyState==4)if(r.status==200){const a={};if(e.responseHeaders)for(const o of e.responseHeaders)a[o]=r.getResponseHeader(o)||"";i({response:r.response,headerValues:a})}else s(`Unable to fetch data from ${n}. Error code: ${r.status}`)}),r.open(t,n),r.send()})}var nA;(function(n){n[n.Clean=0]="Clean",n[n.Stop=1]="Stop",n[n.Sync=2]="Sync",n[n.NoSync=3]="NoSync"})(nA||(nA={}));function e4(n){return!!n.createPlugin}function t4(n){return!!n.name}const kI=new le,xn={};let Wg=!1;function $f(){return xn[".babylon"]}function i4(n){for(const e in xn){const t=xn[e];if(t.mimeType===n)return t}}function jm(n,e){const t=xn[n];return t||(oe.Warn("Unable to find a plugin to load "+n+" files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: https://doc.babylonjs.com/features/featuresDeepDive/importers/loadingFileTypes"),e?$f():void 0)}function s4(n){return!!xn[n]}function r4(n){for(const e in xn){const t=xn[e].plugin;if(t.canDirectLoad&&t.canDirectLoad(n))return xn[e]}return $f()}function n4(n){const e=n.indexOf("?");e!==-1&&(n=n.substring(0,e));const t=n.lastIndexOf(".");return n.substring(t,n.length).toLowerCase()}function a4(n){return n.substring(0,5)==="data:"?n.substring(5):null}function Kb(n,e,t){let s="Unable to load from "+(n.rawData?"binary data":n.url);return e?s+=`: ${e}`:t&&(s+=`: ${t}`),s}async function qb(n,e,t,i,s,r,a,o,c){const u=a4(n.url);if(n.rawData&&!a)throw"When using ArrayBufferView to load data the file extension must be provided.";const d=!u&&!a?n4(n.url):"";let f=a?jm(a,!0):u?r4(n.url):jm(d,!1);if(!f&&d){if(n.url&&!n.url.startsWith("blob:")){const m=await Jz(n.url,{method:"HEAD",responseHeaders:["Content-Type"]}),b=m.headerValues?m.headerValues["Content-Type"]:"";b&&(f=i4(b))}f||(f=$f())}if(!f)throw new Error(`No plugin or fallback for ${a??n.url}`);if(c?.[f.plugin.name]?.enabled===!1)throw new Error(`The '${f.plugin.name}' plugin is disabled via the loader options passed to the loading operation.`);if(n.rawData&&!f.isBinary)throw"Loading from ArrayBufferView can not be used with plugins that don't support binary loading.";return(m=>{if(e4(f.plugin)){const x=f.plugin.createPlugin(c??{});return x instanceof Promise?(x.then(m).catch(v=>{s("Error instantiating plugin.",v)}),null):(m(x),x)}else return m(f.plugin),f.plugin})(m=>{if(!m)throw`The loader plugin corresponding to the '${a}' file type has not been found. If using es6, please import the plugin you wish to use before.`;if(kI.notifyObservers(m),u&&(m.canDirectLoad&&m.canDirectLoad(n.url)||!Cb(n.url))){if
vendor: 1,971 bytes, line 3112
3112(m.directLoad){const R=m.directLoad(e,u);R instanceof Promise?R.then(C=>{t(m,C)}).catch(C=>{s("Error in directLoad of _loadData: "+C,C)}):t(m,R)}else t(m,u);return}const b=f.isBinary,x=(R,C)=>{if(e.isDisposed){s("Scene has been disposed");return}t(m,R,C)};let v=null,E=!1;m.onDisposeObservable?.add(()=>{E=!0,v&&(v.abort(),v=null),r()});const A=()=>{if(E)return;const R=(C,M)=>{s(C?.statusText,M)};if(!m.loadFile&&n.rawData)throw"Plugin does not support loading ArrayBufferView.";v=m.loadFile?m.loadFile(e,n.rawData||n.file||n.url,n.rootUrl,x,i,b,R,o):e._loadFile(n.file||n.url,x,i,!0,b,R)},D=e.getEngine();let I=D.enableOfflineSupport;if(I){let R=!1;for(const C of e.disableOfflineSupportExceptionRules)if(C.test(n.url)){R=!0;break}I=!R}I&&Ce.OfflineProviderFactory?e.offlineProvider=Ce.OfflineProviderFactory(n.url,A,D.disableManifestCheck):A()})}function Zb(n,e){let t,i,s=null,r=null;if(!e)t=n,i=pe.GetFilename(n),n=pe.GetFolderPath(n);else if(t4(e))t=`file:${e.name}`,i=e.name,s=e;else if(ArrayBuffer.isView(e))t="",i=Tb(),r=e;else if(e.startsWith("data:"))t=e,i="";else if(n){const a=e;if(a.substring(0,1)==="/")return pe.Error("Wrong sceneFilename parameter"),null;t=n+a,i=a}else t=e,i=pe.GetFilename(e),n=pe.GetFolderPath(e);return{url:t,rootUrl:n,name:i,file:s,rawData:r}}function o4(n){if(typeof n.extensions=="string"){const e=n.extensions;xn[e.toLowerCase()]={plugin:n,isBinary:!1}}else{const e=n.extensions,t=Object.keys(e);for(const i of t)xn[i.toLowerCase()]={plugin:n,isBinary:e[i].isBinary,mimeType:e[i].mimeType}}}async function VI(n,e,t="",i=Ke.LastCreatedScene,s=null,r=null,a=null,o=null,c="",u={}){if(!i)return oe.Error("No scene available to import mesh to"),null;const d=Zb(e,t);if(!d)return null;const f={};i.addPendingData(f);const g=()=>{i.removePendingData(f)},m=(v,E)=>{const A=Kb(d,v,E);a?a(i,A,new ua(A,Ko.SceneLoaderError,E)):oe.Error(A),g()},b=r?v=>{try{r(v)}catch(E){m("Error in onProgress callback: "+E,E)}}:void 0,x=(v,E,A,D,I,R,C,M)=>
3112{if(i.importedMeshesFiles.push(d.url),s)try{s(v,E,A,D,I,R,C,M)}catch(F){m("Error in onSuccess callback: "+F,F)}i.removePendingData(f)};return await qb(d,i,(v,E,A)=>{if(v.rewriteRootURL&&(d.rootUrl=v.rewriteRootURL(d.rootUrl,A)),v.importMesh){const D=v,I=[],R=[],C=[];if(!D.importMesh(n,i,E,d.rootUrl,I,R,C,m))return;i.loadingPluginName=v.name,x(I,R,C,[],[],[],[],[])}else v.importMeshAsync(n,i,E,d.rootUrl,b,d.name).then(I=>{i.loadingPluginName=v.name,x(I.meshes,I.particleSystems,I.skeletons,I.animationGroups,I.transformNodes,I.geometries,I.lights,I.spriteManagers)}).catch(I=>{m(I.message,I)})},b,m,g,o,c,u)}async function l4(n,e,t,i,s,r,a,o){return await new Promise((c,u)=>{try{VI(n,e,t,i,(d,f,g,m,b,x,v,E)=>{c({meshes:d,particleSystems:f,skeletons:g,animationGroups:m,transformNodes:b,geometries:x,lights:v,spriteManagers:E})},s,(d,f,g)=>{u(g||new Error(f))},r,a,o).catch(u)}catch(d){u(d)}})}async function zI(n,e="",t=Ke.LastCreatedEngine,i=null,s=null,r=null,a=null,o="",c={}){if(!t){pe.Error("No engine available");return}await $b(n,e,new Pt(t),i,s,r,a,o,c)}async function c4(n,e,t,i,s,r,a){return await new Promise((o,c)=>{zI(n,e,t,u=>{o(u)},i,(u,d,f)=>{c(f||new Error(d))},s,r,a)})}async function $b(n,e="",t=Ke.LastCreatedScene,i=null,s=null,r=null,a=null,o="",c={}){if(!t)return oe.Error("No scene available to append to"),null;const u=Zb(n,e);if(!u)return null;const d={};t.addPendingData(d);const f=()=>{t.removePendingData(d)};bi.ShowLoadingScreen&&!Wg&&(Wg=!0,t.getEngine().displayLoadingUI(),t.executeWhenReady(()=>{t.getEngine().hideLoadingUI(),Wg=!1}));const g=(x,v)=>{const E=Kb(u,x,v);r?r(t,E,new ua(E,Ko.SceneLoaderError,v)):oe.Error(E),f()},m=s?x=>{try{s(x)}catch(v){g("Error in onProgress callback",v)}}:void 0,b=()=>{if(i)try{i(t)}catch(x){g("Error in onSuccess callback",x)}t.removePendingData(d)};return await qb(u,t,(x,v)=>{if(x.load){if(!x.load(t,v,u.rootUrl,g))return;t.loadingPluginName=x.name,b()}else x.loadAsync(t,v,u.rootUrl,m,u.name).then(()=>{t.loadingPluginName=x.name,b()}).catch(A=>{g(A.message,A)})},m,g,f,a,o,c)}async function h4(n,e,t,i,s,r,a){return await new Promise((o,c)=>{try{$b(n,e,t,u=>{o(u)},i,(u,d,f)=>{c(f||new Error(d))},s,r,a).catch(c)}catch(u){c(u)}})}async function Qb(n,e="",t=Ke.LastCreatedScene,i=null,s=null,r=null,a=null,o="",c={}){if(!t)return oe.Error("No scene available to load asset container to"),null;const u=Zb(n,e);if(!u)return null;const d={};t.addPendingData(d);const f=()=>{t.removePendingData(d)},g=(x,v)=>{const E=Kb(u,x,v);r?r(t,E,new ua(E,Ko.SceneLoaderError,v)):oe.Error(E),f()},m=s?x=>{try{s(x)}catch(v){g("Error in onProgress callback",v)}}:void 0,b=x=>{if(i)try{i(x)}catch(v){g("Error in onSuccess callback",v)}t.removePendingData(d)};return await qb(u,t,(x,v)=>{if(x.loadAssetContainer){const A=x.loadAssetContainer(t,v,u.rootUrl,g);if(!A)return;A.populateRootNodes(),t.loadingPluginName=x.name,b(A)}else x.loadAssetContainerAsync?x.loadAssetContainerAsync(t,v,u.rootUrl,m,u.name).then(A=>{A.populateRootNodes(),t.loadingPluginName=x.name,b(A)}).catch(A=>{g(A.message,A)}):g("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.")},m,g,f,a,o,c)}async function u4(n,e,t,i,s,r,a){return await new Promise((o,c)=>{try{Qb(n,e,t,u=>{o(u)},i,(u,d,f)=>{c(f||new Error(d))},s,r,a).catch(c)}catch(u){c(u)}})}async function GI(n,e="",t=Ke.LastCreatedScene,i=!0,s=0,r=null,a=null,o=null,c=null,u=null,d="",f={}){if(!t){oe.Error("No scene available to load animations to");return}if(i){for(const v of t.animatables)v.reset();t.stopAllAnimations();const b=t.animationGroups.slice();for(const v of b)v.dispose();const x=t.getNodes();for(const v of x)v.animations&&(v.animations=[])}else switch(s){case 0:const b=t.animationGroups.slice();for(const x of b)x.dispose();break;case 1:for(const x of t.animationGroups)x.stop();break;case 2:for(const x of t.animationGroups)x.reset(),x.restart();break;case 3:break;default:oe.Error("Unknown animation group loading mode value '"+s+"'");return}const g=t.animatables.length;await Qb(n,e,t,b=>{b.mergeAnimationsTo(t,t.animatables.slice(g),r),b.dispose(),t.onAnimationFileImportedObservable.notifyObservers(t),a&&a(t)},o,c,u,d,f)}
3112async function d4(n,e,t,i,s,r,a,o,c,u){return await new Promise((d,f)=>{try{GI(n,e,t,i,s,r,g=>{d(g)},a,(g,m,b)=>{f(b||new Error(m))},o,c,u).catch(f)}catch(g){f(g)}})}class ca{static get ForceFullSceneLoadingForIncremental(){return bi.ForceFullSceneLoadingForIncremental}static set ForceFullSceneLoadingForIncremental(e){bi.ForceFullSceneLoadingForIncremental=e}static get ShowLoadingScreen(){return bi.ShowLoadingScreen}static set ShowLoadingScreen(e){bi.ShowLoadingScreen=e}static get loggingLevel(){return bi.loggingLevel}static set loggingLevel(e){bi.loggingLevel=e}static get CleanBoneMatrixWeights(){return bi.CleanBoneMatrixWeights}static set CleanBoneMatrixWeights(e){bi.CleanBoneMatrixWeights=e}static GetDefaultPlugin(){return $f()}static GetPluginForExtension(e){return jm(e,!0)?.plugin}static IsPluginForExtensionAvailable(e){return s4(e)}static RegisterPlugin(e){o4(e)}static ImportMesh(e,t,i,s,r,a,o,c,u,d){VI(e,t,i,s,r,a,o,c,u,d).catch(f=>o?.(Ke.LastCreatedScene,f?.message,f))}static async ImportMeshAsync(e,t,i,s,r,a,o){return await l4(e,t,i,s,r,a,o)}static Load(e,t,i,s,r,a,o,c){zI(e,t,i,s,r,a,o,c).catch(u=>a?.(Ke.LastCreatedScene,u?.message,u))}static async LoadAsync(e,t,i,s,r,a){return await c4(e,t,i,s,r,a)}static Append(e,t,i,s,r,a,o,c){$b(e,t,i,s,r,a,o,c).catch(u=>a?.(i??Ke.LastCreatedScene,u?.message,u))}static async AppendAsync(e,t,i,s,r,a){return await h4(e,t,i,s,r,a)}static LoadAssetContainer(e,t,i,s,r,a,o,c){Qb(e,t,i,s,r,a,o,c).catch(u=>a?.(i??Ke.LastCreatedScene,u?.message,u))}static async LoadAssetContainerAsync(e,t,i,s,r,a){return await u4(e,t,i,s,r,a)}static ImportAnimations(e,t,i,s,r,a,o,c,u,d,f){GI(e,t,i,s,r,a,o,c,u,d,f).catch(g=>u?.(i??Ke.LastCreatedScene,g?.message,g))}static async ImportAnimationsAsync(e,t,i,s,r,a,o,c,u,d,f){return await d4(e,t,i,s,r,a,c,d,f)}}ca.NO_LOGGING=0;ca.MINIMAL_LOGGING=1;ca.SUMMARY_LOGGING=2;ca.DETAILED_LOGGING=3;ca.OnPluginActivatedObservable=kI;class HI{constructor(e,t,i,s,r=!1,a){if(this.scene=e,this.layout=t,this.gamepadObject=i,this.handedness=s,this._doNotLoadControllerMesh=r,this._controllerCache=a,this._initComponent=o=>{if(!o)return;const c=this.layout.components[o],u=c.type,d=c.gamepadIndices.button,f=[];c.gamepadIndices.xAxis!==void 0&&c.gamepadIndices.yAxis!==void 0&&f.push(c.gamepadIndices.xAxis,c.gamepadIndices.yAxis),this.components[o]=new Tn(o,u,d,f)},this._modelReady=!1,this.components={},this.disableAnimation=!1,this.onModelLoadedObservable=new le,t.components){const o=Object.keys(t.components);for(const c of o)this._initComponent(c)}}dispose(){const e=this.getComponentIds();for(const t of e)this.getComponent(t).dispose();if(this.rootMesh){const t=this.rootMesh.getChildren(void 0,!0);for(const i of t)i.setEnabled(!1);this.rootMesh.dispose(!!this._controllerCache,!this._controllerCache)}this.onModelLoadedObservable.clear()}getAllComponentsOfType(e){return this.getComponentIds().map(t=>this.components[t]).filter(t=>t.type===e)}getComponent(e){return this.components[e]}getComponentIds(){return Object.keys(this.components)}getComponentOfType(e){return this.getAllComponentsOfType(e)[0]||null}getMainComponent(){return this.getComponent(this.layout.selectComponentId)}async loadModel(){const e=!this._getModelLoadingConstraints();let t=this._getGenericFilenameAndPath();return e?oe.Warn("Falling back to generic models"):t=this._getFilenameAndPath(),await new Promise((i,s)=>{const r=a=>{e?this._getGenericParentMesh(a):this._setRootMesh(a),this._processLoadedModel(a),this._modelReady=!0,this.onModelLoadedObservable.notifyObservers(this),i(!0)};if(this._controllerCache){const a=this._controllerCache.filter(o=>o.filename===t.filename&&o.path===t.path);if(a[0]){for(const o of a[0].meshes)o.setEnabled(!0);r(a[0].meshes);return}}ca.ImportMesh("",t.path,t.filename,this.scene,a=>{this._controllerCache&&this._controllerCache.push({...t,meshes:a}),r(a)},null,(a,o)=>{oe.Log(o),oe.Warn(`Failed to retrieve controller model of type ${this.profileId} from the remote server: ${t.path}${t.filename}`),s(o)})})}updateFromXRFrame(e){for(const t of this.getComponentIds())this.getComponent(t).update(this.gamepadObject);this.updateModel(e)}get handness(){return this.handedness}async pulse(e,t,i=0){return this.gamepadObject.hapticActuators&&this.gamepadObject.hapticActuators[i]?await this.gamepadObject.hapticActuators[i].pulse(e,t):!1}_getChildByName(e,t){return e.getChildren(i=>i.name===t,!1)[0]}_getImmediateChildByName(e,t){return e.getChildren(i=>i.name==t,!0)[0]}_lerpTransform(e,t,i){if(!e.minMesh||!e.maxMesh||!e.valueMesh||!e.minMesh.rotationQuaternion||!e.maxMesh.rotationQuaternion||!e.valueMesh.rotationQuaternion)return;const s=i?t*.5+.5:t;Se.SlerpToRef(e.minMesh.rotationQuaternion,e.maxMesh.rotationQuaternion,s,e.valueMesh.rotationQuaternion),T.LerpToRef(e.minMesh.position,e.maxMesh.position,s,e.valueMesh.position)}updateModel(e){this._modelReady&&this._updateModel(e)}_getGenericFilenameAndPath(){return{filename:"generic.babylon",path:"https://controllers.babylonjs.com/generic/"}}_getGenericParentMesh(e){this.rootMesh=new Z(this.profileId+" "+this.handedness,this.scene);for(const t of e)t.parent||(t.isPickable=!1,t.setParent(this.rootMesh));this.rootMesh.rotationQuaternion=Se.FromEulerAngles(0,Math.PI,0)}}class Vh extends HI{constructor(e,t,i){super(e,f4[i],t,i),this.profileId=Vh.ProfileId}_getFilenameAndPath(){return{filename:"generic.babylon",path:"https://controllers.babylonjs.com/generic/"}}_getModelLoadingConstraints(){return!0}_processLoadedModel(e){}_setRootMesh(e){this.rootMesh=new Z(this.profileId+" "+this.handedness,this.scene);for(const t of e)t.isPickable=!1,t.parent||t.setParent(this.rootMesh);this.rootMesh.rotationQuaternion=Se.FromEulerAngles(0,Math.PI,0)}_updateModel(){}}Vh.ProfileId="generic-trigger";const f4={left:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"generic-trigger-left",assetPath:"left.glb"},right:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"generic-trigger-right",assetPath:"right.glb"}
3112,none:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"generic-trigger-none",assetPath:"none.glb"}};class p4 extends HI{constructor(e,t,i,s,r){super(e,i.layouts[t.handedness||"none"],t.gamepad,t.handedness,void 0,r),this._repositoryUrl=s,this.controllerCache=r,this._buttonMeshMapping={},this._touchDots={},this.profileId=i.profileId}dispose(){if(super.dispose(),!this.controllerCache){const e=Object.keys(this._touchDots);for(const t of e)this._touchDots[t].dispose()}}_getFilenameAndPath(){return{filename:this.layout.assetPath,path:`${this._repositoryUrl}/profiles/${this.profileId}/`}}_getModelLoadingConstraints(){const e=ca.IsPluginForExtensionAvailable(".glb");return e||oe.Warn("glTF / glb loader was not registered, using generic controller instead"),e}_processLoadedModel(e){const t=this.getComponentIds();for(const i of t){const s=this.layout.components[i];this._buttonMeshMapping[i]={mainMesh:this._getChildByName(this.rootMesh,s.rootNodeName),states:{}};const r=Object.keys(s.visualResponses);for(const a of r){const o=s.visualResponses[a];if(o.valueNodeProperty==="transform")this._buttonMeshMapping[i].states[a]={valueMesh:this._getChildByName(this.rootMesh,o.valueNodeName),minMesh:this._getChildByName(this.rootMesh,o.minNodeName),maxMesh:this._getChildByName(this.rootMesh,o.maxNodeName)};else{const c=s.type===Tn.TOUCHPAD_TYPE&&s.touchPointNodeName?s.touchPointNodeName:o.valueNodeName;if(this._buttonMeshMapping[i].states[a]={valueMesh:this._getChildByName(this.rootMesh,c)},s.type===Tn.TOUCHPAD_TYPE&&!this._touchDots[a]){const u=Uh(a+"dot",{diameter:.0015,segments:8},this.scene);u.material=new Ae(a+"mat",this.scene),u.material.diffuseColor=Ne.Red(),u.parent=this._buttonMeshMapping[i].states[a].valueMesh||null,u.isVisible=!1,this._touchDots[a]=u}}}}}_setRootMesh(e){this.rootMesh=new Z(this.profileId+"-"+this.handedness,this.scene),this.rootMesh.isPickable=!1;let t;for(let i=0;i<e.length;i++){const s=e[i];s.isPickable=!1,s.parent||(t=s)}t&&t.setParent(this.rootMesh),this.scene.useRightHandedSystem||this.rootMesh.rotate(wr.Y,Math.PI,1)}_updateModel(e){if(this.disableAnimation)return;const t=this.getComponentIds();for(const i of t){const s=this.getComponent(i);if(!s.hasChanges)continue;const r=this._buttonMeshMapping[i],a=this.layout.components[i],o=Object.keys(a.visualResponses);for(const c of o){const u=a.visualResponses[c];let d=s.value;if(u.componentProperty==="xAxis"?d=s.axes.x:u.componentProperty==="yAxis"&&(d=s.axes.y),u.valueNodeProperty==="transform")this._lerpTransform(r.states[c],d,u.componentProperty!=="button");else{const f=r.states[c].valueMesh;f&&(f.isVisible=s.touched||s.pressed),this._touchDots[c]&&(this._touchDots[c].isVisible=s.touched||s.pressed)}}}}}const Xg=[];class da{static ClearProfilesCache(){this._ProfilesList=null,this._ProfileLoadingPromises={}}static DefaultFallbacks(){this.RegisterFallbacksForProfileId("google-daydream",["generic-touchpad"]),this.RegisterFallbacksForProfileId("htc-vive-focus",["generic-trigger-touchpad"]),this.RegisterFallbacksForProfileId("htc-vive",["generic-trigger-squeeze-touchpad"]),this.RegisterFallbacksForProfileId("magicleap-one",["generic-trigger-squeeze-touchpad"]),this.RegisterFallbacksForProfileId("windows-mixed-reality",["generic-trigger-squeeze-touchpad-thumbstick"]),this.RegisterFallbacksForProfileId("microsoft-mixed-reality",["windows-mixed-reality","generic-trigger-squeeze-touchpad-thumbstick"]),this.RegisterFallbacksForProfileId("oculus-go",["generic-trigger-touchpad"]),this.RegisterFallbacksForProfileId("oculus-touch-v2",["oculus-touch","generic-trigger-squeeze-thumbstick"]),this.RegisterFallbacksForProfileId("oculus-touch",["generic-trigger-squeeze-thumbstick"]),this.RegisterFallbacksForProfileId("samsung-gearvr",["windows-mixed-reality","generic-trigger-squeeze-touchpad-thumbstick"]),this.RegisterFallbacksForProfileId("samsung-odyssey",["generic-touchpad"]),this.RegisterFallbacksForProfileId("valve-index",["generic-trigger-squeeze-touchpad-thumbstick"]),this.RegisterFallbacksForProfileId("generic-hand-select",["generic-trigger"]),this.RegisterFallbacksForProfileId("oculus-hand",["generic-trigger"])}static FindFallbackWithProfileId(e){const t=this._Fallbacks[e]||[];return t.unshift(e),t}static async GetMotionControllerWithXRInput(e,t,i){const s=[];if(i&&s.push(i),s.push(...e.profiles||[]),s.length&&!s[0]&&s.pop(),e.gamepad&&e.gamepad.id)switch(e.gamepad.id){case(e.gamepad.id.match(/oculus touch/gi)?e.gamepad.id:void 0):s.push("oculus-touch-v2");break}const r=s.indexOf("windows-mixed-reality");if(r!==-1&&s.splice(r,0,"microsoft-mixed-reality"),s.length||s.push("generic-trigger"),this.UseOnlineRepository){const a=this.PrioritizeOnlineRepository?this._LoadProfileFromRepositoryAsync:this._LoadProfilesFromAvailableControllersAsync,o=this.PrioritizeOnlineRepository?this._LoadProfilesFromAvailableControllersAsync:this._LoadProfileFromRepositoryAsync;return a.call(this,s,e,t).catch(()=>o.call(this,s,e,t))}else return await this._LoadProfilesFromAvailableControllersAsync(s,e,t)}static RegisterController(e,t){this._AvailableControllers[e]=t}static RegisterFallbacksForProfileId(e,t){this._Fallbacks[e]?this._Fallbacks[e].push(...t):this._Fallbacks[e]=t}static async UpdateProfilesList(){const e=await pe.LoadFileAsync(this.BaseRepositoryUrl+"/profiles/profilesList.json",!1);return this._ProfilesList=JSON.parse(e),await this._ProfilesList}static ClearControllerCache(){for(const e of Xg)for(const t of e.meshes)t.dispose(!1,!0);Xg.length=0}static async _LoadProfileFromRepositoryAsync(e,t,i){return await Promise.resolve().then(async()=>this._ProfilesList?await this._ProfilesList:await this.UpdateProfilesList()).then(s=>{for(let r=0;r<e.length;++r)if(e[r]&&s[e[r]])return e[r];throw new Error(`neither controller ${e[0]} nor all fallbacks were found in the repository,`)}).then(async s=>(this._ProfileLoadingPromises[s]||(this._ProfileLoadingPromises[s]=pe.LoadFileAsync(`${this.BaseRepositoryUrl}/profiles/${s}/profile.json`,!1).then(r=>JSON.parse(r))),await this._ProfileLoadingPromises[s])).then(s=>
vendor: 10,017 bytes, line 3112
3112new p4(i,t,s,this.BaseRepositoryUrl,this.DisableControllerCache?void 0:Xg))}static async _LoadProfilesFromAvailableControllersAsync(e,t,i){for(let s=0;s<e.length;++s){if(!e[s])continue;const r=this.FindFallbackWithProfileId(e[s]);for(let a=0;a<r.length;++a){const o=this._AvailableControllers[r[a]];if(o)return o(t,i)}}throw new Error("no controller requested was found in the available controllers list")}}da._AvailableControllers={};da._Fallbacks={};da._ProfileLoadingPromises={};da.BaseRepositoryUrl="https://immersive-web.github.io/webxr-input-profiles/packages/viewer/dist";da.PrioritizeOnlineRepository=!0;da.UseOnlineRepository=!0;da.DisableControllerCache=!0;da.RegisterController(Vh.ProfileId,(n,e)=>new Vh(e,n.gamepad,n.handedness));da.DefaultFallbacks();class ht{constructor(e,t,i=Number.MAX_VALUE,s=bt){this.origin=e,this.direction=t,this.length=i,this.epsilon=s}clone(){return new ht(this.origin.clone(),this.direction.clone(),this.length)}intersectsBoxMinMax(e,t,i=0){const s=ht._TmpVector3[0].copyFromFloats(e.x-i,e.y-i,e.z-i),r=ht._TmpVector3[1].copyFromFloats(t.x+i,t.y+i,t.z+i);let a=0,o=Number.MAX_VALUE,c,u,d,f;if(Math.abs(this.direction.x)<1e-7){if(this.origin.x<s.x||this.origin.x>r.x)return!1}else if(c=1/this.direction.x,u=(s.x-this.origin.x)*c,d=(r.x-this.origin.x)*c,d===-1/0&&(d=1/0),u>d&&(f=u,u=d,d=f),a=Math.max(u,a),o=Math.min(d,o),a>o)return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.y<s.y||this.origin.y>r.y)return!1}else if(c=1/this.direction.y,u=(s.y-this.origin.y)*c,d=(r.y-this.origin.y)*c,d===-1/0&&(d=1/0),u>d&&(f=u,u=d,d=f),a=Math.max(u,a),o=Math.min(d,o),a>o)return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.z<s.z||this.origin.z>r.z)return!1}else if(c=1/this.direction.z,u=(s.z-this.origin.z)*c,d=(r.z-this.origin.z)*c,d===-1/0&&(d=1/0),u>d&&(f=u,u=d,d=f),a=Math.max(u,a),o=Math.min(d,o),a>o)return!1;return!0}intersectsBox(e,t=0){return this.intersectsBoxMinMax(e.minimum,e.maximum,t)}intersectsSphere(e,t=0){const i=e.center.x-this.origin.x,s=e.center.y-this.origin.y,r=e.center.z-this.origin.z,a=i*i+s*s+r*r,o=e.radius+t,c=o*o;if(a<=c)return!0;const u=i*this.direction.x+s*this.direction.y+r*this.direction.z;return u<0?!1:a-u*u<=c}intersectsTriangle(e,t,i){const s=ht._TmpVector3[0],r=ht._TmpVector3[1],a=ht._TmpVector3[2],o=ht._TmpVector3[3],c=ht._TmpVector3[4];t.subtractToRef(e,s),i.subtractToRef(e,r),T.CrossToRef(this.direction,r,a);const u=T.Dot(s,a);if(u===0)return null;const d=1/u;this.origin.subtractToRef(e,o);const f=T.Dot(o,a)*d;if(f<-this.epsilon||f>1+this.epsilon)return null;T.CrossToRef(o,s,c);const g=T.Dot(this.direction,c)*d;if(g<-this.epsilon||f+g>1+this.epsilon)return null;const m=T.Dot(r,c)*d;return m>this.length||m<0?null:new Fm(1-f-g,f,m)}intersectsPlane(e){let t;const i=T.Dot(e.normal,this.direction);if(Math.abs(i)<999999997475243e-21)return null;{const s=T.Dot(e.normal,this.origin);return t=(-e.d-s)/i,t<0?t<-999999997475243e-21?null:0:t}}intersectsAxis(e,t=0){switch(e){case"y":{const i=(this.origin.y-t)/this.direction.y;return i>0?null:new T(this.origin.x+this.direction.x*-i,t,this.origin.z+this.direction.z*-i)}case"x":{const i=(this.origin.x-t)/this.direction.x;return i>0?null:new T(t,this.origin.y+this.direction.y*-i,this.origin.z+this.direction.z*-i)}case"z":{const i=(this.origin.z-t)/this.direction.z;return i>0?null:new T(this.origin.x+this.direction.x*-i,this.origin.y+this.direction.y*-i,t)}default:return null}}intersectsMesh(e,t,i,s=!1,r,a=!1){const o=te.Matrix[0];return e.getWorldMatrix().invertToRef(o),this._tmpRay?ht.TransformToRef(this,o,this._tmpRay):this._tmpRay=ht.Transform(this,o),e.intersects(this._tmpRay,t,i,s,r,a)}intersectsMeshes(e,t,i){i?i.length=0:i=[];for(let s=0;s<e.length;s++){const r=this.intersectsMesh(e[s],t);r.hit&&i.push(r)}return i.sort(this._comparePickingInfo),i}_comparePickingInfo(e,t){return e.distance<t.distance?-1:e.distance>t.distance?1:0}intersectionSegment(e,t,i){const s=this.origin,r=te.Vector3[0],a=te.Vector3[1],o=te.Vector3[2],c=te.Vector3[3];t.subtractToRef(e,r),this.direction.scaleToRef(ht._Rayl,o),s.addToRef(o,a),e.subtractToRef(s,c);const u=T.Dot(r,r),d=T.Dot(r,o),f=T.Dot(o,o),g=T.Dot(r,c),m=T.Dot(o,c),b=u*f-d*d;let x,v=b,E,A=b;b<ht._Smallnum?(x=0,v=1,E=m,A=f):(x=d*m-f*g,E=u*m-d*g,x<0?(x=0,E=m,A=f):x>v&&(x=v,E=m+d,A=f)),E<0?(E=0,-g<0?x=0:-g>u?x=v:(x=-g,v=u)):E>A&&(E=A,-g+d<0?x=0:-g+d>u?x=v:(x=-g+d,v=u));const D=Math.abs(x)<ht._Smallnum?0:x/v,I=Math.abs(E)<ht._Smallnum?0:E/A,R=te.Vector3[4];o.scaleToRef(I,R);const C=te.Vector3[5];r.scaleToRef(D,C),C.addInPlace(c);const M=te.Vector3[6];return C.subtractToRef(R,M),I>0&&I<=this.length&&M.lengthSquared()<i*i?C.length():-1}update(e,t,i,s,r,a,o,c=!1){if(c){ht._RayDistant||(ht._RayDistant=ht.Zero()),ht._RayDistant.unprojectRayToRef(e,t,i,s,W.IdentityReadOnly,a,o);const u=te.Matrix[0];r.invertToRef(u),ht.TransformToRef(ht._RayDistant,u,this)}else this.unprojectRayToRef(e,t,i,s,r,a,o);return this}static Zero(){return new ht(T.Zero(),T.Zero())}static CreateNew(e,t,i,s,r,a,o){return ht.Zero().update(e,t,i,s,r,a,o)}static CreateNewFromTo(e,t,i=W.IdentityReadOnly){const s=new ht(new T(0,0,0),new T(0,0,0));return ht.CreateFromToToRef(e,t,s,i)}static CreateFromToToRef(e,t,i,s=W.IdentityReadOnly){i.origin.copyFrom(e);const r=t.subtractToRef(e,i.direction),a=Math.sqrt(r.x*r.x+r.y*r.y+r.z*r.z);return i.length=a,i.direction.normalize(),ht.TransformToRef(i,s,i)}static Transform(e,t){const i=new ht(new T(0,0,0),new T(0,0,0));return ht.TransformToRef(e,t,i),i}static TransformToRef(e,t,i){T.TransformCoordinatesToRef(e.origin,t,i.origin),T.TransformNormalToRef(e.direction,t,i.direction),i.length=e.length,i.epsilon=e.epsilon;const s=i.direction,r=s.length();if(!(r===0||r===1)){const a=1/r;s.x*=a,s.y*=a,s.z*=a,i.length*=r}return i}unprojectRayToRef(e,t,i,s,r,a,o){const c=te.Matrix[0];r.multiplyToRef(a,c),c.multiplyToRef(o,c),c.invert();const u=Ke.LastCreatedEngine,d=te.Vector3[0];d.x=e/i*2-1,d.y=-(t/s*2-1),d.z=u?.useReverseDepthBuffer?1:u?.isNDCHalfZRange?0:-1;const f=te.Vector3[1].copyFromFloats(d.x,d.y,1-1e-8),g=te.Vector3[2],m=te.Vector3[3];T.TransformCoordinatesToRef(d,c,g),T.TransformCoordinatesToRef(f,c,m),this.origin.copyFrom(g),m.subtractToRef(g,this.direction),this.direction.normalize()}}ht._TmpVector3=Xr(6,T.Zero);ht._RayDistant=ht.Zero();ht._Smallnum=1e-8;ht._Rayl=1e9;function Qf(n,e,t,i,s,r=!1){const a=ht.Zero();return Jf(n,e,t,i,a,s,r),a}function Jf(n,e,t,i,s,r,a=!1,o=!1){const c=n.getEngine();if(!r&&!(r=n.activeCamera))return n;const u=r.viewport,d=c.getRenderHeight(),{x:f,y:g,width:m,height:b}=u.toGlobal(c.getRenderWidth(),d),x=1/c.getHardwareScalingLevel();return e=e*x-f,t=t*x-(d-g-b),s.update(e,t,m,b,i||W.IdentityReadOnly,a?W.IdentityReadOnly:r.getViewMatrix(),r.getProjectionMatrix(),o),n}function _4(n,e,t,i){const s=ht.Zero();return WI(n,e,t,s,i),s}function WI(n,e,t,i,s){if(!as)return n;const r=n.getEngine();if(!s&&!(s=n.activeCamera))throw new Error("Active camera not set");const a=s.viewport,o=r.getRenderHeight(),{x:c,y:u,width:d,height:f}=a.toGlobal(r.getRenderWidth(),o),g=W.Identity(),m=1/r.getHardwareScalingLevel();return e=e*m-c,t=t*m-(o-u-f),i.update(e,t,d,f,g,g,s.getProjectionMatrix()),n}function XI(n,e,t,i,s,r,a,o){const c=e(i,t.enableDistantPicking),u=t.intersects(c,s,a,r,i,o);return!u||!u.hit||!s&&n!=null&&u.distance>=n.distance?null:u}function Jb(n,e,t,i,s,r){let a=null;const o=!!(n.activeCameras&&n.activeCameras.length>1&&n.cameraToUseForPointers!==n.activeCamera),c=n.cameraToUseForPointers||n.activeCamera,u=XI;for(let d=0;d<n.meshes.length;d++){const f=n.meshes[d];if(t){if(!t(f,-1))continue}else if(!f.isEnabled()||!f.isVisible||!f.isPickable)continue;const g=o&&f.isWorldMatrixCameraDependent(),m=f.computeWorldMatrix(g,c);if(f.hasThinInstances&&f.thinInstanceEnablePicking){const b=u(a,e,f,m,!0,!0,r);if(b){if(s)return b;const x=te.Matrix[1],v=f.thinInstanceGetWorldMatrices();for(let E=0;E<v.length;E++){if(t&&!t(f,E))continue;v[E].multiplyToRef(m,x);const D=u(a,e,f,x,i,s,r,!0);if(D&&(a=D,a.thinInstanceIndex=E,i))return a}}}else{const b=u(a,e,f,m,i,s,r);if(b&&(a=b,i))return a}}return a||new as}function jI(n,e,t,i){if(!as)return null;const s=[],r=!!(n.activeCameras&&n.activeCameras.length>1&&n.cameraToUseForPointers!==n.activeCamera),a=n.cameraToUseForPointers||n.activeCamera,o=XI;for(let c=0;c<n.meshes.length;c++){const u=n.meshes[c];if(t){if(!t(u,-1))continue}else if(!u.isEnabled()||!u.isVisible||!u.isPickable)continue;const d=r&&u.isWorldMatrixCameraDependent(),f=u.computeWorldMatrix(d,a);if(u.hasThinInstances&&u.thinInstanceEnablePicking){if(o(null,e,u,f,!0,!0,i)){const m=te.Matrix[1],b=u.thinInstanceGetWorldMatrices();for(let x=0;x<b.length;x++){if(t&&!t(u,x))continue;b[x].multiplyToRef(f,m);const E=o(null,e,u,m,!1,!1,i,!0);E&&(E.thinInstanceIndex=x,s.push(E))}}}else{const g=o(null,e,u,f,!1,!1,i);g&&s.push(g)}}return s}function g4(n,e,t,i,s,r){if(!as)return null;const a=Jb(n,o=>(n._tempPickingRay||(n._tempPickingRay=ht.Zero()),Jf(n,e,t,o,n._tempPickingRay,r||null),n._tempPickingRay),i,s,!0);return a&&(a.ray=Qf(n,e,t,W.Identity(),r||null)),a}function m4(n,e,t,i,s,r,a,o=!1){const c=Jb(n,(u,d)=>(n._tempPickingRay||(n._tempPickingRay=ht.Zero()),Jf(n,e,t,u,n._tempPickingRay,r||null,!1,d),n._tempPickingRay),i,s,!1,a);return c&&(c.ray=Qf(n,e,t,W.Identity(),r||null)),c}function b4(n,e,t,i,s){const r=Jb(n,a=>(n._pickWithRayInverseMatrix||(n._pickWithRayInverseMatrix=W.Identity()),a.invertToRef(n._pickWithRayInverseMatrix),n._cachedRayForTransform||(n._cachedRayForTransform=ht.Zero()),ht.TransformToRef(e,n._pickWithRayInverseMatrix,n._cachedRayForTransform),n._cachedRayForTransform),t,i,!1,s);return r&&(r.ray=e),r}function y4(n,e,t,i,s,r){return jI(n,a=>Qf(n,e,t,a,s||null),i,r)}function v4(n,e,t,i){return jI(n,s=>(n._pickWithRayInverseMatrix||(n._pickWithRayInverseMatrix=W.Identity()),s.invertToRef(n._pickWithRayInverseMatrix),n._cachedRayForTransform||(n._cachedRayForTransform=ht.Zero()),ht.TransformToRef(e,n._pickWithRayInverseMatrix,n._cachedRayForTransform),n._cachedRayForTransform),t,i
3112)}function aA(n,e,t=100,i,s){i||(i=n.getWorldMatrix()),e.length=t,s?e.origin.copyFrom(s):e.origin.copyFrom(n.position);const r=te.Vector3[2];r.set(0,0,n._scene.useRightHandedSystem?-1:1);const a=te.Vector3[3];return T.TransformNormalToRef(r,i,a),T.NormalizeToRef(a,e.direction),e}function x4(n,e){e&&(e.prototype.getForwardRay=function(t=100,i,s){return aA(this,new ht(T.Zero(),T.Zero(),t),t,i,s)},e.prototype.getForwardRayToRef=function(t,i=100,s,r){return aA(this,t,i,s,r)}),n&&(kb._IsPickingAvailable=!0,n.prototype.createPickingRay=function(t,i,s,r,a=!1){return Qf(this,t,i,s,r,a)})}x4(Pt,Ge);Pt.prototype.createPickingRayToRef=function(n,e,t,i,s,r=!1,a=!1){return Jf(this,n,e,t,i,s,r,a)};Pt.prototype.createPickingRayInCameraSpace=function(n,e,t){return _4(this,n,e,t)};Pt.prototype.createPickingRayInCameraSpaceToRef=function(n,e,t,i){return WI(this,n,e,t,i)};Pt.prototype.pickWithBoundingInfo=function(n,e,t,i,s){return g4(this,n,e,t,i,s)};Pt.prototype.pick=function(n,e,t,i,s,r,a=!1){return m4(this,n,e,t,i,s,r,a)};Pt.prototype.pickWithRay=function(n,e,t,i){return b4(this,n,e,t,i)};Pt.prototype.multiPick=function(n,e,t,i,s){return y4(this,n,e,t,i,s)};Pt.prototype.multiPickWithRay=function(n,e,t){return v4(this,n,e,t)};class su{get xrNativeFeatureName(){return this._xrNativeFeatureName}set xrNativeFeatureName(e){!this._xrSessionManager.isNative&&e&&this._xrSessionManager.inXRSession&&this._xrSessionManager.enabledFeatures?.indexOf(e)===-1&&oe.Warn(`The feature ${e} needs to be enabled before starting the XR session. Note - It is still possible it is not supported.`),this._xrNativeFeatureName=e}constructor(e){this._xrSessionManager=e,this._attached=!1,this._removeOnDetach=[],this.isDisposed=!1,this.disableAutoAttach=!1,this._xrNativeFeatureName="",this.onFeatureAttachObservable=new le,this.onFeatureDetachObservable=new le}get attached(){return this._attached}attach(e){if(this.isDisposed)return!1;if(e)this.attached&&this.detach();else if(this.attached)return!1;if(!this._xrSessionManager.enabledFeatures)oe.Warn("session.enabledFeatures is not available on this device. It is possible that this feature is not supported.");else if(!this._xrSessionManager.isNative&&this.xrNativeFeatureName&&this._xrSessionManager.enabledFeatures.indexOf(this.xrNativeFeatureName)===-1)return!1;return this._attached=!0,this._addNewAttachObserver(this._xrSessionManager.onXRFrameObservable,t=>this._onXRFrame(t)),this.onFeatureAttachObservable.notifyObservers(this),!0}detach(){if(!this._attached)return this.disableAutoAttach=!0,!1;this._attached=!1;for(const e of this._removeOnDetach)e.observable.remove(e.observer);return this.onFeatureDetachObservable.notifyObservers(this),!0}dispose(){this.detach(),this.isDisposed=!0,this.onFeatureAttachObservable.clear(),this.onFeatureDetachObservable.clear()}isCompatible(){return!0}_addNewAttachObserver(e,t,i){this._removeOnDetach.push({observable:e,observer:e.add(t,void 0,i)})}}class ui{getRenderCamera(e){if(this._renderCamera)return this._renderCamera;{let t;return this.originalScene.activeCameras&&this.originalScene.activeCameras.length>1?t=this.originalScene.activeCameras[this.originalScene.activeCameras.length-1]:t=this.originalScene.activeCamera,e&&t&&t.isRigCamera?t.rigParent:t}}setRenderCamera(e){this._renderCamera=e}_getSharedGizmoLight(){return this._sharedGizmoLight||(this._sharedGizmoLight=new _c("shared gizmo light",new T(0,1,0),this.utilityLayerScene),this._sharedGizmoLight.intensity=2,this._sharedGizmoLight.groundColor=Ne.Gray()),this._sharedGizmoLight}static get DefaultUtilityLayer(){return ui._DefaultUtilityLayer==null?ui._CreateDefaultUtilityLayerFromScene(Ke.LastCreatedScene):ui._DefaultUtilityLayer}static _CreateDefaultUtilityLayerFromScene(e){return ui._DefaultUtilityLayer=new ui(e),ui._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(()=>{ui._DefaultUtilityLayer=null}),ui._DefaultUtilityLayer}static get DefaultKeepDepthUtilityLayer(){return ui._DefaultKeepDepthUtilityLayer==null&&(ui._DefaultKeepDepthUtilityLayer=new ui(Ke.LastCreatedScene),ui._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,ui._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(()=>{ui._DefaultKeepDepthUtilityLayer=null})),ui._DefaultKeepDepthUtilityLayer}constructor(e,t=!0,i=!1){this.originalScene=e,this.handleEvents=t,this._pointerCaptures={},this._lastPointerEvents={},this._sharedGizmoLight=null,this._renderCamera=null,this.pickUtilitySceneFirst=!0,this.shouldRender=!0,this.onlyCheckPointerDownEvents=!0,this.processAllEvents=!1,this.pickingEnabled=!0,this.onPointerOutObservable=new le,this.utilityLayerScene=new Pt(e.getEngine(),{virtual:!0,useFloatingOrigin:e.floatingOriginMode}),this.utilityLayerScene.useRightHandedSystem=e.useRightHandedSystem,this.utilityLayerScene._allowPostProcessClearColor=!1,this.utilityLayerScene.postProcessesEnabled=!1,this.utilityLayerScene.detachControl(),t&&(this._originalPointerObserver=e.onPrePointerObservable.add(s=>{if(!this.utilityLayerScene.activeCamera||!this.pickingEnabled||!this.processAllEvents&&s.type!==Ve.POINTERMOVE&&s.type!==Ve.POINTERUP&&s.type!==Ve.POINTERDOWN&&s.type!==Ve.POINTERDOUBLETAP)return;this.utilityLayerScene.pointerX=e.pointerX,this.utilityLayerScene.pointerY=e.pointerY;const r=s.event;if(e.isPointerCaptured(r.pointerId)){this._pointerCaptures[r.pointerId]=!1;return}const a=c=>{let u=null;if(s.nearInteractionPickingInfo)s.nearInteractionPickingInfo.pickedMesh.getScene()==c?u=s.nearInteractionPickingInfo:u=new as;else if(c!==this.utilityLayerScene&&s.originalPickingInfo)u=s.originalPickingInfo;else{let d=null;this._renderCamera&&(d=c._activeCamera,c._activeCamera=this._renderCamera,s.ray=null),u=s.ray?c.pickWithRay(s.ray):c.pick(e.pointerX,e.pointerY),d&&(c._activeCamera=d)}return u},o=a(this.utilityLayerScene);
3112if(!s.ray&&o&&(s.ray=o.ray),s.originalPickingInfo?.aimTransform&&o&&(o.aimTransform=s.originalPickingInfo.aimTransform,o.gripTransform=s.originalPickingInfo.gripTransform),this.utilityLayerScene.onPrePointerObservable.notifyObservers(s),this.onlyCheckPointerDownEvents&&s.type!=Ve.POINTERDOWN){s.skipOnPointerObservable||this.utilityLayerScene.onPointerObservable.notifyObservers(new Ar(s.type,s.event,o),s.type),s.type===Ve.POINTERUP&&this._pointerCaptures[r.pointerId]&&(this._pointerCaptures[r.pointerId]=!1);return}if(this.utilityLayerScene.autoClearDepthAndStencil||this.pickUtilitySceneFirst)o&&o.hit&&(s.skipOnPointerObservable||this.utilityLayerScene.onPointerObservable.notifyObservers(new Ar(s.type,s.event,o),s.type),s.skipOnPointerObservable=!0);else{const c=a(e),u=s.event;c&&o&&(o.distance===0&&c.pickedMesh?this.mainSceneTrackerPredicate&&this.mainSceneTrackerPredicate(c.pickedMesh)?(this._notifyObservers(s,c,u),s.skipOnPointerObservable=!0):s.type===Ve.POINTERDOWN?(this._pointerCaptures[u.pointerId]=!0,this._notifyObservers(s,c,u)):(s.type===Ve.POINTERMOVE||s.type===Ve.POINTERUP)&&(this._lastPointerEvents[u.pointerId]&&(this.onPointerOutObservable.notifyObservers(u.pointerId),delete this._lastPointerEvents[u.pointerId]),this._notifyObservers(s,c,u)):!this._pointerCaptures[u.pointerId]&&(o.distance<c.distance||c.distance===0)?(this._notifyObservers(s,o,u),s.skipOnPointerObservable||(s.skipOnPointerObservable=o.distance>0)):!this._pointerCaptures[u.pointerId]&&o.distance>=c.distance&&(this.mainSceneTrackerPredicate&&this.mainSceneTrackerPredicate(c.pickedMesh)?(this._notifyObservers(s,c,u),s.skipOnPointerObservable=!0):((s.type===Ve.POINTERMOVE||s.type===Ve.POINTERUP)&&this._lastPointerEvents[u.pointerId]&&(this.onPointerOutObservable.notifyObservers(u.pointerId),delete this._lastPointerEvents[u.pointerId]),this._notifyObservers(s,o,u))),s.type===Ve.POINTERUP&&this._pointerCaptures[u.pointerId]&&(this._pointerCaptures[u.pointerId]=!1))}}),this._originalPointerObserver&&e.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver)),this.utilityLayerScene.autoClear=!1,i||(this._afterRenderObserver=this.originalScene.onAfterRenderCameraObservable.add(s=>{this.shouldRender&&s==this.getRenderCamera()&&this.render()})),this._sceneDisposeObserver=this.originalScene.onDisposeObservable.add(()=>{this.dispose()}),this._updateCamera()}_notifyObservers(e,t,i){e.skipOnPointerObservable||(this.utilityLayerScene.onPointerObservable.notifyObservers(new Ar(e.type,e.event,t),e.type),this._lastPointerEvents[i.pointerId]=!0)}render(){if(this._updateCamera(),this.utilityLayerScene.activeCamera){const e=this.utilityLayerScene.activeCamera.getScene(),t=this.utilityLayerScene.activeCamera;t._scene=this.utilityLayerScene,t.leftCamera&&(t.leftCamera._scene=this.utilityLayerScene),t.rightCamera&&(t.rightCamera._scene=this.utilityLayerScene),this.utilityLayerScene.render(!1),t._scene=e,t.leftCamera&&(t.leftCamera._scene=e),t.rightCamera&&(t.rightCamera._scene=e)}}dispose(){this.onPointerOutObservable.clear(),this._afterRenderObserver&&this.originalScene.onAfterCameraRenderObservable.remove(this._afterRenderObserver),this._sceneDisposeObserver&&this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver),this._originalPointerObserver&&this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver),this.utilityLayerScene.dispose()}_updateCamera(){this.utilityLayerScene.cameraToUseForPointers=this.getRenderCamera(),this.utilityLayerScene.activeCamera=this.getRenderCamera()}}ui._DefaultUtilityLayer=null;ui._DefaultKeepDepthUtilityLayer=null;class ra extends su{constructor(e,t){super(e),this._options=t,this._attachController=i=>{if(this._controllers[i.uniqueId])return;const{laserPointer:s,selectionMesh:r}=this._generateNewMeshPair(this._options.forceGripIfAvailable&&i.grip?i.grip:i.pointer);switch(this._controllers[i.uniqueId]={xrController:i,laserPointer:s,selectionMesh:r,meshUnderPointer:null,pick:null,tmpRay:new ht(new T,new T),disabledByNearInteraction:!1,id:ra._IdCounter++},this._attachedController?!this._options.enablePointerSelectionOnAllControllers&&this._options.preferredHandedness&&i.inputSource.handedness===this._options.preferredHandedness&&(this._attachedController=i.uniqueId):this._options.enablePointerSelectionOnAllControllers||(this._attachedController=i.uniqueId),i.inputSource.targetRayMode){case"tracked-pointer":return this._attachTrackedPointerRayMode(i);case"gaze":return this._attachGazeMode(i);case"screen":case"transient-pointer":return this._attachScreenRayMode(i)}},this._controllers={},this._tmpVectorForPickCompare=new T,this.disablePointerLighting=!0,this.disableSelectionMeshLighting=!0,this.displayLaserPointer=!0,this.displaySelectionMesh=!0,this.laserPointerP
3112ickedColor=new Ne(.9,.9,.9),this.laserPointerDefaultColor=new Ne(.7,.7,.7),this.selectionMeshDefaultColor=new Ne(.8,.8,.8),this.selectionMeshPickedColor=new Ne(.3,.3,1),this._identityMatrix=W.Identity(),this._screenCoordinatesRef=T.Zero(),this._viewportRef=new Ja(0,0,0,0),this._scene=this._xrSessionManager.scene,this._options.lookAndPickMode===void 0&&(this._scene.getEngine()._badDesktopOS||this._scene.getEngine()._badOS)&&(this._options.lookAndPickMode=!0),this._options.lookAndPickMode&&(this._options.enablePointerSelectionOnAllControllers=!0,this.displayLaserPointer=!1)}attach(){if(!super.attach())return!1;for(const e of this._options.xrInput.controllers)this._attachController(e);if(this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable,this._attachController,!0),this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable,e=>{this._detachController(e.uniqueId)},!0),this._scene.constantlyUpdateMeshUnderPointer=!0,this._options.gazeCamera){const e=this._options.gazeCamera,{laserPointer:t,selectionMesh:i}=this._generateNewMeshPair(e);this._controllers.camera={webXRCamera:e,laserPointer:t,selectionMesh:i,meshUnderPointer:null,pick:null,tmpRay:new ht(new T,new T),disabledByNearInteraction:!1,id:ra._IdCounter++},this._attachGazeMode()}return!0}detach(){if(!super.detach())return!1;const e=Object.keys(this._controllers);for(const t of e)this._detachController(t);return!0}getMeshUnderPointer(e){return this._controllers[e]?this._controllers[e].meshUnderPointer:null}getXRControllerByPointerId(e){const t=Object.keys(this._controllers);for(let i=0;i<t.length;++i)if(this._controllers[t[i]].id===e)return this._controllers[t[i]].xrController||null;return null}_getPointerSelectionDisabledByPointerId(e){const t=Object.keys(this._controllers);for(let i=0;i<t.length;++i)if(this._controllers[t[i]].id===e)return this._controllers[t[i]].disabledByNearInteraction;return!0}_setPointerSelectionDisabledByPointerId(e,t){const i=Object.keys(this._controllers);for(let s=0;s<i.length;++s)if(this._controllers[i[s]].id===e){this._controllers[i[s]].disabledByNearInteraction=t;return}}_onXRFrame(e){const t=Object.keys(this._controllers);for(const i of t){const s=this._controllers[i];if(this._options.lookAndPickMode&&s.xrController?.inputSource.targetRayMode!=="transient-pointer")continue;if(!this._options.enablePointerSelectionOnAllControllers&&i!==this._attachedController||s.disabledByNearInteraction){s.selectionMesh.isVisible=!1,s.laserPointer.isVisible=!1,s.pick=null;continue}s.laserPointer.isVisible=this.displayLaserPointer;let r;if(s.xrController)r=this._options.forceGripIfAvailable&&s.xrController.grip?s.xrController.grip.position:s.xrController.pointer.position,s.xrController.getWorldPointerRayToRef(s.tmpRay,this._options.forceGripIfAvailable);else if(s.webXRCamera)r=s.webXRCamera.position,s.webXRCamera.getForwardRayToRef(s.tmpRay);else continue;if(this._options.maxPointerDistance&&(s.tmpRay.length=this._options.maxPointerDistance),!this._options.disableScenePointerVectorUpdate&&r){const u=this._xrSessionManager.scene,d=this._options.xrInput.xrCamera;d&&(d.viewport.toGlobalToRef(u.getEngine().getRenderWidth()/d.rigCameras.length,u.getEngine().getRenderHeight(),this._viewportRef),T.ProjectToRef(r,this._identityMatrix,d.getTransformationMatrix(),this._viewportRef,this._screenCoordinatesRef),typeof this._screenCoordinatesRef.x=="number"&&typeof this._screenCoordinatesRef.y=="number"&&!isNaN(this._screenCoordinatesRef.x)&&!isNaN(this._screenCoordinatesRef.y)&&this._screenCoordinatesRef.x!==1/0&&this._screenCoordinatesRef.y!==1/0&&(u.pointerX=this._screenCoordinatesRef.x,u.pointerY=this._screenCoordinatesRef.y,s.screenCoordinates={x:this._screenCoordinatesRef.x,y:this._screenCoordinatesRef.y}))}let a=null;this._utilityLayerScene&&(a=this._utilityLayerScene.pickWithRay(s.tmpRay,this._utilityLayerScene.pointerMovePredicate||this.raySelectionPredicate));const o=this._scene.pickWithRay(s.tmpRay,this._scene.pointerMovePredicate||this.raySelectionPredicate);!a||!a.hit?s.pick=o:!o||!o.hit||a.distance<o.distance?s.pick=a:s.pick=o,s.pick&&s.xrController&&(s.pick.aimTransform=s.xrController.pointer,s.pick.gripTransform=s.xrController.grip||null,s.pick.originMesh=s.xrController.pointer,s.tmpRay.length=s.pick.distance);const c=s.pick;if(c&&c.pickedPoint&&c.hit){this._updatePointerDistance(s.laserPointer,c.distance),s.selectionMesh.position.copyFrom(c.pickedPoint),s.selectionMesh.scaling.x=Math.sqrt(c.distance),s.selectionMesh.scaling.y=Math.sqrt(c.distance),s.selectionMesh.scaling.z=M
3112ath.sqrt(c.distance);const u=this._convertNormalToDirectionOfRay(c.getNormal(!0),s.tmpRay),d=.001;if(s.selectionMesh.position.copyFrom(c.pickedPoint),u){const f=T.Cross(wr.Y,u),g=T.Cross(u,f);T.RotationFromAxisToRef(g,u,f,s.selectionMesh.rotation),s.selectionMesh.position.addInPlace(u.scale(d))}s.selectionMesh.isVisible=this.displaySelectionMesh,s.meshUnderPointer=c.pickedMesh}else s.selectionMesh.isVisible=!1,this._updatePointerDistance(s.laserPointer,1),s.meshUnderPointer=null}}get _utilityLayerScene(){return this._options.customUtilityLayerScene||ui.DefaultUtilityLayer.utilityLayerScene}_attachGazeMode(e){const t=this._controllers[e&&e.uniqueId||"camera"],i=this._options.timeToSelect||3e3,s=this._options.useUtilityLayer?this._utilityLayerScene:this._scene;let r=new as;const a=kh("selection",{diameter:.0035*15,thickness:.0025*6,tessellation:20},s);a.isVisible=!1,a.isPickable=!1,a.parent=t.selectionMesh;let o=0,c=!1;const u={pointerId:t.id,pointerType:"xr"};t.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add(()=>{if(t.pick){if(this._augmentPointerInit(u,t.id,t.screenCoordinates),t.laserPointer.material.alpha=0,a.isVisible=!1,t.pick.hit)if(this._pickingMoved(r,t.pick))c&&(this._options.disablePointerUpOnTouchOut||this._scene.simulatePointerUp(t.pick,u)),c=!1,o=0;else if(o>i/10&&(a.isVisible=!0),o+=this._scene.getEngine().getDeltaTime(),o>=i)this._scene.simulatePointerDown(t.pick,u),c=!0,this._options.disablePointerUpOnTouchOut&&this._scene.simulatePointerUp(t.pick,u),a.isVisible=!1;else{const d=1-o/i;a.scaling.set(d,d,d)}else c=!1,o=0;this._scene.simulatePointerMove(t.pick,u),r=t.pick}}),this._options.renderingGroupId!==void 0&&(a.renderingGroupId=this._options.renderingGroupId),e&&e.onDisposeObservable.addOnce(()=>{t.pick&&!this._options.disablePointerUpOnTouchOut&&c&&(this._scene.simulatePointerUp(t.pick,u),t.finalPointerUpTriggered=!0),a.dispose()})}_attachScreenRayMode(e){const t=this._controllers[e.uniqueId];let i=!1;const s={pointerId:t.id,pointerType:"xr"};t.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add(()=>{this._augmentPointerInit(s,t.id,t.screenCoordinates),!(!t.pick||this._options.disablePointerUpOnTouchOut&&i)&&(i?this._scene.simulatePointerMove(t.pick,s):(this._scene.simulatePointerDown(t.pick,s),t.pointerDownTriggered=!0,i=!0,this._options.disablePointerUpOnTouchOut&&this._scene.simulatePointerUp(t.pick,s)))}),e.onDisposeObservable.addOnce(()=>{this._augmentPointerInit(s,t.id,t.screenCoordinates),this._xrSessionManager.runInXRFrame(()=>{t.pick&&!t.finalPointerUpTriggered&&i&&!this._options.disablePointerUpOnTouchOut&&(this._scene.simulatePointerUp(t.pick,s),t.finalPointerUpTriggered=!0)})})}_attachTrackedPointerRayMode(e){const t=this._controllers[e.uniqueId];if(this._options.forceGazeMode)return this._attachGazeMode(e);const i={pointerId:t.id,pointerType:"xr"};if(t.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add(()=>{t.laserPointer.material.disableLighting=this.disablePointerLighting,t.selectionMesh.material.disableLighting=this.disableSelectionMeshLighting,t.pick&&(this._augmentPointerInit(i,t.id,t.screenCoordinates),this._scene.simulatePointerMove(t.pick,i))}),e.inputSource.gamepad){const s=r=>{this._options.overrideButtonId&&(t.selectionComponent=r.getComponent(this._options.overrideButtonId)),t.selectionComponent||(t.selectionComponent=r.getMainComponent()),t.onButtonChangedObserver=t.selectionComponent.onButtonStateChangedObservable.add(a=>{if(a.changes.pressed){const o=a.changes.pressed.current;if(t.pick)(this._options.enablePointerSelectionOnAllControllers||e.uniqueId===this._attachedController)&&(this._augmentPointerInit(i,t.id,t.screenCoordinates),o?(this._scene.simulatePointerDown(t.pick,i),t.pointerDownTriggered=!0,t.selectionMesh.material.emissiveColor=this.selectionMeshPickedColor,t.laserPointer.material.emissiveColor=this.laserPointerPickedColor):(this._scene.simulatePointerUp(t.pick,i),t.selectionMesh.material.emissiveColor=this.selectionMeshDefaultColor,t.laserPointer.material.emissiveColor=this.laserPointerDefaultColor));else if(o&&!this._options.enablePointerSelectionOnAllControllers&&!this._options.disableSwitchOnClick){const c=this._controllers[this._attachedController];c&&c.pointerDownTriggered&&!c.finalPointerUpTriggered&&(this._augmentPointerInit(i,c.id,c.screenCoordinates),this._scene.simulatePointerUp(new as,{pointerId:c.id,pointerType:"xr"}),c.finalPointerUpTriggered=!0),this._attachedController=e.uniqueId}}})};e.motionController?s(e.motionController):e.onMotionControllerInitObservable.add(s)}else{const s=a=>{this._xrSessionManager.onXRFrameObservable.addOnce(()=>{this._augmentPointerInit(i,t.id,t.screenCoordinates),t.xrController&&a.inputSource===t.xrController.inputSource&&t.pick&&(this._scene.simulatePointerDown(t.pick,i),t.pointerDownTriggered=!0,t.selectionMesh.material.emissiveColor=this.selectionMeshPickedColor,t.laserPointer.material.emissiveColor=this.laserPointerP
3112ickedColor)})},r=a=>{this._xrSessionManager.onXRFrameObservable.addOnce(()=>{this._augmentPointerInit(i,t.id,t.screenCoordinates),t.xrController&&a.inputSource===t.xrController.inputSource&&t.pick&&(this._scene.simulatePointerUp(t.pick,i),t.selectionMesh.material.emissiveColor=this.selectionMeshDefaultColor,t.laserPointer.material.emissiveColor=this.laserPointerDefaultColor)})};t.eventListeners={selectend:r,selectstart:s},this._xrSessionManager.session.addEventListener("selectstart",s),this._xrSessionManager.session.addEventListener("selectend",r)}}_convertNormalToDirectionOfRay(e,t){return e&&Math.acos(T.Dot(e,t.direction))<Math.PI/2&&e.scaleInPlace(-1),e}_detachController(e){const t=this._controllers[e];if(t){if(t.selectionComponent&&t.onButtonChangedObserver&&t.selectionComponent.onButtonStateChangedObservable.remove(t.onButtonChangedObserver),t.onFrameObserver&&this._xrSessionManager.onXRFrameObservable.remove(t.onFrameObserver),t.eventListeners){const i=Object.keys(t.eventListeners);for(const s of i){const r=t.eventListeners&&t.eventListeners[s];r&&this._xrSessionManager.session.removeEventListener(s,r)}}if(!t.finalPointerUpTriggered&&t.pointerDownTriggered){const i={pointerId:t.id,pointerType:"xr"};this._xrSessionManager.runInXRFrame(()=>{this._augmentPointerInit(i,t.id,t.screenCoordinates),this._scene.simulatePointerUp(t.pick||new as,i),t.finalPointerUpTriggered=!0})}this._xrSessionManager.scene.onBeforeRenderObservable.addOnce(()=>{try{if(t.selectionMesh.dispose(),t.laserPointer.dispose(),delete this._controllers[e],this._attachedController===e){const i=Object.keys(this._controllers);i.length?this._attachedController=i[0]:this._attachedController=""}}catch{pe.Warn("controller already detached.")}})}}_generateNewMeshPair(e){const t=this._options.useUtilityLayer?this._options.customUtilityLayerScene||ui.DefaultUtilityLayer.utilityLayerScene:this._scene,i=this._options.customLasterPointerMeshGenerator?this._options.customLasterPointerMeshGenerator():Vf("laserPointer",{height:1,diameterTop:2e-4,diameterBottom:.004,tessellation:20,subdivisions:1},t);i.parent=e;const s=new Ae("laserPointerMat",t);s.emissiveColor=this.laserPointerDefaultColor,s.alpha=.7,i.material=s,i.rotation.x=Math.PI/2,this._updatePointerDistance(i,1),i.isPickable=!1,i.isVisible=!1;const r=this._options.customSelectionMeshGenerator?this._options.customSelectionMeshGenerator():kh("gazeTracker",{diameter:.0035*3,thickness:.0025*3,tessellation:20},t);r.bakeCurrentTransformIntoVertices(),r.isPickable=!1,r.isVisible=!1;const a=new Ae("targetMat",t);return a.specularColor=Ne.Black(),a.emissiveColor=this.selectionMeshDefaultColor,a.backFaceCulling=!1,r.material=a,this._options.renderingGroupId!==void 0&&(i.renderingGroupId=this._options.renderingGroupId,r.renderingGroupId=this._options.renderingGroupId),{laserPointer:i,selectionMesh:r}}_pickingMoved(e,t){if(!e.hit||!t.hit||!e.pickedMesh||!e.pickedPoint||!t.pickedMesh||!t.pickedPoint||e.pickedMesh!==t.pickedMesh)return!0;e.pickedPoint?.subtractToRef(t.pickedPoint,this._tmpVectorForPickCompare),this._tmpVectorForPickCompare.set(Math.abs(this._tmpVectorForPickCompare.x),Math.abs(this._tmpVectorForPickCompare.y),Math.abs(this._tmpVectorForPickCompare.z));const i=(this._options.gazeModePointerMovedFactor||1)*.01*t.distance;return this._tmpVectorForPickCompare.length()>i}_updatePointerDistance(e,t=100){e.scaling.y=t,this._scene.useRightHandedSystem&&(t*=-1),e.position.z=t/2+.05}_augmentPointerInit(e,t,i){e.pointerId=t,e.pointerType="xr",i&&(e.screenX=i.x,e.screenY=i.y)}get lasterPointerDefaultColor(){return this.laserPointerDefaultColor}}ra._IdCounter=200;ra.Name=Yt.POINTER_SELECTION;ra.Version=1;Dr.AddWebXRFeature(ra.Name,(n,e)=>()=>new ra(n,e),ra.Version,!0);var re;(function(n){n[n.Float=1]="Float",n[n.Int=2]="Int",n[n.Vector2=4]="Vector2",n[n.Vector3=8]="Vector3",n[n.Vector4=16]="Vector4",n[n.Color3=32]="Color3",n[n.Color4=64]="Color4",n[n.Matrix=128]="Matrix",n[n.Object=256]="Object",n[n.AutoDetect=1024]="AutoDetect",n[n.BasedOnInput=2048]="BasedOnInput",n[n.All=4095]="All"})(re||(re={}));var De;(function(n){n[n.Vertex=1]="Vertex",n[n.Fragment=2]="Fragment",n[n.Neutral=4]="Neutral",n[n.VertexAndFragment=3]="VertexAndFragment"})(De||(De={}));class oA{constructor(){this.supportUniformBuffers=!1,this.attributes=[],this.uniforms=[],this.constants=[],this.samplers=[],this.functions={},this.extensions={},this.prePassOutput={},this.counters={},this._terminalBlocks=new Set,this._attributeDeclaration="",this._uniformDeclaration="",this._constantDeclaration="",this._samplerDeclaration="",this._varyingTransfer="",this._injectAtEnd="",this._injectAtTop="",this._customEntryHeader="",this._repeatableContentAnchorIndex=0,this._builtCompilationString="",this.compilationString=""}get shaderLanguage(){return this.sharedData.nodeMaterial.shaderLanguage}get fSuffix(){return this.shaderLanguage===1?"f":""}
3112async getProcessedShaderAsync(e){if(!this._builtCompilationString)return oe.Error("getProcessedShaderAsync: Shader not built yet."),"";const t=this.sharedData.nodeMaterial.getScene().getEngine(),i={defines:e.split(` 3113`),indexParameters:void 0,isFragment:this.target===De.Fragment,shouldUseHighPrecisionShader:t._shouldUseHighPrecisionShader,processor:t._getShaderProcessor(this.shaderLanguage),supportsUniformBuffers:t.supportsUniformBuffers,shadersRepository:de.GetShadersRepository(this.shaderLanguage),includesShadersStore:de.GetIncludesShadersStore(this.shaderLanguage),version:(t.version*100).toString(),platformName:t.shaderPlatformName,processingContext:null,isNDCHalfZRange:t.isNDCHalfZRange,useReverseDepthBuffer:t.useReverseDepthBuffer};return!t.isWebGPU&&t.version>1&&(i.processor=new tC),await new Promise(s=>{Cm(this._builtCompilationString,i,(r,a)=>{s(r)},t)})}finalize(e){const t=e.sharedData.emitComments,i=this.target===De.Fragment;let s=` 3114${t?`//Entry point 3115`:""}`;this._customEntryHeader?s+=this._customEntryHeader:this.shaderLanguage===1?i?s+=`@fragment 3116fn main(input: FragmentInputs) -> FragmentOutputs { 3117${this.sharedData.varyingInitializationsFragment}`:s+=`@vertex 3118fn main(input: VertexInputs) -> FragmentInputs{ 3119`:s+=`void main(void) { 3120`,this.compilationString=s+this.compilationString,this._constantDeclaration&&(this.compilationString=` 3121${t?`//Constants 3122`:""}${this._constantDeclaration} 3123${this.compilationString}`);let r="";for(const a in this.functions)r+=this.functions[a]+` 3124`;if(this.compilationString=` 3125${r} 3126${this.compilationString}`,!i&&this._varyingTransfer&&(this.compilationString=`${this.compilationString} 3127${this._varyingTransfer}`),this._injectAtEnd&&(this.compilationString=`${this.compilationString} 3128${this._injectAtEnd}`),this.compilationString=`${this.compilationString} 3129}`,this.sharedData.varyingDeclaration&&(this.compilationString=` 3130${t?`//Varyings 3131`:""}${i?this.sharedData.varyingDeclarationFragment:this.sharedData.varyingDeclaration} 3132${this.compilationString}`),this._samplerDeclaration&&(this.compilationString=` 3133${t?`//Samplers 3134`:""}${this._samplerDeclaration} 3135${this.compilationString}`),this._uniformDeclaration&&(this.compilationString=` 3136${t?`//Uniforms 3137`:""}${this._uniformDeclaration} 3138${this.compilationString}`),this._attributeDeclaration&&!i&&(this.compilationString=` 3139${t?`//Attributes 3140`:""}${this._attributeDeclaration} 3141${this.compilationString}`),this.shaderLanguage!==1){this.compilationString=`precision highp float; 3142`+this.compilationString,this.compilationString=`#if defined(WEBGL2) || defined(WEBGPU) 3143precision highp sampler2DArray; 3144#endif 3145`+this.compilationString,i&&(this.compilationString=`#if defined(PREPASS)\r 3146#extension GL_EXT_draw_buffers : require\r 3147layout(location = 0) out highp vec4 glFragData[SCENE_MRT_COUNT];\r 3148highp vec4 gl_FragColor;\r 3149#endif\r 3150`+this.compilationString);for(const a in this.extensions){const o=this.extensions[a];this.compilationString=` 3151${o} 3152${this.compilationString}`}}this._injectAtTop&&(this.compilationString=`${this._injectAtTop} 3153${this.compilationString}`),this._builtCompilationString=this.compilationString}get _repeatableContentAnchor(){return`###___ANCHOR${this._repeatableContentAnchorIndex++}___###`}_getFreeVariableName(e){return e=this.sharedData.formatConfig.formatVariablename(e),this.sharedData.variableNames[e]===void 0?(this.sharedData.variableNames[e]=0,e==="output"||e==="texture"?e+this.sharedData.variableNames[e]:e):(this.sharedData.variableNames[e]++,e+this.sharedData.variableNames[e])}_getFreeDefineName(e){return this.sharedData.defineNames[e]===void 0?this.sharedData.defineNames[e]=0:this.sharedData.defineNames[e]++,e+this.sharedData.defineNames[e]}_excludeVariableName(e){this.sharedData.variableNames[e]=0}_emit2DSampler(e,t="",i=!1,s,r,a){if(this.samplers.indexOf(e)<0||i){if(t&&(this._samplerDeclaration+=`#if ${t} 3154`),this.shaderLanguage===1){const o=r?"u":"f";this._samplerDeclaration+=`var ${e+"Sampler"}: sampler; 3155`,this._samplerDeclaration+=`var ${e}: texture_2d<${o}32>; 3156`}else{const o=r?"u":"",c=a??"";this._samplerDeclaration+=`uniform ${c} ${o}sampler2D ${e}; ${s||""} 3157`}t&&(this._samplerDeclaration+=`#endif 3158`),i||this.samplers.push(e)}}_emitCubeSampler(e,t="",i=!1){(this.samplers.indexOf(e)<0||i)&&(t&&(this._samplerDeclaration+=`#if ${t} 3159`),this.shaderLanguage===1?(this._samplerDeclaration+=`var ${e+"Sampler"}: sampler; 3160`,this._samplerDeclaration+=`var ${e}: texture_cube<f32>; 3161`):this._samplerDeclaration+=`uniform samplerCube ${e}; 3162`,t&&(this._samplerDeclaration+=`#endif 3163`),i||this.samplers.push(e))}_emit2DArraySampler(e){this.samplers.indexOf(e)<0&&(this.shaderLanguage===1?(this._samplerDeclaration+=`var ${e+"Sampler"}: sampler; 3164`,this._samplerDeclaration+=`var ${e}: texture_2d_array<f32>; 3165`):this._samplerDeclaration+=`uniform sampler2DArray ${e}; 3166`,this.samplers.push(e))}_getGLType(e){switch(e){case re.Float:return"float";case re.Int:return"int";case re.Vector2:return"vec2";case re.Color3:case re.Vector3:return"vec3";case re.Color4:case re.Vector4:return"vec4";case re.Matrix:return"mat4"}return""}_getShaderType(e){const t=this.shaderLanguage===1;switch(e){case re.Float:return t?"f32":"float";case re.Int:return t?"i32":"int";case re.Vector2:return t?"vec2f":"vec2";case re.Color3:case re.Vector3:return t?"vec3f":"vec3";case re.Color4:case re.Vector4:return t?"vec4f":"vec4";case re.Matrix:return t?"mat4x4f":"mat4"}return""}_emitExtension(e,t,i=""){this.extensions[e]||(i&&(t=`#if ${i} 3167${t} 3168#endif`),this.extensions[e]=t)}_emitFunction(e,t,i){this.functions[e]||(this.sharedData.emitComments&&(t=i+` 3169`+t),this.functions[e]=t)}_emitCodeFromInclude(e,t,i){const s=de.GetIncludesShadersStore(this.shaderLanguage);if(i&&i.repeatKey)return`#include<${e}>${i.substitutionVars?"("+i.substitutionVars+")":""}[0..${i.repeatKey}] 3170`;let r=s[e]+` 3171`;if(this.sharedData.emitComments&&(r=t+` 3172`+r),!i)return r;if(i.replaceStrings)for(let a=0;a<i.replaceStrings.length;a++){const o=i.replaceStrings[a];r=r.replace(o.search,o.replace)}return r}_emitFunctionFromInclude(e,t,i,s=""){const r=e+s;if(this.functions[r])return;const a=de.GetIncludesShadersStore(this.shaderLanguage);if(!i||!i.removeAttributes&&!i.removeUniforms&&!i.removeVaryings&&!i.removeIfDef&&!i.replaceStrings){i&&i.repeatKey?this.functions[r]=`#include<${e}>${i.substitutionVars?"("+i.substitutionVars+")":""}[0..${i.repeatKey}] 3173`:this.functions[r]=`#include<${e}>${i?.substitutionVars?"("+i?.substitutionVars+")":""} 3174`,this.sharedData.emitComments&&(this.functions[r]=t+` 3175`+this.functions[r]);return}if(this.functions[r]=a[e],this.sharedData.emitComments&&(this.functions[r]=t+` 3176`+this.functions[r]),i.removeIfDef&&(this.functions[r]=this.functions[r].replace(/^\s*?#ifdef.+$/gm,""),this.functions[r]=this.functions[r].replace(/^\s*?#endif.*$/gm,""),this.functions[r]=this.functions[r].replace(/^\s*?#else.*$/gm,""),this.functions[r]=this.functions[r].replace(/^\s*?#elif.*$/gm,"")),i.removeAttributes&&(this.functions[r]=this.functions[r].replace(/\s*?attribute .+?;/g,` 3177`)),i.removeUniforms&&(this.functions[r]=this.functions[r].replace(/\s*?uniform .*?;/g,` 3178`)),i.removeVaryings&&(this.functions[r]=this.functions[r].replace(/\s*?(varying|in) .+?;/g,` 3179`)),i.replaceStrings)for(let o=0;o<i.replaceStrings.length;o++){const c=i.replaceStrings[o];this.functions[r]=this.functions[r].replace(c.search,c.replace)}}_registerTempVariable(e){return this.sharedData.temps.indexOf(e)!==-1?!1:(this.sharedData.temps.push(e),!0)}_emitDefineStart(e,t=!1){let i="";return e&&(e.startsWith("defined(")?i=`#if ${e} 3180`:i=`${t?"#ifndef":"#ifdef"} ${e} 3181`),i}_emitDefineEnd(e){return e?`#endif 3182`:""}_emitVaryingFromString(e,t,i="",s=!1){if(this.sharedData.varyings.indexOf(e)!==-1)return!1;this.sharedData.varyings.push(e);const r=this._getShaderType(t),a=(o=!1)=>{let c=this._emitDefineStart(i,s);if(this.shaderLanguage===1)switch(r){case"i32":case"f32":case"vec2f":case"vec3f":case"vec4f":c+=`varying ${e}: ${r}; 3183`,o&&(c+=`var<private> ${e}: ${r}; 3184`,this.sharedData.varyingInitializationsFragment+=this._emitDefineStart(i,s)+`${e} = fragmentInputs.${e}; 3185`+this._emitDefineEnd(i));break;case"mat4x4f":c+=`varying ${e}_r0: vec4f; 3186`,c+=`varying ${e}_r1: vec4f; 3187`,c+=`varying ${e}_r2: vec4f; 3188`,c+=`varying ${e}_r3: vec4f; 3189`,o&&(c+=`var<private> ${e}: mat4x4f; 3190`,this.sharedData.varyingInitializationsFragment+=this._emitDefineStart(i,s)+`${e} = mat4x4f(fragmentInputs.${e}_r0, fragmentInputs.${e}_r1, fragmentInputs.${e}_r2, fragmentInputs.${e}_r3); 3191`+this._emitDefineEnd(i));break;default:c+=`varying ${e}: ${r}; 3192`;break}else c+=`varying ${r} ${e}; 3193`;return c+=this._emitDefineEnd(i),c};if(this.shaderLanguage===1)this.sharedData.varyingDeclaration+=a(!1),this.sharedData.varyingDeclarationFragment+=a(!0);else{const o=a();this.sharedData.varyingDeclaration+=o,this.sharedData.varyingDeclarationFragment+=o}return!0}_getVaryingName(e){return this.shaderLanguage===1?(this.target!==De.Fragment?"vertexOutputs.":"fragmentInputs.")+e:e}_emitUniformFromString(e,t,i="",s=!1){if(this.uniforms.indexOf(e)!==-1)return;this.uniforms.push(e),i&&(i.startsWith("defined(")?this._uniformDeclaration+=`#if ${i} 3194`:this._uniformDeclaration+=`${s?"#ifndef":"#ifdef"} ${i} 3195`),this.sharedData.formatConfig.getUniformAnnotation&&(this._uniformDeclaration+=this.sharedData.formatConfig.getUniformAnnotation(e));const r=this._getShaderType(t);this.shaderLanguage===1?this._uniformDeclaration+=`uniform ${e}: ${r}; 3196`:this._uniformDeclaration+=`uniform ${r} ${e}; 3197`,i&&(this._uniformDeclaration+=`#endif 3198`)}_generateTernary(e,t,i){return this.shaderLanguage===1?`select(${t}, ${e}, ${i})`:`(${i}) ? ${e} : ${t}`}_emitFloat(e){return e.toString()===e.toFixed(0)?`${e}.0`:e.toString()}_declareOutput(e,t){return this._declareLocalVar(e.associatedVariableName,e.type,t)}_declareLocalVar(e,t,i,s){return this.shaderLanguage===1?`${i?"const":"var"+(s?"<private>":"")} ${e}: ${this._getShaderType(t)}`:`${i?"const ":""}${this._getShaderType(t)} ${e}`}_samplerCubeFunc(){return this.shaderLanguage===1?"textureSample":"textureCube"}_samplerFunc(){return this.shaderLanguage===1?"textureSample":"texture2D"}_samplerLODFunc(){return this.shaderLanguage===1?"textureSampleLevel":"texture2DLodEXT"}_toLinearSpace(e){return this.shaderLanguage===1?e.type===re.Color3||e.type===re.Vector3?`toLinearSpaceVec3(${e.associatedVariableName})`:`toLinearSpace(${e.associatedVariableName})`:`toLinearSpace(${e.associatedVariableName})`}_generateTextureSample(e,t){return this.shaderLanguage===1?`${this._samplerFunc()}(${t},${t+"Sampler"}, ${e})`:`${this._samplerFunc()}(${t}, ${e})`}_generateTextureSampleLOD(e,t,i){return this.shaderLanguage===1?`${this._samplerLODFunc()}(${t},${t+"Sampler"}, ${e}, ${i})`:`${this._samplerLODFunc()}(${t}, ${e}, ${i})`}_generateTextureSampleCube(e,t){return this.shaderLanguage===1?`${this._samplerCubeFunc()}(${t},${t+"Sampler"}, ${e})`:`${this._samplerCubeFunc()}(${t}, ${e})`}_generateTextureSampleCubeLOD(e,t,i){return this.shaderLanguage===1?`${this._samplerCubeFunc()}(${t},${t+"Sampler"}, ${e}, ${i})`:`${this._samplerCubeFunc()}(${t}, ${e}, ${i})`}_convertVariableDeclarationToWGSL(e,t,i){return i.replace(new RegExp(`(${e})\\s+(\\w+)`,"g"),`var $2: ${t}`)}_convertVariableConstructorsToWGSL(e,t,i){return i.replace(new RegExp(`(${e})\\(`,"g"),` ${t}(`)}_convertOutParametersToWGSL(e){return e.replace(new RegExp("out\\s+var\\s+(\\w+)\\s*:\\s*(\\w+)","g"),"$1: ptr<function, $2>")}_convertTernaryOperandsToWGSL(e){return e.replace(new RegExp("\\[(.*?)\\?(.*?):(.*)\\]","g"),(t,i,s,r)=>`select(${r}, ${s}, ${i})`)}_convertModOperatorsToWGSL(e){return e.replace(new RegExp("mod\\((.+?),\\s*(.+?)\\)","g"),(t,i,s)=>`((${i})%(${s}))`)}_convertConstToWGSL(e){return e.replace(new RegExp("const var","g"),"const")}_convertInnerFunctionsToWGSL(e){return e.replace(new RegExp("inversesqrt","g"),"inverseSqrt")}_convertFunctionsToWGSL(e){const t=/var\s+(\w+)\s*:\s*(\w+)\((.*)\)/g;let i;for(;(i=t.exec(e))!==null;){const s=i[1],r=i[2],o=i[3].replace(/var\s/g,"");e=e.replace(i[0],`fn ${s}(${o}) -> ${r}`)}return e}_babylonSLtoWGSL(e){return e=this._convertVariableDeclarationToWGSL("void","voidnull",e),e=this._convertVariableDeclarationToWGSL("bool","bool",e),e=this._convertVariableDeclarationToWGSL("int","i32",e),e=this._convertVariableDeclarationToWGSL("uint","u32",e),e=this._convertVariableDeclarationToWGSL("float","f32",e),e=this._convertVariableDeclarationToWGSL("vec2","vec2f",e),e=this._convertVariableDeclarationToWGSL("vec3","vec3f",e),e=this._convertVariableDeclarationToWGSL("vec4","vec4f",e),e=this._convertVariableDeclarationToWGSL("mat2","mat2x2f",e),e=this._convertVariableDeclarationToWGSL("mat3","mat3x3f",e),e=this._convertVariableDeclarationToWGSL("mat4","mat4x4f",e),e=this._convertVariableConstructorsToWGSL("float","f32",e),e=this._convertVariableConstructorsToWGSL("vec2","vec2f",e),e=this._convertVariableConstructorsToWGSL("vec3","vec3f",e),e=this._convertVariableConstructorsToWGSL("vec4","vec4f",e),e=this._convertVariableConstructorsToWGSL("mat2","mat2x2f",e),e=this._convertVariableConstructorsToWGSL("mat3","mat3x3f",e),e=this._convertVariableConstructorsToWGSL("mat4","mat4x4f",e),e=this._convertTernaryOperandsToWGSL(e),e=this._convertModOperatorsToWGSL(e),e=this._convertConstToWGSL(e),e=this._convertInnerFunctionsToWGSL(e),e=this._convertOutParametersToWGSL(e),e=e.replace(/\[\*\]/g,"*"),e=this._convertFunctionsToWGSL(e),e=e.replace(/\s->\svoidnull/g,""),e=e.replace(/dFdx/g,"dpdx"),e=e.replace(/dFdy/g,"dpdy"),e}_convertTernaryOperandsToGLSL(e){return e.replace(new RegExp("\\[(.+?)\\?(.+?):(.+)\\]","g"),(t,i,s,r)=>`${i} ? ${s} : ${r}`)}_babylonSLtoGLSL(e){return e=e.replace(/\[\*\]/g,""),e=this._convertTernaryOperandsToGLSL(e),e}}class S4{constructor(){this.temps=[],this.varyings=[],this.varyingDeclaration="",this.varyingDeclarationFragment="",this.varyingInitializationsFragment="",this.inputBlocks=[],this.textureBlocks=[],this.bindableBlocks=[],this.forcedBindableBlocks=[],this.blocksWithFallbacks=[],this.blocksWithDefines=[],this.repeatableContentBlocks=[],this.dynamicUniformBlocks=[],this.blockingBlocks=[],this.animatedInputs=[],this.formatConfig={getUniformAnnotation:null,formatVariablename:e=>e.replace(/[^a-zA-Z_]+/g,"")},this.variableNames={},this.defineNames={},this.hints={needWorldViewMatrix:!1,needWorldViewProjectionMatrix:!1,needAlphaBlending:!1,needAlphaTesting:!1},this.checks={emitVertex:!1,emitFragment:!1,notConnectedNonOptionalInputs:new Array,customErrors:new Array},this.allowEmptyVertexProgram=!1,this.variableNames.position=0,this.variableNames.normal=0,this.variableNames.tangent=0,this.variableNames.uv=0,this.variableNames.uv2=0,this.variableNames.uv3=0,this.variableNames.uv4=0,this.variableNames.uv5=0,this.variableNames.uv6=0,this.variableNames.color=0,this.variableNames.matricesIndices=0,this.variableNames.matricesWeights=0,this.variableNames.matricesIndicesExtra=0,this.variableNames.matricesWeightsExtra=0,this.variableNames.diffuseBase=0,this.variableNames.specularBase=0,this.variableNames.worldPos=0,this.variableNames.shadow=0,this.variableNames.view=0,this.variableNames.vTBN=0,this.defineNames.MAINUV0=0,this.defineNames.MAINUV1=0,this.defineNames.MAINUV2=0,this.defineNames.MAINUV3=0,this.defineNames.MAINUV4=0,this.defineNames.MAINUV5=0,this.defineNames.MAINUV6=0,this.defineNames.MAINUV7=0}raiseBuildError(e){this.checks.customErrors.indexOf(e)!==-1&&this.checks.customErrors.push(e)}emitErrors(){let e="";!this.checks.emitVertex&&!this.allowEmptyVertexProgram&&(e+=`NodeMaterial does not have a vertex output. You need to at least add a block that generates a position value. 3199`),this.checks.emitFragment||(e+=`NodeMaterial does not have a fragment output. You need to at least add a block that generates a color value. 3200`);for(const t of this.checks.notConnectedNonOptionalInputs)e+=`input ${t.name} from block ${t.ownerBlock.name}[${t.ownerBlock.getClassName()}] is not connected and is not optional. 3201`;for(const t of this.checks.customErrors)e+=t+` 3202`;return e?(e=`Node material build failed: 3203`+e,oe.Error(e),this.nodeMaterial.onBuildErrorObservable.notifyObservers(e),!1):!0}}var lA;(function(n){n[n.Compatible=0]="Compatible",n[n.TypeIncompatible=1]="TypeIncompatible",n[n.TargetIncompatible=2]="TargetIncompatible",n[n.HierarchyIssue=3]="HierarchyIssue"})(lA||(lA={}));var cA;(function(n){n[n.Input=0]="Input",n[n.Output=1]="Output"})(cA||(cA={}));class zh{static AreEquivalentTypes(e,t){s
3203witch(e){case re.Vector3:{if(t===re.Color3)return!0;break}case re.Vector4:{if(t===re.Color4)return!0;break}case re.Color3:{if(t===re.Vector3)return!0;break}case re.Color4:{if(t===re.Vector4)return!0;break}}return!1}get isInactive(){return this._isInactive}get _connectedPoint(){return this._connectedPointBackingField}set _connectedPoint(e){this._connectedPointBackingField!==e&&(this._connectedPointTypeChangedObserver?.remove(),this._updateTypeDependentState(()=>this._connectedPointBackingField=e),this._connectedPointBackingField&&(this._connectedPointTypeChangedObserver=this._connectedPointBackingField.onTypeChangedObservable.add(()=>{this._notifyTypeChanged()})))}get _typeConnectionSource(){return this._typeConnectionSourceBackingField}set _typeConnectionSource(e){this._typeConnectionSourceBackingField!==e&&(this._typeConnectionSourceTypeChangedObserver?.remove(),this._updateTypeDependentState(()=>this._typeConnectionSourceBackingField=e),this._typeConnectionSourceBackingField&&(this._typeConnectionSourceTypeChangedObserver=this._typeConnectionSourceBackingField.onTypeChangedObservable.add(()=>{this._notifyTypeChanged()})))}get _defaultConnectionPointType(){return this._defaultConnectionPointTypeBackingField}set _defaultConnectionPointType(e){this._updateTypeDependentState(()=>this._defaultConnectionPointTypeBackingField=e)}get _linkedConnectionSource(){return this._linkedConnectionSourceBackingField}set _linkedConnectionSource(e){this._linkedConnectionSourceBackingField!==e&&(this._linkedConnectionSourceTypeChangedObserver?.remove(),this._updateTypeDependentState(()=>this._linkedConnectionSourceBackingField=e),this._isMainLinkSource=!1,this._linkedConnectionSourceBackingField&&(this._linkedConnectionSourceTypeChangedObserver=this._linkedConnectionSourceBackingField.onTypeChangedObservable.add(()=>{this._notifyTypeChanged()})))}get direction(){return this._direction}get declarationVariableName(){return this._ownerBlock.isInput?this._ownerBlock.declarationVariableName:(!this._enforceAssociatedVariableName||!this._associatedVariableName)&&this._connectedPoint?this._connectedPoint.declarationVariableName:this._associatedVariableName}get associatedVariableName(){return this._ownerBlock.isInput?this._ownerBlock.associatedVariableName:(!this._enforceAssociatedVariableName||!this._associatedVariableName)&&this._connectedPoint?this._connectedPoint.associatedVariableName:this._associatedVariableName}set associatedVariableName(e){this._associatedVariableName=e}get innerType(){return this._linkedConnectionSource&&!this._isMainLinkSource&&this._linkedConnectionSource.isConnected?this.type:this._type}get type(){if(this._type===re.AutoDetect){if(this._ownerBlock.isInput)return this._ownerBlock.type;if(this._connectedPoint)return this._connectedPoint.type;if(this._linkedConnectionSource){if(this._linkedConnectionSource.isConnected)return this._linkedConnectionSource.connectedPoint._redirectedSource&&this._linkedConnectionSource.connectedPoint._redirectedSource.isConnected?this._linkedConnectionSource.connectedPoint._redirectedSource.type:this._linkedConnectionSource.type;if(this._linkedConnectionSource._defaultConnectionPointType)return this._linkedConnectionSource._defaultConnectionPointType}if(this._defaultConnectionPointType)return this._defaultConnectionPointType}if(this._type===re.BasedOnInput){if(this._typeConnectionSource)return!this._typeConnectionSource.isConnected&&this._defaultConnectionPointType?this._defaultConnectionPointType:this._typeConnectionSource.type;if(this._defaultConnectionPointType)return this._defaultConnectionPointType}return this._type}set type(e){this._updateTypeDependentState(()=>this._type=e)}get target(){return!this._prioritizeVertex||!this._ownerBlock?this._target:this._target!==De.VertexAndFragment?this._target:this._ownerBlock.target===De.Fragment?De.Fragment:De.Vertex}set target(e){this._target=e}get isConnected(){return this.connectedPoint!==null||this.hasEndpoints}get isConnectedToInputBlock(){return this.connectedPoint!==null&&this.connectedPoint.ownerBlock.isInput}get connectInputBlock(){return this.isConnectedToInputBlock?this.connectedPoint.ownerBlock:null}get connectedPoint(){return this._connectedPoint}get ownerBlock(){return this._ownerBlock}get sourceBlock(){return this._connectedPoint?this._connectedPoint.ownerBlock:null}get connectedBlocks(){return this._endpoints.length===0?[]:this._endpoints.map(e=>e.ownerBlock)}get endpoints(){return this._endpoints}get hasEndpoints(){return this._endpoints&&this._endpoints.length>0}get isDirectlyConnectedToVertexOutput(){if(!this.hasEndpoints)return!1;for(const e of this._endpoints)if(e.ownerBlock.target===De.Vertex||(e.ownerBlock.target===De.Neutral||e.ownerBlock.target===De.VertexAndFragment)&&e.ownerBlock.outputs.some(t=>t.isDirectlyConnectedToVertexOutput))return!0;return!1}
3203get isConnectedInVertexShader(){if(this.target===De.Vertex)return!0;if(!this.hasEndpoints)return!1;for(const e of this._endpoints)if(e.ownerBlock.target===De.Vertex||e.target===De.Vertex||(e.ownerBlock.target===De.Neutral||e.ownerBlock.target===De.VertexAndFragment)&&e.ownerBlock.outputs.some(t=>t.isConnectedInVertexShader))return!0;return!1}get isConnectedInFragmentShader(){if(this.target===De.Fragment)return!0;if(!this.hasEndpoints)return!1;for(const e of this._endpoints)if(e.ownerBlock.target===De.Fragment||(e.ownerBlock.target===De.Neutral||e.ownerBlock.target===De.VertexAndFragment)&&e.ownerBlock.isConnectedInFragmentShader())return!0;return!1}createCustomInputBlock(){return null}constructor(e,t,i){this._isInactive=!1,this._preventBubbleUp=!1,this._connectedPointBackingField=null,this._endpoints=new Array,this._redirectedSource=null,this._typeConnectionSourceBackingField=null,this._defaultConnectionPointTypeBackingField=null,this._isMainLinkSource=!1,this._linkedConnectionSourceBackingField=null,this._acceptedConnectionPointType=null,this._type=re.Float,this._enforceAssociatedVariableName=!1,this._forPostBuild=!1,this.needDualDirectionValidation=!1,this.acceptedConnectionPointTypes=[],this.excludedConnectionPointTypes=[],this.onConnectionObservable=new le,this.onDisconnectionObservable=new le,this.onTypeChangedObservable=new le,this._isTypeChangeObservableNotifying=!1,this.isExposedOnFrame=!1,this.exposedPortPosition=-1,this._prioritizeVertex=!1,this._target=De.VertexAndFragment,this._ownerBlock=t,this.name=e,this._direction=i}getClassName(){return"NodeMaterialConnectionPoint"}canConnectTo(e){return this.checkCompatibilityState(e)===0}checkCompatibilityState(e){const t=this._ownerBlock,i=e.ownerBlock;if(t.target===De.Fragment){if(i.target===De.Vertex)return 2;for(const a of i.outputs)if(a.ownerBlock.target!=De.Neutral&&a.isConnectedInVertexShader)return 2}if(this.type!==e.type&&e.innerType!==re.AutoDetect)return zh.AreEquivalentTypes(this.type,e.type)||e.acceptedConnectionPointTypes&&e.acceptedConnectionPointTypes.indexOf(this.type)!==-1||e._acceptedConnectionPointType&&zh.AreEquivalentTypes(e._acceptedConnectionPointType.type,this.type)?0:1;if(e.excludedConnectionPointTypes&&e.excludedConnectionPointTypes.indexOf(this.type)!==-1)return 1;let s=i,r=t;return this.direction===0&&(s=t,r=i),s.isAnAncestorOf(r)?3:0}connectTo(e,t=!1){if(!t&&!this.canConnectTo(e))throw`Cannot connect these two connectors. source: "${this.ownerBlock.name}".${this.name}, target: "${e.ownerBlock.name}".${e.name}`;return this._endpoints.push(e),e._connectedPoint=this,this._enforceAssociatedVariableName=!1,this.onConnectionObservable.notifyObservers(e),e.onConnectionObservable.notifyObservers(this),this}disconnectFrom(e){const t=this._endpoints.indexOf(e);return t===-1?this:(this._endpoints.splice(t,1),e._connectedPoint=null,this._enforceAssociatedVariableName=!1,e._enforceAssociatedVariableName=!1,this.onDisconnectionObservable.notifyObservers(e),e.onDisconnectionObservable.notifyObservers(this),this)}addExcludedConnectionPointFromAllowedTypes(e){let t=1;for(;t<re.All;)e&t||this.excludedConnectionPointTypes.push(t),t=t<<1}serialize(e=!0){const t={};return t.name=this.name,this.displayName&&(t.displayName=this.displayName),e&&this.connectedPoint&&(t.inputName=this.name,t.targetBlockId=this.connectedPoint.ownerBlock.uniqueId,t.targetConnectionName=this.connectedPoint.name,t.isExposedOnFrame=!0,t.exposedPortPosition=this.exposedPortPosition),(this.isExposedOnFrame||this.exposedPortPosition>=0)&&(t.isExposedOnFrame=!0,t.exposedPortPosition=this.exposedPortPosition),t}dispose(){this.onConnectionObservable.clear(),this.onDisconnectionObservable.clear(),this.onTypeChangedObservable.clear(),this._connectedPoint=null,this._typeConnectionSource=null,this._linkedConnectionSource=null}_updateTypeDependentState(e){const t=this.type;e(),this.type!==t&&this._notifyTypeChanged()}_notifyTypeChanged(){this._isTypeChangeObservableNotifying||(this._isTypeChangeObservableNotifying=!0,this.onTypeChangedObservable.notifyObservers(this.type),this._isTypeChangeObservableNotifying=!1)}}class Ws{get _isFinalOutputAndActive(){return this._isFinalOutput}get _hasPrecedence(){return!1}get name(){return this._name}get codeIsReady(){return this._codeIsReady}set name(e){this.validateBlockName(e)&&(this._name=e)}get isUnique(){return this._isUnique}get isFinalMerger(){return this._isFinalMerger}get isInput(){return this._isInput}get isTeleportOut(){return this._isTeleportOut}get isTeleportIn(){return this._isTeleportIn}get isLoop(){return this._isLoop}get buildId(){return this._buildId}set buildId(e){this._buildId=e}get target(){return this._target}set target(e){(this._target&e)===0&&(this._target=e)}get inputs(){return this._inputs}get outputs(){return this._outputs}getInputByName(e){const t=this._inputs.filter(i=>i.name===e);return t.length?t[0]:null}getOutputByName(e){const t=this._outputs.filter(i=>i.name===e);return t.length?t[0]:null}constructor(e,t=De.Vertex,i=!1,s=!1){switch(this._isFinalMerger=!1,this._isInput=!1,this._isLoop=!1,this._isTeleportOut=!1,this._isTeleportIn=!1,this._name="",this._isUnique=!1,this._codeIsReady=!0,this._isFinalOutput=!1,this.onCodeIsReadyObservable=new le,this.inputsAreExclusive=!1,this._codeVariableName="",this._inputs=new Array,this._outputs=new Array,this.comments="",this.visibleInInspector=!1,this.visibleOnFrame=!1,this._target=t,this._originalTargetIsNeutral=t===De.Neutral,this._isFinalMerger=i,this._isFinalOutput=s,this.getClassName()){case"InputBlock":this._isInput=!0;break;case"NodeMaterialTeleportOutBlock":this._isTeleportOut=!0;break;case"NodeMaterialTeleportInBlock":this._isTeleportIn=!0;break;case"LoopBlock":this._isLoop=!0;break}this._name=e,this.uniqueId=Vb.UniqueId}_setInitialTarget(e){this._target=e,this._originalTargetIsNeutral=e===De.Neutral}initialize(e){}bind(e,t,i,s){}_writeVariable(e){return e.connectedPoint?`${e.associatedVariableName}`:"0."}_writeFloat(e){let t=e.toString();return t.indexOf(".")===-1&&(t+=".0"),`${t}`}getClassName(){return"NodeMaterialBlock"}isConnectedInFragmentShader(){return this.outputs.some(e=>e.isConnectedInFragmentShader)}registerInput(e,t,i=!1,s,r){return r=r??new zh(e,this,0),r.type=t,r.isOptional=i,s&&(r.target=s),this._inputs.push(r),this}registerOutput(e,t,i,s){return s=s??new zh(e,this,1),s.type=t,i&&(s.target=i),this._outputs.push(s),this}getFirstAvailableInput(e=null){for(const t of this._inputs)if(!t.connectedPoint&&(!e||e.type===t.type||t.type===re.AutoDetect||t.acceptedConnectionPointTypes.indexOf(e.type)!==-1))return t;return null}getFirstAvailableOutput(e=null){for(const t of this._outputs)if(!e||!e.target||e.target===De.Neutral||(e.target&t.target)!==0)return t;return null}getSiblingOutput(e){const t=this._outputs.indexOf(e);return t===-1||t>=this._outputs.length?null:this._outputs[t+1]}isAnAncestorOf(e){for(const t of this._outputs)if(t.hasEndpoints){for(const i of t.endpoints)if(i.ownerBlock===e||i.ownerBlock.isAnAncestorOf(e))return!0}return!1}connectTo(e,t){if(this._outputs.length===0)return;let i=t&&t.output?this.getOutputByName(t.output):this.getFirstAvailableOutput(e),s=!0;for(;s;){const r=t&&t.input?e.getInputByName(t.input):e.getFirstAvailableInput(i);if(i&&r&&i.canConnectTo(r))i.connectTo(r),s=!1;else if(i)i=this.getSiblingOutput(i);else throw"Unable to find a compatible match"}return this}_buildBlock(e){}_postBuildBlock(e){}updateUniformsAndSamples(e,t,i,s){}provideFallbacks(e,t){}initializeDefines(e){}prepareDefines(e,t,i,s=!1,r){}
3203autoConfigure(e,t=()=>!0){}replaceRepeatableContent(e,t,i){}get willBeGeneratedIntoVertexShaderFromFragmentShader(){return this.isInput||this.isFinalMerger||this._outputs.some(e=>e.isDirectlyConnectedToVertexOutput)||this.target===De.Vertex?!1:!!((this.target===De.VertexAndFragment||this.target===De.Neutral)&&this._outputs.some(e=>e.isConnectedInVertexShader))}isReady(e,t,i,s=!1){return!0}_linkConnectionTypes(e,t,i=!1){i?this._inputs[t]._acceptedConnectionPointType=this._inputs[e]:(this._inputs[e]._linkedConnectionSource=this._inputs[t],this._inputs[e]._isMainLinkSource=!0),this._inputs[t]._linkedConnectionSource=this._inputs[e]}_processBuild(e,t,i,s){e.build(t,s);const r=t._vertexState!=null,a=e._buildTarget===De.Vertex&&e.target!==De.VertexAndFragment;if(!(e.isTeleportOut&&e.entryPoint?.isConnectedToUniform)&&r&&((e.target&e._buildTarget)===0||(e.target&i.target)===0||this.target!==De.VertexAndFragment&&a)&&(!e.isInput&&t.target!==e._buildTarget||e.isInput&&e.isAttribute&&!e._noContextSwitch)){const o=i.connectedPoint;if(t._vertexState._emitVaryingFromString("v_"+o.declarationVariableName,o.type)){const u=t.shaderLanguage===1?"vertexOutputs.":"";t.shaderLanguage===1&&o.type===re.Matrix?(t._vertexState.compilationString+=`${u}${"v_"+o.declarationVariableName}_r0 = ${o.associatedVariableName}[0]; 3204`,t._vertexState.compilationString+=`${u}${"v_"+o.declarationVariableName}_r1 = ${o.associatedVariableName}[1]; 3205`,t._vertexState.compilationString+=`${u}${"v_"+o.declarationVariableName}_r2 = ${o.associatedVariableName}[2]; 3206`,t._vertexState.compilationString+=`${u}${"v_"+o.declarationVariableName}_r3 = ${o.associatedVariableName}[3]; 3207`):t._vertexState.compilationString+=`${u}${"v_"+o.declarationVariableName} = ${o.associatedVariableName}; 3208`}const c=t.shaderLanguage===1&&o.type!==re.Matrix?"fragmentInputs.":"";i.associatedVariableName=c+"v_"+o.declarationVariableName,i._enforceAssociatedVariableName=!0}}validateBlockName(e){const t=["position","normal","tangent","particle_positionw","uv","uv2","uv3","uv4","uv5","uv6","position2d","particle_uv","postprocess_uv","matricesIndices","matricesWeights","world0","world1","world2","world3","particle_color","particle_texturemask"];for(const i of t)if(e===i)return!1;return!0}_customBuildStep(e,t){}build(e,t){if(this._buildId===e.sharedData.buildId)return!0;if(!this.isInput)for(const i of this._outputs)i.associatedVariableName||(i.associatedVariableName=e._getFreeVariableName(i.name));for(const i of this._inputs){if(!i.connectedPoint){i.isOptional||e.sharedData.checks.notConnectedNonOptionalInputs.push(i);continue}if(this.target!==De.Neutral&&((i.target&this.target)===0||(i.target&e.target)===0))continue;const s=i.connectedPoint.ownerBlock;s&&s!==this&&this._processBuild(s,e,i,t)}if(this._customBuildStep(e,t),this._buildId===e.sharedData.buildId)return!0;if(e.sharedData.verbose&&oe.Log(`${e.target===De.Vertex?"Vertex shader":"Fragment shader"}: Building ${this.name} [${this.getClassName()}]`),this.isFinalMerger)switch(e.target){case De.Vertex:e.sharedData.checks.emitVertex=!0;break;case De.Fragment:e.sharedData.checks.emitFragment=!0;break}!this.isInput&&e.sharedData.emitComments&&(e.compilationString+=` 3209//${this.name} 3210`),this._buildBlock(e),this._buildId=e.sharedData.buildId,this._buildTarget=e.target;for(const i of this._outputs)if(!i._forPostBuild&&(i.target&e.target)!==0)for(const s of i.endpoints){const r=s.ownerBlock;r&&((r.target&e.target)!==0&&t.indexOf(r)!==-1||e._terminalBlocks.has(r))&&this._processBuild(r,e,s,t)}this._postBuildBlock(e);for(const i of this._outputs)if(i._forPostBuild&&(i.target&e.target)!==0)for(const s of i.endpoints){const r=s.ownerBlock;r&&(r.target&e.target)!==0&&t.indexOf(r)!==-1&&this._processBuild(r,e,s,t)}return!1}_inputRename(e){return e}_outputRename(e){return e}_dumpPropertiesCode(){const e=this._codeVariableName;return`${e}.visibleInInspector = ${this.visibleInInspector}; 3211${e}.visibleOnFrame = ${this.visibleOnFrame}; 3212${e}.target = ${this.target}; 3213`}_dumpCode(e,t){t.push(this);const i=this.name.replace(/[^A-Za-z_]+/g,"");if(this._codeVariableName=i||`${this.getClassName()}_${this.uniqueId}`,e.indexOf(this._codeVariableName)!==-1){let r=0;do r++,this._codeVariableName=i+r;while(e.indexOf(this._codeVariableName)!==-1)}
3213e.push(this._codeVariableName);let s=` 3214// ${this.getClassName()} 3215`;this.comments&&(s+=`// ${this.comments} 3216`),s+=`var ${this._codeVariableName} = new BABYLON.${this.getClassName()}("${this.name}"); 3217`,s+=this._dumpPropertiesCode();for(const r of this.inputs){if(!r.isConnected)continue;const o=r.connectedPoint.ownerBlock;t.indexOf(o)===-1&&(s+=o._dumpCode(e,t))}for(const r of this.outputs)if(r.hasEndpoints)for(const a of r.endpoints){const o=a.ownerBlock;o&&t.indexOf(o)===-1&&(s+=o._dumpCode(e,t))}return s}_dumpCodeForOutputConnections(e){let t="";if(e.indexOf(this)!==-1)return t;e.push(this);for(const i of this.inputs){if(!i.isConnected)continue;const s=i.connectedPoint,r=s.ownerBlock;t+=r._dumpCodeForOutputConnections(e),t+=`${r._codeVariableName}.${r._outputRename(s.name)}.connectTo(${this._codeVariableName}.${this._inputRename(i.name)}); 3218`}return t}clone(e,t=""){const i=this.serialize(),s=Kr(i.customType);if(s){const r=new s;return r._deserialize(i,e,t),r}return null}serialize(){const e={};e.customType="BABYLON."+this.getClassName(),e.id=this.uniqueId,e.name=this.name,e.comments=this.comments,e.visibleInInspector=this.visibleInInspector,e.visibleOnFrame=this.visibleOnFrame,e.target=this.target,e.inputs=[],e.outputs=[];for(const t of this.inputs)e.inputs.push(t.serialize());for(const t of this.outputs)e.outputs.push(t.serialize(!1));return e}_deserialize(e,t,i,s){this.name=e.name,this.comments=e.comments,this.visibleInInspector=!!e.visibleInInspector,this.visibleOnFrame=!!e.visibleOnFrame,this._target=e.target??this.target,this._deserializePortDisplayNamesAndExposedOnFrame(e)}_deserializePortDisplayNamesAndExposedOnFrame(e){const t=e.inputs,i=e.outputs;if(t)for(let s=0;s<t.length;s++){const r=t[s];r.displayName&&(this.inputs[s].displayName=r.displayName),r.isExposedOnFrame&&(this.inputs[s].isExposedOnFrame=r.isExposedOnFrame,this.inputs[s].exposedPortPosition=r.exposedPortPosition)}if(i)for(let s=0;s<i.length;s++){const r=i[s];r.displayName&&(this.outputs[s].displayName=r.displayName),r.isExposedOnFrame&&(this.outputs[s].isExposedOnFrame=r.isExposedOnFrame,this.outputs[s].exposedPortPosition=r.exposedPortPosition)}}dispose(){this.onCodeIsReadyObservable.clear();for(const e of this.inputs)e.dispose();for(const e of this.outputs)e.dispose()}}var hA;(function(n){n[n.Boolean=0]="Boolean",n[n.Float=1]="Float",n[n.Int=2]="Int",n[n.Vector2=3]="Vector2",n[n.Vector3=4]="Vector3",n[n.List=5]="List",n[n.Color3=6]="Color3",n[n.Color4=7]="Color4",n[n.SamplingMode=8]="SamplingMode",n[n.TextureFormat=9]="TextureFormat",n[n.TextureType=10]="TextureType",n[n.String=11]="String",n[n.Matrix=12]="Matrix",n[n.Viewport=13]="Viewport"})(hA||(hA={}));function bc(n,e=0,t="PROPERTIES",i){return(s,r)=>{let a=s._propStore;a||(a=[],s._propStore=a),a.push({propertyName:r,displayName:n,type:e,groupName:t,options:i??{},className:s.getClassName()})}}var mn;(function(n){n[n.NoColorSpace=0]="NoColorSpace",n[n.Gamma=1]="Gamma",n[n.Linear=2]="Linear"})(mn||(mn={}));class ja extends Ws{constructor(e){super(e,De.Fragment,!0,!0),this.convertToGammaSpace=!1,this.convertToLinearSpace=!1,this.useLogarithmicDepth=!1,this.registerInput("rgba",re.Color4,!0),this.registerInput("rgb",re.Color3,!0),this.registerInput("a",re.Float,!0),this.registerInput("glow",re.Color3,!0),this.rgb.acceptedConnectionPointTypes.push(re.Vector3),this.rgb.acceptedConnectionPointTypes.push(re.Float),this.additionalColor.acceptedConnectionPointTypes.push(re.Vector3),this.additionalColor.acceptedConnectionPointTypes.push(re.Float)}get colorSpace(){return this.convertToGammaSpace?mn.Gamma:this.convertToLinearSpace?mn.Linear:mn.NoColorSpace}set colorSpace(e){this.convertToGammaSpace=e===mn.Gamma,this.convertToLinearSpace=e===mn.Linear}getClassName(){return"FragmentOutputBlock"}initialize(e){e._excludeVariableName("logarithmicDepthConstant"),e._excludeVariableName("vFragmentDepth")}get rgba(){return this._inputs[0]}get rgb(){return this._inputs[1]}get a(){return this._inputs[2]}get additionalColor(){return this._inputs[3]}get glow(){return this._inputs[3]}_getOutputString(e){return e.shaderLanguage===1?"fragmentOutputsColor":"gl_FragColor"}prepareDefines(e,t){e.setValue(this._linearDefineName,this.convertToLinearSpace,!0),e.setValue(this._gammaDefineName,this.convertToGammaSpace,!0),e.setValue(this._additionalColorDefineName,this.additionalColor.connectedPoint&&t._useAdditionalColor,!0)}bind(e,t,i){(this.useLogarithmicDepth||t.useLogarithmicDepth)&&i&&Fb(void 0,e,i.getScene())}_buildBlock(e){super._buildBlock(e);const t=this.rgba,i=this.rgb,s=this.a,r=this.additionalColor,a=e.shaderLanguage===1;
3218e.sharedData.hints.needAlphaBlending=t.isConnected||s.isConnected,e.sharedData.blocksWithDefines.push(this),(this.useLogarithmicDepth||e.sharedData.nodeMaterial.useLogarithmicDepth)&&(e._emitUniformFromString("logarithmicDepthConstant",re.Float),e._emitVaryingFromString("vFragmentDepth",re.Float),e.sharedData.bindableBlocks.push(this)),r.connectedPoint&&(e._excludeVariableName("useAdditionalColor"),e._emitUniformFromString("useAdditionalColor",re.Float),this._additionalColorDefineName=e._getFreeDefineName("USEADDITIONALCOLOR")),this._linearDefineName=e._getFreeDefineName("CONVERTTOLINEAR"),this._gammaDefineName=e._getFreeDefineName("CONVERTTOGAMMA");const o=`//${this.name}`;e._emitFunctionFromInclude("helperFunctions",o);const c=this._getOutputString(e);e.shaderLanguage===1&&(e.compilationString+=`var ${c} : vec4<f32>;\r 3219`);const u=e._getShaderType(re.Vector4);if(r.connectedPoint){let d="1.0";s.connectedPoint&&(d=s.associatedVariableName),e.compilationString+=`#ifdef ${this._additionalColorDefineName} 3220`,r.connectedPoint.type===re.Float?e.compilationString+=`${c} = ${u}(${r.associatedVariableName}, ${r.associatedVariableName}, ${r.associatedVariableName}, ${d}); 3221`:e.compilationString+=`${c} = ${u}(${r.associatedVariableName}, ${d}); 3222`,e.compilationString+=`#else 3223`}if(t.connectedPoint)s.isConnected?e.compilationString+=`${c} = ${u}(${t.associatedVariableName}.rgb, ${s.associatedVariableName}); 3224`:e.compilationString+=`${c} = ${t.associatedVariableName}; 3225`;else if(i.connectedPoint){let d="1.0";s.connectedPoint&&(d=s.associatedVariableName),i.connectedPoint.type===re.Float?e.compilationString+=`${c} = ${u}(${i.associatedVariableName}, ${i.associatedVariableName}, ${i.associatedVariableName}, ${d}); 3226`:e.compilationString+=`${c} = ${u}(${i.associatedVariableName}, ${d}); 3227`}else e.sharedData.checks.notConnectedNonOptionalInputs.push(t);if(r.connectedPoint&&(e.compilationString+=`#endif 3228`),e.compilationString+=`#ifdef ${this._linearDefineName} 3229`,e.compilationString+=`${c} = toLinearSpace(${c}); 3230`,e.compilationString+=`#endif 3231`,e.compilationString+=`#ifdef ${this._gammaDefineName} 3232`,e.compilationString+=`${c} = toGammaSpace(${c}); 3233`,e.compilationString+=`#endif 3234`,e.shaderLanguage===1&&(e.compilationString+=`#if !defined(PREPASS)\r 3235`,e.compilationString+=`fragmentOutputs.color = ${c};\r 3236`,e.compilationString+=`#endif\r 3237`),this.useLogarithmicDepth||e.sharedData.nodeMaterial.useLogarithmicDepth){const d=a?"input.vFragmentDepth":"vFragmentDepth",f=a?"uniforms.":"",g=a?"fragmentOutputs.fragDepth":"gl_FragDepthEXT";e.compilationString+=`${g} = log2(${d}) * ${f}logarithmicDepthConstant * 0.5; 3238`}return e.compilationString+=`#if defined(PREPASS)\r 3239`,e.compilationString+=`${a?"fragmentOutputs.fragData0":"gl_FragData[0]"} = ${c};\r 3240`,e.compilationString+=`#endif\r 3241`,this}_dumpPropertiesCode(){let e=super._dumpPropertiesCode();return e+=`${this._codeVariableName}.convertToGammaSpace = ${this.convertToGammaSpace}; 3242`,e+=`${this._codeVariableName}.convertToLinearSpace = ${this.convertToLinearSpace}; 3243`,e+=`${this._codeVariableName}.useLogarithmicDepth = ${this.useLogarithmicDepth}; 3244`,e}serialize(){const e=super.serialize();return e.convertToGammaSpace=this.convertToGammaSpace,e.convertToLinearSpace=this.convertToLinearSpace,e.useLogarithmicDepth=this.useLogarithmicDepth,e}_deserialize(e,t,i){super._deserialize(e,t,i),this.convertToGammaSpace=!!e.convertToGammaSpace,this.convertToLinearSpace=!!e.convertToLinearSpace,this.useLogarithmicDepth=e.useLogarithmicDepth??!1}}N([bc("Use logarithmic depth",0,"PROPERTIES",{embedded:!0})],ja.prototype,"useLogarithmicDepth",void 0);N([bc("Color space",5,"ADVANCED",{notifiers:{rebuild:!0},embedded:!0,options:[{label:"No color space",value:mn.NoColorSpace},{label:"Gamma",value:mn.Gamma},{label:"Linear",value:mn.Linear}]})],ja.prototype,"colorSpace",null);Tt("BABYLON.FragmentOutputBlock",ja);var $i;(function(n){n[n.Material=0]="Material",n[n.PostProcess=1]="PostProcess",n[n.Particle=2]="Particle",n[n.ProceduralTexture=3]="ProceduralTexture",n[n.GaussianSplatting=4]="GaussianSplatting",n[n.SFE=5]="SFE"})($i||($i={}));var Bt;(function(n){n[n.World=1]="World",n[n.View=2]="View",n[n.Projection=3]="Projection",n[n.ViewProjection=4]="ViewProjection",n[n.WorldView=5]="WorldView",n[n.WorldViewProjection=6]="WorldViewProjection",n[n.CameraPosition=7]="CameraPosition",n[n.FogColor=8]="FogColor",n[n.DeltaTime=9]="DeltaTime",n[n.CameraParameters=10]="CameraParameters",n[n.MaterialAlpha=11]="MaterialAlpha",n[n.ProjectionInverse=12]="ProjectionInverse"})(Bt||(Bt={}));var $n;(function(n){n[n.None=0]="None",n[n.Time=1]="Time",n[n.RealTime=2]="RealTime",n[n.MouseInfo=3]="MouseInfo"})($n||($n={}));
3244const T4={position2d:"position",particle_uv:"vUV",particle_color:"vColor",particle_texturemask:"textureMask",particle_positionw:"vPositionW",postprocess_uv:"vUV"},jg={particle_uv:!0,particle_color:!0,particle_texturemask:!0,particle_positionw:!0,postprocess_uv:!0},uA={particle_texturemask:!0},dA={normal:"NORMAL",tangent:"TANGENT",uv:"UV1",uv2:"UV2",uv3:"UV3",uv4:"UV4",uv5:"UV5",uv6:"UV6",uv7:"UV7",uv8:"UV8"};class fs extends Ws{get type(){if(this._type===re.AutoDetect){if(this.isUniform&&this.value!=null){if(!isNaN(this.value))return this._type=re.Float,this._type;switch(this.value.getClassName()){case"Vector2":return this._type=re.Vector2,this._type;case"Vector3":return this._type=re.Vector3,this._type;case"Vector4":return this._type=re.Vector4,this._type;case"Color3":return this._type=re.Color3,this._type;case"Color4":return this._type=re.Color4,this._type;case"Matrix":return this._type=re.Matrix,this._type}}if(this.isAttribute)switch(this.name){case"splatIndex":return this._type=re.Float,this._type;case"position":case"normal":case"particle_positionw":case"splatPosition":return this._type=re.Vector3,this._type;case"uv":case"uv2":case"uv3":case"uv4":case"uv5":case"uv6":case"position2d":case"particle_uv":case"splatScale":case"postprocess_uv":return this._type=re.Vector2,this._type;case"matricesIndices":case"matricesWeights":case"matricesIndicesExtra":case"matricesWeightsExtra":case"world0":case"world1":case"world2":case"world3":case"tangent":return this._type=re.Vector4,this._type;case"color":case"instanceColor":case"particle_color":case"particle_texturemask":case"splatColor":return this._type=re.Color4,this._type}if(this.isSystemValue)switch(this._systemValue){case Bt.World:case Bt.WorldView:case Bt.WorldViewProjection:case Bt.View:case Bt.ViewProjection:case Bt.Projection:case Bt.ProjectionInverse:return this._type=re.Matrix,this._type;case Bt.CameraPosition:return this._type=re.Vector3,this._type;case Bt.FogColor:return this._type=re.Color3,this._type;case Bt.DeltaTime:case Bt.MaterialAlpha:return this._type=re.Float,this._type;case Bt.CameraParameters:return this._type=re.Vector4,this._type}}return this._type}constructor(e,t=De.Vertex,i=re.AutoDetect){super(e,t,!1),this._mode=3,this._animationType=$n.None,this._prefix="",this.min=0,this.max=0,this.isBoolean=!1,this.matrixMode=0,this._systemValue=null,this.isConstant=!1,this.groupInInspector="",this.onValueChangedObservable=new le,this.convertToGammaSpace=!1,this.convertToLinearSpace=!1,this._type=i,this.setDefaultValue(),this.registerOutput("output",i)}validateBlockName(e){return this.isAttribute?!0:super.validateBlockName(e)}get output(){return this._outputs[0]}setAsAttribute(e){return this._mode=1,e&&(this.name=e),this}setAsSystemValue(e){return this.systemValue=e,this}get value(){return this._storedValue}set value(e){this.type===re.Float&&(this.isBoolean?e=e?1:0:this.min!==this.max&&(e=Math.max(this.min,e),e=Math.min(this.max,e))),this._storedValue=e,this._mode=0,this.onValueChangedObservable.notifyObservers(this)}get valueCallback(){return this._valueCallback}set valueCallback(e){this._valueCallback=e,this._mode=0}get declarationVariableName(){return this._associatedVariableName}get associatedVariableName(){return this._prefix+this._associatedVariableName}set associatedVariableName(e){this._associatedVariableName=e}get animationType(){return this._animationType}set animationType(e){this._animationType=e}get isUndefined(){return this._mode===3}get isUniform(){return this._mode===0}set isUniform(e){this._mode=e?0:3,this.associatedVariableName=""}get isAttribute(){return this._mode===1}set isAttribute(e){this._mode=e?1:3,this.associatedVariableName=""}get isVarying(){return this._mode===2}set isVarying(e){this._mode=e?2:3,this.associatedVariableName=""}get isSystemValue(){return this._systemValue!=null}get systemValue(){return this._systemValue}set systemValue(e){this._mode=0,this.associatedVariableName="",this._systemValue=e}getClassName(){return"InputBlock"}animate(e){switch(this._animationType){case $n.Time:{this.type===re.Float&&(this.value+=e.getAnimationRatio()*.01);break}case $n.RealTime:{this.type===re.Float&&(this.value=(nr.Now-e.getEngine().startTime)/1e3);break}
3244case $n.MouseInfo:{if(this.type===re.Vector4){const t=e._inputManager._originMouseEvent;if(t){const i=t.offsetX,s=t.offsetY,r=(t.buttons&1)!=0?1:0,a=(t.buttons&2)!=0?1:0;this.value=new rt(i,s,r,a)}else this.value=new rt(0,0,0,0)}break}}}_emitDefine(e,t=!1){return`${t?"#ifndef":"#ifdef"} ${e} 3245`}initialize(){this.associatedVariableName=""}setDefaultValue(){switch(this.type){case re.Float:this.value=0;break;case re.Vector2:this.value=Ie.Zero();break;case re.Vector3:this.value=T.Zero();break;case re.Vector4:this.value=rt.Zero();break;case re.Color3:this.value=Ne.White();break;case re.Color4:this.value=new Ze(1,1,1,1);break;case re.Matrix:this.value=W.Identity();break}}_emitConstant(e){switch(this.type){case re.Float:return`${e._emitFloat(this.value)}`;case re.Vector2:return`vec2(${this.value.x}, ${this.value.y})`;case re.Vector3:return`vec3(${this.value.x}, ${this.value.y}, ${this.value.z})`;case re.Vector4:return`vec4(${this.value.x}, ${this.value.y}, ${this.value.z}, ${this.value.w})`;case re.Color3:return Ft.Color3[0].set(this.value.r,this.value.g,this.value.b),this.convertToGammaSpace&&Ft.Color3[0].toGammaSpaceToRef(Ft.Color3[0],e.sharedData.scene.getEngine().useExactSrgbConversions),this.convertToLinearSpace&&Ft.Color3[0].toLinearSpaceToRef(Ft.Color3[0],e.sharedData.scene.getEngine().useExactSrgbConversions),`vec3(${Ft.Color3[0].r}, ${Ft.Color3[0].g}, ${Ft.Color3[0].b})`;case re.Color4:return Ft.Color4[0].set(this.value.r,this.value.g,this.value.b,this.value.a),this.convertToGammaSpace&&Ft.Color4[0].toGammaSpaceToRef(Ft.Color4[0],e.sharedData.scene.getEngine().useExactSrgbConversions),this.convertToLinearSpace&&Ft.Color4[0].toLinearSpaceToRef(Ft.Color4[0],e.sharedData.scene.getEngine().useExactSrgbConversions),`vec4(${Ft.Color4[0].r}, ${Ft.Color4[0].g}, ${Ft.Color4[0].b}, ${Ft.Color4[0].a})`}return""}get _noContextSwitch(){return jg[this.name]}_emit(e){if(this.isUniform){if(this._associatedVariableName||(this._associatedVariableName=e._getFreeVariableName("u_"+this.name)),this.isConstant){if(e.constants.indexOf(this.associatedVariableName)!==-1)return;e.constants.push(this.associatedVariableName),e._constantDeclaration+=e._declareOutput(this.output,!0)+` = ${this._emitConstant(e)}; 3246`;return}if(e.uniforms.indexOf(this.associatedVariableName)!==-1)return;e._emitUniformFromString(this._associatedVariableName,this.type),e.shaderLanguage===1&&(this._prefix="uniforms.");const t=e.sharedData.hints;if(this._systemValue!==null&&this._systemValue!==void 0)switch(this._systemValue){case Bt.WorldView:t.needWorldViewMatrix=!0;break;case Bt.WorldViewProjection:t.needWorldViewProjectionMatrix=!0;break}else this._animationType!==$n.None&&e.sharedData.animatedInputs.push(this);return}if(this.isAttribute){if(this.associatedVariableName=T4[this.name]??this.name,this.target===De.Vertex&&e._vertexState){jg[this.name]?uA[this.name]?(e._emitUniformFromString(this.declarationVariableName,this.type),e.shaderLanguage===1&&(this._prefix="vertexInputs.")):e._emitVaryingFromString(this.declarationVariableName,this.type):this._emit(e._vertexState);return}const t=e.attributes.indexOf(this.declarationVariableName)!==-1;if(t||e.attributes.push(this.declarationVariableName),jg[this.name])uA[this.name]?(t||e._emitUniformFromString(this.declarationVariableName,this.type),e.shaderLanguage===1&&(this._prefix="uniforms.")):(t||e._emitVaryingFromString(this.declarationVariableName,this.type),e.shaderLanguage===1&&(this._prefix="fragmentInputs."));else if(e.shaderLanguage===1){if(!t){const i=dA[this.name];i?(e._attributeDeclaration+=this._emitDefine(i),e._attributeDeclaration+=`attribute ${this.declarationVariableName}: ${e._getShaderType(this.type)}; 3247`,e._attributeDeclaration+=`#else 3248`,e._attributeDeclaration+=`var<private> ${this.declarationVariableName}: ${e._getShaderType(this.type)} = ${e._getShaderType(this.type)}(0.); 3249`,e._attributeDeclaration+=`#endif 3250`):e._attributeDeclaration+=`attribute ${this.declarationVariableName}: ${e._getShaderType(this.type)}; 3251`}this._prefix="vertexInputs."}else if(!t){const i=dA[this.name];i?(e._attributeDeclaration+=this._emitDefine(i),e._attributeDeclaration+=`attribute ${e._getShaderType(this.type)} ${this.declarationVariableName}; 3252`,e._attributeDeclaration+=`#else 3253`,e._attributeDeclaration+=`${e._getShaderType(this.type)} ${this.declarationVariableName} = ${e._getShaderType(this.type)}(0.); 3254`,e._attributeDeclaration+=`#endif 3255`):e._attributeDeclaration+=`attribute ${e._getShaderType(this.type)} ${this.declarationVariableName}; 3256`}}}_transmitWorld(e,t,i,s){if(!this._systemValue)return;const r=this._associatedVariableName;
3256switch(this._systemValue){case Bt.World:e.setMatrix(r,t);break;case Bt.WorldView:e.setMatrix(r,i);break;case Bt.WorldViewProjection:e.setMatrix(r,s);break}}_transmit(e,t,i){if(this.isAttribute)return;const s=this._associatedVariableName;if(this._systemValue){switch(this._systemValue){case Bt.World:case Bt.WorldView:case Bt.WorldViewProjection:return;case Bt.View:e.setMatrix(s,t.getViewMatrix());break;case Bt.Projection:e.setMatrix(s,t.getProjectionMatrix());break;case Bt.ProjectionInverse:{t.getProjectionMatrix().invertToRef(te.Matrix[0]),e.setMatrix(s,te.Matrix[0]);break}case Bt.ViewProjection:e.setMatrix(s,t.getTransformMatrix());break;case Bt.CameraPosition:t.bindEyePosition(e,s,!0);break;case Bt.FogColor:e.setColor3(s,t.fogColor);break;case Bt.DeltaTime:e.setFloat(s,t.deltaTime/1e3);break;case Bt.CameraParameters:t.activeCamera&&e.setFloat4(s,t.getEngine().hasOriginBottomLeft?-1:1,t.activeCamera.minZ,t.activeCamera.maxZ,1/t.activeCamera.maxZ);break;case Bt.MaterialAlpha:e.setFloat(s,i.alpha);break}return}const r=this._valueCallback?this._valueCallback():this._storedValue;if(r!==null)switch(this.type){case re.Float:e.setFloat(s,r);break;case re.Int:e.setInt(s,r);break;case re.Color3:Ft.Color3[0].set(this.value.r,this.value.g,this.value.b),this.convertToGammaSpace&&Ft.Color3[0].toGammaSpaceToRef(Ft.Color3[0],t.getEngine().useExactSrgbConversions),this.convertToLinearSpace&&Ft.Color3[0].toLinearSpaceToRef(Ft.Color3[0],t.getEngine().useExactSrgbConversions),e.setColor3(s,Ft.Color3[0]);break;case re.Color4:Ft.Color4[0].set(this.value.r,this.value.g,this.value.b,this.value.a),this.convertToGammaSpace&&Ft.Color4[0].toGammaSpaceToRef(Ft.Color4[0],t.getEngine().useExactSrgbConversions),this.convertToLinearSpace&&Ft.Color4[0].toLinearSpaceToRef(Ft.Color4[0],t.getEngine().useExactSrgbConversions),e.setDirectColor4(s,Ft.Color4[0]);break;case re.Vector2:e.setVector2(s,r);break;case re.Vector3:e.setVector3(s,r);break;case re.Vector4:e.setVector4(s,r);break;case re.Matrix:e.setMatrix(s,r);break}}_buildBlock(e){super._buildBlock(e),(this.isUniform||this.isSystemValue)&&e.sharedData.inputBlocks.push(this),this._emit(e)}_dumpPropertiesCode(){const e=this._codeVariableName;if(this.isAttribute)return super._dumpPropertiesCode()+`${e}.setAsAttribute("${this.name}"); 3257`;if(this.isSystemValue)return super._dumpPropertiesCode()+`${e}.setAsSystemValue(BABYLON.NodeMaterialSystemValues.${Bt[this._systemValue]}); 3258`;if(this.isUniform){const t=[];let i="";switch(this.type){case re.Float:i=`${this.value}`;break;case re.Vector2:i=`new BABYLON.Vector2(${this.value.x}, ${this.value.y})`;break;case re.Vector3:i=`new BABYLON.Vector3(${this.value.x}, ${this.value.y}, ${this.value.z})`;break;case re.Vector4:i=`new BABYLON.Vector4(${this.value.x}, ${this.value.y}, ${this.value.z}, ${this.value.w})`;break;case re.Color3:i=`new BABYLON.Color3(${this.value.r}, ${this.value.g}, ${this.value.b})`,this.convertToGammaSpace&&(i+=".toGammaSpace()"),this.convertToLinearSpace&&(i+=".toLinearSpace()");break;case re.Color4:i=`new BABYLON.Color4(${this.value.r}, ${this.value.g}, ${this.value.b}, ${this.value.a})`,this.convertToGammaSpace&&(i+=".toGammaSpace()"),this.convertToLinearSpace&&(i+=".toLinearSpace()");break;case re.Matrix:i=`BABYLON.Matrix.FromArray([${this.value.m.join(", ")}])`;break}return t.push(`${e}.value = ${i}`),this.type===re.Float&&t.push(`${e}.min = ${this.min}`,`${e}.max = ${this.max}`,`${e}.isBoolean = ${this.isBoolean}`,`${e}.matrixMode = ${this.matrixMode}`,`${e}.animationType = BABYLON.AnimatedInputBlockTypes.${$n[this.animationType]}`),t.push(`${e}.isConstant = ${this.isConstant}`),t.push(""),super._dumpPropertiesCode()+t.join(`; 3259`)}return super._dumpPropertiesCode()}dispose(){this.onValueChangedObservable.clear(),super.dispose()}serialize(){const e=super.serialize();return e.type=this.type,e.mode=this._mode,e.systemValue=this._systemValue,e.animationType=this._animationType,e.min=this.min,e.max=this.max,e.isBoolean=this.isBoolean,e.matrixMode=this.matrixMode,e.isConstant=this.isConstant,e.groupInInspector=this.groupInInspector,e.convertToGammaSpace=this.convertToGammaSpace,e.convertToLinearSpace
3259=this.convertToLinearSpace,this._storedValue!=null&&this._mode===0&&(this._storedValue.asArray?(e.valueType="BABYLON."+this._storedValue.getClassName(),e.value=this._storedValue.asArray()):(e.valueType="number",e.value=this._storedValue)),e}_deserialize(e,t,i){if(this._mode=e.mode,super._deserialize(e,t,i),this._type=e.type,this._systemValue=e.systemValue||e.wellKnownValue,this._animationType=e.animationType,this.min=e.min||0,this.max=e.max||0,this.isBoolean=!!e.isBoolean,this.matrixMode=e.matrixMode||0,this.isConstant=!!e.isConstant,this.groupInInspector=e.groupInInspector||"",this.convertToGammaSpace=!!e.convertToGammaSpace,this.convertToLinearSpace=!!e.convertToLinearSpace,e.name==="tangent"&&e.mode===1&&e.type===re.Vector3&&(this._type=re.Vector4),!!e.valueType)if(e.valueType==="number")this._storedValue=e.value;else{const s=Kr(e.valueType);s&&(this._storedValue=s.FromArray(e.value))}}}Tt("BABYLON.InputBlock",fs);class YI extends Ws{get associatedVariableName(){return this._varName}constructor(e){super(e,De.Fragment),this.registerOutput("xy",re.Vector2,De.Fragment),this.registerOutput("x",re.Float,De.Fragment),this.registerOutput("y",re.Float,De.Fragment)}getClassName(){return"ScreenSizeBlock"}get xy(){return this._outputs[0]}get x(){return this._outputs[1]}get y(){return this._outputs[2]}bind(e){const t=this._scene.getEngine();e.setFloat2(this._varName,t.getRenderWidth(),t.getRenderHeight())}writeOutputs(e,t){let i="";for(const s of this._outputs)s.hasEndpoints&&(i+=`${e._declareOutput(s)} = ${t}.${s.name}; 3260`);return i}_buildBlock(e){if(super._buildBlock(e),this._scene=e.sharedData.scene,e.target===De.Vertex)return e.sharedData.raiseBuildError("ScreenSizeBlock must only be used in a fragment shader"),this;e.sharedData.bindableBlocks.push(this),this._varName=e._getFreeVariableName("screenSize"),e._emitUniformFromString(this._varName,re.Vector2);const t=e.shaderLanguage===1?"uniforms.":"";return e.compilationString+=this.writeOutputs(e,t+this._varName),this}}Tt("BABYLON.ScreenSizeBlock",YI);const Ym="USE_SFE_FRAMEWORK";class E4 extends ja{constructor(e){super(e)}getClassName(){return"SmartFilterFragmentOutputBlock"}initialize(e){super.initialize(e),e.sharedData.nodeMaterial.mode!==$i.SFE&&e.sharedData.raiseBuildError("SmartFilterFragmentOutputBlock should not be used outside of SFE mode."),e.sharedData.nodeMaterial.shaderLanguage!==0&&e.sharedData.raiseBuildError("WebGPU is not supported in SmartFilters mode."),e.sharedData.formatConfig.getUniformAnnotation||(e.sharedData.formatConfig.getUniformAnnotation=t=>{for(const i of e.sharedData.nodeMaterial.attachedBlocks){if(i instanceof fs&&i.isUniform&&i.associatedVariableName===t)return this._generateInputBlockAnnotation(i);if(i instanceof YI&&i.associatedVariableName===t)return this._generateScreenSizeBlockAnnotation()}return""}),e.sharedData.formatConfig.formatVariablename=t=>{let i=t;return i.length>1&&i[1]==="_"&&(i=i.substring(2)),i.replace(/[^a-zA-Z]+/g,"")}}_generateInputBlockAnnotation(e){const t=e.valueCallback?e.valueCallback():e.value;return`// { "default": ${JSON.stringify(t)} } 3261`}_generateScreenSizeBlockAnnotation(){return`// { "autoBind": "outputResolution" } 3262`}_getMainUvName(e){const t=e.sharedData.nodeMaterial.getInputBlockByPredicate(i=>i.isAttribute&&i.name==="postprocess_uv");return!t||!t.isAnAncestorOf(this)?"":t.associatedVariableName}_getOutputString(){return"outColor"}_buildBlock(e){super._buildBlock(e);const t=this._getOutputString();return e._customEntryHeader+=`#ifdef ${Ym} 3263`,e._customEntryHeader+=`vec4 nmeMain(vec2 ${this._getMainUvName(e)}) { // main 3264`,e._customEntryHeader+=`#else 3265`,e._customEntryHeader+=`void main(void) { 3266`,e._customEntryHeader+=`#endif 3267`,e._customEntryHeader+=`vec4 ${t} = vec4(0.0); 3268`,e.compilationString+=` 3269#ifndef ${Ym} 3270`,e.compilationString+=`gl_FragColor = ${t}; 3271`,e.compilationString+=`#else 3272`,e.compilationString+=`return ${t}; 3273`,e.compilationString+=`#endif 3274`,this}}Tt("BABYLON.SmartFilterFragmentOutputBlock",E4);class ff extends Ws{get transformAsDirection(){return this.complementW===0}set transformAsDirection(e){this.complementW=e?0:1}constructor(e){super(e,De.Neutral),this.complementW=1,this.complementZ=0,this.target=De.Vertex,this.registerInput("vector",re.AutoDetect),this.registerInput("transform",re.Matr
3274ix),this.registerOutput("output",re.Vector4),this.registerOutput("xyz",re.Vector3),this._inputs[0].onConnectionObservable.add(t=>{if(t.ownerBlock.isInput){const i=t.ownerBlock;(i.name==="normal"||i.name==="tangent")&&(this.complementW=0)}})}getClassName(){return"TransformBlock"}get vector(){return this._inputs[0]}get output(){return this._outputs[0]}get xyz(){return this._outputs[1]}get transform(){return this._inputs[1]}_buildBlock(e){super._buildBlock(e);const t=this.vector,i=this.transform,s=e._getShaderType(re.Vector4),r=e._getShaderType(re.Vector3);if(t.connectedPoint){if(this.complementW===0||this.transformAsDirection){const a=`//${this.name}`;e._emitFunctionFromInclude("helperFunctions",a),e.sharedData.blocksWithDefines.push(this);const o=e._getFreeVariableName(`${i.associatedVariableName}_NUS`);switch(e.shaderLanguage===1?e.compilationString+=`var ${o}: mat3x3f = mat3x3f(${i.associatedVariableName}[0].xyz, ${i.associatedVariableName}[1].xyz, ${i.associatedVariableName}[2].xyz); 3275`:e.compilationString+=`mat3 ${o} = mat3(${i.associatedVariableName}); 3276`,e.compilationString+=`#ifdef NONUNIFORMSCALING 3277`,e.compilationString+=`${o} = transposeMat3(inverseMat3(${o})); 3278`,e.compilationString+=`#endif 3279`,t.connectedPoint.type){case re.Vector2:e.compilationString+=e._declareOutput(this.output)+` = ${s}(${o} * ${r}(${t.associatedVariableName}, ${this._writeFloat(this.complementZ)}), ${this._writeFloat(this.complementW)}); 3280`;break;case re.Vector3:case re.Color3:e.compilationString+=e._declareOutput(this.output)+` = ${s}(${o} * ${t.associatedVariableName}, ${this._writeFloat(this.complementW)}); 3281`;break;default:e.compilationString+=e._declareOutput(this.output)+` = ${s}(${o} * ${t.associatedVariableName}.xyz, ${this._writeFloat(this.complementW)}); 3282`;break}}else{const a=i.associatedVariableName;switch(t.connectedPoint.type){case re.Vector2:e.compilationString+=e._declareOutput(this.output)+` = ${a} * ${s}(${t.associatedVariableName}, ${this._writeFloat(this.complementZ)}, ${this._writeFloat(this.complementW)}); 3283`;break;case re.Vector3:case re.Color3:e.compilationString+=e._declareOutput(this.output)+` = ${a} * ${s}(${t.associatedVariableName}, ${this._writeFloat(this.complementW)}); 3284`;break;default:e.compilationString+=e._declareOutput(this.output)+` = ${a} * ${t.associatedVariableName}; 3285`;break}}this.xyz.hasEndpoints&&(e.compilationString+=e._declareOutput(this.xyz)+` = ${this.output.associatedVariableName}.xyz; 3286`)}return this}prepareDefines(e,t,i){i&&i.nonUniformScaling&&e.setValue("NONUNIFORMSCALING",!0)}serialize(){const e=super.serialize();return e.complementZ=this.complementZ,e.complementW=this.complementW,e}_deserialize(e,t,i){super._deserialize(e,t,i),this.complementZ=e.complementZ!==void 0?e.complementZ:0,this.complementW=e.complementW!==void 0?e.complementW:1}_dumpPropertiesCode(){let e=super._dumpPropertiesCode()+`${this._codeVariableName}.complementZ = ${this.complementZ}; 3287`;return e+=`${this._codeVariableName}.complementW = ${this.complementW}; 3288`,e}}N([bc("Transform as direction",0,void 0,{embedded:!0})],ff.prototype,"transformAsDirection",null);Tt("BABYLON.TransformBlock",ff);class kd extends Ws{constructor(e){super(e,De.Vertex,!0),this.registerInput("vector",re.Vector4)}getClassName(){return"VertexOutputBlock"}get vector(){return this._inputs[0]}_isLogarithmicDepthEnabled(e,t){if(t)return!0;for(const i of e)if(i.useLogarithmicDepth)return!0;return!1}_buildBlock(e){super._buildBlock(e);const t=this.vector,i=e.shaderLanguage===1;if(e.shaderLanguage===1?e.compilationString+=`vertexOutputs.position = ${t.associatedVariableName}; 3289`:e.compilationString+=`gl_Position = ${t.associatedVariableName}; 3290`,this._isLogarithmicDepthEnabled(e.sharedData.fragmentOutputNodes,e.sharedData.nodeMaterial.useLogarithmicDepth)){e._emitUniformFromString("logarithmicDepthConstant",re.Float),e._emitVaryingFromString("vFragmentDepth",re.Float);const s=i?"vertexOutputs.vFragmentDepth":"vFragmentDepth",r=i?"uniforms.":"",a=i?"vertexOutputs.position":"gl_Position";e.compilationString+=`${s} = 1.0 + ${a}.w; 3291`,e.compilationString+=`${a}.z = log2(max(0.000001, ${s})) * ${r}logarithmicDepthConstant; 3292`}return this}}Tt("BABYLON.VertexOutputBlock",kd);class KI extends Ws{get samplerName(){return this._samplerName}get texture(){return this._texture}set texture(e){this._texture=e}constructor(e){super(e,De.VertexAndFragment),this._samplerName="textureSampler",this.convertToGammaSpace=!1,this.convertToLinearSpace
3292=!1,this._isUnique=!1,this.registerInput("uv",re.AutoDetect,!1,De.VertexAndFragment),this.registerOutput("rgba",re.Color4,De.Neutral),this.registerOutput("rgb",re.Color3,De.Neutral),this.registerOutput("r",re.Float,De.Neutral),this.registerOutput("g",re.Float,De.Neutral),this.registerOutput("b",re.Float,De.Neutral),this.registerOutput("a",re.Float,De.Neutral),this._inputs[0].addExcludedConnectionPointFromAllowedTypes(re.Vector2|re.Vector3|re.Vector4),this._inputs[0]._prioritizeVertex=!1}getClassName(){return"CurrentScreenBlock"}get uv(){return this._inputs[0]}get rgba(){return this._outputs[0]}get rgb(){return this._outputs[1]}get r(){return this._outputs[2]}get g(){return this._outputs[3]}get b(){return this._outputs[4]}get a(){return this._outputs[5]}initialize(e){e._excludeVariableName(this.samplerName)}get target(){return!this.uv.isConnected||this.uv.sourceBlock.isInput?De.VertexAndFragment:De.Fragment}prepareDefines(e){e.setValue(this._linearDefineName,this.convertToGammaSpace,!0),e.setValue(this._gammaDefineName,this.convertToLinearSpace,!0)}isReady(){return!(this.texture&&!this.texture.isReadyOrNotBlocking())}_getMainUvName(e){return"vMain"+this.uv.associatedVariableName}_injectVertexCode(e){const t=this.uv;if(t.connectedPoint.ownerBlock.isInput&&(t.connectedPoint.ownerBlock.isAttribute||e._emitUniformFromString(t.associatedVariableName,re.Vector2)),e.compilationString+=`${this._mainUVName} = ${t.associatedVariableName}.xy; 3293`,!!this._outputs.some(i=>i.isConnectedInVertexShader)){this._writeTextureRead(e,!0);for(const i of this._outputs)i.hasEndpoints&&this._writeOutput(e,i,i.name,!0)}}_writeTextureRead(e,t=!1){const i=this.uv;if(t){if(e.target===De.Fragment)return;const r=e.shaderLanguage===0?`texture2D(${this.samplerName},`:`textureSampleLevel(${this.samplerName}, ${this.samplerName+"Sampler"},`,a=e.shaderLanguage===0?"":", 0";e.compilationString+=`${e._declareLocalVar(this._tempTextureRead,re.Vector4)} = ${r} ${i.associatedVariableName}${a}); 3294`;return}const s=e.shaderLanguage===0?`texture2D(${this.samplerName},`:`textureSample(${this.samplerName}, ${this.samplerName+"Sampler"},`;if(this.uv.ownerBlock.target===De.Fragment){e.compilationString+=`${e._declareLocalVar(this._tempTextureRead,re.Vector4)} = ${s} ${i.associatedVariableName}); 3295`;return}e.compilationString+=`${e._declareLocalVar(this._tempTextureRead,re.Vector4)} = ${s} ${this._mainUVName}); 3296`}_writeOutput(e,t,i,s=!1){if(s){if(e.target===De.Fragment)return;e.compilationString+=`${e._declareOutput(t)} = ${this._tempTextureRead}.${i}; 3297`;return}if(this.uv.ownerBlock.target===De.Fragment){e.compilationString+=`${e._declareOutput(t)} = ${this._tempTextureRead}.${i}; 3298`;return}e.compilationString+=`${e._declareOutput(t)} = ${this._tempTextureRead}.${i}; 3299`,e.compilationString+=`#ifdef ${this._linearDefineName} 3300`,e.compilationString+=`${t.associatedVariableName} = toGammaSpace(${t.associatedVariableName}); 3301`,e.compilationString+=`#endif 3302`,e.compilationString+=`#ifdef ${this._gammaDefineName} 3303`,e.compilationString+=`${t.associatedVariableName} = toLinearSpace(${t.associatedVariableName}); 3304`,e.compilationString+=`#endif 3305`}_emitUvAndSampler(e){e._emitVaryingFromString(this._mainUVName,re.Vector2),e._emit2DSampler(this.samplerName)}_buildBlock(e){if(super._buildBlock(e),this._tempTextureRead=e._getFreeVariableName("tempTextureRead"),e.sharedData.blockingBlocks.indexOf(this)<0&&e.sharedData.blockingBlocks.push(this),e.sharedData.textureBlocks.indexOf(this)<0&&e.sharedData.textureBlocks.push(this),e.sharedData.blocksWithDefines.indexOf(this)<0&&e.sharedData.blocksWithDefines.push(this),this._mainUVName=this._getMainUvName(e),this._emitUvAndSampler(e),e.target!==De.Fragment){this._injectVertexCode(e);return}if(!this._outputs.some(i=>i.isConnectedInFragmentShader))return;this._linearDefineName=e._getFreeDefineName("ISLINEAR"),this._gammaDefineName=e._getFreeDefineName("ISGAMMA");const t=`//${this.name}`;e._emitFunctionFromInclude("helperFunctions",t),this._writeTextureRead(e);for(const i of this._outputs)i.hasEndpoints&&this._writeOutput(e,i,i.name);return this}serialize(){const e=super.serialize();return e.convertToGammaSpace=this.convertToGammaSpace,e.convertToLinearSpace
3305=this.convertToLinearSpace,this.texture&&!this.texture.isRenderTarget&&(e.texture=this.texture.serialize()),e}_deserialize(e,t,i){super._deserialize(e,t,i),this.convertToGammaSpace=e.convertToGammaSpace,this.convertToLinearSpace=!!e.convertToLinearSpace,e.texture&&(i=e.texture.url.indexOf("data:")===0?"":i,this.texture=Te.Parse(e.texture,t,i))}}Tt("BABYLON.CurrentScreenBlock",KI);class qI extends Ws{constructor(e){super(e,De.Fragment),this._samplerName="diffuseSampler",this.convertToGammaSpace=!1,this.convertToLinearSpace=!1,this._isUnique=!1,this.registerInput("uv",re.AutoDetect,!1,De.VertexAndFragment),this.registerOutput("rgba",re.Color4,De.Neutral),this.registerOutput("rgb",re.Color3,De.Neutral),this.registerOutput("r",re.Float,De.Neutral),this.registerOutput("g",re.Float,De.Neutral),this.registerOutput("b",re.Float,De.Neutral),this.registerOutput("a",re.Float,De.Neutral),this._inputs[0].addExcludedConnectionPointFromAllowedTypes(re.Vector2|re.Vector3|re.Vector4)}getClassName(){return"ParticleTextureBlock"}get uv(){return this._inputs[0]}get rgba(){return this._outputs[0]}get rgb(){return this._outputs[1]}get r(){return this._outputs[2]}get g(){return this._outputs[3]}get b(){return this._outputs[4]}get a(){return this._outputs[5]}initialize(e){e._excludeVariableName("diffuseSampler")}autoConfigure(e,t=()=>!0){if(!this.uv.isConnected){let i=e.getInputBlockByPredicate(s=>s.isAttribute&&s.name==="particle_uv"&&t(s));i||(i=new fs("uv"),i.setAsAttribute("particle_uv")),i.output.connectTo(this.uv)}}prepareDefines(e){e.setValue(this._linearDefineName,this.convertToGammaSpace,!0),e.setValue(this._gammaDefineName,this.convertToLinearSpace,!0)}isReady(){return!(this.texture&&!this.texture.isReadyOrNotBlocking())}_writeOutput(e,t,i){e.compilationString+=`${e._declareOutput(t)} = ${this._tempTextureRead}.${i}; 3306`,e.compilationString+=`#ifdef ${this._linearDefineName} 3307`,e.compilationString+=`${t.associatedVariableName} = toGammaSpace(${t.associatedVariableName}); 3308`,e.compilationString+=`#endif 3309`,e.compilationString+=`#ifdef ${this._gammaDefineName} 3310`,e.compilationString+=`${t.associatedVariableName} = toLinearSpace(${t.associatedVariableName}); 3311`,e.compilationString+=`#endif 3312`}_buildBlock(e){if(super._buildBlock(e),e.target===De.Vertex)return;this._tempTextureRead=e._getFreeVariableName("tempTextureRead"),e._emit2DSampler(this._samplerName),e.sharedData.blockingBlocks.push(this),e.sharedData.textureBlocks.push(this),e.sharedData.blocksWithDefines.push(this),this._linearDefineName=e._getFreeDefineName("ISLINEAR"),this._gammaDefineName=e._getFreeDefineName("ISGAMMA");const t=`//${this.name}`;e._emitFunctionFromInclude("helperFunctions",t),e.compilationString+=`${e._declareLocalVar(this._tempTextureRead,re.Vector4)} = ${e._generateTextureSample(this.uv.associatedVariableName,this._samplerName)}; 3313`;for(const i of this._outputs)i.hasEndpoints&&this._writeOutput(e,i,i.name);return this}serialize(){const e=super.serialize();return e.convertToGammaSpace=this.convertToGammaSpace,e.convertToLinearSpace=this.convertToLinearSpace,this.texture&&!this.texture.isRenderTarget&&(e.texture=this.texture.serialize()),e}_deserialize(e,t,i){super._deserialize(e,t,i),this.convertToGammaSpace=e.convertToGammaSpace,this.convertToLinearSpace=!!e.convertToLinearSpace,e.texture&&(i=e.texture.url.indexOf("data:")===0?"":i,this.texture=Te.Parse(e.texture,t,i))}}Tt("BABYLON.ParticleTextureBlock",qI);class ZI extends Ws{constructor(e){super(e,De.Fragment),this._isUnique=!0,this.registerInput("color",re.Color4,!1,De.Fragment),this.registerOutput("rampColor",re.Color4,De.Fragment)}getClassName(){return"ParticleRampGradientBlock"}get color(){return this._inputs[0]}get rampColor(){return this._outputs[0]}initialize(e){e._excludeVariableName("remapRanges"),e._excludeVariableName("rampSampler"),e._excludeVariableName("baseColor"),e._excludeVariableName("alpha"),e._excludeVariableName("remappedColorIndex"),e._excludeVariableName("rampColor")}_buildBlock(e){if(super._buildBlock(e),e.target===De.Vertex)return;e._emit2DSampler("rampSampler","RAMPGRADIENT"),e._emitVaryingFromString("remapRanges",re.Vector4,"RAMPGRADIENT");const t=e.shaderLanguage===0?"":"fragmentInputs.";return e.compilationString+=` 3314 #ifdef RAMPGRADIENT 3315 ${e._declareLocalVar("baseColor",re.Vector4)} = ${this.color.associatedVariableName}; 3316 ${e._declareLocalVar("alpha",re.Float)} = ${this.color.associatedVariableName}.a; 3317 3318 ${e._declareLocalVar("remappedColorIndex",re.Float)} = clamp((alpha - ${t}remapRanges.x) / ${t}remapRanges.y, 0.0, 1.0); 3319 3320 ${e._declareLocalVar("rampColor",re.Vector4)} = ${e._generateTextureSample("vec2(1.0 - remappedColorIndex, 0.)","rampSampler")}; 3321 3322 // Remapped alpha 3323 ${e._declareOutput(this.rampColor)} = vec4${e.fSuffix}(baseColor.rgb * rampColor.rgb, clamp((alpha * rampColor.a - ${t}remapRanges.z) / ${t}remapRanges.w, 0.0, 1.0)); 3324 #else 3325 ${e._declareOutput(this.rampColor)} = ${this.color.associatedVariableName}; 3326 #endif 3327 `,this}}Tt("BABYLON.ParticleRampGradientBlock",ZI);class $I extends Ws{constructor(e){super(e,De.Fragment),this._isUnique=!0,this.registerInput("color",re.Color4,!1,De.Fragment),this.registerInput("alphaTexture",re.Float,!1,De.Fragment),this.registerInput("alphaColor",re.Float,!1,De.Fragment),this.registerOutput("blendColor",re.Color4,De.Fragment)}getClassName(){return"ParticleBlendMultiplyBlock"}get color(){return this._inputs[0]}get alphaTexture(){return this._inputs[1]}get alphaColor(){return this._inputs[2]}
3327get blendColor(){return this._outputs[0]}initialize(e){e._excludeVariableName("sourceAlpha")}_buildBlock(e){if(super._buildBlock(e),e.target!==De.Vertex)return e.compilationString+=` 3328 #ifdef BLENDMULTIPLYMODE 3329 ${e._declareOutput(this.blendColor)}; 3330 ${e._declareLocalVar("sourceAlpha",re.Float)} = ${this.alphaColor.associatedVariableName} * ${this.alphaTexture.associatedVariableName}; 3331 ${this.blendColor.associatedVariableName} = vec4${e.fSuffix}(${this.color.associatedVariableName}.rgb * sourceAlpha + vec3(1.0) * (1.0 - sourceAlpha), ${this.color.associatedVariableName}.a); 3332 #else 3333 ${e._declareOutput(this.blendColor)} = ${this.color.associatedVariableName}; 3334 #endif 3335 `,this}}Tt("BABYLON.ParticleBlendMultiplyBlock",$I);class Vd extends Ws{constructor(e){super(e,De.Neutral),this.xSwizzle="x",this.ySwizzle="y",this.zSwizzle="z",this.wSwizzle="w",this.registerInput("xyzw ",re.Vector4,!0),this.registerInput("xyz ",re.Vector3,!0),this.registerInput("xy ",re.Vector2,!0),this.registerInput("zw ",re.Vector2,!0),this.registerInput("x",re.Float,!0),this.registerInput("y",re.Float,!0),this.registerInput("z",re.Float,!0),this.registerInput("w",re.Float,!0),this.registerOutput("xyzw",re.Vector4),this.registerOutput("xyz",re.Vector3),this.registerOutput("xy",re.Vector2),this.registerOutput("zw",re.Vector2)}getClassName(){return"VectorMergerBlock"}get xyzwIn(){return this._inputs[0]}get xyzIn(){return this._inputs[1]}get xyIn(){return this._inputs[2]}get zwIn(){return this._inputs[3]}get x(){return this._inputs[4]}get y(){return this._inputs[5]}get z(){return this._inputs[6]}get w(){return this._inputs[7]}get xyzw(){return this._outputs[0]}get xyzOut(){return this._outputs[1]}get xyOut(){return this._outputs[2]}get zwOut(){return this._outputs[3]}get xy(){return this.xyOut}get xyz(){return this.xyzOut}_inputRename(e){return e==="xyzw "?"xyzwIn":e==="xyz "?"xyzIn":e==="xy "?"xyIn":e==="zw "?"zwIn":e}_buildSwizzle(e){return"."+(this.xSwizzle+this.ySwizzle+this.zSwizzle+this.wSwizzle).substring(0,e)}_buildBlock(e){super._buildBlock(e);const t=this.x,i=this.y,s=this.z,r=this.w,a=this.xyIn,o=this.zwIn,c=this.xyzIn,u=this.xyzwIn,d=this._outputs[0],f=this._outputs[1],g=this._outputs[2],m=this._outputs[3],b=e._getShaderType(re.Vector4),x=e._getShaderType(re.Vector3),v=e._getShaderType(re.Vector2);return u.isConnected?(d.hasEndpoints&&(e.compilationString+=e._declareOutput(d)+` = ${u.associatedVariableName}${this._buildSwizzle(4)}; 3336`),f.hasEndpoints&&(e.compilationString+=e._declareOutput(f)+` = ${u.associatedVariableName}${this._buildSwizzle(3)}; 3337`),g.hasEndpoints&&(e.compilationString+=e._declareOutput(g)+` = ${u.associatedVariableName}${this._buildSwizzle(2)}; 3338`)):c.isConnected?(d.hasEndpoints&&(e.compilationString+=e._declareOutput(d)+` = ${b}(${c.associatedVariableName}, ${r.isConnected?this._writeVariable(r):"0.0"})${this._buildSwizzle(4)}; 3339`),f.hasEndpoints&&(e.compilationString+=e._declareOutput(f)+` = ${c.associatedVariableName}${this._buildSwizzle(3)}; 3340`),g.hasEndpoints&&(e.compilationString+=e._declareOutput(g)+` = ${c.associatedVariableName}${this._buildSwizzle(2)}; 3341`)):a.isConnected?(d.hasEndpoints&&(o.isConnected?e.compilationString+=e._declareOutput(d)+` = ${b}(${a.associatedVariableName}, ${o.associatedVariableName})${this._buildSwizzle(4)}; 3342`:e.compilationString+=e._declareOutput(d)+` = ${b}(${a.associatedVariableName}, ${s.isConnected?this._writeVariable(s):"0.0"}, ${r.isConnected?this._writeVariable(r):"0.0"})${this._buildSwizzle(4)}; 3343`),f.hasEndpoints&&(e.compilationString+=e._declareOutput(f)+` = ${x}(${a.associatedVariableName}, ${s.isConnected?this._writeVariable(s):"0.0"})${this._buildSwizzle(3)}; 3344`),g.hasEndpoints&&(e.compilationString+=e._declareOutput(g)+` = ${a.associatedVariableName}${this._buildSwizzle(2)}; 3345`),m.hasEndpoints&&(o.isConnected?e.compilationString+=e._declareOutput(m)+` = ${o.associatedVariableName}${this._buildSwizzle(2)}; 3346`:e.compilationString+=e._declareOutput(m)+` = ${v}(${s.isConnected?this._writeVariable(s):"0.0"}, ${r.isConnected?this._writeVariable(r):"0.0"})${this._buildSwizzle(2)}; 3347`)):(d.hasEndpoints&&(o.isConnected?e.compilationString+=e._declareOutput(d)+` = ${b}(${t.isConnected?this._writeVariable(t):"0.0"}, ${i.isConnected?this._writeVariable(i):"0.0"}, ${o.associatedVariableName})${this._buildSwizzle(4)}; 3348`:e.compilationString+=e._declareOutput(d)+` = ${b}(${t.isConnected?this._writeVariable(t):"0.0"}, ${i.isConnected?this._writeVariable(i):"0.0"}, ${s.isConnected?this._writeVariable(s):"0.0"}, ${r.isConnected?this._writeVariable(r):"0.0"})${this._buildSwizzle(4)}; 3349`),f.hasEndpoints&&(e.compilationString+=e._declareOutput(f)+` = ${x}(${t.isConnected?this._writeVariable(t):"0.0"}, ${i.isConnected?this._writeVariable(i):"0.0"}, ${s.isConnected?this._writeVariable(s):"0.0"})${this._buildSwizzle(3)}; 3350`),g.hasEndpoints&&(e.compilationString+=e._declareOutput(g)+` = ${v}(${t.isConnected?this._writeVariable(t):"0.0"}, ${i.isConnected?this._writeVariable(i):"0.0"})${this._buildSwizzle(2)}; 3351`),m.hasEndpoints&&(o.isConnected?e.compilationString+=e._declareOutput(m)+` = ${o.associatedVariableName}${this._buildSwizzle(2)}; 3352`:e.compilationString+=e._declareOutput(m)+` = ${v}(${s.isConnected?this._writeVariable(s):"0.0"}, ${r.isConnected?this._writeVariable(r):"0.0"})${this._buildSwizzle(2)}; 3353`)),this}serialize(){const e=super.serialize();return e.xSwizzle=this.xSwizzle,e.ySwizzle=this.ySwizzle,e.zSwizzle=this.zSwizzle,e.wSwizzle=this.wSwizzle,e}_deserialize(e,t,i){super._deserialize(e,t,i),this.xSwizzle=e.xSwizzle??"x",this.ySwizzle=e.ySwizzle??"
3353y",this.zSwizzle=e.zSwizzle??"z",this.wSwizzle=e.wSwizzle??"w"}_dumpPropertiesCode(){let e=super._dumpPropertiesCode();return e+=`${this._codeVariableName}.xSwizzle = "${this.xSwizzle}"; 3354`,e+=`${this._codeVariableName}.ySwizzle = "${this.ySwizzle}"; 3355`,e+=`${this._codeVariableName}.zSwizzle = "${this.zSwizzle}"; 3356`,e+=`${this._codeVariableName}.wSwizzle = "${this.wSwizzle}"; 3357`,e}}Tt("BABYLON.VectorMergerBlock",Vd);class ep extends Ws{constructor(e){super(e,De.Neutral),this.sourceRange=new Ie(-1,1),this.targetRange=new Ie(0,1),this.registerInput("input",re.AutoDetect),this.registerInput("sourceMin",re.Float,!0),this.registerInput("sourceMax",re.Float,!0),this.registerInput("targetMin",re.Float,!0),this.registerInput("targetMax",re.Float,!0),this.registerOutput("output",re.BasedOnInput),this._outputs[0]._typeConnectionSource=this._inputs[0]}getClassName(){return"RemapBlock"}get input(){return this._inputs[0]}get sourceMin(){return this._inputs[1]}get sourceMax(){return this._inputs[2]}get targetMin(){return this._inputs[3]}get targetMax(){return this._inputs[4]}get output(){return this._outputs[0]}_buildBlock(e){super._buildBlock(e);const t=this._outputs[0],i=this.sourceMin.isConnected?this.sourceMin.associatedVariableName:this._writeFloat(this.sourceRange.x),s=this.sourceMax.isConnected?this.sourceMax.associatedVariableName:this._writeFloat(this.sourceRange.y),r=this.targetMin.isConnected?this.targetMin.associatedVariableName:this._writeFloat(this.targetRange.x),a=this.targetMax.isConnected?this.targetMax.associatedVariableName:this._writeFloat(this.targetRange.y);return e.compilationString+=e._declareOutput(t)+` = ${r} + (${this._inputs[0].associatedVariableName} - ${i}) * (${a} - ${r}) / (${s} - ${i}); 3358`,this}_dumpPropertiesCode(){let e=super._dumpPropertiesCode()+`${this._codeVariableName}.sourceRange = new BABYLON.Vector2(${this.sourceRange.x}, ${this.sourceRange.y}); 3359`;return e+=`${this._codeVariableName}.targetRange = new BABYLON.Vector2(${this.targetRange.x}, ${this.targetRange.y}); 3360`,e}serialize(){const e=super.serialize();return e.sourceRange=this.sourceRange.asArray(),e.targetRange=this.targetRange.asArray(),e}_deserialize(e,t,i){super._deserialize(e,t,i),this.sourceRange=Ie.FromArray(e.sourceRange),this.targetRange=Ie.FromArray(e.targetRange)}}N([bc("From",3)],ep.prototype,"sourceRange",void 0);N([bc("To",3)],ep.prototype,"targetRange",void 0);Tt("BABYLON.RemapBlock",ep);class A4 extends Ws{constructor(e){super(e,De.Neutral),this.registerInput("left",re.AutoDetect),this.registerInput("right",re.AutoDetect),this.registerOutput("output",re.BasedOnInput),this.output._t
3360ypeConnectionSource=this.left,this._linkConnectionTypes(0,1,!0),this.left.acceptedConnectionPointTypes.push(re.Float),this.right.acceptedConnectionPointTypes.push(re.Float),this._connectionObservers=[this.left.onTypeChangedObservable.add(()=>this._updateInputOutputTypes()),this.right.onTypeChangedObservable.add(()=>this._updateInputOutputTypes())]}get left(){return this._inputs[0]}get right(){return this._inputs[1]}get output(){return this._outputs[0]}_updateInputOutputTypes(){if(this.output._typeConnectionSource=this.left,this.left.isConnected&&this.right.isConnected?(this.left.type===re.Int||this.left.type===re.Float&&this.right.type!==re.Int)&&(this.output._typeConnectionSource=this.right):this.left.isConnected!==this.right.isConnected&&(this.output._typeConnectionSource=this.left.isConnected?this.left:this.right),this.left.isConnected||this.right.isConnected)for(const[e,t]of[[this.left,this.right],[this.right,this.left]])e.acceptedConnectionPointTypes=[re.Int,re.Float],t.isConnected&&(e.acceptedConnectionPointTypes.push(t.type),(t.type===re.Int||t.type===re.Float)&&e.acceptedConnectionPointTypes.push(re.Vector2,re.Vector3,re.Vector4,re.Color3,re.Color4,re.Matrix))}dispose(){super.dispose();for(const e of this._connectionObservers)e.remove();this._connectionObservers.length=0}}class Km extends A4{constructor(e){super(e)}getClassName(){return"MultiplyBlock"}_buildBlock(e){super._buildBlock(e);const t=this._outputs[0];return e.compilationString+=e._declareOutput(t)+` = ${this.left.associatedVariableName} * ${this.right.associatedVariableName}; 3361`,this}}Tt("BABYLON.MultiplyBlock",Km);class rs{get targetStopDuration(){return this._targetStopDuration}set targetStopDuration(e){this._targetStopDuration!==e&&(this._targetStopDuration=e)}get isNodeGenerated(){return!1}get noiseTexture(){return this._noiseTexture}set noiseTexture(e){this._noiseTexture!==e&&(this._noiseTexture=e,this._reset())}get _isAnimationSheetEnabled(){return this._animationSheetEnabled}set _isAnimationSheetEnabled(e){this._animationSheetEnabled!==e&&(this._animationSheetEnabled=e)}get isAnimationSheetEnabled(){return this._isAnimationSheetEnabled}set isAnimationSheetEnabled(e){this._isAnimationSheetEnabled!=e&&(this._isAnimationSheetEnabled=e,this._reset())}get useLogarithmicDepth(){return this._useLogarithmicDepth}set useLogarithmicDepth(e){this._useLogarithmicDepth=e&&this.get
3361Scene().getEngine().getCaps().fragmentDepthSupported}getScene(){return this._scene}_hasTargetStopDurationDependantGradient(){return this._startSizeGradients&&this._startSizeGradients.length>0||this._emitRateGradients&&this._emitRateGradients.length>0||this._lifeTimeGradients&&this._lifeTimeGradients.length>0}_setEngineBasedOnBlendMode(e){switch(e){case rs.BLENDMODE_MULTIPLYADD:return;case rs.BLENDMODE_ADD:e=1;break;case rs.BLENDMODE_ONEONE:e=6;break;case rs.BLENDMODE_STANDARD:e=2;break;case rs.BLENDMODE_MULTIPLY:e=4;break;case rs.BLENDMODE_SUBTRACT:e=3;break}this._engine.setAlphaMode(e)}getDragGradients(){return this._dragGradients}getLimitVelocityGradients(){return this._limitVelocityGradients}getColorGradients(){return this._colorGradients}getSizeGradients(){return this._sizeGradients}getColorRemapGradients(){return this._colorRemapGradients}getAlphaRemapGradients(){return this._alphaRemapGradients}getLifeTimeGradients(){return this._lifeTimeGradients}getAngularSpeedGradients(){return this._angularSpeedGradients}getVelocityGradients(){return this._velocityGradients}getStartSizeGradients(){return this._startSizeGradients}getEmitRateGradients(){return this._emitRateGradients}get direction1(){return this.particleEmitterType.direction1?this.particleEmitterType.direction1:T.Zero()}set direction1(e){this.particleEmitterType.direction1&&(this.particleEmitterType.direction1=e)}get direction2(){return this.particleEmitterType.direction2?this.particleEmitterType.direction2:T.Zero()}set direction2(e){this.particleEmitterType.direction2&&(this.particleEmitterType.direction2=e)}get minEmitBox(){return this.particleEmitterType.minEmitBox?this.particleEmitterType.minEmitBox:T.Zero()}set minEmitBox(e){this.particleEmitterType.minEmitBox&&(this.particleEmitterType.minEmitBox=e)}get maxEmitBox(){return this.particleEmitterType.maxEmitBox?this.particleEmitterType.maxEmitBox:T.Zero()}set maxEmitBox(e){this.particleEmitterType.maxEmitBox&&(this.particleEmitterType.maxEmitBox=e)}get billboardMode(){return this._billboardMode}set billboardMode(e){this._billboardMode!==e&&(this._billboardMode=e,this._reset())}get isBillboardBased(){return this._isBillboardBased}set isBillboardBased(e){this._isBillboardBased!==e&&(this._isBillboardBased=e,this._reset())}get imageProcessingConfiguration(){return this._imageProcessingConfiguration}set imageProcessingConfiguration(e){this._attachImageProcessingConfiguration(e)}_attachImageProcessingConfiguration(e){e!==this._imageProcessingConfiguration&&(!e&&this._scene?this._imageProcessingConfiguration=this._scene.imageProcessingConfiguration:this._imageProcessingConfiguration=e)}_reset(){}_removeGradientAndTexture(e,t,i){if(!t)return this;let s=0;for(const r of t){if(r.gradient===e){t.splice(s,1);break}s++}return i&&i.dispose(),this}constructor(e){this.animations=[],this.renderingGroupId=0,this.emitter=T.Zero(),this.emitRate=10,this.manualEmitCount=-1,this.updateSpeed=.01,this._targetStopDuration=0,this.disposeOnStop=!1,this.minEmitPower=1,this.maxEmitPower=1,this.minLifeTime=1,this.maxLifeTime=1,this.minSize=1,this.maxSize=1,this.minScaleX=1,this.maxScaleX=1,this.minScaleY=1,this.maxScaleY=1,this.minInitialRotation=0,this.maxInitialRotation=0,this.minAngularSpeed=0,this.maxAngularSpeed=0,this.layerMask=268435455,this.customShader=null,this.preventAutoStart=!1,this.applyFog=!1,this._wasDispatched=!1,this._rootUrl="",this.noiseStrength=new T(10,10,10),this.onAnimationEnd=null,this.blendMode=rs.BLENDMODE_ONEONE,this.forceDepthWrite=!1,this.preWarmCycles=0,this.preWarmStepOffset=1,this.spriteCellChangeSpeed=1,this.startSpriteCellID=0,this.endSpriteCellID=0,this.spriteCellWidth=0,this.spriteCellHeight=0,this.spriteCellLoop=!0,this.spriteRandomStartCell=!1,this.translationPivot=new Ie(0,0),this._animationSheetEnabled=!1,this.beginAnimationOnStart=!1,this.beginAnimationFrom=0,this.beginAnimationTo=60,this.beginAnimationLoop=!1,this.worldOffset=new T(0,0,0),this._useLogarithmicDepth=!1,this.gravity=T.Zero(),this._colorGradients=null,this._sizeGradients=null,this._lifeTimeGradients=null,this._angularSpeedGradients=null,this._velocityGradients=null,this._limitVelocityGradients=null,this._dragGradients=null,this._emitRateGradients=null,this._startSizeGradients=null,this._rampGradients=null,this._colorRemapGradients=null,this._alphaRemapGradients=null,this.startDelay=0,this.limitVelocityDamping=.4,this.color1=new Ze(1,1,1,1),this.color2=new Ze(1,1,1,1),this.colorDead=new Ze(0,0,0,1),this.textureMask=new Ze(1,1,1,1),this._isSubEmitter=!1,this._billboardMode=7,this._isBillboardBased=!0,this._imageProcessingConfigurationDefines=new CV,this.id=e,this.name=e}createPointEmitter(e,t){throw new Error("Method not implemented.")}createHemisphericEmitter(e=1,t=1){throw new Error("Method not implemented.")}createSphereEmitter(e=1,t=1){throw new Error("Method not implemented.")}createDirectedSphereEmitter(e=1,t=new T(0,1,0),i=new T(0,1,0)){throw new Error("Method not implemented.")}createCylinderEmitter(e=1,t=1,i=1,s=0){throw new Error("Method not implemented.")}createDirectedCylinderEmitter(e=1,t=1,i=1,s=new T(0,1,0),r=new T(0,1,0)){throw new Error("Method not implemented.")}createConeEmitter(e=1,t=Math.PI/4){throw new Error("Method not implemented.")}createDirectedConeEmitter(e=1,t=Math.PI/4,i=new T(0,1,0),s=new T(0,1,0)){throw new Error("Method not implemented.")}createBoxEmitter(e,t,i,s){throw new Error("Method not implemented.")}}rs.BLENDMODE_ONEONE=0;rs.BLENDMODE_STANDARD=1;rs.BLENDMODE_ADD=2;rs.BLENDMODE_MULTIPLY=3;rs.BLENDMODE_MULTIPLYADD=4;rs.BLENDMODE_SUBTRACT=-1;Tt("BABYLON.BaseParticleSystem",rs);class QI extends Ws{constructor(e){super(e,De.Neutral),this.registerInput("rgba",re.Color4,!0),this.registerInput("rgb ",re.Color3,!0),this.registerOutput("rgb",re.Color3),this.registerOutput("r",re.Float),this.registerOutput("g",re.Float),this.registerOutput("b",re.Float),this.registerOutput("a",re.Float),this.inputsAreExclusive=!0}getClassName(){return"ColorSplitterBlock"}get rgba(){return this._inputs[0]}get rgbIn(){return this._inputs[1]}get rgbOut(){return this._outputs[0]}get r(){return this._outputs[1]}get g(){return this._outputs[2]}get b(){return this._outputs[3]}get a(){return this._outputs[4]}_inputRename(e){return e==="rgb "?"rgbIn":e}_outputRename(e){return e==="rgb"?"rgbOut":e}_buildBlock(e){super._buildBlock(e);const t=this.rgba.isConnected?this.rgba:this.rgbIn;if(!t.isConnected)return;const i=this._outputs[0],s=this._outputs[1],r=this._outputs[2],a=this._outputs[3],o=this._outputs[4];return i.hasEndpoints&&(e.compilationString+=e._declareOutput(i)+` = ${t.associatedVariableName}.rgb; 3362`),s.hasEndpoints&&(e.compilationString+=e._declareOutput(s)+` = ${t.associatedVariableName}.r; 3363`),r.hasEndpoints&&(e.compilationString+=e._declareOutput(r)+` = ${t.associatedVariableName}.g; 3364`),a.hasEndpoints&&(e.compilationString+=e._declareOutput(a)+` = ${t.associatedVariableName}.b; 3365`),o.hasEndpoints&&(e.compilationString+=e._declareOutput(o)+` = ${t.associatedVariableName}.a; 3366`),this}}Tt("BABYLON.ColorSplitterBlock",QI);class R4{constructor(e){this.name=Ye.NAME_PROCEDURALTEXTURE,this.scene=e}register(){this.scene._beforeClearStage.registerStep(Ye.STEP_BEFORECLEAR_PROCEDURALTEXTURE,this,this._beforeClear)}
vendor: 8,813 bytes, line 3366
3366rebuild(){}dispose(){}_beforeClear(){if(this.scene.proceduralTexturesEnabled){pe.StartPerformanceCounter("Procedural textures",this.scene.proceduralTextures.length>0);for(let e=0;e<this.scene.proceduralTextures.length;e++){const t=this.scene.proceduralTextures[e];t._shouldRender()&&t.render()}pe.EndPerformanceCounter("Procedural textures",this.scene.proceduralTextures.length>0)}}}class fa extends Te{get shaderLanguage(){return this._shaderLanguage}constructor(e,t,i,s,r=null,a=!0,o=!1,c=0){super(null,s,!a),this.isEnabled=!0,this.autoClear=!0,this.onGeneratedObservable=new le,this.onBeforeGenerationObservable=new le,this.nodeMaterialSource=null,this.defines="",this._textures={},this._currentRefreshId=-1,this._frameId=-1,this._refreshRate=1,this._vertexBuffers={},this._uniforms=new Array,this._samplers=new Array,this._floats={},this._ints={},this._floatsArrays={},this._colors3={},this._colors4={},this._vectors2={},this._vectors3={},this._vectors4={},this._matrices={},this._fallbackTextureUsed=!1,this._cachedDefines=null,this._contentUpdateId=-1,this._rtWrapper=null,r!==null&&!(r instanceof Te)?(this._options=r,this._fallbackTexture=r.fallbackTexture??null):(this._options={},this._fallbackTexture=r),this._shaderLanguage=this._options.shaderLanguage??0,s=this.getScene()||Ke.LastCreatedScene;let u=s._getComponent(Ye.NAME_PROCEDURALTEXTURE);u||(u=new R4(s),s._addComponent(u)),s.proceduralTextures.push(this),this._fullEngine=s.getEngine(),this.name=e,this.isRenderTarget=!0,this._size=t,this._textureType=c,this._generateMipMaps=a,this._drawWrapper=new Qh(this._fullEngine),this.setFragment(i);const d=this._createRtWrapper(o,t,a,c);this._texture=d.texture;const f=[];f.push(1,1),f.push(-1,1),f.push(-1,-1),f.push(1,-1),this._vertexBuffers[O.PositionKind]=new O(this._fullEngine,f,O.PositionKind,!1,!1,2),this._createIndexBuffer()}_createRtWrapper(e,t,i,s){return e?(this._rtWrapper=this._fullEngine.createRenderTargetCubeTexture(t,{generateMipMaps:i,generateDepthBuffer:!1,generateStencilBuffer:!1,type:s,...this._options}),this.setFloat("face",0)):(this._rtWrapper=this._fullEngine.createRenderTargetTexture(t,{generateMipMaps:i,generateDepthBuffer:!1,generateStencilBuffer:!1,type:s,...this._options}),this._rtWrapper.is3D&&(this.setFloat("layer",0),this.setInt("layerNum",0))),this._rtWrapper}getEffect(){return this._drawWrapper.effect}_setEffect(e){this._drawWrapper.effect=e}getContent(){return this._contentData&&this._frameId===this._contentUpdateId?this._contentData:(this._contentData?this._contentData.then(e=>{this._contentData=this.readPixels(0,0,e),this._contentUpdateId=this._frameId}):(this._contentData=this.readPixels(0,0),this._contentUpdateId=this._frameId),this._contentData)}_createIndexBuffer(){const e=this._fullEngine,t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=e.createIndexBuffer(t)}_rebuild(){const e=this._vertexBuffers[O.PositionKind];e&&e._rebuild(),this._createIndexBuffer(),this.refreshRate===ar.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=ar.REFRESHRATE_RENDER_ONCE)}reset(){this._drawWrapper.effect?.dispose(),this._drawWrapper.effect=null,this._cachedDefines=null}_getDefines(){return this.defines}executeWhenReady(e){if(this.isReady()){e(this);return}const t=this.getEffect();t&&t.executeWhenCompiled(()=>{e(this)})}isReady(){const e=this._fullEngine;if(this.nodeMaterialSource)return this._drawWrapper.effect.isReady();if(!this._fragment)return!1;if(this._fallbackTextureUsed)return!0;if(!this._texture)return!1;const t=this._getDefines();if(this._drawWrapper.effect&&t===this._cachedDefines&&this._drawWrapper.effect.isReady())return!0;const i={vertex:"procedural",fragmentElement:this._fragment.fragmentElement,fragmentSource:this._fragment.fragmentSource,fragment:typeof this._fragment=="string"?this._fragment:void 0};return this._cachedDefines!==t&&(this._cachedDefines=t,this._drawWrapper.effect=e.createEffect(i,[O.PositionKind],this._uniforms,this._samplers,t,void 0,void 0,()=>{this._rtWrapper?.dispose(),this._rtWrapper=this._texture=null,this._fallbackTexture&&(this._texture=this._fallbackTexture._texture,this._texture&&this._texture.incrementReferences()),this._fallbackTextureUsed=!0},void 0,this._shaderLanguage,async()=>{this._options.extraInitializationsAsync?this.shaderLanguage===1?await Promise.all([_t(()=>import("./procedural.vertex-EYpRBRL8.js"),[]),this._options.extraInitializationsAsync()]):await Promise.all([_t(()=>import("./procedural.vertex-e7QQb2iU.js"),[]),this._options.extraInitializationsAsync()]):this.shaderLanguage===1?await _t(()=>import("./procedural.vertex-EYpRBRL8.js"),[]):await _t(()=>import("./procedural.vertex-e7QQb2iU.js"),[])})),this._drawWrapper.effect.isReady()}resetRefreshCounter(){this._currentRefreshId=-1}setFragment(e){this._fragment=e}get refreshRate(){return this._refreshRate}set refreshRate(e){this._refreshRate=e,this.resetRefreshCounter()}_shouldRender(){return!this.isEnabled||!this.isReady()||!this._texture?(this._texture&&(this._texture.isReady=!1),!1):this._fallbackTextureUsed?!1:this._currentRefreshId===-1?(this._currentRefreshId=1,this._frameId++,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,this._frameId++,!0):(this._currentRefreshId++,!1)}getRenderSize(){return this._size}resize(e,t){if(this._fallbackTextureUsed||!this._rtWrapper||!this._texture)return;const i=this._texture.isCube;this._rtWrapper.dispose();const s=this._createRtWrapper(i,e,t,this._textureType);this._texture=s.texture,this._size=e,this._generateMipMaps=t}_checkUniform(e){this._uniforms.indexOf(e)===-1&&this._uniforms.push(e)}setTexture(e,t){return this._samplers.indexOf(e)===-1&&this._samplers.push(e),this._textures[e]=t,this}setFloat(e,t){return this._checkUniform(e),this._floats[e]=t,this}setInt(e,t){return this._checkUniform(e),this._ints[e]=t,this}setFloats(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this}setColor3(e,t){return this._checkUniform(e),this._colors3[e]=t,this}setColor4(e,t){return this._checkUniform(e),this._colors4[e]=t,this}setVector2(e,t){return this._checkUniform(e),this._vectors2[e]=t,this}setVector3(e,t){return this._checkUniform(e),this._vectors3[e]=t,this}setVector4(e,t){return this._checkUniform(e),this._vectors4[e]=t,this}setMatrix(e,t){return this._checkUniform(e),this._matrices[e]=t,this}render(e){const t=this.getScene();if(!t)return;const i=this._fullEngine;if(i.enableEffect(this._drawWrapper),this.onBeforeGenerationObservable.notifyObservers(this),i.setState(!1),!this.nodeMaterialSource){for(const r in this._textures)this._drawWrapper.effect.setTexture(r,this._textures[r]);for(const r in this._ints)this._drawWrapper.effect.setInt(r,this._ints[r]);for(const r in this._floats)this._drawWrapper.effect.setFloat(r,this._floats[r]);for(const r in this._floatsArrays)this._drawWrapper.effect.setArray(r,this._floatsArrays[r]);for(const r in this._colors3)this._drawWrapper.effect.setColor3(r,this._colors3[r]);for(const r in this._colors4){const a=this._colors4[r];this._drawWrapper.effect.setFloat4(r,a.r,a.g,a.b,a.a)}for(const r in this._vectors2)this._drawWrapper.effect.setVector2(r,this._vectors2[r]);for(const r in this._vectors3)this._drawWrapper.effect.setVector3(r,this._vectors3[r]);for(const r in this._vectors4)this._drawWrapper.effect.setVector4(r,this._vectors4[r]);for(const r in this._matrices)this._drawWrapper.effect.setMatrix(r,this._matrices[r])}if(!this._texture||!this._rtWrapper)return;i._debugPushGroup?.(`procedural texture generation for ${this.name}`,1);const s=i.currentViewport;if(this.isCube)for(let r=0;r<6;r++)i.bindFramebuffer(this._rtWrapper,r,void 0,void 0,!0),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._drawWrapper.effect),this._drawWrapper.effect.setFloat("face",r),this.autoClear&&i.clear(t.clearColor,!0,!1,!1),i.drawElementsType(fe.TriangleFillMode,0,6),i.unBindFramebuffer(this._rtWrapper,!0);else{let r=1;this._rtWrapper.is3D?r=this._rtWrapper.depth:this._rtWrapper.is2DArray&&(r=this._rtWrapper.layers);for(let a=0;a<r;a++){if(i.bindFramebuffer(this._rtWrapper,0,void 0,void 0,!0,0,a),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._drawWrapper.effect),this._rtWrapper.is3D||this._rtWrapper.is2DArray){this._drawWrapper.effect?.setFloat("layer",r!==1?a/(r-1):0),this._drawWrapper.effect?.setInt("layerNum",a);for(const o in this._textures)this._drawWrapper.effect.setTexture(o,this._textures[o])}this.autoClear&&i.clear(t.clearColor,!0,!1,!1),i.drawElementsType(fe.TriangleFillMode,0,6),i.unBindFramebuffer(this._rtWrapper,!this._generateMipMaps)}}s&&i.setViewport(s),this.isCube&&i.generateMipMapsForCubemap(this._texture,!0),i._debugPopGroup?.(1),this.onGenerated&&this.onGenerated(),this.onGeneratedObservable.notifyObservers(this)}clone(){const e=this.getSize(),t=new fa(this.name,e.width,this._fragment,this.get
3366Scene(),this._fallbackTexture,this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,t}dispose(){const e=this.getScene();if(!e)return;const t=e.proceduralTextures.indexOf(this);t>=0&&e.proceduralTextures.splice(t,1);const i=this._vertexBuffers[O.PositionKind];i&&(i.dispose(),this._vertexBuffers[O.PositionKind]=null),this._indexBuffer&&this._fullEngine._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),this.onGeneratedObservable.clear(),this.onBeforeGenerationObservable.clear(),super.dispose()}}N([H()],fa.prototype,"isEnabled",void 0);N([H()],fa.prototype,"autoClear",void 0);N([H()],fa.prototype,"_generateMipMaps",void 0);N([H()],fa.prototype,"_size",void 0);N([H()],fa.prototype,"refreshRate",null);Tt("BABYLON.ProceduralTexture",fa);var mt;(function(n){n[n.Cos=0]="Cos",n[n.Sin=1]="Sin",n[n.Abs=2]="Abs",n[n.Exp=3]="Exp",n[n.Exp2=4]="Exp2",n[n.Round=5]="Round",n[n.Floor=6]="Floor",n[n.Ceiling=7]="Ceiling",n[n.Sqrt=8]="Sqrt",n[n.Log=9]="Log",n[n.Tan=10]="Tan",n[n.ArcTan=11]="ArcTan",n[n.ArcCos=12]="ArcCos",n[n.ArcSin=13]="ArcSin",n[n.Fract=14]="Fract",n[n.Sign=15]="Sign",n[n.Radians=16]="Radians",n[n.Degrees=17]="Degrees",n[n.Set=18]="Set"})(mt||(mt={}));class ey extends Ws{constructor(e){super(e,De.Neutral),this.operation=mt.Cos,this.registerInput("input",re.AutoDetect),this.registerOutput("output",re.BasedOnInput),this._outputs[0]._typeConnectionSource=this._inputs[0]}getClassName(){return"TrigonometryBlock"}get input(){return this._inputs[0]}get output(){return this._outputs[0]}_buildBlock(e){super._buildBlock(e);const t=this._outputs[0];let i="";switch(this.operation){case mt.Cos:{i="cos";break}case mt.Sin:{i="sin";break}case mt.Abs:{i="abs";break}case mt.Exp:{i="exp";break}case mt.Exp2:{i="exp2";break}case mt.Round:{i="round";break}case mt.Floor:{i="floor";break}case mt.Ceiling:{i="ceil";break}case mt.Sqrt:{i="sqrt";break}case mt.Log:{i="log";break}case mt.Tan:{i="tan";break}case mt.ArcTan:{i="atan";break}case mt.ArcCos:{i="acos";break}case mt.ArcSin:{i="asin";break}case mt.Fract:{i="fract";break}case mt.Sign:{i="sign";break}case mt.Radians:{i="radians";break}case mt.Degrees:{i="degrees";break}case mt.Set:{i="";break}}return e.compilationString+=e._declareOutput(t)+` = ${i}(${this.input.associatedVariableName}); 3367`,this}serialize(){const e=super.serialize();return e.operation=this.operation,e}_deserialize(e,t,i){super._deserialize(e,t,i),this.operation=e.operation}_dumpPropertiesCode(){return super._dumpPropertiesCode()+`${this._codeVariableName}.operation = BABYLON.TrigonometryBlockOperations.${mt[this.operation]}; 3368`}}N([bc("Operation",5,"ADVANCED",{notifiers:{rebuild:!0},embedded:!0,options:[{label:"Cos",value:mt.Cos},{label:"Sin",value:mt.Sin},{label:"Abs",value:mt.Abs},{label:"Exp",value:mt.Exp},{label:"Exp2",value:mt.Exp2},{label:"Round",value:mt.Round},{label:"Floor",value:mt.Floor},{label:"Ceiling",value:mt.Ceiling},{label:"Sqrt",value:mt.Sqrt},{label:"Log",value:mt.Log},{label:"Tan",value:mt.Tan},{label:"ArcTan",value:mt.ArcTan},{label:"ArcCos",value:mt.ArcCos},{label:"ArcSin",value:mt.ArcSin},{label:"Fract",value:mt.Fract},{label:"Sign",value:mt.Sign},{label:"Radians",value:mt.Radians},{label:"Degrees",value:mt.Degrees},{label:"Set",value:mt.Set}]})],ey.prototype,"operation",void 0);Tt("BABYLON.TrigonometryBlock",ey);const Yg={effect:null,subMesh:null};class M4 extends II(Hf){}class ph extends CI(M4){constructor(){super(),this.NORMAL=!1,this.TANGENT=!1,this.VERTEXCOLOR_NME=!1,this.PREPASS=!1,this.PREPASS_NORMAL=!1,this.PREPASS_NORMAL_INDEX=-1,this.PREPASS_WORLD_NORMAL=!1,this.PREPASS_WORLD_NORMAL_INDEX=-1,this.PREPASS_POSITION=!1,this.PREPASS_POSITION_INDEX=-1,this.PREPASS_LOCAL_POSITION=!1,this.PREPASS_LOCAL_POSITION_INDEX=-1,this.PREPASS_DEPTH=!1,this.PREPASS_DEPTH_INDEX=-1,this.PREPASS_SCREENSPACE_DEPTH=!1,this.PREPASS_SCREENSPACE_DEPTH_INDEX=-1,this.SCENE_MRT_COUNT=0,this.NUM_BONE_INFLUENCERS=0,this.BonesPerMesh=0,this.BONETEXTURE=!1,this.MORPHTARGETS=!1,this.MORPHTARGETS_POSITION=!1,this.MORPHTARGETS_NORMAL=!1,this.MORPHTARGETS_TANGENT=!1,this.MORPHTARGETS_
3368UV=!1,this.MORPHTARGETS_UV2=!1,this.MORPHTARGETS_COLOR=!1,this.MORPHTARGETTEXTURE_HASPOSITIONS=!1,this.MORPHTARGETTEXTURE_HASNORMALS=!1,this.MORPHTARGETTEXTURE_HASTANGENTS=!1,this.MORPHTARGETTEXTURE_HASUVS=!1,this.MORPHTARGETTEXTURE_HASUV2S=!1,this.MORPHTARGETTEXTURE_HASCOLORS=!1,this.NUM_MORPH_INFLUENCERS=0,this.MORPHTARGETS_TEXTURE=!1,this.BUMPDIRECTUV=0,this.CAMERA_ORTHOGRAPHIC=!1,this.CAMERA_PERSPECTIVE=!1,this.AREALIGHTSUPPORTED=!0,this.AREALIGHTNOROUGHTNESS=!0,this.rebuild()}setValue(e,t,i=!1){this[e]===void 0&&this._keys.push(e),i&&this[e]!==t&&this.markAsUnprocessed(),this[e]=t}}class C4 extends PI(Hb){}class Ht extends C4{static _BlockIsTextureBlock(e){return e.getClassName()==="TextureBlock"||e.getClassName()==="ReflectionTextureBaseBlock"||e.getClassName()==="ReflectionTextureBlock"||e.getClassName()==="ReflectionBlock"||e.getClassName()==="RefractionBlock"||e.getClassName()==="CurrentScreenBlock"||e.getClassName()==="SmartFilterTextureBlock"||e.getClassName()==="ParticleTextureBlock"||e.getClassName()==="ImageSourceBlock"||e.getClassName()==="TriPlanarBlock"||e.getClassName()==="BiPlanarBlock"||e.getClassName()==="PrePassTextureBlock"}get buildIsInProgress(){return this._buildIsInProgress}set _glowModeEnabled(e){this._useAdditionalColor=e}_getGlobalNodeMaterialEditor(){if(typeof NODEEDITOR<"u")return NODEEDITOR;if(typeof BABYLON<"u"&&typeof BABYLON.NodeEditor<"u")return BABYLON}get shaderLanguage(){return this._options?.shaderLanguage||Ht.DefaultShaderLanguage}set shaderLanguage(e){this._options.shaderLanguage=e}get options(){return this._options}set options(e){this._options=e}get mode(){return this._mode}set mode(e){this._mode=e}get buildId(){return this._buildId}set buildId(e){this._buildId=e}constructor(e,t,i={}){if(super(e,t||Ke.LastCreatedScene),this._buildId=Ht._BuildIdGenerator++,this._buildWasSuccessful=!1,this._cachedWorldViewMatrix=new W,this._cachedWorldViewProjectionMatrix=new W,this._optimizers=new Array,this._animationFrame=-1,this._buildIsInProgress=!1,this.BJSNODEMATERIALEDITOR=this._getGlobalNodeMaterialEditor(),this._useAdditionalColor=!1,this.editorData=null,this.ignoreAlpha=!1,this.maxSimultaneousLights=4,this.onBuildObservable=new le,this.onBuildErrorObservable=new le,this._vertexOutputNodes=new Array,this._fragmentOutputNodes=new Array,this.attachedBlocks=[],this._mode=$i.Material,this.forceAlphaBlending=!1,!Ht.UseNativeShaderLanguageOfEngine&&i&&i.shaderLanguage===1&&!this.getScene().getEngine().isWebGPU)throw new Error("WebGPU shader language is only supported with WebGPU engine");this._options={emitComments:!1,shaderLanguage:Ht.DefaultShaderLanguage,...i},Ht.UseNativeShaderLanguageOfEngine&&(this._options.shaderLanguage=this.getScene().getEngine().isWebGPU?1:0),this._attachImageProcessingConfiguration(null)}getClassName(){return"NodeMaterial"}getBlockByName(e){let t=null;for(const i of this.attachedBlocks)if(i.name===e)if(!t)t=i;else return pe.Warn("More than one block was found with the name `"+e+"`"),t;return t}getBlockByPredicate(e){for(const t of this.attachedBlocks)if(e(t))return t;return null}getInputBlockByPredicate(e){for(const t of this.attachedBlocks)if(t.isInput&&e(t))return t;return null}getInputBlocks(){const e=[];for(const t of this.attachedBlocks)t.isInput&&e.push(t);return e}registerOptimizer(e){if(!(this._optimizers.indexOf(e)>-1))return this._optimizers.push(e),this}unregisterOptimizer(e){const t=this._optimizers.indexOf(e);if(t!==-1)return this._optimizers.splice(t,1),this}addOutputNode(e){if(e.target===null)throw"This node is not meant to be an output node. You may want to explicitly set its target value.";return(e.target&De.Vertex)!==0&&this._addVertexOutputNode(e),(e.target&De.Fragment)!==0&&this._addFragmentOutputNode(e),this}removeOutputNode(e){return e.target===null?this:((e.target&De.Vertex)!==0&&this._removeVertexOutputNode(e),(e.target&De.Fragment)!==0&&this._removeFragmentOutputNode(e),this)}_addVertexOutputNode(e){if(this._vertexOutputNodes.indexOf(e)===-1)return e.target=De.Vertex,this._vertexOutputNodes.push(e),this}_removeVertexOutputNode(e){const t=this._vertexOutputNodes.indexOf(e);if(t!==-1)return this._vertexOutputNodes.splice(t,1),this}_addFragmentOutputNode(e){if(this._fragmentOutputNodes.indexOf(e)===-1)return e.target=De.Fragment,this._fragmentOutputNodes.push(e),this}_removeFragmentOutputNode(e){const t=this._fragmentOutputNodes.indexOf(e);if(t!==-1)return this._fragmentOutputNodes.splice(t,1),this}get _supportGlowLayer(){return this._fragmentOutputNodes.length===0?!1:!!this._fragmentOutputNodes.some(e=>e.additionalColor&&e.additionalColor.isConnected)}
3368needAlphaBlending(){return this.ignoreAlpha?!1:this.forceAlphaBlending||this.alpha<1||this._sharedData&&this._sharedData.hints.needAlphaBlending}needAlphaTesting(){return this._sharedData&&this._sharedData.hints.needAlphaTesting}_processInitializeOnLink(e,t,i,s=!0){(e.target===De.VertexAndFragment||t.target===De.Fragment&&e.target===De.Vertex&&e._preparationId!==this._buildId)&&i.push(e),this._initializeBlock(e,t,i,s)}_attachBlock(e){if(this.attachedBlocks.indexOf(e)===-1){if(e.isUnique){const t=e.getClassName();for(const i of this.attachedBlocks)if(i.getClassName()===t){this._sharedData.raiseBuildError(`Cannot have multiple blocks of type ${t} in the same NodeMaterial`);return}}this.attachedBlocks.push(e)}}_initializeBlock(e,t,i,s=!0){e.initialize(t),s&&e.autoConfigure(this),e._preparationId=this._buildId,this._attachBlock(e);for(const r of e.inputs){r.associatedVariableName="";const a=r.connectedPoint;if(a&&!a._preventBubbleUp){const o=a.ownerBlock;o!==e&&this._processInitializeOnLink(o,t,i,s)}}if(e.isLoop){const r=e;if(r.loopID.hasEndpoints)for(const a of r.loopID.endpoints){const o=a.ownerBlock;o.outputs.length===0&&(t._terminalBlocks.add(o),this._processInitializeOnLink(o,t,i,s))}}else if(e.isTeleportOut){const r=e;r.entryPoint&&this._processInitializeOnLink(r.entryPoint,t,i,s)}for(const r of e.outputs)r.associatedVariableName=""}_resetDualBlocks(e,t){e.target===De.VertexAndFragment&&(e.buildId=t);for(const i of e.inputs){const s=i.connectedPoint;if(s&&!s._preventBubbleUp){const r=s.ownerBlock;r!==e&&this._resetDualBlocks(r,t)}}if(e.isTeleportOut){const i=e;i.entryPoint&&this._resetDualBlocks(i.entryPoint,t)}else if(e.isLoop){const i=e;if(i.loopID.hasEndpoints)for(const s of i.loopID.endpoints){const r=s.ownerBlock;r.outputs.length===0&&this._resetDualBlocks(r,t)}}}removeBlock(e){const t=this.attachedBlocks.indexOf(e);t>-1&&this.attachedBlocks.splice(t,1),e.isFinalMerger&&this.removeOutputNode(e)}build(e=!1,t=!0,i=!1){if(this._buildIsInProgress){oe.Warn("Build is already in progress, You can use NodeMaterial.onBuildObservable to determine when the build is completed.");return}this._buildIsInProgress=!0,!this._vertexCompilationState&&!i&&(i=!0),this._buildWasSuccessful=!1;const s=this.getScene().getEngine(),r=this._mode===$i.Particle||this._mode===$i.SFE;if(this._vertexOutputNodes.length===0&&!r){this.onBuildErrorObservable.notifyObservers("You must define at least one vertexOutputNode"),this._buildIsInProgress=!1;return}if(this._fragmentOutputNodes.length===0){this.onBuildErrorObservable.notifyObservers("You must define at least one fragmentOutputNode"),this._buildIsInProgress=!1;return}this._vertexCompilationState=new oA,this._vertexCompilationState.supportUniformBuffers=s.supportsUniformBuffers,this._vertexCompilationState.target=De.Vertex,this._fragmentCompilationState=new oA,this._fragmentCompilationState.supportUniformBuffers=s.supportsUniformBuffers,this._fragmentCompilationState.target=De.Fragment;const a=this._fragmentOutputNodes.filter(f=>f._isFinalOutputAndActive).length>1;let o=this._fragmentOutputNodes;a&&(o=this._fragmentOutputNodes.filter(f=>!f._isFinalOutputAndActive),o.push(this._fragmentOutputNodes.filter(f=>f._isFinalOutputAndActive&&f._hasPrecedence)[0])),this._sharedData=new S4,this._sharedData.nodeMaterial=this,this._sharedData.fragmentOutputNodes=o,this._vertexCompilationState.sharedData=this._sharedData,this._fragmentCompilationState.sharedData=this._sharedData,this._sharedData.buildId=this._buildId,this._sharedData.emitComments=this._options.emitComments,this._sharedData.verbose=e,this._sharedData.scene=this.getScene(),this._sharedData.allowEmptyVertexProgram=r;const c=[],u=[];for(const f of this._vertexOutputNodes)c.push(f),this._initializeBlock(f,this._vertexCompilationState,u,i);for(const f of o)u.push(f),this._initializeBlock(f,this._fragmentCompilationState,c,i);let d=0;for(const f of this.attachedBlocks)f.codeIsReady||(d++,f.onCodeIsReadyObservable.addOnce(()=>{d--,d===0&&this._finishBuildProcess(e,t,c,u)}));d===0&&this._finishBuildProcess(e,t,c,u)}_finishBuildProcess(e=!1,t=!0,i,s){this.optimize();for(const c of i)c.build(this._vertexCompilationState,i);this._fragmentCompilationState.uniforms=this._vertexCompilationState.uniforms.slice(0),this._fragmentCompilationState._uniformDeclaration=this._vertexCompilationState._uniformDeclaration,this._fragmentCompilationState._constantDeclaration=this._vertexCompilationState._constantDeclaration,this._fragmentCompilationState._vertexState=this._vertexCompilationState;for(const c of s)this._resetDualBlocks(c,this._buildId-1);for(const c of s)c.build(this._fragmentCompilationState,s);this._vertexCompilationState.finalize(this._vertexCompilationState),this._fragmentCompilationState.finalize(this._fragmentCompilationState),t&&(this._buildId=Ht._BuildIdGenerator++),e&&(oe.Log("Vertex shader:"),oe.Log
3368(this._vertexCompilationState.compilationString),oe.Log("Fragment shader:"),oe.Log(this._fragmentCompilationState.compilationString));const r=this._sharedData.emitErrors();this._buildIsInProgress=!1,r&&(this._buildWasSuccessful=!0,this.onBuildObservable.notifyObservers(this));const a=this.getScene().meshes;for(const c of a)if(c.subMeshes)for(const u of c.subMeshes){if(u.getMaterial()!==this||!u.materialDefines)continue;const d=u.materialDefines;d.markAllAsDirty(),d.reset()}this.prePassTextureInputs.length&&this.getScene().enablePrePassRenderer();const o=this.getScene().prePassRenderer;o&&o.markAsDirty()}optimize(){for(const e of this._optimizers)e.optimize(this._vertexOutputNodes,this._fragmentOutputNodes)}_prepareDefinesForAttributes(e,t){const i=t.NORMAL,s=t.TANGENT,r=t.VERTEXCOLOR_NME;t.NORMAL=e.isVerticesDataPresent(O.NormalKind),t.TANGENT=e.isVerticesDataPresent(O.TangentKind);const a=e.useVertexColors&&e.isVerticesDataPresent(O.ColorKind);t.VERTEXCOLOR_NME=a;let o=!1;for(let u=1;u<=6;++u){const d=t["UV"+u];t["UV"+u]=e.isVerticesDataPresent(`uv${u===1?"":u}`),o=o||t["UV"+u]!==d}const c=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;LC(this.getScene(),t,!c),Ss.PrepareDefines(this.getScene().getEngine().currentRenderPassId,e,t),(i!==t.NORMAL||s!==t.TANGENT||r!==t.VERTEXCOLOR_NME||o)&&t.markAsAttributesDirty()}get isPrePassCapable(){return!0}get prePassTextureOutputs(){const e=this.getBlockByPredicate(i=>i.getClassName()==="PrePassOutputBlock"),t=[4];return!e||this.prePassTextureInputs.length||(e.viewDepth.isConnected&&t.push(5),e.screenDepth.isConnected&&t.push(10),e.viewNormal.isConnected&&t.push(6),e.worldNormal.isConnected&&t.push(8),e.worldPosition.isConnected&&t.push(1),e.localPosition.isConnected&&t.push(9),e.reflectivity.isConnected&&t.push(3),e.velocity.isConnected&&t.push(2),e.velocityLinear.isConnected&&t.push(11)),t}get prePassTextureInputs(){const e=this.getAllTextureBlocks().filter(i=>i.getClassName()==="PrePassTextureBlock"),t=[];for(const i of e)i.position.isConnected&&!t.includes(1)&&t.push(1),i.localPosition.isConnected&&!t.includes(9)&&t.push(9),i.depth.isConnected&&!t.includes(5)&&t.push(5),i.screenDepth.isConnected&&!t.includes(10)&&t.push(10),i.normal.isConnected&&!t.includes(6)&&t.push(6),i.worldNormal.isConnected&&!t.includes(8)&&t.push(8);return t}setPrePassRenderer(e){const t=this.prePassTextureInputs.concat(this.prePassTextureOutputs);if(e&&t.length>1){let i=e.getEffectConfiguration("nodeMaterial");i||(i=e.addEffectConfiguration({enabled:!0,needsImageProcessing:!1,name:"nodeMaterial",texturesRequired:[]}));for(const s of t)i.texturesRequired.includes(s)||i.texturesRequired.push(s);i.enabled=!0}return t.length>1}createPostProcess(e,t=1,i=1,s,r,a=0,o=5){return this.mode!==$i.PostProcess&&this.mode!==$i.SFE?(oe.Log("Incompatible material mode"),null):this._createEffectForPostProcess(null,e,t,i,s,r,a,o)}createEffectForPostProcess(e){this._createEffectForPostProcess(e)}_createEffectForPostProcess(e,t,i=1,s=1,r,a,o=0,c=5){let u=this.name+this._buildId;const d=new ph;let f=this._buildId;this._processDefines(d);const g=this._sharedData.checks.emitVertex?this._vertexCompilationState._builtCompilationString:void 0;return At.RegisterShader(u,this._fragmentCompilationState._builtCompilationString,g,this.shaderLanguage),e?e.updateEffect(d.toString(),this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,{maxSimultaneousLights:this.maxSimultaneousLights},void 0,void 0,u,u):e=new di(this.name+"PostProcess",u,this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,i,t,s,r,a,d.toString(),o,g?u:"postprocess",{maxSimultaneousLights:this.maxSimultaneousLights},!1,c,this.shaderLanguage),e.nodeMaterialSource=this,e.onApplyObservable.add(m=>{f!==this._buildId&&(delete At.ShadersStore[u+"VertexShader"],delete At.ShadersStore[u+"PixelShader"],u=this.name+this._buildId,d.markAllAsDirty(),f=this._buildId),this._processDefines(d)&&(At.RegisterShader(u,this._fragmentCompilationState._builtCompilationString,this._vertexCompilationState._builtCompilationString),zo.SetImmediate(()=>e.updateEffect(d.toString(),this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,{maxSimultaneousLights:this.maxSimultaneousLights},void 0,void 0,u,u))),this._checkInternals(m)}),e}createProceduralTexture(e,t){if(this.mode!==$i.ProceduralTexture)return oe.Log("Incompatible material mode"),null;let i=this.name+this._buildId;const s=new fa(i,e,null,t),r=new ph,a=this._processDefines(r);At.RegisterShader(i,this._fragmentCompilationState._builtCompilationString,this._vertexCompilationState._builtCompilationString,this.shaderLanguage);
3368let o=this.getScene().getEngine().createEffect({vertexElement:i,fragmentElement:i},[O.PositionKind],this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,r.toString(),a?.fallbacks,void 0,void 0,void 0,this.shaderLanguage);s.nodeMaterialSource=this,s._setEffect(o);let c=this._buildId;const u=()=>{c!==this._buildId&&(delete At.ShadersStore[i+"VertexShader"],delete At.ShadersStore[i+"PixelShader"],i=this.name+this._buildId,r.markAllAsDirty(),c=this._buildId);const d=this._processDefines(r);d&&(At.RegisterShader(i,this._fragmentCompilationState._builtCompilationString,this._vertexCompilationState._builtCompilationString,this.shaderLanguage),zo.SetImmediate(()=>{o=this.getScene().getEngine().createEffect({vertexElement:i,fragmentElement:i},[O.PositionKind],this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,r.toString(),d?.fallbacks,void 0),s._setEffect(o)})),this._checkInternals(o)};return s.onBeforeGenerationObservable.add(()=>{u()}),this.onBuildObservable.add(()=>{u()}),s}_createEffectForParticles(e,t,i,s,r,a,o=""){let c=this.name+this._buildId+"_"+t;a||(a=new ph);let u=this._buildId;const d=[];let f=o;if(!r){const g=this._processDefines(a);At.RegisterShader(c,this._fragmentCompilationState._builtCompilationString,void 0,this.shaderLanguage),e.fillDefines(d,t,!1),f=d.join(` 3369`),r=this.getScene().getEngine().createEffectForParticles(c,this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,a.toString()+` 3370`+f,g?.fallbacks,i,s,e,this.shaderLanguage),e.setCustomEffect(r,t)}r.onBindObservable.add(g=>{u!==this._buildId&&(delete At.ShadersStore[c+"PixelShader"],c=this.name+this._buildId+"_"+t,a.markAllAsDirty(),u=this._buildId),d.length=0,e.fillDefines(d,t,!1);const m=d.join(` 3371`);m!==f&&(a.markAllAsDirty(),f=m);const b=this._processDefines(a);if(b){At.RegisterShader(c,this._fragmentCompilationState._builtCompilationString,void 0,this.shaderLanguage),g=this.getScene().getEngine().createEffectForParticles(c,this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,a.toString()+` 3372`+f,b?.fallbacks,i,s,e),e.setCustomEffect(g,t),this._createEffectForParticles(e,t,i,s,g,a,o);return}this._checkInternals(g)})}_checkInternals(e){if(this._sharedData.animatedInputs){const t=this.getScene(),i=t.getFrameId();if(this._animationFrame!==i){for(const s of this._sharedData.animatedInputs)s.animate(t);this._animationFrame=i}}for(const t of this._sharedData.bindableBlocks)t.bind(e,this);for(const t of this._sharedData.inputBlocks)t._transmit(e,this.getScene(),this)}createEffectForParticles(e,t,i){if(this.mode!==$i.Particle){oe.Log("Incompatible material mode");return}this._createEffectForParticles(e,rs.BLENDMODE_ONEONE,t,i),this._createEffectForParticles(e,rs.BLENDMODE_MULTIPLY,t,i)}createAsShadowDepthWrapper(e){if(this.mode!==$i.Material){oe.Log("Incompatible material mode");return}e.shadowDepthWrapper=new BABYLON.ShadowDepthWrapper(this,this.getScene())}_processDefines(e,t,i=!1,s){let r=null;const a=this.getScene();NC(a,e)&&e.markAsMiscDirty();for(const o of this._sharedData.blocksWithDefines)o.initializeDefines(e);for(const o of this._sharedData.blocksWithDefines)o.prepareDefines(e,this,t,i,s);if(e.isDirty){const o=e._areLightsDisposed;e.markAsProcessed(),this._vertexCompilationState.compilationString=this._vertexCompilationState._builtCompilationString,this._fragmentCompilationState.compilationString=this._fragmentCompilationState._builtCompilationString;for(const g of this._sharedData.repeatableContentBlocks)g.replaceRepeatableContent(this._vertexCompilationState,e,t);const c=[];for(const g of this._sharedData.dynamicUniformBlocks)g.updateUniformsAndSamples(this._vertexCompilationState,this,e,c);const u=this._vertexCompilationState.uniforms;for(const g of this._fragmentCompilationState.uniforms)u.indexOf(g)===-1&&u.push(g);const d=this._vertexCompilationState.samplers;for(const g of this._fragmentCompilationState.samplers)d.indexOf(g)===-1&&d.push(g);const f=new eu;for(const g of this._sharedData.blocksWithFallbacks)g.provideFallbacks(f,t);r={lightDisposed:o,uniformBuffers:c,mergedUniforms:u,mergedSamplers:d,fallbacks:f}}return r}isReadyForSubMesh(e,t,i=!1){if(!this._buildWasSuccessful)return!1;const s=this.getScene();if(this._sharedData.animatedInputs){const u=s.getFrameId();if(this._animationFrame!==u){for(const d of this._sharedData.animatedInputs)d.animate(s);this._animationFrame=u}}const r=t._drawWrapper;if(r.effect&&this.isFrozen&&r._wasPreviouslyReady&&r._wasPreviouslyUsingInstances===i)return!0;(!t.materialDefines||typeof t.materialDefines=="string")&&(t.materialDefines=new ph);const a=t.materialDefines;if(this._isReadyForSubMesh(t))return!0;const o=s.getEngine();if(this._prepareDefinesForAttributes(e,a),this._sharedData.blockingBlocks.some(u=>!u.isReady(e,this,a,i)))return!1;const c=this._processDefines(a,e,i,t);if(c){const u=t.effect,d=a.toString();
3372let f=o.createEffect({vertex:"nodeMaterial"+this._buildId,fragment:"nodeMaterial"+this._buildId,vertexSource:this._vertexCompilationState.compilationString,fragmentSource:this._fragmentCompilationState.compilationString},{attributes:this._vertexCompilationState.attributes,uniformsNames:c.mergedUniforms,uniformBuffersNames:c.uniformBuffers,samplers:c.mergedSamplers,defines:d,fallbacks:c.fallbacks,onCompiled:this.onCompiled,onError:this.onError,multiTarget:a.PREPASS,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights,maxSimultaneousMorphTargets:a.NUM_MORPH_INFLUENCERS},shaderLanguage:this.shaderLanguage},o);if(f)if(this._onEffectCreatedObservable&&(Yg.effect=f,Yg.subMesh=t,this._onEffectCreatedObservable.notifyObservers(Yg)),this.allowShaderHotSwapping&&u&&!f.isReady()){if(f=u,a.markAsUnprocessed(),c.lightDisposed)return a._areLightsDisposed=!0,!1}else s.resetCachedMaterial(),t.setEffect(f,a,this._materialContext)}if(a.AREALIGHTUSED){for(let u=0;u<e.lightSources.length;u++)if(!e.lightSources[u]._isReady())return!1}return!t.effect||!t.effect.isReady()?!1:(a._renderId=s.getRenderId(),r._wasPreviouslyReady=!0,r._wasPreviouslyUsingInstances=i,this._checkScenePerformancePriority(),!0)}get compiledShaders(){return this._buildWasSuccessful||this.build(),`// Vertex shader 3373${this._vertexCompilationState.compilationString} 3374 3375// Fragment shader 3376${this._fragmentCompilationState.compilationString}`}async _getProcessedFragmentAsync(){this._buildWasSuccessful||this.build();const e=new ph;this._processDefines(e);let t=e.toString();return this.mode===$i.SFE&&(t+=`#define ${Ym} 3377`),await this._fragmentCompilationState.getProcessedShaderAsync(t)}bindOnlyWorldMatrix(e){const t=this.getScene();if(!this._activeEffect)return;const i=this._sharedData.hints;i.needWorldViewMatrix&&e.multiplyToRef(t.getViewMatrix(),this._cachedWorldViewMatrix),i.needWorldViewProjectionMatrix&&e.multiplyToRef(t.getTransformMatrix(),this._cachedWorldViewProjectionMatrix);for(const s of this._sharedData.inputBlocks)s._transmitWorld(this._activeEffect,e,this._cachedWorldViewMatrix,this._cachedWorldViewProjectionMatrix)}bindForSubMesh(e,t,i){const s=this.getScene(),r=i.effect;if(!r)return;this._activeEffect=r,this.bindOnlyWorldMatrix(e);const a=this._mustRebind(s,r,i,t.visibility),o=this._sharedData;if(a){for(const c of o.bindableBlocks)c.bind(r,this,t,i);for(const c of o.forcedBindableBlocks)c.bind(r,this,t,i);for(const c of o.inputBlocks)c._transmit(r,s,this)}else if(!this.isFrozen)for(const c of o.forcedBindableBlocks)c.bind(r,this,t,i);this._afterBind(t,this._activeEffect,i)}getActiveTextures(){const e=super.getActiveTextures();return this._sharedData&&e.push(...this._sharedData.textureBlocks.filter(t=>t.texture).map(t=>t.texture)),e}getTextureBlocks(){return this._sharedData?this._sharedData.textureBlocks:[]}getAllTextureBlocks(){const e=[];for(const t of this.attachedBlocks)Ht._BlockIsTextureBlock(t)&&e.push(t);return e}hasTexture(e){if(super.hasTexture(e))return!0;if(!this._sharedData)return!1;for(const t of this._sharedData.textureBlocks)if(t.texture===e)return!0;return!1}dispose(e,t,i){if(t)for(const s of this.getTextureBlocks().filter(r=>r.texture).map(r=>r.texture))s.dispose();for(const s of this.attachedBlocks)s.dispose();this.attachedBlocks.length=0,this._sharedData=null,this._vertexCompilationState=null,this._fragmentCompilationState=null,this.onBuildObservable.clear(),this.onBuildErrorObservable.clear(),this._imageProcessingObserver&&(this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingObserver=null),super.dispose(e,t,i)}_createNodeEditor(e){const t={nodeMaterial:this,...e};this.BJSNODEMATERIALEDITOR.NodeEditor.Show(t)}async edit(e){return await new Promise(t=>{if(this.BJSNODEMATERIALEDITOR=this.BJSNODEMATERIALEDITOR||this._getGlobalNodeMaterialEditor(),typeof this.BJSNODEMATERIALEDITOR>"u"){const i=e&&e.editorURL?e.editorURL:Ht.EditorURL;pe.LoadBabylonScript(i,()=>{this.BJSNODEMATERIALEDITOR=this.BJSNODEMATERIALEDITOR||this._getGlobalNodeMaterialEditor(),this._createNodeEditor(e?.no
3377deEditorConfig),t()})}else this._createNodeEditor(e?.nodeEditorConfig),t()})}clear(){this._vertexOutputNodes.length=0,this._fragmentOutputNodes.length=0,this.attachedBlocks.length=0,this._buildIsInProgress=!1}setToDefault(){this.clear(),this.editorData=null;const e=new fs("Position");e.setAsAttribute("position");const t=new fs("World");t.setAsSystemValue(Bt.World);const i=new ff("WorldPos");e.connectTo(i),t.connectTo(i);const s=new fs("ViewProjection");s.setAsSystemValue(Bt.ViewProjection);const r=new ff("WorldPos * ViewProjectionTransform");i.connectTo(r),s.connectTo(r);const a=new kd("VertexOutput");r.connectTo(a);const o=new fs("color");o.value=new Ze(.8,.8,.8,1);const c=new ja("FragmentOutput");o.connectTo(c),this.addOutputNode(a),this.addOutputNode(c),this._mode=$i.Material}setToDefaultPostProcess(){this.clear(),this.editorData=null;const e=new fs("Position");e.setAsAttribute("position2d");const t=new fs("Constant1");t.isConstant=!0,t.value=1;const i=new Vd("Position3D");e.connectTo(i),t.connectTo(i,{input:"w"});const s=new kd("VertexOutput");i.connectTo(s);const r=new fs("Scale");r.visibleInInspector=!0,r.value=new Ie(1,1);const a=new ep("uv0");e.connectTo(a);const o=new Km("UV scale");a.connectTo(o),r.connectTo(o);const c=new KI("CurrentScreen");o.connectTo(c);const u=pe.GetAssetUrl("https://assets.babylonjs.com/core/nme/currentScreenPostProcess.png");c.texture=new Te(u,this.getScene());const d=new ja("FragmentOutput");c.connectTo(d,{output:"rgba"}),this.addOutputNode(s),this.addOutputNode(d),this._mode=$i.PostProcess}setToDefaultProceduralTexture(){this.clear(),this.editorData=null;const e=new fs("Position");e.setAsAttribute("position2d");const t=new fs("Constant1");t.isConstant=!0,t.value=1;const i=new Vd("Position3D");e.connectTo(i),t.connectTo(i,{input:"w"});const s=new kd("VertexOutput");i.connectTo(s);const r=new fs("Time");r.value=0,r.min=0,r.max=0,r.isBoolean=!1,r.matrixMode=0,r.animationType=$n.Time,r.isConstant=!1;const a=new fs("Color3");a.value=new Ne(1,1,1),a.isConstant=!1;const o=new ja("FragmentOutput"),c=new Vd("VectorMerger");c.visibleInInspector=!1;const u=new ey("Cos");u.operation=mt.Cos,e.connectTo(c),r.output.connectTo(u.input),u.output.connectTo(c.z),c.xyzOut.connectTo(o.rgb),this.addOutputNode(s),this.addOutputNode(o),this._mode=$i.ProceduralTexture}setToDefaultParticle(){this.clear(),this.editorData=null;const e=new fs("uv");e.setAsAttribute("particle_uv");const t=new qI("ParticleTexture");e.connectTo(t);const i=new fs("Color");i.setAsAttribute("particle_color");const s=new Km("Texture * Color");t.connectTo(s),i.connectTo(s);const r=new ZI("ParticleRampGradient");s.connectTo(r);const a=new QI("ColorSplitter");i.connectTo(a);const o=new $I("ParticleBlendMultiply");r.connectTo(o),t.connectTo(o,{output:"a"}),a.connectTo(o,{output:"a"});const c=new ja("FragmentOutput");o.connectTo(c),this.addOutputNode(c),this._mode=$i.Particle}async loadAsync(e,t=""){return await Ht.ParseFromFileAsync("",e,this.getScene(),t,!0,this)}_gatherBlocks(e,t){if(t.indexOf(e)===-1){t.push(e);for(const i of e.inputs){const s=i.connectedPoint;if(s){const r=s.ownerBlock;r!==e&&this._gatherBlocks(r,t)}}if(e.isTeleportOut){const i=e;i.entryPoint&&this._gatherBlocks(i.entryPoint,t)}}}generateCode(){let e=[];const t=[],i=["const","var","let"];for(const a of this._vertexOutputNodes)this._gatherBlocks(a,t);const s=[];for(const a of this._fragmentOutputNodes)this._gatherBlocks(a,s);let r=`var nodeMaterial = new BABYLON.NodeMaterial("${this.name||"node material"}"); 3378`;r+=`nodeMaterial.mode = BABYLON.NodeMaterialModes.${$i[this.mode]}; 3379`;for(const a of t)a.isInput&&e.indexOf(a)===-1&&(r+=a._dumpCode(i,e));for(const a of s)a.isInput&&e.indexOf(a)===-1&&(r+=a._dumpCode(i,e));e=[],r+=` 3380// Connections 3381`;for(const a of this._vertexOutputNodes)r+=a._dumpCodeForOutputConnections(e);for(const a of this._fragmentOutputNodes)r+=a._dumpCodeForOutputConnections(e);r+=` 3382// Output nodes 3383`;for(const a of this._vertexOutputNodes)r+=`nodeMaterial.addOutputNode(${a._codeVariableName}); 3384`;for(const a of this._fragmentOutputNodes)r+=`nodeMaterial.addOutputNode(${a._codeVariableName}); 3385`;return r+=`nodeMaterial.build(); 3386`,r}serialize(e){const t=e?{}:$e.Serialize(this);t.editorData=JSON.parse(JSON.stringify(this.editorData));let i=[];if(e)i=e;else{t.customType="BABYLON.NodeMaterial",t.outputNodes=[];for(const s of this._vertexOutputNodes)this._gatherBlocks(s,i),t.outputNodes.push(s.uniqueId);for(const s of this._fragmentOutputNodes)this._gatherBlocks(s,i),t.outputNodes.indexOf(s.uniqueId)===-1&&t.outputNodes.push(s.uniqueId)}t.blocks=[];for(const s of i)t.blocks.push(s.serialize());if(!e)for(const s of this.attachedBlocks)i.indexOf(s)===-1&&t.blocks.push(s.serialize());return t.uniqueId=this.uniqueId,t}_restoreConnections(e,t,i){for(const s of e.outputs)for(const r of t.blocks){const a=i[r.id];if(a){for(const o of r.inputs)if(i[o.targetBlockId]===e&&o.targetConnectionName===s.name){const c=a.getInputByName(o.inputName);if(!c||c.isConnected)continue;s.connectTo(c,!0),this._restoreConnections(a,t,i);continue}}}}parseSerializedObject(e,t="",i=!1,s){i||this.clear();const r={};for(const a of e.blocks){const o=Kr(a.customType);if(o){const c=new o;
3386c._deserialize(a,this.getScene(),t,s),r[a.id]=c,this.attachedBlocks.push(c)}}for(const a of this.attachedBlocks)if(a.isTeleportOut){const o=a,c=o._tempEntryPointUniqueId;c&&r[c].attachToEndpoint(o)}for(let a=0;a<e.blocks.length;a++){const o=e.blocks[a],c=r[o.id];c&&(c.inputs.length&&!i||this._restoreConnections(c,e,r))}if(e.outputNodes)for(const a of e.outputNodes)this.addOutputNode(r[a]);if(e.locations||e.editorData&&e.editorData.locations){const a=e.locations||e.editorData.locations;for(const c of a)r[c.blockId]&&(c.blockId=r[c.blockId].uniqueId);i&&this.editorData&&this.editorData.locations&&a.concat(this.editorData.locations),e.locations?this.editorData={locations:a}:(this.editorData=e.editorData,this.editorData.locations=a);const o={};for(const c in r)o[c]=r[c].uniqueId;this.editorData.map=o}fe.ParseAlphaMode(e,this),i||(this._mode=e.mode??$i.Material)}loadFromSerialization(e,t="",i=!1){$e.ParseProperties(e,this,this.getScene(),t),this.parseSerializedObject(e,t,i)}clone(e,t=!1){const i=this.serialize(),s=$e.Clone(()=>new Ht(e,this.getScene(),this.options),this);return s.id=e,s.name=e,s.parseSerializedObject(i),s._buildId=this._buildId,s.build(!1,!t),s}whenTexturesReadyAsync(){const e=[],t=this.getActiveTextures();for(const i of t){const s=i.getInternalTexture();s&&!s.isReady&&e.push(new Promise((r,a)=>{s.onLoadedObservable.addOnce(()=>{r()}),s.onErrorObservable.addOnce(o=>{a(o)})}))}return Promise.all(e)}static Parse(e,t,i="",s=0){const r=$e.Parse(()=>new Ht(e.name,t,{shaderLanguage:s}),e,t,i);return r.parseSerializedObject(e,i),r.build(),r}static async ParseFromFileAsync(e,t,i,s="",r=!1,a,o,c){const u=a??new Ht(e,i,c),d=await i._loadFileAsync(t),f=JSON.parse(d);return u.parseSerializedObject(f,s,void 0,o),r||u.build(),u}static ParseFromSnippetAsync(e,t=Ke.LastCreatedScene,i="",s,r=!1,a=!1,o,c){return e==="_BLANK"?Promise.resolve(Ht.CreateDefault("blank",t)):new Promise((u,d)=>{const f=new Ai;f.addEventListener("readystatechange",()=>{if(f.readyState==4)if(f.status==200){const g=JSON.parse(JSON.parse(f.responseText).jsonPayload),m=JSON.parse(g.nodeMaterial);s||(s=$e.Parse(()=>new Ht(e,t,c),m,t,i),s.uniqueId=t.getUniqueId()),s.parseSerializedObject(m,void 0,void 0,o),s.snippetId=e,s.sideOrientation=null;try{r||s.build()}catch(b){d(b)}a?s.whenTexturesReadyAsync().then(()=>{u(s)}).catch(b=>{d(b)}):u(s)}else d("Unable to load the snippet "+e)}),f.open("GET",this.SnippetUrl+"/"+e.replace(/#/g,"/")),f.send()})}static CreateDefault(e,t){const i=new Ht(e,t);return i.setToDefault(),i.build(),i}}Ht._BuildIdGenerator=0;Ht.EditorURL=`${pe._DefaultCdnUrl}/v${Ce.Version}/nodeEditor/babylon.nodeEditor.js`;Ht.SnippetUrl="https://snippet.babylonjs.com";Ht.IgnoreTexturesAtLoadTime=!1;Ht.AllowSerializationOfRenderTargetTextures=!1;Ht.DefaultShaderLanguage=0;Ht.UseNativeShaderLanguageOfEngine=!1;N([H()],Ht.prototype,"ignoreAlpha",void 0);N([H()],Ht.prototype,"maxSimultaneousLights",void 0);N([H("mode")],Ht.prototype,"_mode",void 0);N([H("comment")],Ht.prototype,"comment",void 0);N([H()],Ht.prototype,"forceAlphaBlending",void 0);Tt("BABYLON.NodeMaterial",Ht);As.prototype._projectOnTrianglesToRef=function(n,e,t,i,s,r){const a=te.Vector3[0],o=te.Vector3[1];let c=1/0;for(let u=this.indexStart;u<this.indexStart+this.indexCount-(3-i);u+=i){const d=t[u],f=t[u+1],g=t[u+2];if(s&&g===4294967295){u+=2;continue}const m=e[d],b=e[f],x=e[g];if(!m||!b||!x)continue;const v=T.ProjectOnTriangleToRef(n,m,b,x,o);v<c&&(a.copyFrom(o),c=v)}return r.copyFrom(a),c};As.prototype._projectOnUnIndexedTrianglesToRef=function(n,e,t,i){const s=te.Vector3[0],r=te.Vector3[1];let a=1/0;for(let o=this.verticesStart;o<this.verticesStart+this.verticesCount;o+=3){const c=e[o],u=e[o+1],d=e[o+2],f=T.ProjectOnTriangleToRef(n,c,u,d,r);f<a&&(s.copyFrom(r),a=f)}return i.copyFrom(s),a};As.prototype.projectToRef=function(n,e,t,i){const s=this.getMaterial();if(!s)return-1;let r=3,a=!1;switch(s.fillMode){case 3:case 5:case 6:case 8:return-1;case 7:r=1,a=!0;break}return s.fillMode===4?-1:!t.length&&this._mesh._unIndexed?this._projectOnUnIndexedTrianglesToRef(n,e,t,i):this._projectOnTrianglesToRef(n,e,t,r,a,i)};var ks;(function(n){n[n.DEHYDRATED=0]="DEHYDRATED",n[n.HOVER=1]="HOVER",n[n.TOUCH=2]="TOUCH"})(ks||(ks={}));var fA;(function(n){n[n.DISABLED=0]="DISABLED",n[n.CENTERED_ON_CONTROLLER=1]="CENTERED_ON_CONTROLLER",n[n.CENTERED_IN_FRONT=2]="CENTERED_IN_FRONT"})(fA||(fA={}));const Hl=[new T,new T,new T,new T];class na extends su{constructor(e,t){super(e),this._options=t,this._tmpRay=new ht(new T,new T),this._attachController=i=>{if(this._controllers[i.uniqueId])return;const{touchCollisionMesh:s,touchCollisionMeshFunction:r,hydrateCollisionMeshFunction:a}=this._generateNewTouchPointMesh(),o=this._generateVisualCue();switch(this._controllers[i.uniqueId]={xrController:i,meshUnderPointer:null,nearInteractionTargetMesh:null,pick:null,stalePick:null,touchCollisionMesh:s,touchCollisionMeshFunction:r,hydrateCollisionMeshFunction:a,currentAnimationState:ks.DEHYDRATED,grabRay:new ht(new T,new T),hoverInteraction:!1,nearInteraction:!1,grabInteraction:!1,downTriggered:!1,id:na._IdCounter++,pickedPointVisualCue:o},this._controllers[i.uniqueId]._worldScaleObserver=this._controllers[i.uniqueId]._worldScaleObserver||this._xrSessionManager.onWorldScaleFactorChangedObservable.add(c=>{if(c.newScaleFactor!==c.previousScaleFactor){this._controllers[i.uniqueId].touchCollisionMesh.dispose(),this._controllers[i.uniqueId].pickedPointVisualCue.dispose();const{touchCollisionMesh:u,touchCollisionMeshFunction:d,hydrateCollisionMeshFunction:f}=this._generateNewTouchPointMesh();this._controllers[i.uniqueId].touchCollisionMesh=u,this._controllers[i.uniqueId].touchCollisionMeshFunction=d,this._controllers[i.uniqueId].hydrateCollisionMeshFunction=f,this._controllers[i.uniqueId].pickedPointVisualCue=this._generateVisualCue()}}),this._attachedController?!this._options.enableNearInteractionOnAllControllers&&this._options.preferredHandedness&&i.inputSource.handedness===this._options.preferredHandedness&&(this._attachedController=i.uniqueId):this._options.enableNearInteractionOnAllControllers||(this._attachedController=i.uniqueId),i.inputSource.targetRayMode){case"tracked-pointer":return this._attachNearInteractionMode(i);case"gaze":return null;case"screen":return null}},this._controllers={},this._farInteractionFeature=null,this.selectionMeshDefaultColor=new Ne(.8,.8,.8),this.selectionMeshPickedColor=new Ne(.3,.3,1),this.alwaysHideSelectionMesh=!1,this._hoverRadius=.1,this._pickRadius=.02,this._controllerPickRadius=.03,this._nearGrabLengthScale=5,this._scene=this._xrSessionManager.scene,this._options.nearInteractionControllerMode===void 0&&(this._options.nearInteractionControllerMode=2),this._options.farInteractionFeature&&(this._farInteractionFeature=this._options.farInteractionFeature)}attach(){if(!super.attach())return!1;for(const e of this._options.xrInput.controllers)this._attachController(e);return this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable,this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable,e=>{this._detachController(e.uniqueId)}),this._scene.constantlyUpdateMeshUnderPointer=!0,!0}detach(){if(!super.detach())return!1;const e=Object.keys(this._controllers);for(const t of e)this._detachController(t);return!0}getMeshUnderPointer(e){return this._controllers[e]?this._controllers[e].meshUnderPointer:null}getXRControllerByPointerId(e){const t=Object.keys(this._controllers);for(let i=0;i<t.length;++i)if(this._controllers[t[i]].id===e)return this._controllers[t[i]].xrController||null;return null}setFarInteractionFeature(e){this._farInteractionFeature=e}_nearPickPredicate(e){return e.isEnabled()&&e.isVisible&&e.isPickable&&e.isNearPickable}_nearGrabPredicate(e){return e.isEnabled()&&e.isVisible&&e.isPickable&&e.isNearGrabbable}_nearInteractionPredicate(e){return e.isEnabled()&&e.isVisible&&e.isPickable&&(e.isNearPickable||e.isNearGrabbable)}_controllerAvailablePredicate(e,t){let i=e;for(;i;){if(i.reservedDataStore&&i.reservedDataStore.nearInteraction&&i.reservedDataStore.nearInteraction.excludedControllerId===t)return!1;i=i.parent}return!0}_handleTransitionAnimation(e,t){if(!(e.currentAnimationState===t||this._options.nearInteractionControllerMode!==2||e.xrController?.inputSource.hand)){if(t>e.currentAnimationState)switch(e.currentAnimationState){case ks.DEHYDRATED:if(e.hydrateCollisionMeshFunction(!0),t===ks.HOVER)break;case ks.HOVER:if(e.touchCollisionMeshFunction(!0),t===ks.TOUCH)break}else switch(e.currentAnimationState){case ks.TOUCH:if(e.touchCollisionMeshFunction(!1),t===ks.HOVER)break;case ks.HOVER:if(e.hydrateCollisionMeshFunction(!1),t===ks.DEHYDRATED)break}e.currentAnimationState=t}}_processTouchPoint(e,t,i){const s=this._controllers[e];s.grabRay.origin.copyFrom(t),i.toEulerAnglesToRef(te.Vector3[0]),s.grabRay.direction.copyFrom(te.Vector3[0]),this._options.nearInteractionControllerMode===2&&!s.xrController?.inputSource.hand&&(s.xrController.getWorldPointerRayToRef(this._tmpRay),s.grabRay.origin.addInPlace(this._tmpRay.direction.scale(.05))),s.grabRay.length=this._nearGrabLengthScale*this._hoverRadius*this._xrSessionManager.worldScalingFactor,s.touchCollisionMesh.position.copyFrom(s.grabRay.origin).scaleInPlace(this._xrSessionManager.worldScalingFactor)}_onXRFrame(e){const t=Object.keys(this._controllers);for(const i of t){const s=this._controllers[i],r=s.xrController?.inputSource.hand;if(!this._options.enableNearInteractionOnAllControllers&&i!==this._attachedController||!s.xrController||!r&&(!this._options.nearInteractionControllerMode||!s.xrController.inputSource.gamepad)){s.pick=null;return}if(s.hoverInteraction=!1,s.nearInteraction=!1,s.xrController){if(r){const u=r.get("index-finger-tip");if(u){const d=e.getJointPose(u,this._xrSessionManager.referenceSpace);if(d&&d.transform){const f=this._scene.useRightHandedSystem?1:-1;te.Vector3[0].set(d.transform.position.x,d.transform.position.y,d.transform.position.z*f),te.Quaternion[0].set(d.transform.orientation.x,d.transform.orientation.y,d.transform.orientation.z*f,d.transform.orientation.w*f),this._processTouchPoint(i,te.Vector3[0],te.Quaternion[0])}}}else if(s.xrController.inputSource.gamepad&&this._options.nearInteractionControllerMode!==0){let u=s.xrController.pointer;s.xrController.grip&&this._options.nearInteractionControllerMode===1&&(u=s.xrController.grip),this._processTouchPoint(i,u.position,u.rotationQuaternion)}}else return;const a=(u,d)=>{let f=null;
3386return!d||!d.hit?f=u:!u||!u.hit||d.distance<u.distance?f=d:f=u,f},o=u=>{let d=new as,f=!1;const g=u&&u.pickedPoint&&u.hit;return u?.pickedPoint&&(f=u.pickedPoint.x===0&&u.pickedPoint.y===0&&u.pickedPoint.z===0),g&&!f&&(d=u),d};if(!s.grabInteraction){let u=null,d=null;this._options.useUtilityLayer&&this._utilityLayerScene&&(d=this._pickWithSphere(s,this._hoverRadius*this._xrSessionManager.worldScalingFactor,this._utilityLayerScene,m=>this._nearInteractionPredicate(m)));const f=this._pickWithSphere(s,this._hoverRadius*this._xrSessionManager.worldScalingFactor,this._scene,m=>this._nearInteractionPredicate(m)),g=a(f,d);if(g&&g.hit&&(u=o(g),u.hit&&(s.hoverInteraction=!0)),s.hoverInteraction){let m=null;const b=(r?this._pickRadius:this._controllerPickRadius)*this._xrSessionManager.worldScalingFactor;this._options.useUtilityLayer&&this._utilityLayerScene&&(m=this._pickWithSphere(s,b,this._utilityLayerScene,A=>this._nearPickPredicate(A)));const x=this._pickWithSphere(s,b,this._scene,A=>this._nearPickPredicate(A)),v=a(x,m),E=o(v);E.hit&&(u=E,s.nearInteraction=!0)}s.stalePick=s.pick,s.pick=u,s.pick&&s.pick.pickedPoint&&s.pick.hit?(s.meshUnderPointer=s.pick.pickedMesh,s.pickedPointVisualCue.position.copyFrom(s.pick.pickedPoint),s.pickedPointVisualCue.isVisible=!this.alwaysHideSelectionMesh,this._farInteractionFeature&&this._farInteractionFeature.attached&&this._farInteractionFeature._setPointerSelectionDisabledByPointerId(s.id,!0)):(s.meshUnderPointer=null,s.pickedPointVisualCue.isVisible=!1,this._farInteractionFeature&&this._farInteractionFeature.attached&&this._farInteractionFeature._setPointerSelectionDisabledByPointerId(s.id,!1))}let c=ks.DEHYDRATED;s.grabInteraction||s.nearInteraction?c=ks.TOUCH:s.hoverInteraction&&(c=ks.HOVER),this._handleTransitionAnimation(s,c)}}get _utilityLayerScene(){return this._options.customUtilityLayerScene||ui.DefaultUtilityLayer.utilityLayerScene}_generateVisualCue(){const e=this._options.useUtilityLayer?this._options.customUtilityLayerScene||ui.DefaultUtilityLayer.utilityLayerScene:this._scene,t=Uh("nearInteraction",{diameter:.0035*3*this._xrSessionManager.worldScalingFactor},e);t.bakeCurrentTransformIntoVertices(),t.isPickable=!1,t.isVisible=!1,t.rotationQuaternion=Se.Identity();const i=new Ae("targetMat",e);return i.specularColor=Ne.Black(),i.emissiveColor=this.selectionMeshDefaultColor,i.backFaceCulling=!1,t.material=i,t}_isControllerReadyForNearInteraction(e){return this._farInteractionFeature?this._farInteractionFeature._getPointerSelectionDisabledByPointerId(e):!0}_attachNearInteractionMode(e){const t=this._controllers[e.uniqueId],i={pointerId:t.id,pointerType:"xr-near"};t.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add(()=>{!this._options.enableNearInteractionOnAllControllers&&e.uniqueId!==this._attachedController||!t.xrController||!t.xrController.inputSource.hand&&(!this._options.nearInteractionControllerMode||!t.xrController.inputSource.gamepad)||(t.pick&&(t.pick.ray=t.grabRay),t.pick&&this._isControllerReadyForNearInteraction(t.id)&&this._scene.simulatePointerMove(t.pick,i),t.nearInteraction&&t.pick&&t.pick.hit?t.nearInteractionTargetMesh||(this._scene.simulatePointerDown(t.pick,i),t.nearInteractionTargetMesh=t.meshUnderPointer,t.downTriggered=!0):t.nearInteractionTargetMesh&&t.stalePick&&(this._scene.simulatePointerUp(t.stalePick,i),t.downTriggered=!1,t.nearInteractionTargetMesh=null))});const s=r=>{this._options.enableNearInteractionOnAllControllers||e.uniqueId===this._attachedController&&this._isControllerReadyForNearInteraction(t.id)?(t.pick&&(t.pick.ray=t.grabRay),r&&t.pick&&t.meshUnderPointer&&this._nearGrabPredicate(t.meshUnderPointer)?(t.grabInteraction=!0,t.pickedPointVisualCue.isVisible=!1,this._scene.simulatePointerDown(t.pick,i),t.downTriggered=!0):!r&&t.pick&&t.grabInteraction&&(this._scene.simulatePointerUp(t.pick,i),t.downTriggered=!1,t.grabInteraction=!1,t.pickedPointVisualCue.isVisible=!this.alwaysHideSelectionMesh)):r&&!this._options.enableNearInteractionOnAllControllers&&!this._options.disableSwitchOnClick&&(this._attachedController=e.uniqueId)};if(e.inputSource.gamepad){const r=a=>{t.squeezeComponent=a.getComponent("grasp"),t.squeezeComponent?t.onSqueezeButtonChangedObserver=t.squeezeComponent.onButtonStateChangedObservable.add(o=>{if(o.changes.pressed){const c=o.changes.pressed.current;s(c)}}):(t.selectionComponent=a.getMainComponent(),t.onButtonChangedObserver=t.selectionComponent.onButtonStateChangedObservable.add(o=>{if(o.changes.pressed){const c=o.changes.pressed.current;s(c)}}))};e.motionController?r(e.motionController):e.onMotionControllerInitObservable.add(r)}else{const r=o=>{t.xrController&&o.inputSource===t.xrController.inputSource&&t.pick&&this._isControllerReadyForNearInteraction(t.id)&&t.meshUnderPointer&&this._nearGrabPredicate(t.meshUnderPointer)&&(t.grabInteraction=!0,t.pickedPointVisualCue.isVisible=!1,this._scene.simulatePointerDown(t.pick,i),t.downTriggered=!0)},a=o=>{t.xrController&&o.inputSource===t.xrController.inputSource&&t.pick&&this._isControllerReadyForNearInteraction(t.id)&&(this._scene.simulatePointerUp(t.pick,i),t.grabInteraction=!1,t.pickedPointVisualCue.isVisible=!this.alwaysHideSelectionMesh,t.downTriggered=!1)};t.eventListeners={selectend:a,selectstart:r},this._xrSessionManager.session.addEventListener("selectstart",r),this._xrSessionManager.session.addEventListener("selectend",a)}}_detachController(e){const t=this._controllers[e];if(t){if(t.squeezeComponent&&t.onSqueezeButtonChangedObserver&&t.squeezeComponent.onButtonStateChangedObservable.remove(t.onSqueezeButtonChangedObserver),t.selectionComponent&&t.onButtonChangedObserver&&t.selectionComponent.onButtonStateChangedObservable.remove(t.onButtonChangedObserver),t.onFrameObserver&&this._xrSessionManager.onXRFrameObservable.remove(t.onFrameObserver),t.eventListeners){const i=Object.keys(t.eventListeners);for(const s of i){const r=t.eventListeners&&t.eventListeners[s];r&&this._xrSessionManager.session.removeEventListener(s,r)}}if(t.touchCollisionMesh.dispose(),t.pickedPointVisualCue.dispose(),this._xrSessionManager.runInXRFrame(()=>{if(!t.downTriggered)return;const i={pointerId:t.id,pointerType:"xr-near"};this._scene.simulatePointerUp(new as,i)}),t._worldScaleObserver&&this._xrSessionManager.onWorldScaleFactorChangedObservable.remove(t._worldScaleObserver),delete this._controllers[e],this._attachedController===e){const i=Object.keys(this._controllers);i.length?this._attachedController=i[0]:this._attachedController=""}}}_generateNewTouchPointMesh(){const e=this._xrSessionManager.worldScalingFactor,t=this._options.useUtilityLayer?this._options.customUtilityLayerScene||ui.DefaultUtilityLayer.utilityLayerScene:this._scene,i=Uh("PickSphere",{diameter:1*e},t);if(i.isVisible=!1,this._options.motionControllerOrbMaterial)i.material=this._options.motionControllerOrbMaterial;else{let F;this._options.motionControllerTouchMaterialSnippetUrl?F=Ht.ParseFromFileAsync("motionControllerTouchMaterial",this._options.motionControllerTouchMaterialSnippetUrl,t):F=Ht.ParseFromSnippetAsync("8RUNKL#3",t),F.then(U=>{i.material=U}).catch(U=>{oe.Warn(`Error creating touch material in WebXRNearInteraction: ${U}`)})}const s=new kV;s.setEasingMode(Rs.EASINGMODE_EASEINOUT);const r=new T(this._controllerPickRadius,this._controllerPickRadius,this._controllerPickRadius).scaleInPlace(e),a=this._controllerPickRadius*(4/3),o=new T(a,a,a).scaleInPlace(e),c=this._controllerPickRadius*(7/6),u=new T(c,c,c).scaleInPlace(e),d=this._controllerPickRadius*(4/5),f=new T(d,d,d).scaleInPlace(e),g=this._controllerPickRadius*(3/2),m=new T(g,g,g).scaleInPlace(e),b=[{frame:0,value:r},{frame:10,value:m},{frame:18,value:o}],x=[{frame:0,value:o},{frame:10,value:f},{frame:18,value:r}],v=[{frame:0,value:T.ZeroReadOnly},{frame:12,value:u},{frame:15,value:r}],E=[{frame:0,value:r},{frame:10,value:T.ZeroReadOnly},{frame:15,value:T.ZeroReadOnly}],A=new xe("touch","scaling",60,xe.ANIMATIONTYPE_VECTOR3,xe.ANIMATIONLOOPMODE_CONSTANT),D=new xe("release","scaling",60,xe.ANIMATIONTYPE_VECTOR3,xe.ANIMATIONLOOPMODE_CONSTANT),I=new xe("hydrate","scaling",60,xe.ANIMATIONTYPE_VECTOR3,xe.ANIMATIONLOOPMODE_CONSTANT),R=new xe("dehydrate","scaling",60,xe.ANIMATIONTYPE_VECTOR3,xe.ANIMATIONLOOPMODE_CONSTANT);
3386return A.setEasingFunction(s),D.setEasingFunction(s),I.setEasingFunction(s),R.setEasingFunction(s),A.setKeys(b),D.setKeys(x),I.setKeys(v),R.setKeys(E),{touchCollisionMesh:i,touchCollisionMeshFunction:F=>{const U=F?A:D;t.beginDirectAnimation(i,[U],0,18,!1,1)},hydrateCollisionMeshFunction:F=>{const U=F?I:R;F&&(i.isVisible=!0),t.beginDirectAnimation(i,[U],0,15,!1,1,()=>{F||(i.isVisible=!1)})}}}_pickWithSphere(e,t,i,s){const r=new as;if(r.distance=1/0,e.touchCollisionMesh&&e.xrController){const a=e.touchCollisionMesh.position,o=sa.CreateFromCenterAndRadius(a,t);for(let c=0;c<i.meshes.length;c++){const u=i.meshes[c];if(!s(u)||!this._controllerAvailablePredicate(u,e.xrController.uniqueId))continue;const d=na.PickMeshWithSphere(u,o);d&&d.hit&&d.distance<r.distance&&(r.hit=d.hit,r.pickedMesh=u,r.pickedPoint=d.pickedPoint,r.aimTransform=e.xrController.pointer,r.gripTransform=e.xrController.grip||null,r.originMesh=e.touchCollisionMesh,r.distance=d.distance,r.bu=d.bu,r.bv=d.bv,r.faceId=d.faceId,r.subMeshId=d.subMeshId)}}return r}static PickMeshWithSphere(e,t,i=!1){const s=e.subMeshes,r=new as,a=e.getBoundingInfo();if(!e._generatePointsArray()||!e.subMeshes||!a||!i&&!sa.Intersects(a.boundingSphere,t))return r;const o=Hl[0],c=Hl[1];Hl[2].setAll(0),Hl[3].setAll(0);const u=new ht(Hl[2],Hl[3],1);let d=1/0,f,g,m,b;const x=te.Vector3[2],v=te.Matrix[0];v.copyFrom(e.getWorldMatrix()),v.invert(),T.TransformCoordinatesToRef(t.center,v,x);for(let E=0;E<s.length;E++)s[E].projectToRef(x,e._positions,e.getIndices(),c),T.TransformCoordinatesToRef(c,e.getWorldMatrix(),c),f=T.Distance(c,t.center),m=T.DistanceSquared(c,e.getAbsolutePosition()),g=T.DistanceSquared(t.center,e.getAbsolutePosition()),g!==-1&&m!==-1&&m>g&&(f=0,c.copyFrom(t.center)),f!==-1&&f<d&&(d=f,ht.CreateFromToToRef(t.center,c,u),u.length=d*2,b=u.intersectsMesh(e),o.copyFrom(c));return d<t.radius&&(r.hit=!0,r.distance=d,r.pickedMesh=e,r.pickedPoint=o.clone(),b&&b.bu!==null&&b.bv!==null&&(r.faceId=b.faceId,r.subMeshId=b.subMeshId,r.bu=b.bu,r.bv=b.bv)),r}}na._IdCounter=200;na.Name=Yt.NEAR_INTERACTION;na.Version=1;Dr.AddWebXRFeature(na.Name,(n,e)=>()=>new na(n,e),na.Version,!0);class or{constructor(e,t){this.type=e,this.jointData=t,t.nativeParams=t.nativeParams||{}}get physicsJoint(){return this._physicsJoint}set physicsJoint(e){this._physicsJoint=e}set physicsPlugin(e){this._physicsPlugin=e}executeNativeFunction(e){e(this._physicsPlugin.world,this._physicsJoint)}}or.DistanceJoint=0;or.HingeJoint=1;or.BallAndSocketJoint=2;or.WheelJoint=3;or.SliderJoint=4;or.PrismaticJoint=5;or.UniversalJoint=6;or.Hinge2Joint=or.WheelJoint;or.PointToPointJoint=8;or.SpringJoint=9;or.LockJoint=10;Z._PhysicsImpostorParser=function(n,e,t){return new Ut(e,t.physicsImpostor,{mass:t.physicsMass,friction:t.physicsFriction,restitution:t.physicsRestitution},n)};class Ut{get isDisposed(){return this._isDisposed}get mass(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyMass(this):0}set mass(e){this.setMass(e)}get friction(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyFriction(this):0}set friction(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyFriction(this,e)}get restitution(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this):0}set restitution(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this,e)}get pressure(){if(!this._physicsEngine)return 0;const e=this._physicsEngine.getPhysicsPlugin();return e.setBodyPressure?e.getBodyPressure(this):0}set pressure(e){if(!this._physicsEngine)return;const t=this._physicsEngine.getPhysicsPlugin();t.setBodyPressure&&t.setBodyPressure(this,e)}get stiffness(){if(!this._physicsEngine)return 0;const e=this._physicsEngine.getPhysicsPlugin();return e.getBodyStiffness?e.getBodyStiffness(this):0}set stiffness(e){if(!this._physicsEngine)return;const t=this._physicsEngine.getPhysicsPlugin();t.setBodyStiffness&&t.setBodyStiffness(this,e)}get velocityIterations(){if(!this._physicsEngine)return 0;const e=this._physicsEngine.getPhysicsPlugin();return e.getBodyVelocityIterations?e.getBodyVelocityIterations(this):0}set velocityIterations(e){if(!this._physicsEngine)return;const t=this._physicsEngine.getPhysicsPlugin();t.setBodyVelocityIterations&&t.setBodyVelocityIterations(this,e)}get positionIterations(){if(!this._physicsEngine)return 0;const e=this._physicsEngine.getPhysicsPlugin();return e.getBodyPositionIterations?e.getBodyPositionIterations(this):0}set positionIterations(e){if(!this._physicsEngine)return;const t=this._physicsEngine.getPhysicsPlugin();t.setBodyPositionIterations&&t.setBodyPositionIterations(this,e)}constructor(e,t,i={mass:0},s){if(this.object=e,this.type=t,this._options=i,this._scene=s,this._pluginData={},this._bodyUpdateRequired=!1,this._onBeforePhysicsStepCallbacks=new Array,this._onAfterPhysicsStepCallbacks=new Array,this._onPhysicsCollideCallbacks=[],this._deltaPosition=T.Zero(),this._isDisposed=!1,this.soft=!1,this.segments=0,this._tmpQuat=new Se,this._tmpQuat2=new Se,this.beforeStep=()=>
3386{if(this._physicsEngine){this.object.translate(this._deltaPosition,-1),this._deltaRotationConjugated&&this.object.rotationQuaternion&&this.object.rotationQuaternion.multiplyToRef(this._deltaRotationConjugated,this.object.rotationQuaternion),this.object.computeWorldMatrix(!1),this.object.parent&&this.object.rotationQuaternion?(this.getParentsRotation(),this._tmpQuat.multiplyToRef(this.object.rotationQuaternion,this._tmpQuat)):this._tmpQuat.copyFrom(this.object.rotationQuaternion||new Se),this._options.disableBidirectionalTransformation||this.object.rotationQuaternion&&this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(this,this.object.getAbsolutePosition(),this._tmpQuat);for(const r of this._onBeforePhysicsStepCallbacks)r(this)}},this.afterStep=()=>{if(this._physicsEngine){for(const r of this._onAfterPhysicsStepCallbacks)r(this);this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(this),this.object.parent&&this.object.rotationQuaternion&&(this.getParentsRotation(),this._tmpQuat.conjugateInPlace(),this._tmpQuat.multiplyToRef(this.object.rotationQuaternion,this.object.rotationQuaternion)),this.object.setAbsolutePosition(this.object.position),this._deltaRotation?(this.object.rotationQuaternion&&this.object.rotationQuaternion.multiplyToRef(this._deltaRotation,this.object.rotationQuaternion),this._deltaPosition.applyRotationQuaternionToRef(this._deltaRotation,Ut._TmpVecs[0]),this.object.translate(Ut._TmpVecs[0],1)):this.object.translate(this._deltaPosition,1),this.object.computeWorldMatrix(!0)}},this.onCollideEvent=null,this.onCollide=r=>{if(!this._onPhysicsCollideCallbacks.length&&!this.onCollideEvent||!this._physicsEngine)return;const a=this._physicsEngine.getImpostorWithPhysicsBody(r.body);if(a){this.onCollideEvent&&this.onCollideEvent(this,a);const o=this._onPhysicsCollideCallbacks.filter(c=>c.otherImpostors.indexOf(a)!==-1);for(const c of o)c.callback(this,a,r.point,r.distance,r.impulse,r.normal)}},!this.object){oe.Error("No object was provided. A physics object is obligatory");return}this.object.parent&&i.mass!==0&&oe.Warn("A physics impostor has been created for an object which has a parent. Babylon physics currently works in local space so unexpected issues may occur."),!this._scene&&e.getScene&&(this._scene=e.getScene()),this._scene&&(this.t
3386ype>100&&(this.soft=!0),this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine?(this.object.rotationQuaternion||(this.object.rotation?this.object.rotationQuaternion=Se.RotationYawPitchRoll(this.object.rotation.y,this.object.rotation.x,this.object.rotation.z):this.object.rotationQuaternion=new Se),this._options.mass=i.mass===void 0?0:i.mass,this._options.friction=i.friction===void 0?.2:i.friction,this._options.restitution=i.restitution===void 0?.2:i.restitution,this.soft&&(this._options.mass=this._options.mass>0?this._options.mass:1,this._options.pressure=i.pressure===void 0?200:i.pressure,this._options.stiffness=i.stiffness===void 0?1:i.stiffness,this._options.velocityIterations=i.velocityIterations===void 0?20:i.velocityIterations,this._options.positionIterations=i.positionIterations===void 0?20:i.positionIterations,this._options.fixedPoints=i.fixedPoints===void 0?0:i.fixedPoints,this._options.margin=i.margin===void 0?0:i.margin,this._options.damping=i.damping===void 0?0:i.damping,this._options.path=i.path===void 0?null:i.path,this._options.shape=i.shape===void 0?null:i.shape),this._joints=[],!this.object.parent||this._options.ignoreParent?this._init():this.object.parent.physicsImpostor&&oe.Warn("You must affect impostors to children before affecting impostor to parent.")):oe.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))}_init(){this._physicsEngine&&(this._physicsEngine.removeImpostor(this),this.physicsBody=null,this._parent=this._parent||this._getPhysicsParent(),!this._isDisposed&&(!this.parent||this._options.ignoreParent)&&this._physicsEngine.addImpostor(this))}_getPhysicsParent(){return this.object.parent instanceof os?this.object.parent.physicsImpostor:null}isBodyInitRequired(){return this._bodyUpdateRequired||!this._physicsBody&&(!this._parent||!!this._options.ignoreParent)}setScalingUpdated(){this.forceUpdate()}forceUpdate(){this._init(),this.parent&&!this._options.ignoreParent&&this.parent.forceUpdate()}get physicsBody(){return this._parent&&!this._options.ignoreParent?this._parent.physicsBody:this._physicsBody}get parent(){return!this._options.ignoreParent&&this._parent?this._parent:null}set parent(e){this._parent=e}set physicsBody(e){this._physicsBody&&this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this),this._physicsBody=e,this.resetUpdateFlags()}resetUpdateFlags(){this._bodyUpdateRequired=!1}getObjectExtents(){if(this.object.getBoundingInfo){const e=this.object.rotationQuaternion,t=this.object.scaling.clone();this.object.rotationQuaternion=Ut.IDENTITY_QUATERNION;const i=this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0);i&&i.decompose(t,void 0,void 0);const r=this.object.getBoundingInfo().boundingBox.extendSize.scale(2).multiplyInPlace(t);return r.x=Math.abs(r.x),r.y=Math.abs(r.y),r.z=Math.abs(r.z),this.object.rotationQuaternion=e,this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0),r}else return Ut.DEFAULT_OBJECT_SIZE}getObjectCenter(){return this.object.getBoundingInfo?this.object.getBoundingInfo().boundingBox.centerWorld:this.object.position}getParam(e){return this._options[e]}setParam(e,t){this._options[e]=t,this._bodyUpdateRequired=!0}setMass(e){this.getParam("mass")!==e&&this.setParam("mass",e),this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyMass(this,e)}getLinearVelocity(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this):T.Zero()}setLinearVelocity(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this,e)}getAngularVelocity(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this):T.Zero()}setAngularVelocity(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this,e)}executeNativeFunction(e){this._physicsEngine&&e(this._physicsEngine.getPhysicsPlugin().world,this.physicsBody)}registerBeforePhysicsStep(e){this._onBeforePhysicsStepCallbacks.push(e)}unregisterBeforePhysicsStep(e){const t=this._onBeforePhysicsStepCallbacks.indexOf(e);t>-1?this._onBeforePhysicsStepCallbacks.splice(t,1):oe.Warn("Function to remove was not found")}registerAfterPhysicsStep(e){this._onAfterPhysicsStepCallbacks.push(e)}unregisterAfterPhysicsStep(e){const t=this._onAfterPhysicsStepCallbacks.indexOf(e);t>-1?this._onAfterPhysicsStepCallbacks.splice(t,1):oe.Warn("Function to remove was not found")}registerOnPhysicsCollide(e,t){const i=e instanceof Array?e:[e];this._onPhysicsCollideCallbacks.push({callback:t,otherImpostors:i})}unregisterOnPhysicsCollide(e,t){const i=e instanceof Array?e:[e];let s=-1;this._onPhysicsCollideCallbacks.some((a,o)=>
3386{if(a.callback===t&&a.otherImpostors.length===i.length){const c=a.otherImpostors.every(u=>i.indexOf(u)>-1);return c&&(s=o),c}return!1})?this._onPhysicsCollideCallbacks.splice(s,1):oe.Warn("Function to remove was not found")}getParentsRotation(){let e=this.object.parent;for(this._tmpQuat.copyFromFloats(0,0,0,1);e;)e.rotationQuaternion?this._tmpQuat2.copyFrom(e.rotationQuaternion):Se.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,e.rotation.z,this._tmpQuat2),this._tmpQuat.multiplyToRef(this._tmpQuat2,this._tmpQuat),e=e.parent;return this._tmpQuat}applyForce(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyForce(this,e,t),this}applyImpulse(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyImpulse(this,e,t),this}createJoint(e,t,i){const s=new or(t,i);return this.addJoint(e,s),this}addJoint(e,t){return this._joints.push({otherImpostor:e,joint:t}),this._physicsEngine&&this._physicsEngine.addJoint(this,e,t),this}addAnchor(e,t,i,s,r){if(!this._physicsEngine)return this;const a=this._physicsEngine.getPhysicsPlugin();return a.appendAnchor?(this._physicsEngine&&a.appendAnchor(this,e,t,i,s,r),this):this}addHook(e,t,i,s){if(!this._physicsEngine)return this;const r=this._physicsEngine.getPhysicsPlugin();return r.appendAnchor?(this._physicsEngine&&r.appendHook(this,e,t,i,s),this):this}sleep(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().sleepBody(this),this}wakeUp(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().wakeUpBody(this),this}clone(e){return e?new Ut(e,this.type,this._options,this._scene):null}dispose(){if(this._physicsEngine){for(const e of this._joints)this._physicsEngine&&this._physicsEngine.removeJoint(this,e.otherImpostor,e.joint);this._physicsEngine.removeImpostor(this),this.parent&&this.parent.forceUpdate(),this._isDisposed=!0}}setDeltaPosition(e){this._deltaPosition.copyFrom(e)}setDeltaRotation(e){this._deltaRotation||(this._deltaRotation=new Se),this._deltaRotation.copyFrom(e),this._deltaRotationConjugated=this._deltaRotation.conjugate()}getBoxSizeToRef(e){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this,e),this}getRadius(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getRadius(this):0}syncBoneWithImpostor(e,t,i,s,r){const a=Ut._TmpVecs[0],o=this.object;if(o.rotationQuaternion)if(r){const c=Ut._TmpQuat;o.rotationQuaternion.multiplyToRef(r,c),e.setRotationQuaternion(c,1,t)}else e.setRotationQuaternion(o.rotationQuaternion,1,t);a.x=0,a.y=0,a.z=0,i&&(a.x=i.x,a.y=i.y,a.z=i.z,e.getDirectionToRef(a,t,a),s==null&&(s=i.length()),a.x*=s,a.y*=s,a.z*=s),e.getParent()?(a.addInPlace(o.getAbsolutePosition()),e.setAbsolutePosition(a,t)):(t.setAbsolutePosition(o.getAbsolutePosition()),t.position.x-=a.x,t.position.y-=a.y,t.position.z-=a.z)}syncImpostorWithBone(e,t,i,s,r,a){const o=this.object;if(o.rotationQuaternion)if(r){const d=Ut._TmpQuat;e.getRotationQuaternionToRef(1,t,d),d.multiplyToRef(r,o.rotationQuaternion)}else e.getRotationQuaternionToRef(1,t,o.rotationQuaternion);const c=Ut._TmpVecs[0],u=Ut._TmpVecs[1];a||(a=Ut._TmpVecs[2],a.x=0,a.y=1,a.z=0),e.getDirectionToRef(a,t,u),e.getAbsolutePositionToRef(t,c),s==null&&i&&(s=i.length()),s!=null&&(c.x+=u.x*s,c.y+=u.y*s,c.z+=u.z*s),o.setAbsolutePosition(c)}}Ut.DEFAULT_OBJECT_SIZE=new T(1,1,1);Ut.IDENTITY_QUATERNION=Se.Identity();Ut._TmpVecs=Xr(3,T.Zero);Ut._TmpQuat=Se.Identity();Ut.NoImpostor=0;Ut.SphereImpostor=1;Ut.BoxImpostor=2;Ut.PlaneImpostor=3;Ut.MeshImpostor=4;Ut.CapsuleImpostor=6;Ut.CylinderImpostor=7;Ut.ParticleImpostor=8;Ut.HeightmapImpostor=9;Ut.ConvexHullImpostor=10;Ut.CustomImpostor=100;Ut.RopeImpostor=101;Ut.ClothImpostor=102;Ut.SoftbodyImpostor=103;var pA;(function(n){n.WRIST="wrist",n.THUMB="thumb",n.INDEX="index",n.MIDDLE="middle",n.RING="ring",n.LITTLE="little"})(pA||(pA={}));var Sh;(function(n){n.WRIST="wrist",n.THUMB_METACARPAL="thumb-metacarpal",n.THUMB_PHALANX_PROXIMAL="thumb-phalanx-proximal",n.THUMB_PHALANX_DISTAL="thumb-phalanx-distal",n.THUMB_TIP="thumb-tip",n.INDEX_FINGER_METACARPAL="index-finger-metacarpal",n.INDEX_FINGER_PHALANX_PROXIMAL="index-finger-phalanx-proximal",n.INDEX_FINGER_PHALANX_INTERMEDIATE="index-finger-phalanx-intermediate",n.INDEX_FINGER_PHALANX_DISTAL="index-finger-phalanx-distal",n.INDEX_FINGER_TIP="index-finger-tip",n.MIDDLE_FINGER_METACARPAL="middle-finger-metacarpal",n.MIDDLE_FINGER_PHALANX_PROXIMAL="middle-finger-phalanx-proximal",n.MIDDLE_FINGER_PHALANX_INTERMEDIATE="middle-finger-phalanx-intermediate",n.MIDDLE_FINGER_PHALANX_DISTAL="middle-finger-phalanx-distal",n.MIDDLE_FINGER_TIP="middle-finger-tip",n.RING_FINGER_METACARPAL="ring-finger-metacarpal",n.RING_FINGER_PHALANX_PROXIMAL="ring-finger-phalanx-proximal",n.RING_FINGER_PHALANX_INTERMEDIATE="ring-finger-phalanx-intermediate",n.RING_FINGER_PHALANX_DISTAL="ring-finger-phalanx-distal",n.RING_FINGER_TIP="ring-finger-tip",n.PINKY_FINGER_METACARPAL="pinky-finger-metacarpal",n.PINKY_FINGER_PHALANX_PROXIMAL="pinky-finger-phalanx-proximal",n.PINKY_FINGER_PHALANX_INTERMEDIATE="pinky-finger-phalanx-intermediate",n.PINKY_FINGER_PHALANX_DISTAL="pinky-finger-phalanx-distal",n.PINKY_FINGER_TIP="pinky-finger-tip"})(Sh||(Sh={}));const Er=["wrist","thumb-metacarpal","thumb-phalanx-proximal","thumb-phalanx-distal","thumb-tip","index-finger-metacarpal","index-finger-phalanx-proximal","index-finger-phalanx-intermediate","index-finger-phalanx-distal","index-finger-tip","middle-finger-metacarpal","middle-finger-phalanx-proximal","middle-finger-phalanx-intermediate","middle-finger-phalanx-distal","middle-finger-tip","ring-finger-metacarpal","ring-finger-phalanx-proximal","ring-finger-phalanx-intermediate","ring-finger-phalanx-distal","ring-finger-tip","pinky-finger-metacarpal","pinky-finger-phalanx-proximal","pinky-finger-phalanx-intermediate","pinky-finger-phalanx-distal","pinky-finger-tip"],I4={wrist:["wrist"],thumb:["thumb-metacarpal","thumb-phalanx-proximal","thumb-phalanx-distal","thumb-tip"],index:["index-finger-metacarpal","index-finger-phalanx-proximal","index-finger-phalanx-intermediate","index-finger-phalanx-distal","index-finger-tip"],middle:["middle-finger-metacarpal","middle-finger-phalanx-proximal","middle-finger-phalanx-intermediate","middle-finger-phalanx-distal","middle-finger-tip"],ring:["ring-finger-metacarpal","ring-finger-phalanx-proximal","ring-finger-phalanx-intermediate","ring-finger-phalanx-distal","ring-finger-tip"],little:["pinky-finger-metacarpal","pinky-finger-phalanx-proximal","pinky-finger-phalanx-intermediate","pinky-finger-phalanx-distal","pinky-finger-tip"]};class P4{get handMesh(){return this._handMesh}getHandPartMeshes(e){return I4[e].map(t=>this._jointMeshes[Er.indexOf(t)])}getJointMesh(e){return this._jointMeshes[Er.indexOf(e)]}constructor(e,t,i,s,r=!1,a=!1,o=1){this.xrController=e,this._jointMeshes=t,this._handMesh=i,this.rigMapping=s,this._leftHandedMeshes=r,this._jointsInvisible=a,this._jointScaleFactor=o,this.onHandMeshSetObservable=new le,this._jointTransforms=new Array(Er.length),this._jointTransformMatrices=new Float32Array(Er.length*16),this._tempJointMatrix=new W,this._jointRadii=new Float32Array(Er.length),this._handMeshRoot=null,this._scene=t[0].getScene();for(let c=0;c<this._jointTransforms.length;c++)this._jointTransforms[c]=new qe(Er[c],this._scene),this._jointTransforms[c].rotationQuaternion=new Se,t[c].rotationQuaternion?t[c].rotationQuaternion=new Se:t[c].rotationQuaternion?.set(0,0,0,1);i&&this.setHandMesh(i,s),this.xrController.motionController&&this.xrController.motionController.rootMesh&&this.xrController.motionController.rootMesh.dispose(!1,!0),this.xrController.onMotionControllerInitObservable.add(c=>{c._doNotLoadControllerMesh=!0})}setHandMesh(e,t,i){for(this._handMesh=e,this._handMeshRoot=this._handMesh;this._handMeshRoot.parent;)this._handMeshRoot=this._handMeshRoot.parent;e.alwaysSelectAsActiveMesh=!0;const s=e.getChildMeshes();for(const r of s)r.alwaysSelectAsActiveMesh=!0;if(this._handMesh.skeleton){const r=this._handMesh.skeleton;for(let a=0;a<Er.length;a++){const o=Er[a],c=r.getBoneIndexByName(t?t[o]:o);c!==-1&&r.bones[c].linkTransformNode(this._jointTransforms[a])}}this.onHandMeshSetObservable.notifyObservers(this)}updateFromXRFrame(e,t,i){const s=this.xrController.inputSource.hand;if(!s)return;const r=s,a=Er.map(c=>r[c]||s.get(c));let o=!1;
3386if(e.fillPoses&&e.fillJointRadii)o=e.fillPoses(a,t,this._jointTransformMatrices)&&e.fillJointRadii(a,this._jointRadii);else if(e.getJointPose){o=!0;for(let c=0;c<a.length;c++){const u=e.getJointPose(a[c],t);if(u)this._jointTransformMatrices.set(u.transform.matrix,c*16),this._jointRadii[c]=u.radius||.008;else{o=!1;break}}}if(o){for(let c=0;c<Er.length;c++){const u=this._jointTransforms[c];W.FromArrayToRef(this._jointTransformMatrices,c*16,this._tempJointMatrix),this._tempJointMatrix.decompose(void 0,u.rotationQuaternion,u.position);const d=this._jointRadii[c]*this._jointScaleFactor,f=this._jointMeshes[c];f.isVisible=!this._handMesh&&!this._jointsInvisible,f.position.copyFrom(u.position),f.rotationQuaternion.copyFrom(u.rotationQuaternion),f.scaling.setAll(d),f.parent=i.parent,this._scene.useRightHandedSystem||(f.position.z*=-1,f.rotationQuaternion.z*=-1,f.rotationQuaternion.w*=-1,this._leftHandedMeshes&&this._handMesh&&(u.position.z*=-1,u.rotationQuaternion.z*=-1,u.rotationQuaternion.w*=-1))}this._handMesh&&(this._handMesh.isVisible=!0,this._handMeshRoot&&(this._handMeshRoot.parent=i.parent)),this.xrController.pointer.parent=i.parent}}dispose(e=!1){this._handMesh&&(e?(this._handMesh.skeleton?.dispose(),this._handMesh.dispose(!1,!0)):this._handMesh.isVisible=!1);for(const t of this._jointTransforms)t.dispose();this._jointTransforms.length=0,this.onHandMeshSetObservable.clear()}}class dt extends su{static _GenerateTrackedJointMeshes(e,t=hf("jointParent",dt._ICOSPHERE_PARAMS)){const i={};return["left","right"].map(s=>{const r=[];t.isVisible=!!e.jointMeshes?.keepOriginalVisible;for(let a=0;a<Er.length;++a){let o=t.createInstance(`${s}-handJoint-${a}`);if(e.jointMeshes?.onHandJointMeshGenerated){const c=e.jointMeshes.onHandJointMeshGenerated(o,a,s);c&&c!==o&&(o.dispose(),o=c)}if(o.isPickable=!1,e.jointMeshes?.enablePhysics){const c=e.jointMeshes?.physicsProps||{};o.scaling.setAll(.02);const u=c.impostorType!==void 0?c.impostorType:Ut.SphereImpostor;o.physicsImpostor=new Ut(o,u,{mass:0,...c})}o.rotationQuaternion=new Se,o.isVisible=!1,r.push(o)}i[s]=r}),{left:i.left,right:i.right}}static async _GenerateDefaultHandMeshesAsync(e,t,i){return await new Promise(async s=>{const r={};dt._RightHandGLB?.meshes[1]?.isDisposed()&&(dt._RightHandGLB=null),dt._LeftHandGLB?.meshes[1]?.isDisposed()&&(dt._LeftHandGLB=null);const a=!!(dt._RightHandGLB&&dt._LeftHandGLB),o=pe.GetAssetUrl(dt.DEFAULT_HAND_MODEL_BASE_URL),c=await Promise.all([dt._RightHandGLB||ca.ImportMeshAsync("",o,dt.DEFAULT_HAND_MODEL_RIGHT_FILENAME,e),dt._LeftHandGLB||ca.ImportMeshAsync("",o,dt.DEFAULT_HAND_MODEL_LEFT_FILENAME,e)]);dt._RightHandGLB=c[0],dt._LeftHandGLB=c[1];const u=pe.GetAssetUrl(dt.DEFAULT_HAND_MODEL_SHADER_URL),d=await Ht.ParseFromFileAsync("handShader",u,e,void 0,!0);d.needDepthPrePass=!0,d.transparencyMode=fe.MATERIAL_ALPHABLEND,d.alphaMode=2,d.build(!1);const f={base:Ne.FromInts(116,63,203),fresnel:Ne.FromInts(149,102,229),fingerColor:Ne.FromInts(177,130,255),tipFresnel:Ne.FromInts(220,200,255),...i?.handMeshes?.customColors},g={base:d.getBlockByName("baseColor"),fresnel:d.getBlockByName("fresnelColor"),fingerColor:d.getBlockByName("fingerColor"),tipFresnel:d.getBlockByName("tipFresnelColor")};g.base.value=f.base,g.fresnel.value=f.fresnel,g.fingerColor.value=f.fingerColor,g.tipFresnel.value=f.tipFresnel;const m=t._getBaseLayerWrapper()?.isMultiview,b=["left","right"];for(const x of b){const v=x=="left"?dt._LeftHandGLB:dt._RightHandGLB;if(!v)throw new Error("Could not load hand model");const E=v.meshes[1];E._internalAbstractMeshDataInfo._computeBonesUsingShaders=!0,!m&&!i?.handMeshes?.disableHandShader&&(E.material=d.clone(`${x}HandShaderClone`,!0)),E.isVisible=!1,r[x]=E,!a&&!e.useRightHandedSystem&&v.meshes[1].rotate(wr.Y,Math.PI)}d.dispose(),s({left:r.left,right:r.right})})}static _GenerateDefaultHandMeshRigMapping(e){const t=e=="right"?"R":"L";return{wrist:`wrist_${t}`,"thumb-metacarpal":`thumb_metacarpal_${t}`,"thumb-phalanx-proximal":`thumb_proxPhalanx_${t}`,"thumb-phalanx-distal":`thumb_distPhalanx_${t}`,"thumb-tip":`thumb_tip_${t}`,"index-finger-metacarpal":`index_metacarpal_${t}`,"index-finger-phalanx-proximal":`index_proxPhalanx_${t}`,"index-finger-phalanx-intermediate":`index_intPhalanx_${t}`,"index-finger-phalanx-distal":`index_distPhalanx_${t}`,"index-finger-tip":`index_tip_${t}`,"middle-finger-metacarpal":`middle_metacarpal_${t}`,"middle-finger-phalanx-proximal":`middle_proxPhalanx_${t}`,"middle-finger-phalanx-intermediate":`middle_intPhalanx_${t}`,"middle-finger-phalanx-distal":`middle_distPhalanx_${t}`,"middle-finger-tip":`middle_tip_${t}`,"ring-finger-metacarpal":`ring_metacarpal_${t}`,"ring-finger-phalanx-proximal":`ring_proxPhalanx_${t}`,"ring-finger-phalanx-intermediate":`ring_intPhalanx_${t}`,"ring-finger-phalanx-distal":`ring_distPhalanx_${t}`,"ring-finger-tip":`ring_tip_${t}`,"pinky-finger-metacarpal":`little_metacarpal_${t}`,"pinky-finger-phalanx-proximal":`little_proxPhalanx_${t}`,"pinky-finger-phalanx-intermediate":`little_intPhalanx_${t}`,"pinky-finger-phalanx-distal":`little_distPhalanx_${t}`,"pinky-finger-tip":`little_tip_${t}`}}isCompatible(){return typeof XRHand<"u"}getHandByControllerId(e){return this._attachedHands[e]}getHandByHandedness(e){return e=="none"?null:this._trackingHands[e]}constructor(e,t){super(e),this.options=t,this._attachedHands={},this._trackingHands={left:null,right:null},this._handResources={jointMeshes:null,handMeshes:null,rigMappings:null},this._worldScaleObserver=null,this.onHandAddedObservable=new le,this.onHandRemovedObservable=new le,this._attachHand=r=>{if(!r.inputSource.hand||r.inputSource.handedness=="none"||!this._handResources.jointMeshes)return;const a=r.inputSource.handedness,o=new P4(r,this._handResources.jointMeshes[a],this._handResources.handMeshes&&this._handResources.handMeshes[a],this._handResources.rigMappings&&this._handResources.rigMappings[a],this.options.handMeshes?.meshesUseLeftHandedCoordinates,this.options.jointMeshes?.invisible,this.options.jointMeshes?.scaleFactor);this._attachedHands[r.uniqueId]=o,this._trackingHands[a]=o,this.onHandAddedObservable.notifyObservers(o)},this._detachHand=r=>{this._detachHandById(r.uniqueId)},this.xrNativeFeatureName="hand-tracking";const s=t.jointMeshes;if(s&&(typeof s.disableDefaultHandMesh<"u"&&(t.handMeshes=t.handMeshes||{},t.handMeshes.disableDefaultMeshes=s.disableDefaultHandMesh),typeof s.handMeshes<"u"&&(t.handMeshes=t.handMeshes||{},t.handMeshes.customMeshes=s.handMeshes),typeof s.leftHandedSystemMeshes<"u"&&(t.handMeshes=t.handMeshes||{},t.handMeshes.meshesUseLeftHandedCoordinates=s.leftHandedSystemMeshes),typeof s.rigMapping<"u")){t.handMeshes=t.handMeshes||{};const r={},a={},o=[[s.rigMapping.left,r],[s.rigMapping.right,a]];for(const c of o){const u=c[0],d=c[1];for(let f=0;f<u.length;f++){const g=u[f];d[Er[f]]=g}}t.handMeshes.customRigMappings={left:r,right:a}}}attach(){if(!super.attach())return!1;
3386this._handResources.jointMeshes||(this._originalMesh=this._originalMesh||this.options.jointMeshes?.sourceMesh||hf("jointParent",dt._ICOSPHERE_PARAMS),this._originalMesh.isVisible=!1,this._handResources.jointMeshes=dt._GenerateTrackedJointMeshes(this.options,this._originalMesh)),this._handResources.handMeshes=this.options.handMeshes?.customMeshes||null,this._handResources.rigMappings=this.options.handMeshes?.customRigMappings||null,!this.options.handMeshes?.customMeshes&&!this.options.handMeshes?.disableDefaultMeshes&&(dt._GenerateDefaultHandMeshesAsync(Ke.LastCreatedScene,this._xrSessionManager,this.options).then(e=>{this._handResources.handMeshes=e,this._handResources.rigMappings={left:dt._GenerateDefaultHandMeshRigMapping("left"),right:dt._GenerateDefaultHandMeshRigMapping("right")},this._trackingHands.left?.setHandMesh(this._handResources.handMeshes.left,this._handResources.rigMappings.left,this._xrSessionManager),this._trackingHands.right?.setHandMesh(this._handResources.handMeshes.right,this._handResources.rigMappings.right,this._xrSessionManager),this._handResources.handMeshes.left.scaling.setAll(this._xrSessionManager.worldScalingFactor),this._handResources.handMeshes.right.scaling.setAll(this._xrSessionManager.worldScalingFactor)}),this._worldScaleObserver=this._xrSessionManager.onWorldScaleFactorChangedObservable.add(e=>{this._handResources.handMeshes&&(this._handResources.handMeshes.left.scaling.scaleInPlace(e.newScaleFactor/e.previousScaleFactor),this._handResources.handMeshes.right.scaling.scaleInPlace(e.newScaleFactor/e.previousScaleFactor))}));for(const e of this.options.xrInput.controllers)this._attachHand(e);return this._addNewAttachObserver(this.options.xrInput.onControllerAddedObservable,this._attachHand),this._addNewAttachObserver(this.options.xrInput.onControllerRemovedObservable,this._detachHand),!0}_onXRFrame(e){this._trackingHands.left?.updateFromXRFrame(e,this._xrSessionManager.referenceSpace,this.options.xrInput.xrCamera),this._trackingHands.right?.updateFromXRFrame(e,this._xrSessionManager.referenceSpace,this.options.xrInput.xrCamera)}_detachHandById(e,t){const i=this.getHandByControllerId(e);if(i){const s=i.xrController.inputSource.handedness=="left"?"left":"right";this._trackingHands[s]?.xrController.uniqueId===e&&(this._trackingHands[s]=null),this.onHandRemovedObservable.notifyObservers(i),i.dispose(t),delete this._attachedHands[e]}}detach(){if(!super.detach())return!1;const e=Object.keys(this._attachedHands);for(const t of e)this._detachHandById(t,this.options.handMeshes?.disposeOnSessionEnd);if(this.options.handMeshes?.disposeOnSessionEnd){if(this._handResources.jointMeshes){for(const t of this._handResources.jointMeshes.left)t.dispose();for(const t of this._handResources.jointMeshes.right)t.dispose();this._handResources.jointMeshes=null}if(this._handResources.handMeshes&&(this._handResources.handMeshes.left.dispose(),this._handResources.handMeshes.right.dispose(),this._handResources.handMeshes=null),dt._RightHandGLB)for(const t of dt._RightHandGLB.meshes)t.dispose();if(dt._LeftHandGLB)for(const t of dt._LeftHandGLB.meshes)t.dispose();dt._RightHandGLB=null,dt._LeftHandGLB=null,this._originalMesh?.dispose(),this._originalMesh=void 0}return this._worldScaleObserver&&this._xrSessionManager.onWorldScaleFactorChangedObservable.remove(this._worldScaleObserver),!0}dispose(){if(super.dispose(),this.onHandAddedObservable.clear(),this.onHandRemovedObservable.clear(),this._handResources.handMeshes&&!this.options.handMeshes?.customMeshes){if(this._handResources.handMeshes.left.dispose(),this._handResources.handMeshes.right.dispose(),dt._RightHandGLB)for(const e of dt._RightHandGLB.meshes)e.dispose();if(dt._LeftHandGLB)for(const e of dt._LeftHandGLB.meshes)e.dispose();dt._RightHandGLB=null,dt._LeftHandGLB=null}if(this._handResources.jointMeshes){for(const e of this._handResources.jointMeshes.left)e.dispose();for(const e of this._handResources.jointMeshes.right)e.dispose()}}}dt.Name=Yt.HAND_TRACKING;dt.Version=1;dt.DEFAULT_HAND_MODEL_BASE_URL="https://assets.babylonjs.com/core/HandMeshes/";dt.DEFAULT_HAND_MODEL_RIGHT_FILENAME="r_hand_rhs.glb";dt.DEFAULT_HAND_MODEL_LEFT_FILENAME="l_hand_rhs.glb";dt.DEFAULT_HAND_MODEL_SHADER_URL="https://assets.babylonjs.com/core/H
3386andMeshes/handsShader.json";dt._ICOSPHERE_PARAMS={radius:.5,flat:!1,subdivisions:2};dt._RightHandGLB=null;dt._LeftHandGLB=null;Dr.AddWebXRFeature(dt.Name,(n,e)=>()=>new dt(n,e),dt.Version,!1);ot.prototype.createDynamicTexture=function(n,e,t,i){const s=new Cs(this,4);return s.baseWidth=n,s.baseHeight=e,t&&(n=this.needPOTTextures?Vo(n,this._caps.maxTextureSize):n,e=this.needPOTTextures?Vo(e,this._caps.maxTextureSize):e),s.width=n,s.height=e,s.isReady=!1,s.generateMipMaps=t,s.samplingMode=i,this.updateTextureSamplingMode(i,s),this._internalTexturesCache.push(s),s};ot.prototype.updateDynamicTexture=function(n,e,t,i=!1,s,r=!1,a=!1){if(!n)return;const o=this._gl,c=o.TEXTURE_2D,u=this._bindTextureDirectly(c,n,!0,r);this._unpackFlipY(t===void 0?n.invertY:t),i&&o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1);const d=this._getWebGLTextureType(n.type),f=this._getInternalFormat(s||n.format),g=this._getRGBABufferInternalSizedFormat(n.type,f);o.texImage2D(c,0,g,f,d,e),n.generateMipMaps&&o.generateMipmap(c),u||this._bindTextureDirectly(c,null),i&&o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),s&&(n.format=s),n._dynamicTextureSource=e,n._premulAlpha=i,n.invertY=t||!1,n.isReady=!0};class pf extends Te{constructor(e,t,i,s=!1,r=3,a=5,o){const c=!i||i._isScene,u=c?i:i?.scene,d=c?!s:i;super(null,u,d,o,r,void 0,void 0,void 0,void 0,a),this.name=e,this.wrapU=Te.CLAMP_ADDRESSMODE,this.wrapV=Te.CLAMP_ADDRESSMODE,this._generateMipMaps=s;const f=this._getEngine();if(!f)return;if(t.getContext)this._canvas=t,this._ownCanvas=!1,this._texture=f.createDynamicTexture(this._canvas.width,this._canvas.height,s,r);else{this._canvas=f.createCanvas(1,1),this._ownCanvas=!0;const m=t;m.width||m.width===0?this._texture=f.createDynamicTexture(m.width,m.height,s,r):this._texture=f.createDynamicTexture(t,t,s,r)}const g=this.getSize();this._canvas.width!==g.width&&(this._canvas.width=g.width),this._canvas.height!==g.height&&(this._canvas.height=g.height),this._context=this._canvas.getContext("2d")}getClassName(){return"DynamicTexture"}get canRescale(){return!0}_recreate(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this._getEngine().createDynamicTexture(e.width,e.height,this._generateMipMaps,this.samplingMode)}scale(e){const t=this.getSize();t.width*=e,t.height*=e,this._recreate(t)}scaleTo(e,t){const i=this.getSize();i.width=e,i.height=t,this._recreate(i)}getContext(){return this._context}clear(e){const t=this.getSize();e&&(this._context.fillStyle=e),this._context.clearRect(0,0,t.width,t.height)}update(e,t=!1,i=!1){this._texture&&this._getEngine().updateDynamicTexture(this._texture,this._canvas,e===void 0?!0:e,t,this._format||void 0,void 0,i)}drawText(e,t,i,s,r,a,o,c=!0){const u=this.getSize();if(a&&(this._context.fillStyle=a,this._context.fillRect(0,0,u.width,u.height)),this._context.font=s,t==null){const d=this._context.measureText(e);t=(u.width-d.width)/2}if(i==null){const d=parseInt(s.replace(/\D/g,""));i=u.height/2+d/3.65}this._context.fillStyle=r||"",this._context.fillText(e,t,i),c&&this.update(o)}dispose(){super.dispose(),this._ownCanvas&&this._canvas?.remove?.(),this._canvas=null,this._context=null}clone(){const e=this.getScene();if(!e)return this;const t=this.getSize(),i=new pf(this.name,t,e,this._generateMipMaps);return i.hasAlpha=this.hasAlpha,i.level=this.level,i.wrapU=this.wrapU,i.wrapV=this.wrapV,i}serialize(){const e=this.getScene();e&&!e.isReady()&&oe.Warn("The scene must be ready before serializing the dynamic texture");const t=super.serialize();return pf._IsCanvasElement(this._canvas)&&(t.base64String=this._canvas.toDataURL()),t.invertY=this._invertY,t.samplingMode=this.samplingMode,t}static _IsCanvasElement(e){return e.toDataURL!==void 0}_rebuild(){this.update()}}var _A;(function(n){n[n.INIT=0]="INIT",n[n.STARTED=1]="STARTED",n[n.ENDED=2]="ENDED"})(_A||(_A={}));function Od(n){let e=0;const t=Date.now();n.observableParameters=n.observableParameters??{};const i=n.contextObservable.add(s=>{const r=Date.now();e=r-t;const a={startTime:t,currentTime:r,deltaTime:e,completeRate:e/n.timeout,payload:s};n.onTick&&n.onTick(a),n.breakCondition&&n.breakCondition()&&(n.contextObservable.remove(i),n.onAborted&&n.onAborted(a)),e>=n.timeout&&(n.contextObservable.remove(i),n.onEnded&&n.onEnded(a))},n.observableParameters.mask,n.observableParameters.insertFirst,n.observableParameters.scope);return i}class Th extends su{get rotationEnabled(){return this._rotationEnabled}set rotationEnabled(e){if(this._rotationEnabled=e,this._options.teleportationTargetMesh){const t=this._options.teleportationTargetMesh.getChildMeshes(!1,i=>i.name==="rotationCone");t[0]&&t[0].setEnabled(e)}}get teleportationTargetMesh(){return this._options.teleportationTargetMesh||null}constructor(e,t){super(e),this._options=t,this._controllers={},this._snappedToPoint=!1,this._cachedColor4White=new Ze(1,1,1,1),this._tmpRay=new ht(new T,new T),this._tmpVector=new T,this._tmpQuaternion=new Se,this._worldScaleObserver=null,this.skipNextTeleportation=!1,this.backwardsMovementEnabled=!0,this.backwardsTeleportationDistance=.7,this.parabolicCheckRadius=5,this.parabolicRayEnabled=!0,this.straightRayEnabled=!0,this.rotationAngle=Math.PI/8,this.onTargetMeshPositionUpdatedObservable=new le,this.teleportationEnabled=!0,this._rotationEnabled=!0,this.onBeforeCameraTeleportRotation=new le,this.onAfterCameraTeleportRotation=new le,this._attachController=i=>{if(this._controllers[i.uniqueId]||this._options.forceHandedness&&i.inputSource.handedness!==this._options.forceHandedness)return;this._controllers[i.uniqueId]={xrController:i,teleportationState:{forward:!1,backwards:!1,rotating:!1,currentRotation:0,baseRotation:0,blocked:!1,initialHit:!1,mainComponentUsed:!1}};const s=this._controllers[i.uniqueId];if(s.xrController.inputSource.targetRayMode==="tracked-pointer"&&s.xrController.inputSource.gamepad){const r=()=>{if(i.motionController){const a=i.motionController.getComponentOfType(Tn.THUMBSTICK_TYPE)||i.motionController.getComponentOfType(Tn.TOUCHPAD_TYPE);if(!a||this._options.useMainComponentOnly){const o=i.motionController.getMainComponent();if(!o)return;s.teleportationState.mainComponentUsed=!0,s.teleportationComponent=o,s.onButtonChangedObserver=o.onButtonStateChangedObservable.add(()=>
3386{if(!this.teleportationEnabled)return;const c=()=>{s.teleportationState.forward=!0,s.teleportationState.initialHit=!1,this._currentTeleportationControllerId=s.xrController.uniqueId,s.teleportationState.baseRotation=this._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,s.teleportationState.currentRotation=0;const u=this._options.timeToTeleport||3e3;Od({timeout:u,contextObservable:this._xrSessionManager.onXRFrameObservable,breakCondition:()=>!o.pressed,onEnded:()=>{this._currentTeleportationControllerId===s.xrController.uniqueId&&s.teleportationState.forward&&this._teleportForward(i.uniqueId)}})};o.changes.pressed&&(o.changes.pressed.current?this._options.timeToTeleportStart?Od({timeout:this._options.timeToTeleportStart,contextObservable:this._xrSessionManager.onXRFrameObservable,onEnded:()=>{o.pressed&&c()}}):c():(s.teleportationState.forward=!1,this._currentTeleportationControllerId=""))})}else s.teleportationComponent=a,s.onAxisChangedObserver=a.onAxisValueChangedObservable.add(o=>{if(o.y<=.7&&s.teleportationState.backwards&&(s.teleportationState.backwards=!1),o.y>.7&&!s.teleportationState.forward&&this.backwardsMovementEnabled&&!this.snapPointsOnly&&!s.teleportationState.backwards){s.teleportationState.backwards=!0,this._tmpQuaternion.copyFrom(this._options.xrInput.xrCamera.rotationQuaternion),this._tmpQuaternion.toEulerAnglesToRef(this._tmpVector),this._tmpVector.x=0,this._tmpVector.z=0,Se.FromEulerVectorToRef(this._tmpVector,this._tmpQuaternion),this._tmpVector.set(0,0,this.backwardsTeleportationDistance*(this._xrSessionManager.scene.useRightHandedSystem?1:-1)),this._tmpVector.rotateByQuaternionToRef(this._tmpQuaternion,this._tmpVector),this._tmpVector.addInPlace(this._options.xrInput.xrCamera.position),this._tmpRay.origin.copyFrom(this._tmpVector),this._tmpRay.length=this._options.xrInput.xrCamera.realWorldHeight+.1,this._tmpRay.direction.set(0,-1,0);const c=this._xrSessionManager.scene.pickWithRay(this._tmpRay,u=>this._floorMeshes.indexOf(u)!==-1);c&&c.pickedPoint&&(this._options.xrInput.xrCamera.position.x=c.pickedPoint.x,this._options.xrInput.xrCamera.position.z=c.pickedPoint.z)}if(o.y<-.7&&!this._currentTeleportationControllerId&&!s.teleportationState.rotating&&this.teleportationEnabled&&(s.teleportationState.forward=!0,this._currentTeleportationControllerId=s.xrController.uniqueId,s.teleportationState.baseRotation=this._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y),o.x){if(s.teleportationState.forward)this._currentTeleportationControllerId===s.xrController.uniqueId&&(this.rotationEnabled?setTimeout(()=>{s.teleportationState.currentRotation=Math.atan2(o.x,o.y*(this._xrSessionManager.scene.useRightHandedSystem?1:-1))}):s.teleportationState.currentRotation=0);else if(!s.teleportationState.rotating&&Math.abs(o.x)>.7){s.teleportationState.rotating=!0;const c=this.rotationAngle*(o.x>0?1:-1)*(this._xrSessionManager.scene.useRightHandedSystem?-1:1);this.onBeforeCameraTeleportRotation.notifyObservers(c),Se.FromEulerAngles(0,c,0).multiplyToRef(this._options.xrInput.xrCamera.rotationQuaternion,this._options.xrInput.xrCamera.rotationQuaternion),this.onAfterCameraTeleportRotation.notifyObservers(this._options.xrInput.xrCamera.rotationQuaternion)}}else s.teleportationState.rotating=!1;o.x===0&&o.y===0&&(s.teleportationState.blocked&&(s.teleportationState.blocked=!1,this._setTargetMeshVisibility(!1)),s.teleportationState.forward&&this._teleportForward(i.uniqueId))})}};i.motionController?r():i.onMotionControllerInitObservable.addOnce(()=>{r()})}else{s.teleportationState.mainComponentUsed=!0;let r=!1;const a=()=>{this._currentTeleportationControllerId=s.xrController.uniqueId,s.teleportationState.forward=!0,s.teleportationState.initialHit=!1,s.teleportationState.baseRotation=this._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,s.teleportationState.currentRotation=0;const o=this._options.timeToTeleport||3e3;Od({timeout:o,contextObservable:this._xrSessionManager.onXRFrameObservable,onEnded:()=>{this._currentTeleportationControllerId===s.xrController.uniqueId&&s.teleportationState.forward&&this._teleportForward(i.uniqueId)}})};this._xrSessionManager.scene.onPointerObservable.add(o=>{o.type===Ve.POINTERDOWN?(r=!1,this._options.timeToTeleportStart?Od({timeout:this._options.timeToTeleportStart,contextObservable:this._xrSessionManager.onXRFrameObservable,onEnded:()=>{this._currentTeleportationControllerId===s.xrController.uniqueId&&a()},breakCondition:()=>r?(r=!1,!0):!1}):a()):o.type===Ve.POINTERUP&&(r=!0,s.teleportationState.forward=!1,this._currentTeleportationControllerId="")})}},this._colorArray=Array(24).fill(this._cachedColor4White),this._options.teleportationTargetMesh||this._createDefaultTargetMesh(),this._floorMeshes=this._options.floorMeshes||[],this._snapToPositions=this._options.snapPositions||[],this._blockedRayColor=this._options.blockedRayColor||new Ze(1,0,0,.75),this._setTargetMeshVisibility(!1),this.onBeforeCameraTeleport=t.xrInput.xrCamera.onBeforeCameraTeleport,this.onAfterCameraTeleport=t.xrInput.xrCamera.onAfterCameraTeleport,this.parabolicCheckRadius*=this._xrSessionManager.worldScalingFactor,this._worldScaleObserver=e.onWorldScaleFactorChangedObservable.add(i=>{this.parabolicCheckRadius=this.parabolicCheckRadius/i.previousScaleFactor*i.newScaleFactor,this._options.teleportationTargetMesh?.scaling.scaleInPlace(i.newScaleFactor/i.previousScaleFactor)})}get snapPointsOnly(){return!!this._options.snapPointsOnly}set snapPointsOnly(e){this._options.snapPointsOnly=e}addFloorMesh(e){this._floorMeshes.push(e)}addBlockerMesh(e){this._options.pickBlockerMeshes=this._options.pickBlockerMeshes||[],this._options.pickBlockerMeshes.push(e)}addSnapPoint(e){this._snapToPositions.push(e)}attach(){if(!super.attach())return!1;this._currentTeleportationControllerId="";for(const e of this._options.xrInput.controllers)this._attachController(e);return this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable,this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable,e=>{this._detachController(e.uniqueId)}),!0}detach(){if(!super.detach())return!1;const e=Object.keys(this._controllers);for(const t of e)this._detachController(t);return this._setTargetMeshVisibility(!1),this._currentTeleportationControllerId="",this._controllers={},!0}dispose(){super.dispose(),this._options.teleportationTargetMesh&&this._options.teleportationTargetMesh.dispose(!1,!0),this._worldScaleObserver&&this._xrSessionManager.onWorldScaleFactorChangedObservable.remove(this._worldScaleObserver),this.onTargetMeshPositionUpdatedObservable.clear(),this.onTargetMeshPositionUpdatedObservable.clear(),this.onBeforeCameraTeleportRotation.clear(),this.onAfterCameraTeleportRotation.clear(),this.onBeforeCameraTeleport.clear(),this.onAfterCameraTeleport.clear()}removeFloorMesh(e){const t=this._floorMeshes.indexOf(e);t!==-1&&this._floorMeshes.splice(t,1)}removeBlockerMesh(e){this._options.pickBlockerMeshes=this._options.pickBlockerMeshes||[];const t=this._options.pickBlockerMeshes.indexOf(e);t!==-1&&this._options.pickBlockerMeshes.splice(t,1)}removeFloorMeshByName(e){const t=this._xrSessionManager.scene.getMeshByName(e);t&&this.removeFloorMesh(t)}removeSnapPoint(e){let t=this._snapToPositions.indexOf(e);if(t===-1){for(let i=0;i<this._snapToPositions.length;++i)if(this._snapToPositions[i].equals(e)){t=i;break}}return t!==-1?(this._snapToPositions.splice(t,1),!0):!1}setSelectionFeature(e){this._selectionFeature=e}_onXRFrame(e){const t=this._xrSessionManager.currentFrame,i=this._xrSessionManager.scene;if(!this.attach||!t)return;const s=this._options.teleportationTargetMesh;if(this._currentTeleportationControllerId){if(!s)return;s.rotationQuaternion=s.rotationQuaternion||new Se;const r=this._controllers[this._currentTeleportationControllerId];if(r&&r.teleportationState.forward){Se.RotationYawPitchRollToRef(r.teleportationState.currentRotation+r.teleportationState.baseRotation,0,0,s.rotationQuaternion);let a=!1;const o=r.xrController.inputSource.targetRayMode!=="transient-pointer";if(r.xrController.getWorldPointerRayToRef(this._tmpRay),this.straightRayEnabled){const c=i.pickWithRay(this._tmpRay,d=>{if(this._options.blockerMeshesPredicate&&this._options.blockerMeshesPredicate(d)||this._options.blockAllPickableMeshes&&d.isPickable||this._options.pickBlockerMeshes&&this._options.pickBlockerMeshes.indexOf(d)!==-1)return!0;const f=this._floorMeshes.indexOf(d);return f===-1?!1:this._floorMeshes[f].absolutePosition.y<this._options.xrInput.xrCamera.globalPosition.y}),u=c&&c.pickedMesh&&this._floorMeshes.indexOf(c.pickedMesh)!==-1;
3386if(c&&c.pickedMesh&&!u){if(r.teleportationState.mainComponentUsed&&!r.teleportationState.initialHit){r.teleportationState.forward=!1;return}r.teleportationState.blocked=!0,this._setTargetMeshVisibility(!1,!1,o),this._showParabolicPath(c);return}else c&&c.pickedPoint&&(r.teleportationState.initialHit=!0,r.teleportationState.blocked=!1,a=!0,this._setTargetMeshPosition(c),this._setTargetMeshVisibility(!0,!1,o),this._showParabolicPath(c))}if(this.parabolicRayEnabled&&!a){const c=r.xrController.pointer.rotationQuaternion.toEulerAngles().x,u=1+(Math.PI/2-Math.abs(c)),d=this.parabolicCheckRadius*u;this._tmpRay.origin.addToRef(this._tmpRay.direction.scale(d*2),this._tmpVector),this._tmpVector.y=this._tmpRay.origin.y,this._tmpRay.origin.addInPlace(this._tmpRay.direction.scale(d)),this._tmpVector.subtractToRef(this._tmpRay.origin,this._tmpRay.direction),this._tmpRay.direction.normalize();const f=i.pickWithRay(this._tmpRay,m=>this._options.blockerMeshesPredicate&&this._options.blockerMeshesPredicate(m)||this._options.blockAllPickableMeshes&&m.isPickable||this._options.pickBlockerMeshes&&this._options.pickBlockerMeshes.indexOf(m)!==-1?!0:this._floorMeshes.indexOf(m)!==-1),g=f&&f.pickedMesh&&this._floorMeshes.indexOf(f.pickedMesh)!==-1;if(f&&f.pickedMesh&&!g){if(r.teleportationState.mainComponentUsed&&!r.teleportationState.initialHit){r.teleportationState.forward=!1;return}r.teleportationState.blocked=!0,this._setTargetMeshVisibility(!1,!1,o),this._showParabolicPath(f);return}else f&&f.pickedPoint&&(r.teleportationState.initialHit=!0,r.teleportationState.blocked=!1,a=!0,this._setTargetMeshPosition(f),this._setTargetMeshVisibility(!0,!1,o),this._showParabolicPath(f))}this._setTargetMeshVisibility(a,!1,o)}else this._setTargetMeshVisibility(!1,!1,!0)}else this._disposeBezierCurve(),this._setTargetMeshVisibility(!1,!1,!0)}_createDefaultTargetMesh(){this._options.defaultTargetMeshOptions=this._options.defaultTargetMeshOptions||{};const e=this._options.useUtilityLayer?this._options.customUtilityLayerScene||ui.DefaultUtilityLayer.utilityLayerScene:this._xrSessionManager.scene,t=Ub("teleportationTarget",{width:2,height:2,subdivisions:2},e);if(t.isPickable=!1,this._options.defaultTargetMeshOptions.teleportationCircleMaterial)t.material=this._options.defaultTargetMeshOptions.teleportationCircleMaterial;else{const a=new pf("teleportationPlaneDynamicTexture",512,e,!0);a.hasAlpha=!0;const o=a.getContext(),c=512/2,u=512/2,d=200;o.beginPath(),o.arc(c,u,d,0,2*Math.PI,!1),o.fillStyle=this._options.defaultTargetMeshOptions.teleportationFillColor||"#444444",o.fill(),o.lineWidth=10,o.strokeStyle=this._options.defaultTargetMeshOptions.teleportationBorderColor||"#FFFFFF",o.stroke(),o.closePath(),a.update();const f=new Ae("teleportationPlaneMaterial",e);f.diffuseTexture=a,t.material=f}const i=kh("torusTeleportation",{diameter:.75,thickness:.1,tessellation:20},e);if(i.isPickable=!1,i.parent=t,!this._options.defaultTargetMeshOptions.disableAnimation){const r=new xe("animationInnerCircle","position.y",30,xe.ANIMATIONTYPE_FLOAT,xe.ANIMATIONLOOPMODE_CYCLE),a=[];a.push({frame:0,value:0}),a.push({frame:30,value:.4}),a.push({frame:60,value:0}),r.setKeys(a);const o=new VV;o.setEasingMode(Rs.EASINGMODE_EASEINOUT),r.setEasingFunction(o),i.animations=[],i.animations.push(r),e.beginAnimation(i,0,60,!0)}const s=Vf("rotationCone",{diameterTop:0,tessellation:4},e);if(s.isPickable=!1,s.scaling.set(.5,.12,.2),s.rotate(wr.X,Math.PI/2),s.position.z=.6,s.parent=i,this._options.defaultTargetMeshOptions.torusArrowMaterial)i.material=this._options.defaultTargetMeshOptions.torusArrowMaterial,s.material=this._options.defaultTargetMeshOptions.torusArrowMaterial;else{const r=new Ae("torusConsMat",e);r.disableLighting=!!this._options.defaultTargetMeshOptions.disableLighting,r.disableLighting?r.emissiveColor=new Ne(.3,.3,1):r.diffuseColor=new Ne(.3,.3,1),r.alpha=.9,i.material=r,s.material=r,this._teleportationRingMaterial=r}this._options.renderingGroupId!==void 0&&(t.renderingGroupId=this._options.renderingGroupId,i.renderingGroupId=this._options.renderingGroupId,s.renderingGroupId=this._options.renderingGroupId),this._options.teleportationTargetMesh=t,this._options.teleportationTargetMesh.scaling.setAll(this._xrSessionManager.worldScalingFactor),this._setTargetMeshVisibility(!1)}_detachController(e){const t=this._controllers[e];t&&(t.teleportationComponent&&(t.onAxisChangedObserver&&t.teleportationComponent.onAxisValueChangedObservable.remove(t.onAxisChangedObserver),t.onButtonChangedObserver&&t.teleportationComponent.onButtonStateChangedObservable.remove(t.onButtonChangedObserver)),delete this._controllers[e])}
3386_findClosestSnapPointWithRadius(e,t=this._options.snapToPositionRadius||.8){let i=null,s=Number.MAX_VALUE;if(this._snapToPositions.length){const r=t*t;for(const a of this._snapToPositions){const o=T.DistanceSquared(a,e);o<=r&&o<s&&(s=o,i=a)}}return i}_setTargetMeshPosition(e){const t=e.pickedPoint;if(!this._options.teleportationTargetMesh||!t)return;const i=this._findClosestSnapPointWithRadius(t);this._snappedToPoint=!!i,this.snapPointsOnly&&!this._snappedToPoint&&this._teleportationRingMaterial?this._teleportationRingMaterial.diffuseColor.set(1,.3,.3):this.snapPointsOnly&&this._snappedToPoint&&this._teleportationRingMaterial&&this._teleportationRingMaterial.diffuseColor.set(.3,.3,1),this._options.teleportationTargetMesh.position.copyFrom(i||t),this._options.teleportationTargetMesh.position.y+=.01,this.onTargetMeshPositionUpdatedObservable.notifyObservers(e)}_setTargetMeshVisibility(e,t,i){if(!this._options.teleportationTargetMesh||this._options.teleportationTargetMesh.isVisible===e&&!t)return;this._options.teleportationTargetMesh.isVisible=e;const s=this._options.teleportationTargetMesh.getChildren(void 0,!1);for(const r of s)r.isVisible=e;e?this._selectionFeature&&i&&this._selectionFeature.detach():(this._quadraticBezierCurve&&(this._quadraticBezierCurve.dispose(),this._quadraticBezierCurve=null),this._selectionFeature&&i&&this._selectionFeature.attach())}_disposeBezierCurve(){this._quadraticBezierCurve&&(this._quadraticBezierCurve.dispose(),this._quadraticBezierCurve=null)}_showParabolicPath(e){if(!e.pickedPoint||!this._currentTeleportationControllerId)return;const t=this._options.useUtilityLayer?this._options.customUtilityLayerScene||ui.DefaultUtilityLayer.utilityLayerScene:this._xrSessionManager.scene,i=this._controllers[this._currentTeleportationControllerId],s=Zn.CreateQuadraticBezier(i.xrController.pointer.absolutePosition,e.ray.origin,e.pickedPoint,25),r=i.teleportationState.blocked?this._blockedRayColor:void 0,a=this._colorArray.fill(r||this._cachedColor4White),o=s.getPoints();o.shift(),o.shift(),this._options.generateRayPathMesh?this._quadraticBezierCurve=this._options.generateRayPathMesh(s.getPoints(),e):this._quadraticBezierCurve=Wb("teleportation path line",{points:o,instance:this._quadraticBezierCurve,updatable:!0,colors:a},t),this._quadraticBezierCurve.isPickable=!1,this._options.renderingGroupId!==void 0&&(this._quadraticBezierCurve.renderingGroupId=this._options.renderingGroupId)}_teleportForward(e){const t=this._controllers[e];if(!(!t||!t.teleportationState.forward||!this.teleportationEnabled)&&(t.teleportationState.forward=!1,this._currentTeleportationControllerId="",!(this.snapPointsOnly&&!this._snappedToPoint))){if(this.skipNextTeleportation){this.skipNextTeleportation=!1;return}if(this._options.teleportationTargetMesh&&this._options.teleportationTargetMesh.isVisible){const i=this._options.xrInput.xrCamera.realWorldHeight;this.onBeforeCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position),this._options.xrInput.xrCamera.position.copyFrom(this._options.teleportationTargetMesh.position),this._options.xrInput.xrCamera.position.y+=i,Se.FromEulerAngles(0,t.teleportationState.currentRotation-(this._xrSessionManager.scene.useRightHandedSystem?Math.PI:0),0).multiplyToRef(this._options.xrInput.xrCamera.rotationQuaternion,this._options.xrInput.xrCamera.rotationQuaternion),this.onAfterCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position)}}}}Th.Name=Yt.TELEPORTATION;Th.Version=1;Dr.AddWebXRFeature(Th.Name,(n,e)=>()=>new Th(n,e),Th.Version,!0);class Ql extends su{constructor(e,t={}){super(e),this.options=t,this._tmpMat=new W,this._tmpPos=new T,this._tmpQuat=new Se,this._initHitTestSource=i=>{if(!i)return;const s=new XRRay(this.options.offsetRay||{}),r={space:this.options.useReferenceSpace?i:this._xrSessionManager.viewerReferenceSpace,offsetRay:s};if(this.options.entityTypes&&(r.entityTypes=this.options.entityTypes),!r.space){pe.Warn("waiting for viewer reference space to initialize");return}this._xrSessionManager.session.requestHitTestSource(r).then(a=>{this._xrHitTestSource&&this._xrHitTestSource.cancel(),this._xrHitTestSource=a})},this.autoCloneTransformation=!1,this.onHitTestResultObservable=new le,this.paused=!1,this.xrNativeFeatureName="hit-test",pe.Warn("Hit test is an experimental and unstable feature.")}attach(){if(!super.attach()||!this._xrSessionManager.session.requestHitTestSource)return!1;if(this.options.disablePermanentHitTest||(this._xrSessionManager.referenceSpace&&this._initHitTestSource(this._xrSessionManager.referenceSpace),this._xrSessionManager.onXRReferenceSpaceChanged.add(this._initHitTestSource)),this.options.enableTransientHitTest){const e=new XRRay(this.options.transientOffsetRay||{});this._xrSessionManager.session.requestHitTestSourceForTransientInput({profile:this.options.transientHitTestProfile||"generic-touchscreen",offsetRay:e,entityTypes:this.options.entityTypes}).then(t=>{this._transientXrHitTestSource=t})}return!0}detach(){return super.detach()?(this._xrHitTestSource&&(this._xrHitTestSource.cancel(),this._xrHitTestSource=null),this._xrSessionManager.onXRReferenceSpaceChanged.removeCallback(this._initHitTestSource),this._transientXrHitTestSource&&(this._transientXrHitTestSource.cancel(),this._transientXrHitTestSource=null),!0):!1}dispose(){super.dispose(),this.onHitTestResultObservable.clear()}_onXRFrame(e){if(!(!this.attached||this.paused)){if(this._xrHitTestSource){const t=e.getHitTestResults(this._xrHitTestSource);this._processWebXRHitTestResult(t)}if(this._transientXrHitTestSource){const t=e.getHitTestResultsForTransientInput(this._transientXrHitTestSource);for(const i of t)this._processWebXRHitTestResult(i.results,i.inputSource)}}}_processWebXRHitTestResult(e,t){const i=[];for(const s of e){const r=s.getPose(this._xrSessionManager.referenceSpace);if(!r)continue;const a=r.transform.position,o=r.transform.orientation;this._tmpPos.set(a.x,a.y,a.z).scaleInPlace(this._xrSessionManager.worldScalingFactor),this._tmpQuat.set(o.x,o.y,o.z,o.w),W.FromFloat32ArrayToRefScaled(r.transform.matrix,0,1,this._tmpMat),this._xrSessionManager.scene.useRightHandedSystem||(this._tmpPos.z*=-1,this._tmpQuat.z*=-1,this._tmpQuat.w*=-1,this._tmpMat.toggleModelMatrixHandInPlace());const c={position:this.autoCloneTransformation?this._tmpPos.clone():this._tmpPos,rotationQuaternion:this.autoCloneTransformation?this._tmpQuat.clone():this._tmpQuat,transformationMatrix:this.autoCloneTransformation?this._tmpMat.clone():this._tmpMat,inputSource:t,isTransient:!!t,xrHitResult:s};i.push(c)}this.onHitTestResultObservable.notifyObservers(i)}}Ql.Name=Yt.HIT_TEST;Ql.Version=2;Dr.AddWebXRFeature(Ql.Name,(n,e)=>()=>new Ql(n,e),Ql.Version,!1);function _h(n,e,t,i){const s=new Ae(e,n);return s.diffuseColor=Ne.FromHexString(t),s.specularColor=Ne.Black(),i&&(s.emissiveColor=Ne.FromHexString(i)),s}function D4(n){const e=new Pe(n,!0,{preserveDrawingBuffer:!1,stencil:!0}),t=new Pt(e);t.clearColor=new Ne(.02,.09,.11).toColor4(1);const i=new kt("aura-camera",Math.PI/2,Math.PI/2.35,2.9,new T(0,1.05,0),t);i.attachControl(n,!0),i.lowerRadiusLimit=1.8,i.upperRadiusLimit=4.5,new _
3386c("soft-light",new T(0,1,0),t).intensity=.82;const s=_h(t,"aura-skin","#d9957f"),r=_h(t,"aura-hair","#24161b"),a=_h(t,"aura-dress","#6f927a","#314c40"),o=_h(t,"aura-cyan","#041c20","#22d3ee"),c=_h(t,"aura-orange","#29140b","#ea7a3c"),u=new Ae("aura-portrait",t);u.diffuseTexture=new Te("/manus-storage/aura-blonde-leather-fullbody_79b41ae7.png",t,!0,!1),u.useAlphaFromDiffuseTexture=!0,u.specularColor=Ne.Black(),u.backFaceCulling=!1;const d=qn.CreateBox("aura-root",{size:.001},t);d.isVisible=!1,d.position.set(0,0,-1.75);const f=qn.CreatePlane("aura-portrait",{width:1.74,height:2.6},t);f.material=u,f.position=new T(0,1.3,0),f.isPickable=!1,f.visibility=0,f.billboardMode=7,f.parent=d;const g=qn.CreateCylinder("aura-torso",{height:.85,diameterTop:.48,diameterBottom:.7,tessellation:24},t);g.material=a,g.position.y=.65,g.parent=d;const m=qn.CreateSphere("aura-head",{diameter:.72,segments:24},t);m.material=s,m.position.y=1.52,m.parent=d;const b=qn.CreateSphere("aura-hair-cap",{diameter:.77,segments:24},t);b.material=r,b.scaling=new T(1.03,.76,1.02),b.position=new T(0,1.75,-.08),b.parent=d;const x=qn.CreateTorus("aura-mouth",{diameter:.12,thickness:.018,tessellation:16},t);x.material=c,x.scaling.y=.42,x.position=new T(0,1.38,.34),x.rotation.x=Math.PI/2,x.parent=d;const v=qn.CreateTorus("aura-ring",{diameter:1.55,thickness:.025,tessellation:48},t);v.material=o,v.rotation.x=Math.PI/2,v.position.y=.06,v.parent=d;const E=qn.CreateDisc("aura-lie-anchor",{radius:.7,tessellation:48},t);E.material=o,E.rotation.x=Math.PI/2,E.visibility=0;const A=qn.CreateSphere("aura-hand-target",{diameter:.07,segments:12},t);A.material=o,A.visibility=0;let D=0,I=null,R=null,C=0,M=null,F=null,U=!1,k=null,q=null,Q=0,ie=0,$="Keine geeignete horizontale Fläche erkannt â bitte mit dem Controller nach unten auf Bett, Boden oder Tisch zeigen.",ce=!1;t.onBeforeRenderObservable.add(()=>{D+=e.getDeltaTime()/1e3,g.scaling.y=1+Math.sin(D*1.6)*.025,v.rotation.z+=.003,R&&performance.now()>C&&(R=null),performance.now()-Q>450&&(A.visibility=0);const ae=t.activeCamera?.position??i.position,he=(R??ae).subtract(m.getAbsolutePosition());if(m.rotation.y=Math.max(-.18,Math.min(.18,Math.atan2(he.x,he.z)*.4))+Math.sin(D*.45)*.025,x.scaling.y=.42+Math.abs(Math.sin(D*2.8))*.16,!I)return;const be=(performance.now()-I.startedAt)/1e3,Le=I.name==="lie"?2.8:2.1,Xe=Math.min(be/Le,1),it=Math.sin(Xe*Math.PI);I.name==="turn"&&(d.rotation.y=I.yaw+Xe*Math.PI*2),I.name==="fist"&&(d.position.y=Math.abs(Math.sin(be*5.5))*.16,g.rotation.z=Math.sin(be*5.5)*.05),I.name==="lie"&&(d.rotation.z=-it*Math.PI/2.8,d.position.y=-it*.28,d.position.x=E.position.x,d.position.z=E.position.z),I.name==="kiss"&&(f.scaling.setAll(1+it*.08),x.scaling.y=.56+it*.52),I.name==="wave"&&(g.rotation.z=Math.sin(be*7)*.11),I.name==="dance"&&(d.position.x+=Math.sin(be*6)*.006,d.position.y=Math.abs(Math.sin(be*6))*.08),I.name==="hug"&&(f.scaling.setAll(1+it*.12),d.position.z=-1.75-it*.15),!(Xe<1)&&(d.position.y=0,d.position.z=-1.75,d.rotation.z=0,g.rotation.z=0,f.scaling.setAll(1),I=null)}),e.runRenderLoop(()=>t.render());const G=()=>e.resize();window.addEventListener("resize",G);const K=ae=>{const he=ae.pointer;he&&(F=he.position.clone(),U=he.forward.y<-.22)},X=async()=>{if(!navigator.xr)throw new Error("XR ist in diesem Browser nicht verfügbar");if(!await navigator.xr.isSessionSupported("immersive-ar"))throw new Error("Dieser Browser unterstützt keinen Mixed-Reality-Passthrough. Ãffne Aura im Meta Quest Browser.");const ae=t.clearColor.a;try{const he=await t.createDefaultXRExperienceAsync({uiOptions:{sessionMode:"immersive-ar",referenceSpaceType:"local-floor"},optionalFeatures:!0});await he.baseExperience.enterXRAsync("immersive-ar","local-floor"),t.clearColor.a=0,f.visibility=1,ce=!0,he.baseExperience.sessionManager.onXRFrameObservable.add(()=>he.input.controllers.forEach(K));const be=he.baseExperience.featuresManager.enableFeature(Ql.Name,"latest",{disablePermanentHitTest:!1});try{const Le=he.baseExperience.featuresManager.enableFeature(dt.Name,"latest",{xrInput:he.input,jointMeshes:{invisible:!0}});Le.onHandAddedObservable.add(Xe=>{window.dispatchEvent(new CustomEvent("aura-hand-tracking",{detail:{active:!0}}));const it=Xe.getJointMesh(Sh.WRIST),ut=Xe.getJointMesh(Sh.INDEX_FINGER_TIP),Oe=Xe.getJointMesh(Sh.THUMB_TIP);t.onBeforeRenderObservable.add(()=>
3386{if(it.isDisposed()||ut.isDisposed()||Oe.isDisposed())return;q=it.getAbsolutePosition().clone(),k=ut.getAbsolutePosition().clone(),Q=performance.now(),A.position.copyFrom(k),A.visibility=.9,T.Distance(k,Oe.getAbsolutePosition())<.038&&performance.now()-ie>800&&(ie=performance.now(),j())})}),Le.onHandRemovedObservable.add(()=>{performance.now()-Q>250&&window.dispatchEvent(new CustomEvent("aura-hand-tracking",{detail:{active:!1}}))})}catch{window.dispatchEvent(new CustomEvent("aura-hand-tracking",{detail:{active:!1}}))}be.onHitTestResultObservable.add(Le=>{const Xe=Le[0];if(!Xe?.transformationMatrix)return;const it=new T,ut=Xe.transformationMatrix;ut.decompose(void 0,void 0,it);const Oe=he.baseExperience.camera.globalPosition.y,Qe=new T(ut.m[4]??0,ut.m[5]??0,ut.m[6]??0).normalize(),Be=Math.abs(Qe.y)>=.84,Ot=it.y<Oe-.2;if(!Be){M=null,$="Wand oder steile Fläche erkannt â bitte auf Bett, Boden oder Tisch zeigen.";return}if(!Ot){M=null,$="Die Fläche liegt zu hoch für eine Liegeposition â bitte Bett oder Boden wählen.";return}const Wt=k&&q&&performance.now()-Q<450?k.y<q.y-.06:!1;if(!U&&!Wt){M=null,$="Bitte Controller oder Hand nach unten auf die Liegefläche ausrichten.";return}M=it,$="Liegefläche erkannt."})}catch{throw f.visibility=0,t.clearColor.a=ae,ce=!1,new Error("MR-Start abgebrochen oder Freigabe verweigert. Die 2D-Ansicht bleibt aktiv.")}},J=ae=>d.scaling.setAll(ae),se=(ae,he)=>{d.position.x=ae,d.rotation.y=he},w=ae=>{if(ae==="idle"){I=null;return}I={name:ae,startedAt:performance.now(),yaw:d.rotation.y}},L=()=>
3386{if(ce&&!M)return{success:!1,message:$};const ae=ce?M:F??i.position.add(i.getForwardRay().direction.scale(1.65));return ae?(E.position.copyFrom(ae),E.position.y=Math.max(.03,ae.y),E.visibility=.65,{success:!0,message:"Liegefläche markiert."}):{success:!1,message:"Keine Liegefläche erkannt."}},V=()=>{const ae=!!(k&&performance.now()-Q<450);return R=(ae?k:F??i.position.add(i.getForwardRay().direction.scale(1.2))).clone(),C=performance.now()+2800,{success:ae||!!F,source:ae?"Hand":F?"Controller":"Kein Ziel"}},j=()=>{v.material=c,v.scaling.setAll(1.12),window.setTimeout(()=>{v.material=o,v.scaling.setAll(1)},500)};return{engine:e,scene:t,startMixedReality:X,setScale:J,setTransform:se,playBodyAction:w,markLieDownAnchor:L,lookAtHandOrPointer:V,reactToProximity:j,dispose:()=>{window.removeEventListener("resize",G),t.dispose(),e.dispose()}}}function O4({className:n="",scale:e=1,positionX:t=0,yaw:i=0,speaking:s=!1,bodyAction:r="idle",onMixedRealityReady:a,onReactionReady:o,onRoomActionsReady:c,onPanelAction:u}){const d=Y.useRef(null),f=Y.useRef(null),g=Y.useRef(u),m=Y.useRef(a),b=Y.useRef(o),x=Y.useRef(c);return Y.useEffect(()=>{g.current=u},[u]),Y.useEffect(()=>{m.current=a},[a]),Y.useEffect(()=>{b.current=o},[o]),Y.useEffect(()=>{x.current=c},[c]),Y.useEffect(()=>{if(!d.current)return;const v=D4(d.current);f.current=v,m.current?.(v.startMixedReality),b.current?.(v.reactToProximity);const E={markLieDownAnchor:v.markLieDownAnchor,lookAtHandOrPointer:v.lookAtHandOrPointer};x.current?.(E),window.dispatchEvent(new CustomEvent("aura-room-actions",{detail:E}));const A=I=>{const R=v.scene.pick(I.offsetX,I.offsetY)?.pickedMesh?.name;R==="aura-xr-control-0"&&g.current?.("scale"),R==="aura-xr-control-1"&&g.current?.("rotate"),R==="aura-xr-control-2"&&g.current?.("react"),R==="aura-xr-control-3"&&g.current?.("chat"),R==="aura-xr-control-4"&&g.current?.("startMR")},D=I=>v.playBodyAction(I.detail);return d.current.addEventListener("pointerdown",A),window.addEventListener("aura-body-action",D),()=>{d.current?.removeEventListener("pointerdown",A),window.removeEventListener("aura-body-action",D),v.dispose(),f.current=null}},[]),Y.useEffect(()=>{f.current?.setScale(e)},[e]),Y.useEffect(()=>{f.current?.setTransform(t,i)},[t,i]),Y.useEffect(()=>{f.current?.playBodyAction(r)},[r]),B.jsxs(B.Fragment,{children:[B.jsx("style",{"data-loc":"client/src/components/GameCanvas.tsx:45",children:"@keyframes aura-idle-float { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-8px) scale(1.006); } } @keyframes aura-speaking-pulse { 0%,100% { transform: translateY(0) scale(1.01); filter: saturate(1); } 50% { transform: translateY(-5px) scale(1.028); filter: saturate(1.08) brightness(1.035); } }"}),B.jsx("canvas",{"data-loc":"client/src/components/GameCanvas.tsx:46",ref:d,className:`absolute inset-0 h-full w-full touch-none ${n}`,"aria-label":"Babylon 3D Aura Szene"}),B.jsxs("div",{"data-loc":"client/src/components/GameCanvas.tsx:47",className:"pointer-events-none absolute inset-0 z-[1] overflow-hidden rounded-[inherit]",children:[B.jsx("div",{"data-loc":"client/src/components/GameCanvas.tsx:48",className:"absolute -inset-8 bg-cover bg-center opacity-48 blur-[3px]",style:{backgroundImage:"url(/manus-storage/aura-blonde-leather-fullbody_79b41ae7.png)"}}),B.jsx("div",{"data-loc":"client/src/components/GameCanvas.tsx:49",className:"absolute inset-0 bg-gradient-to-r from-[#052128]/50 via-transparent to-[#052128]/48"}),B.jsx("div",{"data-loc":"client/src/components/GameCanvas.tsx:50",className:"absolute inset-0 flex items-end justify-center",children:B.jsx("div",{"data-loc":"client/src/components/GameCanvas.tsx:51",className:"flex h-full items-end justify-center",style:{animation:s?"aura-speaking-pulse 1.15s ease-in-out infinite":"aura-idle-float 4.5s ease-in-out infinite"},children:B.jsx("img",{"data-loc":"client/src/components/GameCanvas.tsx:52",src:"/manus-storage/aura-blonde-leather-fullbody_79b41ae7.png",alt:"Aura, erwachsene KI-Begleiterin",className:"h-[106%] max-w-none object-contain object-bottom drop-shadow-[0_24px_35px_rgba(0,0,0,.38)]",style:{maskImage:"linear-gradient(to right, transparent 0%, black 18%, black 82%, transparent 100%), linear-gradient(to bottom, transparent 0%, black 8%, black 88%, transparent 100%)",maskComposite:"intersect"}})})}),B.jsx("div",{"data-loc":"client/src/components/GameCanvas.tsx:55",className:"absolute right-8 top-8 flex items-center gap-2 rounded-full border border-cyan-100/25 bg-[#052128]/60 px-3 py-1.5 text-[10px] font-semibold uppercase tracking-[.16em] text-cyan-50/90 backdrop-blur",children:s?"Aura spricht":"Aura ist bei dir"})]})]})}function w4(n){return new Promise((e,t)=>
3386{const i=new FileReader;i.onload=()=>e(String(i.result).split(",")[1]??""),i.onerror=()=>t(i.error),i.readAsDataURL(n)})}function F4({onConfirm:n,onStatus:e}){const[t,i]=Y.useState(!1),[s,r]=Y.useState(""),a=Y.useRef(null),o=Y.useRef([]),c=ns.voice.transcribe.useMutation({onSuccess:g=>{r(g.text),e("Transkript prüfen und bestätigen")},onError:g=>e(g.message)}),u=async()=>{try{const g=await navigator.mediaDevices.getUserMedia({audio:!0}),m=new MediaRecorder(g,{mimeType:MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":void 0});o.current=[],m.ondataavailable=b=>{b.data.size&&o.current.push(b.data)},m.onstop=async()=>{g.getTracks().forEach(x=>x.stop());const b=new Blob(o.current,{type:m.mimeType||"audio/webm"});if(b.size>16*1024*1024){e("Die Aufnahme ist gröÃer als 16 MB.");return}e("Deutschsprachige Transkription läuft â¦"),c.mutate({audioBase64:await w4(b),mimeType:m.mimeType||"audio/webm"})},a.current=m,m.start(),i(!0),e("Aufnahme läuft · erneut drücken zum Stoppen")}catch{e("Mikrofonzugriff wurde nicht erteilt.")}},d=()=>{a.current?.stop(),i(!1)},f=()=>{s.trim()&&(n(s.trim()),r(""))};return B.jsxs(B.Fragment,{children:[B.jsx(ai,{"data-loc":"client/src/components/VoiceCapture.tsx:39",onClick:t?d:u,size:"icon","aria-label":t?"Aufnahme stoppen":"Mikrofon starten",className:`shrink-0 rounded-full ${t?"bg-orange-400 text-[#122126]":"bg-white/10 text-white"}`,children:t?B.jsx(QB,{"data-loc":"client/src/components/VoiceCapture.tsx:39",className:"h-4 w-4"}):B.jsx(yM,{"data-loc":"client/src/components/VoiceCapture.tsx:39",className:"h-4 w-4"})}),c.isPending&&B.jsx(pb,{"data-loc":"client/src/components/VoiceCapture.tsx:39",className:"h-4 w-4 animate-spin text-cyan-200"}),s&&B.jsxs("div",{"data-loc":"client/src/components/VoiceCapture.tsx:39",className:"fixed inset-x-0 bottom-6 z-40 mx-auto max-w-lg rounded-3xl border border-cyan-300/30 bg-[#0a262c] p-4 shadow-2xl",children:[B.jsx("p",{"data-loc":"client/src/components/VoiceCapture.tsx:39",className:"text-xs font-semibold uppercase tracking-wider text-cyan-200",children:"Transkript vor dem Senden"}),B.jsx("textarea",{"data-loc":"client/src/components/VoiceCapture.tsx:39",value:s,onChange:g=>r(g.target.value),className:"mt-3 min-h-24 w-full rounded-xl border border-white/10 bg-black/20 p-3 text-sm text-white outline-none focus:border-cyan-300/60"}),B.jsxs("div",{"data-loc":"client/src/components/VoiceCapture.tsx:39",className:"mt-3 flex justify-end gap-2",children:[B.jsxs(ai,{"data-loc":"client/src/components/VoiceCapture.tsx:39",onClick:()=>r(""),variant:"outline",className:"border-white/15 bg-transparent text-white",children:[B.jsx(TM,{"data-loc":"client/src/components/VoiceCapture.tsx:39",className:"mr-1 h-4 w-4"})," Verwerfen"]}),B.jsxs(ai,{"data-loc":"client/src/components/VoiceCapture.tsx:39",onClick:f,className:"bg-cyan-300 text-[#09252a] hover:bg-cyan-200",children:[B.jsx(mM,{"data-loc":"client/src/components/VoiceCapture.tsx:39",className:"mr-1 h-4 w-4"})," Bestätigen"]})]})]})]})}const L4=["Du siehst heute umwerfend aus.","Erzähl mir etwas Geheimnisvolles.","Lass uns ein Spiel spielen."],gA=[{label:"Dreh dich",transcript:"Dreh dich",action:"turn"},{label:"Faust heben",transcript:"Mach eine Faust und heb die Hand",action:"fist"},{label:"Hinlegen",transcript:"Leg dich hin",action:"lie"},{label:"Kuss",transcript:"Gib mir einen Kuss",action:"kiss"},{label:"Winken",transcript:"Wink mir zu",action:"wave"},{label:"Tanzen",transcript:"Tanz für mich",action:"dance"},{label:"Aufs Bett",transcript:"Leg dich aufs Bett",action:"lie"},{label:"Schau Ziel",transcript:"Schau mal meinen Fuà an",action:"idle"}];function N4({speaking:n}){return B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:27",className:`relative flex h-[min(54vw,27rem)] w-[min(54vw,27rem)] items-center justify-center transition-transform duration-500 ${n?"scale-[1.02]":""}`,children:[B.jsx("div",{"data-loc":"client/src/pages/Home.tsx:28",className:"absolute inset-0 rounded-full bg-cyan-300/10 blur-3xl"}),B.jsx("div",{"data-loc":"client/src/pages/Home.tsx:29",className:"absolute bottom-0 h-24 w-64 roun
3386ded-[50%] bg-orange-400/20 blur-2xl"}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:30",className:"relative h-64 w-48 rounded-[46%_46%_42%_42%] border border-cyan-200/40 bg-gradient-to-b from-[#e9b69d] via-[#b86e67] to-[#18383c] shadow-[0_0_60px_rgba(34,211,238,.18)]",children:[B.jsx("div",{"data-loc":"client/src/pages/Home.tsx:31",className:"absolute -top-8 left-1/2 h-28 w-48 -translate-x-1/2 rounded-[50%_50%_18%_18%] bg-[#26181b] shadow-[0_0_25px_rgba(234,122,60,.2)]"}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:32",className:"absolute left-1/2 top-12 flex w-28 -translate-x-1/2 justify-between",children:[B.jsx("span",{"data-loc":"client/src/pages/Home.tsx:33",className:"h-3 w-3 rounded-full bg-[#10151a] shadow-[0_0_12px_#22d3ee]"}),B.jsx("span",{"data-loc":"client/src/pages/Home.tsx:33",className:"h-3 w-3 rounded-full bg-[#10151a] shadow-[0_0_12px_#22d3ee]"})]}),B.jsx("div",{"data-loc":"client/src/pages/Home.tsx:35",className:`absolute bottom-16 left-1/2 h-2 w-10 -translate-x-1/2 rounded-full bg-orange-400 shadow-[0_0_16px_#ea7a3c] transition-all ${n?"h-4 w-12":""}`}),B.jsx("div",{"data-loc":"client/src/pages/Home.tsx:36",className:"absolute -bottom-20 left-1/2 h-32 w-56 -translate-x-1/2 rounded-[50%] border border-cyan-300/50 bg-[#0b3035]/90"})]}),B.jsx("div",{"data-loc":"client/src/pages/Home.tsx:38",className:"absolute bottom-0 h-3 w-56 rounded-full bg-cyan-300/50 blur-sm"})]})}function B4({onAccept:n}){return B.jsx("div",{"data-loc":"client/src/pages/Home.tsx:44",className:"fixed inset-0 z-50 grid place-items-center bg-[#061a20]/95 p-6 backdrop-blur-xl",children:B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:45",className:"w-full max-w-lg rounded-3xl border border-cyan-200/20 bg-[#0b272c]/95 p-8 text-center shadow-2xl",children:[B.jsx("div",{"data-loc":"client/src/pages/Home.tsx:46",className:"mx-auto mb-5 grid h-14 w-14 place-items-center rounded-2xl bg-orange-400 text-[#132126]",children:B.jsx(Yh,{"data-loc":"client/src/pages/Home.tsx:46"})}),B.jsx("p",{"data-loc":"client/src/pages/Home.tsx:47",className:"mb-2 text-xs font-semibold uppercase tracking-[.28em] text-cyan-200/70",children:"Privater Companion Space"}),B.jsx("h2",{"data-loc":"client/src/pages/Home.tsx:48",className:"text-3xl font-black tracking-tight text-white",children:"Nur für Erwachsene"}),B.jsx("p",{"data-loc":"client/src/pages/Home.tsx:49",className:"mt-4 leading-relaxed text-white/65",children:"Aura ist eine erwachsene KI-Begleiterin für spielerische Gespräche. Bitte bestätige, dass du mindestens 18 Jahre alt bist und die lokale Nutzung auf deinem eigenen Gerät erfolgt."}),B.jsx(ai,{"data-loc":"client/src/pages/Home.tsx:50",onClick:n,className:"mt-7 h-12 w-full bg-orange-400 font-bold text-[#132126] hover:bg-orange-300",children:"Ich bin 18+ und fortfahren"}),B.jsx("p",{"data-loc":"client/src/pages/Home.tsx:51",className:"mt-4 text-xs text-white/35",children:"Keine echten Berührungen: Feedback erfolgt visuell, akustisch und über Controller."})]})})}function U4(){const[,n]=mb(),[e,t]=Y.useState(!1),[i,s]=Y.useState(null),[r,a]=Y.useState(null),[o,c]=Y.useState(""),[u,d]=Y.useState([{from:"aura",text:"Ich bin bereit, deinen Raum ein wenig besonderer zu machen."}]),[f,g]=Y.useState([1]),[m,b]=Y.useState([0]),[x,v]=Y.useState([0]),[E,A]=Y.useState("Desktop-Fallback aktiv"),[D,I]=Y.useState(!1),[R,C]=Y.useState(null),M=ns.kindroid.status.useQuery(),F=ns.payments.createCheckout.useMutation({onSuccess:({url:L})=>window.open(L,"_blank","noopener,noreferrer"),onError:L=>A(L.message)}),U=ns.kindroid.history.useQuery(void 0,{enabled:!!M.data?.connected,retry:!1,refetchOnWindowFocus:!1});Y.useEffect(()=>{Array.isArray(U.data)&&U.data.length&&d(U.data.map(L=>({from:L.role==="user"?"you":"aura",text:L.text})))},[U.data]),Y.useEffect(()=>{const L=V=>C(V.detail);return window.addEventListener("aura-room-actions",L),()=>window.removeEventListener("aura-room-actions",L)},[]),Y.useEffect(()=>{const L=V=>I(!!V.detail.active);return window.addEventListener("aura-hand-tracking",L),()=>window.removeEventListener("aura-hand-tracking",L)},[]);const k=ns.kindroid.send.useMutation({onSuccess:({reply:L})=>{d(ae=>[...ae,{from:"aura",text:L}]),t(!0),A("Aura antwortet");const V=()=>t(!1),j=new SpeechSynthesisUtterance(L);j.lang="de-DE",j.onend=V,window.speechSynthesis.cancel(),window.speechSynthesis.speak(j),window.setTimeout(V,12e3)},onError:L=>A(L.message)}),q=ns.kindroid.chatBreak.useMutation({onSuccess:()=>{d([]),A("Neue Unterhaltung gestartet")},onError:L=>A(L.message)}),Q=ns.kindroid.rewind.useMutation({onSuccess:()=>{d(L=>L.slice(0,-2)),A("Letzten Austausch zurückgenommen")},onError:L=>A(L.message)}),ie=()=>
3386M.data?.connected?!0:(A("Kindroid noch nicht verbunden â öffne die Einstellungen."),n("/settings"),!1),$=(L=o)=>{!L.trim()||k.isPending||!ie()||(d(V=>[...V,{from:"you",text:L}]),c(""),A("Aura schreibt â¦"),k.mutate({message:L}))},ce=()=>{ie()&&Q.mutate({count:2})},G=()=>{ie()&&q.mutate({greeting:"Hallo, lass uns neu beginnen."})},K=()=>{if(typeof i!="function"){A("MR-Start wird noch vorbereitet. Bitte gleich erneut versuchen.");return}A("Prüfe Quest-3-Passthrough â¦"),i().then(()=>A("Mixed Reality aktiv â Aura steht vor dir.")).catch(L=>A(L instanceof Error?L.message:"Der MR-Start wurde abgebrochen."))},X=(L,V)=>{window.dispatchEvent(new CustomEvent("aura-body-action",{detail:L})),A(`Aura führt aus: ${V}`)},J=L=>{const V=L.toLowerCase();if(/schau.*(fuÃ|fuss|hierhin|dorthin)/.test(V)){const ae=R?.lookAtHandOrPointer();A(ae?.success?`Aura folgt deiner ${ae.source==="Hand"?"direkt erkannten Hand":"Controller-Spitze"} mit dem Blick.`:"Richte Hand oder Controller auf das Ziel und wiederhole den Befehl in MR.");return}if(/(bett|liegefläche|liegeflaeche)/.test(V)){const ae=R?.markLieDownAnchor();if(!ae?.success){A(ae?.message??"Raumanker wird noch vorbereitet. Bitte gleich erneut versuchen.");return}X("lie",L),A("Liegefläche markiert â Aura legt sich dort hin.");return}const j=gA.find(ae=>V.includes(ae.transcript.toLowerCase().split(" ")[0])||ae.action==="fist"&&V.includes("faust")||ae.action==="kiss"&&/kuss|küss/.test(V));if(j&&j.action!=="idle"){X(j.action,L);return}c(L),A("Transkript bestätigt â bereit zum Senden")},se=L=>{A(L==="payment"?"Checkout für den Einmalkauf wird geöffnet â¦":"Checkout für Premium wird geöffnet â¦"),F.mutate({mode:L})},w=L=>{L==="scale"&&(g(([V])=>[V>=1.4?.7:Number((V+.1).toFixed(1))]),A("3D-Panel: GröÃe angepasst")),L==="rotate"&&(v(([V])=>[V>=1.2?-1.2:Number((V+.2).toFixed(1))]),A("3D-Panel: Ausrichtung angepasst")),L==="react"&&(r?.(),A("3D-Panel: Nähe-Reaktion")),L==="chat"&&$("Erzähl mir etwas aus deinem Tag."),L==="startMR"&&K()};return B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:94",className:"relative min-h-screen overflow-hidden bg-[#061a20] text-white",children:[B.jsx("div",{"data-loc":"client/src/pages/Home.tsx:95",className:"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_23%_55%,rgba(234,122,60,.45),transparent_31%),radial-gradient(circle_at_80%_30%,rgba(15,105,111,.6),transparent_40%),linear-gradient(135deg,#062329,#102329_52%,#09171e)]"}),B.jsxs("header",{"data-loc":"client/src/pages/Home.tsx:96",className:"relative z-10 flex items-center justify-between px-6 py-5 lg:px-10",children:[B.jsxs(Qa,{"data-loc":"client/src/pages/Home.tsx:96",href:"/",className:"flex items-center gap-3",children:[B.jsx("span",{"data-loc":"client/src/pages/Home.tsx:96",className:"grid h-10 w-10 place-items-center rounded-xl bg-cyan-300 font-black text-[#09252a]",children:"A"}),B.jsx("span",{"data-loc":"client/src/pages/Home.tsx:96",className:"font-black tracking-[.2em]",children:"AURA"})]}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:96",className:"flex items-center gap-3",children:[B.jsxs(OM,{"data-loc":"client/src/pages/Home.tsx:96",variant:"outline",className:M.data?.connected?"border-emerald-300/30 bg-emerald-300/10 text-emerald-100":"border-orange-300/30 bg-orange-300/10 text-orange-200",children:[B.jsx("span",{"data-loc":"client/src/pages/Home.tsx:96",className:`mr-2 inline-block h-2 w-2 rounded-full ${M.data?.connected?"bg-emerald-300":"bg-orange-300"}`}),M.data?.connected?`${M.data.aiName} verbunden`:"Kindroid nicht verbunden"]}),B.jsx(Qa,{"data-loc":"client/src/pages/Home.tsx:96",href:"/settings",children:B.jsxs(ai,{"data-loc":"client/src/pages/Home.tsx:96",variant:"outline",className:"border-white/15 bg-white/5 text-white hover:bg-white/10",children:[B.jsx(vM,{"data-loc":"client/src/pages/Home.tsx:96",className:"mr-2 h-4 w-4"})," Einstellungen"]})})]})]}),B.jsxs("main",{"data-loc":"client/src/pages/Home.tsx:97",className:"relative z-10 grid min-h-[calc(100vh-84px)] grid-cols-1 items-center gap-6 px-5 pb-8 lg:grid-cols-[1fr_390px] lg:px-10",children:[B.jsxs("section",{"data-loc":"client/src/pages/Home.tsx:98",className:"relative flex min-h-[580px] flex-col items-center justify-center overflow-hidden rounded-[3rem] border border-white/5",children:[B.jsx("div",{"data-loc":"client/src/pages/Home.tsx:98",className:"absolute inset-0 opacity-100",children:B.jsx(O4,{"data-loc":"client/src/pages/Home.tsx:98",scale:f[0],positionX:m[0],yaw:x[0],speaking:e,onMixedRealityReady:L=>
3386s(()=>L),onReactionReady:L=>a(()=>L),onPanelAction:w})}),B.jsx("div",{"data-loc":"client/src/pages/Home.tsx:98",className:"pointer-events-none absolute left-8 top-8 z-10 text-xs font-semibold uppercase tracking-[.28em] text-cyan-100/75",children:"Mixed Reality Companion"}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:98",className:"pointer-events-none absolute bottom-8 left-8 z-10 flex items-center gap-3 text-sm text-white/75",children:[B.jsx("span",{"data-loc":"client/src/pages/Home.tsx:98",className:"h-2 w-2 rounded-full bg-cyan-300 shadow-[0_0_12px_#22d3ee]"}),"Aura beobachtet deinen Blick"]})]}),B.jsxs("aside",{"data-loc":"client/src/pages/Home.tsx:99",className:"rounded-3xl border border-white/10 bg-[#09232a]/75 p-4 shadow-2xl backdrop-blur-xl",children:[B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:99",className:"mb-4 flex items-center justify-between",children:[B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:99",children:[B.jsx("p",{"data-loc":"client/src/pages/Home.tsx:99",className:"text-xs uppercase tracking-[.2em] text-cyan-200/60",children:"Private session"}),B.jsx("h1",{"data-loc":"client/src/pages/Home.tsx:99",className:"text-xl font-bold",children:"Dein Raum, eure Regeln."})]}),B.jsx(ai,{"data-loc":"client/src/pages/Home.tsx:99",size:"icon",variant:"ghost",className:"text-white/50",children:B.jsx(TM,{"data-loc":"client/src/pages/Home.tsx:99",className:"h-4 w-4"})})]}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:99",className:"mb-4 rounded-2xl border border-white/10 bg-black/15 p-3 text-xs text-white/55",children:[B.jsx(jB,{"data-loc":"client/src/pages/Home.tsx:99",className:"mr-2 inline h-4 w-4 text-cyan-200"})," Ziehen = bewegen · Mausrad = GröÃe · Quest-3-Controller = greifen"]}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:99",className:"mb-4 flex items-center justify-between rounded-2xl border border-orange-300/20 bg-orange-300/10 p-3",children:[B.jsx("span",{"data-loc":"client/src/pages/Home.tsx:99",className:"text-xs uppercase tracking-wider text-orange-100/70",children:"Status"}),B.jsx("span",{"data-loc":"client/src/pages/Home.tsx:99",className:"text-xs text-orange-100",children:E})]}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:100",className:"max-h-52 space-y-3 overflow-y-auto pr-1",children:[U.isLoading&&B.jsx("div",{"data-loc":"client/src/pages/Home.tsx:100",className:"rounded-2xl bg-white/5 p-3 text-xs text-white/45",children:"Verlauf wird geladen â¦"}),U.error&&M.data?.connected&&B.jsx("div",{"data-loc":"client/src/pages/Home.tsx:100",className:"rounded-2xl bg-orange-300/10 p-3 text-xs text-orange-100",children:"Lokaler Verlauf konnte nicht geladen werden."}),u.map((L,V)=>B.jsx("div",{"data-loc":"client/src/pages/Home.tsx:100",className:`rounded-2xl p-3 text-sm ${L.from==="you"?"ml-8 bg-cyan-300/15 text-cyan-50":"mr-5 bg-white/8 text-white/75"}`,children:L.text},V))]}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:101",className:"mt-4 flex gap-2",children:[B.jsx(F4,{"data-loc":"client/src/pages/Home.tsx:101",onStatus:A,onConfirm:J}),B.jsx(Yl,{"data-loc":"client/src/pages/Home.tsx:101",value:o,onChange:L=>c(L.target.value),onKeyDown:L=>L.key==="Enter"&&$(),placeholder:"Schreib Aura etwas â¦",className:"border-white/10 bg-black/20 text-white placeholder:text-white/35"}),B.jsx(ai,{"data-loc":"client/src/pages/Home.tsx:101",onClick:()=>$(),size:"icon",className:"rounded-full bg-cyan-300 text-[#09252a] hover:bg-cyan-200",children:B.jsx(qB,{"data-loc":"client/src/pages/Home.tsx:101",className:"h-4 w-4"})})]}),B.jsx("div",{"data-loc":"client/src/pages/Home.tsx:102",className:"mt-3 flex flex-wrap gap-2",children:L4.map(L=>B.jsx("button",{"data-loc":"client/src/pages/Home.tsx:102",onClick:()=>$(L),className:"rounded-full border border-white/10 bg-white/5 px-3 py-2 text-left text-xs text-white/65 transition hover:border-cyan-300/40 hover:text-white",children:L},L))}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:102",className:"mt-3",children:[B.jsx("p",{"data-loc":"client/src/pages/Home.tsx:102",className:"mb-2 text-[10px] font-semibold uppercase tracking-[.16em] text-cyan-100/55",children:"Sprach- und Raumbefehle"}),B.jsx("div",{"data-loc":"client/src/pages/Home.tsx:102",className:"flex flex-wrap gap-1.5",children:gA.map(L=>B.jsx("button",{"data-loc":"client/src/pages/Home.tsx:102",onClick:()=>J(L.transcript),className:"rounded-full border border-cyan-300/20 bg-cyan-300/5 px-2.5 py-1.5 text-[11px] text-cyan-100 transition hover:bg-cyan-300/15",children:L.label},`${L.action}-${L.label}`))}),B.jsx("p",{"data-loc":"client/src/pages/Home.tsx:102",className:"mt-2 text-[10px] leading-relaxed text-white/40",children:"In MR: Für âAufs Bettâ mit dem Controller nach unten auf Bett, Boden oder Tisch zeigen. âSchau Zielâ folgt deinem Hand-/Controller-Zeiger."})]}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:102",className:"mt-3 flex gap-2",children:[B.jsx(ai,{"data-loc":"client/src/pages/Home.tsx:102",onClick:ce,variant:"outline",className:"h-8 border border-white/10 bg-transparent px-3 text-xs text-white",children:"Rückgängig"}),B.jsx(ai,{"data-loc":"client/src/pages/Home.tsx:102",onClick:G,variant:"outline",className:"h-8 border border-white/10 bg-transparent px-3 text-xs text-white",children:"Neustart"})]}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:103",className:"mt-3 flex items-center justify-between rounded-xl border border-cyan-300/15 bg-cyan-300/5 px-3 py-2 text-[11px]",children:[B.jsx("span",{"data-loc":"client/src/pages/Home.tsx:103",className:"text-cyan-50/75",children:"Hand-Tracking"}),B.jsx("span",{"data-loc":"client/src/pages/Home.tsx:103",className:D?"font-semibold text-emerald-200":"text-white/45",children:D?"Hand erkannt · Pinch reagiert":"Controller-Fallback aktiv"})]}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:104",className:"mt-4 rounded-2xl border border-white/10 bg-black/15 p-3",children:[B.jsx("p",{"data-loc":"client/src/pages/Home.tsx:104",className:"mb-2 text-[10px] font-semibold uppercase tracking-[.16em] text-cyan-100/55",children:"Aura-Aktionen"}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:104",className:"grid grid-cols-2 gap-2",children:[B.jsx(ai,{"data-loc":"client/src/pages/Home.tsx:104",onClick:()=>X("wave","Winken"),variant:"outline",className:"border-cyan-300/20 bg-cyan-300/5 text-xs text-white hover:bg-cyan-300/15",children:"Winken"}),B.jsx(ai,{"data-loc":"client/src/pages/Home.tsx:104",onClick:()=>X("dance","Tanzen"),variant:"outline",className:"border-orange-300/20 bg-orange-300/5 text-xs text-white hover:bg-orange-300/15",children:"Tanzen"}),B.jsx(ai,{"data-loc":"client/src/pages/Home.tsx:104",onClick:()=>X("hug","Umarmung"),variant:"outline",className:"border-white/10 bg-white/5 text-xs text-white",children:"Umarmen"}),B.jsx(ai,{"data-loc":"client/src/pages/Home.tsx:104",onClick:()=>X("kiss","Kuss"),variant:"outline",className:"border-white/10 bg-white/5 text-xs text-white",children:"Kuss"})]})]}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:105",className:"mt-4 rounded-2xl border border-orange-300/20 bg-orange-300/10 p-3",children:[B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:105",className:"flex items-center gap-2",children:[B.jsx(VB,{"data-loc":"client/src/pages/Home.tsx:105",className:"h-4 w-4 text-orange-200"}),B.jsx("p",{"data-loc":"client/src/pages/Home.tsx:105",className:"text-sm font-semibold text-white",children:"Aura-Zugang"})]}),B.jsx("p",{"data-loc":"client/src/pages/Home.tsx:105",className:"mt-1 text-xs leading-relaxed text-white/55",children:"Zahle einmalig 50 ⬠oder aktiviere Premium für 20 ⬠im Monat."}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:105",className:"mt-3 grid grid-cols-2 gap-2",children:[B.jsx(ai,{"data-loc":"client/src/pages/Home.tsx:105",onClick:()=>se("payment"),disabled:F.isPending,className:"bg-orange-400 text-xs font-bold text-[#132126] hover:bg-orange-300",children:"50 ⬠einmalig"}),B.jsx(ai,{"data-loc":"client/src/pages/Home.tsx:105",onClick:()=>se("subscription"),disabled:F.isPending,variant:"outline",className:"border-orange-300/40 bg-transparent text-xs text-orange-100 hover:bg-orange-300/15",children:"20 ⬠/ Monat"})]})]}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:105",className:"mt-5 space-y-4 border-t border-white/10 pt-4",children:[B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:105",children:[B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:105",className:"mb-2 flex justify-between text-xs text-white/50",children:[B.jsx("span",{"data-loc":"client/src/pages/Home.tsx:105",children:"GröÃe"}),B.jsxs("span",{"data-loc":"client/src/pages/Home.tsx:105",children:[f[0].toFixed(1),"Ã"]})]}),B.jsx(Ig,{"data-loc":"client/src/pages/Home.tsx:105",value:f,min:.7,max:1.4,step:.1,onValueChange:g})]}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:105",children:[B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:105",className:"mb-2 flex justify-between text-xs text-white/50",children:[B.jsx("span",{"data-loc":"client/src/pages/Home.tsx:105",children:"Seitliche Position"}),B.jsxs("span",{"data-loc":"client/src/pages/Home.tsx:105",children:[m[0].toFixed(1)," m"]})]}),B.jsx(Ig,{"data-loc":"client/src/pages/Home.tsx:105",value:m,min:-.9,max:.9,step:.1,onValueChange:b})]}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:105",children:[B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:105",className:"mb-2 flex justify-between text-xs text-white/50",children:[B.jsx("span",{"data-loc":"client/src/pages/Home.tsx:105",children:"Ausrichtung"}),B.jsxs("span",{"data-loc":"client/src/pages/Home.tsx:105",children:[Math.round(x[0]*57),"°"]})]}),B.jsx(Ig,{"data-loc":"client/src/pages/Home.tsx:105",value:x,min:-1.2,max:1.2,step:.1,onValueChange:v})]})]}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:106",className:"mt-4 grid grid-cols-3 gap-2",children:[B.jsxs(ai,{"data-loc":"client/src/pages/Home.tsx:106",onClick:()=>{r?.(),navigator.vibrate?.(15),A("Nähe-Reaktion aktiviert")},variant:"outline",className:"border-white/10 bg-white/5 px-2 text-xs text-white",children:[B.jsx(bM,{"data-loc":"client/src/pages/Home.tsx:106",className:"mr-1 h-4 w-4"})," Nähe"]}),B.jsxs(ai,{"data-loc":"client/src/pages/Home.tsx:106",onClick:()=>t(L=>!L),variant:"outline",className:"border-white/10 bg-white/5 px-2 text-xs text-white",children:[B.jsx(SM,{"data-loc":"client/src/pages/Home.tsx:106",className:"mr-1 h-4 w-4"})," Stimme"]}),B.jsxs(ai,{"data-loc":"client/src/pages/Home.tsx:106",onClick:K,className:"bg-orange-400 px-2 text-xs text-[#132126] hover:bg-orange-300",children:[B.jsx(YB,{"data-loc":"client/src/pages/Home.tsx:106",className:"mr-1 h-4 w-4"})," MR starten"]})]})]})]})]})}function k4(){return B.jsx("div",{"data-loc":"client/src/pages/Home.tsx:113",className:"min-h-screen bg-[#071d24] px-6 py-8 text-white",children:B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:113",className:"mx-auto max-w-2xl",children:[B.jsx(Qa,{"data-loc":"client/src/pages/Home.tsx:113",href:"/experience",className:"text-sm text-cyan-200",children:"â Zur Experience"}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:113",className:"mt-10 flex items-start justify-between",children:[B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:113",children:[B.jsx("p",{"data-loc":"client/src/pages/Home.tsx:113",className:"text-xs uppercase tracking-[.25em] text-cyan-200/60",children:"Private Verbindung"}),B.jsx("h1",{"data-loc":"client/src/pages/Home.tsx:113",className:"mt-2 text-4xl font-black",children:"Kindroid verbinden"})]}),B.jsx(vM,{"data-loc":"client/src/pages/Home.tsx:113",className:"h-8 w-8 text-orange-300"})]}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:113",className:"mt-8 rounded-3xl border border-white/10 bg-white/5 p-6",children:[B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:113",className:"flex gap-3",children:[B.jsx(Yh,{"data-loc":"client/src/pages/Home.tsx:113",className:"mt-1 text-cyan-200"}),B.jsxs("p",{"data-loc":"client/src/pages/Home.tsx:113",className:"text-sm leading-relaxed text-white/65",children:["Dein ",B.jsx("strong",{"data-loc":"client/src/pages/Home.tsx:113",className:"text-white",children:"kn_-API-Key"})," darf nur serverseitig gespeichert werden und wird niemals an den Browser zurückgegeben. Die Felder unten sind in dieser wiederhergestellten Demo noch nicht angeschlossen."]})]}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:113",className:"mt-6 space-y-4",children:[B.jsxs("label",{"data-loc":"client/src/pages/Home.tsx:113",className:"block text-sm text-white/65",children:["AI-ID",B.jsx(Yl,{"data-loc":"client/src/pages/Home.tsx:113",className:"mt-2 border-white/10 bg-black/20 text-white",placeholder:"z. B. deine Kindroid AI-ID"})]}),B.jsxs("label",{"data-loc":"client/src/pages/Home.tsx:113",className:"block text-sm text-white/65",children:["kn_-API-Key",B.jsx(Yl,{"data-loc":"client/src/pages/Home.tsx:113",type:"password",className:"mt-2 border-white/10 bg-black/20 text-white",placeholder:"Wird verschlüsselt übertragen"})]}),B.jsx(ai,{"data-loc":"client/src/pages/Home.tsx:113",className:"w-full bg-orange-400 text-[#132126] hover:bg-orange-300",children:"Verbindung sicher testen"})]})]}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:113",className:"mt-6 grid gap-3 sm:grid-cols-3",children:[B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:113",className:"rounded-2xl border border-white/10 bg-white/5 p-4",children:[B.jsx(bM,{"data-loc":"client/src/pages/Home.tsx:113",className:"mb-3 text-orange-300"}),B.jsx("p",{"data-loc":"client/src/pages/Home.tsx:113",className:"font-semibold",children:"Flirt-Modus"}),B.jsx("p",{"data-loc":"client/src/pages/Home.tsx:113",className:"mt-1 text-xs text-white/50",children:"Spielerisch und erwachsen."})]}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:113",className:"rounded-2xl border border-white/10 bg-white/5 p-4",children:[B.jsx(JB,{"data-loc":"client/src/pages/Home.tsx:113",className:"mb-3 text-cyan-200"}),B.jsx("p",{"data-loc":"client/src/pages/Home.tsx:113",className:"font-semibold",children:"Aktivitäten"}),B.jsx("p",{"data-loc":"client/src/pages/Home.tsx:113",className:"mt-1 text-xs text-white/50",children:"Spiele, Fragen, Reaktionen."})]}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:113",className:"rounded-2xl border border-white/10 bg-white/5 p-4",children:[B.jsx(SM,{"data-loc":"client/src/pages/Home.tsx:113",className:"mb-3 text-orange-300"}),B.jsx("p",{"data-loc":"client/src/pages/Home.tsx:113",className:"font-semibold",children:"Voice"}),B.jsx("p",{"data-loc":"client/src/pages/Home.tsx:113",className:"mt-1 text-xs text-white/50",children:"Whisper + Browser-TTS."})]})]})]})})}function mA(){const[n]=mb(),[e,t]=Y.useState(()=>localStorage.getItem("aura-age-18")==="yes"||window.location.search.includes("demo"));Y.useEffect(()=>{document.title="Aura MR Companion â Private Meta Quest 3 Experience"},[]),Y.useEffect(()=>{localStorage.getItem("aura-age-18")==="yes"&&t(!0)},[]);const i=()=>{localStorage.setItem("aura-age-18","yes"),t(!0)};return e?n==="/experience"?B.jsx(U4,{"data-loc":"client/src/pages/Home.tsx:123"}):n==="/settings"?B.jsx(k4,{"data-loc":"client/src/pages/Home.tsx:124"}):B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:125",className:"min-h-screen bg-[#071d24] text-white",children:[B.jsx("div",{"data-loc":"client/src/pages/Home.tsx:125",className:"absolute inset-0 bg-[radial-gradient(circle_at_20%_30%,rgba(234,122,60,.3),transparent_30%),radial-gradient(circle_at_80%_70%,rgba(34,211,238,.18),transparent_35%)]"}),B.jsxs("header",{"data-loc":"client/src/pages/Home.tsx:125",className:"relative flex items-center justify-between px-6 py-6 lg:px-12",children:[B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:125",className:"flex items-center gap-3",children:[B.jsx("span",{"data-loc":"client/src/pages/Home.tsx:125",className:"grid h-10 w-10 place-items-center rounded-xl bg-cyan-300 font-black text-[#09252a]",children:"A"}),B.jsx("span",{"data-loc":"client/src/pages/Home.tsx:125",className:"font-black tracking-[.2em]",children:"AURA"})]}),B.jsx(OM,{"data-loc":"client/src/pages/Home.tsx:125",variant:"outline",className:"border-white/15 text-white/60",children:"18+ · Private beta"})]}),B.jsxs("main",{"data-loc":"client/src/pages/Home.tsx:125",className:"relative mx-auto grid max-w-6xl items-center gap-12 px-6 pb-20 pt-16 lg:grid-cols-[1.1fr_.9fr] lg:
3386px-12 lg:pt-28",children:[B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:125",children:[B.jsx("p",{"data-loc":"client/src/pages/Home.tsx:125",className:"mb-5 text-xs font-semibold uppercase tracking-[.35em] text-orange-300",children:"Mixed Reality · Quest 3 · Kindroid"}),B.jsxs("h1",{"data-loc":"client/src/pages/Home.tsx:125",className:"max-w-3xl text-5xl font-black leading-[.98] tracking-tight md:text-7xl",children:["Eine Stimme.",B.jsx("br",{"data-loc":"client/src/pages/Home.tsx:125"}),B.jsx("span",{"data-loc":"client/src/pages/Home.tsx:125",className:"text-cyan-200",children:"Dein Raum."})]}),B.jsx("h2",{"data-loc":"client/src/pages/Home.tsx:125",className:"mt-5 max-w-xl text-xl font-semibold tracking-tight text-cyan-100 md:text-2xl",children:"Deine private KI-Begleiterin in Mixed Reality"}),B.jsx("p",{"data-loc":"client/src/pages/Home.tsx:125",className:"mt-7 max-w-xl text-lg leading-relaxed text-white/60",children:"Aura bringt eine erwachsene KI-Begleiterin als ruhige, präsente Figur in dein Zimmer. Sprich, spiel, flirte â mit deiner eigenen Kindroid-Verbindung."}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:125",className:"mt-9 flex flex-wrap gap-3",children:[B.jsx(Qa,{"data-loc":"client/src/pages/Home.tsx:125",href:"/experience",children:B.jsxs(ai,{"data-loc":"client/src/pages/Home.tsx:125",className:"h-12 bg-orange-400 px-6 font-bold text-[#132126] hover:bg-orange-300",children:[B.jsx($B,{"data-loc":"client/src/pages/Home.tsx:125",className:"mr-2 h-4 w-4"})," Experience öffnen"]})}),B.jsx(Qa,{"data-loc":"client/src/pages/Home.tsx:125",href:"/settings",children:B.jsxs(ai,{"data-loc":"client/src/pages/Home.tsx:125",variant:"outline",className:"h-12 border-white/15 bg-white/5 px-6 text-white hover:bg-white/10",children:[B.jsx(Yh,{"data-loc":"client/src/pages/Home.tsx:125",className:"mr-2 h-4 w-4"})," Verbindung einrichten"]})})]}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:125",className:"mt-12 grid max-w-xl grid-cols-3 gap-4 border-t border-white/10 pt-5 text-xs text-white/45",children:[B.jsxs("span",{"data-loc":"client/src/pages/Home.tsx:125",children:["Quest 3 XR",B.jsx("br",{"data-loc":"client/src/pages/Home.tsx:125"}),B.jsx("strong",{"data-loc":"client/src/pages/Home.tsx:125",className:"text-white/80",children:"Passthrough ready"})]}),B.jsxs("span",{"data-loc":"client/src/pages/Home.tsx:125",children:["Deutsch Voice",B.jsx("br",{"data-loc":"client/src/pages/Home.tsx:125"}),B.jsx("strong",{"data-loc":"client/src/pages/Home.tsx:125",className:"text-white/80",children:"Push-to-talk"})]}),B.jsxs("span",{"data-loc":"client/src/pages/Home.tsx:125",children:["Privat by design",B.jsx("br",{"data-loc":"client/src/pages/Home.tsx:125"}),B.jsx("strong",{"data-loc":"client/src/pages/Home.tsx:125",className:"text-white/80",children:"Key serverseitig"})]})]})]}),B.jsxs("div",{"data-loc":"client/src/pages/Home.tsx:125",className:"relative mx-auto flex h-96 w-full max-w-md items-center justify-center rounded-[3rem] border border-white/10 bg-white/5 shadow-2xl backdrop-blur-sm",children:[B.jsx("div",{"data-loc":"client/src/pages/Home.tsx:125",className:"absolute inset-8 rounded-[2.5rem] border border-cyan-300/20"}),B.jsx(N4,{"data-loc":"client/src/pages/Home.tsx:125",speaking:!0}),B.jsx("div",{"data-loc":"client/src/pages/Home.tsx:125",className:"absolute bottom-5 left-1/2 -translate-x-1/2 rounded-full border border-white/10 bg-black/25 px-4 py-2 text-xs text-white/60 backdrop-blur",children:"Dein Companion wartet"})]})]})]}):B.jsx(B4,{"data-loc":"client/src/pages/Home.tsx:122",onAccept:i})}const ty=()=>{const n="https://manus.im",e="B3pJoWQcZfW7Q8AqYxWuah",t=`${window.location.origin}/api/oauth/callback`,i=crypto.randomUUID();document.cookie=`${xw}=${i}; Path=/; Max-Age=600; SameSite=None; Secure`;const s=Sw({redirectUri:t,nonce:i}),r=new URL(`${n}/app-auth`);r.searchParams.set("appId",e),r.searchParams.set("redirectUri",t),r.searchParams.set("state",s),r.searchParams.set("type","signIn"),window.location.href=r.toString()};function V4(n){const{redirectOnUnauthenticated:e=!1,redirectPath:t}={},i=ns.useUtils(),s=ns.auth.me.useQuery(void 0,{retry:!1,refetchOnWindowFocus:!1}),r=ns.auth.logout.useMutation({onSuccess:()=>{i.auth.me.setData(void 0,null)}}),a=Y.useCallback(async()=>{try{await r.mutateAsync()}catch(c){if(c instanceof Jl&&c.data?.code==="UNAUTHORIZED")return;throw c}finally{try{sessionStorage.removeItem("manus-cookie")}catch{}
3386i.auth.me.setData(void 0,null),await i.auth.me.invalidate()}},[r,i]),o=Y.useMemo(()=>(localStorage.setItem("manus-runtime-user-info",JSON.stringify(s.data)),{user:s.data??null,loading:s.isLoading||r.isPending,error:s.error??r.error??null,isAuthenticated:!!s.data}),[s.data,s.error,s.isLoading,r.error,r.isPending]);return Y.useEffect(()=>{e&&(s.isLoading||r.isPending||o.user||typeof window>"u"||t&&window.location.pathname===t||(t?window.location.href=t:ty()))},[e,t,r.isPending,s.isLoading,o.user]),{...o,refresh:()=>s.refetch(),logout:a}}function Kg({children:n}){const{isAuthenticated:e,loading:t}=V4();return typeof window<"u"&&window.location.search.includes("demo")||e?B.jsx(B.Fragment,{children:n}):t?B.jsx("div",{"data-loc":"client/src/components/AuthGuard.tsx:11",className:"grid min-h-screen place-items-center bg-[#071d24] text-cyan-100",children:B.jsx(pb,{"data-loc":"client/src/components/AuthGuard.tsx:11",className:"h-7 w-7 animate-spin"})}):B.jsx("div",{"data-loc":"client/src/components/AuthGuard.tsx:12",className:"grid min-h-screen place-items-center bg-[#071d24] px-6 text-white",children:B.jsxs("div",{"data-loc":"client/src/components/AuthGuard.tsx:12",className:"max-w-md rounded-3xl border border-white/10 bg-white/5 p-8 text-center",children:[B.jsx(Yh,{"data-loc":"client/src/components/AuthGuard.tsx:12",className:"mx-auto h-9 w-9 text-cyan-200"}),B.jsx("h1",{"data-loc":"client/src/components/AuthGuard.tsx:12",className:"mt-5 text-2xl font-bold",children:"Private Session"}),B.jsx("p",{"data-loc":"client/src/components/AuthGuard.tsx:12",className:"mt-3 text-sm leading-relaxed text-white/60",children:"Melde dich an, bevor du persönliche Companion-Einstellungen oder einen Chat-Verlauf öffnest."}),B.jsx(ai,{"data-loc":"client/src/components/AuthGuard.tsx:12",onClick:ty,className:"mt-6 w-full bg-orange-400 font-bold text-[#132126] hover:bg-orange-300",children:"Sicher anmelden"})]})})}const z4=[{number:"1",title:"Mikrofon freigeben",text:"Für Push-to-talk wird der Zugriff erst nach deiner Bestätigung angefragt.",Icon:yM},{number:"2",title:"Aura platzieren",text:"In Quest 3 positionierst, drehst und skalierst du sie mit deinen Controllern.",Icon:XB},{number:"3",title:"Kindroid verbinden",text:"API-Key und AI-ID werden ausschlieÃlich serverseitig und pro Konto abgelegt.",Icon:ZB}];function G4(){const n=ns.profile.confirmAdult.useMutation(),e=ns.profile.completeOnboarding.useMutation();return Y.useEffect(()=>{n.mutate(),e.mutate()},[]),B.jsx("div",{"data-loc":"client/src/pages/Onboarding.tsx:17",className:"min-h-screen bg-[#071d24] px-6 py-10 text-white",children:B.jsxs("main",{"data-loc":"client/src/pages/Onboarding.tsx:17",className:"mx-auto max-w-3xl",children:[B.jsx("p",{"data-loc":"client/src/pages/Onboarding.tsx:17",className:"text-xs font-semibold uppercase tracking-[.3em] text-cyan-200/70",children:"Aura · Erststart"}),B.jsx("h1",{"data-loc":"client/src/pages/Onboarding.tsx:17",className:"mt-3 text-4xl font-black",children:"Dein privater Companion Space"}),B.jsx("p",{"data-loc":"client/src/pages/Onboarding.tsx:17",className:"mt-4 max-w-xl text-white/60",children:"Nimm dir einen Moment für die Einrichtung. Du entscheidest, wann Mikrofon, Mixed Reality und dein persönlicher Kindroid verbunden werden."}),B.jsx("div",{"data-loc":"client/src/pages/Onboarding.tsx:17",className:"mt-10 space-y-4",children:z4.map(({number:t,title:i,text:s,Icon:r})=>B.jsxs("article",{"data-loc":"client/src/pages/Onboarding.tsx:17",className:"flex gap-5 rounded-3xl border border-white/10 bg-white/5 p-5",children:[B.jsx("span",{"data-loc":"client/src/pages/Onboarding.tsx:17",className:"grid h-10 w-10 shrink-0 place-items-center rounded-xl bg-orange-400 font-bold text-[#132126]",children:t}),B.jsxs("div",{"data-loc":"client/src/pages/Onboarding.tsx:17",children:[B.jsx(r,{"data-loc":"client/src/pages/Onboarding.tsx:17",className:"mb-2 h-5 w-5 text-cyan-200"}),B.jsx("h2",{"data-loc":"client/src/pages/Onboarding.tsx:17",className:"font-bold",children:i}),B.jsx("p",{"data-loc":"client/src/pages/Onboarding.tsx:17",className:"mt-1 text-sm text-white/60",children:s})]}),B.jsx(mM,{"data-loc":"client/src/pages/Onboarding.tsx:17",className:"ml-auto h-5 w-5 text-white/20"})]},t))}),B.jsxs("div",{"data-loc":"client/src/pages/Onboarding.tsx:17",className:"mt-8 flex flex-wrap gap-3",children:[B.jsx(Qa,{"data-loc":"client/src/pages/Onboarding.tsx:17",href:"/settings",children:B.jsxs(ai,{"data-loc":"client/src/pages/Onboarding.tsx:17",className:"bg-orange-400 font-bold text-[#132126] hover:bg-orange-300",children:[B.jsx(zB,{"data-loc":"client/src/pages/Onboarding.tsx:17",className:"mr-2 h-4 w-4"})," Verbindung einrichten"]})}),B.jsx(Qa,{"data-loc":"client/src/pages/Onboarding.tsx:17",href:"/experience",children:B.jsx(ai,{"data-loc":"client/src/pages/Onboarding.tsx:17",variant:"outline",className:"border-white/15 bg-white/5 text-white",children:"Später fortsetzen"})})]})]})})}function H4(){const[n,e]=Y.useState(""),[t,i]=Y.useState(""),[s,r]=Y.useState("Aura"),a=ns.useUtils(),o=ns.kindroid.status.useQuery(),c=ns.kindroid.connect.useMutation({onSuccess:()=>{i(""),a.kindroid.status.invalidate()}}),u=()=>c.mutate({aiId:n,apiKey:t,aiName:s}),d=c.error?.message;return B.jsx("div",{"data-loc":"client/src/pages/Settings.tsx:17",className:"min-h-screen bg-[#071d24] px-6 py-8 text-white",children:B.jsxs("main",{"data-loc":"client/src/pages/Settings.tsx:17",className:"mx-auto max-w-2xl",children:[B.jsx(Qa,{"data-loc":"client/src/pages/Settings.tsx:17",href:"/experience",className:"text-sm text-cyan-200",children:"â Zur Experience"}),B.jsx("p",{"data-loc":"client/src/pages/Settings.tsx:17",className:"mt-10 text-xs font-semibold uppercase tracking-[.25em] text-cyan-200/60",children:"Private Verbindung"}),B.jsx("h1",{"data-loc":"client/src/pages/Settings.tsx:17",className:"mt-2 text-4xl font-black",children:"Kindroid verbinden"}),B.jsxs("section",{"data-loc":"client/src/pages/Settings.tsx:17",className:"mt-8 rounded-3xl border border-white/10 bg-white/5 p-6",children:[B.jsxs("div",{"data-loc":"client/src/pages/Settings.tsx:17",className:"flex gap-3",children:[B.jsx(Yh,{"data-loc":"client/src/pages/Settings.tsx:17",className:"mt-1 shrink-0 text-cyan-200"}),B.jsxs("p",{"data-loc":"client/src/pages/Settings.tsx:17",className:"text-sm leading-relaxed text-white/65",children:["Der ",B.jsx("strong",{"data-loc":"client/src/pages/Settings.tsx:17",className:"text-white",children:"kn_-API-Key"})," wird beim Absenden direkt verschlüsselt an den Server übertragen. Danach wird er weder angezeigt noch an den Browser zurückgegeben."]})]}),B.jsxs("div",{"data-loc":"client/src/pages/Settings.tsx:17",className:"mt-6 space-y-4",children:[B.jsxs("label",{"data-loc":"client/src/pages/Settings.tsx:17",className:"block text-sm text-white/65",children:["AI-ID",B.jsx(Yl,{"data-loc":"client/src/pages/Settings.tsx:17",value:n,onChange:f=>e(f.target.value),className:"mt-2 border-white/10 bg-black/20 text-white",placeholder:"Deine Kindroid AI-ID",autoComplete:"off"})]}),B.jsxs("label",{"data-loc":"client/src/pages/Settings.tsx:17",className:"block text-sm text-white/65",children:["Anzeigename",B.jsx(Yl,{"data-loc":"client/src/pages/Settings.tsx:17",value:s,onChange:f=>r(f.target.value),className:"mt-2 border-white/10 bg-black/20 text-white",placeholder:"Aura"})]}),B.jsxs("label",{"data-loc":"client/src/pages/Settings.tsx:17",className:"block text-sm text-white/65",children:["kn_-API-Key",B.jsx(Yl,{"data-loc":"client/src/pages/Settings.tsx:17",value:t,onChange:f=>i(f.target.value),type:"password",className:"mt-2 border-white/10 bg-black/20 text-white",placeholder:"kn_â¦",autoComplete:"new-password"})]}),B.jsx(ai,{"data-loc":"client/src/pages/Settings.tsx:17",disabled:c.isPending||!n||!t,onClick:u,className:"h-12 w-full bg-orange-400 font-bold text-[#132126] hover:bg-orange-300 disabled:opacity-50",children:c.isPending?B.jsxs(B.Fragment,{children:[B.jsx(pb,{"data-loc":"client/src/pages/Settings.tsx:17",className:"mr-2 h-4 w-4 animate-spin"})," Verbindung wird geprüft"]}):B.jsxs(B.Fragment,{children:[B.jsx(WB,{"data-loc":"client/src/pages/Settings.tsx:17",className:"mr-2 h-4 w-4"})," Verbindung sicher testen und speichern"]})})]})]}),o.data?.connected&&B.jsxs("div",{"data-loc":"client/src/pages/Settings.tsx:17",className:"mt-5 flex gap-3 rounded-2xl border border-emerald-300/20 bg-emerald-300/10 p-4 text-sm text-emerald-100",children:[B.jsx(kB,{"data-loc":"client/src/pages/Settings.tsx:17",className:"h-5 w-5 shrink-0"}),B.jsxs("span",{"data-loc":"client/src/pages/Settings.tsx:17",children:["Verbunden mit ",B.jsx("strong",{"data-loc":"client/src/pages/Settings.tsx:17",children:o.data.aiName}),". Der Schlüssel bleibt verschlüsselt auf dem Server."]})]}),d&&B.jsxs("div",{"data-loc":"client/src/pages/Settings.tsx:17",className:"mt-5 flex gap-3 rounded-2xl border border-orange-300/30 bg-
3386orange-300/10 p-4 text-sm text-orange-100",children:[B.jsx(xM,{"data-loc":"client/src/pages/Settings.tsx:17",className:"h-5 w-5 shrink-0"}),B.jsx("span",{"data-loc":"client/src/pages/Settings.tsx:17",children:d})]}),B.jsxs("div",{"data-loc":"client/src/pages/Settings.tsx:17",className:"mt-6 rounded-2xl border border-white/10 bg-black/15 p-4 text-sm text-white/50",children:[B.jsx(HB,{"data-loc":"client/src/pages/Settings.tsx:17",className:"mr-2 inline h-4 w-4 text-cyan-200"})," Teile den Schlüssel nie mit anderen Personen oder in Nachrichten. Er gewährt direkten Zugriff auf dein Kindroid-Konto."]})]})})}function W4(){return B.jsxs(S2,{"data-loc":"client/src/App.tsx:14",children:[B.jsx(Vl,{"data-loc":"client/src/App.tsx:15",path:"/",component:mA}),B.jsx(Vl,{"data-loc":"client/src/App.tsx:16",path:"/onboarding",children:B.jsx(Kg,{"data-loc":"client/src/App.tsx:16",children:B.jsx(G4,{"data-loc":"client/src/App.tsx:16"})})}),B.jsx(Vl,{"data-loc":"client/src/App.tsx:17",path:"/experience",children:B.jsx(Kg,{"data-loc":"client/src/App.tsx:17",children:B.jsx(mA,{"data-loc":"client/src/App.tsx:17"})})}),B.jsx(Vl,{"data-loc":"client/src/App.tsx:18",path:"/settings",children:B.jsx(Kg,{"data-loc":"client/src/App.tsx:18",children:B.jsx(H4,{"data-loc":"client/src/App.tsx:18"})})}),B.jsx(Vl,{"data-loc":"client/src/App.tsx:19",path:"/404",component:JS}),B.jsx(Vl,{"data-loc":"client/src/App.tsx:20",component:JS})]})}function X4(){return B.jsx(T2,{"data-loc":"client/src/App.tsx:27",children:B.jsx(A2,{"data-loc":"client/src/App.tsx:28",defaultTheme:"dark",children:B.jsxs(DB,{"data-loc":"client/src/App.tsx:29",children:[B.jsx(VF,{"data-loc":"client/src/App.tsx:30"}),B.jsx(W4,{"data-loc":"client/src/App.tsx:31"})]})})})}const _f=new UD,JI=n=>{!(n instanceof Jl)||typeof window>"u"||!(n.message===vw)||ty()};_f.getQueryCache().subscribe(n=>{if(n.type==="updated"&&n.action.type==="error"){const e=n.query.state.error;JI(e),console.error("[API Query Error]",e)}});_f.getMutationCache().subscribe(n=>{if(n.type==="updated"&&n.action.type==="error"){const e=n.mutation.state.error;JI(e),console.error("[API Mutation Error]",e)}});const j4=ns.createClient({links:[jO({url:"/api/trpc",transformer:ha,headers(){try{const n=sessionStorage.getItem("manus-cookie");if(n){const e=`${yw}=`,i=n.split(";").find(s=>s.trim().startsWith(e))?.trim().slice(e.length);if(i)return{Authorization:`Bearer ${i}`}}}catch{}return{}},fetch(n,e){return globalThis.fetch(n,{...e??{},credentials:"include"})}})]});Cw.createRoot(document.getElementById("root")).render(B.jsx(ns.Provider,{"data-loc":"client/src/main.tsx:76",client:j4,queryClient:_f,children:B.jsx(VD,{"data-loc":"client/src/main.tsx:77",client:_f,children:B.jsx(X4,{"data-loc":"client/src/main.tsx:78"})})}));export{Ce as A,jt as B,Qt as C,vC as E,Cs as I,Jd as L,di as P,Tb as R,de as S,pe as T,T as V,VU as _,sf as a,Rb as b,oe as c,Te as d,J4 as e,_t as f,Ke as g,eG as h,gs as i,N as j,tf as k,Ne as l,YU as m,la as n,Pe as o,Tt as p,$e as q,H as s,Q4 as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.